diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | ChangeLog.ja | 7 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/inc.c | 11 | ||||
-rw-r--r-- | src/mainwindow.c | 35 | ||||
-rw-r--r-- | src/mainwindow.h | 2 | ||||
-rw-r--r-- | src/trayicon.c | 92 | ||||
-rw-r--r-- | src/trayicon.h | 33 |
8 files changed, 153 insertions, 35 deletions
@@ -1,5 +1,12 @@ 2005-08-24 + * src/trayicon.[ch] + src/mainwindow.[ch] + src/inc.c: separated trayicon into another module. + Notify new messages with trayicon on receive. + +2005-08-24 + * src/prefs.[ch] src/prefs_common.c: use GtkFontButton for font setting (thanks to Alfons). diff --git a/ChangeLog.ja b/ChangeLog.ja index e4a50297..99951411 100644 --- a/ChangeLog.ja +++ b/ChangeLog.ja @@ -1,5 +1,12 @@ 2005-08-24 + * src/trayicon.[ch] + src/mainwindow.[ch] + src/inc.c: トレイアイコンを別モジュールに分割。 + 受信時に新着メッセージをトレイアイコンで通知するようにした。 + +2005-08-24 + * src/prefs.[ch] src/prefs_common.c: フォントの設定に GtkFontButton を使用(Alfons さん thanks)。 diff --git a/src/Makefile.am b/src/Makefile.am index a889be52..3fc61508 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -109,6 +109,7 @@ sylpheed_SOURCES = \ manual.c manual.h \ stringtable.c stringtable.h \ eggtrayicon.c eggtrayicon.h \ + trayicon.c trayicon.h \ quote_fmt_lex.l quote_fmt_lex.h \ quote_fmt_parse.y quote_fmt.h \ sylpheed-marshal.c sylpheed-marshal.h @@ -56,6 +56,7 @@ #include "progressdialog.h" #include "inputdialog.h" #include "alertpanel.h" +#include "trayicon.h" #include "filter.h" #include "folder.h" @@ -151,6 +152,16 @@ static void inc_finished(MainWindow *mainwin, gint new_messages) if (prefs_common.scan_all_after_inc) folderview_check_new(NULL); + if (new_messages > 0) { + gchar buf[1024]; + + g_snprintf(buf, sizeof(buf), _("Sylpheed: %d new messages"), + new_messages); + trayicon_set_tooltip(buf); + } else { + trayicon_set_tooltip(_("Sylpheed")); + } + if (new_messages <= 0 && !prefs_common.scan_all_after_inc) return; if (prefs_common.open_inbox_on_inc) { diff --git a/src/mainwindow.c b/src/mainwindow.c index 8ca82a33..4adb8de6 100644 --- a/src/mainwindow.c +++ b/src/mainwindow.c @@ -77,7 +77,7 @@ #include "alertpanel.h" #include "statusbar.h" #include "inputdialog.h" -#include "eggtrayicon.h" +#include "trayicon.h" #include "utils.h" #include "gtkutils.h" #include "codeconv.h" @@ -160,10 +160,6 @@ 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); @@ -805,9 +801,6 @@ MainWindow *main_window_create(SeparateType type) GtkWidget *ac_label; GtkWidget *tray_icon; - GtkWidget *tray_icon_img; - GtkWidget *eventbox; - GtkTooltips *tray_icon_tip; FolderView *folderview; SummaryView *summaryview; @@ -914,20 +907,7 @@ 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); + tray_icon = trayicon_create(mainwin); /* create views */ mainwin->folderview = folderview = folderview_create(); @@ -963,8 +943,6 @@ MainWindow *main_window_create(SeparateType type) 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 @@ -2570,15 +2548,6 @@ 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) { diff --git a/src/mainwindow.h b/src/mainwindow.h index 97363cd8..01f9c552 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -112,8 +112,6 @@ struct _MainWindow GtkWidget *ac_menu; GtkWidget *tray_icon; - GtkWidget *tray_icon_img; - GtkTooltips *tray_icon_tip; /* context IDs for status bar */ gint mainwin_cid; 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)); +} diff --git a/src/trayicon.h b/src/trayicon.h new file mode 100644 index 00000000..b15c132b --- /dev/null +++ b/src/trayicon.h @@ -0,0 +1,33 @@ +/* + * 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. + */ + +#ifndef __TRAYICON_H__ +#define __TRAYICON_H__ + +#include <glib.h> +#include <gtk/gtkwidget.h> + +#include "mainwindow.h" +#include "stock_pixmap.h" + +GtkWidget *trayicon_create (MainWindow *mainwin); +void trayicon_set_tooltip (const gchar *text); +void trayicon_set_stock_icon (StockPixmap icon); + +#endif /* __TRAYICON_H__ */ |