summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2022-06-11 07:08:23 +0200
committerBenjamin Otte <otte@redhat.com>2022-06-11 08:25:22 +0200
commitf48c9b83889c2dbfeff5405206d4941103f4921f (patch)
tree7704e27f85fb9759787363b566ab3c6f49ed7fbd
parent62096ebd16887f300640c954a10d23db017d1463 (diff)
downloadgtk+-f48c9b83889c2dbfeff5405206d4941103f4921f.tar.gz
directorylist: Add ::item-type and ::n-items
-rw-r--r--gtk/gtkdirectorylist.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/gtk/gtkdirectorylist.c b/gtk/gtkdirectorylist.c
index c725de1853..1c381b051b 100644
--- a/gtk/gtkdirectorylist.c
+++ b/gtk/gtkdirectorylist.c
@@ -60,8 +60,11 @@ enum {
PROP_ERROR,
PROP_FILE,
PROP_IO_PRIORITY,
+ PROP_ITEM_TYPE,
PROP_LOADING,
PROP_MONITORED,
+ PROP_N_ITEMS,
+
NUM_PROPERTIES
};
@@ -204,6 +207,10 @@ gtk_directory_list_get_property (GObject *object,
g_value_set_int (value, self->io_priority);
break;
+ case PROP_ITEM_TYPE:
+ g_value_set_gtype (value, G_TYPE_FILE_INFO);
+ break;
+
case PROP_LOADING:
g_value_set_boolean (value, gtk_directory_list_is_loading (self));
break;
@@ -212,6 +219,10 @@ gtk_directory_list_get_property (GObject *object,
g_value_set_boolean (value, gtk_directory_list_get_monitored (self));
break;
+ case PROP_N_ITEMS:
+ g_value_set_uint (value, g_sequence_get_length (self->items));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -313,6 +324,18 @@ gtk_directory_list_class_init (GtkDirectoryListClass *class)
GTK_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
/**
+ * GtkDirectoryList:item-type:
+ *
+ * The type of items. See [method@Gio.ListModel.get_item_type].
+ *
+ * Since: 4.8
+ **/
+ properties[PROP_ITEM_TYPE] =
+ g_param_spec_gtype ("item-type", NULL, NULL,
+ G_TYPE_FILE_INFO,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+ /**
* GtkDirectoryList:loading: (attributes org.gtk.Property.get=gtk_directory_list_is_loading)
*
* %TRUE if files are being loaded.
@@ -332,6 +355,18 @@ gtk_directory_list_class_init (GtkDirectoryListClass *class)
TRUE,
GTK_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
+ /**
+ * GtkDirectoryList:n-items:
+ *
+ * The number of items. See [method@Gio.ListModel.get_n_items].
+ *
+ * Since: 4.8
+ **/
+ properties[PROP_N_ITEMS] =
+ g_param_spec_uint ("n-items", NULL, NULL,
+ 0, G_MAXUINT, 0,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
g_object_class_install_properties (gobject_class, NUM_PROPERTIES, properties);
}
@@ -380,6 +415,7 @@ gtk_directory_list_clear_items (GtkDirectoryList *self)
g_sequence_get_end_iter (self->items));
g_list_model_items_changed (G_LIST_MODEL (self), 0, n_items, 0);
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_N_ITEMS]);
}
if (self->error)
@@ -462,7 +498,10 @@ gtk_directory_list_got_files_cb (GObject *source,
self);
if (n > 0)
- g_list_model_items_changed (G_LIST_MODEL (self), g_sequence_get_length (self->items) - n, 0, n);
+ {
+ g_list_model_items_changed (G_LIST_MODEL (self), g_sequence_get_length (self->items) - n, 0, n);
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_N_ITEMS]);
+ }
}
static void
@@ -580,6 +619,7 @@ handle_event (QueuedEvent *event)
position = g_sequence_get_length (self->items);
g_sequence_append (self->items, g_object_ref (info));
g_list_model_items_changed (G_LIST_MODEL (self), position, 0, 1);
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_N_ITEMS]);
}
break;
@@ -591,6 +631,7 @@ handle_event (QueuedEvent *event)
position = g_sequence_iter_get_position (iter);
g_sequence_remove (iter);
g_list_model_items_changed (G_LIST_MODEL (self), position, 1, 0);
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_N_ITEMS]);
}
break;