Lumiera  0.pre.03
»edit your freedom«
ui-manager.cpp
Go to the documentation of this file.
1 /*
2  UiManager - Global UI Manager
3 
4  Copyright (C) Lumiera.org
5  2008, Joel Holdsworth <joel@airwebreathe.org.uk>
6  2017, Hermann Vosseler <Ichthyostega@web.de>
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2 of
11  the License, or (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 
22 * *****************************************************/
23 
24 
36 #include "stage/gtk-base.hpp"
37 #include "stage/config-keys.hpp"
40 #include "stage/ctrl/actions.hpp"
41 #include "stage/ctrl/facade.hpp"
43 #include "lib/searchpath.hpp"
44 #include "lib/util.hpp"
45 
46 #include <gdlmm.h>
47 
48 using util::isnil;
49 
50 
51 namespace stage {
52 namespace ctrl {
53 
54  using Gtk::IconSize;
55  using Gtk::IconFactory;
56 
57  using workspace::UiStyle;
58 
59 
60 
61 
62  // dtors via smart-ptr invoked from here...
63  UiManager::~UiManager() { }
64 
65 
76  {
77  Glib::thread_init();
78  //---------------------------------------------copied from Gtk::Main
79  gtk_init (nullptr, nullptr);
80  Gtk::Main::init_gtkmm_internals();
81  //---------------------------------------------copied from Gtk::Main
82  Gdl::init();
83  }
84 
85  ApplicationBase::~ApplicationBase()
86  {
87  //---------------------------------------------copied from Gtk::Main
88  // Release the gtkmm type registration tables,
89  // allowing Main to be instantiated again:
90  Glib::wrap_register_cleanup();
91  Glib::Error::register_cleanup();
92  //---------------------------------------------copied from Gtk::Main
93 
94  // NOTE: GtkMainConnectionNode only serves the deprecated key_snooper API as of 2018
95  }
96 
97 
105  : ApplicationBase()
106  , Gtk::UIManager()
107  , globals_{new GlobalCtx{bus, *this}}
108  , uiStyle_{new UiStyle{}}
109  , actions_{new Actions{*globals_}}
110  , facade_{} // note: not activated yet
111  {
112  actions_->populateMainActions (*this);
113  }
114 
115 
120  void
122  {
123  if (globals_->windowLoc_.empty())
124  globals_->windowLoc_.newWindow();
125  }
126 
127 
137  void
139  {
140  facade_.reset (new Facade{globals_->uiBus_, *this});
141 
142  gtk_main(); // GTK event loop
143 
144  facade_.reset (nullptr);
145  }
146 
147 
155  void
157  {
158  gtk_main_quit();
159  }
160 
161 
169  void
170  UiManager::schedule (Operation&& task)
171  {
172  UNIMPLEMENTED ("TICKET #1151 build a suitable dispatcher into the GTK loop");
173  }
174 
175 
176  void
178  {
180  actions_->updateActionState (globals_->windowLoc_.findActiveWindow());
181  }
182 
183 
184  void
185  UiManager::allowCloseWindow (bool yes)
186  {
187  this->get_action("/MenuBar/WindowMenu/WindowCloseWindow")
188  ->set_sensitive (yes);
189  }
190 
191 
192  void
193  UiManager::configureStyle (timeline::TimelineWidget const& timeline)
194  {
195  uiStyle_->prepareStyleContext (timeline);
196  }
197 
198 
199 
200 }}// namespace stage::ctrl
void performMainLoop()
start the GTK Main loop and thus activate the UI.
Definition: ui-manager.cpp:138
Definition of access keys for global UI configuration.
Service for global theming and style related concerns.
Helpers to handle directory search paths.
Setup of global actions for the main menu.
void createApplicationWindow()
Set up the first top-level application window.
Definition: ui-manager.cpp:121
Dependency context to hold all the global UI top-level entities.
void updateWindowFocusRelatedActions()
Definition: ui-manager.cpp:177
void terminateUI()
Cause the main event loop to terminate, so the application as a whole unwinds.
Definition: ui-manager.cpp:156
A context to hold and manage the implementation of all UI facade interfaces.
Backbone of the Lumiera GTK GUI.
Definition: ui-bus.hpp:159
UiManager(UiBus &bus)
Initialise the GTK framework and the Lumiera UI backbone.
Definition: ui-manager.cpp:104
Manager for global user interface concerns, framework integration and global state.
Core timeline display (custom widget).
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:46
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
A helper class which registers global user actions and populates the main menu and toolbar...
Definition: actions.hpp:76
ApplicationBase()
Initialise the GTK framework libraries.
Definition: ui-manager.cpp:75
A global circle of top-level UI management facilities.
Definition: global-ctx.hpp:79
void schedule(Operation &&task)
perform an action within the UI event loop (GTK loop).
Definition: ui-manager.cpp:170
A set of basic GTK includes for the UI.
Framework initialisation base.
Definition: ui-manager.hpp:77
Manage global concerns regarding a coherent user interface.
Definition: ui-style.hpp:72