[Xfce4-commits] [xfce/xfdesktop] 01/01: Use GIO directly for delete/trash operations (Bug 10778)
noreply at xfce.org
noreply at xfce.org
Sun Mar 30 19:33:43 CEST 2014
This is an automated email from the git hooks/post-receive script.
eric pushed a commit to branch master
in repository xfce/xfdesktop.
commit d48b40f6623a758ff128f5b22b2bd3e581b5b2a3
Author: Eric Koegel <eric.koegel at gmail.com>
Date: Sun Mar 30 19:12:05 2014 +0300
Use GIO directly for delete/trash operations (Bug 10778)
Instead of passing the list of files over to Thunar via D-Bus to
trash or delete files, just use the async GIO functions directly.
We'll continue to use Thunar for the other operations because of
the file transfer dialog.
---
src/xfdesktop-file-utils.c | 106 +++++++++++---------------------------------
1 file changed, 25 insertions(+), 81 deletions(-)
diff --git a/src/xfdesktop-file-utils.c b/src/xfdesktop-file-utils.c
index 8fbd4a7..b6e105b 100644
--- a/src/xfdesktop-file-utils.c
+++ b/src/xfdesktop-file-utils.c
@@ -781,54 +781,38 @@ xfdesktop_file_utils_bulk_rename(GFile *working_directory,
}
}
-void
-xfdesktop_file_utils_unlink_files(GList *files,
- GdkScreen *screen,
- GtkWindow *parent)
+static void
+delete_files(gpointer data, gpointer user_data)
{
- DBusGProxy *fileman_proxy;
-
- g_return_if_fail(files != NULL && G_IS_FILE(files->data));
- g_return_if_fail(GDK_IS_SCREEN(screen) || GTK_IS_WINDOW(parent));
+ if(data == NULL)
+ return;
- if(!screen)
- screen = gtk_widget_get_screen(GTK_WIDGET(parent));
+ if(!G_IS_FILE(data))
+ return;
- fileman_proxy = xfdesktop_file_utils_peek_filemanager_proxy();
- if(fileman_proxy) {
- guint nfiles = g_list_length(files);
- gchar **uris = g_new0(gchar *, nfiles+1);
- gchar *display_name = gdk_screen_make_display_name(screen);
- gchar *startup_id = g_strdup_printf("_TIME%d", gtk_get_current_event_time());
- GList *lp;
- gint n;
+ g_file_delete_async(G_FILE(data), G_PRIORITY_DEFAULT, NULL, NULL, NULL);
+}
- /* convert GFile list into an array of URIs */
- for(n = 0, lp = files; lp != NULL; ++n, lp = lp->next)
- uris[n] = g_file_get_uri(lp->data);
- uris[n] = NULL;
+static void
+trash_files(gpointer data, gpointer user_data)
+{
+ if(data == NULL)
+ return;
- xfdesktop_file_utils_set_window_cursor(parent, GDK_WATCH);
+ if(!G_IS_FILE(data))
+ return;
- xfdesktop_file_manager_proxy_unlink_files_async(fileman_proxy,
- NULL, (const gchar **)uris,
- display_name, startup_id,
- (xfdesktop_file_manager_proxy_unlink_files_reply)xfdesktop_file_utils_async_cb,
- parent);
+ g_file_trash_async(G_FILE(data), G_PRIORITY_DEFAULT, NULL, NULL, NULL);
+}
- xfdesktop_file_utils_set_window_cursor(parent, GDK_LEFT_PTR);
+void
+xfdesktop_file_utils_unlink_files(GList *files,
+ GdkScreen *screen,
+ GtkWindow *parent)
+{
+ g_return_if_fail(files != NULL && G_IS_FILE(files->data));
- g_free(startup_id);
- g_strfreev(uris);
- g_free(display_name);
- } else {
- xfce_message_dialog(parent,
- _("Delete Error"), GTK_STOCK_DIALOG_ERROR,
- _("The selected files could not be deleted"),
- _("This feature requires a file manager service to "
- "be present (such as the one supplied by Thunar)."),
- GTK_STOCK_CLOSE, GTK_RESPONSE_ACCEPT, NULL);
- }
+ g_list_foreach(files, (GFunc)delete_files, NULL);
}
void
@@ -836,49 +820,9 @@ xfdesktop_file_utils_trash_files(GList *files,
GdkScreen *screen,
GtkWindow *parent)
{
- DBusGProxy *trash_proxy;
-
g_return_if_fail(files != NULL && G_IS_FILE(files->data));
- g_return_if_fail(GDK_IS_SCREEN(screen) || GTK_IS_WINDOW(parent));
-
- if(!screen)
- screen = gtk_widget_get_screen(GTK_WIDGET(parent));
-
- trash_proxy = xfdesktop_file_utils_peek_trash_proxy();
- if(trash_proxy) {
- guint nfiles = g_list_length(files);
- gchar **uris = g_new0(gchar *, nfiles+1);
- gchar *display_name = gdk_screen_make_display_name(screen);
- gchar *startup_id = g_strdup_printf("_TIME%d", gtk_get_current_event_time());
- GList *lp;
- gint n;
- /* convert GFile list into an array of URIs */
- for(n = 0, lp = files; lp != NULL; ++n, lp = lp->next)
- uris[n] = g_file_get_uri(lp->data);
- uris[n] = NULL;
-
- xfdesktop_file_utils_set_window_cursor(parent, GDK_WATCH);
-
- xfdesktop_trash_proxy_move_to_trash_async(trash_proxy,
- (const gchar **)uris,
- display_name, startup_id,
- (xfdesktop_trash_proxy_move_to_trash_reply)xfdesktop_file_utils_async_cb,
- parent);
-
- xfdesktop_file_utils_set_window_cursor(parent, GDK_LEFT_PTR);
-
- g_free(startup_id);
- g_strfreev(uris);
- g_free(display_name);
- } else {
- xfce_message_dialog(parent,
- _("Trash Error"), GTK_STOCK_DIALOG_ERROR,
- _("The selected files could not be moved to the trash"),
- _("This feature requires a trash service to "
- "be present (such as the one supplied by Thunar)."),
- GTK_STOCK_CLOSE, GTK_RESPONSE_ACCEPT, NULL);
- }
+ g_list_foreach(files, (GFunc)trash_files, NULL);
}
void
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list