| 1 | /* GIO - GLib Input, Output and Streaming Library |
| 2 | * |
| 3 | * Copyright (C) 2006-2007 Red Hat, Inc. |
| 4 | * |
| 5 | * SPDX-License-Identifier: LGPL-2.1-or-later |
| 6 | * |
| 7 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Lesser General Public |
| 9 | * License as published by the Free Software Foundation; either |
| 10 | * version 2.1 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This library is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * Lesser General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General |
| 18 | * Public License along with this library; if not, see <http://www.gnu.org/licenses/>. |
| 19 | * |
| 20 | * Author: Alexander Larsson <alexl@redhat.com> |
| 21 | */ |
| 22 | |
| 23 | #ifndef __G_APP_INFO_H__ |
| 24 | #define __G_APP_INFO_H__ |
| 25 | |
| 26 | #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) |
| 27 | #error "Only <gio/gio.h> can be included directly." |
| 28 | #endif |
| 29 | |
| 30 | #include <gio/giotypes.h> |
| 31 | |
| 32 | G_BEGIN_DECLS |
| 33 | |
| 34 | #define G_TYPE_APP_INFO (g_app_info_get_type ()) |
| 35 | #define G_APP_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_APP_INFO, GAppInfo)) |
| 36 | #define G_IS_APP_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_APP_INFO)) |
| 37 | #define G_APP_INFO_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_APP_INFO, GAppInfoIface)) |
| 38 | |
| 39 | #define G_TYPE_APP_LAUNCH_CONTEXT (g_app_launch_context_get_type ()) |
| 40 | #define G_APP_LAUNCH_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_APP_LAUNCH_CONTEXT, GAppLaunchContext)) |
| 41 | #define G_APP_LAUNCH_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_APP_LAUNCH_CONTEXT, GAppLaunchContextClass)) |
| 42 | #define G_IS_APP_LAUNCH_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_APP_LAUNCH_CONTEXT)) |
| 43 | #define G_IS_APP_LAUNCH_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_APP_LAUNCH_CONTEXT)) |
| 44 | #define G_APP_LAUNCH_CONTEXT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_APP_LAUNCH_CONTEXT, GAppLaunchContextClass)) |
| 45 | |
| 46 | typedef struct _GAppLaunchContextClass GAppLaunchContextClass; |
| 47 | typedef struct _GAppLaunchContextPrivate GAppLaunchContextPrivate; |
| 48 | |
| 49 | /** |
| 50 | * GAppInfoIface: |
| 51 | * @g_iface: The parent interface. |
| 52 | * @dup: Copies a [iface@Gio.AppInfo]. |
| 53 | * @equal: Checks two [iface@Gio.AppInfo]s for equality. |
| 54 | * @get_id: Gets a string identifier for a [iface@Gio.AppInfo]. |
| 55 | * @get_name: Gets the name of the application for a [iface@Gio.AppInfo]. |
| 56 | * @get_description: Gets a short description for the application described by |
| 57 | * the [iface@Gio.AppInfo]. |
| 58 | * @get_executable: Gets the executable name for the [iface@Gio.AppInfo]. |
| 59 | * @get_icon: Gets the [iface@Gio.Icon] for the [iface@Gio.AppInfo]. |
| 60 | * @launch: Launches an application specified by the [iface@Gio.AppInfo]. |
| 61 | * @supports_uris: Indicates whether the application specified supports |
| 62 | * launching URIs. |
| 63 | * @supports_files: Indicates whether the application specified accepts |
| 64 | * filename arguments. |
| 65 | * @launch_uris: Launches an application with a list of URIs. |
| 66 | * @should_show: Returns whether an application should be shown (e.g. when |
| 67 | * getting a list of installed applications). |
| 68 | * [FreeDesktop.Org Startup Notification Specification](http://standards.freedesktop.org/startup-notification-spec/startup-notification-latest.txt). |
| 69 | * @set_as_default_for_type: Sets an application as default for a given content |
| 70 | * type. |
| 71 | * @set_as_default_for_extension: Sets an application as default for a given |
| 72 | * file extension. |
| 73 | * @add_supports_type: Adds to the [iface@Gio.AppInfo] information about |
| 74 | * supported file types. |
| 75 | * @can_remove_supports_type: Checks for support for removing supported file |
| 76 | * types from a [iface@Gio.AppInfo]. |
| 77 | * @remove_supports_type: Removes a supported application type from a |
| 78 | * [iface@Gio.AppInfo]. |
| 79 | * @can_delete: Checks if a [iface@Gio.AppInfo] can be deleted. (Since 2.20) |
| 80 | * @do_delete: Deletes a [iface@Gio.AppInfo]. (Since 2.20) |
| 81 | * @get_commandline: Gets the commandline for the [iface@Gio.AppInfo]. |
| 82 | * (Since 2.20) |
| 83 | * @get_display_name: Gets the display name for the [iface@Gio.AppInfo]. |
| 84 | * (Since 2.24) |
| 85 | * @set_as_last_used_for_type: Sets the application as the last used. See |
| 86 | * [method@Gio.AppInfo.set_as_last_used_for_type]. |
| 87 | * @get_supported_types: Retrieves the list of content types that @app_info |
| 88 | * claims to support. |
| 89 | * @launch_uris_async: Asynchronously launches an application with a list of |
| 90 | * URIs. (Since: 2.60) |
| 91 | * @launch_uris_finish: Finishes an operation started with @launch_uris_async. |
| 92 | * (Since: 2.60) |
| 93 | |
| 94 | * Application Information interface, for operating system portability. |
| 95 | */ |
| 96 | typedef struct _GAppInfoIface GAppInfoIface; |
| 97 | |
| 98 | struct _GAppInfoIface |
| 99 | { |
| 100 | GTypeInterface g_iface; |
| 101 | |
| 102 | /* Virtual Table */ |
| 103 | |
| 104 | GAppInfo * (* dup) (GAppInfo *appinfo); |
| 105 | gboolean (* equal) (GAppInfo *appinfo1, |
| 106 | GAppInfo *appinfo2); |
| 107 | const char * (* get_id) (GAppInfo *appinfo); |
| 108 | const char * (* get_name) (GAppInfo *appinfo); |
| 109 | const char * (* get_description) (GAppInfo *appinfo); |
| 110 | const char * (* get_executable) (GAppInfo *appinfo); |
| 111 | GIcon * (* get_icon) (GAppInfo *appinfo); |
| 112 | gboolean (* launch) (GAppInfo *appinfo, |
| 113 | GList *files, |
| 114 | GAppLaunchContext *context, |
| 115 | GError **error); |
| 116 | gboolean (* supports_uris) (GAppInfo *appinfo); |
| 117 | gboolean (* supports_files) (GAppInfo *appinfo); |
| 118 | gboolean (* launch_uris) (GAppInfo *appinfo, |
| 119 | GList *uris, |
| 120 | GAppLaunchContext *context, |
| 121 | GError **error); |
| 122 | gboolean (* should_show) (GAppInfo *appinfo); |
| 123 | |
| 124 | /* For changing associations */ |
| 125 | gboolean (* set_as_default_for_type) (GAppInfo *appinfo, |
| 126 | const char *content_type, |
| 127 | GError **error); |
| 128 | gboolean (* set_as_default_for_extension) (GAppInfo *appinfo, |
| 129 | const char *extension, |
| 130 | GError **error); |
| 131 | gboolean (* add_supports_type) (GAppInfo *appinfo, |
| 132 | const char *content_type, |
| 133 | GError **error); |
| 134 | gboolean (* can_remove_supports_type) (GAppInfo *appinfo); |
| 135 | gboolean (* remove_supports_type) (GAppInfo *appinfo, |
| 136 | const char *content_type, |
| 137 | GError **error); |
| 138 | gboolean (* can_delete) (GAppInfo *appinfo); |
| 139 | gboolean (* do_delete) (GAppInfo *appinfo); |
| 140 | const char * (* get_commandline) (GAppInfo *appinfo); |
| 141 | const char * (* get_display_name) (GAppInfo *appinfo); |
| 142 | gboolean (* set_as_last_used_for_type) (GAppInfo *appinfo, |
| 143 | const char *content_type, |
| 144 | GError **error); |
| 145 | const char ** (* get_supported_types) (GAppInfo *appinfo); |
| 146 | void (* launch_uris_async) (GAppInfo *appinfo, |
| 147 | GList *uris, |
| 148 | GAppLaunchContext *context, |
| 149 | GCancellable *cancellable, |
| 150 | GAsyncReadyCallback callback, |
| 151 | gpointer user_data); |
| 152 | gboolean (* launch_uris_finish) (GAppInfo *appinfo, |
| 153 | GAsyncResult *result, |
| 154 | GError **error); |
| 155 | }; |
| 156 | |
| 157 | GIO_AVAILABLE_IN_ALL |
| 158 | GType g_app_info_get_type (void) G_GNUC_CONST; |
| 159 | GIO_AVAILABLE_IN_ALL |
| 160 | GAppInfo * g_app_info_create_from_commandline (const char *commandline, |
| 161 | const char *application_name, |
| 162 | GAppInfoCreateFlags flags, |
| 163 | GError **error); |
| 164 | GIO_AVAILABLE_IN_ALL |
| 165 | GAppInfo * g_app_info_dup (GAppInfo *appinfo); |
| 166 | GIO_AVAILABLE_IN_ALL |
| 167 | gboolean g_app_info_equal (GAppInfo *appinfo1, |
| 168 | GAppInfo *appinfo2); |
| 169 | GIO_AVAILABLE_IN_ALL |
| 170 | const char *g_app_info_get_id (GAppInfo *appinfo); |
| 171 | GIO_AVAILABLE_IN_ALL |
| 172 | const char *g_app_info_get_name (GAppInfo *appinfo); |
| 173 | GIO_AVAILABLE_IN_ALL |
| 174 | const char *g_app_info_get_display_name (GAppInfo *appinfo); |
| 175 | GIO_AVAILABLE_IN_ALL |
| 176 | const char *g_app_info_get_description (GAppInfo *appinfo); |
| 177 | GIO_AVAILABLE_IN_ALL |
| 178 | const char *g_app_info_get_executable (GAppInfo *appinfo); |
| 179 | GIO_AVAILABLE_IN_ALL |
| 180 | const char *g_app_info_get_commandline (GAppInfo *appinfo); |
| 181 | GIO_AVAILABLE_IN_ALL |
| 182 | GIcon * g_app_info_get_icon (GAppInfo *appinfo); |
| 183 | GIO_AVAILABLE_IN_ALL |
| 184 | gboolean g_app_info_launch (GAppInfo *appinfo, |
| 185 | GList *files, |
| 186 | GAppLaunchContext *context, |
| 187 | GError **error); |
| 188 | GIO_AVAILABLE_IN_ALL |
| 189 | gboolean g_app_info_supports_uris (GAppInfo *appinfo); |
| 190 | GIO_AVAILABLE_IN_ALL |
| 191 | gboolean g_app_info_supports_files (GAppInfo *appinfo); |
| 192 | GIO_AVAILABLE_IN_ALL |
| 193 | gboolean g_app_info_launch_uris (GAppInfo *appinfo, |
| 194 | GList *uris, |
| 195 | GAppLaunchContext *context, |
| 196 | GError **error); |
| 197 | GIO_AVAILABLE_IN_2_60 |
| 198 | void g_app_info_launch_uris_async (GAppInfo *appinfo, |
| 199 | GList *uris, |
| 200 | GAppLaunchContext *context, |
| 201 | GCancellable *cancellable, |
| 202 | GAsyncReadyCallback callback, |
| 203 | gpointer user_data); |
| 204 | GIO_AVAILABLE_IN_2_60 |
| 205 | gboolean g_app_info_launch_uris_finish (GAppInfo *appinfo, |
| 206 | GAsyncResult *result, |
| 207 | GError **error); |
| 208 | |
| 209 | GIO_AVAILABLE_IN_ALL |
| 210 | gboolean g_app_info_should_show (GAppInfo *appinfo); |
| 211 | |
| 212 | GIO_AVAILABLE_IN_ALL |
| 213 | gboolean g_app_info_set_as_default_for_type (GAppInfo *appinfo, |
| 214 | const char *content_type, |
| 215 | GError **error); |
| 216 | GIO_AVAILABLE_IN_ALL |
| 217 | gboolean g_app_info_set_as_default_for_extension (GAppInfo *appinfo, |
| 218 | const char *extension, |
| 219 | GError **error); |
| 220 | GIO_AVAILABLE_IN_ALL |
| 221 | gboolean g_app_info_add_supports_type (GAppInfo *appinfo, |
| 222 | const char *content_type, |
| 223 | GError **error); |
| 224 | GIO_AVAILABLE_IN_ALL |
| 225 | gboolean g_app_info_can_remove_supports_type (GAppInfo *appinfo); |
| 226 | GIO_AVAILABLE_IN_ALL |
| 227 | gboolean g_app_info_remove_supports_type (GAppInfo *appinfo, |
| 228 | const char *content_type, |
| 229 | GError **error); |
| 230 | GIO_AVAILABLE_IN_2_34 |
| 231 | const char **g_app_info_get_supported_types (GAppInfo *appinfo); |
| 232 | |
| 233 | GIO_AVAILABLE_IN_ALL |
| 234 | gboolean g_app_info_can_delete (GAppInfo *appinfo); |
| 235 | GIO_AVAILABLE_IN_ALL |
| 236 | gboolean g_app_info_delete (GAppInfo *appinfo); |
| 237 | |
| 238 | GIO_AVAILABLE_IN_ALL |
| 239 | gboolean g_app_info_set_as_last_used_for_type (GAppInfo *appinfo, |
| 240 | const char *content_type, |
| 241 | GError **error); |
| 242 | |
| 243 | GIO_AVAILABLE_IN_ALL |
| 244 | GList * g_app_info_get_all (void); |
| 245 | GIO_AVAILABLE_IN_ALL |
| 246 | GList * g_app_info_get_all_for_type (const char *content_type); |
| 247 | GIO_AVAILABLE_IN_ALL |
| 248 | GList * g_app_info_get_recommended_for_type (const gchar *content_type); |
| 249 | GIO_AVAILABLE_IN_ALL |
| 250 | GList * g_app_info_get_fallback_for_type (const gchar *content_type); |
| 251 | |
| 252 | GIO_AVAILABLE_IN_ALL |
| 253 | void g_app_info_reset_type_associations (const char *content_type); |
| 254 | GIO_AVAILABLE_IN_ALL |
| 255 | GAppInfo *g_app_info_get_default_for_type (const char *content_type, |
| 256 | gboolean must_support_uris); |
| 257 | GIO_AVAILABLE_IN_2_74 |
| 258 | void g_app_info_get_default_for_type_async (const char *content_type, |
| 259 | gboolean must_support_uris, |
| 260 | GCancellable *cancellable, |
| 261 | GAsyncReadyCallback callback, |
| 262 | gpointer user_data); |
| 263 | GIO_AVAILABLE_IN_2_74 |
| 264 | GAppInfo *g_app_info_get_default_for_type_finish (GAsyncResult *result, |
| 265 | GError **error); |
| 266 | GIO_AVAILABLE_IN_ALL |
| 267 | GAppInfo *g_app_info_get_default_for_uri_scheme (const char *uri_scheme); |
| 268 | |
| 269 | GIO_AVAILABLE_IN_2_74 |
| 270 | void g_app_info_get_default_for_uri_scheme_async (const char *uri_scheme, |
| 271 | GCancellable *cancellable, |
| 272 | GAsyncReadyCallback callback, |
| 273 | gpointer user_data); |
| 274 | GIO_AVAILABLE_IN_2_74 |
| 275 | GAppInfo *g_app_info_get_default_for_uri_scheme_finish (GAsyncResult *result, |
| 276 | GError **error); |
| 277 | |
| 278 | GIO_AVAILABLE_IN_ALL |
| 279 | gboolean g_app_info_launch_default_for_uri (const char *uri, |
| 280 | GAppLaunchContext *context, |
| 281 | GError **error); |
| 282 | |
| 283 | GIO_AVAILABLE_IN_2_50 |
| 284 | void g_app_info_launch_default_for_uri_async (const char *uri, |
| 285 | GAppLaunchContext *context, |
| 286 | GCancellable *cancellable, |
| 287 | GAsyncReadyCallback callback, |
| 288 | gpointer user_data); |
| 289 | GIO_AVAILABLE_IN_2_50 |
| 290 | gboolean g_app_info_launch_default_for_uri_finish (GAsyncResult *result, |
| 291 | GError **error); |
| 292 | |
| 293 | |
| 294 | /** |
| 295 | * GAppLaunchContext: |
| 296 | * |
| 297 | * Integrating the launch with the launching application. This is used to |
| 298 | * handle for instance startup notification and launching the new application |
| 299 | * on the same screen as the launching window. |
| 300 | */ |
| 301 | struct _GAppLaunchContext |
| 302 | { |
| 303 | GObject parent_instance; |
| 304 | |
| 305 | /*< private >*/ |
| 306 | GAppLaunchContextPrivate *priv; |
| 307 | }; |
| 308 | |
| 309 | struct _GAppLaunchContextClass |
| 310 | { |
| 311 | GObjectClass parent_class; |
| 312 | |
| 313 | char * (* get_display) (GAppLaunchContext *context, |
| 314 | GAppInfo *info, |
| 315 | GList *files); |
| 316 | char * (* get_startup_notify_id) (GAppLaunchContext *context, |
| 317 | GAppInfo *info, |
| 318 | GList *files); |
| 319 | void (* launch_failed) (GAppLaunchContext *context, |
| 320 | const char *startup_notify_id); |
| 321 | void (* launched) (GAppLaunchContext *context, |
| 322 | GAppInfo *info, |
| 323 | GVariant *platform_data); |
| 324 | void (* launch_started) (GAppLaunchContext *context, |
| 325 | GAppInfo *info, |
| 326 | GVariant *platform_data); |
| 327 | |
| 328 | /* Padding for future expansion */ |
| 329 | void (*_g_reserved1) (void); |
| 330 | void (*_g_reserved2) (void); |
| 331 | void (*_g_reserved3) (void); |
| 332 | }; |
| 333 | |
| 334 | GIO_AVAILABLE_IN_ALL |
| 335 | GType g_app_launch_context_get_type (void) G_GNUC_CONST; |
| 336 | GIO_AVAILABLE_IN_ALL |
| 337 | GAppLaunchContext *g_app_launch_context_new (void); |
| 338 | |
| 339 | GIO_AVAILABLE_IN_2_32 |
| 340 | void g_app_launch_context_setenv (GAppLaunchContext *context, |
| 341 | const char *variable, |
| 342 | const char *value); |
| 343 | GIO_AVAILABLE_IN_2_32 |
| 344 | void g_app_launch_context_unsetenv (GAppLaunchContext *context, |
| 345 | const char *variable); |
| 346 | GIO_AVAILABLE_IN_2_32 |
| 347 | char ** g_app_launch_context_get_environment (GAppLaunchContext *context); |
| 348 | |
| 349 | GIO_AVAILABLE_IN_ALL |
| 350 | char * g_app_launch_context_get_display (GAppLaunchContext *context, |
| 351 | GAppInfo *info, |
| 352 | GList *files); |
| 353 | GIO_AVAILABLE_IN_ALL |
| 354 | char * g_app_launch_context_get_startup_notify_id (GAppLaunchContext *context, |
| 355 | GAppInfo *info, |
| 356 | GList *files); |
| 357 | GIO_AVAILABLE_IN_ALL |
| 358 | void g_app_launch_context_launch_failed (GAppLaunchContext *context, |
| 359 | const char * startup_notify_id); |
| 360 | |
| 361 | #define G_TYPE_APP_INFO_MONITOR (g_app_info_monitor_get_type ()) |
| 362 | #define G_APP_INFO_MONITOR(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ |
| 363 | G_TYPE_APP_INFO_MONITOR, GAppInfoMonitor)) |
| 364 | #define G_IS_APP_INFO_MONITOR(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ |
| 365 | G_TYPE_APP_INFO_MONITOR)) |
| 366 | |
| 367 | typedef struct _GAppInfoMonitor GAppInfoMonitor; |
| 368 | |
| 369 | GIO_AVAILABLE_IN_2_40 |
| 370 | GType g_app_info_monitor_get_type (void); |
| 371 | |
| 372 | GIO_AVAILABLE_IN_2_40 |
| 373 | GAppInfoMonitor * g_app_info_monitor_get (void); |
| 374 | |
| 375 | G_END_DECLS |
| 376 | |
| 377 | #endif /* __G_APP_INFO_H__ */ |
| 378 | |