Browse Source

share, utils: show notification when acting on received 'share' message

bboozzoo/self-announce
Maciek Borzecki 7 years ago
parent
commit
d8ece9669c
3 changed files with 17 additions and 1 deletions
  1. +1
    -1
      meson.build
  2. +4
    -0
      src/mconnect/share.vala
  3. +12
    -0
      src/mconnect/utils.vala

+ 1
- 1
meson.build View File

@ -91,7 +91,7 @@ test_mconn_utils = executable('test-mconn-utils', test_mconn_utils_src,
dependencies: [ dependencies: [
glib_dep, gobject_dep, glib_dep, gobject_dep,
gio_dep, gio_unix_dep, gio_dep, gio_unix_dep,
posix_dep,
posix_dep, libnotify_dep,
], ],
install: false) install: false)
test('mconn-utils', test_mconn_utils) test('mconn-utils', test_mconn_utils)


+ 4
- 0
src/mconnect/share.vala View File

@ -101,6 +101,8 @@ class ShareHandler : Object, PacketHandlerInterface {
if (urls.length > 0) { if (urls.length > 0) {
var url = urls[0]; var url = urls[0];
debug("got URL: %s, launching...", url); debug("got URL: %s, launching...", url);
Utils.show_own_notification("Launching shared URL",
dev.device_name);
AppInfo.launch_default_for_uri(url, null); AppInfo.launch_default_for_uri(url, null);
} }
} }
@ -112,6 +114,8 @@ class ShareHandler : Object, PacketHandlerInterface {
if (display != null) { if (display != null) {
var cb = Gtk.Clipboard.get_default(display); var cb = Gtk.Clipboard.get_default(display);
cb.set_text(text, -1); cb.set_text(text, -1);
Utils.show_own_notification("Text copied to clipboard",
dev.device_name);
} }
} }
} }

+ 12
- 0
src/mconnect/utils.vala View File

@ -186,4 +186,16 @@ using Posix;
return null; 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);
}
}
} }

Loading…
Cancel
Save