GApplication: More documentation tweaks
[platform/upstream/glib.git] / gio / gapplication.c
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 /* Prologue {{{1 */
23 #include "config.h"
24
25 #include "gapplication.h"
26
27 #include "gapplicationcommandline.h"
28 #include "gapplicationimpl.h"
29 #include "gactiongroup.h"
30
31 #include "gioenumtypes.h"
32 #include "gio-marshal.h"
33 #include "gioenums.h"
34 #include "gfile.h"
35
36 #include "glibintl.h"
37
38 #include <string.h>
39
40 /**
41  * SECTION:gapplication
42  * @title: GApplication
43  * @short_description: Core application class
44  *
45  * A #GApplication is the foundation of an application, unique for a
46  * given application identifier.  The GApplication class wraps some
47  * low-level platform-specific services and is intended to act as the
48  * foundation for higher-level application classes such as
49  * #GtkApplication or #MxApplication.  In general, you should not use
50  * this class outside of a higher level framework.
51  *
52  * One of the core features that GApplication provides is process
53  * uniqueness, in the context of a "session".  The session concept is
54  * platform-dependent, but corresponds roughly to a graphical desktop
55  * login.  When your application is launched again, its arguments
56  * are passed through platform communication to the already running
57  * program. The already running instance of the program is called the
58  * <firstterm>primary instance</firstterm>.
59  *
60  * Before using GApplication, you must choose an "application identifier".
61  * The expected form of an application identifier is very close to that of
62  * of a <ulink url="http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-interface">DBus bus name</ulink>.
63  * Examples include: "com.example.MyApp", "org.example.internal-apps.Calculator".
64  * For details on valid application identifiers, see
65  * g_application_id_is_valid().
66  *
67  * The application identifier is claimed by the application as a
68  * well-known bus name on the user's session bus.  This means that the
69  * uniqueness of your application is scoped to the current session.  It
70  * also means that your application may provide additional services
71  * (through registration of other object paths) at that bus name.
72  *
73  * The registration of these object paths should be done with the shared
74  * GDBus session bus.  Note that due to the internal architecture of
75  * GDBus, method calls can be dispatched at any time (even if a main
76  * loop is not running).  For this reason, you must ensure that any
77  * object paths that you wish to register are registered before
78  * #GApplication attempts to acquire the bus name of your application
79  * (which happens in g_application_register()).  Unfortunately, this
80  * means that you can not use g_application_get_is_remote() to decide if
81  * you want to register object paths.
82  *
83  * GApplication provides convenient life cycle management by maintaining
84  * a <firstterm>use count</firstterm> for the primary application instance.
85  * The use count can be changed using g_application_hold() and
86  * g_application_release(). If it drops to zero, the application exits.
87  *
88  * GApplication also implements the #GActionGroup interface and lets you
89  * easily export actions by adding them with g_application_set_action_group().
90  * When invoking an action by calling g_action_group_activate_action() on
91  * the application, it is always invoked in the primary instance.
92  *
93  * There is a number of different entry points into a #GApplication:
94  * <itemizedlist>
95  * <listitem>via 'Activate' (i.e. just starting the application)</listitem>
96  * <listitem>via 'Open' (i.e. opening some files)</listitem>
97  * <listitem>by handling a command-line</listitem>
98  * <listitem>via activating an action</listitem>
99  * </itemizedlist>
100  * The #GApplication::startup signal lets you handle the application
101  * initialization for all of these in a single place.
102  *
103  * Regardless of which of these entry points is used to start the application,
104  * GApplication passes some <firstterm id="platform-data">platform
105  * data</firstterm> from the launching instance to the primary instance,
106  * in the form of a #GVariant dictionary mapping strings to variants.
107  * To use platform data, override the @before_emit or @after_emit virtual
108  * functions in your #GApplication subclass. When dealing with
109  * #GApplicationCommandline objects, the platform data is directly
110  * available via g_application_command_line_get_cwd(),
111  * g_application_command_line_get_environ() and
112  * g_application_command_line_get_platform_data().
113  *
114  * As the name indicates, the platform data may vary depending on the
115  * operating system, but it always includes the current directory (key
116  * "cwd"), and optionally the environment (ie the set of environment
117  * variables and their values) of the calling process (key "environ").
118  * The environment is only added to the platform data if the
119  * #G_APPLICATION_SEND_ENVIONMENT flag is set. GApplication subclasses
120  * can add their own platform data by overriding the @add_platform_data
121  * virtual function. For instance, #GtkApplication adds startup notification
122  * data in this way.
123  *
124  * To parse commandline arguments you may handle the
125  * #GApplication::command-line signal or override the local_command_line()
126  * vfunc, to parse them in either the primary instance or the local instance,
127  * respectively.
128  *
129  * <example id="gapplication-example-open"><title>Opening files with a GApplication</title>
130  * <programlisting>
131  * <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../gio/tests/gapplication-example-open.c">
132  *   <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback>
133  * </xi:include>
134  * </programlisting>
135  * </example>
136  *
137  * <example id="gapplication-example-actions"><title>A GApplication with actions</title>
138  * <programlisting>
139  * <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../gio/tests/gapplication-example-actions.c">
140  *   <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback>
141  * </xi:include>
142  * </programlisting>
143  * </example>
144  */
145
146 struct _GApplicationPrivate
147 {
148   GApplicationFlags  flags;
149   gchar             *id;
150
151   GActionGroup      *actions;
152   GMainLoop         *mainloop;
153
154   guint              inactivity_timeout_id;
155   guint              inactivity_timeout;
156   guint              use_count;
157
158   guint              is_registered : 1;
159   guint              is_remote : 1;
160
161   GHashTable        *remote_actions;  /* string -> RemoteActionInfo */
162   GApplicationImpl  *impl;
163 };
164
165 enum
166 {
167   PROP_NONE,
168   PROP_APPLICATION_ID,
169   PROP_FLAGS,
170   PROP_IS_REGISTERED,
171   PROP_IS_REMOTE,
172   PROP_INACTIVITY_TIMEOUT,
173   PROP_ACTION_GROUP
174 };
175
176 enum
177 {
178   SIGNAL_STARTUP,
179   SIGNAL_ACTIVATE,
180   SIGNAL_OPEN,
181   SIGNAL_ACTION,
182   SIGNAL_COMMAND_LINE,
183   NR_SIGNALS
184 };
185
186 static guint g_application_signals[NR_SIGNALS];
187
188 static void g_application_action_group_iface_init (GActionGroupInterface *);
189 G_DEFINE_TYPE_WITH_CODE (GApplication, g_application, G_TYPE_OBJECT,
190  G_IMPLEMENT_INTERFACE (G_TYPE_ACTION_GROUP,
191    g_application_action_group_iface_init))
192
193 /* vfunc defaults {{{1 */
194 static void
195 g_application_real_before_emit (GApplication *application,
196                                 GVariant     *platform_data)
197 {
198 }
199
200 static void
201 g_application_real_after_emit (GApplication *application,
202                                GVariant     *platform_data)
203 {
204 }
205
206 static void
207 g_application_real_startup (GApplication *application)
208 {
209 }
210
211 static void
212 g_application_real_activate (GApplication *application)
213 {
214   if (!g_signal_has_handler_pending (application,
215                                      g_application_signals[SIGNAL_ACTIVATE],
216                                      0, TRUE) &&
217       G_APPLICATION_GET_CLASS (application)->activate == g_application_real_activate)
218     {
219       static gboolean warned;
220
221       if (warned)
222         return;
223
224       g_warning ("Your application does not implement "
225                  "g_application_activate() and has no handlers connected "
226                  "to the 'activate' signal.  It should do one of these.");
227       warned = TRUE;
228     }
229 }
230
231 static void
232 g_application_real_open (GApplication  *application,
233                          GFile        **files,
234                          gint           n_files,
235                          const gchar   *hint)
236 {
237   if (!g_signal_has_handler_pending (application,
238                                      g_application_signals[SIGNAL_OPEN],
239                                      0, TRUE) &&
240       G_APPLICATION_GET_CLASS (application)->open == g_application_real_open)
241     {
242       static gboolean warned;
243
244       if (warned)
245         return;
246
247       g_warning ("Your application claims to support opening files "
248                  "but does not implement g_application_open() and has no "
249                  "handlers connected to the 'open' signal.");
250       warned = TRUE;
251     }
252 }
253
254 static int
255 g_application_real_command_line (GApplication            *application,
256                                  GApplicationCommandLine *cmdline)
257 {
258   static gboolean warned;
259
260   if (warned) 
261     return 1;
262
263   g_warning ("Your application claims to support custom command line "
264              "handling but does not implement g_application_command_line() "
265              "and has no handlers connected to the 'command-line' signal.");
266
267   warned = TRUE;
268
269   return 1;
270 }
271
272 static gboolean
273 g_application_real_local_command_line (GApplication   *application,
274                                        gchar        ***arguments,
275                                        int            *exit_status)
276 {
277   if (application->priv->flags & G_APPLICATION_HANDLES_COMMAND_LINE)
278     return FALSE;
279
280   else
281     {
282       GError *error = NULL;
283       gint n_args;
284
285       if (!g_application_register (application, NULL, &error))
286         {
287           g_critical ("%s", error->message);
288           g_error_free (error);
289           *exit_status = 1;
290           return TRUE;
291         }
292
293       n_args = g_strv_length (*arguments);
294
295       if (application->priv->flags & G_APPLICATION_IS_SERVICE)
296         {
297           if ((*exit_status = n_args > 1))
298             {
299               g_printerr ("GApplication service mode takes no arguments.\n");
300               application->priv->flags &= ~G_APPLICATION_IS_SERVICE;
301             }
302
303           return TRUE;
304         }
305
306       if (n_args <= 1)
307         {
308           g_application_activate (application);
309           *exit_status = 0;
310         }
311
312       else
313         {
314           if (~application->priv->flags & G_APPLICATION_HANDLES_OPEN)
315             {
316               g_critical ("This application can not open files.");
317               *exit_status = 1;
318             }
319           else
320             {
321               GFile **files;
322               gint n_files;
323               gint i;
324
325               n_files = n_args - 1;
326               files = g_new (GFile *, n_files);
327
328               for (i = 0; i < n_files; i++)
329                 files[i] = g_file_new_for_commandline_arg ((*arguments)[i + 1]);
330
331               g_application_open (application, files, n_files, "");
332
333               for (i = 0; i < n_files; i++)
334                 g_object_unref (files[i]);
335               g_free (files);
336
337               *exit_status = 0;
338             }
339         }
340
341       return TRUE;
342     }
343 }
344
345 static void
346 g_application_real_add_platform_data (GApplication    *application,
347                                       GVariantBuilder *builder)
348 {
349 }
350
351 static void
352 g_application_real_quit_mainloop (GApplication *application)
353 {
354   if (application->priv->mainloop != NULL)
355     g_main_loop_quit (application->priv->mainloop);
356 }
357
358 static void
359 g_application_real_run_mainloop (GApplication *application)
360 {
361   if (application->priv->mainloop == NULL)
362     application->priv->mainloop = g_main_loop_new (NULL, FALSE);
363
364   g_main_loop_run (application->priv->mainloop);
365 }
366
367 /* GObject implementation stuff {{{1 */
368 static void
369 g_application_set_property (GObject      *object,
370                             guint         prop_id,
371                             const GValue *value,
372                             GParamSpec   *pspec)
373 {
374   GApplication *application = G_APPLICATION (object);
375
376   switch (prop_id)
377     {
378     case PROP_APPLICATION_ID:
379       g_application_set_application_id (application,
380                                         g_value_get_string (value));
381       break;
382
383     case PROP_FLAGS:
384       g_application_set_flags (application, g_value_get_flags (value));
385       break;
386
387     case PROP_INACTIVITY_TIMEOUT:
388       g_application_set_inactivity_timeout (application,
389                                             g_value_get_uint (value));
390       break;
391
392     case PROP_ACTION_GROUP:
393       g_application_set_action_group (application,
394                                       g_value_get_object (value));
395       break;
396
397     default:
398       g_assert_not_reached ();
399     }
400 }
401
402 /**
403  * g_application_set_action_group:
404  * @application: a #GApplication
405  * @action_group: (allow-none): a #GActionGroup, or %NULL
406  *
407  * Sets or unsets the group of actions associated with the application.
408  *
409  * These actions are the actions that can be remotely invoked.
410  *
411  * It is an error to call this function after the application has been
412  * registered.
413  *
414  * Since: 2.28
415  **/
416 void
417 g_application_set_action_group (GApplication *application,
418                                 GActionGroup *action_group)
419 {
420   g_return_if_fail (G_IS_APPLICATION (application));
421   g_return_if_fail (!application->priv->is_registered);
422
423   if (application->priv->actions != NULL)
424     g_object_unref (application->priv->actions);
425
426   application->priv->actions = action_group;
427
428   if (application->priv->actions != NULL)
429     g_object_ref (application->priv->actions);
430 }
431
432 static void
433 g_application_get_property (GObject    *object,
434                             guint       prop_id,
435                             GValue     *value,
436                             GParamSpec *pspec)
437 {
438   GApplication *application = G_APPLICATION (object);
439
440   switch (prop_id)
441     {
442     case PROP_APPLICATION_ID:
443       g_value_set_string (value,
444                           g_application_get_application_id (application));
445       break;
446
447     case PROP_FLAGS:
448       g_value_set_flags (value,
449                          g_application_get_flags (application));
450       break;
451
452     case PROP_IS_REGISTERED:
453       g_value_set_boolean (value,
454                            g_application_get_is_registered (application));
455       break;
456
457     case PROP_IS_REMOTE:
458       g_value_set_boolean (value,
459                            g_application_get_is_remote (application));
460       break;
461
462     case PROP_INACTIVITY_TIMEOUT:
463       g_value_set_uint (value,
464                         g_application_get_inactivity_timeout (application));
465       break;
466
467     default:
468       g_assert_not_reached ();
469     }
470 }
471
472 static void
473 g_application_constructed (GObject *object)
474 {
475   GApplication *application = G_APPLICATION (object);
476
477   g_assert (application->priv->id != NULL);
478 }
479
480 static void
481 g_application_finalize (GObject *object)
482 {
483   GApplication *application = G_APPLICATION (object);
484
485   if (application->priv->impl)
486     g_application_impl_destroy (application->priv->impl);
487   g_free (application->priv->id);
488
489   if (application->priv->mainloop)
490     g_main_loop_unref (application->priv->mainloop);
491
492   G_OBJECT_CLASS (g_application_parent_class)
493     ->finalize (object);
494 }
495
496 static void
497 g_application_init (GApplication *application)
498 {
499   application->priv = G_TYPE_INSTANCE_GET_PRIVATE (application,
500                                                    G_TYPE_APPLICATION,
501                                                    GApplicationPrivate);
502 }
503
504 static void
505 g_application_class_init (GApplicationClass *class)
506 {
507   GObjectClass *object_class = G_OBJECT_CLASS (class);
508
509   object_class->constructed = g_application_constructed;
510   object_class->finalize = g_application_finalize;
511   object_class->get_property = g_application_get_property;
512   object_class->set_property = g_application_set_property;
513
514   class->before_emit = g_application_real_before_emit;
515   class->after_emit = g_application_real_after_emit;
516   class->startup = g_application_real_startup;
517   class->activate = g_application_real_activate;
518   class->open = g_application_real_open;
519   class->command_line = g_application_real_command_line;
520   class->local_command_line = g_application_real_local_command_line;
521   class->add_platform_data = g_application_real_add_platform_data;
522   class->quit_mainloop = g_application_real_quit_mainloop;
523   class->run_mainloop = g_application_real_run_mainloop;
524
525   g_object_class_install_property (object_class, PROP_APPLICATION_ID,
526     g_param_spec_string ("application-id",
527                          P_("Application identifier"),
528                          P_("The unique identifier for the application"),
529                          NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
530                          G_PARAM_STATIC_STRINGS));
531
532   g_object_class_install_property (object_class, PROP_FLAGS,
533     g_param_spec_flags ("flags",
534                         P_("Application flags"),
535                         P_("Flags specifying the behaviour of the application"),
536                         G_TYPE_APPLICATION_FLAGS, G_APPLICATION_FLAGS_NONE,
537                         G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
538
539   g_object_class_install_property (object_class, PROP_IS_REGISTERED,
540     g_param_spec_boolean ("is-registered",
541                           P_("Is registered"),
542                           P_("If g_application_register() has been called"),
543                           FALSE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
544
545   g_object_class_install_property (object_class, PROP_IS_REMOTE,
546     g_param_spec_boolean ("is-remote",
547                           P_("Is remote"),
548                           P_("If this application instance is remote"),
549                           FALSE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
550
551   g_object_class_install_property (object_class, PROP_INACTIVITY_TIMEOUT,
552     g_param_spec_uint ("inactivity-timeout",
553                        P_("Inactivity timeout"),
554                        P_("Iime (ms) to stay alive after becoming idle"),
555                        0, G_MAXUINT, 0,
556                        G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
557
558   g_object_class_install_property (object_class, PROP_ACTION_GROUP,
559     g_param_spec_object ("action-group",
560                          P_("Action group"),
561                          P_("The group of actions that the application exports"),
562                          G_TYPE_ACTION_GROUP, 
563                          G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
564
565   /**
566    * GApplication::startup:
567    * @application: the application
568    *
569    * The ::startup signal is emitted on the primary instance immediately
570    * after registration. See g_application_register().
571    */
572   g_application_signals[SIGNAL_STARTUP] =
573     g_signal_new ("startup", G_TYPE_APPLICATION, G_SIGNAL_RUN_LAST,
574                   G_STRUCT_OFFSET (GApplicationClass, startup),
575                   NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
576
577   /**
578    * GApplication::activate:
579    * @application: the application
580    *
581    * The ::activate signal is emitted on the primary instance when an
582    * activation occurs. See g_application_activate().
583    */
584   g_application_signals[SIGNAL_ACTIVATE] =
585     g_signal_new ("activate", G_TYPE_APPLICATION, G_SIGNAL_RUN_LAST,
586                   G_STRUCT_OFFSET (GApplicationClass, activate),
587                   NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
588
589
590   /**
591    * GApplication::open:
592    * @application: the application
593    * @files: (array length=n_files) (element-type GFile): an array of #GFiles
594    * @n_files: the length of @files
595    * @hint: a hint provided by the calling instance
596    *
597    * The ::open signal is emitted on the primary instance when there are
598    * files to open. See g_application_open() for more information.
599    */
600   g_application_signals[SIGNAL_OPEN] =
601     g_signal_new ("open", G_TYPE_APPLICATION, G_SIGNAL_RUN_LAST,
602                   G_STRUCT_OFFSET (GApplicationClass, open),
603                   NULL, NULL, _gio_marshal_VOID__POINTER_INT_STRING,
604                   G_TYPE_NONE, 3, G_TYPE_POINTER, G_TYPE_INT, G_TYPE_STRING);
605
606   /**
607    * GApplication::command-line:
608    * @application: the application
609    * @command_line: a #GApplicationCommandLine representing the
610    *     passed commandline
611    *
612    * The ::command-line signal is emitted on the primary instance when
613    * a commandline is not handled locally. See g_application_run() and
614    * the #GApplicationCommandline documentation for more information.
615    *
616    * Returns: An integer that is set as the exit status for the calling
617    *   process. See g_application_command_line_set_exit_status().
618    */
619   g_application_signals[SIGNAL_COMMAND_LINE] =
620     g_signal_new ("command-line", G_TYPE_APPLICATION, G_SIGNAL_RUN_LAST,
621                   G_STRUCT_OFFSET (GApplicationClass, command_line),
622                   g_signal_accumulator_first_wins, NULL,
623                   _gio_marshal_INT__OBJECT,
624                   G_TYPE_INT, 1, G_TYPE_APPLICATION_COMMAND_LINE);
625
626   g_type_class_add_private (class, sizeof (GApplicationPrivate));
627 }
628
629 static GVariant *
630 get_platform_data (GApplication *application)
631 {
632   GVariantBuilder *builder;
633   GVariant *result;
634
635   builder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
636
637   {
638     gchar *cwd = g_get_current_dir ();
639     g_variant_builder_add (builder, "{sv}", "cwd",
640                            g_variant_new_bytestring (cwd));
641     g_free (cwd);
642   }
643
644   if (application->priv->flags & G_APPLICATION_SEND_ENVIRONMENT)
645     {
646       GVariant *array;
647       gchar **envp;
648      
649       envp = g_get_environ ();
650       array = g_variant_new_bytestring_array ((const gchar **) envp, -1);
651       g_strfreev (envp);
652
653       g_variant_builder_add (builder, "{sv}", "environ", array);
654     }
655
656   G_APPLICATION_GET_CLASS (application)->
657     add_platform_data (application, builder);
658
659   result = g_variant_builder_end (builder);
660   g_variant_builder_unref (builder);
661
662   return result;
663 }
664
665 /* Application ID validity {{{1 */
666
667 /**
668  * g_application_id_is_valid:
669  * @application_id: a potential application identifier
670  * @returns: %TRUE if @application_id is valid
671  *
672  * Checks if @application_id is a valid application identifier.
673  *
674  * A valid ID is required for calls to g_application_new() and
675  * g_application_set_application_id().
676  *
677  * For convenience, the restrictions on application identifiers are
678  * reproduced here:
679  * <itemizedlist>
680  *   <listitem>Application identifiers must contain only the ASCII characters "[A-Z][a-z][0-9]_-." and must not begin with a digit.</listitem>
681  *   <listitem>Application identifiers must contain at least one '.' (period) character (and thus at least three elements).</listitem>
682  *   <listitem>Application identifiers must not begin or end with a '.' (period) character.</listitem>
683  *   <listitem>Application identifiers must not contain consecutive '.' (period) characters.</listitem>
684  *   <listitem>Application identifiers must not exceed 255 characters.</listitem>
685  * </itemizedlist>
686  **/
687 gboolean
688 g_application_id_is_valid (const gchar *application_id)
689 {
690   gsize len;
691   gboolean allow_dot;
692   gboolean has_dot;
693
694   len = strlen (application_id);
695
696   if (len > 255)
697     return FALSE;
698
699   if (!g_ascii_isalpha (application_id[0]))
700     return FALSE;
701
702   if (application_id[len-1] == '.')
703     return FALSE;
704
705   application_id++;
706   allow_dot = TRUE;
707   has_dot = FALSE;
708   for (; *application_id; application_id++)
709     {
710       if (g_ascii_isalnum (*application_id) ||
711           (*application_id == '-') ||
712           (*application_id == '_'))
713         {
714           allow_dot = TRUE;
715         }
716       else if (allow_dot && *application_id == '.')
717         {
718           has_dot = TRUE;
719           allow_dot = FALSE;
720         }
721       else
722         return FALSE;
723     }
724
725   if (!has_dot)
726     return FALSE;
727
728   return TRUE;
729 }
730  
731 /* Public Constructor {{{1 */
732 /**
733  * g_application_new:
734  * @application_id: the application id
735  * @flags: the application flags
736  * @returns: a new #GApplication instance
737  *
738  * Creates a new #GApplication instance.
739  *
740  * This function calls g_type_init() for you.
741  *
742  * The application id must be valid.  See g_application_id_is_valid().
743  **/
744 GApplication *
745 g_application_new (const gchar       *application_id,
746                    GApplicationFlags  flags)
747 {
748   g_return_val_if_fail (g_application_id_is_valid (application_id), NULL);
749
750   g_type_init ();
751
752   return g_object_new (G_TYPE_APPLICATION,
753                        "application-id", application_id,
754                        "flags", flags,
755                        NULL);
756 }
757
758 /* Simple get/set: application id, flags, inactivity timeout {{{1 */
759 /**
760  * g_application_get_application_id:
761  * @application: a #GApplication
762  * @returns: the identifier for @application, owned by @application
763  *
764  * Gets the unique identifier for @application.
765  *
766  * Since: 2.28
767  **/
768 const gchar *
769 g_application_get_application_id (GApplication *application)
770 {
771   g_return_val_if_fail (G_IS_APPLICATION (application), NULL);
772
773   return application->priv->id;
774 }
775
776 /**
777  * g_application_set_application_id:
778  * @application: a #GApplication
779  * @application_id: the identifier for @application
780  *
781  * Sets the unique identifier for @application.
782  *
783  * The application id can only be modified if @application has not yet
784  * been registered.
785  *
786  * The application id must be valid.  See g_application_id_is_valid().
787  *
788  * Since: 2.28
789  **/
790 void
791 g_application_set_application_id (GApplication *application,
792                                   const gchar  *application_id)
793 {
794   g_return_if_fail (G_IS_APPLICATION (application));
795
796   if (g_strcmp0 (application->priv->id, application_id) != 0)
797     {
798       g_return_if_fail (g_application_id_is_valid (application_id));
799       g_return_if_fail (!application->priv->is_registered);
800
801       g_free (application->priv->id);
802       application->priv->id = g_strdup (application_id);
803
804       g_object_notify (G_OBJECT (application), "application-id");
805     }
806 }
807
808 /**
809  * g_application_get_flags:
810  * @application: a #GApplication
811  * @returns: the flags for @application
812  *
813  * Gets the flags for @application.
814  *
815  * See #GApplicationFlags.
816  *
817  * Since: 2.28
818  **/
819 GApplicationFlags
820 g_application_get_flags (GApplication *application)
821 {
822   g_return_val_if_fail (G_IS_APPLICATION (application), 0);
823
824   return application->priv->flags;
825 }
826
827 /**
828  * g_application_set_flags:
829  * @application: a #GApplication
830  * @flags: the flags for @application
831  *
832  * Sets the flags for @application.
833  *
834  * The flags can only be modified if @application has not yet been
835  * registered.
836  *
837  * See #GApplicationFlags.
838  *
839  * Since: 2.28
840  **/
841 void
842 g_application_set_flags (GApplication      *application,
843                          GApplicationFlags  flags)
844 {
845   g_return_if_fail (G_IS_APPLICATION (application));
846
847   if (application->priv->flags != flags)
848     {
849       g_return_if_fail (!application->priv->is_registered);
850
851       application->priv->flags = flags;
852
853       g_object_notify (G_OBJECT (application), "flags");
854     }
855 }
856
857 /**
858  * g_application_get_inactivity_timeout:
859  * @application: a #GApplication
860  *
861  * Gets the current inactivity timeout for the application.
862  *
863  * This is the amount of time (in milliseconds) after the last call to
864  * g_application_release() before the application stops running.
865  *
866  * Returns: the timeout, in milliseconds
867  *
868  * Since: 2.28
869  **/
870 guint
871 g_application_get_inactivity_timeout (GApplication *application)
872 {
873   g_return_val_if_fail (G_IS_APPLICATION (application), 0);
874
875   return application->priv->inactivity_timeout;
876 }
877
878 /**
879  * g_application_set_inactivity_timeout:
880  * @application: a #GApplication
881  * @inactivity_timeout: the timeout, in milliseconds
882  *
883  * Sets the current inactivity timeout for the application.
884  *
885  * This is the amount of time (in milliseconds) after the last call to
886  * g_application_release() before the application stops running.
887  *
888  * This call has no side effects of its own.  The value set here is only
889  * used for next time g_application_release() drops the use count to
890  * zero.  Any timeouts currently in progress are not impacted.
891  *
892  * Returns: the timeout, in milliseconds
893  *
894  * Since: 2.28
895  **/
896 void
897 g_application_set_inactivity_timeout (GApplication *application,
898                                       guint         inactivity_timeout)
899 {
900   g_return_if_fail (G_IS_APPLICATION (application));
901
902   if (application->priv->inactivity_timeout != inactivity_timeout)
903     {
904       application->priv->inactivity_timeout = inactivity_timeout;
905
906       g_object_notify (G_OBJECT (application), "inactivity-timeout");
907     }
908 }
909 /* Read-only property getters (is registered, is remote) {{{1 */
910 /**
911  * g_application_get_is_registered:
912  * @application: a #GApplication
913  * @returns: %TRUE if @application is registered
914  *
915  * Checks if @application is registered.
916  *
917  * An application is registered if g_application_register() has been
918  * successfully called.
919  *
920  * Since: 2.28
921  **/
922 gboolean
923 g_application_get_is_registered (GApplication *application)
924 {
925   g_return_val_if_fail (G_IS_APPLICATION (application), FALSE);
926
927   return application->priv->is_registered;
928 }
929
930 /**
931  * g_application_get_is_remote:
932  * @application: a #GApplication
933  * @returns: %TRUE if @application is remote
934  *
935  * Checks if @application is remote.
936  *
937  * If @application is remote then it means that another instance of
938  * application already exists (the 'primary' instance).  Calls to
939  * perform actions on @application will result in the actions being
940  * performed by the primary instance.
941  *
942  * The value of this property can not be accessed before
943  * g_application_register() has been called.  See
944  * g_application_get_is_registered().
945  *
946  * Since: 2.28
947  **/
948 gboolean
949 g_application_get_is_remote (GApplication *application)
950 {
951   g_return_val_if_fail (G_IS_APPLICATION (application), FALSE);
952   g_return_val_if_fail (application->priv->is_registered, FALSE);
953
954   return application->priv->is_remote;
955 }
956
957 /* Register {{{1 */
958 /**
959  * g_application_register:
960  * @application: a #GApplication
961  * @cancellable: a #GCancellable, or %NULL
962  * @error: a pointer to a NULL #GError, or %NULL
963  * @returns: %TRUE if registration succeeded
964  *
965  * Attempts registration of the application.
966  *
967  * This is the point at which the application discovers if it is the
968  * primary instance or merely acting as a remote for an already-existing
969  * primary instance.  This is implemented by attempting to acquire the
970  * application identifier as a unique bus name on the session bus using
971  * GDBus.
972  *
973  * Due to the internal architecture of GDBus, method calls can be
974  * dispatched at any time (even if a main loop is not running).  For
975  * this reason, you must ensure that any object paths that you wish to
976  * register are registered before calling this function.
977  *
978  * If the application has already been registered then %TRUE is
979  * returned with no work performed.
980  *
981  * The #GApplication::startup signal is emitted if registration succeeds
982  * and @application is the primary instance.
983  *
984  * In the event of an error (such as @cancellable being cancelled, or a
985  * failure to connect to the session bus), %FALSE is returned and @error
986  * is set appropriately.
987  *
988  * Note: the return value of this function is not an indicator that this
989  * instance is or is not the primary instance of the application.  See
990  * g_application_get_is_remote() for that.
991  *
992  * Since: 2.28
993  **/
994 gboolean
995 g_application_register (GApplication  *application,
996                         GCancellable  *cancellable,
997                         GError       **error)
998 {
999   g_return_val_if_fail (G_IS_APPLICATION (application), FALSE);
1000
1001   if (!application->priv->is_registered)
1002     {
1003       application->priv->impl =
1004         g_application_impl_register (application, application->priv->id,
1005                                      application->priv->flags,
1006                                      &application->priv->remote_actions,
1007                                      cancellable, error);
1008
1009       if (application->priv->impl == NULL)
1010         return FALSE;
1011
1012       application->priv->is_remote = application->priv->remote_actions != NULL;
1013       application->priv->is_registered = TRUE;
1014
1015       g_object_notify (G_OBJECT (application), "is-registered");
1016
1017       if (!application->priv->is_remote)
1018         g_signal_emit (application, g_application_signals[SIGNAL_STARTUP], 0);
1019     }
1020
1021   return TRUE;
1022 }
1023
1024 /* Hold/release {{{1 */
1025 /**
1026  * g_application_hold:
1027  * @application: a #GApplication
1028  *
1029  * Increases the use count of @application.
1030  *
1031  * Use this function to indicate that the application has a reason to
1032  * continue to run.  For example, g_application_hold() is called by GTK+ 
1033  * when a toplevel window is on the screen.
1034  *
1035  * To cancel the hold, call g_application_release().
1036  **/
1037 void
1038 g_application_hold (GApplication *application)
1039 {
1040   if (application->priv->inactivity_timeout_id)
1041     {
1042       g_source_remove (application->priv->inactivity_timeout_id);
1043       application->priv->inactivity_timeout_id = 0;
1044     }
1045
1046   application->priv->use_count++;
1047 }
1048
1049 static gboolean
1050 inactivity_timeout_expired (gpointer data)
1051 {
1052   GApplication *application = G_APPLICATION (data);
1053
1054   G_APPLICATION_GET_CLASS (application)
1055     ->quit_mainloop (application);
1056
1057   return FALSE;
1058 }
1059
1060
1061 /**
1062  * g_application_release:
1063  * @application: a #GApplication
1064  *
1065  * Decrease the use count of @application.
1066  *
1067  * When the use count reaches zero, the application will stop running.
1068  *
1069  * Never call this function except to cancel the effect of a previous
1070  * call to g_application_hold().
1071  **/
1072 void
1073 g_application_release (GApplication *application)
1074 {
1075   application->priv->use_count--;
1076
1077   if (application->priv->use_count == 0)
1078     {
1079       if (application->priv->inactivity_timeout)
1080         application->priv->inactivity_timeout_id =
1081           g_timeout_add (application->priv->inactivity_timeout,
1082                          inactivity_timeout_expired, application);
1083
1084       else
1085         G_APPLICATION_GET_CLASS (application)
1086           ->quit_mainloop (application);
1087     }
1088 }
1089
1090 /* Activate, Open {{{1 */
1091 /**
1092  * g_application_activate:
1093  * @application: a #GApplication
1094  *
1095  * Activates the application.
1096  *
1097  * In essence, this results in the #GApplication::activate() signal being
1098  * emitted in the primary instance.
1099  *
1100  * The application must be registered before calling this function.
1101  *
1102  * Since: 2.28
1103  **/
1104 void
1105 g_application_activate (GApplication *application)
1106 {
1107   g_return_if_fail (G_IS_APPLICATION (application));
1108   g_return_if_fail (application->priv->is_registered);
1109
1110   if (application->priv->is_remote)
1111     g_application_impl_activate (application->priv->impl,
1112                                  get_platform_data (application));
1113
1114   else
1115     g_signal_emit (application, g_application_signals[SIGNAL_ACTIVATE], 0);
1116 }
1117
1118 /**
1119  * g_application_open:
1120  * @application: a #GApplication
1121  * @files: (array length=n_files): an array of #GFiles to open
1122  * @n_files: the length of the @files array
1123  * @hint: a hint (or ""), but never %NULL
1124  *
1125  * Opens the given files.
1126  *
1127  * In essence, this results in the #GApplication::open signal being emitted
1128  * in the primary instance.
1129  *
1130  * @n_files must be greater than zero.
1131  *
1132  * @hint is simply passed through to the ::open signal.  It is
1133  * intended to be used by applications that have multiple modes for
1134  * opening files (eg: "view" vs "edit", etc).  Unless you have a need
1135  * for this functionality, you should use "".
1136  *
1137  * The application must be registered before calling this function
1138  * and it must have the %G_APPLICATION_HANDLES_OPEN flag set.
1139  *
1140  * Since: 2.28
1141  **/
1142 void
1143 g_application_open (GApplication  *application,
1144                     GFile        **files,
1145                     gint           n_files,
1146                     const gchar   *hint)
1147 {
1148   g_return_if_fail (G_IS_APPLICATION (application));
1149   g_return_if_fail (application->priv->flags &
1150                     G_APPLICATION_HANDLES_OPEN);
1151   g_return_if_fail (application->priv->is_registered);
1152
1153   if (application->priv->is_remote)
1154     g_application_impl_open (application->priv->impl,
1155                              files, n_files, hint,
1156                              get_platform_data (application));
1157
1158   else
1159     g_signal_emit (application, g_application_signals[SIGNAL_OPEN],
1160                    0, files, n_files, hint);
1161 }
1162
1163 /* Run {{{1 */
1164 /**
1165  * g_application_run:
1166  * @application: a #GApplication
1167  * @argc: the argc from main() (or 0 if @argv is %NULL)
1168  * @argv: (array length=argc): the argv from main(), or %NULL
1169  * @returns: the exit status
1170  *
1171  * Runs the application.
1172  *
1173  * This function is intended to be run from main() and its return value
1174  * is intended to be returned by main(). Although you are expected to pass
1175  * the @argc, @argv parameters from main() to this function, it is possible
1176  * to pass %NULL if @argv is not available or commandline handling is not
1177  * required.
1178  *
1179  * First, the local_command_line() virtual function is invoked.
1180  * This function always runs on the local instance. It gets passed a pointer
1181  * to a %NULL-terminated copy of @argv and is expected to remove the arguments
1182  * that it handled (shifting up remaining arguments). See
1183  * <xref linkend="gapplication-example-cmdline2"/> for an example of
1184  * parsing @argv manually. Alternatively, you may use the #GOptionContext API,
1185  * after setting <literal>argc = g_strv_length (argv);</literal>.
1186  *
1187  * The last argument to local_command_line() is a pointer to the @status
1188  * variable which can used to set the exit status that is returned from
1189  * g_application_run().
1190  *
1191  * If local_command_line() returns %TRUE, the command line is expected
1192  * to be completely handled, including possibly registering as the primary
1193  * instance, calling g_application_activate() or g_application_open(), etc.
1194  *
1195  * If local_command_line() returns %FALSE then the application is registered
1196  * and the #GApplication::command-line signal is emitted in the primary
1197  * instance (which may or may not be this instance).
1198  *
1199  * If the application has the %G_APPLICATION_HANDLES_COMMAND_LINE
1200  * flag set then the default implementation of local_command_line()
1201  * always returns %FALSE immediately, resulting in the commandline
1202  * always being handled in the primary instance.
1203  *
1204  * Otherwise, the default implementation of local_command_line() tries
1205  * to do a couple of things that are probably reasonable for most
1206  * applications.  First, g_application_register() is called to attempt
1207  * to register the application.  If that works, then the command line
1208  * arguments are inspected.  If no commandline arguments are given, then
1209  * g_application_activate() is called.  If commandline arguments are
1210  * given and the %G_APPLICATION_HANDLES_OPEN flag is set then they
1211  * are assumed to be filenames and g_application_open() is called.
1212  *
1213  * If you are interested in doing more complicated local handling of the
1214  * commandline then you should implement your own #GApplication subclass
1215  * and override local_command_line(). In this case, you most likely want
1216  * to return %TRUE from your local_command_line() implementation to
1217  * suppress the default handling. See
1218  * <xref linkend="gapplication-example-cmdline2"/> for an example.
1219  *
1220  * If, after the above is done, the use count of the application is zero
1221  * then the exit status is returned immediately.  If the use count is
1222  * non-zero then the mainloop is run until the use count falls to zero,
1223  * at which point 0 is returned.
1224  *
1225  * If the %G_APPLICATION_IS_SERVICE flag is set, then the exiting at
1226  * use count of zero is delayed for a while (ie: the instance stays
1227  * around to provide its <emphasis>service</emphasis> to others).
1228  *
1229  * Since: 2.28
1230  **/
1231 int
1232 g_application_run (GApplication  *application,
1233                    int            argc,
1234                    char         **argv)
1235 {
1236   gchar **arguments;
1237   int status;
1238   gint i;
1239
1240   g_return_val_if_fail (G_IS_APPLICATION (application), 1);
1241   g_return_val_if_fail (argc == 0 || argv != NULL, 1);
1242
1243   arguments = g_new (gchar *, argc + 1);
1244   for (i = 0; i < argc; i++)
1245     arguments[i] = g_strdup (argv[i]);
1246   arguments[i] = NULL;
1247
1248   if (g_get_prgname () == NULL && argc > 0)
1249     {
1250       gchar *prgname;
1251
1252       prgname = g_path_get_basename (argv[0]);
1253       g_set_prgname (prgname);
1254       g_free (prgname);
1255     }
1256
1257   if (!G_APPLICATION_GET_CLASS (application)
1258         ->local_command_line (application, &arguments, &status))
1259     {
1260       GError *error = NULL;
1261
1262       if (!g_application_register (application, NULL, &error))
1263         {
1264           g_printerr ("%s", error->message);
1265           g_error_free (error);
1266           return 1;
1267         }
1268
1269       if (application->priv->is_remote)
1270         {
1271           GVariant *platform_data;
1272
1273           platform_data = get_platform_data (application);
1274           status = g_application_impl_command_line (application->priv->impl,
1275                                                     arguments, platform_data);
1276         }
1277       else
1278         {
1279           GApplicationCommandLine *cmdline;
1280           GVariant *v;
1281
1282           v = g_variant_new_bytestring_array ((const gchar **) arguments, -1);
1283           cmdline = g_object_new (G_TYPE_APPLICATION_COMMAND_LINE,
1284                                   "arguments", v, NULL);
1285           g_signal_emit (application,
1286                          g_application_signals[SIGNAL_COMMAND_LINE],
1287                          0, cmdline, &status);
1288           g_object_unref (cmdline);
1289         }
1290     }
1291
1292   g_strfreev (arguments);
1293
1294   if (application->priv->flags & G_APPLICATION_IS_SERVICE &&
1295       application->priv->is_registered &&
1296       !application->priv->use_count &&
1297       !application->priv->inactivity_timeout_id)
1298     {
1299       application->priv->inactivity_timeout_id =
1300         g_timeout_add (10000, inactivity_timeout_expired, application);
1301     }
1302
1303   if (application->priv->use_count ||
1304       application->priv->inactivity_timeout_id)
1305     {
1306       G_APPLICATION_GET_CLASS (application)
1307         ->run_mainloop (application);
1308       status = 0;
1309     }
1310
1311   if (application->priv->impl)
1312     g_application_impl_flush (application->priv->impl);
1313
1314   return status;
1315 }
1316
1317 static gboolean
1318 g_application_has_action (GActionGroup *action_group,
1319                           const gchar  *action_name)
1320 {
1321   GApplication *application = G_APPLICATION (action_group);
1322
1323   g_return_val_if_fail (application->priv->is_registered, FALSE);
1324
1325   if (application->priv->remote_actions != NULL)
1326     return g_hash_table_lookup (application->priv->remote_actions,
1327                                 action_name) != NULL;
1328
1329   return application->priv->actions &&
1330          g_action_group_has_action (application->priv->actions, action_name);
1331 }
1332
1333 static gchar **
1334 g_application_list_actions (GActionGroup *action_group)
1335 {
1336   GApplication *application = G_APPLICATION (action_group);
1337
1338   g_return_val_if_fail (application->priv->is_registered, NULL);
1339
1340   if (application->priv->remote_actions != NULL)
1341     {
1342       GHashTableIter iter;
1343       gint n, i = 0;
1344       gchar **keys;
1345       gpointer key;
1346
1347       n = g_hash_table_size (application->priv->remote_actions);
1348       keys = g_new (gchar *, n + 1);
1349
1350       g_hash_table_iter_init (&iter, application->priv->remote_actions);
1351       while (g_hash_table_iter_next (&iter, &key, NULL))
1352         keys[i++] = g_strdup (key);
1353       g_assert_cmpint (i, ==, n);
1354       keys[n] = NULL;
1355
1356       return keys;
1357     }
1358
1359   else if (application->priv->actions != NULL)
1360     return g_action_group_list_actions (application->priv->actions);
1361
1362   else
1363     /* empty string array */
1364     return g_new0 (gchar *, 1);
1365 }
1366
1367 static gboolean
1368 g_application_get_action_enabled (GActionGroup *action_group,
1369                                   const gchar  *action_name)
1370 {
1371   GApplication *application = G_APPLICATION (action_group);
1372
1373   g_return_val_if_fail (application->priv->actions != NULL, FALSE);
1374   g_return_val_if_fail (application->priv->is_registered, FALSE);
1375
1376   if (application->priv->remote_actions)
1377     {
1378       RemoteActionInfo *info;
1379
1380       info = g_hash_table_lookup (application->priv->remote_actions,
1381                                   action_name);
1382
1383       return info && info->enabled;
1384     }
1385
1386   return g_action_group_get_action_enabled (application->priv->actions,
1387                                             action_name);
1388 }
1389
1390 static const GVariantType *
1391 g_application_get_action_parameter_type (GActionGroup *action_group,
1392                                          const gchar  *action_name)
1393 {
1394   GApplication *application = G_APPLICATION (action_group);
1395
1396   g_return_val_if_fail (application->priv->actions != NULL, NULL);
1397   g_return_val_if_fail (application->priv->is_registered, NULL);
1398
1399   if (application->priv->remote_actions)
1400     {
1401       RemoteActionInfo *info;
1402
1403       info = g_hash_table_lookup (application->priv->remote_actions,
1404                                   action_name);
1405
1406       if (info)
1407         return info->parameter_type;
1408       else
1409         return NULL;
1410     }
1411
1412   return g_action_group_get_action_parameter_type (application->priv->actions,
1413                                                    action_name);
1414 }
1415
1416 static const GVariantType *
1417 g_application_get_action_state_type (GActionGroup *action_group,
1418                                      const gchar  *action_name)
1419 {
1420   GApplication *application = G_APPLICATION (action_group);
1421
1422   g_return_val_if_fail (application->priv->actions != NULL, NULL);
1423   g_return_val_if_fail (application->priv->is_registered, NULL);
1424
1425   if (application->priv->remote_actions)
1426     {
1427       RemoteActionInfo *info;
1428
1429       info = g_hash_table_lookup (application->priv->remote_actions,
1430                                   action_name);
1431
1432       if (info && info->state)
1433         return g_variant_get_type (info->state);
1434       else
1435         return NULL;
1436     }
1437
1438   return g_action_group_get_action_state_type (application->priv->actions,
1439                                                action_name);
1440 }
1441
1442 static GVariant *
1443 g_application_get_action_state (GActionGroup *action_group,
1444                                 const gchar  *action_name)
1445 {
1446   GApplication *application = G_APPLICATION (action_group);
1447
1448   g_return_val_if_fail (application->priv->actions != NULL, NULL);
1449   g_return_val_if_fail (application->priv->is_registered, NULL);
1450
1451   if (application->priv->remote_actions)
1452     {
1453       RemoteActionInfo *info;
1454
1455       info = g_hash_table_lookup (application->priv->remote_actions,
1456                                   action_name);
1457
1458       if (info && info->state)
1459         return g_variant_ref (info->state);
1460       else
1461         return NULL;
1462     }
1463
1464   return g_action_group_get_action_state (application->priv->actions,
1465                                           action_name);
1466 }
1467
1468 static void
1469 g_application_change_action_state (GActionGroup *action_group,
1470                                    const gchar  *action_name,
1471                                    GVariant     *value)
1472 {
1473   GApplication *application = G_APPLICATION (action_group);
1474
1475   g_return_if_fail (application->priv->is_registered);
1476
1477   if (application->priv->is_remote)
1478     g_application_impl_change_action_state (application->priv->impl,
1479                                             action_name, value,
1480                                             get_platform_data (application));
1481
1482   else
1483     g_action_group_change_action_state (application->priv->actions,
1484                                         action_name, value);
1485 }
1486
1487 static void
1488 g_application_activate_action (GActionGroup *action_group,
1489                                const gchar  *action_name,
1490                                GVariant     *parameter)
1491 {
1492   GApplication *application = G_APPLICATION (action_group);
1493
1494   g_return_if_fail (application->priv->is_registered);
1495
1496   if (application->priv->is_remote)
1497     g_application_impl_activate_action (application->priv->impl,
1498                                         action_name, parameter,
1499                                         get_platform_data (application));
1500
1501   else
1502     g_action_group_activate_action (application->priv->actions,
1503                                     action_name, parameter);
1504 }
1505
1506 static void
1507 g_application_action_group_iface_init (GActionGroupInterface *iface)
1508 {
1509   iface->has_action = g_application_has_action;
1510   iface->list_actions = g_application_list_actions;
1511
1512   iface->get_action_enabled = g_application_get_action_enabled;
1513   iface->get_action_parameter_type = g_application_get_action_parameter_type;
1514   iface->get_action_state_type = g_application_get_action_state_type;
1515   iface->get_action_state = g_application_get_action_state;
1516   iface->change_action_state = g_application_change_action_state;
1517   iface->activate_action = g_application_activate_action;
1518 }
1519
1520 /* Epilogue {{{1 */
1521 /* vim:set foldmethod=marker: */