status icon
authorJean-Philippe Orsini <jeanfi@gmail.com>
Sat, 12 Nov 2011 21:53:55 +0000 (21:53 +0000)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Sat, 12 Nov 2011 21:53:55 +0000 (21:53 +0000)
src/main.c
src/ui.c
src/ui_appindicator.c
src/ui_status.c
src/ui_status.h

index 19a01e6..f5ff0b3 100644 (file)
@@ -355,10 +355,16 @@ static gboolean initial_window_show(gpointer data)
 {
        struct ui_psensor *ui;
 
+       log_printf(LOG_DEBUG, "initial_window_show()");
+
        ui = (struct ui_psensor *)data;
 
        log_printf(LOG_DEBUG,
-                  "is_status_supported: %d\n", is_status_supported());
+                  "is_status_supported: %d", is_status_supported());
+       log_printf(LOG_DEBUG,
+                  "is_appindicator_supported: %d", is_appindicator_supported());
+       log_printf(LOG_DEBUG,
+                  "hide_on_startup: %d", ui->config->hide_on_startup);
 
        if (!ui->config->hide_on_startup
            || (!is_appindicator_supported() && !is_status_supported()))
@@ -470,14 +476,6 @@ int main(int argc, char **argv)
        /* sensor list */
        ui_sensorlist_create(&ui);
 
-       /*
-        * 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.
-       */
-       g_idle_add((GSourceFunc)initial_window_show, &ui);
-
        thread = g_thread_create((GThreadFunc) update_psensor_measures,
                                 &ui, TRUE, &error);
 
@@ -492,6 +490,14 @@ int main(int argc, char **argv)
        ui_appindicator_init(&ui);
 #endif
 
+       /*
+        * 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.
+       */
+       g_idle_add((GSourceFunc)initial_window_show, &ui);
+
        gdk_notify_startup_complete();
 
        /* main loop */
index aef453b..9a78a86 100644 (file)
--- a/src/ui.c
+++ b/src/ui.c
@@ -344,5 +344,6 @@ void ui_window_update(struct ui_psensor *ui)
 
 void ui_window_show(struct ui_psensor *ui)
 {
+       log_printf(LOG_DEBUG, "ui_window_show()");
        gtk_window_present(GTK_WINDOW(ui->main_window));
 }
index 6607e43..08ef670 100644 (file)
@@ -28,6 +28,7 @@
 #include "ui.h"
 #include "ui_appindicator.h"
 #include "ui_sensorpref.h"
+#include "ui_status.h"
 #include "ui_pref.h"
 
 static GtkMenuItem **sensor_menu_items;
@@ -216,11 +217,9 @@ static GtkStatusIcon *unity_fallback(AppIndicator *indicator)
 {
        log_printf(LOG_DEBUG, "ui_appindicator#unity_fallback");
 
-       gtk_widget_show_all(main_window);
-
        appindicator_supported = 0;
 
-       return NULL;
+       return ui_status_get_icon();
 }
 
 static void
index a316e90..39fe77d 100644 (file)
@@ -17,8 +17,6 @@
  * 02110-1301 USA
  */
 
-#include <gtk/gtk.h>
-
 #include "log.h"
 #include "ui_status.h"
 
@@ -43,6 +41,9 @@ static void cb_popup_menu(GtkStatusIcon *icon,
 
 void ui_status_init(struct ui_psensor *ui)
 {
+       if (status)
+               return ;
+       
        log_printf(LOG_DEBUG, "ui_status_create()");
 
        status = gtk_status_icon_new();
@@ -83,3 +84,8 @@ void ui_status_update(struct ui_psensor *ui, unsigned int attention)
 
        status_attention = attention;
 }
+
+GtkStatusIcon *ui_status_get_icon()
+{
+       return status;
+}
index 7b6c6de..40cc3c5 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef _PSENSOR_UI_STATUS_H_
 #define _PSENSOR_UI_STATUS_H_
 
+#include <gtk/gtk.h>
 #include <ui.h>
 
 void ui_status_init(struct ui_psensor *ui);
@@ -27,5 +28,6 @@ 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();
+GtkStatusIcon *ui_status_get_icon();
 
 #endif