Mercurial > pidgin.yaz
comparison src/gtkutils.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 | e859c1663a27 |
children | 2cbb5993c819 |
comparison
equal
deleted
inserted
replaced
12079:15732b01ea3d | 12080:3b52d94437f3 |
---|---|
1607 if(*width > 100) | 1607 if(*width > 100) |
1608 *width = 100; | 1608 *width = 100; |
1609 if(*height > 100) | 1609 if(*height > 100) |
1610 *height = 100; | 1610 *height = 100; |
1611 } | 1611 } |
1612 | |
1613 GdkPixbuf * | |
1614 gaim_gtk_create_prpl_icon(GaimAccount *account) | |
1615 { | |
1616 GaimPlugin *prpl; | |
1617 GaimPluginProtocolInfo *prpl_info = NULL; | |
1618 GdkPixbuf *status = NULL; | |
1619 char *filename = NULL; | |
1620 const char *protoname = NULL; | |
1621 char buf[256]; /* TODO: We should use a define for max file length */ | |
1622 | |
1623 g_return_val_if_fail(account != NULL, NULL); | |
1624 | |
1625 prpl = gaim_find_prpl(gaim_account_get_protocol_id(account)); | |
1626 | |
1627 if (prpl != NULL) { | |
1628 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); | |
1629 | |
1630 if (prpl_info->list_icon != NULL) | |
1631 protoname = prpl_info->list_icon(account, NULL); | |
1632 } | |
1633 | |
1634 if (protoname == NULL) | |
1635 return NULL; | |
1636 | |
1637 /* | |
1638 * Status icons will be themeable too, and then it will look up | |
1639 * protoname from the theme | |
1640 */ | |
1641 g_snprintf(buf, sizeof(buf), "%s.png", protoname); | |
1642 | |
1643 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", | |
1644 "default", buf, NULL); | |
1645 status = gdk_pixbuf_new_from_file(filename, NULL); | |
1646 g_free(filename); | |
1647 | |
1648 return status; | |
1649 } | |
1650 | |
1651 GdkPixbuf * | |
1652 gaim_gtk_create_prpl_icon_with_status(GaimAccount *account, GaimStatusType *status_type) | |
1653 { | |
1654 char basename2[BUFSIZ]; | |
1655 char *filename; | |
1656 const char *type_name; | |
1657 GdkPixbuf *pixbuf, *scale = NULL, *emblem; | |
1658 | |
1659 pixbuf = gaim_gtk_create_prpl_icon(account); | |
1660 | |
1661 if (pixbuf != NULL) { | |
1662 scale = gdk_pixbuf_scale_simple(pixbuf, 32, 32, | |
1663 GDK_INTERP_BILINEAR); | |
1664 g_object_unref(G_OBJECT(pixbuf)); | |
1665 } else { | |
1666 return NULL; | |
1667 } | |
1668 | |
1669 /* TODO: let the prpl pick the emblem on a per status basis, and only | |
1670 * use the primitive as a fallback */ | |
1671 type_name = gaim_primitive_get_id_from_type(gaim_status_type_get_primitive(status_type)); | |
1672 if (!strcmp(type_name, "hidden")) | |
1673 type_name = "invisible"; | |
1674 else if (!strcmp(type_name, "unavailable")) | |
1675 type_name = "na"; | |
1676 g_snprintf(basename2, sizeof(basename2), "%s.png", | |
1677 type_name); | |
1678 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", | |
1679 basename2, NULL); | |
1680 emblem = gdk_pixbuf_new_from_file(filename, NULL); | |
1681 g_free(filename); | |
1682 | |
1683 if (emblem) { | |
1684 gdk_pixbuf_composite(emblem, | |
1685 scale, 32-15, 32-15, | |
1686 15, 15, | |
1687 32-15, 32-15, | |
1688 1, 1, | |
1689 GDK_INTERP_BILINEAR, | |
1690 255); | |
1691 | |
1692 g_object_unref(emblem); | |
1693 } | |
1694 return scale; | |
1695 } | |
1696 |