}
+enum {
+ LAUNCH_FAILED,
+ LAUNCHED,
+ LAST_SIGNAL
+};
+
+guint signals[LAST_SIGNAL] = { 0 };
+
G_DEFINE_TYPE (GAppLaunchContext, g_app_launch_context, G_TYPE_OBJECT);
struct _GAppLaunchContextPrivate {
g_type_class_add_private (klass, sizeof (GAppLaunchContextPrivate));
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
g_app_launch_context_launch_failed (GAppLaunchContext *context,
const char *startup_notify_id)
{
- GAppLaunchContextClass *class;
-
g_return_if_fail (G_IS_APP_LAUNCH_CONTEXT (context));
g_return_if_fail (startup_notify_id != NULL);
- class = G_APP_LAUNCH_CONTEXT_GET_CLASS (context);
-
- if (class->launch_failed != NULL)
- class->launch_failed (context, startup_notify_id);
+ g_signal_emit (context, signals[LAUNCH_FAILED], 0, startup_notify_id);
}
GList *files);
void (* launch_failed) (GAppLaunchContext *context,
const char *startup_notify_id);
+ void (* launched) (GAppLaunchContext *context,
+ GAppInfo *info,
+ GVariant *platform_data);
/* Padding for future expansion */
void (*_g_reserved1) (void);
void (*_g_reserved2) (void);
void (*_g_reserved3) (void);
void (*_g_reserved4) (void);
- void (*_g_reserved5) (void);
};
GType g_app_launch_context_get_type (void) G_GNUC_CONST;
if (pid_callback != NULL)
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,
info,
pid,