Revision 3288

View differences:

src/compose.c
5892 5892
		if (item->id == -1)
5893 5893
			continue;
5894 5894

  
5895
		if (ditem->stock_id) {
5896
			icon_wid = gtk_image_new_from_stock
5897
				(ditem->stock_id, GTK_ICON_SIZE_LARGE_TOOLBAR);
5898
		} else
5899
			icon_wid = stock_pixbuf_widget(NULL, ditem->icon);
5900

  
5895
		icon_wid = stock_pixbuf_widget_for_toolbar(ditem->icon);
5901 5896
		toolitem = gtk_tool_button_new(icon_wid, gettext(ditem->label));
5902 5897
		if (ditem->description) {
5903 5898
			gtk_tool_item_set_tooltip(toolitem,
src/prefs_toolbar.c
46 46
	 STOCK_PIXMAP_MAIL_RECEIVE_ALL,	NULL, FALSE, FALSE},
47 47
	{T_REMOTE_MAILBOX,	"remote-mailbox",	N_("Remote mailbox"),
48 48
	 N_("POP3 Remote mailbox"),
49
	 -1, GTK_STOCK_NETWORK, FALSE, FALSE},
49
	 STOCK_PIXMAP_REMOTE_MAILBOX, GTK_STOCK_NETWORK, FALSE, FALSE},
50 50
	{T_SEND_QUEUE,	"send-queue",	N_("Send"),
51 51
	 N_("Send queued message(s)"),
52 52
	 STOCK_PIXMAP_MAIL_SEND, NULL, FALSE, FALSE},
......
73 73
	 STOCK_PIXMAP_NOTSPAM, NULL, FALSE, FALSE},
74 74
	{T_NEXT,	"next",		N_("Next"),
75 75
	 N_("Next unread message"),
76
	 -1, GTK_STOCK_GO_DOWN, FALSE, FALSE},
76
	 STOCK_PIXMAP_NEXT, GTK_STOCK_GO_DOWN, FALSE, FALSE},
77 77
	{T_PREV,	"prev",		N_("Prev"),
78 78
	 N_("Previous unread message"),
79
	 -1, GTK_STOCK_GO_UP, FALSE, FALSE},
79
	 STOCK_PIXMAP_PREV, GTK_STOCK_GO_UP, FALSE, FALSE},
80 80
	{T_SEARCH,	"search",	N_("Search"),
81 81
	 N_("Search messages"),
82
	 -1, GTK_STOCK_FIND, FALSE, FALSE},
82
	 STOCK_PIXMAP_SEARCH, GTK_STOCK_FIND, FALSE, FALSE},
83 83
	{T_PRINT,	"print",	N_("Print"),
84 84
	 N_("Print message"),
85
	 -1, GTK_STOCK_PRINT, FALSE, FALSE},
85
	 STOCK_PIXMAP_PRINT, GTK_STOCK_PRINT, FALSE, FALSE},
86 86
	{T_STOP,	"stop",		N_("Stop"),
87 87
	 N_("Stop receiving"),
88
	 -1, GTK_STOCK_STOP, FALSE, FALSE},
88
	 STOCK_PIXMAP_STOP, GTK_STOCK_STOP, FALSE, FALSE},
89 89
	{T_ADDRESS_BOOK,	"address-book",	N_("Address"),
90 90
	 N_("Address book"),
91 91
	 STOCK_PIXMAP_ADDRESS_BOOK, NULL, FALSE, FALSE},
92 92
	{T_EXECUTE,	"execute",	N_("Execute"),
93 93
	 N_("Execute marked process"),
94
	 -1, GTK_STOCK_EXECUTE, FALSE, FALSE},
94
	 STOCK_PIXMAP_EXECUTE, GTK_STOCK_EXECUTE, FALSE, FALSE},
95 95
	{T_COMMON_PREFS,	"common-prefs",	N_("Prefs"),
96 96
	 N_("Common preferences"),
97
	 -1, GTK_STOCK_PREFERENCES, FALSE, FALSE},
97
	 STOCK_PIXMAP_COMMON_PREFS, GTK_STOCK_PREFERENCES, FALSE, FALSE},
98 98
	{T_ACCOUNT_PREFS,	"account-prefs", N_("Account"),
99 99
	 N_("Account preferences"),
100
	 -1, GTK_STOCK_PREFERENCES, FALSE, FALSE},
