[kdbus] KDBUS_ITEM_PAYLOAD_OFF items are (once again) relative to msg header
[platform/upstream/glib.git] / gio / gapplication.h
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 <desrt@desrt.ca>
18  */
19
20 #ifndef __G_APPLICATION_H__
21 #define __G_APPLICATION_H__
22
23 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
24 #error "Only <gio/gio.h> can be included directly."
25 #endif
26
27 #include <gio/giotypes.h>
28
29 G_BEGIN_DECLS
30
31 #define G_TYPE_APPLICATION                                  (g_application_get_type ())
32 #define G_APPLICATION(inst)                                 (G_TYPE_CHECK_INSTANCE_CAST ((inst),                     \
33                                                              G_TYPE_APPLICATION, GApplication))
34 #define G_APPLICATION_CLASS(class)                          (G_TYPE_CHECK_CLASS_CAST ((class),                       \
35                                                              G_TYPE_APPLICATION, GApplicationClass))
36 #define G_IS_APPLICATION(inst)                              (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_APPLICATION))
37 #define G_IS_APPLICATION_CLASS(class)                       (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_APPLICATION))
38 #define G_APPLICATION_GET_CLASS(inst)                       (G_TYPE_INSTANCE_GET_CLASS ((inst),                      \
39                                                              G_TYPE_APPLICATION, GApplicationClass))
40
41 typedef struct _GApplicationPrivate                         GApplicationPrivate;
42 typedef struct _GApplicationClass                           GApplicationClass;
43
44 /**
45  * GApplication:
46  *
47  * Since: 2.28
48  */
49 struct _GApplication
50 {
51   /*< private >*/
52   GObject parent_instance;
53
54   GApplicationPrivate *priv;
55 };
56
57 struct _GApplicationClass
58 {
59   /*< private >*/
60   GObjectClass parent_class;
61
62   /*< public >*/
63   /* signals */
64   void                      (* startup)             (GApplication              *application);
65
66   void                      (* activate)            (GApplication              *application);
67
68   void                      (* open)                (GApplication              *application,
69                                                      GFile                    **files,
70                                                      gint                       n_files,
71                                                      const gchar               *hint);
72
73   int                       (* command_line)        (GApplication              *application,
74                                                      GApplicationCommandLine   *command_line);
75
76   /* vfuncs */
77
78   /**
79    * GApplicationClass::local_command_line:
80    * @application: a #GApplication
81    * @arguments: (inout) (array zero-terminated=1): array of command line arguments
82    * @exit_status: (out): exit status to fill after processing the command line.
83    *
84    * This virtual function is always invoked in the local instance. It
85    * gets passed a pointer to a %NULL-terminated copy of @argv and is
86    * expected to remove arguments that it handled (shifting up remaining
87    * arguments).
88    *
89    * The last argument to local_command_line() is a pointer to the @status
90    * variable which can used to set the exit status that is returned from
91    * g_application_run().
92    *
93    * See g_application_run() for more details on #GApplication startup.
94    *
95    * Returns: %TRUE if the commandline has been completely handled
96    */
97   gboolean                  (* local_command_line)  (GApplication              *application,
98                                                      gchar                   ***arguments,
99                                                      int                       *exit_status);
100
101   void                      (* before_emit)         (GApplication              *application,
102                                                      GVariant                  *platform_data);
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
121   /*< private >*/
122   gpointer padding[8];
123 };
124
125 GLIB_AVAILABLE_IN_ALL
126 GType                   g_application_get_type                          (void) G_GNUC_CONST;
127
128 GLIB_AVAILABLE_IN_ALL
129 gboolean                g_application_id_is_valid                       (const gchar              *application_id);
130
131 GLIB_AVAILABLE_IN_ALL
132 GApplication *          g_application_new                               (const gchar              *application_id,
133                                                                          GApplicationFlags         flags);
134
135 GLIB_AVAILABLE_IN_ALL
136 const gchar *           g_application_get_application_id                (GApplication             *application);
137 GLIB_AVAILABLE_IN_ALL
138 void                    g_application_set_application_id                (GApplication             *application,
139                                                                          const gchar              *application_id);
140
141 GLIB_AVAILABLE_IN_2_34
142 GDBusConnection *       g_application_get_dbus_connection               (GApplication             *application);
143 GLIB_AVAILABLE_IN_2_34
144 const gchar *           g_application_get_dbus_object_path              (GApplication             *application);
145
146 GLIB_AVAILABLE_IN_ALL
147 guint                   g_application_get_inactivity_timeout            (GApplication             *application);
148 GLIB_AVAILABLE_IN_ALL
149 void                    g_application_set_inactivity_timeout            (GApplication             *application,
150                                                                          guint                     inactivity_timeout);
151
152 GLIB_AVAILABLE_IN_ALL
153 GApplicationFlags       g_application_get_flags                         (GApplication             *application);
154 GLIB_AVAILABLE_IN_ALL
155 void                    g_application_set_flags                         (GApplication             *application,
156                                                                          GApplicationFlags         flags);
157
158 GLIB_AVAILABLE_IN_2_42
159 const gchar *           g_application_get_resource_base_path            (GApplication             *application);
160 GLIB_AVAILABLE_IN_2_42
161 void                    g_application_set_resource_base_path            (GApplication             *application,
162                                                                          const gchar              *resource_path);
163
164 GLIB_DEPRECATED
165 void                    g_application_set_action_group                  (GApplication             *application,
166                                                                          GActionGroup             *action_group);
167
168 GLIB_AVAILABLE_IN_2_40
169 void                    g_application_add_main_option_entries           (GApplication             *application,
170                                                                          const GOptionEntry       *entries);
171
172 GLIB_AVAILABLE_IN_2_42
173 void                    g_application_add_main_option                   (GApplication             *application,
174                                                                          const char               *long_name,
175                                                                          char                      short_name,
176                                                                          GOptionFlags              flags,
177                                                                          GOptionArg                arg,
178                                                                          const char               *description,
179                                                                          const char               *arg_description);
180 GLIB_AVAILABLE_IN_2_40
181 void                    g_application_add_option_group                  (GApplication             *application,
182                                                                          GOptionGroup             *group);
183
184 GLIB_AVAILABLE_IN_ALL
185 gboolean                g_application_get_is_registered                 (GApplication             *application);
186 GLIB_AVAILABLE_IN_ALL
187 gboolean                g_application_get_is_remote                     (GApplication             *application);
188
189 GLIB_AVAILABLE_IN_ALL
190 gboolean                g_application_register                          (GApplication             *application,
191                                                                          GCancellable             *cancellable,
192                                                                          GError                  **error);
193
194 GLIB_AVAILABLE_IN_ALL
195 void                    g_application_hold                              (GApplication             *application);
196 GLIB_AVAILABLE_IN_ALL
197 void                    g_application_release                           (GApplication             *application);
198
199 GLIB_AVAILABLE_IN_ALL
200 void                    g_application_activate                          (GApplication             *application);
201
202 GLIB_AVAILABLE_IN_ALL
203 void                    g_application_open                              (GApplication             *application,
204                                                                          GFile                   **files,
205                                                                          gint                      n_files,
206                                                                          const gchar              *hint);
207
208 GLIB_AVAILABLE_IN_ALL
209 int                     g_application_run                               (GApplication             *application,
210                                                                          int                       argc,
211                                                                          char                    **argv);
212
213 GLIB_AVAILABLE_IN_2_32
214 void                    g_application_quit                              (GApplication             *application);
215
216 GLIB_AVAILABLE_IN_2_32
217 GApplication *          g_application_get_default                       (void);
218 GLIB_AVAILABLE_IN_2_32
219 void                    g_application_set_default                       (GApplication             *application);
220
221 GLIB_AVAILABLE_IN_2_38
222 void                    g_application_mark_busy                         (GApplication             *application);
223 GLIB_AVAILABLE_IN_2_38
224 void                    g_application_unmark_busy                       (GApplication             *application);
225
226 GLIB_AVAILABLE_IN_2_40
227 void                    g_application_send_notification                 (GApplication             *application,
228                                                                          const gchar              *id,
229                                                                          GNotification            *notification);
230 GLIB_AVAILABLE_IN_2_40
231 void                    g_application_withdraw_notification             (GApplication             *application,
232                                                                          const gchar              *id);
233
234 G_END_DECLS
235
236 #endif /* __G_APPLICATION_H__ */