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>
25 #include "gapplication.h"
27 #include "gapplicationcommandline.h"
28 #include "gsimpleactiongroup.h"
29 #include "gremoteactiongroup.h"
30 #include "gapplicationimpl.h"
31 #include "gactiongroup.h"
32 #include "gactionmap.h"
33 #include "gmenumodel.h"
34 #include "gsettings.h"
36 #include "gioenumtypes.h"
45 * SECTION:gapplication
46 * @title: GApplication
47 * @short_description: Core application class
49 * A #GApplication is the foundation of an application, unique for a
50 * given application identifier. The GApplication class wraps some
51 * low-level platform-specific services and is intended to act as the
52 * foundation for higher-level application classes such as
53 * #GtkApplication or #MxApplication. In general, you should not use
54 * this class outside of a higher level framework.
56 * One of the core features that GApplication provides is process
57 * uniqueness, in the context of a "session". The session concept is
58 * platform-dependent, but corresponds roughly to a graphical desktop
59 * login. When your application is launched again, its arguments
60 * are passed through platform communication to the already running
61 * program. The already running instance of the program is called the
62 * <firstterm>primary instance</firstterm>. On Linux, the D-Bus session
63 * bus is used for communication.
65 * GApplication provides convenient life cycle management by maintaining
66 * a <firstterm>use count</firstterm> for the primary application instance.
67 * The use count can be changed using g_application_hold() and
68 * g_application_release(). If it drops to zero, the application exits.
69 * Higher-level classes such as #GtkApplication employ the use count to
70 * ensure that the application stays alive as long as it has any opened
73 * Before using GApplication, you must choose an "application identifier".
74 * The expected form of an application identifier is very close to that of
75 * of a <ulink url="http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-interface">DBus bus name</ulink>.
76 * Examples include: "com.example.MyApp", "org.example.internal-apps.Calculator".
77 * For details on valid application identifiers, see g_application_id_is_valid().
79 * On Linux, the application identifier is claimed as a well-known bus name
80 * on the user's session bus. This means that the uniqueness of your
81 * application is scoped to the current session. It also means that your
82 * application may provide additional services (through registration of other
83 * object paths) at that bus name. The registration of these object paths
84 * should be done with the shared GDBus session bus. Note that due to the
85 * internal architecture of GDBus, method calls can be dispatched at any time
86 * (even if a main loop is not running). For this reason, you must ensure that
87 * any object paths that you wish to register are registered before #GApplication
88 * attempts to acquire the bus name of your application (which happens in
89 * g_application_register()). Unfortunately, this means that you cannot use
90 * g_application_get_is_remote() to decide if you want to register object paths.
92 * GApplication also implements the #GActionGroup and #GActionMap
93 * interfaces and lets you easily export actions by adding them with
94 * g_action_map_add_action(). When invoking an action by calling
95 * g_action_group_activate_action() on the application, it is always
96 * invoked in the primary instance. The actions are also exported on
97 * the session bus, and GIO provides the #GDBusActionGroup wrapper to
98 * conveniently access them remotely. GIO provides a #GDBusMenuModel wrapper
99 * for remote access to exported #GMenuModels.
101 * There is a number of different entry points into a GApplication:
103 * <listitem>via 'Activate' (i.e. just starting the application)</listitem>
104 * <listitem>via 'Open' (i.e. opening some files)</listitem>
105 * <listitem>by handling a command-line</listitem>
106 * <listitem>via activating an action</listitem>
108 * The #GApplication::startup signal lets you handle the application
109 * initialization for all of these in a single place.
111 * Regardless of which of these entry points is used to start the application,
112 * GApplication passes some <firstterm id="platform-data">platform
113 * data</firstterm> from the launching instance to the primary instance,
114 * in the form of a #GVariant dictionary mapping strings to variants.
115 * To use platform data, override the @before_emit or @after_emit virtual
116 * functions in your #GApplication subclass. When dealing with
117 * #GApplicationCommandLine objects, the platform data is directly
118 * available via g_application_command_line_get_cwd(),
119 * g_application_command_line_get_environ() and
120 * g_application_command_line_get_platform_data().
122 * As the name indicates, the platform data may vary depending on the
123 * operating system, but it always includes the current directory (key
124 * "cwd"), and optionally the environment (ie the set of environment
125 * variables and their values) of the calling process (key "environ").
126 * The environment is only added to the platform data if the
127 * %G_APPLICATION_SEND_ENVIRONMENT flag is set. #GApplication subclasses
128 * can add their own platform data by overriding the @add_platform_data
129 * virtual function. For instance, #GtkApplication adds startup notification
132 * To parse commandline arguments you may handle the
133 * #GApplication::command-line signal or override the local_command_line()
134 * vfunc, to parse them in either the primary instance or the local instance,
137 * <example id="gapplication-example-open"><title>Opening files with a GApplication</title>
139 * <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../gio/tests/gapplication-example-open.c">
140 * <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback>
145 * <example id="gapplication-example-actions"><title>A GApplication with actions</title>
147 * <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../gio/tests/gapplication-example-actions.c">
148 * <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback>
153 * <example id="gapplication-example-menu"><title>A GApplication with menus</title>
155 * <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../gio/tests/gapplication-example-menu.c">
156 * <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback>
164 * @startup: invoked on the primary instance immediately after registration
165 * @shutdown: invoked only on the registered primary instance immediately
166 * after the main loop terminates
167 * @activate: invoked on the primary instance when an activation occurs
168 * @open: invoked on the primary instance when there are files to open
169 * @command_line: invoked on the primary instance when a command-line is
170 * not handled locally
171 * @local_command_line: invoked (locally) when the process has been invoked
172 * via commandline execution (as opposed to, say, D-Bus activation - which
173 * is not currently supported by GApplication). The virtual function has
174 * the chance to inspect (and possibly replace) the list of command line
175 * arguments. See g_application_run() for more information.
176 * @before_emit: invoked on the primary instance before 'activate', 'open',
177 * 'command-line' or any action invocation, gets the 'platform data' from
178 * the calling instance
179 * @after_emit: invoked on the primary instance after 'activate', 'open',
180 * 'command-line' or any action invocation, gets the 'platform data' from
181 * the calling instance
182 * @add_platform_data: invoked (locally) to add 'platform data' to be sent to
183 * the primary instance when activating, opening or invoking actions
184 * @quit_mainloop: Used to be invoked on the primary instance when the use
185 * count of the application drops to zero (and after any inactivity
186 * timeout, if requested). Not used anymore since 2.32
187 * @run_mainloop: Used to be invoked on the primary instance from
188 * g_application_run() if the use-count is non-zero. Since 2.32,
189 * GApplication is iterating the main context directly and is not
190 * using @run_mainloop anymore
192 * Virtual function table for #GApplication.
197 struct _GApplicationPrivate
199 GApplicationFlags flags
;
202 GActionGroup
*actions
;
203 GMenuModel
*app_menu
;
206 guint inactivity_timeout_id
;
207 guint inactivity_timeout
;
210 guint is_registered
: 1;
212 guint did_startup
: 1;
213 guint did_shutdown
: 1;
214 guint must_quit_now
: 1;
216 GRemoteActionGroup
*remote_actions
;
217 GApplicationImpl
*impl
;
227 PROP_INACTIVITY_TIMEOUT
,
242 static guint g_application_signals
[NR_SIGNALS
];
244 static void g_application_action_group_iface_init (GActionGroupInterface
*);
245 static void g_application_action_map_iface_init (GActionMapInterface
*);
246 G_DEFINE_TYPE_WITH_CODE (GApplication
, g_application
, G_TYPE_OBJECT
,
247 G_IMPLEMENT_INTERFACE (G_TYPE_ACTION_GROUP
, g_application_action_group_iface_init
)
248 G_IMPLEMENT_INTERFACE (G_TYPE_ACTION_MAP
, g_application_action_map_iface_init
))
250 /* GApplicationExportedActions {{{1 */
252 /* We create a subclass of GSimpleActionGroup that implements
253 * GRemoteActionGroup and deals with the platform data using
254 * GApplication's before/after_emit vfuncs. This is the action group we
257 * We could implement GRemoteActionGroup on GApplication directly, but
258 * this would be potentially extremely confusing to have exposed as part
259 * of the public API of GApplication. We certainly don't want anyone in
260 * the same process to be calling these APIs...
262 typedef GSimpleActionGroupClass GApplicationExportedActionsClass
;
265 GSimpleActionGroup parent_instance
;
266 GApplication
*application
;
267 } GApplicationExportedActions
;
269 static GType
g_application_exported_actions_get_type (void);
270 static void g_application_exported_actions_iface_init (GRemoteActionGroupInterface
*iface
);
271 G_DEFINE_TYPE_WITH_CODE (GApplicationExportedActions
, g_application_exported_actions
, G_TYPE_SIMPLE_ACTION_GROUP
,
272 G_IMPLEMENT_INTERFACE (G_TYPE_REMOTE_ACTION_GROUP
, g_application_exported_actions_iface_init
))
275 g_application_exported_actions_activate_action_full (GRemoteActionGroup
*remote
,
276 const gchar
*action_name
,
278 GVariant
*platform_data
)
280 GApplicationExportedActions
*exported
= (GApplicationExportedActions
*) remote
;
282 G_APPLICATION_GET_CLASS (exported
->application
)
283 ->before_emit (exported
->application
, platform_data
);
285 g_action_group_activate_action (G_ACTION_GROUP (exported
), action_name
, parameter
);
287 G_APPLICATION_GET_CLASS (exported
->application
)
288 ->after_emit (exported
->application
, platform_data
);
292 g_application_exported_actions_change_action_state_full (GRemoteActionGroup
*remote
,
293 const gchar
*action_name
,
295 GVariant
*platform_data
)
297 GApplicationExportedActions
*exported
= (GApplicationExportedActions
*) remote
;
299 G_APPLICATION_GET_CLASS (exported
->application
)
300 ->before_emit (exported
->application
, platform_data
);
302 g_action_group_change_action_state (G_ACTION_GROUP (exported
), action_name
, value
);
304 G_APPLICATION_GET_CLASS (exported
->application
)
305 ->after_emit (exported
->application
, platform_data
);
309 g_application_exported_actions_init (GApplicationExportedActions
*actions
)
314 g_application_exported_actions_iface_init (GRemoteActionGroupInterface
*iface
)
316 iface
->activate_action_full
= g_application_exported_actions_activate_action_full
;
317 iface
->change_action_state_full
= g_application_exported_actions_change_action_state_full
;
321 g_application_exported_actions_class_init (GApplicationExportedActionsClass
*class)
325 static GActionGroup
*
326 g_application_exported_actions_new (GApplication
*application
)
328 GApplicationExportedActions
*actions
;
330 actions
= g_object_new (g_application_exported_actions_get_type (), NULL
);
331 actions
->application
= application
;
333 return G_ACTION_GROUP (actions
);
336 /* vfunc defaults {{{1 */
338 g_application_real_before_emit (GApplication
*application
,
339 GVariant
*platform_data
)
344 g_application_real_after_emit (GApplication
*application
,
345 GVariant
*platform_data
)
350 g_application_real_startup (GApplication
*application
)
352 application
->priv
->did_startup
= TRUE
;
356 g_application_real_shutdown (GApplication
*application
)
358 application
->priv
->did_shutdown
= TRUE
;
362 g_application_real_activate (GApplication
*application
)
364 if (!g_signal_has_handler_pending (application
,
365 g_application_signals
[SIGNAL_ACTIVATE
],
367 G_APPLICATION_GET_CLASS (application
)->activate
== g_application_real_activate
)
369 static gboolean warned
;
374 g_warning ("Your application does not implement "
375 "g_application_activate() and has no handlers connected "
376 "to the 'activate' signal. It should do one of these.");
382 g_application_real_open (GApplication
*application
,
387 if (!g_signal_has_handler_pending (application
,
388 g_application_signals
[SIGNAL_OPEN
],
390 G_APPLICATION_GET_CLASS (application
)->open
== g_application_real_open
)
392 static gboolean warned
;
397 g_warning ("Your application claims to support opening files "
398 "but does not implement g_application_open() and has no "
399 "handlers connected to the 'open' signal.");
405 g_application_real_command_line (GApplication
*application
,
406 GApplicationCommandLine
*cmdline
)
408 if (!g_signal_has_handler_pending (application
,
409 g_application_signals
[SIGNAL_COMMAND_LINE
],
411 G_APPLICATION_GET_CLASS (application
)->command_line
== g_application_real_command_line
)
413 static gboolean warned
;
418 g_warning ("Your application claims to support custom command line "
419 "handling but does not implement g_application_command_line() "
420 "and has no handlers connected to the 'command-line' signal.");
429 g_application_real_local_command_line (GApplication
*application
,
433 if (application
->priv
->flags
& G_APPLICATION_HANDLES_COMMAND_LINE
)
438 GError
*error
= NULL
;
441 if (!g_application_register (application
, NULL
, &error
))
443 g_critical ("%s", error
->message
);
444 g_error_free (error
);
449 n_args
= g_strv_length (*arguments
);
451 if (application
->priv
->flags
& G_APPLICATION_IS_SERVICE
)
453 if ((*exit_status
= n_args
> 1))
455 g_printerr ("GApplication service mode takes no arguments.\n");
456 application
->priv
->flags
&= ~G_APPLICATION_IS_SERVICE
;
464 g_application_activate (application
);
470 if (~application
->priv
->flags
& G_APPLICATION_HANDLES_OPEN
)
472 g_critical ("This application can not open files.");
481 n_files
= n_args
- 1;
482 files
= g_new (GFile
*, n_files
);
484 for (i
= 0; i
< n_files
; i
++)
485 files
[i
] = g_file_new_for_commandline_arg ((*arguments
)[i
+ 1]);
487 g_application_open (application
, files
, n_files
, "");
489 for (i
= 0; i
< n_files
; i
++)
490 g_object_unref (files
[i
]);
502 g_application_real_add_platform_data (GApplication
*application
,
503 GVariantBuilder
*builder
)
507 /* GObject implementation stuff {{{1 */
509 g_application_set_property (GObject
*object
,
514 GApplication
*application
= G_APPLICATION (object
);
518 case PROP_APPLICATION_ID
:
519 g_application_set_application_id (application
,
520 g_value_get_string (value
));
524 g_application_set_flags (application
, g_value_get_flags (value
));
527 case PROP_INACTIVITY_TIMEOUT
:
528 g_application_set_inactivity_timeout (application
,
529 g_value_get_uint (value
));
532 case PROP_ACTION_GROUP
:
533 g_clear_object (&application
->priv
->actions
);
534 application
->priv
->actions
= g_value_dup_object (value
);
538 g_assert_not_reached ();
543 * g_application_set_action_group:
544 * @application: a #GApplication
545 * @action_group: (allow-none): a #GActionGroup, or %NULL
547 * This used to be how actions were associated with a #GApplication.
548 * Now there is #GActionMap for that.
552 * Deprecated:2.32:Use the #GActionMap interface instead. Never ever
553 * mix use of this API with use of #GActionMap on the same @application
554 * or things will go very badly wrong. This function is known to
555 * introduce buggy behaviour (ie: signals not emitted on changes to the
556 * action group), so you should really use #GActionMap instead.
559 g_application_set_action_group (GApplication
*application
,
560 GActionGroup
*action_group
)
562 g_return_if_fail (G_IS_APPLICATION (application
));
563 g_return_if_fail (!application
->priv
->is_registered
);
565 if (application
->priv
->actions
!= NULL
)
566 g_object_unref (application
->priv
->actions
);
568 application
->priv
->actions
= action_group
;
570 if (application
->priv
->actions
!= NULL
)
571 g_object_ref (application
->priv
->actions
);
575 g_application_get_property (GObject
*object
,
580 GApplication
*application
= G_APPLICATION (object
);
584 case PROP_APPLICATION_ID
:
585 g_value_set_string (value
,
586 g_application_get_application_id (application
));
590 g_value_set_flags (value
,
591 g_application_get_flags (application
));
594 case PROP_IS_REGISTERED
:
595 g_value_set_boolean (value
,
596 g_application_get_is_registered (application
));
600 g_value_set_boolean (value
,
601 g_application_get_is_remote (application
));
604 case PROP_INACTIVITY_TIMEOUT
:
605 g_value_set_uint (value
,
606 g_application_get_inactivity_timeout (application
));
610 g_assert_not_reached ();
615 g_application_constructed (GObject
*object
)
617 GApplication
*application
= G_APPLICATION (object
);
619 g_assert (application
->priv
->id
!= NULL
);
621 if (g_application_get_default () == NULL
)
622 g_application_set_default (application
);
626 g_application_finalize (GObject
*object
)
628 GApplication
*application
= G_APPLICATION (object
);
630 if (application
->priv
->impl
)
631 g_application_impl_destroy (application
->priv
->impl
);
632 g_free (application
->priv
->id
);
634 if (g_application_get_default () == application
)
635 g_application_set_default (NULL
);
637 if (application
->priv
->actions
)
638 g_object_unref (application
->priv
->actions
);
640 G_OBJECT_CLASS (g_application_parent_class
)
645 g_application_init (GApplication
*application
)
647 application
->priv
= G_TYPE_INSTANCE_GET_PRIVATE (application
,
649 GApplicationPrivate
);
651 application
->priv
->actions
= g_application_exported_actions_new (application
);
653 /* application->priv->actions is the one and only ref on the group, so when
654 * we dispose, the action group will die, disconnecting all signals.
656 g_signal_connect_swapped (application
->priv
->actions
, "action-added",
657 G_CALLBACK (g_action_group_action_added
), application
);
658 g_signal_connect_swapped (application
->priv
->actions
, "action-enabled-changed",
659 G_CALLBACK (g_action_group_action_enabled_changed
), application
);
660 g_signal_connect_swapped (application
->priv
->actions
, "action-state-changed",
661 G_CALLBACK (g_action_group_action_state_changed
), application
);
662 g_signal_connect_swapped (application
->priv
->actions
, "action-removed",
663 G_CALLBACK (g_action_group_action_removed
), application
);
667 g_application_class_init (GApplicationClass
*class)
669 GObjectClass
*object_class
= G_OBJECT_CLASS (class);
671 object_class
->constructed
= g_application_constructed
;
672 object_class
->finalize
= g_application_finalize
;
673 object_class
->get_property
= g_application_get_property
;
674 object_class
->set_property
= g_application_set_property
;
676 class->before_emit
= g_application_real_before_emit
;
677 class->after_emit
= g_application_real_after_emit
;
678 class->startup
= g_application_real_startup
;
679 class->shutdown
= g_application_real_shutdown
;
680 class->activate
= g_application_real_activate
;
681 class->open
= g_application_real_open
;
682 class->command_line
= g_application_real_command_line
;
683 class->local_command_line
= g_application_real_local_command_line
;
684 class->add_platform_data
= g_application_real_add_platform_data
;
686 g_object_class_install_property (object_class
, PROP_APPLICATION_ID
,
687 g_param_spec_string ("application-id",
688 P_("Application identifier"),
689 P_("The unique identifier for the application"),
690 NULL
, G_PARAM_READWRITE
| G_PARAM_CONSTRUCT
|
691 G_PARAM_STATIC_STRINGS
));
693 g_object_class_install_property (object_class
, PROP_FLAGS
,
694 g_param_spec_flags ("flags",
695 P_("Application flags"),
696 P_("Flags specifying the behaviour of the application"),
697 G_TYPE_APPLICATION_FLAGS
, G_APPLICATION_FLAGS_NONE
,
698 G_PARAM_READWRITE
| G_PARAM_STATIC_STRINGS
));
700 g_object_class_install_property (object_class
, PROP_IS_REGISTERED
,
701 g_param_spec_boolean ("is-registered",
703 P_("If g_application_register() has been called"),
704 FALSE
, G_PARAM_READABLE
| G_PARAM_STATIC_STRINGS
));
706 g_object_class_install_property (object_class
, PROP_IS_REMOTE
,
707 g_param_spec_boolean ("is-remote",
709 P_("If this application instance is remote"),
710 FALSE
, G_PARAM_READABLE
| G_PARAM_STATIC_STRINGS
));
712 g_object_class_install_property (object_class
, PROP_INACTIVITY_TIMEOUT
,
713 g_param_spec_uint ("inactivity-timeout",
714 P_("Inactivity timeout"),
715 P_("Time (ms) to stay alive after becoming idle"),
717 G_PARAM_READWRITE
| G_PARAM_STATIC_STRINGS
));
719 g_object_class_install_property (object_class
, PROP_ACTION_GROUP
,
720 g_param_spec_object ("action-group",
722 P_("The group of actions that the application exports"),
724 G_PARAM_DEPRECATED
| G_PARAM_WRITABLE
| G_PARAM_STATIC_STRINGS
));
727 * GApplication::startup:
728 * @application: the application
730 * The ::startup signal is emitted on the primary instance immediately
731 * after registration. See g_application_register().
733 g_application_signals
[SIGNAL_STARTUP
] =
734 g_signal_new ("startup", G_TYPE_APPLICATION
, G_SIGNAL_RUN_FIRST
,
735 G_STRUCT_OFFSET (GApplicationClass
, startup
),
736 NULL
, NULL
, g_cclosure_marshal_VOID__VOID
, G_TYPE_NONE
, 0);
739 * GApplication::shutdown:
740 * @application: the application
742 * The ::shutdown signal is emitted only on the registered primary instance
743 * immediately after the main loop terminates.
745 g_application_signals
[SIGNAL_SHUTDOWN
] =
746 g_signal_new ("shutdown", G_TYPE_APPLICATION
, G_SIGNAL_RUN_LAST
,
747 G_STRUCT_OFFSET (GApplicationClass
, shutdown
),
748 NULL
, NULL
, g_cclosure_marshal_VOID__VOID
, G_TYPE_NONE
, 0);
751 * GApplication::activate:
752 * @application: the application
754 * The ::activate signal is emitted on the primary instance when an
755 * activation occurs. See g_application_activate().
757 g_application_signals
[SIGNAL_ACTIVATE
] =
758 g_signal_new ("activate", G_TYPE_APPLICATION
, G_SIGNAL_RUN_LAST
,
759 G_STRUCT_OFFSET (GApplicationClass
, activate
),
760 NULL
, NULL
, g_cclosure_marshal_VOID__VOID
, G_TYPE_NONE
, 0);
764 * GApplication::open:
765 * @application: the application
766 * @files: (array length=n_files) (element-type GFile): an array of #GFiles
767 * @n_files: the length of @files
768 * @hint: a hint provided by the calling instance
770 * The ::open signal is emitted on the primary instance when there are
771 * files to open. See g_application_open() for more information.
773 g_application_signals
[SIGNAL_OPEN
] =
774 g_signal_new ("open", G_TYPE_APPLICATION
, G_SIGNAL_RUN_LAST
,
775 G_STRUCT_OFFSET (GApplicationClass
, open
),
777 G_TYPE_NONE
, 3, G_TYPE_POINTER
, G_TYPE_INT
, G_TYPE_STRING
);
780 * GApplication::command-line:
781 * @application: the application
782 * @command_line: a #GApplicationCommandLine representing the
785 * The ::command-line signal is emitted on the primary instance when
786 * a commandline is not handled locally. See g_application_run() and
787 * the #GApplicationCommandLine documentation for more information.
789 * Returns: An integer that is set as the exit status for the calling
790 * process. See g_application_command_line_set_exit_status().
792 g_application_signals
[SIGNAL_COMMAND_LINE
] =
793 g_signal_new ("command-line", G_TYPE_APPLICATION
, G_SIGNAL_RUN_LAST
,
794 G_STRUCT_OFFSET (GApplicationClass
, command_line
),
795 g_signal_accumulator_first_wins
, NULL
,
797 G_TYPE_INT
, 1, G_TYPE_APPLICATION_COMMAND_LINE
);
799 g_type_class_add_private (class, sizeof (GApplicationPrivate
));
803 get_platform_data (GApplication
*application
)
805 GVariantBuilder
*builder
;
808 builder
= g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
811 gchar
*cwd
= g_get_current_dir ();
812 g_variant_builder_add (builder
, "{sv}", "cwd",
813 g_variant_new_bytestring (cwd
));
817 if (application
->priv
->flags
& G_APPLICATION_SEND_ENVIRONMENT
)
822 envp
= g_get_environ ();
823 array
= g_variant_new_bytestring_array ((const gchar
**) envp
, -1);
826 g_variant_builder_add (builder
, "{sv}", "environ", array
);
829 G_APPLICATION_GET_CLASS (application
)->
830 add_platform_data (application
, builder
);
832 result
= g_variant_builder_end (builder
);
833 g_variant_builder_unref (builder
);
838 /* Application ID validity {{{1 */
841 * g_application_id_is_valid:
842 * @application_id: a potential application identifier
844 * Checks if @application_id is a valid application identifier.
846 * A valid ID is required for calls to g_application_new() and
847 * g_application_set_application_id().
849 * For convenience, the restrictions on application identifiers are
852 * <listitem>Application identifiers must contain only the ASCII characters "[A-Z][a-z][0-9]_-." and must not begin with a digit.</listitem>
853 * <listitem>Application identifiers must contain at least one '.' (period) character (and thus at least three elements).</listitem>
854 * <listitem>Application identifiers must not begin or end with a '.' (period) character.</listitem>
855 * <listitem>Application identifiers must not contain consecutive '.' (period) characters.</listitem>
856 * <listitem>Application identifiers must not exceed 255 characters.</listitem>
859 * Returns: %TRUE if @application_id is valid
862 g_application_id_is_valid (const gchar
*application_id
)
868 len
= strlen (application_id
);
873 if (!g_ascii_isalpha (application_id
[0]))
876 if (application_id
[len
-1] == '.')
882 for (; *application_id
; application_id
++)
884 if (g_ascii_isalnum (*application_id
) ||
885 (*application_id
== '-') ||
886 (*application_id
== '_'))
890 else if (allow_dot
&& *application_id
== '.')
905 /* Public Constructor {{{1 */
908 * @application_id: the application id
909 * @flags: the application flags
911 * Creates a new #GApplication instance.
913 * This function calls g_type_init() for you.
915 * The application id must be valid. See g_application_id_is_valid().
917 * Returns: a new #GApplication instance
920 g_application_new (const gchar
*application_id
,
921 GApplicationFlags flags
)
923 g_return_val_if_fail (g_application_id_is_valid (application_id
), NULL
);
927 return g_object_new (G_TYPE_APPLICATION
,
928 "application-id", application_id
,
933 /* Simple get/set: application id, flags, inactivity timeout {{{1 */
935 * g_application_get_application_id:
936 * @application: a #GApplication
938 * Gets the unique identifier for @application.
940 * Returns: the identifier for @application, owned by @application
945 g_application_get_application_id (GApplication
*application
)
947 g_return_val_if_fail (G_IS_APPLICATION (application
), NULL
);
949 return application
->priv
->id
;
953 * g_application_set_application_id:
954 * @application: a #GApplication
955 * @application_id: the identifier for @application
957 * Sets the unique identifier for @application.
959 * The application id can only be modified if @application has not yet
962 * The application id must be valid. See g_application_id_is_valid().
967 g_application_set_application_id (GApplication
*application
,
968 const gchar
*application_id
)
970 g_return_if_fail (G_IS_APPLICATION (application
));
972 if (g_strcmp0 (application
->priv
->id
, application_id
) != 0)
974 g_return_if_fail (g_application_id_is_valid (application_id
));
975 g_return_if_fail (!application
->priv
->is_registered
);
977 g_free (application
->priv
->id
);
978 application
->priv
->id
= g_strdup (application_id
);
980 g_object_notify (G_OBJECT (application
), "application-id");
985 * g_application_get_flags:
986 * @application: a #GApplication
988 * Gets the flags for @application.
990 * See #GApplicationFlags.
992 * Returns: the flags for @application
997 g_application_get_flags (GApplication
*application
)
999 g_return_val_if_fail (G_IS_APPLICATION (application
), 0);
1001 return application
->priv
->flags
;
1005 * g_application_set_flags:
1006 * @application: a #GApplication
1007 * @flags: the flags for @application
1009 * Sets the flags for @application.
1011 * The flags can only be modified if @application has not yet been
1014 * See #GApplicationFlags.
1019 g_application_set_flags (GApplication
*application
,
1020 GApplicationFlags flags
)
1022 g_return_if_fail (G_IS_APPLICATION (application
));
1024 if (application
->priv
->flags
!= flags
)
1026 g_return_if_fail (!application
->priv
->is_registered
);
1028 application
->priv
->flags
= flags
;
1030 g_object_notify (G_OBJECT (application
), "flags");
1035 * g_application_get_inactivity_timeout:
1036 * @application: a #GApplication
1038 * Gets the current inactivity timeout for the application.
1040 * This is the amount of time (in milliseconds) after the last call to
1041 * g_application_release() before the application stops running.
1043 * Returns: the timeout, in milliseconds
1048 g_application_get_inactivity_timeout (GApplication
*application
)
1050 g_return_val_if_fail (G_IS_APPLICATION (application
), 0);
1052 return application
->priv
->inactivity_timeout
;
1056 * g_application_set_inactivity_timeout:
1057 * @application: a #GApplication
1058 * @inactivity_timeout: the timeout, in milliseconds
1060 * Sets the current inactivity timeout for the application.
1062 * This is the amount of time (in milliseconds) after the last call to
1063 * g_application_release() before the application stops running.
1065 * This call has no side effects of its own. The value set here is only
1066 * used for next time g_application_release() drops the use count to
1067 * zero. Any timeouts currently in progress are not impacted.
1072 g_application_set_inactivity_timeout (GApplication
*application
,
1073 guint inactivity_timeout
)
1075 g_return_if_fail (G_IS_APPLICATION (application
));
1077 if (application
->priv
->inactivity_timeout
!= inactivity_timeout
)
1079 application
->priv
->inactivity_timeout
= inactivity_timeout
;
1081 g_object_notify (G_OBJECT (application
), "inactivity-timeout");
1084 /* Read-only property getters (is registered, is remote) {{{1 */
1086 * g_application_get_is_registered:
1087 * @application: a #GApplication
1089 * Checks if @application is registered.
1091 * An application is registered if g_application_register() has been
1092 * successfully called.
1094 * Returns: %TRUE if @application is registered
1099 g_application_get_is_registered (GApplication
*application
)
1101 g_return_val_if_fail (G_IS_APPLICATION (application
), FALSE
);
1103 return application
->priv
->is_registered
;
1107 * g_application_get_is_remote:
1108 * @application: a #GApplication
1110 * Checks if @application is remote.
1112 * If @application is remote then it means that another instance of
1113 * application already exists (the 'primary' instance). Calls to
1114 * perform actions on @application will result in the actions being
1115 * performed by the primary instance.
1117 * The value of this property cannot be accessed before
1118 * g_application_register() has been called. See
1119 * g_application_get_is_registered().
1121 * Returns: %TRUE if @application is remote
1126 g_application_get_is_remote (GApplication
*application
)
1128 g_return_val_if_fail (G_IS_APPLICATION (application
), FALSE
);
1129 g_return_val_if_fail (application
->priv
->is_registered
, FALSE
);
1131 return application
->priv
->is_remote
;
1136 * g_application_register:
1137 * @application: a #GApplication
1138 * @cancellable: a #GCancellable, or %NULL
1139 * @error: a pointer to a NULL #GError, or %NULL
1141 * Attempts registration of the application.
1143 * This is the point at which the application discovers if it is the
1144 * primary instance or merely acting as a remote for an already-existing
1145 * primary instance. This is implemented by attempting to acquire the
1146 * application identifier as a unique bus name on the session bus using
1149 * Due to the internal architecture of GDBus, method calls can be
1150 * dispatched at any time (even if a main loop is not running). For
1151 * this reason, you must ensure that any object paths that you wish to
1152 * register are registered before calling this function.
1154 * If the application has already been registered then %TRUE is
1155 * returned with no work performed.
1157 * The #GApplication::startup signal is emitted if registration succeeds
1158 * and @application is the primary instance.
1160 * In the event of an error (such as @cancellable being cancelled, or a
1161 * failure to connect to the session bus), %FALSE is returned and @error
1162 * is set appropriately.
1164 * Note: the return value of this function is not an indicator that this
1165 * instance is or is not the primary instance of the application. See
1166 * g_application_get_is_remote() for that.
1168 * Returns: %TRUE if registration succeeded
1173 g_application_register (GApplication
*application
,
1174 GCancellable
*cancellable
,
1177 g_return_val_if_fail (G_IS_APPLICATION (application
), FALSE
);
1179 if (!application
->priv
->is_registered
)
1181 application
->priv
->impl
=
1182 g_application_impl_register (application
, application
->priv
->id
,
1183 application
->priv
->flags
,
1184 application
->priv
->actions
,
1185 &application
->priv
->remote_actions
,
1186 cancellable
, error
);
1188 if (application
->priv
->impl
== NULL
)
1191 application
->priv
->is_remote
= application
->priv
->remote_actions
!= NULL
;
1192 application
->priv
->is_registered
= TRUE
;
1194 g_object_notify (G_OBJECT (application
), "is-registered");
1196 if (!application
->priv
->is_remote
)
1198 g_signal_emit (application
, g_application_signals
[SIGNAL_STARTUP
], 0);
1200 if (!application
->priv
->did_startup
)
1201 g_critical ("GApplication subclass '%s' failed to chain up on"
1202 " ::startup (from start of override function)",
1203 G_OBJECT_TYPE_NAME (application
));
1210 /* Hold/release {{{1 */
1212 * g_application_hold:
1213 * @application: a #GApplication
1215 * Increases the use count of @application.
1217 * Use this function to indicate that the application has a reason to
1218 * continue to run. For example, g_application_hold() is called by GTK+
1219 * when a toplevel window is on the screen.
1221 * To cancel the hold, call g_application_release().
1224 g_application_hold (GApplication
*application
)
1226 if (application
->priv
->inactivity_timeout_id
)
1228 g_source_remove (application
->priv
->inactivity_timeout_id
);
1229 application
->priv
->inactivity_timeout_id
= 0;
1232 application
->priv
->use_count
++;
1236 inactivity_timeout_expired (gpointer data
)
1238 GApplication
*application
= G_APPLICATION (data
);
1240 application
->priv
->inactivity_timeout_id
= 0;
1242 return G_SOURCE_REMOVE
;
1247 * g_application_release:
1248 * @application: a #GApplication
1250 * Decrease the use count of @application.
1252 * When the use count reaches zero, the application will stop running.
1254 * Never call this function except to cancel the effect of a previous
1255 * call to g_application_hold().
1258 g_application_release (GApplication
*application
)
1260 application
->priv
->use_count
--;
1262 if (application
->priv
->use_count
== 0 && application
->priv
->inactivity_timeout
)
1263 application
->priv
->inactivity_timeout_id
= g_timeout_add (application
->priv
->inactivity_timeout
,
1264 inactivity_timeout_expired
, application
);
1267 /* Activate, Open {{{1 */
1269 * g_application_activate:
1270 * @application: a #GApplication
1272 * Activates the application.
1274 * In essence, this results in the #GApplication::activate signal being
1275 * emitted in the primary instance.
1277 * The application must be registered before calling this function.
1282 g_application_activate (GApplication
*application
)
1284 g_return_if_fail (G_IS_APPLICATION (application
));
1285 g_return_if_fail (application
->priv
->is_registered
);
1287 if (application
->priv
->is_remote
)
1288 g_application_impl_activate (application
->priv
->impl
,
1289 get_platform_data (application
));
1292 g_signal_emit (application
, g_application_signals
[SIGNAL_ACTIVATE
], 0);
1296 * g_application_open:
1297 * @application: a #GApplication
1298 * @files: (array length=n_files): an array of #GFiles to open
1299 * @n_files: the length of the @files array
1300 * @hint: a hint (or ""), but never %NULL
1302 * Opens the given files.
1304 * In essence, this results in the #GApplication::open signal being emitted
1305 * in the primary instance.
1307 * @n_files must be greater than zero.
1309 * @hint is simply passed through to the ::open signal. It is
1310 * intended to be used by applications that have multiple modes for
1311 * opening files (eg: "view" vs "edit", etc). Unless you have a need
1312 * for this functionality, you should use "".
1314 * The application must be registered before calling this function
1315 * and it must have the %G_APPLICATION_HANDLES_OPEN flag set.
1320 g_application_open (GApplication
*application
,
1325 g_return_if_fail (G_IS_APPLICATION (application
));
1326 g_return_if_fail (application
->priv
->flags
&
1327 G_APPLICATION_HANDLES_OPEN
);
1328 g_return_if_fail (application
->priv
->is_registered
);
1330 if (application
->priv
->is_remote
)
1331 g_application_impl_open (application
->priv
->impl
,
1332 files
, n_files
, hint
,
1333 get_platform_data (application
));
1336 g_signal_emit (application
, g_application_signals
[SIGNAL_OPEN
],
1337 0, files
, n_files
, hint
);
1342 * g_application_run:
1343 * @application: a #GApplication
1344 * @argc: the argc from main() (or 0 if @argv is %NULL)
1345 * @argv: (array length=argc) (allow-none): the argv from main(), or %NULL
1347 * Runs the application.
1349 * This function is intended to be run from main() and its return value
1350 * is intended to be returned by main(). Although you are expected to pass
1351 * the @argc, @argv parameters from main() to this function, it is possible
1352 * to pass %NULL if @argv is not available or commandline handling is not
1355 * First, the local_command_line() virtual function is invoked.
1356 * This function always runs on the local instance. It gets passed a pointer
1357 * to a %NULL-terminated copy of @argv and is expected to remove the arguments
1358 * that it handled (shifting up remaining arguments). See
1359 * <xref linkend="gapplication-example-cmdline2"/> for an example of
1360 * parsing @argv manually. Alternatively, you may use the #GOptionContext API,
1361 * after setting <literal>argc = g_strv_length (argv);</literal>.
1363 * The last argument to local_command_line() is a pointer to the @status
1364 * variable which can used to set the exit status that is returned from
1365 * g_application_run().
1367 * If local_command_line() returns %TRUE, the command line is expected
1368 * to be completely handled, including possibly registering as the primary
1369 * instance, calling g_application_activate() or g_application_open(), etc.
1371 * If local_command_line() returns %FALSE then the application is registered
1372 * and the #GApplication::command-line signal is emitted in the primary
1373 * instance (which may or may not be this instance). The signal handler
1374 * gets passed a #GApplicationCommandLine object that (among other things)
1375 * contains the remaining commandline arguments that have not been handled
1376 * by local_command_line().
1378 * If the application has the %G_APPLICATION_HANDLES_COMMAND_LINE
1379 * flag set then the default implementation of local_command_line()
1380 * always returns %FALSE immediately, resulting in the commandline
1381 * always being handled in the primary instance.
1383 * Otherwise, the default implementation of local_command_line() tries
1384 * to do a couple of things that are probably reasonable for most
1385 * applications. First, g_application_register() is called to attempt
1386 * to register the application. If that works, then the command line
1387 * arguments are inspected. If no commandline arguments are given, then
1388 * g_application_activate() is called. If commandline arguments are
1389 * given and the %G_APPLICATION_HANDLES_OPEN flag is set then they
1390 * are assumed to be filenames and g_application_open() is called.
1392 * If you need to handle commandline arguments that are not filenames,
1393 * and you don't mind commandline handling to happen in the primary
1394 * instance, you should set %G_APPLICATION_HANDLES_COMMAND_LINE and
1395 * process the commandline arguments in your #GApplication::command-line
1396 * signal handler, either manually or using the #GOptionContext API.
1398 * If you are interested in doing more complicated local handling of the
1399 * commandline then you should implement your own #GApplication subclass
1400 * and override local_command_line(). In this case, you most likely want
1401 * to return %TRUE from your local_command_line() implementation to
1402 * suppress the default handling. See
1403 * <xref linkend="gapplication-example-cmdline2"/> for an example.
1405 * If, after the above is done, the use count of the application is zero
1406 * then the exit status is returned immediately. If the use count is
1407 * non-zero then the default main context is iterated until the use count
1408 * falls to zero, at which point 0 is returned.
1410 * If the %G_APPLICATION_IS_SERVICE flag is set, then the exiting at
1411 * use count of zero is delayed for a while (ie: the instance stays
1412 * around to provide its <emphasis>service</emphasis> to others).
1414 * Returns: the exit status
1419 g_application_run (GApplication
*application
,
1427 g_return_val_if_fail (G_IS_APPLICATION (application
), 1);
1428 g_return_val_if_fail (argc
== 0 || argv
!= NULL
, 1);
1429 g_return_val_if_fail (!application
->priv
->must_quit_now
, 1);
1431 arguments
= g_new (gchar
*, argc
+ 1);
1432 for (i
= 0; i
< argc
; i
++)
1433 arguments
[i
] = g_strdup (argv
[i
]);
1434 arguments
[i
] = NULL
;
1436 if (g_get_prgname () == NULL
&& argc
> 0)
1440 prgname
= g_path_get_basename (argv
[0]);
1441 g_set_prgname (prgname
);
1445 if (!G_APPLICATION_GET_CLASS (application
)
1446 ->local_command_line (application
, &arguments
, &status
))
1448 GError
*error
= NULL
;
1450 if (!g_application_register (application
, NULL
, &error
))
1452 g_printerr ("%s", error
->message
);
1453 g_error_free (error
);
1457 if (application
->priv
->is_remote
)
1459 GVariant
*platform_data
;
1461 platform_data
= get_platform_data (application
);
1462 status
= g_application_impl_command_line (application
->priv
->impl
,
1463 arguments
, platform_data
);
1467 GApplicationCommandLine
*cmdline
;
1470 v
= g_variant_new_bytestring_array ((const gchar
**) arguments
, -1);
1471 cmdline
= g_object_new (G_TYPE_APPLICATION_COMMAND_LINE
,
1472 "arguments", v
, NULL
);
1473 g_signal_emit (application
,
1474 g_application_signals
[SIGNAL_COMMAND_LINE
],
1475 0, cmdline
, &status
);
1476 g_object_unref (cmdline
);
1480 g_strfreev (arguments
);
1482 if (application
->priv
->flags
& G_APPLICATION_IS_SERVICE
&&
1483 application
->priv
->is_registered
&&
1484 !application
->priv
->use_count
&&
1485 !application
->priv
->inactivity_timeout_id
)
1487 application
->priv
->inactivity_timeout_id
=
1488 g_timeout_add (10000, inactivity_timeout_expired
, application
);
1491 while (application
->priv
->use_count
|| application
->priv
->inactivity_timeout_id
)
1493 if (application
->priv
->must_quit_now
)
1496 g_main_context_iteration (NULL
, TRUE
);
1500 if (!application
->priv
->is_remote
)
1502 g_signal_emit (application
, g_application_signals
[SIGNAL_SHUTDOWN
], 0);
1504 if (!application
->priv
->did_shutdown
)
1505 g_critical ("GApplication subclass '%s' failed to chain up on"
1506 " ::shutdown (from end of override function)",
1507 G_OBJECT_TYPE_NAME (application
));
1510 if (application
->priv
->impl
)
1511 g_application_impl_flush (application
->priv
->impl
);
1519 g_application_list_actions (GActionGroup
*action_group
)
1521 GApplication
*application
= G_APPLICATION (action_group
);
1523 g_return_val_if_fail (application
->priv
->is_registered
, NULL
);
1525 if (application
->priv
->remote_actions
!= NULL
)
1526 return g_action_group_list_actions (G_ACTION_GROUP (application
->priv
->remote_actions
));
1528 else if (application
->priv
->actions
!= NULL
)
1529 return g_action_group_list_actions (application
->priv
->actions
);
1532 /* empty string array */
1533 return g_new0 (gchar
*, 1);
1537 g_application_query_action (GActionGroup
*group
,
1538 const gchar
*action_name
,
1540 const GVariantType
**parameter_type
,
1541 const GVariantType
**state_type
,
1542 GVariant
**state_hint
,
1545 GApplication
*application
= G_APPLICATION (group
);
1547 g_return_val_if_fail (application
->priv
->is_registered
, FALSE
);
1549 if (application
->priv
->remote_actions
!= NULL
)
1550 return g_action_group_query_action (G_ACTION_GROUP (application
->priv
->remote_actions
),
1558 if (application
->priv
->actions
!= NULL
)
1559 return g_action_group_query_action (application
->priv
->actions
,
1571 g_application_change_action_state (GActionGroup
*action_group
,
1572 const gchar
*action_name
,
1575 GApplication
*application
= G_APPLICATION (action_group
);
1577 g_return_if_fail (application
->priv
->is_remote
||
1578 application
->priv
->actions
!= NULL
);
1579 g_return_if_fail (application
->priv
->is_registered
);
1581 if (application
->priv
->remote_actions
)
1582 g_remote_action_group_change_action_state_full (application
->priv
->remote_actions
,
1583 action_name
, value
, get_platform_data (application
));
1586 g_action_group_change_action_state (application
->priv
->actions
, action_name
, value
);
1590 g_application_activate_action (GActionGroup
*action_group
,
1591 const gchar
*action_name
,
1592 GVariant
*parameter
)
1594 GApplication
*application
= G_APPLICATION (action_group
);
1596 g_return_if_fail (application
->priv
->is_remote
||
1597 application
->priv
->actions
!= NULL
);
1598 g_return_if_fail (application
->priv
->is_registered
);
1600 if (application
->priv
->remote_actions
)
1601 g_remote_action_group_activate_action_full (application
->priv
->remote_actions
,
1602 action_name
, parameter
, get_platform_data (application
));
1605 g_action_group_activate_action (application
->priv
->actions
, action_name
, parameter
);
1609 g_application_lookup_action (GActionMap
*action_map
,
1610 const gchar
*action_name
)
1612 GApplication
*application
= G_APPLICATION (action_map
);
1614 g_return_val_if_fail (G_IS_SIMPLE_ACTION_GROUP (application
->priv
->actions
), NULL
);
1616 return g_simple_action_group_lookup (G_SIMPLE_ACTION_GROUP (application
->priv
->actions
), action_name
);
1620 g_application_add_action (GActionMap
*action_map
,
1623 GApplication
*application
= G_APPLICATION (action_map
);
1625 g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP (application
->priv
->actions
));
1627 g_simple_action_group_insert (G_SIMPLE_ACTION_GROUP (application
->priv
->actions
), action
);
1631 g_application_remove_action (GActionMap
*action_map
,
1632 const gchar
*action_name
)
1634 GApplication
*application
= G_APPLICATION (action_map
);
1636 g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP (application
->priv
->actions
));
1638 g_simple_action_group_remove (G_SIMPLE_ACTION_GROUP (application
->priv
->actions
), action_name
);
1642 g_application_action_group_iface_init (GActionGroupInterface
*iface
)
1644 iface
->list_actions
= g_application_list_actions
;
1645 iface
->query_action
= g_application_query_action
;
1646 iface
->change_action_state
= g_application_change_action_state
;
1647 iface
->activate_action
= g_application_activate_action
;
1651 g_application_action_map_iface_init (GActionMapInterface
*iface
)
1653 iface
->lookup_action
= g_application_lookup_action
;
1654 iface
->add_action
= g_application_add_action
;
1655 iface
->remove_action
= g_application_remove_action
;
1658 /* Default Application {{{1 */
1660 static GApplication
*default_app
;
1663 * g_application_get_default:
1665 * Returns the default #GApplication instance for this process.
1667 * Normally there is only one #GApplication per process and it becomes
1668 * the default when it is created. You can exercise more control over
1669 * this by using g_application_set_default().
1671 * If there is no default application then %NULL is returned.
1673 * Returns: (transfer none): the default application for this process, or %NULL
1678 g_application_get_default (void)
1684 * g_application_set_default:
1685 * @application: the application to set as default, or %NULL
1687 * Sets or unsets the default application for the process, as returned
1688 * by g_application_get_default().
1690 * This function does not take its own reference on @application. If
1691 * @application is destroyed then the default application will revert
1697 g_application_set_default (GApplication
*application
)
1699 default_app
= application
;
1703 * g_application_quit:
1704 * @application: a #GApplication
1706 * Immediately quits the application.
1708 * Upon return to the mainloop, g_application_run() will return,
1709 * calling only the 'shutdown' function before doing so.
1711 * The hold count is ignored.
1713 * The result of calling g_application_run() again after it returns is
1719 g_application_quit (GApplication
*application
)
1721 g_return_if_fail (G_IS_APPLICATION (application
));
1723 application
->priv
->must_quit_now
= TRUE
;
1727 /* vim:set foldmethod=marker: */