[gtk/listview-for-merge: 58/150] listview: Pass the CSS name of listitems to the manager



commit 443e44853a57713298109f6a70f373fccd39615b
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/gtkgridview.c               | 2 +-
 gtk/gtklistitemmanager.c        | 5 ++++-
 gtk/gtklistitemmanagerprivate.h | 5 +++--
 gtk/gtklistview.c               | 2 +-
 4 files changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkgridview.c b/gtk/gtkgridview.c
index fd3c94f2dd..3f3ecc72da 100644
--- a/gtk/gtkgridview.c
+++ b/gtk/gtkgridview.c
@@ -476,7 +476,7 @@ cell_augment (GtkRbTree *tree,
 static void
 gtk_grid_view_init (GtkGridView *self)
 {
-  self->item_manager = gtk_list_item_manager_new (GTK_WIDGET (self), Cell, CellAugment, cell_augment);
+  self->item_manager = gtk_list_item_manager_new (GTK_WIDGET (self), "flowboxchild", Cell, CellAugment, 
cell_augment);
 
   self->min_columns = 1;
   self->max_columns = DEFAULT_MAX_COLUMNS;
diff --git a/gtk/gtklistitemmanager.c b/gtk/gtklistitemmanager.c
index fde93c9708..05464d9ef7 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,
@@ -926,7 +929,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]