#define KEY_INTERFACE_WINDOW_DIVIDER_POS \
"/apps/psensor/interface/window_divider_pos"
+#define KEY_INTERFACE_TEMPERATURE_UNIT \
+"/apps/psensor/interface/temperature_unit"
+
GConfClient *client;
static char *get_string(char *key, char *default_value)
c->window_h = 200;
}
+ c->temperature_unit = gconf_client_get_int
+ (client, KEY_INTERFACE_TEMPERATURE_UNIT, NULL);
+
return c;
}
KEY_INTERFACE_WINDOW_DIVIDER_POS,
c->window_divider_pos,
NULL);
+
+ gconf_client_set_int(client,
+ KEY_INTERFACE_TEMPERATURE_UNIT,
+ c->temperature_unit,
+ NULL);
+
}
#include "color.h"
+enum temperature_unit {
+ CELCIUS,
+ FAHRENHEIT
+};
+
enum sensorlist_position {
SENSORLIST_POSITION_RIGHT,
SENSORLIST_POSITION_LEFT,
int unity_launcher_count_disabled;
int hide_on_startup;
+
+ enum temperature_unit temperature_unit;
};
/*
max_rpm = get_max_rpm(sensors);
mint = get_min_temp(sensors);
- strmin = psensor_value_to_string(SENSOR_TYPE_TEMP, mint);
+
+ strmin = psensor_value_to_string(SENSOR_TYPE_TEMP,
+ mint,
+ config->temperature_unit == CELCIUS);
maxt = get_max_temp(sensors);
- strmax = psensor_value_to_string(SENSOR_TYPE_TEMP, maxt);
+ strmax = psensor_value_to_string(SENSOR_TYPE_TEMP,
+ maxt,
+ config->temperature_unit == CELCIUS);
str_btime = time_to_str(get_graph_begin_time_s(config));
str_etime = time_to_str(get_graph_end_time_s());
return type & SENSOR_TYPE_FAN;
}
-char *psensor_value_to_string(unsigned int type, double value)
+static double celcius_to_fahrenheit(double c)
+{
+ return c * (9.0/5.0) + 32;
+}
+
+char *psensor_value_to_string(unsigned int type,
+ double value,
+ int use_celcius)
{
/* should not be possible to exceed 20 characters with temp or
rpm values the .x part is never displayed */
char *unit;
if (is_temp_type(type))
- unit = "C";
+ if (use_celcius) {
+ unit = "C";
+ } else {
+ unit = "F";
+ value = celcius_to_fahrenheit(value);
+ }
else if (type & SENSOR_TYPE_CPU_USAGE)
unit = "%";
else
parameter 'type' is SENSOR_TYPE_LMSENSOR_TEMP, SENSOR_TYPE_NVIDIA,
or SENSOR_TYPE_LMSENSOR_FAN
*/
-char *psensor_value_to_string(unsigned int type, double value);
+char *psensor_value_to_string(unsigned int type,
+ double value,
+ int use_celcius);
struct psensor **get_all_sensors(int use_libatasmart, int values_max_length);
screen = gtk_widget_get_screen(ui->main_window);
- log_debug("Config alpha channel enabled: %d", cfg->alpha_channel_enabled);
+ log_debug("Config alpha channel enabled: %d",
+ cfg->alpha_channel_enabled);
if (cfg->alpha_channel_enabled && gdk_screen_is_composited(screen)) {
log_debug("Screen is composited");
visual = gdk_screen_get_rgba_visual(screen);
GtkToggleButton *w_hide_window_decoration, *w_keep_window_below,
*w_enable_menu, *w_enable_launcher_counter, *w_hide_on_startup,
*w_win_restore;
+ GtkComboBoxText *w_temp_unit;
cfg = ui->config;
gtk_toggle_button_set_active(w_win_restore,
cfg->window_restore_enabled);
+ w_temp_unit
+ = GTK_COMBO_BOX_TEXT(gtk_builder_get_object
+ (builder, "temperature_unit"));
+ gtk_combo_box_set_active(GTK_COMBO_BOX(w_temp_unit),
+ cfg->temperature_unit);
+
+
result = gtk_dialog_run(diag);
if (result == GTK_RESPONSE_ACCEPT) {
cfg->window_restore_enabled
= gtk_toggle_button_get_active(w_win_restore);
+ cfg->temperature_unit
+ = gtk_combo_box_get_active(GTK_COMBO_BOX(w_temp_unit));
+
config_save(cfg);
g_mutex_unlock(ui->sensors_mutex);
void ui_sensorlist_update(struct ui_psensor *ui)
{
+ char *str;
+ struct psensor *s;
GtkTreeIter iter;
struct ui_sensorlist *ui_sl = ui->ui_sensorlist;
GtkTreeModel *model
= gtk_tree_view_get_model(ui_sl->treeview);
gboolean valid = gtk_tree_model_get_iter_first(model, &iter);
struct psensor **sensor = ui->sensors;
+ int use_celcius;
- while (valid && *sensor) {
- struct psensor *s = *sensor;
+ use_celcius = ui->config->temperature_unit == CELCIUS;
- char *str;
+ while (valid && *sensor) {
+ s = *sensor;
str = psensor_value_to_string(s->type,
s->measures[s->values_max_length -
- 1].value.d_num);
+ 1].value.d_num,
+ use_celcius);
gtk_list_store_set(GTK_LIST_STORE(model), &iter, COL_TEMP, str,
-1);
free(str);
- str = psensor_value_to_string(s->type, s->min);
+ str = psensor_value_to_string(s->type, s->min, use_celcius);
gtk_list_store_set(GTK_LIST_STORE(model), &iter,
COL_TEMP_MIN, str, -1);
free(str);
- str = psensor_value_to_string(s->type, s->max);
+ str = psensor_value_to_string(s->type, s->max, use_celcius);
gtk_list_store_set(GTK_LIST_STORE(model), &iter,
COL_TEMP_MAX, str, -1);
free(str);