[glib/wip/application: 2/11] GApplication: fix inactivity-timeout



commit b1c8ad2ba927595c23c0159a67310df41508febf
Author: Ryan Lortie <desrt desrt ca>
Date:   Wed Oct 6 14:05:40 2010 -0400

    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 files 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;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]