[glade] GladeGtk*: always use connect_object() for parse-finished signal



commit 29f75feef750b3fc865317a615ce9244c5b9d582
Author: Juan Pablo Ugarte <juanpablougarte gmail com>
Date:   Fri Oct 2 16:19:25 2020 -0300

    GladeGtk*: always use connect_object() for parse-finished signal
    
    This ensures the signal will get disconnected if object is finalized.

 plugins/gtk+/glade-gtk-action-bar.c      | 25 ++++++++++++-------------
 plugins/gtk+/glade-gtk-assistant.c       |  9 +++++----
 plugins/gtk+/glade-gtk-cell-renderer.c   | 11 ++++++-----
 plugins/gtk+/glade-gtk-grid.c            | 10 ++++++----
 plugins/gtk+/glade-gtk-header-bar.c      | 13 ++++++-------
 plugins/gtk+/glade-gtk-image-menu-item.c | 12 ++++++------
 plugins/gtk+/glade-gtk-list-box.c        | 16 +++++++++-------
 plugins/gtk+/glade-gtk-notebook.c        |  9 +++++----
 plugins/gtk+/glade-gtk-popover-menu.c    |  9 +++++----
 plugins/gtk+/glade-gtk-tool-button.c     | 11 ++++++-----
 plugins/gtk+/glade-gtk-tool-item-group.c | 12 +++++++-----
 plugins/gtk+/glade-gtk-window.c          |  7 ++++---
 12 files changed, 77 insertions(+), 67 deletions(-)
---
diff --git a/plugins/gtk+/glade-gtk-action-bar.c b/plugins/gtk+/glade-gtk-action-bar.c
index 1cb327d0..2a90d220 100644
--- a/plugins/gtk+/glade-gtk-action-bar.c
+++ b/plugins/gtk+/glade-gtk-action-bar.c
@@ -44,27 +44,26 @@ glade_gtk_action_bar_create_editable (GladeWidgetAdaptor * adaptor,
 }
 
 static void
-glade_gtk_action_bar_parse_finished (GladeProject * project,
-                                     GObject * object)
+glade_gtk_action_bar_parse_finished (GladeProject *project, GObject *object)
 {
-  GladeWidget *gbox;
-
-  gbox = glade_widget_get_from_gobject (object);
-  glade_widget_property_set (gbox, "use-center-child", gtk_action_bar_get_center_widget (GTK_ACTION_BAR 
(object)) != NULL);
+  GladeWidget *gbox = glade_widget_get_from_gobject (object);
+  glade_widget_property_set (gbox, "use-center-child",
+                             gtk_action_bar_get_center_widget (GTK_ACTION_BAR (object)) != NULL);
 }
 
 void
-glade_gtk_action_bar_post_create (GladeWidgetAdaptor * adaptor,
-                                  GObject * container,
-                                  GladeCreateReason reason)
+glade_gtk_action_bar_post_create (GladeWidgetAdaptor *adaptor,
+                                  GObject            *container,
+                                  GladeCreateReason   reason)
 {
   GladeWidget *gwidget = glade_widget_get_from_gobject (container);
   GladeProject *project = glade_widget_get_project (gwidget);
 
-  if (reason == GLADE_CREATE_LOAD)
-    g_signal_connect (project, "parse-finished",
-                      G_CALLBACK (glade_gtk_action_bar_parse_finished),
-                      container);
+  if (glade_project_is_loading (project))
+    g_signal_connect_object (project, "parse-finished",
+                             G_CALLBACK (glade_gtk_action_bar_parse_finished),
+                             container,
+                             0);
 }
 
 static gint
