status icon
authorJean-Philippe Orsini <jeanfi@gmail.com>
Fri, 11 Nov 2011 11:15:21 +0000 (11:15 +0000)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Fri, 11 Nov 2011 11:15:21 +0000 (11:15 +0000)
src/main.c
src/ui_appindicator.c
src/ui_appindicator.h
src/ui_status.c
src/ui_status.h

index 8c27902..c2f0eba 100644 (file)
@@ -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.
index 5497c7f..b884db4 100644 (file)
@@ -195,27 +195,14 @@ static GtkWidget *get_menu(struct ui_psensor *ui)
        return GTK_WIDGET(menu);
 }
 
-
-void ui_appindicator_update(struct ui_psensor *ui)
+void ui_appindicator_update(struct ui_psensor *ui,
+                           unsigned int attention)
 {
-       struct psensor **sensor_cur = ui->sensors;
        AppIndicatorStatus status;
-       int attention = 0;
 
        if (!ui->indicator)
                return;
 
-       while (*sensor_cur) {
-               struct psensor *s = *sensor_cur;
-
-               if (s->alarm_enabled && s->alarm_raised) {
-                       attention = 1;
-                       break;
-               }
-
-               sensor_cur++;
-       }
-
        status = app_indicator_get_status(ui->indicator);
 
        if (!attention && status == APP_INDICATOR_STATUS_ATTENTION)
@@ -248,7 +235,6 @@ static void unity_unfallback(AppIndicator *indicator,
        appindicator_supported = 1;
 }
 
-
 void ui_appindicator_init(struct ui_psensor *ui)
 {
        GtkWidget *menu;
index 606e698..f743c8f 100644 (file)
@@ -25,7 +25,7 @@
 
 #if defined(HAVE_APPINDICATOR) || defined(HAVE_APPINDICATOR_029)
 void ui_appindicator_init(struct ui_psensor *ui);
-void ui_appindicator_update(struct ui_psensor *ui);
+void ui_appindicator_update(struct ui_psensor *ui, unsigned int attention);
 int is_appindicator_supported();
 void ui_appindicator_cleanup();
 #else
index d9781de..517ab27 100644 (file)
@@ -73,3 +73,8 @@ void ui_status_cleanup()
 
        g_object_unref(G_OBJECT(status));
 }
+
+void ui_status_update(struct ui_psensor *ui, unsigned int attention)
+{
+       log_printf(LOG_DEBUG, "ui_status_update()");
+}
index 918ac91..7b6c6de 100644 (file)
@@ -24,7 +24,7 @@
 
 void ui_status_init(struct ui_psensor *ui);
 void ui_status_cleanup();
-
+void ui_status_update(struct ui_psensor *ui, unsigned int attention);
 /* Whether status icon is supported i.e. visible. */
 int is_status_supported();