X-Git-Url: https://git.wpitchoune.net/gitweb/?p=psensor.git;a=blobdiff_plain;f=src%2Fui_appindicator.c;h=ed4cc6418ab6d577d8b39c4a9a511dea5fab0f88;hp=25ec3aba2a0168dc010626caced6eaeeb2e74570;hb=c1e20f2631a1249720e9c75d753eacfcb0f6c7b9;hpb=bb0b1e4ae34706014532e9e150998ec2ebe5c374 diff --git a/src/ui_appindicator.c b/src/ui_appindicator.c index 25ec3ab..ed4cc64 100644 --- a/src/ui_appindicator.c +++ b/src/ui_appindicator.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 @@ -96,9 +96,12 @@ create_sensor_menu_items(const struct ui_psensor *ui, GtkMenu *menu) const char *name; struct psensor **sorted_sensors; - celsius = ui->config->temperature_unit == CELSIUS; + if (config_get_temperature_unit() == CELSIUS) + celsius = 1; + else + celsius = 0; - sorted_sensors = ui_get_sensors_ordered_by_position(ui); + sorted_sensors = ui_get_sensors_ordered_by_position(ui->sensors); n = psensor_list_size(sorted_sensors); menu_items = malloc((n + 1) * sizeof(GtkWidget *)); @@ -165,14 +168,20 @@ static void update_label(struct ui_psensor *ui) { char *label, *str, *tmp, *guide; struct psensor **p; + int use_celsius; - p = ui_get_sensors_ordered_by_position(ui); + p = ui_get_sensors_ordered_by_position(ui->sensors); label = NULL; guide = NULL; + + if (config_get_temperature_unit() == CELSIUS) + use_celsius = 1; + else + use_celsius = 0; + while (*p) { if (config_is_appindicator_label_enabled((*p)->id)) { - str = psensor_current_value_to_str - (*p, ui->config->temperature_unit == CELSIUS); + str = psensor_current_value_to_str(*p, use_celsius); if (label == NULL) { label = str; @@ -232,7 +241,10 @@ void ui_appindicator_update(struct ui_psensor *ui, bool attention) app_indicator_set_status(indicator, APP_INDICATOR_STATUS_ATTENTION); - update_menu_items(ui->config->temperature_unit == CELSIUS); + if (config_get_temperature_unit() == CELSIUS) + update_menu_items(1); + else + update_menu_items(0); } static GtkStatusIcon *unity_fallback(AppIndicator *indicator)