comparison src/gtkstatusbox.c @ 11983:39f2aa4350d8

[gaim-migrate @ 14276] Finally turning this on, after sticking in a vpane so you can get it out of your way. I also changed the icons. Still todo is making it show and hide based on if they match the global status, and misc stuff like adding and removing the selectors based on account enable/disable and add/delete. Anyway, now that they're enabled, y'all can tell me what you think, and if I'm really going in the right direction. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Sat, 05 Nov 2005 19:22:26 +0000
parents 053bb5ad040b
children f08a5365e2c9
comparison
equal deleted inserted replaced
11982:54a3eae03182 11983:39f2aa4350d8
277 277
278 g_free(text); 278 g_free(text);
279 } 279 }
280 280
281 static GdkPixbuf * 281 static GdkPixbuf *
282 load_icon(const char *basename) 282 load_icon(GaimAccount *account, GaimStatusType *status_type)
283 { 283 {
284 char basename2[BUFSIZ]; 284 char basename2[BUFSIZ];
285 char *filename; 285 char *filename;
286 GdkPixbuf *pixbuf, *scale = NULL; 286 GaimPluginProtocolInfo *prpl_info = NULL;
287 287 GaimPlugin *plugin;
288 if (!strcmp(basename, "available")) 288 const char *proto_name, *type_name;
289 basename = "online"; 289 GdkPixbuf *pixbuf, *scale = NULL, *emblem;
290 else if (!strcmp(basename, "hidden")) 290
291 basename = "invisible"; 291
292 292 plugin = gaim_find_prpl(gaim_account_get_protocol_id(account));
293 /* 293
294 * TODO: Find a way to fallback to the GaimStatusPrimitive 294 if (plugin != NULL) {
295 * if an icon for this id does not exist. 295 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin);
296 */ 296 proto_name = prpl_info->list_icon(account, NULL);
297 }
298
297 g_snprintf(basename2, sizeof(basename2), "%s.png", 299 g_snprintf(basename2, sizeof(basename2), "%s.png",
298 basename); 300 proto_name);
299 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "icons", 301 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default",
300 basename2, NULL); 302 basename2, NULL);
301 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); 303 pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
302 g_free(filename); 304 g_free(filename);
303 305
304 if (pixbuf != NULL) { 306 if (pixbuf != NULL) {
305 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, 307 scale = gdk_pixbuf_scale_simple(pixbuf, 32, 32,
306 GDK_INTERP_BILINEAR); 308 GDK_INTERP_BILINEAR);
307
308 g_object_unref(G_OBJECT(pixbuf)); 309 g_object_unref(G_OBJECT(pixbuf));
309 } else { 310 }
310 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", 311
311 "default", basename, NULL); 312
312 scale = gdk_pixbuf_new_from_file(filename, NULL); 313 /* TODO: let the prpl pick the emblem on a per status bases, and only
313 g_free(filename); 314 * use the primitive as a fallback */
314 } 315 type_name = gaim_primitive_get_id_from_type(gaim_status_type_get_primitive(status_type));
315 316 if (!strcmp(type_name, "hidden"))
317 type_name = "invisible";
318 if (!strcmp(type_name, "unavailable"))
319 type_name = "na";
320 g_snprintf(basename2, sizeof(basename2), "%s.png",
321 type_name);
322 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default",
323 basename2, NULL);
324 emblem = gdk_pixbuf_new_from_file(filename, NULL);
325 g_free(filename);
326
327 if (emblem) {
328 gdk_pixbuf_composite(emblem,
329 scale, 32-15, 32-15,
330 15, 15,
331 32-15, 32-15,
332 1, 1,
333 GDK_INTERP_BILINEAR,
334 255);
335
336 g_object_unref(emblem);
337 }
316 return scale; 338 return scale;
317 } 339 }
318 340
319 /** 341 /**
320 * This updates the GtkTreeView so that it correctly shows the state 342 * This updates the GtkTreeView so that it correctly shows the state
329 static void 351 static void
330 update_to_reflect_current_status(GtkGaimStatusBox *status_box) 352 update_to_reflect_current_status(GtkGaimStatusBox *status_box)
331 { 353 {
332 const char *current_savedstatus_name; 354 const char *current_savedstatus_name;
333 GaimSavedStatus *saved_status; 355 GaimSavedStatus *saved_status;
356
357 /* this function is inappropriate for ones with accounts */
358 if (status_box->account)
359 return;
334 360
335 current_savedstatus_name = gaim_prefs_get_string("/core/status/current"); 361 current_savedstatus_name = gaim_prefs_get_string("/core/status/current");
336 saved_status = gaim_savedstatus_find(current_savedstatus_name); 362 saved_status = gaim_savedstatus_find(current_savedstatus_name);
337 363
338 /* 364 /*
440 if (!gaim_status_type_is_user_settable(status_type)) 466 if (!gaim_status_type_is_user_settable(status_type))
441 continue; 467 continue;
442 468
443 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), 469 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box),
444 gaim_status_type_get_primitive(status_type), 470 gaim_status_type_get_primitive(status_type),
445 load_icon(gaim_status_type_get_id(status_type)), 471 load_icon(account, status_type),
446 gaim_status_type_get_name(status_type), 472 gaim_status_type_get_name(status_type),
447 NULL); 473 NULL);
448 } 474 }
449 update_to_reflect_account_status(status_box, account, gaim_account_get_active_status(account)); 475 update_to_reflect_account_status(status_box, account, gaim_account_get_active_status(account));
450 } 476 }