hide/show sensors in the main window.
[psensor.git] / src / ui_sensorpref.c
index abf69ba..9e8447e 100644 (file)
@@ -38,13 +38,14 @@ enum {
 struct sensor_pref {
        struct psensor *sensor;
        char *name;
-       int enabled;
+       int graph_enabled;
        struct color *color;
        int alarm_enabled;
        int alarm_high_threshold;
        int alarm_low_threshold;
        unsigned int appindicator_enabled;
        unsigned int appindicator_label_enabled;
+       unsigned int display_enabled;
 };
 
 struct cb_data {
@@ -61,9 +62,10 @@ sensor_pref_new(struct psensor *s, struct config *cfg)
 
        p->sensor = s;
        p->name = strdup(s->name);
-       p->enabled = s->graph_enabled;
+       p->graph_enabled = s->graph_enabled;
        p->alarm_enabled = s->alarm_enabled;
        p->color = color_dup(s->color);
+       p->display_enabled = config_is_sensor_enabled(s->id);
 
        if (cfg->temperature_unit == CELSIUS) {
                p->alarm_high_threshold = s->alarm_high_threshold;
@@ -131,7 +133,17 @@ void ui_sensorpref_draw_toggled_cb(GtkToggleButton *btn, gpointer data)
        p = get_selected_sensor_pref(GTK_TREE_VIEW(data));
 
        if (p)
-               p->enabled = gtk_toggle_button_get_active(btn);
+               p->graph_enabled = gtk_toggle_button_get_active(btn);
+}
+
+void ui_sensorpref_display_toggled_cb(GtkToggleButton *btn, gpointer data)
+{
+       struct sensor_pref *p;
+
+       p = get_selected_sensor_pref(GTK_TREE_VIEW(data));
+
+       if (p)
+               p->display_enabled = gtk_toggle_button_get_active(btn);
 }
 
 void ui_sensorpref_alarm_toggled_cb(GtkToggleButton *btn, gpointer data)
@@ -209,7 +221,7 @@ update_pref(struct sensor_pref *p, struct config *cfg, GtkBuilder *builder)
                *w_chipname;
        GtkEntry *w_name;
        GtkToggleButton *w_draw, *w_alarm, *w_appindicator_enabled,
-               *w_appindicator_label_enabled;
+               *w_appindicator_label_enabled, *w_display;
        GtkColorButton *w_color;
        GtkSpinButton *w_high_threshold, *w_low_threshold;
        GdkColor *color;
@@ -235,7 +247,12 @@ update_pref(struct sensor_pref *p, struct config *cfg, GtkBuilder *builder)
 
        w_draw = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder,
                                                          "sensor_draw"));
-       gtk_toggle_button_set_active(w_draw, p->enabled);
+       gtk_toggle_button_set_active(w_draw, p->graph_enabled);
+
+       w_display = GTK_TOGGLE_BUTTON(gtk_builder_get_object
+                                     (builder,
+                                      "sensor_enable_checkbox"));
+       gtk_toggle_button_set_active(w_display, p->display_enabled);
 
        color = color_to_gdkcolor(p->color);
        w_color = GTK_COLOR_BUTTON(gtk_builder_get_object(builder,
@@ -343,9 +360,9 @@ static void apply_pref(struct sensor_pref *p, int pos, struct config *cfg)
                config_set_sensor_name(s->id, s->name);
        }
 
-       if (s->graph_enabled != p->enabled) {
-               s->graph_enabled = p->enabled;
-               config_set_sensor_enabled(s->id, s->graph_enabled);
+       if (s->graph_enabled != p->graph_enabled) {
+               s->graph_enabled = p->graph_enabled;
+               config_set_sensor_graph_enabled(s->id, s->graph_enabled);
        }
 
        if (is_temp_type(s->type) && cfg->temperature_unit == FAHRENHEIT) {
@@ -378,6 +395,8 @@ static void apply_pref(struct sensor_pref *p, int pos, struct config *cfg)
                                              p->appindicator_label_enabled);
 
        config_set_sensor_position(s->id, pos);
+
+       config_set_sensor_enabled(s->id, p->display_enabled);
 }
 
 static void apply_prefs(GtkTreeModel *model, struct config *cfg)