# HG changeset patch # User Sadrul Habib Chowdhury # Date 1210223076 0 # Node ID eb1321b2e496a8399410f269d9ed7d2913b1a686 # Parent 1334c0de8f321b2f011b992d22364b40d6532b97 Modified patch from John Moody to show aliases in the Invite dialog. Closes #5722. diff -r 1334c0de8f32 -r eb1321b2e496 pidgin/gtkconv.c --- a/pidgin/gtkconv.c Thu May 08 03:52:02 2008 +0000 +++ b/pidgin/gtkconv.c Thu May 08 05:04:36 2008 +0000 @@ -150,7 +150,6 @@ static gboolean infopane_entry_activate(PidginConversation *gtkconv); static void got_typing_keypress(PidginConversation *gtkconv, gboolean first); static void gray_stuff_out(PidginConversation *gtkconv); -static GList *generate_invite_user_names(PurpleConnection *gc); static void add_chat_buddy_common(PurpleConversation *conv, PurpleConvChatBuddy *cb, const char *old_name); static gboolean tab_complete(PurpleConversation *conv); static void pidgin_conv_updated(PurpleConversation *conv, PurpleConvUpdateType type); @@ -697,6 +696,22 @@ gtk_widget_grab_focus(PIDGIN_CONVERSATION(conv)->entry); } +static gboolean +chat_invite_filter(const PidginBuddyCompletionEntry *entry, gpointer data) +{ + PurpleAccount *filter_account = data; + PurpleAccount *account = NULL; + + if (entry->is_buddy) { + account = purple_buddy_get_account(entry->entry.buddy); + } else { + account = entry->entry.logged_buddy->account; + } + if (account == filter_account) + return TRUE; + return FALSE; +} + static void do_invite(GtkWidget *w, int resp, InviteBuddyInfo *info) { @@ -706,7 +721,7 @@ gtkconv = PIDGIN_CONVERSATION(info->conv); if (resp == GTK_RESPONSE_OK) { - buddy = pidgin_text_combo_box_entry_get_text(info->entry); + buddy = gtk_entry_get_text(GTK_ENTRY(info->entry)); message = gtk_entry_get_text(GTK_ENTRY(info->message)); if (!g_ascii_strcasecmp(buddy, "")) @@ -729,6 +744,7 @@ { InviteBuddyInfo *info = (InviteBuddyInfo *)data; const char *convprotocol; + gboolean success = TRUE; convprotocol = purple_account_get_protocol_id(purple_conversation_get_account(info->conv)); @@ -751,11 +767,12 @@ purple_notify_error(PIDGIN_CONVERSATION(info->conv), NULL, _("That buddy is not on the same protocol as this " "chat."), NULL); + success = FALSE; } else - pidgin_text_combo_box_entry_set_text(info->entry, buddy->name); - - gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); + gtk_entry_set_text(GTK_ENTRY(info->entry), purple_buddy_get_name(buddy)); + + gtk_drag_finish(dc, success, (dc->action == GDK_ACTION_MOVE), t); } else if (sd->target == gdk_atom_intern("application/x-im-contact", FALSE)) { @@ -777,17 +794,18 @@ purple_notify_error(PIDGIN_CONVERSATION(info->conv), NULL, _("That buddy is not on the same protocol as this " "chat."), NULL); + success = FALSE; } else { - pidgin_text_combo_box_entry_set_text(info->entry, username); + gtk_entry_set_text(GTK_ENTRY(info->entry), username); } } g_free(username); g_free(protocol); - gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); + gtk_drag_finish(dc, success, (dc->action == GDK_ACTION_MOVE), t); } } @@ -878,7 +896,9 @@ gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); /* Now the Buddy drop-down entry field. */ - info->entry = pidgin_text_combo_box_entry_new(NULL, generate_invite_user_names(gc)); + info->entry = gtk_entry_new(); + pidgin_setup_screenname_autocomplete_with_filter(info->entry, NULL, chat_invite_filter, + purple_conversation_get_account(conv)); gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1); gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->entry); @@ -917,13 +937,12 @@ G_CALLBACK(invite_dnd_recv), info); g_signal_connect(G_OBJECT(info->entry), "drag_data_received", G_CALLBACK(invite_dnd_recv), info); - } gtk_widget_show_all(invite_dialog); if (info != NULL) - gtk_widget_grab_focus(GTK_BIN(info->entry)->child); + gtk_widget_grab_focus(info->entry); } static void @@ -3793,42 +3812,6 @@ update_send_to_selection(win); } -static GList * -generate_invite_user_names(PurpleConnection *gc) -{ - PurpleBlistNode *gnode,*cnode,*bnode; - static GList *tmp = NULL; - - g_list_free(tmp); - tmp = NULL; - - if (gc != NULL) { - for(gnode = purple_get_blist()->root; gnode; gnode = gnode->next) { - if(!PURPLE_BLIST_NODE_IS_GROUP(gnode)) - continue; - for(cnode = gnode->child; cnode; cnode = cnode->next) { - if(!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) - continue; - for(bnode = cnode->child; bnode; bnode = bnode->next) { - PurpleBuddy *buddy; - - if(!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) - continue; - - buddy = (PurpleBuddy *)bnode; - - if (buddy->account == gc->account && - PURPLE_BUDDY_IS_ONLINE(buddy)) - tmp = g_list_insert_sorted(tmp, buddy->name, - (GCompareFunc)g_utf8_collate); - } - } - } - } - - return tmp; -} - static GdkPixbuf * get_chat_buddy_status_icon(PurpleConvChat *chat, const char *name, PurpleConvChatBuddyFlags flags) {