[gnome-contacts] Add add detail menus for all personas that have a writable field
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] Add add detail menus for all personas that have a writable field
- Date: Fri, 26 Aug 2011 12:17:49 +0000 (UTC)
commit 8f11190d9d77004d1f8422ec58fae4ce5fb2b5e2
Author: Alexander Larsson <alexl redhat com>
Date: Fri Aug 26 14:15:31 2011 +0200
Add add detail menus for all personas that have a writable field
src/contacts-contact-pane.vala | 55 ++++++++++++++++++++++++----------------
src/contacts-contact.vala | 5 +++
2 files changed, 38 insertions(+), 22 deletions(-)
---
diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala
index 2f269ba..a53deb0 100644
--- a/src/contacts-contact-pane.vala
+++ b/src/contacts-contact-pane.vala
@@ -668,35 +668,46 @@ public class Contacts.ContactPane : EventBox {
}
}
- if (persona.store.is_writeable) {
+ if (Contact.persona_has_writable_property (persona, "email-addresses") ||
+ Contact.persona_has_writable_property (persona, "phone-numbers") ||
+ Contact.persona_has_writable_property (persona, "postal-addresses") ||
+ Contact.persona_has_writable_property (persona, "urls")) {
button_layout.add_label ("");
var menu_button = new MenuButton (_("Add detail"));
menu_button.set_hexpand (false);
menu_button.set_margin_top (12);
var menu = new Menu ();
- Utils.add_menu_item (menu, _("Email")).activate.connect ( () => {
- add_email_editor (email_layout,
- editing_emails, null);
- email_layout.grid.show_all ();
- });
- Utils.add_menu_item (menu, _("Phone number")).activate.connect ( () => {
- add_phone_editor (phone_layout,
- editing_phones, null);
- phone_layout.grid.show_all ();
- });
- Utils.add_menu_item (menu, _("Postal Address")).activate.connect ( () => {
- add_postal_editor (postal_layout,
- editing_postals,
- new PostalAddressFieldDetails(new PostalAddress (null, null, null, null, null, null, null, null, null), null));
- postal_layout.grid.show_all ();
- });
- Utils.add_menu_item (menu,_("Link")).activate.connect ( () => {
- add_url_editor (url_layout,
- editing_urls,
- null);
- url_layout.grid.show_all ();
+ if (Contact.persona_has_writable_property (persona, "email-addresses")) {
+ Utils.add_menu_item (menu, _("Email")).activate.connect ( () => {
+ add_email_editor (email_layout,
+ editing_emails, null);
+ email_layout.grid.show_all ();
+ });
+ }
+ if (Contact.persona_has_writable_property (persona, "phone-numbers")) {
+ Utils.add_menu_item (menu, _("Phone number")).activate.connect ( () => {
+ add_phone_editor (phone_layout,
+ editing_phones, null);
+ phone_layout.grid.show_all ();
});
+ }
+ if (Contact.persona_has_writable_property (persona, "postal-addresses")) {
+ Utils.add_menu_item (menu, _("Postal Address")).activate.connect ( () => {
+ add_postal_editor (postal_layout,
+ editing_postals,
+ new PostalAddressFieldDetails(new PostalAddress (null, null, null, null, null, null, null, null, null), null));
+ postal_layout.grid.show_all ();
+ });
+ }
+ if (Contact.persona_has_writable_property (persona, "urls")) {
+ Utils.add_menu_item (menu,_("Link")).activate.connect ( () => {
+ add_url_editor (url_layout,
+ editing_urls,
+ null);
+ url_layout.grid.show_all ();
+ });
+ }
menu_button.set_menu (menu);
diff --git a/src/contacts-contact.vala b/src/contacts-contact.vala
index 97812db..2980353 100644
--- a/src/contacts-contact.vala
+++ b/src/contacts-contact.vala
@@ -153,6 +153,11 @@ public class Contacts.Contact : GLib.Object {
}
public static bool persona_has_writable_property (Persona persona, string property) {
+ // TODO: This should check the writibility on the FakePersona store,
+ // but that is not availible in folks yet
+ if (persona is FakePersona)
+ return true;
+
foreach (unowned string p in persona.writeable_properties) {
if (p == property)
return true;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]