add support of smooth curves in the preferences.
[psensor.git] / src / ui_pref.c
index 46b9fc3..72322f4 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <ui.h>
 #include <cfg.h>
+#include <graph.h>
 #include <ui_pref.h>
 #include <ui_color.h>
 #include <pxdg.h>
@@ -53,7 +54,7 @@ void ui_pref_dialog_run(struct ui_psensor *ui)
        GtkComboBox *w_sensorlist_pos;
        GtkToggleButton *w_hide_window_decoration, *w_keep_window_below,
                *w_enable_menu, *w_enable_launcher_counter, *w_hide_on_startup,
-               *w_win_restore, *w_slog_enabled, *w_autostart;
+               *w_win_restore, *w_slog_enabled, *w_autostart, *w_smooth_curves;
        GtkComboBoxText *w_temp_unit;
        GtkEntry *w_notif_script;
        char *notif_script;
@@ -141,6 +142,11 @@ void ui_pref_dialog_run(struct ui_psensor *ui)
        gtk_toggle_button_set_active(w_enable_launcher_counter,
                                     !cfg->unity_launcher_count_disabled);
 
+       w_smooth_curves = GTK_TOGGLE_BUTTON
+               (gtk_builder_get_object(builder, "graph_smooth_curves"));
+       gtk_toggle_button_set_active(w_smooth_curves,
+                                    config_is_smooth_curves_enabled());
+
        w_slog_enabled = GTK_TOGGLE_BUTTON
                (gtk_builder_get_object(builder, "enable_slog"));
        gtk_toggle_button_set_active(w_slog_enabled, cfg->slog_enabled);
@@ -229,10 +235,6 @@ void ui_pref_dialog_run(struct ui_psensor *ui)
                    = gtk_spin_button_get_value_as_int
                        (w_monitoring_duration);
 
-               cfg->sensor_values_max_length
-                   = (cfg->graph_monitoring_duration * 60) /
-                   cfg->sensor_update_interval;
-
                cfg->hide_on_startup
                        = gtk_toggle_button_get_active(w_hide_on_startup);
 
@@ -248,8 +250,13 @@ void ui_pref_dialog_run(struct ui_psensor *ui)
                cfg->temperature_unit
                        = gtk_combo_box_get_active(GTK_COMBO_BOX(w_temp_unit));
 
+               cfg->sensor_values_max_length = compute_values_max_length(cfg);
+
                config_save(cfg);
 
+               config_set_smooth_curves_enabled
+                       (gtk_toggle_button_get_active(w_smooth_curves));
+
                pxdg_set_autostart(gtk_toggle_button_get_active(w_autostart));
 
                pthread_mutex_unlock(&ui->sensors_mutex);