[gtk/wip/otte/listmodels: 17/18] bookmarklist: Add ::item-type and ::n-items
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/listmodels: 17/18] bookmarklist: Add ::item-type and ::n-items
- Date: Sat, 11 Jun 2022 05:35:52 +0000 (UTC)
commit 746ff204a8d4ce5cc07a00df9de39485edc29d5a
Author: Benjamin Otte <otte redhat com>
Date: Sat Jun 11 07:15:30 2022 +0200
bookmarklist: Add ::item-type and ::n-items
gtk/gtkbookmarklist.c | 49 +++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 43 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkbookmarklist.c b/gtk/gtkbookmarklist.c
index 59be4eca12..cf72a77464 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;
@@ -236,6 +247,18 @@ gtk_bookmark_list_class_init (GtkBookmarkListClass *class)
-G_MAXINT, G_MAXINT, G_PRIORITY_DEFAULT,
GTK_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
+ /**
+ * GtkBookmarkList:item-type:
+ *
+ * The type of items. See [func@Gio.ListModel.get_item_type].
+ *
+ * Since: 4.8
+ **/
+ properties[PROP_ITEM_TYPE] =
+ g_param_spec_gtype ("item-type", NULL, NULL,
+ G_TYPE_OBJECT,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
/**
* GtkBookmarkList:loading: (attributes org.gtk.Property.get=gtk_bookmark_list_is_loading)
*
@@ -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 [func@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]);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]