summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels De Graef <nielsdegraef@gmail.com>2018-04-23 07:58:51 +0200
committerNiels De Graef <nielsdegraef@gmail.com>2018-05-08 00:21:11 +0200
commit83aa13d86fcd3d88dbd0a574beefaf43aa3aaac0 (patch)
treecc1e735f6c832f6a47df13a116db5d22dba6c118
parenteea44e5035b295ccba174a64faf6fa4d0e1eef35 (diff)
downloadgnome-contacts-83aa13d86fcd3d88dbd0a574beefaf43aa3aaac0.tar.gz
ContactSheet: use a container grid.
By using that instead of directly attaching the widgets to itself, we can extract more common code wth ContactEditor into ContactForm.
-rw-r--r--data/ui/contacts-contact-pane.ui17
-rw-r--r--data/ui/contacts-contact-sheet.ui39
-rw-r--r--src/contacts-contact-pane.vala9
-rw-r--r--src/contacts-contact-sheet.vala36
4 files changed, 43 insertions, 58 deletions
diff --git a/data/ui/contacts-contact-pane.ui b/data/ui/contacts-contact-pane.ui
index d76e65e..a999b66 100644
--- a/data/ui/contacts-contact-pane.ui
+++ b/data/ui/contacts-contact-pane.ui
@@ -43,23 +43,8 @@
</packing>
</child>
<child>
- <object class="GtkScrolledWindow" id="contact_sheet_page">
+ <object class="GtkBox" id="contact_sheet_page">
<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" id="contact_sheet_container">
- <property name="visible">True</property>
- <property name="max-width">600</property>
- </object>
- </child>
- <style>
- <class name="contacts-main-view"/>
- <class name="view"/>
- </style>
</object>
<packing>
<property name="name">contact-sheet-page</property>
diff --git a/data/ui/contacts-contact-sheet.ui b/data/ui/contacts-contact-sheet.ui
index 835beb6..4ef64b7 100644
--- a/data/ui/contacts-contact-sheet.ui
+++ b/data/ui/contacts-contact-sheet.ui
@@ -3,32 +3,27 @@
<!-- interface-requires gtk+ 3.22 -->
<template class="ContactsContactSheet" parent="ContactsContactForm">
<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>
<child>
- <object class="GtkLabel" id="name_label">
+ <object class="GtkScrolledWindow">
<property name="visible">True</property>
- <property name="selectable">True</property>
<property name="hexpand">True</property>
- <property name="halign">start</property>
- <property name="valign">center</property>
- <property name="margin_start">6</property>
- <property name="xalign">0</property>
- <property name="ellipsize">end</property>
- <style>
- <class name="contacts-contact-sheet"/>
- </style>
+ <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>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- <property name="height">3</property>
- </packing>
</child>
</template>
</interface>
diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala
index ffb5d62..1fabeff 100644
--- a/src/contacts-contact-pane.vala
+++ b/src/contacts-contact-pane.vala
@@ -39,9 +39,7 @@ public class Contacts.ContactPane : Stack {
private Grid none_selected_page;
[GtkChild]
- private ScrolledWindow contact_sheet_page;
- [GtkChild]
- private Container contact_sheet_container;
+ private Container contact_sheet_page;
private ContactSheet? sheet = null;
[GtkChild]
@@ -124,8 +122,7 @@ public class Contacts.ContactPane : Stack {
remove_contact_sheet();
this.sheet = new ContactSheet (this.contact, this.store);
- this.contact_sheet_container.add (this.sheet);
- this.sheet.set_focus_vadjustment (this.contact_sheet_page.get_vadjustment ());
+ this.contact_sheet_page.add (this.sheet);
set_visible_child (this.contact_sheet_page);
var matches = this.store.aggregator.get_potential_matches (this.contact.individual, MatchResult.HIGH);
@@ -145,7 +142,7 @@ public class Contacts.ContactPane : Stack {
// Remove the suggestion grid that goes along with it.
remove_suggestion_grid ();
- this.contact_sheet_container.remove (this.sheet);
+ this.contact_sheet_page.remove (this.sheet);
this.sheet.destroy();
this.sheet = null;
}
diff --git a/src/contacts-contact-sheet.vala b/src/contacts-contact-sheet.vala
index a021507..f518a84 100644
--- a/src/contacts-contact-sheet.vala
+++ b/src/contacts-contact-sheet.vala
@@ -26,9 +26,8 @@ using Gee;
*/
[GtkTemplate (ui = "/org/gnome/Contacts/ui/contacts-contact-sheet.ui")]
public class Contacts.ContactSheet : ContactForm {
-
[GtkChild]
- private Label name_label;
+ private Grid container_grid;
public ContactSheet (Contact contact, Store store) {
this.contact = contact;
@@ -46,14 +45,14 @@ public class Contacts.ContactSheet : ContactForm {
type_label.xalign = 1.0f;
type_label.set_halign (Align.END);
type_label.get_style_context ().add_class ("dim-label");
- attach (type_label, 0, this.last_row);
+ this.container_grid.attach (type_label, 0, this.last_row);
var value_button = new Button.with_label (value);
value_button.focus_on_click = false;
value_button.relief = ReliefStyle.NONE;
value_button.xalign = 0.0f;
value_button.set_hexpand (true);
- attach (value_button, 1, this.last_row);
+ this.container_grid.attach (value_button, 1, this.last_row);
this.last_row++;
(value_button.get_child () as Label).set_ellipsize (Pango.EllipsizeMode.END);
@@ -67,14 +66,14 @@ public class Contacts.ContactSheet : ContactForm {
type_label.xalign = 1.0f;
type_label.set_halign (Align.END);
type_label.get_style_context ().add_class ("dim-label");
- attach (type_label, 0, this.last_row);
+ this.container_grid.attach (type_label, 0, this.last_row);
var value_button = new LinkButton (value);
value_button.focus_on_click = false;
value_button.relief = ReliefStyle.NONE;
value_button.xalign = 0.0f;
value_button.set_hexpand (true);
- attach (value_button, 1, this.last_row);
+ this.container_grid.attach (value_button, 1, this.last_row);
this.last_row++;
(value_button.get_child () as Label).set_ellipsize (Pango.EllipsizeMode.END);
@@ -87,7 +86,7 @@ public class Contacts.ContactSheet : ContactForm {
type_label.set_halign (Align.END);
type_label.set_valign (Align.START);
type_label.get_style_context ().add_class ("dim-label");
- attach (type_label, 0, this.last_row, 1, 1);
+ this.container_grid.attach (type_label, 0, this.last_row, 1, 1);
var value_label = new Label (value);
value_label.set_line_wrap (true);
@@ -103,7 +102,7 @@ public class Contacts.ContactSheet : ContactForm {
value_label.margin_top = 3;
value_label.margin_bottom = 3;
- attach (value_label, 1, this.last_row, 1, 1);
+ this.container_grid.attach (value_label, 1, this.last_row, 1, 1);
this.last_row++;
}
@@ -111,12 +110,9 @@ public class Contacts.ContactSheet : ContactForm {
var image_frame = new Avatar (PROFILE_SIZE, this.contact);
image_frame.set_vexpand (false);
image_frame.set_valign (Align.START);
- attach (image_frame, 0, 0, 1, 3);
+ this.container_grid.attach (image_frame, 0, 0, 1, 3);
- this.contact.keep_widget_uptodate (this.name_label, (w) => {
- this.name_label.set_markup (Markup.printf_escaped ("<span font='16'>%s</span>",
- this.contact.individual.display_name));
- });
+ create_name_label ();
this.last_row += 3; // Name/Avatar takes up 3 rows
bool is_first_persona = true;
@@ -126,7 +122,7 @@ public class Contacts.ContactSheet : ContactForm {
foreach (var p in personas) {
int persona_store_pos = this.last_row;
if (!is_first_persona) {
- attach (create_persona_store_label (p), 0, this.last_row, 3);
+ this.container_grid.attach (create_persona_store_label (p), 0, this.last_row, 3);
this.last_row++;
}
@@ -144,6 +140,18 @@ public class Contacts.ContactSheet : ContactForm {
show_all ();
}
+ private void create_name_label () {
+ var name_label = new Label ("");
+ name_label.ellipsize = Pango.EllipsizeMode.END;
+ name_label.xalign = 0f;
+ name_label.selectable = true;
+ this.container_grid.attach (name_label, 1, 0, 1, 3);
+ this.contact.keep_widget_uptodate (name_label, (w) => {
+ name_label.set_markup (Markup.printf_escaped ("<span font='16'>%s</span>",
+ this.contact.individual.display_name));
+ });
+ }
+
private void add_row_for_property (Persona persona, string property) {
switch (property) {
case "email-addresses":