aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2013-03-30 19:25:21 +0100
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2013-03-30 19:25:21 +0100
commiteacbe640fa7ffb8a99a04ebf21f94982c3679a8c (patch)
tree4fa69148cfa06ee45d84728f2d2196e5be709e88
parent6a225f960257026db4c5d57211b4159127bfc3a0 (diff)
downloadayatana-indicator-sound-eacbe640fa7ffb8a99a04ebf21f94982c3679a8c.tar.gz
ayatana-indicator-sound-eacbe640fa7ffb8a99a04ebf21f94982c3679a8c.tar.bz2
ayatana-indicator-sound-eacbe640fa7ffb8a99a04ebf21f94982c3679a8c.zip
MenuItem: use GtkLaunchContext with proper event timeout to launch applications
Also discards non-activation events
-rw-r--r--src/Makefile.am1
-rw-r--r--src/metadata-menu-item.vala9
-rw-r--r--src/mpris2-controller.vala2
-rw-r--r--src/player-controller.vala7
-rw-r--r--src/sound-service.c2
-rw-r--r--src/transport-menu-item.vala5
6 files changed, 18 insertions, 8 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 5a36822..0a67a7c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -81,6 +81,7 @@ music_bridge_VALAFLAGS = \
--pkg config \
--pkg gio-2.0 \
--pkg gio-unix-2.0 \
+ --pkg gdk-3.0 \
--pkg gdk-pixbuf-2.0 \
--pkg libxml-2.0
diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala
index b2dd752..bcd4378 100644
--- a/src/metadata-menu-item.vala
+++ b/src/metadata-menu-item.vala
@@ -168,13 +168,16 @@ public class MetadataMenuitem : PlayerItem
public override void handle_event (string name,
Variant input_value,
uint timestamp)
- {
+ {
+ if (name != Dbusmenu.MENUITEM_EVENT_ACTIVATED)
+ return;
+
if(this.owner.current_state == PlayerController.state.OFFLINE)
{
- this.owner.instantiate();
+ this.owner.instantiate(timestamp);
}
else if(this.owner.current_state == PlayerController.state.CONNECTED){
- this.owner.mpris_bridge.expose();
+ this.owner.mpris_bridge.expose(timestamp);
}
}
diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala
index 2cc8d12..5015f80 100644
--- a/src/mpris2-controller.vala
+++ b/src/mpris2-controller.vala
@@ -208,7 +208,7 @@ public class Mpris2Controller : GLib.Object
return (this.player != null && this.mpris2_root != null);
}
- public void expose()
+ public void expose(uint timestamp)
{
if(this.connected() == true){
this.mpris2_root.Raise.begin();
diff --git a/src/player-controller.vala b/src/player-controller.vala
index fd66a8a..764efa5 100644
--- a/src/player-controller.vala
+++ b/src/player-controller.vala
@@ -98,11 +98,14 @@ public class PlayerController : GLib.Object
There is a need to wait before the application is on DBus before attempting to access its mpris address
Hence only when the it has registered with us via libindicate do we attempt to kick off mpris communication
*/
- public void instantiate()
+ public void instantiate(uint timestamp)
{
debug("instantiate in player controller for %s", this.app_info.get_name() );
+
try{
- this.app_info.launch(null, null);
+ var context = Gdk.Display.get_default().get_app_launch_context();
+ context.set_timestamp(timestamp);
+ this.app_info.launch(null, context);
this.update_state(state.INSTANTIATING);
}
catch(GLib.Error error){
diff --git a/src/sound-service.c b/src/sound-service.c
index 0170f81..66ef7b0 100644
--- a/src/sound-service.c
+++ b/src/sound-service.c
@@ -88,7 +88,7 @@ main (int argc, char ** argv)
{
gboolean greeter_mode;
- g_type_init();
+ gdk_init(&argc, &argv);
textdomain (GETTEXT_PACKAGE);
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
setlocale (LC_ALL, "");
diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala
index 4ec7dad..0af3118 100644
--- a/src/transport-menu-item.vala
+++ b/src/transport-menu-item.vala
@@ -70,6 +70,9 @@ public class TransportMenuitem : PlayerItem
Variant input_value,
uint timestamp)
{
+ if (name != Dbusmenu.MENUITEM_EVENT_ACTIVATED)
+ return;
+
Variant v = input_value;
if ( input_value.is_of_type (VariantType.VARIANT)){
v = input_value.get_variant();
@@ -82,7 +85,7 @@ public class TransportMenuitem : PlayerItem
}
else{
this.cached_action = (Transport.Action)input;
- this.owner.instantiate();
+ this.owner.instantiate(timestamp);
this.property_set_int (MENUITEM_PLAY_STATE, (int)Transport.State.LAUNCHING);
}
}