gapplication.h 14 KB

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