aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2010-08-09 06:41:24 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2010-08-09 06:41:24 +0000
commite150d462d9adc6c390b4817a94c3b3ea1ec5d088 (patch)
treec47f73f5ef7e5d6167875dc6068595fc2e62b099
parent2d01a4712433affe66a398c4769125015cb7691d (diff)
enabled cancellation of eml/dbx import.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2662 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog6
-rw-r--r--src/import.c44
-rw-r--r--src/main.c1
-rw-r--r--src/setup.c5
4 files changed, 49 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 4dbeb7ad..521b9d4d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2010-08-09
+
+ * src/main.c
+ src/setup.c
+ src/import.c: enabled cancellation of eml/dbx import.
+
2010-08-06
* src/main.c
diff --git a/src/import.c b/src/import.c
index 615ccaf3..1edef02c 100644
--- a/src/import.c
+++ b/src/import.c
@@ -78,6 +78,7 @@ static GtkWidget *cancel_button;
static gboolean import_finished;
static gboolean import_ack;
static ProgressDialog *progress;
+static gboolean import_progress_cancelled;
static void import_create (void);
static gint import_do (void);
@@ -104,6 +105,12 @@ static gboolean key_pressed (GtkWidget *widget,
GdkEventKey *event,
gpointer data);
+static void import_progress_cancel_cb (GtkWidget *widget,
+ gpointer data);
+static gint import_progress_delete_event(GtkWidget *widget,
+ GdkEventAny *event,
+ gpointer data);
+
static void proc_mbox_func(Folder *folder, FolderItem *item, gpointer data)
{
@@ -145,6 +152,7 @@ gint import_mail(FolderItem *default_dest)
import_finished = FALSE;
import_ack = FALSE;
+ import_progress_cancelled = FALSE;
inc_lock();
@@ -212,13 +220,15 @@ static gint import_do(void)
g_free(msg);
gtk_window_set_modal(GTK_WINDOW(progress->window), TRUE);
manage_window_set_transient(GTK_WINDOW(progress->window));
- gtk_widget_hide(progress->cancel_btn);
+ g_signal_connect(G_OBJECT(progress->cancel_btn), "clicked",
+ G_CALLBACK(import_progress_cancel_cb), NULL);
g_signal_connect(G_OBJECT(progress->window), "delete_event",
- G_CALLBACK(gtk_true), NULL);
+ G_CALLBACK(import_progress_delete_event), NULL);
gtk_widget_show(progress->window);
ui_update();
if (type == IMPORT_MBOX) {
+ gtk_widget_set_sensitive(progress->cancel_btn, FALSE);
folder_set_ui_func(dest->folder, proc_mbox_func, NULL);
ok = proc_mbox(dest, filename, NULL);
folder_set_ui_func(dest->folder, NULL, NULL);
@@ -290,6 +300,8 @@ static gint import_eml_folder(FolderItem *dest, const gchar *path)
g_warning("import_eml_folder(): folder_item_add_msg_msginfo() failed.");
break;
}
+ if (import_progress_cancelled)
+ break;
}
}
@@ -452,6 +464,8 @@ static gint import_dbx(FolderItem *dest, const gchar *file)
if (get_dbx_data(fp, g_array_index(array, gint32, i), dest) < 0)
break;
count++;
+ if (import_progress_cancelled)
+ break;
}
debug_print("import_dbx: %d imported\n", count);
@@ -481,14 +495,17 @@ gint import_dbx_folders(FolderItem *dest, const gchar *path)
return -1;
}
+ import_progress_cancelled = FALSE;
+
progress = progress_dialog_simple_create();
gtk_window_set_title(GTK_WINDOW(progress->window), _("Importing"));
progress_dialog_set_label(progress, _("Importing Outlook Express folders"));
gtk_window_set_modal(GTK_WINDOW(progress->window), TRUE);
manage_window_set_transient(GTK_WINDOW(progress->window));
- gtk_widget_hide(progress->cancel_btn);
+ g_signal_connect(G_OBJECT(progress->cancel_btn), "clicked",
+ G_CALLBACK(import_progress_cancel_cb), NULL);
g_signal_connect(G_OBJECT(progress->window), "delete_event",
- G_CALLBACK(gtk_true), NULL);
+ G_CALLBACK(import_progress_delete_event), NULL);
gtk_widget_show(progress->window);
ui_update();
@@ -513,7 +530,7 @@ gint import_dbx_folders(FolderItem *dest, const gchar *path)
g_free(folder_name);
folder_name = g_strdup_printf("%s (%d)", orig_name, count++);
}
- g_print("orig_name: %s , folder_name: %s\n", orig_name, folder_name);
+ debug_print("orig_name: %s , folder_name: %s\n", orig_name, folder_name);
sub_folder = dest->folder->klass->create_folder(dest->folder, dest, folder_name);
if (!sub_folder) {
@@ -536,6 +553,10 @@ gint import_dbx_folders(FolderItem *dest, const gchar *path)
g_free(folder_name);
g_free(orig_name);
g_free(file);
+ if (import_progress_cancelled) {
+ ok = -2;
+ break;
+ }
}
}
@@ -740,3 +761,16 @@ static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer data
import_cancel_cb(NULL, NULL);
return FALSE;
}
+
+static void import_progress_cancel_cb(GtkWidget *widget, gpointer data)
+{
+ debug_print("import cancelled\n");
+ import_progress_cancelled = TRUE;
+}
+
+static gint import_progress_delete_event(GtkWidget *widget, GdkEventAny *event,
+ gpointer data)
+{
+ import_progress_cancel_cb(NULL, NULL);
+ return TRUE;
+}
diff --git a/src/main.c b/src/main.c
index 81bdfd18..8d2a7619 100644
--- a/src/main.c
+++ b/src/main.c
@@ -64,7 +64,6 @@
#include "filter.h"
#include "send_message.h"
#include "inc.h"
-#include "import.h"
#include "manage_window.h"
#include "alertpanel.h"
#include "inputdialog.h"
diff --git a/src/setup.c b/src/setup.c
index 00cbebe0..f761c77e 100644
--- a/src/setup.c
+++ b/src/setup.c
@@ -1123,6 +1123,7 @@ gint setup_import(void)
gchar *src;
Folder *folder;
FolderItem *parent, *dest;
+ gint ok;
debug_print("setup_import\n");
@@ -1164,7 +1165,9 @@ gint setup_import(void)
continue;
folderview_append_item(folderview_get(), NULL, dest, TRUE);
folder_write_list();
- import_dbx_folders(dest, ident->path);
+ ok = import_dbx_folders(dest, ident->path);
+ if (ok < 0)
+ break;
}
finish: