Mercurial > pidgin.yaz
changeset 10791:2ab4b5acc8d1
[gaim-migrate @ 12433]
" When you autocomplete a screenname in a dialog box that
also includes an account selector, it should also
autocomplete the account. This patch implements that." --rlaager
this is how I would expect things to work. I was hit by this just the other
day.
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Thu, 07 Apr 2005 15:22:21 +0000 |
parents | 35edd4d021a4 |
children | 643f458f8414 |
files | src/gtkdialogs.c src/gtkrequest.c src/request.h |
diffstat | 3 files changed, 65 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gtkdialogs.c Thu Apr 07 15:08:14 2005 +0000 +++ b/src/gtkdialogs.c Thu Apr 07 15:22:21 2005 +0000 @@ -458,6 +458,7 @@ gaim_request_field_group_add_field(group, field); field = gaim_request_field_account_new("account", _("_Account"), NULL); + gaim_request_field_set_type_hint(field, "account"); gaim_request_field_set_visible(field, (gaim_connections_get_all() != NULL && gaim_connections_get_all()->next != NULL)); @@ -600,6 +601,7 @@ gaim_request_field_group_add_field(group, field); field = gaim_request_field_account_new("account", _("_Account"), NULL); + gaim_request_field_set_type_hint(field, "account"); gaim_request_field_set_visible(field, (gaim_connections_get_all() != NULL && gaim_connections_get_all()->next != NULL)); @@ -654,6 +656,7 @@ gaim_request_field_group_add_field(group, field); field = gaim_request_field_account_new("account", _("_Account"), NULL); + gaim_request_field_set_type_hint(field, "account"); gaim_request_field_account_set_show_all(field, TRUE); gaim_request_field_set_visible(field, (gaim_accounts_get_all() != NULL &&
--- a/src/gtkrequest.c Thu Apr 07 15:08:14 2005 +0000 +++ b/src/gtkrequest.c Thu Apr 07 15:22:21 2005 +0000 @@ -673,6 +673,7 @@ names = g_list_append(names, ((GaimContact *)cnode)->alias); names = g_list_append(names, (gpointer)gaim_buddy_get_contact_alias(buddy)); + names = g_list_append(names, buddy->account); #endif /* NEW_STYLE_COMPLETION */ names = g_list_append(names, buddy->name); @@ -805,14 +806,55 @@ } static gboolean screenname_completion_match_selected_cb(GtkEntryCompletion *completion, - GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data) { + GtkTreeModel *model, GtkTreeIter *iter, gpointer *user_data) { GValue val = { 0, }; + GaimRequestField *screen_field = user_data[1]; + GList *fields = screen_field->group->fields; gtk_tree_model_get_value(model, iter, 1, &val); - gtk_entry_set_text(GTK_ENTRY(user_data), g_value_get_string(&val)); + gtk_entry_set_text(GTK_ENTRY(user_data[0]), g_value_get_string(&val)); g_value_unset(&val); + do { + GaimRequestField *field = fields->data; + + if (gaim_request_field_get_type(field) == GAIM_REQUEST_FIELD_ACCOUNT) { + const char *type_hint = gaim_request_field_get_type_hint(field); + + if (type_hint != NULL && !strcmp(type_hint, "account")) { + /* We found the corresponding account field. */ + GaimAccount *account; + GtkOptionMenu *optmenu = GTK_OPTION_MENU(field->ui_data); + + gtk_tree_model_get_value(model, iter, 3, &val); + account = g_value_get_pointer(&val); + g_value_unset(&val); + + /* Set the account in the request API. */ + gaim_request_field_account_set_value(field, account); + + if (optmenu != NULL) { + GList *items = GTK_MENU_SHELL(gtk_option_menu_get_menu(optmenu))->children; + guint index = 0; + + do { + if (account == g_object_get_data(G_OBJECT(items->data), "account")) { + /* Set the account in the GUI. */ + + gtk_option_menu_set_history(GTK_OPTION_MENU(field->ui_data), index); + return TRUE; + } + index++; + } while ((items = items->next) != NULL); + } + + return TRUE; + } + } + + } while ((fields = fields->next) != NULL); + return TRUE; } #endif /* !NEW_STYLE_COMPLETION */ @@ -824,19 +866,22 @@ GtkListStore *store; GtkTreeIter iter; GtkEntryCompletion *completion; - GList *aliases_and_screennames, *l; + GList *aliases_and_screennames; + GList *l; + gpointer *data; /* Store the displayed completion value, the screenname, and the value for comparison. */ - store = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); + store = gtk_list_store_new(4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); aliases_and_screennames = get_online_names(); - /* Loop through the list three elements at a time. */ - for (l = aliases_and_screennames; l != NULL; l = l->next->next->next) + /* Loop through the list four elements at a time. */ + for (l = aliases_and_screennames; l != NULL; l = l->next->next->next->next) { char *contact_alias = l->data; char *buddy_alias = l->next->data; - char *screenname = l->next->next->data; + GaimAccount *account = l->next->next->data; + char *screenname = l->next->next->next->data; gboolean completion_added = FALSE; /* There's no sense listing things like: 'xxx "xxx"' @@ -848,6 +893,7 @@ 0, completion_entry, 1, screenname, 2, buddy_alias, + 3, account, -1); g_free(completion_entry); completion_added = TRUE; @@ -865,6 +911,7 @@ 0, completion_entry, 1, screenname, 2, contact_alias, + 3, account, -1); g_free(completion_entry); completion_added = TRUE; @@ -878,6 +925,7 @@ 0, screenname, 1, screenname, 2, NULL, + 3, account, -1); } } @@ -886,8 +934,13 @@ completion = gtk_entry_completion_new(); gtk_entry_completion_set_match_func(completion, screenname_completion_match_func, NULL, NULL); + + data = g_new0(gpointer, 2); + data[0] = entry; + data[1] = field; g_signal_connect(G_OBJECT(completion), "match-selected", - G_CALLBACK(screenname_completion_match_selected_cb), entry); + G_CALLBACK(screenname_completion_match_selected_cb), data); + gtk_entry_set_completion(GTK_ENTRY(entry), completion); g_object_unref(completion);
--- a/src/request.h Thu Apr 07 15:08:14 2005 +0000 +++ b/src/request.h Thu Apr 07 15:22:21 2005 +0000 @@ -450,7 +450,7 @@ * Sets the type hint for the field. * * This is optionally used by the UIs to provide such features as - * auto-completion for type hints like "screenname." + * auto-completion for type hints like "account" and "screenname". * * @param field The field. * @param type_hint The type hint.