gapplication.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. /*
  2. * Copyright © 2010 Codethink Limited
  3. *
  4. * SPDX-License-Identifier: LGPL-2.1-or-later
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General
  17. * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
  18. *
  19. * Authors: Ryan Lortie <desrt@desrt.ca>
  20. */
  21. #ifndef __G_APPLICATION_H__
  22. #define __G_APPLICATION_H__
  23. #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
  24. #error "Only <gio/gio.h> can be included directly."
  25. #endif
  26. #include <gio/giotypes.h>
  27. G_BEGIN_DECLS
  28. #define G_TYPE_APPLICATION (g_application_get_type ())
  29. #define G_APPLICATION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
  30. G_TYPE_APPLICATION, GApplication))
  31. #define G_APPLICATION_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \
  32. G_TYPE_APPLICATION, GApplicationClass))
  33. #define G_IS_APPLICATION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_APPLICATION))
  34. #define G_IS_APPLICATION_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_APPLICATION))
  35. #define G_APPLICATION_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \
  36. G_TYPE_APPLICATION, GApplicationClass))
  37. typedef struct _GApplicationPrivate GApplicationPrivate;
  38. typedef struct _GApplicationClass GApplicationClass;
  39. struct _GApplication
  40. {
  41. /*< private >*/
  42. GObject parent_instance;
  43. GApplicationPrivate *priv;
  44. };
  45. struct _GApplicationClass
  46. {
  47. /*< private >*/
  48. GObjectClass parent_class;
  49. /*< public >*/
  50. /* signals */
  51. void (* startup) (GApplication *application);
  52. void (* activate) (GApplication *application);
  53. void (* open) (GApplication *application,
  54. GFile **files,
  55. gint n_files,
  56. const gchar *hint);
  57. int (* command_line) (GApplication *application,
  58. GApplicationCommandLine *command_line);
  59. /* vfuncs */
  60. /**
  61. * GApplicationClass::local_command_line:
  62. * @application: a #GApplication
  63. * @arguments: (inout) (array zero-terminated=1): array of command line arguments
  64. * @exit_status: (out): exit status to fill after processing the command line.
  65. *
  66. * This virtual function is always invoked in the local instance. It
  67. * gets passed a pointer to a %NULL-terminated copy of @argv and is
  68. * expected to remove arguments that it handled (shifting up remaining
  69. * arguments).
  70. *
  71. * The last argument to local_command_line() is a pointer to the @status
  72. * variable which can used to set the exit status that is returned from
  73. * g_application_run().
  74. *
  75. * See g_application_run() for more details on #GApplication startup.
  76. *
  77. * Returns: %TRUE if the commandline has been completely handled
  78. */
  79. gboolean (* local_command_line) (GApplication *application,
  80. gchar ***arguments,
  81. int *exit_status);
  82. /* @platform_data comes from an external process and is untrusted. All value types
  83. * must be validated before being used. */
  84. void (* before_emit) (GApplication *application,
  85. GVariant *platform_data);
  86. /* Same as for @before_emit. */
  87. void (* after_emit) (GApplication *application,
  88. GVariant *platform_data);
  89. void (* add_platform_data) (GApplication *application,
  90. GVariantBuilder *builder);
  91. void (* quit_mainloop) (GApplication *application);
  92. void (* run_mainloop) (GApplication *application);
  93. void (* shutdown) (GApplication *application);
  94. gboolean (* dbus_register) (GApplication *application,
  95. GDBusConnection *connection,
  96. const gchar *object_path,
  97. GError **error);
  98. void (* dbus_unregister) (GApplication *application,
  99. GDBusConnection *connection,
  100. const gchar *object_path);
  101. gint (* handle_local_options)(GApplication *application,
  102. GVariantDict *options);
  103. gboolean (* name_lost) (GApplication *application);
  104. /*< private >*/
  105. gpointer padding[7];
  106. };
  107. GIO_AVAILABLE_IN_ALL
  108. GType g_application_get_type (void) G_GNUC_CONST;
  109. GIO_AVAILABLE_IN_ALL
  110. gboolean g_application_id_is_valid (const gchar *application_id);
  111. GIO_AVAILABLE_IN_ALL
  112. GApplication * g_application_new (const gchar *application_id,
  113. GApplicationFlags flags);
  114. GIO_AVAILABLE_IN_ALL
  115. const gchar * g_application_get_application_id (GApplication *application);
  116. GIO_AVAILABLE_IN_ALL
  117. void g_application_set_application_id (GApplication *application,
  118. const gchar *application_id);
  119. GIO_AVAILABLE_IN_2_80
  120. const gchar * g_application_get_version (GApplication *application);
  121. GIO_AVAILABLE_IN_2_80
  122. void g_application_set_version (GApplication *application,
  123. const gchar *version);
  124. GIO_AVAILABLE_IN_2_34
  125. GDBusConnection * g_application_get_dbus_connection (GApplication *application);
  126. GIO_AVAILABLE_IN_2_34
  127. const gchar * g_application_get_dbus_object_path (GApplication *application);
  128. GIO_AVAILABLE_IN_ALL
  129. guint g_application_get_inactivity_timeout (GApplication *application);
  130. GIO_AVAILABLE_IN_ALL
  131. void g_application_set_inactivity_timeout (GApplication *application,
  132. guint inactivity_timeout);
  133. GIO_AVAILABLE_IN_ALL
  134. GApplicationFlags g_application_get_flags (GApplication *application);
  135. GIO_AVAILABLE_IN_ALL
  136. void g_application_set_flags (GApplication *application,
  137. GApplicationFlags flags);
  138. GIO_AVAILABLE_IN_2_42
  139. const gchar * g_application_get_resource_base_path (GApplication *application);
  140. GIO_AVAILABLE_IN_2_42
  141. void g_application_set_resource_base_path (GApplication *application,
  142. const gchar *resource_path);
  143. GIO_DEPRECATED
  144. void g_application_set_action_group (GApplication *application,
  145. GActionGroup *action_group);
  146. GIO_AVAILABLE_IN_2_40
  147. void g_application_add_main_option_entries (GApplication *application,
  148. const GOptionEntry *entries);
  149. GIO_AVAILABLE_IN_2_42
  150. void g_application_add_main_option (GApplication *application,
  151. const char *long_name,
  152. char short_name,
  153. GOptionFlags flags,
  154. GOptionArg arg,
  155. const char *description,
  156. const char *arg_description);
  157. GIO_AVAILABLE_IN_2_40
  158. void g_application_add_option_group (GApplication *application,
  159. GOptionGroup *group);
  160. GIO_AVAILABLE_IN_2_56
  161. void g_application_set_option_context_parameter_string (GApplication *application,
  162. const gchar *parameter_string);
  163. GIO_AVAILABLE_IN_2_56
  164. void g_application_set_option_context_summary (GApplication *application,
  165. const gchar *summary);
  166. GIO_AVAILABLE_IN_2_56
  167. void g_application_set_option_context_description (GApplication *application,
  168. const gchar *description);
  169. GIO_AVAILABLE_IN_ALL
  170. gboolean g_application_get_is_registered (GApplication *application);
  171. GIO_AVAILABLE_IN_ALL
  172. gboolean g_application_get_is_remote (GApplication *application);
  173. GIO_AVAILABLE_IN_ALL
  174. gboolean g_application_register (GApplication *application,
  175. GCancellable *cancellable,
  176. GError **error);
  177. GIO_AVAILABLE_IN_ALL
  178. void g_application_hold (GApplication *application);
  179. GIO_AVAILABLE_IN_ALL
  180. void g_application_release (GApplication *application);
  181. GIO_AVAILABLE_IN_ALL
  182. void g_application_activate (GApplication *application);
  183. GIO_AVAILABLE_IN_ALL
  184. void g_application_open (GApplication *application,
  185. GFile **files,
  186. gint n_files,
  187. const gchar *hint);
  188. GIO_AVAILABLE_IN_ALL
  189. int g_application_run (GApplication *application,
  190. int argc,
  191. char **argv);
  192. GIO_AVAILABLE_IN_2_32
  193. void g_application_quit (GApplication *application);
  194. GIO_AVAILABLE_IN_2_32
  195. GApplication * g_application_get_default (void);
  196. GIO_AVAILABLE_IN_2_32
  197. void g_application_set_default (GApplication *application);
  198. GIO_AVAILABLE_IN_2_38
  199. void g_application_mark_busy (GApplication *application);
  200. GIO_AVAILABLE_IN_2_38
  201. void g_application_unmark_busy (GApplication *application);
  202. GIO_AVAILABLE_IN_2_44
  203. gboolean g_application_get_is_busy (GApplication *application);
  204. GIO_AVAILABLE_IN_2_40
  205. void g_application_send_notification (GApplication *application,
  206. const gchar *id,
  207. GNotification *notification);
  208. GIO_AVAILABLE_IN_2_40
  209. void g_application_withdraw_notification (GApplication *application,
  210. const gchar *id);
  211. GIO_AVAILABLE_IN_2_44
  212. void g_application_bind_busy_property (GApplication *application,
  213. gpointer object,
  214. const gchar *property);
  215. GIO_AVAILABLE_IN_2_44
  216. void g_application_unbind_busy_property (GApplication *application,
  217. gpointer object,
  218. const gchar *property);
  219. G_END_DECLS
  220. #endif /* __G_APPLICATION_H__ */