Mercurial > pidgin.yaz
comparison src/gtkaccount.c @ 5703:cee14870644c
[gaim-migrate @ 6124]
Added some niceties, like the OK, Delete, and Modify buttons only being
clickable when something is selected or entered or whatever. Also, some bug
fixes. I had too many sanity checks. Some I did not want.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Tue, 03 Jun 2003 10:15:29 +0000 |
parents | 05858c215226 |
children | cd408d69ad2e |
comparison
equal
deleted
inserted
replaced
5702:05858c215226 | 5703:cee14870644c |
---|---|
60 typedef struct | 60 typedef struct |
61 { | 61 { |
62 GtkWidget *window; | 62 GtkWidget *window; |
63 GtkWidget *treeview; | 63 GtkWidget *treeview; |
64 | 64 |
65 GtkWidget *modify_button; | |
66 GtkWidget *delete_button; | |
67 | |
65 GtkListStore *model; | 68 GtkListStore *model; |
66 GtkTreeIter drag_iter; | 69 GtkTreeIter drag_iter; |
67 | 70 |
68 GtkTreeViewColumn *screenname_col; | 71 GtkTreeViewColumn *screenname_col; |
69 | 72 |
88 GtkSizeGroup *sg; | 91 GtkSizeGroup *sg; |
89 GtkWidget *window; | 92 GtkWidget *window; |
90 | 93 |
91 GtkWidget *top_vbox; | 94 GtkWidget *top_vbox; |
92 GtkWidget *bottom_vbox; | 95 GtkWidget *bottom_vbox; |
96 GtkWidget *ok_button; | |
93 | 97 |
94 /* Login Options */ | 98 /* Login Options */ |
95 GtkWidget *login_frame; | 99 GtkWidget *login_frame; |
96 GtkWidget *protocol_menu; | 100 GtkWidget *protocol_menu; |
97 GtkWidget *password_box; | 101 GtkWidget *password_box; |
183 __add_user_options(dialog, dialog->top_vbox); | 187 __add_user_options(dialog, dialog->top_vbox); |
184 __add_protocol_options(dialog, dialog->bottom_vbox); | 188 __add_protocol_options(dialog, dialog->bottom_vbox); |
185 } | 189 } |
186 | 190 |
187 static void | 191 static void |
192 __screenname_changed_cb(GtkEntry *entry, AccountPrefsDialog *dialog) | |
193 { | |
194 if (dialog->ok_button == NULL) | |
195 return; | |
196 | |
197 gtk_widget_set_sensitive(dialog->ok_button, | |
198 *gtk_entry_get_text(entry) != '\0'); | |
199 } | |
200 | |
201 static void | |
188 __add_login_options(AccountPrefsDialog *dialog, GtkWidget *parent) | 202 __add_login_options(AccountPrefsDialog *dialog, GtkWidget *parent) |
189 { | 203 { |
190 GtkWidget *frame; | 204 GtkWidget *frame; |
191 GtkWidget *vbox; | 205 GtkWidget *vbox; |
192 GtkWidget *entry; | 206 GtkWidget *entry; |
219 | 233 |
220 /* Screen Name */ | 234 /* Screen Name */ |
221 dialog->screenname_entry = gtk_entry_new(); | 235 dialog->screenname_entry = gtk_entry_new(); |
222 | 236 |
223 __add_pref_box(dialog, vbox, _("Screenname:"), dialog->screenname_entry); | 237 __add_pref_box(dialog, vbox, _("Screenname:"), dialog->screenname_entry); |
238 | |
239 g_signal_connect(G_OBJECT(dialog->screenname_entry), "changed", | |
240 G_CALLBACK(__screenname_changed_cb), dialog); | |
224 | 241 |
225 /* Do the user split thang */ | 242 /* Do the user split thang */ |
226 if (dialog->plugin == NULL) /* Yeah right. */ | 243 if (dialog->plugin == NULL) /* Yeah right. */ |
227 user_splits = NULL; | 244 user_splits = NULL; |
228 else | 245 else |
627 else | 644 else |
628 gtk_widget_show_all(dialog->proxy_vbox); | 645 gtk_widget_show_all(dialog->proxy_vbox); |
629 } | 646 } |
630 | 647 |
631 static void | 648 static void |
649 __port_popup_cb(GtkWidget *w, GtkMenu *menu, gpointer data) | |
650 { | |
651 GtkWidget *item; | |
652 | |
653 item = gtk_menu_item_new_with_label( | |
654 _("you can see the butterflies mating")); | |
655 gtk_widget_show(item); | |
656 gtk_menu_shell_prepend(GTK_MENU_SHELL(menu), item); | |
657 | |
658 item = gtk_menu_item_new_with_label(_("If you look real closely")); | |
659 gtk_widget_show(item); | |
660 gtk_menu_shell_prepend(GTK_MENU_SHELL(menu), item); | |
661 } | |
662 | |
663 static void | |
632 __add_proxy_options(AccountPrefsDialog *dialog, GtkWidget *parent) | 664 __add_proxy_options(AccountPrefsDialog *dialog, GtkWidget *parent) |
633 { | 665 { |
634 GaimProxyInfo *proxy_info; | 666 GaimProxyInfo *proxy_info; |
635 GtkWidget *frame; | 667 GtkWidget *frame; |
636 GtkWidget *vbox; | 668 GtkWidget *vbox; |
668 | 700 |
669 /* Port */ | 701 /* Port */ |
670 dialog->proxy_port_entry = gtk_entry_new(); | 702 dialog->proxy_port_entry = gtk_entry_new(); |
671 __add_pref_box(dialog, vbox2, _("_Port:"), dialog->proxy_port_entry); | 703 __add_pref_box(dialog, vbox2, _("_Port:"), dialog->proxy_port_entry); |
672 | 704 |
705 g_signal_connect(G_OBJECT(dialog->proxy_port_entry), "populate-popup", | |
706 G_CALLBACK(__port_popup_cb), NULL); | |
707 | |
673 /* User */ | 708 /* User */ |
674 dialog->proxy_user_entry = gtk_entry_new(); | 709 dialog->proxy_user_entry = gtk_entry_new(); |
710 | |
675 __add_pref_box(dialog, vbox2, _("_Username:"), dialog->proxy_user_entry); | 711 __add_pref_box(dialog, vbox2, _("_Username:"), dialog->proxy_user_entry); |
676 | 712 |
677 /* Password */ | 713 /* Password */ |
678 dialog->proxy_pass_entry = gtk_entry_new(); | 714 dialog->proxy_pass_entry = gtk_entry_new(); |
679 gtk_entry_set_visibility(GTK_ENTRY(dialog->proxy_pass_entry), FALSE); | 715 gtk_entry_set_visibility(GTK_ENTRY(dialog->proxy_pass_entry), FALSE); |
924 } | 960 } |
925 | 961 |
926 gtk_widget_destroy(dialog->window); | 962 gtk_widget_destroy(dialog->window); |
927 | 963 |
928 __account_win_destroy_cb(NULL, NULL, dialog); | 964 __account_win_destroy_cb(NULL, NULL, dialog); |
965 | |
966 gaim_accounts_sync(); | |
929 } | 967 } |
930 | 968 |
931 static void | 969 static void |
932 __show_account_prefs(AccountPrefsDialogType type, | 970 __show_account_prefs(AccountPrefsDialogType type, |
933 AccountsDialog *accounts_dialog, | 971 AccountsDialog *accounts_dialog, |
1025 G_CALLBACK(__cancel_account_prefs_cb), dialog); | 1063 G_CALLBACK(__cancel_account_prefs_cb), dialog); |
1026 | 1064 |
1027 /* OK button */ | 1065 /* OK button */ |
1028 button = gtk_button_new_from_stock(GTK_STOCK_OK); | 1066 button = gtk_button_new_from_stock(GTK_STOCK_OK); |
1029 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | 1067 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); |
1068 | |
1069 if (dialog->account == NULL) | |
1070 gtk_widget_set_sensitive(button, FALSE); | |
1071 | |
1030 gtk_widget_show(button); | 1072 gtk_widget_show(button); |
1073 | |
1074 dialog->ok_button = button; | |
1031 | 1075 |
1032 g_signal_connect(G_OBJECT(button), "clicked", | 1076 g_signal_connect(G_OBJECT(button), "clicked", |
1033 G_CALLBACK(__ok_account_prefs_cb), dialog); | 1077 G_CALLBACK(__ok_account_prefs_cb), dialog); |
1034 | 1078 |
1035 /* Show the window. */ | 1079 /* Show the window. */ |
1431 | 1475 |
1432 for (l = gaim_accounts_get_all(); l != NULL; l = l->next) | 1476 for (l = gaim_accounts_get_all(); l != NULL; l = l->next) |
1433 __add_account(dialog, (GaimAccount *)l->data); | 1477 __add_account(dialog, (GaimAccount *)l->data); |
1434 } | 1478 } |
1435 | 1479 |
1480 static void | |
1481 __account_selected_cb(GtkTreeSelection *sel, AccountsDialog *dialog) | |
1482 { | |
1483 gtk_widget_set_sensitive(dialog->modify_button, TRUE); | |
1484 gtk_widget_set_sensitive(dialog->delete_button, TRUE); | |
1485 } | |
1486 | |
1436 static GtkWidget * | 1487 static GtkWidget * |
1437 __create_accounts_list(AccountsDialog *dialog) | 1488 __create_accounts_list(AccountsDialog *dialog) |
1438 { | 1489 { |
1439 GtkWidget *sw; | 1490 GtkWidget *sw; |
1440 GtkWidget *treeview; | 1491 GtkWidget *treeview; |
1492 GtkTreeSelection *sel; | |
1441 GtkTargetEntry gte[] = {{"GAIM_ACCOUNT", GTK_TARGET_SAME_APP, 0}}; | 1493 GtkTargetEntry gte[] = {{"GAIM_ACCOUNT", GTK_TARGET_SAME_APP, 0}}; |
1442 | 1494 |
1443 /* Create the scrolled window. */ | 1495 /* Create the scrolled window. */ |
1444 sw = gtk_scrolled_window_new(0, 0); | 1496 sw = gtk_scrolled_window_new(0, 0); |
1445 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | 1497 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), |
1468 | 1520 |
1469 __add_columns(treeview, dialog); | 1521 __add_columns(treeview, dialog); |
1470 | 1522 |
1471 __populate_accounts_list(dialog); | 1523 __populate_accounts_list(dialog); |
1472 | 1524 |
1525 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); | |
1526 g_signal_connect(G_OBJECT(sel), "changed", | |
1527 G_CALLBACK(__account_selected_cb), dialog); | |
1528 | |
1473 /* Setup DND. I wanna be an orc! */ | 1529 /* Setup DND. I wanna be an orc! */ |
1474 gtk_tree_view_enable_model_drag_source( | 1530 gtk_tree_view_enable_model_drag_source( |
1475 GTK_TREE_VIEW(treeview), GDK_BUTTON1_MASK, gte, | 1531 GTK_TREE_VIEW(treeview), GDK_BUTTON1_MASK, gte, |
1476 2, GDK_ACTION_COPY); | 1532 2, GDK_ACTION_COPY); |
1477 gtk_tree_view_enable_model_drag_dest( | 1533 gtk_tree_view_enable_model_drag_dest( |
1550 g_signal_connect(G_OBJECT(button), "clicked", | 1606 g_signal_connect(G_OBJECT(button), "clicked", |
1551 G_CALLBACK(__add_account_cb), dialog); | 1607 G_CALLBACK(__add_account_cb), dialog); |
1552 | 1608 |
1553 /* Modify button */ | 1609 /* Modify button */ |
1554 button = gtk_button_new_from_stock(GAIM_STOCK_MODIFY); | 1610 button = gtk_button_new_from_stock(GAIM_STOCK_MODIFY); |
1611 dialog->modify_button = button; | |
1555 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | 1612 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); |
1613 gtk_widget_set_sensitive(button, FALSE); | |
1556 gtk_widget_show(button); | 1614 gtk_widget_show(button); |
1557 | 1615 |
1558 g_signal_connect(G_OBJECT(button), "clicked", | 1616 g_signal_connect(G_OBJECT(button), "clicked", |
1559 G_CALLBACK(__modify_account_cb), dialog); | 1617 G_CALLBACK(__modify_account_cb), dialog); |
1560 | 1618 |
1561 /* Delete button */ | 1619 /* Delete button */ |
1562 button = gtk_button_new_from_stock(GTK_STOCK_DELETE); | 1620 button = gtk_button_new_from_stock(GTK_STOCK_DELETE); |
1621 dialog->delete_button = button; | |
1563 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | 1622 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); |
1623 gtk_widget_set_sensitive(button, FALSE); | |
1564 gtk_widget_show(button); | 1624 gtk_widget_show(button); |
1565 | 1625 |
1566 g_signal_connect(G_OBJECT(button), "clicked", | 1626 g_signal_connect(G_OBJECT(button), "clicked", |
1567 G_CALLBACK(__ask_delete_account_cb), dialog); | 1627 G_CALLBACK(__ask_delete_account_cb), dialog); |
1568 | 1628 |