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
22 #ifndef __G_APPLICATION_H__
23 #define __G_APPLICATION_H__
24
25 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
26 #error "Only <gio/gio.h> can be included directly."
27 #endif
28
29 #include <gio/giotypes.h>
30
31 G_BEGIN_DECLS
32
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))
42
43 typedef struct _GApplicationPrivate GApplicationPrivate;
44 typedef struct _GApplicationClass GApplicationClass;
45
46 struct _GApplication
47 {
48 /*< private >*/
49 GObject parent_instance;
50
51 GApplicationPrivate *priv;
52 };
53
54 struct _GApplicationClass
55 {
56 /*< private >*/
57 GObjectClass parent_class;
58
59 /*< public >*/
60 /* signals */
61 void (* startup) (GApplication *application);
62
63 void (* activate) (GApplication *application);
64
65 void (* open) (GApplication *application,
66 GFile **files,
67 gint n_files,
68 const gchar *hint);
69
70 int (* command_line) (GApplication *application,
71 GApplicationCommandLine *command_line);
72
73 /* vfuncs */
74
75 /**
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.
80 *
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
84 * arguments).
85 *
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().
89 *
90 * See g_application_run() for more details on #GApplication startup.
91 *
92 * Returns: %TRUE if the commandline has been completely handled
93 */
94 gboolean (* local_command_line) (GApplication *application,
95 gchar ***arguments,
96 int *exit_status);
97
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);
110
111 gboolean (* dbus_register) (GApplication *application,
112 GDBusConnection *connection,
113 const gchar *object_path,
114 GError **error);
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);
121
122 /*< private >*/
123 gpointer padding[7];
124 };
125
126 GIO_AVAILABLE_IN_ALL
127 GType g_application_get_type (void) G_GNUC_CONST;
128
129 GIO_AVAILABLE_IN_ALL
130 gboolean g_application_id_is_valid (const gchar *application_id);
131
132 GIO_AVAILABLE_IN_ALL
133 GApplication * g_application_new (const gchar *application_id,
134 GApplicationFlags flags);
135
136 GIO_AVAILABLE_IN_ALL
137 const gchar * g_application_get_application_id (GApplication *application);
138 GIO_AVAILABLE_IN_ALL
139 void g_application_set_application_id (GApplication *application,
140 const gchar *application_id);
141
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);
146
147 GIO_AVAILABLE_IN_ALL
148 guint g_application_get_inactivity_timeout (GApplication *application);
149 GIO_AVAILABLE_IN_ALL
150 void g_application_set_inactivity_timeout (GApplication *application,
151 guint inactivity_timeout);
152
153 GIO_AVAILABLE_IN_ALL
154 GApplicationFlags g_application_get_flags (GApplication *application);
155 GIO_AVAILABLE_IN_ALL
156 void g_application_set_flags (GApplication *application,
157 GApplicationFlags flags);
158
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);
164
165 GIO_DEPRECATED
166 void g_application_set_action_group (GApplication *application,
167 GActionGroup *action_group);
168
169 GIO_AVAILABLE_IN_2_40
170 void g_application_add_main_option_entries (GApplication *application,
171 const GOptionEntry *entries);
172
173 GIO_AVAILABLE_IN_2_42
174 void g_application_add_main_option (GApplication *application,
175 const char *long_name,
176 char short_name,
177 GOptionFlags flags,
178 GOptionArg arg,
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);
193 GIO_AVAILABLE_IN_ALL
194 gboolean g_application_get_is_registered (GApplication *application);
195 GIO_AVAILABLE_IN_ALL
196 gboolean g_application_get_is_remote (GApplication *application);
197
198 GIO_AVAILABLE_IN_ALL
199 gboolean g_application_register (GApplication *application,
200 GCancellable *cancellable,
201 GError **error);
202
203 GIO_AVAILABLE_IN_ALL
204 void g_application_hold (GApplication *application);
205 GIO_AVAILABLE_IN_ALL
206 void g_application_release (GApplication *application);
207
208 GIO_AVAILABLE_IN_ALL
209 void g_application_activate (GApplication *application);
210
211 GIO_AVAILABLE_IN_ALL
212 void g_application_open (GApplication *application,
213 GFile **files,
214 gint n_files,
215 const gchar *hint);
216
217 GIO_AVAILABLE_IN_ALL
218 int g_application_run (GApplication *application,
219 int argc,
220 char **argv);
221
222 GIO_AVAILABLE_IN_2_32
223 void g_application_quit (GApplication *application);
224
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);
229
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);
236
237 GIO_AVAILABLE_IN_2_40
238 void g_application_send_notification (GApplication *application,
239 const gchar *id,
240 GNotification *notification);
241 GIO_AVAILABLE_IN_2_40
242 void g_application_withdraw_notification (GApplication *application,
243 const gchar *id);
244
245 GIO_AVAILABLE_IN_2_44
246 void g_application_bind_busy_property (GApplication *application,
247 gpointer object,
248 const gchar *property);
249
250 GIO_AVAILABLE_IN_2_44
251 void g_application_unbind_busy_property (GApplication *application,
252 gpointer object,
253 const gchar *property);
254
255 G_END_DECLS
256
257 #endif /* __G_APPLICATION_H__ */