[gnome-builder/gnome-builder-43] libide/gui: dont restore session if disabled in gsettings
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/gnome-builder-43] libide/gui: dont restore session if disabled in gsettings
- Date: Mon, 26 Sep 2022 21:11:10 +0000 (UTC)
commit a80911981ef5ce9eea9346871874dbe2dfd8ec49
Author: Christian Hergert <chergert redhat com>
Date: Mon Sep 26 14:08:01 2022 -0700
libide/gui: dont restore session if disabled in gsettings
Fixes #1812
data/gsettings/org.gnome.builder.gschema.xml | 4 ++--
src/libide/gui/ide-workbench.c | 21 +++++++++++++++++++--
2 files changed, 21 insertions(+), 4 deletions(-)
---
diff --git a/data/gsettings/org.gnome.builder.gschema.xml b/data/gsettings/org.gnome.builder.gschema.xml
index 07b8b1898..a1418fadb 100644
--- a/data/gsettings/org.gnome.builder.gschema.xml
+++ b/data/gsettings/org.gnome.builder.gschema.xml
@@ -30,8 +30,8 @@
</key>
<key name="restore-previous-files" type="b">
<default>true</default>
- <summary>Restore Previous Files</summary>
- <description>Restore previously opened files when loading a project.</description>
+ <summary>Restore Session</summary>
+ <description>Restores the projects previous session when loading.</description>
</key>
<key name="clear-cache-at-startup" type="b">
<default>true</default>
diff --git a/src/libide/gui/ide-workbench.c b/src/libide/gui/ide-workbench.c
index 8046cc4b6..33ac1386f 100644
--- a/src/libide/gui/ide-workbench.c
+++ b/src/libide/gui/ide-workbench.c
@@ -38,6 +38,7 @@
#include "ide-transfer-manager-private.h"
#include "ide-application.h"
+#include "ide-application-private.h"
#include "ide-application-tweaks.h"
#include "ide-gui-global.h"
#include "ide-primary-workspace.h"
@@ -971,6 +972,22 @@ ide_workbench_restore_workspace_session_cb (IdeWorkspace *workspace,
_ide_workspace_restore_session (workspace, session);
}
+static gboolean
+ide_workbench_can_restore_session (IdeWorkbench *self)
+{
+ IdeApplication *app = IDE_APPLICATION_DEFAULT;
+
+ g_assert (IDE_IS_MAIN_THREAD ());
+ g_assert (IDE_IS_APPLICATION (app));
+ g_assert (IDE_IS_WORKBENCH (self));
+
+ if (self->session == NULL)
+ return FALSE;
+
+ /* Wish we could rename this setting, maybe in 44 */
+ return g_settings_get_boolean (app->settings, "restore-previous-files");
+}
+
static void
ide_workbench_load_project_completed (IdeWorkbench *self,
IdeTask *task)
@@ -1006,7 +1023,7 @@ ide_workbench_load_project_completed (IdeWorkbench *self,
/* Allow addins to restore session, which might bypass the need to create
* a workspace manually below.
*/
- if (self->session != NULL)
+ if (ide_workbench_can_restore_session (self))
{
/* Restore workspaces, and cancel our request to create a new one
* if the workspace was likely created already.
@@ -1047,7 +1064,7 @@ ide_workbench_load_project_completed (IdeWorkbench *self,
ide_action_mixin_set_enabled (self, "configure-page", TRUE);
/* Now restore the workspace sessions */
- if (self->session)
+ if (ide_workbench_can_restore_session (self))
{
ide_workbench_foreach_workspace (self,
ide_workbench_restore_workspace_session_cb,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]