Updating branch refs/heads/master
         to 15a30ca67a6f95b47231616ee19ed9f0350877ab (commit)
       from aa48d43a2d4263e8084f84389aa6a64d995cc166 (commit)

commit 15a30ca67a6f95b47231616ee19ed9f0350877ab
Author: Nick Schermer <n...@xfce.org>
Date:   Sun Jan 22 13:07:00 2012 +0100

    Don't update more then fourth per second in deep count job.
    
    This restores the old behaviour of the job.

 thunar/thunar-deep-count-job.c |   15 ++++++++++++---
 thunar/thunar-util.c           |   14 ++++++++++++++
 thunar/thunar-util.h           |    6 ++++++
 3 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/thunar/thunar-deep-count-job.c b/thunar/thunar-deep-count-job.c
index 93688c8..d2c9dfb 100644
--- a/thunar/thunar-deep-count-job.c
+++ b/thunar/thunar-deep-count-job.c
@@ -29,6 +29,7 @@
 #include <thunar/thunar-deep-count-job.h>
 #include <thunar/thunar-job.h>
 #include <thunar/thunar-marshal.h>
+#include <thunar/thunar-util.h>
 #include <thunar/thunar-private.h>
 
 
@@ -68,7 +69,7 @@ struct _ThunarDeepCountJob
   GFileQueryInfoFlags query_flags;
 
   /* the time of the last "status-update" emission */
-  GTimeVal            last_time;
+  gint64              last_time;
 
   /* status information */
   guint64             total_size;
@@ -135,6 +136,7 @@ thunar_deep_count_job_init (ThunarDeepCountJob *job)
   job->file_count = 0;
   job->directory_count = 0;
   job->unreadable_directory_count = 0;
+  job->last_time = 0;
 }
 
 
@@ -179,6 +181,7 @@ thunar_deep_count_job_process (ExoJob  *job,
   GFileInfo          *info;
   gboolean            success = TRUE;
   GFile              *child;
+  gint64              real_time;
 
   _thunar_return_val_if_fail (THUNAR_IS_JOB (job), FALSE);
   _thunar_return_val_if_fail (G_IS_FILE (file), FALSE);
@@ -267,8 +270,14 @@ thunar_deep_count_job_process (ExoJob  *job,
             }
         }
 
-      /* emit status update whenever we've finished a directory */
-      thunar_deep_count_job_status_update (count_job);
+      /* emit status update whenever we've finished a directory,
+       * but not more than fourth per second */
+      real_time = thunar_util_get_real_time ();
+      if (real_time >= count_job->last_time)
+        {
+          thunar_deep_count_job_status_update (count_job);
+          count_job->last_time = real_time + (G_USEC_PER_SEC / 4);
+        }
     }
   else
     {
diff --git a/thunar/thunar-util.c b/thunar/thunar-util.c
index 577bc27..7b97414 100644
--- a/thunar/thunar-util.c
+++ b/thunar/thunar-util.c
@@ -419,3 +419,17 @@ thunar_util_change_working_directory (const gchar 
*new_directory)
 
   return old_directory;
 }
+
+
+
+#if !GLIB_CHECK_VERSION (2, 28, 0)
+gint64
+thunar_util_get_real_time (void)
+{
+  GTimeVal tv;
+
+  g_get_current_time (&tv);
+
+  return (((gint64) tv.tv_sec) * G_USEC_PER_SEC) + tv.tv_usec;
+}
+#endif
diff --git a/thunar/thunar-util.h b/thunar/thunar-util.h
index 779f936..53a0bcc 100644
--- a/thunar/thunar-util.h
+++ b/thunar/thunar-util.h
@@ -42,6 +42,12 @@ time_t     thunar_util_time_from_rfc3339        (const gchar 
   *date_string) G_
 
 gchar     *thunar_util_change_working_directory (const gchar    
*new_directory) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
 
+#if GLIB_CHECK_VERSION (2, 28, 0)
+#define    thunar_util_get_real_time            g_get_real_time
+#else
+gint64     thunar_util_get_real_time            (void);
+#endif
+
 G_END_DECLS;
 
 #endif /* !__THUNAR_UTIL_H__ */
_______________________________________________
Xfce4-commits mailing list
Xfce4-commits@xfce.org
https://mail.xfce.org/mailman/listinfo/xfce4-commits

Reply via email to