Mercurial > pidgin
comparison finch/gntblist.c @ 16483:0b97b224a829
Never change the orders of chats or the groups.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Fri, 27 Apr 2007 04:35:57 +0000 |
parents | 08db93bbd798 |
children | 7b692d5dd704 |
comparison
equal
deleted
inserted
replaced
16481:1dc138345d15 | 16483:0b97b224a829 |
---|---|
112 static void blist_show(PurpleBuddyList *list); | 112 static void blist_show(PurpleBuddyList *list); |
113 static void update_buddy_display(PurpleBuddy *buddy, FinchBlist *ggblist); | 113 static void update_buddy_display(PurpleBuddy *buddy, FinchBlist *ggblist); |
114 static void account_signed_on_cb(void); | 114 static void account_signed_on_cb(void); |
115 | 115 |
116 /* Sort functions */ | 116 /* Sort functions */ |
117 static int blist_node_compare_position(PurpleBlistNode *n1, PurpleBlistNode *n2); | |
117 static int blist_node_compare_text(PurpleBlistNode *n1, PurpleBlistNode *n2); | 118 static int blist_node_compare_text(PurpleBlistNode *n1, PurpleBlistNode *n2); |
118 static int blist_node_compare_status(PurpleBlistNode *n1, PurpleBlistNode *n2); | 119 static int blist_node_compare_status(PurpleBlistNode *n1, PurpleBlistNode *n2); |
119 static int blist_node_compare_log(PurpleBlistNode *n1, PurpleBlistNode *n2); | 120 static int blist_node_compare_log(PurpleBlistNode *n1, PurpleBlistNode *n2); |
120 | 121 |
121 static gboolean | 122 static gboolean |
1776 g_signal_handlers_unblock_matched(ggblist->statustext, G_SIGNAL_MATCH_FUNC, | 1777 g_signal_handlers_unblock_matched(ggblist->statustext, G_SIGNAL_MATCH_FUNC, |
1777 0, 0, NULL, status_text_changed, NULL); | 1778 0, 0, NULL, status_text_changed, NULL); |
1778 } | 1779 } |
1779 | 1780 |
1780 static int | 1781 static int |
1782 blist_node_compare_position(PurpleBlistNode *n1, PurpleBlistNode *n2) | |
1783 { | |
1784 while ((n1 = n1->prev) != NULL) | |
1785 if (n1 == n2) | |
1786 return 1; | |
1787 return -1; | |
1788 } | |
1789 | |
1790 static int | |
1781 blist_node_compare_text(PurpleBlistNode *n1, PurpleBlistNode *n2) | 1791 blist_node_compare_text(PurpleBlistNode *n1, PurpleBlistNode *n2) |
1782 { | 1792 { |
1783 const char *s1, *s2; | 1793 const char *s1, *s2; |
1784 char *us1, *us2; | 1794 char *us1, *us2; |
1785 int ret; | 1795 int ret; |
1786 | 1796 |
1787 g_return_val_if_fail(n1->type == n2->type, -1); | 1797 g_return_val_if_fail(n1->type == n2->type, -1); |
1788 | 1798 |
1789 switch (n1->type) | 1799 switch (n1->type) |
1790 { | 1800 { |
1791 case PURPLE_BLIST_GROUP_NODE: | |
1792 s1 = ((PurpleGroup*)n1)->name; | |
1793 s2 = ((PurpleGroup*)n2)->name; | |
1794 break; | |
1795 case PURPLE_BLIST_CHAT_NODE: | 1801 case PURPLE_BLIST_CHAT_NODE: |
1796 s1 = purple_chat_get_name((PurpleChat*)n1); | 1802 s1 = purple_chat_get_name((PurpleChat*)n1); |
1797 s2 = purple_chat_get_name((PurpleChat*)n2); | 1803 s2 = purple_chat_get_name((PurpleChat*)n2); |
1798 break; | 1804 break; |
1799 case PURPLE_BLIST_BUDDY_NODE: | 1805 case PURPLE_BLIST_BUDDY_NODE: |
1803 case PURPLE_BLIST_CONTACT_NODE: | 1809 case PURPLE_BLIST_CONTACT_NODE: |
1804 s1 = purple_contact_get_alias((PurpleContact*)n1); | 1810 s1 = purple_contact_get_alias((PurpleContact*)n1); |
1805 s2 = purple_contact_get_alias((PurpleContact*)n2); | 1811 s2 = purple_contact_get_alias((PurpleContact*)n2); |
1806 break; | 1812 break; |
1807 default: | 1813 default: |
1808 return -1; | 1814 return blist_node_compare_position(n1, n2); |
1809 } | 1815 } |
1810 | 1816 |
1811 us1 = g_utf8_strup(s1, -1); | 1817 us1 = g_utf8_strup(s1, -1); |
1812 us2 = g_utf8_strup(s2, -1); | 1818 us2 = g_utf8_strup(s2, -1); |
1813 ret = g_utf8_collate(us1, us2); | 1819 ret = g_utf8_collate(us1, us2); |
1834 purple_buddy_get_presence((PurpleBuddy*)n2)); | 1840 purple_buddy_get_presence((PurpleBuddy*)n2)); |
1835 if (ret != 0) | 1841 if (ret != 0) |
1836 return ret; | 1842 return ret; |
1837 break; | 1843 break; |
1838 default: | 1844 default: |
1845 return blist_node_compare_position(n1, n2); | |
1839 break; | 1846 break; |
1840 } | 1847 } |
1841 | 1848 |
1842 /* Sort alphabetically if presence is not comparable */ | 1849 /* Sort alphabetically if presence is not comparable */ |
1843 ret = blist_node_compare_text(n1, n2); | 1850 ret = blist_node_compare_text(n1, n2); |
1880 ret = get_contact_log_size(n2) - get_contact_log_size(n1); | 1887 ret = get_contact_log_size(n2) - get_contact_log_size(n1); |
1881 if (ret != 0) | 1888 if (ret != 0) |
1882 return ret; | 1889 return ret; |
1883 break; | 1890 break; |
1884 default: | 1891 default: |
1892 return blist_node_compare_position(n1, n2); | |
1885 break; | 1893 break; |
1886 } | 1894 } |
1887 ret = blist_node_compare_text(n1, n2); | 1895 ret = blist_node_compare_text(n1, n2); |
1888 return ret; | 1896 return ret; |
1889 } | 1897 } |