[Xfce4-commits] <thunar:master> Make sure trash is loaded during session restore (bug #9513).

Nick Schermer noreply at xfce.org
Sun Dec 2 21:34:03 CET 2012


Updating branch refs/heads/master
         to 60e9680e0ed5a3b43e0b396bb11921dcc617a736 (commit)
       from f41318058de59d5645db0a524ec3d7740782e2dd (commit)

commit 60e9680e0ed5a3b43e0b396bb11921dcc617a736
Author: Nick Schermer <nick at xfce.org>
Date:   Sun Dec 2 21:31:45 2012 +0100

    Make sure trash is loaded during session restore (bug #9513).
    
    For some reason the trash count is not up2date when requesting
    this quickly after login (session restore). So idle a reload.

 thunar/thunar-session-client.c |   40 ++++++++++++++++++++++++++++++++++++++--
 1 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/thunar/thunar-session-client.c b/thunar/thunar-session-client.c
index 5bbc8d3..30e5864 100644
--- a/thunar/thunar-session-client.c
+++ b/thunar/thunar-session-client.c
@@ -42,6 +42,7 @@
 #include <thunar/thunar-ice.h>
 #include <thunar/thunar-private.h>
 #include <thunar/thunar-session-client.h>
+#include <thunar/thunar-file.h>
 
 
 
@@ -77,6 +78,8 @@ struct _ThunarSessionClient
   gchar  *path;
   gchar  *id;
 
+  guint   trash_load_idle;
+
 #ifdef HAVE_LIBSM
   SmcConn connection;
 #endif
@@ -113,6 +116,9 @@ thunar_session_client_finalize (GObject *object)
 {
   ThunarSessionClient *session_client = THUNAR_SESSION_CLIENT (object);
 
+  if (session_client->trash_load_idle != 0)
+    g_source_remove (session_client->trash_load_idle);
+
 #ifdef HAVE_LIBSM
   /* disconnect from the session manager */
   if (G_LIKELY (session_client->connection != NULL))
@@ -267,6 +273,28 @@ thunar_session_client_connect (ThunarSessionClient *session_client,
 
 
 
+static gboolean
+thunar_session_client_restore_trash (gpointer data)
+{
+  ThunarSessionClient *session_client = THUNAR_SESSION_CLIENT (data);
+  GFile               *trash;
+  ThunarFile          *directory;
+
+  session_client->trash_load_idle = 0;
+
+  /* make sure the trash is loaded */
+  trash = thunar_g_file_new_for_trash ();
+  directory = thunar_file_cache_lookup (trash);
+  g_object_unref (trash);
+
+  if (G_LIKELY (directory != NULL))
+    thunar_file_reload (directory);
+
+  return FALSE;
+}
+
+
+
 static void
 thunar_session_client_restore (ThunarSessionClient *session_client)
 {
@@ -311,8 +339,16 @@ thunar_session_client_restore (ThunarSessionClient *session_client)
       gtk_widget_show (window);
 
       /* open tabs */
-      if (!thunar_window_set_directories (THUNAR_WINDOW (window), uris, active_tab))
-        gtk_widget_destroy (window);
+      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_idle_add (thunar_session_client_restore_trash, session_client);
+        }
+      else
+        {
+          /* no tabs were opened */
+          gtk_widget_destroy (window);
+        }
 
       /* cleanup */
       g_strfreev (uris);


More information about the Xfce4-commits mailing list