Mercurial > pidgin.yaz
comparison pidgin/gaimstock.c @ 15397:a8ee645e7fb4
A lot of status icon changes:
- Added Tango icons to blist
- Added tooltip changes
A work in progress. TODO:
- desaturate and tranparentify status icons in list
- protocol icon in tooltip
- statusbox icon changes
- Add emblems
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Wed, 24 Jan 2007 09:30:54 +0000 |
parents | 5fe8042783c1 |
children | c9497aad9fc4 9c0cf4db1f4d |
comparison
equal
deleted
inserted
replaced
15396:eb93d03ed6c7 | 15397:a8ee645e7fb4 |
---|---|
115 { GAIM_STOCK_TEXT_NORMAL, "buttons", "text_normal.png" }, | 115 { GAIM_STOCK_TEXT_NORMAL, "buttons", "text_normal.png" }, |
116 { GAIM_STOCK_TEXT_SMALLER, "buttons", "text_smaller.png" }, | 116 { GAIM_STOCK_TEXT_SMALLER, "buttons", "text_smaller.png" }, |
117 { GAIM_STOCK_TYPED, "gaim", "typed.png" }, | 117 { GAIM_STOCK_TYPED, "gaim", "typed.png" }, |
118 { GAIM_STOCK_TYPING, "gaim", "typing.png" }, | 118 { GAIM_STOCK_TYPING, "gaim", "typing.png" }, |
119 { GAIM_STOCK_VOICE_CHAT, "gaim", "phone.png" }, | 119 { GAIM_STOCK_VOICE_CHAT, "gaim", "phone.png" }, |
120 { GAIM_STOCK_STATUS_ONLINE, "gaim", "status-online.png" }, | |
121 { GAIM_STOCK_STATUS_OFFLINE, "gaim", "status-offline.png" }, | |
122 { GAIM_STOCK_STATUS_AWAY, "gaim", "status-away.png" }, | |
123 { GAIM_STOCK_STATUS_INVISIBLE,"gaim", "status-invisible.png" }, | 120 { GAIM_STOCK_STATUS_INVISIBLE,"gaim", "status-invisible.png" }, |
124 { GAIM_STOCK_STATUS_TYPING0, "gaim", "status-typing0.png" }, | 121 { GAIM_STOCK_STATUS_TYPING0, "gaim", "status-typing0.png" }, |
125 { GAIM_STOCK_STATUS_TYPING1, "gaim", "status-typing1.png" }, | 122 { GAIM_STOCK_STATUS_TYPING1, "gaim", "status-typing1.png" }, |
126 { GAIM_STOCK_STATUS_TYPING2, "gaim", "status-typing2.png" }, | 123 { GAIM_STOCK_STATUS_TYPING2, "gaim", "status-typing2.png" }, |
127 { GAIM_STOCK_STATUS_TYPING3, "gaim", "status-typing3.png" }, | 124 { GAIM_STOCK_STATUS_TYPING3, "gaim", "status-typing3.png" }, |
143 { GAIM_STOCK_MODIFY, N_("_Modify"), 0, 0, NULL }, | 140 { GAIM_STOCK_MODIFY, N_("_Modify"), 0, 0, NULL }, |
144 { GAIM_STOCK_OPEN_MAIL, N_("_Open Mail"), 0, 0, NULL }, | 141 { GAIM_STOCK_OPEN_MAIL, N_("_Open Mail"), 0, 0, NULL }, |
145 { GAIM_STOCK_PAUSE, N_("_Pause"), 0, 0, NULL }, | 142 { GAIM_STOCK_PAUSE, N_("_Pause"), 0, 0, NULL }, |
146 }; | 143 }; |
147 | 144 |
145 static struct SizedStockIcon { | |
146 const char *name; | |
147 const char *dir; | |
148 const char *filename; | |
149 gboolean extra_small; | |
150 gboolean small; | |
151 gboolean medium; | |
152 gboolean huge; | |
153 } const sized_stock_icons [] = { | |
154 { GAIM_STOCK_STATUS_AVAILABLE, "status", "available.png", TRUE, TRUE, TRUE, FALSE }, | |
155 { GAIM_STOCK_STATUS_AWAY, "status", "away.png", TRUE, TRUE, TRUE, FALSE }, | |
156 { GAIM_STOCK_STATUS_BUSY, "status", "busy.png", TRUE, TRUE, TRUE, FALSE }, | |
157 { GAIM_STOCK_STATUS_CHAT, "status", "chat.png", TRUE, TRUE, TRUE, FALSE }, | |
158 { GAIM_STOCK_STATUS_XA, "status", "extended-away.png", TRUE, TRUE, TRUE, FALSE }, | |
159 { GAIM_STOCK_STATUS_LOGIN, "status", "log-in.png", TRUE, TRUE, TRUE, FALSE }, | |
160 { GAIM_STOCK_STATUS_LOGOUT, "status", "log-out.png", TRUE, TRUE, TRUE, FALSE }, | |
161 { GAIM_STOCK_STATUS_OFFLINE, "status", "offline.png", TRUE, TRUE, TRUE, FALSE }, | |
162 { GAIM_STOCK_STATUS_PERSON, "status", "person.png", TRUE, TRUE, TRUE, FALSE }, | |
163 { GAIM_STOCK_STATUS_OPERATOR, "status", "operator.png", TRUE, FALSE, FALSE, FALSE }, | |
164 { GAIM_STOCK_STATUS_HALFOP, "status", "half-operator.png", TRUE, FALSE, FALSE, FALSE }, | |
165 }; | |
166 | |
148 static gchar * | 167 static gchar * |
149 find_file(const char *dir, const char *base) | 168 find_file(const char *dir, const char *base) |
150 { | 169 { |
151 char *filename; | 170 char *filename; |
152 | 171 |
159 { | 178 { |
160 filename = g_build_filename(DATADIR, "pixmaps", "gaim", dir, | 179 filename = g_build_filename(DATADIR, "pixmaps", "gaim", dir, |
161 base, NULL); | 180 base, NULL); |
162 } | 181 } |
163 | 182 |
164 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) | |
165 { | |
166 g_critical("Unable to load stock pixmap %s\n", base); | |
167 | |
168 g_free(filename); | |
169 | |
170 return NULL; | |
171 } | |
172 | |
173 return filename; | 183 return filename; |
184 } | |
185 | |
186 static void | |
187 add_sized_icon(GtkIconSet *iconset, GtkIconSize sizeid, const char *dir, | |
188 const char *size, const char *file) | |
189 { | |
190 char *filename; | |
191 GtkIconSource *source; | |
192 | |
193 filename = g_build_filename(DATADIR, "pixmaps", "pidgin", dir, size, file, NULL); | |
194 source = gtk_icon_source_new(); | |
195 gtk_icon_source_set_filename(source, filename); | |
196 gtk_icon_source_set_direction_wildcarded(source, TRUE); | |
197 gtk_icon_source_set_size(source, sizeid); | |
198 gtk_icon_source_set_size_wildcarded(source, FALSE); | |
199 gtk_icon_source_set_state_wildcarded(source, TRUE); | |
200 gtk_icon_set_add_source(iconset, source); | |
201 gtk_icon_source_free(source); | |
202 g_free(filename); | |
174 } | 203 } |
175 | 204 |
176 void | 205 void |
177 gaim_gtk_stock_init(void) | 206 gaim_gtk_stock_init(void) |
178 { | 207 { |
179 static gboolean stock_initted = FALSE; | 208 static gboolean stock_initted = FALSE; |
180 GtkIconFactory *icon_factory; | 209 GtkIconFactory *icon_factory; |
181 size_t i; | 210 size_t i; |
182 GtkWidget *win; | 211 GtkWidget *win; |
183 | 212 GtkIconSize extra_small, small, medium, huge; |
213 | |
184 if (stock_initted) | 214 if (stock_initted) |
185 return; | 215 return; |
186 | 216 |
187 stock_initted = TRUE; | 217 stock_initted = TRUE; |
188 | 218 |
195 win = gtk_window_new(GTK_WINDOW_TOPLEVEL); | 225 win = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
196 gtk_widget_realize(win); | 226 gtk_widget_realize(win); |
197 | 227 |
198 for (i = 0; i < G_N_ELEMENTS(stock_icons); i++) | 228 for (i = 0; i < G_N_ELEMENTS(stock_icons); i++) |
199 { | 229 { |
200 GdkPixbuf *pixbuf; | 230 GtkIconSource *source; |
201 GtkIconSet *iconset; | 231 GtkIconSet *iconset; |
202 gchar *filename; | 232 gchar *filename; |
203 | 233 |
204 if (stock_icons[i].dir == NULL) | 234 if (stock_icons[i].dir == NULL) |
205 { | 235 { |
212 filename = find_file(stock_icons[i].dir, stock_icons[i].filename); | 242 filename = find_file(stock_icons[i].dir, stock_icons[i].filename); |
213 | 243 |
214 if (filename == NULL) | 244 if (filename == NULL) |
215 continue; | 245 continue; |
216 | 246 |
217 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | 247 source = gtk_icon_source_new(); |
218 | 248 gtk_icon_source_set_filename(source, filename); |
249 gtk_icon_source_set_direction_wildcarded(source, TRUE); | |
250 gtk_icon_source_set_size_wildcarded(source, TRUE); | |
251 gtk_icon_source_set_state_wildcarded(source, TRUE); | |
252 | |
253 | |
254 iconset = gtk_icon_set_new(); | |
255 gtk_icon_set_add_source(iconset, source); | |
256 | |
257 gtk_icon_source_free(source); | |
219 g_free(filename); | 258 g_free(filename); |
220 | |
221 iconset = gtk_icon_set_new_from_pixbuf(pixbuf); | |
222 | |
223 g_object_unref(G_OBJECT(pixbuf)); | |
224 } | 259 } |
225 | 260 |
226 gtk_icon_factory_add(icon_factory, stock_icons[i].name, iconset); | 261 gtk_icon_factory_add(icon_factory, stock_icons[i].name, iconset); |
227 | 262 |
228 gtk_icon_set_unref(iconset); | 263 gtk_icon_set_unref(iconset); |
229 } | 264 } |
230 | 265 |
231 gtk_widget_destroy(win); | |
232 | |
233 /* register custom icon sizes */ | 266 /* register custom icon sizes */ |
234 gtk_icon_size_register(GAIM_ICON_SIZE_DIALOG_COOL, 40, 60); | 267 gtk_icon_size_register(GAIM_ICON_SIZE_DIALOG_COOL, 40, 60); |
235 gtk_icon_size_register(GAIM_ICON_SIZE_STATUS, 30, 30); | 268 extra_small = gtk_icon_size_register(GAIM_ICON_SIZE_TANGO_EXTRA_SMALL, 16, 16); |
236 gtk_icon_size_register(GAIM_ICON_SIZE_STATUS_TWO_LINE, 30, 30); | 269 small = gtk_icon_size_register(GAIM_ICON_SIZE_TANGO_SMALL, 22, 22); |
237 gtk_icon_size_register(GAIM_ICON_SIZE_STATUS_SMALL, 16, 16); | 270 medium = gtk_icon_size_register(GAIM_ICON_SIZE_TANGO_MEDIUM, 32, 32); |
238 gtk_icon_size_register(GAIM_ICON_SIZE_STATUS_SMALL_TWO_LINE, 24, 24); | 271 huge = gtk_icon_size_register(GAIM_ICON_SIZE_TANGO_HUGE, 64, 64); |
239 | 272 |
273 for (i = 0; i < G_N_ELEMENTS(sized_stock_icons); i++) | |
274 { | |
275 GtkIconSet *iconset; | |
276 | |
277 iconset = gtk_icon_set_new(); | |
278 if (sized_stock_icons[i].extra_small) | |
279 add_sized_icon(iconset, extra_small, | |
280 sized_stock_icons[i].dir, | |
281 "16", sized_stock_icons[i].filename); | |
282 if (sized_stock_icons[i].small) | |
283 add_sized_icon(iconset, small, | |
284 sized_stock_icons[i].dir, | |
285 "22", sized_stock_icons[i].filename); | |
286 if (sized_stock_icons[i].medium) | |
287 add_sized_icon(iconset, medium, | |
288 sized_stock_icons[i].dir, | |
289 "32", sized_stock_icons[i].filename); | |
290 if (sized_stock_icons[i].huge) | |
291 add_sized_icon(iconset, huge, | |
292 sized_stock_icons[i].dir, | |
293 "64", sized_stock_icons[i].filename); | |
294 | |
295 gtk_icon_factory_add(icon_factory, sized_stock_icons[i].name, iconset); | |
296 gtk_icon_set_unref(iconset); | |
297 } | |
298 | |
299 gtk_widget_destroy(win); | |
240 g_object_unref(G_OBJECT(icon_factory)); | 300 g_object_unref(G_OBJECT(icon_factory)); |
241 | 301 |
242 /* Register the stock items. */ | 302 /* Register the stock items. */ |
243 gtk_stock_add_static(stock_items, G_N_ELEMENTS(stock_items)); | 303 gtk_stock_add_static(stock_items, G_N_ELEMENTS(stock_items)); |
244 } | 304 } |