summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Pablo Ugarte <juanpablougarte@gmail.com>2020-08-17 17:18:10 -0300
committerJuan Pablo Ugarte <juanpablougarte@gmail.com>2020-08-17 19:19:48 -0300
commita987d81b4e9a7c9a3d1f616444500d36c6dda274 (patch)
tree236677a806e35715b3e020ff1fcc7c4f9559b8e4
parent4858565c9528320baae892ab40dc32c45b216201 (diff)
downloadglade-a987d81b4e9a7c9a3d1f616444500d36c6dda274.tar.gz
Utils: Add glade_util_list_objects_ref()
Use new function to fix -Wcast-function-type warnings
-rw-r--r--gladeui/glade-command.c9
-rw-r--r--gladeui/glade-utils.c14
-rw-r--r--gladeui/glade-utils.h1
-rw-r--r--plugins/gtk+/glade-gtk-grid.c5
-rw-r--r--plugins/gtk+/glade-gtk-notebook.c2
-rw-r--r--plugins/gtk+/glade-gtk-table.c5
6 files changed, 23 insertions, 13 deletions
diff --git a/gladeui/glade-command.c b/gladeui/glade-command.c
index 5c87a710..eaec608b 100644
--- a/gladeui/glade-command.c
+++ b/gladeui/glade-command.c
@@ -1240,7 +1240,7 @@ glade_command_add (GList *widgets,
/* Parentless ref */
if ((cdata->reffed =
get_all_parentless_reffed_widgets (cdata->reffed, widget)) != NULL)
- g_list_foreach (cdata->reffed, (GFunc) g_object_ref, NULL);
+ glade_util_list_objects_ref (cdata->reffed);
/* Parent */
if (parent == NULL)
@@ -1410,7 +1410,7 @@ glade_command_remove (GList *widgets)
if ((cdata->reffed =
get_all_parentless_reffed_widgets (cdata->reffed, widget)) != NULL)
- g_list_foreach (cdata->reffed, (GFunc) g_object_ref, NULL);
+ glade_util_list_objects_ref (cdata->reffed);
/* If we're removing the template widget, then we need to unset it as template */
if (glade_project_get_template (priv->project) == widget)
@@ -1541,10 +1541,7 @@ glade_command_add_execute (GladeCommandAddRemove *me)
glade_command_transfer_props (cdata->widget, saved_props);
if (saved_props)
- {
- g_list_foreach (saved_props, (GFunc) g_object_unref, NULL);
- g_list_free (saved_props);
- }
+ g_list_free_full (saved_props, g_object_unref);
/* Now that we've added, apply any packing props if nescisary. */
for (l = cdata->pack_props; l; l = l->next)
diff --git a/gladeui/glade-utils.c b/gladeui/glade-utils.c
index c11e2821..e7d91636 100644
--- a/gladeui/glade-utils.c
+++ b/gladeui/glade-utils.c
@@ -774,6 +774,20 @@ glade_util_find_iter_by_widget (GtkTreeModel *model,
}
/**
+ * glade_util_list_objects_ref: (skip)
+ * @list: (transfer full): A #GList
+ *
+ * Add a reference to each GObject in the list.
+ */
+void
+glade_util_list_objects_ref (GList *list)
+{
+ GList *l;
+ for (l = list; l; l = g_list_next (l))
+ g_object_ref (l->data);
+}
+
+/**
* glade_util_purify_list: (skip)
* @list: (transfer full): A #GList
*
diff --git a/gladeui/glade-utils.h b/gladeui/glade-utils.h
index 9e4d0e1a..903c45db 100644
--- a/gladeui/glade-utils.h
+++ b/gladeui/glade-utils.h
@@ -103,6 +103,7 @@ void glade_utils_cairo_draw_rectangle (cairo_t *cr,
gint height);
/* Lists */
+void glade_util_list_objects_ref (GList *list);
GList *glade_util_purify_list (GList *list);
GList *glade_util_added_in_list (GList *old_list,
GList *new_list);
diff --git a/plugins/gtk+/glade-gtk-grid.c b/plugins/gtk+/glade-gtk-grid.c
index f1760fa0..a851b2e7 100644
--- a/plugins/gtk+/glade-gtk-grid.c
+++ b/plugins/gtk+/glade-gtk-grid.c
@@ -530,7 +530,7 @@ glade_gtk_grid_child_insert_remove_action (GladeWidgetAdaptor *adaptor,
children = glade_widget_adaptor_get_children (adaptor, container);
/* Make sure widgets does not get destroyed */
- g_list_foreach (children, (GFunc) g_object_ref, NULL);
+ glade_util_object_list_ref (children);
glade_widget_property_get (parent, n_row_col, &size);
@@ -612,8 +612,7 @@ glade_gtk_grid_child_insert_remove_action (GladeWidgetAdaptor *adaptor,
size - 1);
}
- g_list_foreach (children, (GFunc) g_object_unref, NULL);
- g_list_free (children);
+ g_list_free_full (children, g_object_unref);
glade_command_pop_group ();
}
diff --git a/plugins/gtk+/glade-gtk-notebook.c b/plugins/gtk+/glade-gtk-notebook.c
index cd5de473..8847e5da 100644
--- a/plugins/gtk+/glade-gtk-notebook.c
+++ b/plugins/gtk+/glade-gtk-notebook.c
@@ -1005,7 +1005,7 @@ glade_gtk_box_notebook_child_insert_remove_action (GladeWidgetAdaptor *adaptor,
/* Make sure widgets does not get destroyed */
children = glade_widget_adaptor_get_children (adaptor, container);
- g_list_foreach (children, (GFunc) g_object_ref, NULL);
+ glade_util_object_list_ref (children);
glade_widget_property_get (parent, size_prop, &size);
diff --git a/plugins/gtk+/glade-gtk-table.c b/plugins/gtk+/glade-gtk-table.c
index dbaa0a28..2c67f338 100644
--- a/plugins/gtk+/glade-gtk-table.c
+++ b/plugins/gtk+/glade-gtk-table.c
@@ -563,7 +563,7 @@ glade_gtk_table_child_insert_remove_action (GladeWidgetAdaptor *adaptor,
children = glade_widget_adaptor_get_children (adaptor, container);
/* Make sure widgets does not get destroyed */
- g_list_foreach (children, (GFunc) g_object_ref, NULL);
+ glade_util_object_list_ref (children);
glade_widget_property_get (parent, n_row_col, &size);
@@ -660,8 +660,7 @@ glade_gtk_table_child_insert_remove_action (GladeWidgetAdaptor *adaptor,
size - 1);
}
- g_list_foreach (children, (GFunc) g_object_unref, NULL);
- g_list_free (children);
+ g_list_free_full (children, g_object_unref);
glade_command_pop_group ();
}