[gthumb/ext] hide the progress dialog when a task shows a dialog
- From: Paolo Bacchilega <paobac src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gthumb/ext] hide the progress dialog when a task shows a dialog
- Date: Thu, 24 Sep 2009 21:25:23 +0000 (UTC)
commit 8f512258ab7dd5254c76eb9b8e1d54b56047816b
Author: Paolo Bacchilega <paobac src gnome org>
Date: Thu Sep 24 23:23:32 2009 +0200
hide the progress dialog when a task shows a dialog
[bug #595158]
extensions/catalogs/gth-file-source-catalogs.c | 3 +++
extensions/file_manager/gth-copy-task.c | 11 +++++++++++
extensions/file_manager/gth-duplicate-task.c | 12 ++++++++++++
extensions/photo_importer/gth-import-task.c | 12 ++++++++++++
gthumb/gio-utils.c | 24 ++++++++++++++++++++++++
gthumb/gio-utils.h | 4 ++++
gthumb/gth-file-source-vfs.c | 3 +++
gthumb/gth-file-source.c | 9 +++++++--
gthumb/gth-file-source.h | 2 ++
gthumb/gth-progress-dialog.c | 24 ++++++++++++++++++++++++
gthumb/gth-task.c | 20 ++++++++++++++++++++
gthumb/gth-task.h | 18 +++++++++++-------
gthumb/typedefs.h | 2 ++
13 files changed, 135 insertions(+), 9 deletions(-)
---
diff --git a/extensions/catalogs/gth-file-source-catalogs.c b/extensions/catalogs/gth-file-source-catalogs.c
index 5f713a0..c5483b9 100644
--- a/extensions/catalogs/gth-file-source-catalogs.c
+++ b/extensions/catalogs/gth-file-source-catalogs.c
@@ -562,6 +562,7 @@ typedef struct {
GthFileData *destination;
GList *file_list;
ProgressCallback progress_callback;
+ DialogCallback dialog_callback;
ReadyCallback ready_callback;
gpointer user_data;
GList *files;
@@ -672,6 +673,7 @@ gth_file_source_catalogs_copy (GthFileSource *file_source,
GList *file_list, /* GFile * list */
gboolean move,
ProgressCallback progress_callback,
+ DialogCallback dialog_callback,
ReadyCallback ready_callback,
gpointer data)
{
@@ -682,6 +684,7 @@ gth_file_source_catalogs_copy (GthFileSource *file_source,
cod->destination = g_object_ref (destination);
cod->file_list = _g_object_list_ref (file_list);
cod->progress_callback = progress_callback;
+ cod->dialog_callback = dialog_callback;
cod->ready_callback = ready_callback;
cod->user_data = data;
diff --git a/extensions/file_manager/gth-copy-task.c b/extensions/file_manager/gth-copy-task.c
index 39c6540..d9678c7 100644
--- a/extensions/file_manager/gth-copy-task.c
+++ b/extensions/file_manager/gth-copy-task.c
@@ -60,6 +60,16 @@ copy_done_cb (GObject *object,
static void
+copy_dialog_cb (gboolean opened,
+ gpointer user_data)
+{
+ GthCopyTask *self = user_data;
+
+ gth_task_dialog (GTH_TASK (self), opened);
+}
+
+
+static void
copy_progress_cb (GObject *object,
const char *description,
const char *details,
@@ -87,6 +97,7 @@ gth_copy_task_exec (GthTask *task)
self->priv->files,
self->priv->move,
copy_progress_cb,
+ copy_dialog_cb,
copy_done_cb,
self);
}
diff --git a/extensions/file_manager/gth-duplicate-task.c b/extensions/file_manager/gth-duplicate-task.c
index 32195fc..b556915 100644
--- a/extensions/file_manager/gth-duplicate-task.c
+++ b/extensions/file_manager/gth-duplicate-task.c
@@ -89,6 +89,16 @@ copy_progress_cb (GObject *object,
}
+static void
+copy_dialog_cb (gboolean opened,
+ gpointer user_data)
+{
+ GthDuplicateTask *self = user_data;
+
+ gth_task_dialog (GTH_TASK (self), opened);
+}
+
+
static void duplicate_current_file (GthDuplicateTask *self);
@@ -139,6 +149,8 @@ duplicate_current_file (GthDuplicateTask *self)
self->priv->cancellable,
copy_progress_cb,
self,
+ copy_dialog_cb,
+ self,
copy_ready_cb,
self);
diff --git a/extensions/photo_importer/gth-import-task.c b/extensions/photo_importer/gth-import-task.c
index 111b325..1048114 100644
--- a/extensions/photo_importer/gth-import-task.c
+++ b/extensions/photo_importer/gth-import-task.c
@@ -200,6 +200,16 @@ copy_progress_cb (GObject *object,
static void
+copy_dialog_cb (gboolean opened,
+ gpointer user_data)
+{
+ GthImportTask *self = user_data;
+
+ gth_task_dialog (GTH_TASK (self), opened);
+}
+
+
+static void
file_info_ready_cb (GList *files,
GError *error,
gpointer user_data)
@@ -241,6 +251,8 @@ file_info_ready_cb (GList *files,
self->priv->cancellable,
copy_progress_cb,
self,
+ copy_dialog_cb,
+ self,
copy_ready_cb,
self);
diff --git a/gthumb/gio-utils.c b/gthumb/gio-utils.c
index 4c58f67..67e91f8 100644
--- a/gthumb/gio-utils.c
+++ b/gthumb/gio-utils.c
@@ -1009,6 +1009,8 @@ typedef struct {
GCancellable *cancellable;
ProgressCallback progress_callback;
gpointer progress_callback_data;
+ DialogCallback dialog_callback;
+ gpointer dialog_callback_data;
ReadyFunc ready_callback;
gpointer user_data;
@@ -1138,6 +1140,9 @@ copy_file__overwrite_dialog_response_cb (GtkDialog *dialog,
gtk_widget_hide (GTK_WIDGET (dialog));
+ if (copy_file_data->dialog_callback != NULL)
+ copy_file_data->dialog_callback (FALSE, copy_file_data->dialog_callback_data);
+
switch (copy_file_data->default_response) {
case GTH_OVERWRITE_RESPONSE_NO:
case GTH_OVERWRITE_RESPONSE_ALWAYS_NO:
@@ -1182,6 +1187,9 @@ copy_file_ready_cb (GObject *source_object,
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS)) {
GtkWidget *dialog;
+ if (copy_file_data->dialog_callback != NULL)
+ copy_file_data->dialog_callback (TRUE, copy_file_data->dialog_callback_data);
+
dialog = gth_overwrite_dialog_new (copy_file_data->source->file,
copy_file_data->current_destination,
copy_file_data->default_response,
@@ -1317,6 +1325,8 @@ _g_copy_file_async_private (GthFileData *source,
GCancellable *cancellable,
ProgressCallback progress_callback,
gpointer progress_callback_data,
+ DialogCallback dialog_callback,
+ gpointer dialog_callback_data,
ReadyFunc ready_callback,
gpointer user_data)
{
@@ -1334,6 +1344,8 @@ _g_copy_file_async_private (GthFileData *source,
copy_file_data->cancellable = _g_object_ref (cancellable);
copy_file_data->progress_callback = progress_callback;
copy_file_data->progress_callback_data = progress_callback_data;
+ copy_file_data->dialog_callback = dialog_callback;
+ copy_file_data->dialog_callback_data = dialog_callback_data;
copy_file_data->ready_callback = ready_callback;
copy_file_data->user_data = user_data;
@@ -1350,6 +1362,8 @@ _g_copy_file_async (GthFileData *source,
GCancellable *cancellable,
ProgressCallback progress_callback,
gpointer progress_callback_data,
+ DialogCallback dialog_callback,
+ gpointer dialog_callback_data,
ReadyFunc ready_callback,
gpointer user_data)
{
@@ -1364,6 +1378,8 @@ _g_copy_file_async (GthFileData *source,
cancellable,
progress_callback,
progress_callback_data,
+ dialog_callback,
+ dialog_callback_data,
ready_callback,
user_data);
}
@@ -1400,6 +1416,8 @@ typedef struct {
GCancellable *cancellable;
ProgressCallback progress_callback;
gpointer progress_callback_data;
+ DialogCallback dialog_callback;
+ gpointer dialog_callback_data;
ReadyFunc done_callback;
gpointer user_data;
} CopyData;
@@ -1510,6 +1528,8 @@ copy_data__copy_current_file (CopyData *copy_data)
copy_data->cancellable,
copy_data->progress_callback,
copy_data->progress_callback_data,
+ copy_data->dialog_callback,
+ copy_data->dialog_callback_data,
copy_data__copy_current_file_ready_cb,
copy_data);
@@ -1557,6 +1577,8 @@ _g_copy_files_async (GList *sources, /* GFile list */
GCancellable *cancellable,
ProgressCallback progress_callback,
gpointer progress_callback_data,
+ DialogCallback dialog_callback,
+ gpointer dialog_callback_data,
ReadyFunc done_callback,
gpointer user_data)
{
@@ -1571,6 +1593,8 @@ _g_copy_files_async (GList *sources, /* GFile list */
copy_data->cancellable = _g_object_ref (cancellable);
copy_data->progress_callback = progress_callback;
copy_data->progress_callback_data = progress_callback_data;
+ copy_data->dialog_callback = dialog_callback;
+ copy_data->dialog_callback_data = dialog_callback_data;
copy_data->done_callback = done_callback;
copy_data->user_data = user_data;
diff --git a/gthumb/gio-utils.h b/gthumb/gio-utils.h
index 98b6bb8..8b3a74d 100644
--- a/gthumb/gio-utils.h
+++ b/gthumb/gio-utils.h
@@ -101,6 +101,8 @@ void _g_copy_file_async (GthFileData *source,
GCancellable *cancellable,
ProgressCallback progress_callback,
gpointer progress_callback_data,
+ DialogCallback dialog_callback,
+ gpointer dialog_callback_data,
ReadyFunc ready_callback,
gpointer user_data);
void _g_copy_files_async (GList *sources,
@@ -111,6 +113,8 @@ void _g_copy_files_async (GList *sources,
GCancellable *cancellable,
ProgressCallback progress_callback,
gpointer progress_callback_data,
+ DialogCallback dialog_callback,
+ gpointer dialog_callback_data,
ReadyFunc callback,
gpointer user_data);
gboolean _g_move_file (GFile *source,
diff --git a/gthumb/gth-file-source-vfs.c b/gthumb/gth-file-source-vfs.c
index e767764..66da77d 100644
--- a/gthumb/gth-file-source-vfs.c
+++ b/gthumb/gth-file-source-vfs.c
@@ -263,6 +263,7 @@ gth_file_source_vfs_copy (GthFileSource *file_source,
GList *file_list, /* GFile * list */
gboolean move,
ProgressCallback progress_callback,
+ DialogCallback dialog_callback,
ReadyCallback ready_callback,
gpointer data)
{
@@ -281,6 +282,8 @@ gth_file_source_vfs_copy (GthFileSource *file_source,
gth_file_source_get_cancellable (file_source),
progress_callback,
data,
+ dialog_callback,
+ data,
copy_done_cb,
cod);
}
diff --git a/gthumb/gth-file-source.c b/gthumb/gth-file-source.c
index 7683032..f4ef824 100644
--- a/gthumb/gth-file-source.c
+++ b/gthumb/gth-file-source.c
@@ -86,6 +86,7 @@ typedef struct {
GList *file_list;
gboolean move;
ProgressCallback progress_callback;
+ DialogCallback dialog_callback;
ReadyCallback ready_callback;
gpointer data;
} CopyData;
@@ -278,6 +279,7 @@ gth_file_source_queue_copy (GthFileSource *file_source,
GList *file_list,
gboolean move,
ProgressCallback progress_callback,
+ DialogCallback dialog_callback,
ReadyCallback ready_callback,
gpointer data)
{
@@ -290,6 +292,7 @@ gth_file_source_queue_copy (GthFileSource *file_source,
async_op->data.copy.file_list = _g_file_list_dup (file_list);
async_op->data.copy.move = move;
async_op->data.copy.progress_callback = progress_callback;
+ async_op->data.copy.dialog_callback = dialog_callback;
async_op->data.copy.ready_callback = ready_callback;
async_op->data.copy.data = data;
@@ -375,6 +378,7 @@ gth_file_source_exec_next_in_queue (GthFileSource *file_source)
async_op->data.copy.file_list,
async_op->data.copy.move,
async_op->data.copy.progress_callback,
+ async_op->data.copy.dialog_callback,
async_op->data.copy.ready_callback,
async_op->data.copy.data);
break;
@@ -965,14 +969,15 @@ gth_file_source_copy (GthFileSource *file_source,
GList *file_list, /* GFile * list */
gboolean move,
ProgressCallback progress_callback,
+ DialogCallback dialog_callback,
ReadyCallback ready_callback,
gpointer data)
{
if (gth_file_source_is_active (file_source)) {
- gth_file_source_queue_copy (file_source, destination, file_list, move, progress_callback, ready_callback, data);
+ gth_file_source_queue_copy (file_source, destination, file_list, move, progress_callback, dialog_callback, ready_callback, data);
return;
}
- GTH_FILE_SOURCE_GET_CLASS (G_OBJECT (file_source))->copy (file_source, destination, file_list, move, progress_callback, ready_callback, data);
+ GTH_FILE_SOURCE_GET_CLASS (G_OBJECT (file_source))->copy (file_source, destination, file_list, move, progress_callback, dialog_callback, ready_callback, data);
}
diff --git a/gthumb/gth-file-source.h b/gthumb/gth-file-source.h
index 439ea4b..375b8fc 100644
--- a/gthumb/gth-file-source.h
+++ b/gthumb/gth-file-source.h
@@ -101,6 +101,7 @@ struct _GthFileSourceClass
GList *file_list, /* GFile * list */
gboolean move,
ProgressCallback progress_callback,
+ DialogCallback dialog_callback,
ReadyCallback callback,
gpointer data);
gboolean (*can_cut) (GthFileSource *file_source);
@@ -166,6 +167,7 @@ void gth_file_source_copy (GthFileSource *file_sou
GList *file_list, /* GFile list */
gboolean move,
ProgressCallback progress_callback,
+ DialogCallback dialog_callback,
ReadyCallback ready_callback,
gpointer data);
gboolean gth_file_source_can_cut (GthFileSource *file_source);
diff --git a/gthumb/gth-progress-dialog.c b/gthumb/gth-progress-dialog.c
index d4b7a06..9bc2431 100644
--- a/gthumb/gth-progress-dialog.c
+++ b/gthumb/gth-progress-dialog.c
@@ -351,12 +351,36 @@ _show_dialog_cb (gpointer data)
}
+static void
+task_dialog_cb (GthTask *task,
+ gboolean opened,
+ gpointer user_data)
+{
+ GthProgressDialog *self = user_data;
+
+ if (opened) {
+ if (self->priv->show_event != 0) {
+ g_source_remove (self->priv->show_event);
+ self->priv->show_event = 0;
+ }
+ gtk_widget_hide (GTK_WIDGET (self));
+ }
+ else if (self->priv->show_event == 0)
+ self->priv->show_event = g_timeout_add (SHOW_DELAY, _show_dialog_cb, self);
+}
+
+
void
gth_progress_dialog_add_task (GthProgressDialog *self,
GthTask *task)
{
GtkWidget *child;
+ g_signal_connect (task,
+ "dialog",
+ G_CALLBACK (task_dialog_cb),
+ self);
+
child = gth_task_progress_new (task);
gtk_widget_show (child);
gtk_box_pack_start (GTK_BOX (self->priv->task_box), child, TRUE, TRUE, 0);
diff --git a/gthumb/gth-task.c b/gthumb/gth-task.c
index c3be98b..50644bb 100644
--- a/gthumb/gth-task.c
+++ b/gthumb/gth-task.c
@@ -30,6 +30,7 @@
enum {
COMPLETED,
PROGRESS,
+ DIALOG,
LAST_SIGNAL
};
@@ -119,6 +120,17 @@ gth_task_class_init (GthTaskClass *class)
G_TYPE_STRING,
G_TYPE_BOOLEAN,
G_TYPE_DOUBLE);
+
+ gth_task_signals[DIALOG] =
+ g_signal_new ("dialog",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GthTaskClass, dialog),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_BOOLEAN);
}
@@ -198,6 +210,14 @@ gth_task_completed (GthTask *task,
void
+gth_task_dialog (GthTask *task,
+ gboolean opened)
+{
+ g_signal_emit (task, gth_task_signals[DIALOG], 0, opened);
+}
+
+
+void
gth_task_progress (GthTask *task,
const char *description,
const char *details,
diff --git a/gthumb/gth-task.h b/gthumb/gth-task.h
index bb07702..ee67ea2 100644
--- a/gthumb/gth-task.h
+++ b/gthumb/gth-task.h
@@ -58,13 +58,15 @@ struct _GthTaskClass
/*< signals >*/
- void (*completed) (GthTask *task,
- GError *error);
- void (*progress) (GthTask *task,
- const char *description,
- const char *details,
- gboolean pulse,
- double fraction);
+ void (*completed) (GthTask *task,
+ GError *error);
+ void (*progress) (GthTask *task,
+ const char *description,
+ const char *details,
+ gboolean pulse,
+ double fraction);
+ void (*dialog) (GthTask *task,
+ gboolean opened);
/*< virtual functions >*/
@@ -81,6 +83,8 @@ gboolean gth_task_is_running (GthTask *task);
void gth_task_cancel (GthTask *task);
void gth_task_completed (GthTask *task,
GError *error);
+void gth_task_dialog (GthTask *task,
+ gboolean opened);
void gth_task_progress (GthTask *task,
const char *description,
const char *details,
diff --git a/gthumb/typedefs.h b/gthumb/typedefs.h
index 65c8594..02849d1 100644
--- a/gthumb/typedefs.h
+++ b/gthumb/typedefs.h
@@ -99,6 +99,8 @@ typedef void (*ProgressCallback) (GObject *object,
gboolean pulse,
double fraction,
gpointer user_data);
+typedef void (*DialogCallback) (gboolean opened,
+ gpointer user_data);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]