X-Git-Url: https://git.wpitchoune.net/gitweb/?p=psensor.git;a=blobdiff_plain;f=src%2Fui_sensorlist.c;h=9d4b748717e7537b04c321569bc7111ea4c07e68;hp=53c7336b035b1b23a547bff43c9f68e83fe0c26b;hb=c1e20f2631a1249720e9c75d753eacfcb0f6c7b9;hpb=9d77e6ab0ca102b9d42072df4fd9d2378897a5ca diff --git a/src/ui_sensorlist.c b/src/ui_sensorlist.c index 53c7336..9d4b748 100644 --- a/src/ui_sensorlist.c +++ b/src/ui_sensorlist.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2014 jeanfi@gmail.com + * Copyright (C) 2010-2016 jeanfi@gmail.com * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -58,12 +58,12 @@ static void populate(struct ui_psensor *ui) { GtkTreeIter iter; GtkListStore *store; - GdkRGBA color; + GdkRGBA *color; char *scolor; struct psensor **ordered_sensors, **s_cur, *s; unsigned int enabled; - ordered_sensors = ui_get_sensors_ordered_by_position(ui); + ordered_sensors = ui_get_sensors_ordered_by_position(ui->sensors); store = ui->sensors_store; gtk_list_store_clear(store); @@ -73,15 +73,11 @@ static void populate(struct ui_psensor *ui) gtk_list_store_append(store, &iter); - color.red = s->color->red; - color.green = s->color->green; - color.blue = s->color->blue; - color.alpha = 1.0; + color = config_get_sensor_color(s->id); - scolor = gdk_rgba_to_string(&color); + scolor = gdk_rgba_to_string(color); enabled = config_is_sensor_enabled(s->id); - gtk_list_store_set(store, &iter, COL_NAME, s->name, COL_COLOR_STR, scolor, @@ -91,6 +87,7 @@ static void populate(struct ui_psensor *ui) COL_DISPLAY_ENABLED, enabled, -1); free(scolor); + gdk_rgba_free(color); } free(ordered_sensors); } @@ -113,7 +110,10 @@ void ui_sensorlist_update(struct ui_psensor *ui, bool complete) store = ui->sensors_store; - use_celsius = ui->config->temperature_unit == CELSIUS; + if (config_get_temperature_unit() == CELSIUS) + use_celsius = 1; + else + use_celsius = 0; valid = gtk_tree_model_get_iter_first(model, &iter); while (valid) { @@ -122,8 +122,12 @@ void ui_sensorlist_update(struct ui_psensor *ui, bool complete) value = psensor_value_to_str(s->type, psensor_get_current_value(s), use_celsius); - min = psensor_value_to_str(s->type, s->min, use_celsius); - max = psensor_value_to_str(s->type, s->max, use_celsius); + min = psensor_value_to_str(s->type, + s->sess_lowest, + use_celsius); + max = psensor_value_to_str(s->type, + s->sess_highest, + use_celsius); gtk_list_store_set(store, &iter, COL_TEMP, value, @@ -284,6 +288,7 @@ static int clicked_cbk(GtkWidget *widget, GdkEventButton *event, gpointer data) GtkTreeView *view; struct psensor *s; int coli; + GdkRGBA *color; ui = (struct ui_psensor *)data; view = ui->sensors_tree; @@ -294,13 +299,15 @@ static int clicked_cbk(GtkWidget *widget, GdkEventButton *event, gpointer data) coli = col_index_to_col(get_col_index_at_pos(view, event->x)); if (coli == COL_COLOR) { + color = config_get_sensor_color(s->id); if (ui_change_color(_("Select sensor color"), - s->color, + color, GTK_WINDOW(ui->main_window))) { + config_set_sensor_color(s->id, color); ui_sensorlist_update(ui, 1); - config_set_sensor_color(s->id, s->color); config_sync(); } + gdk_rgba_free(color); return TRUE; } else if (coli >= 0 && coli != COL_GRAPH_ENABLED) { menu = create_sensor_popup(ui, s);