[gnome-control-center] window: Use HdyLeaflet:folded



commit 0c9b828d6f59e6751ae1ab343d8adcd1a655afda
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Fri Mar 6 09:29:38 2020 +0100

    window: Use HdyLeaflet:folded
    
    Replace the dropped fold enum property by the folded boolean one, and
    directly bind booleans in UI files where possible.

 shell/cc-window.c  | 32 +++-----------------------------
 shell/cc-window.ui |  6 +++---
 2 files changed, 6 insertions(+), 32 deletions(-)
---
diff --git a/shell/cc-window.c b/shell/cc-window.c
index 65d738a726..b7bb371512 100644
--- a/shell/cc-window.c
+++ b/shell/cc-window.c
@@ -513,29 +513,7 @@ switch_to_previous_panel (CcWindow *self)
 
 /* Callbacks */
 static void
-update_fold_state (CcWindow *self)
-{
-  GtkWidget *header_child = hdy_leaflet_get_visible_child (self->header_box);
-  HdyFold fold = hdy_leaflet_get_fold (self->header_box);
-
-  gtk_widget_set_visible (GTK_WIDGET (self->back_revealer), fold == HDY_FOLD_FOLDED);
-  gtk_revealer_set_reveal_child (self->back_revealer, fold == HDY_FOLD_FOLDED);
-}
-
-static void
-notify_header_visible_child_cb (CcWindow *self)
-{
-  update_fold_state (self);
-}
-
-static void
-notify_fold_cb (CcWindow *self)
-{
-  update_fold_state (self);
-}
-
-static void
-on_main_leaflet_fold_changed_cb (CcWindow *self)
+on_main_leaflet_folded_changed_cb (CcWindow *self)
 {
   GtkSelectionMode selection_mode;
 
@@ -543,7 +521,7 @@ on_main_leaflet_fold_changed_cb (CcWindow *self)
 
   selection_mode = GTK_SELECTION_SINGLE;
 
-  if (hdy_leaflet_get_fold (self->main_leaflet) == HDY_FOLD_FOLDED)
+  if (hdy_leaflet_get_folded (self->main_leaflet))
     selection_mode = GTK_SELECTION_NONE;
 
   cc_panel_list_set_selection_mode (self->panel_list, selection_mode);
@@ -915,9 +893,7 @@ cc_window_class_init (CcWindowClass *klass)
 
   gtk_widget_class_bind_template_callback (widget_class, back_button_clicked_cb);
   gtk_widget_class_bind_template_callback (widget_class, gdk_window_set_cb);
-  gtk_widget_class_bind_template_callback (widget_class, notify_header_visible_child_cb);
-  gtk_widget_class_bind_template_callback (widget_class, notify_fold_cb);
-  gtk_widget_class_bind_template_callback (widget_class, on_main_leaflet_fold_changed_cb);
+  gtk_widget_class_bind_template_callback (widget_class, on_main_leaflet_folded_changed_cb);
   gtk_widget_class_bind_template_callback (widget_class, on_development_warning_dialog_responded_cb);
   gtk_widget_class_bind_template_callback (widget_class, previous_button_clicked_cb);
   gtk_widget_class_bind_template_callback (widget_class, search_entry_activate_cb);
@@ -944,8 +920,6 @@ cc_window_init (CcWindow *self)
   /* Add a custom CSS class on development builds */
   if (in_flatpak_sandbox ())
     gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (self)), "devel");
-
-  update_fold_state (self);
 }
 
 CcWindow *
diff --git a/shell/cc-window.ui b/shell/cc-window.ui
index a878ac0617..24f37de353 100644
--- a/shell/cc-window.ui
+++ b/shell/cc-window.ui
@@ -14,7 +14,7 @@
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="transition-type">slide</property>
-        <signal name="notify::fold" handler="on_main_leaflet_fold_changed_cb" object="CcWindow" 
swapped="yes" />
+        <signal name="notify::folded" handler="on_main_leaflet_folded_changed_cb" object="CcWindow" 
swapped="yes" />
         <child>
           <object class="GtkBox" id="sidebar_box">
             <property name="visible">True</property>
@@ -113,8 +113,6 @@
             <property name="mode-transition-duration" bind-source="main_leaflet" 
bind-property="mode-transition-duration" bind-flags="bidirectional|sync-create"/>
             <property name="child-transition-duration" bind-source="main_leaflet" 
bind-property="child-transition-duration" bind-flags="bidirectional|sync-create"/>
             <property name="transition-type" bind-source="main_leaflet" bind-property="transition-type" 
bind-flags="bidirectional|sync-create"/>
-            <signal name="notify::visible-child" handler="notify_header_visible_child_cb" swapped="yes"/>
-            <signal name="notify::fold" handler="notify_fold_cb" object="CcWindow" after="yes" 
swapped="yes"/>
             <child>
               <object class="GtkHeaderBar" id="header">
                 <property name="visible">True</property>
@@ -214,6 +212,8 @@
                     <property name="can_focus">False</property>
                     <property name="transition-type">crossfade</property>
                     <property name="transition-duration" bind-source="main_leaflet" 
bind-property="mode-transition-duration" bind-flags="bidirectional|sync-create"/>
+                    <property name="visible" bind-source="header_box" bind-property="folded" 
bind-flags="sync-create"/>
+                    <property name="reveal-child" bind-source="header_box" bind-property="folded" 
bind-flags="sync-create"/>
                     <child>
                       <object class="GtkButton" id="back">
                         <property name="visible">True</property>


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