[gnote] Disable modifying actions when note is disabled



commit baa33c85b7a6c7b8ca3b22bf2b136fe279a356c1
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Fri Jan 8 23:44:14 2016 +0200

    Disable modifying actions when note is disabled

 src/mainwindowembeds.hpp |    3 ++-
 src/note.cpp             |    5 +++--
 src/recentchanges.cpp    |    9 +++++++++
 src/recentchanges.hpp    |    3 ++-
 4 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/src/mainwindowembeds.hpp b/src/mainwindowembeds.hpp
index 3b4db42..7c451f8 100644
--- a/src/mainwindowembeds.hpp
+++ b/src/mainwindowembeds.hpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2013,2015 Aurimas Cernius
+ * Copyright (C) 2013,2015-2016 Aurimas Cernius
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -41,6 +41,7 @@ public:
   virtual bool contains(EmbeddableWidget &) = 0;
   virtual bool is_foreground(EmbeddableWidget &) = 0;
   virtual MainWindowAction::Ptr find_action(const Glib::ustring & name) = 0;
+  virtual void enabled(bool is_enabled) = 0;
 };
 
 class EmbeddableWidget
diff --git a/src/note.cpp b/src/note.cpp
index 0c4aee7..5afcb01 100644
--- a/src/note.cpp
+++ b/src/note.cpp
@@ -1,7 +1,7 @@
  /*
  * gnote
  *
- * Copyright (C) 2010-2015 Aurimas Cernius
+ * Copyright (C) 2010-2016 Aurimas Cernius
  * Copyright (C) 2009 Hubert Figuiere
  *
  * This program is free software: you can redistribute it and/or modify
@@ -828,8 +828,9 @@ namespace gnote {
         if(!enabled()) {
           m_focus_widget = window->get_focus();
         }
+        m_window->host()->enabled(enabled());
         m_window->enabled(enabled());
-        if(enabled()) {
+        if(enabled() && m_focus_widget) {
           window->set_focus(*m_focus_widget);
         }
       }
diff --git a/src/recentchanges.cpp b/src/recentchanges.cpp
index 87ac2c9..ee5bc55 100644
--- a/src/recentchanges.cpp
+++ b/src/recentchanges.cpp
@@ -604,6 +604,15 @@ namespace gnote {
     return MainWindowAction::Ptr();
   }
 
+  void NoteRecentChanges::enabled(bool is_enabled)
+  {
+    for(auto & iter : m_actions) {
+      if(iter.second->is_modifying()) {
+        iter.second->set_enabled(is_enabled);
+      }
+    }
+  }
+
   EmbeddableWidget *NoteRecentChanges::currently_embedded()
   {
     std::vector<Gtk::Widget*> children = m_embed_box.get_children();
diff --git a/src/recentchanges.hpp b/src/recentchanges.hpp
index edcf8c0..4a08d0a 100644
--- a/src/recentchanges.hpp
+++ b/src/recentchanges.hpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2010-2015 Aurimas Cernius
+ * Copyright (C) 2010-2016 Aurimas Cernius
  * Copyright (C) 2010 Debarshi Ray
  * Copyright (C) 2009 Hubert Figuiere
  *
@@ -63,6 +63,7 @@ public:
   virtual bool contains(EmbeddableWidget &) override;
   virtual bool is_foreground(EmbeddableWidget &) override;
   virtual MainWindowAction::Ptr find_action(const Glib::ustring & name) override;
+  virtual void enabled(bool is_enabled) override;
 protected:
   virtual void present_note(const Note::Ptr & note) override;
   virtual void on_show() override;


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