X-Git-Url: http://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Fui_sensorpref.c;h=b87d53dcb97926d669c9735348779487d8b10645;hb=fd0242c4e19038c1eca927498c6c6d163b46c736;hp=0b6d5859f24b8d4aab45ee3bea6e2eec1f08baaa;hpb=cafb0669edcf38a67c41d331a291bed8e603e480;p=psensor.git diff --git a/src/ui_sensorpref.c b/src/ui_sensorpref.c index 0b6d585..b87d53d 100644 --- a/src/ui_sensorpref.c +++ b/src/ui_sensorpref.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 @@ -23,10 +23,10 @@ #include #include #include +#include #include #include #include -#include enum { COL_NAME = 0, @@ -38,6 +38,8 @@ static GtkDialog *w_dialog; static GtkLabel *w_sensor_id; static GtkLabel *w_sensor_type; static GtkLabel *w_sensor_chipname; +static GtkLabel *w_sensor_min; +static GtkLabel *w_sensor_max; static GtkLabel *w_sensor_low_threshold_unit; static GtkLabel *w_sensor_high_threshold_unit; static GtkEntry *w_sensor_name; @@ -51,9 +53,9 @@ static GtkSpinButton *w_sensor_high_threshold; static GtkSpinButton *w_sensor_low_threshold; static GtkListStore *store; - /* 'true' when the notifications of field changes are due to the change - * of the selected sensor. */ + * of the selected sensor. + */ static bool ignore_changes; static struct psensor *get_selected_sensor(void) @@ -234,7 +236,7 @@ ui_sensorpref_alarm_high_threshold_changed_cb(GtkSpinButton *btn, gpointer data) return; v = gtk_spin_button_get_value(btn); - if (config_get_sensor_unit() == FAHRENHEIT) + if (config_get_temperature_unit() == FAHRENHEIT) v = fahrenheit_to_celsius(v); config_set_sensor_alarm_high_threshold(s->id, v); @@ -257,7 +259,7 @@ ui_sensorpref_alarm_low_threshold_changed_cb(GtkSpinButton *btn, gpointer data) return; v = gtk_spin_button_get_value(btn); - if (config_get_sensor_unit() == FAHRENHEIT) + if (config_get_temperature_unit() == FAHRENHEIT) v = fahrenheit_to_celsius(v); config_set_sensor_alarm_low_threshold(s->id, v); @@ -271,6 +273,7 @@ static void update_pref(struct psensor *s) int use_celsius, threshold; GdkRGBA *color; const char *chip; + char *smin, *smax; if (!s) return; @@ -287,6 +290,23 @@ static void update_pref(struct psensor *s) chip = _("Unknown"); gtk_label_set_text(w_sensor_chipname, chip); + use_celsius = config_get_temperature_unit() == CELSIUS ? 1 : 0; + + if (s->min == UNKNOWN_DBL_VALUE) + smin = strdup(_("Unknown")); + else + smin = psensor_value_to_str(s->type, s->min, use_celsius); + + gtk_label_set_text(w_sensor_min, smin); + free(smin); + + if (s->max == UNKNOWN_DBL_VALUE) + smax = strdup(_("Unknown")); + else + smax = psensor_value_to_str(s->type, s->max, use_celsius); + gtk_label_set_text(w_sensor_max, smax); + free(smax); + gtk_toggle_button_set_active(w_sensor_draw, config_is_sensor_graph_enabled(s->id)); @@ -297,7 +317,6 @@ static void update_pref(struct psensor *s) gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(w_sensor_color), color); gdk_rgba_free(color); - use_celsius = config_get_sensor_unit() == CELSIUS ? 1 : 0; gtk_label_set_text(w_sensor_high_threshold_unit, psensor_type_to_unit_str(s->type, use_celsius)); gtk_label_set_text(w_sensor_low_threshold_unit, @@ -322,12 +341,12 @@ static void update_pref(struct psensor *s) gtk_toggle_button_set_active(w_sensor_alarm, config_get_sensor_alarm_enabled(s->id)); - threshold = config_get_sensor_alarm_high_threshold(s->id); + threshold = s->alarm_high_threshold; if (!use_celsius) threshold = celsius_to_fahrenheit(threshold); gtk_spin_button_set_value(w_sensor_high_threshold, threshold); - threshold = config_get_sensor_alarm_low_threshold(s->id); + threshold = s->alarm_low_threshold; if (!use_celsius) threshold = celsius_to_fahrenheit(threshold); gtk_spin_button_set_value(w_sensor_low_threshold, threshold); @@ -384,7 +403,6 @@ on_delete_event_cb(GtkWidget *widget, GdkEvent *event, gpointer data) void ui_sensorpref_close_clicked_cb(GtkButton *btn, gpointer data) { quit(); - return TRUE; } static GtkBuilder *load_ui(struct ui_psensor *ui) @@ -417,6 +435,10 @@ static GtkBuilder *load_ui(struct ui_psensor *ui) (gtk_builder_get_object(builder, "sensor_name")); w_sensor_chipname = GTK_LABEL (gtk_builder_get_object(builder, "chip_name")); + w_sensor_min = GTK_LABEL + (gtk_builder_get_object(builder, "sensor_min")); + w_sensor_max = GTK_LABEL + (gtk_builder_get_object(builder, "sensor_max")); w_sensor_draw = GTK_TOGGLE_BUTTON (gtk_builder_get_object(builder, "sensor_draw")); w_sensor_display = GTK_TOGGLE_BUTTON @@ -445,6 +467,8 @@ static GtkBuilder *load_ui(struct ui_psensor *ui) store = GTK_LIST_STORE(gtk_builder_get_object(builder, "sensors_liststore")); + gtk_window_set_transient_for(GTK_WINDOW(w_dialog), + GTK_WINDOW(ui->main_window)); gtk_builder_connect_signals(builder, ui); g_signal_connect(w_dialog,