2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2012 Hiroyuki Yamamoto and the Claws Mail team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
27 #include "stock_pixmap.h"
30 #include "prefs_common.h"
32 #include "pixmaps/addr_one.xpm"
33 #include "pixmaps/addr_two.xpm"
34 #include "pixmaps/address.xpm"
35 #include "pixmaps/anonymous.xpm"
36 #include "pixmaps/book.xpm"
37 #include "pixmaps/category.xpm"
38 #include "pixmaps/checkbox_off.xpm"
39 #include "pixmaps/checkbox_on.xpm"
40 #include "pixmaps/clip.xpm"
41 #include "pixmaps/clipkey.xpm"
42 #include "pixmaps/complete.xpm"
43 #include "pixmaps/continue.xpm"
44 #include "pixmaps/deleted.xpm"
45 #include "pixmaps/error.xpm"
46 #include "pixmaps/edit_extern.xpm"
47 #include "pixmaps/forwarded.xpm"
48 #include "pixmaps/group.xpm"
49 #include "pixmaps/insert_file.xpm"
50 #include "pixmaps/interface.xpm"
51 #include "pixmaps/jpilot.xpm"
52 #include "pixmaps/key.xpm"
53 #include "pixmaps/key_gpg_signed.xpm"
54 #include "pixmaps/ldap.xpm"
55 #include "pixmaps/linewrap.xpm"
56 #include "pixmaps/linewrapcurrent.xpm"
57 #include "pixmaps/mark.xpm"
58 #include "pixmaps/locked.xpm"
59 #include "pixmaps/new.xpm"
60 #include "pixmaps/replied.xpm"
61 #include "pixmaps/replied_and_forwarded.xpm"
62 #include "pixmaps/close.xpm"
63 #include "pixmaps/down_arrow.xpm"
64 #include "pixmaps/up_arrow.xpm"
65 #include "pixmaps/exec.xpm"
66 #include "pixmaps/mail.xpm"
67 #include "pixmaps/mail_attach.xpm"
68 #include "pixmaps/mail_compose.xpm"
69 #include "pixmaps/mail_forward.xpm"
70 #include "pixmaps/mail_receive.xpm"
71 #include "pixmaps/mail_receive_all.xpm"
72 #include "pixmaps/mail_reply.xpm"
73 #include "pixmaps/mail_reply_to_all.xpm"
74 #include "pixmaps/mail_reply_to_author.xpm"
75 #include "pixmaps/mail_reply_to_list.xpm"
76 #include "pixmaps/mail_send.xpm"
77 #include "pixmaps/mail_send_queue.xpm"
78 #include "pixmaps/mail_sign.xpm"
79 #include "pixmaps/open_mail.xpm"
80 #include "pixmaps/news_compose.xpm"
81 #include "pixmaps/paste.xpm"
82 #include "pixmaps/preferences.xpm"
83 #include "pixmaps/properties.xpm"
84 #include "pixmaps/queue_close.xpm"
85 #include "pixmaps/queue_close_hrm.xpm"
86 #include "pixmaps/queue_open.xpm"
87 #include "pixmaps/queue_open_hrm.xpm"
88 #include "pixmaps/claws-mail_icon.xpm"
89 #include "pixmaps/claws-mail_compose_logo.xpm"
91 #include "pixmaps/claws-mail_logo.xpm"
93 #include "pixmaps/claws-mail_logo-small.xpm"
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"
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.xpm"
150 #include "pixmaps/delete_btn.xpm"
151 #include "pixmaps/cancel.xpm"
152 #include "pixmaps/trash_btn.xpm"
153 #include "pixmaps/trash_hrm.xpm"
154 #include "pixmaps/drafts_close.xpm"
155 #include "pixmaps/drafts_open.xpm"
156 #include "pixmaps/dir_close_mark.xpm"
157 #include "pixmaps/dir_close_hrm_mark.xpm"
158 #include "pixmaps/dir_open_mark.xpm"
159 #include "pixmaps/dir_open_hrm_mark.xpm"
160 #include "pixmaps/inbox_open_mark.xpm"
161 #include "pixmaps/inbox_open_hrm_mark.xpm"
162 #include "pixmaps/inbox_close_mark.xpm"
163 #include "pixmaps/inbox_close_hrm_mark.xpm"
164 #include "pixmaps/outbox_open_mark.xpm"
165 #include "pixmaps/outbox_open_hrm_mark.xpm"
166 #include "pixmaps/outbox_close_mark.xpm"
167 #include "pixmaps/outbox_close_hrm_mark.xpm"
168 #include "pixmaps/trash_mark.xpm"
169 #include "pixmaps/queue_close_mark.xpm"
170 #include "pixmaps/queue_close_hrm_mark.xpm"
171 #include "pixmaps/queue_open_mark.xpm"
172 #include "pixmaps/queue_open_hrm_mark.xpm"
173 #include "pixmaps/trash_hrm_mark.xpm"
174 #include "pixmaps/drafts_close_mark.xpm"
175 #include "pixmaps/drafts_open_mark.xpm"
176 #include "pixmaps/dir_noselect.xpm"
177 #include "pixmaps/spam.xpm"
178 #include "pixmaps/spam_btn.xpm"
179 #include "pixmaps/ham_btn.xpm"
180 #include "pixmaps/moved.xpm"
181 #include "pixmaps/copied.xpm"
182 #include "pixmaps/selection.xpm"
183 #include "pixmaps/watchthread.xpm"
184 #include "pixmaps/empty.xpm"
185 #include "pixmaps/tray_newmail.offline.xpm"
186 #include "pixmaps/tray_newmail.xpm"
187 #include "pixmaps/tray_newmarkedmail.offline.xpm"
188 #include "pixmaps/tray_newmarkedmail.xpm"
189 #include "pixmaps/tray_nomail.offline.xpm"
190 #include "pixmaps/tray_nomail.xpm"
191 #include "pixmaps/tray_unreadmail.offline.xpm"
192 #include "pixmaps/tray_unreadmail.xpm"
193 #include "pixmaps/tray_unreadmarkedmail.offline.xpm"
194 #include "pixmaps/tray_unreadmarkedmail.xpm"
196 typedef struct _StockPixmapData StockPixmapData
;
198 struct _StockPixmapData
201 cairo_surface_t
*pixmap
;
202 cairo_pattern_t
*mask
;
208 typedef struct _OverlayData OverlayData
;
213 cairo_surface_t
*base_pixmap
;
214 cairo_surface_t
*overlay_pixmap
;
216 GdkPixbuf
*base_pixbuf
;
217 GdkPixbuf
*overlay_pixbuf
;
221 guint overlay_height
;
223 OverlayPosition position
;
229 static void stock_pixmap_find_themes_in_dir(GList
**list
, const gchar
*dirname
);
231 static StockPixmapData pixmaps
[] =
233 {addr_one_xpm
, NULL
, NULL
, "addr_one", NULL
},
234 {addr_two_xpm
, NULL
, NULL
, "addr_two", NULL
},
235 {address_xpm
, NULL
, NULL
, "address", NULL
},
236 {address_book_xpm
, NULL
, NULL
, "address_book", NULL
},
237 {address_search_xpm
, NULL
, NULL
, "address_search", NULL
},
238 {anonymous_xpm
, NULL
, NULL
, "anonymous", NULL
},
239 {book_xpm
, NULL
, NULL
, "book", NULL
},
240 {category_xpm
, NULL
, NULL
, "category", NULL
},
241 {checkbox_off_xpm
, NULL
, NULL
, "checkbox_off", NULL
},
242 {checkbox_on_xpm
, NULL
, NULL
, "checkbox_on", NULL
},
243 {check_spelling_xpm
, NULL
, NULL
, "check_spelling", NULL
},
244 {clip_xpm
, NULL
, NULL
, "clip", NULL
},
245 {clipkey_xpm
, NULL
, NULL
, "clipkey", NULL
},
246 {clip_gpg_signed_xpm
, NULL
, NULL
, "clip_gpg_signed", NULL
},
247 {close_xpm
, NULL
, NULL
, "close", NULL
},
248 {complete_xpm
, NULL
, NULL
, "complete", NULL
},
249 {continue_xpm
, NULL
, NULL
, "continue", NULL
},
250 {deleted_xpm
, NULL
, NULL
, "deleted", NULL
},
251 {dir_close_xpm
, NULL
, NULL
, "dir_close", NULL
},
252 {dir_close_hrm_xpm
, NULL
, NULL
, "dir_close_hrm", NULL
},
253 {dir_open_xpm
, NULL
, NULL
, "dir_open", NULL
},
254 {dir_open_hrm_xpm
, NULL
, NULL
, "dir_open_hrm", NULL
},
255 {dir_close_mark_xpm
, NULL
, NULL
, "dir_close_mark", NULL
},
256 {dir_close_hrm_mark_xpm
, NULL
, NULL
, "dir_close_hrm_mark", NULL
},
257 {dir_open_mark_xpm
, NULL
, NULL
, "dir_open_mark", NULL
},
258 {dir_open_hrm_mark_xpm
, NULL
, NULL
, "dir_open_hrm_mark", NULL
},
259 {down_arrow_xpm
, NULL
, NULL
, "down_arrow", NULL
},
260 {up_arrow_xpm
, NULL
, NULL
, "up_arrow", NULL
},
261 {edit_extern_xpm
, NULL
, NULL
, "edit_extern", NULL
},
262 {error_xpm
, NULL
, NULL
, "error", NULL
},
263 {exec_xpm
, NULL
, NULL
, "exec", NULL
},
264 {forwarded_xpm
, NULL
, NULL
, "forwarded", NULL
},
265 {group_xpm
, NULL
, NULL
, "group", NULL
},
266 {ignorethread_xpm
, NULL
, NULL
, "ignorethread", NULL
},
267 {inbox_close_xpm
, NULL
, NULL
, "inbox_close", NULL
},
268 {inbox_close_hrm_xpm
, NULL
, NULL
, "inbox_close_hrm", NULL
},
269 {inbox_open_xpm
, NULL
, NULL
, "inbox_open", NULL
},
270 {inbox_open_hrm_xpm
, NULL
, NULL
, "inbox_open_hrm", NULL
},
271 {inbox_close_mark_xpm
, NULL
, NULL
, "inbox_close_mark", NULL
},
272 {inbox_close_hrm_mark_xpm
, NULL
, NULL
, "inbox_close_hrm_mark", NULL
},
273 {inbox_open_mark_xpm
, NULL
, NULL
, "inbox_open_mark", NULL
},
274 {inbox_open_hrm_mark_xpm
, NULL
, NULL
, "inbox_open_hrm_mark", NULL
},
275 {insert_file_xpm
, NULL
, NULL
, "insert_file", NULL
},
276 {interface_xpm
, NULL
, NULL
, "interface", NULL
},
277 {jpilot_xpm
, NULL
, NULL
, "jpilot", NULL
},
278 {key_xpm
, NULL
, NULL
, "key", NULL
},
279 {key_gpg_signed_xpm
, NULL
, NULL
, "key_gpg_signed", NULL
},
280 {ldap_xpm
, NULL
, NULL
, "ldap", NULL
},
281 {linewrapcurrent_xpm
, NULL
, NULL
, "linewrapcurrent", NULL
},
282 {linewrap_xpm
, NULL
, NULL
, "linewrap", NULL
},
283 {locked_xpm
, NULL
, NULL
, "locked", NULL
},
284 {mail_xpm
, NULL
, NULL
, "mail", NULL
},
285 {mail_attach_xpm
, NULL
, NULL
, "mail_attach", NULL
},
286 {mail_compose_xpm
, NULL
, NULL
, "mail_compose", NULL
},
287 {mail_forward_xpm
, NULL
, NULL
, "mail_forward", NULL
},
288 {mail_receive_xpm
, NULL
, NULL
, "mail_receive", NULL
},
289 {mail_receive_all_xpm
, NULL
, NULL
, "mail_receive_all", NULL
},
290 {mail_reply_xpm
, NULL
, NULL
, "mail_reply", NULL
},
291 {mail_reply_to_all_xpm
, NULL
, NULL
, "mail_reply_to_all", NULL
},
292 {mail_reply_to_author_xpm
, NULL
, NULL
, "mail_reply_to_author", NULL
},
293 {mail_reply_to_list_xpm
, NULL
, NULL
, "mail_reply_to_list", NULL
},
294 {mail_send_xpm
, NULL
, NULL
, "mail_send", NULL
},
295 {mail_send_queue_xpm
, NULL
, NULL
, "mail_send_queue", NULL
},
296 {mail_sign_xpm
, NULL
, NULL
, "mail_sign", NULL
},
297 {open_mail_xpm
, NULL
, NULL
, "open_mail", NULL
},
298 {mark_xpm
, NULL
, NULL
, "mark", NULL
},
299 {new_xpm
, NULL
, NULL
, "new", NULL
},
300 {news_compose_xpm
, NULL
, NULL
, "news_compose", NULL
},
301 {outbox_close_xpm
, NULL
, NULL
, "outbox_close", NULL
},
302 {outbox_close_hrm_xpm
, NULL
, NULL
, "outbox_close_hrm", NULL
},
303 {outbox_open_xpm
, NULL
, NULL
, "outbox_open", NULL
},
304 {outbox_open_hrm_xpm
, NULL
, NULL
, "outbox_open_hrm", NULL
},
305 {outbox_close_mark_xpm
, NULL
, NULL
, "outbox_close_mark", NULL
},
306 {outbox_close_hrm_mark_xpm
, NULL
, NULL
, "outbox_close_hrm_mark", NULL
},
307 {outbox_open_mark_xpm
, NULL
, NULL
, "outbox_open_mark", NULL
},
308 {outbox_open_hrm_mark_xpm
, NULL
, NULL
, "outbox_open_hrm_mark", NULL
},
309 {replied_xpm
, NULL
, NULL
, "replied", NULL
},
310 {replied_and_forwarded_xpm
, NULL
, NULL
, "replied_and_forwarded", NULL
},
311 {paste_xpm
, NULL
, NULL
, "paste", NULL
},
312 {preferences_xpm
, NULL
, NULL
, "preferences", NULL
},
313 {properties_xpm
, NULL
, NULL
, "properties", NULL
},
314 {queue_close_xpm
, NULL
, NULL
, "queue_close", NULL
},
315 {queue_close_hrm_xpm
, NULL
, NULL
, "queue_close_hrm", NULL
},
316 {queue_open_xpm
, NULL
, NULL
, "queue_open", NULL
},
317 {queue_open_hrm_xpm
, NULL
, NULL
, "queue_open_hrm", NULL
},
318 {trash_xpm
, NULL
, NULL
, "trash_open", NULL
},
319 {trash_hrm_xpm
, NULL
, NULL
, "trash_open_hrm", NULL
},
320 {trash_xpm
, NULL
, NULL
, "trash_close", NULL
},
321 {trash_hrm_xpm
, NULL
, NULL
, "trash_close_hrm", NULL
},
322 {queue_close_mark_xpm
, NULL
, NULL
, "queue_close_mark", NULL
},
323 {queue_close_hrm_mark_xpm
, NULL
, NULL
, "queue_close_hrm_mark", NULL
},
324 {queue_open_mark_xpm
, NULL
, NULL
, "queue_open_mark", NULL
},
325 {queue_open_hrm_mark_xpm
, NULL
, NULL
, "queue_open_hrm_mark", NULL
},
326 {trash_mark_xpm
, NULL
, NULL
, "trash_open_mark", NULL
},
327 {trash_hrm_mark_xpm
, NULL
, NULL
, "trash_open_hrm_mark", NULL
},
328 {trash_mark_xpm
, NULL
, NULL
, "trash_close_mark", NULL
},
329 {trash_hrm_mark_xpm
, NULL
, NULL
, "trash_close_hrm_mark", NULL
},
330 {unread_xpm
, NULL
, NULL
, "unread", NULL
},
331 {vcard_xpm
, NULL
, NULL
, "vcard", NULL
},
332 {online_xpm
, NULL
, NULL
, "online", NULL
},
333 {offline_xpm
, NULL
, NULL
, "offline", NULL
},
334 {notice_warn_xpm
, NULL
, NULL
, "notice_warn", NULL
},
335 {notice_error_xpm
, NULL
, NULL
, "notice_error", NULL
},
336 {notice_note_xpm
, NULL
, NULL
, "notice_note", NULL
},
337 {quicksearch_xpm
, NULL
, NULL
, "quicksearch", NULL
},
338 {gpg_signed_xpm
, NULL
, NULL
, "gpg_signed", NULL
},
339 {go_folders_xpm
, NULL
, NULL
, "go_folders", NULL
},
340 {drafts_close_xpm
, NULL
, NULL
, "drafts_close", NULL
},
341 {drafts_open_xpm
, NULL
, NULL
, "drafts_open", NULL
},
342 {drafts_close_mark_xpm
, NULL
, NULL
, "drafts_close_mark", NULL
},
343 {drafts_open_mark_xpm
, NULL
, NULL
, "drafts_open_mark", NULL
},
344 {mime_text_plain_xpm
, NULL
, NULL
, "mime_text_plain", NULL
},
345 {mime_text_html_xpm
, NULL
, NULL
, "mime_text_html", NULL
},
346 {mime_text_patch_xpm
, NULL
, NULL
, "mime_text_patch", NULL
},
347 {mime_application_xpm
, NULL
, NULL
, "mime_application", NULL
},
348 {mime_image_xpm
, NULL
, NULL
, "mime_image", NULL
},
349 {mime_audio_xpm
, NULL
, NULL
, "mime_audio", NULL
},
350 {mime_text_enriched_xpm
, NULL
, NULL
, "mime_text_enriched", NULL
},
351 {mime_unknown_xpm
, NULL
, NULL
, "mime_unknown", NULL
},
352 {mime_pdf_xpm
, NULL
, NULL
, "mime_pdf", NULL
},
353 {mime_ps_xpm
, NULL
, NULL
, "mime_ps", NULL
},
354 {mime_calendar_xpm
, NULL
, NULL
, "mime_calendar", NULL
},
355 {mime_pgpsig_xpm
, NULL
, NULL
, "mime_pgpsig", NULL
},
356 {printer_xpm
, NULL
, NULL
, "printer", NULL
},
357 {privacy_signed_xpm
, NULL
, NULL
, "privacy_signed", NULL
},
358 {privacy_passed_xpm
, NULL
, NULL
, "privacy_passed", NULL
},
359 {privacy_failed_xpm
, NULL
, NULL
, "privacy_failed", NULL
},
360 {privacy_unknown_xpm
, NULL
, NULL
, "privacy_unknown", NULL
},
361 {privacy_expired_xpm
, NULL
, NULL
, "privacy_expired", NULL
},
362 {privacy_warn_xpm
, NULL
, NULL
, "privacy_warn", NULL
},
363 {privacy_emblem_encrypted_xpm
, NULL
, NULL
, "privacy_emblem_encrypted", NULL
},
364 {privacy_emblem_signed_xpm
, NULL
, NULL
, "privacy_emblem_signed", NULL
},
365 {privacy_emblem_passed_xpm
, NULL
, NULL
, "privacy_emblem_passed", NULL
},
366 {privacy_emblem_failed_xpm
, NULL
, NULL
, "privacy_emblem_failed", NULL
},
367 {privacy_emblem_warn_xpm
, NULL
, NULL
, "privacy_emblem_warn", NULL
},
368 {mime_message_xpm
, NULL
, NULL
, "mime_message", NULL
},
369 {claws_mail_icon_xpm
, NULL
, NULL
, "claws_mail_icon", NULL
},
370 {read_xpm
, NULL
, NULL
, "read", NULL
},
371 {delete_btn_xpm
, NULL
, NULL
, "delete_btn", NULL
},
372 {cancel_xpm
, NULL
, NULL
, "cancel", NULL
},
373 {trash_btn_xpm
, NULL
, NULL
, "trash_btn", NULL
},
374 {claws_mail_compose_logo_xpm
, NULL
, NULL
, "claws_mail_compose_logo", NULL
},
376 {claws_mail_logo_xpm
, NULL
, NULL
, "claws_mail_logo", NULL
},
378 {claws_mail_logo_small_xpm
, NULL
, NULL
, "claws_mail_logo_small", NULL
},
380 {dir_noselect_xpm
, NULL
, NULL
, "dir_noselect" , NULL
},
381 {spam_xpm
, NULL
, NULL
, "spam" , NULL
},
382 {spam_btn_xpm
, NULL
, NULL
, "spam_btn" , NULL
},
383 {ham_btn_xpm
, NULL
, NULL
, "ham_btn" , NULL
},
384 {moved_xpm
, NULL
, NULL
, "moved", NULL
},
385 {copied_xpm
, NULL
, NULL
, "copied", NULL
},
386 {selection_xpm
, NULL
, NULL
, "selection", NULL
},
387 {watchthread_xpm
, NULL
, NULL
, "watchthread", NULL
},
388 {tray_newmail_offline_xpm
, NULL
, NULL
, "tray_newmail.offline", NULL
},
389 {tray_newmail_xpm
, NULL
, NULL
, "tray_newmail", NULL
},
390 {tray_newmarkedmail_offline_xpm
, NULL
, NULL
, "tray_newmarkedmail.offline", NULL
},
391 {tray_newmarkedmail_xpm
, NULL
, NULL
, "tray_newmarkedmail", NULL
},
392 {tray_nomail_offline_xpm
, NULL
, NULL
, "tray_nomail.offline", NULL
},
393 {tray_nomail_xpm
, NULL
, NULL
, "tray_nomail", NULL
},
394 {tray_unreadmail_offline_xpm
, NULL
, NULL
, "tray_unreadmail.offline", NULL
},
395 {tray_unreadmail_xpm
, NULL
, NULL
, "tray_unreadmail", NULL
},
396 {tray_unreadmarkedmail_offline_xpm
, NULL
, NULL
, "tray_unreadmarkedmail.offline", NULL
},
397 {tray_unreadmarkedmail_xpm
, NULL
, NULL
, "tray_unreadmarkedmail", NULL
},
398 {empty_xpm
, NULL
, NULL
, "empty" , NULL
}
401 /* return newly constructed GtkPixmap from GdkPixmap */
402 GtkWidget
*stock_pixmap_widget(GtkWidget
*window
, StockPixmap icon
)
406 cm_return_val_if_fail(window
!= NULL
, NULL
);
407 cm_return_val_if_fail(icon
>= 0 && icon
< N_STOCK_PIXMAPS
, NULL
);
409 if (stock_pixbuf_gdk(window
, icon
, &pixbuf
) != -1)
410 return gtk_image_new_from_pixbuf(pixbuf
);
418 gint
stock_pixbuf_gdk(GtkWidget
*window
, StockPixmap icon
, GdkPixbuf
**pixbuf
)
420 StockPixmapData
*pix_d
;
421 static const char *extension
[]={".png", ".xpm", NULL
};
423 gboolean theme_changed
= FALSE
;
428 cm_return_val_if_fail(icon
>= 0 && icon
< N_STOCK_PIXMAPS
, -1);
430 pix_d
= &pixmaps
[icon
];
432 theme_changed
= (strcmp2(pix_d
->icon_path
, prefs_common
.pixmap_theme_path
) != 0);
433 if (!pix_d
->pixbuf
|| theme_changed
) {
434 GdkPixbuf
*pix
= NULL
;
436 if (theme_changed
&& pix_d
->pixmap
) {
437 g_object_unref(pix_d
->pixmap
);
438 pix_d
->pixmap
= NULL
;
441 if (strcmp(prefs_common
.pixmap_theme_path
, DEFAULT_PIXMAP_THEME
) != 0) {
442 if (is_dir_exist(prefs_common
.pixmap_theme_path
)) {
443 char *icon_file_name
;
445 icon_file_name
= g_strconcat(prefs_common
.pixmap_theme_path
,
450 if (is_file_exist(icon_file_name
)) {
452 pix
= gdk_pixbuf_new_from_file(icon_file_name
, &err
);
453 if (err
) g_error_free(err
);
456 g_free(pix_d
->icon_path
);
457 pix_d
->icon_path
= g_strdup(prefs_common
.pixmap_theme_path
);
459 g_free(icon_file_name
);
463 goto try_next_extension
;
466 /* even the path does not exist (deleted between two sessions), so
467 set the preferences to the internal theme */
468 prefs_common
.pixmap_theme_path
= g_strdup(DEFAULT_PIXMAP_THEME
);
474 if (!pix_d
->pixbuf
) {
475 pix_d
->pixbuf
= gdk_pixbuf_new_from_xpm_data((const gchar
**) pix_d
->data
);
477 g_free(pix_d
->icon_path
);
478 pix_d
->icon_path
= g_strdup(DEFAULT_PIXMAP_THEME
);
482 cm_return_val_if_fail(pix_d
->pixbuf
!= NULL
, -1);
485 *pixbuf
= pix_d
->pixbuf
;
487 /* pixbuf should have one ref outstanding */
492 static void stock_pixmap_find_themes_in_dir(GList
**list
, const gchar
*dirname
)
496 static const char *extension
[]={".png", ".xpm", NULL
};
498 if ((dp
= opendir(dirname
)) == NULL
) {
499 debug_print("dir %s not found, skipping theme scan\n", dirname
?dirname
:"(null)");
503 while ((d
= readdir(dp
)) != NULL
) {
508 fullentry
= g_strconcat(dirname
, G_DIR_SEPARATOR_S
, entry
, NULL
);
510 if (strcmp(entry
, ".") != 0 && strcmp(entry
, "..") != 0 && is_dir_exist(fullentry
)) {
512 gboolean found
= FALSE
;
515 for (i
= 0; i
< N_STOCK_PIXMAPS
&& !found
; i
++) {
516 for (j
= 0; extension
[j
] && !found
; j
++) {
517 filetoexist
= g_strconcat(fullentry
, G_DIR_SEPARATOR_S
, pixmaps
[i
].file
, extension
[j
], NULL
);
518 if (is_file_exist(filetoexist
)) {
519 *list
= g_list_append(*list
, fullentry
);
525 if (i
== N_STOCK_PIXMAPS
)
533 gchar
*stock_pixmap_get_system_theme_dir_for_theme(const gchar
*theme
)
535 const gchar
*sep
= NULL
;
537 sep
= G_DIR_SEPARATOR_S
;
539 return g_strconcat(PACKAGE_DATA_DIR
, G_DIR_SEPARATOR_S
,
540 PIXMAP_THEME_DIR
, sep
, theme
, NULL
);
542 return g_strconcat(get_themes_dir(), sep
, theme
, NULL
);
546 GList
*stock_pixmap_themes_list_new(void)
553 defaulttheme
= g_strdup(DEFAULT_PIXMAP_THEME
);
554 userthemes
= g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S
,
555 PIXMAP_THEME_DIR
, NULL
);
556 systemthemes
= stock_pixmap_get_system_theme_dir_for_theme(NULL
);
558 list
= g_list_append(list
, defaulttheme
);
559 stock_pixmap_find_themes_in_dir(&list
, userthemes
);
560 stock_pixmap_find_themes_in_dir(&list
, systemthemes
);
563 g_free(systemthemes
);
567 void stock_pixmap_themes_list_free(GList
*list
)
571 for (ptr
= g_list_first(list
); ptr
!= NULL
; ptr
= g_list_next(ptr
))
576 gchar
*stock_pixmap_get_name (StockPixmap icon
)
578 if (icon
< 0 || icon
>= N_STOCK_PIXMAPS
)
581 return pixmaps
[icon
].file
;
585 StockPixmap
stock_pixmap_get_icon (gchar
*file
)
589 for (i
= 0; i
< N_STOCK_PIXMAPS
; i
++) {
590 if (strcmp (pixmaps
[i
].file
, file
) == 0)
596 static gboolean
do_pix_draw(GtkWidget
*widget
, cairo_t
*cr
,
599 GdkWindow
*drawable
= gtk_widget_get_window(widget
);
603 if (data
->is_pixmap
) {
604 cm_return_val_if_fail(data
->base_pixmap
!= NULL
, FALSE
);
606 cm_return_val_if_fail(data
->base_pixbuf
!= NULL
, FALSE
);
609 if (data
->highlight
) {
610 MainWindow
*mw
= NULL
;
612 mw
= mainwindow_get_mainwindow();
613 if (mw
!= NULL
&& mw
->menubar
!= NULL
) {
615 GdkColor color
= gtk_widget_get_style(mw
->menubar
)->base
[GTK_STATE_SELECTED
];
617 cr
= gdk_cairo_create(drawable
);
618 gdk_cairo_set_source_color(cr
, &color
);
619 cairo_set_antialias(cr
, CAIRO_ANTIALIAS_NONE
);
620 cairo_set_line_width(cr
, 1.);
621 cairo_set_line_cap(cr
, CAIRO_LINE_CAP_BUTT
);
622 cairo_set_line_join(cr
, CAIRO_LINE_JOIN_BEVEL
);
623 cairo_rectangle(cr
, data
->border_x
-2, data
->border_y
-2,
624 data
->base_width
+3, data
->base_height
+3);
630 if (data
->is_pixmap
) {
631 cairo_set_source_surface(cr
, data
->base_pixmap
, data
->border_x
, data
->border_y
);
632 cairo_pattern_set_extend(cairo_get_source(cr
), CAIRO_EXTEND_REPEAT
);
633 cairo_rectangle(cr
, data
->border_x
, data
->border_y
, data
->base_width
, data
->base_height
);
636 gdk_cairo_set_source_pixbuf(cr
, data
->base_pixbuf
, data
->border_x
, data
->border_y
);
640 if (data
->position
!= OVERLAY_NONE
) {
642 switch (data
->position
) {
643 case OVERLAY_TOP_LEFT
:
644 case OVERLAY_MID_LEFT
:
645 case OVERLAY_BOTTOM_LEFT
:
649 case OVERLAY_TOP_CENTER
:
650 case OVERLAY_MID_CENTER
:
651 case OVERLAY_BOTTOM_CENTER
:
652 left
= (data
->base_width
+ data
->border_x
* 2 - data
->overlay_width
)/2;
655 case OVERLAY_TOP_RIGHT
:
656 case OVERLAY_MID_RIGHT
:
657 case OVERLAY_BOTTOM_RIGHT
:
658 left
= data
->base_width
+ data
->border_x
* 2 - data
->overlay_width
;
664 switch (data
->position
) {
665 case OVERLAY_TOP_LEFT
:
666 case OVERLAY_TOP_CENTER
:
667 case OVERLAY_TOP_RIGHT
:
671 case OVERLAY_MID_LEFT
:
672 case OVERLAY_MID_CENTER
:
673 case OVERLAY_MID_RIGHT
:
674 top
= (data
->base_height
+ data
->border_y
* 2 - data
->overlay_height
)/2;
677 case OVERLAY_BOTTOM_LEFT
:
678 case OVERLAY_BOTTOM_CENTER
:
679 case OVERLAY_BOTTOM_RIGHT
:
680 top
= data
->base_height
+ data
->border_y
* 2 - data
->overlay_height
;
688 if (data
->position
!= OVERLAY_NONE
) {
689 if (data
->is_pixmap
) {
690 cm_return_val_if_fail(data
->overlay_pixmap
!= NULL
, FALSE
);
691 cairo_set_source_surface(cr
, data
->overlay_pixmap
, left
, top
);
692 cairo_pattern_set_extend (cairo_get_source (cr
), CAIRO_EXTEND_REPEAT
);
693 cairo_rectangle (cr
, left
, top
, data
->overlay_width
, data
->overlay_height
);
696 cm_return_val_if_fail(data
->overlay_pixbuf
!= NULL
, FALSE
);
697 gdk_cairo_set_source_pixbuf(cr
, data
->overlay_pixbuf
, left
, top
);
705 #if !GTK_CHECK_VERSION(3,0,0)
706 static gboolean
pixmap_with_overlay_expose_event_cb(GtkWidget
*widget
, GdkEventExpose
*expose
,
709 static gboolean
pixmap_with_overlay_expose_event_cb(GtkWidget
*widget
, cairo_t
*cr
,
713 #if !GTK_CHECK_VERSION(3,0,0)
715 GdkWindow
*drawable
= gtk_widget_get_window(widget
);
718 cr
= gdk_cairo_create(drawable
);
719 gdk_window_clear_area (drawable
, expose
->area
.x
, expose
->area
.y
,
720 expose
->area
.width
, expose
->area
.height
);
722 result
= do_pix_draw(widget
, cr
, data
);
726 return do_pix_draw(widget
, cr
, data
);
730 static void pixmap_with_overlay_destroy_cb(GtkWidget
*object
, OverlayData
*data
)
732 if (data
->is_pixmap
) {
733 cairo_surface_destroy(data
->base_pixmap
);
734 if (data
->position
!= OVERLAY_NONE
) {
735 cairo_surface_destroy(data
->overlay_pixmap
);
738 g_object_unref(data
->base_pixbuf
);
739 if (data
->position
!= OVERLAY_NONE
) {
740 g_object_unref(data
->overlay_pixbuf
);
747 * \brief Get a widget showing one icon with another overlaid on top of it.
749 * The base icon is always centralised, the other icon can be positioned.
750 * The overlay icon is ignored if pos=OVERLAY_NONE is used
752 * \param window top-level window widget
753 * \param icon the base icon
754 * \param overlay the icon to overlay
755 * \param pos how to align the overlay widget, or OVERLAY_NONE for no overlay
756 * \param border_x size of the border around the base icon (left and right)
757 * \param border_y size of the border around the base icon (top and bottom)
759 GtkWidget
*stock_pixmap_widget_with_overlay(GtkWidget
*window
, StockPixmap icon
,
760 StockPixmap overlay
, OverlayPosition pos
,
761 gint border_x
, gint border_y
)
763 cairo_surface_t
*stock_pixmap
= NULL
;
764 GdkPixbuf
*stock_pixbuf
= NULL
;
765 GtkWidget
*widget
= NULL
;
766 GtkWidget
*stock_wid
= NULL
;
767 GtkRequisition requisition
;
768 OverlayData
*data
= NULL
;
770 data
= g_new0(OverlayData
, 1);
772 stock_wid
= stock_pixmap_widget(window
, icon
);
773 gtk_widget_get_requisition(stock_wid
, &requisition
);
775 #if !GTK_CHECK_VERSION(3, 0, 0)
776 if (gtk_image_get_storage_type(GTK_IMAGE(stock_wid
)) == GTK_IMAGE_PIXMAP
)
777 data
->is_pixmap
= TRUE
;
780 data
->is_pixmap
= FALSE
;
782 if (data
->is_pixmap
) {
783 cairo_t
*cr
= gdk_cairo_create(gtk_widget_get_window(stock_wid
));
784 stock_pixmap
= cairo_get_target(cr
);
785 cairo_surface_reference(stock_pixmap
);
787 data
->base_pixmap
= stock_pixmap
;
788 data
->base_height
= requisition
.height
;
789 data
->base_width
= requisition
.width
;
790 gtk_widget_destroy(stock_wid
);
792 if (pos
== OVERLAY_NONE
) {
793 data
->overlay_pixmap
= NULL
;
795 stock_wid
= stock_pixmap_widget(window
, overlay
);
796 cr
= gdk_cairo_create(gtk_widget_get_window(stock_wid
));
797 stock_pixmap
= cairo_get_target(cr
);
798 cairo_surface_reference(stock_pixmap
);
800 data
->overlay_pixmap
= stock_pixmap
;
801 data
->overlay_height
= requisition
.height
;
802 data
->overlay_width
= requisition
.width
;
804 gtk_widget_destroy(stock_wid
);
807 data
->is_pixmap
= FALSE
;
808 stock_pixbuf
= gtk_image_get_pixbuf(GTK_IMAGE(stock_wid
));
809 g_object_ref(stock_pixbuf
);
810 data
->base_pixbuf
= stock_pixbuf
;
811 data
->base_height
= requisition
.height
;
812 data
->base_width
= requisition
.width
;
813 gtk_widget_destroy(stock_wid
);
814 if (pos
== OVERLAY_NONE
) {
815 data
->overlay_pixmap
= NULL
;
817 stock_wid
= stock_pixmap_widget(window
, overlay
);
818 stock_pixbuf
= gtk_image_get_pixbuf(GTK_IMAGE(stock_wid
));
819 g_object_ref(stock_pixbuf
);
820 data
->overlay_pixbuf
= stock_pixbuf
;
821 data
->overlay_height
= requisition
.height
;
822 data
->overlay_width
= requisition
.width
;
824 gtk_widget_destroy(stock_wid
);
827 data
->position
= pos
;
828 data
->border_x
= border_x
;
829 data
->border_y
= border_y
;
830 data
->highlight
= FALSE
;
832 widget
= gtk_drawing_area_new();
833 gtk_widget_set_size_request(widget
, data
->base_width
+ border_x
* 2,
834 data
->base_height
+ border_y
* 2);
835 #if !GTK_CHECK_VERSION(3, 0, 0)
836 g_signal_connect(G_OBJECT(widget
), "expose_event",
837 G_CALLBACK(pixmap_with_overlay_expose_event_cb
), data
);
839 g_signal_connect(G_OBJECT(widget
), "draw",
840 G_CALLBACK(pixmap_with_overlay_expose_event_cb
), data
);
842 g_signal_connect(G_OBJECT(widget
), "destroy",
843 G_CALLBACK(pixmap_with_overlay_destroy_cb
), data
);
844 g_object_set_data(G_OBJECT(widget
), "highlight", &(data
->highlight
));