libyui
YUI.h
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YUI.h
20 
21  Author: Stefan Hundhammer <shundhammer@suse.de>
22 
23 /-*/
24 
25 #ifndef YUI_h
26 #define YUI_h
27 
28 #include <pthread.h>
29 #include <string>
30 
31 #include "YTypes.h"
32 #include "YSettings.h"
33 
34 
35 class YApplication;
36 class YWidget;
37 class YWidgetFactory;
39 class YEvent;
40 class YBuiltinCaller;
41 class YDialog;
42 class YMacroPlayer;
43 class YMacroRecorder;
44 
45 
49 class YUI
50 {
51  friend class YUIFunction;
52  friend class YUILoader;
53 
54 protected:
58  YUI( bool withThreads );
59 
60 public:
61 
65  virtual ~YUI();
66 
72  void shutdownThreads();
73 
77  static YUI * ui();
78 
87  static YWidgetFactory * widgetFactory();
88 
99 
108  static YApplication * app();
109 
113  static YApplication * application() { return app(); }
114  static YApplication * yApp() { return app(); }
115 
122  static void ensureUICreated();
123 
124 
125 protected:
126 
133  virtual YWidgetFactory * createWidgetFactory() = 0;
134 
143 
149  virtual YApplication * createApplication() = 0;
150 
151 
152 public:
153 
162  virtual void blockEvents( bool block = true ) { _eventsBlocked = block; }
163 
170  void unblockEvents() { blockEvents( false ); }
171 
177  virtual bool eventsBlocked() const { return _eventsBlocked; }
178 
186  virtual void deleteNotify( YWidget * widget ) {}
187 
193 
197  bool runningWithThreads() const { return _withThreads; }
198 
207  void uiThreadMainLoop();
208 
214 
220  { _builtinCaller = caller; }
221 
232  virtual YEvent * runPkgSelection( YWidget * packageSelector ) = 0;
233 
241  YWidget * sendWidgetID( const std::string & id );
242 
243 
244 protected:
245 
260  virtual void idleLoop( int fd_ycp ) = 0;
261 
266  void terminateUIThread();
267 
271  void createUIThread();
272  friend void *start_ui_thread( void *ui_int );
273 
281  virtual void uiThreadDestructor();
282 
287  void signalUIThread();
288 
293  bool waitForUIThread();
294 
299  void signalYCPThread();
300 
305  bool waitForYCPThread();
306 
317 
318 
319  //
320  // Data members
321  //
322 
327 
331  pthread_t _uiThread;
332 
341 
347  int pipe_to_ui[2];
348 
354  int pipe_from_ui[2];
355 
363 
369 
370 private:
371 
372  static YUI * _ui;
373 };
374 
375 
376 
377 #endif // YUI_h
virtual YEvent * runPkgSelection(YWidget *packageSelector)=0
Definition: YMacroRecorder.h:38
Definition: YOptionalWidgetFactory.h:56
void setBuiltinCaller(YBuiltinCaller *caller)
Definition: YUI.h:219
int pipe_from_ui[2]
Definition: YUI.h:354
void setButtonOrderFromEnvironment()
Definition: YUI.cc:394
static YWidgetFactory * widgetFactory()
Definition: YUI.cc:134
Definition: YUI.h:49
void createUIThread()
Definition: YUI.cc:243
virtual YApplication * createApplication()=0
virtual bool eventsBlocked() const
Definition: YUI.h:177
Definition: YMacroPlayer.h:35
static YApplication * application()
Definition: YUI.h:113
void topmostConstructorHasFinished()
Definition: YUI.cc:190
int pipe_to_ui[2]
Definition: YUI.h:347
void terminateUIThread()
Definition: YUI.cc:254
YWidget * sendWidgetID(const std::string &id)
Definition: YUI.cc:489
bool _withThreads
Definition: YUI.h:326
bool runningWithThreads() const
Definition: YUI.h:197
Definition: YEvent.h:43
void signalUIThread()
Definition: YUI.cc:281
static void ensureUICreated()
Definition: YUI.cc:178
virtual YOptionalWidgetFactory * createOptionalWidgetFactory()=0
virtual void uiThreadDestructor()
Definition: YUI.cc:119
void shutdownThreads()
Definition: YUI.cc:267
bool waitForYCPThread()
Definition: YUI.cc:333
bool _eventsBlocked
Definition: YUI.h:368
void uiThreadMainLoop()
Definition: YUI.cc:361
Definition: YUILoader.h:49
virtual void blockEvents(bool block=true)
Definition: YUI.h:162
Definition: YApplication.h:45
static YOptionalWidgetFactory * optionalWidgetFactory()
Definition: YUI.cc:149
virtual void deleteNotify(YWidget *widget)
Definition: YUI.h:186
bool waitForUIThread()
Definition: YUI.cc:293
void signalYCPThread()
Definition: YUI.cc:321
virtual ~YUI()
Definition: YUI.cc:90
static YApplication * app()
Definition: YUI.cc:164
virtual YWidgetFactory * createWidgetFactory()=0
bool _terminate_ui_thread
Definition: YUI.h:362
Definition: YDialog.h:47
Definition: YWidgetFactory.h:79
YUI(bool withThreads)
Definition: YUI.cc:76
pthread_t _uiThread
Definition: YUI.h:331
void unblockEvents()
Definition: YUI.h:170
YBuiltinCaller * builtinCaller() const
Definition: YUI.h:213
Definition: YWidget.h:54
static YUI * ui()
Definition: YUI.cc:126
Definition: YBuiltinCaller.h:37
virtual void idleLoop(int fd_ycp)=0
YBuiltinCaller * _builtinCaller
Definition: YUI.h:340