files are saved in ~/.config/metacity/sessions and checked for there and

2008-03-27  Thomas Thurman  <tthurman@gnome.org>

        * src/core/session.c (regenerate_save_file, save_state, load_state):
        files are saved in ~/.config/metacity/sessions and checked for there
        and in ~/.metacity/sessions.  Fixes #518596.


svn path=/trunk/; revision=3666
This commit is contained in:
Thomas Thurman 2008-03-27 13:12:28 +00:00 committed by Thomas James Alexander Thurman
parent f3e64f181d
commit 9730f15411
2 changed files with 50 additions and 11 deletions

View File

@ -1,3 +1,9 @@
2008-03-27 Thomas Thurman <tthurman@gnome.org>
* src/core/session.c (regenerate_save_file, save_state, load_state):
files are saved in ~/.config/metacity/sessions and checked for there
and in ~/.metacity/sessions. Fixes #518596.
2008-03-27 Thomas Thurman <tthurman@gnome.org> 2008-03-27 Thomas Thurman <tthurman@gnome.org>
* src/core/display.c (meta_display_close): fix regression * src/core/display.c (meta_display_close): fix regression

View File

@ -812,10 +812,20 @@ save_state (void)
outfile = NULL; outfile = NULL;
metacity_dir = g_strconcat (g_get_home_dir (), "/.metacity", /*
* g_get_user_config_dir() is guaranteed to return an existing directory.
* Eventually, if SM stays with the WM, I'd like to make this
* something like <config>/window_placement in a standard format.
* Future optimisers should note also that by the time we get here
* we probably already have full_save_path figured out and therefore
* can just use the directory name from that.
*/
metacity_dir = g_strconcat (g_get_user_config_dir (),
G_DIR_SEPARATOR_S "metacity",
NULL); NULL);
session_dir = g_strconcat (metacity_dir, "/sessions", session_dir = g_strconcat (metacity_dir,
G_DIR_SEPARATOR_S "sessions",
NULL); NULL);
if (mkdir (metacity_dir, 0700) < 0 && if (mkdir (metacity_dir, 0700) < 0 &&
@ -1049,8 +1059,9 @@ load_state (const char *previous_save_file)
gsize length; gsize length;
char *session_file; char *session_file;
session_file = g_strconcat (g_get_home_dir (), session_file = g_strconcat (g_get_user_config_dir (),
"/.metacity/sessions/", G_DIR_SEPARATOR_S "metacity"
G_DIR_SEPARATOR_S "sessions" G_DIR_SEPARATOR_S,
previous_save_file, previous_save_file,
NULL); NULL);
@ -1060,13 +1071,34 @@ load_state (const char *previous_save_file)
&length, &length,
&error)) &error))
{ {
char *canonical_session_file = session_file;
/* Maybe they were doing it the old way, with ~/.metacity */
session_file = g_strconcat (g_get_home_dir (),
G_DIR_SEPARATOR_S ".metacity"
G_DIR_SEPARATOR_S "sessions"
G_DIR_SEPARATOR_S,
previous_save_file,
NULL);
if (!g_file_get_contents (session_file,
&text,
&length,
NULL))
{
/* oh, just give up */
meta_warning (_("Failed to read saved session file %s: %s\n"), meta_warning (_("Failed to read saved session file %s: %s\n"),
session_file, error->message); canonical_session_file, error->message);
g_error_free (error); g_error_free (error);
g_free (session_file); g_free (session_file);
g_free (canonical_session_file);
return NULL; return NULL;
} }
g_free (canonical_session_file);
}
meta_topic (META_DEBUG_SM, "Parsing saved session file %s\n", session_file); meta_topic (META_DEBUG_SM, "Parsing saved session file %s\n", session_file);
g_free (session_file); g_free (session_file);
session_file = NULL; session_file = NULL;
@ -1666,8 +1698,9 @@ regenerate_save_file (void)
g_free (full_save_path); g_free (full_save_path);
if (client_id) if (client_id)
full_save_path = g_strconcat (g_get_home_dir (), full_save_path = g_strconcat (g_get_user_config_dir (),
"/.metacity/sessions/", G_DIR_SEPARATOR_S "metacity"
G_DIR_SEPARATOR_S "sessions" G_DIR_SEPARATOR_S,
client_id, client_id,
".ms", ".ms",
NULL); NULL);