[Xfce4-commits] [xfce/xfdesktop] 01/03: g_file_trash_async is too new (Bug 10786)
noreply at xfce.org
noreply at xfce.org
Thu Apr 3 15:42:06 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 f88ce1c815455bb207d3ac608bb8e7bcedfbcc89
Author: Eric Koegel <eric.koegel at gmail.com>
Date: Tue Apr 1 19:48:11 2014 +0300
g_file_trash_async is too new (Bug 10786)
---
src/xfdesktop-file-utils.c | 102 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 102 insertions(+)
diff --git a/src/xfdesktop-file-utils.c b/src/xfdesktop-file-utils.c
index b6e105b..0976b3c 100644
--- a/src/xfdesktop-file-utils.c
+++ b/src/xfdesktop-file-utils.c
@@ -781,6 +781,7 @@ xfdesktop_file_utils_bulk_rename(GFile *working_directory,
}
}
+#if GLIB_CHECK_VERSION (2, 38, 0)
static void
delete_files(gpointer data, gpointer user_data)
{
@@ -792,7 +793,9 @@ delete_files(gpointer data, gpointer user_data)
g_file_delete_async(G_FILE(data), G_PRIORITY_DEFAULT, NULL, NULL, NULL);
}
+#endif
+#if GLIB_CHECK_VERSION (2, 38, 0)
static void
trash_files(gpointer data, gpointer user_data)
{
@@ -804,15 +807,65 @@ trash_files(gpointer data, gpointer user_data)
g_file_trash_async(G_FILE(data), G_PRIORITY_DEFAULT, NULL, NULL, NULL);
}
+#endif
void
xfdesktop_file_utils_unlink_files(GList *files,
GdkScreen *screen,
GtkWindow *parent)
{
+#if GLIB_CHECK_VERSION (2, 38, 0)
g_return_if_fail(files != NULL && G_IS_FILE(files->data));
g_list_foreach(files, (GFunc)delete_files, NULL);
+ /* return statement to explicitly show we don't
+ * want to run any of the fallback code. */
+ return;
+#else
+ 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(!screen)
+ screen = gtk_widget_get_screen(GTK_WIDGET(parent));
+
+ 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;
+
+ /* 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_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);
+
+ 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,
+ _("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);
+ }
+#endif
}
void
@@ -820,9 +873,58 @@ xfdesktop_file_utils_trash_files(GList *files,
GdkScreen *screen,
GtkWindow *parent)
{
+#if GLIB_CHECK_VERSION (2, 38, 0)
g_return_if_fail(files != NULL && G_IS_FILE(files->data));
g_list_foreach(files, (GFunc)trash_files, NULL);
+ /* return statement to explicitly show we don't
+ * want to run any of the fallback code. */
+ return;
+#else
+ 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);
+ }
+#endif
}
void
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list