Mercurial > pidgin
annotate src/stock.c @ 5993:7baf424d78ea
[gaim-migrate @ 6441]
oops, i forgot that i was supposed to add this patch as well as commit the initial translation
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Wed, 02 Jul 2003 15:24:12 +0000 |
parents | 059d95c67cda |
children | 5cd7a10c6ade |
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 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5822
diff
changeset
|
23 #include "internal.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5822
diff
changeset
|
24 |
4359 | 25 #include "stock.h" |
4363
65d98b565fbe
[gaim-migrate @ 4629]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
26 |
4359 | 27 static struct StockIcon |
28 { | |
29 const char *name; | |
30 const char *dir; | |
31 const char *filename; | |
32 | |
33 } const stock_icons[] = | |
34 { | |
5024 | 35 { GAIM_STOCK_ABOUT, "buttons", "about_menu.png" }, |
36 { GAIM_STOCK_ACCOUNTS, "buttons", "accounts.png" }, | |
37 { GAIM_STOCK_BGCOLOR, "buttons", "change-bgcolor-small.png" }, | |
38 { GAIM_STOCK_BLOCK, NULL, GTK_STOCK_STOP }, | |
39 { GAIM_STOCK_CHAT, NULL, GTK_STOCK_JUMP_TO }, | |
40 { GAIM_STOCK_DOWNLOAD, NULL, GTK_STOCK_GO_DOWN }, | |
41 { GAIM_STOCK_DIALOG_AUTH, "dialogs", "gaim_auth.png" }, | |
42 { GAIM_STOCK_DIALOG_COOL, "dialogs", "gaim_cool.png" }, | |
43 { GAIM_STOCK_DIALOG_ERROR, "dialogs", "gaim_error.png" }, | |
44 { GAIM_STOCK_DIALOG_INFO, "dialogs", "gaim_info.png" }, | |
45 { GAIM_STOCK_DIALOG_QUESTION, "dialogs", "gaim_question.png" }, | |
46 { GAIM_STOCK_DIALOG_WARNING, "dialogs", "gaim_warning.png" }, | |
47 { GAIM_STOCK_FGCOLOR, "buttons", "change-fgcolor-small.png" }, | |
48 { GAIM_STOCK_EDIT, "buttons", "edit.png" }, | |
49 { GAIM_STOCK_FILE_CANCELED, NULL, GTK_STOCK_CANCEL }, | |
50 { GAIM_STOCK_FILE_DONE, NULL, GTK_STOCK_APPLY }, | |
51 { GAIM_STOCK_FILE_TRANSFER, NULL, GTK_STOCK_REVERT_TO_SAVED }, | |
52 { GAIM_STOCK_ICON_AWAY, "icons", "away.png" }, | |
53 { GAIM_STOCK_ICON_AWAY_MSG, "icons", "msgpend.png" }, | |
54 { GAIM_STOCK_ICON_CONNECT, "icons", "connect.png" }, | |
55 { GAIM_STOCK_ICON_OFFLINE, "icons", "offline.png" }, | |
56 { GAIM_STOCK_ICON_ONLINE, "icons", "online.png" }, | |
57 { GAIM_STOCK_ICON_ONLINE_MSG, "icons", "msgunread.png" }, | |
58 { GAIM_STOCK_IGNORE, NULL, GTK_STOCK_DIALOG_ERROR }, | |
5822 | 59 { GAIM_STOCK_IM, "buttons", "send-im.png" }, |
5024 | 60 { GAIM_STOCK_IMAGE, "buttons", "insert-image-small.png" }, |
61 { GAIM_STOCK_INFO, NULL, GTK_STOCK_FIND }, | |
62 { GAIM_STOCK_INVITE, NULL, GTK_STOCK_JUMP_TO }, | |
63 { GAIM_STOCK_LINK, "buttons", "insert-link-small.png" }, | |
64 { GAIM_STOCK_LOGO, "gaim", "logo.png" }, | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5523
diff
changeset
|
65 { GAIM_STOCK_MODIFY, NULL, GTK_STOCK_PREFERENCES }, |
5024 | 66 { GAIM_STOCK_PRIVACY, NULL, GTK_STOCK_PROPERTIES }, |
5822 | 67 { GAIM_STOCK_SEND, "buttons", "send-im.png" }, |
5024 | 68 { GAIM_STOCK_SIGN_ON, NULL, GTK_STOCK_EXECUTE }, |
69 { GAIM_STOCK_SIGN_OFF, NULL, GTK_STOCK_CLOSE }, | |
70 { GAIM_STOCK_SMILEY, "buttons", "insert-smiley-small.png" }, | |
5523
fe76565d93c4
[gaim-migrate @ 5923]
Christian Hammond <chipx86@chipx86.com>
parents:
5115
diff
changeset
|
71 { GAIM_STOCK_OPEN_MAIL, NULL, GTK_STOCK_JUMP_TO }, |
5024 | 72 { GAIM_STOCK_TEXT_BIGGER, "buttons", "text_bigger.png" }, |
73 { GAIM_STOCK_TEXT_NORMAL, "buttons", "text_normal.png" }, | |
74 { GAIM_STOCK_TEXT_SMALLER, "buttons", "text_smaller.png" }, | |
75 { GAIM_STOCK_TYPED, "gaim", "typed.png" }, | |
76 { GAIM_STOCK_TYPING, "gaim", "typing.png" }, | |
77 { GAIM_STOCK_UPLOAD, NULL, GTK_STOCK_GO_UP }, | |
78 { GAIM_STOCK_WARN, NULL, GTK_STOCK_DIALOG_WARNING } | |
4359 | 79 }; |
80 | |
5523
fe76565d93c4
[gaim-migrate @ 5923]
Christian Hammond <chipx86@chipx86.com>
parents:
5115
diff
changeset
|
81 const GtkStockItem stock_items[] = |
fe76565d93c4
[gaim-migrate @ 5923]
Christian Hammond <chipx86@chipx86.com>
parents:
5115
diff
changeset
|
82 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5523
diff
changeset
|
83 { GAIM_STOCK_MODIFY, N_("_Modify"), 0, 0, NULL }, |
5523
fe76565d93c4
[gaim-migrate @ 5923]
Christian Hammond <chipx86@chipx86.com>
parents:
5115
diff
changeset
|
84 { GAIM_STOCK_OPEN_MAIL, N_("_Open Mail"), 0, 0, NULL } |
fe76565d93c4
[gaim-migrate @ 5923]
Christian Hammond <chipx86@chipx86.com>
parents:
5115
diff
changeset
|
85 }; |
fe76565d93c4
[gaim-migrate @ 5923]
Christian Hammond <chipx86@chipx86.com>
parents:
5115
diff
changeset
|
86 |
4359 | 87 static gint stock_icon_count = sizeof(stock_icons) / sizeof(*stock_icons); |
5523
fe76565d93c4
[gaim-migrate @ 5923]
Christian Hammond <chipx86@chipx86.com>
parents:
5115
diff
changeset
|
88 static gint stock_item_count = sizeof(stock_items) / sizeof(*stock_items); |
4359 | 89 |
90 static gchar * | |
91 find_file(const char *dir, const char *base) | |
92 { | |
93 char *filename; | |
94 | |
95 if (base == NULL) | |
96 return NULL; | |
97 | |
98 if (!strcmp(dir, "gaim")) | |
99 filename = g_build_filename(DATADIR, "pixmaps", "gaim", base, NULL); | |
100 else | |
5523
fe76565d93c4
[gaim-migrate @ 5923]
Christian Hammond <chipx86@chipx86.com>
parents:
5115
diff
changeset
|
101 filename = g_build_filename(DATADIR, "pixmaps", "gaim", dir, base, NULL); |
4359 | 102 |
103 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { | |
4866
703e02e52262
[gaim-migrate @ 5196]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
104 g_critical("Unable to load stock pixmap %s\n", base); |
4359 | 105 |
106 g_free(filename); | |
107 | |
108 return NULL; | |
109 } | |
110 | |
111 return filename; | |
112 } | |
113 | |
114 void | |
115 setup_stock() | |
116 { | |
117 GtkIconFactory *icon_factory; | |
118 int i; | |
4670
ada933d434cb
[gaim-migrate @ 4981]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
119 GtkWidget *win; |
4359 | 120 |
121 /* Setup the icon factory. */ | |
122 icon_factory = gtk_icon_factory_new(); | |
123 | |
124 gtk_icon_factory_add_default(icon_factory); | |
125 | |
4670
ada933d434cb
[gaim-migrate @ 4981]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
126 /* Er, yeah, a hack, but it works. :) */ |
ada933d434cb
[gaim-migrate @ 4981]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
127 win = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
ada933d434cb
[gaim-migrate @ 4981]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
128 gtk_widget_realize(win); |
ada933d434cb
[gaim-migrate @ 4981]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
129 |
4359 | 130 for (i = 0; i < stock_icon_count; i++) { |
131 GdkPixbuf *pixbuf; | |
132 GtkIconSet *iconset; | |
133 gchar *filename; | |
134 | |
135 if (stock_icons[i].dir == NULL) { | |
4670
ada933d434cb
[gaim-migrate @ 4981]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
136 |
4359 | 137 /* GTK+ Stock icon */ |
4670
ada933d434cb
[gaim-migrate @ 4981]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
138 iconset = gtk_style_lookup_icon_set(gtk_widget_get_style(win), |
ada933d434cb
[gaim-migrate @ 4981]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
139 stock_icons[i].filename); |
4359 | 140 } |
141 else { | |
142 filename = find_file(stock_icons[i].dir, stock_icons[i].filename); | |
143 | |
144 if (filename == NULL) | |
145 continue; | |
146 | |
147 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | |
148 | |
149 g_free(filename); | |
150 | |
151 iconset = gtk_icon_set_new_from_pixbuf(pixbuf); | |
152 } | |
153 | |
154 gtk_icon_factory_add(icon_factory, stock_icons[i].name, iconset); | |
155 | |
156 gtk_icon_set_unref(iconset); | |
157 } | |
158 | |
4670
ada933d434cb
[gaim-migrate @ 4981]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
159 gtk_widget_destroy(win); |
ada933d434cb
[gaim-migrate @ 4981]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
160 |
5024 | 161 /* register logo icon size */ |
162 gtk_icon_size_register(GAIM_ICON_SIZE_LOGO, 210, 150); | |
163 | |
4359 | 164 g_object_unref(G_OBJECT(icon_factory)); |
5523
fe76565d93c4
[gaim-migrate @ 5923]
Christian Hammond <chipx86@chipx86.com>
parents:
5115
diff
changeset
|
165 |
fe76565d93c4
[gaim-migrate @ 5923]
Christian Hammond <chipx86@chipx86.com>
parents:
5115
diff
changeset
|
166 /* Register the stock items. */ |
fe76565d93c4
[gaim-migrate @ 5923]
Christian Hammond <chipx86@chipx86.com>
parents:
5115
diff
changeset
|
167 gtk_stock_add_static(stock_items, stock_item_count); |
4359 | 168 } |