[niepce] Follow selection in the darkroom module. Fix a regression where selecting again would reset the imag



commit c4cdef5faa7a8d55287e4d39718840c9e12c14b5
Author: Hubert Figuière <hub figuiere net>
Date:   Sat Jun 29 19:49:24 2013 -0400

    Follow selection in the darkroom module. Fix a regression where selecting
    again would reset the image.

 src/niepce/modules/darkroom/darkroommodule.cpp |    9 ++++++---
 src/niepce/modules/darkroom/imagecanvas.cpp    |   10 +++++++++-
 src/niepce/modules/darkroom/imagecanvas.hpp    |    6 ++++--
 3 files changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/src/niepce/modules/darkroom/darkroommodule.cpp b/src/niepce/modules/darkroom/darkroommodule.cpp
index 59cf615..22680dc 100644
--- a/src/niepce/modules/darkroom/darkroommodule.cpp
+++ b/src/niepce/modules/darkroom/darkroommodule.cpp
@@ -70,12 +70,14 @@ void DarkroomModule::set_image(const eng::LibFile::Ptr & file)
 {
     if(m_imagefile.expired() || (file != m_imagefile.lock())) {
         m_imagefile = eng::LibFile::WeakPtr(file);
+        m_need_reload = true;
     }
-    else {
+    else if(!static_cast<bool>(file)) {
         m_imagefile.reset();
+        m_need_reload = true;
     }
-    m_need_reload = true;
-    if(m_active) {
+
+    if(m_need_reload && m_active) {
         reload_image();
     }
 }
@@ -150,6 +152,7 @@ Gtk::Widget * DarkroomModule::buildWidget(const Glib::RefPtr<Gtk::UIManager> & m
 void DarkroomModule::on_selected(eng::library_id_t id)
 {
     eng::LibFile::Ptr file = m_shell.get_selection_controller()->get_file(id);
+    DBG_OUT("selection is %ld", id);
     set_image(file);
 }
 
diff --git a/src/niepce/modules/darkroom/imagecanvas.cpp b/src/niepce/modules/darkroom/imagecanvas.cpp
index 76fe6fe..c077f95 100644
--- a/src/niepce/modules/darkroom/imagecanvas.cpp
+++ b/src/niepce/modules/darkroom/imagecanvas.cpp
@@ -1,7 +1,7 @@
 /*
  * niepce - darkroom/imagecanvas.cpp
  *
- * Copyright (C) 2008-2009 Hubert Figuiere
+ * Copyright (C) 2008-2013 Hubert Figuiere
  *
  * 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
@@ -58,8 +58,16 @@ void ImageCanvas::set_image(const ncr::Image::Ptr & img)
 void ImageCanvas::on_image_reloaded()
 {
     m_need_redisplay = true;
+    invalidate();
 }
 
+void ImageCanvas::invalidate()
+{
+    Glib::RefPtr<Gdk::Window> w = get_window();
+    if(w) {
+        w->invalidate(false);
+    }
+}
 
 double ImageCanvas::_calc_image_scale(int img_w, int img_h)
 {
diff --git a/src/niepce/modules/darkroom/imagecanvas.hpp b/src/niepce/modules/darkroom/imagecanvas.hpp
index 5bea986..df60ff2 100644
--- a/src/niepce/modules/darkroom/imagecanvas.hpp
+++ b/src/niepce/modules/darkroom/imagecanvas.hpp
@@ -1,7 +1,7 @@
 /*
- * niepce - darkroom/imagecanvas.h
+ * niepce - darkroom/imagecanvas.hpp
  *
- * Copyright (C) 2008-2009 Hubert Figuiere
+ * Copyright (C) 2008-2013 Hubert Figuiere
  *
  * 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
@@ -56,6 +56,8 @@ public:
 protected:
     virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
 private:
+    void invalidate();
+
     void on_image_reloaded();
 
     void _calc_image_frame(int img_w, int img_h,


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