[niepce: 11/17] Fix module activate / deactivate sequence



commit 055db844893207ca6e3dda7ab5a47f1e9cad35a1
Author: Hub Figuiere <hub figuiere net>
Date:   Thu Dec 15 00:15:36 2011 -0800

    Fix module activate / deactivate sequence

 src/niepce/ui/moduleshell.cpp       |    7 +++++++
 src/niepce/ui/moduleshell.hpp       |    1 +
 src/niepce/ui/moduleshellwidget.cpp |    1 +
 src/niepce/ui/moduleshellwidget.hpp |    1 +
 4 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/src/niepce/ui/moduleshell.cpp b/src/niepce/ui/moduleshell.cpp
index ce6e6fb..7947712 100644
--- a/src/niepce/ui/moduleshell.cpp
+++ b/src/niepce/ui/moduleshell.cpp
@@ -204,6 +204,7 @@ Gtk::Widget * ModuleShell::buildWidget(const Glib::RefPtr<Gtk::UIManager> & mana
     add_library_module(m_darkroom, _("Darkroom"));
 
     m_shell.signal_activated.connect(sigc::mem_fun(*this, &ModuleShell::on_module_activated));
+    m_shell.signal_deactivated.connect(sigc::mem_fun(*this, &ModuleShell::on_module_deactivated));
 
     // TODO PrintModuleController
     // add_library_module(, _("Print"));
@@ -255,6 +256,12 @@ void ModuleShell::on_image_activated(eng::library_id_t id)
     }
 }
 
+void ModuleShell::on_module_deactivated(int idx)
+{
+    DBG_ASSERT(idx < m_modules.size(), "wrong module index");
+    m_modules[idx]->set_active(false);
+}
+
 void ModuleShell::on_module_activated(int idx)
 {
     DBG_ASSERT(idx < m_modules.size(), "wrong module index");
diff --git a/src/niepce/ui/moduleshell.hpp b/src/niepce/ui/moduleshell.hpp
index ed70c34..00f160a 100644
--- a/src/niepce/ui/moduleshell.hpp
+++ b/src/niepce/ui/moduleshell.hpp
@@ -81,6 +81,7 @@ protected:
     virtual void add_library_module(const ILibraryModule::Ptr & module,
                                     const std::string & label);
     virtual void on_ready();
+    void on_module_deactivated(int idx);
     void on_module_activated(int idx);
 private:
     libraryclient::LibraryClient::Ptr m_libraryclient;
diff --git a/src/niepce/ui/moduleshellwidget.cpp b/src/niepce/ui/moduleshellwidget.cpp
index dffa9af..57ef74a 100644
--- a/src/niepce/ui/moduleshellwidget.cpp
+++ b/src/niepce/ui/moduleshellwidget.cpp
@@ -83,6 +83,7 @@ void ModuleShellWidget::set_current_page(int idx, Gtk::ToggleButton * btn)
         m_buttons[m_currentpage].second.unblock();
     }
     btn->set_active(true);
+    signal_deactivated(m_currentpage);
     m_currentpage = idx;
     signal_activated(idx);
 }
diff --git a/src/niepce/ui/moduleshellwidget.hpp b/src/niepce/ui/moduleshellwidget.hpp
index 492f255..632f8b1 100644
--- a/src/niepce/ui/moduleshellwidget.hpp
+++ b/src/niepce/ui/moduleshellwidget.hpp
@@ -44,6 +44,7 @@ public:
     void activate_page(int);
 
     sigc::signal<void, int> signal_activated;
+    sigc::signal<void, int> signal_deactivated;
 protected:
     
     void set_current_page(int, Gtk::ToggleButton *);



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