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 
134 
143 
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
Definition: YApplication.h:46
Definition: YBuiltinCaller.h:38
Definition: YDialog.h:48
Definition: YEvent.h:44
Definition: YMacroPlayer.h:36
Definition: YMacroRecorder.h:39
Definition: YOptionalWidgetFactory.h:57
Definition: YUILoader.h:50
Definition: YUI.h:50
void topmostConstructorHasFinished()
Definition: YUI.cc:190
YUI(bool withThreads)
Definition: YUI.cc:76
virtual ~YUI()
Definition: YUI.cc:90
bool runningWithThreads() const
Definition: YUI.h:197
virtual void idleLoop(int fd_ycp)=0
virtual void blockEvents(bool block=true)
Definition: YUI.h:162
void unblockEvents()
Definition: YUI.h:170
static YUI * ui()
Definition: YUI.cc:126
void uiThreadMainLoop()
Definition: YUI.cc:361
YBuiltinCaller * _builtinCaller
Definition: YUI.h:340
bool waitForYCPThread()
Definition: YUI.cc:333
int pipe_to_ui[2]
Definition: YUI.h:347
static YApplication * app()
Definition: YUI.cc:164
static YApplication * application()
Definition: YUI.h:113
virtual bool eventsBlocked() const
Definition: YUI.h:177
bool _terminate_ui_thread
Definition: YUI.h:362
virtual void deleteNotify(YWidget *widget)
Definition: YUI.h:186
virtual YOptionalWidgetFactory * createOptionalWidgetFactory()=0
bool _withThreads
Definition: YUI.h:326
bool waitForUIThread()
Definition: YUI.cc:293
static YWidgetFactory * widgetFactory()
Definition: YUI.cc:134
void signalUIThread()
Definition: YUI.cc:281
void terminateUIThread()
Definition: YUI.cc:254
virtual YWidgetFactory * createWidgetFactory()=0
static YOptionalWidgetFactory * optionalWidgetFactory()
Definition: YUI.cc:149
bool _eventsBlocked
Definition: YUI.h:368
void shutdownThreads()
Definition: YUI.cc:267
void setButtonOrderFromEnvironment()
Definition: YUI.cc:394
int pipe_from_ui[2]
Definition: YUI.h:354
virtual YApplication * createApplication()=0
virtual void uiThreadDestructor()
Definition: YUI.cc:119
static void ensureUICreated()
Definition: YUI.cc:178
virtual YEvent * runPkgSelection(YWidget *packageSelector)=0
void setBuiltinCaller(YBuiltinCaller *caller)
Definition: YUI.h:219
void createUIThread()
Definition: YUI.cc:243
void signalYCPThread()
Definition: YUI.cc:321
YWidget * sendWidgetID(const std::string &id)
Definition: YUI.cc:489
pthread_t _uiThread
Definition: YUI.h:331
YBuiltinCaller * builtinCaller() const
Definition: YUI.h:213
Definition: YWidgetFactory.h:80
Definition: YWidget.h:55