aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-03-01 11:54:40 +0000
committerChristian Grothoff <christian@grothoff.org>2012-03-01 11:54:40 +0000
commit566a2506418b17631f101fb81a320616bde0fdaa (patch)
treed6a132165b6b51d4baebabaa62b3972d68ef36df
parentc2f8fc70a1dc5f63f799c0af2e7d9edb1ffce486 (diff)
downloadgnunet-gtk-566a2506418b17631f101fb81a320616bde0fdaa.tar.gz
gnunet-gtk-566a2506418b17631f101fb81a320616bde0fdaa.zip
LRN: add main window context; apply pseudonym rank filtering
-rw-r--r--contrib/gnunet_fs_gtk_main_window.glade1
-rw-r--r--src/fs/gnunet-fs-gtk.c92
-rw-r--r--src/fs/gnunet-fs-gtk.h30
-rw-r--r--src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c23
-rw-r--r--src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c261
-rw-r--r--src/fs/gnunet-fs-gtk_main-window-search.c25
-rw-r--r--src/fs/gnunet-fs-gtk_namespace_manager.c7
-rw-r--r--src/include/gnunet_gtk.h12
-rw-r--r--src/lib/eventloop.c28
9 files changed, 269 insertions, 210 deletions
diff --git a/contrib/gnunet_fs_gtk_main_window.glade b/contrib/gnunet_fs_gtk_main_window.glade
index 710c7697..fd46bceb 100644
--- a/contrib/gnunet_fs_gtk_main_window.glade
+++ b/contrib/gnunet_fs_gtk_main_window.glade
@@ -161,7 +161,6 @@
161 <property name="default_width">700</property> 161 <property name="default_width">700</property>
162 <property name="default_height">500</property> 162 <property name="default_height">500</property>
163 <property name="icon_name">gnunet-gtk</property> 163 <property name="icon_name">gnunet-gtk</property>
164 <signal name="realize" handler="GNUNET_GTK_main_window_realize_cb"/>
165 <signal name="delete_event" handler="GNUNET_GTK_quit_cb" after="yes"/> 164 <signal name="delete_event" handler="GNUNET_GTK_quit_cb" after="yes"/>
166 <child> 165 <child>
167 <object class="GtkVBox" id="GNUNET_GTK_main_window_vbox"> 166 <object class="GtkVBox" id="GNUNET_GTK_main_window_vbox">
diff --git a/src/fs/gnunet-fs-gtk.c b/src/fs/gnunet-fs-gtk.c
index ccc05c15..7cee7ac3 100644
--- a/src/fs/gnunet-fs-gtk.c
+++ b/src/fs/gnunet-fs-gtk.c
@@ -23,6 +23,7 @@
23 * @brief Main function of gnunet-fs-gtk 23 * @brief Main function of gnunet-fs-gtk
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26#include "gnunet-fs-gtk.h"
26#include "gnunet-fs-gtk_common.h" 27#include "gnunet-fs-gtk_common.h"
27#include "gnunet-fs-gtk_event-handler.h" 28#include "gnunet-fs-gtk_event-handler.h"
28#include <gdk/gdkkeysyms.h> 29#include <gdk/gdkkeysyms.h>
@@ -172,14 +173,14 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
172void 173void
173GNUNET_GTK_quit_cb (GObject * object, gpointer user_data) 174GNUNET_GTK_quit_cb (GObject * object, gpointer user_data)
174{ 175{
175 GtkWidget *main_window = GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object ( 176 struct GNUNET_GTK_MainWindowContext *main_context;
176 "GNUNET_GTK_main_window"));
177 177
178 main_window_save_position (main_window); 178 main_window_save_position (main_context->main_window);
179 179
180 GNUNET_GTK_tray_icon_destroy (); 180 GNUNET_GTK_tray_icon_destroy ();
181 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, 181 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
182 &shutdown_task, NULL); 182 &shutdown_task, NULL);
183 GNUNET_free (main_context);
183} 184}
184 185
185 186
@@ -193,72 +194,97 @@ GNUNET_GTK_quit_cb (GObject * object, gpointer user_data)
193static void 194static void
194run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 195run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
195{ 196{
196 GtkWidget *main_window;
197 GtkTreeView *metadata_tree;
198 unsigned long long dl_parallel, req_parallel, window_x, window_y, 197 unsigned long long dl_parallel, req_parallel, window_x, window_y,
199 window_width, window_height; 198 window_width, window_height;
200 int maximized; 199 int maximized;
201 const struct GNUNET_CONFIGURATION_Handle *cfg; 200
201 struct GNUNET_GTK_MainWindowContext *main_context;
202
203 main_context = GNUNET_malloc (sizeof (struct GNUNET_GTK_MainWindowContext));
202 204
203 ml = cls; 205 ml = cls;
204 206
207 /* setup main context */
208 if (GNUNET_OK != GNUNET_GTK_main_loop_build_window (cls, main_context))
209 {
210 GNUNET_free (main_context);
211 return;
212 }
213
214 main_context->builder = GNUNET_GTK_main_loop_get_builder (cls);
215 main_context->cfg = GNUNET_GTK_main_loop_get_configuration (cls);
216 main_context->search_ns_treestore = GTK_TREE_STORE (GNUNET_FS_GTK_get_main_window_object ("main_window_search_namespace_treestore"));
217 main_context->main_window = GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_window"));
218 main_context->ns_selector_treeview = GTK_TREE_VIEW (GNUNET_FS_GTK_get_main_window_object ("namespace_selector_treeview"));
219 main_context->ns_selector_window = GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object ("namespace_selector_window"));
220 main_context->ns_dropdown_button = GTK_TOGGLE_BUTTON (GNUNET_FS_GTK_get_main_window_object ("main_window_search_namespace_dropdown_button"));
221 main_context->search_ns_label = GTK_LABEL (GNUNET_FS_GTK_get_main_window_object ("main_window_search_selected_namespace_label"));
222
223 main_context->search_entry = GTK_ENTRY (GNUNET_FS_GTK_get_main_window_object ("main_window_search_entry"));
224
225 main_context->anonymity_combo = GTK_COMBO_BOX (GNUNET_FS_GTK_get_main_window_object ("main_window_search_anonymity_combobox"));
226 main_context->anonymity_level_liststore = GTK_LIST_STORE (GNUNET_FS_GTK_get_main_window_object ("anonymity_level_liststore"));
227
228 main_context->preview_image = GTK_IMAGE (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_window_preview_image"));
229 main_context->md_liststore = GTK_LIST_STORE (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_meta_data_list_store"));
230 main_context->md_treeview = GTK_TREE_VIEW (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_window_metadata_treeview"));
231 main_context->ns_callback_registered = GNUNET_NO;
232
205 GNUNET_GTK_set_icon_search_path (); 233 GNUNET_GTK_set_icon_search_path ();
206 GNUNET_GTK_setup_nls (); 234 GNUNET_GTK_setup_nls ();
207 235
208 /* setup main window */ 236 /* Make sure button class is realized */
209 main_window = 237 g_type_class_unref (g_type_class_ref (GTK_TYPE_BUTTON));
210 GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object 238 /* GNUnet main window assumes that images on buttons are visible,
211 ("GNUNET_GTK_main_window")); 239 * override the theme's gtkrc setting
212 240 */
213 cfg = GNUNET_GTK_main_loop_get_configuration (ml); 241 g_object_set (gtk_settings_get_default (), "gtk-button-images", TRUE, NULL);
214 242
215 maximized = GNUNET_CONFIGURATION_get_value_yesno (cfg, 243 /* setup main window */
244 maximized = GNUNET_CONFIGURATION_get_value_yesno (main_context->cfg,
216 "gnunet-gtk", "MAIN_WINDOW_MAXIMIZED"); 245 "gnunet-gtk", "MAIN_WINDOW_MAXIMIZED");
217 if (GNUNET_SYSERR == maximized) 246 if (GNUNET_SYSERR == maximized)
218 maximized = GNUNET_YES; 247 maximized = GNUNET_YES;
219 if ( (GNUNET_NO == maximized) && 248 if ( (GNUNET_NO == maximized) &&
220 (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "gnunet-gtk", 249 (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (main_context->cfg, "gnunet-gtk",
221 "MAIN_WINDOW_X", &window_x)) && 250 "MAIN_WINDOW_X", &window_x)) &&
222 (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "gnunet-gtk", 251 (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (main_context->cfg, "gnunet-gtk",
223 "MAIN_WINDOW_Y", &window_y)) && 252 "MAIN_WINDOW_Y", &window_y)) &&
224 (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "gnunet-gtk", 253 (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (main_context->cfg, "gnunet-gtk",
225 "MAIN_WINDOW_WIDTH", &window_width)) && 254 "MAIN_WINDOW_WIDTH", &window_width)) &&
226 (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "gnunet-gtk", 255 (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (main_context->cfg, "gnunet-gtk",
227 "MAIN_WINDOW_HEIGHT", &window_height)) ) 256 "MAIN_WINDOW_HEIGHT", &window_height)) )
228 { 257 {
229 gtk_window_move (GTK_WINDOW (main_window), window_x, window_y); 258 gtk_window_move (GTK_WINDOW (main_context->main_window), window_x, window_y);
230 gtk_window_resize (GTK_WINDOW (main_window), window_width, window_height); 259 gtk_window_resize (GTK_WINDOW (main_context->main_window), window_width, window_height);
231 } 260 }
232 else 261 else
233 { 262 {
234 /* If anything is wrong - play safe and show it maximized */ 263 /* If anything is wrong - play safe and show it maximized */
235 gtk_window_maximize (GTK_WINDOW (main_window)); 264 gtk_window_maximize (GTK_WINDOW (main_context->main_window));
236 } 265 }
237 266
238 /* Allow multiple selection in metadata view; */ 267 /* Allow multiple selection in metadata view; */
239 /* FIXME-GTK3: this can be done within (modern versions of) glade */ 268 /* FIXME-GTK3: this can be done within (modern versions of) glade */
240 metadata_tree = 269 gtk_tree_selection_set_mode (gtk_tree_view_get_selection (main_context->md_treeview),
241 GTK_TREE_VIEW (GNUNET_FS_GTK_get_main_window_object
242 ("GNUNET_GTK_main_window_metadata_treeview"));
243 gtk_tree_selection_set_mode (gtk_tree_view_get_selection (metadata_tree),
244 GTK_SELECTION_MULTIPLE); 270 GTK_SELECTION_MULTIPLE);
245 271
246 GNUNET_GTK_tray_icon_create (GTK_WINDOW (main_window), 272 GNUNET_GTK_tray_icon_create (GTK_WINDOW (main_context->main_window),
247 "gnunet-fs-gtk", 273 "gnunet-fs-gtk",
248 "gnunet-fs-gtk"); 274 "gnunet-fs-gtk");
249 275
250 /* FIXME: should these '1's be here? Maybe better to put them into 276 /* FIXME: should these '1's be here? Maybe better to put them into
251 * default config files? 277 * default config files?
252 */ 278 */
253 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "gnunet-gtk", 279 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (main_context->cfg, "gnunet-gtk",
254 "MAX_PARALLEL_DOWNLOADS", &dl_parallel)) 280 "MAX_PARALLEL_DOWNLOADS", &dl_parallel))
255 dl_parallel = 1; 281 dl_parallel = 1;
256 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "gnunet-gtk", 282 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (main_context->cfg, "gnunet-gtk",
257 "MAX_PARALLEL_REQUESTS", &req_parallel)) 283 "MAX_PARALLEL_REQUESTS", &req_parallel))
258 req_parallel = 1; 284 req_parallel = 1;
259 285
260 /* initialize file-sharing */ 286 /* initialize file-sharing */
261 fs = GNUNET_FS_start (cfg, "gnunet-fs-gtk", 287 fs = GNUNET_FS_start (main_context->cfg, "gnunet-fs-gtk",
262 &GNUNET_GTK_fs_event_handler, NULL, 288 &GNUNET_GTK_fs_event_handler, NULL,
263 GNUNET_FS_FLAGS_NONE | GNUNET_FS_FLAGS_PERSISTENCE 289 GNUNET_FS_FLAGS_NONE | GNUNET_FS_FLAGS_PERSISTENCE
264 /* | GNUNET_FS_FLAGS_DO_PROBES */ , 290 /* | GNUNET_FS_FLAGS_DO_PROBES */ ,
@@ -269,14 +295,18 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
269 GNUNET_FS_OPTIONS_END); 295 GNUNET_FS_OPTIONS_END);
270 if (NULL == fs) 296 if (NULL == fs)
271 { 297 {
272 GNUNET_GTK_main_loop_quit (ml); 298 GNUNET_GTK_main_loop_quit (cls);
299 GNUNET_free (main_context);
273 return; 300 return;
274 } 301 }
302
303 GNUNET_GTK_main_window_refresh_ns_list (main_context);
304
275 /* make GUI visible */ 305 /* make GUI visible */
276 if (!tray_only) 306 if (!tray_only)
277 { 307 {
278 gtk_widget_show (main_window); 308 gtk_widget_show (main_context->main_window);
279 gtk_window_present (GTK_WINDOW (main_window)); 309 gtk_window_present (GTK_WINDOW (main_context->main_window));
280 } 310 }
281 311
282} 312}
diff --git a/src/fs/gnunet-fs-gtk.h b/src/fs/gnunet-fs-gtk.h
index 4f5c7476..af533fad 100644
--- a/src/fs/gnunet-fs-gtk.h
+++ b/src/fs/gnunet-fs-gtk.h
@@ -30,6 +30,33 @@
30#include <gnunet/gnunet_fs_service.h> 30#include <gnunet/gnunet_fs_service.h>
31#include <extractor.h> 31#include <extractor.h>
32 32
33struct GNUNET_GTK_MainWindowContext
34{
35 GtkBuilder *builder;
36
37 const struct GNUNET_CONFIGURATION_Handle *cfg;
38
39 GtkTreeStore *search_ns_treestore;
40 GtkTreeView *ns_selector_treeview;
41 GtkWidget *ns_selector_window;
42 GtkToggleButton *ns_dropdown_button;
43 GtkLabel *search_ns_label;
44
45 GtkEntry *search_entry;
46
47 GtkComboBox *anonymity_combo;
48 GtkListStore *anonymity_level_liststore;
49
50 GtkImage *preview_image;
51 GtkListStore *md_liststore;
52 GtkTreeView *md_treeview;
53
54 GtkWidget *main_window;
55
56 GtkTreeRowReference *ns_selector_pushed_row;
57 GtkTreeRowReference *selected_ns_row;
58 int ns_callback_registered;
59};
33 60
34/** 61/**
35 * Get our configuration. 62 * Get our configuration.
@@ -114,5 +141,8 @@ GNUNET_GTK_select_anonymity_level (GtkBuilder * builder, gchar * combo_name,
114gboolean 141gboolean
115GNUNET_GTK_select_anonymity_combo_level (GtkComboBox *combo, guint sel_level); 142GNUNET_GTK_select_anonymity_combo_level (GtkComboBox *combo, guint sel_level);
116 143
144void
145GNUNET_GTK_main_window_refresh_ns_list (struct GNUNET_GTK_MainWindowContext *main_ctx);
146
117#endif 147#endif
118/* end of gnunet-fs-gtk.h */ 148/* end of gnunet-fs-gtk.h */
diff --git a/src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c b/src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c
index bf3421ee..f209415d 100644
--- a/src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c
+++ b/src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c
@@ -64,7 +64,7 @@ void
64GNUNET_GTK_FS_metadata_copy_selection_activated (GtkMenuItem * menuitem, 64GNUNET_GTK_FS_metadata_copy_selection_activated (GtkMenuItem * menuitem,
65 gpointer user_data) 65 gpointer user_data)
66{ 66{
67 GtkBuilder *builder = GTK_BUILDER (user_data); 67 struct GNUNET_GTK_MainWindowContext *main_ctx = user_data;
68 GtkTreeView *tree; 68 GtkTreeView *tree;
69 GtkClipboard *cb; 69 GtkClipboard *cb;
70 GList *pairs; 70 GList *pairs;
@@ -75,9 +75,7 @@ GNUNET_GTK_FS_metadata_copy_selection_activated (GtkMenuItem * menuitem,
75 gchar *s; 75 gchar *s;
76 gchar *p; 76 gchar *p;
77 77
78 tree = 78 tree = main_ctx->md_treeview;
79 GTK_TREE_VIEW (gtk_builder_get_object
80 (builder, "GNUNET_GTK_main_window_metadata_treeview"));
81 pairs = NULL; 79 pairs = NULL;
82 gtk_tree_selection_selected_foreach (gtk_tree_view_get_selection (tree), 80 gtk_tree_selection_selected_foreach (gtk_tree_view_get_selection (tree),
83 &copy_metadata_to_clipboard, &pairs); 81 &copy_metadata_to_clipboard, &pairs);
@@ -129,17 +127,18 @@ GNUNET_GTK_FS_metadata_copy_selection_activated (GtkMenuItem * menuitem,
129 * 127 *
130 * @param button which button caused the event (0 for none) 128 * @param button which button caused the event (0 for none)
131 * @param event_time time of the event (current time or 'event->time') 129 * @param event_time time of the event (current time or 'event->time')
132 * @param user_data the gtk builder of the main window 130 * @param user_data the context of the main window
133 */ 131 */
134static void 132static void
135do_metadata_popup_menu (int button, 133do_metadata_popup_menu (int button,
136 int event_time, 134 int event_time,
137 GtkBuilder *builder) 135 gpointer user_data)
138{ 136{
139 GtkMenu *menu; 137 GtkMenu *menu;
138 struct GNUNET_GTK_MainWindowContext *main_ctx = user_data;
140 139
141 menu = GTK_MENU (gtk_builder_get_object (builder, "metadata_popup_menu")); 140 menu = GTK_MENU (gtk_builder_get_object (main_ctx->builder, "metadata_popup_menu"));
142 gtk_menu_popup (menu, NULL, NULL, NULL, builder, button, event_time); 141 gtk_menu_popup (menu, NULL, NULL, NULL, main_ctx, button, event_time);
143} 142}
144 143
145 144
@@ -158,14 +157,12 @@ GNUNET_GTK_main_window_metadata_treeview_button_press_event_cb (GtkWidget *
158 gpointer 157 gpointer
159 user_data) 158 user_data)
160{ 159{
161 GtkBuilder *builder = GTK_BUILDER (user_data);
162
163 /* Ignore double-clicks and triple-clicks */ 160 /* Ignore double-clicks and triple-clicks */
164 if ( (event->button != 3) || (event->type != GDK_BUTTON_PRESS) ) 161 if ( (event->button != 3) || (event->type != GDK_BUTTON_PRESS) )
165 return FALSE; 162 return FALSE;
166 do_metadata_popup_menu (event->button, 163 do_metadata_popup_menu (event->button,
167 event->time, 164 event->time,
168 builder); 165 user_data);
169 return TRUE; 166 return TRUE;
170} 167}
171 168
@@ -182,11 +179,9 @@ gboolean
182GNUNET_GTK_main_window_metadata_treeview_popup_menu_cb (GtkWidget * widget, 179GNUNET_GTK_main_window_metadata_treeview_popup_menu_cb (GtkWidget * widget,
183 gpointer user_data) 180 gpointer user_data)
184{ 181{
185 GtkBuilder *builder = GTK_BUILDER (user_data);
186
187 do_metadata_popup_menu (0 /* no button */, 182 do_metadata_popup_menu (0 /* no button */,
188 gtk_get_current_event_time (), 183 gtk_get_current_event_time (),
189 builder); 184 user_data);
190 return TRUE; 185 return TRUE;
191} 186}
192 187
diff --git a/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c b/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c
index 818caa6c..f5697ef1 100644
--- a/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c
+++ b/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c
@@ -48,7 +48,7 @@ static guint namespace_selector_window_leave_timeout_source;
48 * 48 *
49 * @param widget the dropdown widget 49 * @param widget the dropdown widget
50 * @param event the mouse-enter event 50 * @param event the mouse-enter event
51 * @param user_data the builder for the main window 51 * @param user_data the context for the main window
52 */ 52 */
53gboolean 53gboolean
54GNUNET_FS_GTK_search_namespace_dropdown_button_enter_notify_event_cb (GtkWidget *widget, 54GNUNET_FS_GTK_search_namespace_dropdown_button_enter_notify_event_cb (GtkWidget *widget,
@@ -85,26 +85,21 @@ namespace_selector_window_leave_timeout_cb (gpointer user_data)
85 * window. It will be cancelled if the cursor re-enters the namespace 85 * window. It will be cancelled if the cursor re-enters the namespace
86 * selector window or the toggle button within 100ms 86 * selector window or the toggle button within 100ms
87 * 87 *
88 * @param user_data the builder for the main window 88 * @param user_data the context for the main window
89 */ 89 */
90gboolean 90gboolean
91GNUNET_FS_GTK_search_namespace_selector_window_leave_notify_event_cb (GtkWidget * widget, 91GNUNET_FS_GTK_search_namespace_selector_window_leave_notify_event_cb (GtkWidget * widget,
92 GdkEvent * event, 92 GdkEvent * event,
93 gpointer user_data) 93 gpointer user_data)
94{ 94{
95 GtkBuilder *builder = GTK_BUILDER (user_data); 95 struct GNUNET_GTK_MainWindowContext *main_ctx = user_data;
96 GtkToggleButton *toggle_button;
97 96
98 toggle_button =
99 GTK_TOGGLE_BUTTON (gtk_builder_get_object
100 (builder,
101 "main_window_search_namespace_dropdown_button"));
102 if (namespace_selector_window_leave_timeout_source > 0) 97 if (namespace_selector_window_leave_timeout_source > 0)
103 g_source_remove (namespace_selector_window_leave_timeout_source); 98 g_source_remove (namespace_selector_window_leave_timeout_source);
104 namespace_selector_window_leave_timeout_source 99 namespace_selector_window_leave_timeout_source
105 = g_timeout_add (AUTO_HIDE_TIMEOUT_MS, 100 = g_timeout_add (AUTO_HIDE_TIMEOUT_MS,
106 &namespace_selector_window_leave_timeout_cb, 101 &namespace_selector_window_leave_timeout_cb,
107 toggle_button); 102 main_ctx->ns_dropdown_button);
108 return FALSE; 103 return FALSE;
109} 104}
110 105
@@ -139,51 +134,35 @@ get_selected_row_from_treeview (GtkTreeView * tree)
139 * user clicked to confirm. Hide the drop down and display the 134 * user clicked to confirm. Hide the drop down and display the
140 * selected entry as the new namespace label. 135 * selected entry as the new namespace label.
141 * 136 *
142 * @param builder the builder for the main window 137 * @param main_ctx the context for the main window
143 * @param tv the tree view that was updated 138 * @param tv the tree view that was updated
144 */ 139 */
145static void 140static void
146commit_changes (GtkBuilder *builder, 141commit_changes (struct GNUNET_GTK_MainWindowContext *main_ctx,
147 GtkTreeView *tv) 142 GtkTreeView *tv)
148{ 143{
149 GtkToggleButton *toggle_button;
150 GtkTreeRowReference *ref;
151 GtkTreePath *treepath; 144 GtkTreePath *treepath;
152 gchar *value; 145 gchar *value;
153
154 toggle_button =
155 GTK_TOGGLE_BUTTON (gtk_builder_get_object
156 (builder,
157 "main_window_search_namespace_dropdown_button"));
158 ref = g_object_get_data (G_OBJECT (toggle_button), "selected-row-reference");
159 if (NULL != ref)
160 gtk_tree_row_reference_free (ref);
161 ref = get_selected_row_from_treeview (tv);
162 g_object_set_data (G_OBJECT (toggle_button), "selected-row-reference", ref);
163 146
164 treepath = gtk_tree_row_reference_get_path (ref); 147 if (NULL != main_ctx->selected_ns_row)
148 gtk_tree_row_reference_free (main_ctx->selected_ns_row);
149 main_ctx->selected_ns_row = get_selected_row_from_treeview (tv);
150
151 treepath = gtk_tree_row_reference_get_path (main_ctx->selected_ns_row);
165 if (GNUNET_GTK_get_tree_string (tv, treepath, 0, &value)) 152 if (GNUNET_GTK_get_tree_string (tv, treepath, 0, &value))
166 { 153 {
167 GtkLabel *sel_namespace_label; 154 gtk_label_set_text (main_ctx->search_ns_label, (NULL != value) ? value : "");
168
169 sel_namespace_label =
170 GTK_LABEL (gtk_builder_get_object
171 (builder, "main_window_search_selected_namespace_label"));
172 gtk_label_set_text (sel_namespace_label, (NULL != value) ? value : "");
173 g_free (value); 155 g_free (value);
174 } 156 }
175 if (GNUNET_GTK_get_tree_string (tv, treepath, 2, &value)) 157 if (GNUNET_GTK_get_tree_string (tv, treepath, 2, &value))
176 { 158 {
177 GtkEntry *search_entry; 159 gtk_entry_set_text (main_ctx->search_entry, (NULL != value) ? value : "");
178
179 search_entry = GTK_ENTRY (gtk_builder_get_object (builder, "main_window_search_entry"));
180 gtk_entry_set_text (search_entry, (NULL != value) ? value : "");
181 g_free (value); 160 g_free (value);
182 } 161 }
183 gtk_tree_path_free (treepath); 162 gtk_tree_path_free (treepath);
184 163
185 /* hide the namespace selector */ 164 /* hide the namespace selector */
186 gtk_toggle_button_set_active (toggle_button, FALSE); 165 gtk_toggle_button_set_active (main_ctx->ns_dropdown_button, FALSE);
187} 166}
188 167
189 168
@@ -194,7 +173,7 @@ commit_changes (GtkBuilder *builder,
194 * 173 *
195 * @param widget the tree view widget 174 * @param widget the tree view widget
196 * @param event the push event 175 * @param event the push event
197 * @param user_data the builder for the main window 176 * @param user_data the context for the main window
198 * @return FALSE 177 * @return FALSE
199 */ 178 */
200gboolean 179gboolean
@@ -202,13 +181,11 @@ GNUNET_FS_GTK_namespace_selector_treeview_button_press_event_cb (GtkWidget * wid
202 GdkEvent * event, 181 GdkEvent * event,
203 gpointer user_data) 182 gpointer user_data)
204{ 183{
205 GtkTreeRowReference *ref; 184 struct GNUNET_GTK_MainWindowContext *main_ctx = user_data;
206 gpointer old = g_object_get_data (G_OBJECT (widget), "pushed-rowreference");
207 185
208 if (NULL != old) 186 if (NULL != main_ctx->ns_selector_pushed_row)
209 gtk_tree_row_reference_free (old); 187 gtk_tree_row_reference_free (main_ctx->ns_selector_pushed_row);
210 ref = get_selected_row_from_treeview (GTK_TREE_VIEW (widget)); 188 main_ctx->ns_selector_pushed_row = get_selected_row_from_treeview (GTK_TREE_VIEW (widget));
211 g_object_set_data (G_OBJECT (widget), "pushed-rowreference", ref);
212 return FALSE; 189 return FALSE;
213} 190}
214 191
@@ -216,13 +193,11 @@ GNUNET_FS_GTK_namespace_selector_treeview_button_press_event_cb (GtkWidget * wid
216/** 193/**
217 * User released the button in the treeview. Get the selected entry 194 * User released the button in the treeview. Get the selected entry
218 * and update the cursor accordingly, but only if the user pushed the 195 * and update the cursor accordingly, but only if the user pushed the
219 * button down and released it in the same row. We have stored the 196 * button down and released it in the same row.
220 * row that the user selected when pushing the button down in the
221 * "pushed-rowreference" of the widget.
222 * 197 *
223 * @param widget the tree view widget 198 * @param widget the tree view widget
224 * @param event the release event 199 * @param event the release event
225 * @param user_data the builder for the main window 200 * @param user_data the context for the main window
226 * @return FALSE 201 * @return FALSE
227 */ 202 */
228gboolean 203gboolean
@@ -230,20 +205,19 @@ GNUNET_FS_GTK_namespace_selector_treeview_button_release_event_cb (GtkWidget * w
230 GdkEvent * event, 205 GdkEvent * event,
231 gpointer user_data) 206 gpointer user_data)
232{ 207{
233 GtkBuilder *builder = GTK_BUILDER (user_data); 208 struct GNUNET_GTK_MainWindowContext *main_ctx = user_data;
234 GtkTreeRowReference *ref; 209 GtkTreeRowReference *ref;
235 gpointer old = g_object_get_data (G_OBJECT (widget), "pushed-rowreference");
236 210
237 ref = get_selected_row_from_treeview (GTK_TREE_VIEW (widget)); 211 ref = get_selected_row_from_treeview (GTK_TREE_VIEW (widget));
238 if ( (NULL != ref) && (NULL != old)) 212 if ( (NULL != ref) && (NULL != main_ctx->ns_selector_pushed_row))
239 { 213 {
240 GtkTreePath *path_ref; 214 GtkTreePath *path_ref;
241 GtkTreePath *path_old; 215 GtkTreePath *path_old;
242 216
243 path_ref = gtk_tree_row_reference_get_path (ref); 217 path_ref = gtk_tree_row_reference_get_path (ref);
244 path_old = gtk_tree_row_reference_get_path (old); 218 path_old = gtk_tree_row_reference_get_path (main_ctx->ns_selector_pushed_row);
245 if (0 == gtk_tree_path_compare (path_ref, path_old)) 219 if (0 == gtk_tree_path_compare (path_ref, path_old))
246 commit_changes (builder, GTK_TREE_VIEW (widget)); 220 commit_changes (main_ctx, GTK_TREE_VIEW (widget));
247 if (path_ref) 221 if (path_ref)
248 gtk_tree_path_free (path_ref); 222 gtk_tree_path_free (path_ref);
249 if (path_old) 223 if (path_old)
@@ -251,9 +225,9 @@ GNUNET_FS_GTK_namespace_selector_treeview_button_release_event_cb (GtkWidget * w
251 } 225 }
252 if (NULL != ref) 226 if (NULL != ref)
253 gtk_tree_row_reference_free (ref); 227 gtk_tree_row_reference_free (ref);
254 if (NULL != old) 228 if (NULL != main_ctx->ns_selector_pushed_row)
255 gtk_tree_row_reference_free (old); 229 gtk_tree_row_reference_free (main_ctx->ns_selector_pushed_row);
256 g_object_set_data (G_OBJECT (widget), "pushed-rowreference", NULL); 230 main_ctx->ns_selector_pushed_row = NULL;
257 return FALSE; 231 return FALSE;
258} 232}
259 233
@@ -263,17 +237,15 @@ GNUNET_FS_GTK_namespace_selector_treeview_button_release_event_cb (GtkWidget * w
263 * list was toggled. 237 * list was toggled.
264 * 238 *
265 * @param togglebutton the button that toggles the namespace dropdown list 239 * @param togglebutton the button that toggles the namespace dropdown list
266 * @param user_data the builder for the main window 240 * @param user_data the contexxt for the main window
267 */ 241 */
268void 242void
269GNUNET_FS_GTK_search_namespace_dropdown_button_toggled_cb (GtkToggleButton * 243GNUNET_FS_GTK_search_namespace_dropdown_button_toggled_cb (GtkToggleButton *
270 togglebutton, 244 togglebutton,
271 gpointer user_data) 245 gpointer user_data)
272{ 246{
273 GtkBuilder *builder = GTK_BUILDER (user_data); 247 struct GNUNET_GTK_MainWindowContext *main_ctx = user_data;
274 gboolean active; 248 gboolean active;
275 GtkWidget *namespace_selector_window;
276 GtkWidget *namespace_selector_treeview;
277 GtkAllocation togglebutton_allocation; 249 GtkAllocation togglebutton_allocation;
278 GdkWindow *main_window_gdk; 250 GdkWindow *main_window_gdk;
279 gint mwg_x; 251 gint mwg_x;
@@ -283,19 +255,13 @@ GNUNET_FS_GTK_search_namespace_dropdown_button_toggled_cb (GtkToggleButton *
283 gint popup_x; 255 gint popup_x;
284 gint popup_y; 256 gint popup_y;
285 257
286 namespace_selector_window =
287 GTK_WIDGET (gtk_builder_get_object
288 (builder, "namespace_selector_window"));
289 g_object_get (G_OBJECT (togglebutton), "active", &active, NULL); 258 g_object_get (G_OBJECT (togglebutton), "active", &active, NULL);
290 if (! active) 259 if (! active)
291 { 260 {
292 gtk_widget_hide (namespace_selector_window); 261 gtk_widget_hide (main_ctx->ns_selector_window);
293 gtk_widget_grab_focus (GTK_WIDGET (togglebutton)); 262 gtk_widget_grab_focus (GTK_WIDGET (togglebutton));
294 return; 263 return;
295 } 264 }
296 namespace_selector_treeview =
297 GTK_WIDGET (gtk_builder_get_object
298 (builder, "namespace_selector_treeview"));
299 gtk_widget_get_allocation (GTK_WIDGET (togglebutton), 265 gtk_widget_get_allocation (GTK_WIDGET (togglebutton),
300 &togglebutton_allocation); 266 &togglebutton_allocation);
301 main_window_gdk = gtk_widget_get_window (GTK_WIDGET (togglebutton)); 267 main_window_gdk = gtk_widget_get_window (GTK_WIDGET (togglebutton));
@@ -305,9 +271,9 @@ GNUNET_FS_GTK_search_namespace_dropdown_button_toggled_cb (GtkToggleButton *
305 tgb_y = mwg_y + togglebutton_allocation.y; 271 tgb_y = mwg_y + togglebutton_allocation.y;
306 popup_x = tgb_x; 272 popup_x = tgb_x;
307 popup_y = tgb_y + togglebutton_allocation.height; 273 popup_y = tgb_y + togglebutton_allocation.height;
308 gtk_window_move (GTK_WINDOW (namespace_selector_window), popup_x, popup_y); 274 gtk_window_move (GTK_WINDOW (main_ctx->ns_selector_window), popup_x, popup_y);
309 gtk_widget_show_all (namespace_selector_window); 275 gtk_widget_show_all (main_ctx->ns_selector_window);
310 gtk_widget_grab_focus (namespace_selector_treeview); 276 gtk_widget_grab_focus (GTK_WIDGET (main_ctx->ns_selector_treeview));
311} 277}
312 278
313 279
@@ -370,92 +336,103 @@ add_namespace_to_ts (void *cls, const GNUNET_HashCode * pseudonym,
370 return GNUNET_OK; 336 return GNUNET_OK;
371} 337}
372 338
373
374/**
375 * Startup hook to initialize the namespace dropdown widget.
376 *
377 * @param widget the main window
378 * @param user_data the builder for the main window
379 */
380/* FIXME-STYLE: hang up on 'realize' event of a widget closer to home? */
381void 339void
382GNUNET_GTK_main_window_realize_cb (GtkWidget * widget, gpointer user_data) 340GNUNET_GTK_main_window_refresh_ns_list (struct GNUNET_GTK_MainWindowContext *main_ctx)
383{ 341{
384 GtkBuilder *builder = GTK_BUILDER (user_data);
385 GtkTreeIter iter; 342 GtkTreeIter iter;
386 GtkTreeStore *namespace_treestore; 343 gint i;
387 344
388 /* FIXME-STYLE: can't we do the button initialization when we create the main window? */ 345 GtkTreePath *treepath;
389 /* Make sure button class is realized */ 346 GNUNET_HashCode *key = NULL, *selected_ns_id;
390 g_type_class_unref (g_type_class_ref (GTK_TYPE_BUTTON));
391 /* GNUnet main window assumes that images on buttons are visible,
392 * override the theme's gtkrc setting
393 */
394 g_object_set (gtk_settings_get_default (), "gtk-button-images", TRUE, NULL);
395 347
396 /* setup namespace treestore */ 348 gboolean found = FALSE;
397 { 349 gchar *value = NULL;
398 namespace_treestore =
399 GTK_TREE_STORE (GNUNET_FS_GTK_get_main_window_object
400 ("main_window_search_namespace_treestore"));
401 350
402 /* FIXME-FEATURE: find a way to manage pseudonyms. 351 if (NULL != main_ctx->selected_ns_row)
403 * Right now the list will be filled with ALL and ANY pseudonyms that we
404 * find, these are held as files in a special directory.
405 * I don't see an easy way to ignore certain pseudonyms in that directory,
406 * and that require for pseudonym management. Also, pseudonyms are presented
407 * in arbitrary order. We must either sort them (by name?) or let the user
408 * drag them around to change the order in which they appear in the list.
409 * All that is not possible with a simple "files in a directory" concept.
410 */
411 gtk_tree_store_insert_with_values (namespace_treestore, &iter, NULL, G_MAXINT,
412 0, "Any", 1, NULL, 2, "", 3,
413 "Do not search in any particular namespace",
414 -1);
415 /* FIXME-BUG-MINOR: when do we unregister? */
416 GNUNET_PSEUDONYM_discovery_callback_register (GNUNET_FS_GTK_get_configuration (),
417 &add_namespace_to_ts,
418 namespace_treestore);
419 }
420
421 /* select the first item and update the label */
422 /* FIXME-STYLE: is this even necessary? If the first item is "Any", we can
423 just have the label have the right default, or not? */
424 if (gtk_tree_model_get_iter_first
425 (GTK_TREE_MODEL (namespace_treestore), &iter))
426 { 352 {
427 gchar *value; 353 GtkTreeModel *model;
428 GtkLabel *sel_namespace_label; 354 treepath = gtk_tree_row_reference_get_path (main_ctx->selected_ns_row);
429 GtkTreePath *treepath = gtk_tree_path_new_first (); 355 model = gtk_tree_view_get_model (main_ctx->ns_selector_treeview);
430 GtkTreeView *namespace_tree; 356 if (model)
431 357 {
432 namespace_tree = 358 if (gtk_tree_model_get_iter (model, &iter, treepath))
433 GTK_TREE_VIEW (GNUNET_FS_GTK_get_main_window_object 359 {
434 ("namespace_selector_treeview")); 360 gtk_tree_model_get (model, &iter, 1, &key, -1);
435 gtk_tree_selection_select_iter (gtk_tree_view_get_selection 361 }
436 (namespace_tree), &iter); 362 }
437 sel_namespace_label =
438 GTK_LABEL (gtk_builder_get_object
439 (builder, "main_window_search_selected_namespace_label"));
440 if (GNUNET_GTK_get_tree_string (namespace_tree, treepath, 0, &value))
441 gtk_label_set_text (sel_namespace_label, value);
442 gtk_tree_path_free (treepath); 363 gtk_tree_path_free (treepath);
364 gtk_tree_row_reference_free (main_ctx->selected_ns_row);
365 main_ctx->selected_ns_row = NULL;
443 } 366 }
444 367 selected_ns_id = NULL;
445 /* show the window (to trigger certain events) and immediately hide it */ 368 if (key != NULL)
446 /* FIXME-STYLE: yuck, can't we trigger these events by other means?
447 CG->LRN: Which events are you even talking about here? I can't find anything
448 that would seem to be needed here. */
449 { 369 {
450 GtkWidget *namespace_selector_window; 370 selected_ns_id = GNUNET_malloc (sizeof (GNUNET_HashCode));
371 memcpy (selected_ns_id, key, sizeof (GNUNET_HashCode));
372 }
451 373
452 namespace_selector_window = 374 if (TRUE == gtk_tree_model_get_iter_first (GTK_TREE_MODEL (
453 GTK_WIDGET (gtk_builder_get_object 375 main_ctx->search_ns_treestore), &iter))
454 (builder, "namespace_selector_window")); 376 {
455 gtk_widget_show (namespace_selector_window); 377 while (TRUE)
456 gtk_widget_hide (namespace_selector_window); 378 {
379 gtk_tree_model_get (GTK_TREE_MODEL (main_ctx->search_ns_treestore), &iter,
380 1, &key,
381 -1);
382 GNUNET_free_non_null (key);
383 if (TRUE != gtk_tree_model_iter_next (GTK_TREE_MODEL (
384 main_ctx->search_ns_treestore), &iter))
385 break;
386 }
387 }
388 gtk_tree_store_clear (main_ctx->search_ns_treestore);
389
390 gtk_tree_store_insert_with_values (main_ctx->search_ns_treestore, &iter, NULL, G_MAXINT,
391 0, "Any", 1, NULL, 2, "", 3,
392 "Do not search in any particular namespace",
393 -1);
394
395 if (GNUNET_YES == main_ctx->ns_callback_registered)
396 GNUNET_PSEUDONYM_discovery_callback_unregister (add_namespace_to_ts,
397 main_ctx->search_ns_treestore);
398 GNUNET_PSEUDONYM_discovery_callback_register (main_ctx->cfg,
399 add_namespace_to_ts, main_ctx->search_ns_treestore);
400 main_ctx->ns_callback_registered = GNUNET_YES;
401
402 if (TRUE == gtk_tree_model_get_iter_first (GTK_TREE_MODEL (
403 main_ctx->search_ns_treestore), &iter))
404 {
405 while (TRUE)
406 {
407 gtk_tree_model_get (GTK_TREE_MODEL (main_ctx->search_ns_treestore), &iter,
408 0, &value,
409 1, &key,
410 -1);
411 if (selected_ns_id == NULL)
412 found = TRUE;
413 else if (key != NULL && memcmp (key, selected_ns_id, sizeof (GNUNET_HashCode)) == 0)
414 found = TRUE;
415 if (found || (TRUE != gtk_tree_model_iter_next (GTK_TREE_MODEL (
416 main_ctx->search_ns_treestore), &iter)))
417 break;
418 else
419 g_free (value);
420 }
457 } 421 }
422 if (!found)
423 {
424 gtk_tree_model_get_iter_first (GTK_TREE_MODEL (
425 main_ctx->search_ns_treestore), &iter);
426 gtk_tree_model_get (GTK_TREE_MODEL (main_ctx->search_ns_treestore), &iter,
427 0, &value, 1, &key, -1);
428 found = TRUE;
429 }
430 gtk_tree_selection_select_iter (gtk_tree_view_get_selection
431 (main_ctx->ns_selector_treeview), &iter);
432 if (value != NULL)
433 gtk_label_set_text (main_ctx->search_ns_label, value);
434 g_free(value);
435 GNUNET_free_non_null (selected_ns_id);
458} 436}
459 437
460
461/* end of gnunet-fs-gtk_main-window-namespace-dropdown.c */ 438/* end of gnunet-fs-gtk_main-window-namespace-dropdown.c */
diff --git a/src/fs/gnunet-fs-gtk_main-window-search.c b/src/fs/gnunet-fs-gtk_main-window-search.c
index fdab7b94..ff43ff62 100644
--- a/src/fs/gnunet-fs-gtk_main-window-search.c
+++ b/src/fs/gnunet-fs-gtk_main-window-search.c
@@ -34,7 +34,7 @@
34 * @param builder the main dialog builder 34 * @param builder the main dialog builder
35 */ 35 */
36static void 36static void
37start_search (GtkBuilder *builder) 37start_search (struct GNUNET_GTK_MainWindowContext *main_ctx)
38{ 38{
39 guint anonymity_level; 39 guint anonymity_level;
40 gchar *keywords; 40 gchar *keywords;
@@ -44,7 +44,7 @@ start_search (GtkBuilder *builder)
44 44
45 /* get anonymity level */ 45 /* get anonymity level */
46 if (!GNUNET_GTK_get_selected_anonymity_level 46 if (!GNUNET_GTK_get_selected_anonymity_level
47 (builder, "main_window_search_anonymity_combobox", &anonymity_level)) 47 (main_ctx->builder, "main_window_search_anonymity_combobox", &anonymity_level))
48 { 48 {
49 GNUNET_break (0); 49 GNUNET_break (0);
50 return; 50 return;
@@ -73,15 +73,10 @@ start_search (GtkBuilder *builder)
73 /* get selected namespace */ 73 /* get selected namespace */
74 { 74 {
75 GtkTreeRowReference *ref; 75 GtkTreeRowReference *ref;
76 GtkToggleButton *toggle_button;
77 GtkTreeIter iter; 76 GtkTreeIter iter;
78 77
79 nsid = NULL; 78 nsid = NULL;
80 toggle_button = 79 ref = g_object_get_data (G_OBJECT (main_ctx->ns_dropdown_button), "selected-row-reference");
81 GTK_TOGGLE_BUTTON (gtk_builder_get_object
82 (builder,
83 "main_window_search_namespace_dropdown_button"));
84 ref = g_object_get_data (G_OBJECT (toggle_button), "selected-row-reference");
85 if (NULL != ref) 80 if (NULL != ref)
86 { 81 {
87 GtkTreePath *namespace_treepath; 82 GtkTreePath *namespace_treepath;
@@ -97,12 +92,9 @@ start_search (GtkBuilder *builder)
97 92
98 /* get keywords and compose keyword string */ 93 /* get keywords and compose keyword string */
99 { 94 {
100 GtkEntry *query_entry;
101 const char *entry_keywords; 95 const char *entry_keywords;
102 96
103 query_entry = GTK_ENTRY (gtk_builder_get_object (builder, 97 entry_keywords = gtk_entry_get_text (main_ctx->search_entry);
104 "main_window_search_entry"));
105 entry_keywords = gtk_entry_get_text (query_entry);
106 if (NULL != mime_keyword) 98 if (NULL != mime_keyword)
107 { 99 {
108 keywords = g_strdup_printf ("%s +%s", 100 keywords = g_strdup_printf ("%s +%s",
@@ -156,9 +148,8 @@ void
156main_window_search_button_clicked_cb (GtkButton * button, 148main_window_search_button_clicked_cb (GtkButton * button,
157 gpointer user_data) 149 gpointer user_data)
158{ 150{
159 GtkBuilder *builder = GTK_BUILDER (user_data); 151 struct GNUNET_GTK_MainWindowContext *main_ctx = user_data;
160 152 start_search (main_ctx);
161 start_search (builder);
162} 153}
163 154
164 155
@@ -176,11 +167,11 @@ main_window_search_entry_key_press_event_cb (GtkWidget * widget,
176 GdkEventKey * event, 167 GdkEventKey * event,
177 gpointer user_data) 168 gpointer user_data)
178{ 169{
179 GtkBuilder *builder = GTK_BUILDER (user_data); 170 struct GNUNET_GTK_MainWindowContext *main_ctx = user_data;
180 171
181 if (event->keyval == GDK_KEY_Return) 172 if (event->keyval == GDK_KEY_Return)
182 { 173 {
183 start_search (builder); 174 start_search (main_ctx);
184 return TRUE; 175 return TRUE;
185 } 176 }
186 return FALSE; 177 return FALSE;
diff --git a/src/fs/gnunet-fs-gtk_namespace_manager.c b/src/fs/gnunet-fs-gtk_namespace_manager.c
index 772d3339..95763aef 100644
--- a/src/fs/gnunet-fs-gtk_namespace_manager.c
+++ b/src/fs/gnunet-fs-gtk_namespace_manager.c
@@ -47,6 +47,7 @@ struct GNUNET_GTK_NamespaceManagerContext
47 GtkWidget *details_delete_button; 47 GtkWidget *details_delete_button;
48 int sort_direction; 48 int sort_direction;
49 struct GNUNET_CONTAINER_MetaData *uneditable_md; 49 struct GNUNET_CONTAINER_MetaData *uneditable_md;
50 struct GNUNET_GTK_MainWindowContext *main_ctx;
50}; 51};
51 52
52/** 53/**
@@ -747,6 +748,7 @@ GNUNET_GTK_namespace_manager_dialog_response_cb (GtkDialog *dialog,
747 case GTK_RESPONSE_APPLY: 748 case GTK_RESPONSE_APPLY:
748 case GTK_RESPONSE_OK: 749 case GTK_RESPONSE_OK:
749 apply_known_ns_changes (ctx); 750 apply_known_ns_changes (ctx);
751 GNUNET_GTK_main_window_refresh_ns_list (ctx->main_ctx);
750 break; 752 break;
751 default: 753 default:
752 break; 754 break;
@@ -902,7 +904,8 @@ void
902GNUNET_GTK_main_menu_file_manage_pseudonyms_activate_cb (GtkMenuItem *menuitem, 904GNUNET_GTK_main_menu_file_manage_pseudonyms_activate_cb (GtkMenuItem *menuitem,
903 gpointer user_data) 905 gpointer user_data)
904{ 906{
905 struct GNUNET_GTK_NamespaceManagerContext *ctx; 907 struct GNUNET_GTK_MainWindowContext *main_ctx = user_data;
908 struct GNUNET_GTK_NamespaceManagerContext *ctx;
906 909
907 if (ns_manager != NULL) 910 if (ns_manager != NULL)
908 return; 911 return;
@@ -916,6 +919,8 @@ GNUNET_GTK_main_menu_file_manage_pseudonyms_activate_cb (GtkMenuItem *menuitem,
916 return; 919 return;
917 } 920 }
918 921
922 ctx->main_ctx = main_ctx;
923
919 /* initialize widget references */ 924 /* initialize widget references */
920 ctx->known_ns = GTK_WIDGET (gtk_builder_get_object (ctx->builder, 925 ctx->known_ns = GTK_WIDGET (gtk_builder_get_object (ctx->builder,
921 "GNUNET_GTK_namespace_manager_known_treeview")); 926 "GNUNET_GTK_namespace_manager_known_treeview"));
diff --git a/src/include/gnunet_gtk.h b/src/include/gnunet_gtk.h
index c1528759..2d53806d 100644
--- a/src/include/gnunet_gtk.h
+++ b/src/include/gnunet_gtk.h
@@ -208,6 +208,18 @@ GObject *
208GNUNET_GTK_main_loop_get_object (struct GNUNET_GTK_MainLoop *ml, 208GNUNET_GTK_main_loop_get_object (struct GNUNET_GTK_MainLoop *ml,
209 const char *name); 209 const char *name);
210 210
211/**
212 * Get the builder from the main window.
213 *
214 * @param ml handle to the main loop
215 * @return NULL on error, otherwise the builder
216 */
217GtkBuilder *
218GNUNET_GTK_main_loop_get_builder (struct GNUNET_GTK_MainLoop *ml);
219
220int
221GNUNET_GTK_main_loop_build_window (struct GNUNET_GTK_MainLoop *ml,
222 gpointer data);
211 223
212 224
213/** 225/**
diff --git a/src/lib/eventloop.c b/src/lib/eventloop.c
index 60bd1faa..aef8d966 100644
--- a/src/lib/eventloop.c
+++ b/src/lib/eventloop.c
@@ -191,6 +191,30 @@ GNUNET_GTK_main_loop_quit (struct GNUNET_GTK_MainLoop *ml)
191 } 191 }
192} 192}
193 193
194/**
195 * Get the builder from the main window.
196 *
197 * @param ml handle to the main loop
198 * @return NULL on error, otherwise the builder
199 */
200GtkBuilder *
201GNUNET_GTK_main_loop_get_builder (struct GNUNET_GTK_MainLoop *ml)
202{
203 return ml->builder;
204}
205
206int
207GNUNET_GTK_main_loop_build_window (struct GNUNET_GTK_MainLoop *ml, gpointer data)
208{
209 ml->builder = GNUNET_GTK_get_new_builder (ml->main_window_file, data);
210 if (ml->builder == NULL)
211 {
212 GNUNET_GTK_main_loop_quit (ml);
213 return GNUNET_SYSERR;
214 }
215 return GNUNET_OK;
216}
217
194 218
195/** 219/**
196 * Obtain the name of the configuration file that is being used. 220 * Obtain the name of the configuration file that is being used.
@@ -841,10 +865,6 @@ run_main_loop (void *cls, char *const *args, const char *cfgfile,
841 argc++; 865 argc++;
842 gtk_init (&argc, (char ***) &args); 866 gtk_init (&argc, (char ***) &args);
843 867
844 /* setup main context */
845 ml->builder = GNUNET_GTK_get_new_builder (ml->main_window_file, NULL);
846 if (ml->builder == NULL)
847 return;
848 ml->rs = GNUNET_NETWORK_fdset_create (); 868 ml->rs = GNUNET_NETWORK_fdset_create ();
849 ml->ws = GNUNET_NETWORK_fdset_create (); 869 ml->ws = GNUNET_NETWORK_fdset_create ();
850 ml->gml = g_main_loop_new (NULL, TRUE); 870 ml->gml = g_main_loop_new (NULL, TRUE);