GApplication: document Since properly in header files, 2.26 -> 2.28
[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, write to the
16  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
17  * Boston, MA 02111-1307, USA.
18  *
19  * Authors: Ryan Lortie <desrt@desrt.ca>
20  */
21
22 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
23 #error "Only <gio/gio.h> can be included directly."
24 #endif
25
26 #ifndef __G_APPLICATION_H__
27 #define __G_APPLICATION_H__
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 /**
47  * GApplication:
48  *
49  * The <structname>GApplication</structname> structure contains private
50  * data and should only be accessed using the provided API
51  *
52  * Since: 2.28
53  */
54 struct _GApplication
55 {
56   /*< private >*/
57   GObject parent_instance;
58
59   GApplicationPrivate *priv;
60 };
61
62 /**
63  * GApplicationClass:
64  * @startup: invoked on the primary instance immediately after registration
65  * @activate: invoked on the primary instance when an activation occurs
66  * @open: invoked on the primary instance when there are files to open
67  * @command_line: invoked on the primary instance when a command-line is
68  *   not handled locally
69  * @local_command_line: invoked (locally) when the process has been invoked
70  *     via commandline execution.  The virtual function has the chance to
71  *     inspect (and possibly replace) the list of command line arguments.
72  *     See g_application_run() for more information.
73  * @before_emit: invoked on the primary instance before 'activate', 'open' or any action invocation
74  * @after_emit: invoked on the primary instance after 'activate', 'open' or any action invocation
75  * @add_platform_data: invoked (locally) to add 'platform data' to be sent to the primary instance when
76  *   activating, opening or invoking actions
77  * @quit_mainloop: invoked on the primary instance when the use count of the application drops to zero (and
78  *   after any inactivity timeout, if requested)
79  * @run_mainloop: invoked on the primary instance from g_application_run() if the use-count is non-zero
80  *
81  * Since: 2.28
82  */
83 struct _GApplicationClass
84 {
85   /*< private >*/
86   GObjectClass parent_class;
87
88   /*< public >*/
89   /* signals */
90   void                      (* startup)             (GApplication              *application);
91
92   void                      (* activate)            (GApplication              *application);
93
94   void                      (* open)                (GApplication              *application,
95                                                      GFile                    **files,
96                                                      gint                       n_files,
97                                                      const gchar               *hint);
98
99   int                       (* command_line)        (GApplication              *application,
100                                                      GApplicationCommandLine   *command_line);
101
102   /* vfuncs */
103   gboolean                  (* local_command_line)  (GApplication              *application,
104                                                      gchar                   ***arguments,
105                                                      int                       *exit_status);
106
107   void                      (* before_emit)         (GApplication              *application,
108                                                      GVariant                  *platform_data);
109   void                      (* after_emit)          (GApplication              *application,
110                                                      GVariant                  *platform_data);
111   void                      (* add_platform_data)   (GApplication              *application,
112                                                      GVariantBuilder           *builder);
113   void                      (* quit_mainloop)       (GApplication              *application);
114   void                      (* run_mainloop)        (GApplication              *application);
115
116   /*< private >*/
117   gpointer padding[12];
118 };
119
120 GType                   g_application_get_type                          (void) G_GNUC_CONST;
121
122 gboolean                g_application_id_is_valid                       (const gchar              *application_id);
123
124 GApplication *          g_application_new                               (const gchar              *application_id,
125                                                                          GApplicationFlags         flags);
126
127 const gchar *           g_application_get_application_id                (GApplication             *application);
128 void                    g_application_set_application_id                (GApplication             *application,
129                                                                          const gchar              *application_id);
130
131 guint                   g_application_get_inactivity_timeout            (GApplication             *application);
132 void                    g_application_set_inactivity_timeout            (GApplication             *application,
133                                                                          guint                     inactivity_timeout);
134
135 GApplicationFlags       g_application_get_flags                         (GApplication             *application);
136 void                    g_application_set_flags                         (GApplication             *application,
137                                                                          GApplicationFlags         flags);
138
139 void                    g_application_set_action_group                  (GApplication             *application,
140                                                                          GActionGroup             *action_group);
141
142 gboolean                g_application_get_is_registered                 (GApplication             *application);
143 gboolean                g_application_get_is_remote                     (GApplication             *application);
144
145 gboolean                g_application_register                          (GApplication             *application,
146                                                                          GCancellable             *cancellable,
147                                                                          GError                  **error);
148
149 void                    g_application_hold                              (GApplication             *application);
150 void                    g_application_release                           (GApplication             *application);
151
152 void                    g_application_activate                          (GApplication             *application);
153
154 void                    g_application_open                              (GApplication             *application,
155                                                                          GFile                   **files,
156                                                                          gint                      n_files,
157                                                                          const gchar              *hint);
158
159 int                     g_application_run                               (GApplication             *application,
160                                                                          int                       argc,
161                                                                          char                    **argv);
162
163 G_END_DECLS
164
165 #endif /* __G_APPLICATION_H__ */