diff --git a/src/contacts-utils.vala b/src/contacts-utils.vala index 1e5eef8..215f1ee 100644 --- a/src/contacts-utils.vala +++ b/src/contacts-utils.vala @@ -20,6 +20,9 @@ using Gtk; using Folks; using Gee; using TelepathyGLib; +using DBus; +using GLib; +using Gdk; namespace Contacts { private static bool is_set (string? str) { @@ -51,6 +54,44 @@ namespace Contacts { ListBoxRow? before_row) { row.set_header (new Separator (Orientation.HORIZONTAL)); } + + [DBus (name = "org.freedesktop.Application")] + interface FreedesktopApplication : Object { + [DBus (name = "ActivateAction")] + public abstract void ActivateAction (string action, + Variant[] parameter, + HashTable data) throws IOError; + } + + public void activate_action (string app_id, + string action, + Variant? parameter, + uint32 timestamp) { + FreedesktopApplication? con = null; + + try { + string object_path = "/" + app_id.replace(".", "/"); + Display display = Display.get_default (); + DesktopAppInfo info = new DesktopAppInfo (app_id + ".desktop"); + Gdk.AppLaunchContext context = display.get_app_launch_context (); + + con = Bus.get_proxy_sync (BusType.SESSION, app_id, object_path); + context.set_timestamp (timestamp); + + Variant[] param_array = {}; + if (parameter != null) { + param_array += parameter; + } + + var startup_id = context.get_startup_notify_id (info, + new GLib.List()); + var data = new HashTable(str_hash, str_equal); + data.insert ("desktop-startup-id", new Variant.string (startup_id)); + con.ActivateAction (action, param_array, data); + } catch (IOError e) { + debug ("Failed to activate action" + action); + } + } } public class Center : Bin {