From a9791c82f0513cdeb607c94f8b73c8040dc16bf5 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Fri, 8 Mar 2002 00:13:41 +0000 Subject: Re-focus the account name entry widget. (identity_prepare): If a name is 2002-03-07 Jeffrey Stedfast * mail-config-druid.c (management_changed): Re-focus the account name entry widget. (identity_prepare): If a name is not set, try and get the user's full name for them and set the text on the entry widget. (management_prepare): If the account name is already taken, generate a unique one by appending " (%d)". svn path=/trunk/; revision=15986 --- mail/ChangeLog | 16 ++++++++++++++-- mail/mail-config-druid.c | 50 +++++++++++++++++++++++++++++++++++++----------- mail/mail-config.glade | 22 +++++++++++++++++++-- 3 files changed, 73 insertions(+), 15 deletions(-) diff --git a/mail/ChangeLog b/mail/ChangeLog index b94a636e53..9db70b38b5 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,12 @@ +2002-03-07 Jeffrey Stedfast + + * mail-config-druid.c (management_changed): Re-focus the account + name entry widget. + (identity_prepare): If a name is not set, try and get the user's + full name for them and set the text on the entry widget. + (management_prepare): If the account name is already taken, + generate a unique one by appending " (%d)". + 2002-03-07 Radek Doulik * mail-account-gui.c (sig_new_html): make edit button sensitive @@ -6,8 +15,11 @@ 2002-03-07 Anna Marie Dirks - * folder-browser.c: Made all the acclerators in the context menu on a message work. (There are 22 different menu items here, so picking a unique accelerator for each label was tricky, and some of the choices I made are different from the ones I would have made if there weren't so many stinking menu items.) - + * folder-browser.c: Made all the acclerators in the context menu + on a message work. (There are 22 different menu items here, so + picking a unique accelerator for each label was tricky, and some + of the choices I made are different from the ones I would have + made if there weren't so many stinking menu items.) 2002-03-07 Jeffrey Stedfast diff --git a/mail/mail-config-druid.c b/mail/mail-config-druid.c index 68c745debe..e43f0dfbf5 100644 --- a/mail/mail-config-druid.c +++ b/mail/mail-config-druid.c @@ -244,8 +244,16 @@ static void identity_prepare (EvolutionWizard *wizard, gpointer data) { MailConfigWizard *gui = data; + const char *name; gui->page = MAIL_CONFIG_WIZARD_PAGE_IDENTITY; + + name = gtk_entry_get_text (gui->gui->full_name); + if (!name) { + name = g_get_real_name (); + gtk_entry_set_text (gui->gui->full_name, name ? name : ""); + gtk_entry_select_region (gui->gui->full_name, 0, -1); + } gtk_widget_grab_focus (GTK_WIDGET (gui->gui->full_name)); identity_changed (NULL, data); } @@ -382,15 +390,16 @@ static void management_check (MailConfigWizard *wizard) { gboolean next_sensitive; + GtkWidget *label; char *text; - + text = gtk_entry_get_text (wizard->gui->account_name); next_sensitive = text && *text; - + /* no accounts with the same name */ if (next_sensitive && mail_config_get_account_by_name (text)) next_sensitive = FALSE; - + evolution_wizard_set_buttons_sensitive (wizard->wizard, TRUE, next_sensitive, TRUE, NULL); } @@ -399,12 +408,28 @@ static void management_prepare (EvolutionWizard *wizard, gpointer data) { MailConfigWizard *gui = data; - char *name; + const char *name; gui->page = MAIL_CONFIG_WIZARD_PAGE_MANAGEMENT; name = gtk_entry_get_text (gui->gui->email_address); - if (name && *name) + if (name && *name) { + if (mail_config_get_account_by_name (name)) { + char *template, *p; + unsigned int i = 1; + + /* length of name + 1 char for ' ' + 1 char + for '(' + 10 chars for %d + 1 char for ')' + + 1 char for nul */ + template = alloca (strlen (name) + 14); + p = stpcpy (template, name); + name = template; + do { + sprintf (p, " (%d)", i++); + } while (mail_config_get_account_by_name (name) && i != 0); + } + gtk_entry_set_text (gui->gui->account_name, name); + } management_check (gui); } @@ -413,10 +438,13 @@ static void management_changed (GtkWidget *widget, gpointer data) { MailConfigWizard *gui = data; - + if (gui->page != MAIL_CONFIG_WIZARD_PAGE_MANAGEMENT) return; + management_check (gui); + + gtk_widget_grab_focus (GTK_WIDGET (gui->gui->account_name)); } static MailConfigAccount * @@ -425,19 +453,19 @@ make_account (void) MailConfigAccount *account; char *name, *user; struct utsname uts; - + account = g_new0 (MailConfigAccount, 1); - + account->id = g_new0 (MailConfigIdentity, 1); name = g_get_real_name (); account->id->name = e_utf8_from_locale_string (name); - user = getenv ("USER"); + user = g_get_user_name (); if (user && !uname (&uts) && strchr (uts.nodename, '.')) account->id->address = g_strdup_printf ("%s@%s", user, uts.nodename); - + if (mail_config_get_default_transport ()) account->transport = service_copy (mail_config_get_default_transport ()); - + return account; } diff --git a/mail/mail-config.glade b/mail/mail-config.glade index 5d87d490f6..e00f31e685 100644 --- a/mail/mail-config.glade +++ b/mail/mail-config.glade @@ -247,17 +247,35 @@ Click "Finish" to save your settings. GtkVBox - vbox31 + account_vbox 3 False 0 + + GtkLabel + management_description_label + + GTK_JUSTIFY_LEFT + False + 0 + 0.5 + 0 + 0 + + 0 + False + True + + + GtkHBox hbox24 3 False - 5 + 4 0 False -- cgit v1.2.3