Revision 3288 src/stock_pixmap.c

View differences:

stock_pixmap.c
99 99
	gint size;
100 100

  
101 101
	gchar *icon_file;
102
	GdkPixbuf *icon_file_pixbuf;
102 103
};
103 104

  
104 105
static StockPixmapData pixmaps[] =
......
159 160
	{NULL, NULL, NULL, NULL, stock_person, sizeof(stock_person), "stock_person", 16, "stock_person.png"},
160 161
	{NULL, NULL, NULL, NULL, folder_search, sizeof(folder_search), "folder-search", 0, "folder-search.png"},
161 162
	{NULL, NULL, NULL, NULL, stock_spam_16, sizeof(stock_spam_16), "stock_spam", 16, "stock_spam_16.png"},
163

  
164
	/* for toolbar */
165
	{NULL, NULL, NULL, NULL, NULL, 0, GTK_STOCK_NETWORK, 24, "remote-mailbox.png"},
166
	{NULL, NULL, NULL, NULL, NULL, 0, GTK_STOCK_GO_DOWN, 24, "next.png"},
167
	{NULL, NULL, NULL, NULL, NULL, 0, GTK_STOCK_GO_UP, 24, "prev.png"},
168
	{NULL, NULL, NULL, NULL, NULL, 0, GTK_STOCK_FIND, 24, "search.png"},
169
	{NULL, NULL, NULL, NULL, NULL, 0, GTK_STOCK_PRINT, 24, "print.png"},
170
	{NULL, NULL, NULL, NULL, NULL, 0, GTK_STOCK_STOP, 24, "stop.png"},
171
	{NULL, NULL, NULL, NULL, NULL, 0, GTK_STOCK_EXECUTE, 24, "execute.png"},
172
	{NULL, NULL, NULL, NULL, NULL, 0, GTK_STOCK_PREFERENCES, 24, "common-prefs.png"},
173
	{NULL, NULL, NULL, NULL, NULL, 0, GTK_STOCK_PREFERENCES, 24, "account-prefs.png"},
174
	{NULL, NULL, NULL, NULL, NULL, 0, GTK_STOCK_SAVE, 24, "save.png"},
175
	{NULL, NULL, NULL, NULL, NULL, 0, GTK_STOCK_EDIT, 24, "editor.png"},
162 176
};
163 177

  
164 178
static gchar *theme_dir = NULL;
......
192 206
	return image;
193 207
}
194 208

  
209
static gboolean stock_pixbuf_load_theme_icon_file(StockPixmap icon)
210
{
211
	StockPixmapData *pix_d;
212

  
213
	g_return_val_if_fail(icon >= 0 && icon < N_STOCK_PIXMAPS, FALSE);
214

  
215
	pix_d = &pixmaps[icon];
216

  
217
	if (!pix_d->icon_file_pixbuf && pix_d->icon_file && theme_dir) {
218
		gchar *path;
219

  
220
		path = g_strconcat(theme_dir, G_DIR_SEPARATOR_S,
221
				   pix_d->icon_file, NULL);
222
		debug_print("stock_pixbuf_load_theme_icon_file: checking theme icon: %s\n", path);
223
		if (is_file_exist(path)) {
224
			debug_print("stock_pixbuf_load_theme_icon_file: loading theme icon: %s\n", path);
225
			pix_d->icon_file_pixbuf = gdk_pixbuf_new_from_file(path, NULL);
226
			if (!pix_d->icon_file_pixbuf) {
227
				g_warning("stock_pixbuf_load_theme_icon_file: loading of theme icon failed: %s", path);
228
				pix_d->icon_file = NULL;
229
			} else if (!pix_d->pixbuf)
230
				pix_d->pixbuf = pix_d->icon_file_pixbuf;
231
		} else
232
			pix_d->icon_file = NULL;
233
		g_free(path);
234
	}
235

  
236
	return pix_d->icon_file_pixbuf != NULL;
237
}
238

  
239
GtkWidget *stock_pixbuf_widget_for_toolbar(StockPixmap icon)
240
{
241
	GtkWidget *image = NULL;
242
	StockPixmapData *pix_d;
243

  
244
	g_return_val_if_fail(icon >= 0 && icon < N_STOCK_PIXMAPS, NULL);
245

  
246
	stock_pixbuf_load_theme_icon_file(icon);
247

  
248
	pix_d = &pixmaps[icon];
249

  
250
	if (pix_d->icon_file_pixbuf) {
251
		image = gtk_image_new_from_pixbuf(pix_d->icon_file_pixbuf);
252
	}
253

  
254
	if (!image && pix_d->icon_name)
255
		image = gtk_image_new_from_stock(pix_d->icon_name, GTK_ICON_SIZE_LARGE_TOOLBAR);
256

  
257
	if (!image)
258
		image = stock_pixbuf_widget(NULL, icon);
259

  
260
	return image;
261
}
262

  
195 263
/* create GdkPixmap if it has not created yet */
196 264
gint stock_pixmap_gdk(GtkWidget *window, StockPixmap icon,
197 265
		      GdkPixmap **pixmap, GdkBitmap **mask)
......
228 296

  
229 297
	g_return_val_if_fail(icon >= 0 && icon < N_STOCK_PIXMAPS, -1);
230 298

  
299
	stock_pixbuf_load_theme_icon_file(icon);
300

  
231 301
	pix_d = &pixmaps[icon];
232 302

  
233
	if (!pix_d->pixbuf && pix_d->icon_file && theme_dir) {
234
		gchar *path;
235

  
236
		path = g_strconcat(theme_dir, G_DIR_SEPARATOR_S,
237
				   pix_d->icon_file, NULL);
238
		if (is_file_exist(path)) {
239
			debug_print("stock_pixbuf_gdk: loading theme icon: %s\n", path);
240
			pix_d->pixbuf = gdk_pixbuf_new_from_file(path, NULL);
241
		}
242
		g_free(path);
243
	}
244

  
245 303
	if (!pix_d->pixbuf && pix_d->pixbuf_data)
246 304
		pix_d->pixbuf = gdk_pixbuf_new_from_inline
247 305
			(pix_d->pixbuf_data_len, pix_d->pixbuf_data,

Also available in: Unified diff