Mercurial > pidgin
comparison src/gtkaccount.c @ 5774:e8f6209c4f59
[gaim-migrate @ 6199]
Moved the protocol name to the second column in the account editor and put
the screenname in the first. The protocol icon is now in the screenname
column. I think this is much better.
Also, I removed all of Chip's ANSI standard breaking double-underscore
function names. If you want to use some other naming convention to designate
static functions, Chip, knock yourself out; I just s/__//'ed it.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Fri, 06 Jun 2003 15:47:32 +0000 |
parents | d1aecc84319c |
children | 758fa27534b3 |
comparison
equal
deleted
inserted
replaced
5773:8107b9ee8789 | 5774:e8f6209c4f59 |
---|---|
131 } AccountPrefsDialog; | 131 } AccountPrefsDialog; |
132 | 132 |
133 | 133 |
134 static AccountsDialog *accounts_dialog = NULL; | 134 static AccountsDialog *accounts_dialog = NULL; |
135 | 135 |
136 static void __add_account(AccountsDialog *dialog, GaimAccount *account); | 136 static void add_account(AccountsDialog *dialog, GaimAccount *account); |
137 static void __set_account(GtkListStore *store, GtkTreeIter *iter, | 137 static void set_account(GtkListStore *store, GtkTreeIter *iter, |
138 GaimAccount *account); | 138 GaimAccount *account); |
139 | 139 |
140 static char * | 140 static char * |
141 proto_name(int proto) | 141 proto_name(int proto) |
142 { | 142 { |
146 } | 146 } |
147 | 147 |
148 /************************************************************************** | 148 /************************************************************************** |
149 * Add/Modify Account dialog | 149 * Add/Modify Account dialog |
150 **************************************************************************/ | 150 **************************************************************************/ |
151 static void __add_login_options(AccountPrefsDialog *dialog, GtkWidget *parent); | 151 static void add_login_options(AccountPrefsDialog *dialog, GtkWidget *parent); |
152 static void __add_user_options(AccountPrefsDialog *dialog, GtkWidget *parent); | 152 static void add_user_options(AccountPrefsDialog *dialog, GtkWidget *parent); |
153 static void __add_protocol_options(AccountPrefsDialog *dialog, | 153 static void add_protocol_options(AccountPrefsDialog *dialog, |
154 GtkWidget *parent); | 154 GtkWidget *parent); |
155 static void __add_proxy_options(AccountPrefsDialog *dialog, GtkWidget *parent); | 155 static void add_proxy_options(AccountPrefsDialog *dialog, GtkWidget *parent); |
156 | 156 |
157 static GtkWidget * | 157 static GtkWidget * |
158 __add_pref_box(AccountPrefsDialog *dialog, GtkWidget *parent, | 158 add_pref_box(AccountPrefsDialog *dialog, GtkWidget *parent, |
159 const char *text, GtkWidget *widget) | 159 const char *text, GtkWidget *widget) |
160 { | 160 { |
161 GtkWidget *hbox; | 161 GtkWidget *hbox; |
162 GtkWidget *label; | 162 GtkWidget *label; |
163 | 163 |
176 | 176 |
177 return hbox; | 177 return hbox; |
178 } | 178 } |
179 | 179 |
180 static void | 180 static void |
181 __set_account_protocol_cb(GtkWidget *item, GaimProtocol protocol, | 181 set_account_protocol_cb(GtkWidget *item, GaimProtocol protocol, |
182 AccountPrefsDialog *dialog) | 182 AccountPrefsDialog *dialog) |
183 { | 183 { |
184 dialog->protocol = protocol; | 184 dialog->protocol = protocol; |
185 | 185 |
186 if ((dialog->plugin = gaim_find_prpl(dialog->protocol)) != NULL) | 186 if ((dialog->plugin = gaim_find_prpl(dialog->protocol)) != NULL) |
187 dialog->prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(dialog->plugin); | 187 dialog->prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(dialog->plugin); |
188 | 188 |
189 __add_login_options(dialog, dialog->top_vbox); | 189 add_login_options(dialog, dialog->top_vbox); |
190 __add_user_options(dialog, dialog->top_vbox); | 190 add_user_options(dialog, dialog->top_vbox); |
191 __add_protocol_options(dialog, dialog->bottom_vbox); | 191 add_protocol_options(dialog, dialog->bottom_vbox); |
192 } | 192 } |
193 | 193 |
194 static void | 194 static void |
195 __screenname_changed_cb(GtkEntry *entry, AccountPrefsDialog *dialog) | 195 screenname_changed_cb(GtkEntry *entry, AccountPrefsDialog *dialog) |
196 { | 196 { |
197 if (dialog->ok_button == NULL) | 197 if (dialog->ok_button == NULL) |
198 return; | 198 return; |
199 | 199 |
200 gtk_widget_set_sensitive(dialog->ok_button, | 200 gtk_widget_set_sensitive(dialog->ok_button, |
201 *gtk_entry_get_text(entry) != '\0'); | 201 *gtk_entry_get_text(entry) != '\0'); |
202 } | 202 } |
203 | 203 |
204 static void | 204 static void |
205 __add_login_options(AccountPrefsDialog *dialog, GtkWidget *parent) | 205 add_login_options(AccountPrefsDialog *dialog, GtkWidget *parent) |
206 { | 206 { |
207 GtkWidget *frame; | 207 GtkWidget *frame; |
208 GtkWidget *vbox; | 208 GtkWidget *vbox; |
209 GtkWidget *entry; | 209 GtkWidget *entry; |
210 GList *user_splits; | 210 GList *user_splits; |
228 gtk_container_add(GTK_CONTAINER(frame), vbox); | 228 gtk_container_add(GTK_CONTAINER(frame), vbox); |
229 gtk_widget_show(vbox); | 229 gtk_widget_show(vbox); |
230 | 230 |
231 /* Protocol */ | 231 /* Protocol */ |
232 dialog->protocol_menu = gaim_gtk_protocol_option_menu_new( | 232 dialog->protocol_menu = gaim_gtk_protocol_option_menu_new( |
233 dialog->protocol, G_CALLBACK(__set_account_protocol_cb), dialog); | 233 dialog->protocol, G_CALLBACK(set_account_protocol_cb), dialog); |
234 | 234 |
235 __add_pref_box(dialog, vbox, _("Protocol:"), dialog->protocol_menu); | 235 add_pref_box(dialog, vbox, _("Protocol:"), dialog->protocol_menu); |
236 | 236 |
237 /* Screen Name */ | 237 /* Screen Name */ |
238 dialog->screenname_entry = gtk_entry_new(); | 238 dialog->screenname_entry = gtk_entry_new(); |
239 | 239 |
240 __add_pref_box(dialog, vbox, _("Screenname:"), dialog->screenname_entry); | 240 add_pref_box(dialog, vbox, _("Screenname:"), dialog->screenname_entry); |
241 | 241 |
242 g_signal_connect(G_OBJECT(dialog->screenname_entry), "changed", | 242 g_signal_connect(G_OBJECT(dialog->screenname_entry), "changed", |
243 G_CALLBACK(__screenname_changed_cb), dialog); | 243 G_CALLBACK(screenname_changed_cb), dialog); |
244 | 244 |
245 /* Do the user split thang */ | 245 /* Do the user split thang */ |
246 if (dialog->plugin == NULL) /* Yeah right. */ | 246 if (dialog->plugin == NULL) /* Yeah right. */ |
247 user_splits = NULL; | 247 user_splits = NULL; |
248 else | 248 else |
262 | 262 |
263 buf = g_strdup_printf("%s:", gaim_account_user_split_get_text(split)); | 263 buf = g_strdup_printf("%s:", gaim_account_user_split_get_text(split)); |
264 | 264 |
265 entry = gtk_entry_new(); | 265 entry = gtk_entry_new(); |
266 | 266 |
267 __add_pref_box(dialog, vbox, buf, entry); | 267 add_pref_box(dialog, vbox, buf, entry); |
268 | 268 |
269 g_free(buf); | 269 g_free(buf); |
270 | 270 |
271 dialog->user_split_entries = | 271 dialog->user_split_entries = |
272 g_list_append(dialog->user_split_entries, entry); | 272 g_list_append(dialog->user_split_entries, entry); |
308 | 308 |
309 | 309 |
310 /* Password */ | 310 /* Password */ |
311 dialog->password_entry = gtk_entry_new(); | 311 dialog->password_entry = gtk_entry_new(); |
312 gtk_entry_set_visibility(GTK_ENTRY(dialog->password_entry), FALSE); | 312 gtk_entry_set_visibility(GTK_ENTRY(dialog->password_entry), FALSE); |
313 dialog->password_box = __add_pref_box(dialog, vbox, _("Password:"), | 313 dialog->password_box = add_pref_box(dialog, vbox, _("Password:"), |
314 dialog->password_entry); | 314 dialog->password_entry); |
315 | 315 |
316 /* Alias */ | 316 /* Alias */ |
317 dialog->alias_entry = gtk_entry_new(); | 317 dialog->alias_entry = gtk_entry_new(); |
318 __add_pref_box(dialog, vbox, _("Alias:"), dialog->alias_entry); | 318 add_pref_box(dialog, vbox, _("Alias:"), dialog->alias_entry); |
319 | 319 |
320 /* Remember Password */ | 320 /* Remember Password */ |
321 dialog->remember_pass_check = | 321 dialog->remember_pass_check = |
322 gtk_check_button_new_with_label(_("Remember password")); | 322 gtk_check_button_new_with_label(_("Remember password")); |
323 gtk_box_pack_start(GTK_BOX(vbox), dialog->remember_pass_check, | 323 gtk_box_pack_start(GTK_BOX(vbox), dialog->remember_pass_check, |
356 gtk_widget_hide(dialog->remember_pass_check); | 356 gtk_widget_hide(dialog->remember_pass_check); |
357 } | 357 } |
358 } | 358 } |
359 | 359 |
360 static void | 360 static void |
361 __add_user_options(AccountPrefsDialog *dialog, GtkWidget *parent) | 361 add_user_options(AccountPrefsDialog *dialog, GtkWidget *parent) |
362 { | 362 { |
363 GtkWidget *frame; | 363 GtkWidget *frame; |
364 GtkWidget *vbox; | 364 GtkWidget *vbox; |
365 GtkWidget *hbox; | 365 GtkWidget *hbox; |
366 GtkWidget *button; | 366 GtkWidget *button; |
432 gtk_widget_hide(dialog->user_frame); | 432 gtk_widget_hide(dialog->user_frame); |
433 } | 433 } |
434 } | 434 } |
435 | 435 |
436 static void | 436 static void |
437 __add_protocol_options(AccountPrefsDialog *dialog, GtkWidget *parent) | 437 add_protocol_options(AccountPrefsDialog *dialog, GtkWidget *parent) |
438 { | 438 { |
439 GaimAccountOption *option; | 439 GaimAccountOption *option; |
440 GaimAccount *account; | 440 GaimAccount *account; |
441 GtkWidget *frame; | 441 GtkWidget *frame; |
442 GtkWidget *vbox; | 442 GtkWidget *vbox; |
528 gtk_entry_set_text(GTK_ENTRY(entry), buf); | 528 gtk_entry_set_text(GTK_ENTRY(entry), buf); |
529 | 529 |
530 title = g_strdup_printf("%s:", | 530 title = g_strdup_printf("%s:", |
531 gaim_account_option_get_text(option)); | 531 gaim_account_option_get_text(option)); |
532 | 532 |
533 __add_pref_box(dialog, vbox, title, entry); | 533 add_pref_box(dialog, vbox, title, entry); |
534 | 534 |
535 g_free(title); | 535 g_free(title); |
536 | 536 |
537 dialog->protocol_opt_entries = | 537 dialog->protocol_opt_entries = |
538 g_list_append(dialog->protocol_opt_entries, entry); | 538 g_list_append(dialog->protocol_opt_entries, entry); |
556 gtk_entry_set_text(GTK_ENTRY(entry), str_value); | 556 gtk_entry_set_text(GTK_ENTRY(entry), str_value); |
557 | 557 |
558 title = g_strdup_printf("%s:", | 558 title = g_strdup_printf("%s:", |
559 gaim_account_option_get_text(option)); | 559 gaim_account_option_get_text(option)); |
560 | 560 |
561 __add_pref_box(dialog, vbox, title, entry); | 561 add_pref_box(dialog, vbox, title, entry); |
562 | 562 |
563 g_free(title); | 563 g_free(title); |
564 | 564 |
565 dialog->protocol_opt_entries = | 565 dialog->protocol_opt_entries = |
566 g_list_append(dialog->protocol_opt_entries, entry); | 566 g_list_append(dialog->protocol_opt_entries, entry); |
582 gtk_widget_show(dialog->register_check); | 582 gtk_widget_show(dialog->register_check); |
583 } | 583 } |
584 } | 584 } |
585 | 585 |
586 static GtkWidget * | 586 static GtkWidget * |
587 __make_proxy_dropdown(void) | 587 make_proxy_dropdown(void) |
588 { | 588 { |
589 GtkWidget *dropdown; | 589 GtkWidget *dropdown; |
590 GtkWidget *menu; | 590 GtkWidget *menu; |
591 GtkWidget *item; | 591 GtkWidget *item; |
592 | 592 |
632 | 632 |
633 return dropdown; | 633 return dropdown; |
634 } | 634 } |
635 | 635 |
636 static void | 636 static void |
637 __proxy_type_changed_cb(GtkWidget *optmenu, AccountPrefsDialog *dialog) | 637 proxy_type_changed_cb(GtkWidget *optmenu, AccountPrefsDialog *dialog) |
638 { | 638 { |
639 dialog->new_proxy_type = | 639 dialog->new_proxy_type = |
640 gtk_option_menu_get_history(GTK_OPTION_MENU(optmenu)) - 1; | 640 gtk_option_menu_get_history(GTK_OPTION_MENU(optmenu)) - 1; |
641 | 641 |
642 if (dialog->new_proxy_type == GAIM_PROXY_USE_GLOBAL || | 642 if (dialog->new_proxy_type == GAIM_PROXY_USE_GLOBAL || |
647 else | 647 else |
648 gtk_widget_show_all(dialog->proxy_vbox); | 648 gtk_widget_show_all(dialog->proxy_vbox); |
649 } | 649 } |
650 | 650 |
651 static void | 651 static void |
652 __port_popup_cb(GtkWidget *w, GtkMenu *menu, gpointer data) | 652 port_popup_cb(GtkWidget *w, GtkMenu *menu, gpointer data) |
653 { | 653 { |
654 GtkWidget *item; | 654 GtkWidget *item; |
655 | 655 |
656 item = gtk_menu_item_new_with_label( | 656 item = gtk_menu_item_new_with_label( |
657 _("you can see the butterflies mating")); | 657 _("you can see the butterflies mating")); |
662 gtk_widget_show(item); | 662 gtk_widget_show(item); |
663 gtk_menu_shell_prepend(GTK_MENU_SHELL(menu), item); | 663 gtk_menu_shell_prepend(GTK_MENU_SHELL(menu), item); |
664 } | 664 } |
665 | 665 |
666 static void | 666 static void |
667 __add_proxy_options(AccountPrefsDialog *dialog, GtkWidget *parent) | 667 add_proxy_options(AccountPrefsDialog *dialog, GtkWidget *parent) |
668 { | 668 { |
669 GaimProxyInfo *proxy_info; | 669 GaimProxyInfo *proxy_info; |
670 GtkWidget *frame; | 670 GtkWidget *frame; |
671 GtkWidget *vbox; | 671 GtkWidget *vbox; |
672 GtkWidget *vbox2; | 672 GtkWidget *vbox2; |
684 vbox = gtk_vbox_new(FALSE, 6); | 684 vbox = gtk_vbox_new(FALSE, 6); |
685 gtk_container_add(GTK_CONTAINER(frame), vbox); | 685 gtk_container_add(GTK_CONTAINER(frame), vbox); |
686 gtk_widget_show(vbox); | 686 gtk_widget_show(vbox); |
687 | 687 |
688 /* Proxy Type drop-down. */ | 688 /* Proxy Type drop-down. */ |
689 dialog->proxy_dropdown = __make_proxy_dropdown(); | 689 dialog->proxy_dropdown = make_proxy_dropdown(); |
690 dialog->proxy_menu = | 690 dialog->proxy_menu = |
691 gtk_option_menu_get_menu(GTK_OPTION_MENU(dialog->proxy_dropdown)); | 691 gtk_option_menu_get_menu(GTK_OPTION_MENU(dialog->proxy_dropdown)); |
692 | 692 |
693 __add_pref_box(dialog, vbox, _("Proxy _type:"), dialog->proxy_dropdown); | 693 add_pref_box(dialog, vbox, _("Proxy _type:"), dialog->proxy_dropdown); |
694 | 694 |
695 /* Setup the second vbox, which may be hidden at times. */ | 695 /* Setup the second vbox, which may be hidden at times. */ |
696 dialog->proxy_vbox = vbox2 = gtk_vbox_new(FALSE, 6); | 696 dialog->proxy_vbox = vbox2 = gtk_vbox_new(FALSE, 6); |
697 gtk_box_pack_start(GTK_BOX(vbox), vbox2, FALSE, FALSE, 0); | 697 gtk_box_pack_start(GTK_BOX(vbox), vbox2, FALSE, FALSE, 0); |
698 gtk_widget_show(vbox2); | 698 gtk_widget_show(vbox2); |
699 | 699 |
700 /* Host */ | 700 /* Host */ |
701 dialog->proxy_host_entry = gtk_entry_new(); | 701 dialog->proxy_host_entry = gtk_entry_new(); |
702 __add_pref_box(dialog, vbox2, _("_Host:"), dialog->proxy_host_entry); | 702 add_pref_box(dialog, vbox2, _("_Host:"), dialog->proxy_host_entry); |
703 | 703 |
704 /* Port */ | 704 /* Port */ |
705 dialog->proxy_port_entry = gtk_entry_new(); | 705 dialog->proxy_port_entry = gtk_entry_new(); |
706 __add_pref_box(dialog, vbox2, _("_Port:"), dialog->proxy_port_entry); | 706 add_pref_box(dialog, vbox2, _("_Port:"), dialog->proxy_port_entry); |
707 | 707 |
708 g_signal_connect(G_OBJECT(dialog->proxy_port_entry), "populate-popup", | 708 g_signal_connect(G_OBJECT(dialog->proxy_port_entry), "populate-popup", |
709 G_CALLBACK(__port_popup_cb), NULL); | 709 G_CALLBACK(port_popup_cb), NULL); |
710 | 710 |
711 /* User */ | 711 /* User */ |
712 dialog->proxy_user_entry = gtk_entry_new(); | 712 dialog->proxy_user_entry = gtk_entry_new(); |
713 | 713 |
714 __add_pref_box(dialog, vbox2, _("_Username:"), dialog->proxy_user_entry); | 714 add_pref_box(dialog, vbox2, _("_Username:"), dialog->proxy_user_entry); |
715 | 715 |
716 /* Password */ | 716 /* Password */ |
717 dialog->proxy_pass_entry = gtk_entry_new(); | 717 dialog->proxy_pass_entry = gtk_entry_new(); |
718 gtk_entry_set_visibility(GTK_ENTRY(dialog->proxy_pass_entry), FALSE); | 718 gtk_entry_set_visibility(GTK_ENTRY(dialog->proxy_pass_entry), FALSE); |
719 __add_pref_box(dialog, vbox2, _("Pa_ssword:"), dialog->proxy_pass_entry); | 719 add_pref_box(dialog, vbox2, _("Pa_ssword:"), dialog->proxy_pass_entry); |
720 | 720 |
721 if (dialog->account != NULL && | 721 if (dialog->account != NULL && |
722 (proxy_info = gaim_account_get_proxy_info(dialog->account)) != NULL) { | 722 (proxy_info = gaim_account_get_proxy_info(dialog->account)) != NULL) { |
723 | 723 |
724 GaimProxyType type = gaim_proxy_info_get_type(proxy_info); | 724 GaimProxyType type = gaim_proxy_info_get_type(proxy_info); |
755 else | 755 else |
756 gtk_widget_hide_all(vbox2); | 756 gtk_widget_hide_all(vbox2); |
757 | 757 |
758 /* Connect signals. */ | 758 /* Connect signals. */ |
759 g_signal_connect(G_OBJECT(dialog->proxy_dropdown), "changed", | 759 g_signal_connect(G_OBJECT(dialog->proxy_dropdown), "changed", |
760 G_CALLBACK(__proxy_type_changed_cb), dialog); | 760 G_CALLBACK(proxy_type_changed_cb), dialog); |
761 } | 761 } |
762 | 762 |
763 static void | 763 static void |
764 __account_win_destroy_cb(GtkWidget *w, GdkEvent *event, | 764 account_win_destroy_cb(GtkWidget *w, GdkEvent *event, |
765 AccountPrefsDialog *dialog) | 765 AccountPrefsDialog *dialog) |
766 { | 766 { |
767 if (dialog->user_split_entries != NULL) | 767 if (dialog->user_split_entries != NULL) |
768 g_list_free(dialog->user_split_entries); | 768 g_list_free(dialog->user_split_entries); |
769 | 769 |
772 | 772 |
773 g_free(dialog); | 773 g_free(dialog); |
774 } | 774 } |
775 | 775 |
776 static void | 776 static void |
777 __cancel_account_prefs_cb(GtkWidget *w, AccountPrefsDialog *dialog) | 777 cancel_account_prefs_cb(GtkWidget *w, AccountPrefsDialog *dialog) |
778 { | 778 { |
779 gtk_widget_destroy(dialog->window); | 779 gtk_widget_destroy(dialog->window); |
780 | 780 |
781 __account_win_destroy_cb(NULL, NULL, dialog); | 781 account_win_destroy_cb(NULL, NULL, dialog); |
782 } | 782 } |
783 | 783 |
784 static void | 784 static void |
785 __ok_account_prefs_cb(GtkWidget *w, AccountPrefsDialog *dialog) | 785 ok_account_prefs_cb(GtkWidget *w, AccountPrefsDialog *dialog) |
786 { | 786 { |
787 GaimProxyInfo *proxy_info = NULL; | 787 GaimProxyInfo *proxy_info = NULL; |
788 GList *l, *l2; | 788 GList *l, *l2; |
789 const char *value; | 789 const char *value; |
790 char *username; | 790 char *username; |
949 if (index != -1 && | 949 if (index != -1 && |
950 (gtk_tree_model_iter_nth_child( | 950 (gtk_tree_model_iter_nth_child( |
951 GTK_TREE_MODEL(dialog->accounts_dialog->model), &iter, | 951 GTK_TREE_MODEL(dialog->accounts_dialog->model), &iter, |
952 NULL, index))) { | 952 NULL, index))) { |
953 | 953 |
954 __set_account(dialog->accounts_dialog->model, &iter, dialog->account); | 954 set_account(dialog->accounts_dialog->model, &iter, dialog->account); |
955 } | 955 } |
956 else { | 956 else { |
957 __add_account(dialog->accounts_dialog, dialog->account); | 957 add_account(dialog->accounts_dialog, dialog->account); |
958 gaim_accounts_add(dialog->account); | 958 gaim_accounts_add(dialog->account); |
959 } | 959 } |
960 | 960 |
961 /* See if we want to register with a server now. */ | 961 /* See if we want to register with a server now. */ |
962 if (dialog->prpl_info->register_user != NULL && | 962 if (dialog->prpl_info->register_user != NULL && |
966 dialog->prpl_info->register_user(dialog->account); | 966 dialog->prpl_info->register_user(dialog->account); |
967 } | 967 } |
968 | 968 |
969 gtk_widget_destroy(dialog->window); | 969 gtk_widget_destroy(dialog->window); |
970 | 970 |
971 __account_win_destroy_cb(NULL, NULL, dialog); | 971 account_win_destroy_cb(NULL, NULL, dialog); |
972 | 972 |
973 gaim_accounts_sync(); | 973 gaim_accounts_sync(); |
974 } | 974 } |
975 | 975 |
976 static void | 976 static void |
977 __show_account_prefs(AccountPrefsDialogType type, | 977 show_account_prefs(AccountPrefsDialogType type, |
978 AccountsDialog *accounts_dialog, | 978 AccountsDialog *accounts_dialog, |
979 GaimAccount *account) | 979 GaimAccount *account) |
980 { | 980 { |
981 AccountPrefsDialog *dialog; | 981 AccountPrefsDialog *dialog; |
982 GtkWidget *win; | 982 GtkWidget *win; |
1015 gtk_window_set_resizable(GTK_WINDOW(win), FALSE); | 1015 gtk_window_set_resizable(GTK_WINDOW(win), FALSE); |
1016 | 1016 |
1017 gtk_container_set_border_width(GTK_CONTAINER(win), 12); | 1017 gtk_container_set_border_width(GTK_CONTAINER(win), 12); |
1018 | 1018 |
1019 g_signal_connect(G_OBJECT(win), "delete_event", | 1019 g_signal_connect(G_OBJECT(win), "delete_event", |
1020 G_CALLBACK(__account_win_destroy_cb), dialog); | 1020 G_CALLBACK(account_win_destroy_cb), dialog); |
1021 | 1021 |
1022 /* Setup the vbox */ | 1022 /* Setup the vbox */ |
1023 main_vbox = gtk_vbox_new(FALSE, 12); | 1023 main_vbox = gtk_vbox_new(FALSE, 12); |
1024 gtk_container_add(GTK_CONTAINER(win), main_vbox); | 1024 gtk_container_add(GTK_CONTAINER(win), main_vbox); |
1025 gtk_widget_show(main_vbox); | 1025 gtk_widget_show(main_vbox); |
1028 dialog->top_vbox = vbox = gtk_vbox_new(FALSE, 18); | 1028 dialog->top_vbox = vbox = gtk_vbox_new(FALSE, 18); |
1029 gtk_box_pack_start(GTK_BOX(main_vbox), vbox, FALSE, FALSE, 0); | 1029 gtk_box_pack_start(GTK_BOX(main_vbox), vbox, FALSE, FALSE, 0); |
1030 gtk_widget_show(vbox); | 1030 gtk_widget_show(vbox); |
1031 | 1031 |
1032 /* Setup the top frames. */ | 1032 /* Setup the top frames. */ |
1033 __add_login_options(dialog, vbox); | 1033 add_login_options(dialog, vbox); |
1034 __add_user_options(dialog, vbox); | 1034 add_user_options(dialog, vbox); |
1035 | 1035 |
1036 /* Add the disclosure */ | 1036 /* Add the disclosure */ |
1037 disclosure = gaim_disclosure_new(_("Show more options"), | 1037 disclosure = gaim_disclosure_new(_("Show more options"), |
1038 _("Show fewer options")); | 1038 _("Show fewer options")); |
1039 gtk_box_pack_start(GTK_BOX(vbox), disclosure, FALSE, FALSE, 0); | 1039 gtk_box_pack_start(GTK_BOX(vbox), disclosure, FALSE, FALSE, 0); |
1044 gtk_box_pack_start(GTK_BOX(vbox), dbox, FALSE, FALSE, 0); | 1044 gtk_box_pack_start(GTK_BOX(vbox), dbox, FALSE, FALSE, 0); |
1045 | 1045 |
1046 gaim_disclosure_set_container(GAIM_DISCLOSURE(disclosure), dbox); | 1046 gaim_disclosure_set_container(GAIM_DISCLOSURE(disclosure), dbox); |
1047 | 1047 |
1048 /** Setup the bottom frames. */ | 1048 /** Setup the bottom frames. */ |
1049 __add_protocol_options(dialog, dbox); | 1049 add_protocol_options(dialog, dbox); |
1050 __add_proxy_options(dialog, dbox); | 1050 add_proxy_options(dialog, dbox); |
1051 | 1051 |
1052 /* Separator... */ | 1052 /* Separator... */ |
1053 sep = gtk_hseparator_new(); | 1053 sep = gtk_hseparator_new(); |
1054 gtk_box_pack_start(GTK_BOX(main_vbox), sep, FALSE, FALSE, 0); | 1054 gtk_box_pack_start(GTK_BOX(main_vbox), sep, FALSE, FALSE, 0); |
1055 gtk_widget_show(sep); | 1055 gtk_widget_show(sep); |
1065 button = gtk_button_new_from_stock(GTK_STOCK_CANCEL); | 1065 button = gtk_button_new_from_stock(GTK_STOCK_CANCEL); |
1066 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | 1066 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); |
1067 gtk_widget_show(button); | 1067 gtk_widget_show(button); |
1068 | 1068 |
1069 g_signal_connect(G_OBJECT(button), "clicked", | 1069 g_signal_connect(G_OBJECT(button), "clicked", |
1070 G_CALLBACK(__cancel_account_prefs_cb), dialog); | 1070 G_CALLBACK(cancel_account_prefs_cb), dialog); |
1071 | 1071 |
1072 /* OK button */ | 1072 /* OK button */ |
1073 button = gtk_button_new_from_stock(GTK_STOCK_OK); | 1073 button = gtk_button_new_from_stock(GTK_STOCK_OK); |
1074 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | 1074 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); |
1075 | 1075 |
1079 gtk_widget_show(button); | 1079 gtk_widget_show(button); |
1080 | 1080 |
1081 dialog->ok_button = button; | 1081 dialog->ok_button = button; |
1082 | 1082 |
1083 g_signal_connect(G_OBJECT(button), "clicked", | 1083 g_signal_connect(G_OBJECT(button), "clicked", |
1084 G_CALLBACK(__ok_account_prefs_cb), dialog); | 1084 G_CALLBACK(ok_account_prefs_cb), dialog); |
1085 | 1085 |
1086 /* Show the window. */ | 1086 /* Show the window. */ |
1087 gtk_widget_show(win); | 1087 gtk_widget_show(win); |
1088 } | 1088 } |
1089 | 1089 |
1090 /************************************************************************** | 1090 /************************************************************************** |
1091 * Accounts Dialog | 1091 * Accounts Dialog |
1092 **************************************************************************/ | 1092 **************************************************************************/ |
1093 | 1093 |
1094 static void | 1094 static void |
1095 __signed_on_off_cb(GaimConnection *gc, AccountsDialog *dialog) | 1095 signed_on_off_cb(GaimConnection *gc, AccountsDialog *dialog) |
1096 { | 1096 { |
1097 GaimAccount *account = gaim_connection_get_account(gc); | 1097 GaimAccount *account = gaim_connection_get_account(gc); |
1098 GtkTreeModel *model = GTK_TREE_MODEL(dialog->model); | 1098 GtkTreeModel *model = GTK_TREE_MODEL(dialog->model); |
1099 GtkTreeIter iter; | 1099 GtkTreeIter iter; |
1100 size_t index = g_list_index(gaim_accounts_get_all(), account); | 1100 size_t index = g_list_index(gaim_accounts_get_all(), account); |
1105 -1); | 1105 -1); |
1106 } | 1106 } |
1107 } | 1107 } |
1108 | 1108 |
1109 static void | 1109 static void |
1110 __drag_data_get_cb(GtkWidget *widget, GdkDragContext *ctx, | 1110 drag_data_get_cb(GtkWidget *widget, GdkDragContext *ctx, |
1111 GtkSelectionData *data, guint info, guint time, | 1111 GtkSelectionData *data, guint info, guint time, |
1112 AccountsDialog *dialog) | 1112 AccountsDialog *dialog) |
1113 { | 1113 { |
1114 if (data->target == gdk_atom_intern("GAIM_ACCOUNT", FALSE)) { | 1114 if (data->target == gdk_atom_intern("GAIM_ACCOUNT", FALSE)) { |
1115 GtkTreeRowReference *ref; | 1115 GtkTreeRowReference *ref; |
1139 gtk_tree_path_free(source_row); | 1139 gtk_tree_path_free(source_row); |
1140 } | 1140 } |
1141 } | 1141 } |
1142 | 1142 |
1143 static void | 1143 static void |
1144 __drag_data_received_cb(GtkWidget *widget, GdkDragContext *ctx, | 1144 drag_data_received_cb(GtkWidget *widget, GdkDragContext *ctx, |
1145 guint x, guint y, GtkSelectionData *sd, | 1145 guint x, guint y, GtkSelectionData *sd, |
1146 guint info, guint t, AccountsDialog *dialog) | 1146 guint info, guint t, AccountsDialog *dialog) |
1147 { | 1147 { |
1148 if (sd->target == gdk_atom_intern("GAIM_ACCOUNT", FALSE) && sd->data) { | 1148 if (sd->target == gdk_atom_intern("GAIM_ACCOUNT", FALSE) && sd->data) { |
1149 size_t dest_index; | 1149 size_t dest_index; |
1215 } | 1215 } |
1216 } | 1216 } |
1217 } | 1217 } |
1218 | 1218 |
1219 static gint | 1219 static gint |
1220 __accedit_win_destroy_cb(GtkWidget *w, GdkEvent *event, AccountsDialog *dialog) | 1220 accedit_win_destroy_cb(GtkWidget *w, GdkEvent *event, AccountsDialog *dialog) |
1221 { | 1221 { |
1222 gaim_signals_disconnect_by_handle(dialog); | 1222 gaim_signals_disconnect_by_handle(dialog); |
1223 | 1223 |
1224 g_free(accounts_dialog); | 1224 g_free(accounts_dialog); |
1225 accounts_dialog = NULL; | 1225 accounts_dialog = NULL; |
1234 | 1234 |
1235 return FALSE; | 1235 return FALSE; |
1236 } | 1236 } |
1237 | 1237 |
1238 static gboolean | 1238 static gboolean |
1239 __configure_cb(GtkWidget *w, GdkEventConfigure *event, AccountsDialog *dialog) | 1239 configure_cb(GtkWidget *w, GdkEventConfigure *event, AccountsDialog *dialog) |
1240 { | 1240 { |
1241 if (GTK_WIDGET_VISIBLE(w)) { | 1241 if (GTK_WIDGET_VISIBLE(w)) { |
1242 int old_width = gaim_prefs_get_int("/gaim/gtk/accounts/dialog/width"); | 1242 int old_width = gaim_prefs_get_int("/gaim/gtk/accounts/dialog/width"); |
1243 int col_width; | 1243 int col_width; |
1244 int difference; | 1244 int difference; |
1267 | 1267 |
1268 return FALSE; | 1268 return FALSE; |
1269 } | 1269 } |
1270 | 1270 |
1271 static void | 1271 static void |
1272 __add_account_cb(GtkWidget *w, AccountsDialog *dialog) | 1272 add_account_cb(GtkWidget *w, AccountsDialog *dialog) |
1273 { | 1273 { |
1274 __show_account_prefs(ADD_ACCOUNT_DIALOG, dialog, NULL); | 1274 show_account_prefs(ADD_ACCOUNT_DIALOG, dialog, NULL); |
1275 } | 1275 } |
1276 | 1276 |
1277 static void | 1277 static void |
1278 __modify_account_sel(GtkTreeModel *model, GtkTreePath *path, | 1278 modify_account_sel(GtkTreeModel *model, GtkTreePath *path, |
1279 GtkTreeIter *iter, gpointer data) | 1279 GtkTreeIter *iter, gpointer data) |
1280 { | 1280 { |
1281 GaimAccount *account; | 1281 GaimAccount *account; |
1282 | 1282 |
1283 gtk_tree_model_get(model, iter, COLUMN_DATA, &account, -1); | 1283 gtk_tree_model_get(model, iter, COLUMN_DATA, &account, -1); |
1284 | 1284 |
1285 if (account != NULL) | 1285 if (account != NULL) |
1286 __show_account_prefs(MODIFY_ACCOUNT_DIALOG, data, account); | 1286 show_account_prefs(MODIFY_ACCOUNT_DIALOG, data, account); |
1287 } | 1287 } |
1288 | 1288 |
1289 static void | 1289 static void |
1290 __modify_account_cb(GtkWidget *w, AccountsDialog *dialog) | 1290 modify_account_cb(GtkWidget *w, AccountsDialog *dialog) |
1291 { | 1291 { |
1292 GtkTreeSelection *selection; | 1292 GtkTreeSelection *selection; |
1293 | 1293 |
1294 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview)); | 1294 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview)); |
1295 | 1295 |
1296 gtk_tree_selection_selected_foreach(selection, __modify_account_sel, | 1296 gtk_tree_selection_selected_foreach(selection, modify_account_sel, |
1297 dialog); | 1297 dialog); |
1298 } | 1298 } |
1299 | 1299 |
1300 static void | 1300 static void |
1301 __delete_account_cb(GaimAccount *account) | 1301 delete_account_cb(GaimAccount *account) |
1302 { | 1302 { |
1303 size_t index; | 1303 size_t index; |
1304 GtkTreeIter iter; | 1304 GtkTreeIter iter; |
1305 | 1305 |
1306 index = g_list_index(gaim_accounts_get_all(), account); | 1306 index = g_list_index(gaim_accounts_get_all(), account); |
1314 gaim_accounts_remove(account); | 1314 gaim_accounts_remove(account); |
1315 gaim_account_destroy(account); | 1315 gaim_account_destroy(account); |
1316 } | 1316 } |
1317 | 1317 |
1318 static void | 1318 static void |
1319 __ask_delete_account_sel(GtkTreeModel *model, GtkTreePath *path, | 1319 ask_delete_account_sel(GtkTreeModel *model, GtkTreePath *path, |
1320 GtkTreeIter *iter, gpointer data) | 1320 GtkTreeIter *iter, gpointer data) |
1321 { | 1321 { |
1322 GaimAccount *account; | 1322 GaimAccount *account; |
1323 | 1323 |
1324 gtk_tree_model_get(model, iter, COLUMN_DATA, &account, -1); | 1324 gtk_tree_model_get(model, iter, COLUMN_DATA, &account, -1); |
1329 g_snprintf(buf, sizeof(buf), | 1329 g_snprintf(buf, sizeof(buf), |
1330 _("Are you sure you want to delete %s?"), | 1330 _("Are you sure you want to delete %s?"), |
1331 gaim_account_get_username(account)); | 1331 gaim_account_get_username(account)); |
1332 | 1332 |
1333 gaim_request_action(NULL, NULL, buf, NULL, 1, account, 2, | 1333 gaim_request_action(NULL, NULL, buf, NULL, 1, account, 2, |
1334 _("Delete"), __delete_account_cb, | 1334 _("Delete"), delete_account_cb, |
1335 _("Cancel"), NULL); | 1335 _("Cancel"), NULL); |
1336 } | 1336 } |
1337 } | 1337 } |
1338 | 1338 |
1339 static void | 1339 static void |
1340 __ask_delete_account_cb(GtkWidget *w, AccountsDialog *dialog) | 1340 ask_delete_account_cb(GtkWidget *w, AccountsDialog *dialog) |
1341 { | 1341 { |
1342 GtkTreeSelection *selection; | 1342 GtkTreeSelection *selection; |
1343 | 1343 |
1344 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview)); | 1344 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview)); |
1345 | 1345 |
1346 gtk_tree_selection_selected_foreach(selection, __ask_delete_account_sel, | 1346 gtk_tree_selection_selected_foreach(selection, ask_delete_account_sel, |
1347 dialog); | 1347 dialog); |
1348 } | 1348 } |
1349 | 1349 |
1350 static void | 1350 static void |
1351 __close_accounts_cb(GtkWidget *w, AccountsDialog *dialog) | 1351 close_accounts_cb(GtkWidget *w, AccountsDialog *dialog) |
1352 { | 1352 { |
1353 gtk_widget_destroy(dialog->window); | 1353 gtk_widget_destroy(dialog->window); |
1354 | 1354 |
1355 __accedit_win_destroy_cb(NULL, NULL, dialog); | 1355 accedit_win_destroy_cb(NULL, NULL, dialog); |
1356 } | 1356 } |
1357 | 1357 |
1358 static void | 1358 static void |
1359 __online_cb(GtkCellRendererToggle *renderer, gchar *path_str, gpointer data) | 1359 online_cb(GtkCellRendererToggle *renderer, gchar *path_str, gpointer data) |
1360 { | 1360 { |
1361 AccountsDialog *dialog = (AccountsDialog *)data; | 1361 AccountsDialog *dialog = (AccountsDialog *)data; |
1362 GaimAccount *account; | 1362 GaimAccount *account; |
1363 GtkTreeModel *model = GTK_TREE_MODEL(dialog->model); | 1363 GtkTreeModel *model = GTK_TREE_MODEL(dialog->model); |
1364 GtkTreeIter iter; | 1364 GtkTreeIter iter; |
1375 else | 1375 else |
1376 gaim_account_connect(account); | 1376 gaim_account_connect(account); |
1377 } | 1377 } |
1378 | 1378 |
1379 static void | 1379 static void |
1380 __autologin_cb(GtkCellRendererToggle *renderer, gchar *path_str, | 1380 autologin_cb(GtkCellRendererToggle *renderer, gchar *path_str, |
1381 gpointer data) | 1381 gpointer data) |
1382 { | 1382 { |
1383 | 1383 |
1384 } | 1384 } |
1385 | 1385 |
1386 static void | 1386 static void |
1387 __add_columns(GtkWidget *treeview, AccountsDialog *dialog) | 1387 add_columns(GtkWidget *treeview, AccountsDialog *dialog) |
1388 { | 1388 { |
1389 GtkCellRenderer *renderer; | 1389 GtkCellRenderer *renderer; |
1390 GtkTreeViewColumn *column; | 1390 GtkTreeViewColumn *column; |
1391 | 1391 |
1392 /* Protocol */ | 1392 /* Protocol */ |
1393 column = gtk_tree_view_column_new(); | 1393 column = gtk_tree_view_column_new(); |
1394 gtk_tree_view_column_set_title(column, _("Protocol")); | 1394 gtk_tree_view_column_set_title(column, _("Screenname")); |
1395 gtk_tree_view_insert_column(GTK_TREE_VIEW(treeview), column, -1); | 1395 gtk_tree_view_insert_column(GTK_TREE_VIEW(treeview), column, -1); |
1396 | 1396 |
1397 /* Icon text */ | 1397 /* Icon text */ |
1398 renderer = gtk_cell_renderer_pixbuf_new(); | 1398 renderer = gtk_cell_renderer_pixbuf_new(); |
1399 gtk_tree_view_column_pack_start(column, renderer, FALSE); | 1399 gtk_tree_view_column_pack_start(column, renderer, FALSE); |
1400 gtk_tree_view_column_add_attribute(column, renderer, | 1400 gtk_tree_view_column_add_attribute(column, renderer, |
1401 "pixbuf", COLUMN_ICON); | 1401 "pixbuf", COLUMN_ICON); |
1402 | 1402 |
1403 /* Screennames */ | |
1404 renderer = gtk_cell_renderer_text_new(); | |
1405 gtk_tree_view_column_pack_start(column, renderer, TRUE); | |
1406 gtk_tree_view_column_add_attribute(column, renderer, | |
1407 "text", COLUMN_SCREENNAME); | |
1408 dialog->screenname_col = column; | |
1409 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); | |
1410 | |
1403 /* Protocol name */ | 1411 /* Protocol name */ |
1412 column = gtk_tree_view_column_new(); | |
1413 gtk_tree_view_column_set_title(column, _("Protocol")); | |
1414 gtk_tree_view_insert_column(GTK_TREE_VIEW(treeview), column, -1); | |
1415 | |
1404 renderer = gtk_cell_renderer_text_new(); | 1416 renderer = gtk_cell_renderer_text_new(); |
1405 gtk_tree_view_column_pack_start(column, renderer, TRUE); | 1417 gtk_tree_view_column_pack_start(column, renderer, TRUE); |
1406 gtk_tree_view_column_add_attribute(column, renderer, | 1418 gtk_tree_view_column_add_attribute(column, renderer, |
1407 "text", COLUMN_PROTOCOL); | 1419 "text", COLUMN_PROTOCOL); |
1408 | 1420 |
1409 /* Screennames */ | |
1410 renderer = gtk_cell_renderer_text_new(); | |
1411 column = gtk_tree_view_column_new_with_attributes(_("Screenname"), | |
1412 renderer, "text", COLUMN_SCREENNAME, NULL); | |
1413 dialog->screenname_col = column; | |
1414 | |
1415 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); | |
1416 gtk_tree_view_insert_column(GTK_TREE_VIEW(treeview), column, -1); | |
1417 | |
1418 /* Online? */ | 1421 /* Online? */ |
1419 renderer = gtk_cell_renderer_toggle_new(); | 1422 renderer = gtk_cell_renderer_toggle_new(); |
1420 | 1423 |
1421 g_signal_connect(G_OBJECT(renderer), "toggled", | 1424 g_signal_connect(G_OBJECT(renderer), "toggled", |
1422 G_CALLBACK(__online_cb), dialog); | 1425 G_CALLBACK(online_cb), dialog); |
1423 | 1426 |
1424 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeview), | 1427 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeview), |
1425 -1, _("Online"), | 1428 -1, _("Online"), |
1426 renderer, | 1429 renderer, |
1427 "active", COLUMN_ONLINE, | 1430 "active", COLUMN_ONLINE, |
1429 | 1432 |
1430 /* Auto-login? */ | 1433 /* Auto-login? */ |
1431 renderer = gtk_cell_renderer_toggle_new(); | 1434 renderer = gtk_cell_renderer_toggle_new(); |
1432 | 1435 |
1433 g_signal_connect(G_OBJECT(renderer), "toggled", | 1436 g_signal_connect(G_OBJECT(renderer), "toggled", |
1434 G_CALLBACK(__autologin_cb), dialog); | 1437 G_CALLBACK(autologin_cb), dialog); |
1435 | 1438 |
1436 column = gtk_tree_view_column_new_with_attributes(_("Auto-login"), | 1439 column = gtk_tree_view_column_new_with_attributes(_("Auto-login"), |
1437 renderer, "active", COLUMN_AUTOLOGIN, NULL); | 1440 renderer, "active", COLUMN_AUTOLOGIN, NULL); |
1438 | 1441 |
1439 gtk_tree_view_insert_column(GTK_TREE_VIEW(treeview), column, -1); | 1442 gtk_tree_view_insert_column(GTK_TREE_VIEW(treeview), column, -1); |
1440 g_object_set(renderer, "xalign", 0.0, "xpad", 10, NULL); | 1443 g_object_set(renderer, "xalign", 0.0, "xpad", 10, NULL); |
1441 } | 1444 } |
1442 | 1445 |
1443 static void | 1446 static void |
1444 __set_account(GtkListStore *store, GtkTreeIter *iter, GaimAccount *account) | 1447 set_account(GtkListStore *store, GtkTreeIter *iter, GaimAccount *account) |
1445 { | 1448 { |
1446 GdkPixbuf *pixbuf; | 1449 GdkPixbuf *pixbuf; |
1447 GdkPixbuf *scale; | 1450 GdkPixbuf *scale; |
1448 | 1451 |
1449 scale = NULL; | 1452 scale = NULL; |
1465 if (pixbuf != NULL) g_object_unref(G_OBJECT(pixbuf)); | 1468 if (pixbuf != NULL) g_object_unref(G_OBJECT(pixbuf)); |
1466 if (scale != NULL) g_object_unref(G_OBJECT(scale)); | 1469 if (scale != NULL) g_object_unref(G_OBJECT(scale)); |
1467 } | 1470 } |
1468 | 1471 |
1469 static void | 1472 static void |
1470 __add_account(AccountsDialog *dialog, GaimAccount *account) | 1473 add_account(AccountsDialog *dialog, GaimAccount *account) |
1471 { | 1474 { |
1472 GtkTreeIter iter; | 1475 GtkTreeIter iter; |
1473 | 1476 |
1474 gtk_list_store_append(dialog->model, &iter); | 1477 gtk_list_store_append(dialog->model, &iter); |
1475 | 1478 |
1476 __set_account(dialog->model, &iter, account); | 1479 set_account(dialog->model, &iter, account); |
1477 } | 1480 } |
1478 | 1481 |
1479 static void | 1482 static void |
1480 __populate_accounts_list(AccountsDialog *dialog) | 1483 populate_accounts_list(AccountsDialog *dialog) |
1481 { | 1484 { |
1482 GList *l; | 1485 GList *l; |
1483 | 1486 |
1484 gtk_list_store_clear(dialog->model); | 1487 gtk_list_store_clear(dialog->model); |
1485 | 1488 |
1486 for (l = gaim_accounts_get_all(); l != NULL; l = l->next) | 1489 for (l = gaim_accounts_get_all(); l != NULL; l = l->next) |
1487 __add_account(dialog, (GaimAccount *)l->data); | 1490 add_account(dialog, (GaimAccount *)l->data); |
1488 } | 1491 } |
1489 | 1492 |
1490 static void | 1493 static void |
1491 __account_selected_cb(GtkTreeSelection *sel, AccountsDialog *dialog) | 1494 account_selected_cb(GtkTreeSelection *sel, AccountsDialog *dialog) |
1492 { | 1495 { |
1493 gtk_widget_set_sensitive(dialog->modify_button, TRUE); | 1496 gtk_widget_set_sensitive(dialog->modify_button, TRUE); |
1494 gtk_widget_set_sensitive(dialog->delete_button, TRUE); | 1497 gtk_widget_set_sensitive(dialog->delete_button, TRUE); |
1495 } | 1498 } |
1496 | 1499 |
1497 static GtkWidget * | 1500 static GtkWidget * |
1498 __create_accounts_list(AccountsDialog *dialog) | 1501 create_accounts_list(AccountsDialog *dialog) |
1499 { | 1502 { |
1500 GtkWidget *sw; | 1503 GtkWidget *sw; |
1501 GtkWidget *treeview; | 1504 GtkWidget *treeview; |
1502 GtkTreeSelection *sel; | 1505 GtkTreeSelection *sel; |
1503 GtkTargetEntry gte[] = {{"GAIM_ACCOUNT", GTK_TARGET_SAME_APP, 0}}; | 1506 GtkTargetEntry gte[] = {{"GAIM_ACCOUNT", GTK_TARGET_SAME_APP, 0}}; |
1526 GTK_SELECTION_MULTIPLE); | 1529 GTK_SELECTION_MULTIPLE); |
1527 | 1530 |
1528 gtk_container_add(GTK_CONTAINER(sw), treeview); | 1531 gtk_container_add(GTK_CONTAINER(sw), treeview); |
1529 gtk_widget_show(treeview); | 1532 gtk_widget_show(treeview); |
1530 | 1533 |
1531 __add_columns(treeview, dialog); | 1534 add_columns(treeview, dialog); |
1532 | 1535 |
1533 __populate_accounts_list(dialog); | 1536 populate_accounts_list(dialog); |
1534 | 1537 |
1535 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); | 1538 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); |
1536 g_signal_connect(G_OBJECT(sel), "changed", | 1539 g_signal_connect(G_OBJECT(sel), "changed", |
1537 G_CALLBACK(__account_selected_cb), dialog); | 1540 G_CALLBACK(account_selected_cb), dialog); |
1538 | 1541 |
1539 /* Setup DND. I wanna be an orc! */ | 1542 /* Setup DND. I wanna be an orc! */ |
1540 gtk_tree_view_enable_model_drag_source( | 1543 gtk_tree_view_enable_model_drag_source( |
1541 GTK_TREE_VIEW(treeview), GDK_BUTTON1_MASK, gte, | 1544 GTK_TREE_VIEW(treeview), GDK_BUTTON1_MASK, gte, |
1542 2, GDK_ACTION_COPY); | 1545 2, GDK_ACTION_COPY); |
1543 gtk_tree_view_enable_model_drag_dest( | 1546 gtk_tree_view_enable_model_drag_dest( |
1544 GTK_TREE_VIEW(treeview), gte, 2, | 1547 GTK_TREE_VIEW(treeview), gte, 2, |
1545 GDK_ACTION_COPY | GDK_ACTION_MOVE); | 1548 GDK_ACTION_COPY | GDK_ACTION_MOVE); |
1546 | 1549 |
1547 g_signal_connect(G_OBJECT(treeview), "drag-data-received", | 1550 g_signal_connect(G_OBJECT(treeview), "drag-data-received", |
1548 G_CALLBACK(__drag_data_received_cb), dialog); | 1551 G_CALLBACK(drag_data_received_cb), dialog); |
1549 g_signal_connect(G_OBJECT(treeview), "drag-data-get", | 1552 g_signal_connect(G_OBJECT(treeview), "drag-data-get", |
1550 G_CALLBACK(__drag_data_get_cb), dialog); | 1553 G_CALLBACK(drag_data_get_cb), dialog); |
1551 | 1554 |
1552 return sw; | 1555 return sw; |
1553 } | 1556 } |
1554 | 1557 |
1555 void | 1558 void |
1580 gtk_window_set_role(GTK_WINDOW(win), "accounts"); | 1583 gtk_window_set_role(GTK_WINDOW(win), "accounts"); |
1581 gtk_window_set_title(GTK_WINDOW(win), _("Accounts")); | 1584 gtk_window_set_title(GTK_WINDOW(win), _("Accounts")); |
1582 gtk_container_set_border_width(GTK_CONTAINER(win), 12); | 1585 gtk_container_set_border_width(GTK_CONTAINER(win), 12); |
1583 | 1586 |
1584 g_signal_connect(G_OBJECT(win), "delete_event", | 1587 g_signal_connect(G_OBJECT(win), "delete_event", |
1585 G_CALLBACK(__accedit_win_destroy_cb), accounts_dialog); | 1588 G_CALLBACK(accedit_win_destroy_cb), accounts_dialog); |
1586 g_signal_connect(G_OBJECT(win), "configure_event", | 1589 g_signal_connect(G_OBJECT(win), "configure_event", |
1587 G_CALLBACK(__configure_cb), accounts_dialog); | 1590 G_CALLBACK(configure_cb), accounts_dialog); |
1588 | 1591 |
1589 /* Setup the vbox */ | 1592 /* Setup the vbox */ |
1590 vbox = gtk_vbox_new(FALSE, 12); | 1593 vbox = gtk_vbox_new(FALSE, 12); |
1591 gtk_container_add(GTK_CONTAINER(win), vbox); | 1594 gtk_container_add(GTK_CONTAINER(win), vbox); |
1592 gtk_widget_show(vbox); | 1595 gtk_widget_show(vbox); |
1593 | 1596 |
1594 /* Setup the scrolled window that will contain the list of accounts. */ | 1597 /* Setup the scrolled window that will contain the list of accounts. */ |
1595 sw = __create_accounts_list(dialog); | 1598 sw = create_accounts_list(dialog); |
1596 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); | 1599 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); |
1597 gtk_widget_show(sw); | 1600 gtk_widget_show(sw); |
1598 | 1601 |
1599 /* Separator... */ | 1602 /* Separator... */ |
1600 sep = gtk_hseparator_new(); | 1603 sep = gtk_hseparator_new(); |
1612 button = gtk_button_new_from_stock(GTK_STOCK_ADD); | 1615 button = gtk_button_new_from_stock(GTK_STOCK_ADD); |
1613 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | 1616 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); |
1614 gtk_widget_show(button); | 1617 gtk_widget_show(button); |
1615 | 1618 |
1616 g_signal_connect(G_OBJECT(button), "clicked", | 1619 g_signal_connect(G_OBJECT(button), "clicked", |
1617 G_CALLBACK(__add_account_cb), dialog); | 1620 G_CALLBACK(add_account_cb), dialog); |
1618 | 1621 |
1619 /* Modify button */ | 1622 /* Modify button */ |
1620 button = gtk_button_new_from_stock(GAIM_STOCK_MODIFY); | 1623 button = gtk_button_new_from_stock(GAIM_STOCK_MODIFY); |
1621 dialog->modify_button = button; | 1624 dialog->modify_button = button; |
1622 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | 1625 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); |
1623 gtk_widget_set_sensitive(button, FALSE); | 1626 gtk_widget_set_sensitive(button, FALSE); |
1624 gtk_widget_show(button); | 1627 gtk_widget_show(button); |
1625 | 1628 |
1626 g_signal_connect(G_OBJECT(button), "clicked", | 1629 g_signal_connect(G_OBJECT(button), "clicked", |
1627 G_CALLBACK(__modify_account_cb), dialog); | 1630 G_CALLBACK(modify_account_cb), dialog); |
1628 | 1631 |
1629 /* Delete button */ | 1632 /* Delete button */ |
1630 button = gtk_button_new_from_stock(GTK_STOCK_DELETE); | 1633 button = gtk_button_new_from_stock(GTK_STOCK_DELETE); |
1631 dialog->delete_button = button; | 1634 dialog->delete_button = button; |
1632 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | 1635 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); |
1633 gtk_widget_set_sensitive(button, FALSE); | 1636 gtk_widget_set_sensitive(button, FALSE); |
1634 gtk_widget_show(button); | 1637 gtk_widget_show(button); |
1635 | 1638 |
1636 g_signal_connect(G_OBJECT(button), "clicked", | 1639 g_signal_connect(G_OBJECT(button), "clicked", |
1637 G_CALLBACK(__ask_delete_account_cb), dialog); | 1640 G_CALLBACK(ask_delete_account_cb), dialog); |
1638 | 1641 |
1639 /* Close button */ | 1642 /* Close button */ |
1640 button = gtk_button_new_from_stock(GTK_STOCK_CLOSE); | 1643 button = gtk_button_new_from_stock(GTK_STOCK_CLOSE); |
1641 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | 1644 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); |
1642 gtk_widget_show(button); | 1645 gtk_widget_show(button); |
1643 | 1646 |
1644 g_signal_connect(G_OBJECT(button), "clicked", | 1647 g_signal_connect(G_OBJECT(button), "clicked", |
1645 G_CALLBACK(__close_accounts_cb), dialog); | 1648 G_CALLBACK(close_accounts_cb), dialog); |
1646 | 1649 |
1647 /* Setup some gaim signal handlers. */ | 1650 /* Setup some gaim signal handlers. */ |
1648 gaim_signal_connect(dialog, event_signon, __signed_on_off_cb, dialog); | 1651 gaim_signal_connect(dialog, event_signon, signed_on_off_cb, dialog); |
1649 gaim_signal_connect(dialog, event_signoff, __signed_on_off_cb, dialog); | 1652 gaim_signal_connect(dialog, event_signoff, signed_on_off_cb, dialog); |
1650 | 1653 |
1651 gtk_widget_show(win); | 1654 gtk_widget_show(win); |
1652 } | 1655 } |
1653 | 1656 |