[Xfce4-commits] <thunar:master> Reload ThunarView if job finishes.
Nick Schermer
noreply at xfce.org
Mon Apr 2 20:48:01 CEST 2012
Updating branch refs/heads/master
to a70c7477ac34e547ab5738a9804f5cfd1adf988e (commit)
from 3c465449d9d94813420658ab7d9dde1038eb72a9 (commit)
commit a70c7477ac34e547ab5738a9804f5cfd1adf988e
Author: Nick Schermer <nick at xfce.org>
Date: Mon Apr 2 20:44:34 2012 +0200
Reload ThunarView if job finishes.
This makes more or less all thunar file actions instant
in the interface (well the actions that complete before
the file monitor picks it up).
Remove the old hook for new files from commit e5e26b9
since that will trigger the reload twice.
thunar/thunar-application.c | 55 ++++++++++++++++++++++++++++++++++++++++-
thunar/thunar-standard-view.c | 3 --
2 files changed, 54 insertions(+), 4 deletions(-)
diff --git a/thunar/thunar-application.c b/thunar/thunar-application.c
index 8a5744a..31ad89e 100644
--- a/thunar/thunar-application.c
+++ b/thunar/thunar-application.c
@@ -56,6 +56,7 @@
#include <thunar/thunar-renamer-dialog.h>
#include <thunar/thunar-thumbnail-cache.h>
#include <thunar/thunar-util.h>
+#include <thunar/thunar-view.h>
@@ -91,6 +92,8 @@ static void thunar_application_collect_and_launch (ThunarApplicati
GList *source_file_list,
GFile *target_file,
GClosure *new_files_closure);
+static void thunar_application_launch_finished (ThunarJob *job,
+ ThunarView *view);
static void thunar_application_launch (ThunarApplication *application,
gpointer parent,
const gchar *icon_name,
@@ -403,6 +406,42 @@ thunar_application_collect_and_launch (ThunarApplication *application,
static void
+thunar_application_launch_finished_too_late (gpointer user_data,
+ GObject *where_the_object_was)
+{
+ ThunarJob *job = THUNAR_JOB (user_data);
+
+ _thunar_return_if_fail (THUNAR_IS_JOB (job));
+ _thunar_return_if_fail (THUNAR_IS_VIEW (where_the_object_was));
+
+ /* remove the finished signal */
+ g_signal_handlers_disconnect_by_func (G_OBJECT (job),
+ G_CALLBACK (thunar_application_launch_finished),
+ where_the_object_was);
+}
+
+
+
+static void
+thunar_application_launch_finished (ThunarJob *job,
+ ThunarView *view)
+{
+ _thunar_return_if_fail (THUNAR_IS_JOB (job));
+ _thunar_return_if_fail (THUNAR_IS_VIEW (view));
+
+ /* remove the view weak ref */
+ g_object_weak_unref (G_OBJECT (view),
+ thunar_application_launch_finished_too_late,
+ job);
+
+ /* the job completed, refresh the interface
+ * directly to make it feel snappy */
+ thunar_view_reload (view);
+}
+
+
+
+static void
thunar_application_launch (ThunarApplication *application,
gpointer parent,
const gchar *icon_name,
@@ -423,7 +462,21 @@ thunar_application_launch (ThunarApplication *application,
/* try to allocate a new job for the operation */
job = (*launcher) (source_file_list, target_file_list);
-
+
+ if (THUNAR_IS_VIEW (parent))
+ {
+ /* connect a callback to instantly refresh the thunar view */
+ g_signal_connect (G_OBJECT (job), "finished",
+ G_CALLBACK (thunar_application_launch_finished),
+ parent);
+
+ /* watch destruction of the parent, so we disconnect before the
+ * job is finished */
+ g_object_weak_ref (G_OBJECT (parent),
+ thunar_application_launch_finished_too_late,
+ job);
+ }
+
/* connect the "new-files" closure (if any) */
if (G_LIKELY (new_files_closure != NULL))
g_signal_connect_closure (job, "new-files", new_files_closure, FALSE);
diff --git a/thunar/thunar-standard-view.c b/thunar/thunar-standard-view.c
index 356488d..9ea8265 100644
--- a/thunar/thunar-standard-view.c
+++ b/thunar/thunar-standard-view.c
@@ -2420,9 +2420,6 @@ thunar_standard_view_new_files (ThunarStandardView *standard_view,
/* grab the focus to the view widget */
gtk_widget_grab_focus (GTK_BIN (standard_view)->child);
}
-
- /* manually reload the folder to avoid a delay */
- thunar_standard_view_reload (THUNAR_VIEW (standard_view));
}
}
More information about the Xfce4-commits
mailing list