[niepce] Properly handle deselection.
- From: Hubert Figuière <hub src gnome org>
- To: svn-commits-list gnome org
- Subject: [niepce] Properly handle deselection.
- Date: Fri, 17 Jul 2009 03:57:12 +0000 (UTC)
commit 81fcb109943eed88d7e824ce00e04a21e86770a6
Author: Hubert Figuiere <hub figuiere net>
Date: Wed Jul 15 20:36:13 2009 -0400
Properly handle deselection.
ChangeLog | 2 ++
src/niepce/ui/filmstripcontroller.cpp | 7 ++++++-
src/niepce/ui/gridviewmodule.cpp | 7 ++++++-
src/niepce/ui/selectioncontroller.cpp | 17 ++++++++++++-----
src/niepce/ui/selectioncontroller.hpp | 8 ++++----
5 files changed, 30 insertions(+), 11 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1c5d4e8..855efe3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
2009-07-15 Hubert Figuiere <hub figuiere net>
+ * Properly handle deselection.
+
* Show a 0 rating of rating was unset.
2009-07-14 Hubert Figuiere <hub figuiere net>
diff --git a/src/niepce/ui/filmstripcontroller.cpp b/src/niepce/ui/filmstripcontroller.cpp
index 0e34b75..a637ffd 100644
--- a/src/niepce/ui/filmstripcontroller.cpp
+++ b/src/niepce/ui/filmstripcontroller.cpp
@@ -80,7 +80,12 @@ void FilmStripController::select_image(int id)
{
DBG_OUT("filmstrip select %d", id);
Gtk::TreePath path = m_store->get_path_from_id(id);
- m_thumbview->select_path(path);
+ if(path) {
+ m_thumbview->select_path(path);
+ }
+ else {
+ m_thumbview->unselect_all();
+ }
}
diff --git a/src/niepce/ui/gridviewmodule.cpp b/src/niepce/ui/gridviewmodule.cpp
index b1e2bfb..c93224b 100644
--- a/src/niepce/ui/gridviewmodule.cpp
+++ b/src/niepce/ui/gridviewmodule.cpp
@@ -154,7 +154,12 @@ void GridViewModule::select_image(int id)
{
DBG_OUT("library select %d", id);
Gtk::TreePath path = m_model->get_path_from_id(id);
- m_librarylistview.select_path(path);
+ if(path) {
+ m_librarylistview.select_path(path);
+ }
+ else {
+ m_librarylistview.unselect_all();
+ }
}
diff --git a/src/niepce/ui/selectioncontroller.cpp b/src/niepce/ui/selectioncontroller.cpp
index bb403a6..96e8836 100644
--- a/src/niepce/ui/selectioncontroller.cpp
+++ b/src/niepce/ui/selectioncontroller.cpp
@@ -20,6 +20,7 @@
#include <boost/bind.hpp>
#include <gtkmm/iconview.h>
+#include <gtkmm/treeiter.h>
#include <glibmm/i18n.h>
#include "fwk/base/autoflag.hpp"
@@ -60,13 +61,19 @@ void SelectionController::add_selectable(IImageSelectable * selectable)
}
-void SelectionController::activated(const Gtk::TreeModel::Path & /*path*/,
- IImageSelectable * selectable)
+void SelectionController::activated(const Gtk::TreeModel::Path & path,
+ IImageSelectable * /*selectable*/)
{
fwk::AutoFlag f(m_in_handler);
- int selection = selectable->get_selected();
- DBG_OUT("item activated %d", selection);
- signal_activated(selection);
+ Gtk::TreeIter iter = m_imageliststore->get_iter(path);
+ if(iter) {
+ eng::LibFile::Ptr file = (*iter)[m_imageliststore->columns().m_libfile];
+ if(file) {
+ int selection = file->id();
+ DBG_OUT("item activated %d", selection);
+ signal_activated(selection);
+ }
+ }
}
void SelectionController::selected(IImageSelectable * selectable)
diff --git a/src/niepce/ui/selectioncontroller.hpp b/src/niepce/ui/selectioncontroller.hpp
index f9538db..c343021 100644
--- a/src/niepce/ui/selectioncontroller.hpp
+++ b/src/niepce/ui/selectioncontroller.hpp
@@ -41,14 +41,14 @@ namespace ui {
class IImageSelectable
{
public:
- virtual ~IImageSelectable() {}
- virtual Gtk::IconView * image_list() = 0;
+ virtual ~IImageSelectable() {}
+ virtual Gtk::IconView * image_list() = 0;
/** Return the id of the selection. <= 0 is none. */
- virtual int get_selected() = 0;
+ virtual int get_selected() = 0;
/** select the image a specific id
* might emit the signals.
*/
- virtual void select_image(int id) = 0;
+ virtual void select_image(int id) = 0;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]