aboutsummaryrefslogtreecommitdiff
path: root/src/lib/trayicon.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/trayicon.c')
-rw-r--r--src/lib/trayicon.c69
1 files changed, 31 insertions, 38 deletions
diff --git a/src/lib/trayicon.c b/src/lib/trayicon.c
index 200c9068..899f6db0 100644
--- a/src/lib/trayicon.c
+++ b/src/lib/trayicon.c
@@ -42,9 +42,8 @@ static GtkWindow *main_window;
42 * We got a click on our tray icon. Toggle visibility of the main 42 * We got a click on our tray icon. Toggle visibility of the main
43 * window. 43 * window.
44 */ 44 */
45static void 45static void
46tray_icon_on_click(GtkStatusIcon *status_icon, 46tray_icon_on_click (GtkStatusIcon * status_icon, gpointer user_data)
47 gpointer user_data)
48{ 47{
49 if (gtk_window_is_active (main_window)) 48 if (gtk_window_is_active (main_window))
50 gtk_widget_hide (GTK_WIDGET (main_window)); 49 gtk_widget_hide (GTK_WIDGET (main_window));
@@ -57,28 +56,27 @@ tray_icon_on_click(GtkStatusIcon *status_icon,
57 * We got a right-click on the tray icon. Display the context 56 * We got a right-click on the tray icon. Display the context
58 * menu (which should have a 'quit' button). 57 * menu (which should have a 'quit' button).
59 */ 58 */
60static int 59static int
61tray_icon_on_menu(GtkWidget *widget, 60tray_icon_on_menu (GtkWidget * widget, GdkEvent * event, gpointer user_data)
62 GdkEvent *event,
63 gpointer user_data)
64{ 61{
65 GtkMenu *tray_menu; 62 GtkMenu *tray_menu;
66 GdkEventButton *event_button; 63 GdkEventButton *event_button;
67 GtkBuilder *builder; 64 GtkBuilder *builder;
68 65
69 if (event->type == GDK_BUTTON_PRESS) 66 if (event->type == GDK_BUTTON_PRESS)
67 {
68 event_button = (GdkEventButton *) event;
69 if (event_button->button == 3)
70 { 70 {
71 event_button = (GdkEventButton *) event; 71 builder = GNUNET_GTK_get_new_builder ("gnunet_gtk_status_bar_menu.glade");
72 if (event_button->button == 3) 72 tray_menu =
73 { 73 GTK_MENU (gtk_builder_get_object
74 builder = GNUNET_GTK_get_new_builder ("gnunet_gtk_status_bar_menu.glade"); 74 (builder, "GNUNET_GTK_status_bar_popup_menu"));
75 tray_menu = GTK_MENU (gtk_builder_get_object (builder, 75 gtk_menu_popup (tray_menu, NULL, NULL, NULL, NULL, event_button->button,
76 "GNUNET_GTK_status_bar_popup_menu")); 76 event_button->time);
77 gtk_menu_popup (tray_menu, NULL, NULL, NULL, NULL, 77 g_object_unref (builder);
78 event_button->button, event_button->time);
79 g_object_unref (builder);
80 }
81 } 78 }
79 }
82 return FALSE; 80 return FALSE;
83} 81}
84 82
@@ -91,35 +89,30 @@ tray_icon_on_menu(GtkWidget *widget,
91 * @param tooltip tooltip for the tray icon 89 * @param tooltip tooltip for the tray icon
92 */ 90 */
93void 91void
94GNUNET_GTK_tray_icon_create (GtkWindow *main, 92GNUNET_GTK_tray_icon_create (GtkWindow * main, const char *icon_name,
95 const char *icon_name, 93 const char *tooltip)
96 const char *tooltip)
97{ 94{
98 if (NULL != tray_icon) 95 if (NULL != tray_icon)
99 { 96 {
100 GNUNET_break (0); 97 GNUNET_break (0);
101 return; 98 return;
102 } 99 }
103 main_window = main; 100 main_window = main;
104 tray_icon = gtk_status_icon_new(); 101 tray_icon = gtk_status_icon_new ();
105 g_signal_connect(G_OBJECT(tray_icon), "activate", 102 g_signal_connect (G_OBJECT (tray_icon), "activate",
106 G_CALLBACK(tray_icon_on_click), NULL); 103 G_CALLBACK (tray_icon_on_click), NULL);
107 g_signal_connect (G_OBJECT(tray_icon), 104 g_signal_connect (G_OBJECT (tray_icon), "button_press_event",
108 "button_press_event", 105 G_CALLBACK (tray_icon_on_menu), tray_icon);
109 G_CALLBACK(tray_icon_on_menu), 106 gtk_status_icon_set_from_icon_name (tray_icon, icon_name);
110 tray_icon); 107 gtk_status_icon_set_tooltip (tray_icon, tooltip);
111 gtk_status_icon_set_from_icon_name (tray_icon, 108 gtk_status_icon_set_visible (tray_icon, TRUE);
112 icon_name);
113 gtk_status_icon_set_tooltip(tray_icon,
114 tooltip);
115 gtk_status_icon_set_visible(tray_icon, TRUE);
116} 109}
117 110
118 111
119/** 112/**
120 * Destroy the tray icon. 113 * Destroy the tray icon.
121 */ 114 */
122void 115void
123GNUNET_GTK_tray_icon_destroy () 116GNUNET_GTK_tray_icon_destroy ()
124{ 117{
125 if (tray_icon == NULL) 118 if (tray_icon == NULL)