gapplication.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. /*
  2. * Copyright © 2010 Codethink Limited
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU Lesser General Public License as published
  6. * by the Free Software Foundation; either version 2 of the licence or (at
  7. * 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. /*< private >*/
  99. gpointer padding[8];
  100. };
  101. GLIB_AVAILABLE_IN_ALL
  102. GType g_application_get_type (void) G_GNUC_CONST;
  103. GLIB_AVAILABLE_IN_ALL
  104. gboolean g_application_id_is_valid (const gchar *application_id);
  105. GLIB_AVAILABLE_IN_ALL
  106. GApplication * g_application_new (const gchar *application_id,
  107. GApplicationFlags flags);
  108. GLIB_AVAILABLE_IN_ALL
  109. const gchar * g_application_get_application_id (GApplication *application);
  110. GLIB_AVAILABLE_IN_ALL
  111. void g_application_set_application_id (GApplication *application,
  112. const gchar *application_id);
  113. GLIB_AVAILABLE_IN_2_34
  114. GDBusConnection * g_application_get_dbus_connection (GApplication *application);
  115. GLIB_AVAILABLE_IN_2_34
  116. const gchar * g_application_get_dbus_object_path (GApplication *application);
  117. GLIB_AVAILABLE_IN_ALL
  118. guint g_application_get_inactivity_timeout (GApplication *application);
  119. GLIB_AVAILABLE_IN_ALL
  120. void g_application_set_inactivity_timeout (GApplication *application,
  121. guint inactivity_timeout);
  122. GLIB_AVAILABLE_IN_ALL
  123. GApplicationFlags g_application_get_flags (GApplication *application);
  124. GLIB_AVAILABLE_IN_ALL
  125. void g_application_set_flags (GApplication *application,
  126. GApplicationFlags flags);
  127. GLIB_AVAILABLE_IN_2_42
  128. const gchar * g_application_get_resource_base_path (GApplication *application);
  129. GLIB_AVAILABLE_IN_2_42
  130. void g_application_set_resource_base_path (GApplication *application,
  131. const gchar *resource_path);
  132. GLIB_DEPRECATED
  133. void g_application_set_action_group (GApplication *application,
  134. GActionGroup *action_group);
  135. GLIB_AVAILABLE_IN_2_40
  136. void g_application_add_main_option_entries (GApplication *application,
  137. const GOptionEntry *entries);
  138. GLIB_AVAILABLE_IN_2_42
  139. void g_application_add_main_option (GApplication *application,
  140. const char *long_name,
  141. char short_name,
  142. GOptionFlags flags,
  143. GOptionArg arg,
  144. const char *description,
  145. const char *arg_description);
  146. GLIB_AVAILABLE_IN_2_40
  147. void g_application_add_option_group (GApplication *application,
  148. GOptionGroup *group);
  149. GLIB_AVAILABLE_IN_ALL
  150. gboolean g_application_get_is_registered (GApplication *application);
  151. GLIB_AVAILABLE_IN_ALL
  152. gboolean g_application_get_is_remote (GApplication *application);
  153. GLIB_AVAILABLE_IN_ALL
  154. gboolean g_application_register (GApplication *application,
  155. GCancellable *cancellable,
  156. GError **error);
  157. GLIB_AVAILABLE_IN_ALL
  158. void g_application_hold (GApplication *application);
  159. GLIB_AVAILABLE_IN_ALL
  160. void g_application_release (GApplication *application);
  161. GLIB_AVAILABLE_IN_ALL
  162. void g_application_activate (GApplication *application);
  163. GLIB_AVAILABLE_IN_ALL
  164. void g_application_open (GApplication *application,
  165. GFile **files,
  166. gint n_files,
  167. const gchar *hint);
  168. GLIB_AVAILABLE_IN_ALL
  169. int g_application_run (GApplication *application,
  170. int argc,
  171. char **argv);
  172. GLIB_AVAILABLE_IN_2_32
  173. void g_application_quit (GApplication *application);
  174. GLIB_AVAILABLE_IN_2_32
  175. GApplication * g_application_get_default (void);
  176. GLIB_AVAILABLE_IN_2_32
  177. void g_application_set_default (GApplication *application);
  178. GLIB_AVAILABLE_IN_2_38
  179. void g_application_mark_busy (GApplication *application);
  180. GLIB_AVAILABLE_IN_2_38
  181. void g_application_unmark_busy (GApplication *application);
  182. GLIB_AVAILABLE_IN_2_44
  183. gboolean g_application_get_is_busy (GApplication *application);
  184. GLIB_AVAILABLE_IN_2_40
  185. void g_application_send_notification (GApplication *application,
  186. const gchar *id,
  187. GNotification *notification);
  188. GLIB_AVAILABLE_IN_2_40
  189. void g_application_withdraw_notification (GApplication *application,
  190. const gchar *id);
  191. GLIB_AVAILABLE_IN_2_44
  192. void g_application_bind_busy_property (GApplication *application,
  193. gpointer object,
  194. const gchar *property);
  195. GLIB_AVAILABLE_IN_2_44
  196. void g_application_unbind_busy_property (GApplication *application,
  197. gpointer object,
  198. const gchar *property);
  199. G_END_DECLS
  200. #endif /* __G_APPLICATION_H__ */