src/mn-stock.c (3162B) - raw
1 /* 2 * Mail Notification 3 * Copyright (C) 2003-2008 Jean-Yves Lefort <jylefort@brutele.be> 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 along 16 * with this program; if not, write to the Free Software Foundation, Inc., 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 */ 19 20 #include <glib/gi18n.h> 21 #include <gtk/gtk.h> 22 #include "mn-stock.h" 23 #include "mn-util.h" 24 25 void 26 mn_stock_init (void) 27 { 28 static const struct 29 { 30 const char *stock_id; 31 const char *filename; 32 const char *icon_name; 33 const char *source_stock_id; 34 } icons[] = { 35 { MN_STOCK_MAIL, NULL, "mail-message-new" }, 36 { MN_STOCK_NO_MAIL, NULL, "mail-notification" }, 37 { MN_STOCK_LOCAL, NULL, "folder" }, 38 { MN_STOCK_REMOTE, NULL, "applications-internet" }, 39 { MN_STOCK_UNKNOWN, NULL, "dialog-question" }, 40 { MN_STOCK_ERROR, NULL, NULL, GTK_STOCK_DIALOG_ERROR }, 41 #if WITH_GMAIL 42 { MN_STOCK_GMAIL, PKGDATADIR G_DIR_SEPARATOR_S "gmail.png" }, 43 #endif 44 #if WITH_YAHOO 45 { MN_STOCK_YAHOO, PKGDATADIR G_DIR_SEPARATOR_S "yahoo.png" }, 46 #endif 47 #if WITH_HOTMAIL 48 { MN_STOCK_HOTMAIL, PKGDATADIR G_DIR_SEPARATOR_S "hotmail.png" }, 49 #endif 50 #if WITH_MBOX || WITH_MOZILLA || WITH_MH || WITH_MAILDIR || WITH_SYLPHEED 51 { MN_STOCK_SYSTEM_MAILBOX, NULL, "applications-system" }, 52 #endif 53 #if WITH_EVOLUTION 54 { MN_STOCK_EVOLUTION_MAILBOX, NULL, "evolution" }, 55 #endif 56 { MN_STOCK_MAIL_READER, NULL, "mail-unread" }, 57 { MN_STOCK_OPEN_MESSAGE, NULL, "mail-read" }, 58 { MN_STOCK_CONSIDER_NEW_MAIL_AS_READ, NULL, "mail-mark-read" } 59 }; 60 GtkIconFactory *factory; 61 GtkIconTheme *icon_theme; 62 int i; 63 64 factory = gtk_icon_factory_new(); 65 gtk_icon_factory_add_default(factory); 66 icon_theme = gtk_icon_theme_get_default(); 67 68 for (i = 0; i < G_N_ELEMENTS(icons); i++) 69 { 70 GtkIconSet *icon_set; 71 72 if (icons[i].filename) 73 { 74 GdkPixbuf *pixbuf; 75 76 pixbuf = mn_pixbuf_new(icons[i].filename); 77 icon_set = gtk_icon_set_new_from_pixbuf(pixbuf); 78 g_object_unref(pixbuf); 79 } 80 else if (icons[i].icon_name) 81 { 82 GtkIconSource *icon_source; 83 84 icon_set = gtk_icon_set_new(); 85 icon_source = gtk_icon_source_new(); 86 gtk_icon_source_set_icon_name(icon_source, icons[i].icon_name); 87 gtk_icon_set_add_source(icon_set, icon_source); 88 gtk_icon_source_free(icon_source); 89 } 90 else if (icons[i].source_stock_id) 91 { 92 icon_set = gtk_icon_factory_lookup_default(icons[i].source_stock_id); 93 gtk_icon_set_ref(icon_set); 94 } 95 else 96 g_assert_not_reached(); 97 98 gtk_icon_factory_add(factory, icons[i].stock_id, icon_set); 99 gtk_icon_set_unref(icon_set); 100 } 101 102 g_object_unref(factory); 103 }