summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJonas Danielsson <jonas@threetimestwo.org>2014-12-16 05:29:15 -0500
committerJonas Danielsson <jonas@threetimestwo.org>2015-01-14 01:42:17 -0500
commit988a7ef95914ff8e7b341ac727890b4ac3c3cd9e (patch)
tree3f8896be96435f3c3068fbf6973cbc9ae189306d /src
parent8c638fee4af5f03cdee83e33dfb60a9b650ca981 (diff)
downloadgnome-contacts-988a7ef95914ff8e7b341ac727890b4ac3c3cd9e.tar.gz
contacts-utils: Add activate_action function
Add a function that activates an action on a given appid. https://bugzilla.gnome.org/show_bug.cgi?id=658553
Diffstat (limited to 'src')
-rw-r--r--src/contacts-utils.vala41
1 files changed, 41 insertions, 0 deletions
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<string, Variant> 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<File>());
+ var data = new HashTable<string, Variant>(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 {