gappinfo.h 19 KB

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