[evolution-exchange] Bug #580904 - Kill libgnome(ui) dependency



commit a0ba3a0ce8ea29c6be2290e63b6d3e83a61805e7
Author: Milan Crha <mcrha redhat com>
Date:   Thu Aug 20 12:21:19 2009 +0200

    Bug #580904 - Kill libgnome(ui) dependency

 configure.ac                             |    2 -
 storage/Makefile.am                      |    1 -
 storage/exchange-autoconfig-wizard.c     |  563 ++++++++++++++++-----------
 storage/exchange-autoconfig-wizard.glade |  640 ------------------------------
 storage/exchange-autoconfig-wizard.h     |    2 +-
 storage/main.c                           |   13 +-
 storage/migr-test.c                      |    5 +-
 storage/ximian-connector-setup.c         |   29 +-
 8 files changed, 363 insertions(+), 892 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index e165b12..4635625 100644
--- a/configure.ac
+++ b/configure.ac
@@ -14,7 +14,6 @@ m4_define([eds_minimum_version], [eex_version])
 m4_define([gconf_minimum_version], [2.0.0])             # XXX Just a Guess
 m4_define([libbonobo_minimum_version], [2.20.3])
 m4_define([libglade_minimum_version], [2.0.0])          # XXX Just a Guess
-m4_define([libgnomeui_minimum_version], [2.0.0])        # XXX Just a Guess
 m4_define([libxml_minimum_version], [2.0.0])            # XXX Just a Guess
 m4_define([libsoup_minimum_version], [2.3.0])
 
@@ -143,7 +142,6 @@ PKG_CHECK_MODULES(GNOME_PLATFORM,
 	 gconf-2.0 >= gconf_minimum_version
 	 libbonobo-2.0 >= libbonobo_minimum_version
 	 libglade-2.0 >= libglade_minimum_version
-	 libgnomeui-2.0 >= libgnomeui_minimum_version
 	 libxml-2.0 >= libxml_minimum_version
 	 libsoup-2.4 >= libsoup_minimum_version])
 
diff --git a/storage/Makefile.am b/storage/Makefile.am
index 40cdfd4..3d90152 100644
--- a/storage/Makefile.am
+++ b/storage/Makefile.am
@@ -109,7 +109,6 @@ images_DATA = \
 
 gladedir   = $(CONNECTOR_DATADIR)/glade
 glade_DATA = \
-	exchange-autoconfig-wizard.glade \
 	exchange-change-password.glade \
 	exchange-delegates.glade \
 	exchange-oof.glade \
diff --git a/storage/exchange-autoconfig-wizard.c b/storage/exchange-autoconfig-wizard.c
index 493781e..f9b463a 100644
--- a/storage/exchange-autoconfig-wizard.c
+++ b/storage/exchange-autoconfig-wizard.c
@@ -35,32 +35,24 @@
 #include <libedataserverui/e-passwords.h>
 
 #include <gconf/gconf-client.h>
-#include <glade/glade-xml.h>
 #include <gtk/gtk.h>
-#include <libgnomeui/gnome-druid.h>
-#include <libgnomeui/gnome-druid-page-standard.h>
 
 #include "exchange-storage.h"
 
 #ifdef G_OS_WIN32
 
