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