[niepce] remove more std::bind() to replace by lambdas
- From: Hubert Figuière <hub src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [niepce] remove more std::bind() to replace by lambdas
- Date: Tue, 16 May 2017 04:48:28 +0000 (UTC)
commit 7e8d88a177a772208e8c7146b66e450a4e5f35ea
Author: Hubert Figuière <hub figuiere net>
Date: Sat May 13 21:23:50 2017 -0400
remove more std::bind() to replace by lambdas
src/niepce/ui/dialogs/editlabels.cpp | 29 ++++++++-------
src/niepce/ui/dialogs/preferencesdialog.cpp | 17 +++++----
src/niepce/ui/metadatapanecontroller.cpp | 8 ++--
src/niepce/ui/selectioncontroller.cpp | 52 ++++++++++++++++----------
src/niepce/ui/workspacecontroller.cpp | 12 +++---
5 files changed, 68 insertions(+), 50 deletions(-)
---
diff --git a/src/niepce/ui/dialogs/editlabels.cpp b/src/niepce/ui/dialogs/editlabels.cpp
index 1634d44..74a5e0d 100644
--- a/src/niepce/ui/dialogs/editlabels.cpp
+++ b/src/niepce/ui/dialogs/editlabels.cpp
@@ -112,25 +112,28 @@ void EditLabels::update_labels(int /*response*/)
undo = fwk::Application::app()->begin_undo(_("Change Labels"));
}
+ auto libclient = m_lib_client;
if(has_label) {
std::string current_name = m_labels[i]->label();
std::string current_colour = m_labels[i]->colour().to_string();
+ auto label_id = m_labels[i]->id();
undo->new_command<void>(
- std::bind(&libraryclient::LibraryClient::updateLabel,
- m_lib_client, m_labels[i]->id(), new_name,
- new_colour),
- std::bind(&libraryclient::LibraryClient::updateLabel,
- m_lib_client, m_labels[i]->id(), current_name,
- current_colour));
- }
- else {
- using std::placeholders::_1;
+ [libclient, new_name, new_colour, label_id] () {
+ libclient->updateLabel(label_id, new_name, new_colour);
+ },
+ [libclient, current_name, current_colour, label_id] () {
+ libclient->updateLabel(label_id, current_name,
+ current_colour);
+ });
+ } else {
undo->new_command<int>(
- std::bind(&libraryclient::LibraryClient::createLabel,
- m_lib_client, new_name, new_colour),
- std::bind(&libraryclient::LibraryClient::deleteLabel,
- m_lib_client, _1));
+ [libclient, new_name, new_colour] () {
+ return libclient->createLabel(new_name, new_colour);
+ },
+ [libclient] (int label) {
+ libclient->deleteLabel(label);
+ });
}
}
}
diff --git a/src/niepce/ui/dialogs/preferencesdialog.cpp b/src/niepce/ui/dialogs/preferencesdialog.cpp
index ed30743..2bb1cf3 100644
--- a/src/niepce/ui/dialogs/preferencesdialog.cpp
+++ b/src/niepce/ui/dialogs/preferencesdialog.cpp
@@ -44,17 +44,20 @@ void PreferencesDialog::setup_widget()
Gtk::CheckButton* write_xmp_checkbutton = nullptr;
fwk::DataBinderPool* binder_pool = new fwk::DataBinderPool();
- gtkDialog().signal_hide().connect(std::bind(&fwk::DataBinderPool::destroy,
- binder_pool));
-
+ gtkDialog().signal_hide().connect(
+ [binder_pool] () {
+ fwk::DataBinderPool::destroy(binder_pool);
+ });
+
builder()->get_widget("dark_theme_checkbox", theme_checkbutton);
-
+
theme_checkbutton->set_active(fwk::Application::app()
->get_use_dark_theme());
+ auto app = fwk::Application::app();
theme_checkbutton->signal_toggled().connect(
- std::bind(&fwk::Application::set_use_dark_theme,
- fwk::Application::app(),
- theme_checkbutton->property_active()));
+ [app, theme_checkbutton] () {
+ app->set_use_dark_theme(theme_checkbutton->property_active());
+ });
builder()->get_widget("reopen_checkbutton", reopen_checkbutton);
binder_pool->add_binder(new fwk::ConfigDataBinder<bool>(
diff --git a/src/niepce/ui/metadatapanecontroller.cpp b/src/niepce/ui/metadatapanecontroller.cpp
index e8b63f1..d5d9b6f 100644
--- a/src/niepce/ui/metadatapanecontroller.cpp
+++ b/src/niepce/ui/metadatapanecontroller.cpp
@@ -152,12 +152,12 @@ void MetaDataPaneController::display(eng::library_id_t file_id, const eng::LibMe
const fwk::PropertySet & propset = get_property_set();
meta->to_properties(propset, properties);
}
- using std::placeholders::_1;
std::for_each(m_widgets.begin(), m_widgets.end(),
- std::bind(&fwk::MetaDataWidget::set_data_source,
- _1, properties));
+ [properties] (auto w) {
+ w->set_data_source(properties);
+ });
}
-
+
}
/*
diff --git a/src/niepce/ui/selectioncontroller.cpp b/src/niepce/ui/selectioncontroller.cpp
index 2220d46..336b0ef 100644
--- a/src/niepce/ui/selectioncontroller.cpp
+++ b/src/niepce/ui/selectioncontroller.cpp
@@ -36,14 +36,14 @@ namespace ui {
SelectionController::SelectionController()
- : m_in_handler(false)
+ : m_in_handler(false)
{
- m_imageliststore = ImageListStore::create();
+ m_imageliststore = ImageListStore::create();
}
void SelectionController::_added()
{
- m_imageliststore->set_parent_controller(m_parent);
+ m_imageliststore->set_parent_controller(m_parent);
}
void SelectionController::add_selectable(const IImageSelectable::WeakPtr & selectableWeak)
@@ -196,13 +196,18 @@ bool SelectionController::_set_metadata(const std::string & undo_label,
fwk::PropertyIndex meta,
int old_value, int new_value)
{
- std::shared_ptr<fwk::UndoTransaction> undo = fwk::Application::app()->begin_undo(undo_label);
+ std::shared_ptr<fwk::UndoTransaction> undo =
+ fwk::Application::app()->begin_undo(undo_label);
+
+ auto libclient = getLibraryClient();
+ auto file_id = file->id();
undo->new_command<void>(
- std::bind(&libraryclient::LibraryClient::setMetadata,
- getLibraryClient(), file->id(), meta, fwk::PropertyValue(new_value)),
- std::bind(&libraryclient::LibraryClient::setMetadata,
- getLibraryClient(), file->id(), meta, fwk::PropertyValue(old_value))
- );
+ [libclient, file_id, meta, new_value] () {
+ libclient->setMetadata(file_id, meta, fwk::PropertyValue(new_value));
+ },
+ [libclient, file_id, meta, old_value] () {
+ libclient->setMetadata(file_id, meta, fwk::PropertyValue(old_value));
+ });
undo->execute();
return true;
}
@@ -225,13 +230,17 @@ bool SelectionController::_set_metadata(const std::string & undo_label,
}
}
+ auto libclient = getLibraryClient();
+ auto file_id = file->id();
+ auto key = iter.first;
+ auto new_value = iter.second;
undo->new_command<void>(
- std::bind(&libraryclient::LibraryClient::setMetadata,
- getLibraryClient(), file->id(),
- iter.first, iter.second),
- std::bind(&libraryclient::LibraryClient::setMetadata,
- getLibraryClient(), file->id(), iter.first, value)
- );
+ [libclient, file_id, key, new_value] () {
+ libclient->setMetadata(file_id, key, new_value);
+ },
+ [libclient, file_id, key, value] () {
+ libclient->setMetadata(file_id, key, value);
+ });
}
undo->execute();
return true;
@@ -318,12 +327,15 @@ void SelectionController::move_to_trash()
eng::library_id_t from_folder = file->folderId();
std::shared_ptr<fwk::UndoTransaction> undo =
fwk::Application::app()->begin_undo(_("Move to Trash"));
+
+ auto libclient = getLibraryClient();
undo->new_command<void>(
- std::bind(&libraryclient::LibraryClient::moveFileToFolder,
- getLibraryClient(), selection, from_folder, trash_folder),
- std::bind(&libraryclient::LibraryClient::moveFileToFolder,
- getLibraryClient(), selection, trash_folder, from_folder )
- );
+ [libclient, selection, from_folder, trash_folder] () {
+ libclient->moveFileToFolder(selection, from_folder, trash_folder);
+ },
+ [libclient, selection, from_folder, trash_folder] () {
+ libclient->moveFileToFolder(selection, trash_folder, from_folder);
+ });
undo->execute();
}
}
diff --git a/src/niepce/ui/workspacecontroller.cpp b/src/niepce/ui/workspacecontroller.cpp
index c1aabe4..3eb4edf 100644
--- a/src/niepce/ui/workspacecontroller.cpp
+++ b/src/niepce/ui/workspacecontroller.cpp
@@ -82,8 +82,6 @@ fwk::Configuration::Ptr WorkspaceController::getLibraryConfig() const
void WorkspaceController::on_lib_notification(const eng::LibNotification &ln)
{
- using std::placeholders::_1;
-
DBG_OUT("notification for workspace");
switch(ln.type) {
case eng::Library::NotifyType::ADDED_FOLDERS:
@@ -92,8 +90,9 @@ void WorkspaceController::on_lib_notification(const eng::LibNotification &ln)
= boost::any_cast<eng::LibFolder::ListPtr>(ln.param);
DBG_OUT("received added folders # %lu", l->size());
for_each(l->cbegin(), l->cend(),
- std::bind(&WorkspaceController::add_folder_item,
- this, _1));
+ [this] (const eng::LibFolder::Ptr& f) {
+ this->add_folder_item(f);
+ });
break;
}
case eng::Library::NotifyType::ADDED_KEYWORD:
@@ -110,8 +109,9 @@ void WorkspaceController::on_lib_notification(const eng::LibNotification &ln)
= boost::any_cast<eng::Keyword::ListPtr>(ln.param);
DBG_ASSERT(static_cast<bool>(l), "keyword list must not be NULL");
for_each(l->cbegin(), l->cend(),
- std::bind(&WorkspaceController::add_keyword_item,
- this, _1));
+ [this] (const eng::Keyword::Ptr& k) {
+ this->add_keyword_item(k);
+ });
break;
}
case eng::Library::NotifyType::FOLDER_COUNTED:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]