aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog21
-rw-r--r--mail/mail-account-gui.c19
-rw-r--r--mail/mail-config-druid.c69
-rw-r--r--mail/mail-config.c5
-rw-r--r--mail/mail-config.glade17
5 files changed, 81 insertions, 50 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 639122624a..66673e48bb 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,5 +1,26 @@
2001-08-22 Peter Williams <peterw@ximian.com>
+ Prevent the user from creating two accounts with the same name.
+
+ * mail-config.c (impl_GNOME_Evolution_MailConfig_addAccount): Abort
+ if the account has the same name as another account.
+
+ * mail-account-gui.c (mail_account_gui_save): Don't let the user
+ save if the account has the same name as another account.
+
+ * mail-config-druid.c (management_check): Disable the next button
+ if the account name is the same as a preexisting account.
+ (construct): The only part of 'pages' that was being used was the
+ name. 'wizard_pages' now has the callbacks, while 'pages' is just
+ an array of char *'s.
+ (wizard_finish_cb): Save the account first because that's the
+ right way, and try to honor mail_account_gui_save's return value.
+
+ * mail-config.glade: Add a label noting that you're not allowed
+ to create two accounts with the same name.
+
+2001-08-22 Peter Williams <peterw@ximian.com>
+
* folder-browser-ui.c (fbui_sensitize_timeout): Check for NULL uic
here as well.
(fbui_sensitize_items): Up the timeout interval to 110 ms.
diff --git a/mail/mail-account-gui.c b/mail/mail-account-gui.c
index 0769ad1ab8..26c6fbf5b4 100644
--- a/mail/mail-account-gui.c
+++ b/mail/mail-account-gui.c
@@ -32,6 +32,7 @@
#include <bonobo.h>
#include <bonobo/bonobo-stream-memory.h>
#include <gal/widgets/e-unicode.h>
+#include <gal/widgets/e-gui-utils.h>
#include "shell/evolution-shell-client.h"
#include "mail-account-gui.h"
@@ -1562,6 +1563,8 @@ gboolean
mail_account_gui_save (MailAccountGui *gui)
{
MailConfigAccount *account = gui->account;
+ const MailConfigAccount *old_account;
+ gchar *new_name;
gboolean old_enabled;
if (!mail_account_gui_identity_complete (gui, NULL) ||
@@ -1570,8 +1573,22 @@ mail_account_gui_save (MailAccountGui *gui)
!mail_account_gui_management_complete (gui, NULL))
return FALSE;
+ /* this would happen at an inconvenient time in the druid,
+ * but the druid performs its own check so this can't happen
+ * here. */
+
+ new_name = e_utf8_gtk_entry_get_text (gui->account_name);
+ old_account = mail_config_get_account_by_name (new_name);
+
+ if (old_account != account) {
+ e_notice (NULL, GNOME_MESSAGE_BOX_ERROR,
+ _("You may not create two accounts with the same name."));
+ return FALSE;
+ }
+
g_free (account->name);
- account->name = e_utf8_gtk_entry_get_text (gui->account_name);
+ account->name = new_name;
+
if (gtk_toggle_button_get_active (gui->default_account))
mail_config_set_default_account (account);
diff --git a/mail/mail-config-druid.c b/mail/mail-config-druid.c
index 966894bc81..f5781cacb9 100644
--- a/mail/mail-config-druid.c
+++ b/mail/mail-config-druid.c
@@ -355,6 +355,10 @@ management_check (MailConfigWizard *wizard)
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);
}
@@ -380,7 +384,6 @@ management_changed (GtkWidget *widget, gpointer data)
management_check (gui);
}
-
static MailConfigAccount *
make_account (void)
{
@@ -403,48 +406,14 @@ make_account (void)
return account;
}
-static struct {
- char *name;
- GtkSignalFunc next_func;
- GtkSignalFunc prepare_func;
- GtkSignalFunc back_func;
- GtkSignalFunc finish_func;
-} pages[] = {
- { "identity_page",
- GTK_SIGNAL_FUNC (identity_next),
- GTK_SIGNAL_FUNC (identity_prepare),
- GTK_SIGNAL_FUNC (NULL),
- GTK_SIGNAL_FUNC (NULL) },
- { "source_page",
- GTK_SIGNAL_FUNC (source_next),
- GTK_SIGNAL_FUNC (source_prepare),
- GTK_SIGNAL_FUNC (NULL),
- GTK_SIGNAL_FUNC (NULL) },
- { "extra_page",
- GTK_SIGNAL_FUNC (NULL),
- GTK_SIGNAL_FUNC (extra_prepare),
- GTK_SIGNAL_FUNC (NULL),
- GTK_SIGNAL_FUNC (NULL) },
- { "transport_page",
- GTK_SIGNAL_FUNC (transport_next),
- GTK_SIGNAL_FUNC (transport_prepare),
- GTK_SIGNAL_FUNC (transport_back),
- GTK_SIGNAL_FUNC (NULL) },
- { "management_page",
- GTK_SIGNAL_FUNC (NULL),
- GTK_SIGNAL_FUNC (management_prepare),
- GTK_SIGNAL_FUNC (NULL),
- GTK_SIGNAL_FUNC (NULL) },
- { "finish_page",
- GTK_SIGNAL_FUNC (NULL),
- GTK_SIGNAL_FUNC (NULL),
- GTK_SIGNAL_FUNC (NULL),
- GTK_SIGNAL_FUNC (druid_finish) },
- { NULL,
- GTK_SIGNAL_FUNC (NULL),
- GTK_SIGNAL_FUNC (NULL),
- GTK_SIGNAL_FUNC (NULL),
- GTK_SIGNAL_FUNC (NULL) }
+static const char *pages[] = {
+ "identity_page",
+ "source_page",
+ "extra_page",
+ "transport_page",
+ "management_page",
+ "finish_page",
+ NULL
};
static int
@@ -611,11 +580,11 @@ construct (MailConfigDruid *druid)
g_hash_table_destroy (page_hash);
}
page_hash = g_hash_table_new (NULL, NULL);
- for (i = 0; pages[i].name != NULL; i++) {
+ for (i = 0; pages[i] != NULL; i++) {
GtkWidget *page;
GnomeDruidPageStandard *dpage;
- page = glade_xml_get_widget (druid->xml, pages[i].name);
+ page = glade_xml_get_widget (druid->xml, pages[i]);
/* Store pages */
g_hash_table_insert (page_hash, page, GINT_TO_POINTER (i));
page_list = g_list_append (page_list, page);
@@ -703,7 +672,6 @@ get_fn (EvolutionWizard *wizard,
gtk_signal_connect (GTK_OBJECT (gui->gui->source.path),
"changed", source_changed, gui);
gtk_signal_connect (GTK_OBJECT (gui->gui->transport.hostname),
-
"changed", transport_changed, gui);
gtk_signal_connect (GTK_OBJECT (gui->gui->transport.username),
"changed", transport_changed, gui);
@@ -837,12 +805,15 @@ wizard_finish_cb (EvolutionWizard *wizard,
{
MailAccountGui *gui = w->gui;
- /* Add the account to our list (do it first because future
+ /* Save the settings for that account */
+ if (mail_account_gui_save (gui) == FALSE)
+ /* problem. Um, how to keep the druid alive? */
+ return;
+
+ /* Add the account to our list (do it early because future
steps might want to access config->accounts) */
mail_config_add_account (gui->account);
- /* Save the settings for that account */
- mail_account_gui_save (gui);
if (gui->account->source)
gui->account->source->enabled = TRUE;
diff --git a/mail/mail-config.c b/mail/mail-config.c
index a406ba1367..7c0b4a4c97 100644
--- a/mail/mail-config.c
+++ b/mail/mail-config.c
@@ -1925,6 +1925,11 @@ impl_GNOME_Evolution_MailConfig_addAccount (PortableServer_Servant servant,
MailConfigService *mail_service;
MailConfigIdentity *mail_id;
+ if (mail_config_get_account_by_name (account->name)) {
+ /* FIXME: we need an exception. */
+ return;
+ }
+
mail_account = g_new0 (MailConfigAccount, 1);
mail_account->name = g_strdup (account->name);
diff --git a/mail/mail-config.glade b/mail/mail-config.glade
index 6dbce2a568..73309bdf1a 100644
--- a/mail/mail-config.glade
+++ b/mail/mail-config.glade
@@ -252,6 +252,23 @@ Click &quot;Finish&quot; to save your settings.</text>
<spacing>0</spacing>
<widget>
+ <class>GtkLabel</class>
+ <name>label40</name>
+ <label>Each account must have a different name.</label>
+ <justify>GTK_JUSTIFY_CENTER</justify>
+ <wrap>False</wrap>
+ <xalign>0.5</xalign>
+ <yalign>0.5</yalign>
+ <xpad>4</xpad>
+ <ypad>0</ypad>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+ </widget>
+
+ <widget>
<class>GtkHBox</class>
<name>hbox24</name>
<border_width>3</border_width>