diff --git a/plugins/gtk+/glade-gtk-assistant.c b/plugins/gtk+/glade-gtk-assistant.c
index 8f13593a..5e646a10 100644
--- a/plugins/gtk+/glade-gtk-assistant.c
+++ b/plugins/gtk+/glade-gtk-assistant.c
@@ -201,11 +201,12 @@ glade_gtk_assistant_post_create (GladeWidgetAdaptor *adaptor,
   /* Chain Up first */
   GLADE_WIDGET_ADAPTOR_GET_ADAPTOR_CLASS (GTK_TYPE_WINDOW)->post_create (adaptor, object, reason);
 
-  if (reason == GLADE_CREATE_LOAD)
+  if (glade_project_is_loading (project))
     {
-      g_signal_connect (project, "parse-finished",
-                        G_CALLBACK (glade_gtk_assistant_parse_finished),
-                        object);
+      g_signal_connect_object (project, "parse-finished",
+                               G_CALLBACK (glade_gtk_assistant_parse_finished),
+                               object,
+                               0);
     }
   else if (reason == GLADE_CREATE_USER)
     {
diff --git a/plugins/gtk+/glade-gtk-cell-renderer.c b/plugins/gtk+/glade-gtk-cell-renderer.c
index a8777372..660df431 100644
--- a/plugins/gtk+/glade-gtk-cell-renderer.c
+++ b/plugins/gtk+/glade-gtk-cell-renderer.c
@@ -269,9 +269,9 @@ glade_gtk_cell_renderer_write_widget (GladeWidgetAdaptor *adaptor,
 }
 
 static void
-glade_gtk_cell_renderer_parse_finished (GladeProject *project,
-                                        GladeWidget  *widget)
+glade_gtk_cell_renderer_parse_finished (GladeProject *project, GObject *object)
 {
+  GladeWidget *widget = glade_widget_get_from_gobject (object);
   GladeProperty *property;
   GList *l;
   static gint attr_len = 0, use_attr_len = 0;
@@ -321,9 +321,10 @@ glade_gtk_cell_renderer_read_widget (GladeWidgetAdaptor *adaptor,
   /* First chain up and read in all the properties... */
   GLADE_WIDGET_ADAPTOR_GET_ADAPTOR_CLASS (G_TYPE_OBJECT)->read_widget (adaptor, widget, node);
 
-  g_signal_connect (glade_widget_get_project (widget), "parse-finished",
-                    G_CALLBACK (glade_gtk_cell_renderer_parse_finished),
-                    widget);
+  g_signal_connect_object (glade_widget_get_project (widget), "parse-finished",
+                           G_CALLBACK (glade_gtk_cell_renderer_parse_finished),
+                           glade_widget_get_object (widget),
+                           0);
 }
 
 static gboolean
diff --git a/plugins/gtk+/glade-gtk-grid.c b/plugins/gtk+/glade-gtk-grid.c
index a940ae6d..9384540b 100644
--- a/plugins/gtk+/glade-gtk-grid.c
+++ b/plugins/gtk+/glade-gtk-grid.c
@@ -199,6 +199,7 @@ glade_gtk_grid_post_create (GladeWidgetAdaptor *adaptor,
                             GladeCreateReason   reason)
 {
   GladeWidget *gwidget = glade_widget_get_from_gobject (container);
+  GladeProject *project = glade_widget_get_project (gwidget);
 
   g_signal_connect (G_OBJECT (gwidget), "configure-child",
                     G_CALLBACK (glade_gtk_grid_configure_child), container);
@@ -209,10 +210,11 @@ glade_gtk_grid_post_create (GladeWidgetAdaptor *adaptor,
   g_signal_connect (G_OBJECT (gwidget), "configure-end",
                     G_CALLBACK (glade_gtk_grid_configure_end), container);
 
-  if (reason == GLADE_CREATE_LOAD)
-    g_signal_connect (glade_widget_get_project (gwidget), "parse-finished",
-                      G_CALLBACK (glade_gtk_grid_parse_finished),
-                      container);
+  if (glade_project_is_loading (project))
+    g_signal_connect_object (project, "parse-finished",
+                             G_CALLBACK (glade_gtk_grid_parse_finished),
+                             container,
+                             0);
 }
 
 void
diff --git a/plugins/gtk+/glade-gtk-header-bar.c b/plugins/gtk+/glade-gtk-header-bar.c
index 0d6f5251..7a9f5082 100644
--- a/plugins/gtk+/glade-gtk-header-bar.c
+++ b/plugins/gtk+/glade-gtk-header-bar.c
@@ -70,9 +70,7 @@ static void
 glade_gtk_header_bar_parse_finished (GladeProject *project,
                                      GObject      *object)
 {
-  GladeWidget *gbox;
-
-  gbox = glade_widget_get_from_gobject (object);
+  GladeWidget *gbox = glade_widget_get_from_gobject (object);
   glade_widget_property_set (gbox, "size", glade_gtk_header_bar_get_num_children (object));
   glade_widget_property_set (gbox, "use-custom-title", gtk_header_bar_get_custom_title (GTK_HEADER_BAR 
(object)) != NULL);
 }
@@ -85,11 +83,12 @@ glade_gtk_header_bar_post_create (GladeWidgetAdaptor *adaptor,
   GladeWidget *parent = glade_widget_get_from_gobject (container);
   GladeProject *project = glade_widget_get_project (parent);
 
-  if (reason == GLADE_CREATE_LOAD)
+  if (glade_project_is_loading (project))
     {
-      g_signal_connect (project, "parse-finished",
-                        G_CALLBACK (glade_gtk_header_bar_parse_finished),
-                        container);
+      g_signal_connect_object (project, "parse-finished",
+                               G_CALLBACK (glade_gtk_header_bar_parse_finished),
+                               container,
+                               0);
     }
   else if (reason == GLADE_CREATE_USER)
     {
diff --git a/plugins/gtk+/glade-gtk-image-menu-item.c b/plugins/gtk+/glade-gtk-image-menu-item.c
index eddcee9a..6830ffde 100644
--- a/plugins/gtk+/glade-gtk-image-menu-item.c
+++ b/plugins/gtk+/glade-gtk-image-menu-item.c
@@ -139,9 +139,9 @@ glade_gtk_image_menu_item_set_property (GladeWidgetAdaptor *adaptor,
 }
 
 static void
-glade_gtk_image_menu_item_parse_finished (GladeProject *project,
-                                          GladeWidget  *widget)
+glade_gtk_image_menu_item_parse_finished (GladeProject *project, GObject *object)
 {
+  GladeWidget *widget = glade_widget_get_from_gobject (object);
   GladeWidget *gimage;
   GtkWidget *image = NULL;
   glade_widget_property_get (widget, "image", &image);
@@ -181,11 +181,11 @@ glade_gtk_image_menu_item_read_widget (GladeWidgetAdaptor *adaptor,
   property = glade_widget_get_property (widget, "use-stock");
   glade_property_sync (property);
 
-
   /* Run this after the load so that image is resolved. */
-  g_signal_connect (G_OBJECT (glade_widget_get_project (widget)), "parse-finished",
-                    G_CALLBACK (glade_gtk_image_menu_item_parse_finished),
-                    widget);
+  g_signal_connect_object (glade_widget_get_project (widget), "parse-finished",
+                           G_CALLBACK (glade_gtk_image_menu_item_parse_finished),
+                           glade_widget_get_object (widget),
+                           0);
 }
 
 
diff --git a/plugins/gtk+/glade-gtk-list-box.c b/plugins/gtk+/glade-gtk-list-box.c
index e918094a..bee989c9 100644
--- a/plugins/gtk+/glade-gtk-list-box.c
+++ b/plugins/gtk+/glade-gtk-list-box.c
@@ -171,25 +171,27 @@ glade_listbox_get_placeholder (GtkListBox *list_box) {
 }
 
 static void
-glade_gtk_listbox_parse_finished (GladeProject *project, GladeWidget *gbox)
+glade_gtk_listbox_parse_finished (GladeProject *project, GObject *box)
 {
-  GObject *box = glade_widget_get_object (gbox);
-  glade_widget_property_set (gbox, "use-placeholder", glade_listbox_get_placeholder (GTK_LIST_BOX (box)) != 
NULL);
+  GladeWidget *gbox = glade_widget_get_from_gobject (box);
+  glade_widget_property_set (gbox, "use-placeholder",
+                             glade_listbox_get_placeholder (GTK_LIST_BOX (box)) != NULL);
 }
 
 void
 glade_gtk_listbox_post_create (GladeWidgetAdaptor *adaptor,
-                                GObject            *container,
-                                GladeCreateReason   reason)
+                               GObject            *container,
+                               GladeCreateReason   reason)
 {
   GladeWidget *gwidget = glade_widget_get_from_gobject (container);
   GladeProject *project = glade_widget_get_project (gwidget);
 
-  if (reason == GLADE_CREATE_LOAD)
+  if (glade_project_is_loading (project))
     {
       g_signal_connect_object (project, "parse-finished",
                                G_CALLBACK (glade_gtk_listbox_parse_finished),
-                               gwidget, 0);
+                               container,
+                               0);
     }
 }
 
diff --git a/plugins/gtk+/glade-gtk-notebook.c b/plugins/gtk+/glade-gtk-notebook.c
index 47d26997..0492300e 100644
--- a/plugins/gtk+/glade-gtk-notebook.c
+++ b/plugins/gtk+/glade-gtk-notebook.c
@@ -414,10 +414,11 @@ glade_gtk_notebook_post_create (GladeWidgetAdaptor *adaptor,
   g_signal_connect (G_OBJECT (notebook), "switch-page",
                     G_CALLBACK (glade_gtk_notebook_switch_page), NULL);
 
-  if (reason == GLADE_CREATE_LOAD)
-    g_signal_connect (project, "parse-finished",
-                      G_CALLBACK (glade_gtk_notebook_parse_finished),
-                      notebook);
+  if (glade_project_is_loading (project))
+    g_signal_connect_object (project, "parse-finished",
+                             G_CALLBACK (glade_gtk_notebook_parse_finished),
+                             notebook,
+                             0);
 }
 
 static gint
diff --git a/plugins/gtk+/glade-gtk-popover-menu.c b/plugins/gtk+/glade-gtk-popover-menu.c
index b58be8bc..1008c99e 100644
--- a/plugins/gtk+/glade-gtk-popover-menu.c
+++ b/plugins/gtk+/glade-gtk-popover-menu.c
@@ -167,10 +167,11 @@ glade_gtk_popover_menu_post_create (GladeWidgetAdaptor *adaptor,
   GladeWidget *parent = glade_widget_get_from_gobject (container);
   GladeProject *project = glade_widget_get_project (parent);
 
-  if (reason == GLADE_CREATE_LOAD)
-    g_signal_connect (project, "parse-finished",
-                      G_CALLBACK (glade_gtk_popover_menu_parse_finished),
-                      container);
+  if (glade_project_is_loading (project))
+    g_signal_connect_object (project, "parse-finished",
+                             G_CALLBACK (glade_gtk_popover_menu_parse_finished),
+                             container,
+                             0);
 
   g_signal_connect (G_OBJECT (parent), "notify::project",
                     G_CALLBACK (glade_gtk_popover_menu_project_changed), NULL);
diff --git a/plugins/gtk+/glade-gtk-tool-button.c b/plugins/gtk+/glade-gtk-tool-button.c
index 34f68507..8e68d2b5 100644
--- a/plugins/gtk+/glade-gtk-tool-button.c
+++ b/plugins/gtk+/glade-gtk-tool-button.c
@@ -157,9 +157,9 @@ glade_gtk_tool_button_set_property (GladeWidgetAdaptor *adaptor,
 }
 
 static void
-glade_gtk_tool_button_parse_finished (GladeProject *project,
-                                      GladeWidget  *widget)
+glade_gtk_tool_button_parse_finished (GladeProject *project, GObject *object)
 {
+  GladeWidget  *widget = glade_widget_get_from_gobject (object);
   gchar *stock_str = NULL, *icon_name = NULL;
   gint stock_id = 0;
   GtkWidget *label_widget = NULL, *image_widget = NULL;
@@ -207,7 +207,8 @@ glade_gtk_tool_button_read_widget (GladeWidgetAdaptor *adaptor,
   GLADE_WIDGET_ADAPTOR_GET_ADAPTOR_CLASS (GTK_TYPE_TOOL_ITEM)->read_widget (adaptor, widget, node);
 
   /* Run this after the load so that icon-widget is resolved. */
-  g_signal_connect (glade_widget_get_project (widget),
-                    "parse-finished",
-                    G_CALLBACK (glade_gtk_tool_button_parse_finished), widget);
+  g_signal_connect_object (glade_widget_get_project (widget), "parse-finished",
+                           G_CALLBACK (glade_gtk_tool_button_parse_finished),
+                           glade_widget_get_object (widget),
+                           0);
 }
diff --git a/plugins/gtk+/glade-gtk-tool-item-group.c b/plugins/gtk+/glade-gtk-tool-item-group.c
index 46285231..8c48c9d3 100644
--- a/plugins/gtk+/glade-gtk-tool-item-group.c
+++ b/plugins/gtk+/glade-gtk-tool-item-group.c
@@ -71,9 +71,9 @@ glade_gtk_tool_item_group_remove_child (GladeWidgetAdaptor *adaptor,
 }
 
 static void
-glade_gtk_tool_item_group_parse_finished (GladeProject *project,
-                                          GladeWidget  *widget)
+glade_gtk_tool_item_group_parse_finished (GladeProject *project, GObject *object)
 {
+  GladeWidget *widget = glade_widget_get_from_gobject (object);
   GtkWidget *label_widget = NULL;
 
   glade_widget_property_get (widget, "label-widget", &label_widget);
@@ -97,9 +97,11 @@ glade_gtk_tool_item_group_read_widget (GladeWidgetAdaptor *adaptor,
   GLADE_WIDGET_ADAPTOR_GET_ADAPTOR_CLASS (GTK_TYPE_TOOL_ITEM)->read_widget (adaptor, widget, node);
 
   /* Run this after the load so that icon-widget is resolved. */
-  g_signal_connect (glade_widget_get_project (widget),
-                    "parse-finished",
-                    G_CALLBACK (glade_gtk_tool_item_group_parse_finished), widget);
+  g_signal_connect_object (glade_widget_get_project (widget),
+                           "parse-finished",
+                           G_CALLBACK (glade_gtk_tool_item_group_parse_finished),
+                           glade_widget_get_object (widget),
+                           0);
 }
 
 static void
diff --git a/plugins/gtk+/glade-gtk-window.c b/plugins/gtk+/glade-gtk-window.c
index 56049f10..52282413 100644
--- a/plugins/gtk+/glade-gtk-window.c
+++ b/plugins/gtk+/glade-gtk-window.c
@@ -84,9 +84,10 @@ glade_gtk_window_post_create (GladeWidgetAdaptor *adaptor,
 
   if (reason == GLADE_CREATE_LOAD)
     {
-      g_signal_connect (project, "parse-finished",
-                        G_CALLBACK (glade_gtk_window_parse_finished),
-                        object);
+      g_signal_connect_object (project, "parse-finished",
+                               G_CALLBACK (glade_gtk_window_parse_finished),
+                               object,
+                               0);
     }
   else if (reason == GLADE_CREATE_USER &&
            gtk_bin_get_child (GTK_BIN (object)) == NULL)


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