[niepce] Refactor / split the library view code for the modules.
- From: Hubert Figuière <hub src gnome org>
- To: svn-commits-list gnome org
- Subject: [niepce] Refactor / split the library view code for the modules.
- Date: Sat, 23 May 2009 03:30:10 -0400 (EDT)
commit 4ecc661248cca41e9f913b4b1ea153cc82bba6fd
Author: Hubert Figuiere <hub figuiere net>
Date: Mon May 18 02:54:00 2009 -0400
Refactor / split the library view code for the modules.
---
ChangeLog | 5 +
src/niepce/modules/darkroom/darkroommodule.cpp | 20 +++-
src/niepce/modules/darkroom/darkroommodule.hpp | 13 +-
src/niepce/ui/Makefile.am | 10 ++-
src/niepce/ui/gridviewmodule.cpp | 156 ++++++++++++++++++++++++
src/niepce/ui/gridviewmodule.hpp | 83 +++++++++++++
src/niepce/ui/ilibrarymodule.hpp | 46 +++++++
src/niepce/ui/librarymainviewcontroller.cpp | 124 +++-----------------
src/niepce/ui/librarymainviewcontroller.hpp | 51 +++-----
src/niepce/ui/niepcewindow.cpp | 10 +-
10 files changed, 361 insertions(+), 157 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ab5641d..956e056 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-05-18 Hubert Figuiere <hub figuiere net>
+
+ * Refactor / split the library view code
+ for the modules.
+
2009-05-17 Hubert Figuiere <hub figuiere net>
* src/ncr/image.cpp
diff --git a/src/niepce/modules/darkroom/darkroommodule.cpp b/src/niepce/modules/darkroom/darkroommodule.cpp
index c101df2..0e96fa2 100644
--- a/src/niepce/modules/darkroom/darkroommodule.cpp
+++ b/src/niepce/modules/darkroom/darkroommodule.cpp
@@ -39,6 +39,10 @@ void DarkroomModule::set_image(const eng::LibFile::Ptr & file)
}
+void DarkroomModule::dispatch_action(const std::string & /*action_name*/)
+{
+}
+
Gtk::Widget * DarkroomModule::buildWidget()
{
@@ -54,14 +58,22 @@ Gtk::Widget * DarkroomModule::buildWidget()
Gtk::Toolbar * toolbar = Gtk::manage(new Gtk::Toolbar);
Glib::RefPtr<Gtk::Action> an_action;
+ Gtk::ToolItem * tool_item;
an_action = m_actionGroup->get_action("PrevImage");
- toolbar->append(*(an_action->create_tool_item()));
+ tool_item = an_action->create_tool_item();
+ toolbar->append(*manage(tool_item));
+
an_action = m_actionGroup->get_action("NextImage");
- toolbar->append(*(an_action->create_tool_item()));
+ tool_item = an_action->create_tool_item();
+ toolbar->append(*manage(tool_item));
+
an_action = m_actionGroup->get_action("RotateLeft");
- toolbar->append(*(an_action->create_tool_item()));
+ tool_item = an_action->create_tool_item();
+ toolbar->append(*manage(tool_item));
+
an_action = m_actionGroup->get_action("RotateRight");
- toolbar->append(*(an_action->create_tool_item()));
+ tool_item = an_action->create_tool_item();
+ toolbar->append(*manage(tool_item));
m_vbox.pack_start(*toolbar, Gtk::PACK_SHRINK);
m_dr_splitview.pack1(m_vbox, Gtk::EXPAND);
diff --git a/src/niepce/modules/darkroom/darkroommodule.hpp b/src/niepce/modules/darkroom/darkroommodule.hpp
index 4450e27..6ca1c0a 100644
--- a/src/niepce/modules/darkroom/darkroommodule.hpp
+++ b/src/niepce/modules/darkroom/darkroommodule.hpp
@@ -18,8 +18,6 @@
*/
-
-
#ifndef _DARKROOM_MODULE_H__
#define _DARKROOM_MODULE_H__
@@ -33,6 +31,7 @@
#include "engine/db/libfile.hpp"
#include "libraryclient/libraryclient.hpp"
#include "ncr/image.hpp"
+#include "niepce/ui/ilibrarymodule.hpp"
#include "modules/darkroom/imagecanvas.hpp"
#include "modules/darkroom/toolboxcontroller.hpp"
@@ -43,21 +42,23 @@ class Dock;
namespace darkroom {
class DarkroomModule
- : public fwk::Controller
+ : public ui::ILibraryModule
{
public:
typedef std::tr1::shared_ptr<DarkroomModule> Ptr;
DarkroomModule(const Glib::RefPtr<Gtk::ActionGroup> & action_group,
- const libraryclient::LibraryClient::Ptr & client)
+ const sigc::slot<libraryclient::LibraryClient::Ptr> & getclient)
: m_actionGroup(action_group),
m_image(new ncr::Image),
- m_libClient(client)
+ m_getClient(getclient)
{
}
void set_image(const eng::LibFile::Ptr & file);
+ virtual void dispatch_action(const std::string & action_name);
+
protected:
virtual Gtk::Widget * buildWidget();
@@ -70,7 +71,7 @@ private:
ToolboxController::Ptr m_toolbox_ctrl;
Glib::RefPtr<Gtk::ActionGroup> m_actionGroup;
ncr::Image::Ptr m_image;
- libraryclient::LibraryClient::Ptr m_libClient;
+ sigc::slot<libraryclient::LibraryClient::Ptr> m_getClient;
fwk::Dock *m_dock;
};
diff --git a/src/niepce/ui/Makefile.am b/src/niepce/ui/Makefile.am
index 6b49fd7..8e0fa97 100644
--- a/src/niepce/ui/Makefile.am
+++ b/src/niepce/ui/Makefile.am
@@ -23,9 +23,13 @@ EXTRA_DIST = $(gladefiles)
noinst_LIBRARIES = libniepceui.a
+PUBLICHEADERS = ilibrarymodule.hpp
+
libniepceui_a_CPPFLAGS =
-libniepceui_a_SOURCES = niepcewindow.hpp niepcewindow.cpp \
+libniepceui_a_SOURCES = \
+ niepcewindow.hpp niepcewindow.cpp \
niepceapplication.hpp niepceapplication.cpp \
+ gridviewmodule.hpp gridviewmodule.cpp \
librarymainview.hpp librarymainview.cpp \
librarycellrenderer.hpp librarycellrenderer.cpp \
librarymainviewcontroller.hpp librarymainviewcontroller.cpp \
@@ -39,4 +43,6 @@ libniepceui_a_SOURCES = niepcewindow.hpp niepcewindow.cpp \
filmstripcontroller.hpp filmstripcontroller.cpp \
dialogs/importdialog.hpp dialogs/importdialog.cpp \
thumb-view/eog-thumb-nav.cpp thumb-view/eog-thumb-nav.hpp \
- thumb-view/eog-thumb-view.cpp thumb-view/eog-thumb-view.hpp
+ thumb-view/eog-thumb-view.cpp thumb-view/eog-thumb-view.hpp \
+ $(PUBLICHEADERS) \
+ $(NULL)
diff --git a/src/niepce/ui/gridviewmodule.cpp b/src/niepce/ui/gridviewmodule.cpp
new file mode 100644
index 0000000..3f7ca61
--- /dev/null
+++ b/src/niepce/ui/gridviewmodule.cpp
@@ -0,0 +1,156 @@
+/*
+ * niepce - ui/gridviewmodule.hpp
+ *
+ * Copyright (C) 2009 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include <gtkmm/liststore.h>
+#include <gtkmm/treestore.h>
+#include <gtkmm/treeselection.h>
+
+#include "fwk/base/debug.hpp"
+#include "fwk/toolkit/application.hpp"
+#include "fwk/toolkit/configdatabinder.hpp"
+#include "fwk/toolkit/widgets/dock.hpp"
+#include "gridviewmodule.hpp"
+#include "librarycellrenderer.hpp"
+
+
+namespace ui {
+
+
+GridViewModule::GridViewModule(const sigc::slot<libraryclient::LibraryClient::Ptr> & getclient,
+ const Glib::RefPtr<ImageListStore> & store)
+ : m_getclient(getclient)
+ , m_model(store)
+{
+}
+
+void
+GridViewModule::on_lib_notification(const eng::LibNotification &ln)
+{
+ switch(ln.type) {
+ case eng::Library::NOTIFY_METADATA_QUERIED:
+ {
+ eng::LibMetadata::Ptr lm
+ = boost::any_cast<eng::LibMetadata::Ptr>(ln.param);
+ DBG_OUT("received metadata");
+ m_metapanecontroller->display(lm->id(), lm.get());
+ break;
+ }
+ case eng::Library::NOTIFY_METADATA_CHANGED:
+ {
+ DBG_OUT("metadata changed");
+ std::tr1::array<int, 3> m = boost::any_cast<std::tr1::array<int, 3> >(ln.param);
+ if(m[0] == m_metapanecontroller->displayed_file()) {
+ // FIXME: actually just update the metadata
+ m_getclient()->requestMetadata(m[0]);
+ }
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+
+void GridViewModule::display_none()
+{
+ m_metapanecontroller->display(0, NULL);
+}
+
+
+Gtk::Widget * GridViewModule::buildWidget()
+{
+ m_librarylistview.set_model(m_model);
+ m_librarylistview.set_selection_mode(Gtk::SELECTION_SINGLE);
+ m_librarylistview.property_row_spacing() = 0;
+ m_librarylistview.property_column_spacing() = 0;
+ m_librarylistview.property_spacing() = 0;
+
+ // the main cell
+ LibraryCellRenderer * libcell = Gtk::manage(new LibraryCellRenderer());
+
+ GtkCellLayout *cl = GTK_CELL_LAYOUT(m_librarylistview.gobj());
+ DBG_ASSERT(cl, "No cell layout");
+ gtk_cell_layout_pack_start(cl, GTK_CELL_RENDERER(libcell->gobj()),
+ FALSE);
+ gtk_cell_layout_add_attribute(cl,
+ GTK_CELL_RENDERER(libcell->gobj()),
+ "pixbuf", m_model->columns().m_pix.index());
+ gtk_cell_layout_add_attribute(cl,
+ GTK_CELL_RENDERER(libcell->gobj()),
+ "libfile", m_model->columns().m_libfile.index());
+
+ m_scrollview.add(m_librarylistview);
+ m_scrollview.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
+ m_lib_splitview.pack1(m_scrollview);
+ m_dock = new fwk::Dock();
+ m_metapanecontroller = MetaDataPaneController::Ptr(new MetaDataPaneController(*m_dock));
+ add(m_metapanecontroller);
+ m_lib_splitview.pack2(m_dock->getWidget());
+ (void)m_metapanecontroller->buildWidget();
+
+ m_databinders.add_binder(new fwk::ConfigDataBinder<int>(
+ m_lib_splitview.property_position(),
+ fwk::Application::app()->config(),
+ "meta_pane_splitter"));
+ return &m_lib_splitview;
+}
+
+
+void GridViewModule::dispatch_action(const std::string & /*action_name*/)
+{
+}
+
+
+Gtk::IconView * GridViewModule::image_list()
+{
+ return & m_librarylistview;
+}
+
+int GridViewModule::get_selected()
+{
+ int id = 0;
+ Glib::RefPtr<Gtk::TreeSelection> selection;
+
+ Gtk::IconView::ArrayHandle_TreePaths paths = m_librarylistview.get_selected_items();
+ if(!paths.empty()) {
+ Gtk::TreePath path(*(paths.begin()));
+ DBG_OUT("found path %s", path.to_string().c_str());
+ Gtk::TreeRow row = *(m_model->get_iter(path));
+ if(row) {
+ DBG_OUT("found row");
+ eng::LibFile::Ptr libfile = row[m_model->columns().m_libfile];
+ if(libfile) {
+ id = libfile->id();
+ }
+ }
+ }
+ DBG_OUT("get_selected %d", id);
+ return id;
+}
+
+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);
+}
+
+
+}
diff --git a/src/niepce/ui/gridviewmodule.hpp b/src/niepce/ui/gridviewmodule.hpp
new file mode 100644
index 0000000..33ad5ef
--- /dev/null
+++ b/src/niepce/ui/gridviewmodule.hpp
@@ -0,0 +1,83 @@
+/*
+ * niepce - ui/gridviewmodule.hpp
+ *
+ * Copyright (C) 2009 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+
+#ifndef __UI_GRIDVIEWMODULE_HPP_
+#define __UI_GRIDVIEWMODULE_HPP_
+
+#include <gtkmm/iconview.h>
+#include <gtkmm/scrolledwindow.h>
+#include <gtkmm/paned.h>
+#include <gtkmm/liststore.h>
+#include <gtkmm/treestore.h>
+
+#include "engine/db/library.hpp"
+#include "niepce/ui/ilibrarymodule.hpp"
+#include "niepce/ui/metadatapanecontroller.hpp"
+#include "niepce/ui/selectioncontroller.hpp"
+
+namespace fwk {
+class Dock;
+}
+
+namespace ui {
+
+
+class GridViewModule
+ : public ILibraryModule
+ , public IImageSelectable
+{
+public:
+ typedef std::tr1::shared_ptr<GridViewModule> Ptr;
+
+ GridViewModule(const sigc::slot<libraryclient::LibraryClient::Ptr> & getclient,
+ const Glib::RefPtr<ImageListStore> & store);
+
+
+ void on_lib_notification(const eng::LibNotification &);
+ void display_none();
+
+ /* ILibraryModule */
+ virtual void dispatch_action(const std::string & action_name);
+
+ /* IImageSelectable */
+ virtual Gtk::IconView * image_list();
+ virtual int get_selected();
+ virtual void select_image(int id);
+
+protected:
+ virtual Gtk::Widget * buildWidget();
+
+
+private:
+ sigc::slot<libraryclient::LibraryClient::Ptr> m_getclient;
+ Glib::RefPtr<ImageListStore> m_model;
+
+ // library split view
+ Gtk::IconView m_librarylistview;
+ Gtk::ScrolledWindow m_scrollview;
+ MetaDataPaneController::Ptr m_metapanecontroller;
+ Gtk::HPaned m_lib_splitview;
+ fwk::Dock *m_dock;
+};
+
+
+}
+#endif
diff --git a/src/niepce/ui/ilibrarymodule.hpp b/src/niepce/ui/ilibrarymodule.hpp
new file mode 100644
index 0000000..c134acb
--- /dev/null
+++ b/src/niepce/ui/ilibrarymodule.hpp
@@ -0,0 +1,46 @@
+/*
+ * niepce - niepce/ui/niepcelibrarymodule.hpp
+ *
+ * Copyright (C) 2009 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef __NIEPCE_UI_ILIBRARYMODULE_HPP_
+#define __NIEPCE_UI_ILIBRARYMODULE_HPP_
+
+#include <string>
+#include <tr1/memory>
+
+#include "fwk/toolkit/controller.hpp"
+
+namespace ui {
+
+/** interface to implement a library module */
+class ILibraryModule
+ : public fwk::Controller
+{
+public:
+ typedef std::tr1::shared_ptr<ILibraryModule> Ptr;
+
+ /** dispatch action by name to the controller */
+ virtual void dispatch_action(const std::string & action_name) = 0;
+};
+
+
+}
+
+
+#endif
diff --git a/src/niepce/ui/librarymainviewcontroller.cpp b/src/niepce/ui/librarymainviewcontroller.cpp
index fc7c36f..4148964 100644
--- a/src/niepce/ui/librarymainviewcontroller.cpp
+++ b/src/niepce/ui/librarymainviewcontroller.cpp
@@ -29,94 +29,40 @@
#include "fwk/base/debug.hpp"
#include "niepce/notifications.hpp"
#include "engine/db/library.hpp"
+#include "engine/db/libfile.hpp"
#include "fwk/toolkit/application.hpp"
-#include "fwk/toolkit/widgets/dock.hpp"
#include "librarymainviewcontroller.hpp"
#include "niepcewindow.hpp"
#include "metadatapanecontroller.hpp"
-#include "librarycellrenderer.hpp"
namespace ui {
-void
-LibraryMainViewController::on_lib_notification(const eng::LibNotification &ln)
-{
- switch(ln.type) {
- case eng::Library::NOTIFY_METADATA_QUERIED:
- {
- eng::LibMetadata::Ptr lm
- = boost::any_cast<eng::LibMetadata::Ptr>(ln.param);
- DBG_OUT("received metadata");
- m_metapanecontroller->display(lm->id(), lm.get());
- break;
- }
- case eng::Library::NOTIFY_METADATA_CHANGED:
- {
- DBG_OUT("metadata changed");
- std::tr1::array<int, 3> m = boost::any_cast<std::tr1::array<int, 3> >(ln.param);
- if(m[0] == m_metapanecontroller->displayed_file()) {
- // FIXME: actually just update the metadata
- getLibraryClient()->requestMetadata(m[0]);
- }
- break;
- }
- default:
- break;
- }
-}
Gtk::Widget * LibraryMainViewController::buildWidget()
{
- m_librarylistview.set_model(m_model);
- m_librarylistview.set_selection_mode(Gtk::SELECTION_SINGLE);
- m_librarylistview.property_row_spacing() = 0;
- m_librarylistview.property_column_spacing() = 0;
- m_librarylistview.property_spacing() = 0;
-
- // the main cell
- LibraryCellRenderer * libcell = Gtk::manage(new LibraryCellRenderer());
-
- GtkCellLayout *cl = GTK_CELL_LAYOUT(m_librarylistview.gobj());
- DBG_ASSERT(cl, "No cell layout");
- gtk_cell_layout_pack_start(cl, GTK_CELL_RENDERER(libcell->gobj()),
- FALSE);
- gtk_cell_layout_add_attribute(cl,
- GTK_CELL_RENDERER(libcell->gobj()),
- "pixbuf", m_model->columns().m_pix.index());
- gtk_cell_layout_add_attribute(cl,
- GTK_CELL_RENDERER(libcell->gobj()),
- "libfile", m_model->columns().m_libfile.index());
-
- m_scrollview.add(m_librarylistview);
- m_scrollview.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
- m_lib_splitview.pack1(m_scrollview);
- m_dock = new fwk::Dock();
- m_metapanecontroller = MetaDataPaneController::Ptr(new MetaDataPaneController(*m_dock));
- add(m_metapanecontroller);
- m_lib_splitview.pack2(m_dock->getWidget());
- (void)m_metapanecontroller->buildWidget();
-
- m_databinders.add_binder(new fwk::ConfigDataBinder<int>(
- m_lib_splitview.property_position(),
- fwk::Application::app()->config(),
- "meta_pane_splitter"));
-
- m_mainview.append_page(m_lib_splitview, _("Library"));
+ m_gridview = GridViewModule::Ptr(new GridViewModule(m_getclient, m_model));
+ add_library_module(m_gridview, _("Library"));
m_darkroom = darkroom::DarkroomModule::Ptr(
- new darkroom::DarkroomModule(m_actionGroup, getLibraryClient()));
- add(m_darkroom);
- m_mainview.append_page(*m_darkroom->widget(), _("Darkroom"));
+ new darkroom::DarkroomModule(m_actionGroup, m_getclient));
+ add_library_module(m_darkroom, _("Darkroom"));
// TODO PrintModuleController
- // m_mainview.append_page(, _("Print"));
+ // add_library_module(, _("Print"));
return &m_mainview;
}
+void LibraryMainViewController::add_library_module(const ILibraryModule::Ptr & module,
+ const std::string & label)
+{
+ add(module);
+ m_mainview.append_page(*module->widget(), label);
+}
+
void LibraryMainViewController::on_ready()
{
}
@@ -126,10 +72,10 @@ void LibraryMainViewController::on_selected(int id)
{
DBG_OUT("selected callback %d", id);
if(id > 0) {
- getLibraryClient()->requestMetadata(id);
+ m_getclient()->requestMetadata(id);
}
else {
- m_metapanecontroller->display(0, NULL);
+ m_gridview->display_none();
}
}
@@ -143,47 +89,7 @@ void LibraryMainViewController::on_image_activated(int id)
m_mainview.activate_page(1);
}
}
-
-
-libraryclient::LibraryClient::Ptr LibraryMainViewController::getLibraryClient()
-{
- return std::tr1::dynamic_pointer_cast<NiepceWindow>(m_parent.lock())->getLibraryClient();
-}
-
-
-Gtk::IconView * LibraryMainViewController::image_list()
-{
- return & m_librarylistview;
-}
-
-int LibraryMainViewController::get_selected()
-{
- int id = 0;
- Glib::RefPtr<Gtk::TreeSelection> selection;
-
- Gtk::IconView::ArrayHandle_TreePaths paths = m_librarylistview.get_selected_items();
- if(!paths.empty()) {
- Gtk::TreePath path(*(paths.begin()));
- DBG_OUT("found path %s", path.to_string().c_str());
- Gtk::TreeRow row = *(m_model->get_iter(path));
- if(row) {
- DBG_OUT("found row");
- eng::LibFile::Ptr libfile = row[m_model->columns().m_libfile];
- if(libfile) {
- id = libfile->id();
- }
- }
- }
- DBG_OUT("get_selected %d", id);
- return id;
-}
-void LibraryMainViewController::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);
-}
}
diff --git a/src/niepce/ui/librarymainviewcontroller.hpp b/src/niepce/ui/librarymainviewcontroller.hpp
index ae9f4c0..16b30eb 100644
--- a/src/niepce/ui/librarymainviewcontroller.hpp
+++ b/src/niepce/ui/librarymainviewcontroller.hpp
@@ -1,7 +1,7 @@
/*
* niepce - ui/librarymainviewcontroller.h
*
- * Copyright (C) 2007-2008 Hubert Figuiere
+ * Copyright (C) 2007-2009 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
@@ -22,75 +22,62 @@
#define __UI_LIBRARYMAINVIEWCONTROLLER_H__
-#include <gtkmm/iconview.h>
-#include <gtkmm/liststore.h>
-#include <gtkmm/treestore.h>
-#include <gtkmm/scrolledwindow.h>
-#include <gtkmm/paned.h>
#include "librarymainview.hpp"
-#include "engine/db/libfile.hpp"
-#include "engine/db/library.hpp"
#include "libraryclient/libraryclient.hpp"
#include "fwk/toolkit/controller.hpp"
#include "fwk/toolkit/notification.hpp"
-#include "metadatapanecontroller.hpp"
-#include "selectioncontroller.hpp"
+#include "niepce/ui/gridviewmodule.hpp"
#include "modules/darkroom/darkroommodule.hpp"
#include "imageliststore.hpp"
namespace Gtk {
class Widget;
}
-namespace fwk {
-class Dock;
-}
namespace ui {
class LibraryMainViewController
- : public fwk::Controller,
- public IImageSelectable
+ : public fwk::Controller
{
public:
typedef std::tr1::shared_ptr<LibraryMainViewController> Ptr;
typedef std::tr1::weak_ptr<LibraryMainViewController> WeakPtr;
- LibraryMainViewController(const Glib::RefPtr<Gtk::ActionGroup> & actions,
+ LibraryMainViewController(const sigc::slot<libraryclient::LibraryClient::Ptr> get_client,
+ const Glib::RefPtr<Gtk::ActionGroup> & actions,
const Glib::RefPtr<ImageListStore> & store)
- : m_actionGroup(actions),
- m_model(store)
+ : m_getclient(get_client)
+ , m_actionGroup(actions)
+ , m_model(store)
{
}
- void on_lib_notification(const eng::LibNotification &);
+
+ const GridViewModule::Ptr & get_gridview() const
+ {
+ return m_gridview;
+ }
/** called when somehing is selected by the shared selection */
void on_selected(int id);
void on_image_activated(int id);
- virtual Gtk::IconView * image_list();
- virtual int get_selected();
- virtual void select_image(int id);
protected:
virtual Gtk::Widget * buildWidget();
+ virtual void add_library_module(const ILibraryModule::Ptr & module,
+ const std::string & label);
virtual void on_ready();
private:
- libraryclient::LibraryClient::Ptr getLibraryClient();
+ sigc::slot<libraryclient::LibraryClient::Ptr> m_getclient;
Glib::RefPtr<Gtk::ActionGroup> m_actionGroup;
+ Glib::RefPtr<ImageListStore> m_model;
// managed widgets...
- LibraryMainView m_mainview;
- Gtk::IconView m_librarylistview;
- Gtk::ScrolledWindow m_scrollview;
- // library split view
- Gtk::HPaned m_lib_splitview;
- fwk::Dock *m_dock;
- MetaDataPaneController::Ptr m_metapanecontroller;
+ LibraryMainView m_mainview;
+ GridViewModule::Ptr m_gridview;
darkroom::DarkroomModule::Ptr m_darkroom;
-
- Glib::RefPtr<ImageListStore> m_model;
};
}
diff --git a/src/niepce/ui/niepcewindow.cpp b/src/niepce/ui/niepcewindow.cpp
index c8fc1c5..501f08c 100644
--- a/src/niepce/ui/niepcewindow.cpp
+++ b/src/niepce/ui/niepcewindow.cpp
@@ -103,12 +103,14 @@ NiepceWindow::buildWidget()
// main view
m_mainviewctrl = LibraryMainViewController::Ptr(
- new LibraryMainViewController(m_refActionGroup,
+ new LibraryMainViewController(sigc::mem_fun(
+ *this, &NiepceWindow::getLibraryClient),
+ m_refActionGroup,
m_selection_controller->list_store()));
m_notifcenter->signal_lib_notification
.connect(sigc::mem_fun(
- *m_mainviewctrl,
- &LibraryMainViewController::on_lib_notification));
+ *m_mainviewctrl->get_gridview(),
+ &GridViewModule::on_lib_notification));
add(m_mainviewctrl);
// workspace treeview
@@ -143,7 +145,7 @@ NiepceWindow::buildWidget()
m_statusBar.push(Glib::ustring(_("Ready")));
m_selection_controller->add_selectable(m_filmstrip.get());
- m_selection_controller->add_selectable(m_mainviewctrl.get());
+ m_selection_controller->add_selectable(m_mainviewctrl->get_gridview().get());
m_selection_controller->signal_selected
.connect(sigc::mem_fun(*m_mainviewctrl,
&LibraryMainViewController::on_selected));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]