[gnote/stable-0.7] Use actual visibility of status icon



commit 1cda8cc41fc431e505e06683d2ae81c5d987c1b1
Author: Aurimas Äernius <aurisc4 gmail com>
Date:   Wed Jul 20 22:49:35 2011 +0300

    Use actual visibility of status icon
    
    When checking for status icon visibility, use actual state
    instead of the value, recorded during startup.
    Fixes bug 650001.

 src/gnote.cpp         |   11 ++++-------
 src/gnote.hpp         |    8 ++++----
 src/recentchanges.cpp |    4 ++--
 3 files changed, 10 insertions(+), 13 deletions(-)
---
diff --git a/src/gnote.cpp b/src/gnote.cpp
index 0b804ff..8bda8d4 100644
--- a/src/gnote.cpp
+++ b/src/gnote.cpp
@@ -64,8 +64,6 @@
 
 namespace gnote {
 
-  bool Gnote::s_tray_icon_showing = false;
-
   Gnote::Gnote()
     : m_manager(NULL)
     , m_keybinder(NULL)
@@ -123,7 +121,6 @@ namespace gnote {
 
     if(m_is_panel_applet) {
       DBG_OUT("starting applet");
-      s_tray_icon_showing = true;
 
       am["CloseWindowAction"]->set_visible(true);
       am["QuitGNoteAction"]->set_visible(false);
@@ -179,10 +176,10 @@ namespace gnote {
 
     // Give the TrayIcon 2 seconds to appear.  If it
     // doesn't by then, open the SearchAllNotes window.
-    s_tray_icon_showing = m_tray_icon->is_embedded() 
+    bool is_tray_icon_showing = m_tray_icon->is_embedded()
       && m_tray_icon->get_visible();
       
-    if (!s_tray_icon_showing) {
+    if (!is_tray_icon_showing) {
       Glib::RefPtr<Glib::TimeoutSource> timeout 
         = Glib::TimeoutSource::create(2000);
       timeout->connect(sigc::mem_fun(*this, &Gnote::check_tray_icon_showing));
@@ -195,9 +192,9 @@ namespace gnote {
 
   bool Gnote::check_tray_icon_showing()
   {
-    s_tray_icon_showing = m_tray_icon->is_embedded() 
+    bool is_tray_icon_showing = m_tray_icon->is_embedded()
       && m_tray_icon->get_visible();
-    if(!s_tray_icon_showing) {
+    if(!is_tray_icon_showing) {
       ActionManager & am(ActionManager::obj());
       am["ShowSearchAllNotesAction"]->activate();
     }
diff --git a/src/gnote.hpp b/src/gnote.hpp
index 4337fb6..b7d4857 100644
--- a/src/gnote.hpp
+++ b/src/gnote.hpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2010 Aurimas Cernius
+ * Copyright (C) 2010-2011 Aurimas Cernius
  * Copyright (C) 2009 Hubert Figuiere
  *
  * This program is free software: you can redistribute it and/or modify
@@ -76,9 +76,10 @@ public:
   static std::string data_dir();
   static std::string old_note_dir();
 
-  static bool tray_icon_showing()
+  bool tray_icon_showing()
     {
-      return s_tray_icon_showing;
+      return m_is_panel_applet
+             || (m_tray_icon && m_tray_icon->is_embedded() && m_tray_icon->get_visible());
     }
   bool is_panel_applet()
     {
@@ -96,7 +97,6 @@ private:
   NoteManager *m_manager;
   IKeybinder  *m_keybinder;
   Glib::RefPtr<Gtk::IconTheme> m_icon_theme;
-  static bool s_tray_icon_showing;
   Glib::RefPtr<TrayIcon> m_tray_icon;
   Tray::Ptr m_tray;
   bool m_is_panel_applet;
diff --git a/src/recentchanges.cpp b/src/recentchanges.cpp
index a0cc8e3..bc95119 100644
--- a/src/recentchanges.cpp
+++ b/src/recentchanges.cpp
@@ -241,7 +241,7 @@ namespace gnote {
     // end notebook addin
     am ["CloseWindowAction"]->signal_activate()
       .connect(sigc::mem_fun(*this, &NoteRecentChanges::on_close_window));
-    if (Gnote::tray_icon_showing() == false)
+    if (Gnote::obj().tray_icon_showing() == false)
       am ["CloseWindowAction"]->set_visible(false);
 
     // Allow Escape to close the window as well as <Control>W
@@ -1090,7 +1090,7 @@ namespace gnote {
     hide ();
     delete s_instance;
     s_instance = NULL;
-    if (Gnote::tray_icon_showing() == false) {
+    if (Gnote::obj().tray_icon_showing() == false) {
       ActionManager::obj()["QuitGNoteAction"]->activate();
     }
   }



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