diff options
author | Benjamin Otte <otte@redhat.com> | 2022-06-11 07:15:30 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2022-06-11 08:25:23 +0200 |
commit | 11aef91fa574b3ab254c9023f2dd9e63046a98f5 (patch) | |
tree | 827647ed0b034eeca655ae991140d2956c8d7bad /gtk | |
parent | f48c9b83889c2dbfeff5405206d4941103f4921f (diff) | |
download | gtk+-11aef91fa574b3ab254c9023f2dd9e63046a98f5.tar.gz |
bookmarklist: Add ::item-type and ::n-items
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkbookmarklist.c | 49 |
1 files changed, 43 insertions, 6 deletions
diff --git a/gtk/gtkbookmarklist.c b/gtk/gtkbookmarklist.c index 59be4eca12..fbddda7a79 100644 --- a/gtk/gtkbookmarklist.c +++ b/gtk/gtkbookmarklist.c @@ -43,7 +43,10 @@ enum { PROP_FILENAME, PROP_ATTRIBUTES, PROP_IO_PRIORITY, + PROP_ITEM_TYPE, PROP_LOADING, + PROP_N_ITEMS, + NUM_PROPERTIES }; @@ -149,10 +152,10 @@ gtk_bookmark_list_set_property (GObject *object, } static void -gtk_bookmark_list_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) +gtk_bookmark_list_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) { GtkBookmarkList *self = GTK_BOOKMARK_LIST (object); @@ -162,18 +165,26 @@ gtk_bookmark_list_get_property (GObject *object, g_value_set_string (value, self->attributes); break; + case PROP_FILENAME: + g_value_set_string (value, self->filename); + break; + case PROP_IO_PRIORITY: g_value_set_int (value, self->io_priority); break; - case PROP_FILENAME: - g_value_set_string (value, self->filename); + case PROP_ITEM_TYPE: + g_value_set_gtype (value, G_TYPE_FILE_INFO); break; case PROP_LOADING: g_value_set_boolean (value, gtk_bookmark_list_is_loading (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; @@ -237,6 +248,18 @@ gtk_bookmark_list_class_init (GtkBookmarkListClass *class) GTK_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY); /** + * GtkBookmarkList: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); + + /** * GtkBookmarkList:loading: (attributes org.gtk.Property.get=gtk_bookmark_list_is_loading) * * %TRUE if files are being loaded. @@ -246,6 +269,18 @@ gtk_bookmark_list_class_init (GtkBookmarkListClass *class) FALSE, GTK_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY); + /** + * GtkBookmarkList: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); } @@ -306,6 +341,7 @@ got_file_info (GObject *source, g_sequence_append (self->items, info); g_list_model_items_changed (G_LIST_MODEL (self), g_sequence_get_length (self->items) - 1, 0, 1); + g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_N_ITEMS]); g_free (uri); } @@ -331,6 +367,7 @@ gtk_bookmark_list_clear_items (GtkBookmarkList *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]); } } |