Mercurial > pidgin
comparison src/gtkblist.c @ 13090:0aa231ebbfd5
[gaim-migrate @ 15452]
Changes to some pixbuf stuff.
I added a 'gaim_gtk_create_gaim_icon_with_status()' function to util.c,
and changed 'gaim_gtk_create_prpl_icon_with_status()' to accept a scale
factor because almost everywhere this function was used we would scale
the pixbuf to a smaller size as soon as we got it. So there's a bit less
code duplication.
Also, I think I added some g_object_unref()'s in one or two places where
it was missing.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 01 Feb 2006 22:38:34 +0000 |
parents | 97fa7332b034 |
children | a0a4b44239e8 |
comparison
equal
deleted
inserted
replaced
13089:b553326bc468 | 13090:0aa231ebbfd5 |
---|---|
3490 static void | 3490 static void |
3491 create_connection_error_buttons(gpointer key, gpointer value, | 3491 create_connection_error_buttons(gpointer key, gpointer value, |
3492 gpointer user_data) | 3492 gpointer user_data) |
3493 { | 3493 { |
3494 GaimAccount *account; | 3494 GaimAccount *account; |
3495 gchar *escaped, *text, *filename; | 3495 GaimStatusType *status_type; |
3496 gchar *escaped, *text; | |
3496 GtkWidget *button, *label, *image, *hbox; | 3497 GtkWidget *button, *label, *image, *hbox; |
3497 GdkPixbuf *pixbuf, *emblem, *scale; | 3498 GdkPixbuf *pixbuf; |
3498 | 3499 |
3499 account = key; | 3500 account = key; |
3500 escaped = g_markup_escape_text((const gchar *)value, -1); | 3501 escaped = g_markup_escape_text((const gchar *)value, -1); |
3501 text = g_strdup_printf(_("<span color=\"red\">%s disconnected: %s</span>"), | 3502 text = g_strdup_printf(_("<span color=\"red\">%s disconnected: %s</span>"), |
3502 gaim_account_get_username(account), | 3503 gaim_account_get_username(account), |
3504 g_free(escaped); | 3505 g_free(escaped); |
3505 | 3506 |
3506 hbox = gtk_hbox_new(FALSE, 0); | 3507 hbox = gtk_hbox_new(FALSE, 0); |
3507 | 3508 |
3508 /* Create the icon */ | 3509 /* Create the icon */ |
3509 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "offline.png", NULL); | 3510 status_type = gaim_account_get_status_type_with_primitive(account, |
3510 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | 3511 GAIM_STATUS_OFFLINE); |
3511 g_free(filename); | 3512 pixbuf = gaim_gtk_create_prpl_icon_with_status(account, status_type, 0.5); |
3512 if (pixbuf != NULL) { | 3513 if (pixbuf != NULL) { |
3513 scale = gdk_pixbuf_scale_simple(pixbuf, 10, 10, | 3514 image = gtk_image_new_from_pixbuf(pixbuf); |
3514 GDK_INTERP_BILINEAR); | |
3515 g_object_unref(pixbuf); | 3515 g_object_unref(pixbuf); |
3516 emblem = scale; | |
3517 scale = NULL; | |
3518 | |
3519 pixbuf = gaim_gtk_create_prpl_icon(account); | |
3520 if (pixbuf != NULL) { | |
3521 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, | |
3522 GDK_INTERP_BILINEAR); | |
3523 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.0, FALSE); | |
3524 g_object_unref(G_OBJECT(pixbuf)); | |
3525 | |
3526 gdk_pixbuf_composite(emblem, scale, 6, 6, 10, 10, 6, 6, 1, 1, | |
3527 GDK_INTERP_BILINEAR, 255); | |
3528 g_object_unref(emblem); | |
3529 | |
3530 emblem = scale; | |
3531 } | |
3532 | |
3533 image = gtk_image_new_from_pixbuf(emblem); | |
3534 g_object_unref(emblem); | |
3535 | 3516 |
3536 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, | 3517 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, |
3537 GAIM_HIG_BOX_SPACE); | 3518 GAIM_HIG_BOX_SPACE); |
3538 } | 3519 } |
3539 | 3520 |
5543 char *buf = NULL; | 5524 char *buf = NULL; |
5544 GtkWidget *image = NULL; | 5525 GtkWidget *image = NULL; |
5545 GaimConnection *gc = NULL; | 5526 GaimConnection *gc = NULL; |
5546 GaimAccount *account = NULL; | 5527 GaimAccount *account = NULL; |
5547 GaimStatus *status = NULL; | 5528 GaimStatus *status = NULL; |
5548 GdkPixbuf *pixbuf = NULL, *scale = NULL; | 5529 GdkPixbuf *pixbuf = NULL; |
5549 | 5530 |
5550 account = accounts->data; | 5531 account = accounts->data; |
5551 | 5532 |
5552 if(gaim_account_get_enabled(account, GAIM_GTK_UI)) { | 5533 if(gaim_account_get_enabled(account, GAIM_GTK_UI)) { |
5553 buf = g_strconcat(gaim_account_get_username(account), " (", | 5534 buf = g_strconcat(gaim_account_get_username(account), " (", |
5554 gaim_account_get_protocol_name(account), ")", NULL); | 5535 gaim_account_get_protocol_name(account), ")", NULL); |
5555 menuitem = gtk_image_menu_item_new_with_label(buf); | 5536 menuitem = gtk_image_menu_item_new_with_label(buf); |
5556 g_free(buf); | 5537 g_free(buf); |
5557 status = gaim_account_get_active_status(account); | 5538 status = gaim_account_get_active_status(account); |
5558 pixbuf = gaim_gtk_create_prpl_icon_with_status(account, gaim_status_get_type(status)); | 5539 pixbuf = gaim_gtk_create_prpl_icon_with_status(account, gaim_status_get_type(status), 0.5); |
5559 if (pixbuf) { | 5540 if (pixbuf != NULL) |
5560 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, | 5541 { |
5561 GDK_INTERP_BILINEAR); | |
5562 if (!gaim_account_is_connected(account)) | 5542 if (!gaim_account_is_connected(account)) |
5563 gdk_pixbuf_saturate_and_pixelate(scale, scale, | 5543 gdk_pixbuf_saturate_and_pixelate(pixbuf, pixbuf, |
5564 0.0, FALSE); | 5544 0.0, FALSE); |
5565 image = gtk_image_new_from_pixbuf(scale); | 5545 image = gtk_image_new_from_pixbuf(pixbuf); |
5566 g_object_unref(G_OBJECT(pixbuf)); | 5546 g_object_unref(G_OBJECT(pixbuf)); |
5567 g_object_unref(G_OBJECT(scale)); | |
5568 gtk_widget_show(image); | 5547 gtk_widget_show(image); |
5569 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image); | 5548 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image); |
5570 } | 5549 } |
5571 gtk_menu_shell_append(GTK_MENU_SHELL(accountmenu), menuitem); | 5550 gtk_menu_shell_append(GTK_MENU_SHELL(accountmenu), menuitem); |
5572 gtk_widget_show(menuitem); | 5551 gtk_widget_show(menuitem); |
5645 | 5624 |
5646 for (accounts = gaim_accounts_get_all(); accounts; accounts = accounts->next) { | 5625 for (accounts = gaim_accounts_get_all(); accounts; accounts = accounts->next) { |
5647 char *buf = NULL; | 5626 char *buf = NULL; |
5648 GtkWidget *image = NULL; | 5627 GtkWidget *image = NULL; |
5649 GaimAccount *account = NULL; | 5628 GaimAccount *account = NULL; |
5650 GdkPixbuf *pixbuf = NULL, *scale = NULL; | 5629 GdkPixbuf *pixbuf = NULL; |
5651 | 5630 |
5652 account = accounts->data; | 5631 account = accounts->data; |
5653 | 5632 |
5654 if(!gaim_account_get_enabled(account, GAIM_GTK_UI)) { | 5633 if(!gaim_account_get_enabled(account, GAIM_GTK_UI)) { |
5655 | 5634 |
5657 | 5636 |
5658 buf = g_strconcat(gaim_account_get_username(account), " (", | 5637 buf = g_strconcat(gaim_account_get_username(account), " (", |
5659 gaim_account_get_protocol_name(account), ")", NULL); | 5638 gaim_account_get_protocol_name(account), ")", NULL); |
5660 menuitem = gtk_image_menu_item_new_with_label(buf); | 5639 menuitem = gtk_image_menu_item_new_with_label(buf); |
5661 g_free(buf); | 5640 g_free(buf); |
5662 pixbuf = gaim_gtk_create_prpl_icon(account); | 5641 pixbuf = gaim_gtk_create_prpl_icon(account, 0.5); |
5663 if (pixbuf) { | 5642 if (pixbuf != NULL) |
5664 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, | 5643 { |
5665 GDK_INTERP_BILINEAR); | 5644 if (!gaim_account_is_connected(account)) |
5666 if (gaim_account_is_disconnected(account)) | 5645 gdk_pixbuf_saturate_and_pixelate(pixbuf, pixbuf, 0.0, FALSE); |
5667 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.00, FALSE); | 5646 image = gtk_image_new_from_pixbuf(pixbuf); |
5668 image = gtk_image_new_from_pixbuf(scale); | |
5669 g_object_unref(G_OBJECT(pixbuf)); | 5647 g_object_unref(G_OBJECT(pixbuf)); |
5670 g_object_unref(G_OBJECT(scale)); | |
5671 gtk_widget_show(image); | 5648 gtk_widget_show(image); |
5672 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image); | 5649 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image); |
5673 } | 5650 } |
5674 g_signal_connect(G_OBJECT(menuitem), "activate", | 5651 g_signal_connect(G_OBJECT(menuitem), "activate", |
5675 G_CALLBACK(enable_account_cb), account); | 5652 G_CALLBACK(enable_account_cb), account); |