[gthumb] make 'delete files' and 'trash files' asyncronous
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] make 'delete files' and 'trash files' asyncronous
- Date: Sun, 15 Mar 2015 17:36:13 +0000 (UTC)
commit fd18a89e74faf4f3ba9f570241de275327cc505a
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sun Mar 1 12:04:32 2015 +0100
make 'delete files' and 'trash files' asyncronous
extensions/file_manager/Makefile.am | 2 -
extensions/file_manager/actions.c | 1 -
gthumb/Makefile.am | 4 +
gthumb/gio-utils.c | 149 +++++++++++--
gthumb/gio-utils.h | 4 +
.../file_manager => gthumb}/gth-delete-task.c | 2 +
.../file_manager => gthumb}/gth-delete-task.h | 4 +-
gthumb/gth-file-source-vfs.c | 249 ++++++++------------
gthumb/gth-monitor.c | 56 +++++
gthumb/gth-monitor.h | 2 +
.../gth-delete-task.c => gthumb/gth-trash-task.c | 56 +++---
gthumb/gth-trash-task.h | 57 +++++
12 files changed, 384 insertions(+), 202 deletions(-)
---
diff --git a/extensions/file_manager/Makefile.am b/extensions/file_manager/Makefile.am
index 5c4ea8c..6a52aac 100644
--- a/extensions/file_manager/Makefile.am
+++ b/extensions/file_manager/Makefile.am
@@ -8,8 +8,6 @@ libfile_manager_la_SOURCES = \
callbacks.h \
gth-copy-task.c \
gth-copy-task.h \
- gth-delete-task.c \
- gth-delete-task.h \
gth-duplicate-task.c \
gth-duplicate-task.h \
gth-reorder-task.c \
diff --git a/extensions/file_manager/actions.c b/extensions/file_manager/actions.c
index 629fc96..f595457 100644
--- a/extensions/file_manager/actions.c
+++ b/extensions/file_manager/actions.c
@@ -25,7 +25,6 @@
#include <gthumb.h>
#include "actions.h"
#include "gth-copy-task.h"
-#include "gth-delete-task.h"
#include "gth-duplicate-task.h"
#include "preferences.h"
diff --git a/gthumb/Makefile.am b/gthumb/Makefile.am
index dba678f..fb68e9e 100644
--- a/gthumb/Makefile.am
+++ b/gthumb/Makefile.am
@@ -36,6 +36,7 @@ PUBLIC_HEADER_FILES = \
gth-buffer-data.h \
gth-browser.h \
gth-color-scale.h \
+ gth-delete-task.h \
gth-dumb-notebook.h \
gth-duplicable.h \
gth-empty-list.h \
@@ -135,6 +136,7 @@ PRIVATE_HEADER_FILES = \
gth-browser-actions-entries.h \
gth-file-details.h \
gth-metadata-provider-file.h \
+ gth-trash-task.h \
dlg-personalize-filters.h \
dlg-preferences.h \
dlg-sort-order.h \
@@ -175,6 +177,7 @@ gthumb_SOURCES = \
gth-browser-actions-callbacks.c \
gth-buffer-data.c \
gth-color-scale.c \
+ gth-delete-task.c \
gth-dumb-notebook.c \
gth-duplicable.c \
gth-empty-list.c \
@@ -258,6 +261,7 @@ gthumb_SOURCES = \
gth-time.c \
gth-time-selector.c \
gth-toolbox.c \
+ gth-trash-task.c \
gth-uri-list.c \
gth-user-dir.c \
gth-viewer-page.c \
diff --git a/gthumb/gio-utils.c b/gthumb/gio-utils.c
index 3545e24..bc3ae0a 100644
--- a/gthumb/gio-utils.c
+++ b/gthumb/gio-utils.c
@@ -1899,6 +1899,8 @@ _g_delete_files (GList *file_list,
typedef struct {
+ GList *file_list;
+ GList *current;
gboolean include_metadata;
GCancellable *cancellable;
ReadyFunc callback;
@@ -1909,37 +1911,72 @@ typedef struct {
static void
delete_data_free (DeleteData *delete_data)
{
+ _g_object_list_unref (delete_data->file_list);
_g_object_unref (delete_data->cancellable);
g_free (delete_data);
}
+static void delete_files__delete_current (DeleteData *delete_data);
+
+
static void
-delete_files__info_ready_cb (GList *files,
- GError *error,
- gpointer user_data)
+delete_files__delete_current_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
DeleteData *delete_data = user_data;
+ GError *error = NULL;
- if (error == NULL) {
- GList *file_list;
- GList *scan;
+ if (! g_file_delete_finish (G_FILE (source_object), result, &error)) {
+ delete_data->callback (error, delete_data->user_data);
+ delete_data_free (delete_data);
+ g_error_free (error);
+ return;
+ }
- file_list = _g_object_list_ref (files);
- file_list = g_list_reverse (file_list);
+ delete_data->current = delete_data->current->next;
+ delete_files__delete_current (delete_data);
+}
- for (scan = file_list; scan; scan = scan->next) {
- GthFileData *file_data = scan->data;
- if (! g_file_delete (file_data->file, delete_data->cancellable, &error))
- break;
- }
+static void
+delete_files__delete_current (DeleteData *delete_data)
+{
+ GthFileData *file_data;
- _g_object_list_unref (file_list);
+ if (delete_data->current == NULL) {
+ delete_data->callback (NULL, delete_data->user_data);
+ delete_data_free (delete_data);
+ return;
}
- delete_data->callback (error, delete_data->user_data);
- delete_data_free (delete_data);
+ file_data = delete_data->current->data;
+ g_file_delete_async (file_data->file,
+ G_PRIORITY_DEFAULT,
+ delete_data->cancellable,
+ delete_files__delete_current_cb,
+ delete_data);
+}
+
+
+static void
+delete_files__info_ready_cb (GList *files,
+ GError *error,
+ gpointer user_data)
+{
+ DeleteData *delete_data = user_data;
+
+ if (error != NULL) {
+ delete_data->callback (error, delete_data->user_data);
+ delete_data_free (delete_data);
+ return;
+ }
+
+ delete_data->file_list = _g_object_list_ref (files);
+ delete_data->file_list = g_list_reverse (delete_data->file_list);
+ delete_data->current = delete_data->file_list;
+ delete_files__delete_current (delete_data);
}
@@ -1955,6 +1992,7 @@ _g_delete_files_async (GList *file_list,
GthListFlags flags;
delete_data = g_new0 (DeleteData, 1);
+ delete_data->file_list = NULL;
delete_data->include_metadata = include_metadata;
delete_data->cancellable = _g_object_ref (cancellable);
delete_data->callback = callback;
@@ -1973,6 +2011,85 @@ _g_delete_files_async (GList *file_list,
}
+/* -- _g_trash_files_async -- */
+
+
+typedef struct {
+ GList *file_list;
+ GList *current;
+ GCancellable *cancellable;
+ ReadyFunc callback;
+ gpointer user_data;
+} TrashData;
+
+
+static void
+trash_data_free (TrashData *tdata)
+{
+ _g_object_list_unref (tdata->file_list);
+ _g_object_unref (tdata->cancellable);
+ g_free (tdata);
+}
+
+
+static void trash_files__delete_current (TrashData *tdata);
+
+
+static void
+trash_files__delete_current_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ TrashData *tdata = user_data;
+ GError *error = NULL;
+
+ if (! g_file_trash_finish (G_FILE (source_object), result, &error)) {
+ tdata->callback (error, tdata->user_data);
+ trash_data_free (tdata);
+ g_error_free (error);
+ return;
+ }
+
+ tdata->current = tdata->current->next;
+ trash_files__delete_current (tdata);
+}
+
+
+static void
+trash_files__delete_current (TrashData *tdata)
+{
+ if (tdata->current == NULL) {
+ tdata->callback (NULL, tdata->user_data);
+ trash_data_free (tdata);
+ return;
+ }
+
+ g_file_trash_async ((GFile *) tdata->current->data,
+ G_PRIORITY_DEFAULT,
+ tdata->cancellable,
+ trash_files__delete_current_cb,
+ tdata);
+}
+
+
+void
+_g_trash_files_async (GList *file_list, /* GFile list */
+ GCancellable *cancellable,
+ ReadyFunc callback,
+ gpointer user_data)
+{
+ TrashData *tdata;
+
+ tdata = g_new0 (TrashData, 1);
+ tdata->file_list = _g_object_list_ref (file_list);
+ tdata->cancellable = _g_object_ref (cancellable);
+ tdata->callback = callback;
+ tdata->user_data = user_data;
+
+ trash_files__delete_current (tdata);
+}
+
+
#define BUFFER_SIZE (64 * 1024)
diff --git a/gthumb/gio-utils.h b/gthumb/gio-utils.h
index e9d1dde..1fcea2c 100644
--- a/gthumb/gio-utils.h
+++ b/gthumb/gio-utils.h
@@ -151,6 +151,10 @@ void _g_delete_files_async (GList *file_list,
GCancellable *cancellable,
ReadyFunc callback,
gpointer user_data);
+void _g_trash_files_async (GList *file_list,
+ GCancellable *cancellable,
+ ReadyFunc callback,
+ gpointer user_data);
/* -- load/write/create file -- */
diff --git a/extensions/file_manager/gth-delete-task.c b/gthumb/gth-delete-task.c
similarity index 98%
copy from extensions/file_manager/gth-delete-task.c
copy to gthumb/gth-delete-task.c
index 459ea49..f775699 100644
--- a/extensions/file_manager/gth-delete-task.c
+++ b/gthumb/gth-delete-task.c
@@ -20,6 +20,8 @@
*/
#include <config.h>
+#include <glib.h>
+#include <glib/gi18n-lib.h>
#include "gth-delete-task.h"
diff --git a/extensions/file_manager/gth-delete-task.h b/gthumb/gth-delete-task.h
similarity index 96%
rename from extensions/file_manager/gth-delete-task.h
rename to gthumb/gth-delete-task.h
index b04a418..d74dc0d 100644
--- a/extensions/file_manager/gth-delete-task.h
+++ b/gthumb/gth-delete-task.h
@@ -23,7 +23,9 @@
#define GTH_DELETE_TASK_H
#include <glib.h>
-#include <gthumb.h>
+#include "glib-utils.h"
+#include "gio-utils.h"
+#include "gth-task.h"
G_BEGIN_DECLS
diff --git a/gthumb/gth-file-source-vfs.c b/gthumb/gth-file-source-vfs.c
index be93ac3..56ecbf4 100644
--- a/gthumb/gth-file-source-vfs.c
+++ b/gthumb/gth-file-source-vfs.c
@@ -26,6 +26,8 @@
#include "gth-file-data.h"
#include "gio-utils.h"
#include "glib-utils.h"
+#include "gth-browser.h"
+#include "gth-delete-task.h"
#include "gth-file-source-vfs.h"
#include "gth-main.h"
#include "gth-preferences.h"
@@ -650,73 +652,17 @@ gth_file_source_vfs_monitor_directory (GthFileSource *file_source,
static void
-parent_table_value_free (gpointer key,
- gpointer value,
- gpointer user_data)
-{
- _g_object_list_unref (value);
-}
-
-
-static void
-notify_files_delete (GtkWindow *window,
- GList *files)
-{
- GHashTable *parent_table;
- GList *scan;
- GList *parent_list;
-
- parent_table = g_hash_table_new_full (g_file_hash, (GEqualFunc) g_file_equal, g_object_unref, NULL);
- for (scan = files; scan; scan = scan->next) {
- GFile *file = scan->data;
- GFile *parent;
- GList *children;
-
- parent = g_file_get_parent (file);
- if (parent == NULL)
- return;
-
- children = g_hash_table_lookup (parent_table, parent);
- children = g_list_prepend (children, g_object_ref (file));
- g_hash_table_replace (parent_table, g_object_ref (parent), children);
-
- g_object_unref (parent);
- }
-
- parent_list = g_hash_table_get_keys (parent_table);
- for (scan = parent_list; scan; scan = scan->next) {
- GFile *parent = scan->data;
- GList *children;
-
- children = g_hash_table_lookup (parent_table, parent);
- if (children != NULL)
- gth_monitor_folder_changed (gth_main_get_default_monitor (),
- parent,
- children,
- GTH_MONITOR_EVENT_DELETED);
- }
-
- g_list_free (parent_list);
- g_hash_table_foreach (parent_table, parent_table_value_free, NULL);
- g_hash_table_unref (parent_table);
-}
-
-
-static void
delete_file_permanently (GtkWindow *window,
- GList *file_list)
+ GList *file_list /* GthFileData list */)
{
- GList *files;
- GError *error = NULL;
+ GList *files;
+ GthTask *task;
files = gth_file_data_list_to_file_list (file_list);
- if (! _g_delete_files (files, TRUE, &error)) {
- _gtk_error_dialog_from_gerror_show (window, _("Could not delete the files"), error);
- g_clear_error (&error);
- }
- else
- notify_files_delete (window, files);
+ task = gth_delete_task_new (files);
+ gth_browser_exec_task (GTH_BROWSER (window), task, FALSE);
+ g_object_unref (task);
_g_object_list_unref (files);
}
@@ -736,66 +682,77 @@ delete_permanently_response_cb (GtkDialog *dialog,
}
+/* -- gth_file_mananger_trash_files -- */
+
+
+typedef struct {
+ GtkWindow *window;
+ GList *files;
+} TrashData;
+
+
static void
-trash_files (GtkWindow *window,
- GList *file_list)
-{
- GList *scan;
- gboolean moved_to_trash = TRUE;
- GError *error = NULL;
-
- for (scan = file_list; scan; scan = scan->next) {
- GthFileData *file_data = scan->data;
-
- if (! g_file_trash (file_data->file, NULL, &error)) {
- moved_to_trash = FALSE;
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED)) {
- GtkWidget *d;
-
- g_clear_error (&error);
-
- d = _gtk_yesno_dialog_new (window,
- GTK_DIALOG_MODAL,
- _("The files cannot be moved to the Trash. Do you
want to delete them permanently?"),
- _GTK_LABEL_CANCEL,
- _GTK_LABEL_DELETE);
- g_signal_connect (d,
- "response",
- G_CALLBACK (delete_permanently_response_cb),
- gth_file_data_list_dup (file_list));
- gtk_widget_show (d);
+trash_data_free (TrashData *tdata)
+{
+ _g_object_list_unref (tdata->files);
+ g_free (tdata);
+}
- break;
- }
- _gtk_error_dialog_from_gerror_show (window, _("Could not move the files to the
Trash"), error);
- g_clear_error (&error);
- break;
- }
- }
- if (moved_to_trash) {
- GList *files;
+static void
+trash_failed_delete_permanently_response_cb (GtkDialog *dialog,
+ int response_id,
+ gpointer user_data)
+{
+ TrashData *tdata = user_data;
- files = gth_file_data_list_to_file_list (file_list);
- notify_files_delete (window, files);
+ if (response_id == GTK_RESPONSE_YES) {
+ GthTask *task = gth_delete_task_new (tdata->files);
+ gth_browser_exec_task (GTH_BROWSER (tdata->window), task, FALSE);
- _g_object_list_unref (files);
+ g_object_unref (task);
}
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ trash_data_free (tdata);
}
static void
-trash_files_response_cb (GtkDialog *dialog,
- int response_id,
- gpointer user_data)
+trash_task_completed_cb (GthTask *task,
+ GError *error,
+ gpointer user_data)
{
- GList *file_list = user_data;
+ TrashData *tdata = user_data;
- if (response_id == GTK_RESPONSE_YES)
- trash_files (gtk_window_get_transient_for (GTK_WINDOW (dialog)), file_list);
+ if (error == NULL) {
+ gth_monitor_files_deleted (gth_main_get_default_monitor (), tdata->files);
+ trash_data_free (tdata);
+ }
+ else if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ trash_data_free (tdata);
+ }
+ else if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED)) {
+ GtkWidget *d;
- gtk_widget_destroy (GTK_WIDGET (dialog));
- _g_object_list_unref (file_list);
+ g_clear_error (&error);
+
+ d = _gtk_yesno_dialog_new (tdata->window,
+ GTK_DIALOG_MODAL,
+ _("The files cannot be moved to the Trash. Do you want to delete
them permanently?"),
+ _GTK_LABEL_CANCEL,
+ _GTK_LABEL_DELETE);
+ g_signal_connect (d,
+ "response",
+ G_CALLBACK (trash_failed_delete_permanently_response_cb),
+ tdata);
+ gtk_widget_show (d);
+ }
+ else {
+ _gtk_error_dialog_from_gerror_show (tdata->window, _("Could not move the files to the
Trash"), error);
+ g_clear_error (&error);
+ trash_data_free (tdata);
+ }
}
@@ -803,6 +760,28 @@ void
gth_file_mananger_trash_files (GtkWindow *window,
GList *file_list /* GthFileData list */)
{
+ TrashData *tdata;
+ GList *files;
+ GthTask *task;
+
+ tdata = g_new0 (TrashData, 1);
+ tdata->window = window;
+ tdata->files = gth_file_data_list_to_file_list (file_list);
+
+ task = gth_delete_task_new (tdata->files);
+ g_signal_connect (task,
+ "completed",
+ trash_task_completed_cb,
+ tdata);
+
+ gth_browser_exec_task (GTH_BROWSER (window), task, FALSE);
+}
+
+
+void
+gth_file_mananger_delete_files (GtkWindow *window,
+ GList *file_list /* GthFileData list */)
+{
GSettings *settings;
settings = g_settings_new (GTHUMB_MESSAGES_SCHEMA);
@@ -811,16 +790,16 @@ gth_file_mananger_trash_files (GtkWindow *window,
char *prompt;
GtkWidget *d;
+ file_list = _g_object_list_ref (file_list);
file_count = g_list_length (file_list);
if (file_count == 1) {
GthFileData *file_data = file_list->data;
- prompt = g_strdup_printf (_("Are you sure you want to move \"%s\" to trash?"),
- g_file_info_get_display_name (file_data->info));
+ prompt = g_strdup_printf (_("Are you sure you want to permanently delete \"%s\"?"),
g_file_info_get_display_name (file_data->info));
}
else
- prompt = g_strdup_printf (ngettext("Are you sure you want to move to trash "
+ prompt = g_strdup_printf (ngettext("Are you sure you want to permanently delete "
"the %'d selected file?",
- "Are you sure you want to move to trash "
+ "Are you sure you want to permanently delete "
"the %'d selected files?", file_count),
file_count);
@@ -828,60 +807,22 @@ gth_file_mananger_trash_files (GtkWindow *window,
GTK_DIALOG_MODAL,
_GTK_ICON_NAME_DIALOG_QUESTION,
prompt,
- NULL,
+ _("If you delete a file, it will be permanently lost."),
_GTK_LABEL_CANCEL, GTK_RESPONSE_CANCEL,
- _("Mo_ve to Trash"), GTK_RESPONSE_YES,
+ _GTK_LABEL_DELETE, GTK_RESPONSE_YES,
NULL);
- g_signal_connect (d, "response",
- G_CALLBACK (trash_files_response_cb),
- gth_file_data_list_dup (file_list));
+ g_signal_connect (d, "response", G_CALLBACK (delete_permanently_response_cb), file_list);
gtk_widget_show (d);
g_free (prompt);
}
else
- trash_files (window, file_list);
+ delete_file_permanently (window, file_list);
g_object_unref (settings);
}
-void
-gth_file_mananger_delete_files (GtkWindow *window,
- GList *file_list /* GthFileData list */)
-{
- int file_count;
- char *prompt;
- GtkWidget *d;
-
- file_list = _g_object_list_ref (file_list);
- file_count = g_list_length (file_list);
- if (file_count == 1) {
- GthFileData *file_data = file_list->data;
- prompt = g_strdup_printf (_("Are you sure you want to permanently delete \"%s\"?"),
g_file_info_get_display_name (file_data->info));
- }
- else
- prompt = g_strdup_printf (ngettext("Are you sure you want to permanently delete "
- "the %'d selected file?",
- "Are you sure you want to permanently delete "
- "the %'d selected files?", file_count),
- file_count);
-
- d = _gtk_message_dialog_new (window,
- GTK_DIALOG_MODAL,
- _GTK_ICON_NAME_DIALOG_QUESTION,
- prompt,
- _("If you delete a file, it will be permanently lost."),
- _GTK_LABEL_CANCEL, GTK_RESPONSE_CANCEL,
- _GTK_LABEL_DELETE, GTK_RESPONSE_YES,
- NULL);
- g_signal_connect (d, "response", G_CALLBACK (delete_permanently_response_cb), file_list);
- gtk_widget_show (d);
-
- g_free (prompt);
-}
-
-
static void
gth_file_source_vfs_remove (GthFileSource *file_source,
GthFileData *location,
diff --git a/gthumb/gth-monitor.c b/gthumb/gth-monitor.c
index 6475003..d292186 100644
--- a/gthumb/gth-monitor.c
+++ b/gthumb/gth-monitor.c
@@ -334,6 +334,62 @@ gth_monitor_file_renamed (GthMonitor *self,
}
+/* -- gth_monitor_files_deleted -- */
+
+
+static void
+parent_table_value_free (gpointer key,
+ gpointer value,
+ gpointer user_data)
+{
+ _g_object_list_unref (value);
+}
+
+
+void
+gth_monitor_files_deleted (GthMonitor *monitor,
+ GList *list /* GFile list */)
+{
+ GHashTable *parent_table;
+ GList *scan;
+ GList *parent_list;
+
+ parent_table = g_hash_table_new_full (g_file_hash, (GEqualFunc) g_file_equal, g_object_unref, NULL);
+ for (scan = list; scan; scan = scan->next) {
+ GFile *file = scan->data;
+ GFile *parent;
+ GList *children;
+
+ parent = g_file_get_parent (file);
+ if (parent == NULL)
+ return;
+
+ children = g_hash_table_lookup (parent_table, parent);
+ children = g_list_prepend (children, g_object_ref (file));
+ g_hash_table_replace (parent_table, g_object_ref (parent), children);
+
+ g_object_unref (parent);
+ }
+
+ parent_list = g_hash_table_get_keys (parent_table);
+ for (scan = parent_list; scan; scan = scan->next) {
+ GFile *parent = scan->data;
+ GList *children;
+
+ children = g_hash_table_lookup (parent_table, parent);
+ if (children != NULL)
+ gth_monitor_folder_changed (monitor,
+ parent,
+ children,
+ GTH_MONITOR_EVENT_DELETED);
+ }
+
+ g_list_free (parent_list);
+ g_hash_table_foreach (parent_table, parent_table_value_free, NULL);
+ g_hash_table_unref (parent_table);
+}
+
+
void
gth_monitor_metadata_changed (GthMonitor *self,
GthFileData *file_data)
diff --git a/gthumb/gth-monitor.h b/gthumb/gth-monitor.h
index c75acfa..e046d94 100644
--- a/gthumb/gth-monitor.h
+++ b/gthumb/gth-monitor.h
@@ -102,6 +102,8 @@ void gth_monitor_files_created_with_pos (GthMonitor *monitor,
void gth_monitor_file_renamed (GthMonitor *monitor,
GFile *file,
GFile *new_file);
+void gth_monitor_files_deleted (GthMonitor *monitor,
+ GList *list /* GFile list */);
void gth_monitor_metadata_changed (GthMonitor *monitor,
GthFileData *file_data);
void gth_monitor_emblems_changed (GthMonitor *monitor,
diff --git a/extensions/file_manager/gth-delete-task.c b/gthumb/gth-trash-task.c
similarity index 53%
rename from extensions/file_manager/gth-delete-task.c
rename to gthumb/gth-trash-task.c
index 459ea49..7912fd4 100644
--- a/extensions/file_manager/gth-delete-task.c
+++ b/gthumb/gth-trash-task.c
@@ -3,7 +3,7 @@
/*
* GThumb
*
- * Copyright (C) 2009 Free Software Foundation, Inc.
+ * Copyright (C) 2015 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
@@ -20,85 +20,85 @@
*/
#include <config.h>
-#include "gth-delete-task.h"
+#include <glib.h>
+#include <glib/gi18n-lib.h>
+#include "gth-trash-task.h"
-struct _GthDeleteTaskPrivate {
+struct _GthTrashTaskPrivate {
GList *file_list;
};
-G_DEFINE_TYPE (GthDeleteTask, gth_delete_task, GTH_TYPE_TASK)
+G_DEFINE_TYPE (GthTrashTask, gth_trash_task, GTH_TYPE_TASK)
static void
-gth_delete_task_finalize (GObject *object)
+gth_trash_task_finalize (GObject *object)
{
- GthDeleteTask *self;
+ GthTrashTask *self;
- self = GTH_DELETE_TASK (object);
+ self = GTH_TRASH_TASK (object);
_g_object_list_unref (self->priv->file_list);
- G_OBJECT_CLASS (gth_delete_task_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gth_trash_task_parent_class)->finalize (object);
}
static void
-delete_ready_cb (GError *error,
- gpointer user_data)
+trash_ready_cb (GError *error,
+ gpointer user_data)
{
gth_task_completed (GTH_TASK (user_data), error);
}
static void
-gth_delete_task_exec (GthTask *task)
+gth_trash_task_exec (GthTask *task)
{
- GthDeleteTask *self;
+ GthTrashTask *self;
- self = GTH_DELETE_TASK (task);
+ self = GTH_TRASH_TASK (task);
gth_task_progress (task, _("Deleting files"), NULL, TRUE, 0.0);
- _g_delete_files_async (self->priv->file_list,
- TRUE,
- TRUE,
- gth_task_get_cancellable (task),
- delete_ready_cb,
- self);
+ _g_trash_files_async (self->priv->file_list,
+ gth_task_get_cancellable (task),
+ trash_ready_cb,
+ self);
}
static void
-gth_delete_task_class_init (GthDeleteTaskClass *klass)
+gth_trash_task_class_init (GthTrashTaskClass *klass)
{
GObjectClass *object_class;
GthTaskClass *task_class;
- g_type_class_add_private (klass, sizeof (GthDeleteTaskPrivate));
+ g_type_class_add_private (klass, sizeof (GthTrashTaskPrivate));
object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = gth_delete_task_finalize;
+ object_class->finalize = gth_trash_task_finalize;
task_class = GTH_TASK_CLASS (klass);
- task_class->exec = gth_delete_task_exec;
+ task_class->exec = gth_trash_task_exec;
}
static void
-gth_delete_task_init (GthDeleteTask *self)
+gth_trash_task_init (GthTrashTask *self)
{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTH_TYPE_DELETE_TASK, GthDeleteTaskPrivate);
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTH_TYPE_TRASH_TASK, GthTrashTaskPrivate);
}
GthTask *
-gth_delete_task_new (GList *file_list)
+gth_trash_task_new (GList *file_list)
{
- GthDeleteTask *self;
+ GthTrashTask *self;
- self = GTH_DELETE_TASK (g_object_new (GTH_TYPE_DELETE_TASK, NULL));
+ self = GTH_TRASH_TASK (g_object_new (GTH_TYPE_TRASH_TASK, NULL));
self->priv->file_list = _g_object_list_ref (file_list);
return (GthTask *) self;
diff --git a/gthumb/gth-trash-task.h b/gthumb/gth-trash-task.h
new file mode 100644
index 0000000..1cf215b
--- /dev/null
+++ b/gthumb/gth-trash-task.h
@@ -0,0 +1,57 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * GThumb
+ *
+ * Copyright (C) 2015 The 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GTH_TRASH_TASK_H
+#define GTH_TRASH_TASK_H
+
+#include <glib.h>
+#include "glib-utils.h"
+#include "gio-utils.h"
+#include "gth-task.h"
+
+G_BEGIN_DECLS
+
+#define GTH_TYPE_TRASH_TASK (gth_trash_task_get_type ())
+#define GTH_TRASH_TASK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTH_TYPE_TRASH_TASK,
GthTrashTask))
+#define GTH_TRASH_TASK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTH_TYPE_TRASH_TASK,
GthTrashTaskClass))
+#define GTH_IS_TRASH_TASK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTH_TYPE_TRASH_TASK))
+#define GTH_IS_TRASH_TASK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTH_TYPE_TRASH_TASK))
+#define GTH_TRASH_TASK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTH_TYPE_TRASH_TASK,
GthTrashTaskClass))
+
+typedef struct _GthTrashTask GthTrashTask;
+typedef struct _GthTrashTaskClass GthTrashTaskClass;
+typedef struct _GthTrashTaskPrivate GthTrashTaskPrivate;
+
+struct _GthTrashTask {
+ GthTask __parent;
+ GthTrashTaskPrivate *priv;
+};
+
+struct _GthTrashTaskClass {
+ GthTaskClass __parent;
+};
+
+GType gth_trash_task_get_type (void);
+GthTask * gth_trash_task_new (GList *file_list);
+
+G_END_DECLS
+
+#endif /* GTH_TRASH_TASK_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]