Remove extra entries, not yet in git.
[claws.git] / src / stock_pixmap.c
1 /*
2  * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2016 Hiroyuki Yamamoto and the Claws Mail team
4  *
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 3 of the License, or
8  * (at your option) any later version.
9  *
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.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18
19 #include "defs.h"
20 #include <glib.h>
21 #include <gtk/gtk.h>
22 #include <string.h>
23 #include <dirent.h>
24
25 #include "config.h"
26 #include "stock_pixmap.h"
27 #include "gtkutils.h"
28 #include "utils.h"
29 #include "prefs_common.h"
30
31 #include "pixmaps/addr_one.xpm"
32 #include "pixmaps/addr_two.xpm"
33 #include "pixmaps/address.xpm"
34 #include "pixmaps/anonymous.xpm"
35 #include "pixmaps/book.xpm"
36 #include "pixmaps/category.xpm"
37 #include "pixmaps/checkbox_off.xpm"
38 #include "pixmaps/checkbox_on.xpm"
39 #include "pixmaps/clip.xpm"
40 #include "pixmaps/clipkey.xpm"
41 #include "pixmaps/complete.xpm"
42 #include "pixmaps/continue.xpm"
43 #include "pixmaps/deleted.xpm"
44 #include "pixmaps/error.xpm"
45 #include "pixmaps/edit_extern.xpm"
46 #include "pixmaps/forwarded.xpm"
47 #include "pixmaps/group.xpm"
48 #include "pixmaps/insert_file.xpm"
49 #include "pixmaps/interface.xpm"
50 #include "pixmaps/jpilot.xpm"
51 #include "pixmaps/key.xpm"
52 #include "pixmaps/key_gpg_signed.xpm"
53 #include "pixmaps/ldap.xpm"
54 #include "pixmaps/linewrap.xpm"
55 #include "pixmaps/linewrapcurrent.xpm"
56 #include "pixmaps/mark.xpm"
57 #include "pixmaps/locked.xpm"
58 #include "pixmaps/new.xpm"
59 #include "pixmaps/replied.xpm"
60 #include "pixmaps/replied_and_forwarded.xpm"
61 #include "pixmaps/close.xpm"
62 #include "pixmaps/down_arrow.xpm"
63 #include "pixmaps/up_arrow.xpm"
64 #include "pixmaps/exec.xpm"
65 #include "pixmaps/mail.xpm"
66 #include "pixmaps/mail_attach.xpm"
67 #include "pixmaps/mail_compose.xpm"
68 #include "pixmaps/mail_forward.xpm"
69 #include "pixmaps/mail_receive.xpm"
70 #include "pixmaps/mail_receive_all.xpm"
71 #include "pixmaps/mail_reply.xpm"
72 #include "pixmaps/mail_reply_to_all.xpm"
73 #include "pixmaps/mail_reply_to_author.xpm"
74 #include "pixmaps/mail_reply_to_list.xpm"
75 #include "pixmaps/mail_send.xpm"
76 #include "pixmaps/mail_send_queue.xpm"
77 #include "pixmaps/mail_sign.xpm"
78 #include "pixmaps/open_mail.xpm"
79 #include "pixmaps/news_compose.xpm"
80 #include "pixmaps/paste.xpm"
81 #include "pixmaps/preferences.xpm"
82 #include "pixmaps/properties.xpm"
83 #include "pixmaps/queue_close.xpm"
84 #include "pixmaps/queue_close_hrm.xpm"
85 #include "pixmaps/queue_open.xpm"
86 #include "pixmaps/queue_open_hrm.xpm"
87 #include "pixmaps/claws_mail_icon.xpm"
88 #include "pixmaps/claws_mail_icon_64.xpm"
89 #include "pixmaps/claws_mail_compose_logo.xpm"
90 #ifndef GENERIC_UMPC
91 #include "pixmaps/claws_mail_logo.xpm"
92 #else
93 #include "pixmaps/claws_mail_logo_small.xpm"
94 #endif
95 #include "pixmaps/address_book.xpm"
96 #include "pixmaps/unread.xpm"
97 #include "pixmaps/read.xpm"
98 #include "pixmaps/vcard.xpm"
99 #include "pixmaps/ignorethread.xpm"
100 #include "pixmaps/online.xpm"
101 #include "pixmaps/offline.xpm"
102 #include "pixmaps/notice_warn.xpm"
103 #include "pixmaps/notice_error.xpm"
104 #include "pixmaps/notice_note.xpm"
105 #include "pixmaps/quicksearch.xpm"
106 #include "pixmaps/clip_gpg_signed.xpm"
107 #include "pixmaps/gpg_signed.xpm"
108 #include "pixmaps/go_folders.xpm"
109 #include "pixmaps/mime_text_plain.xpm"
110 #include "pixmaps/mime_text_html.xpm"
111 #include "pixmaps/mime_text_patch.xpm"
112 #include "pixmaps/mime_application.xpm"
113 #include "pixmaps/mime_image.xpm"
114 #include "pixmaps/mime_audio.xpm"
115 #include "pixmaps/mime_text_enriched.xpm"
116 #include "pixmaps/mime_unknown.xpm"
117 #include "pixmaps/mime_pdf.xpm"
118 #include "pixmaps/mime_ps.xpm"
119 #include "pixmaps/mime_calendar.xpm"
120 #include "pixmaps/mime_pgpsig.xpm"
121 #include "pixmaps/printer.xpm"
122 #include "pixmaps/privacy_signed.xpm"
123 #include "pixmaps/privacy_passed.xpm"
124 #include "pixmaps/privacy_failed.xpm"
125 #include "pixmaps/privacy_unknown.xpm"
126 #include "pixmaps/privacy_expired.xpm"
127 #include "pixmaps/privacy_warn.xpm"
128 #include "pixmaps/privacy_emblem_encrypted.xpm"
129 #include "pixmaps/privacy_emblem_signed.xpm"
130 #include "pixmaps/privacy_emblem_passed.xpm"
131 #include "pixmaps/privacy_emblem_failed.xpm"
132 #include "pixmaps/privacy_emblem_warn.xpm"
133 #include "pixmaps/mime_message.xpm"
134 #include "pixmaps/address_search.xpm"
135 #include "pixmaps/check_spelling.xpm"
136
137 #include "pixmaps/dir_close.xpm"
138 #include "pixmaps/dir_close_hrm.xpm"
139 #include "pixmaps/dir_open.xpm"
140 #include "pixmaps/dir_open_hrm.xpm"
141 #include "pixmaps/inbox_open.xpm"
142 #include "pixmaps/inbox_open_hrm.xpm"
143 #include "pixmaps/inbox_close.xpm"
144 #include "pixmaps/inbox_close_hrm.xpm"
145 #include "pixmaps/outbox_open.xpm"
146 #include "pixmaps/outbox_open_hrm.xpm"
147 #include "pixmaps/outbox_close.xpm"
148 #include "pixmaps/outbox_close_hrm.xpm"
149 #include "pixmaps/trash_open.xpm"
150 #include "pixmaps/trash_close.xpm"
151 #include "pixmaps/delete_btn.xpm"
152 #include "pixmaps/cancel.xpm"
153 #include "pixmaps/trash_btn.xpm"
154 #include "pixmaps/trash_open_hrm.xpm"
155 #include "pixmaps/trash_close_hrm.xpm"
156 #include "pixmaps/drafts_close.xpm"
157 #include "pixmaps/drafts_open.xpm"
158 #include "pixmaps/dir_close_mark.xpm"
159 #include "pixmaps/dir_close_hrm_mark.xpm"
160 #include "pixmaps/dir_open_mark.xpm"
161 #include "pixmaps/dir_open_hrm_mark.xpm"
162 #include "pixmaps/inbox_open_mark.xpm"
163 #include "pixmaps/inbox_open_hrm_mark.xpm"
164 #include "pixmaps/inbox_close_mark.xpm"
165 #include "pixmaps/inbox_close_hrm_mark.xpm"
166 #include "pixmaps/outbox_open_mark.xpm"
167 #include "pixmaps/outbox_open_hrm_mark.xpm"
168 #include "pixmaps/outbox_close_mark.xpm"
169 #include "pixmaps/outbox_close_hrm_mark.xpm"
170 #include "pixmaps/trash_open_mark.xpm"
171 #include "pixmaps/trash_close_mark.xpm"
172 #include "pixmaps/queue_close_mark.xpm"
173 #include "pixmaps/queue_close_hrm_mark.xpm"
174 #include "pixmaps/queue_open_mark.xpm"
175 #include "pixmaps/queue_open_hrm_mark.xpm"
176 #include "pixmaps/trash_open_hrm_mark.xpm"
177 #include "pixmaps/trash_close_hrm_mark.xpm"
178 #include "pixmaps/drafts_close_mark.xpm"
179 #include "pixmaps/drafts_open_mark.xpm"
180 #include "pixmaps/dir_noselect_close.xpm"
181 #include "pixmaps/dir_noselect_close_mark.xpm"
182 #include "pixmaps/dir_noselect_open.xpm"
183 #include "pixmaps/dir_subs_close_mark.xpm"
184 #include "pixmaps/dir_subs_close.xpm"
185 #include "pixmaps/dir_subs_open.xpm"
186 #include "pixmaps/spam.xpm"
187 #include "pixmaps/spam_btn.xpm"
188 #include "pixmaps/ham_btn.xpm"
189 #include "pixmaps/moved.xpm"
190 #include "pixmaps/copied.xpm"
191 #include "pixmaps/selection.xpm"
192 #include "pixmaps/watchthread.xpm"
193 #include "pixmaps/empty.xpm"
194 #include "pixmaps/tray_newmail_offline.xpm"
195 #include "pixmaps/tray_newmail.xpm"
196 #include "pixmaps/tray_newmarkedmail_offline.xpm"
197 #include "pixmaps/tray_newmarkedmail.xpm"
198 #include "pixmaps/tray_nomail_offline.xpm"
199 #include "pixmaps/tray_nomail.xpm"
200 #include "pixmaps/tray_unreadmail_offline.xpm"
201 #include "pixmaps/tray_unreadmail.xpm"
202 #include "pixmaps/tray_unreadmarkedmail_offline.xpm"
203 #include "pixmaps/tray_unreadmarkedmail.xpm"
204 #include "pixmaps/doc_index.xpm"
205 #include "pixmaps/doc_index_close.xpm"
206 #include "pixmaps/doc_info.xpm"
207 #include "pixmaps/first_arrow.xpm"
208 #include "pixmaps/last_arrow.xpm"
209 #include "pixmaps/left_arrow.xpm"
210 #include "pixmaps/right_arrow.xpm"
211 #include "pixmaps/rotate_left.xpm"
212 #include "pixmaps/rotate_right.xpm"
213 #include "pixmaps/zoom_fit.xpm"
214 #include "pixmaps/zoom_in.xpm"
215 #include "pixmaps/zoom_out.xpm"
216 #include "pixmaps/zoom_width.xpm"
217
218 typedef struct _StockPixmapData StockPixmapData;
219
220 struct _StockPixmapData
221 {
222         gchar **data;
223         cairo_surface_t *pixmap;
224         cairo_pattern_t *mask;
225         gchar *file;
226         gchar *icon_path;
227         GdkPixbuf *pixbuf;
228 };
229
230 typedef struct _OverlayData OverlayData;
231
232 struct _OverlayData
233 {
234         gboolean is_pixmap;
235         cairo_surface_t *base_pixmap;
236         cairo_surface_t *overlay_pixmap;
237         
238         GdkPixbuf *base_pixbuf;
239         GdkPixbuf *overlay_pixbuf;
240         
241         guint base_height;
242         guint base_width;
243         guint overlay_height;
244         guint overlay_width;
245         OverlayPosition position;
246         gint border_x;
247         gint border_y;
248         gboolean highlight;
249 };
250
251 static void stock_pixmap_find_themes_in_dir(GList **list, const gchar *dirname);
252
253 static StockPixmapData pixmaps[] =
254 {
255     {addr_one_xpm                         , NULL, NULL, "addr_one", NULL, NULL},
256     {addr_two_xpm                         , NULL, NULL, "addr_two", NULL, NULL},
257     {address_xpm                          , NULL, NULL, "address", NULL, NULL},
258     {address_book_xpm                     , NULL, NULL, "address_book", NULL, NULL},
259     {address_search_xpm                   , NULL, NULL, "address_search", NULL, NULL},
260     {anonymous_xpm                        , NULL, NULL, "anonymous", NULL, NULL},
261     {book_xpm                             , NULL, NULL, "book", NULL, NULL},
262     {category_xpm                         , NULL, NULL, "category", NULL, NULL},
263     {checkbox_off_xpm                     , NULL, NULL, "checkbox_off", NULL, NULL},
264     {checkbox_on_xpm                      , NULL, NULL, "checkbox_on", NULL, NULL},
265     {check_spelling_xpm                   , NULL, NULL, "check_spelling", NULL, NULL},
266     {clip_xpm                             , NULL, NULL, "clip", NULL, NULL},
267     {clipkey_xpm                          , NULL, NULL, "clipkey", NULL, NULL},
268     {clip_gpg_signed_xpm                  , NULL, NULL, "clip_gpg_signed", NULL, NULL},
269     {close_xpm                            , NULL, NULL, "close", NULL, NULL},
270     {complete_xpm                         , NULL, NULL, "complete", NULL, NULL},
271     {continue_xpm                         , NULL, NULL, "continue", NULL, NULL},
272     {deleted_xpm                          , NULL, NULL, "deleted", NULL, NULL},
273     {dir_close_xpm                        , NULL, NULL, "dir_close", NULL, NULL},
274     {dir_close_hrm_xpm                    , NULL, NULL, "dir_close_hrm", NULL, NULL},
275     {dir_open_xpm                         , NULL, NULL, "dir_open", NULL, NULL},
276     {dir_open_hrm_xpm                     , NULL, NULL, "dir_open_hrm", NULL, NULL},
277     {dir_close_mark_xpm                   , NULL, NULL, "dir_close_mark", NULL, NULL},
278     {dir_close_hrm_mark_xpm               , NULL, NULL, "dir_close_hrm_mark", NULL, NULL},
279     {dir_open_mark_xpm                    , NULL, NULL, "dir_open_mark", NULL, NULL},
280     {dir_open_hrm_mark_xpm                , NULL, NULL, "dir_open_hrm_mark", NULL, NULL},
281     {down_arrow_xpm                       , NULL, NULL, "down_arrow", NULL, NULL},
282     {up_arrow_xpm                         , NULL, NULL, "up_arrow", NULL, NULL},
283     {edit_extern_xpm                      , NULL, NULL, "edit_extern", NULL, NULL},
284     {error_xpm                            , NULL, NULL, "error", NULL, NULL},
285     {exec_xpm                             , NULL, NULL, "exec", NULL, NULL},
286     {forwarded_xpm                        , NULL, NULL, "forwarded", NULL, NULL},
287     {group_xpm                            , NULL, NULL, "group", NULL, NULL},
288     {ignorethread_xpm                     , NULL, NULL, "ignorethread", NULL, NULL},
289     {inbox_close_xpm                      , NULL, NULL, "inbox_close", NULL, NULL},
290     {inbox_close_hrm_xpm                  , NULL, NULL, "inbox_close_hrm", NULL, NULL},
291     {inbox_open_xpm                       , NULL, NULL, "inbox_open", NULL, NULL},
292     {inbox_open_hrm_xpm                   , NULL, NULL, "inbox_open_hrm", NULL, NULL},
293     {inbox_close_mark_xpm                 , NULL, NULL, "inbox_close_mark", NULL, NULL},
294     {inbox_close_hrm_mark_xpm             , NULL, NULL, "inbox_close_hrm_mark", NULL, NULL},
295     {inbox_open_mark_xpm                  , NULL, NULL, "inbox_open_mark", NULL, NULL},
296     {inbox_open_hrm_mark_xpm              , NULL, NULL, "inbox_open_hrm_mark", NULL, NULL},
297     {insert_file_xpm                      , NULL, NULL, "insert_file", NULL, NULL},
298     {interface_xpm                        , NULL, NULL, "interface", NULL, NULL},
299     {jpilot_xpm                           , NULL, NULL, "jpilot", NULL, NULL},
300     {key_xpm                              , NULL, NULL, "key", NULL, NULL},
301     {key_gpg_signed_xpm                   , NULL, NULL, "key_gpg_signed", NULL, NULL},
302     {ldap_xpm                             , NULL, NULL, "ldap", NULL, NULL},
303     {linewrapcurrent_xpm                  , NULL, NULL, "linewrapcurrent", NULL, NULL},
304     {linewrap_xpm                         , NULL, NULL, "linewrap", NULL, NULL},
305     {locked_xpm                           , NULL, NULL, "locked", NULL, NULL},
306     {mail_xpm                             , NULL, NULL, "mail", NULL, NULL},
307     {mail_attach_xpm                      , NULL, NULL, "mail_attach", NULL, NULL},
308     {mail_compose_xpm                     , NULL, NULL, "mail_compose", NULL, NULL},
309     {mail_forward_xpm                     , NULL, NULL, "mail_forward", NULL, NULL},
310     {mail_receive_xpm                     , NULL, NULL, "mail_receive", NULL, NULL},
311     {mail_receive_all_xpm                 , NULL, NULL, "mail_receive_all", NULL, NULL},
312     {mail_reply_xpm                       , NULL, NULL, "mail_reply", NULL, NULL},
313     {mail_reply_to_all_xpm                , NULL, NULL, "mail_reply_to_all", NULL, NULL},
314     {mail_reply_to_author_xpm             , NULL, NULL, "mail_reply_to_author", NULL, NULL},
315     {mail_reply_to_list_xpm               , NULL, NULL, "mail_reply_to_list", NULL, NULL},
316     {mail_send_xpm                        , NULL, NULL, "mail_send", NULL, NULL},
317     {mail_send_queue_xpm                  , NULL, NULL, "mail_send_queue", NULL, NULL},
318     {mail_sign_xpm                        , NULL, NULL, "mail_sign", NULL, NULL},
319     {open_mail_xpm                        , NULL, NULL, "open_mail", NULL, NULL},
320     {mark_xpm                             , NULL, NULL, "mark", NULL, NULL},
321     {new_xpm                              , NULL, NULL, "new", NULL, NULL},
322     {news_compose_xpm                 , NULL, NULL, "news_compose", NULL, NULL},
323     {outbox_close_xpm                 , NULL, NULL, "outbox_close", NULL, NULL},
324     {outbox_close_hrm_xpm             , NULL, NULL, "outbox_close_hrm", NULL, NULL},
325     {outbox_open_xpm                  , NULL, NULL, "outbox_open", NULL, NULL},
326     {outbox_open_hrm_xpm              , NULL, NULL, "outbox_open_hrm", NULL, NULL},
327     {outbox_close_mark_xpm            , NULL, NULL, "outbox_close_mark", NULL, NULL},
328     {outbox_close_hrm_mark_xpm        , NULL, NULL, "outbox_close_hrm_mark", NULL, NULL},
329     {outbox_open_mark_xpm             , NULL, NULL, "outbox_open_mark", NULL, NULL},
330     {outbox_open_hrm_mark_xpm         , NULL, NULL, "outbox_open_hrm_mark", NULL, NULL},
331     {replied_xpm                      , NULL, NULL, "replied", NULL, NULL},
332     {replied_and_forwarded_xpm        , NULL, NULL, "replied_and_forwarded", NULL, NULL},
333     {paste_xpm                        , NULL, NULL, "paste", NULL, NULL},
334     {preferences_xpm                  , NULL, NULL, "preferences", NULL, NULL},
335     {properties_xpm                   , NULL, NULL, "properties", NULL, NULL},
336     {queue_close_xpm                  , NULL, NULL, "queue_close", NULL, NULL},
337     {queue_close_hrm_xpm              , NULL, NULL, "queue_close_hrm", NULL, NULL},
338     {queue_open_xpm                   , NULL, NULL, "queue_open", NULL, NULL},
339     {queue_open_hrm_xpm               , NULL, NULL, "queue_open_hrm", NULL, NULL},
340     {trash_open_xpm                   , NULL, NULL, "trash_open", NULL, NULL},
341     {trash_open_hrm_xpm               , NULL, NULL, "trash_open_hrm", NULL, NULL},
342     {trash_close_xpm                  , NULL, NULL, "trash_close", NULL, NULL},
343     {trash_close_hrm_xpm              , NULL, NULL, "trash_close_hrm", NULL, NULL},
344     {queue_close_mark_xpm             , NULL, NULL, "queue_close_mark", NULL, NULL},
345     {queue_close_hrm_mark_xpm         , NULL, NULL, "queue_close_hrm_mark", NULL, NULL},
346     {queue_open_mark_xpm              , NULL, NULL, "queue_open_mark", NULL, NULL},
347     {queue_open_hrm_mark_xpm          , NULL, NULL, "queue_open_hrm_mark", NULL, NULL},
348     {trash_open_mark_xpm              , NULL, NULL, "trash_open_mark", NULL, NULL},
349     {trash_open_hrm_mark_xpm          , NULL, NULL, "trash_open_hrm_mark", NULL, NULL},
350     {trash_close_mark_xpm             , NULL, NULL, "trash_close_mark", NULL, NULL},
351     {trash_close_hrm_mark_xpm         , NULL, NULL, "trash_close_hrm_mark", NULL, NULL},
352     {unread_xpm                       , NULL, NULL, "unread", NULL, NULL},
353     {vcard_xpm                        , NULL, NULL, "vcard", NULL, NULL},
354     {online_xpm                       , NULL, NULL, "online", NULL, NULL},
355     {offline_xpm                      , NULL, NULL, "offline", NULL, NULL},
356     {notice_warn_xpm                  , NULL, NULL, "notice_warn",  NULL, NULL},
357     {notice_error_xpm                 , NULL, NULL, "notice_error",  NULL, NULL},
358     {notice_note_xpm                  , NULL, NULL, "notice_note",  NULL, NULL},
359     {quicksearch_xpm                  , NULL, NULL, "quicksearch",  NULL, NULL},
360     {gpg_signed_xpm                   , NULL, NULL, "gpg_signed", NULL, NULL},
361     {go_folders_xpm                   , NULL, NULL, "go_folders", NULL, NULL},
362     {drafts_close_xpm                 , NULL, NULL, "drafts_close", NULL, NULL},
363     {drafts_open_xpm                  , NULL, NULL, "drafts_open", NULL, NULL},
364     {drafts_close_mark_xpm            , NULL, NULL, "drafts_close_mark", NULL, NULL},
365     {drafts_open_mark_xpm             , NULL, NULL, "drafts_open_mark", NULL, NULL},
366     {mime_text_plain_xpm              , NULL, NULL, "mime_text_plain", NULL, NULL},
367     {mime_text_html_xpm               , NULL, NULL, "mime_text_html", NULL, NULL},
368     {mime_text_patch_xpm              , NULL, NULL, "mime_text_patch", NULL, NULL},
369     {mime_application_xpm             , NULL, NULL, "mime_application", NULL, NULL},
370     {mime_image_xpm                   , NULL, NULL, "mime_image", NULL, NULL},
371     {mime_audio_xpm                   , NULL, NULL, "mime_audio", NULL, NULL},
372     {mime_text_enriched_xpm           , NULL, NULL, "mime_text_enriched", NULL, NULL},
373     {mime_unknown_xpm                 , NULL, NULL, "mime_unknown", NULL, NULL},    
374     {mime_pdf_xpm                     , NULL, NULL, "mime_pdf", NULL, NULL},    
375     {mime_ps_xpm                      , NULL, NULL, "mime_ps", NULL, NULL},    
376     {mime_calendar_xpm                , NULL, NULL, "mime_calendar", NULL, NULL},    
377     {mime_pgpsig_xpm                  , NULL, NULL, "mime_pgpsig", NULL, NULL},    
378     {printer_xpm                      , NULL, NULL, "printer", NULL, NULL},
379     {privacy_signed_xpm               , NULL, NULL, "privacy_signed", NULL, NULL},
380     {privacy_passed_xpm               , NULL, NULL, "privacy_passed", NULL, NULL},
381     {privacy_failed_xpm               , NULL, NULL, "privacy_failed", NULL, NULL},    
382     {privacy_unknown_xpm              , NULL, NULL, "privacy_unknown", NULL, NULL},
383     {privacy_expired_xpm              , NULL, NULL, "privacy_expired", NULL, NULL},
384     {privacy_warn_xpm                 , NULL, NULL, "privacy_warn", NULL, NULL},
385     {privacy_emblem_encrypted_xpm     , NULL, NULL, "privacy_emblem_encrypted", NULL, NULL},
386     {privacy_emblem_signed_xpm        , NULL, NULL, "privacy_emblem_signed", NULL, NULL},
387     {privacy_emblem_passed_xpm        , NULL, NULL, "privacy_emblem_passed", NULL, NULL},
388     {privacy_emblem_failed_xpm        , NULL, NULL, "privacy_emblem_failed", NULL, NULL},    
389     {privacy_emblem_warn_xpm          , NULL, NULL, "privacy_emblem_warn", NULL, NULL},
390     {mime_message_xpm                 , NULL, NULL, "mime_message", NULL, NULL},
391     {claws_mail_icon_xpm              , NULL, NULL, "claws_mail_icon", NULL, NULL},
392     {claws_mail_icon_64_xpm           , NULL, NULL, "claws_mail_icon_64", NULL, NULL},
393     {read_xpm                         , NULL, NULL, "read", NULL, NULL},
394     {delete_btn_xpm                   , NULL, NULL, "delete_btn", NULL, NULL},
395     {cancel_xpm                       , NULL, NULL, "cancel", NULL, NULL},
396     {trash_btn_xpm                    , NULL, NULL, "trash_btn", NULL, NULL},
397     {claws_mail_compose_logo_xpm      , NULL, NULL, "claws_mail_compose_logo", NULL, NULL},
398 #ifndef GENERIC_UMPC
399     {claws_mail_logo_xpm              , NULL, NULL, "claws_mail_logo", NULL, NULL},
400 #else
401     {claws_mail_logo_small_xpm        , NULL, NULL, "claws_mail_logo_small", NULL, NULL},
402 #endif
403     {dir_noselect_close_xpm           , NULL, NULL, "dir_noselect_close", NULL, NULL},
404     {dir_noselect_close_mark_xpm      , NULL, NULL, "dir_noselect_close_mark", NULL, NULL},
405     {dir_noselect_open_xpm            , NULL, NULL, "dir_noselect_open", NULL, NULL},
406     {dir_subs_close_mark_xpm          , NULL, NULL, "dir_subs_close_mark", NULL, NULL},
407     {dir_subs_close_xpm               , NULL, NULL, "dir_subs_close", NULL, NULL},
408     {dir_subs_open_xpm                , NULL, NULL, "dir_subs_open", NULL, NULL},
409     {spam_xpm                         , NULL, NULL, "spam", NULL, NULL},
410     {spam_btn_xpm                     , NULL, NULL, "spam_btn", NULL, NULL},
411     {ham_btn_xpm                      , NULL, NULL, "ham_btn", NULL, NULL},
412     {moved_xpm                        , NULL, NULL, "moved", NULL, NULL},
413     {copied_xpm                       , NULL, NULL, "copied", NULL, NULL},
414     {selection_xpm                    , NULL, NULL, "selection", NULL, NULL},
415     {watchthread_xpm                  , NULL, NULL, "watchthread", NULL, NULL},
416     {tray_newmail_offline_xpm         , NULL, NULL, "tray_newmail_offline", NULL, NULL},
417     {tray_newmail_xpm                 , NULL, NULL, "tray_newmail", NULL, NULL},
418     {tray_newmarkedmail_offline_xpm   , NULL, NULL, "tray_newmarkedmail_offline", NULL, NULL},
419     {tray_newmarkedmail_xpm           , NULL, NULL, "tray_newmarkedmail", NULL, NULL},
420     {tray_nomail_offline_xpm          , NULL, NULL, "tray_nomail_offline", NULL, NULL},
421     {tray_nomail_xpm                  , NULL, NULL, "tray_nomail", NULL, NULL},
422     {tray_unreadmail_offline_xpm      , NULL, NULL, "tray_unreadmail_offline", NULL, NULL},
423     {tray_unreadmail_xpm              , NULL, NULL, "tray_unreadmail", NULL, NULL},
424     {tray_unreadmarkedmail_offline_xpm, NULL, NULL, "tray_unreadmarkedmail_offline", NULL, NULL},
425     {tray_unreadmarkedmail_xpm        , NULL, NULL, "tray_unreadmarkedmail", NULL, NULL},
426     {doc_index_xpm                    , NULL, NULL, "doc_index", NULL, NULL,},
427     {doc_index_close_xpm              , NULL, NULL, "doc_index_close", NULL, NULL,},
428     {doc_info_xpm                     , NULL, NULL, "doc_info", NULL, NULL,},
429     {first_arrow_xpm                  , NULL, NULL, "first_arrow", NULL, NULL},
430     {last_arrow_xpm                   , NULL, NULL, "last_arrow", NULL, NULL},
431     {left_arrow_xpm                   , NULL, NULL, "left_arrow", NULL, NULL},
432     {right_arrow_xpm                  , NULL, NULL, "right_arrow", NULL, NULL},
433     {rotate_left_xpm                  , NULL, NULL, "rotate_left", NULL, NULL},
434     {rotate_right_xpm                 , NULL, NULL, "rotate_right", NULL, NULL},
435     {zoom_fit_xpm                     , NULL, NULL, "zoom_fit", NULL, NULL},
436     {zoom_in_xpm                      , NULL, NULL, "zoom_in", NULL, NULL},
437     {zoom_out_xpm                     , NULL, NULL, "zoom_out", NULL, NULL},
438     {zoom_width_xpm                   , NULL, NULL, "zoom_width", NULL, NULL},
439     {empty_xpm                        , NULL, NULL, "empty", NULL, NULL}
440 };
441
442 /* return newly constructed GtkPixmap from GdkPixmap */
443 GtkWidget *stock_pixmap_widget(StockPixmap icon)
444 {
445         GdkPixbuf *pixbuf;
446
447         cm_return_val_if_fail(icon >= 0 && icon < N_STOCK_PIXMAPS, NULL);
448
449         if (stock_pixbuf_gdk(icon, &pixbuf) != -1)
450                 return gtk_image_new_from_pixbuf(pixbuf);
451         
452         return NULL;
453 }
454
455 /*!
456  *\brief        
457  */
458 gint stock_pixbuf_gdk(StockPixmap icon, GdkPixbuf **pixbuf)
459 {
460         StockPixmapData *pix_d;
461         static const char *extension[]={".png", ".xpm", NULL};
462         int i = 0;
463         gboolean theme_changed = FALSE;
464
465         if (pixbuf)
466                 *pixbuf = NULL;
467                 
468         cm_return_val_if_fail(icon >= 0 && icon < N_STOCK_PIXMAPS, -1);
469
470         pix_d = &pixmaps[icon];
471
472         theme_changed = (strcmp2(pix_d->icon_path, prefs_common.pixmap_theme_path) != 0);
473         if (!pix_d->pixbuf || theme_changed) {
474                 GdkPixbuf *pix = NULL;
475                 
476                 if (theme_changed && pix_d->pixmap) {
477                         g_object_unref(pix_d->pixmap);
478                         pix_d->pixmap = NULL;
479                 }
480
481                 if (strcmp(prefs_common.pixmap_theme_path, DEFAULT_PIXMAP_THEME) != 0) {
482                         if (is_dir_exist(prefs_common.pixmap_theme_path)) {
483                                 char *icon_file_name; 
484 try_next_extension:                             
485                                 icon_file_name = g_strconcat(prefs_common.pixmap_theme_path,
486                                                              G_DIR_SEPARATOR_S,
487                                                              pix_d->file,
488                                                              extension[i],
489                                                              NULL);
490                                 if (is_file_exist(icon_file_name)) {
491                                         GError *err = NULL;
492                                         pix = gdk_pixbuf_new_from_file(icon_file_name, &err);   
493                                         if (err) g_error_free(err);
494                                 }                                       
495                                 if (pix) {
496                                         g_free(pix_d->icon_path);
497                                         pix_d->icon_path = g_strdup(prefs_common.pixmap_theme_path);
498                                 }
499                                 g_free(icon_file_name);
500                                 if (!pix) {
501                                         i++;
502                                         if (extension[i])
503                                                 goto try_next_extension;
504                                 }
505                         } else {
506                                 /* even the path does not exist (deleted between two sessions), so
507                                 set the preferences to the internal theme */
508                                 prefs_common.pixmap_theme_path = g_strdup(DEFAULT_PIXMAP_THEME);
509                         }
510                 }
511                 pix_d->pixbuf = pix;
512         }
513
514         if (!pix_d->pixbuf) {
515                 pix_d->pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **) pix_d->data);
516                 if (pix_d->pixbuf) {
517                         g_free(pix_d->icon_path);
518                         pix_d->icon_path = g_strdup(DEFAULT_PIXMAP_THEME);      
519                 }
520         }
521
522         cm_return_val_if_fail(pix_d->pixbuf != NULL, -1);
523
524         if (pixbuf)
525                 *pixbuf = pix_d->pixbuf;
526
527         /* pixbuf should have one ref outstanding */            
528
529         return 0;
530 }
531
532 static void stock_pixmap_find_themes_in_dir(GList **list, const gchar *dirname)
533 {
534         const gchar *entry;
535         gchar *fullentry;
536         GDir *dp;
537         GError *error = NULL;
538         static const char *extension[]={".png", ".xpm", NULL};
539         
540         if ((dp = g_dir_open(dirname, 0, &error)) == NULL) {
541                 debug_print("skipping theme scan, dir %s could not be opened: %s (%d)\n",
542                                 dirname ? dirname : "(null)", error->message, error->code);
543                 g_error_free(error);
544                 return;
545         }
546         
547         while ((entry = g_dir_read_name(dp)) != NULL) {
548                 fullentry = g_strconcat(dirname, G_DIR_SEPARATOR_S, entry, NULL);
549                 
550                 if (strcmp(entry, ".") != 0 && strcmp(entry, "..") != 0 && is_dir_exist(fullentry)) {
551                         gchar *filetoexist;
552                         gboolean found = FALSE;
553                         int i;
554                         int j;
555                         for (i = 0; i < N_STOCK_PIXMAPS && !found; i++) {
556                                 for (j = 0; extension[j] && !found; j++) {
557                                         filetoexist = g_strconcat(fullentry, G_DIR_SEPARATOR_S, pixmaps[i].file, extension[j], NULL);
558                                         if (is_file_exist(filetoexist)) {
559                                                 *list = g_list_append(*list, fullentry);
560                                                 found = TRUE;
561                                         }
562                                         g_free(filetoexist);
563                                 }
564                         }
565                         if (i == N_STOCK_PIXMAPS) 
566                                 g_free(fullentry);
567                 } else 
568                         g_free(fullentry);
569         }
570         g_dir_close(dp);
571 }
572
573 gchar *stock_pixmap_get_system_theme_dir_for_theme(const gchar *theme)
574 {
575         const gchar *sep = NULL;
576         if (theme && *theme)
577                 sep = G_DIR_SEPARATOR_S;
578 #ifndef G_OS_WIN32
579         return g_strconcat(PACKAGE_DATA_DIR, G_DIR_SEPARATOR_S,
580                            PIXMAP_THEME_DIR, sep, theme, NULL);
581 #else
582         return g_strconcat(w32_get_themes_dir(), sep, theme, NULL);
583 #endif
584 }
585
586 GList *stock_pixmap_themes_list_new(void)
587 {
588         gchar *defaulttheme;
589         gchar *userthemes;
590         gchar *systemthemes;
591         GList *list = NULL;
592         
593         defaulttheme = g_strdup(DEFAULT_PIXMAP_THEME);
594         userthemes   = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, 
595                                    PIXMAP_THEME_DIR, NULL);
596         systemthemes = stock_pixmap_get_system_theme_dir_for_theme(NULL);
597
598         list = g_list_append(list, defaulttheme);
599         stock_pixmap_find_themes_in_dir(&list, userthemes);
600         stock_pixmap_find_themes_in_dir(&list, systemthemes);
601
602         g_free(userthemes);
603         g_free(systemthemes);
604         return list;
605 }
606
607 void stock_pixmap_themes_list_free(GList *list)
608 {
609         GList *ptr;
610
611         for (ptr = g_list_first(list); ptr != NULL; ptr = g_list_next(ptr)) 
612                 g_free(ptr->data);
613         g_list_free(list);              
614 }
615
616 gchar *stock_pixmap_get_name (StockPixmap icon)
617 {
618         if (icon < 0 || icon >= N_STOCK_PIXMAPS)
619                 return NULL;
620         
621         return pixmaps[icon].file;
622
623 }
624
625 StockPixmap stock_pixmap_get_icon (gchar *file)
626 {
627         gint i;
628         
629         for (i = 0; i < N_STOCK_PIXMAPS; i++) {
630                 if (strcmp (pixmaps[i].file, file) == 0)
631                         return i;
632         }
633         return -1;
634 }
635
636 static gboolean do_pix_draw(GtkWidget *widget, cairo_t *cr,
637                             OverlayData *data) 
638 {
639         GdkWindow *drawable = gtk_widget_get_window(widget);    
640         gint left = 0;
641         gint top = 0;
642
643         if (data->is_pixmap) {
644                 cm_return_val_if_fail(data->base_pixmap != NULL, FALSE);
645         } else {
646                 cm_return_val_if_fail(data->base_pixbuf != NULL, FALSE);
647         }
648
649         if (data->highlight) {
650                 MainWindow *mw = NULL;
651
652                 mw = mainwindow_get_mainwindow();
653                 if (mw != NULL && mw->menubar != NULL) {
654                         cairo_t *cr;
655                         GdkColor color = gtk_widget_get_style(mw->menubar)->base[GTK_STATE_SELECTED];
656
657                         cr = gdk_cairo_create(drawable);
658                         gdk_cairo_set_source_color(cr, &color);
659                         cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
660                         cairo_set_line_width(cr, 1.);
661                         cairo_set_line_cap(cr, CAIRO_LINE_CAP_BUTT);
662                         cairo_set_line_join(cr, CAIRO_LINE_JOIN_BEVEL);
663                         cairo_rectangle(cr, data->border_x-2, data->border_y-2,
664                             data->base_width+3, data->base_height+3);
665                         cairo_stroke(cr);
666                         cairo_destroy(cr);
667                 }
668         }
669
670         if (data->is_pixmap) {
671                 cairo_set_source_surface(cr, data->base_pixmap, data->border_x, data->border_y);
672                 cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT);
673                 cairo_rectangle(cr, data->border_x, data->border_y, data->base_width, data->base_height);
674                 cairo_fill(cr);
675         } else {
676                 gdk_cairo_set_source_pixbuf(cr, data->base_pixbuf, data->border_x, data->border_y);
677                 cairo_paint(cr);
678         }
679
680         if (data->position != OVERLAY_NONE) {
681
682                 switch (data->position) {
683                         case OVERLAY_TOP_LEFT:
684                         case OVERLAY_MID_LEFT:
685                         case OVERLAY_BOTTOM_LEFT:
686                                 left = 0;
687                                 break;
688
689                         case OVERLAY_TOP_CENTER:
690                         case OVERLAY_MID_CENTER:
691                         case OVERLAY_BOTTOM_CENTER:
692                                 left = (data->base_width + data->border_x * 2 - data->overlay_width)/2;
693                                 break;
694
695                         case OVERLAY_TOP_RIGHT:
696                         case OVERLAY_MID_RIGHT:
697                         case OVERLAY_BOTTOM_RIGHT:
698                                 left = data->base_width + data->border_x * 2 - data->overlay_width;
699                                 break;
700
701                         default:
702                                 break;
703                 }
704                 switch (data->position) {
705                         case OVERLAY_TOP_LEFT:
706                         case OVERLAY_TOP_CENTER:
707                         case OVERLAY_TOP_RIGHT:
708                                 top = 0;
709                                 break;
710
711                         case OVERLAY_MID_LEFT:
712                         case OVERLAY_MID_CENTER:
713                         case OVERLAY_MID_RIGHT:
714                                 top = (data->base_height + data->border_y * 2 - data->overlay_height)/2;
715                                 break;
716                                         
717                         case OVERLAY_BOTTOM_LEFT:
718                         case OVERLAY_BOTTOM_CENTER:
719                         case OVERLAY_BOTTOM_RIGHT:
720                                 top = data->base_height + data->border_y * 2 - data->overlay_height;
721                                 break;
722
723                         default:
724                                 break;
725                 }
726         }
727
728         if (data->position != OVERLAY_NONE) {
729                 if (data->is_pixmap) {
730                         cm_return_val_if_fail(data->overlay_pixmap != NULL, FALSE);
731                         cairo_set_source_surface(cr, data->overlay_pixmap, left, top);
732                         cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
733                         cairo_rectangle (cr, left, top, data->overlay_width, data->overlay_height);
734                         cairo_fill(cr);
735                 } else {
736       cm_return_val_if_fail(data->overlay_pixbuf != NULL, FALSE);
737       gdk_cairo_set_source_pixbuf(cr, data->overlay_pixbuf, left, top);
738       cairo_paint(cr);
739                 }
740         }
741
742         return TRUE;
743 }
744
745 #if !GTK_CHECK_VERSION(3,0,0)
746 static gboolean pixmap_with_overlay_expose_event_cb(GtkWidget *widget, GdkEventExpose *expose,
747                                                    OverlayData *data) 
748 #else
749 static gboolean pixmap_with_overlay_expose_event_cb(GtkWidget *widget, cairo_t *cr,
750                                                     OverlayData *data) 
751 #endif
752 {
753 #if !GTK_CHECK_VERSION(3,0,0)
754         cairo_t *cr;
755         GdkWindow *drawable = gtk_widget_get_window(widget);    
756         gboolean result;
757
758         cr = gdk_cairo_create(drawable);
759         gdk_window_clear_area (drawable, expose->area.x, expose->area.y,
760                                expose->area.width, expose->area.height);
761
762         result = do_pix_draw(widget, cr, data);
763         cairo_destroy(cr);
764         return result;
765 #else
766         return do_pix_draw(widget, cr, data);
767 #endif
768 }
769
770 static void pixmap_with_overlay_destroy_cb(GtkWidget *object, OverlayData *data) 
771 {
772         if (data->is_pixmap) {
773                 cairo_surface_destroy(data->base_pixmap);
774                 if (data->position != OVERLAY_NONE) {
775                         cairo_surface_destroy(data->overlay_pixmap);
776                 }
777         } else {
778                 g_object_unref(data->base_pixbuf);
779                 if (data->position != OVERLAY_NONE) {
780                         g_object_unref(data->overlay_pixbuf);
781                 }
782         }
783         g_free(data);
784 }
785
786 /**
787  * \brief Get a widget showing one icon with another overlaid on top of it.
788  *
789  * The base icon is always centralised, the other icon can be positioned.
790  * The overlay icon is ignored if pos=OVERLAY_NONE is used
791  *
792  * \param window   top-level window widget
793  * \param icon     the base icon
794  * \param overlay  the icon to overlay
795  * \param pos      how to align the overlay widget, or OVERLAY_NONE for no overlay
796  * \param border_x size of the border around the base icon (left and right)
797  * \param border_y size of the border around the base icon (top and bottom)
798  */
799 GtkWidget *stock_pixmap_widget_with_overlay(StockPixmap icon,
800                                             StockPixmap overlay, OverlayPosition pos,
801                                             gint border_x, gint border_y)
802 {
803         cairo_surface_t *stock_pixmap = NULL;
804         GdkPixbuf *stock_pixbuf = NULL;
805         GtkWidget *widget = NULL;
806         GtkWidget *stock_wid = NULL;
807         GtkRequisition requisition;
808         OverlayData *data = NULL;
809         
810         data = g_new0(OverlayData, 1);
811
812         stock_wid = stock_pixmap_widget(icon);
813         gtk_widget_get_requisition(stock_wid, &requisition);
814
815 #if !GTK_CHECK_VERSION(3, 0, 0)
816         if (gtk_image_get_storage_type(GTK_IMAGE(stock_wid)) == GTK_IMAGE_PIXMAP)
817                 data->is_pixmap = TRUE;
818         else
819 #endif
820                 data->is_pixmap = FALSE;
821
822         if (data->is_pixmap) {
823                 cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(stock_wid));
824                 stock_pixmap = cairo_get_target(cr);
825                 cairo_surface_reference(stock_pixmap);
826                 cairo_destroy(cr);
827                 data->base_pixmap = stock_pixmap;
828                 data->base_height = requisition.height;
829                 data->base_width  = requisition.width;
830                 gtk_widget_destroy(stock_wid);
831
832                 if (pos == OVERLAY_NONE) {
833                         data->overlay_pixmap = NULL;
834                 } else {
835                         stock_wid = stock_pixmap_widget(overlay);
836                         cr = gdk_cairo_create(gtk_widget_get_window(stock_wid));
837                         stock_pixmap = cairo_get_target(cr);
838                         cairo_surface_reference(stock_pixmap);
839                         cairo_destroy(cr);
840                         data->overlay_pixmap = stock_pixmap;
841                         data->overlay_height = requisition.height;
842                         data->overlay_width  = requisition.width;
843
844                         gtk_widget_destroy(stock_wid);
845                 }
846         } else {
847                 data->is_pixmap = FALSE;
848                 stock_pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(stock_wid));
849                 g_object_ref(stock_pixbuf);
850                 data->base_pixbuf = stock_pixbuf;
851                 data->base_height = requisition.height;
852                 data->base_width  = requisition.width;
853                 gtk_widget_destroy(stock_wid);
854                 if (pos == OVERLAY_NONE) {
855                         data->overlay_pixmap = NULL;
856                 } else {
857                         stock_wid = stock_pixmap_widget(overlay);
858                         stock_pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(stock_wid));
859                         g_object_ref(stock_pixbuf);
860                         data->overlay_pixbuf = stock_pixbuf;
861                         data->overlay_height = requisition.height;
862                         data->overlay_width  = requisition.width;
863
864                         gtk_widget_destroy(stock_wid);
865                 }
866         }
867         data->position = pos;
868         data->border_x = border_x;
869         data->border_y = border_y;
870         data->highlight = FALSE;
871
872         widget = gtk_drawing_area_new();
873         gtk_widget_set_size_request(widget, data->base_width + border_x * 2, 
874                               data->base_height + border_y * 2);
875 #if !GTK_CHECK_VERSION(3, 0, 0)
876         g_signal_connect(G_OBJECT(widget), "expose_event", 
877                          G_CALLBACK(pixmap_with_overlay_expose_event_cb), data);
878 #else
879         g_signal_connect(G_OBJECT(widget), "draw", 
880                          G_CALLBACK(pixmap_with_overlay_expose_event_cb), data);
881 #endif
882         g_signal_connect(G_OBJECT(widget), "destroy",
883                          G_CALLBACK(pixmap_with_overlay_destroy_cb), data);
884         g_object_set_data(G_OBJECT(widget), "highlight", &(data->highlight));
885         return widget;
886
887 }