Mercurial > pidgin.yaz
annotate src/stock.c @ 5018:f82e6763e039
[gaim-migrate @ 5354]
javabsp pointed out that it was actually Taso N. Devetzis (devetzis) that
did that right-click event patch.
this is a patch from robot101 to fix the tooltips on the buttons at the
bottom of the blist.
I wonder what the land speed record for cvs commits is
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Sat, 05 Apr 2003 02:55:12 +0000 |
parents | aa273fba7b09 |
children | 8e55a4d362a3 |
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 }, | |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
42 { GAIM_STOCK_DOWNLOAD, NULL, GTK_STOCK_GO_DOWN }, |
4359 | 43 { GAIM_STOCK_FGCOLOR, "buttons", "change-fgcolor-small.png" }, |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
44 { GAIM_STOCK_FILE_CANCELED, NULL, GTK_STOCK_CANCEL }, |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
45 { GAIM_STOCK_FILE_DONE, NULL, GTK_STOCK_APPLY }, |
4359 | 46 { GAIM_STOCK_IGNORE, NULL, GTK_STOCK_DIALOG_ERROR }, |
47 { GAIM_STOCK_IMAGE, "menus", "insert-image-small.png" }, | |
48 { GAIM_STOCK_INFO, NULL, GTK_STOCK_FIND }, | |
49 { GAIM_STOCK_INVITE, NULL, GTK_STOCK_JUMP_TO }, | |
50 { GAIM_STOCK_LINK, "menus", "insert-link-small.png" }, | |
51 { GAIM_STOCK_SEND, NULL, GTK_STOCK_CONVERT }, | |
52 { GAIM_STOCK_SMILEY, "buttons", "insert-smiley-small.png" }, | |
53 { GAIM_STOCK_TEXT_BIGGER, "buttons", "text_bigger.png" }, | |
54 { GAIM_STOCK_TEXT_NORMAL, "buttons", "text_normal.png" }, | |
55 { GAIM_STOCK_TEXT_SMALLER, "buttons", "text_smaller.png" }, | |
4866
703e02e52262
[gaim-migrate @ 5196]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
56 { GAIM_STOCK_TYPED, "gaim", "typed.png" }, |
703e02e52262
[gaim-migrate @ 5196]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
57 { GAIM_STOCK_TYPING, "gaim", "typing.png" }, |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
58 { GAIM_STOCK_UPLOAD, NULL, GTK_STOCK_GO_UP }, |
4687 | 59 { GAIM_STOCK_WARN, NULL, GTK_STOCK_DIALOG_WARNING }, |
60 { GAIM_STOCK_IM, NULL, GTK_STOCK_CONVERT }, | |
61 { GAIM_STOCK_CHAT, NULL, GTK_STOCK_JUMP_TO }, | |
4956 | 62 { GAIM_STOCK_AWAY, "gaim", "away.png" } |
4359 | 63 }; |
64 | |
65 static gint stock_icon_count = sizeof(stock_icons) / sizeof(*stock_icons); | |
66 | |
67 static gchar * | |
68 find_file(const char *dir, const char *base) | |
69 { | |
70 char *filename; | |
71 | |
72 if (base == NULL) | |
73 return NULL; | |
74 | |
75 if (!strcmp(dir, "gaim")) | |
76 filename = g_build_filename(DATADIR, "pixmaps", "gaim", base, NULL); | |
77 else | |
78 filename = g_build_filename(DATADIR, "pixmaps", "gaim", | |
79 dir, base, NULL); | |
80 | |
81 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { | |
4866
703e02e52262
[gaim-migrate @ 5196]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
82 g_critical("Unable to load stock pixmap %s\n", base); |
4359 | 83 |
84 g_free(filename); | |
85 | |
86 return NULL; | |
87 } | |
88 | |
89 return filename; | |
90 } | |
91 | |
92 void | |
93 setup_stock() | |
94 { | |
95 GtkIconFactory *icon_factory; | |
96 int i; | |
4670
ada933d434cb
[gaim-migrate @ 4981]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
97 GtkWidget *win; |
4359 | 98 |
99 /* Setup the icon factory. */ | |
100 icon_factory = gtk_icon_factory_new(); | |
101 | |
102 gtk_icon_factory_add_default(icon_factory); | |
103 | |
4670
ada933d434cb
[gaim-migrate @ 4981]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
104 /* Er, yeah, a hack, but it works. :) */ |
ada933d434cb
[gaim-migrate @ 4981]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
105 win = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
ada933d434cb
[gaim-migrate @ 4981]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
106 gtk_widget_realize(win); |
ada933d434cb
[gaim-migrate @ 4981]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
107 |
4359 | 108 for (i = 0; i < stock_icon_count; i++) { |
109 GdkPixbuf *pixbuf; | |
110 GtkIconSet *iconset; | |
111 gchar *filename; | |
112 | |
113 if (stock_icons[i].dir == NULL) { | |
4670
ada933d434cb
[gaim-migrate @ 4981]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
114 |
4359 | 115 /* GTK+ Stock icon */ |
4670
ada933d434cb
[gaim-migrate @ 4981]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
116 iconset = gtk_style_lookup_icon_set(gtk_widget_get_style(win), |
ada933d434cb
[gaim-migrate @ 4981]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
117 stock_icons[i].filename); |
4359 | 118 } |
119 else { | |
120 filename = find_file(stock_icons[i].dir, stock_icons[i].filename); | |
121 | |
122 if (filename == NULL) | |
123 continue; | |
124 | |
125 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | |
126 | |
127 g_free(filename); | |
128 | |
129 iconset = gtk_icon_set_new_from_pixbuf(pixbuf); | |
130 } | |
131 | |
132 gtk_icon_factory_add(icon_factory, stock_icons[i].name, iconset); | |
133 | |
134 gtk_icon_set_unref(iconset); | |
135 } | |
136 | |
4670
ada933d434cb
[gaim-migrate @ 4981]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
137 gtk_widget_destroy(win); |
ada933d434cb
[gaim-migrate @ 4981]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
138 |
4359 | 139 g_object_unref(G_OBJECT(icon_factory)); |
140 } |