[niepce] Add UiController. Properly merge and unmerge UI and split actions from NiepceWindow to the ModuleShe
- From: Hubert Figuière <hub src gnome org>
- To: svn-commits-list gnome org
- Subject: [niepce] Add UiController. Properly merge and unmerge UI and split actions from NiepceWindow to the ModuleShe
- Date: Fri, 17 Jul 2009 03:56:32 +0000 (UTC)
commit 290fe9aa55d0b6929565e6ec813118634499367f
Author: Hubert Figuiere <hub figuiere net>
Date: Mon Jul 13 16:43:57 2009 -0400
Add UiController. Properly merge and unmerge UI and split actions from NiepceWindow to the ModuleShell.
ChangeLog | 3 +
src/fwk/toolkit/Makefile.am | 1 +
src/fwk/toolkit/application.cpp | 13 +--
src/fwk/toolkit/application.hpp | 5 +-
src/fwk/toolkit/controller.cpp | 6 -
src/fwk/toolkit/controller.hpp | 9 --
src/fwk/toolkit/dockable.hpp | 4 +-
src/fwk/toolkit/frame.hpp | 4 +-
src/fwk/toolkit/uicontroller.cpp | 56 +++++++++++
src/fwk/toolkit/uicontroller.hpp | 67 ++++++++++++++
src/niepce/ui/filmstripcontroller.hpp | 4 +-
src/niepce/ui/ilibrarymodule.hpp | 4 +-
src/niepce/ui/imageliststore.cpp | 4 +-
src/niepce/ui/moduleshell.cpp | 135 +++++++++++++++++++++++++++-
src/niepce/ui/moduleshell.hpp | 26 ++++--
src/niepce/ui/niepcewindow.cpp | 162 ++++++---------------------------
src/niepce/ui/niepcewindow.hpp | 3 +-
src/niepce/ui/selectioncontroller.hpp | 4 +-
src/niepce/ui/workspacecontroller.cpp | 4 +-
src/niepce/ui/workspacecontroller.hpp | 6 +-
20 files changed, 332 insertions(+), 188 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a7270d2..2e0c7bb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2009-07-13 Hubert Figuiere <hub figuiere net>
+ * Add UiController. Properly merge and unmerge UI and split
+ actions from NiepceWindow to the ModuleShell.
+
* API change in fwk::Controller to pass a Gtk::UIManager
to buildWidget()
diff --git a/src/fwk/toolkit/Makefile.am b/src/fwk/toolkit/Makefile.am
index 33546dd..7c0940a 100644
--- a/src/fwk/toolkit/Makefile.am
+++ b/src/fwk/toolkit/Makefile.am
@@ -17,6 +17,7 @@ libniepceframework_a_SOURCES = configuration.hpp configuration.cpp \
dialog.hpp dialog.cpp \
frame.hpp frame.cpp \
controller.hpp controller.cpp \
+ uicontroller.hpp uicontroller.cpp \
notification.hpp \
mimetype.hpp mimetype.cpp \
imageloader.hpp imageloader.cpp \
diff --git a/src/fwk/toolkit/application.cpp b/src/fwk/toolkit/application.cpp
index b13568d..800b8b3 100644
--- a/src/fwk/toolkit/application.cpp
+++ b/src/fwk/toolkit/application.cpp
@@ -30,6 +30,7 @@
#include "fwk/base/debug.hpp"
#include "fwk/utils/boost.hpp"
#include "application.hpp"
+#include "uicontroller.hpp"
#include "frame.hpp"
@@ -39,7 +40,7 @@ Application::Ptr Application::m_application;
Application::Application(const char * name)
: m_config(Glib::ustring("/apps/") + name),
- m_refUIManager()
+ m_refUIManager(Gtk::UIManager::create())
{
register_theme(_("System"), "");
}
@@ -49,11 +50,6 @@ Application::~Application()
{
}
-/** no widget for applications */
-Gtk::Widget * Application::buildWidget(const Glib::RefPtr<Gtk::UIManager> &)
-{
- return NULL;
-}
Application::Ptr Application::app()
{
@@ -161,7 +157,10 @@ void Application::about()
void Application::add(const Controller::Ptr & sub)
{
Controller::add(sub);
- sub->buildWidget(uiManager());
+ UiController::Ptr uictrl = std::tr1::dynamic_pointer_cast<UiController>(sub);
+ if(uictrl) {
+ uictrl->buildWidget(uiManager());
+ }
}
void Application::on_about()
diff --git a/src/fwk/toolkit/application.hpp b/src/fwk/toolkit/application.hpp
index a41127e..14d563a 100644
--- a/src/fwk/toolkit/application.hpp
+++ b/src/fwk/toolkit/application.hpp
@@ -57,13 +57,10 @@ public:
{ return m_config; }
Glib::RefPtr<Gtk::UIManager> uiManager()
{
- if(!m_refUIManager) {
- m_refUIManager = Gtk::UIManager::create();
- }
return m_refUIManager;
}
- virtual Gtk::Widget * buildWidget(const Glib::RefPtr<Gtk::UIManager> & manager);
+
virtual void quit();
void about();
virtual void add(const Controller::Ptr & sub);
diff --git a/src/fwk/toolkit/controller.cpp b/src/fwk/toolkit/controller.cpp
index 79a2d25..efa1b79 100644
--- a/src/fwk/toolkit/controller.cpp
+++ b/src/fwk/toolkit/controller.cpp
@@ -29,7 +29,6 @@
namespace fwk {
Controller::Controller()
- : m_widget(NULL)
{
}
@@ -39,11 +38,6 @@ Controller::~Controller()
// DBG_OUT("destroy Controllers");
}
-Gtk::Widget * Controller::widget() const
-{
- DBG_ASSERT(!m_parent.expired(), "must be attached");
- return m_widget;
-}
void
Controller::add(const Controller::Ptr & sub)
diff --git a/src/fwk/toolkit/controller.hpp b/src/fwk/toolkit/controller.hpp
index cd50ddd..1c21fcc 100644
--- a/src/fwk/toolkit/controller.hpp
+++ b/src/fwk/toolkit/controller.hpp
@@ -26,14 +26,10 @@
#include <list>
#include <tr1/memory>
-#include <gtkmm/uimanager.h>
#include <sigc++/trackable.h>
#include "fwk/utils/databinder.hpp"
-namespace Gtk {
- class Widget;
-}
namespace fwk {
@@ -61,10 +57,6 @@ public:
/** signal that the controller needs to terminate */
virtual void terminate();
- /** return the widget controlled (construct it if needed) */
- virtual Gtk::Widget * buildWidget(const Glib::RefPtr<Gtk::UIManager> & manager) = 0;
- Gtk::Widget * widget() const;
-
/** called when everything is ready
* subclasses should reimplement if needed
*/
@@ -74,7 +66,6 @@ protected:
virtual void _added();
void _ready();
- Gtk::Widget* m_widget;
WeakPtr m_parent;
std::list<Ptr> m_subs; /**< sub controllers */
diff --git a/src/fwk/toolkit/dockable.hpp b/src/fwk/toolkit/dockable.hpp
index 2c7a63c..cac9bb4 100644
--- a/src/fwk/toolkit/dockable.hpp
+++ b/src/fwk/toolkit/dockable.hpp
@@ -21,7 +21,7 @@
#ifndef __FRAMEWORK_DOCKABLE_H__
#define __FRAMEWORK_DOCKABLE_H__
-#include "fwk/toolkit/controller.hpp"
+#include "fwk/toolkit/uicontroller.hpp"
#include "fwk/toolkit/widgets/dock-item.hpp"
namespace fwk {
@@ -30,7 +30,7 @@ namespace fwk {
/** A dockable item controller
*/
class Dockable
- : public Controller,
+ : public UiController,
protected DockItem
{
public:
diff --git a/src/fwk/toolkit/frame.hpp b/src/fwk/toolkit/frame.hpp
index 10d1c91..0f07f8e 100644
--- a/src/fwk/toolkit/frame.hpp
+++ b/src/fwk/toolkit/frame.hpp
@@ -28,7 +28,7 @@
#include <gtkmm/toggleaction.h>
#include <gtkmm/builder.h>
-#include "fwk/toolkit/controller.hpp"
+#include "fwk/toolkit/uicontroller.hpp"
namespace Gtk {
class Dialog;
@@ -37,7 +37,7 @@ namespace Gtk {
namespace fwk {
class Frame
- : public Controller
+ : public UiController
{
public:
typedef std::tr1::shared_ptr<Frame> Ptr;
diff --git a/src/fwk/toolkit/uicontroller.cpp b/src/fwk/toolkit/uicontroller.cpp
new file mode 100644
index 0000000..6c545cf
--- /dev/null
+++ b/src/fwk/toolkit/uicontroller.cpp
@@ -0,0 +1,56 @@
+/*
+ * niepce - fwk/toolkit/uicontroller.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 "fwk/base/debug.hpp"
+#include "uicontroller.hpp"
+
+namespace fwk {
+
+UiController::UiController()
+ : m_widget(NULL)
+ , m_ui_merge_id(0)
+{
+}
+
+UiController::~UiController()
+{
+ if(m_uimanager && m_ui_merge_id) {
+ m_uimanager->remove_ui(m_ui_merge_id);
+ }
+}
+
+
+Gtk::Widget * UiController::widget() const
+{
+ DBG_ASSERT(!m_parent.expired(), "must be attached");
+ return m_widget;
+}
+
+}
+
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
diff --git a/src/fwk/toolkit/uicontroller.hpp b/src/fwk/toolkit/uicontroller.hpp
new file mode 100644
index 0000000..81f11c9
--- /dev/null
+++ b/src/fwk/toolkit/uicontroller.hpp
@@ -0,0 +1,67 @@
+/*
+ * niepce - fwk/toolkit/uicontroller.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 __FRAMEWORK_UICONTROLLER_H__
+#define __FRAMEWORK_UICONTROLLER_H__
+
+
+#include <gtkmm/uimanager.h>
+
+#include "fwk/toolkit/controller.hpp"
+
+namespace Gtk {
+ class Widget;
+}
+
+namespace fwk {
+
+class UiController
+ : public Controller
+{
+public:
+ typedef std::tr1::shared_ptr<UiController> Ptr;
+
+ UiController();
+ virtual ~UiController();
+
+ /** return the widget controlled (construct it if needed) */
+ virtual Gtk::Widget * buildWidget(const Glib::RefPtr<Gtk::UIManager> & manager) = 0;
+ Gtk::Widget * widget() const;
+
+protected:
+ Gtk::Widget* m_widget;
+ Glib::RefPtr<Gtk::UIManager> m_uimanager;
+ Gtk::UIManager::ui_merge_id m_ui_merge_id;
+};
+
+}
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+
+
+#endif
diff --git a/src/niepce/ui/filmstripcontroller.hpp b/src/niepce/ui/filmstripcontroller.hpp
index 7b2c684..4b3701d 100644
--- a/src/niepce/ui/filmstripcontroller.hpp
+++ b/src/niepce/ui/filmstripcontroller.hpp
@@ -22,7 +22,7 @@
#ifndef __UI_FILMSTRIPCONTROLLER_H_
#define __UI_FILMSTRIPCONTROLLER_H_
-#include "fwk/toolkit/controller.hpp"
+#include "fwk/toolkit/uicontroller.hpp"
#include "fwk/toolkit/notificationcenter.hpp"
#include "ui/selectioncontroller.hpp"
@@ -34,7 +34,7 @@ namespace ui {
class FilmStripController
- : public fwk::Controller,
+ : public fwk::UiController,
public IImageSelectable
{
public:
diff --git a/src/niepce/ui/ilibrarymodule.hpp b/src/niepce/ui/ilibrarymodule.hpp
index c134acb..8ff2ab5 100644
--- a/src/niepce/ui/ilibrarymodule.hpp
+++ b/src/niepce/ui/ilibrarymodule.hpp
@@ -24,13 +24,13 @@
#include <string>
#include <tr1/memory>
-#include "fwk/toolkit/controller.hpp"
+#include "fwk/toolkit/uicontroller.hpp"
namespace ui {
/** interface to implement a library module */
class ILibraryModule
- : public fwk::Controller
+ : public fwk::UiController
{
public:
typedef std::tr1::shared_ptr<ILibraryModule> Ptr;
diff --git a/src/niepce/ui/imageliststore.cpp b/src/niepce/ui/imageliststore.cpp
index a2cae2d..37e2ec0 100644
--- a/src/niepce/ui/imageliststore.cpp
+++ b/src/niepce/ui/imageliststore.cpp
@@ -133,7 +133,9 @@ void ImageListStore::on_tnail_notification(const eng::ThumbnailNotification &tn)
libraryclient::LibraryClient::Ptr ImageListStore::getLibraryClient()
{
- return std::tr1::dynamic_pointer_cast<NiepceWindow>(m_controller.lock())->getLibraryClient();
+ ModuleShell::Ptr shell = std::tr1::dynamic_pointer_cast<ModuleShell>(m_controller.lock());
+ DBG_ASSERT(shell, "parent not a ModuleShell");
+ return shell->getLibraryClient();
}
}
diff --git a/src/niepce/ui/moduleshell.cpp b/src/niepce/ui/moduleshell.cpp
index e3d80a3..22c8093 100644
--- a/src/niepce/ui/moduleshell.cpp
+++ b/src/niepce/ui/moduleshell.cpp
@@ -23,9 +23,11 @@
#include <gtkmm/celllayout.h>
#include <gtkmm/cellrenderer.h>
+#include <gtkmm/stock.h>
#include "fwk/base/debug.hpp"
#include "niepce/notifications.hpp"
+#include "niepce/stock.hpp"
#include "engine/db/library.hpp"
#include "engine/db/libfile.hpp"
#include "fwk/toolkit/application.hpp"
@@ -43,10 +45,138 @@ Gtk::Widget * ModuleShell::buildWidget(const Glib::RefPtr<Gtk::UIManager> & mana
if(m_widget) {
return m_widget;
}
+ DBG_ASSERT(manager, "manager is NULL");
+
m_widget = &m_shell;
m_ui_manager = manager;
+
+ m_selection_controller = SelectionController::Ptr(new SelectionController);
+ add(m_selection_controller);
+
+ Glib::RefPtr<Gtk::Action> an_action;
+
+ m_actionGroup->add(Gtk::Action::create("MenuImage", _("_Image")));
+
+ m_actionGroup->add(Gtk::Action::create("PrevImage", Gtk::Stock::GO_BACK),
+ Gtk::AccelKey(GDK_Left, Gdk::ModifierType(0)),
+ sigc::mem_fun(*m_selection_controller,
+ &SelectionController::select_previous));
+ m_actionGroup->add(Gtk::Action::create("NextImage", Gtk::Stock::GO_FORWARD),
+ Gtk::AccelKey(GDK_Right, Gdk::ModifierType(0)),
+ sigc::mem_fun(*m_selection_controller,
+ &SelectionController::select_next));
+
+ an_action = Gtk::Action::create("RotateLeft", niepce::Stock::ROTATE_LEFT);
+ m_actionGroup->add(an_action, sigc::bind(
+ sigc::mem_fun(*m_selection_controller,
+ &SelectionController::rotate), -90));
+ an_action = Gtk::Action::create("RotateRight", niepce::Stock::ROTATE_RIGHT);
+ m_actionGroup->add(an_action, sigc::bind(
+ sigc::mem_fun(*m_selection_controller,
+ &SelectionController::rotate), 90));
+
+ m_actionGroup->add(Gtk::Action::create("SetLabel", _("Set _Label")));
+ m_actionGroup->add(Gtk::Action::create("SetLabel6", _("Label _6")),
+ Gtk::AccelKey("6"), sigc::bind(
+ sigc::mem_fun(*m_selection_controller,
+ &SelectionController::set_label),
+ 1));
+ m_actionGroup->add(Gtk::Action::create("SetLabel7", _("Label _7")),
+ Gtk::AccelKey("7"), sigc::bind(
+ sigc::mem_fun(*m_selection_controller,
+ &SelectionController::set_label),
+ 2));
+ m_actionGroup->add(Gtk::Action::create("SetLabel8", _("Label _8")),
+ Gtk::AccelKey("8"), sigc::bind(
+ sigc::mem_fun(*m_selection_controller,
+ &SelectionController::set_label),
+ 3));
+ m_actionGroup->add(Gtk::Action::create("SetLabel9", _("Label _9")),
+ Gtk::AccelKey("9"), sigc::bind(
+ sigc::mem_fun(*m_selection_controller,
+ &SelectionController::set_label),
+ 4));
+
+ m_actionGroup->add(Gtk::Action::create("SetRating", _("Set _Rating")));
+ m_actionGroup->add(Gtk::Action::create("SetRating0", _("_No Rating")),
+ Gtk::AccelKey("0"), sigc::bind(
+ sigc::mem_fun(*m_selection_controller,
+ &SelectionController::set_rating),
+ 0));
+ m_actionGroup->add(Gtk::Action::create("SetRating1", _("_1 Star")),
+ Gtk::AccelKey("1"), sigc::bind(
+ sigc::mem_fun(*m_selection_controller,
+ &SelectionController::set_rating),
+ 1));
+ m_actionGroup->add(Gtk::Action::create("SetRating2", _("_2 Stars")),
+ Gtk::AccelKey("2"), sigc::bind(
+ sigc::mem_fun(*m_selection_controller,
+ &SelectionController::set_rating),
+ 2));
+ m_actionGroup->add(Gtk::Action::create("SetRating3", _("_3 Stars")),
+ Gtk::AccelKey("3"), sigc::bind(
+ sigc::mem_fun(*m_selection_controller,
+ &SelectionController::set_rating),
+ 3));
+ m_actionGroup->add(Gtk::Action::create("SetRating4", _("_4 Stars")),
+ Gtk::AccelKey("4"), sigc::bind(
+ sigc::mem_fun(*m_selection_controller,
+ &SelectionController::set_rating),
+ 4));
+ m_actionGroup->add(Gtk::Action::create("SetRating5", _("_5 Stars")),
+ Gtk::AccelKey("5"), sigc::bind(
+ sigc::mem_fun(*m_selection_controller,
+ &SelectionController::set_rating),
+ 5));
+ m_actionGroup->add(Gtk::Action::create("DeleteImage", Gtk::Stock::DELETE));
+
+ manager->insert_action_group(m_actionGroup);
+
+
+ Glib::ustring ui_info =
+ "<ui>"
+ " <menubar>"
+ " <placeholder action='MenuImage'>"
+ " <menuitem action='PrevImage'/>"
+ " <menuitem action='NextImage'/>"
+ " <separator/>"
+ " <menuitem action='RotateLeft'/>"
+ " <menuitem action='RotateRight'/>"
+ " <separator/>"
+ " <menu action='SetRating'>"
+ " <menuitem action='SetRating0'/>"
+ " <menuitem action='SetRating1'/>"
+ " <menuitem action='SetRating2'/>"
+ " <menuitem action='SetRating3'/>"
+ " <menuitem action='SetRating4'/>"
+ " <menuitem action='SetRating5'/>"
+ " </menu>"
+ " <menu action='SetLabel'>"
+ " <menuitem action='SetLabel6'/>"
+ " <menuitem action='SetLabel7'/>"
+ " <menuitem action='SetLabel8'/>"
+ " <menuitem action='SetLabel9'/>"
+ " <separator/>"
+ " </menu>"
+ " <separator/>"
+ " <menuitem action='DeleteImage'/>"
+ " </placeholder>"
+ " </menubar>"
+ "</ui>";
+ m_ui_merge_id = manager->add_ui_from_string(ui_info);
+
+
+ m_gridview = GridViewModule::Ptr(
+ new GridViewModule(m_getclient,
+ m_selection_controller->get_list_store()));
add_library_module(m_gridview, _("Library"));
+ m_selection_controller->add_selectable(m_gridview.get());
+ m_selection_controller->signal_selected
+ .connect(sigc::mem_fun(*this, &ModuleShell::on_selected));
+ m_selection_controller->signal_activated
+ .connect(sigc::mem_fun(*this, &ModuleShell::on_image_activated));
+
m_darkroom = darkroom::DarkroomModule::Ptr(
new darkroom::DarkroomModule(m_actionGroup, m_getclient));
@@ -87,9 +217,10 @@ void ModuleShell::on_selected(int id)
void ModuleShell::on_image_activated(int id)
{
DBG_OUT("on image activated %d", id);
- Gtk::TreeIter iter = m_model->get_iter_from_id(id);
+ Glib::RefPtr<ImageListStore> store = m_selection_controller->get_list_store();
+ Gtk::TreeIter iter = store->get_iter_from_id(id);
if(iter) {
- eng::LibFile::Ptr libfile = (*iter)[m_model->columns().m_libfile];
+ eng::LibFile::Ptr libfile = (*iter)[store->columns().m_libfile];
m_darkroom->set_image(libfile);
m_shell.activate_page(1);
}
diff --git a/src/niepce/ui/moduleshell.hpp b/src/niepce/ui/moduleshell.hpp
index bc0f740..d65770e 100644
--- a/src/niepce/ui/moduleshell.hpp
+++ b/src/niepce/ui/moduleshell.hpp
@@ -25,7 +25,7 @@
#include "moduleshellwidget.hpp"
#include "libraryclient/libraryclient.hpp"
-#include "fwk/toolkit/controller.hpp"
+#include "fwk/toolkit/uicontroller.hpp"
#include "fwk/toolkit/notification.hpp"
#include "niepce/ui/gridviewmodule.hpp"
#include "modules/darkroom/darkroommodule.hpp"
@@ -38,19 +38,15 @@ namespace Gtk {
namespace ui {
class ModuleShell
- : public fwk::Controller
+ : public fwk::UiController
{
public:
typedef std::tr1::shared_ptr<ModuleShell> Ptr;
typedef std::tr1::weak_ptr<ModuleShell> WeakPtr;
- ModuleShell(const sigc::slot<libraryclient::LibraryClient::Ptr> get_client,
- const Glib::RefPtr<Gtk::ActionGroup> & actions,
- const Glib::RefPtr<ImageListStore> & store)
+ ModuleShell(const sigc::slot<libraryclient::LibraryClient::Ptr> get_client)
: m_getclient(get_client)
- , m_actionGroup(actions)
- , m_model(store)
- , m_gridview(new GridViewModule(m_getclient, m_model))
+ , m_actionGroup(Gtk::ActionGroup::create("ModuleShell"))
{
}
@@ -59,6 +55,18 @@ public:
{
return m_gridview;
}
+ const Glib::RefPtr<ImageListStore> & get_list_store() const
+ {
+ return m_selection_controller->get_list_store();
+ }
+ const SelectionController::Ptr & get_selection_controller() const
+ {
+ return m_selection_controller;
+ }
+ libraryclient::LibraryClient::Ptr getLibraryClient() const
+ {
+ return m_getclient();
+ }
/** called when somehing is selected by the shared selection */
void on_selected(int id);
@@ -72,12 +80,12 @@ protected:
private:
sigc::slot<libraryclient::LibraryClient::Ptr> m_getclient;
Glib::RefPtr<Gtk::ActionGroup> m_actionGroup;
- Glib::RefPtr<ImageListStore> m_model;
// managed widgets...
ModuleShellWidget m_shell;
Glib::RefPtr<Gtk::UIManager> m_ui_manager;
+ ui::SelectionController::Ptr m_selection_controller;
GridViewModule::Ptr m_gridview;
darkroom::DarkroomModule::Ptr m_darkroom;
};
diff --git a/src/niepce/ui/niepcewindow.cpp b/src/niepce/ui/niepcewindow.cpp
index c45344f..0af9838 100644
--- a/src/niepce/ui/niepcewindow.cpp
+++ b/src/niepce/ui/niepcewindow.cpp
@@ -71,6 +71,7 @@ NiepceWindow::~NiepceWindow()
Gtk::Widget *
NiepceWindow::buildWidget(const Glib::RefPtr<Gtk::UIManager> & manager)
{
+ DBG_ASSERT(manager, "manager is NULL");
if(m_widget) {
return m_widget;
}
@@ -78,10 +79,7 @@ NiepceWindow::buildWidget(const Glib::RefPtr<Gtk::UIManager> & manager)
m_widget = &win;
- m_selection_controller = SelectionController::Ptr(new SelectionController);
- add(m_selection_controller);
-
- init_actions();
+ init_actions(manager);
init_ui(manager);
m_notifcenter.reset(new niepce::NotificationCenter());
@@ -94,27 +92,29 @@ NiepceWindow::buildWidget(const Glib::RefPtr<Gtk::UIManager> & manager)
sigc::mem_fun(*this, &NiepceWindow::on_lib_notification));
- m_notifcenter->signal_lib_notification
- .connect(sigc::mem_fun(
- *get_pointer(m_selection_controller->list_store()),
- &ImageListStore::on_lib_notification));
- m_notifcenter->signal_thumbnail_notification
- .connect(sigc::mem_fun(
- *get_pointer(m_selection_controller->list_store()),
- &ImageListStore::on_tnail_notification));
// main view
m_moduleshell = ModuleShell::Ptr(
new ModuleShell(sigc::mem_fun(
- *this, &NiepceWindow::getLibraryClient),
- m_refActionGroup,
- m_selection_controller->list_store()));
+ *this, &NiepceWindow::getLibraryClient)));
+ m_moduleshell->buildWidget(manager);
+
+ add(m_moduleshell);
+
m_notifcenter->signal_lib_notification
.connect(sigc::mem_fun(
*m_moduleshell->get_gridview(),
&GridViewModule::on_lib_notification));
+ m_notifcenter->signal_lib_notification
+ .connect(sigc::mem_fun(
+ *get_pointer(m_moduleshell->get_list_store()),
+ &ImageListStore::on_lib_notification));
+ m_notifcenter->signal_thumbnail_notification
+ .connect(sigc::mem_fun(
+ *get_pointer(m_moduleshell->get_list_store()),
+ &ImageListStore::on_tnail_notification));
+
- add(m_moduleshell);
// workspace treeview
m_workspacectrl = WorkspaceController::Ptr( new WorkspaceController() );
@@ -137,7 +137,8 @@ NiepceWindow::buildWidget(const Glib::RefPtr<Gtk::UIManager> & manager)
m_vbox.pack_start(m_hbox);
- m_filmstrip = FilmStripController::Ptr(new FilmStripController(m_selection_controller->list_store()));
+ SelectionController::Ptr selection_controller = m_moduleshell->get_selection_controller();
+ m_filmstrip = FilmStripController::Ptr(new FilmStripController(m_moduleshell->get_list_store()));
add(m_filmstrip);
m_vbox.pack_start(*(m_filmstrip->buildWidget(manager)), Gtk::PACK_SHRINK);
@@ -146,15 +147,7 @@ NiepceWindow::buildWidget(const Glib::RefPtr<Gtk::UIManager> & manager)
m_vbox.pack_start(m_statusBar, Gtk::PACK_SHRINK);
m_statusBar.push(Glib::ustring(_("Ready")));
- m_selection_controller->add_selectable(m_filmstrip.get());
- m_selection_controller->add_selectable(m_moduleshell->get_gridview().get());
- m_selection_controller->signal_selected
- .connect(sigc::mem_fun(*m_moduleshell,
- &ModuleShell::on_selected));
-
- m_selection_controller->signal_activated
- .connect(sigc::mem_fun(*m_moduleshell,
- &ModuleShell::on_image_activated));
+ selection_controller->add_selectable(m_filmstrip.get());
win.set_size_request(600, 400);
win.show_all_children();
@@ -179,7 +172,7 @@ void NiepceWindow::init_ui(const Glib::RefPtr<Gtk::UIManager> & manager)
" <menuitem action='Close'/>"
" <menuitem action='Quit'/>"
" </menu>"
- " <menu name='edit-menu' action='MenuEdit'>"
+ " <menu action='MenuEdit'>"
" <menuitem action='Undo'/>"
" <menuitem action='Redo'/>"
" <separator/>"
@@ -191,32 +184,10 @@ void NiepceWindow::init_ui(const Glib::RefPtr<Gtk::UIManager> & manager)
" <menuitem action='Preferences'/>"
" </menu>"
" <menu action='MenuImage'>"
- " <menuitem action='PrevImage'/>"
- " <menuitem action='NextImage'/>"
- " <separator/>"
- " <menuitem action='RotateLeft'/>"
- " <menuitem action='RotateRight'/>"
- " <separator/>"
- " <menu action='SetRating'>"
- " <menuitem action='SetRating0'/>"
- " <menuitem action='SetRating1'/>"
- " <menuitem action='SetRating2'/>"
- " <menuitem action='SetRating3'/>"
- " <menuitem action='SetRating4'/>"
- " <menuitem action='SetRating5'/>"
- " </menu>"
- " <menu action='SetLabel'>"
- " <menuitem action='SetLabel6'/>"
- " <menuitem action='SetLabel7'/>"
- " <menuitem action='SetLabel8'/>"
- " <menuitem action='SetLabel9'/>"
- " <separator/>"
- " <menuitem action='EditLabels'/>"
- " </menu>"
- " <separator/>"
- " <menuitem action='DeleteImage'/>"
" </menu>"
" <menu action='MenuTools'>"
+ " <menuitem action='EditLabels'/>"
+ " <separator/>"
" <menuitem action='ToggleToolsVisible'/>"
" <separator/>"
" </menu>"
@@ -230,12 +201,12 @@ void NiepceWindow::init_ui(const Glib::RefPtr<Gtk::UIManager> & manager)
" <toolitem action='Quit'/>"
" </toolbar>"
"</ui>";
- manager->add_ui_from_string(ui_info);
+ m_ui_merge_id = manager->add_ui_from_string(ui_info);
}
-void NiepceWindow::init_actions()
+void NiepceWindow::init_actions(const Glib::RefPtr<Gtk::UIManager> & manager)
{
Glib::RefPtr<Gtk::Action> an_action;
@@ -276,84 +247,12 @@ void NiepceWindow::init_actions()
sigc::mem_fun(*this,
&NiepceWindow::on_preferences));
- m_refActionGroup->add(Gtk::Action::create("MenuImage", _("_Image")));
-
- m_refActionGroup->add(Gtk::Action::create("PrevImage", Gtk::Stock::GO_BACK),
- Gtk::AccelKey(GDK_Left, Gdk::ModifierType(0)),
- sigc::mem_fun(*m_selection_controller,
- &SelectionController::select_previous));
- m_refActionGroup->add(Gtk::Action::create("NextImage", Gtk::Stock::GO_FORWARD),
- Gtk::AccelKey(GDK_Right, Gdk::ModifierType(0)),
- sigc::mem_fun(*m_selection_controller,
- &SelectionController::select_next));
-
- an_action = Gtk::Action::create("RotateLeft", niepce::Stock::ROTATE_LEFT);
- m_refActionGroup->add(an_action, sigc::bind(
- sigc::mem_fun(*m_selection_controller,
- &SelectionController::rotate), -90));
- an_action = Gtk::Action::create("RotateRight", niepce::Stock::ROTATE_RIGHT);
- m_refActionGroup->add(an_action, sigc::bind(
- sigc::mem_fun(*m_selection_controller,
- &SelectionController::rotate), 90));
-
- m_refActionGroup->add(Gtk::Action::create("SetLabel", _("Set _Label")));
- m_refActionGroup->add(Gtk::Action::create("SetLabel6", _("Label _6")),
- Gtk::AccelKey("6"), sigc::bind(
- sigc::mem_fun(*m_selection_controller,
- &SelectionController::set_label),
- 1));
- m_refActionGroup->add(Gtk::Action::create("SetLabel7", _("Label _7")),
- Gtk::AccelKey("7"), sigc::bind(
- sigc::mem_fun(*m_selection_controller,
- &SelectionController::set_label),
- 2));
- m_refActionGroup->add(Gtk::Action::create("SetLabel8", _("Label _8")),
- Gtk::AccelKey("8"), sigc::bind(
- sigc::mem_fun(*m_selection_controller,
- &SelectionController::set_label),
- 3));
- m_refActionGroup->add(Gtk::Action::create("SetLabel9", _("Label _9")),
- Gtk::AccelKey("9"), sigc::bind(
- sigc::mem_fun(*m_selection_controller,
- &SelectionController::set_label),
- 4));
- m_refActionGroup->add(Gtk::Action::create("EditLabels", _("_Edit Labels...")),
- sigc::mem_fun(*this, &NiepceWindow::on_action_edit_labels));
-
- m_refActionGroup->add(Gtk::Action::create("SetRating", _("Set _Rating")));
- m_refActionGroup->add(Gtk::Action::create("SetRating0", _("_No Rating")),
- Gtk::AccelKey("0"), sigc::bind(
- sigc::mem_fun(*m_selection_controller,
- &SelectionController::set_rating),
- 0));
- m_refActionGroup->add(Gtk::Action::create("SetRating1", _("_1 Star")),
- Gtk::AccelKey("1"), sigc::bind(
- sigc::mem_fun(*m_selection_controller,
- &SelectionController::set_rating),
- 1));
- m_refActionGroup->add(Gtk::Action::create("SetRating2", _("_2 Stars")),
- Gtk::AccelKey("2"), sigc::bind(
- sigc::mem_fun(*m_selection_controller,
- &SelectionController::set_rating),
- 2));
- m_refActionGroup->add(Gtk::Action::create("SetRating3", _("_3 Stars")),
- Gtk::AccelKey("3"), sigc::bind(
- sigc::mem_fun(*m_selection_controller,
- &SelectionController::set_rating),
- 3));
- m_refActionGroup->add(Gtk::Action::create("SetRating4", _("_4 Stars")),
- Gtk::AccelKey("4"), sigc::bind(
- sigc::mem_fun(*m_selection_controller,
- &SelectionController::set_rating),
- 4));
- m_refActionGroup->add(Gtk::Action::create("SetRating5", _("_5 Stars")),
- Gtk::AccelKey("5"), sigc::bind(
- sigc::mem_fun(*m_selection_controller,
- &SelectionController::set_rating),
- 5));
- m_refActionGroup->add(Gtk::Action::create("DeleteImage", Gtk::Stock::DELETE));
+
+
m_refActionGroup->add(Gtk::Action::create("MenuTools", _("_Tools")));
+ m_refActionGroup->add(Gtk::Action::create("EditLabels", _("_Edit Labels...")),
+ sigc::mem_fun(*this, &NiepceWindow::on_action_edit_labels));
m_hide_tools_action = Gtk::ToggleAction::create("ToggleToolsVisible",
_("_Hide tools"));
m_refActionGroup->add(m_hide_tools_action,
@@ -365,10 +264,9 @@ void NiepceWindow::init_actions()
sigc::mem_fun(*Application::app(),
&Application::about));
- Application::app()->uiManager()->insert_action_group(m_refActionGroup);
+ manager->insert_action_group(m_refActionGroup);
- gtkWindow().add_accel_group(Application::app()
- ->uiManager()->get_accel_group());
+ gtkWindow().add_accel_group(manager->get_accel_group());
}
diff --git a/src/niepce/ui/niepcewindow.hpp b/src/niepce/ui/niepcewindow.hpp
index cd2fd8b..e10b763 100644
--- a/src/niepce/ui/niepcewindow.hpp
+++ b/src/niepce/ui/niepcewindow.hpp
@@ -75,7 +75,7 @@ private:
void on_lib_notification(const eng::LibNotification & n);
void init_ui(const Glib::RefPtr<Gtk::UIManager> & manager);
- void init_actions();
+ void init_actions(const Glib::RefPtr<Gtk::UIManager> & manager);
void open_library(const std::string & libMoniker);
eng::Label::List & get_labels()
@@ -88,7 +88,6 @@ private:
ModuleShell::Ptr m_moduleshell; // the main views stacked.
WorkspaceController::Ptr m_workspacectrl;
FilmStripController::Ptr m_filmstrip;
- ui::SelectionController::Ptr m_selection_controller;
Gtk::Statusbar m_statusBar;
Glib::RefPtr<Gtk::ActionGroup> m_refActionGroup;
libraryclient::LibraryClient::Ptr m_libClient;
diff --git a/src/niepce/ui/selectioncontroller.hpp b/src/niepce/ui/selectioncontroller.hpp
index 9e9ded3..f9538db 100644
--- a/src/niepce/ui/selectioncontroller.hpp
+++ b/src/niepce/ui/selectioncontroller.hpp
@@ -66,7 +66,7 @@ public:
void selected(IImageSelectable *);
- const Glib::RefPtr<ImageListStore> & list_store() const
+ const Glib::RefPtr<ImageListStore> & get_list_store() const
{ return m_imageliststore; }
// the signal to call when selection is changed.
@@ -88,8 +88,6 @@ public:
void set_label(int label);
protected:
virtual void _added();
- virtual Gtk::Widget * buildWidget(const Glib::RefPtr<Gtk::UIManager> &)
- { return NULL; }
private:
int get_selection();
libraryclient::LibraryClient::Ptr getLibraryClient();
diff --git a/src/niepce/ui/workspacecontroller.cpp b/src/niepce/ui/workspacecontroller.cpp
index a90ea80..c84cbc3 100644
--- a/src/niepce/ui/workspacecontroller.cpp
+++ b/src/niepce/ui/workspacecontroller.cpp
@@ -1,7 +1,7 @@
/*
* niepce - ui/workspacecontroller.cpp
*
- * Copyright (C) 2007 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
@@ -38,7 +38,7 @@ using fwk::Application;
namespace ui {
WorkspaceController::WorkspaceController()
- : fwk::Controller()
+ : fwk::UiController()
{
Glib::RefPtr< Gtk::IconTheme > icon_theme(Application::app()->getIconTheme());
try {
diff --git a/src/niepce/ui/workspacecontroller.hpp b/src/niepce/ui/workspacecontroller.hpp
index 1d507a9..e48493f 100644
--- a/src/niepce/ui/workspacecontroller.hpp
+++ b/src/niepce/ui/workspacecontroller.hpp
@@ -1,7 +1,7 @@
/*
* niepce - ui/workspacecontroller.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
@@ -31,7 +31,7 @@
#include <gtkmm/treestore.h>
#include "engine/db/libfolder.hpp"
-#include "fwk/toolkit/controller.hpp"
+#include "fwk/toolkit/uicontroller.hpp"
#include "fwk/toolkit/notification.hpp"
namespace Gtk {
@@ -41,7 +41,7 @@ namespace Gtk {
namespace ui {
class WorkspaceController
- : public fwk::Controller
+ : public fwk::UiController
{
public:
typedef std::tr1::shared_ptr<WorkspaceController> Ptr;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]