[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r16544 - in gnunet-gtk/src: include lib
From: |
gnunet |
Subject: |
[GNUnet-SVN] r16544 - in gnunet-gtk/src: include lib |
Date: |
Mon, 15 Aug 2011 16:12:01 +0200 |
Author: grothoff
Date: 2011-08-15 16:12:01 +0200 (Mon, 15 Aug 2011)
New Revision: 16544
Added:
gnunet-gtk/src/lib/trayicon.c
Modified:
gnunet-gtk/src/include/gnunet_gtk.h
gnunet-gtk/src/lib/Makefile.am
gnunet-gtk/src/lib/glade.c
Log:
trayicon
Modified: gnunet-gtk/src/include/gnunet_gtk.h
===================================================================
--- gnunet-gtk/src/include/gnunet_gtk.h 2011-08-15 14:11:40 UTC (rev 16543)
+++ gnunet-gtk/src/include/gnunet_gtk.h 2011-08-15 14:12:01 UTC (rev 16544)
@@ -40,6 +40,7 @@
#include <gladeui/glade.h>
#include <gtk/gtk.h>
+/* ****************** Initialization *************** */
/**
* Initialize natural language support.
@@ -49,6 +50,13 @@
/**
+ * Initialize GTK search path for icons.
+ */
+void
+GNUNET_GTK_set_icon_search_path ();
+
+
+/**
* Get the name of the directory where all of our package
* data is stored ($PREFIX/share/)
*
@@ -68,6 +76,8 @@
GNUNET_GTK_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind);
+/* **************** Glade/Gtk helpers *************** */
+
/**
* Create an initialize a new builder based on the GNUnet-GTK glade
* file.
@@ -90,7 +100,30 @@
const char *dialogname);
+
/**
+ * Create our tray icon.
+ *
+ * @param main handle to the main window (show or hide)
+ * @param icon_name name of the tray icon file
+ * @param tooltip tooltip for the tray icon
+ */
+void
+GNUNET_GTK_tray_icon_create (GtkWindow *main,
+ const char *icon_name,
+ const char *tooltip);
+
+
+/**
+ * Destroy the tray icon.
+ */
+void
+GNUNET_GTK_tray_icon_destroy (void);
+
+
+/* ******************* main loop ***************** */
+
+/**
* Handle for our main loop.
*/
struct GNUNET_GTK_MainLoop;
@@ -117,7 +150,6 @@
const char *main_window_file,
GNUNET_SCHEDULER_Task main_task);
-
/**
* Get an object from the main window.
*
@@ -130,6 +162,7 @@
const char *name);
+
/**
* Get the configuration.
*
Modified: gnunet-gtk/src/lib/Makefile.am
===================================================================
--- gnunet-gtk/src/lib/Makefile.am 2011-08-15 14:11:40 UTC (rev 16543)
+++ gnunet-gtk/src/lib/Makefile.am 2011-08-15 14:12:01 UTC (rev 16544)
@@ -12,11 +12,12 @@
lib_LTLIBRARIES = libgnunetgtk.la
libgnunetgtk_la_SOURCES = \
+ about.c \
eventloop.c \
glade.c \
+ nls.c \
os_installation.c \
- nls.c \
- about.c
+ trayicon.c
libgnunetgtk_la_LIBADD = \
-lgnunetutil $(XLIB)
Modified: gnunet-gtk/src/lib/glade.c
===================================================================
--- gnunet-gtk/src/lib/glade.c 2011-08-15 14:11:40 UTC (rev 16543)
+++ gnunet-gtk/src/lib/glade.c 2011-08-15 14:12:01 UTC (rev 16544)
@@ -28,6 +28,20 @@
/**
+ * Initialize GTK search path for icons.
+ */
+void
+GNUNET_GTK_set_icon_search_path ()
+{
+ char *buf;
+
+ buf = GNUNET_GTK_installation_get_path (GNUNET_OS_IPK_ICONDIR);
+ gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), buf);
+ GNUNET_free (buf);
+}
+
+
+/**
* Get the name of the directory where all of our package
* data is stored ($PREFIX/share/)
*
Added: gnunet-gtk/src/lib/trayicon.c
===================================================================
--- gnunet-gtk/src/lib/trayicon.c (rev 0)
+++ gnunet-gtk/src/lib/trayicon.c 2011-08-15 14:12:01 UTC (rev 16544)
@@ -0,0 +1,132 @@
+/*
+ This file is part of GNUnet.
+ (C) 2010, 2011 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file src/lib/trayicon.c
+ * @brief trayicon support
+ * @author Christian Grothoff
+ */
+#include "gnunet_gtk_config.h"
+#include "gnunet_gtk.h"
+
+
+/**
+ * Our tray icon.
+ */
+static GtkStatusIcon *tray_icon;
+
+/**
+ * The main window.
+ */
+static GtkWindow *main_window;
+
+
+/**
+ * We got a click on our tray icon. Toggle visibility of the main
+ * window.
+ */
+static void
+tray_icon_on_click(GtkStatusIcon *status_icon,
+ gpointer user_data)
+{
+ if (gtk_window_is_active (main_window))
+ gtk_widget_hide (GTK_WIDGET (main_window));
+ else
+ gtk_window_present (main_window);
+}
+
+
+/**
+ * We got a right-click on the tray icon. Display the context
+ * menu (which should have a 'quit' button).
+ */
+static int
+tray_icon_on_menu(GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ GtkMenu *tray_menu;
+ GdkEventButton *event_button;
+ GtkBuilder *builder;
+
+ if (event->type == GDK_BUTTON_PRESS)
+ {
+ event_button = (GdkEventButton *) event;
+ if (event_button->button == 3)
+ {
+ builder = GNUNET_GTK_get_new_builder
("gnunet_gtk_status_bar_menu.glade");
+ tray_menu = GTK_MENU (gtk_builder_get_object (builder,
+
"GNUNET_GTK_status_bar_popup_menu"));
+ gtk_menu_popup (tray_menu, NULL, NULL, NULL, NULL,
+ event_button->button, event_button->time);
+ g_object_unref (builder);
+ }
+ }
+ return FALSE;
+}
+
+
+/**
+ * Create our tray icon.
+ *
+ * @param main handle to the main window (show or hide)
+ * @param icon_name name of the tray icon file
+ * @param tooltip tooltip for the tray icon
+ */
+void
+GNUNET_GTK_tray_icon_create (GtkWindow *main,
+ const char *icon_name,
+ const char *tooltip)
+{
+ if (NULL != tray_icon)
+ {
+ GNUNET_break (0);
+ return;
+ }
+ main_window = main;
+ tray_icon = gtk_status_icon_new();
+ g_signal_connect(G_OBJECT(tray_icon), "activate",
+ G_CALLBACK(tray_icon_on_click), NULL);
+ g_signal_connect (G_OBJECT(tray_icon),
+ "button_press_event",
+ G_CALLBACK(tray_icon_on_menu),
+ tray_icon);
+ gtk_status_icon_set_from_icon_name (tray_icon,
+ icon_name);
+ gtk_status_icon_set_tooltip(tray_icon,
+ tooltip);
+ gtk_status_icon_set_visible(tray_icon, TRUE);
+}
+
+
+/**
+ * Destroy the tray icon.
+ */
+void
+GNUNET_GTK_tray_icon_destroy ()
+{
+ if (tray_icon == NULL)
+ return;
+ g_object_unref (G_OBJECT (tray_icon));
+ tray_icon = NULL;
+ main_window = NULL;
+}
+
+/* end of trayicon.c */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r16544 - in gnunet-gtk/src: include lib,
gnunet <=