You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

237 lines
12 KiB

  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, write to the
  17. * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  18. * Boston, MA 02111-1307, USA.
  19. *
  20. * Author: Alexander Larsson <alexl@redhat.com>
  21. */
  22. #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
  23. #error "Only <gio/gio.h> can be included directly."
  24. #endif
  25. #ifndef __G_APP_INFO_H__
  26. #define __G_APP_INFO_H__
  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. * GAppInfo:
  43. *
  44. * Information about an installed application and methods to launch
  45. * it (with file arguments).
  46. */
  47. /**
  48. * GAppInfoIface:
  49. * @g_iface: The parent interface.
  50. * @dup: Copies a #GAppInfo.
  51. * @equal: Checks two #GAppInfo<!-- -->s for equality.
  52. * @get_id: Gets a string identifier for a #GAppInfo.
  53. * @get_name: Gets the name of the application for a #GAppInfo.
  54. * @get_description: Gets a short description for the application described by the #GAppInfo.
  55. * @get_executable: Gets the executable name for the #GAppInfo.
  56. * @get_icon: Gets the #GIcon for the #GAppInfo.
  57. * @launch: Launches an application specified by the #GAppInfo.
  58. * @supports_uris: Indicates whether the application specified supports launching URIs.
  59. * @supports_files: Indicates whether the application specified accepts filename arguments.
  60. * @launch_uris: Launches an application with a list of URIs.
  61. * @should_show: Returns whether an application should be shown (e.g. when getting a list of installed applications).
  62. * <ulink url="http://standards.freedesktop.org/startup-notification-spec/startup-notification-latest.txt">
  63. * <citetitle>FreeDesktop.Org Startup Notification Specification</citetitle></ulink>.
  64. * @set_as_default_for_type: Sets an application as default for a given content type.
  65. * @set_as_default_for_extension: Sets an application as default for a given file extension.
  66. * @add_supports_type: Adds to the #GAppInfo information about supported file types.
  67. * @can_remove_supports_type: Checks for support for removing supported file types from a #GAppInfo.
  68. * @remove_supports_type: Removes a supported application type from a #GAppInfo.
  69. * @can_delete: Checks if a #GAppInfo can be deleted. Since 2.20
  70. * @do_delete: Deletes a #GAppInfo. Since 2.20
  71. * @get_commandline: Gets the commandline for the #GAppInfo. Since 2.20
  72. * @get_display_name: Gets the display name for the #GAppInfo. Since 2.24
  73. *
  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 *filenames,
  91. GAppLaunchContext *launch_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 *launch_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. };
  119. GType g_app_info_get_type (void) G_GNUC_CONST;
  120. GAppInfo * g_app_info_create_from_commandline (const char *commandline,
  121. const char *application_name,
  122. GAppInfoCreateFlags flags,
  123. GError **error);
  124. GAppInfo * g_app_info_dup (GAppInfo *appinfo);
  125. gboolean g_app_info_equal (GAppInfo *appinfo1,
  126. GAppInfo *appinfo2);
  127. const char *g_app_info_get_id (GAppInfo *appinfo);
  128. const char *g_app_info_get_name (GAppInfo *appinfo);
  129. const char *g_app_info_get_display_name (GAppInfo *appinfo);
  130. const char *g_app_info_get_description (GAppInfo *appinfo);
  131. const char *g_app_info_get_executable (GAppInfo *appinfo);
  132. const char *g_app_info_get_commandline (GAppInfo *appinfo);
  133. GIcon * g_app_info_get_icon (GAppInfo *appinfo);
  134. gboolean g_app_info_launch (GAppInfo *appinfo,
  135. GList *files,
  136. GAppLaunchContext *launch_context,
  137. GError **error);
  138. gboolean g_app_info_supports_uris (GAppInfo *appinfo);
  139. gboolean g_app_info_supports_files (GAppInfo *appinfo);
  140. gboolean g_app_info_launch_uris (GAppInfo *appinfo,
  141. GList *uris,
  142. GAppLaunchContext *launch_context,
  143. GError **error);
  144. gboolean g_app_info_should_show (GAppInfo *appinfo);
  145. gboolean g_app_info_set_as_default_for_type (GAppInfo *appinfo,
  146. const char *content_type,
  147. GError **error);
  148. gboolean g_app_info_set_as_default_for_extension (GAppInfo *appinfo,
  149. const char *extension,
  150. GError **error);
  151. gboolean g_app_info_add_supports_type (GAppInfo *appinfo,
  152. const char *content_type,
  153. GError **error);
  154. gboolean g_app_info_can_remove_supports_type (GAppInfo *appinfo);
  155. gboolean g_app_info_remove_supports_type (GAppInfo *appinfo,
  156. const char *content_type,
  157. GError **error);
  158. gboolean g_app_info_can_delete (GAppInfo *appinfo);
  159. gboolean g_app_info_delete (GAppInfo *appinfo);
  160. GList * g_app_info_get_all (void);
  161. GList * g_app_info_get_all_for_type (const char *content_type);
  162. void g_app_info_reset_type_associations (const char *content_type);
  163. GAppInfo *g_app_info_get_default_for_type (const char *content_type,
  164. gboolean must_support_uris);
  165. GAppInfo *g_app_info_get_default_for_uri_scheme (const char *uri_scheme);
  166. gboolean g_app_info_launch_default_for_uri (const char *uri,
  167. GAppLaunchContext *launch_context,
  168. GError **error);
  169. /**
  170. * GAppLaunchContext:
  171. *
  172. * Integrating the launch with the launching application. This is used to
  173. * handle for instance startup notification and launching the new application
  174. * on the same screen as the launching window.
  175. */
  176. struct _GAppLaunchContext
  177. {
  178. GObject parent_instance;
  179. /*< private >*/
  180. GAppLaunchContextPrivate *priv;
  181. };
  182. struct _GAppLaunchContextClass
  183. {
  184. GObjectClass parent_class;
  185. char * (* get_display) (GAppLaunchContext *context,
  186. GAppInfo *info,
  187. GList *files);
  188. char * (* get_startup_notify_id) (GAppLaunchContext *context,
  189. GAppInfo *info,
  190. GList *files);
  191. void (* launch_failed) (GAppLaunchContext *context,
  192. const char *startup_notify_id);
  193. /* Padding for future expansion */
  194. void (*_g_reserved1) (void);
  195. void (*_g_reserved2) (void);
  196. void (*_g_reserved3) (void);
  197. void (*_g_reserved4) (void);
  198. void (*_g_reserved5) (void);
  199. };
  200. GType g_app_launch_context_get_type (void) G_GNUC_CONST;
  201. GAppLaunchContext *g_app_launch_context_new (void);
  202. char * g_app_launch_context_get_display (GAppLaunchContext *context,
  203. GAppInfo *info,
  204. GList *files);
  205. char * g_app_launch_context_get_startup_notify_id (GAppLaunchContext *context,
  206. GAppInfo *info,
  207. GList *files);
  208. void g_app_launch_context_launch_failed (GAppLaunchContext *context,
  209. const char * startup_notify_id);
  210. G_END_DECLS
  211. #endif /* __G_APP_INFO_H__ */