gapplication.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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 <[email protected]>
  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. /**
  38. * GApplication:
  39. *
  40. * Since: 2.28
  41. */
  42. struct _GApplication
  43. {
  44. /*< private >*/
  45. GObject parent_instance;
  46. GApplicationPrivate *priv;
  47. };
  48. struct _GApplicationClass
  49. {
  50. /*< private >*/
  51. GObjectClass parent_class;
  52. /*< public >*/
  53. /* signals */
  54. void (* startup) (GApplication *application);
  55. void (* activate) (GApplication *application);
  56. void (* open) (GApplication *application,
  57. GFile **files,
  58. gint n_files,
  59. const gchar *hint);
  60. int (* command_line) (GApplication *application,
  61. GApplicationCommandLine *command_line);
  62. /* vfuncs */
  63. /**
  64. * GApplicationClass::local_command_line:
  65. * @application: a #GApplication
  66. * @arguments: (inout) (array zero-terminated=1): array of command line arguments
  67. * @exit_status: (out): exit status to fill after processing the command line.
  68. *
  69. * This virtual function is always invoked in the local instance. It
  70. * gets passed a pointer to a %NULL-terminated copy of @argv and is
  71. * expected to remove arguments that it handled (shifting up remaining
  72. * arguments).
  73. *
  74. * The last argument to local_command_line() is a pointer to the @status
  75. * variable which can used to set the exit status that is returned from
  76. * g_application_run().
  77. *
  78. * See g_application_run() for more details on #GApplication startup.
  79. *
  80. * Returns: %TRUE if the commandline has been completely handled
  81. */
  82. gboolean (* local_command_line) (GApplication *application,
  83. gchar ***arguments,
  84. int *exit_status);
  85. void (* before_emit) (GApplication *application,
  86. GVariant *platform_data);
  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. /*< private >*/
  104. gpointer padding[8];
  105. };
  106. GLIB_AVAILABLE_IN_ALL
  107. GType g_application_get_type (void) G_GNUC_CONST;
  108. GLIB_AVAILABLE_IN_ALL
  109. gboolean g_application_id_is_valid (const gchar *application_id);
  110. GLIB_AVAILABLE_IN_ALL
  111. GApplication * g_application_new (const gchar *application_id,
  112. GApplicationFlags flags);
  113. GLIB_AVAILABLE_IN_ALL
  114. const gchar * g_application_get_application_id (GApplication *application);
  115. GLIB_AVAILABLE_IN_ALL
  116. void g_application_set_application_id (GApplication *application,
  117. const gchar *application_id);
  118. GLIB_AVAILABLE_IN_2_34
  119. GDBusConnection * g_application_get_dbus_connection (GApplication *application);
  120. GLIB_AVAILABLE_IN_2_34
  121. const gchar * g_application_get_dbus_object_path (GApplication *application);
  122. GLIB_AVAILABLE_IN_ALL
  123. guint g_application_get_inactivity_timeout (GApplication *application);
  124. GLIB_AVAILABLE_IN_ALL
  125. void g_application_set_inactivity_timeout (GApplication *application,
  126. guint inactivity_timeout);
  127. GLIB_AVAILABLE_IN_ALL
  128. GApplicationFlags g_application_get_flags (GApplication *application);
  129. GLIB_AVAILABLE_IN_ALL
  130. void g_application_set_flags (GApplication *application,
  131. GApplicationFlags flags);
  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_40
  139. void g_application_add_option_group (GApplication *application,
  140. GOptionGroup *group);
  141. GLIB_AVAILABLE_IN_ALL
  142. gboolean g_application_get_is_registered (GApplication *application);
  143. GLIB_AVAILABLE_IN_ALL
  144. gboolean g_application_get_is_remote (GApplication *application);
  145. GLIB_AVAILABLE_IN_ALL
  146. gboolean g_application_register (GApplication *application,
  147. GCancellable *cancellable,
  148. GError **error);
  149. GLIB_AVAILABLE_IN_ALL
  150. void g_application_hold (GApplication *application);
  151. GLIB_AVAILABLE_IN_ALL
  152. void g_application_release (GApplication *application);
  153. GLIB_AVAILABLE_IN_ALL
  154. void g_application_activate (GApplication *application);
  155. GLIB_AVAILABLE_IN_ALL
  156. void g_application_open (GApplication *application,
  157. GFile **files,
  158. gint n_files,
  159. const gchar *hint);
  160. GLIB_AVAILABLE_IN_ALL
  161. int g_application_run (GApplication *application,
  162. int argc,
  163. char **argv);
  164. GLIB_AVAILABLE_IN_2_32
  165. void g_application_quit (GApplication *application);
  166. GLIB_AVAILABLE_IN_2_32
  167. GApplication * g_application_get_default (void);
  168. GLIB_AVAILABLE_IN_2_32
  169. void g_application_set_default (GApplication *application);
  170. GLIB_AVAILABLE_IN_2_38
  171. void g_application_mark_busy (GApplication *application);
  172. GLIB_AVAILABLE_IN_2_38
  173. void g_application_unmark_busy (GApplication *application);
  174. GLIB_AVAILABLE_IN_2_40
  175. void g_application_send_notification (GApplication *application,
  176. const gchar *id,
  177. GNotification *notification);
  178. GLIB_AVAILABLE_IN_2_40
  179. void g_application_withdraw_notification (GApplication *application,
  180. const gchar *id);
  181. G_END_DECLS
  182. #endif /* __G_APPLICATION_H__ */