[Xfce4-commits] r29896 - in thunar/branches/migration-to-gio: . thunar
Jannis Pohlmann
jannis at xfce.org
Thu Apr 23 22:00:35 CEST 2009
Author: jannis
Date: 2009-04-23 20:00:34 +0000 (Thu, 23 Apr 2009)
New Revision: 29896
Modified:
thunar/branches/migration-to-gio/ChangeLog
thunar/branches/migration-to-gio/thunar/thunar-application.c
thunar/branches/migration-to-gio/thunar/thunar-application.h
thunar/branches/migration-to-gio/thunar/thunar-dbus-service.c
thunar/branches/migration-to-gio/thunar/thunar-io-jobs.c
thunar/branches/migration-to-gio/thunar/thunar-io-jobs.h
thunar/branches/migration-to-gio/thunar/thunar-standard-view.c
Log:
* thunar/thunar-application.{c,h}, thunar/thunar-dbus-service.c,
thunar/thunar-io-jobs.{c,h},: Add new job
thunar_io_jobs_trash_files() and a new function
thunar_application_trash() which are used in
thunar_dbus_service_move_to_trash(), thunar_application_move_into()
and thunar_application_unlink() to move files into the trash.
* thunar/thunar-standard-view.c: Use GFiles for the drag file list.
Modified: thunar/branches/migration-to-gio/ChangeLog
===================================================================
--- thunar/branches/migration-to-gio/ChangeLog 2009-04-23 19:10:14 UTC (rev 29895)
+++ thunar/branches/migration-to-gio/ChangeLog 2009-04-23 20:00:34 UTC (rev 29896)
@@ -1,5 +1,15 @@
2009-04-23 Jannis Pohlmann <jannis at xfce.org>
+ * thunar/thunar-application.{c,h}, thunar/thunar-dbus-service.c,
+ thunar/thunar-io-jobs.{c,h},: Add new job
+ thunar_io_jobs_trash_files() and a new function
+ thunar_application_trash() which are used in
+ thunar_dbus_service_move_to_trash(), thunar_application_move_into()
+ and thunar_application_unlink() to move files into the trash.
+ * thunar/thunar-standard-view.c: Use GFiles for the drag file list.
+
+2009-04-23 Jannis Pohlmann <jannis at xfce.org>
+
* thunar/thunar-application.h: Fix thunar_appliation_link_into()
declaration and rename a few parameters.
Modified: thunar/branches/migration-to-gio/thunar/thunar-application.c
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-application.c 2009-04-23 19:10:14 UTC (rev 29895)
+++ thunar/branches/migration-to-gio/thunar/thunar-application.c 2009-04-23 20:00:34 UTC (rev 29896)
@@ -1226,31 +1226,23 @@
GFile *target_file,
GClosure *new_files_closure)
{
- const gchar *icon;
- const gchar *text;
-
_thunar_return_if_fail (parent == NULL || GDK_IS_SCREEN (parent) || GTK_IS_WIDGET (parent));
_thunar_return_if_fail (THUNAR_IS_APPLICATION (application));
_thunar_return_if_fail (target_file != NULL);
-
- /* determine the appropriate message text and the icon based on the target_path */
- /* TODO we can remove this once we have thunar_application_trash() */
- if (g_file_is_trashed (target_file))
+
+ /* launch the appropriate operation depending on the target file */
+ if (g_file_is_trashed (target_file))
{
- icon = "gnome-fs-trash-full";
- text = _("Moving files into the trash...");
+ thunar_application_trash (application, parent, source_file_list);
}
else
{
- icon = "stock_folder-move";
- text = _("Moving files...");
+ thunar_application_collect_and_launch (application, parent,
+ "stock_folder-move", _("Moving files..."),
+ thunar_io_jobs_move_files,
+ source_file_list, target_file,
+ new_files_closure);
}
-
- /* launch the operation */
- thunar_application_collect_and_launch (application, parent, icon, text,
- thunar_io_jobs_move_files,
- source_file_list, target_file,
- new_files_closure);
}
@@ -1286,7 +1278,6 @@
GtkWindow *window;
GdkScreen *screen;
gboolean permanently;
- GFile *path;
GList *path_list = NULL;
GList *lp;
gchar *message;
@@ -1361,10 +1352,7 @@
else
{
/* launch the "Move to Trash" operation */
- /* TODO Use thunar_application_trash() here */
- path = g_file_new_for_trash ();
- thunar_application_move_into (application, parent, path_list, path, NULL);
- g_object_unref (path);
+ thunar_application_trash (application, parent, path_list);
}
/* release the path list */
@@ -1373,6 +1361,31 @@
+static ThunarJob *
+trash_stub (GList *source_file_list,
+ GList *target_file_list)
+{
+ return thunar_io_jobs_trash_files (source_file_list);
+}
+
+
+
+void
+thunar_application_trash (ThunarApplication *application,
+ gpointer parent,
+ GList *file_list)
+{
+ _thunar_return_if_fail (parent == NULL || GDK_IS_SCREEN (parent) || GTK_IS_WIDGET (parent));
+ _thunar_return_if_fail (THUNAR_IS_APPLICATION (application));
+ _thunar_return_if_fail (file_list != NULL);
+
+ thunar_application_launch (application, parent, "gnome-fs-trash-full",
+ _("Moving files into the trash..."), trash_stub,
+ file_list, NULL, NULL);
+}
+
+
+
static ThunarJob*
creat_stub (GList *source_path_list,
GList *target_path_list)
Modified: thunar/branches/migration-to-gio/thunar/thunar-application.h
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-application.h 2009-04-23 19:10:14 UTC (rev 29895)
+++ thunar/branches/migration-to-gio/thunar/thunar-application.h 2009-04-23 20:00:34 UTC (rev 29896)
@@ -96,6 +96,10 @@
gpointer parent,
GList *file_list);
+void thunar_application_trash (ThunarApplication *application,
+ gpointer parent,
+ GList *file_list);
+
void thunar_application_creat (ThunarApplication *application,
gpointer parent,
GList *file_list,
Modified: thunar/branches/migration-to-gio/thunar/thunar-dbus-service.c
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-dbus-service.c 2009-04-23 19:10:14 UTC (rev 29895)
+++ thunar/branches/migration-to-gio/thunar/thunar-dbus-service.c 2009-04-23 20:00:34 UTC (rev 29896)
@@ -590,7 +590,6 @@
{
ThunarApplication *application;
GFile *file;
- GFile *target_file;
GdkScreen *screen;
GError *err = NULL;
GList *file_list = NULL;
@@ -624,10 +623,7 @@
{
/* tell the application to move the specified files to the trash */
application = thunar_application_get ();
- /* TODO use thunar_application_trash() instead of thunar_application_move_into() here */
- target_file = g_file_new_for_trash ();
- thunar_application_move_into (application, screen, file_list, target_file, NULL);
- g_object_unref (target_file);
+ thunar_application_trash (application, screen, file_list);
g_object_unref (application);
}
Modified: thunar/branches/migration-to-gio/thunar/thunar-io-jobs.c
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-io-jobs.c 2009-04-23 19:10:14 UTC (rev 29895)
+++ thunar/branches/migration-to-gio/thunar/thunar-io-jobs.c 2009-04-23 20:00:34 UTC (rev 29896)
@@ -617,3 +617,52 @@
G_TYPE_FILE_LIST, source_file_list,
G_TYPE_FILE_LIST, target_file_list);
}
+
+
+
+static gboolean
+_thunar_io_jobs_trash (ThunarJob *job,
+ GValueArray *param_values,
+ GError **error)
+{
+ GError *err = NULL;
+ GList *file_list;
+ GList *lp;
+
+ _thunar_return_val_if_fail (THUNAR_IS_JOB (job), FALSE);
+ _thunar_return_val_if_fail (param_values != NULL, FALSE);
+ _thunar_return_val_if_fail (param_values->n_values == 1, FALSE);
+ _thunar_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+ file_list = g_value_get_boxed (g_value_array_get_nth (param_values, 0));
+
+ if (thunar_job_set_error_if_cancelled (job, error))
+ return FALSE;
+
+ for (lp = file_list; err == NULL && lp != NULL; lp = lp->next)
+ {
+ _thunar_assert (G_IS_FILE (lp->data));
+ g_file_trash (lp->data, thunar_job_get_cancellable (job), &err);
+ }
+
+ if (err != NULL)
+ {
+ g_propagate_error (error, err);
+ return FALSE;
+ }
+ else
+ {
+ return TRUE;
+ }
+}
+
+
+
+ThunarJob *
+thunar_io_jobs_trash_files (GList *file_list)
+{
+ _thunar_return_val_if_fail (file_list != NULL, NULL);
+
+ return thunar_simple_job_launch (_thunar_io_jobs_trash, 1,
+ G_TYPE_FILE_LIST, file_list);
+}
Modified: thunar/branches/migration-to-gio/thunar/thunar-io-jobs.h
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-io-jobs.h 2009-04-23 19:10:14 UTC (rev 29895)
+++ thunar/branches/migration-to-gio/thunar/thunar-io-jobs.h 2009-04-23 20:00:34 UTC (rev 29896)
@@ -34,6 +34,7 @@
GList *target_file_list) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
ThunarJob *thunar_io_jobs_link_files (GList *source_file_list,
GList *target_file_list) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
+ThunarJob *thunar_io_jobs_trash_files (GList *file_list) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
G_END_DECLS
Modified: thunar/branches/migration-to-gio/thunar/thunar-standard-view.c
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-standard-view.c 2009-04-23 19:10:14 UTC (rev 29895)
+++ thunar/branches/migration-to-gio/thunar/thunar-standard-view.c 2009-04-23 20:00:34 UTC (rev 29896)
@@ -292,7 +292,7 @@
gint custom_merge_id;
/* right-click drag/popup support */
- GList *drag_path_list;
+ GList *drag_file_list;
gint drag_scroll_timer_id;
gint drag_timer_id;
gint drag_x;
@@ -764,7 +764,7 @@
g_object_unref (G_OBJECT (standard_view->priv->provider_factory));
/* release the drag path list (just in case the drag-end wasn't fired before) */
- thunar_vfs_path_list_free (standard_view->priv->drag_path_list);
+ g_file_list_free (standard_view->priv->drag_file_list);
/* release the drop path list (just in case the drag-leave wasn't fired before) */
g_file_list_free (standard_view->priv->drop_file_list);
@@ -1878,10 +1878,12 @@
ThunarApplication *application;
const gchar *content_type;
ThunarFile *current_directory;
+ GFile *file;
GList source_path_list;
GList target_path_list;
+ gchar *name;
gchar *title;
- gchar *name;
+ gchar *uri;
_thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view));
_thunar_return_if_fail (GTK_IS_ACTION (action));
@@ -1903,9 +1905,12 @@
current_directory = thunar_navigator_get_current_directory (THUNAR_NAVIGATOR (standard_view));
if (G_LIKELY (current_directory != NULL))
{
+ uri = thunar_vfs_path_dup_uri (info->path);
+ file = g_file_new_for_uri (uri);
+ g_free (uri);
+
/* fake the source path list */
- /* TODO Use a GFile here */
- source_path_list.data = info->path;
+ source_path_list.data = file;
source_path_list.next = NULL;
source_path_list.prev = NULL;
@@ -1922,6 +1927,7 @@
/* release the target path */
g_object_unref (target_path_list.data);
+ g_object_unref (source_path_list.data);
}
/* release the file name */
@@ -2902,14 +2908,14 @@
gint size;
/* release the drag path list (just in case the drag-end wasn't fired before) */
- thunar_vfs_path_list_free (standard_view->priv->drag_path_list);
+ g_file_list_free (standard_view->priv->drag_file_list);
/* query the list of selected URIs */
- standard_view->priv->drag_path_list = thunar_file_list_to_path_list (standard_view->selected_files);
- if (G_LIKELY (standard_view->priv->drag_path_list != NULL))
+ standard_view->priv->drag_file_list = thunar_file_list_to_g_file_list (standard_view->selected_files);
+ if (G_LIKELY (standard_view->priv->drag_file_list != NULL))
{
/* determine the first selected file */
- file = thunar_file_get_for_path (standard_view->priv->drag_path_list->data, NULL);
+ file = thunar_file_get (standard_view->priv->drag_file_list->data, NULL);
if (G_LIKELY (file != NULL))
{
/* generate an icon based on that file */
@@ -2937,7 +2943,7 @@
gchar *uri_string;
/* set the URI list for the drag selection */
- uri_string = thunar_vfs_path_list_to_string (standard_view->priv->drag_path_list);
+ uri_string = g_file_list_to_string (standard_view->priv->drag_file_list);
gtk_selection_data_set (selection_data, selection_data->target, 8, (guchar *) uri_string, strlen (uri_string));
g_free (uri_string);
}
@@ -2965,8 +2971,8 @@
g_source_remove (standard_view->priv->drag_scroll_timer_id);
/* release the list of dragged URIs */
- thunar_vfs_path_list_free (standard_view->priv->drag_path_list);
- standard_view->priv->drag_path_list = NULL;
+ g_file_list_free (standard_view->priv->drag_file_list);
+ standard_view->priv->drag_file_list = NULL;
}
More information about the Xfce4-commits
mailing list