[gnome-text-editor] preferences: use AdwFlap



commit bbae663b95e56d565dea44601beb51f0b07457d2
Author: Christian Hergert <chergert redhat com>
Date:   Thu Oct 7 15:32:08 2021 -0700

    preferences: use AdwFlap
    
    Currently this moves the preferences to the left, which isn't what our
    design had in mind, but perhaps that can be changed later.
    
    Fixes #174

 src/TextEditor.css          |   4 +
 src/editor-window-actions.c |   4 +-
 src/editor-window-private.h |   2 +-
 src/editor-window.c         |   2 +-
 src/editor-window.ui        | 204 +++++++++++++++++++++-----------------------
 5 files changed, 107 insertions(+), 109 deletions(-)
---
diff --git a/src/TextEditor.css b/src/TextEditor.css
index 64bfb76..b02d62f 100644
--- a/src/TextEditor.css
+++ b/src/TextEditor.css
@@ -109,3 +109,7 @@ textview.source-map:dir(ltr) {
 textview.source-map:dir(rtl) {
   border-right: 1px solid @borders;
 }
+
+flap > scrolledwindow.preferences > viewport {
+  background: @theme_bg_color;
+}
diff --git a/src/editor-window-actions.c b/src/editor-window-actions.c
index adf33d1..6b357a6 100644
--- a/src/editor-window-actions.c
+++ b/src/editor-window-actions.c
@@ -523,7 +523,7 @@ editor_window_actions_show_preferences_cb (GtkWidget  *widget,
 
   g_assert (EDITOR_IS_WINDOW (self));
 
-  gtk_revealer_set_reveal_child (self->preferences_revealer, TRUE);
+  adw_flap_set_reveal_flap (self->flap, TRUE);
 }
 
 static void
@@ -535,7 +535,7 @@ editor_window_actions_hide_preferences_cb (GtkWidget  *widget,
 
   g_assert (EDITOR_IS_WINDOW (self));
 
-  gtk_revealer_set_reveal_child (self->preferences_revealer, FALSE);
+  adw_flap_set_reveal_flap (self->flap, FALSE);
 }
 
 void
diff --git a/src/editor-window-private.h b/src/editor-window-private.h
index 5235196..143b6bc 100644
--- a/src/editor-window-private.h
+++ b/src/editor-window-private.h
@@ -51,8 +51,8 @@ struct _EditorWindow
   GtkMenuButton        *primary_menu;
   GtkMenuButton        *options_menu;
   GtkMenuButton        *export_menu;
-  GtkRevealer          *preferences_revealer;
   AdwPreferencesGroup  *scheme_group;
+  AdwFlap              *flap;
 
   /* Borrowed References */
   EditorPage           *visible_page;
diff --git a/src/editor-window.c b/src/editor-window.c
index 288e446..d1c7f25 100644
--- a/src/editor-window.c
+++ b/src/editor-window.c
@@ -532,6 +532,7 @@ editor_window_class_init (EditorWindowClass *klass)
   gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/TextEditor/ui/editor-window.ui");
 
   gtk_widget_class_bind_template_child (widget_class, EditorWindow, empty);
+  gtk_widget_class_bind_template_child (widget_class, EditorWindow, flap);
   gtk_widget_class_bind_template_child (widget_class, EditorWindow, is_modified);
   gtk_widget_class_bind_template_child (widget_class, EditorWindow, open_menu_button);
   gtk_widget_class_bind_template_child (widget_class, EditorWindow, open_menu_popover);
@@ -539,7 +540,6 @@ editor_window_class_init (EditorWindowClass *klass)
   gtk_widget_class_bind_template_child (widget_class, EditorWindow, pages);
   gtk_widget_class_bind_template_child (widget_class, EditorWindow, position_box);
   gtk_widget_class_bind_template_child (widget_class, EditorWindow, position_label);
-  gtk_widget_class_bind_template_child (widget_class, EditorWindow, preferences_revealer);
   gtk_widget_class_bind_template_child (widget_class, EditorWindow, primary_menu);
   gtk_widget_class_bind_template_child (widget_class, EditorWindow, scheme_group);
   gtk_widget_class_bind_template_child (widget_class, EditorWindow, stack);
diff --git a/src/editor-window.ui b/src/editor-window.ui
index 50cc3a4..68686cd 100644
--- a/src/editor-window.ui
+++ b/src/editor-window.ui
@@ -120,9 +120,15 @@
           </object>
         </child>
         <child>
-          <object class="GtkBox">
-            <property name="orientation">horizontal</property>
-            <child>
+          <object class="AdwFlap" id="flap">
+            <property name="transition-type">over</property>
+            <property name="reveal-flap">false</property>
+            <child type="separator">
+              <object class="GtkSeparator">
+                <property name="orientation">vertical</property>
+              </object>
+            </child>
+            <child type="content">
               <object class="GtkStack" id="stack">
                 <property name="hexpand">true</property>
                 <style>
@@ -163,117 +169,105 @@ Or, press Ctrl+W to close the window.</property>
                 </child>
               </object>
             </child>
-            <child>
-              <object class="GtkRevealer" id="preferences_revealer">
-                <property name="transition-type">slide-left</property>
+            <child type="flap">
+              <object class="GtkScrolledWindow">
+                <property name="propagate-natural-width">true</property>
+                <property name="propagate-natural-height">true</property>
+                <property name="hscrollbar-policy">never</property>
+                <style>
+                  <class name="preferences"/>
+                </style>
                 <child>
                   <object class="GtkBox">
-                    <property name="orientation">horizontal</property>
+                    <property name="orientation">vertical</property>
+                    <property name="width-request">300</property>
+                    <property name="margin-start">12</property>
+                    <property name="margin-end">12</property>
+                    <property name="margin-top">12</property>
+                    <property name="margin-bottom">12</property>
+                    <child>
+                      <object class="GtkCenterBox">
+                        <property name="orientation">horizontal</property>
+                        <child type="center">
+                          <object class="GtkLabel">
+                            <property name="label" translatable="yes">Preferences</property>
+                            <property name="xalign">.5</property>
+                            <attributes>
+                              <attribute name="weight" value="bold"/>
+                            </attributes>
+                          </object>
+                        </child>
+                        <child type="end">
+                          <object class="GtkButton">
+                            <property name="icon-name">window-close-symbolic</property>
+                            <property name="action-name">win.hide-preferences</property>
+                            <style>
+                              <class name="image-button"/>
+                              <class name="circular"/>
+                              <class name="flat"/>
+                            </style>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="AdwPreferencesGroup">
+                        <property name="title" translatable="yes">Font</property>
+                        <property name="margin-top">12</property>
+                        <child>
+                          <object class="EditorPreferencesSwitch" id="use_system_font">
+                            <property name="title" translatable="yes">Use System Font</property>
+                            <property name="schema-key">use-system-font</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="EditorPreferencesFont" id="custom_font">
+                            <property name="title" translatable="yes">Custom Font</property>
+                            <property name="schema-key">custom-font</property>
+                            <property name="sensitive" bind-source="use_system_font" bind-property="active" 
bind-flags="sync-create|invert-boolean"/>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
                     <child>
-                      <object class="GtkSeparator">
-                        <property name="orientation">vertical</property>
+                      <object class="AdwPreferencesGroup">
+                        <property name="title" translatable="yes">Right Margin</property>
+                        <property name="margin-top">24</property>
+                        <child>
+                          <object class="EditorPreferencesSpin" id="right_margin">
+                            <property name="title" translatable="yes">Margin Position</property>
+                            <property name="schema-key">right-margin-position</property>
+                          </object>
+                        </child>
                       </object>
                     </child>
                     <child>
-                      <object class="GtkScrolledWindow">
-                        <property name="propagate-natural-width">true</property>
-                        <property name="propagate-natural-height">true</property>
-                        <property name="hscrollbar-policy">never</property>
+                      <object class="AdwPreferencesGroup">
+                        <property name="title" translatable="yes">Appearance</property>
+                        <property name="margin-top">24</property>
                         <child>
-                          <object class="GtkBox">
-                            <property name="orientation">vertical</property>
-                            <property name="width-request">300</property>
-                            <property name="margin-start">12</property>
-                            <property name="margin-end">12</property>
-                            <property name="margin-top">12</property>
-                            <property name="margin-bottom">12</property>
-                            <child>
-                              <object class="GtkCenterBox">
-                                <property name="orientation">horizontal</property>
-                                <child type="center">
-                                  <object class="GtkLabel">
-                                    <property name="label" translatable="yes">Preferences</property>
-                                    <property name="xalign">.5</property>
-                                    <attributes>
-                                      <attribute name="weight" value="bold"/>
-                                    </attributes>
-                                  </object>
-                                </child>
-                                <child type="end">
-                                  <object class="GtkButton">
-                                    <property name="icon-name">window-close-symbolic</property>
-                                    <property name="action-name">win.hide-preferences</property>
-                                    <style>
-                                      <class name="image-button"/>
-                                      <class name="circular"/>
-                                      <class name="flat"/>
-                                    </style>
-                                  </object>
-                                </child>
-                              </object>
-                            </child>
-                            <child>
-                              <object class="AdwPreferencesGroup">
-                                <property name="title" translatable="yes">Font</property>
-                                <property name="margin-top">12</property>
-                                <child>
-                                  <object class="EditorPreferencesSwitch" id="use_system_font">
-                                    <property name="title" translatable="yes">Use System Font</property>
-                                    <property name="schema-key">use-system-font</property>
-                                  </object>
-                                </child>
-                                <child>
-                                  <object class="EditorPreferencesFont" id="custom_font">
-                                    <property name="title" translatable="yes">Custom Font</property>
-                                    <property name="schema-key">custom-font</property>
-                                    <property name="sensitive" bind-source="use_system_font" 
bind-property="active" bind-flags="sync-create|invert-boolean"/>
-                                  </object>
-                                </child>
-                              </object>
-                            </child>
-                            <child>
-                              <object class="AdwPreferencesGroup">
-                                <property name="title" translatable="yes">Right Margin</property>
-                                <property name="margin-top">24</property>
-                                <child>
-                                  <object class="EditorPreferencesSpin" id="right_margin">
-                                    <property name="title" translatable="yes">Margin Position</property>
-                                    <property name="schema-key">right-margin-position</property>
-                                  </object>
-                                </child>
-                              </object>
-                            </child>
-                            <child>
-                              <object class="AdwPreferencesGroup">
-                                <property name="title" translatable="yes">Appearance</property>
-                                <property name="margin-top">24</property>
-                                <child>
-                                  <object class="EditorPreferencesSwitch" id="grid">
-                                    <property name="title" translatable="yes">Display Grid Pattern</property>
-                                    <property name="schema-key">show-grid</property>
-                                  </object>
-                                </child>
-                                <child>
-                                  <object class="EditorPreferencesSwitch" id="highlight_current_line">
-                                    <property name="title" translatable="yes">Highlight Current 
Line</property>
-                                    <property name="schema-key">highlight-current-line</property>
-                                  </object>
-                                </child>
-                                <child>
-                                  <object class="EditorPreferencesSwitch" id="map">
-                                    <property name="title" translatable="yes">Display Overview Map</property>
-                                    <property name="schema-key">show-map</property>
-                                  </object>
-                                </child>
-                              </object>
-                            </child>
-                            <child>
-                              <object class="AdwPreferencesGroup" id="scheme_group">
-                                <property name="margin-top">12</property>
-                              </object>
-                            </child>
+                          <object class="EditorPreferencesSwitch" id="grid">
+                            <property name="title" translatable="yes">Display Grid Pattern</property>
+                            <property name="schema-key">show-grid</property>
                           </object>
                         </child>
+                        <child>
+                          <object class="EditorPreferencesSwitch" id="highlight_current_line">
+                            <property name="title" translatable="yes">Highlight Current Line</property>
+                            <property name="schema-key">highlight-current-line</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="EditorPreferencesSwitch" id="map">
+                            <property name="title" translatable="yes">Display Overview Map</property>
+                            <property name="schema-key">show-map</property>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="AdwPreferencesGroup" id="scheme_group">
+                        <property name="margin-top">12</property>
                       </object>
                     </child>
                   </object>


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