gappinfo.h 20 KB

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