comparison src/gtkaccount.c @ 7956:1b8261f374ea

[gaim-migrate @ 8631] This is the death of protocol numbers. There are probably now a few functions that should now go away, but i'll let our crack team of crazy patch writers figure out which ones they are. out-of-tree and unofficial prpl-writers, rejoice! committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Mon, 29 Dec 2003 09:03:47 +0000
parents e873d0bd0e6c
children fa6395637e2c
comparison
equal deleted inserted replaced
7955:119a22025818 7956:1b8261f374ea
79 typedef struct 79 typedef struct
80 { 80 {
81 GaimGtkAccountDialogType type; 81 GaimGtkAccountDialogType type;
82 82
83 GaimAccount *account; 83 GaimAccount *account;
84 GaimProtocol protocol;
85 char *protocol_id; 84 char *protocol_id;
86 GaimPlugin *plugin; 85 GaimPlugin *plugin;
87 GaimPluginProtocolInfo *prpl_info; 86 GaimPluginProtocolInfo *prpl_info;
88 87
89 GaimProxyType new_proxy_type; 88 GaimProxyType new_proxy_type;
150 static void add_account(AccountsWindow *dialog, GaimAccount *account); 149 static void add_account(AccountsWindow *dialog, GaimAccount *account);
151 static void set_account(GtkListStore *store, GtkTreeIter *iter, 150 static void set_account(GtkListStore *store, GtkTreeIter *iter,
152 GaimAccount *account); 151 GaimAccount *account);
153 152
154 static char * 153 static char *
155 proto_name(int proto) 154 proto_name(const char *id)
156 { 155 {
157 GaimPlugin *p = gaim_find_prpl(proto); 156 GaimPlugin *p = gaim_find_prpl(id);
158 157
159 return ((p && p->info->name) ? _(p->info->name) : _("Unknown")); 158 return ((p && p->info->name) ? _(p->info->name) : _("Unknown"));
160 } 159 }
161 160
162 /************************************************************************** 161 /**************************************************************************
190 189
191 return hbox; 190 return hbox;
192 } 191 }
193 192
194 static void 193 static void
195 set_account_protocol_cb(GtkWidget *item, GaimProtocol protocol, 194 set_account_protocol_cb(GtkWidget *item, const char *id,
196 AccountPrefsDialog *dialog) 195 AccountPrefsDialog *dialog)
197 { 196 {
198 if ((dialog->plugin = gaim_find_prpl(protocol)) != NULL) { 197 if ((dialog->plugin = gaim_find_prpl(id)) != NULL) {
199 dialog->prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(dialog->plugin); 198 dialog->prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(dialog->plugin);
200 dialog->protocol = dialog->prpl_info->protocol;
201 199
202 if (dialog->protocol_id != NULL) 200 if (dialog->protocol_id != NULL)
203 g_free(dialog->protocol_id); 201 g_free(dialog->protocol_id);
204 202
205 dialog->protocol_id = g_strdup(dialog->plugin->info->id); 203 dialog->protocol_id = g_strdup(dialog->plugin->info->id);
379 gtk_container_add(GTK_CONTAINER(frame), vbox); 377 gtk_container_add(GTK_CONTAINER(frame), vbox);
380 gtk_widget_show(vbox); 378 gtk_widget_show(vbox);
381 379
382 /* Protocol */ 380 /* Protocol */
383 dialog->protocol_menu = gaim_gtk_protocol_option_menu_new( 381 dialog->protocol_menu = gaim_gtk_protocol_option_menu_new(
384 dialog->protocol, G_CALLBACK(set_account_protocol_cb), dialog); 382 dialog->protocol_id, G_CALLBACK(set_account_protocol_cb), dialog);
385 383
386 add_pref_box(dialog, vbox, _("Protocol:"), dialog->protocol_menu); 384 add_pref_box(dialog, vbox, _("Protocol:"), dialog->protocol_menu);
387 385
388 /* Screen Name */ 386 /* Screen Name */
389 dialog->screenname_entry = gtk_entry_new(); 387 dialog->screenname_entry = gtk_entry_new();
645 for (l = dialog->prpl_info->protocol_options; l != NULL; l = l->next) { 643 for (l = dialog->prpl_info->protocol_options; l != NULL; l = l->next) {
646 option = (GaimAccountOption *)l->data; 644 option = (GaimAccountOption *)l->data;
647 645
648 switch (gaim_account_option_get_type(option)) { 646 switch (gaim_account_option_get_type(option)) {
649 case GAIM_PREF_BOOLEAN: 647 case GAIM_PREF_BOOLEAN:
650 if (account == NULL || 648 if (account == NULL || !strcmp(gaim_account_get_protocol_id(account), dialog->protocol_id)) {
651 gaim_account_get_protocol(account) != dialog->protocol) {
652
653 bool_value = gaim_account_option_get_default_bool(option); 649 bool_value = gaim_account_option_get_default_bool(option);
654 } 650 } else {
655 else
656 bool_value = gaim_account_get_bool(account, 651 bool_value = gaim_account_get_bool(account,
657 gaim_account_option_get_setting(option), 652 gaim_account_option_get_setting(option),
658 gaim_account_option_get_default_bool(option)); 653 gaim_account_option_get_default_bool(option));
654 }
659 655
660 check = gtk_check_button_new_with_label( 656 check = gtk_check_button_new_with_label(
661 gaim_account_option_get_text(option)); 657 gaim_account_option_get_text(option));
662 658
663 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), 659 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),
670 g_list_append(dialog->protocol_opt_entries, check); 666 g_list_append(dialog->protocol_opt_entries, check);
671 667
672 break; 668 break;
673 669
674 case GAIM_PREF_INT: 670 case GAIM_PREF_INT:
675 if (account == NULL || 671 if (account == NULL || !strcmp(gaim_account_get_protocol_id(account), dialog->protocol_id)) {
676 gaim_account_get_protocol(account) != dialog->protocol) {
677
678 int_value = gaim_account_option_get_default_int(option); 672 int_value = gaim_account_option_get_default_int(option);
679 } 673 } else {
680 else
681 int_value = gaim_account_get_int(account, 674 int_value = gaim_account_get_int(account,
682 gaim_account_option_get_setting(option), 675 gaim_account_option_get_setting(option),
683 gaim_account_option_get_default_int(option)); 676 gaim_account_option_get_default_int(option));
677 }
684 678
685 g_snprintf(buf, sizeof(buf), "%d", int_value); 679 g_snprintf(buf, sizeof(buf), "%d", int_value);
686 680
687 entry = gtk_entry_new(); 681 entry = gtk_entry_new();
688 gtk_entry_set_text(GTK_ENTRY(entry), buf); 682 gtk_entry_set_text(GTK_ENTRY(entry), buf);
698 g_list_append(dialog->protocol_opt_entries, entry); 692 g_list_append(dialog->protocol_opt_entries, entry);
699 693
700 break; 694 break;
701 695
702 case GAIM_PREF_STRING: 696 case GAIM_PREF_STRING:
703 if (account == NULL || 697 if (account == NULL || !strcmp(gaim_account_get_protocol_id(account), dialog->protocol_id)) {
704 gaim_account_get_protocol(account) != dialog->protocol) {
705
706 str_value = gaim_account_option_get_default_string(option); 698 str_value = gaim_account_option_get_default_string(option);
707 } 699 } else {
708 else
709 str_value = gaim_account_get_string(account, 700 str_value = gaim_account_get_string(account,
710 gaim_account_option_get_setting(option), 701 gaim_account_option_get_setting(option),
711 gaim_account_option_get_default_string(option)); 702 gaim_account_option_get_default_string(option));
703 }
712 704
713 entry = gtk_entry_new(); 705 entry = gtk_entry_new();
714 706
715 if (str_value != NULL) 707 if (str_value != NULL)
716 gtk_entry_set_text(GTK_ENTRY(entry), str_value); 708 gtk_entry_set_text(GTK_ENTRY(entry), str_value);
1196 dialog->account = account; 1188 dialog->account = account;
1197 dialog->type = type; 1189 dialog->type = type;
1198 dialog->sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); 1190 dialog->sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
1199 1191
1200 if (dialog->account == NULL) { 1192 if (dialog->account == NULL) {
1201 dialog->protocol_id = g_strdup("prpl-oscar"); 1193 dialog->protocol_id = g_strdup(GAIM_PROTO_DEFAULT);
1202 dialog->protocol = GAIM_PROTO_OSCAR;
1203 } 1194 }
1204 else { 1195 else {
1205 dialog->protocol_id = 1196 dialog->protocol_id =
1206 g_strdup(gaim_account_get_protocol_id(dialog->account)); 1197 g_strdup(gaim_account_get_protocol_id(dialog->account));
1207 dialog->protocol = gaim_account_get_protocol(dialog->account); 1198 }
1208 } 1199
1209 1200 if ((dialog->plugin = gaim_find_prpl(dialog->protocol_id)) != NULL)
1210 if ((dialog->plugin = gaim_find_prpl(dialog->protocol)) != NULL)
1211 dialog->prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(dialog->plugin); 1201 dialog->prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(dialog->plugin);
1212 1202
1213 1203
1214 dialog->window = win = gtk_window_new(GTK_WINDOW_TOPLEVEL); 1204 dialog->window = win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1215 gtk_window_set_role(GTK_WINDOW(win), "account"); 1205 gtk_window_set_role(GTK_WINDOW(win), "account");
1803 gtk_list_store_set(store, iter, 1793 gtk_list_store_set(store, iter,
1804 COLUMN_ICON, scale, 1794 COLUMN_ICON, scale,
1805 COLUMN_SCREENNAME, gaim_account_get_username(account), 1795 COLUMN_SCREENNAME, gaim_account_get_username(account),
1806 COLUMN_ONLINE, gaim_account_is_connected(account), 1796 COLUMN_ONLINE, gaim_account_is_connected(account),
1807 COLUMN_AUTOLOGIN, gaim_account_get_auto_login(account, GAIM_GTK_UI), 1797 COLUMN_AUTOLOGIN, gaim_account_get_auto_login(account, GAIM_GTK_UI),
1808 COLUMN_PROTOCOL, proto_name(gaim_account_get_protocol(account)), 1798 COLUMN_PROTOCOL, proto_name(gaim_account_get_protocol_id(account)),
1809 COLUMN_DATA, account, 1799 COLUMN_DATA, account,
1810 -1); 1800 -1);
1811 1801
1812 if (pixbuf != NULL) g_object_unref(G_OBJECT(pixbuf)); 1802 if (pixbuf != NULL) g_object_unref(G_OBJECT(pixbuf));
1813 if (scale != NULL) g_object_unref(G_OBJECT(scale)); 1803 if (scale != NULL) g_object_unref(G_OBJECT(scale));