talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

stock_pixmap.c (34554B)


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