Implement focused widget saving between iconify/deiconify events in
[claws.git] / src / plugins / notification / notification_pixbuf.c
1 /* Notification plugin for Claws-Mail
2  * Copyright (C) 2005-2007 Holger Berndt
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 #include "notification_pixbuf.h"
19 #include "common/utils.h"
20
21 /* The following files were created from the respective .png or
22  * xpm files with the command 
23  * gdk-pixbuf-csource --raw --name=<name> file.png > <name>.h
24  */
25 /* From the Claws-Mail distribution */
26 #include "raw_claws_mail_logo_64x64.h"
27
28 #include "stock_pixmap.h"
29
30 static GdkPixbuf* notification_pixbuf[NOTIFICATION_PIXBUF_LAST];
31
32 GdkPixbuf* notification_pixbuf_get(NotificationPixbuf wanted)
33 {
34   if(!notification_pixbuf[wanted]) {
35     switch(wanted) {
36     case NOTIFICATION_CM_LOGO_64x64:
37       notification_pixbuf[wanted] =
38                                 gdk_pixbuf_new_from_inline(-1, raw_claws_mail_logo_64x64,
39                                                                                                                                          FALSE, NULL);
40       break;
41     case NOTIFICATION_TRAYICON_NEWMAIL:
42                         stock_pixbuf_gdk(NULL, STOCK_PIXMAP_TRAY_NEWMAIL, &(notification_pixbuf[wanted]));
43       g_object_ref(notification_pixbuf[wanted]);
44       break;
45     case NOTIFICATION_TRAYICON_NEWMAIL_OFFLINE:
46                         stock_pixbuf_gdk(NULL, STOCK_PIXMAP_TRAY_NEWMAIL_OFFLINE, &(notification_pixbuf[wanted]));
47       g_object_ref(notification_pixbuf[wanted]);
48       break;
49     case NOTIFICATION_TRAYICON_NEWMARKEDMAIL:
50                         stock_pixbuf_gdk(NULL, STOCK_PIXMAP_TRAY_NEWMARKEDMAIL, &(notification_pixbuf[wanted]));
51       g_object_ref(notification_pixbuf[wanted]);
52       break;
53     case NOTIFICATION_TRAYICON_NEWMARKEDMAIL_OFFLINE:
54                         stock_pixbuf_gdk(NULL, STOCK_PIXMAP_TRAY_NEWMARKEDMAIL_OFFLINE, &(notification_pixbuf[wanted]));
55       g_object_ref(notification_pixbuf[wanted]);
56       break;
57     case NOTIFICATION_TRAYICON_NOMAIL:
58                         stock_pixbuf_gdk(NULL, STOCK_PIXMAP_TRAY_NOMAIL, &(notification_pixbuf[wanted]));
59       g_object_ref(notification_pixbuf[wanted]);
60       break;
61     case NOTIFICATION_TRAYICON_NOMAIL_OFFLINE:
62                         stock_pixbuf_gdk(NULL, STOCK_PIXMAP_TRAY_NOMAIL_OFFLINE, &(notification_pixbuf[wanted]));
63       g_object_ref(notification_pixbuf[wanted]);
64       break;
65     case NOTIFICATION_TRAYICON_UNREADMAIL:
66                         stock_pixbuf_gdk(NULL, STOCK_PIXMAP_TRAY_UNREADMAIL, &(notification_pixbuf[wanted]));
67       g_object_ref(notification_pixbuf[wanted]);
68       break;
69     case NOTIFICATION_TRAYICON_UNREADMAIL_OFFLINE:
70                         stock_pixbuf_gdk(NULL, STOCK_PIXMAP_TRAY_UNREADMAIL_OFFLINE, &(notification_pixbuf[wanted]));
71       g_object_ref(notification_pixbuf[wanted]);
72       break;
73     case NOTIFICATION_TRAYICON_UNREADMARKEDMAIL:
74                         stock_pixbuf_gdk(NULL, STOCK_PIXMAP_TRAY_UNREADMARKEDMAIL, &(notification_pixbuf[wanted]));
75       g_object_ref(notification_pixbuf[wanted]);
76       break;
77     case NOTIFICATION_TRAYICON_UNREADMARKEDMAIL_OFFLINE:
78                         stock_pixbuf_gdk(NULL, STOCK_PIXMAP_TRAY_UNREADMARKEDMAIL_OFFLINE, &(notification_pixbuf[wanted]));
79       g_object_ref(notification_pixbuf[wanted]);
80       break;
81     case NOTIFICATION_PIXBUF_LAST:
82       break;
83     }
84   }
85   cm_return_val_if_fail(wanted < NOTIFICATION_PIXBUF_LAST, NULL);
86   return notification_pixbuf[wanted];
87 }
88
89 void notification_pixbuf_free_all(void)
90 {
91   gint ii;
92
93   for(ii = NOTIFICATION_CM_LOGO_64x64; ii < NOTIFICATION_PIXBUF_LAST; ii++) {
94     if(notification_pixbuf[ii]) {
95       g_object_unref(notification_pixbuf[ii]);
96       notification_pixbuf[ii] = NULL;
97     }
98   }
99 }