[gnome-contacts/nielsdg/phones] wip: add phone number supoort




commit 1bf5ae93f41412caffeb224682daf41ad703eee2
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Wed Jun 29 12:21:02 2022 +0200

    wip: add phone number supoort

 src/contacts-contact-sheet.vala | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)
---
diff --git a/src/contacts-contact-sheet.vala b/src/contacts-contact-sheet.vala
index 5c6677ed..b9f2295e 100644
--- a/src/contacts-contact-sheet.vala
+++ b/src/contacts-contact-sheet.vala
@@ -280,25 +280,39 @@ public class Contacts.ContactSheet : Gtk.Grid {
     if (phone_details == null)
       return;
 
+    bool ephonenr_support = E.PhoneNumber.is_supported ();
+    debug ("Support for E.PhoneNumber: %s", ephonenr_support.to_string ());
+
     var phones = Utils.sort_fields<PhoneFieldDetails>(phone_details.phone_numbers);
     var rows = new GLib.List<Gtk.ListBoxRow> ();
     foreach (var phone in phones) {
       if (phone.value == "")
         continue;
 
+      string phonenr = phone.value;
+      E.PhoneNumber? ephone = null;
+      if (ephonenr_support) {
+        try {
+          ephone = E.PhoneNumber.from_string (phone.value, null);
+        } catch (Error e) {
+          debug ("Can't parse phone number: %s", e.message);
+        }
+      }
+
       var row = new ContactSheetRow (property,
-                                     phone.value,
+                                     phonenr,
                                      TypeSet.phone.format_type (phone));
 
-#if HAVE_TELEPATHY
-      if (this.store.caller_account != null) {
+      if (ephone != null) {
         var button = row.add_button ("call-start-symbolic");
-        button.tooltip_text = _("Start a call");
-        button.clicked.connect (() => {
-          Utils.start_call (phone.value, this.store.caller_account);
+        var tel_uri = ephone.to_string (E.PhoneNumberFormat.RFC3966);
+        button.tooltip_text = _("Call %s").printf (tel_uri[4:]);
+        button.clicked.connect ((b) => {
+          unowned var window = button.get_root () as Gtk.Window;
+          // FIXME: use show_uri_full so we can show errors
+          Gtk.show_uri (window, tel_uri, Gdk.CURRENT_TIME);
         });
       }
-#endif
 
       rows.append (row);
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]