From 733d4928e512c31baf076c6b97267c6b4691ba73 Mon Sep 17 00:00:00 2001 From: hiro Date: Tue, 23 Aug 2005 09:49:26 +0000 Subject: initial implementation of the tray icon. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@501 ee746299-78ed-0310-b773-934348b2243d --- src/mainwindow.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/mainwindow.c') diff --git a/src/mainwindow.c b/src/mainwindow.c index faca8664..9e928ef2 100644 --- a/src/mainwindow.c +++ b/src/mainwindow.c @@ -77,6 +77,7 @@ #include "alertpanel.h" #include "statusbar.h" #include "inputdialog.h" +#include "eggtrayicon.h" #include "utils.h" #include "gtkutils.h" #include "codeconv.h" @@ -159,6 +160,10 @@ static void ac_label_button_pressed (GtkWidget *widget, static void ac_menu_popup_closed (GtkMenuShell *menu_shell, gpointer data); +static void tray_icon_button_pressed (GtkWidget *widget, + GdkEventButton *event, + gpointer data); + static gint main_window_close_cb (GtkWidget *widget, GdkEventAny *event, gpointer data); @@ -799,6 +804,11 @@ MainWindow *main_window_create(SeparateType type) GtkWidget *ac_button; GtkWidget *ac_label; + GtkWidget *tray_icon; + GtkWidget *tray_icon_img; + GtkWidget *eventbox; + GtkTooltips *tray_icon_tip; + FolderView *folderview; SummaryView *summaryview; MessageView *messageview; @@ -904,6 +914,21 @@ MainWindow *main_window_create(SeparateType type) gtk_widget_show_all(statusbar); + tray_icon = GTK_WIDGET(egg_tray_icon_new("Sylpheed")); + + eventbox = gtk_event_box_new(); + gtk_container_add(GTK_CONTAINER(tray_icon), eventbox); + g_signal_connect(G_OBJECT(eventbox), "button_press_event", + G_CALLBACK(tray_icon_button_pressed), mainwin); + tray_icon_img = stock_pixbuf_widget_scale(NULL, STOCK_PIXMAP_SYLPHEED, + 24, 24); + gtk_container_add(GTK_CONTAINER(eventbox), tray_icon_img); + + tray_icon_tip = gtk_tooltips_new(); + gtk_tooltips_set_tip(tray_icon_tip, tray_icon, _("Sylpheed"), NULL); + + gtk_widget_show_all(tray_icon); + /* create views */ mainwin->folderview = folderview = folderview_create(); mainwin->summaryview = summaryview = summary_create(); @@ -937,6 +962,10 @@ MainWindow *main_window_create(SeparateType type) mainwin->ac_button = ac_button; mainwin->ac_label = ac_label; + mainwin->tray_icon = tray_icon; + mainwin->tray_icon_img = tray_icon_img; + mainwin->tray_icon_tip = tray_icon_tip; + /* set context IDs for status bar */ mainwin->mainwin_cid = gtk_statusbar_get_context_id (GTK_STATUSBAR(statusbar), "Main Window"); @@ -2541,6 +2570,15 @@ static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data) manage_window_focus_in(mainwin->window, NULL, NULL); } +static void tray_icon_button_pressed(GtkWidget *widget, GdkEventButton *event, + gpointer data) +{ + MainWindow *mainwin = (MainWindow *)data; + + if (event && event->button == 1) + gtk_window_present(GTK_WINDOW(mainwin->window)); +} + static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event, gpointer data) { -- cgit v1.2.3