Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
gtk-lumiera.cpp
Go to the documentation of this file.
1/*
2 GtkLumiera - entry point for the lumiera GUI loaded as shared module
3
4 Copyright (C)
5 2007-2008, Joel Holdsworth <joel@airwebreathe.org.uk>
6 2009, Hermann Vosseler <Ichthyostega@web.de>
7 2016,2017 Hermann Vosseler <Ichthyostega@web.de>
8
9  **Lumiera** is free software; you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by the
11  Free Software Foundation; either version 2 of the License, or (at your
12  option) any later version. See the file COPYING for further details.
13
14* *****************************************************************/
15
16
40#include "stage/gtk-base.hpp"
41
42#include "lib/error.hpp"
43#include "lib/thread.hpp"
44#include "stage/ui-bus.hpp"
45#include "stage/guifacade.hpp"
47#include "common/subsys.hpp"
48#include "lib/nocopy.hpp"
49
50extern "C" {
51#include "common/interface.h"
53}
54
55#include <string>
56
57
58
59using lumiera::Subsys;
61using lumiera::error::LUMIERA_ERROR_STATE;
62using stage::LUMIERA_INTERFACE_INAME(lumieraorg_Gui, 1);
63
64using std::string;
65
66
67namespace lumiera {
68namespace error {
69 /* == definition common error marks for the UI, declared in gtk-base.hpp == */
70 LUMIERA_ERROR_DEFINE (UIWIRING, "GUI state contradicts assumptions in signal wiring");
71}}
72
73
74namespace stage {
75
76 namespace { // implementation details
77
78 using ctrl::UiManager;
79
80
81 /**************************************************************************/
89 {
92
93 public:
95 : uiBus_{}
96 , uiManager_{uiBus_}
97 { }
98
99
100 string
102 {
103 string errorMsgBuff;
104 try
105 {
106 // execute the GTK Event Loop____________
107 uiManager_.createApplicationWindow();
108 uiManager_.performMainLoop();
109 } // all went well, regular shutdown
110
111 catch (lumiera::Error& problem)
112 {
113 errorMsgBuff = problem.what();
114 lumiera_error(); // clear error flag
115 }
116 catch (...)
117 {
118 errorMsgBuff = "unexpected error terminated the GUI.";
119 }
120 if (lumiera_error_peek())
121 errorMsgBuff = string{lumiera_error()};
122
123 return errorMsgBuff;
124 }
125 };
126 //(End) GUI-Thread.
127 }//(End) impl details
128
129
130
131
132 bool
133 launchUI (Subsys::SigTerm& reportOnTermination)
134 {
135 try
136 {
137 launchDetached ("GUI-Main"
138 , [reportOnTermination]
139 {
140 string shutdownLog = GtkLumiera{}.run();
141 // inform main thread that the GUI has been shut down...
142 reportOnTermination (&shutdownLog);
143 });
144 return true; // if we reach this line...
145 }
146 catch(...)
147 {
148 CStr errID = lumiera_error(); // clear C-style error flag
149 WARN (stage, "Unexpected error while starting the GUI thread.");
150 if (errID)
151 TRACE (stage, "Error flag was: %s", errID);
152 return false;
153 }
154 }
155
156} // namespace stage
157
158
159
160
161
162
163extern "C" { /* ================== define a lumieraorg_Gui instance ======================= */
164
165
166 LUMIERA_INTERFACE_INSTANCE (lumieraorg_interfacedescriptor, 0
167 ,lumieraorg_GuiStarterPlugin_descriptor
168 , NULL, NULL, NULL
169 , LUMIERA_INTERFACE_INLINE (name,
170 const char*, (LumieraInterface ifa),
171 { (void)ifa; return "GuiStarterPlugin"; }
172 )
173 , LUMIERA_INTERFACE_INLINE (brief,
174 const char*, (LumieraInterface ifa),
175 { (void)ifa; return "entry point to start up the Lumiera GTK GUI contained in this dynamic module"; }
176 )
177 , LUMIERA_INTERFACE_INLINE (homepage,
178 const char*, (LumieraInterface ifa),
179 { (void)ifa; return "http://www.lumiera.org/develompent.html" ;}
180 )
181 , LUMIERA_INTERFACE_INLINE (version,
182 const char*, (LumieraInterface ifa),
183 { (void)ifa; return "0.1~pre"; }
184 )
185 , LUMIERA_INTERFACE_INLINE (author,
186 const char*, (LumieraInterface ifa),
187 { (void)ifa; return "Joel Holdsworth, Christian Thaeter, Hermann Vosseler"; }
188 )
189 , LUMIERA_INTERFACE_INLINE (email,
190 const char*, (LumieraInterface ifa),
191 { (void)ifa; return "Lumiera@lists.lumiera.org"; }
192 )
193 , LUMIERA_INTERFACE_INLINE (copyright,
194 const char*, (LumieraInterface ifa),
195 {
196 (void)ifa;
197 return
198 "Copyright (C)\n"
199 " 2007-2008, Joel Holdsworth <joel@airwebreathe.org.uk>\n"
200 " 2009, Christian Thaeter <ct@pipapo.org>\n"
201 " 2009, Hermann Vosseler <Ichthyostega@web.de>"
202 " 2016,2017, Hermann Vosseler <Ichthyostega@web.de>";
203 }
204 )
205 , LUMIERA_INTERFACE_INLINE (license,
206 const char*, (LumieraInterface ifa),
207 {
208 (void)ifa;
209 return
210 "**Lumiera** is free software; you can redistribute it and/or modify it\n"
211 "under the terms of the GNU General Public License as published by the\n"
212 "Free Software Foundation; either version 2 of the License, or (at your\n"
213 "option) any later version. See the file COPYING for further details."
214 ;
215 }
216 )
217 , LUMIERA_INTERFACE_INLINE (state,
218 int, (LumieraInterface ifa),
219 {(void)ifa; return LUMIERA_INTERFACE_EXPERIMENTAL; }
220 )
221 , LUMIERA_INTERFACE_INLINE (versioncmp,
222 int, (const char* a, const char* b),
223 {(void)a;(void)b; return 0;}
224 )
225 );
226
227
228 LUMIERA_EXPORT( /* ===================== PLUGIN EXPORTS ================================== */
229
230 LUMIERA_INTERFACE_DEFINE (lumieraorg_Gui, 1
231 ,lumieraorg_GuiStarterPlugin
232 , LUMIERA_INTERFACE_REF(lumieraorg_interfacedescriptor, 0, lumieraorg_GuiStarterPlugin_descriptor)
233 , NULL /* on open */
234 , NULL /* on close */
235 , LUMIERA_INTERFACE_INLINE (launchUI,
236 bool, (void* termSig),
237 {
238 return stage::launchUI (*reinterpret_cast<Subsys::SigTerm *> (termSig));
239 }
240 )
241 )
242 );
243
244} // extern "C"
Interface and Base definition for all Lumiera Exceptions.
Definition error.hpp:65
virtual CStr what() const noexcept override
std::exception interface : yield a diagnostic message
Dependencies and lifecycle of a partially independent Subsystem of the Application.
Definition subsys.hpp:63
function< void(string *)> SigTerm
Definition subsys.hpp:65
Backbone of the Lumiera GTK GUI.
Definition ui-bus.hpp:124
Implement the necessary steps for actually making the Lumiera UI available.
The Lumiera UI framework and backbone object.
void performMainLoop()
start the GTK Main loop and thus activate the UI.
void createApplicationWindow()
Set up the first top-level application window.
Any copy and copy construction prohibited.
Definition nocopy.hpp:38
lumiera_err lumiera_error_peek(void)
Check current error state without clearing it Please avoid this function and use lumiera_error() if p...
lumiera_err lumiera_error(void)
Get and clear current error state.
#define LUMIERA_ERROR_DEFINE(err, msg)
Definition and initialisation of an error constant.
Definition error.h:71
Lumiera error handling (C++ interface).
const char * CStr
Definition error.hpp:42
A set of basic GTK includes for the UI.
Interface for the GUI loader and for accessing the GUI interface from the lower layers of Lumiera.
A data record to describe interface, interface instances and plug-in instances.
@ LUMIERA_INTERFACE_EXPERIMENTAL
Not finished development code.
Lumiera interface macros and structures.
#define LUMIERA_INTERFACE_REF(iname, version, dname)
Return a reference (pointer) to an interface implementation.
Definition interface.h:119
#define LUMIERA_EXPORT(...)
Generate interface container suitable for enumerating interfaces.
Definition interface.h:273
#define LUMIERA_INTERFACE_INSTANCE(iname, version, name, descriptor, acquire, release,...)
Define an interface instance.
Definition interface.h:185
lumiera_interface * LumieraInterface
Definition interface.h:355
return NULL
Definition llist.h:586
void launchDetached(ThreadHookable::Launch &&launchBuilder)
Launch an autonomous self-managing thread (and forget about it).
Definition thread.hpp:742
Lumiera public interface.
Definition advice.hpp:102
Lumiera GTK UI implementation root.
Definition guifacade.cpp:37
bool launchUI(Subsys::SigTerm &reportOnTermination)
Mix-Ins to allow or prohibit various degrees of copying and cloning.
Describing dependencies and lifecycle of the application's primary parts.
Convenience front-end to simplify and codify basic thread handling.
Under construction: the top level UI controller.
Manager for global user interface concerns, framework integration and global state.