mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-26 22:16:16 +01:00
Make default-quit not apply if register=FALSE
Callers who are using g_application_unregistered_try_new are likely wanting to continue doing something else if _register() fails. Change the semantics so that passing register=FALSE unsets default-quit as well. This means that a later _register() call will send Activate but continue the process. https://bugzilla.gnome.org/show_bug.cgi?id=622005
This commit is contained in:
parent
7e0121dfe0
commit
8a2e7d371f
@ -214,6 +214,7 @@ struct _GApplicationPrivate
|
|||||||
guint do_register : 1;
|
guint do_register : 1;
|
||||||
guint default_quit : 1;
|
guint default_quit : 1;
|
||||||
guint is_remote : 1;
|
guint is_remote : 1;
|
||||||
|
guint registration_tried : 1;
|
||||||
|
|
||||||
guint actions_changed_id;
|
guint actions_changed_id;
|
||||||
|
|
||||||
@ -382,8 +383,8 @@ initable_init (GInitable *initable,
|
|||||||
if (!_g_application_platform_init (app, cancellable, error))
|
if (!_g_application_platform_init (app, cancellable, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (app->priv->do_register &&
|
if (app->priv->do_register
|
||||||
!_g_application_platform_register (app, &unique, cancellable ,error))
|
&& !_g_application_platform_register (app, &unique, cancellable ,error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -557,7 +558,14 @@ g_application_unregistered_try_new (const gchar *appid,
|
|||||||
* initialized, but this behavior is controlled by the
|
* initialized, but this behavior is controlled by the
|
||||||
* GApplication:register property. If it was given as %FALSE at
|
* GApplication:register property. If it was given as %FALSE at
|
||||||
* construction time, this function allows you to later attempt
|
* construction time, this function allows you to later attempt
|
||||||
* to ensure uniqueness.
|
* to ensure uniqueness. Note that the GApplication:default-quit
|
||||||
|
* property no longer applies at this point; if this function returns
|
||||||
|
* %FALSE, platform activation will occur, but the current process
|
||||||
|
* will not be terminated.
|
||||||
|
*
|
||||||
|
* It is an error to call this function more than once. It is
|
||||||
|
* also an error to call this function if the GApplication:register
|
||||||
|
* property was %TRUE at construction time.
|
||||||
*
|
*
|
||||||
* Returns: %TRUE if registration was successful
|
* Returns: %TRUE if registration was successful
|
||||||
*/
|
*/
|
||||||
@ -568,6 +576,7 @@ g_application_register (GApplication *application)
|
|||||||
|
|
||||||
g_return_val_if_fail (G_IS_APPLICATION (application), FALSE);
|
g_return_val_if_fail (G_IS_APPLICATION (application), FALSE);
|
||||||
g_return_val_if_fail (application->priv->is_remote, FALSE);
|
g_return_val_if_fail (application->priv->is_remote, FALSE);
|
||||||
|
g_return_val_if_fail (!application->priv->registration_tried, FALSE);
|
||||||
|
|
||||||
if (!_g_application_platform_register (application, &unique, NULL, NULL))
|
if (!_g_application_platform_register (application, &unique, NULL, NULL))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -1054,6 +1063,9 @@ g_application_set_property (GObject *object,
|
|||||||
|
|
||||||
case PROP_REGISTER:
|
case PROP_REGISTER:
|
||||||
app->priv->do_register = g_value_get_boolean (value);
|
app->priv->do_register = g_value_get_boolean (value);
|
||||||
|
/* If we're not registering, the default_quit no longer applies */
|
||||||
|
if (!app->priv->do_register)
|
||||||
|
app->priv->default_quit = FALSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_ARGV:
|
case PROP_ARGV:
|
||||||
@ -1274,8 +1286,9 @@ g_application_class_init (GApplicationClass *klass)
|
|||||||
/**
|
/**
|
||||||
* GApplication:default-quit:
|
* GApplication:default-quit:
|
||||||
*
|
*
|
||||||
* By default, if a different process is running this application, the
|
* By default, if the GApplication:register property is %TRUE, and a
|
||||||
* process will be exited. Set this property to %FALSE to allow custom
|
* different process is running this application, the process will
|
||||||
|
* be exited. Set this property to %FALSE to allow custom
|
||||||
* interaction with the remote process.
|
* interaction with the remote process.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -301,6 +301,10 @@ _g_application_platform_register (GApplication *app,
|
|||||||
gboolean result;
|
gboolean result;
|
||||||
guint registration_id;
|
guint registration_id;
|
||||||
|
|
||||||
|
/* Callers should have verified this */
|
||||||
|
g_assert (app->priv->registration_tried == FALSE);
|
||||||
|
app->priv->registration_tried = TRUE;
|
||||||
|
|
||||||
registration_id = g_dbus_connection_register_object (app->priv->session_bus,
|
registration_id = g_dbus_connection_register_object (app->priv->session_bus,
|
||||||
app->priv->dbus_path,
|
app->priv->dbus_path,
|
||||||
&application_dbus_interface_info,
|
&application_dbus_interface_info,
|
||||||
@ -339,7 +343,7 @@ _g_application_platform_register (GApplication *app,
|
|||||||
{
|
{
|
||||||
app->priv->is_remote = FALSE;
|
app->priv->is_remote = FALSE;
|
||||||
}
|
}
|
||||||
else if (app->priv->default_quit)
|
else
|
||||||
{
|
{
|
||||||
GVariantBuilder builder;
|
GVariantBuilder builder;
|
||||||
GVariant *message;
|
GVariant *message;
|
||||||
@ -361,7 +365,8 @@ _g_application_platform_register (GApplication *app,
|
|||||||
if (result)
|
if (result)
|
||||||
g_variant_unref (result);
|
g_variant_unref (result);
|
||||||
|
|
||||||
exit (0);
|
if (app->priv->default_quit)
|
||||||
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
Loading…
Reference in New Issue
Block a user