summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNiels De Graef <nielsdegraef@gmail.com>2017-08-27 21:41:42 +0200
committerNiels De Graef <nielsdegraef@gmail.com>2017-08-27 21:41:42 +0200
commit0f8647fba93135dfc6dbcd7a30c66ec71f4b44f1 (patch)
tree27cbe9bcfea25c222684d37a867b0e12948c59cf /src
parent8f854e594c5cac6a4bb3e921791bc8a8133903b4 (diff)
downloadgnome-contacts-0f8647fba93135dfc6dbcd7a30c66ec71f4b44f1.tar.gz
Prevent more uses of App singleton for its Store
Diffstat (limited to 'src')
-rw-r--r--src/contacts-contact-pane.vala39
-rw-r--r--src/contacts-contact-sheet.vala10
2 files changed, 28 insertions, 21 deletions
diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala
index 2eb026c..eda3193 100644
--- a/src/contacts-contact-pane.vala
+++ b/src/contacts-contact-pane.vala
@@ -203,24 +203,7 @@ public class Contacts.ContactPane : Stack {
this.edit_contact_actions = new SimpleActionGroup ();
this.edit_contact_actions.add_action_entries (action_entries, this);
- // contact editor page
- sheet = new ContactSheet ();
- sheet.hexpand = true;
- sheet.vexpand = true;
- sheet.margin = 36;
- sheet.set_margin_bottom (24);
-
- var hcenter = new Center ();
- hcenter.max_width = 600;
- hcenter.xalign = 0.0;
- hcenter.show ();
- hcenter.add (sheet);
-
- this.contact_sheet_page.add (hcenter);
- sheet.set_focus_vadjustment (this.contact_sheet_page.get_vadjustment ());
-
- this.contact_sheet_page.get_child ().get_style_context ().add_class ("contacts-main-view");
- this.contact_sheet_page.get_child ().get_style_context ().add_class ("view");
+ create_contact_sheet ();
this.suggestion_grid = null;
@@ -253,6 +236,26 @@ public class Contacts.ContactPane : Stack {
BindingFlags.INVERT_BOOLEAN);
}
+ private void create_contact_sheet () {
+ this.sheet = new ContactSheet (this.store);
+ this.sheet.hexpand = true;
+ this.sheet.vexpand = true;
+ this.sheet.margin = 36;
+ this.sheet.set_margin_bottom (24);
+
+ var hcenter = new Center ();
+ hcenter.max_width = 600;
+ hcenter.xalign = 0.0;
+ hcenter.show ();
+ hcenter.add (this.sheet);
+
+ this.contact_sheet_page.add (hcenter);
+ this.sheet.set_focus_vadjustment (this.contact_sheet_page.get_vadjustment ());
+
+ this.contact_sheet_page.get_child ().get_style_context ().add_class ("contacts-main-view");
+ this.contact_sheet_page.get_child ().get_style_context ().add_class ("view");
+ }
+
void on_add_detail (GLib.SimpleAction action, GLib.Variant? parameter) {
var tok = action.name.split (".");
diff --git a/src/contacts-contact-sheet.vala b/src/contacts-contact-sheet.vala
index bbeb9ba..113e294 100644
--- a/src/contacts-contact-sheet.vala
+++ b/src/contacts-contact-sheet.vala
@@ -22,6 +22,8 @@ using Gee;
public class Contacts.ContactSheet : Grid {
+ private Store contacts_store;
+
Button add_row_with_button (ref int row, string label_value, string value) {
var type_label = new Label (label_value);
type_label.xalign = 1.0f;
@@ -88,7 +90,9 @@ public class Contacts.ContactSheet : Grid {
row++;
}
- public ContactSheet () {
+ public ContactSheet (Store contacts_store) {
+ this.contacts_store = contacts_store;
+
set_row_spacing (12);
set_column_spacing (16);
set_orientation (Orientation.VERTICAL);
@@ -152,10 +156,10 @@ public class Contacts.ContactSheet : Grid {
if (phone_details != null) {
var phones = Contact.sort_fields<PhoneFieldDetails>(phone_details.phone_numbers);
foreach (var phone in phones) {
- if (App.app.contacts_store.can_call) {
+ if (this.contacts_store.can_call) {
var button = add_row_with_button (ref i, TypeSet.phone.format_type (phone), phone.value);
button.clicked.connect (() => {
- Utils.start_call (phone.value, App.app.contacts_store.calling_accounts);
+ Utils.start_call (phone.value, this.contacts_store.calling_accounts);
});
} else {
add_row_with_label (ref i, TypeSet.phone.format_type (phone), phone.value);