[gnome-text-editor] preferences: add preference to disable session
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-text-editor] preferences: add preference to disable session
- Date: Fri, 8 Oct 2021 00:35:52 +0000 (UTC)
commit fdc7982e86710d8ad3bcb47ac00ad79ed840ab64
Author: Christian Hergert <chergert redhat com>
Date: Thu Oct 7 17:35:45 2021 -0700
preferences: add preference to disable session
This will disable reloading of session at startup, similar to the
--ignore-session command line option.
Fixes #161
data/org.gnome.TextEditor.gschema.xml | 5 +++++
src/editor-application.c | 6 ++++--
src/editor-window.ui | 12 ++++++++++++
3 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/data/org.gnome.TextEditor.gschema.xml b/data/org.gnome.TextEditor.gschema.xml
index 7f3bc1b..2126dad 100644
--- a/data/org.gnome.TextEditor.gschema.xml
+++ b/data/org.gnome.TextEditor.gschema.xml
@@ -91,5 +91,10 @@
<summary>Automatically check spelling</summary>
<description>If enabled, then Text Editor will check spelling as you type.</description>
</key>
+ <key name="restore-session" type="b">
+ <default>true</default>
+ <summary>Restore session</summary>
+ <description>When Text Editor is run, restore the previous session.</description>
+ </key>
</schema>
</schemalist>
diff --git a/src/editor-application.c b/src/editor-application.c
index eb93afc..25ae819 100644
--- a/src/editor-application.c
+++ b/src/editor-application.c
@@ -159,8 +159,6 @@ editor_application_startup (GApplication *application)
gtk_application_set_accels_for_action (GTK_APPLICATION (self), "app.quit", quit_accels);
gtk_application_set_accels_for_action (GTK_APPLICATION (self), "app.help", help_accels);
- self->settings = g_settings_new ("org.gnome.TextEditor");
-
_editor_application_actions_init (self);
style_manager = adw_style_manager_get_default ();
@@ -264,8 +262,12 @@ static const GOptionEntry entries[] = {
static void
editor_application_init (EditorApplication *self)
{
+ self->settings = g_settings_new ("org.gnome.TextEditor");
self->session = _editor_session_new ();
+
editor_session_set_auto_save (self->session, TRUE);
+ if (!g_settings_get_boolean (self->settings, "restore-session"))
+ _editor_session_set_restore_pages (self->session, FALSE);
g_application_add_main_option_entries (G_APPLICATION (self), entries);
}
diff --git a/src/editor-window.ui b/src/editor-window.ui
index bbbc840..423053d 100644
--- a/src/editor-window.ui
+++ b/src/editor-window.ui
@@ -213,6 +213,18 @@ Or, press Ctrl+W to close the window.</property>
</child>
</object>
</child>
+ <child>
+ <object class="AdwPreferencesGroup">
+ <property name="title" translatable="yes">Behavior</property>
+ <property name="margin-top">24</property>
+ <child>
+ <object class="EditorPreferencesSwitch" id="session">
+ <property name="title" translatable="yes">Restore Session</property>
+ <property name="schema-key">restore-session</property>
+ </object>
+ </child>
+ </object>
+ </child>
<child>
<object class="AdwPreferencesGroup">
<property name="title" translatable="yes">Font</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]