]> Dogcows Code - chaz/openbox/blob - otk/application.cc
otk::Timer-ng!! thanks ManMower for this shizznit!
[chaz/openbox] / otk / application.cc
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2
3 #ifdef HAVE_CONFIG_H
4 # include "../config.h"
5 #endif
6
7 #include "application.hh"
8 #include "eventhandler.hh"
9 #include "widget.hh"
10 #include "timer.hh"
11
12 extern "C" {
13 #ifdef HAVE_STDLIB_H
14 # include <stdlib.h>
15 #endif
16 }
17
18 #include <iostream>
19
20 namespace otk {
21
22 Application::Application(int argc, char **argv)
23 : EventDispatcher(),
24 _display(),
25 _dockable(false),
26 _appwidget_count(0)
27 {
28 (void)argc;
29 (void)argv;
30
31 const ScreenInfo *s_info = _display.screenInfo(DefaultScreen(*_display));
32
33 Timer::initialize();
34 _img_ctrl = new ImageControl(s_info, True, 4, 5, 200);
35 _style_conf = new Configuration(False);
36 _style = new Style(_img_ctrl);
37
38 loadStyle();
39 }
40
41 Application::~Application()
42 {
43 delete _style_conf;
44 delete _img_ctrl;
45 delete _style;
46 Timer::destroy();
47 }
48
49 void Application::loadStyle(void)
50 {
51 // find the style name as a property
52 std::string style = "/usr/local/share/openbox/styles/artwiz";
53 _style_conf->setFile(style);
54 if (!_style_conf->load()) {
55 std::cerr << "ERROR: Unable to load style \"" << style << "\".\n";
56 ::exit(1);
57 }
58 _style->load(*_style_conf);
59 }
60
61 void Application::run(void)
62 {
63 if (_appwidget_count <= 0) {
64 std::cerr << "ERROR: No main widgets exist. You must create and show() " <<
65 "an AppWidget for the Application before calling " <<
66 "Application::run().\n";
67 ::exit(1);
68 }
69
70 while (_appwidget_count > 0) {
71 dispatchEvents();
72 Timer::dispatchTimers(); // fire pending events
73 }
74 }
75
76 }
This page took 0.034699 seconds and 4 git commands to generate.