LUMIERA.clone/src/gui/ctrl/ui-manager.cpp

130 lines
3.2 KiB
C++
Raw Normal View History

2008-04-20 00:16:27 +02:00
/*
UiManager - Global UI Manager
2010-12-17 23:28:49 +01:00
2008-04-20 00:16:27 +02:00
Copyright (C) Lumiera.org
2008, Joel Holdsworth <joel@airwebreathe.org.uk>
2017, Hermann Vosseler <Ichthyostega@web.de>
2010-12-17 23:28:49 +01:00
2008-04-20 00:16:27 +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-20 00:16:27 +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-20 00:16:27 +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-20 00:16:27 +02:00
* *****************************************************/
/** @file ui-manager.cpp
** Implementation of global concerns regarding a coherent UI and global state.
** Especially, the wiring of top-level components is done here, as is the
** basic initialisation of the interface and global configuration on
** UI toolkit level.
**
*/
#include "gui/gtk-base.hpp"
#include "gui/config-keys.hpp"
#include "gui/ctrl/ui-manager.hpp"
#include "gui/ctrl/global-ctx.hpp"
#include "gui/ctrl/actions.hpp"
#include "gui/workspace/style-manager.hpp"
#include "lib/searchpath.hpp"
#include "lib/util.hpp"
#include <gdlmm.h>
using util::cStr;
using util::isnil;
2008-04-20 00:16:27 +02:00
2008-04-20 00:16:27 +02:00
namespace gui {
namespace ctrl {
using Gtk::IconSize;
using Gtk::IconFactory;
using workspace::StyleManager;
namespace { // dummy command line for GTK
int argc =0;
}
// dtors via smart-ptr invoked from here...
UiManager::~UiManager()
{ }
/**
* Initialise the interface globally on application start.
* Setup the main application menu and bind the corresponding actions.
* Register the icon configuration and sizes and lookup all the icons.
* @see lumiera::Config
*/
UiManager::UiManager (UiBus& bus)
: Gtk::UIManager()
, globals_{new GlobalCtx{bus, *this}}
, actions_{new Actions{*globals_}}
, styleManager_{new StyleManager{}}
, gtkMain_(&argc, nullptr)
2017-02-02 19:41:58 +01:00
{
Glib::thread_init();
Gdl::init();
actions_->populateMainActions (*this);
2017-02-02 19:41:58 +01:00
}
/**
* @remarks this function is invoked once from the main application object,
* immediately prior to starting the GTK event loop. */
void
UiManager::createApplicationWindow()
{
if (globals_->windowList_.empty())
globals_->windowList_.newWindow();
}
void
UiManager::performMainLoop()
{
gtkMain_.run(); // GTK event loop
}
void
UiManager::terminateUI()
{
gtkMain_.quit();
}
void
UiManager::updateWindowFocusRelatedActions()
{
UNIMPLEMENTED ("how to handle activation of menu entries depending on window focus"); ////////TICKET #1076 find out how to handle this properly
//////see Actions::updateActionState()
}
void
UiManager::allowCloseWindow (bool yes)
{
this->get_action("/MenuBar/WindowMenu/WindowCloseWindow")
->set_sensitive (yes);
}
}}// namespace gui::ctrl