fixed graph not fitting well in the central region.
[psensor.git] / src / cfg.c
index 8f22975..ce82834 100644 (file)
--- a/src/cfg.c
+++ b/src/cfg.c
@@ -29,9 +29,8 @@
 #include <libintl.h>
 #define _(str) gettext(str)
 
-#include <gio/gio.h>
-
 #include <cfg.h>
+#include <graph.h>
 #include <pio.h>
 #include <plog.h>
 
@@ -55,17 +54,14 @@ static const char *KEY_SENSOR_UPDATE_INTERVAL
 
 /* Graph settings */
 static const char *KEY_GRAPH_UPDATE_INTERVAL = "graph-update-interval";
-
 static const char *KEY_GRAPH_MONITORING_DURATION = "graph-monitoring-duration";
-
 static const char *KEY_GRAPH_BACKGROUND_COLOR = "graph-background-color";
-
 static const char *DEFAULT_GRAPH_BACKGROUND_COLOR = "#e8f4e8f4a8f5";
-
 static const char *KEY_GRAPH_BACKGROUND_ALPHA = "graph-background-alpha";
-
 static const char *KEY_GRAPH_FOREGROUND_COLOR
 = "graph-foreground-color";
+static const char *KEY_GRAPH_SMOOTH_CURVES_ENABLED
+= "graph-smooth-curves-enabled";
 
 static const char *DEFAULT_GRAPH_FOREGROUND_COLOR = "#000000000000";
 
@@ -335,6 +331,17 @@ static void set_window_keep_below_enabled(bool enabled)
        set_bool(KEY_INTERFACE_WINDOW_KEEP_BELOW_ENABLED, enabled);
 }
 
+bool config_is_smooth_curves_enabled()
+{
+       return get_bool(KEY_GRAPH_SMOOTH_CURVES_ENABLED);
+}
+
+void config_set_smooth_curves_enabled(bool b)
+{
+       set_bool(KEY_GRAPH_SMOOTH_CURVES_ENABLED, b);
+}
+
+
 static void init()
 {
        log_fct_enter();
@@ -405,12 +412,6 @@ struct config *config_load()
        if (c->graph_monitoring_duration < 1)
                c->graph_monitoring_duration = 10;
 
-       c->sensor_values_max_length
-           = (c->graph_monitoring_duration * 60) / c->sensor_update_interval;
-
-       if (c->sensor_values_max_length < 3)
-               c->sensor_values_max_length = 3;
-
        c->menu_bar_disabled = get_bool(KEY_INTERFACE_MENU_BAR_DISABLED);
 
        c->unity_launcher_count_disabled
@@ -435,6 +436,8 @@ struct config *config_load()
 
        c->temperature_unit = get_int(KEY_INTERFACE_TEMPERATURE_UNIT);
 
+       c->sensor_values_max_length = compute_values_max_length(c);
+
        return c;
 }
 
@@ -537,15 +540,10 @@ static GKeyFile *get_sensor_key_file()
                                                | G_KEY_FILE_KEEP_TRANSLATIONS,
                                                &err);
 
-               if (!ret) {
-                       if (err->code == G_KEY_FILE_ERROR_NOT_FOUND)
-                               log_fct(_("The configuration file "
-                                         "does not exist."));
-                       else
-                               log_err(_("Failed to parse configuration "
-                                         "file: %s"),
-                                       path);
-               }
+               if (!ret)
+                       log_warn(_("Failed to load configuration file %s: %s"),
+                                path,
+                                err->message);
        }
 
        return key_file;
@@ -757,3 +755,8 @@ void config_set_appindicator_label_enabled(const char *sid, bool enabled)
 {
        sensor_set_bool(sid, ATT_SENSOR_APPINDICATOR_LABEL_ENABLED, enabled);
 }
+
+GSettings *config_get_GSettings()
+{
+       return settings;
+}