File 0001-ContactSheet-Add-make-call-and-send-sms-button.patch of Package gnome-contacts-42.0-1.25

From: Julian Sparber <julian@sparber.net>
Date: Fri, 2 Aug 2019 18:32:31 +0200
Subject: [PATCH] ContactSheet: Add make call and send sms button

This adds a button to make calls via the default handler for tel:
and a button to send sms via the default handler for sms:

The buttons are hidden when no handler is available
---
 src/contacts-contact-sheet.vala | 16 ++++++++++++++++
 src/contacts-utils.vala         | 10 ++++++++++
 2 files changed, 26 insertions(+)

diff --git a/src/contacts-contact-sheet.vala b/src/contacts-contact-sheet.vala
index 3ddc9ef..c9b6180 100644
--- a/src/contacts-contact-sheet.vala
+++ b/src/contacts-contact-sheet.vala
@@ -300,6 +300,22 @@ public class Contacts.ContactSheet : Gtk.Grid {
           Utils.start_call (phone.value, this.store.caller_account);
         });
       }
+#else
+      // Show a call button when we have a hanlder for it
+      if (AppInfo.get_all_for_type ("x-scheme-handler/tel").length () > 0) {
+        var call_button = row.add_button ("call-start-symbolic");
+        call_button.tooltip_text = _("Start a call");
+        call_button.clicked.connect (() => {
+          Utils.start_call (phone.value);
+        });
+      }
+      if (AppInfo.get_all_for_type ("x-scheme-handler/sms").length () > 0) {
+        var sms_button = row.add_button ("mail-unread-symbolic");
+        sms_button.tooltip_text = _("Send a message");
+        sms_button.clicked.connect (() => {
+          Utils.send_sms (phone.value);
+        });
+      }
 #endif
 
       rows.append (row);
diff --git a/src/contacts-utils.vala b/src/contacts-utils.vala
index f85cb59..1a3de3d 100644
--- a/src/contacts-utils.vala
+++ b/src/contacts-utils.vala
@@ -67,6 +67,16 @@ namespace Contacts.Utils {
     var request = new TelepathyGLib.AccountChannelRequest(account, request_dict, int64.MAX);
     request.ensure_channel_async.begin ("org.freedesktop.Telepathy.Client.Empathy.Call", null);
   }
+#else
+  public void start_call (string number) {
+    var uri = "tel:" + Uri.escape_string (number, "+" , false);
+    Gtk.show_uri (null, uri, 0);
+  }
+
+  public void send_sms (string number) {
+    var uri = "sms:" + Uri.escape_string (number, "+" , false);
+    Gtk.show_uri (null, uri, 0);
+  }
 #endif
 
   public T? get_first<T> (Gee.Collection<T> collection) {
openSUSE Build Service is sponsored by