2 * Copyright © 2010 Codethink Limited
4 * SPDX-License-Identifier: LGPL-2.1-or-later
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.
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.
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/>.
19 * Authors: Ryan Lortie <desrt@desrt.ca>
22 #ifndef __G_APPLICATION_H__
23 #define __G_APPLICATION_H__
25 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
26 #error "Only <gio/gio.h> can be included directly."
29 #include <gio/giotypes.h>
33 #define G_TYPE_APPLICATION (g_application_get_type ())
34 #define G_APPLICATION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
35 G_TYPE_APPLICATION, GApplication))
36 #define G_APPLICATION_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \
37 G_TYPE_APPLICATION, GApplicationClass))
38 #define G_IS_APPLICATION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_APPLICATION))
39 #define G_IS_APPLICATION_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_APPLICATION))
40 #define G_APPLICATION_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \
41 G_TYPE_APPLICATION, GApplicationClass))
43 typedef struct _GApplicationPrivate GApplicationPrivate;
44 typedef struct _GApplicationClass GApplicationClass;
49 GObject parent_instance;
51 GApplicationPrivate *priv;
54 struct _GApplicationClass
57 GObjectClass parent_class;
61 void (* startup) (GApplication *application);
63 void (* activate) (GApplication *application);
65 void (* open) (GApplication *application,
70 int (* command_line) (GApplication *application,
71 GApplicationCommandLine *command_line);
76 * GApplicationClass::local_command_line:
77 * @application: a #GApplication
78 * @arguments: (inout) (array zero-terminated=1): array of command line arguments
79 * @exit_status: (out): exit status to fill after processing the command line.
81 * This virtual function is always invoked in the local instance. It
82 * gets passed a pointer to a %NULL-terminated copy of @argv and is
83 * expected to remove arguments that it handled (shifting up remaining
86 * The last argument to local_command_line() is a pointer to the @status
87 * variable which can used to set the exit status that is returned from
88 * g_application_run().
90 * See g_application_run() for more details on #GApplication startup.
92 * Returns: %TRUE if the commandline has been completely handled
94 gboolean (* local_command_line) (GApplication *application,
98 /* @platform_data comes from an external process and is untrusted. All value types
99 * must be validated before being used. */
100 void (* before_emit) (GApplication *application,
101 GVariant *platform_data);
102 /* Same as for @before_emit. */
103 void (* after_emit) (GApplication *application,
104 GVariant *platform_data);
105 void (* add_platform_data) (GApplication *application,
106 GVariantBuilder *builder);
107 void (* quit_mainloop) (GApplication *application);
108 void (* run_mainloop) (GApplication *application);
109 void (* shutdown) (GApplication *application);
111 gboolean (* dbus_register) (GApplication *application,
112 GDBusConnection *connection,
113 const gchar *object_path,
115 void (* dbus_unregister) (GApplication *application,
116 GDBusConnection *connection,
117 const gchar *object_path);
118 gint (* handle_local_options)(GApplication *application,
119 GVariantDict *options);
120 gboolean (* name_lost) (GApplication *application);
127 GType g_application_get_type (void) G_GNUC_CONST;
130 gboolean g_application_id_is_valid (const gchar *application_id);
133 GApplication * g_application_new (const gchar *application_id,
134 GApplicationFlags flags);
137 const gchar * g_application_get_application_id (GApplication *application);
139 void g_application_set_application_id (GApplication *application,
140 const gchar *application_id);
142 GIO_AVAILABLE_IN_2_34
143 GDBusConnection * g_application_get_dbus_connection (GApplication *application);
144 GIO_AVAILABLE_IN_2_34
145 const gchar * g_application_get_dbus_object_path (GApplication *application);
148 guint g_application_get_inactivity_timeout (GApplication *application);
150 void g_application_set_inactivity_timeout (GApplication *application,
151 guint inactivity_timeout);
154 GApplicationFlags g_application_get_flags (GApplication *application);
156 void g_application_set_flags (GApplication *application,
157 GApplicationFlags flags);
159 GIO_AVAILABLE_IN_2_42
160 const gchar * g_application_get_resource_base_path (GApplication *application);
161 GIO_AVAILABLE_IN_2_42
162 void g_application_set_resource_base_path (GApplication *application,
163 const gchar *resource_path);
166 void g_application_set_action_group (GApplication *application,
167 GActionGroup *action_group);
169 GIO_AVAILABLE_IN_2_40
170 void g_application_add_main_option_entries (GApplication *application,
171 const GOptionEntry *entries);
173 GIO_AVAILABLE_IN_2_42
174 void g_application_add_main_option (GApplication *application,
175 const char *long_name,
179 const char *description,
180 const char *arg_description);
181 GIO_AVAILABLE_IN_2_40
182 void g_application_add_option_group (GApplication *application,
183 GOptionGroup *group);
184 GIO_AVAILABLE_IN_2_56
185 void g_application_set_option_context_parameter_string (GApplication *application,
186 const gchar *parameter_string);
187 GIO_AVAILABLE_IN_2_56
188 void g_application_set_option_context_summary (GApplication *application,
189 const gchar *summary);
190 GIO_AVAILABLE_IN_2_56
191 void g_application_set_option_context_description (GApplication *application,
192 const gchar *description);
194 gboolean g_application_get_is_registered (GApplication *application);
196 gboolean g_application_get_is_remote (GApplication *application);
199 gboolean g_application_register (GApplication *application,
200 GCancellable *cancellable,
204 void g_application_hold (GApplication *application);
206 void g_application_release (GApplication *application);
209 void g_application_activate (GApplication *application);
212 void g_application_open (GApplication *application,
218 int g_application_run (GApplication *application,
222 GIO_AVAILABLE_IN_2_32
223 void g_application_quit (GApplication *application);
225 GIO_AVAILABLE_IN_2_32
226 GApplication * g_application_get_default (void);
227 GIO_AVAILABLE_IN_2_32
228 void g_application_set_default (GApplication *application);
230 GIO_AVAILABLE_IN_2_38
231 void g_application_mark_busy (GApplication *application);
232 GIO_AVAILABLE_IN_2_38
233 void g_application_unmark_busy (GApplication *application);
234 GIO_AVAILABLE_IN_2_44
235 gboolean g_application_get_is_busy (GApplication *application);
237 GIO_AVAILABLE_IN_2_40
238 void g_application_send_notification (GApplication *application,
240 GNotification *notification);
241 GIO_AVAILABLE_IN_2_40
242 void g_application_withdraw_notification (GApplication *application,
245 GIO_AVAILABLE_IN_2_44
246 void g_application_bind_busy_property (GApplication *application,
248 const gchar *property);
250 GIO_AVAILABLE_IN_2_44
251 void g_application_unbind_busy_property (GApplication *application,
253 const gchar *property);
257 #endif /* __G_APPLICATION_H__ */