2
* @file icons.c Using icons from theme and package pixmaps
4
* Copyright (C) 2010 Lars Lindner <lars.lindner@gmail.com>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29
static GdkPixbuf *icons[MAX_ICONS]; /**< list of icon assignments */
32
icon_find_pixmap_file (const gchar *filename)
34
gchar *pathname = g_build_filename (PACKAGE_DATA_DIR G_DIR_SEPARATOR_S PACKAGE G_DIR_SEPARATOR_S "pixmaps", filename, NULL);
35
if (g_file_test (pathname, G_FILE_TEST_EXISTS))
42
icon_create_from_file (const gchar *filename)
44
gchar *pathname = NULL;
48
if (!filename || !filename[0])
51
pathname = icon_find_pixmap_file (filename);
54
g_warning (_("Couldn't find pixmap file: %s"), filename);
58
pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
60
fprintf (stderr, "Failed to load pixbuf file: %s: %s\n",
61
pathname, error->message);
69
icon_get_from_theme (GtkIconTheme *icon_theme, const gchar *name, gint size)
74
pixbuf = gtk_icon_theme_load_icon (icon_theme,
80
g_warning ("Couldn't load icon: %s", error->message);
89
GtkIconTheme *icon_theme;
93
/* first try to load icons from theme */
94
static const gchar *iconThemeNames[] = {
95
NULL, /* ICON_UNREAD */
96
"emblem-important", /* ICON_FLAG */
97
NULL, /* ICON_AVAILABLE */
98
NULL, /* ICON_AVAILABLE_OFFLINE */
99
NULL, /* ICON_UNAVAILABLE */
100
NULL, /* ICON_DEFAULT */
101
"folder", /* ICON_FOLDER */
102
"folder-saved-search", /* ICON_VFOLDER */
103
NULL, /* ICON_NEWSBIN */
104
NULL, /* ICON_EMPTY */
105
NULL, /* ICON_EMPTY_OFFLINE */
106
"gtk-connect", /* ICON_ONLINE */
107
"gtk-disconnect", /* ICON_OFFLINE */
108
"mail-attachment", /* ICON_ENCLOSURE */
112
icon_theme = gtk_icon_theme_get_default ();
113
for (i = 0; i < MAX_ICONS; i++)
114
if (iconThemeNames[i])
115
icons[i] = icon_get_from_theme (icon_theme, iconThemeNames[i], 16);
117
/* and then load own default icons */
118
static const gchar *iconNames[] = {
119
"unread.png", /* ICON_UNREAD */
120
"flag.png", /* ICON_FLAG */
121
"available.png", /* ICON_AVAILABLE */
122
"available_offline.png", /* ICON_AVAILABLE_OFFLINE */
123
NULL, /* ICON_UNAVAILABLE */
124
"default.png", /* ICON_DEFAULT */
125
"directory.png", /* ICON_FOLDER */
126
"vfolder.png", /* ICON_VFOLDER */
127
"newsbin.png", /* ICON_NEWSBIN */
128
"empty.png", /* ICON_EMPTY */
129
"empty_offline.png", /* ICON_EMPTY_OFFLINE */
130
"online.png", /* ICON_ONLINE */
131
"offline.png", /* ICON_OFFLINE */
132
"attachment.png", /* ICON_ENCLOSURE */
136
for (i = 0; i < MAX_ICONS; i++)
138
icons[i] = icon_create_from_file (iconNames[i]);
140
/* set up icons that are build from stock */
141
widget = gtk_button_new ();
142
icons[ICON_UNAVAILABLE] = gtk_widget_render_icon (widget, GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_MENU, "");
143
gtk_widget_destroy (widget);
147
icon_get (lifereaIcon icon)