2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2003 Hiroyuki Yamamoto and the Sylpheed-Claws Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 #include "mainwindow.h"
31 #include "eggtrayicon.h"
32 #include "newmail.xpm"
33 #include "unreadmail.xpm"
38 static GdkPixmap *newmail_pixmap;
39 static GdkPixmap *newmail_bitmap;
40 static GdkPixmap *unreadmail_pixmap;
41 static GdkPixmap *unreadmail_bitmap;
42 static GdkPixmap *nomail_pixmap;
43 static GdkPixmap *nomail_bitmap;
45 static EggTrayIcon *trayicon;
46 static GtkWidget *eventbox;
47 static GtkWidget *image;
48 static GtkTooltips *tooltips;
54 TRAYICON_UNREADMARKED,
58 static gboolean mainwin_hidden = FALSE;
60 static gboolean click_cb(GtkWidget * widget,
61 GdkEventButton * event, gpointer user_data)
66 mainwin = mainwindow_get_mainwindow();
68 gtk_widget_show(mainwin->window);
69 mainwin_hidden = FALSE;
71 gtk_widget_hide(mainwin->window);
72 mainwin_hidden = TRUE;
78 static void set_trayicon_pixmap(TrayIconType icontype)
80 GdkPixmap *pixmap = NULL;
81 GdkBitmap *bitmap = NULL;
85 pixmap = newmail_pixmap;
86 bitmap = newmail_bitmap;
89 case TRAYICON_UNREADMARKED:
90 pixmap = unreadmail_pixmap;
91 bitmap = unreadmail_bitmap;
94 pixmap = nomail_pixmap;
95 bitmap = nomail_bitmap;
99 gtk_pixmap_set(GTK_PIXMAP(image), pixmap, bitmap);
100 gtk_widget_shape_combine_mask(trayicon, bitmap, 0, 3);
105 gint new, unread, unreadmarked, total;
108 folder_count_total_msgs(&new, &unread, &unreadmarked, &total);
109 buf = g_strdup_printf("New %d, Unread: %d, Total: %d", new, unread, total);
111 gtk_tooltips_set_tip(tooltips, eventbox, buf, "");
114 set_trayicon_pixmap(new > 0 ? TRAYICON_NEW : (unread > 0 ? TRAYICON_UNREAD : TRAYICON_NOTHING));
119 static gboolean folder_item_update_hook(gpointer source, gpointer data)
124 int plugin_init(gchar **error)
126 hook_id = hooks_register_hook (FOLDER_ITEM_UPDATE_HOOKLIST, folder_item_update_hook, NULL);
128 *error = g_strdup("Failed to register folder item update hook");
132 trayicon = egg_tray_icon_new("Sylpheed-Claws");
133 gtk_widget_set_usize(GTK_WIDGET(trayicon), 16, 16);
134 gtk_container_set_border_width(GTK_CONTAINER(trayicon), 0);
136 PIXMAP_CREATE(GTK_WIDGET(trayicon), nomail_pixmap, nomail_bitmap, nomail_xpm);
137 PIXMAP_CREATE(GTK_WIDGET(trayicon), unreadmail_pixmap, unreadmail_bitmap, unreadmail_xpm);
138 PIXMAP_CREATE(GTK_WIDGET(trayicon), newmail_pixmap, newmail_bitmap, newmail_xpm);
140 printf("%p\n", nomail_bitmap->user_data);
142 eventbox = gtk_event_box_new();
143 gtk_container_set_border_width(eventbox, 0);
144 gtk_container_add(GTK_CONTAINER(trayicon), GTK_WIDGET(eventbox));
146 image = gtk_pixmap_new (nomail_pixmap, nomail_bitmap);
147 gtk_container_add(GTK_CONTAINER(eventbox), GTK_WIDGET(image));
149 gtk_signal_connect(GTK_OBJECT(eventbox), "button-press-event", GTK_SIGNAL_FUNC(click_cb), NULL);
151 tooltips = gtk_tooltips_new();
152 gtk_tooltips_set_delay(tooltips, 1000);
153 gtk_tooltips_enable(tooltips);
155 gtk_widget_show_all(GTK_WIDGET(trayicon));
164 gtk_widget_destroy(GTK_WIDGET(trayicon));
165 hooks_unregister_hook(FOLDER_ITEM_UPDATE_HOOKLIST, hook_id);
168 const gchar *plugin_name()
173 const gchar *plugin_desc()
178 const gchar *plugin_type()