aboutsummaryrefslogtreecommitdiff
path: root/src/trayicon.c
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-08-24 10:31:28 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-08-24 10:31:28 +0000
commit1003322f977add069c7ec91546274ffe22de493e (patch)
tree4152d6d05ebca4f989292b5bbb9660521b392199 /src/trayicon.c
parentd99c5a9b8032f5290c640bcea7f406326c325c04 (diff)
separated trayicon into another module, and notify new messages with trayicon on receive.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@510 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src/trayicon.c')
-rw-r--r--src/trayicon.c92
1 files changed, 92 insertions, 0 deletions
diff --git a/src/trayicon.c b/src/trayicon.c
new file mode 100644
index 00000000..537b7671
--- /dev/null
+++ b/src/trayicon.c
@@ -0,0 +1,92 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2005 Hiroyuki Yamamoto
+ *
+ * This program 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 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <gtk/gtkwindow.h>
+#include <gtk/gtkeventbox.h>
+#include <gtk/gtktooltips.h>
+#include <gtk/gtkimage.h>
+
+#include "eggtrayicon.h"
+#include "trayicon.h"
+#include "mainwindow.h"
+#include "utils.h"
+#include "eggtrayicon.h"
+#include "stock_pixmap.h"
+
+
+static GtkWidget *trayicon;
+static GtkWidget *trayicon_img;
+static GtkWidget *eventbox;
+static GtkTooltips *trayicon_tip;
+
+static void trayicon_button_pressed (GtkWidget *widget,
+ GdkEventButton *event,
+ gpointer data);
+
+GtkWidget *trayicon_create(MainWindow *mainwin)
+{
+ trayicon = GTK_WIDGET(egg_tray_icon_new("Sylpheed"));
+
+ eventbox = gtk_event_box_new();
+ gtk_container_add(GTK_CONTAINER(trayicon), eventbox);
+ g_signal_connect(G_OBJECT(eventbox), "button_press_event",
+ G_CALLBACK(trayicon_button_pressed), mainwin);
+ trayicon_img = stock_pixbuf_widget_scale(NULL, STOCK_PIXMAP_SYLPHEED,
+ 24, 24);
+ gtk_container_add(GTK_CONTAINER(eventbox), trayicon_img);
+
+ trayicon_tip = gtk_tooltips_new();
+ gtk_tooltips_set_tip(trayicon_tip, trayicon, _("Sylpheed"), NULL);
+
+ gtk_widget_show_all(trayicon);
+
+ return trayicon;
+}
+
+void trayicon_set_tooltip(const gchar *text)
+{
+ gtk_tooltips_set_tip(trayicon_tip, trayicon, text, NULL);
+}
+
+void trayicon_set_stock_icon(StockPixmap icon)
+{
+ GdkPixbuf *pixbuf;
+ GdkPixbuf *scaled_pixbuf;
+
+ stock_pixbuf_gdk(NULL, icon, &pixbuf);
+ scaled_pixbuf = gdk_pixbuf_scale_simple(pixbuf, 24, 24,
+ GDK_INTERP_HYPER);
+ gtk_image_set_from_pixbuf(GTK_IMAGE(trayicon_img), scaled_pixbuf);
+ g_object_unref(scaled_pixbuf);
+}
+
+static void trayicon_button_pressed(GtkWidget *widget, GdkEventButton *event,
+ gpointer data)
+{
+ MainWindow *mainwin = (MainWindow *)data;
+
+ if (event && event->button == 1)
+ gtk_window_present(GTK_WINDOW(mainwin->window));
+}