[Xfce4-commits] <thunar:master> Check trash longer with session startup (bug #9513).

Nick Schermer noreply at xfce.org
Thu Dec 27 13:22:03 CET 2012


Updating branch refs/heads/master
         to 689a52e5e93437bda2cbcb69c9a4ecd1fc0dbba9 (commit)
       from a8a2ce8c41578ece8fdcd79c9ab82eed6e0073d5 (commit)

commit 689a52e5e93437bda2cbcb69c9a4ecd1fc0dbba9
Author: Nick Schermer <nick at xfce.org>
Date:   Thu Dec 27 13:19:36 2012 +0100

    Check trash longer with session startup (bug #9513).
    
    Check for 15 seconds with 3 second intervals or trash items
    were found.

 thunar/thunar-session-client.c |   31 ++++++++++++++++++++++++++-----
 1 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/thunar/thunar-session-client.c b/thunar/thunar-session-client.c
index 1c529f4..3465709 100644
--- a/thunar/thunar-session-client.c
+++ b/thunar/thunar-session-client.c
@@ -75,10 +75,12 @@ struct _ThunarSessionClientClass
 struct _ThunarSessionClient
 {
   GObject __parent__;
+
   gchar  *path;
   gchar  *id;
 
   guint   trash_load_idle;
+  guint   trash_checks;
 
 #ifdef HAVE_LIBSM
   SmcConn connection;
@@ -279,8 +281,7 @@ thunar_session_client_restore_trash (gpointer data)
   ThunarSessionClient *session_client = THUNAR_SESSION_CLIENT (data);
   GFile               *trash;
   ThunarFile          *directory;
-
-  session_client->trash_load_idle = 0;
+  guint32              item_count = 0;
 
   /* make sure the trash is loaded */
   trash = thunar_g_file_new_for_trash ();
@@ -288,9 +289,24 @@ thunar_session_client_restore_trash (gpointer data)
   g_object_unref (trash);
 
   if (G_LIKELY (directory != NULL))
-    thunar_file_reload (directory);
+    {
+      thunar_file_reload (directory);
+      item_count = thunar_file_get_item_count (directory);
+    }
+
+  /* continue checking for 15 seconds or files are found */
+  return (session_client->trash_checks++ < 5 && item_count == 0);
+}
+
 
-  return FALSE;
+
+static void
+thunar_session_client_restore_finised (gpointer data)
+{
+  ThunarSessionClient *session_client = THUNAR_SESSION_CLIENT (data);
+
+  session_client->trash_load_idle = 0;
+  session_client->trash_checks = 0;
 }
 
 
@@ -342,7 +358,12 @@ thunar_session_client_restore (ThunarSessionClient *session_client)
       if (thunar_window_set_directories (THUNAR_WINDOW (window), uris, active_tab))
         {
           /* add idle to make sure the trash status is up2date (bug #9513) */
-          session_client->trash_load_idle = g_timeout_add_seconds (2, thunar_session_client_restore_trash, session_client);
+          if (session_client->trash_load_idle == 0)
+            {
+              session_client->trash_load_idle =
+                  g_timeout_add_seconds_full (G_PRIORITY_DEFAULT_IDLE, 3, thunar_session_client_restore_trash,
+                                              session_client, thunar_session_client_restore_finised);
+            }
         }
       else
         {


More information about the Xfce4-commits mailing list