mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-25 21:46:14 +01:00
GApplication: add g_application_quit()
A long requested feature; this quits the application immediately, ignoring the hold count. https://bugzilla.gnome.org/show_bug.cgi?id=670485
This commit is contained in:
parent
486c694af0
commit
ed51975899
@ -2897,6 +2897,7 @@ g_application_register
|
|||||||
<SUBSECTION>
|
<SUBSECTION>
|
||||||
g_application_hold
|
g_application_hold
|
||||||
g_application_release
|
g_application_release
|
||||||
|
g_application_quit
|
||||||
<SUBSECTION>
|
<SUBSECTION>
|
||||||
g_application_activate
|
g_application_activate
|
||||||
g_application_open
|
g_application_open
|
||||||
|
@ -211,6 +211,7 @@ struct _GApplicationPrivate
|
|||||||
guint is_remote : 1;
|
guint is_remote : 1;
|
||||||
guint did_startup : 1;
|
guint did_startup : 1;
|
||||||
guint did_shutdown : 1;
|
guint did_shutdown : 1;
|
||||||
|
guint must_quit_now : 1;
|
||||||
|
|
||||||
GRemoteActionGroup *remote_actions;
|
GRemoteActionGroup *remote_actions;
|
||||||
GApplicationImpl *impl;
|
GApplicationImpl *impl;
|
||||||
@ -1425,6 +1426,7 @@ g_application_run (GApplication *application,
|
|||||||
|
|
||||||
g_return_val_if_fail (G_IS_APPLICATION (application), 1);
|
g_return_val_if_fail (G_IS_APPLICATION (application), 1);
|
||||||
g_return_val_if_fail (argc == 0 || argv != NULL, 1);
|
g_return_val_if_fail (argc == 0 || argv != NULL, 1);
|
||||||
|
g_return_val_if_fail (!application->priv->must_quit_now, 1);
|
||||||
|
|
||||||
arguments = g_new (gchar *, argc + 1);
|
arguments = g_new (gchar *, argc + 1);
|
||||||
for (i = 0; i < argc; i++)
|
for (i = 0; i < argc; i++)
|
||||||
@ -1488,6 +1490,9 @@ g_application_run (GApplication *application,
|
|||||||
|
|
||||||
while (application->priv->use_count || application->priv->inactivity_timeout_id)
|
while (application->priv->use_count || application->priv->inactivity_timeout_id)
|
||||||
{
|
{
|
||||||
|
if (application->priv->must_quit_now)
|
||||||
|
break;
|
||||||
|
|
||||||
g_main_context_iteration (NULL, TRUE);
|
g_main_context_iteration (NULL, TRUE);
|
||||||
status = 0;
|
status = 0;
|
||||||
}
|
}
|
||||||
@ -1694,5 +1699,29 @@ g_application_set_default (GApplication *application)
|
|||||||
default_app = application;
|
default_app = application;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* g_application_quit:
|
||||||
|
* @application: a #GApplication
|
||||||
|
*
|
||||||
|
* Immediately quits the application.
|
||||||
|
*
|
||||||
|
* Upon return to the mainloop, g_application_run() will return,
|
||||||
|
* calling only the 'shutdown' function before doing so.
|
||||||
|
*
|
||||||
|
* The hold count is ignored.
|
||||||
|
*
|
||||||
|
* The result of calling g_application_run() again after it returns is
|
||||||
|
* unspecified.
|
||||||
|
*
|
||||||
|
* Since: 2.32
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
g_application_quit (GApplication *application)
|
||||||
|
{
|
||||||
|
g_return_if_fail (G_IS_APPLICATION (application));
|
||||||
|
|
||||||
|
application->priv->must_quit_now = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Epilogue {{{1 */
|
/* Epilogue {{{1 */
|
||||||
/* vim:set foldmethod=marker: */
|
/* vim:set foldmethod=marker: */
|
||||||
|
@ -138,6 +138,8 @@ int g_application_run (GApplic
|
|||||||
int argc,
|
int argc,
|
||||||
char **argv);
|
char **argv);
|
||||||
|
|
||||||
|
void g_application_quit (GApplication *application);
|
||||||
|
|
||||||
GApplication * g_application_get_default (void);
|
GApplication * g_application_get_default (void);
|
||||||
void g_application_set_default (GApplication *application);
|
void g_application_set_default (GApplication *application);
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ g_application_set_application_id
|
|||||||
g_application_set_default
|
g_application_set_default
|
||||||
g_application_set_flags
|
g_application_set_flags
|
||||||
g_application_set_inactivity_timeout
|
g_application_set_inactivity_timeout
|
||||||
|
g_application_quit
|
||||||
g_application_command_line_get_arguments
|
g_application_command_line_get_arguments
|
||||||
g_application_command_line_get_cwd
|
g_application_command_line_get_cwd
|
||||||
g_application_command_line_get_environ
|
g_application_command_line_get_environ
|
||||||
|
Loading…
Reference in New Issue
Block a user