aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2005-07-13 13:47:39 +0800
committerMichael Zucci <zucchi@src.gnome.org>2005-07-13 13:47:39 +0800
commit1e28d8c9d32381799d82f5e1bc496cf28ab9ad53 (patch)
tree94d05224dfc18003e81e5b5f804dd587fcffdaf3 /plugins
parentc409f1ca7f6c441f06b8b5fe901248877e435710 (diff)
downloadgsoc2013-evolution-1e28d8c9d32381799d82f5e1bc496cf28ab9ad53.tar.gz
gsoc2013-evolution-1e28d8c9d32381799d82f5e1bc496cf28ab9ad53.tar.zst
gsoc2013-evolution-1e28d8c9d32381799d82f5e1bc496cf28ab9ad53.zip
re-write the importer stuff to use the eplugin stuff.
2005-07-13 Not Zed <NotZed@Ximian.com> * startup-wizard.c (startup_wizard_importer_page) (startup_wizard_commit): re-write the importer stuff to use the eplugin stuff. svn path=/trunk/; revision=29747
Diffstat (limited to 'plugins')
-rw-r--r--plugins/startup-wizard/ChangeLog6
-rw-r--r--plugins/startup-wizard/startup-wizard.c187
2 files changed, 89 insertions, 104 deletions
diff --git a/plugins/startup-wizard/ChangeLog b/plugins/startup-wizard/ChangeLog
index c6427baa89..cd5268d31b 100644
--- a/plugins/startup-wizard/ChangeLog
+++ b/plugins/startup-wizard/ChangeLog
@@ -1,3 +1,9 @@
+2005-07-13 Not Zed <NotZed@Ximian.com>
+
+ * startup-wizard.c (startup_wizard_importer_page)
+ (startup_wizard_commit): re-write the importer stuff to use the
+ eplugin stuff.
+
2005-07-12 Not Zed <NotZed@Ximian.com>
* startup-wizard.c: removed all the importer stuff. fixed the
diff --git a/plugins/startup-wizard/startup-wizard.c b/plugins/startup-wizard/startup-wizard.c
index 9dc85f306f..6e159e72c4 100644
--- a/plugins/startup-wizard/startup-wizard.c
+++ b/plugins/startup-wizard/startup-wizard.c
@@ -22,11 +22,11 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <libgnomeui/libgnomeui.h>
-#include <bonobo/bonobo-exception.h>
-#include <bonobo/bonobo-widget.h>
#include "widgets/e-timezone-dialog/e-timezone-dialog.h"
#include "e-util/e-icon-factory.h"
#include "e-util/e-gtk-utils.h"
+#include "e-util/e-error.h"
+#include "e-util/e-import.h"
#include "shell/es-event.h"
#include "mail/em-config.h"
#include "mail/em-account-editor.h"
@@ -41,19 +41,11 @@ gboolean startup_wizard_check (EPlugin *ep, EConfigHookPageCheckData *check_data
void startup_wizard_commit (EPlugin *ep, EMConfigTargetAccount *target);
void startup_wizard_abort (EPlugin *ep, EMConfigTargetAccount *target);
-static GList *useable_importers = NULL;
-gboolean useable_importers_init = FALSE;
-
-static GList *
-get_intelligent_importers (void)
-{
- return NULL;
-}
-
-static void
-init_importers (void)
-{
-}
+static EImport *import;
+static EImportTargetHome *import_target;
+static EImportImporter *import_importer;
+static GtkWidget *import_dialog, *import_progress, *import_label;
+static GSList *import_iterator, *import_importers;
static void
startup_wizard_delete (void) {
@@ -61,7 +53,6 @@ startup_wizard_delete (void) {
_exit (0);
}
-
void
startup_wizard (EPlugin *ep, ESEventTargetUpgrade *target)
{
@@ -131,8 +122,19 @@ startup_wizard_timezone_page (EPlugin *ep, EConfigHookItemFactoryData *hook_data
GtkWidget *
startup_wizard_importer_page (EPlugin *ep, EConfigHookItemFactoryData *hook_data)
{
- return NULL;
-#if 0
+ GtkWidget *page, *label, *sep, *table;
+ GSList *l;
+ int row=0;
+
+ if (import == NULL) {
+ import = e_import_new("org.gnome.evolution.shell.importer");
+ import_target = e_import_target_new_home(import, g_get_home_dir());
+ import_importers = e_import_get_importers(import, (EImportTarget *)import_target);
+ }
+
+ if (import_importers == NULL)
+ return NULL;
+
page = gnome_druid_page_standard_new_with_vals ("Importing files", NULL, NULL);
label = gtk_label_new (_("Please select the information that you would like to import:"));
@@ -141,107 +143,69 @@ startup_wizard_importer_page (EPlugin *ep, EConfigHookItemFactoryData *hook_data
sep = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (GNOME_DRUID_PAGE_STANDARD (page)->vbox), sep, FALSE, FALSE, 3);
- table = gtk_table_new (g_list_length (useable_importers), 2, FALSE);
- for (l = useable_importers, i = 0; l; l = l->next, i++) {
- IntelligentImporterData *id = l->data;
- GtkWidget *widget;
+ table = gtk_table_new(g_slist_length(import_importers), 2, FALSE);
+ for (l = import_importers; l; l = l->next) {
+ EImportImporter *eii = l->data;
char *str;
-
- CORBA_Environment ev;
- CORBA_exception_init (&ev);
+ GtkWidget *w, *label;
- str = g_strdup_printf (_("From %s:"), id->name);
- label = gtk_label_new (str);
- g_free (str);
-
- gtk_misc_set_alignment (GTK_MISC (label), 0, .5);
+ w = e_import_get_widget(import, (EImportTarget *)import_target, eii);
- widget = bonobo_widget_new_control_from_objref (id->control, CORBA_OBJECT_NIL);
+ str = g_strdup_printf(_("From %s:"), eii->name);
+ label = gtk_label_new(str);
+ gtk_widget_show(label);
+ g_free(str);
- gtk_table_attach (GTK_TABLE (table), label, 0, 1, i, i + 1, GTK_FILL, 0, 0, 0);
- gtk_table_attach (GTK_TABLE (table), widget, 1, 2, i, i + 1, GTK_FILL, 0, 3, 0);
- gtk_widget_show_all (table);
-
- gtk_box_pack_start (GTK_BOX (GNOME_DRUID_PAGE_STANDARD (page)->vbox), table,
- FALSE, FALSE, 0);
+ gtk_misc_set_alignment((GtkMisc *)label, 0, .5);
+
+ gtk_table_attach((GtkTable *)table, label, 0, 1, row, row+1, GTK_FILL, 0, 0, 0);
+ if (w)
+ gtk_table_attach((GtkTable *)table, w, 1, 2, row, row+1, GTK_FILL, 0, 3, 0);
+ row++;
}
+ gtk_widget_show(table);
+ gtk_box_pack_start((GtkBox *)((GnomeDruidPageStandard *)page)->vbox, table, FALSE, FALSE, 3);
gnome_druid_append_page (GNOME_DRUID (hook_data->parent), GNOME_DRUID_PAGE (page));
- return GTK_WIDGET (page);
-#endif
+ return page;
}
-#if 0
static void
-start_importers (GList *p)
+import_status(EImport *import, const char *what, int pc, void *d)
{
- CORBA_Environment ev;
-
- for (; p; p = p->next) {
- SelectedImporterData *sid = p->data;
-
- CORBA_exception_init (&ev);
- GNOME_Evolution_IntelligentImporter_importData (sid->importer, &ev);
- if (BONOBO_EX (&ev)) {
- g_warning ("Error importing %s\n%s", sid->iid,
- CORBA_exception_id (&ev));
- }
- CORBA_exception_free (&ev);
- }
+ gtk_progress_bar_set_fraction((GtkProgressBar *)import_progress, (gfloat)(pc/100.0));
+ gtk_progress_bar_set_text((GtkProgressBar *)import_progress, what);
}
static void
-do_import ()
+import_dialog_response(GtkDialog *d, guint button, void *data)
{
- CORBA_Environment ev;
- GList *l, *selected = NULL;
-
- for (l = useable_importers; l; l = l->next) {
- IntelligentImporterData *importer_data;
- SelectedImporterData *sid;
- char *iid;
-
- importer_data = l->data;
- iid = g_strdup (importer_data->iid);
-
- sid = g_new (SelectedImporterData, 1);
- sid->iid = iid;
-
- CORBA_exception_init (&ev);
- sid->importer = bonobo_object_dup_ref (importer_data->object, &ev);
- if (BONOBO_EX (&ev)) {
- g_warning ("Error duplication %s\n(%s)", iid,
- CORBA_exception_id (&ev));
- g_free (iid);
- CORBA_exception_free (&ev);
- g_free (sid);
- continue;
- }
- CORBA_exception_free (&ev);
-
- selected = g_list_prepend (selected, sid);
- }
-
- free_importers ();
-
- if (selected != NULL) {
- start_importers (selected);
-
- for (l = selected; l; l = l->next) {
- SelectedImporterData *sid = l->data;
-
- CORBA_exception_init (&ev);
- bonobo_object_release_unref (sid->importer, &ev);
- CORBA_exception_free (&ev);
+ if (button == GTK_RESPONSE_CANCEL)
+ e_import_cancel(import, (EImportTarget *)import_target, import_importer);
+}
- g_free (sid->iid);
- g_free (sid);
- }
- g_list_free (selected);
+static void
+import_done(EImport *ei, void *d)
+{
+ if (import_iterator && (import_iterator = import_iterator->next)) {
+ import_status(ei, "", 0, NULL);
+ import_importer = import_iterator->data;
+ e_import_import(import, (EImportTarget *)import_target, import_importer, import_status, import_done, NULL);
+ } else {
+ gtk_widget_destroy(import_dialog);
+
+ g_slist_free(import_importers);
+ import_importers = NULL;
+ import_importer = NULL;
+ e_import_target_free(import, (EImportTarget *)import_target);
+ import_target = NULL;
+ g_object_unref(import);
+ import = NULL;
+
+ gtk_main_quit();
}
}
-#endif
void
startup_wizard_commit (EPlugin *ep, EMConfigTargetAccount *target)
@@ -250,8 +214,6 @@ startup_wizard_commit (EPlugin *ep, EMConfigTargetAccount *target)
ETimezoneDialog *etd;
icaltimezone *zone;
- /*FIXME: do_import ();*/
-
/* Set Timezone */
etd = g_object_get_data (G_OBJECT (ec), IMPORT_TIMEZONE_DIALOG);
if (etd) {
@@ -264,9 +226,23 @@ startup_wizard_commit (EPlugin *ep, EMConfigTargetAccount *target)
g_object_unref (etd);
g_object_set_data (G_OBJECT (ec), IMPORT_TIMEZONE_DIALOG, NULL);
}
-
- gtk_main_quit ();
+ if (import_importers) {
+ import_iterator = import_importers;
+ import_importer = import_iterator->data;
+
+ import_dialog = e_error_new(NULL, "shell:importing", _("Importing data."), NULL);
+ g_signal_connect(import_dialog, "response", G_CALLBACK(import_dialog_response), NULL);
+ import_label = gtk_label_new(_("Please wait"));
+ import_progress = gtk_progress_bar_new();
+ gtk_box_pack_start(GTK_BOX(((GtkDialog *)import_dialog)->vbox), import_label, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(((GtkDialog *)import_dialog)->vbox), import_progress, FALSE, FALSE, 0);
+ gtk_widget_show_all(import_dialog);
+
+ e_import_import(import, (EImportTarget *)import_target, import_importer, import_status, import_done, NULL);
+ } else {
+ gtk_main_quit();
+ }
}
void
@@ -275,6 +251,9 @@ startup_wizard_abort (EPlugin *ep, EMConfigTargetAccount *target)
EConfig *ec = ((EConfigTarget *)target)->config;
ETimezoneDialog *etd;
+ /* We're doing an _exit(), so i dont see why we're bothering to do
+ any cleanup whatsoever here ... */
+
etd = g_object_get_data (G_OBJECT (ec), IMPORT_TIMEZONE_DIALOG);
if (etd) {
/* Need to do this otherwise the timezone widget gets destroyed but the