gappinfo: Add launch-started signal

Emit this when we're about to spawn or DBus activate a GAppInfo.  This
allows lauchers to keep the appinfo associated with a startup id.

We use a GVariant to allow for future exansion of the supplied data.
This commit is contained in:
Guido Günther
2021-09-29 08:19:09 +02:00
parent 5890b2bdea
commit 7665b748bb
4 changed files with 90 additions and 3 deletions

View File

@@ -728,6 +728,20 @@ test_show_in (void)
assert_shown ("invalid-desktop.desktop", FALSE, "../invalid/desktop:../invalid/desktop");
}
static void
on_launch_started (GAppLaunchContext *context, GAppInfo *info, GVariant *platform_data, gpointer data)
{
gboolean *invoked = data;
g_assert_true (G_IS_APP_LAUNCH_CONTEXT (context));
g_assert_true (G_IS_APP_INFO (info));
/* Our default context doesn't fill in any platform data */
g_assert_null (platform_data);
g_assert_false (*invoked);
*invoked = TRUE;
}
/* Test g_desktop_app_info_launch_uris_as_manager() and
* g_desktop_app_info_launch_uris_as_manager_with_fds()
*/
@@ -738,6 +752,8 @@ test_launch_as_manager (void)
GError *error = NULL;
gboolean retval;
const gchar *path;
gboolean invoked = FALSE;
GAppLaunchContext *context;
if (g_getenv ("DISPLAY") == NULL || g_getenv ("DISPLAY")[0] == '\0')
{
@@ -754,23 +770,31 @@ test_launch_as_manager (void)
return;
}
retval = g_desktop_app_info_launch_uris_as_manager (appinfo, NULL, NULL, 0,
context = g_app_launch_context_new ();
g_signal_connect (context, "launch-started",
G_CALLBACK (on_launch_started),
&invoked);
retval = g_desktop_app_info_launch_uris_as_manager (appinfo, NULL, context, 0,
NULL, NULL,
NULL, NULL,
&error);
g_assert_no_error (error);
g_assert_true (retval);
g_assert_true (invoked);
invoked = FALSE;
retval = g_desktop_app_info_launch_uris_as_manager_with_fds (appinfo,
NULL, NULL, 0,
NULL, context, 0,
NULL, NULL,
NULL, NULL,
-1, -1, -1,
&error);
g_assert_no_error (error);
g_assert_true (retval);
g_assert_true (invoked);
g_object_unref (appinfo);
g_assert_finalize_object (context);
}
int