diff options
author | Niels De Graef <nielsdegraef@gmail.com> | 2018-04-25 08:26:41 +0200 |
---|---|---|
committer | Niels De Graef <nielsdegraef@gmail.com> | 2018-05-08 00:21:11 +0200 |
commit | 86a648f47a7504f95d28ea3af102797e905a1d9b (patch) | |
tree | c4b0562e0adfb1cfb15e1ebb237a752df0ed5553 | |
parent | 83aa13d86fcd3d88dbd0a574beefaf43aa3aaac0 (diff) | |
download | gnome-contacts-86a648f47a7504f95d28ea3af102797e905a1d9b.tar.gz |
ContactForm: use a common container Grid.
This is already a common structure of both the ContactEditor and the
ContactSheet. By declaring this in the parent class, we can freely
make changes while make sure it's consistent over both classes.
-rw-r--r-- | data/contacts.gresource.xml | 2 | ||||
-rw-r--r-- | data/ui/contacts-contact-editor.ui | 22 | ||||
-rw-r--r-- | data/ui/contacts-contact-form.ui | 35 | ||||
-rw-r--r-- | data/ui/contacts-contact-sheet.ui | 29 | ||||
-rw-r--r-- | data/ui/style.css | 4 | ||||
-rw-r--r-- | src/contacts-contact-editor.vala | 19 | ||||
-rw-r--r-- | src/contacts-contact-form.vala | 11 | ||||
-rw-r--r-- | src/contacts-contact-sheet.vala | 3 |
8 files changed, 53 insertions, 72 deletions
diff --git a/data/contacts.gresource.xml b/data/contacts.gresource.xml index 6564cfd..30c7fc3 100644 --- a/data/contacts.gresource.xml +++ b/data/contacts.gresource.xml @@ -7,8 +7,8 @@ <file compressed="true" preprocess="xml-stripblanks">ui/contacts-accounts-list.ui</file> <file compressed="true" preprocess="xml-stripblanks">ui/contacts-avatar-selector.ui</file> <file compressed="true" preprocess="xml-stripblanks">ui/contacts-contact-editor.ui</file> + <file compressed="true" preprocess="xml-stripblanks">ui/contacts-contact-form.ui</file> <file compressed="true" preprocess="xml-stripblanks">ui/contacts-contact-pane.ui</file> - <file compressed="true" preprocess="xml-stripblanks">ui/contacts-contact-sheet.ui</file> <file compressed="true" preprocess="xml-stripblanks">ui/contacts-crop-cheese-dialog.ui</file> <file compressed="true" preprocess="xml-stripblanks">ui/contacts-in-app-notification.ui</file> <file compressed="true" preprocess="xml-stripblanks">ui/contacts-link-suggestion-grid.ui</file> diff --git a/data/ui/contacts-contact-editor.ui b/data/ui/contacts-contact-editor.ui index 4f181e8..a601209 100644 --- a/data/ui/contacts-contact-editor.ui +++ b/data/ui/contacts-contact-editor.ui @@ -53,28 +53,6 @@ <property name="visible">True</property> <property name="orientation">vertical</property> <child> - <object class="GtkScrolledWindow" id="main_sw"> - <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="GtkGrid" id="container_grid"> - <property name="visible">True</property> - <property name="margin">36</property> - <property name="margin_bottom">24</property> - <property name="row_spacing">12</property> - <property name="column_spacing">12</property> - <property name="hexpand">True</property> - <property name="vexpand">True</property> - <signal name="size-allocate" handler="on_container_grid_size_allocate" after="true" /> - </object> - </child> - </object> - </child> - <child> <object class="GtkActionBar"> <property name="visible">True</property> <child> diff --git a/data/ui/contacts-contact-form.ui b/data/ui/contacts-contact-form.ui new file mode 100644 index 0000000..b0c1fd1 --- /dev/null +++ b/data/ui/contacts-contact-form.ui @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <!-- interface-requires gtk+ 3.22 --> + <template class="ContactsContactForm" parent="GtkGrid"> + <property name="visible">True</property> + <child> + <object class="GtkScrolledWindow" id="main_sw"> + <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="ContactsMaxWidthBin"> + <property name="visible">True</property> + <property name="max_width">600</property> + <child> + <object class="GtkGrid" id="container_grid"> + <property name="visible">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="orientation">vertical</property> + <property name="row_spacing">12</property> + <property name="column_spacing">16</property> + <property name="margin">36</property> + <property name="margin_bottom">24</property> + </object> + </child> + </object> + </child> + </object> + </child> + </template> +</interface> diff --git a/data/ui/contacts-contact-sheet.ui b/data/ui/contacts-contact-sheet.ui deleted file mode 100644 index 4ef64b7..0000000 --- a/data/ui/contacts-contact-sheet.ui +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<interface> - <!-- interface-requires gtk+ 3.22 --> - <template class="ContactsContactSheet" parent="ContactsContactForm"> - <property name="visible">True</property> - <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="GtkGrid" id="container_grid"> - <property name="visible">True</property> - <property name="hexpand">True</property> - <property name="vexpand">True</property> - <property name="orientation">vertical</property> - <property name="row_spacing">12</property> - <property name="column_spacing">16</property> - <property name="margin">36</property> - <property name="margin_bottom">24</property> - </object> - </child> - </object> - </child> - </template> -</interface> diff --git a/data/ui/style.css b/data/ui/style.css index 455dd65..848f849 100644 --- a/data/ui/style.css +++ b/data/ui/style.css @@ -23,8 +23,8 @@ ContactsListPane.frame:dir(rtl) { row.contact-data-row { } -/* Background color in contacts pane, similar to .documents-main-view.view */ -.contacts-main-view.view { +/* Styles for a ContactsContactForm */ +.contacts-contact-form { background-color: mix(@theme_bg_color, @theme_base_color, 0.4); } diff --git a/src/contacts-contact-editor.vala b/src/contacts-contact-editor.vala index 2a1cb31..c641877 100644 --- a/src/contacts-contact-editor.vala +++ b/src/contacts-contact-editor.vala @@ -71,8 +71,6 @@ public class Contacts.ContactEditor : ContactForm { "postal-addresses.home" }; - [GtkChild] - private Grid container_grid; private weak Widget focus_widget; private Entry name_entry; @@ -80,9 +78,6 @@ public class Contacts.ContactEditor : ContactForm { private Avatar avatar; [GtkChild] - private ScrolledWindow main_sw; - - [GtkChild] private MenuButton add_detail_button; [GtkChild] @@ -122,11 +117,7 @@ public class Contacts.ContactEditor : ContactForm { construct { this.writable_personas = new HashMap<string, HashMap<string, Field?>> (); - - this.container_grid.set_focus_vadjustment (this.main_sw.get_vadjustment ()); - - this.main_sw.get_style_context ().add_class ("contacts-main-view"); - this.main_sw.get_style_context ().add_class ("view"); + this.container_grid.size_allocate.connect(on_container_grid_size_allocate); } public ContactEditor (Contact? contact, Store store, GLib.ActionGroup editor_actions) { @@ -830,12 +821,10 @@ public class Contacts.ContactEditor : ContactForm { container_grid.insert_row (idx); } - [GtkCallback] private void on_container_grid_size_allocate (Allocation alloc) { - if (focus_widget != null && - focus_widget is Widget) { - focus_widget.grab_focus (); - focus_widget = null; + if (this.focus_widget != null && this.focus_widget is Widget) { + this.focus_widget.grab_focus (); + this.focus_widget = null; } } diff --git a/src/contacts-contact-form.vala b/src/contacts-contact-form.vala index 16c0dc9..f44a2fb 100644 --- a/src/contacts-contact-form.vala +++ b/src/contacts-contact-form.vala @@ -26,6 +26,7 @@ using Gtk; * (possibly empty) contact, starting with a header and subsequently iterating * over the several {@link Folks.Persona}s, displaying their properties. */ +[GtkTemplate (ui = "/org/gnome/Contacts/ui/contacts-contact-form.ui")] public abstract class Contacts.ContactForm : Grid { protected const string[] SORTED_PROPERTIES = { @@ -43,8 +44,18 @@ public abstract class Contacts.ContactForm : Grid { protected Store store; + [GtkChild] + private ScrolledWindow main_sw; + + [GtkChild] + protected Grid container_grid; protected int last_row = 0; + construct { + this.container_grid.set_focus_vadjustment (this.main_sw.get_vadjustment ()); + this.main_sw.get_style_context ().add_class ("contacts-contact-form"); + } + protected string[] sort_persona_properties (string[] props) { CompareDataFunc<string> compare_properties = (a, b) => { foreach (var prop in SORTED_PROPERTIES) { diff --git a/src/contacts-contact-sheet.vala b/src/contacts-contact-sheet.vala index f518a84..37ff5c3 100644 --- a/src/contacts-contact-sheet.vala +++ b/src/contacts-contact-sheet.vala @@ -24,10 +24,7 @@ using Gee; * * (Note: to edit a contact, use the {@link ContactEditor} instead. */ -[GtkTemplate (ui = "/org/gnome/Contacts/ui/contacts-contact-sheet.ui")] public class Contacts.ContactSheet : ContactForm { - [GtkChild] - private Grid container_grid; public ContactSheet (Contact contact, Store store) { this.contact = contact; |