diff options
author | hark <hark@puscii.nl> | 2014-01-30 21:09:48 +0000 |
---|---|---|
committer | hark <hark@puscii.nl> | 2014-01-30 21:09:48 +0000 |
commit | 4847e8ae6e1b024850185af252f2d3d892cc1190 (patch) | |
tree | 362bb727f77fd48e35ff05427d62bc2f5fd84179 | |
parent | c550669862607e6f764f6579f0154fe472255990 (diff) | |
download | gnunet-gtk-4847e8ae6e1b024850185af252f2d3d892cc1190.tar.gz gnunet-gtk-4847e8ae6e1b024850185af252f2d3d892cc1190.zip |
added GNUNET_GTK_tray_icon_change
-rw-r--r-- | src/include/gnunet_gtk.h | 56 | ||||
-rw-r--r-- | src/lib/trayicon.c | 37 |
2 files changed, 60 insertions, 33 deletions
diff --git a/src/include/gnunet_gtk.h b/src/include/gnunet_gtk.h index ec500705..4603343a 100644 --- a/src/include/gnunet_gtk.h +++ b/src/include/gnunet_gtk.h | |||
@@ -64,8 +64,7 @@ struct GNUNET_GTK_MainLoop; | |||
64 | * @return new main window to initialize | 64 | * @return new main window to initialize |
65 | */ | 65 | */ |
66 | GtkWidget * | 66 | GtkWidget * |
67 | GNUNET_GTK_plug_me (const char *env_name, | 67 | GNUNET_GTK_plug_me (const char *env_name, GtkWidget * main_window); |
68 | GtkWidget *main_window); | ||
69 | 68 | ||
70 | 69 | ||
71 | /** | 70 | /** |
@@ -117,8 +116,7 @@ GNUNET_GTK_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind); | |||
117 | * @return NULL on error | 116 | * @return NULL on error |
118 | */ | 117 | */ |
119 | GtkBuilder * | 118 | GtkBuilder * |
120 | GNUNET_GTK_get_new_builder2 (const char *filename, | 119 | GNUNET_GTK_get_new_builder2 (const char *filename, void *user_data, |
121 | void *user_data, | ||
122 | GtkBuilderConnectFunc cb); | 120 | GtkBuilderConnectFunc cb); |
123 | 121 | ||
124 | 122 | ||
@@ -156,8 +154,7 @@ GNUNET_GTK_display_about (const char *dialogfile); | |||
156 | * @return TRUE on success, FALSE on errors | 154 | * @return TRUE on success, FALSE on errors |
157 | */ | 155 | */ |
158 | gboolean | 156 | gboolean |
159 | GNUNET_GTK_get_tree_string (GtkTreeView *treeview, | 157 | GNUNET_GTK_get_tree_string (GtkTreeView * treeview, GtkTreePath * treepath, |
160 | GtkTreePath *treepath, | ||
161 | guint column, gchar ** value); | 158 | guint column, gchar ** value); |
162 | 159 | ||
163 | 160 | ||
@@ -170,9 +167,19 @@ GNUNET_GTK_get_tree_string (GtkTreeView *treeview, | |||
170 | * @param tooltip tooltip for the tray icon | 167 | * @param tooltip tooltip for the tray icon |
171 | */ | 168 | */ |
172 | void | 169 | void |
173 | GNUNET_GTK_tray_icon_create (struct GNUNET_GTK_MainLoop *ml, | 170 | GNUNET_GTK_tray_icon_create (struct GNUNET_GTK_MainLoop *ml, GtkWindow * main, |
174 | GtkWindow * main, const char *icon_name, | 171 | const char *icon_name, const char *tooltip); |
175 | const char *tooltip); | 172 | |
173 | /** | ||
174 | * Change our tray icon. | ||
175 | * | ||
176 | * @param ml main loop | ||
177 | * @param main handle to the main window (show or hide) | ||
178 | * @param icon_name name of the tray icon file | ||
179 | * @param tooltip tooltip for the tray icon | ||
180 | */ | ||
181 | void | ||
182 | GNUNET_GTK_tray_icon_change (const char *icon_name, const char *tooltip); | ||
176 | 183 | ||
177 | 184 | ||
178 | /** | 185 | /** |
@@ -189,7 +196,7 @@ GNUNET_GTK_tray_icon_destroy (void); | |||
189 | * @return string in UTF-8, NULL if str_loc was NULL | 196 | * @return string in UTF-8, NULL if str_loc was NULL |
190 | */ | 197 | */ |
191 | char * | 198 | char * |
192 | GNUNET_GTK_from_loc_to_utf8 (const char * str_loc); | 199 | GNUNET_GTK_from_loc_to_utf8 (const char *str_loc); |
193 | 200 | ||
194 | 201 | ||
195 | /** | 202 | /** |
@@ -209,8 +216,7 @@ GNUNET_GTK_filechooser_get_filename_utf8 (GtkFileChooser * fc); | |||
209 | * @param root root of the subtree to remove | 216 | * @param root root of the subtree to remove |
210 | */ | 217 | */ |
211 | void | 218 | void |
212 | GNUNET_FS_GTK_remove_treestore_subtree (GtkTreeStore * ts, | 219 | GNUNET_FS_GTK_remove_treestore_subtree (GtkTreeStore * ts, GtkTreeIter * root); |
213 | GtkTreeIter * root); | ||
214 | 220 | ||
215 | 221 | ||
216 | /* ******************* main loop ***************** */ | 222 | /* ******************* main loop ***************** */ |
@@ -266,9 +272,8 @@ GNUNET_GTK_main_loop_get_builder (struct GNUNET_GTK_MainLoop *ml); | |||
266 | * @param argv set to argument vector | 272 | * @param argv set to argument vector |
267 | */ | 273 | */ |
268 | void | 274 | void |
269 | GNUNET_GTK_main_loop_get_args (struct GNUNET_GTK_MainLoop * ml, | 275 | GNUNET_GTK_main_loop_get_args (struct GNUNET_GTK_MainLoop *ml, int *argc, |
270 | int *argc, | 276 | char *const **argv); |
271 | char *const**argv); | ||
272 | 277 | ||
273 | 278 | ||
274 | /** | 279 | /** |
@@ -376,8 +381,8 @@ GNUNET_GTK_animation_context_get_pixbuf (struct GNUNET_FS_AnimationContext *ac); | |||
376 | * @return handle to unregister the tree view later | 381 | * @return handle to unregister the tree view later |
377 | */ | 382 | */ |
378 | struct GNUNET_FS_AnimationTreeViewHandle * | 383 | struct GNUNET_FS_AnimationTreeViewHandle * |
379 | GNUNET_GTK_animation_tree_view_register (GtkTreeView *tv, | 384 | GNUNET_GTK_animation_tree_view_register (GtkTreeView * tv, |
380 | GtkTreeViewColumn *image_col); | 385 | GtkTreeViewColumn * image_col); |
381 | 386 | ||
382 | 387 | ||
383 | /** | 388 | /** |
@@ -386,7 +391,9 @@ GNUNET_GTK_animation_tree_view_register (GtkTreeView *tv, | |||
386 | * @param atv tree view to unregister | 391 | * @param atv tree view to unregister |
387 | */ | 392 | */ |
388 | void | 393 | void |
389 | GNUNET_GTK_animation_tree_view_unregister (struct GNUNET_FS_AnimationTreeViewHandle *atv); | 394 | GNUNET_GTK_animation_tree_view_unregister (struct |
395 | GNUNET_FS_AnimationTreeViewHandle | ||
396 | *atv); | ||
390 | 397 | ||
391 | 398 | ||
392 | /* ********************* generic helpers ******************* */ | 399 | /* ********************* generic helpers ******************* */ |
@@ -396,22 +403,22 @@ GNUNET_GTK_animation_tree_view_unregister (struct GNUNET_FS_AnimationTreeViewHan | |||
396 | * Columns in the anonymity level model. | 403 | * Columns in the anonymity level model. |
397 | */ | 404 | */ |
398 | enum GNUNET_GTK_FS_MAIN_WINDOW_AnonymityLevelModelColumns | 405 | enum GNUNET_GTK_FS_MAIN_WINDOW_AnonymityLevelModelColumns |
399 | { | 406 | { |
400 | /** | 407 | /** |
401 | * A gchararray. | 408 | * A gchararray. |
402 | */ | 409 | */ |
403 | GNUNET_GTK_ANONYMITY_LEVEL_MC_NAME = 0, | 410 | GNUNET_GTK_ANONYMITY_LEVEL_MC_NAME = 0, |
404 | 411 | ||
405 | /** | 412 | /** |
406 | * A guint. | 413 | * A guint. |
407 | */ | 414 | */ |
408 | GNUNET_GTK_ANONYMITY_LEVEL_MC_LEVEL = 1, | 415 | GNUNET_GTK_ANONYMITY_LEVEL_MC_LEVEL = 1, |
409 | 416 | ||
410 | /** | 417 | /** |
411 | * A gchararray. | 418 | * A gchararray. |
412 | */ | 419 | */ |
413 | GNUNET_GTK_ANONYMITY_LEVEL_MC_COLOR = 2 | 420 | GNUNET_GTK_ANONYMITY_LEVEL_MC_COLOR = 2 |
414 | }; | 421 | }; |
415 | 422 | ||
416 | 423 | ||
417 | /** | 424 | /** |
@@ -459,7 +466,8 @@ GNUNET_GTK_get_selected_anonymity_level (GtkBuilder * builder, | |||
459 | * @return TRUE on success, FALSE on failure | 466 | * @return TRUE on success, FALSE on failure |
460 | */ | 467 | */ |
461 | gboolean | 468 | gboolean |
462 | GNUNET_GTK_get_selected_anonymity_combo_level (GtkComboBox *combo, guint *p_level); | 469 | GNUNET_GTK_get_selected_anonymity_combo_level (GtkComboBox * combo, |
470 | guint * p_level); | ||
463 | 471 | ||
464 | 472 | ||
465 | #endif | 473 | #endif |
diff --git a/src/lib/trayicon.c b/src/lib/trayicon.c index d25b9d77..cf755b43 100644 --- a/src/lib/trayicon.c +++ b/src/lib/trayicon.c | |||
@@ -47,9 +47,7 @@ tray_icon_on_click (GtkStatusIcon * status_icon, gpointer user_data) | |||
47 | { | 47 | { |
48 | gboolean tlf; | 48 | gboolean tlf; |
49 | 49 | ||
50 | g_object_get (main_window, | 50 | g_object_get (main_window, "visible", &tlf, NULL); |
51 | "visible", &tlf, | ||
52 | NULL); | ||
53 | if (tlf) | 51 | if (tlf) |
54 | { | 52 | { |
55 | gtk_widget_hide (GTK_WIDGET (main_window)); | 53 | gtk_widget_hide (GTK_WIDGET (main_window)); |
@@ -71,8 +69,7 @@ tray_icon_on_click (GtkStatusIcon * status_icon, gpointer user_data) | |||
71 | * @param user_data the main loop context | 69 | * @param user_data the main loop context |
72 | */ | 70 | */ |
73 | void | 71 | void |
74 | GNUNET_GTK_tray_icon_quit (GtkMenuItem *menuitem, | 72 | GNUNET_GTK_tray_icon_quit (GtkMenuItem * menuitem, gpointer user_data) |
75 | gpointer user_data) | ||
76 | { | 73 | { |
77 | /* struct GNUNET_GTK_MainLoop *ml = user_data; */ | 74 | /* struct GNUNET_GTK_MainLoop *ml = user_data; */ |
78 | GNUNET_SCHEDULER_shutdown (); | 75 | GNUNET_SCHEDULER_shutdown (); |
@@ -96,7 +93,8 @@ tray_icon_on_menu (GtkWidget * widget, GdkEvent * event, gpointer user_data) | |||
96 | event_button = (GdkEventButton *) event; | 93 | event_button = (GdkEventButton *) event; |
97 | if (event_button->button == 3) | 94 | if (event_button->button == 3) |
98 | { | 95 | { |
99 | builder = GNUNET_GTK_get_new_builder ("gnunet_gtk_status_bar_menu.glade", ml); | 96 | builder = |
97 | GNUNET_GTK_get_new_builder ("gnunet_gtk_status_bar_menu.glade", ml); | ||
100 | tray_menu = | 98 | tray_menu = |
101 | GTK_MENU (gtk_builder_get_object | 99 | GTK_MENU (gtk_builder_get_object |
102 | (builder, "GNUNET_GTK_status_bar_popup_menu")); | 100 | (builder, "GNUNET_GTK_status_bar_popup_menu")); |
@@ -119,9 +117,8 @@ tray_icon_on_menu (GtkWidget * widget, GdkEvent * event, gpointer user_data) | |||
119 | * @param tooltip tooltip for the tray icon | 117 | * @param tooltip tooltip for the tray icon |
120 | */ | 118 | */ |
121 | void | 119 | void |
122 | GNUNET_GTK_tray_icon_create (struct GNUNET_GTK_MainLoop *ml, | 120 | GNUNET_GTK_tray_icon_create (struct GNUNET_GTK_MainLoop *ml, GtkWindow * main, |
123 | GtkWindow * main, const char *icon_name, | 121 | const char *icon_name, const char *tooltip) |
124 | const char *tooltip) | ||
125 | { | 122 | { |
126 | if (NULL != tray_icon) | 123 | if (NULL != tray_icon) |
127 | { | 124 | { |
@@ -139,6 +136,28 @@ GNUNET_GTK_tray_icon_create (struct GNUNET_GTK_MainLoop *ml, | |||
139 | gtk_status_icon_set_visible (tray_icon, TRUE); | 136 | gtk_status_icon_set_visible (tray_icon, TRUE); |
140 | } | 137 | } |
141 | 138 | ||
139 | /** | ||
140 | * Change our tray icon. | ||
141 | * | ||
142 | * @param ml main loop | ||
143 | * @param main handle to the main window (show or hide) | ||
144 | * @param icon_name name of the tray icon file | ||
145 | * @param tooltip tooltip for the tray icon | ||
146 | */ | ||
147 | void | ||
148 | GNUNET_GTK_tray_icon_change (const char *icon_name, const char *tooltip) | ||
149 | { | ||
150 | if (NULL == tray_icon) | ||
151 | { | ||
152 | GNUNET_break (0); | ||
153 | return; | ||
154 | } | ||
155 | gtk_status_icon_set_from_icon_name (tray_icon, icon_name); | ||
156 | gtk_status_icon_set_tooltip_text (tray_icon, tooltip); | ||
157 | gtk_status_icon_set_visible (tray_icon, TRUE); | ||
158 | } | ||
159 | |||
160 | |||
142 | 161 | ||
143 | /** | 162 | /** |
144 | * Destroy the tray icon. | 163 | * Destroy the tray icon. |