[anjuta] anjuta: bgo #688609 - Saved dock positions not applied when opening a project



commit 76c71cd12a12764d23d54d31347d51356dcc031e
Author: SÃbastien Granjoux <seb sfo free fr>
Date:   Mon Jan 14 22:50:13 2013 +0100

    anjuta: bgo #688609 - Saved dock positions not applied when opening a project
    
    When using preferences, do not load last session or last files only for the
    first (user) session as written in the GUI.
    It is still possible to avoid loading a project session or only the project
    files using the command line options.

 src/anjuta-application.c |   37 ++++++++++++++++++++-----------------
 src/anjuta-window.c      |    9 ++-------
 2 files changed, 22 insertions(+), 24 deletions(-)
---
diff --git a/src/anjuta-application.c b/src/anjuta-application.c
index 41a8f0a..4e41eb4 100644
--- a/src/anjuta-application.c
+++ b/src/anjuta-application.c
@@ -36,12 +36,14 @@
 #define ANJUTA_REMEMBERED_PLUGINS "remembered-plugins"
 #define USER_SESSION_PATH_NEW (anjuta_util_get_user_cache_file_path ("session/", NULL))
 
+#define ANJUTA_SESSION_SKIP_LAST "session-skip-last"
+#define ANJUTA_SESSION_SKIP_LAST_FILES "session-skip-last-files"
+
 #define DEFAULT_PROFILE "file://"PACKAGE_DATA_DIR"/profiles/default.profile"
 #define USER_PROFILE_NAME "user"
 
 #define ANJUTA_PIXMAP_SPLASH_SCREEN       "anjuta_splash.png"
 
-
 #define ANJUTA_GEOMETRY_HINT "-g="
 #define ANJUTA_NO_SPLASH_HINT "-s"
 #define ANJUTA_NO_SESSION_HINT "-n"
@@ -49,8 +51,6 @@
 
 G_DEFINE_TYPE (AnjutaApplication, anjuta_application, GTK_TYPE_APPLICATION)
 
-static gchar *system_restore_session = NULL;
-
 struct _AnjutaApplicationPrivate {
 	gboolean no_splash;
 	gboolean proper_shutdown;
@@ -140,6 +140,7 @@ on_profile_scoped (AnjutaProfileManager *profile_manager,
 {
 	gchar *session_dir;
 	static gboolean first_time = TRUE;
+	AnjutaSession *session;
 
 	DEBUG_PRINT ("Profile scoped: %s", anjuta_profile_get_name (profile));
 	if (strcmp (anjuta_profile_get_name (profile), USER_PROFILE_NAME) != 0)
@@ -148,30 +149,32 @@ on_profile_scoped (AnjutaProfileManager *profile_manager,
 	DEBUG_PRINT ("%s", "User profile loaded; Restoring user session");
 
 	/* If profile scoped to "user", restore user session */
-	if (system_restore_session)
-	{
-		session_dir = system_restore_session;
-		system_restore_session = NULL;
-	}
-	else
-	{
-		session_dir = USER_SESSION_PATH_NEW;
-	}
+	session_dir = USER_SESSION_PATH_NEW;
 
+	session = anjuta_session_new (session_dir);
 	if (first_time)
 	{
+		if (g_settings_get_boolean (win->settings, ANJUTA_SESSION_SKIP_LAST))
+		{
+			/* Clear session */
+			anjuta_session_clear (session);
+		}
+		else if (g_settings_get_boolean (win->settings, ANJUTA_SESSION_SKIP_LAST_FILES))
+		{
+			/* Clear files from session */
+			anjuta_session_set_string_list (session, "File Loader",
+			                                "Files", NULL);
+		}
 		first_time = FALSE;
 	}
 	else
 	{
 		/* Clear the files list since we don't want to load them later */
-		AnjutaSession *session;
-		session = anjuta_session_new (session_dir);
 		anjuta_session_set_string_list (session, "File Loader",
-										"Files", NULL);
-		anjuta_session_sync (session);
-		g_object_unref (session);
+		                                "Files", NULL);
 	}
+	anjuta_session_sync (session);
+	g_object_unref (session);
 
 	/* Restore session */
 	anjuta_shell_session_load (ANJUTA_SHELL (win), session_dir, NULL);
diff --git a/src/anjuta-window.c b/src/anjuta-window.c
index e15d16d..b559bf2 100644
--- a/src/anjuta-window.c
+++ b/src/anjuta-window.c
@@ -55,9 +55,6 @@
 #define TOOLBAR_VISIBLE "toolbar-visible"
 #define TOOLBAR_STYLE "toolbar-style"
 
-#define ANJUTA_SESSION_SKIP_LAST "session-skip-last"
-#define ANJUTA_SESSION_SKIP_LAST_FILES "session-skip-last-files"
-
 static void anjuta_window_layout_load (AnjutaWindow *win,
 									const gchar *layout_filename,
 									const gchar *name);
@@ -446,14 +443,12 @@ on_session_load (AnjutaShell *shell, AnjutaSessionPhase phase,
 		app = ANJUTA_APPLICATION (gtk_window_get_application (GTK_WINDOW (win)));
 		if (app != NULL)
 		{
-			if (anjuta_application_get_no_session (app) ||
-			    g_settings_get_boolean (win->settings, ANJUTA_SESSION_SKIP_LAST))
+			if (anjuta_application_get_no_session (app))
 			{
 				/* Clear session */
 				anjuta_session_clear (session);
 			}
-			else if (anjuta_application_get_no_files (app)  ||
-			    g_settings_get_boolean (win->settings, ANJUTA_SESSION_SKIP_LAST_FILES))
+			else if (anjuta_application_get_no_files (app))
 			{
 				/* Clear files from session */
 				anjuta_session_set_string_list (session, "File Loader",



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]