aboutsummaryrefslogtreecommitdiff
path: root/src/core/eggtrayicon.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/eggtrayicon.c')
-rw-r--r--src/core/eggtrayicon.c72
1 files changed, 47 insertions, 25 deletions
diff --git a/src/core/eggtrayicon.c b/src/core/eggtrayicon.c
index f16bc9ed..d1fc2a66 100644
--- a/src/core/eggtrayicon.c
+++ b/src/core/eggtrayicon.c
@@ -102,11 +102,11 @@ guint egg_tray_icon_send_message (EggTrayIcon *icon,
102void egg_tray_icon_cancel_message (EggTrayIcon *icon, 102void egg_tray_icon_cancel_message (EggTrayIcon *icon,
103 guint id); 103 guint id);
104 104
105void initTrayIcon(); 105GtkOrientation egg_tray_icon_get_orientation (EggTrayIcon *icon);
106static gboolean tray_clicked (GtkWidget *event_box, GdkEventButton *event, gpointer data);
107 106
108 107
109GtkOrientation egg_tray_icon_get_orientation (EggTrayIcon *icon); 108static gboolean tray_clicked (GtkWidget *trayContextMenu, GdkEvent *event);
109static gboolean on_tray_quit_activate(GtkWidget *widget, GdkEvent *event, gpointer data);
110 110
111G_END_DECLS 111G_END_DECLS
112 112
@@ -589,25 +589,41 @@ egg_tray_icon_get_orientation (EggTrayIcon *icon)
589} 589}
590 590
591 591
592 592/* Callback for the "Quit" element on the tray icon menu */
593static gboolean on_tray_quit_activate(GtkWidget *widget, GdkEvent *event, gpointer data) {
594 gnunet_gtk_main_quit();
595 return TRUE;
596}
593 597
594/* Function activated when the user clicks the tray icon */ 598/* Function activated when the user clicks the tray icon */
595static gboolean tray_clicked(GtkWidget *event_box, 599static gboolean tray_clicked(GtkWidget *widget, GdkEvent *event) {
596 GdkEventButton *event, 600 if(event->type == GDK_BUTTON_PRESS) {
597 gpointer data){ 601 GdkEventButton *event_button;
598 GtkWidget *root; 602 event_button = (GdkEventButton *) event;
599 root 603 if(event_button->button == 1) {
600 = glade_xml_get_widget(getMainXML(), 604 GtkWidget *root;
601 "mainWindow"); 605 root = glade_xml_get_widget(getMainXML(),
602 GdkWindowState main_window_state; 606 "mainWindow");
603 if (gtk_window_is_active (GTK_WINDOW(root))) 607 GdkWindowState main_window_state;
604 gtk_widget_hide (root); 608 if (gtk_window_is_active (GTK_WINDOW(root)))
605 else 609 gtk_widget_hide (root);
606 gtk_window_present (GTK_WINDOW(root)); 610 else
607 main_window_state = getMainWindowState(); 611 gtk_window_present (GTK_WINDOW(root));
608 if(main_window_state & GDK_WINDOW_STATE_MAXIMIZED) 612 main_window_state = getMainWindowState();
609 gtk_window_maximize (GTK_WINDOW(root)); 613 if(main_window_state & GDK_WINDOW_STATE_MAXIMIZED)
610 return TRUE; 614 gtk_window_maximize (GTK_WINDOW(root));
615 return TRUE;
616 }
617 else if(event_button->button == 3) {
618 GtkMenu *trayContextMenu;
619 trayContextMenu = GTK_MENU (widget);
620 g_return_val_if_fail (GTK_IS_MENU (trayContextMenu), FALSE);
621 gtk_menu_popup(trayContextMenu, NULL, NULL, NULL, NULL,
622 event_button->button, event_button->time);
623 return TRUE;
624 }
625 }
626 return FALSE;
611} 627}
612 628
613/* Initiate the system tray icon */ 629/* Initiate the system tray icon */
@@ -615,19 +631,25 @@ void initTrayIcon() {
615 static EggTrayIcon *tray_icon; 631 static EggTrayIcon *tray_icon;
616 static GtkWidget *tray_icon_image; 632 static GtkWidget *tray_icon_image;
617 static GtkTooltips *tray_icon_tooltip; 633 static GtkTooltips *tray_icon_tooltip;
618 GtkWidget *eventbox; 634 GtkWidget *eventbox, *trayContextMenu, *tray_quit;
619 GdkPixbuf *pixbuf; 635 GdkPixbuf *pixbuf;
636 GladeXML *trayContextMenuXML;
637
638 trayContextMenuXML = glade_xml_new (getGladeFileName(), "trayContextMenu", PACKAGE_NAME);
639 trayContextMenu = glade_xml_get_widget (trayContextMenuXML, "trayContextMenu");
640 tray_quit = glade_xml_get_widget (trayContextMenuXML, "tray_quit");
620 641
621 tray_icon = egg_tray_icon_new ("gnunet-gtk, GNU's p2p network"); 642 tray_icon = egg_tray_icon_new (_("GNU's p2p network"));
622 pixbuf = gdk_pixbuf_new_from_file (PACKAGE_DATA_DIR"/gnunet-gtk-tray.png", NULL); 643 pixbuf = gdk_pixbuf_new_from_file (PACKAGE_DATA_DIR"/gnunet-gtk-tray.png", NULL);
623 tray_icon_image = gtk_image_new_from_pixbuf (pixbuf); 644 tray_icon_image = gtk_image_new_from_pixbuf (pixbuf);
624 eventbox = gtk_event_box_new (); 645 eventbox = gtk_event_box_new ();
625 gtk_widget_show (eventbox);
626 gtk_container_add (GTK_CONTAINER (eventbox), tray_icon_image); 646 gtk_container_add (GTK_CONTAINER (eventbox), tray_icon_image);
627 gtk_container_add (GTK_CONTAINER (tray_icon), eventbox); 647 gtk_container_add (GTK_CONTAINER (tray_icon), eventbox);
628 g_signal_connect (G_OBJECT (eventbox), "button_press_event", G_CALLBACK (tray_clicked), NULL ); 648 g_signal_connect(G_OBJECT(tray_quit), "activate", G_CALLBACK(on_tray_quit_activate), NULL);
649 g_signal_connect_swapped (G_OBJECT (eventbox), "button_press_event", G_CALLBACK (tray_clicked), trayContextMenu);
629 tray_icon_tooltip = gtk_tooltips_new (); 650 tray_icon_tooltip = gtk_tooltips_new ();
630 gtk_tooltips_set_tip (tray_icon_tooltip, GTK_WIDGET (tray_icon), "gnunet-gtk, GNU's p2p network", NULL); 651 gtk_tooltips_set_tip (tray_icon_tooltip, GTK_WIDGET (tray_icon), _("GNU's p2p network"), NULL);
652 gtk_widget_show (eventbox);
631 gtk_widget_show_all (GTK_WIDGET (tray_icon)); 653 gtk_widget_show_all (GTK_WIDGET (tray_icon));
632} 654}
633 655