[gtk/wip/otte/listview: 3/10] listitemmanager: Handle NULL factory



commit 58d84244d5706e9fbfef4f39070cf96f5c24f6c3
Author: Benjamin Otte <otte redhat com>
Date:   Sat Oct 19 03:19:56 2019 +0200

    listitemmanager: Handle NULL factory
    
    Just don't call it and create empty listitems.

 gtk/gtklistitemmanager.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gtklistitemmanager.c b/gtk/gtklistitemmanager.c
index 1fe112d9ab..f5808b5b2e 100644
--- a/gtk/gtklistitemmanager.c
+++ b/gtk/gtklistitemmanager.c
@@ -927,11 +927,13 @@ gtk_list_item_manager_acquire_list_item (GtkListItemManager *self,
   g_return_val_if_fail (prev_sibling == NULL || GTK_IS_WIDGET (prev_sibling), NULL);
 
   result = gtk_list_item_new (self->item_css_name);
-  gtk_list_item_factory_setup (self->factory, result);
+  if (self->factory)
+    gtk_list_item_factory_setup (self->factory, result);
 
   item = g_list_model_get_item (G_LIST_MODEL (self->model), position);
   selected = gtk_selection_model_is_selected (self->model, position);
-  gtk_list_item_factory_bind (self->factory, result, position, item, selected);
+  if (self->factory)
+    gtk_list_item_factory_bind (self->factory, result, position, item, selected);
   g_object_unref (item);
   gtk_widget_insert_after (GTK_WIDGET (result), self->widget, prev_sibling);
 
@@ -969,7 +971,8 @@ gtk_list_item_manager_try_reacquire_list_item (GtkListItemManager *self,
   item = g_list_model_get_item (G_LIST_MODEL (self->model), position);
   if (g_hash_table_steal_extended (change, item, NULL, (gpointer *) &result))
     {
-      gtk_list_item_factory_update (self->factory, result, position, FALSE);
+      if (self->factory)
+        gtk_list_item_factory_update (self->factory, result, position, FALSE);
       gtk_widget_insert_after (GTK_WIDGET (result), self->widget, prev_sibling);
       /* XXX: Should we let the listview do this? */
       gtk_widget_queue_resize (GTK_WIDGET (result));
@@ -1007,7 +1010,8 @@ gtk_list_item_manager_move_list_item (GtkListItemManager     *self,
 
   item = g_list_model_get_item (G_LIST_MODEL (self->model), position);
   selected = gtk_selection_model_is_selected (self->model, position);
-  gtk_list_item_factory_rebind (self->factory, GTK_LIST_ITEM (list_item), position, item, selected);
+  if (self->factory)
+    gtk_list_item_factory_rebind (self->factory, GTK_LIST_ITEM (list_item), position, item, selected);
   gtk_widget_insert_after (list_item, _gtk_widget_get_parent (list_item), prev_sibling);
   g_object_unref (item);
 }
@@ -1032,7 +1036,8 @@ gtk_list_item_manager_update_list_item (GtkListItemManager *self,
   g_return_if_fail (GTK_IS_LIST_ITEM (item));
 
   selected = gtk_selection_model_is_selected (self->model, position);
-  gtk_list_item_factory_update (self->factory, GTK_LIST_ITEM (item), position, selected);
+  if (self->factory)
+    gtk_list_item_factory_update (self->factory, GTK_LIST_ITEM (item), position, selected);
 }
 
 /*
@@ -1062,8 +1067,11 @@ gtk_list_item_manager_release_list_item (GtkListItemManager *self,
       g_warning ("FIXME: Handle the same item multiple times in the list.\nLars says this totally should not 
happen, but here we are.");
     }
 
-  gtk_list_item_factory_unbind (self->factory, GTK_LIST_ITEM (item));
-  gtk_list_item_factory_teardown (self->factory, GTK_LIST_ITEM (item));
+  if (self->factory)
+    {
+      gtk_list_item_factory_unbind (self->factory, GTK_LIST_ITEM (item));
+      gtk_list_item_factory_teardown (self->factory, GTK_LIST_ITEM (item));
+    }
   gtk_widget_unparent (item);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]