diff options
Diffstat (limited to 'mail/mail-config-druid.c')
-rw-r--r-- | mail/mail-config-druid.c | 1166 |
1 files changed, 726 insertions, 440 deletions
diff --git a/mail/mail-config-druid.c b/mail/mail-config-druid.c index 6210d8177b..6afa19b642 100644 --- a/mail/mail-config-druid.c +++ b/mail/mail-config-druid.c @@ -23,7 +23,6 @@ * */ - #ifdef HAVE_CONFIG_H #include <config.h> #endif @@ -33,23 +32,38 @@ #include <string.h> #include <unistd.h> -#include <gal/util/e-util.h> -#include <glade/glade.h> -#include <gtkhtml/gtkhtml.h> #include <libgnomeui/gnome-dialog.h> #include <libgnomeui/gnome-dialog-util.h> #include <libgnomeui/gnome-druid.h> #include <libgnomeui/gnome-druid-page-standard.h> -#include <bonobo/bonobo-exception.h> - +#include <glade/glade.h> +#include <gtkhtml/gtkhtml.h> +#include <gal/widgets/e-unicode.h> #include "mail-config-druid.h" #include "mail-config.h" #include "mail-ops.h" #include "mail.h" #include "mail-session.h" +#include <bonobo/bonobo-exception.h> +#include <bonobo/bonobo-control.h> +#include <bonobo/bonobo-widget.h> +#include <bonobo/bonobo-generic-factory.h> +#include <bonobo/bonobo-context.h> + #include <evolution-wizard.h> -#include <e-util/e-account.h> + +static void mail_config_druid_class_init (MailConfigDruidClass *class); +static void mail_config_druid_finalize (GtkObject *obj); + +static GtkWindowClass *parent_class; + +/* These globals need fixed FIXME FIXME FIXME FIXME*/ +static GHashTable *page_hash = NULL; +static GList *page_list = NULL; +static EvolutionWizard *account_wizard; + +#define WIZARD_IID "OAFIID:GNOME_Evolution_Mail_Wizard_Factory" typedef enum { MAIL_CONFIG_WIZARD_PAGE_NONE = -1, @@ -58,202 +72,294 @@ typedef enum { MAIL_CONFIG_WIZARD_PAGE_EXTRA, MAIL_CONFIG_WIZARD_PAGE_TRANSPORT, MAIL_CONFIG_WIZARD_PAGE_MANAGEMENT, - - MAIL_CONFIG_WIZARD_NUM_PAGES } MailConfigWizardPage; typedef struct { - /* Only one of these will be set */ - GnomeDruid *druid; - EvolutionWizard *corba_wizard; - MailAccountGui *gui; - GPtrArray *interior_pages; - GnomeDruidPage *last_page; + MailConfigAccount *account; + EvolutionWizard *wizard; gboolean identity_copied; CamelProvider *last_source; MailConfigWizardPage page; } MailConfigWizard; +GtkType +mail_config_druid_get_type (void) +{ + static GtkType type = 0; + + if (!type) { + GtkTypeInfo type_info = { + "MailConfigDruid", + sizeof (MailConfigDruid), + sizeof (MailConfigDruidClass), + (GtkClassInitFunc) mail_config_druid_class_init, + (GtkObjectInitFunc) NULL, + (GtkArgSetFunc) NULL, + (GtkArgGetFunc) NULL + }; + + type = gtk_type_unique (gtk_window_get_type (), &type_info); + } + + return type; +} + +static void +mail_config_druid_class_init (MailConfigDruidClass *class) +{ + GtkObjectClass *object_class; + + object_class = (GtkObjectClass *) class; + parent_class = gtk_type_class (gtk_window_get_type ()); + + /* override methods */ + object_class->finalize = mail_config_druid_finalize; +} + +static void +mail_config_druid_finalize (GtkObject *obj) +{ + MailConfigDruid *druid = (MailConfigDruid *) obj; + CORBA_Environment ev; + + gtk_object_destroy (GTK_OBJECT (druid->xml)); + + CORBA_exception_init (&ev); + Bonobo_EventSource_removeListener ((Bonobo_EventSource) druid->event_source, druid->id, &ev); + CORBA_exception_free (&ev); + + bonobo_object_release_unref ((Bonobo_Unknown) druid->event_source, &ev); + bonobo_object_unref (BONOBO_OBJECT (druid->listener)); + + ((GtkObjectClass *)(parent_class))->finalize (obj); +} +static struct { + char *name; + char *text; +} info[] = { + { "identity_html", + N_("Please enter your name and email address below. The \"optional\" fields below do not need to be filled in, unless you wish to include this information in email you send.") }, + { "source_html", + N_("Please enter information about your incoming mail server below. If you are not sure, ask your system administrator or Internet Service Provider.") }, + { "extra_html", + N_("Please select among the following options") }, + { "transport_html", + N_("Please enter information about the way you will send mail. If you are not sure, ask your system administrator or Internet Service Provider.") }, + { "management_html", + N_("You are almost done with the mail configuration process. The identity, incoming mail server and outgoing mail transport method which you provided will be grouped together to make an Evolution mail account. Please enter a name for this account in the space below. This name will be used for display purposes only.") } +}; +static int num_info = (sizeof (info) / sizeof (info[0])); + +static GtkWidget * +create_label (const char *name) +{ + GtkWidget *widget, *align; + int i; + + for (i = 0; i < num_info; i++) { + if (!strcmp (name, info[i].name)) + break; + } + + g_return_val_if_fail (i != num_info, NULL); + + widget = gtk_label_new (_(info[i].text)); + gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE); + gtk_label_set_justify (GTK_LABEL (widget), GTK_JUSTIFY_FILL); + gtk_widget_show (widget); + + align = gtk_alignment_new (0.0, 0.5, 1.0, 1.0); + gtk_container_add (GTK_CONTAINER (align), widget); + + gtk_widget_show (align); + + return align; +} static void -config_wizard_set_buttons_sensitive (MailConfigWizard *mcw, - gboolean prev_sensitive, - gboolean next_sensitive) -{ - if (mcw->corba_wizard) { - evolution_wizard_set_buttons_sensitive (mcw->corba_wizard, - prev_sensitive, - next_sensitive, - TRUE, NULL); - } else { - gnome_druid_set_buttons_sensitive (mcw->druid, - prev_sensitive, - next_sensitive, - TRUE, FALSE); +druid_cancel (GnomeDruid *druid, gpointer user_data) +{ + MailConfigDruid *config = user_data; + GNOME_Evolution_Wizard wiz; + CORBA_Environment ev; + + wiz = bonobo_object_corba_objref (BONOBO_OBJECT (account_wizard)); + CORBA_exception_init (&ev); + + GNOME_Evolution_Wizard_notifyAction (wiz, 0, GNOME_Evolution_Wizard_CANCEL, &ev); + CORBA_exception_free (&ev); + + if (page_list != NULL) { + g_list_free (page_list); + page_list = NULL; + } + + if (page_hash != NULL) { + g_hash_table_destroy (page_hash); + page_hash = NULL; } + + gtk_widget_destroy (GTK_WIDGET (config)); } static void -config_wizard_set_page (MailConfigWizard *mcw, MailConfigWizardPage page) +druid_finish (GnomeDruidPage *page, gpointer arg1, gpointer user_data) { - if (mcw->corba_wizard) - evolution_wizard_set_page (mcw->corba_wizard, page, NULL); - else { - if (page <= mcw->interior_pages->len) - gnome_druid_set_page (mcw->druid, mcw->interior_pages->pdata[page]); - else - gnome_druid_set_page (mcw->druid, mcw->last_page); + MailConfigDruid *druid = user_data; + + gtk_object_set_data (GTK_OBJECT (account_wizard), "account-data", NULL); + if (page_list != NULL) { + g_list_free (page_list); + page_list = NULL; + } + + if (page_hash != NULL) { + g_hash_table_destroy (page_hash); + page_hash = NULL; } + + gtk_widget_destroy (GTK_WIDGET (druid)); } /* Identity Page */ static void identity_changed (GtkWidget *widget, gpointer data) { - MailConfigWizard *mcw = data; + MailConfigWizard *gui = data; GtkWidget *incomplete; gboolean next_sensitive; - if (mcw->page != MAIL_CONFIG_WIZARD_PAGE_IDENTITY) + if (gui->page != MAIL_CONFIG_WIZARD_PAGE_IDENTITY) return; - next_sensitive = mail_account_gui_identity_complete (mcw->gui, &incomplete); + next_sensitive = mail_account_gui_identity_complete (gui->gui, &incomplete); - config_wizard_set_buttons_sensitive (mcw, TRUE, next_sensitive); + evolution_wizard_set_buttons_sensitive (gui->wizard, TRUE, next_sensitive, TRUE, NULL); if (!next_sensitive) gtk_widget_grab_focus (incomplete); } static void -identity_prepare (MailConfigWizard *mcw) +identity_prepare (EvolutionWizard *wizard, gpointer data) { + MailConfigWizard *gui = data; const char *name; - mcw->page = MAIL_CONFIG_WIZARD_PAGE_IDENTITY; + gui->page = MAIL_CONFIG_WIZARD_PAGE_IDENTITY; - name = gtk_entry_get_text (mcw->gui->full_name); + name = gtk_entry_get_text (gui->gui->full_name); if (!name) { name = g_get_real_name (); - gtk_entry_set_text (mcw->gui->full_name, name ? name : ""); - gtk_editable_select_region (GTK_EDITABLE (mcw->gui->full_name), 0, -1); + 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 (mcw->gui->full_name)); - identity_changed (NULL, mcw); + gtk_widget_grab_focus (GTK_WIDGET (gui->gui->full_name)); + identity_changed (NULL, data); } static gboolean -identity_next (MailConfigWizard *mcw) +identity_next (EvolutionWizard *wizard, gpointer data) { - if (!mcw->identity_copied) { + MailConfigWizard *gui = data; + + if (!gui->identity_copied) { char *username; - const char *user; - + /* Copy the username part of the email address into * the Username field of the source and transport pages. */ - user = gtk_entry_get_text (mcw->gui->email_address); - username = g_strndup (user, strcspn (user, "@")); - gtk_entry_set_text (mcw->gui->source.username, username); - gtk_entry_set_text (mcw->gui->transport.username, username); + username = gtk_entry_get_text (gui->gui->email_address); + username = g_strndup (username, strcspn (username, "@")); + gtk_entry_set_text (gui->gui->source.username, username); + gtk_entry_set_text (gui->gui->transport.username, username); g_free (username); - mcw->identity_copied = TRUE; + gui->identity_copied = TRUE; } return FALSE; } -static void -identity_activate_cb (GtkEntry *ent, gpointer user_data) -{ - MailConfigWizard *mcw = user_data; - - if (mail_account_gui_identity_complete (mcw->gui, NULL) && - !identity_next (mcw)) - config_wizard_set_page (mcw, MAIL_CONFIG_WIZARD_PAGE_SOURCE); -} - /* Incoming mail Page */ static void source_changed (GtkWidget *widget, gpointer data) { - MailConfigWizard *mcw = data; + MailConfigWizard *gui = data; GtkWidget *incomplete; gboolean next_sensitive; - if (mcw->page != MAIL_CONFIG_WIZARD_PAGE_SOURCE) + if (gui->page != MAIL_CONFIG_WIZARD_PAGE_SOURCE) return; - next_sensitive = mail_account_gui_source_complete (mcw->gui, &incomplete); + next_sensitive = mail_account_gui_source_complete (gui->gui, &incomplete); - config_wizard_set_buttons_sensitive (mcw, TRUE, next_sensitive); + evolution_wizard_set_buttons_sensitive (gui->wizard, TRUE, next_sensitive, TRUE, NULL); if (!next_sensitive) gtk_widget_grab_focus (incomplete); } static void -source_prepare (MailConfigWizard *mcw) +source_prepare (EvolutionWizard *wizard, gpointer data) { - mcw->page = MAIL_CONFIG_WIZARD_PAGE_SOURCE; - source_changed (NULL, mcw); + MailConfigWizard *gui = data; + + gui->page = MAIL_CONFIG_WIZARD_PAGE_SOURCE; + source_changed (NULL, gui); } static gboolean -source_next (MailConfigWizard *mcw) +source_next (EvolutionWizard *wizard, gpointer data) { + MailConfigWizard *gui = data; + /* FIXME: if online, check that the data is good. */ - if (mcw->gui->source.provider && mcw->gui->source.provider->extra_conf) + if (gui->gui->source.provider && gui->gui->source.provider->extra_conf) return FALSE; /* Otherwise, skip to transport page. */ - config_wizard_set_page (mcw, MAIL_CONFIG_WIZARD_PAGE_TRANSPORT); + evolution_wizard_set_page (gui->wizard, MAIL_CONFIG_WIZARD_PAGE_TRANSPORT, NULL); + return TRUE; } -static void -source_activate_cb (GtkEntry *ent, gpointer user_data) -{ - MailConfigWizard *mcw = user_data; - - if (mail_account_gui_source_complete (mcw->gui, NULL) && - !source_next (mcw)) - config_wizard_set_page (mcw, MAIL_CONFIG_WIZARD_PAGE_EXTRA); -} - /* Extra Config Page */ static void -extra_prepare (MailConfigWizard *mcw) +extra_prepare (EvolutionWizard *wizard, gpointer data) { - mcw->page = MAIL_CONFIG_WIZARD_PAGE_EXTRA; - if (mcw->gui->source.provider != mcw->last_source) { - mcw->last_source = mcw->gui->source.provider; - mail_account_gui_auto_detect_extra_conf (mcw->gui); + MailConfigWizard *gui = data; + + gui->page = MAIL_CONFIG_WIZARD_PAGE_EXTRA; + if (gui->gui->source.provider != gui->last_source) { + gui->last_source = gui->gui->source.provider; + mail_account_gui_auto_detect_extra_conf (gui->gui); } } /* Transport Page */ static gboolean -transport_next (MailConfigWizard *mcw) +transport_next (EvolutionWizard *wizard, gpointer data) { /* FIXME: if online, check that the data is good. */ return FALSE; } static gboolean -transport_back (MailConfigWizard *mcw) +transport_back (EvolutionWizard *wizard, gpointer data) { - if (mcw->gui->source.provider && mcw->gui->source.provider->extra_conf) + MailConfigWizard *gui = data; + + if (gui->gui->source.provider && gui->gui->source.provider->extra_conf) return FALSE; else { - config_wizard_set_page (mcw, MAIL_CONFIG_WIZARD_PAGE_SOURCE); + evolution_wizard_set_page (wizard, MAIL_CONFIG_WIZARD_PAGE_SOURCE, NULL); return TRUE; } } @@ -261,66 +367,60 @@ transport_back (MailConfigWizard *mcw) static void transport_changed (GtkWidget *widget, gpointer data) { - MailConfigWizard *mcw = data; + MailConfigWizard *gui = data; GtkWidget *incomplete; gboolean next_sensitive; - if (mcw->page != MAIL_CONFIG_WIZARD_PAGE_TRANSPORT) + if (gui->page != MAIL_CONFIG_WIZARD_PAGE_TRANSPORT) return; - next_sensitive = mail_account_gui_transport_complete (mcw->gui, &incomplete); + next_sensitive = mail_account_gui_transport_complete (gui->gui, &incomplete); - config_wizard_set_buttons_sensitive (mcw, TRUE, next_sensitive); + evolution_wizard_set_buttons_sensitive (gui->wizard, TRUE, next_sensitive, TRUE, NULL); if (!next_sensitive) gtk_widget_grab_focus (incomplete); } static void -transport_prepare (MailConfigWizard *mcw) -{ - mcw->page = MAIL_CONFIG_WIZARD_PAGE_TRANSPORT; - transport_changed (NULL, mcw); -} - -static void -transport_activate_cb (GtkEntry *ent, gpointer user_data) +transport_prepare (EvolutionWizard *wizard, gpointer data) { - MailConfigWizard *mcw = user_data; - - if (mail_account_gui_transport_complete (mcw->gui, NULL) && - !transport_next (mcw)) - config_wizard_set_page (mcw, MAIL_CONFIG_WIZARD_PAGE_MANAGEMENT); + MailConfigWizard *gui = data; + + gui->page = MAIL_CONFIG_WIZARD_PAGE_TRANSPORT; + transport_changed (NULL, data); } /* Management page */ static gboolean -management_check (MailConfigWizard *mcw) +management_check (MailConfigWizard *wizard) { gboolean next_sensitive; - const char *text; + char *text; - text = gtk_entry_get_text (mcw->gui->account_name); + 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; - config_wizard_set_buttons_sensitive (mcw, TRUE, next_sensitive); + evolution_wizard_set_buttons_sensitive (wizard->wizard, TRUE, + next_sensitive, TRUE, NULL); return next_sensitive; } static void -management_prepare (MailConfigWizard *mcw) +management_prepare (EvolutionWizard *wizard, gpointer data) { + MailConfigWizard *gui = data; const char *name, *text; - mcw->page = MAIL_CONFIG_WIZARD_PAGE_MANAGEMENT; + gui->page = MAIL_CONFIG_WIZARD_PAGE_MANAGEMENT; - text = gtk_entry_get_text (mcw->gui->account_name); + text = gtk_entry_get_text (gui->gui->account_name); if (!text || *text == '\0') { - name = gtk_entry_get_text(mcw->gui->email_address); + name = e_utf8_gtk_entry_get_text (gui->gui->email_address); if (name && *name) { if (mail_config_get_account_by_name (name)) { char *template; @@ -338,444 +438,630 @@ management_prepare (MailConfigWizard *mcw) } while (mail_config_get_account_by_name (name) && i != 0); } - gtk_entry_set_text(mcw->gui->account_name, name); + e_utf8_gtk_entry_set_text (gui->gui->account_name, name); } } - management_check (mcw); + management_check (gui); } static void management_changed (GtkWidget *widget, gpointer data) { - MailConfigWizard *mcw = data; + MailConfigWizard *gui = data; - if (mcw->page != MAIL_CONFIG_WIZARD_PAGE_MANAGEMENT) + if (gui->page != MAIL_CONFIG_WIZARD_PAGE_MANAGEMENT) return; - management_check (mcw); + management_check (gui); - gtk_widget_grab_focus (GTK_WIDGET (mcw->gui->account_name)); + gtk_widget_grab_focus (GTK_WIDGET (gui->gui->account_name)); } -static void -management_activate_cb (GtkEntry *ent, gpointer user_data) +static MailConfigAccount * +make_account (void) { - MailConfigWizard *mcw = user_data; - - if (management_check (mcw)) - config_wizard_set_page (mcw, mcw->page + 1); + 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 = 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; } +static const char *pages[] = { + "identity_page", + "source_page", + "extra_page", + "transport_page", + "management_page", + "finish_page", + NULL +}; -#define WIZARD_ICON(name) (EVOLUTION_IMAGES "/mail-config-druid-" name ".png") +static int +page_to_num (gpointer page) +{ + gpointer r; -static struct { - const char *page_name, *title, *icon_path; - void (*prepare_func) (MailConfigWizard *mcw); - gboolean (*back_func) (MailConfigWizard *mcw); - gboolean (*next_func) (MailConfigWizard *mcw); - const char *help_text; -} wizard_pages[] = { - { "identity_page", N_("Identity"), WIZARD_ICON ("identity"), - identity_prepare, NULL, identity_next, - N_("Please enter your name and email address below. " - "The \"optional\" fields below do not need to be " - "filled in, unless you wish to include this " - "information in email you send.") - }, - - { "source_page", N_("Receiving Mail"), WIZARD_ICON ("receive"), - source_prepare, NULL, source_next, - N_("Please enter information about your incoming " - "mail server below. If you are not sure, ask your " - "system administrator or Internet Service Provider.") - }, - - { "extra_page", N_("Receiving Mail"), WIZARD_ICON ("receive"), - extra_prepare, NULL, NULL, - N_("Please select among the following options") - }, - - { "transport_page", N_("Sending Mail"), WIZARD_ICON ("send"), - transport_prepare, transport_back, transport_next, - N_("Please enter information about the way you will " - "send mail. If you are not sure, ask your system " - "administrator or Internet Service Provider.") - }, - - { "management_page", N_("Account Management"), WIZARD_ICON ("account-name"), - management_prepare, NULL, NULL, - N_("You are almost done with the mail configuration " - "process. The identity, incoming mail server and " - "outgoing mail transport method which you provided " - "will be grouped together to make an Evolution mail " - "account. Please enter a name for this account in " - "the space below. This name will be used for display " - "purposes only.") + r = g_hash_table_lookup (page_hash, page); + if (r == NULL) { + return 0; } -}; -static const int num_wizard_pages = sizeof (wizard_pages) / sizeof (wizard_pages[0]); -static GtkWidget * -get_page (GladeXML *xml, int page_num) + return GPOINTER_TO_INT (r); +} + +static gboolean +next_func (GnomeDruidPage *page, + GnomeDruid *druid, + gpointer data) { - GtkWidget *vbox, *widget; + GNOME_Evolution_Wizard wiz; + CORBA_Environment ev; + int pagenum; - vbox = gtk_vbox_new (FALSE, 4); + wiz = bonobo_object_corba_objref (BONOBO_OBJECT (account_wizard)); + CORBA_exception_init (&ev); - widget = gtk_label_new (_(wizard_pages[page_num].help_text)); - gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE); - gtk_label_set_justify (GTK_LABEL (widget), GTK_JUSTIFY_FILL); - gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0); - gtk_widget_show_all (vbox); - - switch (page_num) { - case MAIL_CONFIG_WIZARD_PAGE_IDENTITY: - widget = glade_xml_get_widget (xml, "identity_required_frame"); - gtk_container_set_border_width (GTK_CONTAINER (widget), 0); - gtk_widget_reparent (widget, vbox); - gtk_box_set_child_packing (GTK_BOX (vbox), widget, FALSE, FALSE, 0, GTK_PACK_START); - widget = glade_xml_get_widget (xml, "identity_optional_frame"); - gtk_container_set_border_width (GTK_CONTAINER (widget), 0); - gtk_widget_reparent (widget, vbox); - gtk_box_set_child_packing (GTK_BOX (vbox), widget, FALSE, FALSE, 0, GTK_PACK_START); - break; + pagenum = page_to_num (page); + GNOME_Evolution_Wizard_notifyAction (wiz, pagenum, GNOME_Evolution_Wizard_NEXT, &ev); + CORBA_exception_free (&ev); - case MAIL_CONFIG_WIZARD_PAGE_SOURCE: - widget = glade_xml_get_widget (xml, "source_vbox"); - gtk_container_set_border_width (GTK_CONTAINER (widget), 0); - gtk_widget_reparent (widget, vbox); - break; + if (pagenum < 5-1) + return TRUE; - case MAIL_CONFIG_WIZARD_PAGE_EXTRA: - widget = glade_xml_get_widget (xml, "extra_table"); - gtk_container_set_border_width (GTK_CONTAINER (widget), 0); - gtk_widget_reparent (widget, vbox); - break; + return FALSE; +} - case MAIL_CONFIG_WIZARD_PAGE_TRANSPORT: - widget = glade_xml_get_widget (xml, "transport_vbox"); - gtk_container_set_border_width (GTK_CONTAINER (widget), 0); - gtk_widget_reparent (widget, vbox); - break; +static gboolean +prepare_func (GnomeDruidPage *page, + GnomeDruid *druid, + gpointer data) +{ + GNOME_Evolution_Wizard wiz; + CORBA_Environment ev; + int pagenum; - case MAIL_CONFIG_WIZARD_PAGE_MANAGEMENT: - widget = glade_xml_get_widget (xml, "management_frame"); - gtk_container_set_border_width (GTK_CONTAINER (widget), 0); - gtk_widget_reparent (widget, vbox); - break; + wiz = bonobo_object_corba_objref (BONOBO_OBJECT (account_wizard)); + CORBA_exception_init (&ev); - default: - g_return_val_if_reached (NULL); - } - - return vbox; + pagenum = page_to_num (page); + GNOME_Evolution_Wizard_notifyAction (wiz, pagenum, GNOME_Evolution_Wizard_PREPARE, &ev); + CORBA_exception_free (&ev); + return FALSE; +} + +static gboolean +back_func (GnomeDruidPage *page, + GnomeDruid *druid, + gpointer data) +{ + GNOME_Evolution_Wizard wiz; + CORBA_Environment ev; + int pagenum; + + wiz = bonobo_object_corba_objref (BONOBO_OBJECT (account_wizard)); + CORBA_exception_init (&ev); + + pagenum = page_to_num (page); + GNOME_Evolution_Wizard_notifyAction (wiz, pagenum, GNOME_Evolution_Wizard_BACK, &ev); + CORBA_exception_free (&ev); + + if (pagenum > 0) + return TRUE; + + return FALSE; } +static gboolean +finish_func (GnomeDruidPage *page, + GnomeDruid *druid, + gpointer data) +{ + GNOME_Evolution_Wizard wiz; + CORBA_Environment ev; + int pagenum; + + wiz = bonobo_object_corba_objref (BONOBO_OBJECT (account_wizard)); + CORBA_exception_init (&ev); + + pagenum = page_to_num (page); + GNOME_Evolution_Wizard_notifyAction (wiz, 0, GNOME_Evolution_Wizard_FINISH, &ev); + CORBA_exception_free (&ev); -static MailConfigWizard * -config_wizard_new (void) + druid_finish (page, druid, data); + return FALSE; +} + +static void +wizard_listener_event (BonoboListener *listener, + char *event_name, + BonoboArg *event_data, + CORBA_Environment *ev, + MailConfigDruid *druid) { - MailConfigWizard *mcw; - const char *name, *user; - EAccountService *xport; - struct utsname uts; - EAccount *account; - - /* Create a new account object with some defaults */ - account = e_account_new (); - account->enabled = TRUE; + CORBA_short buttons, pagenum; + GnomeDruidPage *page; + + if (strcmp (event_name, EVOLUTION_WIZARD_SET_BUTTONS_SENSITIVE) == 0) { + buttons = (int) *((CORBA_short *)event_data->_value); + gnome_druid_set_buttons_sensitive (GNOME_DRUID (druid->druid), + (buttons & 4) >> 2, + (buttons & 2) >> 1, + (buttons & 1)); + } else if (strcmp (event_name, EVOLUTION_WIZARD_SET_SHOW_FINISH) == 0) { + gnome_druid_set_show_finish (GNOME_DRUID (druid->druid), + (gboolean) *((CORBA_boolean *)event_data->_value)); + } else if (strcmp (event_name, EVOLUTION_WIZARD_SET_PAGE) == 0) { + pagenum = (int) *((CORBA_short *) event_data->_value); + + page = g_list_nth_data (page_list, pagenum); + gnome_druid_set_page (GNOME_DRUID (druid->druid), page); + } +} + +static void +construct (MailConfigDruid *druid) +{ + GtkWidget *widget; + GNOME_Evolution_Wizard corba_wizard; + Bonobo_Listener corba_listener; + CORBA_Environment ev; + int i; + + /* Start account wizard */ + CORBA_exception_init (&ev); + corba_wizard = oaf_activate_from_id ("OAFIID:GNOME_Evolution_Mail_Wizard", 0, NULL, &ev); + CORBA_exception_free (&ev); + g_assert (account_wizard != NULL); - name = g_get_real_name (); - account->id->name = g_strdup (name); - user = g_get_user_name (); - if (user && !uname (&uts) && strchr (uts.nodename, '.')) - account->id->address = g_strdup_printf ("%s@%s", user, uts.nodename); + druid->xml = glade_xml_new (EVOLUTION_GLADEDIR "/mail-config.glade", NULL); + /* get our toplevel widget and reparent it */ + widget = glade_xml_get_widget (druid->xml, "druid"); + gtk_widget_reparent (widget, GTK_WIDGET (druid)); - if ((xport = mail_config_get_default_transport ())) { - account->transport->url = g_strdup (xport->url); - account->transport->save_passwd = xport->save_passwd; + druid->druid = GNOME_DRUID (widget); + + /* set window title */ + gtk_window_set_title (GTK_WINDOW (druid), _("Evolution Account Assistant")); + gtk_window_set_policy (GTK_WINDOW (druid), FALSE, TRUE, FALSE); + gtk_window_set_modal (GTK_WINDOW (druid), FALSE); + gtk_object_set (GTK_OBJECT (druid), "type", GTK_WINDOW_DIALOG, NULL); + + druid->listener = bonobo_listener_new (NULL, NULL); + gtk_signal_connect (GTK_OBJECT (druid->listener), "event-notify", + GTK_SIGNAL_FUNC (wizard_listener_event), druid); + corba_listener = bonobo_object_corba_objref (BONOBO_OBJECT (druid->listener)); + CORBA_exception_init (&ev); + druid->event_source = (Bonobo_Unknown) bonobo_object_query_interface ( + BONOBO_OBJECT (account_wizard), "IDL:Bonobo/EventSource:1.0"); + g_assert (druid->event_source != CORBA_OBJECT_NIL); + druid->id = Bonobo_EventSource_addListener ((Bonobo_EventSource) druid->event_source, corba_listener, &ev); + if (BONOBO_EX (&ev)) { + g_warning ("Error adding listener (%s)", + CORBA_exception_id (&ev)); + } + CORBA_exception_free (&ev); + + if (page_hash != NULL) { + g_hash_table_destroy (page_hash); } + page_hash = g_hash_table_new (NULL, NULL); + for (i = 0; pages[i] != NULL; i++) { + GtkWidget *page; + GnomeDruidPageStandard *dpage; + + 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); + + gtk_signal_connect (GTK_OBJECT (page), "next", + GTK_SIGNAL_FUNC (next_func), druid); + gtk_signal_connect (GTK_OBJECT (page), "prepare", + GTK_SIGNAL_FUNC (prepare_func), druid); + gtk_signal_connect (GTK_OBJECT (page), "back", + GTK_SIGNAL_FUNC (back_func), druid); - /* Create the config wizard object */ - mcw = g_new0 (MailConfigWizard, 1); - mcw->gui = mail_account_gui_new (account, NULL); - g_object_unref (account); - - /* Set up gui */ - g_signal_connect (mcw->gui->account_name, "changed", - G_CALLBACK (management_changed), mcw); - g_signal_connect (mcw->gui->full_name, "changed", - G_CALLBACK (identity_changed), mcw); - g_signal_connect (mcw->gui->email_address, "changed", - G_CALLBACK (identity_changed), mcw); - g_signal_connect (mcw->gui->reply_to,"changed", - G_CALLBACK (identity_changed), mcw); - g_signal_connect (mcw->gui->source.hostname, "changed", - G_CALLBACK (source_changed), mcw); - g_signal_connect (mcw->gui->source.username, "changed", - G_CALLBACK (source_changed), mcw); - g_signal_connect (mcw->gui->source.path, "changed", - G_CALLBACK (source_changed), mcw); - g_signal_connect (mcw->gui->transport.hostname, "changed", - G_CALLBACK (transport_changed), mcw); - g_signal_connect (mcw->gui->transport.username, "changed", - G_CALLBACK (transport_changed), mcw); - g_signal_connect (mcw->gui->transport_needs_auth, "toggled", - G_CALLBACK (transport_changed), mcw); - - g_signal_connect (mcw->gui->account_name, "activate", - G_CALLBACK (management_activate_cb), mcw); - - g_signal_connect (mcw->gui->full_name, "activate", - G_CALLBACK (identity_activate_cb), mcw); - g_signal_connect (mcw->gui->email_address, "activate", - G_CALLBACK (identity_activate_cb), mcw); - g_signal_connect (mcw->gui->reply_to,"activate", - G_CALLBACK (identity_activate_cb), mcw); - g_signal_connect (mcw->gui->organization, "activate", - G_CALLBACK (identity_activate_cb), mcw); - - g_signal_connect (mcw->gui->source.hostname, "activate", - G_CALLBACK (source_activate_cb), mcw); - g_signal_connect (mcw->gui->source.username, "activate", - G_CALLBACK (source_activate_cb), mcw); - g_signal_connect (mcw->gui->source.path, "activate", - G_CALLBACK (source_activate_cb), mcw); - - g_signal_connect (mcw->gui->transport.hostname, "activate", - G_CALLBACK (transport_activate_cb), mcw); - g_signal_connect (mcw->gui->transport.username, "activate", - G_CALLBACK (transport_activate_cb), mcw); - - return mcw; + gtk_signal_connect (GTK_OBJECT (page), "finish", + GTK_SIGNAL_FUNC (finish_func), druid); + + if (i != 5) { + Bonobo_Control control; + GtkWidget *w; + CORBA_Environment ev; + + dpage = GNOME_DRUID_PAGE_STANDARD (page); + + CORBA_exception_init (&ev); + control = GNOME_Evolution_Wizard_getControl (corba_wizard, i, &ev); + if (BONOBO_EX (&ev)) { + g_warning ("Error getting page %d: %s", i, + CORBA_exception_id (&ev)); + CORBA_exception_free (&ev); + continue; + } + + w = bonobo_widget_new_control_from_objref (control, + CORBA_OBJECT_NIL); + gtk_box_pack_start (GTK_BOX (dpage->vbox), w, TRUE, + TRUE, 0); + gtk_widget_show_all (w); + } + } + gtk_signal_connect (GTK_OBJECT (druid->druid), "cancel", druid_cancel, druid); + + gnome_druid_set_buttons_sensitive (druid->druid, FALSE, TRUE, TRUE); } -static void -free_config_wizard (MailConfigWizard *mcw) +MailConfigDruid * +mail_config_druid_new (GNOME_Evolution_Shell shell) { - mail_account_gui_destroy (mcw->gui); + MailConfigDruid *new; - if (mcw->interior_pages) - g_ptr_array_free (mcw->interior_pages, TRUE); + new = (MailConfigDruid *) gtk_type_new (mail_config_druid_get_type ()); + construct (new); + new->shell = shell; - g_free (mcw); + return new; } -/* In-proc config druid */ +static void wizard_next_cb (EvolutionWizard *wizard, int page_num, MailConfigWizard *gui); static void -druid_cancel (GnomeDruid *druid, gpointer user_data) +goto_next_page (MailConfigWizard *gui) { - MailConfigWizard *mcw = user_data; - GtkWidget *window; - - window = glade_xml_get_widget (mcw->gui->xml, "account_druid"); - gtk_widget_destroy (window); - - free_config_wizard (mcw); + wizard_next_cb (gui->wizard, gui->page, gui); } static void -druid_finish (GnomeDruidPage *page, GnomeDruid *druid, gpointer user_data) +identity_activate_cb (GtkEntry *ent, gpointer user_data) { - MailConfigWizard *mcw = user_data; + MailConfigWizard *gui = (MailConfigWizard *) user_data; - mail_account_gui_save (mcw->gui); - druid_cancel (druid, user_data); + if (mail_account_gui_identity_complete (gui->gui, NULL)) + goto_next_page (gui); } static void -druid_prepare (GnomeDruidPage *page, GnomeDruid *druid, gpointer data) +source_activate_cb (GtkEntry *ent, gpointer user_data) { - MailConfigWizard *mcw = g_object_get_data (G_OBJECT (druid), "MailConfigWizard"); - int page_num = GPOINTER_TO_INT (data); + MailConfigWizard *gui = (MailConfigWizard *) user_data; - if (wizard_pages[page_num].prepare_func) - wizard_pages[page_num].prepare_func (mcw); + if (mail_account_gui_source_complete (gui->gui, NULL)) + goto_next_page (gui); } - -static gboolean -druid_back (GnomeDruidPage *page, GnomeDruid *druid, gpointer data) -{ - MailConfigWizard *mcw = g_object_get_data (G_OBJECT (druid), "MailConfigWizard"); - int page_num = GPOINTER_TO_INT (data); - if (wizard_pages[page_num].back_func) - return wizard_pages[page_num].back_func (mcw); - else - return FALSE; -} - -static gboolean -druid_next (GnomeDruidPage *page, GnomeDruid *druid, gpointer data) +static void +transport_activate_cb (GtkEntry *ent, gpointer user_data) { - MailConfigWizard *mcw = g_object_get_data (G_OBJECT (druid), "MailConfigWizard"); - int page_num = GPOINTER_TO_INT (data); + MailConfigWizard *gui = (MailConfigWizard *) user_data; - if (wizard_pages[page_num].next_func) - return wizard_pages[page_num].next_func (mcw); - else - return FALSE; + if (mail_account_gui_transport_complete (gui->gui, NULL)) + goto_next_page (gui); } - -MailConfigDruid * -mail_config_druid_new (void) +static void +management_activate_cb (GtkEntry *ent, gpointer user_data) { - MailConfigWizard *mcw; - GtkWidget *new, *page; - int i; + MailConfigWizard *gui = (MailConfigWizard *) user_data; - mcw = config_wizard_new (); - mcw->druid = (GnomeDruid *)glade_xml_get_widget (mcw->gui->xml, "druid"); - g_object_set_data (G_OBJECT (mcw->druid), "MailConfigWizard", mcw); - - mcw->interior_pages = g_ptr_array_new (); - for (i = 0; i < num_wizard_pages; i++) { - page = glade_xml_get_widget (mcw->gui->xml, - wizard_pages[i].page_name); - g_ptr_array_add (mcw->interior_pages, page); - gtk_box_pack_start (GTK_BOX (GNOME_DRUID_PAGE_STANDARD (page)->vbox), - get_page (mcw->gui->xml, i), - FALSE, FALSE, 0); - g_signal_connect (page, "back", G_CALLBACK (druid_back), - GINT_TO_POINTER (i)); - g_signal_connect (page, "next", G_CALLBACK (druid_next), - GINT_TO_POINTER (i)); - - /* At least in 2.0 (and probably 2.2 too), - * GnomeDruidPageStandard is broken and you need to - * connect_after to "prepare" or else its default - * method will run after your signal handler and - * undo its button sensitivity changes. - */ - g_signal_connect_after (page, "prepare", - G_CALLBACK (druid_prepare), - GINT_TO_POINTER (i)); - } - g_signal_connect (mcw->druid, "cancel", G_CALLBACK (druid_cancel), mcw); + if (management_check (gui)) + goto_next_page (gui); +} - mcw->last_page = (GnomeDruidPage *)glade_xml_get_widget (mcw->gui->xml, "finish_page"); - g_signal_connect (mcw->last_page, "finish", G_CALLBACK (druid_finish), mcw); +static BonoboControl * +get_fn (EvolutionWizard *wizard, + int page_num, + void *closure) +{ + MailConfigWizard *gui = closure; + BonoboControl *control; + GtkWidget *vbox, *widget; + static gboolean first_time = TRUE; + + if (gui->gui == NULL) { + if (gui->account == NULL) { + gui->account = make_account (); + gtk_object_set_data (GTK_OBJECT (wizard), "account-data", + gui->account); + } + + gui->gui = mail_account_gui_new (gui->account, NULL); + + /* set up signals, etc */ + gtk_signal_connect (GTK_OBJECT (gui->gui->account_name), + "changed", management_changed, gui); + gtk_signal_connect (GTK_OBJECT (gui->gui->full_name), + "changed", identity_changed, gui); + gtk_signal_connect (GTK_OBJECT (gui->gui->email_address), + "changed", identity_changed, gui); + gtk_signal_connect (GTK_OBJECT (gui->gui->reply_to), + "changed", identity_changed, gui); + gtk_signal_connect (GTK_OBJECT (gui->gui->source.hostname), + "changed", source_changed, gui); + gtk_signal_connect (GTK_OBJECT (gui->gui->source.username), + "changed", source_changed, gui); + 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); + gtk_signal_connect (GTK_OBJECT (gui->gui->transport_needs_auth), + "toggled", transport_changed, gui); + + gtk_signal_connect (GTK_OBJECT (gui->gui->account_name), + "activate", management_activate_cb, gui); + + gtk_signal_connect (GTK_OBJECT (gui->gui->full_name), + "activate", identity_activate_cb, gui); + gtk_signal_connect (GTK_OBJECT (gui->gui->email_address), + "activate", identity_activate_cb, gui); + gtk_signal_connect (GTK_OBJECT (gui->gui->reply_to), + "activate", identity_activate_cb, gui); + gtk_signal_connect (GTK_OBJECT (gui->gui->organization), + "activate", identity_activate_cb, gui); + + gtk_signal_connect (GTK_OBJECT (gui->gui->source.hostname), + "activate", source_activate_cb, gui); + gtk_signal_connect (GTK_OBJECT (gui->gui->source.username), + "activate", source_activate_cb, gui); + gtk_signal_connect (GTK_OBJECT (gui->gui->source.path), + "activate", source_activate_cb, gui); + + gtk_signal_connect (GTK_OBJECT (gui->gui->transport.hostname), + "activate", transport_activate_cb, gui); + gtk_signal_connect (GTK_OBJECT (gui->gui->transport.username), + "activate", transport_activate_cb, gui); + first_time = TRUE; + } + + /* Fill in the druid pages */ + vbox = gtk_vbox_new (FALSE, 0); + switch (page_num) { + case 0: + widget = create_label ("identity_html"); + gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0); + widget = glade_xml_get_widget (gui->gui->xml, "identity_required_frame"); + gtk_widget_reparent (widget, vbox); + gtk_box_set_child_packing (GTK_BOX (vbox), widget, FALSE, FALSE, 0, GTK_PACK_START); + widget = glade_xml_get_widget (gui->gui->xml, "identity_optional_frame"); + gtk_widget_reparent (widget, vbox); + gtk_box_set_child_packing (GTK_BOX (vbox), widget, FALSE, FALSE, 0, GTK_PACK_START); + break; + + case 1: + widget = create_label ("source_html"); + gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0); + widget = glade_xml_get_widget (gui->gui->xml, "source_vbox"); + gtk_widget_reparent (widget, vbox); + gtk_widget_show (widget); + break; + + case 2: + widget = create_label ("extra_html"); + gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0); + widget = glade_xml_get_widget (gui->gui->xml, "extra_vbox"); + gtk_widget_reparent (widget, vbox); + break; + + case 3: + widget = create_label ("transport_html"); + gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0); + widget = glade_xml_get_widget (gui->gui->xml, "transport_vbox"); + gtk_widget_reparent (widget, vbox); + gtk_widget_show (widget); + break; + + case 4: + widget = glade_xml_get_widget (gui->gui->xml, "management_frame"); + gtk_widget_reparent (widget, vbox); + break; - gnome_druid_set_buttons_sensitive (mcw->druid, FALSE, TRUE, TRUE, FALSE); - gtk_widget_show_all (GTK_WIDGET (mcw->druid)); - mail_account_gui_setup (mcw->gui, NULL); + default: + return NULL; + } + + gtk_widget_show (vbox); + control = bonobo_control_new (vbox); - new = glade_xml_get_widget (mcw->gui->xml, "account_druid"); - gtk_window_set_type_hint ((GtkWindow *) new, GDK_WINDOW_TYPE_HINT_DIALOG); + if (first_time) { + mail_account_gui_setup (gui->gui, NULL); + first_time = FALSE; + } - return (MailConfigDruid *) new; + return control; } +typedef gboolean (*NextFunc)(EvolutionWizard *wizard, gpointer data); -/* CORBA wizard */ +static struct { + NextFunc next_func; + GtkSignalFunc prepare_func; + NextFunc back_func; + GtkSignalFunc finish_func; + GtkSignalFunc help_func; +} wizard_pages[] = { + { identity_next, + GTK_SIGNAL_FUNC (identity_prepare), + NULL, + GTK_SIGNAL_FUNC (NULL), + GTK_SIGNAL_FUNC (NULL) }, + { source_next, + GTK_SIGNAL_FUNC (source_prepare), + NULL, + GTK_SIGNAL_FUNC (NULL), + GTK_SIGNAL_FUNC (NULL) }, + { NULL, + GTK_SIGNAL_FUNC (extra_prepare), + NULL, + GTK_SIGNAL_FUNC (NULL), + GTK_SIGNAL_FUNC (NULL) }, + { transport_next, + GTK_SIGNAL_FUNC (transport_prepare), + transport_back, + GTK_SIGNAL_FUNC (NULL), + GTK_SIGNAL_FUNC (NULL) }, + { NULL, + GTK_SIGNAL_FUNC (management_prepare), + NULL, + GTK_SIGNAL_FUNC (NULL), + GTK_SIGNAL_FUNC (NULL) } +}; static void wizard_next_cb (EvolutionWizard *wizard, - int page_num, - MailConfigWizard *mcw) + int page_num, + MailConfigWizard *gui) { - if (page_num >= MAIL_CONFIG_WIZARD_PAGE_MANAGEMENT) - return; - - if (wizard_pages[page_num].next_func && - wizard_pages[page_num].next_func (mcw)) - return; - - evolution_wizard_set_page (wizard, page_num + 1, NULL); + if (wizard_pages[page_num].next_func == NULL + || !(wizard_pages[page_num].next_func (wizard, gui))) { + if (page_num < 5-1) { + evolution_wizard_set_page(wizard, page_num+1, NULL); + } + } } static void wizard_prepare_cb (EvolutionWizard *wizard, - int page_num, - MailConfigWizard *mcw) + int page_num, + MailConfigWizard *gui) { - if (wizard_pages[page_num].prepare_func) - wizard_pages[page_num].prepare_func (mcw); + if (wizard_pages[page_num].prepare_func != NULL) { + wizard_pages[page_num].prepare_func (wizard, gui); + } } static void wizard_back_cb (EvolutionWizard *wizard, - int page_num, - MailConfigWizard *mcw) + int page_num, + MailConfigWizard *gui) { - if (page_num >= MAIL_CONFIG_WIZARD_NUM_PAGES) { - evolution_wizard_set_page (wizard, MAIL_CONFIG_WIZARD_PAGE_MANAGEMENT, NULL); - return; - } - - if (wizard_pages[page_num].back_func && - wizard_pages[page_num].back_func (mcw)) - return; - - if (page_num > 0) - evolution_wizard_set_page (wizard, page_num - 1, NULL); + if (page_num >= 5) + evolution_wizard_set_page(wizard, 4, NULL); + else if (wizard_pages[page_num].back_func == NULL + || !(wizard_pages[page_num].back_func (wizard, gui))) { + if (page_num > 0) + evolution_wizard_set_page(wizard, page_num-1, NULL); + } } static void wizard_finish_cb (EvolutionWizard *wizard, + int page_num, MailConfigWizard *w) { MailAccountGui *gui = w->gui; - + /* Save the settings for that account */ if (mail_account_gui_save (gui) == FALSE) /* problem. Um, how to keep the druid alive? */ return; + if (gui->account->source) + gui->account->source->enabled = TRUE; + /* Write out the config info */ mail_config_write (); mail_account_gui_destroy (gui); w->gui = NULL; + w->account = NULL; } static void wizard_cancel_cb (EvolutionWizard *wizard, - MailConfigWizard *mcw) + int page_num, + MailConfigWizard *gui) { - mail_account_gui_destroy (mcw->gui); - mcw->gui = NULL; + mail_account_gui_destroy (gui->gui); + gui->gui = NULL; } static void wizard_help_cb (EvolutionWizard *wizard, - int page_num, - MailConfigWizard *mcw) + int page_num, + MailConfigWizard *gui) { } -BonoboObject * -evolution_mail_config_wizard_new (void) +static void +wizard_free (MailConfigWizard *wizard) +{ + if (wizard->gui) + mail_account_gui_destroy (wizard->gui); + + if (wizard->account) + account_destroy (wizard->account); + + g_free (wizard); +} + +static BonoboObject * +evolution_mail_config_wizard_factory_fn (BonoboGenericFactory *factory, + void *closure) { EvolutionWizard *wizard; - MailConfigWizard *mcw; - GdkPixbuf *icon; - int i; + MailConfigAccount *account; + MailConfigWizard *gui; - mcw = config_wizard_new (); - mail_account_gui_setup (mcw->gui, NULL); + account = make_account (); - wizard = evolution_wizard_new (); - for (i = 0; i < MAIL_CONFIG_WIZARD_NUM_PAGES; i++) { - icon = gdk_pixbuf_new_from_file (wizard_pages[i].icon_path, NULL); - evolution_wizard_add_page (wizard, _(wizard_pages[i].title), - icon, get_page (mcw->gui->xml, i)); - g_object_unref (icon); - } + gui = g_new (MailConfigWizard, 1); + gui->gui = NULL; + gui->account = account; + gui->identity_copied = FALSE; + gui->last_source = NULL; + gui->page = MAIL_CONFIG_WIZARD_PAGE_NONE; - g_object_set_data_full (G_OBJECT (wizard), "MailConfigWizard", - mcw, (GDestroyNotify)free_config_wizard); - mcw->corba_wizard = wizard; + wizard = evolution_wizard_new (get_fn, 5, gui); + account_wizard = wizard; - g_signal_connect (wizard, "next", G_CALLBACK (wizard_next_cb), mcw); - g_signal_connect (wizard, "prepare", G_CALLBACK (wizard_prepare_cb), mcw); - g_signal_connect (wizard, "back", G_CALLBACK (wizard_back_cb), mcw); - g_signal_connect (wizard, "finish", G_CALLBACK (wizard_finish_cb), mcw); - g_signal_connect (wizard, "cancel", G_CALLBACK (wizard_cancel_cb), mcw); - g_signal_connect (wizard, "help", G_CALLBACK (wizard_help_cb), mcw); + gtk_object_set_data_full (GTK_OBJECT (account_wizard), + "account-data", gui, + (GtkDestroyNotify) wizard_free); + gui->wizard = wizard; - return BONOBO_OBJECT (wizard); + gtk_signal_connect (GTK_OBJECT (wizard), "next", + GTK_SIGNAL_FUNC (wizard_next_cb), gui); + gtk_signal_connect (GTK_OBJECT (wizard), "prepare", + GTK_SIGNAL_FUNC (wizard_prepare_cb), gui); + gtk_signal_connect (GTK_OBJECT (wizard), "back", + GTK_SIGNAL_FUNC (wizard_back_cb), gui); + gtk_signal_connect (GTK_OBJECT (wizard), "finish", + GTK_SIGNAL_FUNC (wizard_finish_cb), gui); + gtk_signal_connect (GTK_OBJECT (wizard), "cancel", + GTK_SIGNAL_FUNC (wizard_cancel_cb), gui); + gtk_signal_connect (GTK_OBJECT (wizard), "help", + GTK_SIGNAL_FUNC (wizard_help_cb), gui); + + return BONOBO_OBJECT (wizard); +} + +void +evolution_mail_config_wizard_init (void) +{ + BonoboGenericFactory *factory; + + factory = bonobo_generic_factory_new (WIZARD_IID, + evolution_mail_config_wizard_factory_fn, NULL); + + if (factory == NULL) { + g_warning ("Error starting factory"); + return; + } + + bonobo_running_context_auto_exit_unref (BONOBO_OBJECT (factory)); } |