[gnome-contacts/wip/cdavis/hdy-style-updates: 8/8] contact-pane: Re-arrange widgets, subclass GtkBin




commit 5e568a6d1afde331b1d9acd075325e8ef10ccda4
Author: Christopher Davis <brainblasted disroot org>
Date:   Fri Feb 5 22:44:12 2021 -0800

    contact-pane: Re-arrange widgets, subclass GtkBin
    
    Subclassing GtkScrollWindow and putting the stack, etc.
    nested in the hierarchy messed with HdyStatusPage and
    caused it to have odd margins. Since HdyStatusPage also
    includes a GtkScrolledWindow, this would cause double
    scrolling as well.
    
    This commit rearranges things to work well with HdyStatusPage.

 data/ui/contacts-contact-pane.ui | 89 +++++++++++++++++++++++++---------------
 src/contacts-contact-pane.vala   | 12 +++---
 2 files changed, 63 insertions(+), 38 deletions(-)
---
diff --git a/data/ui/contacts-contact-pane.ui b/data/ui/contacts-contact-pane.ui
index bf5282a0..409d5385 100644
--- a/data/ui/contacts-contact-pane.ui
+++ b/data/ui/contacts-contact-pane.ui
@@ -1,54 +1,79 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <requires lib="gtk+" version="3.20"/>
-  <template class="ContactsContactPane" parent="GtkScrolledWindow">
+  <template class="ContactsContactPane" parent="GtkBin">
     <property name="visible">True</property>
     <property name="hexpand">True</property>
     <property name="vexpand">True</property>
-    <property name="shadow_type">none</property>
-    <property name="hscrollbar_policy">never</property>
-    <property name="vscrollbar_policy">automatic</property>
     <child>
-      <object class="HdyClamp">
+      <object class="GtkStack" id="stack">
         <property name="visible">True</property>
-        <property name="margin-top">32</property>
-        <property name="margin-bottom">32</property>
-        <property name="margin-left">24</property>
-        <property name="margin-right">24</property>
+        <property name="visible-child">none_selected_page</property>
         <child>
-          <object class="GtkStack" id="stack">
+          <object class="HdyStatusPage" id="none_selected_page">
             <property name="visible">True</property>
-            <property name="visible-child">none_selected_page</property>
-            <child>
-              <object class="HdyStatusPage" id="none_selected_page">
-                <property name="visible">True</property>
-                <property name="hexpand">True</property>
-                <property name="vexpand">True</property>
-                <property name="icon_name">avatar-default-symbolic</property>
-                <property name="title" translatable="yes">Select a Contact</property>
-              </object>
-              <packing>
-                <property name="name">none-selected-page</property>
-              </packing>
-            </child>
+            <property name="hexpand">True</property>
+            <property name="vexpand">True</property>
+            <property name="icon_name">avatar-default-symbolic</property>
+            <property name="title" translatable="yes">Select a Contact</property>
+          </object>
+          <packing>
+            <property name="name">none-selected-page</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkScrolledWindow">
+            <property name="visible">True</property>
+            <property name="hexpand">True</property>
+            <property name="vexpand">True</property>
+            <property name="shadow_type">none</property>
+            <property name="hscrollbar_policy">never</property>
+            <property name="vscrollbar_policy">automatic</property>
             <child>
-              <object class="GtkBox" id="contact_sheet_page">
+              <object class="HdyClamp">
                 <property name="visible">True</property>
+                <property name="margin-top">32</property>
+                <property name="margin-bottom">32</property>
+                <property name="margin-left">24</property>
+                <property name="margin-right">24</property>
+                <child>
+                  <object class="GtkBox" id="contact_sheet_page">
+                    <property name="visible">True</property>
+                  </object>
+                </child>
               </object>
-              <packing>
-                <property name="name">contact-sheet-page</property>
-              </packing>
             </child>
+          </object>
+          <packing>
+            <property name="name">contact-sheet-page</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkScrolledWindow">
+            <property name="visible">True</property>
+            <property name="hexpand">True</property>
+            <property name="vexpand">True</property>
+            <property name="shadow_type">none</property>
+            <property name="hscrollbar_policy">never</property>
+            <property name="vscrollbar_policy">automatic</property>
             <child>
-              <object class="GtkBox" id="contact_editor_page">
+              <object class="HdyClamp">
                 <property name="visible">True</property>
+                <property name="margin-top">32</property>
+                <property name="margin-bottom">32</property>
+                <property name="margin-left">24</property>
+                <property name="margin-right">24</property>
+                <child>
+                  <object class="GtkBox" id="contact_editor_page">
+                    <property name="visible">True</property>
+                  </object>
+                </child>
               </object>
-              <packing>
-                <property name="name">contact-editor-page</property>
-              </packing>
             </child>
-
           </object>
+          <packing>
+            <property name="name">contact-editor-page</property>
+          </packing>
         </child>
       </object>
     </child>
diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala
index eae68ae1..a392a5b2 100644
--- a/src/contacts-contact-pane.vala
+++ b/src/contacts-contact-pane.vala
@@ -25,7 +25,7 @@ const int PROFILE_SIZE = 128;
  * and a ContactEditor to edit contact information.
  */
 [GtkTemplate (ui = "/org/gnome/Contacts/ui/contacts-contact-pane.ui")]
-public class Contacts.ContactPane : Gtk.ScrolledWindow {
+public class Contacts.ContactPane : Gtk.Bin {
 
   private MainWindow main_window;
 
@@ -98,7 +98,7 @@ public class Contacts.ContactPane : Gtk.ScrolledWindow {
       show_contact_sheet ();
     } else {
       remove_contact_sheet ();
-      this.stack.set_visible_child (this.none_selected_page);
+      this.stack.set_visible_child_name ("none-selected-page");
     }
   }
 
@@ -108,7 +108,7 @@ public class Contacts.ContactPane : Gtk.ScrolledWindow {
     remove_contact_sheet();
     this.sheet = new ContactSheet (this.individual, this.store);
     this.contact_sheet_page.add (this.sheet);
-    this.stack.set_visible_child (this.contact_sheet_page);
+    this.stack.set_visible_child_name ("contact-sheet-page");
 
     var matches = this.store.aggregator.get_potential_matches (this.individual, MatchResult.HIGH);
     foreach (var i in matches.keys) {
@@ -154,7 +154,7 @@ public class Contacts.ContactPane : Gtk.ScrolledWindow {
     this.on_edit_mode = true;
 
     create_contact_editor ();
-    this.stack.set_visible_child (this.contact_editor_page);
+    this.stack.set_visible_child_name ("contact-editor-page");
   }
 
   public void stop_editing (bool cancel = false) {
@@ -169,9 +169,9 @@ public class Contacts.ContactPane : Gtk.ScrolledWindow {
       if (fake_individual != null && fake_individual.real_individual != null) {
         // Reset individual on to the real one
         this.individual = fake_individual.real_individual;
-        this.stack.set_visible_child (this.contact_sheet_page);
+        this.stack.set_visible_child_name ("contact-sheet-page");
       } else {
-        this.stack.set_visible_child (this.none_selected_page);
+        this.stack.set_visible_child_name ("none-selected-page");
       }
       return;
     }


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