From d8ece9669c016a6a70d76376a30a8c5ff439b373 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Sun, 1 Oct 2017 19:58:06 +0200 Subject: [PATCH] share, utils: show notification when acting on received 'share' message --- meson.build | 2 +- src/mconnect/share.vala | 4 ++++ src/mconnect/utils.vala | 12 ++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 851dfb6..514e9e7 100644 --- a/meson.build +++ b/meson.build @@ -91,7 +91,7 @@ test_mconn_utils = executable('test-mconn-utils', test_mconn_utils_src, dependencies: [ glib_dep, gobject_dep, gio_dep, gio_unix_dep, - posix_dep, + posix_dep, libnotify_dep, ], install: false) test('mconn-utils', test_mconn_utils) diff --git a/src/mconnect/share.vala b/src/mconnect/share.vala index 13684c2..c3c1473 100644 --- a/src/mconnect/share.vala +++ b/src/mconnect/share.vala @@ -101,6 +101,8 @@ class ShareHandler : Object, PacketHandlerInterface { if (urls.length > 0) { var url = urls[0]; debug("got URL: %s, launching...", url); + Utils.show_own_notification("Launching shared URL", + dev.device_name); AppInfo.launch_default_for_uri(url, null); } } @@ -112,6 +114,8 @@ class ShareHandler : Object, PacketHandlerInterface { if (display != null) { var cb = Gtk.Clipboard.get_default(display); cb.set_text(text, -1); + Utils.show_own_notification("Text copied to clipboard", + dev.device_name); } } } \ No newline at end of file diff --git a/src/mconnect/utils.vala b/src/mconnect/utils.vala index 5c41557..69512b8 100644 --- a/src/mconnect/utils.vala +++ b/src/mconnect/utils.vala @@ -186,4 +186,16 @@ using Posix; return null; } } + + public void show_own_notification(string message, + string summary = "mconnect", + string icon = "dialog-information") { + try { + var notif = new Notify.Notification(summary, message, + "phone"); + notif.show(); + } catch (Error e) { + critical("failed to show notification: %s", e.message); + } + } } \ No newline at end of file