| 591 if (status_box->typing != 0) |
591 if (status_box->typing != 0) |
| 592 pixbuf = status_box->typing_pixbufs[status_box->typing_index]; |
592 pixbuf = status_box->typing_pixbufs[status_box->typing_index]; |
| 593 else if (status_box->connecting) |
593 else if (status_box->connecting) |
| 594 pixbuf = status_box->connecting_pixbufs[status_box->connecting_index]; |
594 pixbuf = status_box->connecting_pixbufs[status_box->connecting_index]; |
| 595 else |
595 else |
| 596 { |
596 { |
| |
597 GaimStatusType *status_type; |
| |
598 GaimStatusPrimitive prim; |
| |
599 GtkIconSize icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_TANGO_EXTRA_SMALL); |
| |
600 if (account_status) { |
| |
601 status_type = gaim_status_get_type(gaim_account_get_active_status(acct)); |
| |
602 prim = gaim_status_type_get_primitive(status_type); |
| |
603 } else { |
| |
604 prim = gaim_savedstatus_get_type(saved_status); |
| |
605 } |
| |
606 |
| |
607 if (prim == GAIM_STATUS_UNAVAILABLE) |
| |
608 pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_BUSY, |
| |
609 icon_size, "GtkTreeView"); |
| |
610 else if (prim == GAIM_STATUS_AWAY) |
| |
611 pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_AWAY, |
| |
612 icon_size, "GtkTreeView"); |
| |
613 else if (prim == GAIM_STATUS_EXTENDED_AWAY) |
| |
614 pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_XA, |
| |
615 icon_size, "GtkTreeView"); |
| |
616 else if (prim == GAIM_STATUS_OFFLINE) |
| |
617 pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_OFFLINE, |
| |
618 icon_size, "GtkTreeView"); |
| |
619 else |
| |
620 pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_AVAILABLE, |
| |
621 icon_size, "GtkTreeView"); |
| |
622 #if 0 |
| 597 if (account_status) |
623 if (account_status) |
| 598 pixbuf = gaim_gtk_create_prpl_icon_with_status(acct, |
624 pixbuf = gaim_gtk_create_prpl_icon_with_status(acct, |
| 599 gaim_status_get_type(gaim_account_get_active_status(acct)), |
625 gaim_status_get_type(gaim_account_get_active_status(acct)), |
| 600 0.5); |
626 0.5); |
| 601 else |
627 else |
| 619 width, height, 0, height, |
645 width, height, 0, height, |
| 620 0.5, 0.5, GDK_INTERP_BILINEAR, 255); |
646 0.5, 0.5, GDK_INTERP_BILINEAR, 255); |
| 621 g_object_unref(G_OBJECT(emblem)); |
647 g_object_unref(G_OBJECT(emblem)); |
| 622 } |
648 } |
| 623 } |
649 } |
| |
650 #endif |
| |
651 |
| 624 } |
652 } |
| 625 |
653 |
| 626 if (status_box->account != NULL) { |
654 if (status_box->account != NULL) { |
| 627 text = g_strdup_printf("%s - <span size=\"smaller\" color=\"%s\">%s</span>", |
655 text = g_strdup_printf("%s - <span size=\"smaller\" color=\"%s\">%s</span>", |
| 628 gaim_account_get_username(status_box->account), |
656 gaim_account_get_username(status_box->account), |
| 825 for (cur = list; cur != NULL; cur = cur->next) |
853 for (cur = list; cur != NULL; cur = cur->next) |
| 826 { |
854 { |
| 827 GaimSavedStatus *saved = cur->data; |
855 GaimSavedStatus *saved = cur->data; |
| 828 const gchar *message; |
856 const gchar *message; |
| 829 gchar *stripped = NULL; |
857 gchar *stripped = NULL; |
| |
858 GaimStatusPrimitive prim; |
| 830 |
859 |
| 831 /* Get an appropriate status icon */ |
860 /* Get an appropriate status icon */ |
| 832 pixbuf = gaim_gtk_create_gaim_icon_with_status( |
861 prim = gaim_savedstatus_get_type(saved); |
| 833 gaim_savedstatus_get_type(saved), |
862 |
| 834 0.5); |
863 if (prim == GAIM_STATUS_UNAVAILABLE) |
| 835 |
864 pixbuf = gtk_widget_render_icon (GTK_WIDGET(statusbox), GAIM_STOCK_STATUS_BUSY, |
| |
865 icon_size, "GtkTreeView"); |
| |
866 else if (prim == GAIM_STATUS_AWAY) |
| |
867 pixbuf = gtk_widget_render_icon (GTK_WIDGET(statusbox), GAIM_STOCK_STATUS_AWAY, |
| |
868 icon_size, "GtkTreeView"); |
| |
869 else if (prim == GAIM_STATUS_EXTENDED_AWAY) |
| |
870 pixbuf = gtk_widget_render_icon (GTK_WIDGET(statusbox), GAIM_STOCK_STATUS_XA, |
| |
871 icon_size, "GtkTreeView"); |
| |
872 else if (prim == GAIM_STATUS_OFFLINE) |
| |
873 pixbuf = gtk_widget_render_icon (GTK_WIDGET(statusbox), GAIM_STOCK_STATUS_OFFLINE, |
| |
874 icon_size, "GtkTreeView"); |
| |
875 else |
| |
876 pixbuf = gtk_widget_render_icon (GTK_WIDGET(statusbox), GAIM_STOCK_STATUS_AVAILABLE, |
| |
877 icon_size, "GtkTreeView"); |
| |
878 |
| 836 if (gaim_savedstatus_is_transient(saved)) |
879 if (gaim_savedstatus_is_transient(saved)) |
| 837 { |
880 { |
| 838 /* |
881 /* |
| 839 * Transient statuses do not have a title, so the savedstatus |
882 * Transient statuses do not have a title, so the savedstatus |
| 840 * API returns the message when gaim_savedstatus_get_title() is |
883 * API returns the message when gaim_savedstatus_get_title() is |
| 847 if (message != NULL) |
890 if (message != NULL) |
| 848 { |
891 { |
| 849 stripped = gaim_markup_strip_html(message); |
892 stripped = gaim_markup_strip_html(message); |
| 850 gaim_util_chrreplace(stripped, '\n', ' '); |
893 gaim_util_chrreplace(stripped, '\n', ' '); |
| 851 } |
894 } |
| 852 |
895 #if 0 |
| 853 /* Overlay a disk in the bottom left corner */ |
896 /* Overlay a disk in the bottom left corner */ |
| 854 emblem = gtk_widget_render_icon(GTK_WIDGET(statusbox->vbox), |
897 emblem = gtk_widget_render_icon(GTK_WIDGET(statusbox->vbox), |
| 855 GTK_STOCK_SAVE, icon_size, "GtkGaimStatusBox"); |
898 GTK_STOCK_SAVE, icon_size, "GtkGaimStatusBox"); |
| 856 if (emblem != NULL) |
899 if (emblem != NULL) |
| 857 { |
900 { |
| 860 gdk_pixbuf_composite(emblem, pixbuf, 0, height, |
903 gdk_pixbuf_composite(emblem, pixbuf, 0, height, |
| 861 width, height, 0, height, |
904 width, height, 0, height, |
| 862 0.5, 0.5, GDK_INTERP_BILINEAR, 255); |
905 0.5, 0.5, GDK_INTERP_BILINEAR, 255); |
| 863 g_object_unref(G_OBJECT(emblem)); |
906 g_object_unref(G_OBJECT(emblem)); |
| 864 } |
907 } |
| |
908 #endif |
| 865 } |
909 } |
| 866 |
910 |
| 867 gtk_gaim_status_box_add(statusbox, GTK_GAIM_STATUS_BOX_TYPE_POPULAR, |
911 gtk_gaim_status_box_add(statusbox, GTK_GAIM_STATUS_BOX_TYPE_POPULAR, |
| 868 pixbuf, gaim_savedstatus_get_title(saved), stripped, |
912 pixbuf, gaim_savedstatus_get_title(saved), stripped, |
| 869 GINT_TO_POINTER(gaim_savedstatus_get_creation_time(saved))); |
913 GINT_TO_POINTER(gaim_savedstatus_get_creation_time(saved))); |
| 928 static void |
972 static void |
| 929 add_account_statuses(GtkGaimStatusBox *status_box, GaimAccount *account) |
973 add_account_statuses(GtkGaimStatusBox *status_box, GaimAccount *account) |
| 930 { |
974 { |
| 931 /* Per-account */ |
975 /* Per-account */ |
| 932 const GList *l; |
976 const GList *l; |
| 933 GdkPixbuf *tmp; |
977 GdkPixbuf *pixbuf; |
| 934 |
978 |
| 935 for (l = gaim_account_get_status_types(account); l != NULL; l = l->next) |
979 for (l = gaim_account_get_status_types(account); l != NULL; l = l->next) |
| 936 { |
980 { |
| 937 GaimStatusType *status_type = (GaimStatusType *)l->data; |
981 GaimStatusType *status_type = (GaimStatusType *)l->data; |
| |
982 GaimStatusPrimitive prim; |
| |
983 GtkIconSize icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_TANGO_EXTRA_SMALL); |
| 938 |
984 |
| 939 if (!gaim_status_type_is_user_settable(status_type)) |
985 if (!gaim_status_type_is_user_settable(status_type)) |
| 940 continue; |
986 continue; |
| 941 |
987 |
| 942 tmp = gaim_gtk_create_prpl_icon_with_status(account, status_type, 0.5); |
988 prim = gaim_status_type_get_primitive(status_type); |
| |
989 |
| |
990 if (prim == GAIM_STATUS_UNAVAILABLE) |
| |
991 pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_BUSY, |
| |
992 icon_size, "GtkTreeView"); |
| |
993 else if (prim == GAIM_STATUS_AWAY) |
| |
994 pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_AWAY, |
| |
995 icon_size, "GtkTreeView"); |
| |
996 else if (prim == GAIM_STATUS_EXTENDED_AWAY) |
| |
997 pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_XA, |
| |
998 icon_size, "GtkTreeView"); |
| |
999 else if (prim == GAIM_STATUS_OFFLINE) |
| |
1000 pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_OFFLINE, |
| |
1001 icon_size, "GtkTreeView"); |
| |
1002 else |
| |
1003 pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_AVAILABLE, |
| |
1004 icon_size, "GtkTreeView"); |
| |
1005 |
| 943 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), |
1006 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), |
| 944 GTK_GAIM_STATUS_BOX_TYPE_PRIMITIVE, tmp, |
1007 GTK_GAIM_STATUS_BOX_TYPE_PRIMITIVE, pixbuf, |
| 945 gaim_status_type_get_name(status_type), |
1008 gaim_status_type_get_name(status_type), |
| 946 NULL, |
1009 NULL, |
| 947 GINT_TO_POINTER(gaim_status_type_get_primitive(status_type))); |
1010 GINT_TO_POINTER(gaim_status_type_get_primitive(status_type))); |
| 948 if (tmp != NULL) |
1011 if (pixbuf != NULL) |
| 949 g_object_unref(tmp); |
1012 g_object_unref(pixbuf); |
| 950 } |
1013 } |
| 951 } |
1014 } |
| 952 |
1015 |
| 953 static void |
1016 static void |
| 954 gtk_gaim_status_box_regenerate(GtkGaimStatusBox *status_box) |
1017 gtk_gaim_status_box_regenerate(GtkGaimStatusBox *status_box) |
| 1671 gint border_width = GTK_CONTAINER (widget)->border_width; |
1734 gint border_width = GTK_CONTAINER (widget)->border_width; |
| 1672 |
1735 |
| 1673 gtk_widget_size_request(GTK_GAIM_STATUS_BOX(widget)->toggle_button, requisition); |
1736 gtk_widget_size_request(GTK_GAIM_STATUS_BOX(widget)->toggle_button, requisition); |
| 1674 |
1737 |
| 1675 /* Make this icon the same size as other buddy icons in the list; unless it already wants to be bigger */ |
1738 /* Make this icon the same size as other buddy icons in the list; unless it already wants to be bigger */ |
| 1676 requisition->height = MAX(requisition->height, 32 + (border_width*2)); |
1739 requisition->height = MAX(requisition->height, 34); |
| |
1740 requisition->height += border_width * 2; |
| 1677 |
1741 |
| 1678 /* If the gtkimhtml is visible, then add some additional padding */ |
1742 /* If the gtkimhtml is visible, then add some additional padding */ |
| 1679 gtk_widget_size_request(GTK_GAIM_STATUS_BOX(widget)->vbox, &box_req); |
1743 gtk_widget_size_request(GTK_GAIM_STATUS_BOX(widget)->vbox, &box_req); |
| 1680 if (box_req.height > 1) |
1744 if (box_req.height > 1) |
| 1681 requisition->height += box_req.height + border_width * 2; |
1745 requisition->height += box_req.height + border_width * 2; |
| 1733 gint border_width = GTK_CONTAINER (widget)->border_width; |
1797 gint border_width = GTK_CONTAINER (widget)->border_width; |
| 1734 |
1798 |
| 1735 gtk_widget_size_request(status_box->toggle_button, &req); |
1799 gtk_widget_size_request(status_box->toggle_button, &req); |
| 1736 /* Make this icon the same size as other buddy icons in the list; unless it already wants to be bigger */ |
1800 /* Make this icon the same size as other buddy icons in the list; unless it already wants to be bigger */ |
| 1737 |
1801 |
| 1738 req.height = MAX(req.height, 32 + (border_width*2)); |
1802 req.height = MAX(req.height, 34); |
| |
1803 req.height += border_width * 2; |
| 1739 |
1804 |
| 1740 box_alc = *allocation; |
1805 box_alc = *allocation; |
| 1741 |
1806 |
| 1742 box_alc.width -= (border_width * 2); |
1807 box_alc.width -= (border_width * 2); |
| 1743 box_alc.height = MAX(1, ((allocation->height - req.height) - (border_width*2))); |
1808 box_alc.height = MAX(1, ((allocation->height - req.height) - (border_width*2))); |
| 1753 |
1818 |
| 1754 if (status_box->icon_box) |
1819 if (status_box->icon_box) |
| 1755 { |
1820 { |
| 1756 GtkTextDirection dir = gtk_widget_get_direction(widget); |
1821 GtkTextDirection dir = gtk_widget_get_direction(widget); |
| 1757 parent_alc.width -= (parent_alc.height + border_width); |
1822 parent_alc.width -= (parent_alc.height + border_width); |
| 1758 icon_alc = *allocation; |
1823 icon_alc = parent_alc; |
| 1759 icon_alc.height = MAX(1,req.height) - (border_width*2); |
1824 icon_alc.height = MAX(1,req.height) - (border_width*2) -2; |
| 1760 icon_alc.width = icon_alc.height; |
1825 icon_alc.width = icon_alc.height; |
| 1761 if (dir == GTK_TEXT_DIR_RTL) { |
1826 if (dir == GTK_TEXT_DIR_RTL) { |
| 1762 icon_alc.x = parent_alc.x; |
1827 icon_alc.x = parent_alc.x; |
| 1763 parent_alc.x += icon_alc.width + border_width; |
1828 parent_alc.x += icon_alc.width + border_width; |
| 1764 } else { |
1829 } else { |
| 1765 icon_alc.x = allocation->width - (icon_alc.width + border_width); |
1830 icon_alc.x = allocation->width - (icon_alc.width + border_width + 1); |
| 1766 } |
1831 } |
| 1767 icon_alc.y += border_width; |
1832 icon_alc.y += 1; |
| 1768 |
1833 |
| 1769 if (status_box->icon_size != icon_alc.height) |
1834 if (status_box->icon_size != icon_alc.height) |
| 1770 { |
1835 { |
| 1771 status_box->icon_size = icon_alc.height; |
1836 status_box->icon_size = icon_alc.height; |
| 1772 gtk_gaim_status_box_redisplay_buddy_icon(status_box); |
1837 gtk_gaim_status_box_redisplay_buddy_icon(status_box); |
| 1773 } |
1838 } |
| 1774 gtk_widget_size_allocate(status_box->icon_box, &icon_alc); |
1839 gtk_widget_size_allocate(status_box->icon_box, &icon_alc); |
| 1775 } |
1840 } |
| 1776 |
|
| 1777 gtk_widget_size_allocate(status_box->toggle_button, &parent_alc); |
1841 gtk_widget_size_allocate(status_box->toggle_button, &parent_alc); |
| 1778 widget->allocation = *allocation; |
1842 widget->allocation = *allocation; |
| 1779 } |
1843 } |
| 1780 |
1844 |
| 1781 static gboolean |
1845 static gboolean |
| 1783 GdkEventExpose *event) |
1847 GdkEventExpose *event) |
| 1784 { |
1848 { |
| 1785 GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX(widget); |
1849 GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX(widget); |
| 1786 gtk_container_propagate_expose(GTK_CONTAINER(widget), status_box->vbox, event); |
1850 gtk_container_propagate_expose(GTK_CONTAINER(widget), status_box->vbox, event); |
| 1787 gtk_container_propagate_expose(GTK_CONTAINER(widget), status_box->toggle_button, event); |
1851 gtk_container_propagate_expose(GTK_CONTAINER(widget), status_box->toggle_button, event); |
| 1788 if (status_box->icon_box) |
1852 if (status_box->icon_box && status_box->icon_opaque) { |
| 1789 gtk_container_propagate_expose(GTK_CONTAINER(widget), status_box->icon_box, event); |
1853 gtk_paint_box(widget->style, widget->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, |
| |
1854 status_box->icon_box, "button", status_box->icon_box->allocation.x-1, status_box->icon_box->allocation.y-1, |
| |
1855 34, 34); |
| |
1856 } |
| 1790 return FALSE; |
1857 return FALSE; |
| 1791 } |
1858 } |
| 1792 |
1859 |
| 1793 static void |
1860 static void |
| 1794 gtk_gaim_status_box_forall(GtkContainer *container, |
1861 gtk_gaim_status_box_forall(GtkContainer *container, |
| 1947 status_box->buddy_icon = gdk_pixbuf_new_from_file(filename, NULL); |
2014 status_box->buddy_icon = gdk_pixbuf_new_from_file(filename, NULL); |
| 1948 g_free(filename); |
2015 g_free(filename); |
| 1949 } |
2016 } |
| 1950 |
2017 |
| 1951 if (status_box->buddy_icon != NULL) { |
2018 if (status_box->buddy_icon != NULL) { |
| |
2019 status_box->icon_opaque = gaim_gdk_pixbuf_is_opaque(status_box->buddy_icon); |
| 1952 gtk_image_set_from_pixbuf(GTK_IMAGE(status_box->icon), status_box->buddy_icon); |
2020 gtk_image_set_from_pixbuf(GTK_IMAGE(status_box->icon), status_box->buddy_icon); |
| 1953 status_box->buddy_icon_hover = gdk_pixbuf_copy(status_box->buddy_icon); |
2021 status_box->buddy_icon_hover = gdk_pixbuf_copy(status_box->buddy_icon); |
| 1954 do_colorshift(status_box->buddy_icon_hover, status_box->buddy_icon_hover, 32); |
2022 do_colorshift(status_box->buddy_icon_hover, status_box->buddy_icon_hover, 32); |
| |
2023 gtk_widget_queue_resize(GTK_WIDGET(status_box)); |
| 1955 } |
2024 } |
| 1956 } |
2025 } |
| 1957 |
2026 |
| 1958 void |
2027 void |
| 1959 gtk_gaim_status_box_set_buddy_icon(GtkGaimStatusBox *status_box, const char *filename) |
2028 gtk_gaim_status_box_set_buddy_icon(GtkGaimStatusBox *status_box, const char *filename) |