From 72ce1c7eb6ece6353abaf3882ff4d50a39992efe Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Wed, 6 Oct 2010 14:05:40 -0400 Subject: [PATCH] GApplication: fix inactivity-timeout Create the gobject property for it. Tweak the logic of having a pending timeout at the time that the application starts -- run the mainloop with a use count of zero if there is a timeout active. --- gio/gapplication.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/gio/gapplication.c b/gio/gapplication.c index d9beb2d..27d60b6 100644 --- a/gio/gapplication.c +++ b/gio/gapplication.c @@ -372,6 +372,11 @@ g_application_class_init (GApplicationClass *class) "If this application instance is remote", FALSE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (object_class, PROP_INACTIVITY_TIMEOUT, + g_param_spec_boolean ("inactivity-timeout", "inactivity timeout", + "time (ms) to stay alive after becoming idle", + 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_application_signals[SIGNAL_STARTUP] = g_signal_new ("startup", G_TYPE_APPLICATION, G_SIGNAL_RUN_LAST, @@ -984,14 +989,17 @@ g_application_run_with_arguments (GApplication *application, g_variant_unref (arguments); - if (application->priv->use_count || - application->priv->flags & G_APPLICATION_FLAGS_IS_SERVICE) + if (application->priv->flags & G_APPLICATION_FLAGS_IS_SERVICE && + !application->priv->use_count && + !application->priv->inactivity_timeout_id) { - if (!application->priv->use_count) - application->priv->inactivity_timeout_id = - g_timeout_add (10000, inactivity_timeout_expired, application); - + application->priv->inactivity_timeout_id = + g_timeout_add (10000, inactivity_timeout_expired, application); + } + if (application->priv->use_count || + application->priv->inactivity_timeout_id) + { G_APPLICATION_GET_CLASS (application) ->run_mainloop (application); status = 0; -- 2.7.4