2008-04-09 00:21:05 +02:00
|
|
|
/*
|
2011-02-06 21:23:34 +01:00
|
|
|
GtkLumiera - The Lumiera GUI Application Object
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2008-04-11 23:04:39 +02:00
|
|
|
Copyright (C) Lumiera.org
|
|
|
|
|
2008, Joel Holdsworth <joel@airwebreathe.org.uk>
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2008-04-11 23:04:39 +02:00
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License as
|
2010-12-17 23:28:49 +01:00
|
|
|
published by the Free Software Foundation; either version 2 of
|
|
|
|
|
the License, or (at your option) any later version.
|
|
|
|
|
|
2008-04-11 23:04:39 +02:00
|
|
|
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.
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2008-04-11 23:04:39 +02:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2008-04-11 23:04:39 +02:00
|
|
|
* *****************************************************/
|
2008-04-09 00:21:05 +02:00
|
|
|
|
|
|
|
|
|
2011-02-06 21:23:34 +01:00
|
|
|
#include "gui/gtk-lumiera.hpp"
|
Rectify UI top-level -- introduce a global UiManager (#1067)
There seems to be a mismatch in the arrangement of the top-level entities
* we support multiple windows, yet from reading the code, you'd ge the impression we aren't really aware we have multiple top-level windows
* the `WindowManager` is the core UI manager, which feels like a mix-up in concerns
* the `WorkspaceWindow::createUI()` does the global UI initialisation. Again, we have multiple workspace windows.
* `GtkLumiera::main()` creates a `Model` and a `Controller` in local function scope, but stores the `WindowManager` in an object field.
* it seems, for that very reason, `GtlLumiera` needed to be a singleton, to allow by-name access to "the" `WindowManager`
* needless to say, this causes a host of problems when shutting down the UI.
The idea is to introduce a dedicated UiManager, to deal with the central
framework induced concerns solely, and to demote the WindowManager and the
WorkspaceWindows to care only for their local concerns
2017-01-23 00:40:17 +01:00
|
|
|
#include "gui/workspace/ui-manager.hpp"
|
2011-02-06 21:23:34 +01:00
|
|
|
#include "gui/workspace/workspace-window.hpp"
|
2015-01-06 14:37:26 +01:00
|
|
|
#include "gui/ui-bus.hpp"
|
2013-10-30 02:35:20 +01:00
|
|
|
#include "lib/format-string.hpp"
|
2013-10-20 03:19:36 +02:00
|
|
|
#include "lib/depend.hpp"
|
2011-02-07 00:54:16 +01:00
|
|
|
#include "lib/symbol.hpp"
|
2008-04-09 00:21:05 +02:00
|
|
|
|
2011-02-07 00:54:16 +01:00
|
|
|
#include "include/config-facade.h"
|
|
|
|
|
|
|
|
|
|
#include <boost/algorithm/string/classification.hpp>
|
|
|
|
|
#include <boost/algorithm/string/split.hpp>
|
2013-10-30 02:35:20 +01:00
|
|
|
#include <string>
|
2011-02-07 00:54:16 +01:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
namespace gui {
|
|
|
|
|
|
2017-01-27 22:47:01 +01:00
|
|
|
using namespace Gtk; ////////////////////////////////////////////////////////////////////////////////TICKET #1071 no wildcard includes please!
|
2015-05-29 04:44:58 +02:00
|
|
|
using namespace Glib;
|
|
|
|
|
using namespace gui::model;
|
|
|
|
|
using namespace gui::workspace;
|
|
|
|
|
using namespace gui::controller;
|
2011-02-07 00:54:16 +01:00
|
|
|
|
2017-01-26 21:51:19 +01:00
|
|
|
namespace error = lumiera::error;
|
|
|
|
|
|
2015-05-29 04:44:58 +02:00
|
|
|
using boost::algorithm::is_any_of;
|
|
|
|
|
using boost::algorithm::split;
|
2011-02-07 00:54:16 +01:00
|
|
|
|
2015-05-29 04:44:58 +02:00
|
|
|
using lumiera::Config;
|
|
|
|
|
using lib::Literal;
|
|
|
|
|
using ::util::_Fmt;
|
|
|
|
|
using std::string;
|
2011-02-07 00:54:16 +01:00
|
|
|
|
2015-05-29 04:44:58 +02:00
|
|
|
typedef std::vector<uString> UVector;
|
2011-02-07 00:54:16 +01:00
|
|
|
|
2015-05-29 04:44:58 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
/** storage for the Main Application object */
|
|
|
|
|
lib::Depend<GtkLumiera> theApplicationInstance;
|
|
|
|
|
|
2017-01-23 01:13:38 +01:00
|
|
|
Literal KEY_TITLE = "Lumiera.title"; //////////////////////////////////////////////////////////TICKET #1067 : turn these into global constants
|
2015-05-29 04:44:58 +02:00
|
|
|
Literal KEY_VERSION = "Lumiera.version";
|
|
|
|
|
Literal KEY_WEBSITE = "Lumiera.website";
|
|
|
|
|
Literal KEY_AUTHORS = "Lumiera.authors";
|
|
|
|
|
Literal KEY_COPYRIGHT = "Lumiera.copyright";
|
|
|
|
|
|
|
|
|
|
Literal KEY_STYLESHEET = "Gui.stylesheet";
|
|
|
|
|
Literal KEY_UIRES_PATH = "Gui.resourcepath";
|
|
|
|
|
Literal KEY_ICON_PATH = "Gui.iconpath";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GtkLumiera&
|
|
|
|
|
GtkLumiera::application()
|
|
|
|
|
{
|
|
|
|
|
return theApplicationInstance();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @remarks this function blocks until shutdown of the UI */
|
|
|
|
|
void
|
|
|
|
|
GtkLumiera::main (int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
Glib::thread_init();
|
|
|
|
|
Gdl::init();
|
|
|
|
|
Main kit(argc, argv);
|
|
|
|
|
|
|
|
|
|
Glib::set_application_name (getAppTitle());
|
|
|
|
|
|
2015-12-19 03:40:19 +01:00
|
|
|
//////////////////////TICKET #959 : establish the new backbone here / replaces Project and Controller
|
2016-12-10 04:01:06 +01:00
|
|
|
UiBus uiBus;
|
2015-12-19 03:40:19 +01:00
|
|
|
|
2017-01-26 20:51:43 +01:00
|
|
|
workspace::UiManager uiManager(uiBus);
|
2017-01-23 01:13:38 +01:00
|
|
|
uiManager.init (Config::get (KEY_ICON_PATH), Config::get (KEY_UIRES_PATH));
|
|
|
|
|
uiManager.setTheme (Config::get (KEY_STYLESHEET));
|
2015-05-29 04:44:58 +02:00
|
|
|
|
2017-01-27 20:42:42 +01:00
|
|
|
windowManagerInstance_.reset (new workspace::WindowList (uiManager));
|
2017-01-27 23:29:38 +01:00
|
|
|
windowManagerInstance_->newWindow();
|
2015-05-29 04:44:58 +02:00
|
|
|
kit.run(); // GTK event loop
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2017-01-27 20:42:42 +01:00
|
|
|
WindowList&
|
2015-05-29 04:44:58 +02:00
|
|
|
GtkLumiera::windowManager()
|
|
|
|
|
{
|
2017-01-26 21:51:19 +01:00
|
|
|
if (not windowManagerInstance_)
|
|
|
|
|
throw error::Logic ("GTK UI is not in running state"
|
|
|
|
|
, error::LUMIERA_ERROR_LIFECYCLE);
|
|
|
|
|
|
|
|
|
|
return *windowManagerInstance_;
|
2015-05-29 04:44:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cuString
|
|
|
|
|
GtkLumiera::getAppTitle()
|
|
|
|
|
{
|
|
|
|
|
return Config::get (KEY_TITLE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cuString
|
|
|
|
|
GtkLumiera::getAppVersion()
|
|
|
|
|
{
|
|
|
|
|
return Config::get (KEY_VERSION);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cuString
|
|
|
|
|
GtkLumiera::getCopyright()
|
|
|
|
|
{
|
|
|
|
|
return string (
|
2015-11-02 21:54:48 +01:00
|
|
|
_Fmt(_("© %s the original Authors\n"
|
|
|
|
|
"-- Lumiera Team --\n"
|
2015-05-29 04:44:58 +02:00
|
|
|
"Lumiera is Free Software (GPL)"))
|
|
|
|
|
% Config::get (KEY_COPYRIGHT));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cuString
|
|
|
|
|
GtkLumiera::getLumieraWebsite()
|
|
|
|
|
{
|
|
|
|
|
return Config::get (KEY_WEBSITE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const UVector
|
|
|
|
|
GtkLumiera::getLumieraAuthors()
|
|
|
|
|
{
|
|
|
|
|
string authors = Config::get (KEY_AUTHORS);
|
|
|
|
|
UVector authorsList;
|
|
|
|
|
|
|
|
|
|
split (authorsList, authors, is_any_of (",|"));
|
|
|
|
|
return authorsList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}// namespace gui
|