gitignore
[glib.git] / gio / gapplication.h
blob254b8415226d845db07d3b842fdf37a4026df2c9
1 /*
2 * Copyright © 2010 Codethink Limited
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.
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.
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.
19 * Authors: Ryan Lortie <desrt@desrt.ca>
22 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
23 #error "Only <gio/gio.h> can be included directly."
24 #endif
26 #ifndef __G_APPLICATION_H__
27 #define __G_APPLICATION_H__
29 #include <gio/giotypes.h>
31 G_BEGIN_DECLS
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))
43 typedef struct _GApplicationPrivate GApplicationPrivate;
44 typedef struct _GApplicationClass GApplicationClass;
46 /**
47 * GApplication:
49 * The <structname>GApplication</structname> structure contains private
50 * data and should only be accessed using the provided API
52 * Since: 2.28
54 struct _GApplication
56 /*< private >*/
57 GObject parent_instance;
59 GApplicationPrivate *priv;
62 /**
63 * GApplicationClass:
64 * @startup: invoked on the primary instance immediately after registration
65 * @shutdown: invoked only on the registered primary instance immediately
66 * after the main loop terminates
67 * @activate: invoked on the primary instance when an activation occurs
68 * @open: invoked on the primary instance when there are files to open
69 * @command_line: invoked on the primary instance when a command-line is
70 * not handled locally
71 * @local_command_line: invoked (locally) when the process has been invoked
72 * via commandline execution. The virtual function has the chance to
73 * inspect (and possibly replace) the list of command line arguments.
74 * See g_application_run() for more information.
75 * @before_emit: invoked on the primary instance before 'activate', 'open',
76 * 'command-line' or any action invocation, gets the 'platform data' from
77 * the calling instance
78 * @after_emit: invoked on the primary instance after 'activate', 'open',
79 * 'command-line' or any action invocation, gets the 'platform data' from
80 * the calling instance
81 * @add_platform_data: invoked (locally) to add 'platform data' to be sent to
82 * the primary instance when activating, opening or invoking actions
83 * @quit_mainloop: invoked on the primary instance when the use count of the
84 * application drops to zero (and after any inactivity timeout, if
85 * requested)
86 * @run_mainloop: invoked on the primary instance from g_application_run()
87 * if the use-count is non-zero
89 * Since: 2.28
91 struct _GApplicationClass
93 /*< private >*/
94 GObjectClass parent_class;
96 /*< public >*/
97 /* signals */
98 void (* startup) (GApplication *application);
100 void (* activate) (GApplication *application);
102 void (* open) (GApplication *application,
103 GFile **files,
104 gint n_files,
105 const gchar *hint);
107 int (* command_line) (GApplication *application,
108 GApplicationCommandLine *command_line);
110 /* vfuncs */
111 gboolean (* local_command_line) (GApplication *application,
112 gchar ***arguments,
113 int *exit_status);
115 void (* before_emit) (GApplication *application,
116 GVariant *platform_data);
117 void (* after_emit) (GApplication *application,
118 GVariant *platform_data);
119 void (* add_platform_data) (GApplication *application,
120 GVariantBuilder *builder);
121 void (* quit_mainloop) (GApplication *application);
122 void (* run_mainloop) (GApplication *application);
123 void (* shutdown) (GApplication *application);
125 /*< private >*/
126 gpointer padding[11];
129 GType g_application_get_type (void) G_GNUC_CONST;
131 gboolean g_application_id_is_valid (const gchar *application_id);
133 GApplication * g_application_new (const gchar *application_id,
134 GApplicationFlags flags);
136 const gchar * g_application_get_application_id (GApplication *application);
137 void g_application_set_application_id (GApplication *application,
138 const gchar *application_id);
140 guint g_application_get_inactivity_timeout (GApplication *application);
141 void g_application_set_inactivity_timeout (GApplication *application,
142 guint inactivity_timeout);
144 GApplicationFlags g_application_get_flags (GApplication *application);
145 void g_application_set_flags (GApplication *application,
146 GApplicationFlags flags);
148 void g_application_set_action_group (GApplication *application,
149 GActionGroup *action_group);
151 gboolean g_application_get_is_registered (GApplication *application);
152 gboolean g_application_get_is_remote (GApplication *application);
154 gboolean g_application_register (GApplication *application,
155 GCancellable *cancellable,
156 GError **error);
158 void g_application_hold (GApplication *application);
159 void g_application_release (GApplication *application);
161 void g_application_activate (GApplication *application);
163 void g_application_open (GApplication *application,
164 GFile **files,
165 gint n_files,
166 const gchar *hint);
168 int g_application_run (GApplication *application,
169 int argc,
170 char **argv);
172 G_END_DECLS
174 #endif /* __G_APPLICATION_H__ */