Mercurial > pidgin
comparison src/gtkstatusbox.c @ 12080:3b52d94437f3
[gaim-migrate @ 14377]
The rest of sf patch #1354886, from Sadrul Habib Chowdhury, with
an EXTREME amount of changes from me. Come to me, first, if something
doesn't work.
This allows you to edit the substatuses of a saved status.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Mon, 14 Nov 2005 07:20:22 +0000 |
parents | 4fb1edd43f45 |
children | 383226e075f2 |
comparison
equal
deleted
inserted
replaced
12079:15732b01ea3d | 12080:3b52d94437f3 |
---|---|
31 | 31 |
32 #include "gtkgaim.h" | 32 #include "gtkgaim.h" |
33 #include "gtksavedstatuses.h" | 33 #include "gtksavedstatuses.h" |
34 #include "gtkstock.h" | 34 #include "gtkstock.h" |
35 #include "gtkstatusbox.h" | 35 #include "gtkstatusbox.h" |
36 #include "gtkutils.h" | |
36 | 37 |
37 static void imhtml_changed_cb(GtkTextBuffer *buffer, void *data); | 38 static void imhtml_changed_cb(GtkTextBuffer *buffer, void *data); |
38 static void remove_typing_cb(GtkGaimStatusBox *box); | 39 static void remove_typing_cb(GtkGaimStatusBox *box); |
39 | 40 |
40 static void gtk_gaim_status_box_refresh(GtkGaimStatusBox *status_box); | 41 static void gtk_gaim_status_box_refresh(GtkGaimStatusBox *status_box); |
290 gtk_tree_path_free(path); | 291 gtk_tree_path_free(path); |
291 | 292 |
292 g_free(text); | 293 g_free(text); |
293 } | 294 } |
294 | 295 |
295 static GdkPixbuf * | |
296 load_icon(GaimAccount *account, GaimStatusType *status_type) | |
297 { | |
298 char basename2[BUFSIZ]; | |
299 char *filename; | |
300 GaimPluginProtocolInfo *prpl_info = NULL; | |
301 GaimPlugin *plugin; | |
302 const char *proto_name = NULL, *type_name; | |
303 GdkPixbuf *pixbuf, *scale = NULL, *emblem; | |
304 | |
305 | |
306 plugin = gaim_find_prpl(gaim_account_get_protocol_id(account)); | |
307 | |
308 if (plugin != NULL) { | |
309 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); | |
310 proto_name = prpl_info->list_icon(account, NULL); | |
311 } else { | |
312 return NULL; | |
313 } | |
314 | |
315 g_snprintf(basename2, sizeof(basename2), "%s.png", | |
316 proto_name); | |
317 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", | |
318 basename2, NULL); | |
319 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | |
320 g_free(filename); | |
321 | |
322 if (pixbuf != NULL) { | |
323 scale = gdk_pixbuf_scale_simple(pixbuf, 32, 32, | |
324 GDK_INTERP_BILINEAR); | |
325 g_object_unref(G_OBJECT(pixbuf)); | |
326 } | |
327 | |
328 | |
329 /* TODO: let the prpl pick the emblem on a per status bases, and only | |
330 * use the primitive as a fallback */ | |
331 type_name = gaim_primitive_get_id_from_type(gaim_status_type_get_primitive(status_type)); | |
332 if (!strcmp(type_name, "hidden")) | |
333 type_name = "invisible"; | |
334 if (!strcmp(type_name, "unavailable")) | |
335 type_name = "na"; | |
336 g_snprintf(basename2, sizeof(basename2), "%s.png", | |
337 type_name); | |
338 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", | |
339 basename2, NULL); | |
340 emblem = gdk_pixbuf_new_from_file(filename, NULL); | |
341 g_free(filename); | |
342 | |
343 if (emblem) { | |
344 gdk_pixbuf_composite(emblem, | |
345 scale, 32-15, 32-15, | |
346 15, 15, | |
347 32-15, 32-15, | |
348 1, 1, | |
349 GDK_INTERP_BILINEAR, | |
350 255); | |
351 | |
352 g_object_unref(emblem); | |
353 } | |
354 return scale; | |
355 } | |
356 | |
357 /** | 296 /** |
358 * This updates the GtkTreeView so that it correctly shows the state | 297 * This updates the GtkTreeView so that it correctly shows the state |
359 * we are currently using. It is used when the current state is | 298 * we are currently using. It is used when the current state is |
360 * updated from somewhere other than the GtkStatusBox (from a plugin, | 299 * updated from somewhere other than the GtkStatusBox (from a plugin, |
361 * or when signing on with the "-n" option, for example). It is | 300 * or when signing on with the "-n" option, for example). It is |
398 ((primitive != GAIM_STATUS_AVAILABLE) && | 337 ((primitive != GAIM_STATUS_AVAILABLE) && |
399 (primitive != GAIM_STATUS_OFFLINE) && | 338 (primitive != GAIM_STATUS_OFFLINE) && |
400 (primitive != GAIM_STATUS_AWAY) && | 339 (primitive != GAIM_STATUS_AWAY) && |
401 (primitive != GAIM_STATUS_HIDDEN))) | 340 (primitive != GAIM_STATUS_HIDDEN))) |
402 { | 341 { |
403 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 4); | 342 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 5); |
404 } | 343 } |
405 else | 344 else |
406 { | 345 { |
407 if (primitive == GAIM_STATUS_AVAILABLE) | 346 if (primitive == GAIM_STATUS_AVAILABLE) |
408 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 0); | 347 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 0); |
484 if (!gaim_status_type_is_user_settable(status_type)) | 423 if (!gaim_status_type_is_user_settable(status_type)) |
485 continue; | 424 continue; |
486 | 425 |
487 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), | 426 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), |
488 gaim_status_type_get_primitive(status_type), | 427 gaim_status_type_get_primitive(status_type), |
489 load_icon(account, status_type), | 428 gaim_gtk_create_prpl_icon_with_status(account, status_type), |
490 gaim_status_type_get_name(status_type), | 429 gaim_status_type_get_name(status_type), |
491 NULL); | 430 NULL); |
492 } | 431 } |
493 update_to_reflect_account_status(status_box, account, gaim_account_get_active_status(account)); | 432 update_to_reflect_account_status(status_box, account, gaim_account_get_active_status(account)); |
494 } | 433 } |