[gnome-control-center/gbsneto/display-panel-redesign: 17/17] display: Use AdwLeaflet in CcDisplayPanel




commit 35639d62cdb2f9e98718949d76a9c3497858a6c6
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Jan 13 16:13:55 2022 -0300

    display: Use AdwLeaflet in CcDisplayPanel
    
    This makes the transition between the main page, night light,
    and display preferences more inline with other GNOME apps
    using GTK4.

 panels/display/cc-display-panel.c  | 12 ++++++------
 panels/display/cc-display-panel.ui | 12 +++++-------
 2 files changed, 11 insertions(+), 13 deletions(-)
---
diff --git a/panels/display/cc-display-panel.c b/panels/display/cc-display-panel.c
index f463fe598..8b5fb2998 100644
--- a/panels/display/cc-display-panel.c
+++ b/panels/display/cc-display-panel.c
@@ -99,8 +99,8 @@ struct _CcDisplayPanel
   GtkWidget      *config_type_switcher_row;
   AdwBin         *display_settings_bin;
   GtkWidget      *display_settings_group;
+  AdwLeaflet     *leaflet;
   AdwComboRow    *primary_display_row;
-  GtkStack       *stack;
   AdwPreferencesGroup *single_display_settings_group;
 
   GtkShortcutController *toplevel_shortcuts;
@@ -465,7 +465,7 @@ static void
 on_back_button_clicked_cb (GtkButton      *button,
                            CcDisplayPanel *self)
 {
-  gtk_stack_set_visible_child_name (self->stack, "displays");
+  adw_leaflet_set_visible_child_name (self->leaflet, "displays");
 }
 
 static void
@@ -523,7 +523,7 @@ static void
 on_night_light_row_activated_cb (GtkListBoxRow  *row,
                                  CcDisplayPanel *self)
 {
-  gtk_stack_set_visible_child_name (self->stack, "night-light");
+  adw_leaflet_set_visible_child_name (self->leaflet, "night-light");
 }
 
 static void
@@ -549,7 +549,7 @@ on_stack_visible_child_name_changed_cb (GtkStack       *stack,
                                         GParamSpec     *pspec,
                                         CcDisplayPanel *self)
 {
-  const gchar *visible_child_name = gtk_stack_get_visible_child_name (self->stack);
+  const gchar *visible_child_name = adw_leaflet_get_visible_child_name (self->leaflet);
 
   gtk_widget_set_visible (self->back_button, g_strcmp0 (visible_child_name, "displays") != 0);
 }
@@ -626,10 +626,10 @@ cc_display_panel_class_init (CcDisplayPanelClass *klass)
   gtk_widget_class_bind_template_child (widget_class, CcDisplayPanel, display_settings_bin);
   gtk_widget_class_bind_template_child (widget_class, CcDisplayPanel, display_settings_group);
   gtk_widget_class_bind_template_child (widget_class, CcDisplayPanel, escape_shortcut);
+  gtk_widget_class_bind_template_child (widget_class, CcDisplayPanel, leaflet);
   gtk_widget_class_bind_template_child (widget_class, CcDisplayPanel, night_light_page);
   gtk_widget_class_bind_template_child (widget_class, CcDisplayPanel, night_light_state_label);
   gtk_widget_class_bind_template_child (widget_class, CcDisplayPanel, primary_display_row);
-  gtk_widget_class_bind_template_child (widget_class, CcDisplayPanel, stack);
   gtk_widget_class_bind_template_child (widget_class, CcDisplayPanel, single_display_settings_group);
   gtk_widget_class_bind_template_child (widget_class, CcDisplayPanel, toplevel_shortcuts);
 
@@ -677,7 +677,7 @@ on_monitor_row_activated_cb (GtkListBoxRow  *row,
   monitor = g_object_get_data (G_OBJECT (row), "monitor");
   set_current_output (self, monitor, FALSE);
 
-  gtk_stack_set_visible_child_name (self->stack, "display-settings");
+  adw_leaflet_set_visible_child_name (self->leaflet, "display-settings");
 }
 
 static void
diff --git a/panels/display/cc-display-panel.ui b/panels/display/cc-display-panel.ui
index d432cb8bf..751517479 100644
--- a/panels/display/cc-display-panel.ui
+++ b/panels/display/cc-display-panel.ui
@@ -17,15 +17,14 @@
     </child>
 
     <child>
-      <object class="GtkStack" id="stack">
-        <property name="transition-type">crossfade</property>
+      <object class="AdwLeaflet" id="leaflet">
+        <property name="can-unfold">False</property>
         <signal name="notify::visible-child-name" handler="on_stack_visible_child_name_changed_cb" 
object="CcDisplayPanel" swapped="no" />
 
         <!-- Displays page -->
         <child>
-          <object class="GtkStackPage">
+          <object class="AdwLeafletPage">
             <property name="name">displays</property>
-            <property name="title" translatable="yes">Displays</property>
             <property name="child">
               <object class="GtkScrolledWindow">
                 <property name="hscrollbar_policy">never</property>
@@ -149,9 +148,8 @@
 
         <!-- Night Light page -->
         <child>
-          <object class="GtkStackPage">
+          <object class="AdwLeafletPage">
             <property name="name">night-light</property>
-            <property name="title" translatable="yes" comments="This is the redshift functionality where we 
suppress blue light when the sun has gone down">Night Light</property>
             <property name="child">
               <object class="CcNightLightPage" id="night_light_page" />
             </property>
@@ -160,7 +158,7 @@
 
         <!-- Display Settings page -->
         <child>
-          <object class="GtkStackPage">
+          <object class="AdwLeafletPage">
             <property name="name">display-settings</property>
             <property name="child">
               <object class="AdwPreferencesPage">


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