diff options
Diffstat (limited to 'src/lib/glade.c')
-rw-r--r-- | src/lib/glade.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/lib/glade.c b/src/lib/glade.c index 407e23f0..1d829788 100644 --- a/src/lib/glade.c +++ b/src/lib/glade.c | |||
@@ -99,11 +99,13 @@ GNUNET_GTK_get_tree_string (GtkTreeView * treeview, GtkTreePath * treepath, | |||
99 | * @param filename name of the resource file to load | 99 | * @param filename name of the resource file to load |
100 | * @param user_data user_data to pass to signal handlers, | 100 | * @param user_data user_data to pass to signal handlers, |
101 | * use "NULL" to pass the GtkBuilder itself. | 101 | * use "NULL" to pass the GtkBuilder itself. |
102 | * @param cb function to call before connecting signals | ||
102 | * @return NULL on error | 103 | * @return NULL on error |
103 | */ | 104 | */ |
104 | GtkBuilder * | 105 | GtkBuilder * |
105 | GNUNET_GTK_get_new_builder (const char *filename, | 106 | GNUNET_GTK_get_new_builder2 (const char *filename, |
106 | void *user_data) | 107 | void *user_data, |
108 | GtkBuilderConnectFunc cb) | ||
107 | { | 109 | { |
108 | char *glade_path; | 110 | char *glade_path; |
109 | GtkBuilder *ret; | 111 | GtkBuilder *ret; |
@@ -111,17 +113,25 @@ GNUNET_GTK_get_new_builder (const char *filename, | |||
111 | 113 | ||
112 | ret = gtk_builder_new (); | 114 | ret = gtk_builder_new (); |
113 | gtk_builder_set_translation_domain (ret, "gnunet-gtk"); | 115 | gtk_builder_set_translation_domain (ret, "gnunet-gtk"); |
114 | GNUNET_asprintf (&glade_path, "%s%s", GNUNET_GTK_get_data_dir (), filename); | 116 | GNUNET_asprintf (&glade_path, "%s%s", |
117 | GNUNET_GTK_get_data_dir (), | ||
118 | filename); | ||
115 | error = NULL; | 119 | error = NULL; |
116 | if (0 == gtk_builder_add_from_file (ret, glade_path, &error)) | 120 | if (0 == gtk_builder_add_from_file (ret, glade_path, &error)) |
117 | { | 121 | { |
118 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to load `%s': %s\n"), | 122 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
123 | _("Failed to load `%s': %s\n"), | ||
119 | glade_path, error->message); | 124 | glade_path, error->message); |
120 | g_error_free (error); | 125 | g_error_free (error); |
121 | GNUNET_free (glade_path); | 126 | GNUNET_free (glade_path); |
122 | return NULL; | 127 | return NULL; |
123 | } | 128 | } |
124 | gtk_builder_connect_signals (ret, (user_data == NULL) ? ret : user_data); | 129 | if (NULL == user_data) |
130 | user_data = ret; | ||
131 | if (NULL != cb) | ||
132 | gtk_builder_connect_signals_full (ret, cb, user_data); | ||
133 | else | ||
134 | gtk_builder_connect_signals (ret, user_data); | ||
125 | GNUNET_free (glade_path); | 135 | GNUNET_free (glade_path); |
126 | return ret; | 136 | return ret; |
127 | } | 137 | } |