100
	 STOCK_PIXMAP_ACCOUNT_PREFS, GTK_STOCK_PREFERENCES, FALSE, FALSE},
101 101

  
102 102
	{T_SEND,	"send",		N_("Send"),
103 103
	 N_("Send message"),
......
107 107
	 STOCK_PIXMAP_MAIL_SEND_QUEUE, NULL, FALSE, FALSE},
108 108
	{T_DRAFT,	"draft",	N_("Draft"),
109 109
	 N_("Save to draft folder"),
110
	 -1, GTK_STOCK_SAVE, FALSE, FALSE},
110
	 STOCK_PIXMAP_SAVE, GTK_STOCK_SAVE, FALSE, FALSE},
111 111
	{T_INSERT_FILE,	"insert-file",	N_("Insert"),
112 112
	 N_("Insert file"),
113 113
	 STOCK_PIXMAP_INSERT_FILE, NULL, FALSE, FALSE},
......
119 119
	 STOCK_PIXMAP_SIGN, NULL, FALSE, FALSE},
120 120
	{T_EDITOR,	"editor",	N_("Editor"),
121 121
	 N_("Edit with external editor"),
122
#ifdef GTK_STOCK_EDIT
123
	 -1, GTK_STOCK_EDIT, FALSE, FALSE},
124
#else
125
	 STOCK_PIXMAP_MAIL_COMPOSE, NULL, FALSE, FALSE},
126
#endif
122
	 STOCK_PIXMAP_EDIT, GTK_STOCK_EDIT, FALSE, FALSE},
127 123
	{T_LINEWRAP,	"linewrap",	N_("Linewrap"),
128 124
	 N_("Wrap all long lines"),
129 125
	 STOCK_PIXMAP_LINEWRAP, NULL, FALSE, FALSE},
src/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,
src/stock_pixmap.h
82 82
	STOCK_PIXMAP_FOLDER_SEARCH,
83 83
	STOCK_PIXMAP_SPAM_SMALL,
84 84

  
85
	/* for toolbar */
86

  
87
	STOCK_PIXMAP_REMOTE_MAILBOX,
88
	STOCK_PIXMAP_NEXT,
89
	STOCK_PIXMAP_PREV,
90
	STOCK_PIXMAP_SEARCH,
91
	STOCK_PIXMAP_PRINT,
92
	STOCK_PIXMAP_STOP,
93
	STOCK_PIXMAP_EXECUTE,
94
	STOCK_PIXMAP_COMMON_PREFS,
95
	STOCK_PIXMAP_ACCOUNT_PREFS,
96
	STOCK_PIXMAP_SAVE,
97
	STOCK_PIXMAP_EDIT,
98

  
85 99
	N_STOCK_PIXMAPS
86 100
} StockPixmap;
87 101

  
......
93 107
					 gint		 width,
94 108
					 gint		 height);
95 109

  
110
GtkWidget *stock_pixbuf_widget_for_toolbar(StockPixmap	 icon);
111

  
96 112
gint stock_pixmap_gdk		(GtkWidget	 *window,
97 113
				 StockPixmap	  icon,
98 114
				 GdkPixmap	**pixmap,
src/mainwindow.c
2708 2708
		if (item->id == -1)
2709 2709
			continue;
2710 2710

  
2711
		if (ditem->stock_id) {
2712
			icon_wid = gtk_image_new_from_stock
2713
				(ditem->stock_id, GTK_ICON_SIZE_LARGE_TOOLBAR);
2714
		} else
2715
			icon_wid = stock_pixbuf_widget(NULL, ditem->icon);
2716

  
2711
		icon_wid = stock_pixbuf_widget_for_toolbar(ditem->icon);
2717 2712
		toolitem = gtk_tool_button_new(icon_wid, gettext(ditem->label));
2718 2713
		if (ditem->description) {
2719 2714
			gtk_tool_item_set_tooltip(toolitem,
ChangeLog
1
2013-10-04
2

  
3
	* src/compose.c
4
	  src/prefs_toolbar.c
5
	  src/stock_pixmap.[ch]
6
	  src/mainwindow.c: made the rest of toolbar icons themeable.
7

  
1 8
2013-09-20
2 9

  
3 10
	* makewin32.sh: added --with-themedir configure option.

Also available in: Unified diff