Mercurial > pidgin.yaz
changeset 12319:7630a95f3b8b
[gaim-migrate @ 14623]
Improve Handling of Aliasing with respect to Contacts
Basically, if you choose "Alias", your changes will be saved to whichever text field you saw. This makes sense, given we're doing inline editing. Also, because we're doing inline editing, I think it's weird to have Alias offered in a buddy submenu (as choosing it causes the text to change pre-edit and post-edit, making you feel like your changes weren't saved). I've removed it. If you need to alias a buddy that's not currently online, you can always expand the contact.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Sun, 04 Dec 2005 17:54:43 +0000 |
parents | e346a085bb4f |
children | c2867c4ddcd3 |
files | plugins/ChangeLog.API src/blist.c src/blist.h src/gtkblist.c |
diffstat | 4 files changed, 77 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/ChangeLog.API Sun Dec 04 17:47:37 2005 +0000 +++ b/plugins/ChangeLog.API Sun Dec 04 17:54:43 2005 +0000 @@ -178,6 +178,7 @@ * gaim_account_request_add: Notifies the user that they were added to someone's buddy list, and offers them the choice of adding that person to their buddy list. + * gaim_blist_alias_contact() Signals - Changed: (See the Doxygen docs for details on all signals.) * Signal propagation now stops after a handler returns a non-NULL value.
--- a/src/blist.c Sun Dec 04 17:47:37 2005 +0000 +++ b/src/blist.c Sun Dec 04 17:54:43 2005 +0000 @@ -832,6 +832,40 @@ ops->update(gaimbuddylist, (GaimBlistNode *)buddy); } +void gaim_blist_alias_contact(GaimContact *contact, const char *alias) +{ + GaimBlistUiOps *ops = gaimbuddylist->ui_ops; + GaimConversation *conv; + char *old_alias = contact->alias; + GaimBlistNode *bnode; + + g_return_if_fail(contact != NULL); + + if ((alias != NULL) && (*alias != '\0')) + contact->alias = g_strdup(alias); + else + contact->alias = NULL; + + gaim_blist_schedule_save(); + + if (ops && ops->update) + ops->update(gaimbuddylist, (GaimBlistNode *)contact); + + for(bnode = ((GaimBlistNode *)contact)->child; bnode != NULL; bnode = bnode->next) + { + GaimBuddy *buddy = (GaimBuddy *)bnode; + + conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, buddy->name, + buddy->account); + if (conv) + gaim_conversation_autoset_title(conv); + } + + gaim_signal_emit(gaim_blist_get_handle(), "blist-node-aliased", + contact, old_alias); + g_free(old_alias); +} + void gaim_blist_alias_chat(GaimChat *chat, const char *alias) { GaimBlistUiOps *ops = gaimbuddylist->ui_ops;
--- a/src/blist.h Sun Dec 04 17:47:37 2005 +0000 +++ b/src/blist.h Sun Dec 04 17:54:43 2005 +0000 @@ -271,6 +271,13 @@ */ void gaim_blist_rename_buddy(GaimBuddy *buddy, const char *name); +/** + * Aliases a contact in the buddy list. + * + * @param contact The contact whose alias will be changed. + * @param alias The contact's alias. + */ +void gaim_blist_alias_contact(GaimContact *contact, const char *alias); /** * Aliases a buddy in the buddy list.
--- a/src/gtkblist.c Sun Dec 04 17:47:37 2005 +0000 +++ b/src/gtkblist.c Sun Dec 04 17:54:43 2005 +0000 @@ -290,21 +290,32 @@ node = g_value_get_pointer(&val); gtk_tree_view_set_enable_search (GTK_TREE_VIEW(gtkblist->treeview), TRUE); g_object_set(G_OBJECT(gtkblist->text_rend), "editable", FALSE, NULL); - switch (node->type){ - case GAIM_BLIST_CONTACT_NODE: - gaim_blist_alias_buddy(gaim_contact_get_priority_buddy((GaimContact*)node), arg2); - break; - case GAIM_BLIST_BUDDY_NODE: - gaim_blist_alias_buddy((GaimBuddy*)node, arg2); - break; - case GAIM_BLIST_GROUP_NODE: - gaim_blist_rename_group((GaimGroup*)node, arg2); - break; - case GAIM_BLIST_CHAT_NODE: - gaim_blist_alias_chat((GaimChat*)node, arg2); - break; - default: - break; + + switch (node->type) + { + case GAIM_BLIST_CONTACT_NODE: + { + GaimContact *contact = (GaimContact *)node; + struct _gaim_gtk_blist_node *gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; + + if (contact->alias || gtknode->contact_expanded) + gaim_blist_alias_contact(contact, arg2); + else + gaim_blist_alias_buddy(gaim_contact_get_priority_buddy(contact), arg2); + } + break; + + case GAIM_BLIST_BUDDY_NODE: + gaim_blist_alias_buddy((GaimBuddy*)node, arg2); + break; + case GAIM_BLIST_GROUP_NODE: + gaim_blist_rename_group((GaimGroup*)node, arg2); + break; + case GAIM_BLIST_CHAT_NODE: + gaim_blist_alias_chat((GaimChat*)node, arg2); + break; + default: + break; } } @@ -327,7 +338,7 @@ text = gaim_buddy_get_alias((GaimBuddy *)node); break; case GAIM_BLIST_CONTACT_NODE: - text = gaim_buddy_get_alias(gaim_contact_get_priority_buddy((GaimContact *)node)); + text = gaim_contact_get_alias((GaimContact *)node); break; case GAIM_BLIST_GROUP_NODE: text = ((GaimGroup *)node)->name; @@ -1022,20 +1033,18 @@ (GaimBlistNode *)buddy); gaim_gtk_append_blist_node_extended_menu(menu, (GaimBlistNode *)buddy); - gaim_separator(menu); - - if(((GaimBlistNode*)buddy)->parent->child->next && !sub && !contact_expanded) { - gaim_new_item_from_stock(menu, _("_Alias Buddy..."), GAIM_STOCK_ALIAS, - G_CALLBACK(gtk_blist_menu_alias_cb), buddy, 0, 0, NULL); - gaim_new_item_from_stock(menu, _("_Remove Buddy"), GTK_STOCK_REMOVE, - G_CALLBACK(gaim_gtk_blist_remove_cb), buddy, 0, 0, NULL); - gaim_new_item_from_stock(menu, _("Alias Contact..."), GAIM_STOCK_ALIAS, + if (((GaimBlistNode*)buddy)->parent->child->next && !sub && !contact_expanded) { + gaim_separator(menu); + + gaim_new_item_from_stock(menu, _("Alias..."), GAIM_STOCK_ALIAS, G_CALLBACK(gtk_blist_menu_alias_cb), contact, 0, 0, NULL); - gaim_new_item_from_stock(menu, _("Remove Contact"), GTK_STOCK_REMOVE, + gaim_new_item_from_stock(menu, _("Remove"), GTK_STOCK_REMOVE, G_CALLBACK(gaim_gtk_blist_remove_cb), contact, 0, 0, NULL); - } else { + } else if (!sub || contact_expanded) { + gaim_separator(menu); + gaim_new_item_from_stock(menu, _("_Alias..."), GAIM_STOCK_ALIAS, G_CALLBACK(gtk_blist_menu_alias_cb), buddy, 0, 0, NULL); gaim_new_item_from_stock(menu, _("_Remove"), GTK_STOCK_REMOVE,