Mercurial > pidgin.yaz
comparison src/gtkrequest.c @ 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 | d83f745c997b |
children | 6240d7fd5b2c |
comparison
equal
deleted
inserted
replaced
10790:35edd4d021a4 | 10791:2ab4b5acc8d1 |
---|---|
671 | 671 |
672 #ifdef NEW_STYLE_COMPLETION | 672 #ifdef NEW_STYLE_COMPLETION |
673 names = g_list_append(names, ((GaimContact *)cnode)->alias); | 673 names = g_list_append(names, ((GaimContact *)cnode)->alias); |
674 names = g_list_append(names, | 674 names = g_list_append(names, |
675 (gpointer)gaim_buddy_get_contact_alias(buddy)); | 675 (gpointer)gaim_buddy_get_contact_alias(buddy)); |
676 names = g_list_append(names, buddy->account); | |
676 #endif /* NEW_STYLE_COMPLETION */ | 677 #endif /* NEW_STYLE_COMPLETION */ |
677 | 678 |
678 names = g_list_append(names, buddy->name); | 679 names = g_list_append(names, buddy->name); |
679 } | 680 } |
680 } | 681 } |
803 | 804 |
804 return ret; | 805 return ret; |
805 } | 806 } |
806 | 807 |
807 static gboolean screenname_completion_match_selected_cb(GtkEntryCompletion *completion, | 808 static gboolean screenname_completion_match_selected_cb(GtkEntryCompletion *completion, |
808 GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data) { | 809 GtkTreeModel *model, GtkTreeIter *iter, gpointer *user_data) { |
809 | 810 |
810 GValue val = { 0, }; | 811 GValue val = { 0, }; |
812 GaimRequestField *screen_field = user_data[1]; | |
813 GList *fields = screen_field->group->fields; | |
811 | 814 |
812 gtk_tree_model_get_value(model, iter, 1, &val); | 815 gtk_tree_model_get_value(model, iter, 1, &val); |
813 gtk_entry_set_text(GTK_ENTRY(user_data), g_value_get_string(&val)); | 816 gtk_entry_set_text(GTK_ENTRY(user_data[0]), g_value_get_string(&val)); |
814 g_value_unset(&val); | 817 g_value_unset(&val); |
818 | |
819 do { | |
820 GaimRequestField *field = fields->data; | |
821 | |
822 if (gaim_request_field_get_type(field) == GAIM_REQUEST_FIELD_ACCOUNT) { | |
823 const char *type_hint = gaim_request_field_get_type_hint(field); | |
824 | |
825 if (type_hint != NULL && !strcmp(type_hint, "account")) { | |
826 /* We found the corresponding account field. */ | |
827 GaimAccount *account; | |
828 GtkOptionMenu *optmenu = GTK_OPTION_MENU(field->ui_data); | |
829 | |
830 gtk_tree_model_get_value(model, iter, 3, &val); | |
831 account = g_value_get_pointer(&val); | |
832 g_value_unset(&val); | |
833 | |
834 /* Set the account in the request API. */ | |
835 gaim_request_field_account_set_value(field, account); | |
836 | |
837 if (optmenu != NULL) { | |
838 GList *items = GTK_MENU_SHELL(gtk_option_menu_get_menu(optmenu))->children; | |
839 guint index = 0; | |
840 | |
841 do { | |
842 if (account == g_object_get_data(G_OBJECT(items->data), "account")) { | |
843 /* Set the account in the GUI. */ | |
844 | |
845 gtk_option_menu_set_history(GTK_OPTION_MENU(field->ui_data), index); | |
846 return TRUE; | |
847 } | |
848 index++; | |
849 } while ((items = items->next) != NULL); | |
850 } | |
851 | |
852 return TRUE; | |
853 } | |
854 } | |
855 | |
856 } while ((fields = fields->next) != NULL); | |
815 | 857 |
816 return TRUE; | 858 return TRUE; |
817 } | 859 } |
818 #endif /* !NEW_STYLE_COMPLETION */ | 860 #endif /* !NEW_STYLE_COMPLETION */ |
819 | 861 |
822 { | 864 { |
823 #ifdef NEW_STYLE_COMPLETION | 865 #ifdef NEW_STYLE_COMPLETION |
824 GtkListStore *store; | 866 GtkListStore *store; |
825 GtkTreeIter iter; | 867 GtkTreeIter iter; |
826 GtkEntryCompletion *completion; | 868 GtkEntryCompletion *completion; |
827 GList *aliases_and_screennames, *l; | 869 GList *aliases_and_screennames; |
870 GList *l; | |
871 gpointer *data; | |
828 | 872 |
829 /* Store the displayed completion value, the screenname, and the value for comparison. */ | 873 /* Store the displayed completion value, the screenname, and the value for comparison. */ |
830 store = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); | 874 store = gtk_list_store_new(4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); |
831 | 875 |
832 aliases_and_screennames = get_online_names(); | 876 aliases_and_screennames = get_online_names(); |
833 | 877 |
834 /* Loop through the list three elements at a time. */ | 878 /* Loop through the list four elements at a time. */ |
835 for (l = aliases_and_screennames; l != NULL; l = l->next->next->next) | 879 for (l = aliases_and_screennames; l != NULL; l = l->next->next->next->next) |
836 { | 880 { |
837 char *contact_alias = l->data; | 881 char *contact_alias = l->data; |
838 char *buddy_alias = l->next->data; | 882 char *buddy_alias = l->next->data; |
839 char *screenname = l->next->next->data; | 883 GaimAccount *account = l->next->next->data; |
884 char *screenname = l->next->next->next->data; | |
840 gboolean completion_added = FALSE; | 885 gboolean completion_added = FALSE; |
841 | 886 |
842 /* There's no sense listing things like: 'xxx "xxx"' | 887 /* There's no sense listing things like: 'xxx "xxx"' |
843 when the screenname and buddy alias match. */ | 888 when the screenname and buddy alias match. */ |
844 if (buddy_alias && strcmp(buddy_alias, screenname)) { | 889 if (buddy_alias && strcmp(buddy_alias, screenname)) { |
846 gtk_list_store_append(store, &iter); | 891 gtk_list_store_append(store, &iter); |
847 gtk_list_store_set(store, &iter, | 892 gtk_list_store_set(store, &iter, |
848 0, completion_entry, | 893 0, completion_entry, |
849 1, screenname, | 894 1, screenname, |
850 2, buddy_alias, | 895 2, buddy_alias, |
896 3, account, | |
851 -1); | 897 -1); |
852 g_free(completion_entry); | 898 g_free(completion_entry); |
853 completion_added = TRUE; | 899 completion_added = TRUE; |
854 } | 900 } |
855 | 901 |
863 gtk_list_store_append(store, &iter); | 909 gtk_list_store_append(store, &iter); |
864 gtk_list_store_set(store, &iter, | 910 gtk_list_store_set(store, &iter, |
865 0, completion_entry, | 911 0, completion_entry, |
866 1, screenname, | 912 1, screenname, |
867 2, contact_alias, | 913 2, contact_alias, |
914 3, account, | |
868 -1); | 915 -1); |
869 g_free(completion_entry); | 916 g_free(completion_entry); |
870 completion_added = TRUE; | 917 completion_added = TRUE; |
871 } | 918 } |
872 } | 919 } |
876 gtk_list_store_append(store, &iter); | 923 gtk_list_store_append(store, &iter); |
877 gtk_list_store_set(store, &iter, | 924 gtk_list_store_set(store, &iter, |
878 0, screenname, | 925 0, screenname, |
879 1, screenname, | 926 1, screenname, |
880 2, NULL, | 927 2, NULL, |
928 3, account, | |
881 -1); | 929 -1); |
882 } | 930 } |
883 } | 931 } |
884 | 932 |
885 g_list_free(aliases_and_screennames); | 933 g_list_free(aliases_and_screennames); |
886 | 934 |
887 completion = gtk_entry_completion_new(); | 935 completion = gtk_entry_completion_new(); |
888 gtk_entry_completion_set_match_func(completion, screenname_completion_match_func, NULL, NULL); | 936 gtk_entry_completion_set_match_func(completion, screenname_completion_match_func, NULL, NULL); |
937 | |
938 data = g_new0(gpointer, 2); | |
939 data[0] = entry; | |
940 data[1] = field; | |
889 g_signal_connect(G_OBJECT(completion), "match-selected", | 941 g_signal_connect(G_OBJECT(completion), "match-selected", |
890 G_CALLBACK(screenname_completion_match_selected_cb), entry); | 942 G_CALLBACK(screenname_completion_match_selected_cb), data); |
943 | |
891 gtk_entry_set_completion(GTK_ENTRY(entry), completion); | 944 gtk_entry_set_completion(GTK_ENTRY(entry), completion); |
892 g_object_unref(completion); | 945 g_object_unref(completion); |
893 | 946 |
894 gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(store)); | 947 gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(store)); |
895 g_object_unref(store); | 948 g_object_unref(store); |