Rework GApplication API to use GInitable
[platform/upstream/glib.git] / gio / gapplication.h
1 /* GIO - GLib Input, Output and Streaming Library
2  *
3  * Copyright © 2010 Red Hat, Inc
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published
7  * by the Free Software Foundation; either version 2 of the licence or (at
8  * your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General
16  * Public License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18  * Boston, MA 02111-1307, USA.
19  *
20  * Authors: Colin Walters <walters@verbum.org>
21  *          Emmanuele Bassi <ebassi@linux.intel.com>
22  */
23
24 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
25 #error "Only <gio/gio.h> can be included directly."
26 #endif
27
28 #ifndef __G_APPLICATION_H__
29 #define __G_APPLICATION_H__
30
31 #include <glib-object.h>
32 #include <gio/giotypes.h>
33
34 G_BEGIN_DECLS
35
36 #define G_TYPE_APPLICATION              (g_application_get_type ())
37 #define G_APPLICATION(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_APPLICATION, GApplication))
38 #define G_APPLICATION_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), G_TYPE_APPLICATION, GApplicationClass))
39 #define G_IS_APPLICATION(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_APPLICATION))
40 #define G_IS_APPLICATION_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), G_TYPE_APPLICATION))
41 #define G_APPLICATION_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), G_TYPE_APPLICATION, GApplicationClass))
42
43 typedef struct _GApplication            GApplication;
44 typedef struct _GApplicationPrivate     GApplicationPrivate;
45 typedef struct _GApplicationClass       GApplicationClass;
46
47 /**
48  * GApplication:
49  *
50  * The <structname>GApplication</structname> structure contains private
51  * data and should only be accessed using the provided API
52  *
53  * Since: 2.26
54  */
55 struct _GApplication
56 {
57   /*< private >*/
58   GObject parent_instance;
59
60   GApplicationPrivate *priv;
61 };
62
63 /**
64  * GApplicationClass:
65  * @action: class handler for the #GApplication::action signal
66  * @quit: class handler for the #GApplication::quit signal
67  * @prepare_activation: class handler for the #GApplication::prepare-activation signal
68  * @run: virtual function, called by g_application_run()
69  *
70  * The <structname>GApplicationClass</structname> structure contains
71  * private data only
72  *
73  * Since: 2.26
74  */
75 struct _GApplicationClass
76 {
77   /*< private >*/
78   GObjectClass parent_class;
79
80   /*< public >*/
81   /* signals */
82   void        (* action_with_data) (GApplication *application,
83                                     const gchar  *action_name,
84                                     GVariant     *platform_data);
85   gboolean    (* quit_with_data)   (GApplication *application,
86                                     GVariant     *platform_data);
87   void        (* prepare_activation)   (GApplication  *application,
88                                         GVariant      *arguments,
89                                         GVariant      *platform_data);
90
91   /* vfuncs */
92   void        (* run)    (GApplication *application);
93
94   /*< private >*/
95   /* Padding for future expansion */
96   void (*_g_reserved1) (void);
97   void (*_g_reserved2) (void);
98   void (*_g_reserved3) (void);
99   void (*_g_reserved4) (void);
100   void (*_g_reserved5) (void);
101   void (*_g_reserved6) (void);
102 };
103 GType                   g_application_get_type                  (void) G_GNUC_CONST;
104
105 GApplication *          g_application_new                       (const gchar      *appid,
106                                                                  int               argc,
107                                                                  char            **argv);
108
109 GApplication *          g_application_try_new                   (const gchar      *appid,
110                                                                  int               argc,
111                                                                  char            **argv,
112                                                                  GError          **error);
113
114 GApplication *          g_application_unregistered_try_new      (const gchar      *appid,
115                                                                  int               argc,
116                                                                  char            **argv,
117                                                                  GError          **error);
118
119 gboolean                g_application_register                  (GApplication      *application);
120
121 GApplication *          g_application_get_instance              (void);
122 G_CONST_RETURN gchar *  g_application_get_id                    (GApplication      *application);
123
124 void                    g_application_add_action                (GApplication      *application,
125                                                                  const gchar       *name,
126                                                                  const gchar       *description);
127 void                    g_application_remove_action             (GApplication      *application,
128                                                                  const gchar       *name);
129 gchar **                g_application_list_actions              (GApplication      *application);
130 void                    g_application_set_action_enabled        (GApplication      *application,
131                                                                  const gchar       *name,
132                                                                  gboolean           enabled);
133 gboolean                g_application_get_action_enabled        (GApplication      *application,
134                                                                  const gchar       *name);
135 G_CONST_RETURN gchar *  g_application_get_action_description    (GApplication      *application,
136                                                                  const gchar       *name);
137 void                    g_application_invoke_action             (GApplication      *application,
138                                                                  const gchar       *name,
139                                                                  GVariant          *platform_data);
140
141 void                    g_application_run                       (GApplication      *application);
142 gboolean                g_application_quit_with_data            (GApplication      *app,
143                                                                  GVariant          *platform_data);
144
145 gboolean                g_application_is_remote                 (GApplication      *application);
146
147 G_END_DECLS
148
149 #endif /* __G_APPLICATION_H__ */