[gnote] Fix status icon for Xfce 4



commit 11a13390e6daa654b9a617869b6544bfe406e70d
Author: Aurimas Äernius <aurisc4 gmail com>
Date:   Sun Dec 30 20:20:35 2012 +0200

    Fix status icon for Xfce 4
    
    Make status icon appear on Xfce 4.
    Fixes bug 666775.

 src/gnote.cpp |   30 ++++++++++++++++++++++--------
 src/gnote.hpp |    1 +
 2 files changed, 23 insertions(+), 8 deletions(-)
---
diff --git a/src/gnote.cpp b/src/gnote.cpp
index 95767f1..80481bc 100644
--- a/src/gnote.cpp
+++ b/src/gnote.cpp
@@ -229,14 +229,30 @@ namespace gnote {
     return note_path;
   }
 
+  bool Gnote::show_tray_icon_timeout()
+  {
+    // Setting to false and back to true is required to make it work on some tray implementations
+    m_tray_icon->set_visible(false);
+    m_tray_icon->set_visible(true);
+    return false;
+  }
+
   void Gnote::start_tray_icon()
   {
     // Create Search All Notes window as we need it present for application to run
     get_main_window();
 
-    // Create the tray icon and run the main loop
-    m_tray_icon = Glib::RefPtr<TrayIcon>(new TrayIcon(default_note_manager()));
-    m_tray = m_tray_icon->tray();
+    if(!m_tray_icon) {
+      // Create the tray icon and run the main loop
+      m_tray_icon = Glib::RefPtr<TrayIcon>(new TrayIcon(default_note_manager()));
+      m_tray = m_tray_icon->tray();
+    }
+
+    // Tome make status icon visible on some implementations, it should be made visible
+    // after some timeout.
+    Glib::RefPtr<Glib::TimeoutSource> timeout = Glib::TimeoutSource::create(100);
+    timeout->connect(sigc::mem_fun(*this, &Gnote::show_tray_icon_timeout));
+    timeout->attach();
   }
 
 
@@ -263,14 +279,12 @@ namespace gnote {
     bool use_status_icon = Preferences::obj()
       .get_schema_settings(Preferences::SCHEMA_GNOTE)->get_boolean(key);
     if(use_status_icon) {
-      if(!m_tray_icon) {
-        m_tray_icon = Glib::RefPtr<TrayIcon>(new TrayIcon(default_note_manager()));
-      }
-      m_tray_icon->set_visible(true);
+      start_tray_icon();
     }
     else {
-      if(m_tray_icon)
+      if(m_tray_icon) {
         m_tray_icon->set_visible(false);
+      }
       ActionManager::obj()["ShowSearchAllNotesAction"]->activate();
     }
   }
diff --git a/src/gnote.hpp b/src/gnote.hpp
index da3ef43..192a47a 100644
--- a/src/gnote.hpp
+++ b/src/gnote.hpp
@@ -187,6 +187,7 @@ private:
   void on_new_window_action(const Glib::VariantBase&);
   void on_new_note_app_action(const Glib::VariantBase&);
   NoteRecentChanges *get_active_window();
+  bool show_tray_icon_timeout();
 
   NoteManager *m_manager;
   IKeybinder  *m_keybinder;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]