[gnome-settings-daemon] power: Export the LID_CLOSE_SAFETY_TIMEOUT constant



commit faa4a9eef17d56abf394f4e18d049adce1e9b467
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Apr 17 16:45:05 2013 +0200

    power: Export the LID_CLOSE_SAFETY_TIMEOUT constant
    
    And use it in the tests.

 plugins/power/gsd-power-constants.h | 4 ++++
 plugins/power/gsd-power-manager.c   | 7 +++----
 plugins/power/gsdpowerconstants.py  | 1 +
 plugins/power/test.py               | 2 +-
 4 files changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/plugins/power/gsd-power-constants.h b/plugins/power/gsd-power-constants.h
index a168366..2a43ba9 100644
--- a/plugins/power/gsd-power-constants.h
+++ b/plugins/power/gsd-power-constants.h
@@ -37,3 +37,7 @@
 /* Default brightness values for the mock backlight used in the test suite */
 #define GSD_MOCK_DEFAULT_BRIGHTNESS                     50
 #define GSD_MOCK_MAX_BRIGHTNESS                        100
+
+/* When unplugging the external monitor, give a certain amount
+ * of time before suspending the laptop */
+#define LID_CLOSE_SAFETY_TIMEOUT                        30 /* seconds */
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c
index 9794e61..abfb6f4 100644
--- a/plugins/power/gsd-power-manager.c
+++ b/plugins/power/gsd-power-manager.c
@@ -78,7 +78,6 @@
 #define GSD_POWER_MANAGER_NOTIFY_TIMEOUT_LONG           30 * 1000 /* ms */
 
 #define GSD_POWER_MANAGER_RECALL_DELAY                  30 /* seconds */
-#define GSD_POWER_MANAGER_LID_CLOSE_SAFETY_TIMEOUT      30 /* seconds */
 
 #define SYSTEMD_DBUS_NAME                       "org.freedesktop.login1"
 #define SYSTEMD_DBUS_PATH                       "/org/freedesktop/login1"
@@ -2195,9 +2194,9 @@ setup_inhibit_lid_switch_timer (GsdPowerManager *manager)
 
         g_debug ("setting up lid close safety timer");
 
-        manager->priv->inhibit_lid_switch_timer_id = g_timeout_add_seconds 
(GSD_POWER_MANAGER_LID_CLOSE_SAFETY_TIMEOUT,
-                                                                          (GSourceFunc) 
inhibit_lid_switch_timer_cb,
-                                                                          manager);
+        manager->priv->inhibit_lid_switch_timer_id = g_timeout_add_seconds (LID_CLOSE_SAFETY_TIMEOUT,
+                                                                            (GSourceFunc) 
inhibit_lid_switch_timer_cb,
+                                                                            manager);
         g_source_set_name_by_id (manager->priv->inhibit_lid_switch_timer_id, "[GsdPowerManager] lid close 
safety timer");
 }
 
diff --git a/plugins/power/gsdpowerconstants.py b/plugins/power/gsdpowerconstants.py
index 3028bc8..eebba6f 100644
--- a/plugins/power/gsdpowerconstants.py
+++ b/plugins/power/gsdpowerconstants.py
@@ -13,3 +13,4 @@ MINIMUM_IDLE_DIM_DELAY = 10;
 POWER_UP_TIME_ON_AC = 15;
 GSD_MOCK_DEFAULT_BRIGHTNESS = 50;
 GSD_MOCK_MAX_BRIGHTNESS = 100;
+LID_CLOSE_SAFETY_TIMEOUT = 30;
diff --git a/plugins/power/test.py b/plugins/power/test.py
index bab0fdb..3159b23 100755
--- a/plugins/power/test.py
+++ b/plugins/power/test.py
@@ -575,7 +575,7 @@ class PowerPluginTest(gsdtestcase.GSDTestCase):
         # Unplug the external monitor
         self.set_has_external_monitor(False)
         # Wait for the safety timer + 3 seconds
-        time.sleep (30 + 3)
+        time.sleep (gsdpowerconstants.LID_CLOSE_SAFETY_TIMEOUT + 3)
         # Check that we're uninhibited
         self.check_for_uninhibited()
 


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