-#undef CONNECTOR_GLADEDIR
-#define CONNECTOR_GLADEDIR _exchange_storage_gladedir
-
 #undef CONNECTOR_IMAGESDIR
 #define CONNECTOR_IMAGESDIR _exchange_storage_imagesdir
 
 #endif
 
 typedef struct {
-	GnomeDruid *druid;
+	GtkWidget *assistant;
+	gint active_page;
+	gboolean changing;
 
-	GladeXML *xml;
 	E2kAutoconfig *ac;
 	E2kOperation op;
-	GPtrArray *pages;
-
-	GtkWindow *window;
 
 	/* OWA Page */
 	GtkEntry *owa_uri_entry;
@@ -83,84 +75,147 @@ typedef struct {
 } ExchangeAutoconfigGUI;
 
 enum {
+	EXCHANGE_AUTOCONFIG_PAGE_START,
 	EXCHANGE_AUTOCONFIG_PAGE_OWA,
 	EXCHANGE_AUTOCONFIG_PAGE_GC,
 	EXCHANGE_AUTOCONFIG_PAGE_FAILURE,
-	EXCHANGE_AUTOCONFIG_PAGE_VERIFY
+	EXCHANGE_AUTOCONFIG_PAGE_VERIFY,
+	EXCHANGE_AUTOCONFIG_PAGE_FINISH
 };
 
-static void owa_page_changed (GtkEntry *entry, ExchangeAutoconfigGUI *gui);
-static void gc_page_changed (GtkEntry *entry, ExchangeAutoconfigGUI *gui);
-static void verify_page_changed (GtkEntry *entry, ExchangeAutoconfigGUI *gui);
+static void assistant_page_content_changed (GtkWidget *sender, ExchangeAutoconfigGUI *gui);
 
-static void
-autoconfig_gui_set_page (ExchangeAutoconfigGUI *gui, gint page)
+static inline gboolean
+check_field (GtkEntry *entry)
 {
-	gnome_druid_set_page (gui->druid, gui->pages->pdata[page]);
+	return (*gtk_entry_get_text (entry) != '\0');
 }
 
 static void
-autoconfig_gui_set_next_sensitive (ExchangeAutoconfigGUI *gui,
-				   gboolean next_sensitive)
+fill_failure_page (ExchangeAutoconfigGUI *gui, const gchar *url, const gchar *fmt, ...)
 {
-	gnome_druid_set_buttons_sensitive (gui->druid, TRUE,
-					   next_sensitive,
-					   TRUE, FALSE);
+	va_list ap;
+	gchar *text;
+
+	va_start (ap, fmt);
+	text = g_strdup_vprintf (fmt, ap);
+	va_end (ap);
+
+	gtk_label_set_text (gui->failure_label, text);
+
+	g_free (text);
+
+	if (gui->failure_href)
+		gtk_widget_destroy (gui->failure_href);
+
+	if (url) {
+		gui->failure_href = gtk_link_button_new (url);
+		gtk_box_pack_start (gui->failure_vbox, gui->failure_href, FALSE, FALSE, 0);
+		gtk_widget_show (gui->failure_href);
+	} else {
+		gui->failure_href = NULL;
+	}
 }
 
-#define SETUP_ENTRY(name, changed)				\
-	gui->name = (GtkEntry *)				\
-		glade_xml_get_widget (gui->xml, #name);		\
-	g_signal_connect (gui->name, "changed",			\
-			  G_CALLBACK (changed), gui);
+#define CONNECT_CHANGE_SIGNAL(_where,_signal_name) g_signal_connect (_where, _signal_name, G_CALLBACK (assistant_page_content_changed), gui)
 
-static ExchangeAutoconfigGUI *
-autoconfig_gui_new (void)
+static GtkWidget *
+create_page_vbox (GtkAssistant *assistant, GdkPixbuf *logo, const gchar *page_title, const gchar *page_info, GtkAssistantPageType page_type, GtkWidget **page, gint *page_index)
 {
-	ExchangeAutoconfigGUI *gui;
-	gchar *gladefile;
+	GtkWidget *vbox;
+	gboolean is_edge = page_type == GTK_ASSISTANT_PAGE_INTRO || page_type == GTK_ASSISTANT_PAGE_CONFIRM;
 
-	gui = g_new0 (ExchangeAutoconfigGUI, 1);
+	g_return_val_if_fail (assistant != NULL, NULL);
+	g_return_val_if_fail (page != NULL, NULL);
+	g_return_val_if_fail (page_index != NULL, NULL);
+
+	vbox = gtk_vbox_new (FALSE, 0);
+
+	gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
 
-	gladefile = g_build_filename (CONNECTOR_GLADEDIR,
-				      "exchange-autoconfig-wizard.glade",
-				      NULL);
-	gui->xml = glade_xml_new (gladefile, NULL, NULL);
-	g_free (gladefile);
-	if (!gui->xml) {
-		g_warning ("Could not find exchange-autoconfig-wizard.glade");
-		g_free (gui);
-		return NULL;
+	*page = vbox;
+	*page_index = gtk_assistant_append_page (assistant, vbox);
+
+	gtk_assistant_set_page_type (assistant, vbox, page_type);
+	gtk_assistant_set_page_title (assistant, vbox, page_title);
+	gtk_assistant_set_page_complete (assistant, vbox, is_edge);
+	gtk_assistant_set_page_header_image (assistant, vbox, logo);
+
+	if (page_info) {
+		GtkWidget *label;
+
+		label = gtk_label_new (page_info);
+		gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+		gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+
+		gtk_box_pack_start (GTK_BOX (vbox), label, is_edge, is_edge, 0);
 	}
 
-	gui->ac = e2k_autoconfig_new (NULL, NULL, NULL,
-				      E2K_AUTOCONFIG_USE_EITHER);
+	return vbox;
+}
+
+static GtkWidget *
+add_table_row (GtkTable *table, gint row, const gchar *label_text, GtkWidget *action_widget)
+{
+	GtkWidget *w;
 
-	SETUP_ENTRY (owa_uri_entry, owa_page_changed);
-	SETUP_ENTRY (username_entry, owa_page_changed);
-	SETUP_ENTRY (password_entry, owa_page_changed);
-	gui->remember_password_check = (GtkToggleButton *)
-		glade_xml_get_widget (gui->xml, "remember_password_check");
+	w = gtk_label_new (label_text);
+	gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.5);
+	gtk_table_attach (table, w, 0, 1, row, row + 1, GTK_FILL, 0, 0, 0);
 
-	SETUP_ENTRY (gc_server_entry, gc_page_changed);
+	w = action_widget;
+	gtk_table_attach (table, w, 1, 2, row, row + 1, GTK_FILL | GTK_EXPAND, 0, 0, 0);
 
-	gui->failure_label = (GtkLabel *)
-		glade_xml_get_widget (gui->xml, "failure_label");
-	gui->failure_vbox = (GtkBox *)
-		glade_xml_get_widget (gui->xml, "failure_vbox");
+	return w;
+}
 
-	SETUP_ENTRY (name_entry, verify_page_changed);
-	SETUP_ENTRY (email_entry, verify_page_changed);
-	gui->default_account_check = (GtkToggleButton *)
-		glade_xml_get_widget (gui->xml, "default_account_check");
+static void
+start_page_create (ExchangeAutoconfigGUI *gui, GdkPixbuf *logo, GtkWidget **page, gint *page_index)
+{
+	GtkWidget *vbox;
 
-	return gui;
+	vbox = create_page_vbox (GTK_ASSISTANT (gui->assistant), logo, _("Welcome"), _("Welcome to Evolution Connector for Microsoft Exchange.\nThe next few screens will help you configure Evolution\nto connect to your Exchange account.\n\nPlease click the \"Forward\" button to continue."), GTK_ASSISTANT_PAGE_INTRO, page, page_index);
+	g_return_if_fail (vbox != NULL);
+
+	gtk_widget_show_all (vbox);
 }
 
-static inline gboolean
-check_field (GtkEntry *entry)
+static void
+owa_page_create (ExchangeAutoconfigGUI *gui, GdkPixbuf *logo, GtkWidget **page, gint *page_index)
 {
-	return (*gtk_entry_get_text (entry) != '\0');
+	GtkWidget *vbox, *w;
+	GtkTable *table;
+
+	vbox = create_page_vbox (GTK_ASSISTANT (gui->assistant), logo, _("Exchange Configuration"), _("Evolution Connector for Microsoft Exchange can use account information from your existing Outlook Web Access (OWA) account.\n\nEnter your OWA site address (URL), username, and password, then click \"Forward\".\n"), GTK_ASSISTANT_PAGE_CONTENT, page, page_index);
+	g_return_if_fail (vbox != NULL);
+
+	table = GTK_TABLE (gtk_table_new (4, 2, FALSE));
+	gtk_container_set_border_width (GTK_CONTAINER (table), 6);
+	gtk_table_set_row_spacings (table, 6);
+	gtk_table_set_col_spacings (table, 6);
+
+	w = add_table_row (table, 0, _("OWA URL:"), gtk_entry_new ());
+	CONNECT_CHANGE_SIGNAL (w, "changed");
+	gui->owa_uri_entry = GTK_ENTRY (w);
+
+	w = add_table_row (table, 1, _("Username:"), gtk_entry_new ());
+	CONNECT_CHANGE_SIGNAL (w, "changed");
+	gui->username_entry = GTK_ENTRY (w);
+
+	w = add_table_row (table, 2, _("Password:"), gtk_entry_new ());
+	CONNECT_CHANGE_SIGNAL (w, "changed");
+	gui->password_entry = GTK_ENTRY (w);
+	gtk_entry_set_visibility (gui->password_entry, FALSE);
+
+	w = gtk_check_button_new_with_label (_("Remember this password"));
+	CONNECT_CHANGE_SIGNAL (w, "toggled");
+	gtk_table_attach (table, w, 0, 2, 3, 4, GTK_FILL, 0, 0, 0);
+
+	gui->remember_password_check = GTK_TOGGLE_BUTTON (w);
+
+	gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (table), TRUE, TRUE, 0);
+
+	gtk_widget_show_all (vbox);
 }
 
 static void
@@ -171,43 +226,48 @@ owa_page_prepare (ExchangeAutoconfigGUI *gui)
 
 	if (gui->ac->owa_uri)
 		gtk_entry_set_text (gui->owa_uri_entry, gui->ac->owa_uri);
-
-	if (!gui->window)
-		gui->window = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gui->owa_uri_entry)));
-
-	owa_page_changed (NULL, gui);
 }
 
 static gboolean
