[gthumb/ext: 41/79] Added ability to have many background tasks.
- From: Paolo Bacchilega <paobac src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gthumb/ext: 41/79] Added ability to have many background tasks.
- Date: Sun, 2 Aug 2009 20:28:32 +0000 (UTC)
commit 6d25501aa73cbed09c986a552be1e68f11556869
Author: Paolo Bacchilega <paobac src gnome org>
Date: Mon Jul 13 16:54:45 2009 +0200
Added ability to have many background tasks.
Use a dialog to display the tasks. Allow to cancel a single task.
extensions/catalogs/gth-file-source-catalogs.c | 2 +-
.../comments/gth-metadata-provider-comment.c | 2 +-
extensions/file_manager/actions.c | 2 +-
extensions/file_manager/gth-duplicate-task.c | 6 +-
extensions/file_tools/gth-file-tool-desaturate.c | 2 +-
extensions/list_tools/callbacks.c | 2 +-
extensions/list_tools/data/ui/ask-value.ui | 84 +++++-
extensions/list_tools/data/ui/script-editor.ui | 4 +-
extensions/list_tools/gth-script-task.c | 22 +-
extensions/list_tools/gth-script.c | 30 ++-
extensions/search/actions.c | 50 ++--
extensions/search/gth-search-task.c | 2 +-
gthumb/Makefile.am | 2 +
gthumb/gth-browser.c | 25 ++-
gthumb/gth-browser.h | 3 +-
gthumb/gth-filter.c | 2 +-
gthumb/gth-marshal.list | 2 +-
gthumb/gth-pixbuf-task.c | 6 +-
gthumb/gth-progress-dialog.c | 332 ++++++++++++++++++++
gthumb/gth-progress-dialog.h | 58 ++++
gthumb/gth-task.c | 10 +-
gthumb/gth-task.h | 9 +-
22 files changed, 588 insertions(+), 69 deletions(-)
---
diff --git a/extensions/catalogs/gth-file-source-catalogs.c b/extensions/catalogs/gth-file-source-catalogs.c
index f4704ed..aed46e1 100644
--- a/extensions/catalogs/gth-file-source-catalogs.c
+++ b/extensions/catalogs/gth-file-source-catalogs.c
@@ -39,7 +39,7 @@ struct _GthFileSourceCatalogsPrivate
};
-static GthFileSourceClass *parent_class = NULL;
+static gpointer parent_class = NULL;
static GList *
diff --git a/extensions/comments/gth-metadata-provider-comment.c b/extensions/comments/gth-metadata-provider-comment.c
index e6f9bfb..6d6876f 100644
--- a/extensions/comments/gth-metadata-provider-comment.c
+++ b/extensions/comments/gth-metadata-provider-comment.c
@@ -37,7 +37,7 @@ struct _GthMetadataProviderCommentPrivate {
};
-static GthMetadataProviderClass *parent_class = NULL;
+static gpointer parent_class = NULL;
static void
diff --git a/extensions/file_manager/actions.c b/extensions/file_manager/actions.c
index d881bd7..81bf525 100644
--- a/extensions/file_manager/actions.c
+++ b/extensions/file_manager/actions.c
@@ -370,7 +370,7 @@ gth_browser_activate_action_edit_duplicate (GtkAction *action,
items = gth_file_selection_get_selected (GTH_FILE_SELECTION (gth_browser_get_file_list_view (browser)));
file_list = gth_file_list_get_files (GTH_FILE_LIST (gth_browser_get_file_list (browser)), items);
task = gth_duplicate_task_new (file_list);
- gth_browser_exec_task (browser, task);
+ gth_browser_exec_task (browser, task, FALSE);
g_object_unref (task);
_g_object_list_unref (file_list);
diff --git a/extensions/file_manager/gth-duplicate-task.c b/extensions/file_manager/gth-duplicate-task.c
index 4bfc6d8..b56ab5f 100644
--- a/extensions/file_manager/gth-duplicate-task.c
+++ b/extensions/file_manager/gth-duplicate-task.c
@@ -86,8 +86,12 @@ copy_progress_cb (goffset current_file,
gpointer user_data)
{
GthDuplicateTask *self = user_data;
+ char *name;
- gth_task_progress (GTH_TASK (self), _("Duplicating files"), FALSE, (double) current_num_bytes / total_num_bytes);
+ name = _g_file_get_display_name (source);
+ gth_task_progress (GTH_TASK (self), _("Duplicating files"), name, FALSE, (double) current_num_bytes / total_num_bytes);
+
+ g_free (name);
}
diff --git a/extensions/file_tools/gth-file-tool-desaturate.c b/extensions/file_tools/gth-file-tool-desaturate.c
index d72acf8..d80857b 100644
--- a/extensions/file_tools/gth-file-tool-desaturate.c
+++ b/extensions/file_tools/gth-file-tool-desaturate.c
@@ -98,7 +98,7 @@ gth_file_tool_desaturate_activate (GthFileTool *base)
desaturate_step,
desaturate_release,
viewer_page);
- gth_browser_exec_task (GTH_BROWSER (window), task);
+ gth_browser_exec_task (GTH_BROWSER (window), task, FALSE);
g_object_unref (task);
g_object_unref (dest_pixbuf);
diff --git a/extensions/list_tools/callbacks.c b/extensions/list_tools/callbacks.c
index 3c7b6de..91286e1 100644
--- a/extensions/list_tools/callbacks.c
+++ b/extensions/list_tools/callbacks.c
@@ -101,7 +101,7 @@ activate_script_menu_item (GtkMenuItem *menuitem,
GthTask *task;
task = gth_script_task_new (GTK_WINDOW (data->browser), script, file_list);
- gth_browser_exec_task (data->browser, task);
+ gth_browser_exec_task (data->browser, task, FALSE);
g_object_unref (task);
}
diff --git a/extensions/list_tools/data/ui/ask-value.ui b/extensions/list_tools/data/ui/ask-value.ui
index e69533e..49e3757 100644
--- a/extensions/list_tools/data/ui/ask-value.ui
+++ b/extensions/list_tools/data/ui/ask-value.ui
@@ -18,11 +18,44 @@
<property name="border_width">5</property>
<property name="spacing">12</property>
<child>
- <object class="GtkImage" id="request_image">
- <property name="width_request">128</property>
- <property name="height_request">128</property>
+ <object class="GtkVBox" id="vbox2">
<property name="visible">True</property>
- <property name="stock">gtk-missing-image</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkAspectFrame" id="aspectframe1">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <child>
+ <object class="GtkImage" id="request_image">
+ <property name="width_request">128</property>
+ <property name="height_request">128</property>
+ <property name="visible">True</property>
+ <property name="stock">gtk-missing-image</property>
+ <property name="icon-size">6</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="filename_label">
+ <property name="width_request">128</property>
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="wrap">True</property>
+ <property name="wrap_mode">char</property>
+ <attributes>
+ <attribute name="size" value="8500"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
@@ -35,13 +68,33 @@
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
+ <object class="GtkAlignment" id="alignment1">
+ <property name="visible">True</property>
+ <property name="bottom_padding">12</property>
+ <child>
+ <object class="GtkLabel" id="title_label">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ <attribute name="size" value="12000"/>
+ </attributes>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkLabel" id="request_label">
<property name="visible">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
- <property name="position">0</property>
+ <property name="position">1</property>
</packing>
</child>
<child>
@@ -53,7 +106,7 @@
</object>
<packing>
<property name="expand">False</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
</object>
@@ -72,6 +125,20 @@
<property name="visible">True</property>
<property name="layout_style">end</property>
<child>
+ <object class="GtkButton" id="skip_button">
+ <property name="label" translatable="yes">_Skip</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkButton" id="cancel_button">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
@@ -82,7 +149,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">0</property>
+ <property name="position">1</property>
</packing>
</child>
<child>
@@ -98,7 +165,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
</object>
@@ -111,6 +178,7 @@
</object>
</child>
<action-widgets>
+ <action-widget response="3">skip_button</action-widget>
<action-widget response="1">cancel_button</action-widget>
<action-widget response="2">ok_button</action-widget>
</action-widgets>
diff --git a/extensions/list_tools/data/ui/script-editor.ui b/extensions/list_tools/data/ui/script-editor.ui
index ccafed5..692c206 100644
--- a/extensions/list_tools/data/ui/script-editor.ui
+++ b/extensions/list_tools/data/ui/script-editor.ui
@@ -258,7 +258,7 @@
<object class="GtkLabel" id="label8">
<property name="visible">True</property>
<property name="xalign">0</property>
- <property name="label" translatable="yes" comments="Translate only 'message' and 'default_value', keeping the underscore if possible.">%ask{ message }{ default_value }</property>
+ <property name="label" translatable="yes" comments="Translate only 'message' and 'default_value'.">%ask{ message }{ default value }</property>
<attributes>
<attribute name="size" value="8000"/>
</attributes>
@@ -288,7 +288,7 @@
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="xalign">0</property>
- <property name="label" translatable="yes" comments="Translate only 'property_name', keeping the underscore if possible.">%attr{ property_name }</property>
+ <property name="label" translatable="yes" comments="Translate only 'attribute name'">%attr{ attribute name }</property>
<attributes>
<attribute name="size" value="8000"/>
</attributes>
diff --git a/extensions/list_tools/gth-script-task.c b/extensions/list_tools/gth-script-task.c
index fb64db9..7c51e6f 100644
--- a/extensions/list_tools/gth-script-task.c
+++ b/extensions/list_tools/gth-script-task.c
@@ -104,11 +104,16 @@ _gth_script_task_exec (GthScriptTask *self)
gboolean retval = FALSE;
if (gth_script_for_each_file (self->priv->script)) {
- GList *list;
+ GthFileData *file_data = self->priv->current->data;
+ GList *list;
- gth_task_progress (GTH_TASK (self), gth_script_get_display_name (self->priv->script), FALSE, (double) self->priv->n_current / (self->priv->n_files + 1));
+ gth_task_progress (GTH_TASK (self),
+ gth_script_get_display_name (self->priv->script),
+ g_file_info_get_display_name (file_data->info),
+ FALSE,
+ (double) self->priv->n_current / (self->priv->n_files + 1));
- list = g_list_prepend (NULL, self->priv->current->data);
+ list = g_list_prepend (NULL, file_data);
command_line = gth_script_get_command_line (self->priv->script,
self->priv->parent,
list,
@@ -117,7 +122,11 @@ _gth_script_task_exec (GthScriptTask *self)
g_list_free (list);
}
else {
- gth_task_progress (GTH_TASK (self), gth_script_get_display_name (self->priv->script), TRUE, 0.0);
+ gth_task_progress (GTH_TASK (self),
+ gth_script_get_display_name (self->priv->script),
+ NULL,
+ TRUE,
+ 0.0);
command_line = gth_script_get_command_line (self->priv->script,
self->priv->parent,
@@ -160,6 +169,11 @@ _gth_script_task_exec (GthScriptTask *self)
g_free (command_line);
+ if (g_error_matches (error, GTH_TASK_ERROR, GTH_TASK_ERROR_SKIP_TO_NEXT_FILE)) {
+ _gth_script_task_exec_next_file (self);
+ return;
+ }
+
if (! retval) {
gth_task_completed (GTH_TASK (self), error);
return;
diff --git a/extensions/list_tools/gth-script.c b/extensions/list_tools/gth-script.c
index 2ee38c6..9304308 100644
--- a/extensions/list_tools/gth-script.c
+++ b/extensions/list_tools/gth-script.c
@@ -556,9 +556,11 @@ thumb_loader_ready_cb (GthThumbLoader *thumb_loader,
static char *
-ask_value (ReplaceData *replace_data,
- char *match)
+ask_value (ReplaceData *replace_data,
+ char *match,
+ GError **error)
{
+ GthFileData *file_data;
GRegex *re;
char **a;
int len;
@@ -570,6 +572,8 @@ ask_value (ReplaceData *replace_data,
int result;
char *value;
+ file_data = (GthFileData *) replace_data->file_list->data;
+
re = g_regex_new ("%ask(\\{([^}]+)\\}(\\{([^}]+)\\})?)?", 0, 0, NULL);
a = g_regex_split (re, match, 0);
len = g_strv_length (a);
@@ -584,23 +588,33 @@ ask_value (ReplaceData *replace_data,
builder = _gtk_builder_new_from_file ("ask-value.ui", "list_tools");
dialog = _gtk_builder_get_widget (builder, "ask_value_dialog");
+ gtk_label_set_text (GTK_LABEL (_gtk_builder_get_widget (builder, "title_label")), gth_script_get_display_name (replace_data->script));
+ gtk_label_set_text (GTK_LABEL (_gtk_builder_get_widget (builder, "filename_label")), g_file_info_get_display_name (file_data->info));
gtk_label_set_text (GTK_LABEL (_gtk_builder_get_widget (builder, "request_label")), prompt);
gtk_entry_set_text (GTK_ENTRY (_gtk_builder_get_widget (builder, "request_entry")), default_value);
gtk_window_set_title (GTK_WINDOW (dialog), "");
gtk_window_set_transient_for (GTK_WINDOW (dialog), replace_data->parent);
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+ if (! gth_script_for_each_file(replace_data->script))
+ gtk_widget_hide (_gtk_builder_get_widget (builder, "skip_button"));
g_object_ref (builder);
thumb_loader = gth_thumb_loader_new (128, 128);
g_signal_connect (thumb_loader, "ready", G_CALLBACK (thumb_loader_ready_cb), builder);
- gth_thumb_loader_set_file (thumb_loader, (GthFileData *) replace_data->file_list->data);
+ gth_thumb_loader_set_file (thumb_loader, file_data);
gth_thumb_loader_load (thumb_loader);
result = gtk_dialog_run (GTK_DIALOG (dialog));
- if (result == 2)
+ if (result == 2) {
value = g_utf8_normalize (gtk_entry_get_text (GTK_ENTRY (_gtk_builder_get_widget (builder, "request_entry"))), -1, G_NORMALIZE_NFC);
- else
+ }
+ else {
+ if (result == 3)
+ *error = g_error_new_literal (GTH_TASK_ERROR, GTH_TASK_ERROR_SKIP_TO_NEXT_FILE, "");
+ else
+ *error = g_error_new_literal (GTH_TASK_ERROR, GTH_TASK_ERROR_CANCELLED, "");
value = NULL;
+ }
gtk_widget_destroy (dialog);
@@ -698,10 +712,8 @@ command_line_eval_cb (const GMatchInfo *info,
*replace_data->error = g_error_new_literal (GTH_TASK_ERROR, GTH_TASK_ERROR_FAILED, _("Malformed command"));
}
else if (strncmp (match, "%ask", 4) == 0) {
- r = ask_value (replace_data, match);
- if (r == NULL)
- *replace_data->error = g_error_new_literal (GTH_TASK_ERROR, GTH_TASK_ERROR_CANCELLED, "");
- else if (replace_data->quote_values) {
+ r = ask_value (replace_data, match, replace_data->error);
+ if ((r != NULL) && replace_data->quote_values) {
char *q;
q = g_shell_quote (r);
diff --git a/extensions/search/actions.c b/extensions/search/actions.c
index 1bcdf40..b57a883 100644
--- a/extensions/search/actions.c
+++ b/extensions/search/actions.c
@@ -53,11 +53,11 @@ search_editor_dialog__response_cb (GtkDialog *dialog,
search_catalog = gth_catalog_file_from_relative_path (_("Search Result"), ".search");
task = gth_search_task_new (browser, search, search_catalog);
- gth_browser_exec_task (browser, task);
+ gth_browser_exec_task (browser, task, TRUE);
g_object_unref (task);
g_object_unref (search_catalog);
- g_object_unref (search);
+ g_object_unref (search);
gtk_widget_destroy (GTK_WIDGET (dialog));
}
@@ -69,17 +69,17 @@ gth_browser_activate_action_edit_find (GtkAction *action,
GthSearch *search;
GthFileSource *file_source;
GtkWidget *dialog;
-
- search = gth_search_new ();
+
+ search = gth_search_new ();
file_source = gth_main_get_file_source (gth_browser_get_location (browser));
if (GTH_IS_FILE_SOURCE_VFS (file_source)) {
GFile *folder;
-
+
folder = gth_file_source_to_gio_file (file_source, gth_browser_get_location (browser));
gth_search_set_folder (search, folder);
g_object_unref (folder);
}
- gth_search_set_recursive (search, TRUE);
+ gth_search_set_recursive (search, TRUE);
dialog = gth_search_editor_dialog_new (_("Find"), search, GTK_WINDOW (browser));
gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
@@ -91,7 +91,7 @@ gth_browser_activate_action_edit_find (GtkAction *action,
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
gtk_window_present (GTK_WINDOW (dialog));
-
+
g_object_unref (file_source);
g_object_unref (search);
}
@@ -135,7 +135,7 @@ search_edit_response_cb (GtkDialog *dialog,
}
task = gth_search_task_new (search_data->browser, search, search_data->file);
- gth_browser_exec_task (search_data->browser, task);
+ gth_browser_exec_task (search_data->browser, task, TRUE);
gtk_widget_destroy (GTK_WIDGET (dialog));
@@ -155,18 +155,18 @@ search_edit_buffer_ready_cb (void *buffer,
GError *local_error = NULL;
GthSearch *search;
GtkWidget *dialog;
-
+
if (error != NULL) {
_gtk_error_dialog_from_gerror_show (GTK_WINDOW (search_data->browser), _("Could not perform the search"), &error);
return;
}
-
+
search = gth_search_new_from_data (buffer, count, &local_error);
if (search == NULL) {
_gtk_error_dialog_from_gerror_show (GTK_WINDOW (search_data->browser), _("Could not perform the search"), &local_error);
return;
}
-
+
dialog = gth_search_editor_dialog_new (_("Find"), search, GTK_WINDOW (search_data->browser));
gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_FIND, GTK_RESPONSE_OK);
@@ -177,7 +177,7 @@ search_edit_buffer_ready_cb (void *buffer,
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
gtk_window_present (GTK_WINDOW (dialog));
-
+
g_object_unref (search);
}
@@ -189,20 +189,20 @@ gth_browser_activate_action_edit_search_edit (GtkAction *action,
GFile *location;
SearchData *search_data;
GFile *file;
-
+
location = gth_browser_get_location (browser);
-
+
search_data = g_new0 (SearchData, 1);
search_data->browser = browser;
search_data->file = g_file_dup (location);
-
+
file = gth_main_get_gio_file (location);
g_load_file_async (file,
G_PRIORITY_DEFAULT,
NULL,
search_edit_buffer_ready_cb,
search_data);
-
+
g_object_unref (file);
}
@@ -217,21 +217,21 @@ search_update_buffer_ready_cb (void *buffer,
GError *local_error = NULL;
GthSearch *search;
GthTask *task;
-
+
if (error != NULL) {
_gtk_error_dialog_from_gerror_show (GTK_WINDOW (search_data->browser), _("Could not perform the search"), &error);
return;
}
-
+
search = gth_search_new_from_data (buffer, count, &local_error);
if (search == NULL) {
_gtk_error_dialog_from_gerror_show (GTK_WINDOW (search_data->browser), _("Could not perform the search"), &local_error);
return;
}
-
+
task = gth_search_task_new (search_data->browser, search, search_data->file);
- gth_browser_exec_task (search_data->browser, task);
-
+ gth_browser_exec_task (search_data->browser, task, TRUE);
+
g_object_unref (task);
g_object_unref (search);
search_data_free (search_data);
@@ -245,19 +245,19 @@ gth_browser_activate_action_edit_search_update (GtkAction *action,
GFile *location;
SearchData *search_data;
GFile *file;
-
+
location = gth_browser_get_location (browser);
-
+
search_data = g_new0 (SearchData, 1);
search_data->browser = browser;
search_data->file = g_file_dup (location);
-
+
file = gth_main_get_gio_file (location);
g_load_file_async (file,
G_PRIORITY_DEFAULT,
NULL,
search_update_buffer_ready_cb,
search_data);
-
+
g_object_unref (file);
}
diff --git a/extensions/search/gth-search-task.c b/extensions/search/gth-search-task.c
index db4cda8..71bc692 100644
--- a/extensions/search/gth-search-task.c
+++ b/extensions/search/gth-search-task.c
@@ -343,7 +343,7 @@ gth_search_task_exec (GthTask *base)
search_result_real_file = gth_catalog_file_to_gio_file (task->priv->search_catalog);
g_write_file_async (search_result_real_file,
data,
- size,
+ size,
G_PRIORITY_DEFAULT,
task->priv->cancellable,
clear_search_result_copy_done_cb,
diff --git a/gthumb/Makefile.am b/gthumb/Makefile.am
index a04421e..e884c6d 100644
--- a/gthumb/Makefile.am
+++ b/gthumb/Makefile.am
@@ -73,6 +73,7 @@ PUBLIC_HEADER_FILES = \
gth-nav-window.h \
gth-pixbuf-task.h \
gth-preferences.h \
+ gth-progress-dialog.h \
gth-sidebar.h \
gth-statusbar.h \
gth-source-tree.h \
@@ -181,6 +182,7 @@ gthumb_SOURCES = \
gth-nav-window.c \
gth-pixbuf-task.c \
gth-preferences.c \
+ gth-progress-dialog.c \
gth-sidebar.c \
gth-source-tree.c \
gth-statusbar.c \
diff --git a/gthumb/gth-browser.c b/gthumb/gth-browser.c
index 10a75b5..c14fc9f 100644
--- a/gthumb/gth-browser.c
+++ b/gthumb/gth-browser.c
@@ -45,6 +45,7 @@
#include "gth-marshal.h"
#include "gth-metadata-provider.h"
#include "gth-preferences.h"
+#include "gth-progress-dialog.h"
#include "gth-sidebar.h"
#include "gth-statusbar.h"
#include "gth-toggle-menu-tool-button.h"
@@ -66,6 +67,7 @@
#define LOAD_FILE_DELAY 150
#define HIDE_MOUSE_DELAY 1000
#define MOTION_THRESHOLD 0
+#define PROGRESS_DIALOG_DELAY 1000
typedef void (*GthBrowserCallback) (GthBrowser *, gboolean cancelled, gpointer user_data);
@@ -111,6 +113,8 @@ struct _GthBrowserPrivateData {
GthViewerPage *viewer_page;
GthImagePreloader *image_preloader;
+ GtkWidget *progress_dialog;
+
GHashTable *named_dialogs;
GList *toolbar_menu_buttons[GTH_BROWSER_N_PAGES];
@@ -1710,6 +1714,8 @@ gth_browser_finalize (GObject *object)
GthBrowser *browser = GTH_BROWSER (object);
if (browser->priv != NULL) {
+ if (browser->priv->progress_dialog != NULL)
+ gtk_widget_destroy (browser->priv->progress_dialog);
_g_object_unref (browser->priv->location_source);
_g_object_unref (browser->priv->location);
_g_object_unref (browser->priv->current_file);
@@ -3296,21 +3302,34 @@ task_completed_cb (GthTask *task,
static void
task_progress_cb (GthTask *task,
- const char *text,
+ const char *description,
+ const char *details,
gboolean pulse,
double fraction,
GthBrowser *browser)
{
- gth_statusbar_set_progress (GTH_STATUSBAR (browser->priv->statusbar), text, pulse, fraction);
+ gth_statusbar_set_progress (GTH_STATUSBAR (browser->priv->statusbar), description, pulse, fraction);
}
void
gth_browser_exec_task (GthBrowser *browser,
- GthTask *task)
+ GthTask *task,
+ gboolean foreground)
{
g_return_if_fail (task != NULL);
+ if (! foreground) {
+ if (browser->priv->progress_dialog == NULL) {
+ browser->priv->progress_dialog = gth_progress_dialog_new (GTK_WINDOW (browser));
+ g_object_add_weak_pointer (G_OBJECT (browser->priv->progress_dialog), (gpointer*) &(browser->priv->progress_dialog));
+ }
+ gth_progress_dialog_add_task (GTH_PROGRESS_DIALOG (browser->priv->progress_dialog), task);
+ return;
+ }
+
+ /* foreground task */
+
if (browser->priv->task != NULL)
gth_task_cancel (task);
diff --git a/gthumb/gth-browser.h b/gthumb/gth-browser.h
index 7c7b5cd..f97701d 100644
--- a/gthumb/gth-browser.h
+++ b/gthumb/gth-browser.h
@@ -105,7 +105,8 @@ void gth_browser_set_sort_order (GthBrowser *browser,
void gth_browser_stop (GthBrowser *browser);
void gth_browser_reload (GthBrowser *browser);
void gth_browser_exec_task (GthBrowser *browser,
- GthTask *task);
+ GthTask *task,
+ gboolean foreground);
void gth_browser_set_list_extra_widget (GthBrowser *browser,
GtkWidget *widget);
GtkWidget * gth_browser_get_list_extra_widget (GthBrowser *browser);
diff --git a/gthumb/gth-filter.c b/gthumb/gth-filter.c
index bd1d925..0dae6ce 100644
--- a/gthumb/gth-filter.c
+++ b/gthumb/gth-filter.c
@@ -60,7 +60,7 @@ struct _GthFilterPrivate {
};
-static gpointer *parent_class = NULL;
+static gpointer parent_class = NULL;
static DomElement*
diff --git a/gthumb/gth-marshal.list b/gthumb/gth-marshal.list
index 45ba709..edd97c8 100644
--- a/gthumb/gth-marshal.list
+++ b/gthumb/gth-marshal.list
@@ -6,4 +6,4 @@ VOID:OBJECT, BOOLEAN
VOID:OBJECT, UINT
VOID:OBJECT, STRING
VOID:POINTER, POINTER
-VOID:STRING, BOOLEAN, DOUBLE
+VOID:STRING, STRING, BOOLEAN, DOUBLE
diff --git a/gthumb/gth-pixbuf-task.c b/gthumb/gth-pixbuf-task.c
index f00e88a..79fedf9 100644
--- a/gthumb/gth-pixbuf-task.c
+++ b/gthumb/gth-pixbuf-task.c
@@ -99,7 +99,11 @@ one_step (gpointer data)
pixbuf_task->dest_line += pixbuf_task->rowstride;
if (pixbuf_task->line % PROGRESS_STEP == 0)
- gth_task_progress (GTH_TASK (pixbuf_task), pixbuf_task->description, FALSE, (double) pixbuf_task->line / pixbuf_task->height);
+ gth_task_progress (GTH_TASK (pixbuf_task),
+ pixbuf_task->description,
+ NULL,
+ FALSE,
+ (double) pixbuf_task->line / pixbuf_task->height);
if (! pixbuf_task->ltr) { /* right to left */
int ofs = (pixbuf_task->width - 1) * pixbuf_task->bytes_per_pixel;
diff --git a/gthumb/gth-progress-dialog.c b/gthumb/gth-progress-dialog.c
new file mode 100644
index 0000000..596cf25
--- /dev/null
+++ b/gthumb/gth-progress-dialog.c
@@ -0,0 +1,332 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * GThumb
+ *
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <glib/gi18n.h>
+#include <pango/pango.h>
+#include "gth-progress-dialog.h"
+#include "gtk-utils.h"
+
+#define DIALOG_WIDTH 450
+
+
+/* -- gth_task_progress -- */
+
+
+#define GTH_TYPE_TASK_PROGRESS (gth_task_progress_get_type ())
+#define GTH_TASK_PROGRESS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTH_TYPE_TASK_PROGRESS, GthTaskProgress))
+#define GTH_TASK_PROGRESS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTH_TYPE_TASK_PROGRESS, GthTaskProgressClass))
+#define GTH_IS_TASK_PROGRESS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTH_TYPE_TASK_PROGRESS))
+#define GTH_IS_TASK_PROGRESS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTH_TYPE_TASK_PROGRESS))
+#define GTH_TASK_PROGRESS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTH_TYPE_TASK_PROGRESS, GthTaskProgressClass))
+
+typedef struct _GthTaskProgress GthTaskProgress;
+typedef struct _GthTaskProgressClass GthTaskProgressClass;
+
+struct _GthTaskProgress {
+ GtkHBox parent_instance;
+ GthTask *task;
+ GtkWidget *description_label;
+ GtkWidget *details_label;
+ GtkWidget *fraction_progressbar;
+ GtkWidget *cancel_button;
+ gulong task_progress;
+ gulong task_completed;
+};
+
+struct _GthTaskProgressClass {
+ GtkHBoxClass parent_class;
+};
+
+static gpointer gth_task_progress_parent_class = NULL;
+
+
+static void
+gth_task_progress_finalize (GObject *base)
+{
+ GthTaskProgress *self = (GthTaskProgress *) base;
+
+ g_signal_handler_disconnect (self->task, self->task_progress);
+ g_signal_handler_disconnect (self->task, self->task_completed);
+ gth_task_cancel (self->task);
+ g_object_unref (self->task);
+
+ G_OBJECT_CLASS (gth_task_progress_parent_class)->finalize (base);
+}
+
+static void
+gth_task_progress_class_init (GthTaskProgressClass *klass)
+{
+ gth_task_progress_parent_class = g_type_class_peek_parent (klass);
+ G_OBJECT_CLASS (klass)->finalize = gth_task_progress_finalize;
+}
+
+
+static void
+gth_task_progress_init (GthTaskProgress *self)
+{
+ GtkWidget *vbox;
+ PangoAttrList *attr_list;
+ GtkWidget *image;
+
+ self->task = NULL;
+
+ vbox = gtk_vbox_new (FALSE, 3);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+ gtk_widget_show (vbox);
+ gtk_box_pack_start (GTK_BOX (self), vbox, TRUE, TRUE, 0);
+
+ self->description_label = gtk_label_new ("");
+ gtk_misc_set_alignment (GTK_MISC (self->description_label), 0.0, 0.5);
+ gtk_widget_show (self->description_label);
+ gtk_box_pack_start (GTK_BOX (vbox), self->description_label, FALSE, FALSE, 0);
+
+ self->fraction_progressbar = gtk_progress_bar_new ();
+ gtk_widget_set_size_request (self->fraction_progressbar, -1, 15);
+ gtk_widget_show (self->fraction_progressbar);
+ gtk_box_pack_start (GTK_BOX (vbox), self->fraction_progressbar, FALSE, FALSE, 0);
+
+ self->details_label = gtk_label_new ("");
+ attr_list = pango_attr_list_new ();
+ pango_attr_list_insert (attr_list, pango_attr_size_new (8500));
+ g_object_set (self->details_label, "attributes", attr_list, NULL);
+ gtk_misc_set_alignment (GTK_MISC (self->details_label), 0.0, 0.5);
+ gtk_widget_show (self->details_label);
+ gtk_box_pack_start (GTK_BOX (vbox), self->details_label, FALSE, FALSE, 0);
+
+ vbox = gtk_vbox_new (FALSE, 0);
+ gtk_widget_show (vbox);
+ gtk_box_pack_start (GTK_BOX (self), vbox, FALSE, FALSE, 0);
+
+ self->cancel_button = gtk_button_new ();
+ gtk_widget_show (self->cancel_button);
+ gtk_widget_set_tooltip_text (self->cancel_button, _("Cancel operation"));
+ gtk_box_pack_start (GTK_BOX (vbox), self->cancel_button, TRUE, FALSE, 0);
+
+ image = gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_MENU);
+ gtk_widget_show (image);
+ gtk_container_add (GTK_CONTAINER (self->cancel_button), image);
+
+ pango_attr_list_unref (attr_list);
+}
+
+
+GType
+gth_task_progress_get_type (void)
+{
+ static GType type = 0;
+
+ if (type == 0) {
+ static const GTypeInfo g_define_type_info = {
+ sizeof (GthTaskProgressClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) gth_task_progress_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (GthTaskProgress),
+ 0,
+ (GInstanceInitFunc) gth_task_progress_init,
+ NULL
+ };
+ type = g_type_register_static (GTK_TYPE_HBOX,
+ "GthTaskProgress",
+ &g_define_type_info,
+ 0);
+ }
+
+ return type;
+}
+
+
+static void
+task_progress_cb (GthTask *task,
+ const char *description,
+ const char *details,
+ gboolean pulse,
+ double fraction,
+ gpointer user_data)
+{
+ GthTaskProgress *self = user_data;
+
+ if (description == NULL)
+ return;
+
+ gtk_label_set_text (GTK_LABEL (self->description_label), description);
+ gtk_label_set_text (GTK_LABEL (self->details_label), details);
+ if (pulse)
+ gtk_progress_bar_pulse (GTK_PROGRESS_BAR (self->fraction_progressbar));
+ else
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (self->fraction_progressbar), fraction);
+}
+
+
+static void gth_progress_dialog_remove_child (GthProgressDialog *dialog, GtkWidget *child);
+
+
+static void
+task_completed_cb (GthTask *task,
+ GError *error,
+ gpointer user_data)
+{
+ GthTaskProgress *self = user_data;
+
+ gth_progress_dialog_remove_child (GTH_PROGRESS_DIALOG (gtk_widget_get_toplevel (GTK_WIDGET (self))), GTK_WIDGET (self));
+}
+
+
+GtkWidget *
+gth_task_progress_new (GthTask *task)
+{
+ GthTaskProgress *self;
+
+ self = g_object_new (GTH_TYPE_TASK_PROGRESS, NULL);
+ self->task = g_object_ref (task);
+ self->task_progress = g_signal_connect (self->task,
+ "progress",
+ G_CALLBACK (task_progress_cb),
+ self);
+ self->task_completed = g_signal_connect (self->task,
+ "completed",
+ G_CALLBACK (task_completed_cb),
+ self);
+
+ return (GtkWidget *) self;
+}
+
+
+/* -- gth_progress_dialog -- */
+
+
+static gpointer gth_progress_dialog_parent_class = NULL;
+
+
+struct _GthProgressDialogPrivate {
+ GtkWidget *task_box;
+};
+
+
+static void
+gth_progress_dialog_class_init (GthProgressDialogClass *klass)
+{
+ gth_progress_dialog_parent_class = g_type_class_peek_parent (klass);
+ g_type_class_add_private (klass, sizeof (GthProgressDialogPrivate));
+}
+
+
+static void
+progress_dialog_response_cb (GtkDialog *dialog,
+ int response,
+ gpointer user_data)
+{
+ if (response == GTK_RESPONSE_CLOSE)
+ gtk_widget_hide (GTK_WIDGET (dialog));
+}
+
+
+static void
+gth_progress_dialog_init (GthProgressDialog *self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTH_TYPE_PROGRESS_DIALOG, GthProgressDialogPrivate);
+
+ gtk_widget_set_size_request (GTK_WIDGET (self), DIALOG_WIDTH, -1);
+ gtk_window_set_title (GTK_WINDOW (self), "");
+ gtk_window_set_resizable (GTK_WINDOW (self), TRUE);
+ gtk_dialog_set_has_separator (GTK_DIALOG (self), FALSE);
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (self)->vbox), 5);
+ gtk_container_set_border_width (GTK_CONTAINER (self), 5);
+
+ gtk_dialog_add_button (GTK_DIALOG (self), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
+
+ self->priv->task_box = gtk_vbox_new (FALSE, 6);
+ gtk_widget_show (self->priv->task_box);
+ gtk_container_set_border_width (GTK_CONTAINER (self->priv->task_box), 5);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (self)->vbox), self->priv->task_box, FALSE, FALSE, 0);
+
+ g_signal_connect (self, "response", G_CALLBACK (progress_dialog_response_cb), self);
+ g_signal_connect (self, "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), self);
+}
+
+
+GType
+gth_progress_dialog_get_type (void)
+{
+ static GType type = 0;
+
+ if (type == 0) {
+ static const GTypeInfo g_define_type_info = {
+ sizeof (GthProgressDialogClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) gth_progress_dialog_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (GthProgressDialog),
+ 0,
+ (GInstanceInitFunc) gth_progress_dialog_init,
+ NULL
+ };
+ type = g_type_register_static (GTK_TYPE_DIALOG,
+ "GthProgressDialog",
+ &g_define_type_info,
+ 0);
+ }
+
+ return type;
+}
+
+
+GtkWidget *
+gth_progress_dialog_new (GtkWindow *parent)
+{
+ GthProgressDialog *self;
+
+ self = g_object_new (GTH_TYPE_PROGRESS_DIALOG, NULL);
+ gtk_window_set_transient_for (GTK_WINDOW (self), parent);
+
+ return (GtkWidget *) self;
+}
+
+
+void
+gth_progress_dialog_add_task (GthProgressDialog *self,
+ GthTask *task)
+{
+ GtkWidget *child;
+
+ child = gth_task_progress_new (task);
+ gtk_widget_show (child);
+ gtk_box_pack_start (GTK_BOX (self->priv->task_box), child, TRUE, TRUE, 0);
+ gtk_window_present (GTK_WINDOW (self));
+
+ gth_task_exec (task);
+}
+
+
+static void
+gth_progress_dialog_remove_child (GthProgressDialog *self,
+ GtkWidget *child)
+{
+ gtk_container_remove (GTK_CONTAINER (self->priv->task_box), child);
+ if (_gtk_container_get_n_children (GTK_CONTAINER (self->priv->task_box)) == 0)
+ gtk_widget_hide (GTK_WIDGET (self));
+}
diff --git a/gthumb/gth-progress-dialog.h b/gthumb/gth-progress-dialog.h
new file mode 100644
index 0000000..a7d2e45
--- /dev/null
+++ b/gthumb/gth-progress-dialog.h
@@ -0,0 +1,58 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * GThumb
+ *
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef GTH_PROGRESS_DIALOG_H
+#define GTH_PROGRESS_DIALOG_H
+
+#include <gtk/gtk.h>
+#include "gth-task.h"
+
+G_BEGIN_DECLS
+
+#define GTH_TYPE_PROGRESS_DIALOG (gth_progress_dialog_get_type ())
+#define GTH_PROGRESS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTH_TYPE_PROGRESS_DIALOG, GthProgressDialog))
+#define GTH_PROGRESS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTH_TYPE_PROGRESS_DIALOG, GthProgressDialogClass))
+#define GTH_IS_PROGRESS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTH_TYPE_PROGRESS_DIALOG))
+#define GTH_IS_PROGRESS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTH_TYPE_PROGRESS_DIALOG))
+#define GTH_PROGRESS_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTH_TYPE_PROGRESS_DIALOG, GthProgressDialogClass))
+
+typedef struct _GthProgressDialog GthProgressDialog;
+typedef struct _GthProgressDialogClass GthProgressDialogClass;
+typedef struct _GthProgressDialogPrivate GthProgressDialogPrivate;
+
+struct _GthProgressDialog {
+ GtkDialog parent_instance;
+ GthProgressDialogPrivate *priv;
+};
+
+struct _GthProgressDialogClass {
+ GtkDialogClass parent_class;
+};
+
+GType gth_progress_dialog_get_type (void);
+GtkWidget * gth_progress_dialog_new (GtkWindow *parent);
+void gth_progress_dialog_add_task (GthProgressDialog *dialog,
+ GthTask *task);
+
+G_END_DECLS
+
+#endif /* GTH_PROGRESS_DIALOG_H */
diff --git a/gthumb/gth-task.c b/gthumb/gth-task.c
index 93e82da..1cd96ad 100644
--- a/gthumb/gth-task.c
+++ b/gthumb/gth-task.c
@@ -112,9 +112,10 @@ gth_task_class_init (GthTaskClass *class)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GthTaskClass, progress),
NULL, NULL,
- gth_marshal_VOID__STRING_BOOLEAN_DOUBLE,
+ gth_marshal_VOID__STRING_STRING_BOOLEAN_DOUBLE,
G_TYPE_NONE,
- 3,
+ 4,
+ G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_BOOLEAN,
G_TYPE_DOUBLE);
@@ -198,9 +199,10 @@ gth_task_completed (GthTask *task,
void
gth_task_progress (GthTask *task,
- const char *text,
+ const char *description,
+ const char *details,
gboolean pulse,
double fraction)
{
- g_signal_emit (task, gth_task_signals[PROGRESS], 0, text, pulse, fraction);
+ g_signal_emit (task, gth_task_signals[PROGRESS], 0, description, details, pulse, fraction);
}
diff --git a/gthumb/gth-task.h b/gthumb/gth-task.h
index a8499f0..bb07702 100644
--- a/gthumb/gth-task.h
+++ b/gthumb/gth-task.h
@@ -31,7 +31,8 @@ G_BEGIN_DECLS
typedef enum {
GTH_TASK_ERROR_FAILED,
- GTH_TASK_ERROR_CANCELLED
+ GTH_TASK_ERROR_CANCELLED,
+ GTH_TASK_ERROR_SKIP_TO_NEXT_FILE,
} GthTaskErrorEnum;
#define GTH_TYPE_TASK (gth_task_get_type ())
@@ -60,7 +61,8 @@ struct _GthTaskClass
void (*completed) (GthTask *task,
GError *error);
void (*progress) (GthTask *task,
- const char *text,
+ const char *description,
+ const char *details,
gboolean pulse,
double fraction);
@@ -80,7 +82,8 @@ void gth_task_cancel (GthTask *task);
void gth_task_completed (GthTask *task,
GError *error);
void gth_task_progress (GthTask *task,
- const char *text,
+ const char *description,
+ const char *details,
gboolean pulse,
double fraction);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]