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
31G_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
43typedef struct _GApplicationPrivate GApplicationPrivate;
44typedef struct _GApplicationClass GApplicationClass;
45
46struct _GApplication
47{
48 /*< private >*/
49 GObject parent_instance;
50
51 GApplicationPrivate *priv;
52};
53
54struct _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
126GIO_AVAILABLE_IN_ALL
127GType g_application_get_type (void) G_GNUC_CONST;
128
129GIO_AVAILABLE_IN_ALL
130gboolean g_application_id_is_valid (const gchar *application_id);
131
132GIO_AVAILABLE_IN_ALL
133GApplication * g_application_new (const gchar *application_id,
134 GApplicationFlags flags);
135
136GIO_AVAILABLE_IN_ALL
137const gchar * g_application_get_application_id (GApplication *application);
138GIO_AVAILABLE_IN_ALL
139void g_application_set_application_id (GApplication *application,
140 const gchar *application_id);
141
142GIO_AVAILABLE_IN_2_80
143const gchar * g_application_get_version (GApplication *application);
144GIO_AVAILABLE_IN_2_80
145void g_application_set_version (GApplication *application,
146 const gchar *version);
147
148GIO_AVAILABLE_IN_2_34
149GDBusConnection * g_application_get_dbus_connection (GApplication *application);
150GIO_AVAILABLE_IN_2_34
151const gchar * g_application_get_dbus_object_path (GApplication *application);
152
153GIO_AVAILABLE_IN_ALL
154guint g_application_get_inactivity_timeout (GApplication *application);
155GIO_AVAILABLE_IN_ALL
156void g_application_set_inactivity_timeout (GApplication *application,
157 guint inactivity_timeout);
158
159GIO_AVAILABLE_IN_ALL
160GApplicationFlags g_application_get_flags (GApplication *application);
161GIO_AVAILABLE_IN_ALL
162void g_application_set_flags (GApplication *application,
163 GApplicationFlags flags);
164
165GIO_AVAILABLE_IN_2_42
166const gchar * g_application_get_resource_base_path (GApplication *application);
167GIO_AVAILABLE_IN_2_42
168void g_application_set_resource_base_path (GApplication *application,
169 const gchar *resource_path);
170
171GIO_DEPRECATED
172void g_application_set_action_group (GApplication *application,
173 GActionGroup *action_group);
174
175GIO_AVAILABLE_IN_2_40
176void g_application_add_main_option_entries (GApplication *application,
177 const GOptionEntry *entries);
178
179GIO_AVAILABLE_IN_2_42
180void g_application_add_main_option (GApplication *application,
181 const char *long_name,
182 char short_name,
183 GOptionFlags flags,
184 GOptionArg arg,
185 const char *description,
186 const char *arg_description);
187GIO_AVAILABLE_IN_2_40
188void g_application_add_option_group (GApplication *application,
189 GOptionGroup *group);
190GIO_AVAILABLE_IN_2_56
191void g_application_set_option_context_parameter_string (GApplication *application,
192 const gchar *parameter_string);
193GIO_AVAILABLE_IN_2_56
194void g_application_set_option_context_summary (GApplication *application,
195 const gchar *summary);
196GIO_AVAILABLE_IN_2_56
197void g_application_set_option_context_description (GApplication *application,
198 const gchar *description);
199GIO_AVAILABLE_IN_ALL
200gboolean g_application_get_is_registered (GApplication *application);
201GIO_AVAILABLE_IN_ALL
202gboolean g_application_get_is_remote (GApplication *application);
203
204GIO_AVAILABLE_IN_ALL
205gboolean g_application_register (GApplication *application,
206 GCancellable *cancellable,
207 GError **error);
208
209GIO_AVAILABLE_IN_ALL
210void g_application_hold (GApplication *application);
211GIO_AVAILABLE_IN_ALL
212void g_application_release (GApplication *application);
213
214GIO_AVAILABLE_IN_ALL
215void g_application_activate (GApplication *application);
216
217GIO_AVAILABLE_IN_ALL
218void g_application_open (GApplication *application,
219 GFile **files,
220 gint n_files,
221 const gchar *hint);
222
223GIO_AVAILABLE_IN_ALL
224int g_application_run (GApplication *application,
225 int argc,
226 char **argv);
227
228GIO_AVAILABLE_IN_2_32
229void g_application_quit (GApplication *application);
230
231GIO_AVAILABLE_IN_2_32
232GApplication * g_application_get_default (void);
233GIO_AVAILABLE_IN_2_32
234void g_application_set_default (GApplication *application);
235
236GIO_AVAILABLE_IN_2_38
237void g_application_mark_busy (GApplication *application);
238GIO_AVAILABLE_IN_2_38
239void g_application_unmark_busy (GApplication *application);
240GIO_AVAILABLE_IN_2_44
241gboolean g_application_get_is_busy (GApplication *application);
242
243GIO_AVAILABLE_IN_2_40
244void g_application_send_notification (GApplication *application,
245 const gchar *id,
246 GNotification *notification);
247GIO_AVAILABLE_IN_2_40
248void g_application_withdraw_notification (GApplication *application,
249 const gchar *id);
250
251GIO_AVAILABLE_IN_2_44
252void g_application_bind_busy_property (GApplication *application,
253 gpointer object,
254 const gchar *property);
255
256GIO_AVAILABLE_IN_2_44
257void g_application_unbind_busy_property (GApplication *application,
258 gpointer object,
259 const gchar *property);
260
261G_END_DECLS
262
263#endif /* __G_APPLICATION_H__ */
264