gappinfo.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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 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 <[email protected]>
  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 #GAppInfo<!-- -->s 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. * <ulink url="http://standards.freedesktop.org/startup-notification-spec/startup-notification-latest.txt">
  61. * <citetitle>FreeDesktop.Org Startup Notification Specification</citetitle></ulink>.
  62. * @set_as_default_for_type: Sets an application as default for a given content type.
  63. * @set_as_default_for_extension: Sets an application as default for a given file extension.
  64. * @add_supports_type: Adds to the #GAppInfo information about supported file types.
  65. * @can_remove_supports_type: Checks for support for removing supported file types from a #GAppInfo.
  66. * @remove_supports_type: Removes a supported application type from a #GAppInfo.
  67. * @can_delete: Checks if a #GAppInfo can be deleted. Since 2.20
  68. * @do_delete: Deletes a #GAppInfo. Since 2.20
  69. * @get_commandline: Gets the commandline for the #GAppInfo. Since 2.20
  70. * @get_display_name: Gets the display name for the #GAppInfo. Since 2.24
  71. * @set_as_last_used_for_type: Sets the application as the last used. See g_app_info_set_as_last_used_for_type().
  72. *
  73. * Application Information interface, for operating system portability.
  74. */
  75. typedef struct _GAppInfoIface GAppInfoIface;
  76. struct _GAppInfoIface
  77. {
  78. GTypeInterface g_iface;
  79. /* Virtual Table */
  80. GAppInfo * (* dup) (GAppInfo *appinfo);
  81. gboolean (* equal) (GAppInfo *appinfo1,
  82. GAppInfo *appinfo2);
  83. const char * (* get_id) (GAppInfo *appinfo);
  84. const char * (* get_name) (GAppInfo *appinfo);
  85. const char * (* get_description) (GAppInfo *appinfo);
  86. const char * (* get_executable) (GAppInfo *appinfo);
  87. GIcon * (* get_icon) (GAppInfo *appinfo);
  88. gboolean (* launch) (GAppInfo *appinfo,
  89. GList *files,
  90. GAppLaunchContext *launch_context,
  91. GError **error);
  92. gboolean (* supports_uris) (GAppInfo *appinfo);
  93. gboolean (* supports_files) (GAppInfo *appinfo);
  94. gboolean (* launch_uris) (GAppInfo *appinfo,
  95. GList *uris,
  96. GAppLaunchContext *launch_context,
  97. GError **error);
  98. gboolean (* should_show) (GAppInfo *appinfo);
  99. /* For changing associations */
  100. gboolean (* set_as_default_for_type) (GAppInfo *appinfo,
  101. const char *content_type,
  102. GError **error);
  103. gboolean (* set_as_default_for_extension) (GAppInfo *appinfo,
  104. const char *extension,
  105. GError **error);
  106. gboolean (* add_supports_type) (GAppInfo *appinfo,
  107. const char *content_type,
  108. GError **error);
  109. gboolean (* can_remove_supports_type) (GAppInfo *appinfo);
  110. gboolean (* remove_supports_type) (GAppInfo *appinfo,
  111. const char *content_type,
  112. GError **error);
  113. gboolean (* can_delete) (GAppInfo *appinfo);
  114. gboolean (* do_delete) (GAppInfo *appinfo);
  115. const char * (* get_commandline) (GAppInfo *appinfo);
  116. const char * (* get_display_name) (GAppInfo *appinfo);
  117. gboolean (* set_as_last_used_for_type) (GAppInfo *appinfo,
  118. const char *content_type,
  119. GError **error);
  120. const char ** (* get_supported_types) (GAppInfo *appinfo);
  121. };
  122. GLIB_AVAILABLE_IN_ALL
  123. GType g_app_info_get_type (void) G_GNUC_CONST;
  124. GLIB_AVAILABLE_IN_ALL
  125. GAppInfo * g_app_info_create_from_commandline (const char *commandline,
  126. const char *application_name,
  127. GAppInfoCreateFlags flags,
  128. GError **error);
  129. GLIB_AVAILABLE_IN_ALL
  130. GAppInfo * g_app_info_dup (GAppInfo *appinfo);
  131. GLIB_AVAILABLE_IN_ALL
  132. gboolean g_app_info_equal (GAppInfo *appinfo1,
  133. GAppInfo *appinfo2);
  134. GLIB_AVAILABLE_IN_ALL
  135. const char *g_app_info_get_id (GAppInfo *appinfo);
  136. GLIB_AVAILABLE_IN_ALL
  137. const char *g_app_info_get_name (GAppInfo *appinfo);
  138. GLIB_AVAILABLE_IN_ALL
  139. const char *g_app_info_get_display_name (GAppInfo *appinfo);
  140. GLIB_AVAILABLE_IN_ALL
  141. const char *g_app_info_get_description (GAppInfo *appinfo);
  142. GLIB_AVAILABLE_IN_ALL
  143. const char *g_app_info_get_executable (GAppInfo *appinfo);
  144. GLIB_AVAILABLE_IN_ALL
  145. const char *g_app_info_get_commandline (GAppInfo *appinfo);
  146. GLIB_AVAILABLE_IN_ALL
  147. GIcon * g_app_info_get_icon (GAppInfo *appinfo);
  148. GLIB_AVAILABLE_IN_ALL
  149. gboolean g_app_info_launch (GAppInfo *appinfo,
  150. GList *files,
  151. GAppLaunchContext *launch_context,
  152. GError **error);
  153. GLIB_AVAILABLE_IN_ALL
  154. gboolean g_app_info_supports_uris (GAppInfo *appinfo);
  155. GLIB_AVAILABLE_IN_ALL
  156. gboolean g_app_info_supports_files (GAppInfo *appinfo);
  157. GLIB_AVAILABLE_IN_ALL
  158. gboolean g_app_info_launch_uris (GAppInfo *appinfo,
  159. GList *uris,
  160. GAppLaunchContext *launch_context,
  161. GError **error);
  162. GLIB_AVAILABLE_IN_ALL
  163. gboolean g_app_info_should_show (GAppInfo *appinfo);
  164. GLIB_AVAILABLE_IN_ALL
  165. gboolean g_app_info_set_as_default_for_type (GAppInfo *appinfo,
  166. const char *content_type,
  167. GError **error);
  168. GLIB_AVAILABLE_IN_ALL
  169. gboolean g_app_info_set_as_default_for_extension (GAppInfo *appinfo,
  170. const char *extension,
  171. GError **error);
  172. GLIB_AVAILABLE_IN_ALL
  173. gboolean g_app_info_add_supports_type (GAppInfo *appinfo,
  174. const char *content_type,
  175. GError **error);
  176. GLIB_AVAILABLE_IN_ALL
  177. gboolean g_app_info_can_remove_supports_type (GAppInfo *appinfo);
  178. GLIB_AVAILABLE_IN_ALL
  179. gboolean g_app_info_remove_supports_type (GAppInfo *appinfo,
  180. const char *content_type,
  181. GError **error);
  182. GLIB_AVAILABLE_IN_2_34
  183. const char **g_app_info_get_supported_types (GAppInfo *appinfo);
  184. GLIB_AVAILABLE_IN_ALL
  185. gboolean g_app_info_can_delete (GAppInfo *appinfo);
  186. GLIB_AVAILABLE_IN_ALL
  187. gboolean g_app_info_delete (GAppInfo *appinfo);
  188. GLIB_AVAILABLE_IN_ALL
  189. gboolean g_app_info_set_as_last_used_for_type (GAppInfo *appinfo,
  190. const char *content_type,
  191. GError **error);
  192. GLIB_AVAILABLE_IN_ALL
  193. GList * g_app_info_get_all (void);
  194. GLIB_AVAILABLE_IN_ALL
  195. GList * g_app_info_get_all_for_type (const char *content_type);
  196. GLIB_AVAILABLE_IN_ALL
  197. GList * g_app_info_get_recommended_for_type (const gchar *content_type);
  198. GLIB_AVAILABLE_IN_ALL
  199. GList * g_app_info_get_fallback_for_type (const gchar *content_type);
  200. GLIB_AVAILABLE_IN_ALL
  201. void g_app_info_reset_type_associations (const char *content_type);
  202. GLIB_AVAILABLE_IN_ALL
  203. GAppInfo *g_app_info_get_default_for_type (const char *content_type,
  204. gboolean must_support_uris);
  205. GLIB_AVAILABLE_IN_ALL
  206. GAppInfo *g_app_info_get_default_for_uri_scheme (const char *uri_scheme);
  207. GLIB_AVAILABLE_IN_ALL
  208. gboolean g_app_info_launch_default_for_uri (const char *uri,
  209. GAppLaunchContext *launch_context,
  210. GError **error);
  211. /**
  212. * GAppLaunchContext:
  213. *
  214. * Integrating the launch with the launching application. This is used to
  215. * handle for instance startup notification and launching the new application
  216. * on the same screen as the launching window.
  217. */
  218. struct _GAppLaunchContext
  219. {
  220. GObject parent_instance;
  221. /*< private >*/
  222. GAppLaunchContextPrivate *priv;
  223. };
  224. struct _GAppLaunchContextClass
  225. {
  226. GObjectClass parent_class;
  227. char * (* get_display) (GAppLaunchContext *context,
  228. GAppInfo *info,
  229. GList *files);
  230. char * (* get_startup_notify_id) (GAppLaunchContext *context,
  231. GAppInfo *info,
  232. GList *files);
  233. void (* launch_failed) (GAppLaunchContext *context,
  234. const char *startup_notify_id);
  235. void (* launched) (GAppLaunchContext *context,
  236. GAppInfo *info,
  237. GVariant *platform_data);
  238. /* Padding for future expansion */
  239. void (*_g_reserved1) (void);
  240. void (*_g_reserved2) (void);
  241. void (*_g_reserved3) (void);
  242. void (*_g_reserved4) (void);
  243. };
  244. GLIB_AVAILABLE_IN_ALL
  245. GType g_app_launch_context_get_type (void) G_GNUC_CONST;
  246. GLIB_AVAILABLE_IN_ALL
  247. GAppLaunchContext *g_app_launch_context_new (void);
  248. GLIB_AVAILABLE_IN_2_32
  249. void g_app_launch_context_setenv (GAppLaunchContext *context,
  250. const char *variable,
  251. const char *value);
  252. GLIB_AVAILABLE_IN_2_32
  253. void g_app_launch_context_unsetenv (GAppLaunchContext *context,
  254. const char *variable);
  255. GLIB_AVAILABLE_IN_2_32
  256. char ** g_app_launch_context_get_environment (GAppLaunchContext *context);
  257. GLIB_AVAILABLE_IN_ALL
  258. char * g_app_launch_context_get_display (GAppLaunchContext *context,
  259. GAppInfo *info,
  260. GList *files);
  261. GLIB_AVAILABLE_IN_ALL
  262. char * g_app_launch_context_get_startup_notify_id (GAppLaunchContext *context,
  263. GAppInfo *info,
  264. GList *files);
  265. GLIB_AVAILABLE_IN_ALL
  266. void g_app_launch_context_launch_failed (GAppLaunchContext *context,
  267. const char * startup_notify_id);
  268. #define G_TYPE_APP_INFO_MONITOR (g_app_info_monitor_get_type ())
  269. #define G_APP_INFO_MONITOR(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
  270. G_TYPE_APP_INFO_MONITOR, GAppInfoMonitor))
  271. #define G_IS_APP_INFO_MONITOR(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
  272. G_TYPE_APP_INFO_MONITOR))
  273. typedef struct _GAppInfoMonitor GAppInfoMonitor;
  274. GLIB_AVAILABLE_IN_2_40
  275. GType g_app_info_monitor_get_type (void);
  276. GLIB_AVAILABLE_IN_2_40
  277. GAppInfoMonitor * g_app_info_monitor_get (void);
  278. G_END_DECLS
  279. #endif /* __G_APP_INFO_H__ */