Convert Contacts.ContactEditor to GtkTemplate
This commit is contained in:
parent
1f864b0ee2
commit
9a55109d99
6 changed files with 148 additions and 103 deletions
|
@ -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 \
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
117
data/ui/contacts-contact-editor.ui
Normal file
117
data/ui/contacts-contact-editor.ui
Normal file
|
@ -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>
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
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);
|
||||
|
||||
hcenter.add (container_grid);
|
||||
main_sw.add (hcenter);
|
||||
container_grid.set_focus_vadjustment (main_sw.get_vadjustment ());
|
||||
hcenter.add (this.container_grid);
|
||||
this.main_sw.add (hcenter);
|
||||
this.container_grid.set_focus_vadjustment (this.main_sw.get_vadjustment ());
|
||||
|
||||
main_sw.get_child ().get_style_context ().add_class ("contacts-main-view");
|
||||
main_sw.get_child ().get_style_context ().add_class ("view");
|
||||
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 edit_toolbar = new ActionBar ();
|
||||
this.main_sw.show_all ();
|
||||
|
||||
var builder = load_ui ("app-menu.ui");
|
||||
var gmenu = builder.get_object ("edit-contact") as MenuModel;
|
||||
this.add_detail_button.get_popover ().insert_action_group ("edit", editor_actions);
|
||||
|
||||
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);
|
||||
this.writable_personas = new HashMap<string, HashMap<string, Field?>> ();
|
||||
|
||||
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 ();
|
||||
|
||||
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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue