gappinfo: Allow giving no GAppInfo for getting startup notify id

On Wayland the activation token returned by
`g_app_launch_context_get_startup_notify_id()` doesn't depend on the
`GAppInfo`. The token is only used to hand over focus to the
application that is launched. In some cases it's not even possible to know
what application will actually be used to open the files. For example
when using portals within a sandbox. Therefore, allow providing no
`GAppInfo`.

This also makes clear in the docs that the `files` argument can be `NULL`.
This commit is contained in:
Julian Sparber 2024-07-22 14:24:22 +02:00
parent 6ee0389f68
commit 6210708f05

View File

@ -1782,8 +1782,8 @@ g_app_launch_context_get_display (GAppLaunchContext *context,
/** /**
* g_app_launch_context_get_startup_notify_id: * g_app_launch_context_get_startup_notify_id:
* @context: the launch context * @context: the launch context
* @info: the app info * @info: (nullable): the app info
* @files: (element-type GFile): list of [iface@Gio.File] objects * @files: (nullable): (element-type GFile): a list of [iface@Gio.File] objects
* *
* Initiates startup notification for the application and returns the * Initiates startup notification for the application and returns the
* `XDG_ACTIVATION_TOKEN` or `DESKTOP_STARTUP_ID` for the launched operation, * `XDG_ACTIVATION_TOKEN` or `DESKTOP_STARTUP_ID` for the launched operation,
@ -1798,6 +1798,7 @@ g_app_launch_context_get_display (GAppLaunchContext *context,
* [freedesktop.org Startup Notification Protocol](http://standards.freedesktop.org/startup-notification-spec/startup-notification-latest.txt). * [freedesktop.org Startup Notification Protocol](http://standards.freedesktop.org/startup-notification-spec/startup-notification-latest.txt).
* *
* Support for the XDG Activation Protocol was added in GLib 2.76. * Support for the XDG Activation Protocol was added in GLib 2.76.
* Since GLib 2.82 @info and @files can be `NULL`, but if it's not supported the returned token may be `NULL`.
* *
* Returns: (nullable): a startup notification ID for the application, or `NULL` if * Returns: (nullable): a startup notification ID for the application, or `NULL` if
* not supported. * not supported.
@ -1810,7 +1811,7 @@ g_app_launch_context_get_startup_notify_id (GAppLaunchContext *context,
GAppLaunchContextClass *class; GAppLaunchContextClass *class;
g_return_val_if_fail (G_IS_APP_LAUNCH_CONTEXT (context), NULL); g_return_val_if_fail (G_IS_APP_LAUNCH_CONTEXT (context), NULL);
g_return_val_if_fail (G_IS_APP_INFO (info), NULL); g_return_val_if_fail (info == NULL || G_IS_APP_INFO (info), NULL);
class = G_APP_LAUNCH_CONTEXT_GET_CLASS (context); class = G_APP_LAUNCH_CONTEXT_GET_CLASS (context);