[gtk/wip/otte/listview: 42/92] listview: Pass the CSS name of listitems to the manager
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/listview: 42/92] listview: Pass the CSS name of listitems to the manager
- Date: Wed, 30 Oct 2019 03:35:48 +0000 (UTC)
commit 1f3ea5c3f0c72d2fe3b49f5aef1a51a0baf0f259
Author: Benjamin Otte <otte redhat com>
Date: Sat Oct 12 13:16:54 2019 +0200
listview: Pass the CSS name of listitems to the manager
... instead of hardcoding "row".
gtk/gtklistitemmanager.c | 5 ++++-
gtk/gtklistitemmanagerprivate.h | 5 +++--
gtk/gtklistview.c | 2 +-
3 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtklistitemmanager.c b/gtk/gtklistitemmanager.c
index 53fab4c53a..1fe112d9ab 100644
--- a/gtk/gtklistitemmanager.c
+++ b/gtk/gtklistitemmanager.c
@@ -33,6 +33,7 @@ struct _GtkListItemManager
GtkWidget *widget;
GtkSelectionModel *model;
GtkListItemFactory *factory;
+ const char *item_css_name;
GtkRbTree *items;
GSList *trackers;
@@ -108,6 +109,7 @@ gtk_list_item_manager_clear_node (gpointer _item)
GtkListItemManager *
gtk_list_item_manager_new_for_size (GtkWidget *widget,
+ const char *item_css_name,
gsize element_size,
gsize augment_size,
GtkRbTreeAugmentFunc augment_func)
@@ -122,6 +124,7 @@ gtk_list_item_manager_new_for_size (GtkWidget *widget,
/* not taking a ref because the widget refs us */
self->widget = widget;
+ self->item_css_name = g_intern_string (item_css_name);
self->items = gtk_rb_tree_new_for_size (element_size,
augment_size,
@@ -923,7 +926,7 @@ gtk_list_item_manager_acquire_list_item (GtkListItemManager *self,
g_return_val_if_fail (GTK_IS_LIST_ITEM_MANAGER (self), NULL);
g_return_val_if_fail (prev_sibling == NULL || GTK_IS_WIDGET (prev_sibling), NULL);
- result = gtk_list_item_new ("row");
+ result = gtk_list_item_new (self->item_css_name);
gtk_list_item_factory_setup (self->factory, result);
item = g_list_model_get_item (G_LIST_MODEL (self->model), position);
diff --git a/gtk/gtklistitemmanagerprivate.h b/gtk/gtklistitemmanagerprivate.h
index c83fc7d92f..a41ea84472 100644
--- a/gtk/gtklistitemmanagerprivate.h
+++ b/gtk/gtklistitemmanagerprivate.h
@@ -57,11 +57,12 @@ struct _GtkListItemManagerItemAugment
GType gtk_list_item_manager_get_type (void) G_GNUC_CONST;
GtkListItemManager * gtk_list_item_manager_new_for_size (GtkWidget *widget,
+ const char *item_css_name,
gsize element_size,
gsize augment_size,
GtkRbTreeAugmentFunc augment_func);
-#define gtk_list_item_manager_new(widget, type, augment_type, augment_func) \
- gtk_list_item_manager_new_for_size (widget, sizeof (type), sizeof (augment_type), (augment_func))
+#define gtk_list_item_manager_new(widget, item_css_name, type, augment_type, augment_func) \
+ gtk_list_item_manager_new_for_size (widget, item_css_name, sizeof (type), sizeof (augment_type),
(augment_func))
void gtk_list_item_manager_augment_node (GtkRbTree *tree,
gpointer node_augment,
diff --git a/gtk/gtklistview.c b/gtk/gtklistview.c
index 27bac8e484..87a80513de 100644
--- a/gtk/gtklistview.c
+++ b/gtk/gtklistview.c
@@ -1012,7 +1012,7 @@ gtk_list_view_class_init (GtkListViewClass *klass)
static void
gtk_list_view_init (GtkListView *self)
{
- self->item_manager = gtk_list_item_manager_new (GTK_WIDGET (self), ListRow, ListRowAugment,
list_row_augment);
+ self->item_manager = gtk_list_item_manager_new (GTK_WIDGET (self), "row", ListRow, ListRowAugment,
list_row_augment);
self->anchor = gtk_list_item_tracker_new (self->item_manager);
self->selected = gtk_list_item_tracker_new (self->item_manager);
self->orientation = GTK_ORIENTATION_VERTICAL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]