X-Git-Url: http://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Fui_unity.c;h=9f9bd046b1af83076e95d5a7c3549aca140d745b;hb=51450a36b7143fe230197dfa89b5fd072af7421c;hp=17ee29dbe85fc355b0db78a41c6f5ca968b2ff07;hpb=0e52be5c9e4d3bfe732f90abe7ca3cbfa32ad59c;p=psensor.git diff --git a/src/ui_unity.c b/src/ui_unity.c index 17ee29d..9f9bd04 100644 --- a/src/ui_unity.c +++ b/src/ui_unity.c @@ -18,12 +18,36 @@ */ #include +#include +#include #include static int initialized; static UnityLauncherEntry *psensor_entry; static unsigned int last_visible = -1; +static double get_max_current_value(struct psensor **sensors, unsigned int type) +{ + double m, v; + struct psensor *s; + + m = UNKNOWN_DBL_VALUE; + while (*sensors) { + s = *sensors; + + if ((s->type & type) && config_is_sensor_graph_enabled(s->id)) { + v = psensor_get_current_value(s); + + if (m == UNKNOWN_DBL_VALUE || v > m) + m = v; + } + + sensors++; + } + + return m; +} + void ui_unity_launcher_entry_update(struct psensor **sensors, unsigned int show, int use_celsius) @@ -32,7 +56,7 @@ void ui_unity_launcher_entry_update(struct psensor **sensors, if (!initialized) { psensor_entry = unity_launcher_entry_get_for_desktop_file - ("psensor.desktop"); + (PSENSOR_DESKTOP_FILE); unity_launcher_entry_set_count(psensor_entry, 0); initialized = 1; @@ -48,12 +72,18 @@ void ui_unity_launcher_entry_update(struct psensor **sensors, last_visible = show; } - if (sensors && *sensors) { - v = psensor_get_max_current_value(sensors, SENSOR_TYPE_TEMP); + if (show && sensors && *sensors) { + v = get_max_current_value(sensors, SENSOR_TYPE_TEMP); - if (!use_celsius) - v = celsius_to_fahrenheit(v); + if (v != UNKNOWN_DBL_VALUE) { + if (!use_celsius) + v = celsius_to_fahrenheit(v); - unity_launcher_entry_set_count(psensor_entry, v); + unity_launcher_entry_set_count(psensor_entry, v); + } } } + +void ui_unity_init(void) +{ +}