diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-02-02 19:00:24 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-02-02 19:00:24 +0000 |
commit | 469b6351510e0d52be9397efc53956097585904f (patch) | |
tree | 86508068e81a5c9d1e1ab4de3ed86d31545713e4 | |
parent | 7b65369356e8b73a803be8175811ea155ad51fd2 (diff) | |
download | gnunet-gtk-469b6351510e0d52be9397efc53956097585904f.tar.gz gnunet-gtk-469b6351510e0d52be9397efc53956097585904f.zip |
-fix
-rw-r--r-- | contrib/gnunet_fs_gtk_main_window.glade | 6 | ||||
-rw-r--r-- | src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c | 133 |
2 files changed, 70 insertions, 69 deletions
diff --git a/contrib/gnunet_fs_gtk_main_window.glade b/contrib/gnunet_fs_gtk_main_window.glade index aeb95ad3..9aeab4a9 100644 --- a/contrib/gnunet_fs_gtk_main_window.glade +++ b/contrib/gnunet_fs_gtk_main_window.glade | |||
@@ -351,7 +351,7 @@ | |||
351 | <property name="use_action_appearance">False</property> | 351 | <property name="use_action_appearance">False</property> |
352 | <property name="image_position">right</property> | 352 | <property name="image_position">right</property> |
353 | <signal name="toggled" handler="GNUNET_FS_GTK_search_namespace_dropdown_button_toggled_cb" swapped="no"/> | 353 | <signal name="toggled" handler="GNUNET_FS_GTK_search_namespace_dropdown_button_toggled_cb" swapped="no"/> |
354 | <signal name="leave-notify-event" handler="GNUNET_FS_GTK_namespace_selector_window_leave_notify_event_cb" swapped="no"/> | 354 | <signal name="leave-notify-event" handler="GNUNET_FS_GTK_search_namespace_selector_window_leave_notify_event_cb" swapped="no"/> |
355 | <signal name="enter-notify-event" handler="GNUNET_FS_GTK_search_namespace_dropdown_button_enter_notify_event_cb" swapped="no"/> | 355 | <signal name="enter-notify-event" handler="GNUNET_FS_GTK_search_namespace_dropdown_button_enter_notify_event_cb" swapped="no"/> |
356 | <child> | 356 | <child> |
357 | <object class="GtkArrow" id="arrow1"> | 357 | <object class="GtkArrow" id="arrow1"> |
@@ -845,8 +845,8 @@ | |||
845 | <property name="deletable">False</property> | 845 | <property name="deletable">False</property> |
846 | <property name="transient_for">GNUNET_GTK_main_window</property> | 846 | <property name="transient_for">GNUNET_GTK_main_window</property> |
847 | <property name="mnemonics_visible">False</property> | 847 | <property name="mnemonics_visible">False</property> |
848 | <signal name="leave-notify-event" handler="namespace_selector_window_leave_notify_event_cb" swapped="no"/> | 848 | <signal name="leave-notify-event" handler="GNUNET_FS_GTK_search_namespace_selector_window_leave_notify_event_cb" swapped="no"/> |
849 | <signal name="enter-notify-event" handler="main_window_search_namespace_dropdown_button_enter_notify_event_cb" swapped="no"/> | 849 | <signal name="enter-notify-event" handler="GNUNET_FS_GTK_search_namespace_dropdown_button_enter_notify_event_cb" swapped="no"/> |
850 | <child> | 850 | <child> |
851 | <object class="GtkTreeView" id="namespace_selector_treeview"> | 851 | <object class="GtkTreeView" id="namespace_selector_treeview"> |
852 | <property name="visible">True</property> | 852 | <property name="visible">True</property> |
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 973f3889..47f48f8d 100644 --- a/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c +++ b/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c | |||
@@ -36,67 +36,6 @@ static guint namespace_selector_window_leave_timeout_source; | |||
36 | * | 36 | * |
37 | * @param user_data the builder for the main window | 37 | * @param user_data the builder for the main window |
38 | */ | 38 | */ |
39 | void | ||
40 | GNUNET_FS_GTK_search_namespace_dropdown_button_toggled_cb (GtkToggleButton * | ||
41 | togglebutton, | ||
42 | gpointer user_data) | ||
43 | { | ||
44 | GtkBuilder *builder = GTK_BUILDER (user_data); | ||
45 | gboolean active; | ||
46 | GtkWidget *namespace_selector_window; | ||
47 | GtkWidget *namespace_selector_treeview; | ||
48 | |||
49 | namespace_selector_window = | ||
50 | GTK_WIDGET (gtk_builder_get_object | ||
51 | (builder, "namespace_selector_window")); | ||
52 | namespace_selector_treeview = | ||
53 | GTK_WIDGET (gtk_builder_get_object | ||
54 | (builder, "namespace_selector_treeview")); | ||
55 | g_object_get (G_OBJECT (togglebutton), "active", &active, NULL); | ||
56 | if (active) | ||
57 | { | ||
58 | GtkAllocation togglebutton_allocation; | ||
59 | GdkWindow *main_window_gdk; | ||
60 | gint mwg_x; | ||
61 | gint mwg_y; | ||
62 | gint tgb_x; | ||
63 | gint tgb_y; | ||
64 | gint popup_x; | ||
65 | gint popup_y; | ||
66 | |||
67 | gtk_widget_get_allocation (GTK_WIDGET (togglebutton), | ||
68 | &togglebutton_allocation); | ||
69 | |||
70 | main_window_gdk = gtk_widget_get_window (GTK_WIDGET (togglebutton)); | ||
71 | |||
72 | gdk_window_get_origin (main_window_gdk, &mwg_x, &mwg_y); | ||
73 | |||
74 | /* FIXME: this might become a problem in other window managers, | ||
75 | * where reference point is not in the top-left corner. | ||
76 | * We want to show the window below the button. | ||
77 | */ | ||
78 | tgb_x = mwg_x + togglebutton_allocation.x; | ||
79 | tgb_y = mwg_y + togglebutton_allocation.y; | ||
80 | popup_x = tgb_x; | ||
81 | popup_y = tgb_y + togglebutton_allocation.height; | ||
82 | |||
83 | gtk_window_move (GTK_WINDOW (namespace_selector_window), popup_x, popup_y); | ||
84 | |||
85 | gtk_widget_show_all (namespace_selector_window); | ||
86 | gtk_widget_grab_focus (namespace_selector_treeview); | ||
87 | } | ||
88 | else | ||
89 | { | ||
90 | gtk_widget_hide (namespace_selector_window); | ||
91 | gtk_widget_grab_focus (GTK_WIDGET (togglebutton)); | ||
92 | } | ||
93 | } | ||
94 | |||
95 | |||
96 | /** | ||
97 | * | ||
98 | * @param user_data the builder for the main window | ||
99 | */ | ||
100 | gboolean | 39 | gboolean |
101 | GNUNET_FS_GTK_search_namespace_dropdown_button_enter_notify_event_cb (GtkWidget *widget, | 40 | GNUNET_FS_GTK_search_namespace_dropdown_button_enter_notify_event_cb (GtkWidget *widget, |
102 | GdkEvent *event, | 41 | GdkEvent *event, |
@@ -128,9 +67,9 @@ namespace_selector_window_leave_timeout_cb (gpointer user_data) | |||
128 | * @param user_data the builder for the main window | 67 | * @param user_data the builder for the main window |
129 | */ | 68 | */ |
130 | gboolean | 69 | gboolean |
131 | GNUNET_FS_GTK_namespace_selector_window_leave_notify_event_cb (GtkWidget * widget, | 70 | GNUNET_FS_GTK_search_namespace_selector_window_leave_notify_event_cb (GtkWidget * widget, |
132 | GdkEvent * event, | 71 | GdkEvent * event, |
133 | gpointer user_data) | 72 | gpointer user_data) |
134 | { | 73 | { |
135 | GtkBuilder *builder; | 74 | GtkBuilder *builder; |
136 | GtkToggleButton *toggle_button; | 75 | GtkToggleButton *toggle_button; |
@@ -440,6 +379,67 @@ add_namespace_to_ts (void *cls, const GNUNET_HashCode * pseudonym, | |||
440 | } | 379 | } |
441 | 380 | ||
442 | 381 | ||
382 | |||
383 | |||
384 | /** | ||
385 | * The toggle button that changes the visibility of the namespace dropdown | ||
386 | * list was toggled. | ||
387 | * | ||
388 | * @param togglebutton the button that toggles the namespace dropdown list | ||
389 | * @param user_data the builder for the main window | ||
390 | */ | ||
391 | void | ||
392 | GNUNET_FS_GTK_search_namespace_dropdown_button_toggled_cb (GtkToggleButton * | ||
393 | togglebutton, | ||
394 | gpointer user_data) | ||
395 | { | ||
396 | GtkBuilder *builder = GTK_BUILDER (user_data); | ||
397 | gboolean active; | ||
398 | GtkWidget *namespace_selector_window; | ||
399 | GtkWidget *namespace_selector_treeview; | ||
400 | GtkAllocation togglebutton_allocation; | ||
401 | GdkWindow *main_window_gdk; | ||
402 | gint mwg_x; | ||
403 | gint mwg_y; | ||
404 | gint tgb_x; | ||
405 | gint tgb_y; | ||
406 | gint popup_x; | ||
407 | gint popup_y; | ||
408 | |||
409 | namespace_selector_window = | ||
410 | GTK_WIDGET (gtk_builder_get_object | ||
411 | (builder, "namespace_selector_window")); | ||
412 | g_object_get (G_OBJECT (togglebutton), "active", &active, NULL); | ||
413 | if (! active) | ||
414 | { | ||
415 | gtk_widget_hide (namespace_selector_window); | ||
416 | gtk_widget_grab_focus (GTK_WIDGET (togglebutton)); | ||
417 | return; | ||
418 | } | ||
419 | namespace_selector_treeview = | ||
420 | GTK_WIDGET (gtk_builder_get_object | ||
421 | (builder, "namespace_selector_treeview")); | ||
422 | gtk_widget_get_allocation (GTK_WIDGET (togglebutton), | ||
423 | &togglebutton_allocation); | ||
424 | main_window_gdk = gtk_widget_get_window (GTK_WIDGET (togglebutton)); | ||
425 | gdk_window_get_origin (main_window_gdk, &mwg_x, &mwg_y); | ||
426 | |||
427 | /* FIXME: this might become a problem in other window managers, | ||
428 | * where reference point is not in the top-left corner. | ||
429 | * We want to show the window below the button. | ||
430 | */ | ||
431 | tgb_x = mwg_x + togglebutton_allocation.x; | ||
432 | tgb_y = mwg_y + togglebutton_allocation.y; | ||
433 | popup_x = tgb_x; | ||
434 | popup_y = tgb_y + togglebutton_allocation.height; | ||
435 | |||
436 | gtk_window_move (GTK_WINDOW (namespace_selector_window), popup_x, popup_y); | ||
437 | |||
438 | gtk_widget_show_all (namespace_selector_window); | ||
439 | gtk_widget_grab_focus (namespace_selector_treeview); | ||
440 | } | ||
441 | |||
442 | |||
443 | /** | 443 | /** |
444 | * Startup hook to initialize the namespace dropdown widget. | 444 | * Startup hook to initialize the namespace dropdown widget. |
445 | * | 445 | * |
@@ -481,14 +481,14 @@ GNUNET_GTK_main_window_realize_cb (GtkWidget * widget, gpointer user_data) | |||
481 | 0, "Any", 1, NULL, 2, "", 3, | 481 | 0, "Any", 1, NULL, 2, "", 3, |
482 | "Do not search in any particular namespace", | 482 | "Do not search in any particular namespace", |
483 | -1); | 483 | -1); |
484 | /* FIXME: when do we unregister? */ | 484 | /* FIXME-BUG: when do we unregister? */ |
485 | GNUNET_PSEUDONYM_discovery_callback_register (GNUNET_FS_GTK_get_configuration (), | 485 | GNUNET_PSEUDONYM_discovery_callback_register (GNUNET_FS_GTK_get_configuration (), |
486 | &add_namespace_to_ts, | 486 | &add_namespace_to_ts, |
487 | namespace_treestore); | 487 | namespace_treestore); |
488 | } | 488 | } |
489 | 489 | ||
490 | /* select the first item and update the label */ | 490 | /* select the first item and update the label */ |
491 | /* FIXME: is this even necessary? If the first item is "Any", we can | 491 | /* FIXME-STYLE: is this even necessary? If the first item is "Any", we can |
492 | just have the label have the right default, or not? */ | 492 | just have the label have the right default, or not? */ |
493 | if (gtk_tree_model_get_iter_first | 493 | if (gtk_tree_model_get_iter_first |
494 | (GTK_TREE_MODEL (namespace_treestore), &iter)) | 494 | (GTK_TREE_MODEL (namespace_treestore), &iter)) |
@@ -512,6 +512,7 @@ GNUNET_GTK_main_window_realize_cb (GtkWidget * widget, gpointer user_data) | |||
512 | } | 512 | } |
513 | 513 | ||
514 | /* show the window (to trigger certain events) and immediately hide it */ | 514 | /* show the window (to trigger certain events) and immediately hide it */ |
515 | /* FIXME: yuck, can't we trigger these events by other means? */ | ||
515 | { | 516 | { |
516 | GtkWidget *namespace_selector_window; | 517 | GtkWidget *namespace_selector_window; |
517 | 518 | ||