Mercurial > pidgin.yaz
comparison pidgin/gtkutils.c @ 15435:29e443e0613f
I think this takes care of protocol icons. Note there are still places
that ask for a "stauts icon" and expect a protocol icon. I haven't hit
those yet.
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Sat, 27 Jan 2007 10:15:07 +0000 |
parents | e6b40365930c |
children | 9c0cf4db1f4d |
comparison
equal
deleted
inserted
replaced
15434:974e8112b27e | 15435:29e443e0613f |
---|---|
439 GtkWidget *optmenu; | 439 GtkWidget *optmenu; |
440 GtkWidget *menu; | 440 GtkWidget *menu; |
441 GtkWidget *item; | 441 GtkWidget *item; |
442 GtkWidget *image; | 442 GtkWidget *image; |
443 GdkPixbuf *pixbuf; | 443 GdkPixbuf *pixbuf; |
444 GdkPixbuf *scale; | |
445 GList *p; | 444 GList *p; |
446 GtkSizeGroup *sg; | 445 GtkSizeGroup *sg; |
447 char *filename; | 446 char *filename; |
448 const char *proto_name; | 447 const char *proto_name; |
449 char buf[256]; | 448 char buf[256]; |
476 | 475 |
477 /* Load the image. */ | 476 /* Load the image. */ |
478 proto_name = prpl_info->list_icon(NULL, NULL); | 477 proto_name = prpl_info->list_icon(NULL, NULL); |
479 g_snprintf(buf, sizeof(buf), "%s.png", proto_name); | 478 g_snprintf(buf, sizeof(buf), "%s.png", proto_name); |
480 | 479 |
481 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", | 480 filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "protocols", |
482 "default", buf, NULL); | 481 "16", buf, NULL); |
483 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | 482 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
484 g_free(filename); | 483 g_free(filename); |
485 | 484 |
486 if (pixbuf != NULL) { | 485 if (pixbuf) { |
487 /* Scale and insert the image */ | 486 image = gtk_image_new_from_pixbuf(pixbuf); |
488 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, | |
489 GDK_INTERP_BILINEAR); | |
490 image = gtk_image_new_from_pixbuf(scale); | |
491 | 487 |
492 g_object_unref(G_OBJECT(pixbuf)); | 488 g_object_unref(G_OBJECT(pixbuf)); |
493 g_object_unref(G_OBJECT(scale)); | |
494 } | 489 } |
495 else | 490 else |
496 image = gtk_image_new(); | 491 image = gtk_image_new(); |
497 | 492 |
498 gtk_size_group_add_widget(sg, image); | 493 gtk_size_group_add_widget(sg, image); |
566 GtkWidget *item; | 561 GtkWidget *item; |
567 GtkWidget *image; | 562 GtkWidget *image; |
568 GtkWidget *hbox; | 563 GtkWidget *hbox; |
569 GtkWidget *label; | 564 GtkWidget *label; |
570 GdkPixbuf *pixbuf; | 565 GdkPixbuf *pixbuf; |
571 GdkPixbuf *scale; | |
572 GList *list; | 566 GList *list; |
573 GList *p; | 567 GList *p; |
574 GtkSizeGroup *sg; | 568 GtkSizeGroup *sg; |
575 char *filename; | 569 char *filename; |
576 const char *proto_name; | 570 const char *proto_name; |
620 /* Load the image. */ | 614 /* Load the image. */ |
621 if (prpl_info != NULL) { | 615 if (prpl_info != NULL) { |
622 proto_name = prpl_info->list_icon(account, NULL); | 616 proto_name = prpl_info->list_icon(account, NULL); |
623 g_snprintf(buf, sizeof(buf), "%s.png", proto_name); | 617 g_snprintf(buf, sizeof(buf), "%s.png", proto_name); |
624 | 618 |
625 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", | 619 filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "protocols", |
626 "default", buf, NULL); | 620 "16", buf, NULL); |
627 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | 621 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
628 g_free(filename); | 622 g_free(filename); |
629 | 623 |
630 if (pixbuf != NULL) { | 624 if (pixbuf != NULL) { |
631 /* Scale and insert the image */ | |
632 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, | |
633 GDK_INTERP_BILINEAR); | |
634 | |
635 if (gaim_account_is_disconnected(account) && show_all && | 625 if (gaim_account_is_disconnected(account) && show_all && |
636 gaim_connections_get_all()) | 626 gaim_connections_get_all()) |
637 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.0, FALSE); | 627 gdk_pixbuf_saturate_and_pixelate(pixbuf, pixbuf, 0.0, FALSE); |
638 | 628 |
639 image = gtk_image_new_from_pixbuf(scale); | 629 image = gtk_image_new_from_pixbuf(pixbuf); |
640 | 630 |
641 g_object_unref(G_OBJECT(pixbuf)); | 631 g_object_unref(G_OBJECT(pixbuf)); |
642 g_object_unref(G_OBJECT(scale)); | |
643 } | 632 } |
644 else | 633 else |
645 image = gtk_image_new(); | 634 image = gtk_image_new(); |
646 } | 635 } |
647 else | 636 else |
1541 if(*height > 100) | 1530 if(*height > 100) |
1542 *height = 100; | 1531 *height = 100; |
1543 } | 1532 } |
1544 | 1533 |
1545 GdkPixbuf * | 1534 GdkPixbuf * |
1546 gaim_gtk_create_prpl_icon(GaimAccount *account, double scale_factor) | 1535 gaim_gtk_create_prpl_icon(GaimAccount *account, PidginPrplIconSize size) |
1547 { | 1536 { |
1548 GaimPlugin *prpl; | 1537 GaimPlugin *prpl; |
1549 GaimPluginProtocolInfo *prpl_info; | 1538 GaimPluginProtocolInfo *prpl_info; |
1550 const char *protoname = NULL; | 1539 const char *protoname = NULL; |
1551 char buf[256]; /* TODO: We should use a define for max file length */ | 1540 char buf[256]; /* TODO: We should use a define for max file length */ |
1552 char *filename = NULL; | 1541 char *filename = NULL; |
1553 GdkPixbuf *pixbuf, *scaled; | 1542 GdkPixbuf *pixbuf; |
1554 | 1543 |
1555 g_return_val_if_fail(account != NULL, NULL); | 1544 g_return_val_if_fail(account != NULL, NULL); |
1556 | 1545 |
1557 prpl = gaim_find_prpl(gaim_account_get_protocol_id(account)); | 1546 prpl = gaim_find_prpl(gaim_account_get_protocol_id(account)); |
1558 if (prpl == NULL) | 1547 if (prpl == NULL) |
1570 * Status icons will be themeable too, and then it will look up | 1559 * Status icons will be themeable too, and then it will look up |
1571 * protoname from the theme | 1560 * protoname from the theme |
1572 */ | 1561 */ |
1573 g_snprintf(buf, sizeof(buf), "%s.png", protoname); | 1562 g_snprintf(buf, sizeof(buf), "%s.png", protoname); |
1574 | 1563 |
1575 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", | 1564 filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "protocols", |
1576 "default", buf, NULL); | 1565 size == PIDGIN_PRPL_ICON_SMALL ? "16" : |
1566 size == PIDGIN_PRPL_ICON_MEDIUM ? "22" : "48", | |
1567 buf, NULL); | |
1577 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | 1568 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
1578 g_free(filename); | 1569 g_free(filename); |
1579 | 1570 |
1580 scaled = gdk_pixbuf_scale_simple(pixbuf, 32*scale_factor, | 1571 return pixbuf; |
1581 32*scale_factor, GDK_INTERP_BILINEAR); | |
1582 g_object_unref(pixbuf); | |
1583 | |
1584 return scaled; | |
1585 } | 1572 } |
1586 | 1573 |
1587 static GdkPixbuf * | 1574 static GdkPixbuf * |
1588 overlay_status_onto_icon(GdkPixbuf *pixbuf, GaimStatusPrimitive primitive) | 1575 overlay_status_onto_icon(GdkPixbuf *pixbuf, GaimStatusPrimitive primitive) |
1589 { | 1576 { |