[gnome-settings-daemon] housekeeping: Use GSettings features to clamp options



commit bb6c585f81f53fd04de377379da828cd15e75dd4
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Feb 21 00:00:34 2013 +0100

    housekeeping: Use GSettings features to clamp options
    
    Instead of checking min/max values by hand, tell GSettings
    the range of values we allow.

 ...s-daemon.plugins.housekeeping.gschema.xml.in.in |    2 ++
 plugins/housekeeping/gsd-disk-space.c              |   11 -----------
 2 files changed, 2 insertions(+), 11 deletions(-)
---
diff --git a/data/org.gnome.settings-daemon.plugins.housekeeping.gschema.xml.in.in 
b/data/org.gnome.settings-daemon.plugins.housekeeping.gschema.xml.in.in
index 594c045..5fe3374 100644
--- a/data/org.gnome.settings-daemon.plugins.housekeeping.gschema.xml.in.in
+++ b/data/org.gnome.settings-daemon.plugins.housekeeping.gschema.xml.in.in
@@ -12,11 +12,13 @@
     </key>
     <key name="free-percent-notify" type="d">
       <default>0.05</default>
+      <range min="0.0" max="1.0"/>
       <_summary>Free percentage notify threshold</_summary>
       <_description>Percentage free space threshold for initial warning of low disk space. If the percentage 
free space drops below this, a warning will be shown.</_description>
     </key>
     <key name="free-percent-notify-again" type="d">
       <default>0.01</default>
+      <range min="0.0" max="1.0"/>
       <_summary>Subsequent free space percentage notify threshold</_summary>
       <_description>Specify the percentage that the free disk space should reduce by before issuing a 
subsequent warning.</_description>
     </key>
diff --git a/plugins/housekeeping/gsd-disk-space.c b/plugins/housekeeping/gsd-disk-space.c
index 5ad264d..0dcfe7f 100644
--- a/plugins/housekeeping/gsd-disk-space.c
+++ b/plugins/housekeeping/gsd-disk-space.c
@@ -953,18 +953,7 @@ gsd_ldsm_get_config (void)
         gchar **settings_list;
 
         free_percent_notify = g_settings_get_double (settings, SETTINGS_FREE_PC_NOTIFY_KEY);
-        if (free_percent_notify >= 1 || free_percent_notify < 0) {
-                g_warning ("Invalid configuration of free_percent_notify: %f\n" \
-                           "Using sensible default", free_percent_notify);
-                free_percent_notify = 0.05;
-        }
-
         free_percent_notify_again = g_settings_get_double (settings, SETTINGS_FREE_PC_NOTIFY_AGAIN_KEY);
-        if (free_percent_notify_again >= 1 || free_percent_notify_again < 0) {
-                g_warning ("Invalid configuration of free_percent_notify_again: %f\n" \
-                           "Using sensible default\n", free_percent_notify_again);
-                free_percent_notify_again = 0.01;
-        }
 
         free_size_gb_no_notify = g_settings_get_int (settings, SETTINGS_FREE_SIZE_NO_NOTIFY);
         min_notify_period = g_settings_get_int (settings, SETTINGS_MIN_NOTIFY_PERIOD);


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