[niepce] * Don't use boost::bind() for signals.
- From: Hubert Figuière <hub src gnome org>
- To: svn-commits-list gnome org
- Subject: [niepce] * Don't use boost::bind() for signals.
- Date: Mon, 11 May 2009 20:34:45 -0400 (EDT)
commit 4e3a0795ab3b6e06ea7b4c4c1e3a7b36524beade
Author: Hubert Figuiere <hub figuiere net>
Date: Sun May 10 22:07:56 2009 -0400
* Don't use boost::bind() for signals.
* Make the UndoManager sigc::trackable.
---
ChangeLog | 3 +
src/fwk/toolkit/undo.hpp | 2 +
src/niepce/ui/niepcewindow.cpp | 121 +++++++++++++++++----------------
src/niepce/ui/selectioncontroller.cpp | 23 +++---
4 files changed, 79 insertions(+), 70 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 6792836..6f3d45c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2009-05-10 Hubert Figuiere <hub figuiere net>
+ * Don't use boost::bind() for signals.
+ * Make the UndoManager sigc::trackable.
+
* Refactor NotificationCenter to not have to decode
the notification every time.
diff --git a/src/fwk/toolkit/undo.hpp b/src/fwk/toolkit/undo.hpp
index 1b01468..e6a0acb 100644
--- a/src/fwk/toolkit/undo.hpp
+++ b/src/fwk/toolkit/undo.hpp
@@ -27,6 +27,7 @@
#include <boost/noncopyable.hpp>
#include <sigc++/signal.h>
+#include <sigc++/trackable.h>
#include "fwk/toolkit/command.hpp"
@@ -68,6 +69,7 @@ Command *UndoTransaction::new_command(const typename CommandWithArg<_ArgType>::R
class UndoHistory
: public boost::noncopyable
+ , public sigc::trackable
{
public:
~UndoHistory();
diff --git a/src/niepce/ui/niepcewindow.cpp b/src/niepce/ui/niepcewindow.cpp
index 76c0662..c8fc1c5 100644
--- a/src/niepce/ui/niepcewindow.cpp
+++ b/src/niepce/ui/niepcewindow.cpp
@@ -145,14 +145,12 @@ NiepceWindow::buildWidget()
m_selection_controller->add_selectable(m_filmstrip.get());
m_selection_controller->add_selectable(m_mainviewctrl.get());
m_selection_controller->signal_selected
- .connect(boost::bind(&LibraryMainViewController::on_selected,
- BIND_SHARED_PTR(LibraryMainViewController, m_mainviewctrl)
- , _1));
+ .connect(sigc::mem_fun(*m_mainviewctrl,
+ &LibraryMainViewController::on_selected));
m_selection_controller->signal_activated
- .connect(boost::bind(&LibraryMainViewController::on_image_activated,
- BIND_SHARED_PTR(LibraryMainViewController, m_mainviewctrl)
- , _1));
+ .connect(sigc::mem_fun(*m_mainviewctrl,
+ &LibraryMainViewController::on_image_activated));
win.set_size_request(600, 400);
win.show_all_children();
@@ -243,14 +241,14 @@ void NiepceWindow::init_actions()
m_refActionGroup->add(Gtk::Action::create("MenuLibrary", _("_Library")));
m_refActionGroup->add(Gtk::Action::create("NewLibrary", Gtk::Stock::NEW));
m_refActionGroup->add(Gtk::Action::create("OpenLibrary", Gtk::Stock::OPEN),
- boost::bind(&NiepceWindow::on_action_file_open,
- this));
+ sigc::mem_fun(*this,
+ &NiepceWindow::on_action_file_open));
m_refActionGroup->add(Gtk::Action::create("NewFolder", _("New _Folder...")));
m_refActionGroup->add(Gtk::Action::create("NewProject", _("New _Project...")));
m_refActionGroup->add(Gtk::Action::create("Import", _("_Import...")),
- sigc::mem_fun(this,
+ sigc::mem_fun(*this,
&NiepceWindow::on_action_file_import));
m_refActionGroup->add(Gtk::Action::create("Close", Gtk::Stock::CLOSE),
sigc::mem_fun(gtkWindow(),
@@ -262,15 +260,15 @@ void NiepceWindow::init_actions()
m_refActionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit")));
m_undo_action = Gtk::Action::create("Undo", Gtk::Stock::UNDO);
m_refActionGroup->add(m_undo_action, Gtk::AccelKey("<control>Z"),
- boost::bind(&UndoHistory::undo,
- boost::ref(Application::app()->undo_history())));
+ sigc::mem_fun(Application::app()->undo_history(),
+ &UndoHistory::undo));
Application::app()->undo_history().signal_changed.connect(
sigc::mem_fun(*this, &NiepceWindow::undo_state));
undo_state();
m_redo_action = Gtk::Action::create("Redo", Gtk::Stock::REDO);
m_refActionGroup->add(m_redo_action, Gtk::AccelKey("<control><shift>Z"),
- boost::bind(&UndoHistory::redo,
- boost::ref(Application::app()->undo_history())));
+ sigc::mem_fun(Application::app()->undo_history(),
+ &UndoHistory::redo));
Application::app()->undo_history().signal_changed.connect(
sigc::mem_fun(*this, &NiepceWindow::redo_state));
redo_state();
@@ -283,79 +281,84 @@ void NiepceWindow::init_actions()
m_refActionGroup->add(Gtk::Action::create("Preferences",
Gtk::Stock::PREFERENCES),
- sigc::mem_fun(this,
+ 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)),
- boost::bind(&SelectionController::select_previous,
- BIND_SHARED_PTR(SelectionController, m_selection_controller)));
+ 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)),
- boost::bind(&SelectionController::select_next,
- BIND_SHARED_PTR(SelectionController, m_selection_controller)));
+ sigc::mem_fun(*m_selection_controller,
+ &SelectionController::select_next));
an_action = Gtk::Action::create("RotateLeft", niepce::Stock::ROTATE_LEFT);
- m_refActionGroup->add(an_action, boost::bind(&SelectionController::rotate,
- BIND_SHARED_PTR(SelectionController, m_selection_controller)
- , -90));
+ 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, boost::bind(&SelectionController::rotate,
- BIND_SHARED_PTR(SelectionController, m_selection_controller)
- , 90));
+ 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"),
- boost::bind(&SelectionController::set_label,
- BIND_SHARED_PTR(SelectionController, m_selection_controller)
- , 1));
+ 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"),
- boost::bind(&SelectionController::set_label,
- BIND_SHARED_PTR(SelectionController, m_selection_controller)
- , 2));
+ 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"),
- boost::bind(&SelectionController::set_label,
- BIND_SHARED_PTR(SelectionController, m_selection_controller)
- , 3));
+ 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"),
- boost::bind(&SelectionController::set_label,
- BIND_SHARED_PTR(SelectionController, m_selection_controller)
- , 4));
+ 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"),
- boost::bind(&SelectionController::set_rating,
- BIND_SHARED_PTR(SelectionController, m_selection_controller), 0));
+ 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"),
- boost::bind(&SelectionController::set_rating,
- BIND_SHARED_PTR(SelectionController, m_selection_controller), 1));
+ 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"),
- boost::bind(&SelectionController::set_rating,
- BIND_SHARED_PTR(SelectionController, m_selection_controller), 2));
+ 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"),
- boost::bind(&SelectionController::set_rating,
- BIND_SHARED_PTR(SelectionController, m_selection_controller), 3));
+ 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"),
- boost::bind(&SelectionController::set_rating,
- BIND_SHARED_PTR(SelectionController, m_selection_controller), 4));
+ 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"),
- boost::bind(&SelectionController::set_rating,
- BIND_SHARED_PTR(SelectionController, m_selection_controller), 5));
-
+ 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")));
diff --git a/src/niepce/ui/selectioncontroller.cpp b/src/niepce/ui/selectioncontroller.cpp
index 6c78acb..062456c 100644
--- a/src/niepce/ui/selectioncontroller.cpp
+++ b/src/niepce/ui/selectioncontroller.cpp
@@ -1,5 +1,5 @@
/*
- * niepce - ui/selectioncontroller.cpp
+ * niepce - niepce/ui/selectioncontroller.cpp
*
* Copyright (C) 2008-2009 Hubert Figuiere
*
@@ -50,22 +50,23 @@ void SelectionController::_added()
void SelectionController::add_selectable(IImageSelectable * selectable)
{
DBG_OUT("added %lx", selectable);
- m_selectables.push_back(selectable);
- selectable->image_list()->signal_selection_changed().connect(
- boost::bind(&SelectionController::selected,
- this, selectable));
- selectable->image_list()->signal_item_activated().connect(
- boost::bind(&SelectionController::activated, this, _1, selectable));
+ m_selectables.push_back(selectable);
+ selectable->image_list()->signal_selection_changed().connect(
+ sigc::bind(sigc::mem_fun(*this, &SelectionController::selected),
+ selectable));
+ selectable->image_list()->signal_item_activated().connect(
+ sigc::bind(sigc::mem_fun(*this, &SelectionController::activated),
+ 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);
+ fwk::AutoFlag f(m_in_handler);
+ int selection = selectable->get_selected();
+ DBG_OUT("item activated %d", selection);
+ signal_activated(selection);
}
void SelectionController::selected(IImageSelectable * selectable)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]