aboutsummaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorIain Holmes <iain@src.gnome.org>2001-05-09 06:53:41 +0800
committerIain Holmes <iain@src.gnome.org>2001-05-09 06:53:41 +0800
commitc64eccfe004f5c30932fe571bb506626bb0c186d (patch)
tree2260477f72c474e00ae9f2b0afa7f5242e60c5a5 /shell
parent9bcfef421b420061f7342e5517d226aa9f58dbdd (diff)
downloadgsoc2013-evolution-c64eccfe004f5c30932fe571bb506626bb0c186d.tar
gsoc2013-evolution-c64eccfe004f5c30932fe571bb506626bb0c186d.tar.gz
gsoc2013-evolution-c64eccfe004f5c30932fe571bb506626bb0c186d.tar.bz2
gsoc2013-evolution-c64eccfe004f5c30932fe571bb506626bb0c186d.tar.lz
gsoc2013-evolution-c64eccfe004f5c30932fe571bb506626bb0c186d.tar.xz
gsoc2013-evolution-c64eccfe004f5c30932fe571bb506626bb0c186d.tar.zst
gsoc2013-evolution-c64eccfe004f5c30932fe571bb506626bb0c186d.zip
Importer changes
svn path=/trunk/; revision=9722
Diffstat (limited to 'shell')
-rw-r--r--shell/ChangeLog19
-rw-r--r--shell/e-local-storage.c7
-rw-r--r--shell/evolution-storage.c1
-rw-r--r--shell/importer/evolution-importer-client.c32
-rw-r--r--shell/importer/evolution-importer-client.h6
-rw-r--r--shell/importer/evolution-importer-listener.c1
-rw-r--r--shell/importer/importer.c4
-rw-r--r--shell/importer/intelligent.c446
8 files changed, 363 insertions, 153 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index 74cdd3f6ba..6d746217d8 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,3 +1,22 @@
+2001-05-08 Iain Holmes <iain@ximian.com>
+
+ * importer/evolution-importer-client.c (evolution_importer_client_load_file):
+ Actually use the duplicated value.
+
+ * e-local-storage.c (create_folder_directory): Assign
+ physical_path_return before trying to create the directory.
+ (create_folder): Return the physical_path even if the directory
+ creation failed. Free the physical path.
+
+ * importer/evolution-importer-client.[ch]: Make EvolutionImporterClient
+ from a GtkObject instead of a BonoboObject.
+
+ * importer/importer.c: Use gtk_object_unref instead of
+ bonobo_object_unref on the clients.
+
+ * importer/intelligent.c: New prettier dialog, and multiple importers
+ done in the same window.
+
2001-05-07 Dan Winship <danw@ximian.com>
* e-shell-offline-handler.c (update_dialog_clist_hash_foreach):
diff --git a/shell/e-local-storage.c b/shell/e-local-storage.c
index d0d433abc0..233a3a4107 100644
--- a/shell/e-local-storage.c
+++ b/shell/e-local-storage.c
@@ -469,12 +469,11 @@ create_folder_directory (ELocalStorage *local_storage,
/* Create the directory that holds the folder. */
+ *physical_path_return = physical_path;
if (mkdir (physical_path, 0700) == -1) {
- g_free (physical_path);
return errno_to_storage_result ();
}
- *physical_path_return = physical_path;
return E_STORAGE_OK;
}
@@ -512,10 +511,12 @@ create_folder (ELocalStorage *local_storage,
result = create_folder_directory (local_storage, path, type, description, &physical_path);
if (result != E_STORAGE_OK) {
+ g_warning ("physical_path: %s", physical_path);
if (callback != NULL)
(* callback) (storage, result, data);
if (listener != CORBA_OBJECT_NIL)
- notify_bonobo_listener (listener, result, NULL);
+ notify_bonobo_listener (listener, result, physical_path);
+ g_free (physical_path);
return;
}
diff --git a/shell/evolution-storage.c b/shell/evolution-storage.c
index 68cbf0c7f3..20b4372cd5 100644
--- a/shell/evolution-storage.c
+++ b/shell/evolution-storage.c
@@ -293,6 +293,7 @@ impl_Storage_async_create_folder (PortableServer_Servant servant,
bonobo_object = bonobo_object_from_servant (servant);
storage = EVOLUTION_STORAGE (bonobo_object);
+ g_warning ("Path: %s", path);
gtk_signal_emit (GTK_OBJECT (storage), signals[CREATE_FOLDER],
listener, path, type, description, parent_physical_uri);
}
diff --git a/shell/importer/evolution-importer-client.c b/shell/importer/evolution-importer-client.c
index 25a8f11b65..280e851c14 100644
--- a/shell/importer/evolution-importer-client.c
+++ b/shell/importer/evolution-importer-client.c
@@ -37,8 +37,8 @@
#include "GNOME_Evolution_Importer.h"
-#define PARENT_TYPE BONOBO_OBJECT_CLIENT_TYPE
-static BonoboObjectClass *parent_class = NULL;
+#define PARENT_TYPE gtk_object_get_type ()
+static GtkObjectClass *parent_class = NULL;
static void
@@ -63,17 +63,6 @@ init (EvolutionImporterClient *client)
{
}
-static void
-evolution_importer_client_construct (EvolutionImporterClient *client,
- CORBA_Object corba_object)
-{
- g_return_if_fail (client != NULL);
- g_return_if_fail (EVOLUTION_IS_IMPORTER_CLIENT (client));
- g_return_if_fail (corba_object != CORBA_OBJECT_NIL);
-
- bonobo_object_client_construct (BONOBO_OBJECT_CLIENT (client), corba_object);
-}
-
/**
* evolution_importer_client_new:
* @objref: The CORBA_Object to make a client for.
@@ -90,7 +79,7 @@ evolution_importer_client_new (const CORBA_Object objref)
g_return_val_if_fail (objref != CORBA_OBJECT_NIL, NULL);
client = gtk_type_new (evolution_importer_client_get_type ());
- evolution_importer_client_construct (client, objref);
+ client->objref = objref;
return client;
}
@@ -151,7 +140,7 @@ evolution_importer_client_support_format (EvolutionImporterClient *client,
g_return_val_if_fail (filename != NULL, FALSE);
CORBA_exception_init (&ev);
- corba_importer = bonobo_object_corba_objref (BONOBO_OBJECT (client));
+ corba_importer = client->objref;
result = GNOME_Evolution_Importer_supportFormat (corba_importer,
filename, &ev);
CORBA_exception_free (&ev);
@@ -183,11 +172,17 @@ evolution_importer_client_load_file (EvolutionImporterClient *client,
g_return_val_if_fail (filename != NULL, FALSE);
CORBA_exception_init (&ev);
- corba_importer = bonobo_object_corba_objref (BONOBO_OBJECT (client));
+ corba_importer = client->objref;
result = GNOME_Evolution_Importer_loadFile (corba_importer,
filename,
folderpath ? folderpath : "",
&ev);
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning ("Oh there *WAS* an exception.\nIt was %s",
+ CORBA_exception_id (&ev));
+ CORBA_exception_free (&ev);
+ return FALSE;
+ }
CORBA_exception_free (&ev);
return result;
@@ -216,8 +211,9 @@ evolution_importer_client_process_item (EvolutionImporterClient *client,
CORBA_exception_init (&ev);
- corba_importer = bonobo_object_corba_objref (BONOBO_OBJECT (client));
+ corba_importer = client->objref;
corba_listener = bonobo_object_corba_objref (BONOBO_OBJECT (listener));
+ g_warning ("%s", __FUNCTION__);
GNOME_Evolution_Importer_processItem (corba_importer,
corba_listener, &ev);
CORBA_exception_free (&ev);
@@ -242,7 +238,7 @@ evolution_importer_client_get_error (EvolutionImporterClient *client)
g_return_val_if_fail (client != NULL, NULL);
g_return_val_if_fail (EVOLUTION_IS_IMPORTER_CLIENT (client), NULL);
- corba_importer = bonobo_object_corba_objref (BONOBO_OBJECT (client));
+ corba_importer = client->objref;
CORBA_exception_init (&ev);
str = GNOME_Evolution_Importer_getError (corba_importer, &ev);
diff --git a/shell/importer/evolution-importer-client.h b/shell/importer/evolution-importer-client.h
index 71b20afc6a..3b38d7bc3f 100644
--- a/shell/importer/evolution-importer-client.h
+++ b/shell/importer/evolution-importer-client.h
@@ -45,11 +45,13 @@ typedef struct _EvolutionImporterClient EvolutionImporterClient;
typedef struct _EvolutionImporterClientClass EvolutionImporterClientClass;
struct _EvolutionImporterClient {
- BonoboObjectClient parent;
+ GtkObject parent_type;
+
+ GNOME_Evolution_Importer objref;
};
struct _EvolutionImporterClientClass {
- BonoboObjectClientClass parent_class;
+ GtkObjectClass parent_class;
};
GtkType evolution_importer_client_get_type (void);
diff --git a/shell/importer/evolution-importer-listener.c b/shell/importer/evolution-importer-listener.c
index 905ebd72fe..8a547e6f3e 100644
--- a/shell/importer/evolution-importer-listener.c
+++ b/shell/importer/evolution-importer-listener.c
@@ -109,6 +109,7 @@ impl_GNOME_Evolution_ImporterListener_notifyResult (PortableServer_Servant serva
listener = evolution_importer_listener_from_servant (servant);
priv = listener->priv;
+ g_print ("Notified\n");
out_result = corba_result_to_evolution (result);
if (priv->callback) {
(priv->callback) (listener, out_result, more_items,
diff --git a/shell/importer/importer.c b/shell/importer/importer.c
index e7163cf329..15d18db10b 100644
--- a/shell/importer/importer.c
+++ b/shell/importer/importer.c
@@ -217,7 +217,7 @@ import_cb (EvolutionImporterListener *listener,
if (!icd->destroyed)
gtk_object_destroy (GTK_OBJECT (icd->dialog));
bonobo_object_unref (BONOBO_OBJECT (icd->listener));
- bonobo_object_unref (BONOBO_OBJECT (icd->client));
+ gtk_object_unref (GTK_OBJECT (icd->client));
g_free (icd);
OUT;
@@ -383,7 +383,7 @@ start_import (const char *filename,
g_free (real_iid);
/* NULL for folderpath means use Inbox */
- if (evolution_importer_client_load_file (icd->client, filename, NULL) == FALSE) {
+ if (evolution_importer_client_load_file (icd->client, filename, "/Inbox") == FALSE) {
label = g_strdup_printf (_("Error loading %s"), filename);
gtk_label_set_text (GTK_LABEL (icd->contents), label);
g_free (label);
diff --git a/shell/importer/intelligent.c b/shell/importer/intelligent.c
index 166be226ad..d9589df676 100644
--- a/shell/importer/intelligent.c
+++ b/shell/importer/intelligent.c
@@ -36,6 +36,10 @@
#include <gtk/gtktogglebutton.h>
#include <gtk/gtkwidget.h>
#include <gtk/gtkwindow.h>
+#include <gtk/gtkframe.h>
+#include <gtk/gtkclist.h>
+#include <gtk/gtknotebook.h>
+#include <gtk/gtkscrolledwindow.h>
#include <libgnome/gnome-defs.h>
#include <libgnome/gnome-config.h>
@@ -46,6 +50,10 @@
#include <liboaf/liboaf.h>
+#include <bonobo/bonobo-object.h>
+#include <bonobo/bonobo-widget.h>
+
+#include "intelligent.h"
#include "GNOME_Evolution_Importer.h"
/* Prototypes */
@@ -54,142 +62,75 @@ void intelligent_importer_init (void);
/* End prototypes */
-static void
-start_importer (const char *iid)
-{
- CORBA_Object importer;
- CORBA_Environment ev;
- CORBA_char *name;
- CORBA_char *message;
- CORBA_boolean can_run;
+typedef struct {
+ CORBA_Object object;
+ Bonobo_Control control;
+ GtkWidget *widget;
- GtkWidget *dialog, *label, *ask;
- gboolean dontaskagain;
- char *prefix;
+ char *name;
+ char *blurb;
+ char *iid;
+} IntelligentImporterData;
- if (iid == NULL || *iid == '\0')
- return;
+typedef struct {
+ GtkWidget *dialog;
+ GtkWidget *placeholder;
+ GtkWidget *clist;
+ BonoboWidget *current;
- /* Check if we want to show this one again */
- prefix = g_strdup_printf ("=%s/evolution/config/Shell=/intelligent-importers/", gnome_util_user_home ());
- gnome_config_push_prefix (prefix);
- g_free (prefix);
-
- dontaskagain = gnome_config_get_bool (iid);
- gnome_config_pop_prefix ();
+ GList *importers;
- if (dontaskagain)
- return;
+ int running;
+} IntelligentImporterDialog;
- CORBA_exception_init (&ev);
- importer = oaf_activate_from_id ((char *) iid, 0, NULL, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- CORBA_exception_free (&ev);
- g_warning ("Could not start %s", iid);
- return;
- }
-
- CORBA_exception_free (&ev);
- if (importer == CORBA_OBJECT_NIL) {
- g_warning ("Could not activate_component %s", iid);
- return;
- }
-
- CORBA_exception_init (&ev);
- can_run = GNOME_Evolution_IntelligentImporter_canImport (importer, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("Could not get canImport(%s): %s", iid, CORBA_exception_id (&ev));
- CORBA_Object_release (importer, &ev);
- CORBA_exception_free (&ev);
- return;
- }
- CORBA_exception_free (&ev);
-
- if (can_run == FALSE) {
- return;
- }
-
- name = GNOME_Evolution_IntelligentImporter__get_importername (importer,
- &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("Could not get name(%s): %s", iid, CORBA_exception_id (&ev));
- CORBA_Object_release (importer, &ev);
- CORBA_exception_free (&ev);
- return;
- }
- message = GNOME_Evolution_IntelligentImporter__get_message (importer, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("Could not get message(%s): %s", iid, CORBA_exception_id (&ev));
- CORBA_Object_release (importer, &ev);
- CORBA_exception_free (&ev);
- return;
- }
-
- CORBA_exception_free (&ev);
-
- dialog = gnome_dialog_new ("Import files",
- GNOME_STOCK_BUTTON_YES, GNOME_STOCK_BUTTON_NO,
- NULL);
- gtk_window_set_title (GTK_WINDOW (dialog), name);
- CORBA_free (name);
-
- label = gtk_label_new (message);
- CORBA_free (message);
-
- gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), label,
- FALSE, FALSE, 0);
- gtk_widget_show (label);
+typedef struct {
+ CORBA_Object importer;
+ char *iid;
+} SelectedImporterData;
- ask = gtk_check_button_new_with_label (_("Don't ask me again"));
- gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), ask,
- FALSE, FALSE, 0);
- gtk_widget_show (ask);
+static void
+free_importer_dialog (IntelligentImporterDialog *d)
+{
+ GList *l;
- switch (gnome_dialog_run (GNOME_DIALOG (dialog))) {
- case 0:
- /* Yes */
- dontaskagain = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ask));
- prefix = g_strdup_printf ("=%s/evolution/config/Shell=/intelligent-importers/", gnome_util_user_home ());
- gnome_config_push_prefix (prefix);
- g_free (prefix);
+ for (l = d->importers; l; l = l->next) {
+ CORBA_Environment ev;
+ IntelligentImporterData *data;
- gnome_config_set_bool (iid, dontaskagain);
- gnome_config_sync ();
- gnome_config_drop_all ();
+ data = l->data;
- gnome_config_pop_prefix ();
+ CORBA_exception_init (&ev);
+ if (data->object != CORBA_OBJECT_NIL)
+ bonobo_object_release_unref (data->object, &ev);
- gtk_object_destroy (GTK_OBJECT (dialog));
- while (gtk_events_pending ())
- gtk_main_iteration ();
+ g_free (data->iid);
+ g_free (data->name);
+ g_free (data->blurb);
+ g_free (data);
+ }
- GNOME_Evolution_IntelligentImporter_importData (importer, &ev);
- break;
- case 1:
- case -1:
- default:
- /* No */
- dontaskagain = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ask));
- prefix = g_strdup_printf ("=%s/evolution/config/Shell=/intelligent-importers/", gnome_util_user_home ());
- gnome_config_push_prefix (prefix);
- g_free (prefix);
-
- gnome_config_set_bool (iid, dontaskagain);
- gnome_config_sync ();
- gnome_config_drop_all ();
-
- gnome_config_pop_prefix ();
-
- gtk_object_destroy (GTK_OBJECT (dialog));
+ g_list_free (d->importers);
+ gtk_widget_destroy (d->dialog);
+ g_free (d);
+}
- break;
- }
+static void
+start_importers (GList *selected)
+{
+ CORBA_Environment ev;
CORBA_exception_init (&ev);
- CORBA_Object_release (importer, &ev);
+ for (; selected; selected = selected->next) {
+ SelectedImporterData *selection = selected->data;
+
+ GNOME_Evolution_IntelligentImporter_importData (selection->importer, &ev);
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning ("Error importing %s\n%s", selection->iid,
+ CORBA_exception_id (&ev));
+ }
+ }
CORBA_exception_free (&ev);
}
-
static GList *
get_intelligent_importers (void)
@@ -210,26 +151,275 @@ get_intelligent_importers (void)
iids_ret = g_list_prepend (iids_ret, g_strdup (info->iid));
}
- CORBA_free (info_list);
-
return iids_ret;
}
+static void
+select_row_cb (GtkCList *clist,
+ int row,
+ int column,
+ GdkEvent *ev,
+ IntelligentImporterDialog *d)
+{
+ gtk_notebook_set_page (GTK_NOTEBOOK (d->placeholder), row);
+}
+
+static void
+unselect_row_cb (GtkCList *clist,
+ int row,
+ int column,
+ GdkEvent *ev,
+ IntelligentImporterDialog *d)
+{
+ gtk_notebook_set_page (GTK_NOTEBOOK (d->placeholder), d->running);
+}
+
+IntelligentImporterDialog *
+create_gui (GList *importers)
+{
+ GtkWidget *dialog, *clist, *placeholder, *sw;
+ IntelligentImporterDialog *d;
+ GList *l;
+ int running = 0;
+
+ d = g_new (IntelligentImporterDialog, 1);
+ d->dialog = dialog = gnome_dialog_new (_("Importers"), "Import",
+ GNOME_STOCK_BUTTON_CANCEL,
+ NULL);
+ gnome_dialog_close_hides (GNOME_DIALOG (dialog), TRUE);
+ d->importers = NULL;
+ d->current = NULL;
+
+ d->clist = clist = gtk_clist_new (1);
+ gtk_clist_set_selection_mode (GTK_CLIST (d->clist), GTK_SELECTION_MULTIPLE);
+
+ sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_set_usize (sw, 300, 150);
+ gtk_container_add (GTK_CONTAINER (sw), clist);
+ gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), sw,
+ TRUE, TRUE, 0);
+
+ d->placeholder = gtk_notebook_new ();
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (d->placeholder), FALSE);
+ gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), d->placeholder,
+ FALSE, FALSE, 0);
+
+ for (l = importers; l; l = l->next) {
+ IntelligentImporterData *data;
+ CORBA_Environment ev;
+ gboolean dontaskagain, can_run;
+ char *text[1], *prefix;
+
+ /* Check if we want to show this one again */
+ prefix = g_strdup_printf ("=%s/evolution/config/Shell=/intelligent-importers/", gnome_util_user_home ());
+ gnome_config_push_prefix (prefix);
+ g_free (prefix);
+
+ dontaskagain = gnome_config_get_bool (l->data);
+ gnome_config_pop_prefix ();
+
+ if (dontaskagain)
+ continue;
+
+ data = g_new0 (IntelligentImporterData, 1);
+ data->iid = g_strdup (l->data);
+
+ g_warning ("data->iid %s", data->iid);
+ CORBA_exception_init (&ev);
+ data->object = oaf_activate_from_id ((char *) data->iid, 0,
+ NULL, &ev);
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning ("Could not start %s: %s", data->iid,
+ CORBA_exception_id (&ev));
+ CORBA_exception_free (&ev);
+
+ /* Clean up the IntelligentImporterData */
+ g_free (data->iid);
+ g_free (data);
+ continue;
+ }
+
+ CORBA_exception_free (&ev);
+ if (data->object == CORBA_OBJECT_NIL) {
+ g_warning ("Could not activate_component %s", data->iid);
+ g_free (data->iid);
+ g_free (data);
+ continue;
+ }
+
+ CORBA_exception_init (&ev);
+ can_run = GNOME_Evolution_IntelligentImporter_canImport (data->object,
+ &ev);
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning ("Could not get canImport(%s): %s",
+ data->iid, CORBA_exception_id (&ev));
+ bonobo_object_release_unref (data->object, &ev);
+ CORBA_exception_free (&ev);
+ g_free (data->iid);
+ g_free (data);
+ continue;
+ }
+ CORBA_exception_free (&ev);
+
+ if (can_run == FALSE) {
+ CORBA_exception_init (&ev);
+ bonobo_object_release_unref (data->object, &ev);
+ CORBA_exception_free (&ev);
+ g_free (data->iid);
+ g_free (data);
+ continue;
+ }
+
+ running++;
+
+ data->name = g_strdup (GNOME_Evolution_IntelligentImporter__get_importername (data->object, &ev));
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning ("Could not get name(%s): %s",
+ data->iid, CORBA_exception_id (&ev));
+ bonobo_object_release_unref (data->object, &ev);
+ CORBA_exception_free (&ev);
+ g_free (data->iid);
+ g_free (data);
+ continue;
+ }
+
+ data->blurb = g_strdup (GNOME_Evolution_IntelligentImporter__get_message (data->object, &ev));
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning ("Could not get message(%s): %s",
+ data->iid, CORBA_exception_id (&ev));
+ bonobo_object_release_unref (data->object, &ev);
+ CORBA_exception_free (&ev);
+ g_free (data->iid);
+ g_free (data->name);
+ g_free (data);
+ continue;
+ }
+
+ data->control = Bonobo_Unknown_queryInterface (data->object,
+ "IDL:Bonobo/Control:1.0", &ev);
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning ("Could not QI for Bonobo/Control:1.0 %s:%s",
+ data->iid, CORBA_exception_id (&ev));
+ bonobo_object_release_unref (data->object, &ev);
+ CORBA_exception_free (&ev);
+ g_free (data->iid);
+ g_free (data->name);
+ g_free (data->blurb);
+ continue;
+ }
+ if (data->control != CORBA_OBJECT_NIL) {
+ data->widget = bonobo_widget_new_control_from_objref (data->control, CORBA_OBJECT_NIL);
+ /* Ref this widget so even if we remove it from the
+ containers it will always have an extra ref. */
+ gtk_widget_show (data->widget);
+ gtk_widget_ref (data->widget);
+ } else {
+ data->widget = gtk_label_new ("");
+ }
+
+ CORBA_exception_free (&ev);
+
+ d->importers = g_list_prepend (d->importers, data);
+ gtk_notebook_prepend_page (GTK_NOTEBOOK (d->placeholder),
+ data->widget, NULL);
+ text[0] = data->name;
+ gtk_clist_prepend (GTK_CLIST (clist), text);
+ }
+
+ d->running = running;
+ gtk_notebook_append_page (GTK_NOTEBOOK (d->placeholder),
+ gtk_label_new (""), NULL);
+ /* Set the start to the blank page */
+ gtk_notebook_set_page (GTK_NOTEBOOK (d->placeholder), running);
+
+ gtk_signal_connect (GTK_OBJECT (clist), "select-row",
+ GTK_SIGNAL_FUNC (select_row_cb), d);
+ gtk_signal_connect (GTK_OBJECT (clist), "unselect-row",
+ GTK_SIGNAL_FUNC (unselect_row_cb), d);
+
+ gtk_widget_show_all (GNOME_DIALOG (dialog)->vbox);
+ return d;
+}
+
void
intelligent_importer_init (void)
{
- GList *importers, *l;
+ GList *importers, *l, *selected = NULL;
+ IntelligentImporterDialog *d;
importers = get_intelligent_importers ();
if (importers == NULL)
return; /* No intelligent importers. Easy :) */
- /* Loop through each importer, running it. */
- for (l = importers; l; l = l->next) {
- start_importer (l->data);
- g_free (l->data);
+ d = create_gui (importers);
+ if (d->running == 0) {
+ free_importer_dialog (d);
+ return; /* No runnable intelligent importers. */
+ }
+
+ switch (gnome_dialog_run_and_close (GNOME_DIALOG (d->dialog))) {
+ case 0: /* Okay button */
+ /* Make a list of the importers */
+
+ /* FIXME: Sort this list and don't do it a slow way */
+ for (l = GTK_CLIST (d->clist)->selection; l; l = l->next) {
+ IntelligentImporterData *data;
+ SelectedImporterData *new_data;
+ CORBA_Environment ev;
+ char *iid;
+
+ data = g_list_nth_data (d->importers, l->data);
+ iid = g_strdup (data->iid);
+
+ new_data = g_new (SelectedImporterData, 1);
+ new_data->iid = iid;
+
+ /* Reference the remote object, and duplicate the
+ local one. */
+ CORBA_exception_init (&ev);
+ new_data->importer = bonobo_object_dup_ref (data->object, &ev);
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning ("Error duplicating %s\n%s", iid,
+ CORBA_exception_id (&ev));
+ g_free (iid);
+ CORBA_exception_free (&ev);
+ g_free (new_data);
+ continue;
+ }
+ CORBA_exception_free (&ev);
+
+ selected = g_list_prepend (selected, new_data);
+ }
+
+ /* Now destroy all the importers, as we've kept references to
+ the ones we need */
+ free_importer_dialog (d);
+
+ if (selected != NULL) {
+ /* Restart the selected ones */
+ start_importers (selected);
+
+ /* Free the selected list */
+ for (l = selected; l; l = l->next) {
+ CORBA_Environment ev;
+ SelectedImporterData *selection = l->data;
+
+ CORBA_exception_init (&ev);
+ bonobo_object_release_unref (selection->importer, &ev);
+ CORBA_exception_free (&ev);
+
+ g_free (selection->iid);
+ g_free (selection);
+ }
+ g_list_free (selected);
+ }
+
+ break;
+
+ default:
+ free_importer_dialog (d);
+ break;
}
g_list_free (importers);
}
-