Commit 20194ff9 authored by Murray Cumming's avatar Murray Cumming

C++11: Use std::function instead of sigc::slot.

parent 00951d90
......@@ -108,9 +108,9 @@ AppWindow::AppWindow(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>&
ConnectionPool* connection_pool = ConnectionPool::get_instance();
if(!connection_pool)
connection_pool->set_avahi_publish_callbacks(
sigc::mem_fun(*this, &AppWindow::on_connection_avahi_begin),
sigc::mem_fun(*this, &AppWindow::on_connection_avahi_progress),
sigc::mem_fun(*this, &AppWindow::on_connection_avahi_done) );
sigc::bind(&AppWindow::on_connection_avahi_begin, this),
sigc::bind(&AppWindow::on_connection_avahi_progress, this),
sigc::bind(&AppWindow::on_connection_avahi_done, this) );
#endif
#endif // !GLOM_ENABLE_CLIENT_ONLY
......@@ -1129,7 +1129,7 @@ bool AppWindow::on_document_load()
else
{
#ifndef GLOM_ENABLE_CLIENT_ONLY
connection_pool->set_get_document_func( sigc::mem_fun(*this, &AppWindow::on_connection_pool_get_document) );
connection_pool->set_get_document_func( std::bind(&AppWindow::on_connection_pool_get_document, this) );
#endif
connection_pool->set_ready_to_connect(true); //connect_to_server() will now attempt the connection-> Shared instances of m_Connection will also be usable.
......@@ -1545,7 +1545,7 @@ void AppWindow::existing_or_new_new()
//Tell the connection pool about the document:
ConnectionPool* connection_pool = ConnectionPool::get_instance();
if(connection_pool)
connection_pool->set_get_document_func( sigc::mem_fun(*this, &AppWindow::on_connection_pool_get_document) );
connection_pool->set_get_document_func( std::bind(&AppWindow::on_connection_pool_get_document, this) );
const bool connected = m_pFrame->connection_request_password_and_choose_new_database_name();
if(!connected)
......
......@@ -2294,7 +2294,7 @@ bool Frame_Glom::create_database(const Glib::ustring& database_name, const Glib:
{
BusyCursor busycursor(*pWindowApp);
sigc::slot<void> onProgress; //TODO: Show visual feedback.
std::function<void()> onProgress; //TODO: Show visual feedback.
result = DbUtils::create_database(get_document(), database_name, title, onProgress);
}
......
......@@ -511,7 +511,7 @@ int main(int argc, char* argv[])
}
g_assert(started == Glom::ConnectionPool::Backend::STARTUPERROR_NONE);
const bool recreated = Glom::DbUtils::recreate_database_from_document(&document, sigc::ptr_fun(&on_recreate_progress) );
const bool recreated = Glom::DbUtils::recreate_database_from_document(&document, &on_recreate_progress);
if(!recreated)
cleanup();
g_assert(recreated);
......
......@@ -111,7 +111,7 @@ public:
/// Delete the singleton so it doesn't show up as leaked memory in, for instance, valgrind.
static void delete_instance();
typedef sigc::slot<void> type_void_slot;
typedef std::function<void()> type_void_slot;
#ifndef G_OS_WIN32
/** Set callbacks that will be called to show UI while starting to advertise
......@@ -283,7 +283,7 @@ public:
* This callback avoids Connection having to link to AppWindow,
* and avoids us worrying about whether a previously-set document (via a set_document() method) is still valid.
*/
typedef sigc::slot<Document*> SlotGetDocument;
typedef std::function<Document*()> SlotGetDocument;
void set_get_document_func(const SlotGetDocument& slot);
#ifndef G_OS_WIN32
......
......@@ -27,6 +27,7 @@
#include <libglom/data_structure/field.h>
#include <memory>
#include <functional>
namespace Glom
{
......@@ -119,7 +120,7 @@ protected:
/** This callback should show UI to indicate that work is still happening.
* For instance, a pulsing ProgressBar.
*/
typedef sigc::slot<void> SlotProgress;
typedef std::function<void()> SlotProgress;
/** This method is called for one-time initialization of the database
* storage. There is no need to implement this function if the data is centrally
......
......@@ -101,7 +101,7 @@ static bool update_gda_metastore_for_table(const Glib::ustring& table_name)
return true;
}
bool create_database(Document* document, const Glib::ustring& database_name, const Glib::ustring& title, const sigc::slot<void>& progress)
bool create_database(Document* document, const Glib::ustring& database_name, const Glib::ustring& title, const std::function<void()>& progress)
{
#if 1
// This seems to increase the chance that the database creation does not
......@@ -207,7 +207,7 @@ bool create_database(Document* document, const Glib::ustring& database_name, con
}
}
bool recreate_database_from_document(Document* document, const sigc::slot<void>& progress)
bool recreate_database_from_document(Document* document, const std::function<void()>& progress)
{
ConnectionPool* connection_pool = ConnectionPool::get_instance();
if(!connection_pool)
......
......@@ -33,13 +33,13 @@ namespace DbUtils
/**
* This also saves the connection port in the document if self-hosting.
*/
bool create_database(Document* document, const Glib::ustring& database_name, const Glib::ustring& title, const sigc::slot<void>& progress);
bool create_database(Document* document, const Glib::ustring& database_name, const Glib::ustring& title, const std::function<void()>& progress);
//TODO: Use this in Glom::AppWindow?
/** Create the database on an already-connected server.
* This also saves some details in the document.
*/
bool recreate_database_from_document(Document* document, const sigc::slot<void>& progress);
bool recreate_database_from_document(Document* document, const std::function<void()>& progress);
/** This creates the standard tables if necessary,
* filling them with some information from the document.
......
......@@ -42,6 +42,7 @@
#include <vector>
#include <map>
#include <limits> // for numeric_limits
#include <functional>
namespace Gtk
{
......@@ -453,7 +454,7 @@ public:
/** This callback should show UI to indicate that work is still happening.
* For instance, a pulsing ProgressBar.
*/
typedef sigc::slot<void> SlotProgress;
typedef std::function<void()> SlotProgress;
/** Save a copy of the document as a backup.
* This document (and its URI) will not be changed.
......
......@@ -39,28 +39,28 @@ public:
/** For example,
* void on_show_table_details(const Glib::ustring& table_name, const Gnome::Gda::Value& primary_key_value);
*/
sigc::slot<void, const Glib::ustring&, const Gnome::Gda::Value&> m_slot_show_table_details;
std::function<void(const Glib::ustring&, const Gnome::Gda::Value&)> m_slot_show_table_details;
/** For example,
* void on_show_table_list(const Glib::ustring& table_name);
*/
sigc::slot<void, const Glib::ustring&> m_slot_show_table_list;
std::function<void(const Glib::ustring&)> m_slot_show_table_list;
/** For example,
* void on_print_report(const Glib::ustring& report_name);
*/
sigc::slot<void, const Glib::ustring&> m_slot_print_report;
std::function<void(const Glib::ustring&)> m_slot_print_report;
/** For example,
* void on_print_layout();
*/
sigc::slot<void> m_slot_print_layout;
std::function<void()> m_slot_print_layout;
/** For example,
* void on_start_new_record();
* Use an empty Value for auto-created fields.
*/
sigc::slot<void> m_slot_start_new_record;
std::function<void()> m_slot_start_new_record;
};
} //namespace Glom
......
......@@ -22,7 +22,7 @@
#define GLOM_SPAWN_WITH_FEEDBACK_H
#include <glibmm/ustring.h>
#include <sigc++/sigc++.h>
#include <functional>
namespace Glom
{
......@@ -33,7 +33,7 @@ namespace Spawn
/** This callback should show UI to indicate that work is still happening.
* For instance, a pulsing ProgressBar.
*/
typedef sigc::slot<void> SlotProgress;
typedef std::function<void()> SlotProgress;
/** Execute a command-line command, and wait for it to return.
* @param command The command-line command.
......
......@@ -27,15 +27,15 @@ namespace Glom
AppPythonUICallbacks::AppPythonUICallbacks()
{
m_slot_show_table_details =
sigc::mem_fun(*this, &AppPythonUICallbacks::on_show_table_details);
std::bind(&AppPythonUICallbacks::on_show_table_details, this, std::placeholders::_1, std::placeholders::_2);
m_slot_show_table_list =
sigc::mem_fun(*this, &AppPythonUICallbacks::on_show_table_list);
std::bind(&AppPythonUICallbacks::on_show_table_list, this, std::placeholders::_1);
m_slot_print_report =
sigc::mem_fun(*this, &AppPythonUICallbacks::on_print_report);
std::bind(&AppPythonUICallbacks::on_print_report, this, std::placeholders::_1);
m_slot_print_layout =
sigc::mem_fun(*this, &AppPythonUICallbacks::on_print_layout);
std::bind(&AppPythonUICallbacks::on_print_layout, this);
m_slot_start_new_record =
sigc::mem_fun(*this, &AppPythonUICallbacks::on_start_new_record);
std::bind(&AppPythonUICallbacks::on_start_new_record, this);
}
void AppPythonUICallbacks::on_show_table_details(const Glib::ustring& table_name, const Gnome::Gda::Value& primary_key_value)
......
......@@ -69,15 +69,15 @@ int main()
Glom::PythonUICallbacks callbacks;
callbacks.m_slot_show_table_list =
sigc::ptr_fun(&on_script_ui_show_table_list);
&on_script_ui_show_table_list;
callbacks.m_slot_show_table_details =
sigc::ptr_fun(&on_script_ui_show_table_details);
&on_script_ui_show_table_details;
callbacks.m_slot_print_report =
sigc::ptr_fun(&on_script_ui_print_report);
&on_script_ui_print_report;
callbacks.m_slot_print_layout =
sigc::ptr_fun(&on_script_ui_print_layout);
&on_script_ui_print_layout;
callbacks.m_slot_start_new_record =
sigc::ptr_fun(&on_script_ui_start_new_record);
&on_script_ui_start_new_record;
//Execute a python script:
Glib::ustring error_message;
......
......@@ -254,7 +254,7 @@ bool test_create_and_selfhost_new_database(Glom::Document& document, Glom::Docum
//Create a database:
const bool created = Glom::DbUtils::create_database(&document, db_name,
"test title", sigc::ptr_fun(&on_db_creation_progress));
"test title", &on_db_creation_progress);
if(!created)
{
std::cerr << "DbUtils::create_database() failed." << std::endl;
......@@ -357,7 +357,7 @@ bool test_create_and_selfhost_from_uri(const Glib::ustring& example_file_uri, Gl
return false;
}
const bool recreated = Glom::DbUtils::recreate_database_from_document(&document, sigc::ptr_fun(&on_recreate_progress) );
const bool recreated = Glom::DbUtils::recreate_database_from_document(&document, &on_recreate_progress );
if(!recreated)
test_selfhosting_cleanup();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment