From feb37e4a4b72e312669a7b4c1d67d75a52bf62b8 Mon Sep 17 00:00:00 2001 From: Benedikt Meurer Date: Mon, 17 May 2004 22:31:54 +0000 Subject: Run DiscardCommand if it changes during a SAVE YOURSELF to cleanup unneeded session files. Remember ActiveWorkspace for all Screens and restore it after the session is restored. (Old svn revision: 4553) --- xfce4-session/xfsm-client.c | 74 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) (limited to 'xfce4-session/xfsm-client.c') diff --git a/xfce4-session/xfsm-client.c b/xfce4-session/xfsm-client.c index ee094840..bb20aeeb 100644 --- a/xfce4-session/xfsm-client.c +++ b/xfce4-session/xfsm-client.c @@ -1,5 +1,28 @@ /* $Id$ */ /*- + * Copyright (c) 2003-2004 Benedikt Meurer + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H @@ -7,6 +30,8 @@ #endif #include +#include +#include XfsmClient* @@ -30,6 +55,8 @@ xfsm_client_free (XfsmClient *client) xfsm_properties_free (client->properties); if (client->save_timeout_id > 0) g_source_remove (client->save_timeout_id); + if (client->old_discard_command != NULL) + g_strfreev (client->old_discard_command); g_free (client); } @@ -47,3 +74,50 @@ xfsm_client_set_initial_properties (XfsmClient *client, client->id = properties->client_id; } + +void +xfsm_client_remember_discard_command (XfsmClient *client) +{ + XfsmProperties *properties = client->properties; + + if (client->old_discard_command != NULL) + { + g_strfreev (client->old_discard_command); + client->old_discard_command = NULL; + } + + if (properties != NULL && properties->discard_command != NULL) + { + client->old_discard_command = xfsm_strv_copy(properties->discard_command); + } +} + + +void +xfsm_client_maybe_run_old_discard_command (XfsmClient *client) +{ + gchar **old_discard_command = client->old_discard_command; + XfsmProperties *properties = client->properties; + + if (old_discard_command != NULL) + { + if (!xfsm_strv_equal (old_discard_command, properties->discard_command)) + { + xfsm_verbose ("Client Id = %s, running old discard command.\n\n", + client->id); + + g_spawn_sync (properties->current_directory, + old_discard_command, + NULL, + G_SPAWN_SEARCH_PATH, + NULL, NULL, + NULL, NULL, + NULL, NULL); + } + + g_strfreev (client->old_discard_command); + client->old_discard_command = NULL; + } +} + + -- cgit v1.2.1