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.c68
1 files changed, 63 insertions, 5 deletions
diff --git a/src/core/eggtrayicon.c b/src/core/eggtrayicon.c
index 71ccdaa8..cc0fbc85 100644
--- a/src/core/eggtrayicon.c
+++ b/src/core/eggtrayicon.c
@@ -46,11 +46,11 @@
46 46
47#include "platform.h" 47#include "platform.h"
48#include "gnunetgtk_common.h" 48#include "gnunetgtk_common.h"
49#include "eggtrayicon.h" 49#include <gtk/gtkversion.h>
50
51 50
51#if !GTK_CHECK_VERSION (2,10,0) && !defined(WINDOWS)
52#include "eggtrayicon.h"
52#include <gtk/gtkplug.h> 53#include <gtk/gtkplug.h>
53#include <gtk/gtkversion.h>
54#include <gdk/gdkx.h> 54#include <gdk/gdkx.h>
55#include <X11/Xatom.h> 55#include <X11/Xatom.h>
56 56
@@ -586,6 +586,7 @@ egg_tray_icon_get_orientation (EggTrayIcon * icon)
586 586
587 return icon->orientation; 587 return icon->orientation;
588} 588}
589#endif /* !GTK_CHECK_VERSION (2,10,0) && !defined(WINDOWS) */
589 590
590 591
591/* Callback for the "Quit" element on the tray icon menu */ 592/* Callback for the "Quit" element on the tray icon menu */
@@ -600,6 +601,21 @@ on_tray_quit_activate (GtkWidget * widget, GdkEvent * event, gpointer data)
600static gboolean 601static gboolean
601tray_clicked (GtkWidget * widget, GdkEvent * event) 602tray_clicked (GtkWidget * widget, GdkEvent * event)
602{ 603{
604#if GTK_CHECK_VERSION(2,10,0)
605 GtkWidget *root;
606 root =
607 glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
608 "mainWindow");
609 GdkWindowState main_window_state;
610 if (gtk_window_is_active (GTK_WINDOW (root)))
611 gtk_widget_hide (root);
612 else
613 gtk_window_present (GTK_WINDOW (root));
614 main_window_state = GNUNET_GTK_get_main_window_state ();
615 if (main_window_state & GDK_WINDOW_STATE_MAXIMIZED)
616 gtk_window_maximize (GTK_WINDOW (root));
617 return TRUE;
618#elif !defined (WINDOWS)
603 if (event->type == GDK_BUTTON_PRESS) 619 if (event->type == GDK_BUTTON_PRESS)
604 { 620 {
605 GdkEventButton *event_button; 621 GdkEventButton *event_button;
@@ -631,12 +647,53 @@ tray_clicked (GtkWidget * widget, GdkEvent * event)
631 } 647 }
632 } 648 }
633 return FALSE; 649 return FALSE;
650#endif
634} 651}
635 652
653#if GTK_CHECK_VERSION(2,10,0)
654/* Function activated when the user tries to popup the menu */
655static gboolean
656on_tray_popup_menu (GtkStatusIcon *status_icon, guint button,
657 guint activate_time, gpointer trayContextMenu)
658{
659 gtk_menu_popup (GTK_MENU(trayContextMenu), NULL, NULL, NULL, NULL,
660 button, activate_time);
661 return TRUE;
662}
663#endif
664
636/* Initiate the system tray icon */ 665/* Initiate the system tray icon */
637void 666void
638initTrayIcon () 667initTrayIcon ()
639{ 668{
669#if GTK_CHECK_VERSION (2,10,0)
670 char *instDir;
671 char *iconPath;
672 GtkStatusIcon *trayIcon;
673 GtkWidget *trayContextMenu;
674 GladeXML *trayContextMenuXML;
675 GtkWidget *tray_quit;
676
677 trayContextMenuXML =
678 glade_xml_new (GNUNET_GTK_get_glade_filename (), "trayContextMenu",
679 PACKAGE_NAME);
680 trayContextMenu = glade_xml_get_widget (trayContextMenuXML,
681 "trayContextMenu");
682 trayIcon = GNUNET_GTK_get_trayIcon ();
683 instDir = GNUNET_get_installation_path (GNUNET_IPK_DATADIR);
684 iconPath = g_strconcat (instDir, "/../gnunet-gtk/gnunet-gtk-tray.png", NULL);
685 GNUNET_free (instDir);
686 gtk_status_icon_set_from_file (trayIcon, iconPath);
687 g_free (iconPath);
688 gtk_status_icon_set_tooltip (trayIcon, _("GNU's peer-to-peer network"));
689 tray_quit = glade_xml_get_widget (trayContextMenuXML, "tray_quit");
690 g_signal_connect_swapped (G_OBJECT (tray_quit), "activate",
691 G_CALLBACK (on_tray_quit_activate), trayContextMenu);
692 g_signal_connect_swapped (G_OBJECT (trayIcon), "activate",
693 G_CALLBACK (tray_clicked), trayContextMenu);
694 g_signal_connect (G_OBJECT (trayIcon), "popup-menu",
695 G_CALLBACK (on_tray_popup_menu), trayContextMenu);
696#elif !defined(WINDOWS)
640 static EggTrayIcon *tray_icon; 697 static EggTrayIcon *tray_icon;
641 static GtkWidget *tray_icon_image; 698 static GtkWidget *tray_icon_image;
642 static GtkTooltips *tray_icon_tooltip; 699 static GtkTooltips *tray_icon_tooltip;
@@ -653,7 +710,7 @@ initTrayIcon ()
653 glade_xml_get_widget (trayContextMenuXML, "trayContextMenu"); 710 glade_xml_get_widget (trayContextMenuXML, "trayContextMenu");
654 tray_quit = glade_xml_get_widget (trayContextMenuXML, "tray_quit"); 711 tray_quit = glade_xml_get_widget (trayContextMenuXML, "tray_quit");
655 712
656 tray_icon = egg_tray_icon_new (_("GNU's p2p network")); 713 tray_icon = egg_tray_icon_new (_("GNU's peer-to-peer network"));
657 instDir = GNUNET_get_installation_path (GNUNET_IPK_DATADIR); 714 instDir = GNUNET_get_installation_path (GNUNET_IPK_DATADIR);
658 iconPath = GNUNET_malloc (strlen (instDir) + 40); 715 iconPath = GNUNET_malloc (strlen (instDir) + 40);
659 strcpy (iconPath, instDir); 716 strcpy (iconPath, instDir);
@@ -671,7 +728,8 @@ initTrayIcon ()
671 G_CALLBACK (tray_clicked), trayContextMenu); 728 G_CALLBACK (tray_clicked), trayContextMenu);
672 tray_icon_tooltip = gtk_tooltips_new (); 729 tray_icon_tooltip = gtk_tooltips_new ();
673 gtk_tooltips_set_tip (tray_icon_tooltip, GTK_WIDGET (tray_icon), 730 gtk_tooltips_set_tip (tray_icon_tooltip, GTK_WIDGET (tray_icon),
674 _("GNU's p2p network"), NULL); 731 _("GNU's peer-to-peer network"), NULL);
675 gtk_widget_show (eventbox); 732 gtk_widget_show (eventbox);
676 gtk_widget_show_all (GTK_WIDGET (tray_icon)); 733 gtk_widget_show_all (GTK_WIDGET (tray_icon));
734#endif
677} 735}