[gnome-contacts/wip/cdavis/hdy-style-updates: 9/10] contact-pane: Re-arrange widgets, subclass GtkBin
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts/wip/cdavis/hdy-style-updates: 9/10] contact-pane: Re-arrange widgets, subclass GtkBin
- Date: Sat, 13 Feb 2021 09:44:41 +0000 (UTC)
commit d2bb1a5d648aebe623eaf7894c00c61ebdf7a190
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 | 14 +++++--
2 files changed, 67 insertions(+), 36 deletions(-)
---
diff --git a/data/ui/contacts-contact-pane.ui b/data/ui/contacts-contact-pane.ui
index bf5282a0..b75c3be1 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" id="contact_sheet_view">
+ <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" id="contact_editor_view">
+ <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..0796a11f 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;
@@ -39,10 +39,16 @@ public class Contacts.ContactPane : Gtk.ScrolledWindow {
[GtkChild]
private Hdy.StatusPage none_selected_page;
+ [GtkChild]
+ private unowned Gtk.ScrolledWindow contact_sheet_view;
+
[GtkChild]
private Gtk.Container contact_sheet_page;
private ContactSheet? sheet = null;
+ [GtkChild]
+ private unowned Gtk.ScrolledWindow contact_editor_view;
+
[GtkChild]
private Gtk.Box contact_editor_page;
private ContactEditor? editor = null;
@@ -108,7 +114,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 (this.contact_sheet_view);
var matches = this.store.aggregator.get_potential_matches (this.individual, MatchResult.HIGH);
foreach (var i in matches.keys) {
@@ -154,7 +160,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 (this.contact_editor_view);
}
public void stop_editing (bool cancel = false) {
@@ -169,7 +175,7 @@ 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 (this.contact_sheet_view);
} else {
this.stack.set_visible_child (this.none_selected_page);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]