X-Git-Url: https://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Fmain.c;h=c2f0eba9197c8942d4e35032c244c1f8ac98c506;hb=bd79e2e58e6988ba9ba57a9cbc8613aff2b1bb32;hp=8c2790273c2d1590ba43dcb4b461eb7c43b4158a;hpb=7455357fec8cb68e67eca0632dc17d8fea5a145a;p=psensor.git diff --git a/src/main.c b/src/main.c index 8c27902..c2f0eba 100644 --- a/src/main.c +++ b/src/main.c @@ -174,6 +174,34 @@ void update_psensor_measures(struct ui_psensor *ui) } } +static void indicators_update(struct ui_psensor *ui) +{ + struct psensor **sensor_cur = ui->sensors; + unsigned int attention = 0; + + if (!is_appindicator_supported() && !is_status_supported()) + return ; + + while (*sensor_cur) { + struct psensor *s = *sensor_cur; + + if (s->alarm_enabled && s->alarm_raised) { + attention = 1; + break; + } + + sensor_cur++; + } + +#if defined(HAVE_APPINDICATOR) || defined(HAVE_APPINDICATOR_029) + if (is_appindicator_supported()) + ui_appindicator_update(ui, attention); +#endif + + if (is_status_supported()) + ui_status_update(ui, attention); +} + gboolean ui_refresh_thread(gpointer data) { struct config *cfg; @@ -189,9 +217,7 @@ gboolean ui_refresh_thread(gpointer data) ui_sensorlist_update(ui); -#if defined(HAVE_APPINDICATOR) || defined(HAVE_APPINDICATOR_029) - ui_appindicator_update(ui); -#endif + indicators_update(ui); #ifdef HAVE_UNITY ui_unity_launcher_entry_update(ui->sensors, @@ -451,7 +477,7 @@ int main(int argc, char **argv) ui_sensorlist_create(&ui); /* - * show the window as soon as all gtk event has been processed + * show the window as soon as all gtk events have been processed * in order to ensure that the status icon is attempted to be * drawn before. If not, there is no way to detect that it is * visible.