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_80 |
143 | const gchar * g_application_get_version (GApplication *application); |
144 | GIO_AVAILABLE_IN_2_80 |
145 | void g_application_set_version (GApplication *application, |
146 | const gchar *version); |
147 | |
148 | GIO_AVAILABLE_IN_2_34 |
149 | GDBusConnection * g_application_get_dbus_connection (GApplication *application); |
150 | GIO_AVAILABLE_IN_2_34 |
151 | const gchar * g_application_get_dbus_object_path (GApplication *application); |
152 | |
153 | GIO_AVAILABLE_IN_ALL |
154 | guint g_application_get_inactivity_timeout (GApplication *application); |
155 | GIO_AVAILABLE_IN_ALL |
156 | void g_application_set_inactivity_timeout (GApplication *application, |
157 | guint inactivity_timeout); |
158 | |
159 | GIO_AVAILABLE_IN_ALL |
160 | GApplicationFlags g_application_get_flags (GApplication *application); |
161 | GIO_AVAILABLE_IN_ALL |
162 | void g_application_set_flags (GApplication *application, |
163 | GApplicationFlags flags); |
164 | |
165 | GIO_AVAILABLE_IN_2_42 |
166 | const gchar * g_application_get_resource_base_path (GApplication *application); |
167 | GIO_AVAILABLE_IN_2_42 |
168 | void g_application_set_resource_base_path (GApplication *application, |
169 | const gchar *resource_path); |
170 | |
171 | GIO_DEPRECATED |
172 | void g_application_set_action_group (GApplication *application, |
173 | GActionGroup *action_group); |
174 | |
175 | GIO_AVAILABLE_IN_2_40 |
176 | void g_application_add_main_option_entries (GApplication *application, |
177 | const GOptionEntry *entries); |
178 | |
179 | GIO_AVAILABLE_IN_2_42 |
180 | void 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); |
187 | GIO_AVAILABLE_IN_2_40 |
188 | void g_application_add_option_group (GApplication *application, |
189 | GOptionGroup *group); |
190 | GIO_AVAILABLE_IN_2_56 |
191 | void g_application_set_option_context_parameter_string (GApplication *application, |
192 | const gchar *parameter_string); |
193 | GIO_AVAILABLE_IN_2_56 |
194 | void g_application_set_option_context_summary (GApplication *application, |
195 | const gchar *summary); |
196 | GIO_AVAILABLE_IN_2_56 |
197 | void g_application_set_option_context_description (GApplication *application, |
198 | const gchar *description); |
199 | GIO_AVAILABLE_IN_ALL |
200 | gboolean g_application_get_is_registered (GApplication *application); |
201 | GIO_AVAILABLE_IN_ALL |
202 | gboolean g_application_get_is_remote (GApplication *application); |
203 | |
204 | GIO_AVAILABLE_IN_ALL |
205 | gboolean g_application_register (GApplication *application, |
206 | GCancellable *cancellable, |
207 | GError **error); |
208 | |
209 | GIO_AVAILABLE_IN_ALL |
210 | void g_application_hold (GApplication *application); |
211 | GIO_AVAILABLE_IN_ALL |
212 | void g_application_release (GApplication *application); |
213 | |
214 | GIO_AVAILABLE_IN_ALL |
215 | void g_application_activate (GApplication *application); |
216 | |
217 | GIO_AVAILABLE_IN_ALL |
218 | void g_application_open (GApplication *application, |
219 | GFile **files, |
220 | gint n_files, |
221 | const gchar *hint); |
222 | |
223 | GIO_AVAILABLE_IN_ALL |
224 | int g_application_run (GApplication *application, |
225 | int argc, |
226 | char **argv); |
227 | |
228 | GIO_AVAILABLE_IN_2_32 |
229 | void g_application_quit (GApplication *application); |
230 | |
231 | GIO_AVAILABLE_IN_2_32 |
232 | GApplication * g_application_get_default (void); |
233 | GIO_AVAILABLE_IN_2_32 |
234 | void g_application_set_default (GApplication *application); |
235 | |
236 | GIO_AVAILABLE_IN_2_38 |
237 | void g_application_mark_busy (GApplication *application); |
238 | GIO_AVAILABLE_IN_2_38 |
239 | void g_application_unmark_busy (GApplication *application); |
240 | GIO_AVAILABLE_IN_2_44 |
241 | gboolean g_application_get_is_busy (GApplication *application); |
242 | |
243 | GIO_AVAILABLE_IN_2_40 |
244 | void g_application_send_notification (GApplication *application, |
245 | const gchar *id, |
246 | GNotification *notification); |
247 | GIO_AVAILABLE_IN_2_40 |
248 | void g_application_withdraw_notification (GApplication *application, |
249 | const gchar *id); |
250 | |
251 | GIO_AVAILABLE_IN_2_44 |
252 | void g_application_bind_busy_property (GApplication *application, |
253 | gpointer object, |
254 | const gchar *property); |
255 | |
256 | GIO_AVAILABLE_IN_2_44 |
257 | void g_application_unbind_busy_property (GApplication *application, |
258 | gpointer object, |
259 | const gchar *property); |
260 | |
261 | G_END_DECLS |
262 | |
263 | #endif /* __G_APPLICATION_H__ */ |
264 | |