mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-03 14:42:10 +01:00
GAppLaunchContext: make it possible ot get the effective startup id
gnome-session needs to know the startup id that was given to a started app; this was not available via GAppLaunchContext. This commit adds a ::launched signal to get this information. At the same time, turn the launch_failed vfunc into a signal as well. https://bugzilla.gnome.org/show_bug.cgi?id=688497
This commit is contained in:
parent
7b0c93554b
commit
bace1822d7
@ -782,6 +782,14 @@ g_app_info_delete (GAppInfo *appinfo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
enum {
|
||||||
|
LAUNCH_FAILED,
|
||||||
|
LAUNCHED,
|
||||||
|
LAST_SIGNAL
|
||||||
|
};
|
||||||
|
|
||||||
|
guint signals[LAST_SIGNAL] = { 0 };
|
||||||
|
|
||||||
G_DEFINE_TYPE (GAppLaunchContext, g_app_launch_context, G_TYPE_OBJECT);
|
G_DEFINE_TYPE (GAppLaunchContext, g_app_launch_context, G_TYPE_OBJECT);
|
||||||
|
|
||||||
struct _GAppLaunchContextPrivate {
|
struct _GAppLaunchContextPrivate {
|
||||||
@ -820,6 +828,46 @@ g_app_launch_context_class_init (GAppLaunchContextClass *klass)
|
|||||||
g_type_class_add_private (klass, sizeof (GAppLaunchContextPrivate));
|
g_type_class_add_private (klass, sizeof (GAppLaunchContextPrivate));
|
||||||
|
|
||||||
object_class->finalize = g_app_launch_context_finalize;
|
object_class->finalize = g_app_launch_context_finalize;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* GAppLaunchContext::launch-failed:
|
||||||
|
* @context: the object emitting the signal
|
||||||
|
* @startup_notify_id: the startup notification id for the failed launch
|
||||||
|
*
|
||||||
|
* The ::launch-failed signal is emitted when a #GAppInfo launch
|
||||||
|
* fails. The startup notification id is provided, so that the launcher
|
||||||
|
* can cancel the startup notification.
|
||||||
|
*
|
||||||
|
* Since: 2.36
|
||||||
|
*/
|
||||||
|
signals[LAUNCH_FAILED] = g_signal_new ("launch-failed",
|
||||||
|
G_OBJECT_CLASS_TYPE (object_class),
|
||||||
|
G_SIGNAL_RUN_LAST,
|
||||||
|
G_STRUCT_OFFSET (GAppLaunchContextClass, launch_failed),
|
||||||
|
NULL, NULL, NULL,
|
||||||
|
G_TYPE_NONE, 1, G_TYPE_STRING);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* GAppLaunchContext::launched:
|
||||||
|
* @context: the object emitting the signal
|
||||||
|
* @info: the #GAppInfo that was just launched
|
||||||
|
* @platform_data: additional platform-specific data for this launch
|
||||||
|
*
|
||||||
|
* The ::launched signal is emitted when a #GAppInfo is successfully
|
||||||
|
* launched. The @platform_data is an GVariant dictionary mapping
|
||||||
|
* strings to variants (ie a{sv}), which contains additional,
|
||||||
|
* platform-specific data about this launch. On UNIX, at least the
|
||||||
|
* "pid" and "startup-notification-id" keys will be present.
|
||||||
|
*
|
||||||
|
* Since: 2.36
|
||||||
|
*/
|
||||||
|
signals[LAUNCHED] = g_signal_new ("launched",
|
||||||
|
G_OBJECT_CLASS_TYPE (object_class),
|
||||||
|
G_SIGNAL_RUN_LAST,
|
||||||
|
G_STRUCT_OFFSET (GAppLaunchContextClass, launched),
|
||||||
|
NULL, NULL, NULL,
|
||||||
|
G_TYPE_NONE, 2,
|
||||||
|
G_TYPE_APP_INFO, G_TYPE_VARIANT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -974,13 +1022,8 @@ void
|
|||||||
g_app_launch_context_launch_failed (GAppLaunchContext *context,
|
g_app_launch_context_launch_failed (GAppLaunchContext *context,
|
||||||
const char *startup_notify_id)
|
const char *startup_notify_id)
|
||||||
{
|
{
|
||||||
GAppLaunchContextClass *class;
|
|
||||||
|
|
||||||
g_return_if_fail (G_IS_APP_LAUNCH_CONTEXT (context));
|
g_return_if_fail (G_IS_APP_LAUNCH_CONTEXT (context));
|
||||||
g_return_if_fail (startup_notify_id != NULL);
|
g_return_if_fail (startup_notify_id != NULL);
|
||||||
|
|
||||||
class = G_APP_LAUNCH_CONTEXT_GET_CLASS (context);
|
g_signal_emit (context, signals[LAUNCH_FAILED], 0, startup_notify_id);
|
||||||
|
|
||||||
if (class->launch_failed != NULL)
|
|
||||||
class->launch_failed (context, startup_notify_id);
|
|
||||||
}
|
}
|
||||||
|
@ -226,13 +226,15 @@ struct _GAppLaunchContextClass
|
|||||||
GList *files);
|
GList *files);
|
||||||
void (* launch_failed) (GAppLaunchContext *context,
|
void (* launch_failed) (GAppLaunchContext *context,
|
||||||
const char *startup_notify_id);
|
const char *startup_notify_id);
|
||||||
|
void (* launched) (GAppLaunchContext *context,
|
||||||
|
GAppInfo *info,
|
||||||
|
GVariant *platform_data);
|
||||||
|
|
||||||
/* Padding for future expansion */
|
/* Padding for future expansion */
|
||||||
void (*_g_reserved1) (void);
|
void (*_g_reserved1) (void);
|
||||||
void (*_g_reserved2) (void);
|
void (*_g_reserved2) (void);
|
||||||
void (*_g_reserved3) (void);
|
void (*_g_reserved3) (void);
|
||||||
void (*_g_reserved4) (void);
|
void (*_g_reserved4) (void);
|
||||||
void (*_g_reserved5) (void);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GType g_app_launch_context_get_type (void) G_GNUC_CONST;
|
GType g_app_launch_context_get_type (void) G_GNUC_CONST;
|
||||||
|
@ -1358,6 +1358,20 @@ _g_desktop_app_info_launch_uris_internal (GAppInfo *appinfo,
|
|||||||
if (pid_callback != NULL)
|
if (pid_callback != NULL)
|
||||||
pid_callback (info, pid, pid_callback_data);
|
pid_callback (info, pid, pid_callback_data);
|
||||||
|
|
||||||
|
if (launch_context != NULL)
|
||||||
|
{
|
||||||
|
GVariantBuilder builder;
|
||||||
|
GVariant *platform_data;
|
||||||
|
|
||||||
|
g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY);
|
||||||
|
g_variant_builder_add (&builder, "{sv}", "pid", g_variant_new_int32 (pid));
|
||||||
|
if (sn_id)
|
||||||
|
g_variant_builder_add (&builder, "{sv}", "startup-notification-id", g_variant_new_string (sn_id));
|
||||||
|
platform_data = g_variant_ref_sink (g_variant_builder_end (&builder));
|
||||||
|
g_signal_emit_by_name (launch_context, "launched", info, platform_data);
|
||||||
|
g_variant_unref (platform_data);
|
||||||
|
}
|
||||||
|
|
||||||
notify_desktop_launch (session_bus,
|
notify_desktop_launch (session_bus,
|
||||||
info,
|
info,
|
||||||
pid,
|
pid,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user