From 23d93b9cf3dceac06f26bf741f9128d556244cbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 3 Apr 2013 17:40:56 +0200 Subject: AppSection: use the GAppLaunchContext with event timestamp when launching an app --- src/app-section.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/app-section.c') diff --git a/src/app-section.c b/src/app-section.c index 6aac52a..93f59a2 100644 --- a/src/app-section.c +++ b/src/app-section.c @@ -25,6 +25,7 @@ with this program. If not, see . #include "config.h" #endif +#include #include #include #include @@ -390,7 +391,7 @@ app_section_update_menu (AppSection *self) g_simple_action_group_clear (priv->static_shortcuts); is_running = priv->name_watch_id > 0; - launch = g_simple_action_new_stateful ("launch", NULL, g_variant_new_boolean (is_running)); + launch = g_simple_action_new_stateful ("launch", G_VARIANT_TYPE_UINT32, g_variant_new_boolean (is_running)); g_signal_connect (launch, "activate", G_CALLBACK (activate_cb), self); g_signal_connect (launch, "change-state", G_CALLBACK (launch_action_change_state), self); g_simple_action_group_insert (priv->static_shortcuts, G_ACTION (launch)); @@ -506,13 +507,19 @@ activate_cb (GSimpleAction *action, AppSection * mi = APP_SECTION (userdata); AppSectionPrivate * priv = mi->priv; GError *error = NULL; + GdkDisplay *display = gdk_display_get_default(); + GdkAppLaunchContext *launch_context = gdk_display_get_app_launch_context (display); - if (!g_app_info_launch (G_APP_INFO (priv->appinfo), NULL, NULL, &error)) { + gdk_app_launch_context_set_timestamp (launch_context, g_variant_get_uint32 (param)); + + if (!g_app_info_launch (G_APP_INFO (priv->appinfo), NULL, G_APP_LAUNCH_CONTEXT (launch_context), &error)) { g_warning("Unable to execute application for desktop file '%s': %s", g_desktop_app_info_get_filename (priv->appinfo), error->message); g_error_free (error); } + + g_object_unref (launch_context); } static void -- cgit v1.2.3 From 35bf2c9320e7c62a574e80b3ed463c110dce7060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20=27sil2100=27=20Zemczak?= Date: Mon, 22 Apr 2013 10:45:52 +0200 Subject: indicator_desktop_shortcuts_nick_exec() is deprecated, use indicator_desktop_shortcuts_nick_exec_with_context() with a NULL context instead - fixes the FTBFS --- src/app-section.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/app-section.c') diff --git a/src/app-section.c b/src/app-section.c index 93f59a2..474e700 100644 --- a/src/app-section.c +++ b/src/app-section.c @@ -303,7 +303,7 @@ nick_activate_cb (GSimpleAction *action, g_return_if_fail(priv->ids != NULL); - if (!indicator_desktop_shortcuts_nick_exec(priv->ids, nick)) { + if (!indicator_desktop_shortcuts_nick_exec_with_context(priv->ids, nick, NULL)) { g_warning("Unable to execute nick '%s' for desktop file '%s'", nick, g_desktop_app_info_get_filename (priv->appinfo)); } -- cgit v1.2.3 From 6a3dad7dbe2004c8b3c92f914b01e181b5adb646 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 22 Apr 2013 17:26:51 +0200 Subject: AppSection: use LaunchContext to exec shortcut nicks --- src/app-section.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'src/app-section.c') diff --git a/src/app-section.c b/src/app-section.c index 474e700..1106c62 100644 --- a/src/app-section.c +++ b/src/app-section.c @@ -291,6 +291,17 @@ app_section_finalize (GObject *object) G_OBJECT_CLASS (app_section_parent_class)->dispose (object); } +static GAppLaunchContext * +get_launch_context (guint32 timestamp) +{ + GdkDisplay *display = gdk_display_get_default(); + GdkAppLaunchContext *launch_context = gdk_display_get_app_launch_context (display); + + gdk_app_launch_context_set_timestamp (launch_context, timestamp); + + return G_APP_LAUNCH_CONTEXT (launch_context); +} + /* Respond to one of the shortcuts getting clicked on. */ static void nick_activate_cb (GSimpleAction *action, @@ -303,10 +314,14 @@ nick_activate_cb (GSimpleAction *action, g_return_if_fail(priv->ids != NULL); - if (!indicator_desktop_shortcuts_nick_exec_with_context(priv->ids, nick, NULL)) { + GAppLaunchContext *context = get_launch_context (g_variant_get_uint32 (param)); + + if (!indicator_desktop_shortcuts_nick_exec_with_context(priv->ids, nick, context)) { g_warning("Unable to execute nick '%s' for desktop file '%s'", nick, g_desktop_app_info_get_filename (priv->appinfo)); } + + g_object_unref (context); } static void @@ -416,7 +431,7 @@ app_section_update_menu (AppSection *self) name = indicator_desktop_shortcuts_nick_get_name(priv->ids, nicks[i]); - action = g_simple_action_new (nicks[i], NULL); + action = g_simple_action_new (nicks[i], G_VARIANT_TYPE_UINT32); g_signal_connect(action, "activate", G_CALLBACK (nick_activate_cb), self); g_simple_action_group_insert (priv->static_shortcuts, G_ACTION (action)); g_object_unref (action); @@ -507,12 +522,9 @@ activate_cb (GSimpleAction *action, AppSection * mi = APP_SECTION (userdata); AppSectionPrivate * priv = mi->priv; GError *error = NULL; - GdkDisplay *display = gdk_display_get_default(); - GdkAppLaunchContext *launch_context = gdk_display_get_app_launch_context (display); - - gdk_app_launch_context_set_timestamp (launch_context, g_variant_get_uint32 (param)); + GAppLaunchContext *launch_context = get_launch_context (g_variant_get_uint32 (param)); - if (!g_app_info_launch (G_APP_INFO (priv->appinfo), NULL, G_APP_LAUNCH_CONTEXT (launch_context), &error)) { + if (!g_app_info_launch (G_APP_INFO (priv->appinfo), NULL, launch_context, &error)) { g_warning("Unable to execute application for desktop file '%s': %s", g_desktop_app_info_get_filename (priv->appinfo), error->message); -- cgit v1.2.3