[gtk/matthiasc/for-master: 1/2] Stop using GtkFunctionsListItemFactory



commit 5c2da80e7595841b54777cd49a0f12e21eb858d1
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Jun 29 16:37:14 2020 -0400

    Stop using GtkFunctionsListItemFactory
    
    This was an early attempt at a factory, and has been
    superseded by GtkSignalsListItemFactory. Port all users
    the the newer one.

 demos/gtk-demo/listview_weather.c | 17 +++++++++--------
 gtk/inspector/recorder.c          | 18 ++++++++++--------
 tests/testlistview-animating.c    | 18 ++++++++++--------
 tests/testlistview.c              | 12 ++++++------
 4 files changed, 35 insertions(+), 30 deletions(-)
---
diff --git a/demos/gtk-demo/listview_weather.c b/demos/gtk-demo/listview_weather.c
index 5904d256a0..535a9d179b 100644
--- a/demos/gtk-demo/listview_weather.c
+++ b/demos/gtk-demo/listview_weather.c
@@ -194,8 +194,8 @@ create_weather_model (void)
 }
 
 static void
-setup_widget (GtkListItem *list_item,
-              gpointer     unused)
+setup_widget (GtkSignalListItemFactory *factory,
+              GtkListItem              *list_item)
 {
   GtkWidget *box, *child;
 
@@ -218,8 +218,8 @@ setup_widget (GtkListItem *list_item,
 }
 
 static void
-bind_widget (GtkListItem *list_item,
-             gpointer     unused)
+bind_widget (GtkSignalListItemFactory *factory,
+             GtkListItem              *list_item)
 {
   GtkWidget *box, *child;
   GtkWeatherInfo *info;
@@ -282,11 +282,12 @@ create_weather_view (void)
 {
   GtkWidget *listview;
   GListModel *model, *selection;
+  GtkListItemFactory *factory;
 
-  listview = gtk_list_view_new_with_factory (
-  gtk_functions_list_item_factory_new (setup_widget,
-                                       bind_widget,
-                                       NULL, NULL));
+  factory = gtk_signal_list_item_factory_new ();
+  g_signal_connect (factory, "setup", G_CALLBACK (setup_widget), NULL);
+  g_signal_connect (factory, "bind", G_CALLBACK (bind_widget), NULL);
+  listview = gtk_list_view_new_with_factory (factory);
   gtk_orientable_set_orientation (GTK_ORIENTABLE (listview), GTK_ORIENTATION_HORIZONTAL);
   gtk_list_view_set_show_separators (GTK_LIST_VIEW (listview), TRUE);
   model = create_weather_model ();
diff --git a/gtk/inspector/recorder.c b/gtk/inspector/recorder.c
index f48016162c..80164af7cc 100644
--- a/gtk/inspector/recorder.c
+++ b/gtk/inspector/recorder.c
@@ -22,9 +22,10 @@
 #include <gtk/gtkbinlayout.h>
 #include <gtk/gtkbox.h>
 #include <gtk/gtkfilechooserdialog.h>
-#include <gtk/gtkfunctionslistitemfactory.h>
+#include <gtk/gtksignallistitemfactory.h>
 #include <gtk/gtklabel.h>
 #include <gtk/gtklistbox.h>
+#include <gtk/gtklistitem.h>
 #include <gtk/gtklistview.h>
 #include <gtk/gtkliststore.h>
 #include <gtk/gtkmessagedialog.h>
@@ -302,8 +303,8 @@ node_name (GskRenderNode *node)
 }
 
 static void
-setup_widget_for_render_node (GtkListItem *list_item,
-                              gpointer     unused)
+setup_widget_for_render_node (GtkSignalListItemFactory *factory,
+                              GtkListItem              *list_item)
 {
   GtkWidget *expander, *box, *child;
 
@@ -324,8 +325,8 @@ setup_widget_for_render_node (GtkListItem *list_item,
 }
 
 static void
-bind_widget_for_render_node (GtkListItem *list_item,
-                             gpointer     unused)
+bind_widget_for_render_node (GtkSignalListItemFactory *factory,
+                             GtkListItem              *list_item)
 {
   GdkPaintable *paintable;
   GskRenderNode *node;
@@ -1291,9 +1292,10 @@ gtk_inspector_recorder_init (GtkInspectorRecorder *recorder)
   priv->render_node_selection = gtk_single_selection_new (G_LIST_MODEL (priv->render_node_model));
   g_signal_connect (priv->render_node_selection, "notify::selected-item", G_CALLBACK 
(render_node_list_selection_changed), recorder);
 
-  factory = gtk_functions_list_item_factory_new (setup_widget_for_render_node,
-                                                 bind_widget_for_render_node,
-                                                 NULL, NULL);
+  factory = gtk_signal_list_item_factory_new ();
+  g_signal_connect (factory, "setup", G_CALLBACK (setup_widget_for_render_node), NULL);
+  g_signal_connect (factory, "bind", G_CALLBACK (bind_widget_for_render_node), NULL);
+
   gtk_list_view_set_factory (GTK_LIST_VIEW (priv->render_node_list), factory);
   g_object_unref (factory);
   gtk_list_view_set_model (GTK_LIST_VIEW (priv->render_node_list),
diff --git a/tests/testlistview-animating.c b/tests/testlistview-animating.c
index a69cb9a6fd..d824118d78 100644
--- a/tests/testlistview-animating.c
+++ b/tests/testlistview-animating.c
@@ -9,8 +9,8 @@
 #endif
 
 static void
-setup_list_item (GtkListItem *list_item,
-                 gpointer     unused)
+setup_list_item (GtkSignalListItemFactory *factory,
+                 GtkListItem              *list_item)
 {
   GtkWidget *label = gtk_label_new ("");
 
@@ -18,8 +18,8 @@ setup_list_item (GtkListItem *list_item,
 }
 
 static void
-bind_list_item (GtkListItem *list_item,
-                gpointer     unused)
+bind_list_item (GtkSignalListItemFactory *factory,
+                GtkListItem              *list_item)
 {
   GtkWidget *label;
   gpointer item;
@@ -118,6 +118,7 @@ main (int   argc,
   GtkSortListModel *sort;
   GtkSorter *sorter;
   guint i;
+  GtkListItemFactory *factory;
 
   gtk_init ();
 
@@ -145,10 +146,11 @@ main (int   argc,
   gtk_widget_set_vexpand (sw, TRUE);
   gtk_box_append (GTK_BOX (vbox), sw);
 
-  listview = gtk_list_view_new_with_factory (
-    gtk_functions_list_item_factory_new (setup_list_item,
-                                         bind_list_item,
-                                         NULL, NULL));
+  factory = gtk_signal_list_item_factory_new ();
+  g_signal_connect (factory, "setup", G_CALLBACK (setup_list_item), NULL);
+  g_signal_connect (factory, "bind", G_CALLBACK (bind_list_item), NULL);
+  listview = gtk_list_view_new_with_factory (factory);
+
   gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), listview);
 
   vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
diff --git a/tests/testlistview.c b/tests/testlistview.c
index 0d33349d58..a230c50ed0 100644
--- a/tests/testlistview.c
+++ b/tests/testlistview.c
@@ -486,8 +486,8 @@ row_data_free (gpointer _data)
 }
 
 static void
-setup_widget (GtkListItem *list_item,
-              gpointer     unused)
+setup_widget (GtkSignalListItemFactory *factory,
+              GtkListItem              *list_item)
 {
   GtkWidget *box, *child;
   RowData *data;
@@ -601,6 +601,7 @@ main (int argc, char *argv[])
   FileInfoSelection *selectionmodel;
   GFile *root;
   GListModel *toplevels;
+  GtkListItemFactory *factory;
 
   gtk_init ();
 
@@ -618,10 +619,9 @@ main (int argc, char *argv[])
   gtk_search_entry_set_key_capture_widget (GTK_SEARCH_ENTRY (search_entry), sw);
   gtk_box_append (GTK_BOX (vbox), sw);
 
-  listview = gtk_grid_view_new_with_factory (
-    gtk_functions_list_item_factory_new (setup_widget,
-                                         NULL,
-                                         NULL, NULL));
+  factory = gtk_signal_list_item_factory_new ();
+  g_signal_connect (factory, "setup", G_CALLBACK (setup_widget), NULL);
+  listview = gtk_grid_view_new_with_factory (factory);
   gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), listview);
 
   if (argc > 1)


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