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
32G_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
46typedef struct _GAppLaunchContextClass GAppLaunchContextClass;
47typedef 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 */
96typedef struct _GAppInfoIface GAppInfoIface;
97
98struct _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
157GIO_AVAILABLE_IN_ALL
158GType g_app_info_get_type (void) G_GNUC_CONST;
159GIO_AVAILABLE_IN_ALL
160GAppInfo * g_app_info_create_from_commandline (const char *commandline,
161 const char *application_name,
162 GAppInfoCreateFlags flags,
163 GError **error);
164GIO_AVAILABLE_IN_ALL
165GAppInfo * g_app_info_dup (GAppInfo *appinfo);
166GIO_AVAILABLE_IN_ALL
167gboolean g_app_info_equal (GAppInfo *appinfo1,
168 GAppInfo *appinfo2);
169GIO_AVAILABLE_IN_ALL
170const char *g_app_info_get_id (GAppInfo *appinfo);
171GIO_AVAILABLE_IN_ALL
172const char *g_app_info_get_name (GAppInfo *appinfo);
173GIO_AVAILABLE_IN_ALL
174const char *g_app_info_get_display_name (GAppInfo *appinfo);
175GIO_AVAILABLE_IN_ALL
176const char *g_app_info_get_description (GAppInfo *appinfo);
177GIO_AVAILABLE_IN_ALL
178const char *g_app_info_get_executable (GAppInfo *appinfo);
179GIO_AVAILABLE_IN_ALL
180const char *g_app_info_get_commandline (GAppInfo *appinfo);
181GIO_AVAILABLE_IN_ALL
182GIcon * g_app_info_get_icon (GAppInfo *appinfo);
183GIO_AVAILABLE_IN_ALL
184gboolean g_app_info_launch (GAppInfo *appinfo,
185 GList *files,
186 GAppLaunchContext *context,
187 GError **error);
188GIO_AVAILABLE_IN_ALL
189gboolean g_app_info_supports_uris (GAppInfo *appinfo);
190GIO_AVAILABLE_IN_ALL
191gboolean g_app_info_supports_files (GAppInfo *appinfo);
192GIO_AVAILABLE_IN_ALL
193gboolean g_app_info_launch_uris (GAppInfo *appinfo,
194 GList *uris,
195 GAppLaunchContext *context,
196 GError **error);
197GIO_AVAILABLE_IN_2_60
198void g_app_info_launch_uris_async (GAppInfo *appinfo,
199 GList *uris,
200 GAppLaunchContext *context,
201 GCancellable *cancellable,
202 GAsyncReadyCallback callback,
203 gpointer user_data);
204GIO_AVAILABLE_IN_2_60
205gboolean g_app_info_launch_uris_finish (GAppInfo *appinfo,
206 GAsyncResult *result,
207 GError **error);
208
209GIO_AVAILABLE_IN_ALL
210gboolean g_app_info_should_show (GAppInfo *appinfo);
211
212GIO_AVAILABLE_IN_ALL
213gboolean g_app_info_set_as_default_for_type (GAppInfo *appinfo,
214 const char *content_type,
215 GError **error);
216GIO_AVAILABLE_IN_ALL
217gboolean g_app_info_set_as_default_for_extension (GAppInfo *appinfo,
218 const char *extension,
219 GError **error);
220GIO_AVAILABLE_IN_ALL
221gboolean g_app_info_add_supports_type (GAppInfo *appinfo,
222 const char *content_type,
223 GError **error);
224GIO_AVAILABLE_IN_ALL
225gboolean g_app_info_can_remove_supports_type (GAppInfo *appinfo);
226GIO_AVAILABLE_IN_ALL
227gboolean g_app_info_remove_supports_type (GAppInfo *appinfo,
228 const char *content_type,
229 GError **error);
230GIO_AVAILABLE_IN_2_34
231const char **g_app_info_get_supported_types (GAppInfo *appinfo);
232
233GIO_AVAILABLE_IN_ALL
234gboolean g_app_info_can_delete (GAppInfo *appinfo);
235GIO_AVAILABLE_IN_ALL
236gboolean g_app_info_delete (GAppInfo *appinfo);
237
238GIO_AVAILABLE_IN_ALL
239gboolean g_app_info_set_as_last_used_for_type (GAppInfo *appinfo,
240 const char *content_type,
241 GError **error);
242
243GIO_AVAILABLE_IN_ALL
244GList * g_app_info_get_all (void);
245GIO_AVAILABLE_IN_ALL
246GList * g_app_info_get_all_for_type (const char *content_type);
247GIO_AVAILABLE_IN_ALL
248GList * g_app_info_get_recommended_for_type (const gchar *content_type);
249GIO_AVAILABLE_IN_ALL
250GList * g_app_info_get_fallback_for_type (const gchar *content_type);
251
252GIO_AVAILABLE_IN_ALL
253void g_app_info_reset_type_associations (const char *content_type);
254GIO_AVAILABLE_IN_ALL
255GAppInfo *g_app_info_get_default_for_type (const char *content_type,
256 gboolean must_support_uris);
257GIO_AVAILABLE_IN_2_74
258void 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);
263GIO_AVAILABLE_IN_2_74
264GAppInfo *g_app_info_get_default_for_type_finish (GAsyncResult *result,
265 GError **error);
266GIO_AVAILABLE_IN_ALL
267GAppInfo *g_app_info_get_default_for_uri_scheme (const char *uri_scheme);
268
269GIO_AVAILABLE_IN_2_74
270void g_app_info_get_default_for_uri_scheme_async (const char *uri_scheme,
271 GCancellable *cancellable,
272 GAsyncReadyCallback callback,
273 gpointer user_data);
274GIO_AVAILABLE_IN_2_74
275GAppInfo *g_app_info_get_default_for_uri_scheme_finish (GAsyncResult *result,
276 GError **error);
277
278GIO_AVAILABLE_IN_ALL
279gboolean g_app_info_launch_default_for_uri (const char *uri,
280 GAppLaunchContext *context,
281 GError **error);
282
283GIO_AVAILABLE_IN_2_50
284void g_app_info_launch_default_for_uri_async (const char *uri,
285 GAppLaunchContext *context,
286 GCancellable *cancellable,
287 GAsyncReadyCallback callback,
288 gpointer user_data);
289GIO_AVAILABLE_IN_2_50
290gboolean 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 */
301struct _GAppLaunchContext
302{
303 GObject parent_instance;
304
305 /*< private >*/
306 GAppLaunchContextPrivate *priv;
307};
308
309struct _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
334GIO_AVAILABLE_IN_ALL
335GType g_app_launch_context_get_type (void) G_GNUC_CONST;
336GIO_AVAILABLE_IN_ALL
337GAppLaunchContext *g_app_launch_context_new (void);
338
339GIO_AVAILABLE_IN_2_32
340void g_app_launch_context_setenv (GAppLaunchContext *context,
341 const char *variable,
342 const char *value);
343GIO_AVAILABLE_IN_2_32
344void g_app_launch_context_unsetenv (GAppLaunchContext *context,
345 const char *variable);
346GIO_AVAILABLE_IN_2_32
347char ** g_app_launch_context_get_environment (GAppLaunchContext *context);
348
349GIO_AVAILABLE_IN_ALL
350char * g_app_launch_context_get_display (GAppLaunchContext *context,
351 GAppInfo *info,
352 GList *files);
353GIO_AVAILABLE_IN_ALL
354char * g_app_launch_context_get_startup_notify_id (GAppLaunchContext *context,
355 GAppInfo *info,
356 GList *files);
357GIO_AVAILABLE_IN_ALL
358void 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
367typedef struct _GAppInfoMonitor GAppInfoMonitor;
368
369GIO_AVAILABLE_IN_2_40
370GType g_app_info_monitor_get_type (void);
371
372GIO_AVAILABLE_IN_2_40
373GAppInfoMonitor * g_app_info_monitor_get (void);
374
375G_END_DECLS
376
377#endif /* __G_APP_INFO_H__ */
378