[balsa/wip/gtk4: 207/351] libalsa-progress: Use gtk_container_foreach()
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/wip/gtk4: 207/351] libalsa-progress: Use gtk_container_foreach()
- Date: Wed, 23 May 2018 21:34:21 +0000 (UTC)
commit 56766adbd9fcd5f7616d7e0b95a9a2f52e6e757d
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Mon Mar 5 19:06:16 2018 -0500
libalsa-progress: Use gtk_container_foreach()
…instead of allocating a GList in gtk_container_get_children and
later freeing it.
libbalsa/libbalsa-progress.c | 32 ++++++++++++++++----------------
1 files changed, 16 insertions(+), 16 deletions(-)
---
diff --git a/libbalsa/libbalsa-progress.c b/libbalsa/libbalsa-progress.c
index caeb6f8..881d6df 100644
--- a/libbalsa/libbalsa-progress.c
+++ b/libbalsa/libbalsa-progress.c
@@ -249,28 +249,28 @@ progress_data_destroy_cb(GtkWidget G_GNUC_UNUSED *widget,
libbalsa_clear_source_id(&progress_data->fadeout_id);
}
+typedef struct {
+ const gchar *id;
+ progress_widget_data_t *data;
+} find_progress_data_info;
+
+static void
+find_progress_data_func(GtkWidget * child,
+ find_progress_data_info * info)
+{
+ if (info->data == NULL && strcmp(gtk_widget_get_name(child), info->id) == 0)
+ info->data = g_object_get_data(G_OBJECT(child), "data");
+}
static progress_widget_data_t *
find_progress_data_by_name(GtkContainer *container,
const gchar *id)
{
- GList *children;
- GList *this_child;
- progress_widget_data_t *data;
-
- children = gtk_container_get_children(container);
- data = NULL;
- this_child = children;
- while ((data == NULL) && (this_child != NULL)) {
- if (strcmp(gtk_widget_get_name(GTK_WIDGET(this_child->data)), id) == 0) {
- data = g_object_get_data(G_OBJECT(this_child->data), "data");
- } else {
- this_child = this_child->next;
- }
- }
- g_list_free(children);
+ find_progress_data_info info = {id, NULL};
+
+ gtk_container_foreach(container, (GtkCallback) find_progress_data_func, &info);
- return data;
+ return info.data;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]