[gnome-contacts] Convert Contacts.ContactEditor to GtkTemplate
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] Convert Contacts.ContactEditor to GtkTemplate
- Date: Mon, 26 Jun 2017 20:00:24 +0000 (UTC)
commit 9a55109d997e681cdc0a67653f78f73c05232c21
Author: Niels De Graef <nielsdegraef gmail com>
Date: Mon Jun 26 21:59:46 2017 +0200
Convert Contacts.ContactEditor to GtkTemplate
data/Makefile.am | 1 +
data/contacts.gresource.xml | 1 +
data/ui/app-menu.ui | 46 --------------
data/ui/contacts-contact-editor.ui | 117 ++++++++++++++++++++++++++++++++++++
po/POTFILES.in | 1 +
src/contacts-contact-editor.vala | 85 +++++++++-----------------
6 files changed, 148 insertions(+), 103 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index da230ba..9b7d637 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -37,6 +37,7 @@ EXTRA_DIST = \
ui/app-menu.ui \
ui/contacts-address-map.ui \
ui/contacts-avatar-dialog.ui \
+ ui/contacts-contact-editor.ui \
ui/contacts-in-app-notification.ui \
ui/contacts-list-pane.ui \
ui/contacts-window.ui \
diff --git a/data/contacts.gresource.xml b/data/contacts.gresource.xml
index a40f05a..1f6cd8f 100644
--- a/data/contacts.gresource.xml
+++ b/data/contacts.gresource.xml
@@ -5,6 +5,7 @@
<file compressed="true" preprocess="xml-stripblanks">ui/app-menu.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/contacts-address-map.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/contacts-avatar-dialog.ui</file>
+ <file compressed="true" preprocess="xml-stripblanks">ui/contacts-contact-editor.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/contacts-in-app-notification.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/contacts-list-pane.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/contacts-window.ui</file>
diff --git a/data/ui/app-menu.ui b/data/ui/app-menu.ui
index 852515a..1ae5152 100644
--- a/data/ui/app-menu.ui
+++ b/data/ui/app-menu.ui
@@ -22,50 +22,4 @@
</item>
</section>
</menu>
- <menu id="edit-contact">
- <item>
- <attribute name="action">edit.add.email-addresses.home</attribute>
- <attribute name="label" translatable="yes">Home email</attribute>
- </item>
- <item>
- <attribute name="action">edit.add.email-addresses.work</attribute>
- <attribute name="label" translatable="yes">Work email</attribute>
- </item>
- <item>
- <attribute name="action">edit.add.phone-numbers.cell</attribute>
- <attribute name="label" translatable="yes">Mobile phone</attribute>
- </item>
- <item>
- <attribute name="action">edit.add.phone-numbers.home</attribute>
- <attribute name="label" translatable="yes">Home phone</attribute>
- </item>
- <item>
- <attribute name="action">edit.add.phone-numbers.work</attribute>
- <attribute name="label" translatable="yes">Work phone</attribute>
- </item>
- <item>
- <attribute name="action">edit.add.urls</attribute>
- <attribute name="label" translatable="yes">Website</attribute>
- </item>
- <item>
- <attribute name="action">edit.add.nickname</attribute>
- <attribute name="label" translatable="yes">Nickname</attribute>
- </item>
- <item>
- <attribute name="action">edit.add.birthday</attribute>
- <attribute name="label" translatable="yes">Birthday</attribute>
- </item>
- <item>
- <attribute name="action">edit.add.postal-addresses.home</attribute>
- <attribute name="label" translatable="yes">Home address</attribute>
- </item>
- <item>
- <attribute name="action">edit.add.postal-addresses.work</attribute>
- <attribute name="label" translatable="yes">Work address</attribute>
- </item>
- <item>
- <attribute name="action">edit.add.notes</attribute>
- <attribute name="label" translatable="yes">Notes</attribute>
- </item>
- </menu>
</interface>
diff --git a/data/ui/contacts-contact-editor.ui b/data/ui/contacts-contact-editor.ui
new file mode 100644
index 0000000..7783698
--- /dev/null
+++ b/data/ui/contacts-contact-editor.ui
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="3.20"/>
+
+ <menu id="edit-contact-menu">
+ <item>
+ <attribute name="action">edit.add.email-addresses.home</attribute>
+ <attribute name="label" translatable="yes">Home email</attribute>
+ </item>
+ <item>
+ <attribute name="action">edit.add.email-addresses.work</attribute>
+ <attribute name="label" translatable="yes">Work email</attribute>
+ </item>
+ <item>
+ <attribute name="action">edit.add.phone-numbers.cell</attribute>
+ <attribute name="label" translatable="yes">Mobile phone</attribute>
+ </item>
+ <item>
+ <attribute name="action">edit.add.phone-numbers.home</attribute>
+ <attribute name="label" translatable="yes">Home phone</attribute>
+ </item>
+ <item>
+ <attribute name="action">edit.add.phone-numbers.work</attribute>
+ <attribute name="label" translatable="yes">Work phone</attribute>
+ </item>
+ <item>
+ <attribute name="action">edit.add.urls</attribute>
+ <attribute name="label" translatable="yes">Website</attribute>
+ </item>
+ <item>
+ <attribute name="action">edit.add.nickname</attribute>
+ <attribute name="label" translatable="yes">Nickname</attribute>
+ </item>
+ <item>
+ <attribute name="action">edit.add.birthday</attribute>
+ <attribute name="label" translatable="yes">Birthday</attribute>
+ </item>
+ <item>
+ <attribute name="action">edit.add.postal-addresses.home</attribute>
+ <attribute name="label" translatable="yes">Home address</attribute>
+ </item>
+ <item>
+ <attribute name="action">edit.add.postal-addresses.work</attribute>
+ <attribute name="label" translatable="yes">Work address</attribute>
+ </item>
+ <item>
+ <attribute name="action">edit.add.notes</attribute>
+ <attribute name="label" translatable="yes">Notes</attribute>
+ </item>
+ </menu>
+
+ <template class="ContactsContactEditor" parent="GtkGrid">
+ <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>
+ </object>
+ </child>
+ <child>
+ <object class="GtkActionBar">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkMenuButton" id="add_detail_button">
+ <property name="visible">True</property>
+ <property name="menu_model">edit-contact-menu</property>
+ <property name="use_popover">True</property>
+ <property name="direction">up</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <property name="orientation">horizontal</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="label" translatable="yes">New Detail</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="pixel_size">16</property>
+ <property name="icon_name">go-down-symbolic</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="linked_button">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Linked Accounts</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="remove_button">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Remove Contact</property>
+ <style>
+ <class name="destructive-action"/>
+ </style>
+ </object>
+ <packing>
+ <property name="pack_type">end</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index ab747aa..097b160 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -4,6 +4,7 @@ data/org.gnome.Contacts.appdata.xml.in
data/org.gnome.Contacts.desktop.in
data/ui/app-menu.ui
data/ui/contacts-avatar-dialog.ui
+data/ui/contacts-contact-editor.ui
data/ui/contacts-list-pane.ui
data/ui/contacts-window.ui
src/contacts-accounts-list.vala
diff --git a/src/contacts-contact-editor.vala b/src/contacts-contact-editor.vala
index c0e9fd7..d380c2e 100644
--- a/src/contacts-contact-editor.vala
+++ b/src/contacts-contact-editor.vala
@@ -61,14 +61,23 @@ public class Contacts.AddressEditor : Box {
}
}
+[GtkTemplate (ui = "/org/gnome/contacts/ui/contacts-contact-editor.ui")]
public class Contacts.ContactEditor : Grid {
- Contact contact;
+ private Contact contact;
- Grid container_grid;
- weak Widget focus_widget;
+ private Grid container_grid;
+ private weak Widget focus_widget;
+ [GtkChild]
+ private ScrolledWindow main_sw;
+
+ [GtkChild]
+ private MenuButton add_detail_button;
+
+ [GtkChild]
public Button linked_button;
+ [GtkChild]
public Button remove_button;
public struct PropertyData {
@@ -751,70 +760,32 @@ public class Contacts.ContactEditor : Grid {
}
public ContactEditor (SimpleActionGroup editor_actions) {
- set_orientation (Orientation.VERTICAL);
-
- var main_sw = new ScrolledWindow (null, null);
- add (main_sw);
-
- main_sw.set_shadow_type (ShadowType.NONE);
- main_sw.set_hexpand (true);
- main_sw.set_vexpand (true);
- main_sw.set_policy (PolicyType.NEVER, PolicyType.AUTOMATIC);
-
var hcenter = new Center ();
hcenter.max_width = 600;
hcenter.xalign = 0.0;
- container_grid = new Grid ();
- container_grid.set_row_spacing (12);
- container_grid.set_column_spacing (12);
- container_grid.set_vexpand (true);
- container_grid.set_hexpand (true);
- container_grid.margin = 36;
- container_grid.set_margin_bottom (24);
-
- hcenter.add (container_grid);
- main_sw.add (hcenter);
- container_grid.set_focus_vadjustment (main_sw.get_vadjustment ());
+ this.container_grid = new Grid ();
+ this.container_grid.set_row_spacing (12);
+ this.container_grid.set_column_spacing (12);
+ this.container_grid.set_vexpand (true);
+ this.container_grid.set_hexpand (true);
+ this.container_grid.margin = 36;
+ this.container_grid.set_margin_bottom (24);
- main_sw.get_child ().get_style_context ().add_class ("contacts-main-view");
- main_sw.get_child ().get_style_context ().add_class ("view");
+ hcenter.add (this.container_grid);
+ this.main_sw.add (hcenter);
+ this.container_grid.set_focus_vadjustment (this.main_sw.get_vadjustment ());
- var edit_toolbar = new ActionBar ();
+ this.main_sw.get_child ().get_style_context ().add_class ("contacts-main-view");
+ this.main_sw.get_child ().get_style_context ().add_class ("view");
- var builder = load_ui ("app-menu.ui");
- var gmenu = builder.get_object ("edit-contact") as MenuModel;
+ this.main_sw.show_all ();
- var add_detail_button = new Gtk.MenuButton ();
- add_detail_button.use_popover = true;
- add_detail_button.set_menu_model (gmenu);
- add_detail_button.set_direction (ArrowType.UP);
- add_detail_button.get_popover ().insert_action_group ("edit", editor_actions);
-
- var box = new Box (Orientation.HORIZONTAL, 6);
- box.add (new Label (_("New Detail")));
- box.add (new Image.from_icon_name ("go-down-symbolic", IconSize.BUTTON));
- add_detail_button.add (box);
-
- edit_toolbar.pack_start (add_detail_button);
-
- linked_button = new Button.with_label (_("Linked Accounts"));
- edit_toolbar.pack_start (linked_button);
-
- remove_button = new Button.with_label (_("Remove Contact"));
- remove_button.get_style_context ().add_class ("destructive-action");
- edit_toolbar.pack_end (remove_button);
-
- edit_toolbar.show_all ();
- add (edit_toolbar);
-
- container_grid.show_all ();
- main_sw.show ();
- show_all ();
+ this.add_detail_button.get_popover ().insert_action_group ("edit", editor_actions);
- writable_personas = new HashMap<string, HashMap<string, Field?> > ();
+ this.writable_personas = new HashMap<string, HashMap<string, Field?>> ();
- container_grid.size_allocate.connect_after (size_allocate_cb);
+ this.container_grid.size_allocate.connect_after (size_allocate_cb);
}
public void edit (Contact c) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]