Mercurial > pidgin.yaz
comparison src/blist.c @ 11454:201617d49573
[gaim-migrate @ 13693]
This commit includes a number of changes:
1. Aliases are now used consistently in chats. If the prpl uses unique screen names for chats (e.g. Jabber), then aliases are not used at all.
2. The chat list is now colorized to match the colors used in the chat itself.
3. Buddies are bolded in the chat user list.
4. Buddies are sorted above non-buddies in the chat user list.
5. The chat user list is ellipsized when possible (i.e. on GTK+ 2.6.0 or above).
6. I've accepted patch #1178248, by Matt Amato to add "buddy-added" and "buddy-removed" signals. These were used in my implementation of #3 and #4, to update the GUI when users are added or removed from the buddy list.
7. I've added a "blist-node-aliased" signal that is emitted when a buddy, contact, or chat is aliased.
8. Since it was hard to separate and I need it at some point, I'm letting it slip in... I've changed GaimConversation.log to be a GList named logs. This way, we can have multiple logs for a single conversation. This will be necessary to implement unnamed chat logging in some reasonable fasion (see my notes in the TODO file).
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Tue, 06 Sep 2005 03:04:07 +0000 |
parents | f191b5bc199b |
children | 3314953511de |
comparison
equal
deleted
inserted
replaced
11453:d446fcc2c63b | 11454:201617d49573 |
---|---|
848 } | 848 } |
849 | 849 |
850 void gaim_blist_alias_chat(GaimChat *chat, const char *alias) | 850 void gaim_blist_alias_chat(GaimChat *chat, const char *alias) |
851 { | 851 { |
852 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; | 852 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
853 char *old_alias = chat->alias; | |
853 | 854 |
854 g_return_if_fail(chat != NULL); | 855 g_return_if_fail(chat != NULL); |
855 | 856 |
856 g_free(chat->alias); | |
857 if ((alias != NULL) && (*alias != '\0')) | 857 if ((alias != NULL) && (*alias != '\0')) |
858 chat->alias = g_strdup(alias); | 858 chat->alias = g_strdup(alias); |
859 else | 859 else |
860 chat->alias = NULL; | 860 chat->alias = NULL; |
861 | 861 |
862 gaim_blist_schedule_save(); | 862 gaim_blist_schedule_save(); |
863 | 863 |
864 if (ops && ops->update) | 864 if (ops && ops->update) |
865 ops->update(gaimbuddylist, (GaimBlistNode *)chat); | 865 ops->update(gaimbuddylist, (GaimBlistNode *)chat); |
866 | |
867 gaim_signal_emit(gaim_blist_get_handle(), "blist-node-aliased", | |
868 chat, old_alias); | |
869 g_free(old_alias); | |
866 } | 870 } |
867 | 871 |
868 void gaim_blist_alias_buddy(GaimBuddy *buddy, const char *alias) | 872 void gaim_blist_alias_buddy(GaimBuddy *buddy, const char *alias) |
869 { | 873 { |
870 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; | 874 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
871 GaimConversation *conv; | 875 GaimConversation *conv; |
876 char *old_alias = buddy->alias; | |
872 | 877 |
873 g_return_if_fail(buddy != NULL); | 878 g_return_if_fail(buddy != NULL); |
874 | 879 |
875 g_free(buddy->alias); | |
876 if ((alias != NULL) && (*alias != '\0')) | 880 if ((alias != NULL) && (*alias != '\0')) |
877 buddy->alias = g_strdup(alias); | 881 buddy->alias = g_strdup(alias); |
878 else | 882 else |
879 buddy->alias = NULL; | 883 buddy->alias = NULL; |
880 | 884 |
885 | 889 |
886 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, buddy->name, | 890 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, buddy->name, |
887 buddy->account); | 891 buddy->account); |
888 if (conv) | 892 if (conv) |
889 gaim_conversation_autoset_title(conv); | 893 gaim_conversation_autoset_title(conv); |
894 | |
895 gaim_signal_emit(gaim_blist_get_handle(), "blist-node-aliased", | |
896 buddy, old_alias); | |
897 g_free(old_alias); | |
890 } | 898 } |
891 | 899 |
892 void gaim_blist_server_alias_buddy(GaimBuddy *buddy, const char *alias) | 900 void gaim_blist_server_alias_buddy(GaimBuddy *buddy, const char *alias) |
893 { | 901 { |
894 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; | 902 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
895 GaimConversation *conv; | 903 GaimConversation *conv; |
904 char *old_alias = buddy->server_alias; | |
896 | 905 |
897 g_return_if_fail(buddy != NULL); | 906 g_return_if_fail(buddy != NULL); |
898 | 907 |
899 g_free(buddy->server_alias); | |
900 if ((alias != NULL) && (*alias != '\0') && g_utf8_validate(alias, -1, NULL)) | 908 if ((alias != NULL) && (*alias != '\0') && g_utf8_validate(alias, -1, NULL)) |
901 buddy->server_alias = g_strdup(alias); | 909 buddy->server_alias = g_strdup(alias); |
902 else | 910 else |
903 buddy->server_alias = NULL; | 911 buddy->server_alias = NULL; |
904 | 912 |
909 | 917 |
910 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, buddy->name, | 918 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, buddy->name, |
911 buddy->account); | 919 buddy->account); |
912 if (conv) | 920 if (conv) |
913 gaim_conversation_autoset_title(conv); | 921 gaim_conversation_autoset_title(conv); |
922 | |
923 gaim_signal_emit(gaim_blist_get_handle(), "blist-node-aliased", | |
924 buddy, old_alias); | |
925 g_free(old_alias); | |
914 } | 926 } |
915 | 927 |
916 /* | 928 /* |
917 * TODO: If merging, prompt the user if they want to merge. | 929 * TODO: If merging, prompt the user if they want to merge. |
918 */ | 930 */ |
1336 | 1348 |
1337 gaim_blist_schedule_save(); | 1349 gaim_blist_schedule_save(); |
1338 | 1350 |
1339 if (ops && ops->update) | 1351 if (ops && ops->update) |
1340 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); | 1352 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); |
1353 | |
1354 /* Signal that the buddy has been added */ | |
1355 gaim_signal_emit(gaim_blist_get_handle(), "buddy-added", buddy); | |
1341 } | 1356 } |
1342 | 1357 |
1343 GaimContact *gaim_contact_new() | 1358 GaimContact *gaim_contact_new() |
1344 { | 1359 { |
1345 GaimBlistUiOps *ops = gaim_blist_get_ui_ops(); | 1360 GaimBlistUiOps *ops = gaim_blist_get_ui_ops(); |
1359 } | 1374 } |
1360 | 1375 |
1361 void gaim_contact_set_alias(GaimContact *contact, const char *alias) | 1376 void gaim_contact_set_alias(GaimContact *contact, const char *alias) |
1362 { | 1377 { |
1363 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; | 1378 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
1379 char *old_alias = contact->alias; | |
1364 | 1380 |
1365 g_return_if_fail(contact != NULL); | 1381 g_return_if_fail(contact != NULL); |
1366 | |
1367 if (contact->alias != NULL) | |
1368 g_free(contact->alias); | |
1369 | 1382 |
1370 if ((alias != NULL) && (*alias != '\0')) | 1383 if ((alias != NULL) && (*alias != '\0')) |
1371 contact->alias = g_strdup(alias); | 1384 contact->alias = g_strdup(alias); |
1372 else | 1385 else |
1373 contact->alias = NULL; | 1386 contact->alias = NULL; |
1374 | 1387 |
1375 gaim_blist_schedule_save(); | 1388 gaim_blist_schedule_save(); |
1376 | 1389 |
1377 if (ops && ops->update) | 1390 if (ops && ops->update) |
1378 ops->update(gaimbuddylist, (GaimBlistNode*)contact); | 1391 ops->update(gaimbuddylist, (GaimBlistNode*)contact); |
1392 | |
1393 gaim_signal_emit(gaim_blist_get_handle(), "blist-node-aliased", | |
1394 contact, old_alias); | |
1395 g_free(old_alias); | |
1379 } | 1396 } |
1380 | 1397 |
1381 const char *gaim_contact_get_alias(GaimContact* contact) | 1398 const char *gaim_contact_get_alias(GaimContact* contact) |
1382 { | 1399 { |
1383 g_return_val_if_fail(contact != NULL, NULL); | 1400 g_return_val_if_fail(contact != NULL, NULL); |
1668 while (node->child->next) { | 1685 while (node->child->next) { |
1669 gaim_blist_remove_buddy((GaimBuddy*)node->child); | 1686 gaim_blist_remove_buddy((GaimBuddy*)node->child); |
1670 } | 1687 } |
1671 /* | 1688 /* |
1672 * Remove the last buddy and trigger the deletion of the contact. | 1689 * Remove the last buddy and trigger the deletion of the contact. |
1673 * It would probably be cleaner if contact-deletion was done after | 1690 * It would probably be cleaner if contact-deletion was done after |
1674 * a timeout? Or if it had to be done manually, like below? | 1691 * a timeout? Or if it had to be done manually, like below? |
1675 */ | 1692 */ |
1676 gaim_blist_remove_buddy((GaimBuddy*)node->child); | 1693 gaim_blist_remove_buddy((GaimBuddy*)node->child); |
1677 } else { | 1694 } else { |
1678 /* Remove the node from its parent */ | 1695 /* Remove the node from its parent */ |
1754 | 1771 |
1755 /* Update the UI */ | 1772 /* Update the UI */ |
1756 if (ops && ops->remove) | 1773 if (ops && ops->remove) |
1757 ops->remove(gaimbuddylist, node); | 1774 ops->remove(gaimbuddylist, node); |
1758 | 1775 |
1776 /* Signal that the buddy has been removed before freeing the memory for it */ | |
1777 gaim_signal_emit(gaim_blist_get_handle(), "buddy-removed", buddy); | |
1778 | |
1759 /* Delete the node */ | 1779 /* Delete the node */ |
1760 if (buddy->timer > 0) | 1780 if (buddy->timer > 0) |
1761 gaim_timeout_remove(buddy->timer); | 1781 gaim_timeout_remove(buddy->timer); |
1762 if (buddy->icon != NULL) | 1782 if (buddy->icon != NULL) |
1763 gaim_buddy_icon_unref(buddy->icon); | 1783 gaim_buddy_icon_unref(buddy->icon); |
1837 count++; | 1857 count++; |
1838 | 1858 |
1839 buf = g_strdup_printf(ngettext("%d buddy from group %s was not removed " | 1859 buf = g_strdup_printf(ngettext("%d buddy from group %s was not removed " |
1840 "because its account was not logged in." | 1860 "because its account was not logged in." |
1841 " This buddy and the group were not " | 1861 " This buddy and the group were not " |
1842 "removed.\n", | 1862 "removed.\n", |
1843 "%d buddies from group %s were not " | 1863 "%d buddies from group %s were not " |
1844 "removed because their accounts were " | 1864 "removed because their accounts were " |
1845 "not logged in. These buddies and " | 1865 "not logged in. These buddies and " |
1846 "the group were not removed.\n", count), | 1866 "the group were not removed.\n", count), |
1847 count, group->name); | 1867 count, group->name); |
2599 gaim_signal_register(handle, "buddy-signed-off", | 2619 gaim_signal_register(handle, "buddy-signed-off", |
2600 gaim_marshal_VOID__POINTER, NULL, 1, | 2620 gaim_marshal_VOID__POINTER, NULL, 1, |
2601 gaim_value_new(GAIM_TYPE_SUBTYPE, | 2621 gaim_value_new(GAIM_TYPE_SUBTYPE, |
2602 GAIM_SUBTYPE_BLIST_BUDDY)); | 2622 GAIM_SUBTYPE_BLIST_BUDDY)); |
2603 | 2623 |
2624 gaim_signal_register(handle, "buddy-added", | |
2625 gaim_marshal_VOID__POINTER, NULL, 1, | |
2626 gaim_value_new(GAIM_TYPE_SUBTYPE, | |
2627 GAIM_SUBTYPE_BLIST_BUDDY)); | |
2628 | |
2629 gaim_signal_register(handle, "buddy-removed", | |
2630 gaim_marshal_VOID__POINTER, NULL, 1, | |
2631 gaim_value_new(GAIM_TYPE_SUBTYPE, | |
2632 GAIM_SUBTYPE_BLIST_BUDDY)); | |
2633 | |
2604 gaim_signal_register(handle, "update-idle", gaim_marshal_VOID, NULL, 0); | 2634 gaim_signal_register(handle, "update-idle", gaim_marshal_VOID, NULL, 0); |
2605 | 2635 |
2606 gaim_signal_register(handle, "blist-node-extended-menu", | 2636 gaim_signal_register(handle, "blist-node-extended-menu", |
2607 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, | 2637 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
2608 gaim_value_new(GAIM_TYPE_SUBTYPE, | 2638 gaim_value_new(GAIM_TYPE_SUBTYPE, |
2609 GAIM_SUBTYPE_BLIST_NODE), | 2639 GAIM_SUBTYPE_BLIST_NODE), |
2610 gaim_value_new(GAIM_TYPE_BOXED, "GList **")); | 2640 gaim_value_new(GAIM_TYPE_BOXED, "GList **")); |
2641 | |
2642 gaim_signal_register(handle, "blist-node-aliased", | |
2643 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, | |
2644 gaim_value_new(GAIM_TYPE_SUBTYPE, | |
2645 GAIM_SUBTYPE_BLIST_NODE), | |
2646 gaim_value_new(GAIM_TYPE_STRING)); | |
2611 } | 2647 } |
2612 | 2648 |
2613 void | 2649 void |
2614 gaim_blist_uninit(void) | 2650 gaim_blist_uninit(void) |
2615 { | 2651 { |