[niepce] Refactor init to fwk::utils::init(). Some namespace changes required.
- From: Hubert Figuière <hub src gnome org>
- To: svn-commits-list gnome org
- Subject: [niepce] Refactor init to fwk::utils::init(). Some namespace changes required.
- Date: Fri, 8 May 2009 14:58:39 -0400 (EDT)
commit f47cc957a035e034d20535cf467a66bb0c74489a
Author: Hubert Figuiere <hub figuiere net>
Date: Fri May 8 14:57:28 2009 -0400
Refactor init to fwk::utils::init(). Some namespace changes required.
---
ChangeLog | 3 ++
src/engine/db/test_filebundle.cpp | 6 ++--
src/engine/db/test_library.cpp | 5 +--
src/fwk/toolkit/application.cpp | 6 ----
src/fwk/toolkit/configdatabinder.cpp | 2 +-
src/fwk/toolkit/configdatabinder.hpp | 2 +-
src/fwk/toolkit/controller.hpp | 2 +-
src/fwk/utils/Makefile.am | 4 ++-
src/fwk/utils/databinder.cpp | 2 +-
src/fwk/utils/databinder.hpp | 2 +-
src/fwk/utils/init.cpp | 42 +++++++++++++++++++++++++++
src/fwk/utils/init.hpp | 42 +++++++++++++++++++++++++++
src/fwk/utils/testfiles.cpp | 8 ++---
src/fwk/utils/testufrawmeta.cpp | 6 ++--
src/libraryclient/test_worker.cpp | 9 ++----
src/niepce/main.cpp | 7 ++--
src/niepce/ui/dialogs/preferencesdialog.cpp | 4 +-
17 files changed, 114 insertions(+), 38 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 8f0a7a3..87ae067 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2009-05-08 Hubert Figuiere <hub figuiere net>
+ * Refactor init to fwk::utils::init()
+ Some namespace changes required.
+
* src/fwk/toolkit/dialog.hpp (fwk): Remove a leftover
boost::shared_ptr<>
diff --git a/src/engine/db/test_filebundle.cpp b/src/engine/db/test_filebundle.cpp
index cec1392..408dac6 100644
--- a/src/engine/db/test_filebundle.cpp
+++ b/src/engine/db/test_filebundle.cpp
@@ -18,11 +18,10 @@
*/
-#include <giomm/init.h>
-
#include "filebundle.hpp"
+#include "fwk/utils/init.hpp"
#include "fwk/utils/files.hpp"
#include <boost/test/minimal.hpp>
@@ -30,7 +29,8 @@
int test_main(int, char *[])
{
- Gio::init();
+ fwk::utils::init();
+
utils::FileList::Ptr thelist(new utils::FileList());
thelist->push_back("/foo/bar/img_0001.cr2");
diff --git a/src/engine/db/test_library.cpp b/src/engine/db/test_library.cpp
index 15acf8b..79b31e7 100644
--- a/src/engine/db/test_library.cpp
+++ b/src/engine/db/test_library.cpp
@@ -20,8 +20,7 @@
*/
-#include <giomm/init.h>
-
+#include "fwk/utils/init.hpp"
#include "fwk/utils/db/sqlstatement.hpp"
#include "fwk/utils/db/iconnectiondriver.hpp"
#include "library.hpp"
@@ -34,7 +33,7 @@
//BOOST_AUTO_TEST_CASE(library_test)
int test_main(int, char *[])
{
- Gio::init();
+ fwk::utils::init();
db::Library lib("./", fwk::NotificationCenter::Ptr());
BOOST_CHECK(lib.checkDatabaseVersion() == DB_SCHEMA_VERSION);
diff --git a/src/fwk/toolkit/application.cpp b/src/fwk/toolkit/application.cpp
index f5712dc..49641d6 100644
--- a/src/fwk/toolkit/application.cpp
+++ b/src/fwk/toolkit/application.cpp
@@ -22,7 +22,6 @@
#include <boost/lexical_cast.hpp>
#include <glibmm/i18n.h>
-#include <giomm/init.h>
#include <gtkmm/main.h>
#include <gtkmm/aboutdialog.h>
#include <gtkmm/rc.h>
@@ -112,11 +111,6 @@ int Application::main(boost::function<Application::Ptr (void)> constructor,
{
// TODO fix error check
gconf_init(argc, argv, NULL);
- if(!Glib::thread_supported()) {
- DBG_OUT("thread init");
- Glib::thread_init();
- }
- Gio::init();
Gtk::Main kit(argc, argv);
Application::Ptr app = constructor();
diff --git a/src/fwk/toolkit/configdatabinder.cpp b/src/fwk/toolkit/configdatabinder.cpp
index 6242cae..a80d3e1 100644
--- a/src/fwk/toolkit/configdatabinder.cpp
+++ b/src/fwk/toolkit/configdatabinder.cpp
@@ -25,7 +25,7 @@ namespace fwk {
ConfigDataBinderBase::ConfigDataBinderBase(const property_t & property,
Configuration & config,
const std::string & key)
- : utils::DataBinderBase(),
+ : DataBinderBase(),
m_property(property),
m_config_key(key),
m_config(config)
diff --git a/src/fwk/toolkit/configdatabinder.hpp b/src/fwk/toolkit/configdatabinder.hpp
index 47f72e1..6042377 100644
--- a/src/fwk/toolkit/configdatabinder.hpp
+++ b/src/fwk/toolkit/configdatabinder.hpp
@@ -35,7 +35,7 @@
namespace fwk {
class ConfigDataBinderBase
- : public utils::DataBinderBase
+ : public DataBinderBase
{
public:
typedef Glib::PropertyProxy_Base property_t;
diff --git a/src/fwk/toolkit/controller.hpp b/src/fwk/toolkit/controller.hpp
index 07beeb3..4ee3b43 100644
--- a/src/fwk/toolkit/controller.hpp
+++ b/src/fwk/toolkit/controller.hpp
@@ -78,7 +78,7 @@ namespace fwk {
WeakPtr m_parent;
std::list<Ptr> m_subs; /**< sub controllers */
- utils::DataBinderPool m_databinders;
+ DataBinderPool m_databinders;
};
}
diff --git a/src/fwk/utils/Makefile.am b/src/fwk/utils/Makefile.am
index db66e36..6ff64c8 100644
--- a/src/fwk/utils/Makefile.am
+++ b/src/fwk/utils/Makefile.am
@@ -66,7 +66,9 @@ test_db4_LDADD = libniepceutils.a \
noinst_LIBRARIES = libniepceutils.a
-libniepceutils_a_SOURCES = exception.hpp exception.cpp \
+libniepceutils_a_SOURCES = \
+ init.hpp init.cpp \
+ exception.hpp exception.cpp \
fsutils.cpp fsutils.hpp \
fractions.cpp fractions.hpp \
mtqueue.hpp stringutils.hpp \
diff --git a/src/fwk/utils/databinder.cpp b/src/fwk/utils/databinder.cpp
index 9d09bab..7552c64 100644
--- a/src/fwk/utils/databinder.cpp
+++ b/src/fwk/utils/databinder.cpp
@@ -20,7 +20,7 @@
#include "debug.hpp"
#include "databinder.hpp"
-namespace utils {
+namespace fwk {
DataBinderPool::~DataBinderPool()
{
diff --git a/src/fwk/utils/databinder.hpp b/src/fwk/utils/databinder.hpp
index 501dc01..c099b17 100644
--- a/src/fwk/utils/databinder.hpp
+++ b/src/fwk/utils/databinder.hpp
@@ -28,7 +28,7 @@
#include <boost/utility.hpp>
-namespace utils {
+namespace fwk {
/** @brief the base class for all the data binders */
class DataBinderBase
diff --git a/src/fwk/utils/init.cpp b/src/fwk/utils/init.cpp
new file mode 100644
index 0000000..0f8143f
--- /dev/null
+++ b/src/fwk/utils/init.cpp
@@ -0,0 +1,42 @@
+/*
+ * niepce - fwk/utils/init.cpp
+ *
+ * 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 <glibmm/thread.h>
+#include <giomm/init.h>
+
+
+#include "init.hpp"
+
+namespace fwk {
+namespace utils {
+
+
+void init()
+{
+ Gio::init();
+ if(!Glib::thread_supported()) {
+ Glib::thread_init();
+ }
+}
+
+
+
+}
+}
diff --git a/src/fwk/utils/init.hpp b/src/fwk/utils/init.hpp
new file mode 100644
index 0000000..83f9a5c
--- /dev/null
+++ b/src/fwk/utils/init.hpp
@@ -0,0 +1,42 @@
+/*
+ * niepce - fwk/utils/init.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 _FWK_INIT_HPP_
+#define _FWK_INIT_HPP_
+
+namespace fwk {
+namespace utils {
+
+void init();
+
+}
+}
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0))
+ indent-tabs-mode:nil
+ fill-column:80
+ End:
+*/
+
+
+#endif
diff --git a/src/fwk/utils/testfiles.cpp b/src/fwk/utils/testfiles.cpp
index 91f1f42..0b60391 100644
--- a/src/fwk/utils/testfiles.cpp
+++ b/src/fwk/utils/testfiles.cpp
@@ -23,17 +23,15 @@
#include <stdlib.h>
-#include <giomm/init.h>
-#include <glibmm/init.h>
-
#include "files.hpp"
+#include "init.hpp"
using utils::FileList;
int test_main( int, char *[] ) // note the name!
{
- Glib::init();
- Gio::init();
+ fwk::utils::init();
+
system( "mkdir -p AAtest/sub" );
system( "touch AAtest/1" );
system( "touch AAtest/2" );
diff --git a/src/fwk/utils/testufrawmeta.cpp b/src/fwk/utils/testufrawmeta.cpp
index 0d918f2..57e5633 100644
--- a/src/fwk/utils/testufrawmeta.cpp
+++ b/src/fwk/utils/testufrawmeta.cpp
@@ -26,15 +26,15 @@
#include <exempi/xmpconsts.h>
-#include <giomm/init.h>
-
+#include "init.hpp"
#include "debug.hpp"
#include "exempi.hpp"
#include "ufrawmeta.hpp"
int test_main( int, char *[] ) // note the name!
{
- Gio::init();
+ fwk::utils::init();
+
std::string dir;
const char * pdir = getenv("srcdir");
if(pdir == NULL) {
diff --git a/src/libraryclient/test_worker.cpp b/src/libraryclient/test_worker.cpp
index 3462c22..c012709 100644
--- a/src/libraryclient/test_worker.cpp
+++ b/src/libraryclient/test_worker.cpp
@@ -18,6 +18,7 @@
*/
+#include "fwk/utils/init.hpp"
#include "fwk/utils/fsutils.hpp"
#define BOOST_AUTO_TEST_MAIN
@@ -26,8 +27,6 @@
#include <boost/bind.hpp>
#include <boost/test/minimal.hpp>
-#include <giomm/init.h>
-#include <glibmm/thread.h>
using namespace library;
using namespace libraryclient;
@@ -39,10 +38,8 @@ void foo(const db::Library::Ptr &)
//BOOST_AUTO_TEST_CASE(worker_test)
int test_main(int, char *[])
-{
- Gio::init();
- if(!Glib::thread_supported())
- Glib::thread_init();
+{
+ fwk::utils::init();
char templ[] = "/tmp/niepce-tmpXXXXXX";
char *ptempl = mkdtemp(templ);
diff --git a/src/niepce/main.cpp b/src/niepce/main.cpp
index aa59041..516bf77 100644
--- a/src/niepce/main.cpp
+++ b/src/niepce/main.cpp
@@ -25,8 +25,8 @@
#include <boost/bind.hpp>
#include <glibmm/i18n.h>
-#include <glibmm/thread.h>
+#include "fwk/utils/init.hpp"
#include "fwk/utils/exempi.hpp"
#include "xmp.hpp"
#include "ui/niepceapplication.hpp"
@@ -40,10 +40,9 @@ int main(int argc, char ** argv)
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
textdomain(GETTEXT_PACKAGE);
- ExempiManager ex_manager(niepce::xmp_namespaces);
+ fwk::utils::init();
- if(!Glib::thread_supported())
- Glib::thread_init();
+ ExempiManager ex_manager(niepce::xmp_namespaces);
return fwk::Application::main(
boost::bind(&ui::NiepceApplication::create),
diff --git a/src/niepce/ui/dialogs/preferencesdialog.cpp b/src/niepce/ui/dialogs/preferencesdialog.cpp
index 2a8f17c..d17da24 100644
--- a/src/niepce/ui/dialogs/preferencesdialog.cpp
+++ b/src/niepce/ui/dialogs/preferencesdialog.cpp
@@ -44,9 +44,9 @@ void PreferencesDialog::setup_widget()
Gtk::ComboBox * theme_combo = NULL;
Gtk::CheckButton * reopen_checkbutton = NULL;
- utils::DataBinderPool * binder_pool = new utils::DataBinderPool();
+ fwk::DataBinderPool * binder_pool = new fwk::DataBinderPool();
- gtkDialog().signal_hide().connect(boost::bind(&utils::DataBinderPool::destroy,
+ gtkDialog().signal_hide().connect(boost::bind(&fwk::DataBinderPool::destroy,
binder_pool));
builder()->get_widget("theme_combo", theme_combo);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]