Commit 60e9680e authored by Nick Schermer's avatar Nick Schermer

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.
parent f4131805
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment