Mercurial > pidgin
annotate src/stock.c @ 4428:b5669740e34c
[gaim-migrate @ 4703]
Two patches from Ray Strode to clean up browser launching (esp. Netscape and
Mozilla) and to show only available browsers in the prefs drop down list.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Sun, 26 Jan 2003 19:39:43 +0000 |
parents | 65d98b565fbe |
children | 7521e29658bc |
rev | line source |
---|---|
4359 | 1 /** |
2 * @file stock.c GTK+ Stock resources | |
3 * | |
4 * gaim | |
5 * | |
6 * Copyright (C) 2002-2003, Christian Hammond <chipx86@gnupdate.org> | |
7 * | |
8 * This program is free software; you can redistribute it and/or modify | |
9 * it under the terms of the GNU General Public License as published by | |
10 * the Free Software Foundation; either version 2 of the License, or | |
11 * (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, | |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 * GNU General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
19 * along with this program; if not, write to the Free Software | |
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 * | |
22 */ | |
23 #include "stock.h" | |
24 #include "core.h" | |
25 #include <gtk/gtk.h> | |
26 #include <string.h> | |
27 | |
4363
65d98b565fbe
[gaim-migrate @ 4629]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
28 #ifdef _WIN32 |
65d98b565fbe
[gaim-migrate @ 4629]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
29 #include "win32dep.h" |
65d98b565fbe
[gaim-migrate @ 4629]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
30 #endif |
65d98b565fbe
[gaim-migrate @ 4629]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
31 |
4359 | 32 static struct StockIcon |
33 { | |
34 const char *name; | |
35 const char *dir; | |
36 const char *filename; | |
37 | |
38 } const stock_icons[] = | |
39 { | |
40 { GAIM_STOCK_BGCOLOR, "buttons", "change-bgcolor-small.png" }, | |
41 { GAIM_STOCK_BLOCK, NULL, GTK_STOCK_STOP }, | |
42 { GAIM_STOCK_FGCOLOR, "buttons", "change-fgcolor-small.png" }, | |
43 { GAIM_STOCK_IGNORE, NULL, GTK_STOCK_DIALOG_ERROR }, | |
44 { GAIM_STOCK_IMAGE, "menus", "insert-image-small.png" }, | |
45 { GAIM_STOCK_INFO, NULL, GTK_STOCK_FIND }, | |
46 { GAIM_STOCK_INVITE, NULL, GTK_STOCK_JUMP_TO }, | |
47 { GAIM_STOCK_LINK, "menus", "insert-link-small.png" }, | |
48 { GAIM_STOCK_SEND, NULL, GTK_STOCK_CONVERT }, | |
49 { GAIM_STOCK_SMILEY, "buttons", "insert-smiley-small.png" }, | |
50 { GAIM_STOCK_TEXT_BIGGER, "buttons", "text_bigger.png" }, | |
51 { GAIM_STOCK_TEXT_NORMAL, "buttons", "text_normal.png" }, | |
52 { GAIM_STOCK_TEXT_SMALLER, "buttons", "text_smaller.png" }, | |
53 { GAIM_STOCK_WARN, NULL, GTK_STOCK_DIALOG_WARNING } | |
54 }; | |
55 | |
56 static gint stock_icon_count = sizeof(stock_icons) / sizeof(*stock_icons); | |
57 | |
58 static gchar * | |
59 find_file(const char *dir, const char *base) | |
60 { | |
61 char *filename; | |
62 | |
63 if (base == NULL) | |
64 return NULL; | |
65 | |
66 if (!strcmp(dir, "gaim")) | |
67 filename = g_build_filename(DATADIR, "pixmaps", "gaim", base, NULL); | |
68 else | |
69 filename = g_build_filename(DATADIR, "pixmaps", "gaim", | |
70 dir, base, NULL); | |
71 | |
72 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { | |
73 debug_printf("Unable to load stock pixmap %s\n", base); | |
74 | |
75 g_free(filename); | |
76 | |
77 return NULL; | |
78 } | |
79 | |
80 return filename; | |
81 } | |
82 | |
83 void | |
84 setup_stock() | |
85 { | |
86 GtkIconFactory *icon_factory; | |
87 int i; | |
88 | |
89 /* Setup the icon factory. */ | |
90 icon_factory = gtk_icon_factory_new(); | |
91 | |
92 gtk_icon_factory_add_default(icon_factory); | |
93 | |
94 for (i = 0; i < stock_icon_count; i++) { | |
95 GdkPixbuf *pixbuf; | |
96 GtkIconSet *iconset; | |
97 gchar *filename; | |
98 | |
99 if (stock_icons[i].dir == NULL) { | |
100 /* GTK+ Stock icon */ | |
101 | |
102 iconset = gtk_icon_factory_lookup_default(stock_icons[i].filename); | |
103 } | |
104 else { | |
105 filename = find_file(stock_icons[i].dir, stock_icons[i].filename); | |
106 | |
107 if (filename == NULL) | |
108 continue; | |
109 | |
110 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | |
111 | |
112 g_free(filename); | |
113 | |
114 iconset = gtk_icon_set_new_from_pixbuf(pixbuf); | |
115 } | |
116 | |
117 gtk_icon_factory_add(icon_factory, stock_icons[i].name, iconset); | |
118 | |
119 gtk_icon_set_unref(iconset); | |
120 } | |
121 | |
122 g_object_unref(G_OBJECT(icon_factory)); | |
123 } |