diff options
author | Jeffrey Stedfast <fejj@helixcode.com> | 2001-01-09 11:31:31 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2001-01-09 11:31:31 +0800 |
commit | a2d998fe1391733fa472f2c142891d31fd81f958 (patch) | |
tree | c554cd3852b61c3166b749097c0be976974526d8 /mail/mail-account-editor.c | |
parent | 20b3bc147ce1de0fe2708236c7915df96d275634 (diff) | |
download | gsoc2013-evolution-a2d998fe1391733fa472f2c142891d31fd81f958.tar.gz gsoc2013-evolution-a2d998fe1391733fa472f2c142891d31fd81f958.tar.zst gsoc2013-evolution-a2d998fe1391733fa472f2c142891d31fd81f958.zip |
Brand spankin' new config druid, editor, and manager.
2001-01-08 Jeffrey Stedfast <fejj@helixcode.com>
* Makefile.am:
* component-factory.c:
* folder-browser-factory.c:
* folder-browser.c:
* mail-accounts.[c,h]:
* mail-account-editor.[c,h]:
* mail-callbacks.c:
* mail-config.[c,h]:
* mail-config-druid.[c,h]:
* mail-config-druid.glade:
* mail-display.c:
* mail-format.c:
* mail-tools.c: Brand spankin' new config druid, editor,
and manager.
svn path=/trunk/; revision=7313
Diffstat (limited to 'mail/mail-account-editor.c')
-rw-r--r-- | mail/mail-account-editor.c | 85 |
1 files changed, 75 insertions, 10 deletions
diff --git a/mail/mail-account-editor.c b/mail/mail-account-editor.c index 6d25d54a0a..a17fc389ad 100644 --- a/mail/mail-account-editor.c +++ b/mail/mail-account-editor.c @@ -86,10 +86,27 @@ mail_account_editor_finalise (GtkObject *obj) ((GtkObjectClass *)(parent_class))->finalize (obj); } +/* callbacks */ static void -apply_clicked (GtkWidget *widget, gpointer data) +entry_changed (GtkEntry *entry, gpointer data) { MailAccountEditor *editor = data; + char *account_name, *name, *address; + gboolean sensitive; + + account_name = gtk_entry_get_text (editor->account_name); + name = gtk_entry_get_text (editor->name); + address = gtk_entry_get_text (editor->email); + + sensitive = account_name && *account_name && name && *name && address && *address; + + gnome_dialog_set_sensitive (GNOME_DIALOG (editor), 0, sensitive); + gnome_dialog_set_sensitive (GNOME_DIALOG (editor), 1, sensitive); +} + +static gboolean +apply_changes (MailAccountEditor *editor) +{ MailConfigAccount *account; char *host, *pport; CamelURL *url; @@ -143,6 +160,14 @@ apply_clicked (GtkWidget *widget, gpointer data) account->source->save_passwd = GTK_TOGGLE_BUTTON (editor->save_passwd)->active; account->source->keep_on_server = GTK_TOGGLE_BUTTON (editor->keep_on_server)->active; + /* check to make sure the source works */ + if (!mail_config_check_service (url, CAMEL_PROVIDER_STORE, NULL)) { + camel_url_free (url); + account_destroy (account); + return FALSE; + } + + /* now that we know this url works, set it */ g_free (account->source->url); account->source->url = camel_url_to_string (url, account->source->save_passwd); camel_url_free (url); @@ -164,19 +189,38 @@ apply_clicked (GtkWidget *widget, gpointer data) url->host = host; url->port = port; + /* check to make sure the transport works */ + if (!mail_config_check_service (url, CAMEL_PROVIDER_TRANSPORT, NULL)) { + camel_url_free (url); + account_destroy (account); + return FALSE; + } + + /* now that we know this url works, set it */ g_free (account->transport->url); account->transport->url = camel_url_to_string (url, FALSE); camel_url_free (url); + + mail_config_write (); + + return TRUE; } static void -ok_clicked (GtkWidget *widget, gpointer data) +apply_clicked (GtkWidget *widget, gpointer data) { MailAccountEditor *editor = data; - apply_clicked (widget, data); + apply_changes (editor); +} + +static void +ok_clicked (GtkWidget *widget, gpointer data) +{ + MailAccountEditor *editor = data; - gtk_widget_destroy (GTK_WIDGET (editor)); + if (apply_changes (editor)) + gtk_widget_destroy (GTK_WIDGET (editor)); } static void @@ -215,17 +259,18 @@ source_auth_init (MailAccountEditor *editor, CamelURL *url) GList *authtypes = NULL; menu = gtk_menu_new (); - gtk_option_menu_set_menu (editor->source_auth, menu); + gtk_option_menu_remove_menu (editor->source_auth); /* If we can't connect, don't let them continue. */ if (!mail_config_check_service (url, CAMEL_PROVIDER_STORE, &authtypes)) { + gtk_option_menu_set_menu (editor->source_auth, menu); + return; } if (authtypes) { GList *l; - menu = gtk_menu_new (); l = authtypes; while (l) { authtype = l->data; @@ -238,13 +283,19 @@ source_auth_init (MailAccountEditor *editor, CamelURL *url) gtk_menu_append (GTK_MENU (menu), item); + gtk_widget_show (item); + if (url->authmech && !g_strcasecmp (authtype->authproto, url->authmech)) authmech = item; + + l = l->next; } if (authmech) gtk_signal_emit_by_name (GTK_OBJECT (authmech), "activate", editor); } + + gtk_option_menu_set_menu (editor->source_auth, menu); } static void @@ -267,17 +318,19 @@ transport_construct_authmenu (MailAccountEditor *editor, CamelURL *url) GList *authtypes = NULL; menu = gtk_menu_new (); - gtk_option_menu_set_menu (editor->transport_auth, menu); + gtk_option_menu_remove_menu (editor->transport_auth); - /* If we can't connect, don't let them continue. */ if (!mail_config_check_service (url, CAMEL_PROVIDER_TRANSPORT, &authtypes)) { + gtk_option_menu_set_menu (editor->transport_auth, menu); + return; } + menu = gtk_menu_new (); + if (authtypes) { GList *l; - menu = gtk_menu_new (); l = authtypes; while (l) { authtype = l->data; @@ -290,6 +343,8 @@ transport_construct_authmenu (MailAccountEditor *editor, CamelURL *url) gtk_menu_append (GTK_MENU (menu), item); + gtk_widget_show (item); + if (!first) first = item; @@ -298,6 +353,8 @@ transport_construct_authmenu (MailAccountEditor *editor, CamelURL *url) } } + gtk_option_menu_set_menu (editor->transport_auth, menu); + if (preferred) gtk_signal_emit_by_name (GTK_OBJECT (preferred), "activate", editor); else if (first) @@ -343,7 +400,9 @@ transport_type_init (MailAccountEditor *editor, CamelURL *url) GList *providers, *l; menu = gtk_menu_new (); - providers = camel_session_list_providers (session, FALSE); + gtk_option_menu_remove_menu (editor->transport_auth); + + providers = camel_session_list_providers (session, TRUE); l = providers; while (l) { CamelProvider *provider = l->data; @@ -364,6 +423,8 @@ transport_type_init (MailAccountEditor *editor, CamelURL *url) gtk_menu_append (GTK_MENU (menu), item); + gtk_widget_show (item); + if (!g_strcasecmp (provider->protocol, url->protocol)) xport = item; } @@ -396,6 +457,7 @@ construct (MailAccountEditor *editor, const MailConfigAccount *account) /* give our dialog an OK button and title */ gtk_window_set_title (GTK_WINDOW (editor), _("Evolution Account Editor")); gtk_window_set_policy (GTK_WINDOW (editor), FALSE, TRUE, TRUE); + gtk_window_set_modal (GTK_WINDOW (editor), TRUE); gnome_dialog_append_buttons (GNOME_DIALOG (editor), GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_APPLY, @@ -415,10 +477,13 @@ construct (MailAccountEditor *editor, const MailConfigAccount *account) /* General */ editor->account_name = GTK_ENTRY (glade_xml_get_widget (gui, "txtAccountName")); gtk_entry_set_text (editor->account_name, account->name); + gtk_signal_connect (GTK_OBJECT (editor->account_name), "changed", entry_changed, editor); editor->name = GTK_ENTRY (glade_xml_get_widget (gui, "txtName")); gtk_entry_set_text (editor->name, account->id->name); + gtk_signal_connect (GTK_OBJECT (editor->name), "changed", entry_changed, editor); editor->email = GTK_ENTRY (glade_xml_get_widget (gui, "txtAddress")); gtk_entry_set_text (editor->email, account->id->address); + gtk_signal_connect (GTK_OBJECT (editor->email), "changed", entry_changed, editor); editor->reply_to = GTK_ENTRY (glade_xml_get_widget (gui, "txtReplyTo")); gtk_entry_set_text (editor->reply_to, account->id->reply_to); editor->organization = GTK_ENTRY (glade_xml_get_widget (gui, "txtOrganization")); |