-owa_page_next (ExchangeAutoconfigGUI *gui)
+owa_page_check (ExchangeAutoconfigGUI *gui)
+{
+	return (check_field (gui->owa_uri_entry) &&
+		check_field (gui->username_entry) &&
+		check_field (gui->password_entry));
+}
+
+static gint
+owa_page_get_next (ExchangeAutoconfigGUI *gui)
 {
 	E2kAutoconfigResult result;
 	const gchar *old, *new;
+	gint next_page = EXCHANGE_AUTOCONFIG_PAGE_FAILURE;
 
 	e2k_autoconfig_set_owa_uri (gui->ac, gtk_entry_get_text (gui->owa_uri_entry));
 	e2k_autoconfig_set_username (gui->ac, gtk_entry_get_text (gui->username_entry));
 	e2k_autoconfig_set_password (gui->ac, gtk_entry_get_text (gui->password_entry));
 
-	gtk_widget_set_sensitive (GTK_WIDGET (gui->window), FALSE);
+	gtk_widget_set_sensitive (GTK_WIDGET (gui->assistant), FALSE);
 	e2k_operation_init (&gui->op);
 	result = e2k_autoconfig_check_exchange (gui->ac, &gui->op);
 
 	if (result == E2K_AUTOCONFIG_OK) {
 		result = e2k_autoconfig_check_global_catalog (gui->ac, &gui->op);
 		e2k_operation_free (&gui->op);
-		gtk_widget_set_sensitive (GTK_WIDGET (gui->window), TRUE);
+		gtk_widget_set_sensitive (GTK_WIDGET (gui->assistant), TRUE);
 
 		if (result == E2K_AUTOCONFIG_OK)
-			autoconfig_gui_set_page (gui, EXCHANGE_AUTOCONFIG_PAGE_VERIFY);
+			next_page = EXCHANGE_AUTOCONFIG_PAGE_VERIFY;
 		else
-			autoconfig_gui_set_page (gui, EXCHANGE_AUTOCONFIG_PAGE_GC);
-		return TRUE;
+			next_page = EXCHANGE_AUTOCONFIG_PAGE_GC;
+
+		return next_page;
 	}
 
 	/* Update the entries with anything we autodetected */
 	owa_page_prepare (gui);
 	e2k_operation_free (&gui->op);
-	gtk_widget_set_sensitive (GTK_WIDGET (gui->window), TRUE);
+	gtk_widget_set_sensitive (GTK_WIDGET (gui->assistant), TRUE);
 
 	switch (result) {
 	case E2K_AUTOCONFIG_CANT_CONNECT:
@@ -219,31 +279,31 @@ owa_page_next (ExchangeAutoconfigGUI *gui)
 			new = "http";
 		}
 
-		e_notice (gui->window, GTK_MESSAGE_ERROR,
+		fill_failure_page (gui, NULL,
 			  _("Could not connect to the Exchange "
 			    "server.\nMake sure the URL is correct "
 			    "(try \"%s\" instead of \"%s\"?) "
 			    "and try again."), new, old);
-		return TRUE;
+		break;
 
 	case E2K_AUTOCONFIG_CANT_RESOLVE:
-		e_notice (gui->window, GTK_MESSAGE_ERROR,
+		fill_failure_page (gui, NULL,
 			  _("Could not locate Exchange server.\n"
 			    "Make sure the server name is spelled correctly "
 			    "and try again."));
-		return TRUE;
+		break;
 
 	case E2K_AUTOCONFIG_AUTH_ERROR:
 	case E2K_AUTOCONFIG_AUTH_ERROR_TRY_NTLM:
 	case E2K_AUTOCONFIG_AUTH_ERROR_TRY_BASIC:
-		e_notice (gui->window, GTK_MESSAGE_ERROR,
+		fill_failure_page (gui, NULL,
 			  _("Could not authenticate to the Exchange "
 			    "server.\nMake sure the username and "
 			    "password are correct and try again."));
-		return TRUE;
+		break;
 
 	case E2K_AUTOCONFIG_AUTH_ERROR_TRY_DOMAIN:
-		e_notice (gui->window, GTK_MESSAGE_ERROR,
+		fill_failure_page (gui, NULL,
 			  _("Could not authenticate to the Exchange "
 			    "server.\nMake sure the username and "
 			    "password are correct and try again.\n\n"
@@ -251,18 +311,17 @@ owa_page_next (ExchangeAutoconfigGUI *gui)
 			    "domain name as part of your username "
 			    "(eg, \"MY-DOMAIN\\%s\")."),
 			  gui->ac->username);
-		return TRUE;
+		break;
 
 	case E2K_AUTOCONFIG_NO_OWA:
 	case E2K_AUTOCONFIG_NOT_EXCHANGE:
-		e_notice (gui->window, GTK_MESSAGE_ERROR,
+		fill_failure_page (gui, NULL,
 			  _("Could not find OWA data at the indicated URL.\n"
 			    "Make sure the URL is correct and try again."));
-		return TRUE;
+		break;
 
 	case E2K_AUTOCONFIG_CANT_BPROPFIND:
-		gtk_label_set_text (
-			gui->failure_label,
+		fill_failure_page (gui, "http://support.novell.com/cgi-bin/search/searchtid.cgi?/ximian/ximian328.html";,
 			_("Evolution Connector for Microsoft Exchange requires "
 			  "access to certain functionality on the Exchange "
 			  "server that appears to be disabled or blocked.  "
@@ -272,113 +331,146 @@ owa_page_next (ExchangeAutoconfigGUI *gui)
 			  "the Evolution Connector.\n\n"
 			  "For information to provide to your Exchange "
 			  "administrator, please follow the link below:"));
-
-		if (gui->failure_href)
-			gtk_widget_destroy (gui->failure_href);
-		gui->failure_href = gtk_link_button_new ("http://support.novell.com/cgi-bin/search/searchtid.cgi?/ximian/ximian328.html";);
-		gtk_box_pack_start (gui->failure_vbox, gui->failure_href, FALSE, FALSE, 0);
-		gtk_widget_show (gui->failure_href);
-
-		autoconfig_gui_set_page (gui, EXCHANGE_AUTOCONFIG_PAGE_FAILURE);
-		return TRUE;
+		break;
 
 	case E2K_AUTOCONFIG_EXCHANGE_5_5:
-		gtk_label_set_text (
-			gui->failure_label,
+		fill_failure_page (gui, NULL,
 			_("The Exchange server URL you provided is for an "
 			  "Exchange 5.5 server. Evolution Connector for "
 			  "Microsoft Exchange supports Microsoft Exchange 2000 "
 			  "and 2003 only."));
-
-		if (gui->failure_href) {
-			gtk_widget_destroy (gui->failure_href);
-			gui->failure_href = NULL;
-		}
-		autoconfig_gui_set_page (gui, EXCHANGE_AUTOCONFIG_PAGE_FAILURE);
-		return TRUE;
+		break;
 
 	default:
-		e_notice (gui->window, GTK_MESSAGE_ERROR,
+		fill_failure_page (gui, NULL,
 			  _("Could not configure Exchange account because "
 			    "an unknown error occurred. Check the URL, "
 			    "username, and password, and try again."));
-		return TRUE;
+		break;
 	}
-}
 
-static gboolean
-owa_page_check (ExchangeAutoconfigGUI *gui)
-{
-	return (check_field (gui->owa_uri_entry) &&
-		check_field (gui->username_entry) &&
-		check_field (gui->password_entry));
+	/* can move forward only when not requested to stay on the actual page */
+	return next_page;
 }
 
 static void
-owa_page_changed (GtkEntry *entry, ExchangeAutoconfigGUI *gui)
+gc_page_create (ExchangeAutoconfigGUI *gui, GdkPixbuf *logo, GtkWidget **page, gint *page_index)
 {
-	autoconfig_gui_set_next_sensitive (gui, owa_page_check (gui));
+	GtkWidget *vbox, *w;
+	GtkTable *table;
+
+	vbox = create_page_vbox (GTK_ASSISTANT (gui->assistant), logo, _("Exchange Configuration"), _("Evolution Connector for Microsoft Exchange could not find the Global Catalog replica for your site. Please enter the name of your Global Catalog server. You may need to ask your system administrator for the correct value."), GTK_ASSISTANT_PAGE_CONTENT, page, page_index);
+	g_return_if_fail (vbox != NULL);
+
+	table = GTK_TABLE (gtk_table_new (1, 2, FALSE));
+	gtk_container_set_border_width (GTK_CONTAINER (table), 6);
+	gtk_table_set_row_spacings (table, 6);
+	gtk_table_set_col_spacings (table, 6);
+
+	w = add_table_row (table, 0, _("GC Server:"), gtk_entry_new ());
+	CONNECT_CHANGE_SIGNAL (w, "changed");
+	gui->gc_server_entry = GTK_ENTRY (w);
+
+	gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (table), TRUE, TRUE, 0);
+
+	gtk_widget_show_all (vbox);
 }
 
-static void
-gc_page_prepare (ExchangeAutoconfigGUI *gui)
+static gboolean
+gc_page_check (ExchangeAutoconfigGUI *gui)
 {
-	gc_page_changed (NULL, gui);
+	return check_field (gui->gc_server_entry);
 }
 
-static gboolean
-gc_page_next (ExchangeAutoconfigGUI *gui)
+static gint
+gc_page_get_next (ExchangeAutoconfigGUI *gui)
 {
 	E2kAutoconfigResult result;
+	gint next_page = EXCHANGE_AUTOCONFIG_PAGE_FAILURE;
 
 	e2k_autoconfig_set_gc_server (gui->ac, gtk_entry_get_text (gui->gc_server_entry), -1, E2K_AUTOCONFIG_USE_GAL_DEFAULT);
 
-	gtk_widget_set_sensitive (GTK_WIDGET (gui->window), FALSE);
+	gtk_widget_set_sensitive (GTK_WIDGET (gui->assistant), FALSE);
 	e2k_operation_init (&gui->op);
 	result = e2k_autoconfig_check_global_catalog (gui->ac, &gui->op);
 	e2k_operation_free (&gui->op);
-	gtk_widget_set_sensitive (GTK_WIDGET (gui->window), TRUE);
+	gtk_widget_set_sensitive (GTK_WIDGET (gui->assistant), TRUE);
 
-	if (result == E2K_AUTOCONFIG_OK)
-		autoconfig_gui_set_page (gui, EXCHANGE_AUTOCONFIG_PAGE_VERIFY);
-	else if (result == E2K_AUTOCONFIG_AUTH_ERROR_TRY_DOMAIN) {
-		e_notice (gui->window, GTK_MESSAGE_ERROR,
+	if (result == E2K_AUTOCONFIG_OK) {
+		next_page = EXCHANGE_AUTOCONFIG_PAGE_VERIFY;
+	} else if (result == E2K_AUTOCONFIG_AUTH_ERROR_TRY_DOMAIN) {
+		fill_failure_page (gui, NULL,
 			  _("Could not authenticate to the Global Catalog "
 			    "server. You may need to go back and specify "
 			    "the Windows domain name as part of your "
 			    "username (eg, \"MY-DOMAIN\\%s\")."),
 			  gui->ac->username);
 	} else {
-		e_notice (gui->window, GTK_MESSAGE_ERROR,
+		fill_failure_page (gui, NULL,
 			  _("Could not connect to specified server.\n"
 			    "Please check the server name and try again."));
 	}
-	return TRUE;
-}
 
-static gboolean
-gc_page_check (ExchangeAutoconfigGUI *gui)
-{
-	return check_field (gui->gc_server_entry);
+	return next_page;
 }
 
 static void
-gc_page_changed (GtkEntry *entry, ExchangeAutoconfigGUI *gui)
+failure_page_create (ExchangeAutoconfigGUI *gui, GdkPixbuf *logo, GtkWidget **page, gint *page_index)
 {
-	autoconfig_gui_set_next_sensitive (gui, gc_page_check (gui));
+	GtkWidget *vbox, *w;
+
+	vbox = create_page_vbox (GTK_ASSISTANT (gui->assistant), logo, _("Configuration Failed"), _("Evolution Connector for Microsoft Exchange has encountered a problem configuring your Exchange account."), GTK_ASSISTANT_PAGE_CONTENT, page, page_index);
+	g_return_if_fail (vbox != NULL);
+
+	w = gtk_label_new (NULL);
+	gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.0);
+	gtk_label_set_line_wrap (GTK_LABEL (w), TRUE);
+
+	gui->failure_vbox = GTK_BOX (vbox);
+	gui->failure_label = GTK_LABEL (w);
+
+	gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0);
+
+	gtk_widget_show_all (vbox);
 }
 
-static void
-failure_page_prepare (ExchangeAutoconfigGUI *gui)
+static gboolean
+failure_page_check (ExchangeAutoconfigGUI *gui)
 {
-	autoconfig_gui_set_next_sensitive (gui, FALSE);
+	return FALSE;
 }
 
-static gboolean
-failure_page_back (ExchangeAutoconfigGUI *gui)
+static void
+verify_page_create (ExchangeAutoconfigGUI *gui, GdkPixbuf *logo, GtkWidget **page, gint *page_index)
 {
-	autoconfig_gui_set_page (gui, EXCHANGE_AUTOCONFIG_PAGE_OWA);
-	return TRUE;
+	GtkWidget *vbox, *w;
+	GtkTable *table;
+
+	vbox = create_page_vbox (GTK_ASSISTANT (gui->assistant), logo, _("Exchange Configuration"), _("Your account information is as follows. Please correct any errors, then click \"Forward\"."), GTK_ASSISTANT_PAGE_CONTENT, page, page_index);
+	g_return_if_fail (vbox != NULL);
+
+	table = GTK_TABLE (gtk_table_new (3, 2, FALSE));
+	gtk_container_set_border_width (GTK_CONTAINER (table), 6);
+	gtk_table_set_row_spacings (table, 6);
+	gtk_table_set_col_spacings (table, 6);
+
+	w = add_table_row (table, 0, _("Full Name:"), gtk_entry_new ());
+	CONNECT_CHANGE_SIGNAL (w, "changed");
+	gui->name_entry = GTK_ENTRY (w);
+
+	w = add_table_row (table, 1, _("Email Address:"), gtk_entry_new ());
+	CONNECT_CHANGE_SIGNAL (w, "changed");
+	gui->email_entry = GTK_ENTRY (w);
+
+	w = gtk_check_button_new_with_label ("Make this my default account");
+	CONNECT_CHANGE_SIGNAL (w, "toggled");
+	gtk_table_attach (table, w, 0, 2, 2, 3, GTK_FILL, 0, 0, 10);
+
+	gui->default_account_check = GTK_TOGGLE_BUTTON (w);
+
+	gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (table), TRUE, TRUE, 0);
+
+	gtk_widget_show_all (vbox);
 }
 
 static void
@@ -392,44 +484,36 @@ verify_page_prepare (ExchangeAutoconfigGUI *gui)
 		gtk_entry_set_text (gui->email_entry, gui->ac->email);
 	else
 		gtk_entry_set_text (gui->email_entry, _("Unknown"));
-
-	verify_page_changed (NULL, gui);
 }
 
 static gboolean
-verify_page_back (ExchangeAutoconfigGUI *gui)
+verify_page_check (ExchangeAutoconfigGUI *gui)
 {
-	autoconfig_gui_set_page (gui, EXCHANGE_AUTOCONFIG_PAGE_OWA);
-	return TRUE;
-}
+	const gchar *email;
 
-static gboolean
-verify_page_next (ExchangeAutoconfigGUI *gui)
-{
 	g_free (gui->ac->display_name);
 	gui->ac->display_name = g_strdup (gtk_entry_get_text (gui->name_entry));
 	g_free (gui->ac->email);
 	gui->ac->email = g_strdup (gtk_entry_get_text (gui->email_entry));
 
-	return FALSE;
-}
-
-static gboolean
-verify_page_check (ExchangeAutoconfigGUI *gui)
-{
-	const gchar *email;
-
 	email = gtk_entry_get_text (gui->email_entry);
 
 	return (check_field (gui->name_entry) && strchr (email, '@'));
 }
 
 static void
-verify_page_changed (GtkEntry *entry, ExchangeAutoconfigGUI *gui)
+finish_page_create (ExchangeAutoconfigGUI *gui, GdkPixbuf *logo, GtkWidget **page, gint *page_index)
 {
-	autoconfig_gui_set_next_sensitive (gui, verify_page_check (gui));
+	GtkWidget *vbox;
+
+	vbox = create_page_vbox (GTK_ASSISTANT (gui->assistant), logo, _("Done"), _("Your Connector account is now ready to use. Click the \"Apply\" button to save your settings."), GTK_ASSISTANT_PAGE_CONFIRM, page, page_index);
+	g_return_if_fail (vbox != NULL);
+
+	gtk_widget_show_all (vbox);
 }
 
+#undef CONNECT_CHANGE_SIGNAL
+
 static gboolean
 is_active_exchange_account (EAccount *account)
 {
@@ -455,7 +539,7 @@ autoconfig_gui_apply (ExchangeAutoconfigGUI *gui)
 	list = e_account_list_new (gconf);
 	g_object_unref (gconf);
 	if (!list) {
-		e_notice (gui->window, GTK_MESSAGE_ERROR,
+		e_notice (gui->assistant, GTK_MESSAGE_ERROR,
 			  _("Configuration system error.\n"
 			    "Unable to create new account."));
 		return;
@@ -469,7 +553,7 @@ autoconfig_gui_apply (ExchangeAutoconfigGUI *gui)
 	     e_iterator_next (iter)) {
 		account = (EAccount *)e_iterator_get (iter);
 		if (account && (found = is_active_exchange_account (account))) {
-			e_notice (gui->window, GTK_MESSAGE_ERROR,
+			e_notice (gui->assistant, GTK_MESSAGE_ERROR,
 			_("You may only configure a single Exchange account"));
 			break;
 		}
@@ -515,141 +599,162 @@ autoconfig_gui_apply (ExchangeAutoconfigGUI *gui)
 static void
 autoconfig_gui_free (ExchangeAutoconfigGUI *gui)
 {
-	g_object_unref (gui->xml);
 	e2k_autoconfig_free (gui->ac);
-	if (gui->pages)
-		g_ptr_array_free (gui->pages, TRUE);
 	g_free (gui);
 }
 
 static struct {
-	const gchar *page_name, *body_name;
+	GtkWidget *assistant_page;
+	gint assistant_page_index;
+	void (*create_func) (ExchangeAutoconfigGUI *gui, GdkPixbuf *logo, GtkWidget **page, gint *page_index);
 	void (*prepare_func) (ExchangeAutoconfigGUI *gui);
-	gboolean (*back_func) (ExchangeAutoconfigGUI *gui);
-	gboolean (*next_func) (ExchangeAutoconfigGUI *gui);
+	gboolean (*check_func) (ExchangeAutoconfigGUI *gui);
+	gint (*get_next_page_func) (ExchangeAutoconfigGUI *gui);
 } autoconfig_pages[] = {
-	{ "owa_page", "owa_page_vbox", owa_page_prepare,
-	  NULL, owa_page_next },
-	{ "gc_page", "gc_page_vbox", gc_page_prepare,
-	  NULL, gc_page_next },
-	{ "failure_page", "failure_page_vbox", failure_page_prepare,
-	  failure_page_back, NULL },
-	{ "verify_page", "verify_page_vbox", verify_page_prepare,
-	  verify_page_back, verify_page_next }
+	{ NULL, -1, start_page_create, NULL, NULL, NULL },
+	{ NULL, -1, owa_page_create,     owa_page_prepare,    owa_page_check,     owa_page_get_next },
+	{ NULL, -1, gc_page_create,      NULL,                gc_page_check,      gc_page_get_next  },
+	{ NULL, -1, failure_page_create, NULL,                failure_page_check, NULL              },
+	{ NULL, -1, verify_page_create,  verify_page_prepare, verify_page_check,  NULL              },
+	{ NULL, -1, finish_page_create, NULL, NULL, NULL }
 };
+
 static const gint num_autoconfig_pages = sizeof (autoconfig_pages) / sizeof (autoconfig_pages[0]);
 
-/* Autoconfig druid */
+/* Autoconfig assistant */
 
 static gint
-find_page (ExchangeAutoconfigGUI *gui, gpointer page)
+find_page (ExchangeAutoconfigGUI *gui, GtkWidget *page)
 {
 	gint page_num;
 
-	for (page_num = 0; page_num < gui->pages->len; page_num++) {
-		if (gui->pages->pdata[page_num] == (gpointer)page)
+	for (page_num = 0; page_num < num_autoconfig_pages; page_num++) {
+		if (autoconfig_pages[page_num].assistant_page == page)
 			return page_num;
 	}
 
 	return -1;
 }
 
-static gboolean
-druid_next_cb (GnomeDruidPage *page, GtkWidget *druid,
-	       ExchangeAutoconfigGUI *gui)
+static void
+assistant_prepare_cb (GtkAssistant *assistant, GtkWidget *page, ExchangeAutoconfigGUI *gui)
 {
 	gint page_num = find_page (gui, page);
 
-	if (page_num == -1 || !autoconfig_pages[page_num].next_func)
-		return FALSE;
+	if (page_num == -1)
+		return;
+
+	gui->changing = TRUE;
+
+	if (autoconfig_pages[page_num].prepare_func)
+		autoconfig_pages[page_num].prepare_func (gui);
 
-	return autoconfig_pages[page_num].next_func (gui);
+	gtk_assistant_set_page_complete (
+		GTK_ASSISTANT (gui->assistant),
+		autoconfig_pages[page_num].assistant_page,
+		autoconfig_pages[page_num].check_func == NULL || autoconfig_pages[page_num].check_func (gui));
+
+	gui->changing = FALSE;
+	gui->active_page = page_num;
 }
 
 static void
-druid_prepare_cb (GnomeDruidPage *page, GtkWidget *druid,
-		  ExchangeAutoconfigGUI *gui)
+assistant_page_content_changed (GtkWidget *sender, ExchangeAutoconfigGUI *gui)
 {
-	gint page_num = find_page (gui, page);
+	gint page_num = gtk_assistant_get_current_page (GTK_ASSISTANT (gui->assistant));
 
-	if (page_num == -1 || !autoconfig_pages[page_num].prepare_func)
+	if (page_num == -1)
 		return;
 
-	autoconfig_pages[page_num].prepare_func (gui);
-}
+	g_return_if_fail (page_num >= 0 && page_num < num_autoconfig_pages);
 
-static gboolean
-druid_back_cb (GnomeDruidPage *page, GtkWidget *druid,
-	       ExchangeAutoconfigGUI *gui)
-{
-	gint page_num = find_page (gui, page);
+	gui->changing = TRUE;
 
-	if (page_num == -1 || !autoconfig_pages[page_num].back_func)
-		return FALSE;
+	gtk_assistant_set_page_complete (
+		GTK_ASSISTANT (gui->assistant),
+		autoconfig_pages[page_num].assistant_page,
+		autoconfig_pages[page_num].check_func == NULL || autoconfig_pages[page_num].check_func (gui));
 
-	return autoconfig_pages[page_num].back_func (gui);
+	gui->changing = FALSE;
 }
 
 static void
-druid_finish_cb (GnomeDruidPage *page, GtkWidget *druid,
-		 ExchangeAutoconfigGUI *gui)
+assistant_apply_cb (GtkAssistant *assistant, ExchangeAutoconfigGUI *gui)
 {
 	autoconfig_gui_apply (gui);
-	gtk_widget_destroy (GTK_WIDGET (gui->window));
 }
 
 static void
-druid_cancel_cb (GnomeDruid *druid, ExchangeAutoconfigGUI *gui)
+assistant_cancel_cb (GtkAssistant *assistant, ExchangeAutoconfigGUI *gui)
 {
-	gtk_widget_destroy (GTK_WIDGET (gui->window));
+	gtk_widget_destroy (GTK_WIDGET (gui->assistant));
 }
 
 static void
-druid_destroyed (gpointer gui, GObject *where_druid_was)
+assistant_destroyed (gpointer gui, GObject *where_druid_was)
 {
 	gtk_main_quit ();
 }
 
+static gint
+assistant_forward_func (gint current_page, gpointer user_data)
+{
+	ExchangeAutoconfigGUI *gui = user_data;
+	gint next_page = current_page + 1;
+
+	if (!gui->changing && gui->active_page == current_page) {
+		gint page_num;
+
+		for (page_num = 0; page_num < num_autoconfig_pages; page_num++) {
+			if (autoconfig_pages[page_num].assistant_page_index == current_page) {
+				if (autoconfig_pages[page_num].get_next_page_func)
+					next_page = autoconfig_pages[page_num].get_next_page_func (gui);
+				break;
+			}
+		}
+	}
+
+	return next_page;
+}
+
 void
-exchange_autoconfig_druid_run (void)
+exchange_autoconfig_assistant_run (void)
 {
 	ExchangeAutoconfigGUI *gui;
-	GtkWidget *page;
 	GdkPixbuf *icon;
-	gint i;
 	gchar *pngfile;
+	gint i;
+
+	gui = g_new0 (ExchangeAutoconfigGUI, 1);
+	gui->ac = e2k_autoconfig_new (NULL, NULL, NULL, E2K_AUTOCONFIG_USE_EITHER);
+	gui->assistant = gtk_assistant_new ();
+	gui->active_page = EXCHANGE_AUTOCONFIG_PAGE_START;
+	gui->changing = FALSE;
 
-	gui = autoconfig_gui_new ();
-	g_return_if_fail (gui);
+	gtk_window_set_title (GTK_WINDOW (gui->assistant), _("Evolution Connector for Microsoft Exchange Configuration"));
 
-	gui->druid = (GnomeDruid *)glade_xml_get_widget (gui->xml, "autoconfig_druid");
-	g_signal_connect (gui->druid, "cancel", G_CALLBACK (druid_cancel_cb), gui);
-	gui->window = (GtkWindow *)glade_xml_get_widget (gui->xml, "window");
-	gui->pages = g_ptr_array_new ();
+	gtk_assistant_set_forward_page_func (GTK_ASSISTANT (gui->assistant), assistant_forward_func, gui, NULL);
+
+	g_signal_connect (gui->assistant, "cancel", G_CALLBACK (assistant_cancel_cb), gui);
+	g_signal_connect (gui->assistant, "close", G_CALLBACK (assistant_cancel_cb), gui);
+	g_signal_connect (gui->assistant, "apply", G_CALLBACK (assistant_apply_cb), gui);
+	g_signal_connect (gui->assistant, "prepare", G_CALLBACK (assistant_prepare_cb), gui);
 
 	pngfile = g_build_filename (CONNECTOR_IMAGESDIR,
 				    "connector.png",
 				    NULL);
 	icon = gdk_pixbuf_new_from_file (pngfile, NULL);
 	g_free (pngfile);
-	for (i = 0; i < num_autoconfig_pages; i++) {
-		page = glade_xml_get_widget (gui->xml, autoconfig_pages[i].page_name);
-		g_ptr_array_add (gui->pages, page);
-		gnome_druid_page_standard_set_logo (GNOME_DRUID_PAGE_STANDARD (page), icon);
 
-		g_signal_connect (page, "next", G_CALLBACK (druid_next_cb), gui);
-		g_signal_connect_after (page, "prepare", G_CALLBACK (druid_prepare_cb), gui);
-		g_signal_connect (page, "back", G_CALLBACK (druid_back_cb), gui);
+	for (i = 0; i < num_autoconfig_pages; i++) {
+		autoconfig_pages[i].create_func (gui, icon, &autoconfig_pages[i].assistant_page, &autoconfig_pages[i].assistant_page_index);
 	}
-	g_object_unref (icon);
 
-	page = glade_xml_get_widget (gui->xml, "finish_page");
-	g_signal_connect (page, "finish", G_CALLBACK (druid_finish_cb), gui);
+	g_object_unref (icon);
 
-	g_object_weak_ref (G_OBJECT (gui->druid), druid_destroyed, gui);
+	g_object_weak_ref (G_OBJECT (gui->assistant), assistant_destroyed, gui);
 
-	gtk_widget_show_all (GTK_WIDGET (gui->window));
+	gtk_widget_show_all (GTK_WIDGET (gui->assistant));
 	gtk_main ();
 	autoconfig_gui_free (gui);
 }
-
diff --git a/storage/exchange-autoconfig-wizard.h b/storage/exchange-autoconfig-wizard.h
index becea30..59295f1 100644
--- a/storage/exchange-autoconfig-wizard.h
+++ b/storage/exchange-autoconfig-wizard.h
@@ -12,7 +12,7 @@ G_BEGIN_DECLS
 
 BonoboObject *exchange_autoconfig_wizard_new (void);
 
-void          exchange_autoconfig_druid_run  (void);
+void          exchange_autoconfig_assistant_run  (void);
 
 G_END_DECLS
 
diff --git a/storage/main.c b/storage/main.c
index c26a8e6..12b29e6 100644
--- a/storage/main.c
+++ b/storage/main.c
@@ -35,7 +35,6 @@
 #include <bonobo/bonobo-main.h>
 #include <bonobo/bonobo-generic-factory.h>
 #include <bonobo/bonobo-exception.h>
-#include <libgnomeui/gnome-ui-init.h>
 #include <gconf/gconf-client.h>
 
 #include <camel/camel.h>
@@ -214,10 +213,14 @@ main (gint argc, gchar **argv)
 	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 	textdomain (GETTEXT_PACKAGE);
 
-	gnome_program_init (PACKAGE, VERSION, LIBGNOMEUI_MODULE, argc, argv,
-			    GNOME_PROGRAM_STANDARD_PROPERTIES,
-			    GNOME_PARAM_HUMAN_READABLE_NAME, _("Evolution Connector for Microsoft Exchange"),
-			    NULL);
+	g_type_init ();
+	g_thread_init (NULL);
+	gtk_init (&argc, &argv);
+	if (!bonobo_init (&argc, argv)) {
+		g_warning ("Bonobo initialization failed");
+		return 1;
+	}
+
 	e_icon_factory_init ();
 
 	config_directory = g_build_filename (g_get_home_dir(), ".evolution", NULL);
diff --git a/storage/migr-test.c b/storage/migr-test.c
index ef72ff0..cac401f 100644
--- a/storage/migr-test.c
+++ b/storage/migr-test.c
@@ -25,7 +25,6 @@
 #include <string.h>
 #include <stdlib.h>
 #include <gtk/gtk.h>
-#include <libgnomeui/gnome-ui-init.h>
 
 #include <gdk/gdk.h>
 
@@ -47,8 +46,10 @@ main (gint argc, gchar **argv)
 	gint opt;
 	gchar optstr[] = "M:m:r:u:h:s:d:";
 
-	gnome_program_init("migr-test", VERSION, LIBGNOMEUI_MODULE, argc, argv, NULL);
+	g_type_init ();
+	g_thread_init (NULL);
 	gdk_init(&argc, &argv);
+	gtk_init (&argc, &argv);
 
 	if (argc == 1) {
 		printf("Usage: %s [-M major][ -m minor][ -r revision] <-u user> <-h server> [-s source][ -d destination] \n", argv[0]);
diff --git a/storage/ximian-connector-setup.c b/storage/ximian-connector-setup.c
index 9dd8455..5d11274 100644
--- a/storage/ximian-connector-setup.c
+++ b/storage/ximian-connector-setup.c
@@ -21,14 +21,9 @@
 #include <config.h>
 #endif
 
-#include <libgnomeui/gnome-ui-init.h>
-
-#include <e-util/e-dialog-utils.h>
-#include <libedataserver/e-data-server-util.h>
+#include <gtk/gtk.h>
 #include <libedataserverui/e-passwords.h>
 
-#include <e2k-utils.h>
-
 #include "exchange-autoconfig-wizard.h"
 
 #ifdef G_OS_WIN32
@@ -40,6 +35,8 @@ const gchar *_exchange_storage_imagesdir;
 gint
 main (gint argc, gchar **argv)
 {
+	GError *error = NULL;
+
 #ifdef G_OS_WIN32
 	{
 		gchar *localedir;
@@ -69,13 +66,21 @@ main (gint argc, gchar **argv)
 	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 	textdomain (GETTEXT_PACKAGE);
 
-	gnome_program_init ("ximian-connector-setup", VERSION,
-			    LIBGNOMEUI_MODULE, argc, argv,
-			    GNOME_PROGRAM_STANDARD_PROPERTIES,
-			    GNOME_PARAM_HUMAN_READABLE_NAME, _("Evolution Connector for Microsoft Exchange Setup Tool"),
-			    NULL);
+	g_type_init ();
+	g_thread_init (NULL);
+	gtk_init_with_args (&argc, &argv, NULL, NULL, (char *)GETTEXT_PACKAGE, &error);
+
+	if (error != NULL) {
+		g_printerr ("Failed initialize application, %s\n", error->message);
+		g_error_free (error);
+		return (1);
+	}
+
+	e_passwords_init ();
+
+	exchange_autoconfig_assistant_run ();
 
-	exchange_autoconfig_druid_run ();
 	e_passwords_shutdown ();
+
 	return 0;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]