[niepce] Use Gtk::Application. Bump to Gtkmm 3.4 as a requirement.
- From: Hubert Figuière <hub src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [niepce] Use Gtk::Application. Bump to Gtkmm 3.4 as a requirement.
- Date: Wed, 10 Apr 2013 02:53:23 +0000 (UTC)
commit 8730d8f02ee8c4f4a5062e56eb568bbfe2363155
Author: Hubert Figuière <hub figuiere net>
Date: Tue Apr 9 22:38:28 2013 -0400
Use Gtk::Application. Bump to Gtkmm 3.4 as a requirement.
camerawire/src/cwapplication.cpp | 10 ++++----
camerawire/src/cwapplication.hpp | 6 ++--
camerawire/src/main.cpp | 7 ++---
configure.ac | 2 +-
src/fwk/toolkit/application.cpp | 39 ++++++++++++++++++++--------------
src/fwk/toolkit/application.hpp | 11 ++++++---
src/niepce/main.cpp | 8 +++---
src/niepce/ui/niepceapplication.cpp | 10 ++++----
src/niepce/ui/niepceapplication.hpp | 24 ++++++++++----------
9 files changed, 63 insertions(+), 54 deletions(-)
---
diff --git a/camerawire/src/cwapplication.cpp b/camerawire/src/cwapplication.cpp
index 371f309..74f13e3 100644
--- a/camerawire/src/cwapplication.cpp
+++ b/camerawire/src/cwapplication.cpp
@@ -1,7 +1,7 @@
/*
* niepce - cwapplication.cpp
*
- * Copyright (C) 2009 Hubert Figuiere
+ * Copyright (C) 2009, 2013 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
@@ -26,16 +26,16 @@
namespace cw {
- CwApplication::CwApplication()
- : Application(PACKAGE)
+ CwApplication::CwApplication(int & argc, char** & argv)
+ : Application(argc, argv, "net.figuiere.camerawire", PACKAGE)
{
}
- fwk::Application::Ptr CwApplication::create()
+ fwk::Application::Ptr CwApplication::create(int & argc, char** & argv)
{
if (!m_application) {
- m_application = fwk::Application::Ptr(new CwApplication());
+ m_application = fwk::Application::Ptr(new CwApplication(argc, argv));
}
return m_application;
}
diff --git a/camerawire/src/cwapplication.hpp b/camerawire/src/cwapplication.hpp
index 347f021..3f17b83 100644
--- a/camerawire/src/cwapplication.hpp
+++ b/camerawire/src/cwapplication.hpp
@@ -1,7 +1,7 @@
/*
* niepce - cwwindow.hpp
*
- * Copyright (C) 2009 Hubert Figuiere
+ * Copyright (C) 2009, 2013 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,11 +31,11 @@ class CwApplication
: public fwk::Application
{
public:
- static fwk::Application::Ptr create();
+ static fwk::Application::Ptr create(int & argc, char** & argv);
virtual fwk::Frame::Ptr makeMainFrame();
protected:
- CwApplication();
+ CwApplication(int & argc, char** & argv);
};
diff --git a/camerawire/src/main.cpp b/camerawire/src/main.cpp
index 20a7b72..d10b2d3 100644
--- a/camerawire/src/main.cpp
+++ b/camerawire/src/main.cpp
@@ -1,7 +1,7 @@
/*
* niepce - camerawire/main.cpp
*
- * Copyright (C) 2007-2009 Hubert Figuiere
+ * Copyright (C) 2007-2009, 2013 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
@@ -37,9 +37,8 @@ int main(int argc, char ** argv)
fwk::utils::init();
- return fwk::Application::main(
- boost::bind(&cw::CwApplication::create),
- argc, argv);
+ fwk::Application::Ptr app = cw::CwApplication::create(argc, argv);
+ return fwk::Application::main(app, argc, argv);
}
diff --git a/configure.ac b/configure.ac
index 2a3d55b..d5bcdaa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,7 +21,7 @@ dnl all the library version.
dnl if one is harcoded elsewhere, it is a bug
LIBGIOMM_VERSION=2.16
LIBGLIBMM_VERSION=2.32
-LIBGTKMM_VERSION=3.2
+LIBGTKMM_VERSION=3.4
LIBGNOMEUI_VERSION=2.0.0
EXEMPI_VERSION=2.2.0
SQLITE_VERSION=3.0
diff --git a/src/fwk/toolkit/application.cpp b/src/fwk/toolkit/application.cpp
index ba086fa..9c88413 100644
--- a/src/fwk/toolkit/application.cpp
+++ b/src/fwk/toolkit/application.cpp
@@ -2,7 +2,7 @@
/*
* niepce - framework/application.cpp
*
- * Copyright (C) 2007-2009 Hubert Figuiere
+ * Copyright (C) 2007-2009, 2013 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
@@ -39,10 +39,12 @@ namespace fwk {
Application::Ptr Application::m_application;
-Application::Application(const char * name)
+Application::Application(int & argc, char** &argv, const char* app_id,
+ const char * name)
: m_config(name)
, m_refUIManager(Gtk::UIManager::create())
, m_module_manager(new ModuleManager())
+ , m_gtkapp(Gtk::Application::create(argc, argv, app_id))
{
}
@@ -69,7 +71,7 @@ bool Application::get_use_dark_theme() const
bool v;
try {
v = boost::lexical_cast<bool>(m_config.getValue("ui_dark_theme", "0"));
- }
+ }
catch(...) {
v = false;
}
@@ -82,29 +84,25 @@ void Application::set_use_dark_theme(bool value)
boost::lexical_cast<Glib::ustring>(value));
}
-
-/** Main loop.
+/** Main loop.
* @param constructor the Application object constructor
* @param argc
* @param argv
* @return main return code
*/
-int Application::main(boost::function<Application::Ptr (void)> constructor,
- int argc, char **argv)
+int Application::main(const Application::Ptr & app,
+ int /*argc*/, char ** /*argv*/)
{
- Gtk::Main kit(argc, argv);
- Application::Ptr app = constructor();
-
bool use_dark = app->get_use_dark_theme();
Glib::RefPtr<Gtk::Settings> settings = Gtk::Settings::get_default();
settings->set_property("gtk-application-prefer-dark-theme", use_dark);
Frame::Ptr window(app->makeMainFrame());
- app->add(window);
+ app->_add(window, false);
// signal_run() is gone in Gtkmm3. Call directly. Should work.
app->_ready();
- Gtk::Main::run(window->gtkWindow());
-
+ app->m_gtkapp->run(window->gtkWindow());
+
return 0;
}
@@ -122,7 +120,7 @@ void Application::terminate()
void Application::quit()
{
terminate();
- Gtk::Main::quit();
+ m_gtkapp->quit();
}
void Application::about()
@@ -131,14 +129,23 @@ void Application::about()
}
/** adding a controller to an application build said controller
- * widget
+ * widget
*/
void Application::add(const Controller::Ptr & sub)
{
+ _add(sub, true);
+}
+
+void Application::_add(const Controller::Ptr & sub, bool attach)
+{
Controller::add(sub);
UiController::Ptr uictrl = std::tr1::dynamic_pointer_cast<UiController>(sub);
if(uictrl) {
- uictrl->buildWidget(uiManager());
+ Gtk::Widget *w = uictrl->buildWidget(uiManager());
+ Gtk::Window *win = NULL;
+ if(attach && m_gtkapp && (win = dynamic_cast<Gtk::Window*>(w))) {
+ m_gtkapp->add_window(*win);
+ }
}
}
diff --git a/src/fwk/toolkit/application.hpp b/src/fwk/toolkit/application.hpp
index df7125a..b427314 100644
--- a/src/fwk/toolkit/application.hpp
+++ b/src/fwk/toolkit/application.hpp
@@ -1,7 +1,7 @@
/*
* niepce - framework/application.h
*
- * Copyright (C) 2007-2008 Hubert Figuiere
+ * Copyright (C) 2007-2008, 2013 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
@@ -24,6 +24,7 @@
#include <boost/function.hpp>
#include <glibmm/refptr.h>
+#include <gtkmm/application.h>
#include <gtkmm/uimanager.h>
#include <gtkmm/icontheme.h>
@@ -66,7 +67,7 @@ public:
Glib::RefPtr<Gtk::IconTheme> getIconTheme() const;
static Application::Ptr app();
- static int main(boost::function<Application::Ptr (void)> constructor,
+ static int main(const Application::Ptr & app,
int argc, char **argv);
UndoHistory & undo_history()
@@ -80,14 +81,16 @@ public:
ModuleManager * module_manager() const
{ return m_module_manager; }
protected:
- Application(const char *);
- static Application::Ptr m_application;
+ Application(int & argc, char** &argv, const char* app_id, const char *name);
+ static Application::Ptr m_application;
+ void _add(const Controller::Ptr & sub, bool attach = true);
virtual void on_about();
private:
Configuration m_config;
Glib::RefPtr<Gtk::UIManager> m_refUIManager;
UndoHistory m_undo;
ModuleManager *m_module_manager;
+ Glib::RefPtr<Gtk::Application> m_gtkapp;
};
}
diff --git a/src/niepce/main.cpp b/src/niepce/main.cpp
index dd477a9..de2bc87 100644
--- a/src/niepce/main.cpp
+++ b/src/niepce/main.cpp
@@ -1,7 +1,7 @@
/*
* niepce - main/main.cpp
*
- * Copyright (C) 2007 Hubert Figuiere
+ * Copyright (C) 2007, 2013 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
@@ -40,9 +40,9 @@ int main(int argc, char ** argv)
fwk::ExempiManager ex_manager(NULL);
- return fwk::Application::main(
- boost::bind(&ui::NiepceApplication::create),
- argc, argv);
+ fwk::Application::Ptr app = ui::NiepceApplication::create(argc, argv);
+ return fwk::Application::main(app,
+ argc, argv);
}
diff --git a/src/niepce/ui/niepceapplication.cpp b/src/niepce/ui/niepceapplication.cpp
index b26952f..8311640 100644
--- a/src/niepce/ui/niepceapplication.cpp
+++ b/src/niepce/ui/niepceapplication.cpp
@@ -1,7 +1,7 @@
/*
* niepce - ui/niepceapplication.cpp
*
- * Copyright (C) 2007-2008 Hubert Figuiere
+ * Copyright (C) 2007-2008, 2013 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
@@ -32,8 +32,8 @@ using fwk::Application;
namespace ui {
-NiepceApplication::NiepceApplication()
- : Application(PACKAGE)
+NiepceApplication::NiepceApplication(int & argc, char** & argv)
+ : Application(argc, argv, "net.figuiere.Niepce", PACKAGE)
{
niepce::Stock::registerStockItems();
@@ -43,10 +43,10 @@ NiepceApplication::NiepceApplication()
modmgr->add_path(DATADIR"/"PACKAGE"/modules/"VERSION);
}
-Application::Ptr NiepceApplication::create()
+Application::Ptr NiepceApplication::create(int & argc, char** & argv)
{
if (!m_application) {
- m_application = Application::Ptr(new NiepceApplication());
+ m_application = Application::Ptr(new NiepceApplication(argc, argv));
}
return m_application;
}
diff --git a/src/niepce/ui/niepceapplication.hpp b/src/niepce/ui/niepceapplication.hpp
index cc88a58..0d0aeac 100644
--- a/src/niepce/ui/niepceapplication.hpp
+++ b/src/niepce/ui/niepceapplication.hpp
@@ -4,7 +4,7 @@
/*
* niepce - ui/niepceapplication.h
*
- * Copyright (C) 2007-2009 Hubert Figuiere
+ * Copyright (C) 2007-2009, 2013 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
@@ -25,17 +25,17 @@
namespace ui {
- class NiepceApplication
- : public fwk::Application
- {
- public:
- static fwk::Application::Ptr create();
-
- virtual fwk::Frame::Ptr makeMainFrame();
- protected:
- NiepceApplication();
- virtual void on_about();
- };
+class NiepceApplication
+ : public fwk::Application
+{
+public:
+ static fwk::Application::Ptr create(int & argc, char** & argv);
+
+ virtual fwk::Frame::Ptr makeMainFrame();
+protected:
+ NiepceApplication(int & argc, char** & argv);
+ virtual void on_about();
+};
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]