[gnome-settings-daemon] power: Make GSD_ACTION_DELAY a constant



commit 7359ef6de02b21089ef3c3f5fe39231fc74546c6
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Jan 29 12:08:37 2013 +0100

    power: Make GSD_ACTION_DELAY a constant
    
    Instead of poking at the envvars.

 plugins/power/Makefile.am         |    2 +-
 plugins/power/gsd-power-manager.c |   25 ++++++++-----------------
 plugins/power/test.py             |    1 -
 3 files changed, 9 insertions(+), 19 deletions(-)
---
diff --git a/plugins/power/Makefile.am b/plugins/power/Makefile.am
index 4ceec0d..af0793c 100644
--- a/plugins/power/Makefile.am
+++ b/plugins/power/Makefile.am
@@ -76,7 +76,7 @@ gsd_test_power_SOURCES =				\
 	test-power.c
 
 gsd_test_power_CFLAGS = $(libpower_la_CFLAGS)
-gsd_test_power_CPPFLAGS = $(libpower_la_CPPFLAGS) -DGSD_MOCK=1
+gsd_test_power_CPPFLAGS = $(libpower_la_CPPFLAGS) -DGSD_MOCK=1 -DGSD_ACTION_DELAY=1
 gsd_test_power_LDADD =					\
 	-lm						\
 	$(top_builddir)/plugins/common/libcommon.la	\
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c
index edb92f3..3abd97e 100644
--- a/plugins/power/gsd-power-manager.c
+++ b/plugins/power/gsd-power-manager.c
@@ -86,6 +86,12 @@
 /* Keep this in sync with gnome-shell */
 #define SCREENSAVER_FADE_TIME                           10 /* seconds */
 
+/* Time between notifying the user about a critical action and executing it.
+ * This can be changed with the GSD_ACTION_DELAY constant. */
+#ifndef GSD_ACTION_DELAY
+#define GSD_ACTION_DELAY 20
+#endif /* !GSD_ACTION_DELAY */
+
 static const gchar introspection_xml[] =
 "<node>"
 "  <interface name='org.gnome.SettingsDaemon.Power'>"
@@ -241,10 +247,6 @@ G_DEFINE_TYPE (GsdPowerManager, gsd_power_manager, G_TYPE_OBJECT)
 
 static gpointer manager_object = NULL;
 
-/* Time between notifying the user about a critical action and executing it.
- * This can be changed with the $GSD_ACTION_DELAY environment variable. */
-static guint critical_action_delay = 20;
-
 GQuark
 gsd_power_manager_error_quark (void)
 {
@@ -1684,7 +1686,7 @@ engine_charge_action (GsdPowerManager *manager, UpDevice *device)
                 }
 
                 /* wait 20 seconds for user-panic */
-                timer_id = g_timeout_add_seconds (critical_action_delay,
+                timer_id = g_timeout_add_seconds (GSD_ACTION_DELAY,
                                                   (GSourceFunc) manager_critical_action_do_cb,
                                                   manager);
                 g_source_set_name_by_id (timer_id, "[GsdPowerManager] battery critical-action");
@@ -1715,7 +1717,7 @@ engine_charge_action (GsdPowerManager *manager, UpDevice *device)
                 }
 
                 /* wait 20 seconds for user-panic */
-                timer_id = g_timeout_add_seconds (critical_action_delay,
+                timer_id = g_timeout_add_seconds (GSD_ACTION_DELAY,
                                                   (GSourceFunc) manager_critical_ups_action_do_cb,
                                                   manager);
                 g_source_set_name_by_id (timer_id, "[GsdPowerManager] ups critical-action");
@@ -2818,21 +2820,10 @@ static void
 gsd_power_manager_class_init (GsdPowerManagerClass *klass)
 {
         GObjectClass *object_class = G_OBJECT_CLASS (klass);
-        const char* env_action_delay;
 
         object_class->finalize = gsd_power_manager_finalize;
 
         g_type_class_add_private (klass, sizeof (GsdPowerManagerPrivate));
-
-        env_action_delay = g_getenv ("GSD_ACTION_DELAY");
-        if (env_action_delay != NULL) {
-                critical_action_delay = atoi (env_action_delay);
-                /* use the default for invalid values */
-                if (critical_action_delay < 0) {
-                        g_warning ("Invalid value '%s' of $GSD_ACTION_DELAY, ignoring", env_action_delay);
-                        critical_action_delay = 20;
-                }
-        }
 }
 
 static void
diff --git a/plugins/power/test.py b/plugins/power/test.py
index 7eedea8..3fe3b81 100755
--- a/plugins/power/test.py
+++ b/plugins/power/test.py
@@ -84,7 +84,6 @@ class PowerPluginTest(gsdtestcase.GSDTestCase):
         self.plugin_log_write = open(os.path.join(self.workdir, 'plugin_power.log'), 'wb')
         # avoid painfully long delays of actions for tests
         env = os.environ.copy()
-        env['GSD_ACTION_DELAY'] = '1'
         env['GSD_DISABLE_BACKLIGHT_HELPER'] = '1'
         self.daemon = subprocess.Popen(
             [os.path.join(builddir, 'gsd-test-power')],



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