[gnome-text-editor] prefs: only show clear history when restore-session is active



commit 68db02c0ae492090e9a5a46f2e2615c1e0757d32
Author: Christian Hergert <chergert redhat com>
Date:   Fri Jan 28 12:50:18 2022 -0800

    prefs: only show clear history when restore-session is active
    
    This is directly related to there being session state to remove.

 src/editor-preferences-dialog.c  |  5 +++++
 src/editor-preferences-dialog.ui | 42 ++++++++++++++++++++++++++--------------
 2 files changed, 32 insertions(+), 15 deletions(-)
---
diff --git a/src/editor-preferences-dialog.c b/src/editor-preferences-dialog.c
index 3457a65..77e237a 100644
--- a/src/editor-preferences-dialog.c
+++ b/src/editor-preferences-dialog.c
@@ -42,6 +42,7 @@ struct _EditorPreferencesDialog
   GtkCssProvider       *css_provider;
 
   GtkSwitch            *use_custom_font;
+  GtkSwitch            *restore_session;
   GtkFlowBox           *scheme_group;
   GtkSourceBuffer      *buffer;
   GtkSourceView        *source_view;
@@ -413,6 +414,7 @@ editor_preferences_dialog_class_init (EditorPreferencesDialogClass *klass)
   gtk_widget_class_bind_template_child (widget_class, EditorPreferencesDialog, scheme_group);
   gtk_widget_class_bind_template_child (widget_class, EditorPreferencesDialog, source_view);
   gtk_widget_class_bind_template_child (widget_class, EditorPreferencesDialog, use_custom_font);
+  gtk_widget_class_bind_template_child (widget_class, EditorPreferencesDialog, restore_session);
   gtk_widget_class_bind_template_callback (widget_class, style_scheme_activated_cb);
 
   g_type_ensure (EDITOR_TYPE_PREFERENCES_FONT);
@@ -459,6 +461,9 @@ editor_preferences_dialog_init (EditorPreferencesDialog *self)
                                 self->source_view, "background-pattern",
                                 G_SETTINGS_BIND_GET,
                                 bind_background_pattern, NULL, NULL, NULL);
+  g_settings_bind (self->settings, "restore-session",
+                   self->restore_session, "active",
+                   G_SETTINGS_BIND_DEFAULT);
   g_signal_connect_object (self->settings,
                            "changed::custom-font",
                            G_CALLBACK (update_custom_font_cb),
diff --git a/src/editor-preferences-dialog.ui b/src/editor-preferences-dialog.ui
index 858364c..d98fde1 100644
--- a/src/editor-preferences-dialog.ui
+++ b/src/editor-preferences-dialog.ui
@@ -119,23 +119,35 @@
               </object>
             </child>
             <child>
-              <object class="EditorPreferencesSwitch" id="session">
+              <object class="AdwExpanderRow">
                 <property name="title" translatable="yes">Restore Session</property>
                 <property name="subtitle" translatable="yes">Return to your previous session when Text 
Editor is started</property>
-                <property name="schema-key">restore-session</property>
-              </object>
-            </child>
-            <child>
-              <object class="GtkButton">
-                <property name="action-name">app.clear-history</property>
-                <property name="focus-on-click">false</property>
-                <property name="halign">end</property>
-                <property name="label" translatable="yes">_Clear History</property>
-                <property name="margin-top">24</property>
-                <property name="use-underline">true</property>
-                <style>
-                  <class name="destructive-action"/>
-                </style>
+                <property name="expanded" bind-source="restore_session" bind-property="active" 
bind-flags="sync-create|bidirectional"/>
+                <child type="action">
+                  <object class="GtkSwitch" id="restore_session">
+                    <property name="halign">end</property>
+                    <property name="valign">center</property>
+                  </object>
+                </child>
+                <child>
+                  <object class="AdwPreferencesRow" id="clear_history_row">
+                    <child type="suffix">
+                      <object class="GtkButton">
+                        <property name="action-name">app.clear-history</property>
+                        <property name="focus-on-click">false</property>
+                        <property name="halign">end</property>
+                        <property name="label" translatable="yes">_Clear History</property>
+                        <property name="margin-top">6</property>
+                        <property name="margin-end">6</property>
+                        <property name="margin-bottom">6</property>
+                        <property name="use-underline">true</property>
+                        <style>
+                          <class name="destructive-action"/>
+                        </style>
+                      </object>
+                    </child>
+                  </object>
+                </child>
               </object>
             </child>
           </object>


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