aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2009-09-26 21:58:11 +0800
committerMatthew Barnes <mbarnes@redhat.com>2009-09-26 22:28:36 +0800
commitbab29564a3067a8eefbe4c92a7117d54fb031b49 (patch)
tree9fb17b4643e333d09f7c11c17ade5ead86ced5b3
parent02c2097ea67846b0ff697f6222539d852da87a40 (diff)
downloadgsoc2013-evolution-bab29564a3067a8eefbe4c92a7117d54fb031b49.tar
gsoc2013-evolution-bab29564a3067a8eefbe4c92a7117d54fb031b49.tar.gz
gsoc2013-evolution-bab29564a3067a8eefbe4c92a7117d54fb031b49.tar.bz2
gsoc2013-evolution-bab29564a3067a8eefbe4c92a7117d54fb031b49.tar.lz
gsoc2013-evolution-bab29564a3067a8eefbe4c92a7117d54fb031b49.tar.xz
gsoc2013-evolution-bab29564a3067a8eefbe4c92a7117d54fb031b49.tar.zst
gsoc2013-evolution-bab29564a3067a8eefbe4c92a7117d54fb031b49.zip
Show import progress directly in the assistant window.
-rw-r--r--doc/reference/shell/Makefile.am1
-rw-r--r--doc/reference/shell/eshell.types1
-rw-r--r--shell/e-shell-window-actions.c8
-rw-r--r--widgets/misc/e-import-assistant.c177
4 files changed, 106 insertions, 81 deletions
diff --git a/doc/reference/shell/Makefile.am b/doc/reference/shell/Makefile.am
index 176eba6de9..ffbfb9108a 100644
--- a/doc/reference/shell/Makefile.am
+++ b/doc/reference/shell/Makefile.am
@@ -69,7 +69,6 @@ GTKDOC_LIBS= \
$(top_builddir)/shell/.libs/e-shell.o \
$(top_builddir)/shell/.libs/e-shell-backend.o \
$(top_builddir)/shell/.libs/e-shell-content.o \
- $(top_builddir)/shell/.libs/e-shell-importer.o \
$(top_builddir)/shell/.libs/e-shell-migrate.o \
$(top_builddir)/shell/.libs/e-shell-settings.o \
$(top_builddir)/shell/.libs/e-shell-sidebar.o \
diff --git a/doc/reference/shell/eshell.types b/doc/reference/shell/eshell.types
index 88a4dfa1d8..e03302f8d5 100644
--- a/doc/reference/shell/eshell.types
+++ b/doc/reference/shell/eshell.types
@@ -6,7 +6,6 @@ e_signature_list_get_type
e_shell_get_type
e_shell_backend_get_type
e_shell_content_get_type
-e_shell_importer_get_type
e_shell_sidebar_get_type
e_shell_switcher_get_type
e_shell_taskbar_get_type
diff --git a/shell/e-shell-window-actions.c b/shell/e-shell-window-actions.c
index ce10bca488..e01aeb1b7b 100644
--- a/shell/e-shell-window-actions.c
+++ b/shell/e-shell-window-actions.c
@@ -840,11 +840,15 @@ action_import_cb (GtkAction *action,
assistant = e_import_assistant_new (GTK_WINDOW (shell_window));
- g_signal_connect (
+ /* These are "Run Last" signals, so use g_signal_connect_after()
+ * to give the default handlers a chance to run before we destroy
+ * the window. */
+
+ g_signal_connect_after (
assistant, "cancel",
G_CALLBACK (gtk_widget_destroy), NULL);
- g_signal_connect (
+ g_signal_connect_after (
assistant, "finished",
G_CALLBACK (gtk_widget_destroy), NULL);
diff --git a/widgets/misc/e-import-assistant.c b/widgets/misc/e-import-assistant.c
index 8815fd9228..cec3325ea1 100644
--- a/widgets/misc/e-import-assistant.c
+++ b/widgets/misc/e-import-assistant.c
@@ -42,6 +42,7 @@ typedef struct _ImportFilePage ImportFilePage;
typedef struct _ImportDestinationPage ImportDestinationPage;
typedef struct _ImportTypePage ImportTypePage;
typedef struct _ImportSelectionPage ImportSelectionPage;
+typedef struct _ImportProgressPage ImportProgressPage;
struct _ImportFilePage {
GtkWidget *filename;
@@ -66,20 +67,22 @@ struct _ImportSelectionPage {
EImportTargetHome *target;
};
+struct _ImportProgressPage {
+ GtkWidget *progress_bar;
+};
+
struct _EImportAssistantPrivate {
ImportFilePage file_page;
ImportDestinationPage destination_page;
ImportTypePage type_page;
ImportSelectionPage selection_page;
+ ImportProgressPage progress_page;
EImport *import;
/* Used for importing phase of operation */
EImportTarget *import_target;
EImportImporter *import_importer;
- GtkWidget *import_dialog;
- GtkWidget *import_label;
- GtkWidget *import_progress;
};
enum {
@@ -88,7 +91,8 @@ enum {
PAGE_INTELI_SOURCE,
PAGE_FILE_CHOOSE,
PAGE_FILE_DEST,
- PAGE_FINISH
+ PAGE_FINISH,
+ PAGE_PROGRESS
};
enum {
@@ -378,6 +382,27 @@ import_assistant_selection_page_init (EImportAssistant *import_assistant)
return page;
}
+static GtkWidget *
+import_assistant_progress_page_init (EImportAssistant *import_assistant)
+{
+ GtkWidget *page;
+ GtkWidget *container;
+ GtkWidget *widget;
+
+ page = gtk_vbox_new (FALSE, 6);
+ gtk_container_set_border_width (GTK_CONTAINER (page), 12);
+ gtk_widget_show (page);
+
+ container = page;
+
+ widget = gtk_progress_bar_new ();
+ gtk_box_pack_start (GTK_BOX (container), widget, TRUE, FALSE, 0);
+ import_assistant->priv->progress_page.progress_bar = widget;
+ gtk_widget_show (widget);
+
+ return page;
+}
+
static void
prepare_intelligent_page (GtkAssistant *assistant,
GtkWidget *vbox)
@@ -409,10 +434,10 @@ prepare_intelligent_page (GtkAssistant *assistant,
const gchar *text;
text = _("Evolution checked for settings to import from "
- "the following\napplications: Pine, Netscape, Elm, "
- "iCalendar. No importable\nsettings found. If you "
- "would like to\ntry again, please click the "
- "\"Back\" button.\n");
+ "the following applications: Pine, Netscape, Elm, "
+ "iCalendar. No importable settings found. If you "
+ "would like to try again, please click the "
+ "\"Back\" button.");
widget = gtk_label_new (text);
gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE);
@@ -467,24 +492,12 @@ import_status (EImport *import,
GtkProgressBar *progress_bar;
progress_bar = GTK_PROGRESS_BAR (
- import_assistant->priv->import_progress);
+ import_assistant->priv->progress_page.progress_bar);
gtk_progress_bar_set_fraction (progress_bar, percent / 100.0);
gtk_progress_bar_set_text (progress_bar, what);
}
static void
-import_dialog_response (GtkDialog *dialog,
- guint button,
- EImportAssistant *import_assistant)
-{
- if (button == GTK_RESPONSE_CANCEL)
- e_import_cancel (
- import_assistant->priv->import,
- import_assistant->priv->import_target,
- import_assistant->priv->import_importer);
-}
-
-static void
import_done (EImport *ei,
gpointer user_data)
{
@@ -591,6 +604,48 @@ prepare_destination_page (GtkAssistant *assistant,
return FALSE;
}
+static void
+prepare_progress_page (GtkAssistant *assistant,
+ GtkWidget *vbox)
+{
+ EImportAssistantPrivate *priv;
+ EImportCompleteFunc done = NULL;
+ GtkToggleButton *toggle_button;
+ ImportSelectionPage *page;
+
+ priv = E_IMPORT_ASSISTANT_GET_PRIVATE (assistant);
+ page = &priv->selection_page;
+
+ /* Hide the Back and Forward buttons, so only Cancel is visible. */
+ gtk_widget_hide (assistant->back);
+ gtk_widget_hide (assistant->forward);
+
+ toggle_button = GTK_TOGGLE_BUTTON (priv->type_page.intelligent);
+
+ if (gtk_toggle_button_get_active (toggle_button)) {
+ page->current = page->importers;
+ if (page->current) {
+ priv->import_target = (EImportTarget *) page->target;
+ priv->import_importer = page->current->data;
+ done = import_intelligent_done;
+ }
+ } else {
+ if (priv->file_page.importer) {
+ priv->import_importer = priv->file_page.importer;
+ priv->import_target = (EImportTarget *)priv->file_page.target;
+ done = import_done;
+ }
+ }
+
+ if (done)
+ e_import_import (
+ priv->import, priv->import_target,
+ priv->import_importer, import_status,
+ import_done, assistant);
+ else
+ import_assistant_emit_finished (E_IMPORT_ASSISTANT (assistant));
+}
+
static gint
forward_cb (gint current_page,
EImportAssistant *import_assistant)
@@ -686,71 +741,30 @@ import_assistant_prepare (GtkAssistant *assistant,
case PAGE_FILE_DEST:
prepare_destination_page (assistant, page);
break;
+ case PAGE_PROGRESS:
+ prepare_progress_page (assistant, page);
+ break;
default:
break;
}
}
static void
-import_assistant_apply (GtkAssistant *assistant)
+import_assistant_cancel (GtkAssistant *assistant)
{
EImportAssistantPrivate *priv;
- EImportCompleteFunc done = NULL;
- GtkToggleButton *toggle_button;
- ImportSelectionPage *page;
- gchar *msg = NULL;
+ gint current_page;
priv = E_IMPORT_ASSISTANT_GET_PRIVATE (assistant);
- page = &priv->selection_page;
-
- toggle_button = GTK_TOGGLE_BUTTON (priv->type_page.intelligent);
-
- if (gtk_toggle_button_get_active (toggle_button)) {
- page->current = page->importers;
- if (page->current) {
- priv->import_target = (EImportTarget *) page->target;
- priv->import_importer = page->current->data;
- done = import_intelligent_done;
- msg = g_strdup (_("Importing Data"));
- }
- } else {
- if (priv->file_page.importer) {
- priv->import_importer = priv->file_page.importer;
- priv->import_target = (EImportTarget *)priv->file_page.target;
- done = import_done;
- msg = g_strdup_printf (
- _("Importing \"%s\""),
- priv->file_page.target->uri_src);
- }
- }
-
- if (done) {
- GtkWidget *content_area;
-
- priv->import_dialog = e_error_new (
- GTK_WINDOW (assistant), "shell:importing", msg, NULL);
- g_signal_connect (priv->import_dialog, "response", G_CALLBACK(import_dialog_response), assistant);
- priv->import_label = gtk_label_new (_("Please wait"));
- priv->import_progress = gtk_progress_bar_new ();
- content_area = gtk_dialog_get_content_area (
- GTK_DIALOG (priv->import_dialog));
- gtk_box_pack_start (
- GTK_BOX (content_area),
- priv->import_label, FALSE, FALSE, 0);
- gtk_box_pack_start (
- GTK_BOX (content_area),
- priv->import_progress, FALSE, FALSE, 0);
- gtk_widget_show_all (priv->import_dialog);
- e_import_import (
- priv->import, priv->import_target,
- priv->import_importer, import_status,
- import_done, assistant);
- } else {
- import_assistant_emit_finished (E_IMPORT_ASSISTANT (assistant));
- }
+ current_page = gtk_assistant_get_current_page (assistant);
- g_free (msg);
+ /* Cancel the import if it's in progress. */
+ if (current_page == PAGE_PROGRESS)
+ e_import_cancel (
+ priv->import,
+ priv->import_target,
+ priv->import_importer);
}
static void
@@ -772,12 +786,12 @@ import_assistant_class_init (EImportAssistantClass *class)
assistant_class = GTK_ASSISTANT_CLASS (class);
assistant_class->prepare = import_assistant_prepare;
- assistant_class->apply = import_assistant_apply;
+ assistant_class->cancel = import_assistant_cancel;
signals[FINISHED] = g_signal_new (
"finished",
G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_FIRST,
+ G_SIGNAL_RUN_LAST,
0, NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
@@ -869,10 +883,19 @@ import_assistant_init (EImportAssistant *import_assistant)
gtk_assistant_append_page (assistant, page);
gtk_assistant_set_page_header_image (assistant, page, pixbuf);
- gtk_assistant_set_page_title (assistant, page, _("Import File"));
+ gtk_assistant_set_page_title (assistant, page, _("Import Data"));
gtk_assistant_set_page_type (assistant, page, GTK_ASSISTANT_PAGE_CONFIRM);
gtk_assistant_set_page_complete (assistant, page, TRUE);
+ /* Progress Page */
+ page = import_assistant_progress_page_init (import_assistant);
+
+ gtk_assistant_append_page (assistant, page);
+ gtk_assistant_set_page_header_image (assistant, page, pixbuf);
+ gtk_assistant_set_page_title (assistant, page, _("Import Data"));
+ gtk_assistant_set_page_type (assistant, page, GTK_ASSISTANT_PAGE_PROGRESS);
+ gtk_assistant_set_page_complete (assistant, page, TRUE);
+
gtk_assistant_set_forward_page_func (
assistant, (GtkAssistantPageFunc)
forward_cb, import_assistant, NULL);