2002-11-17 09:41:58 +00:00
|
|
|
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "../config.h"
|
|
|
|
#endif
|
|
|
|
|
2002-11-16 02:18:37 +00:00
|
|
|
#include "application.hh"
|
|
|
|
#include "eventhandler.hh"
|
2002-11-16 13:50:59 +00:00
|
|
|
#include "widget.hh"
|
2002-11-16 02:18:37 +00:00
|
|
|
|
2002-11-16 12:12:38 +00:00
|
|
|
extern "C" {
|
|
|
|
#ifdef HAVE_STDLIB_H
|
|
|
|
# include <stdlib.h>
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2002-11-16 09:59:37 +00:00
|
|
|
#include <iostream>
|
|
|
|
|
2002-11-16 02:18:37 +00:00
|
|
|
namespace otk {
|
|
|
|
|
2003-01-11 19:17:13 +00:00
|
|
|
Application::Application(int argc, char **argv)
|
|
|
|
: EventDispatcher(),
|
2002-11-16 14:30:18 +00:00
|
|
|
_dockable(false),
|
|
|
|
_appwidget_count(0)
|
2002-11-16 02:18:37 +00:00
|
|
|
{
|
2003-01-11 19:17:13 +00:00
|
|
|
(void)argc;
|
|
|
|
(void)argv;
|
2002-11-16 02:18:37 +00:00
|
|
|
|
2003-01-11 19:17:13 +00:00
|
|
|
Display::initialize(0);
|
2002-11-16 14:30:18 +00:00
|
|
|
const ScreenInfo *s_info =
|
2003-01-11 19:17:13 +00:00
|
|
|
Display::screenInfo(DefaultScreen(Display::display));
|
2002-11-16 02:18:37 +00:00
|
|
|
|
2003-01-11 19:17:13 +00:00
|
|
|
_timer_manager = new TimerQueueManager();
|
|
|
|
_img_ctrl = new ImageControl(_timer_manager, s_info, True, 4, 5, 200);
|
2002-11-16 02:18:37 +00:00
|
|
|
_style_conf = new Configuration(False);
|
|
|
|
_style = new Style(_img_ctrl);
|
|
|
|
|
|
|
|
loadStyle();
|
|
|
|
}
|
|
|
|
|
2003-01-11 19:17:13 +00:00
|
|
|
Application::~Application()
|
2002-11-16 02:18:37 +00:00
|
|
|
{
|
|
|
|
delete _style_conf;
|
|
|
|
delete _img_ctrl;
|
|
|
|
delete _timer_manager;
|
|
|
|
delete _style;
|
|
|
|
|
2003-01-11 19:17:13 +00:00
|
|
|
Display::destroy();
|
2002-11-16 02:18:37 +00:00
|
|
|
}
|
|
|
|
|
2003-01-11 19:17:13 +00:00
|
|
|
void Application::loadStyle(void)
|
2002-11-16 02:18:37 +00:00
|
|
|
{
|
|
|
|
// find the style name as a property
|
2002-11-16 12:12:38 +00:00
|
|
|
std::string style = "/usr/local/share/openbox/styles/artwiz";
|
|
|
|
_style_conf->setFile(style);
|
|
|
|
if (!_style_conf->load()) {
|
2002-11-16 14:32:26 +00:00
|
|
|
std::cerr << "ERROR: Unable to load style \"" << style << "\".\n";
|
2002-11-16 12:12:38 +00:00
|
|
|
::exit(1);
|
|
|
|
}
|
2002-11-16 09:59:37 +00:00
|
|
|
_style->load(*_style_conf);
|
2002-11-16 02:18:37 +00:00
|
|
|
}
|
|
|
|
|
2003-01-11 19:17:13 +00:00
|
|
|
void Application::run(void)
|
2002-11-16 02:18:37 +00:00
|
|
|
{
|
2002-11-16 14:30:18 +00:00
|
|
|
if (_appwidget_count <= 0) {
|
|
|
|
std::cerr << "ERROR: No main widgets exist. You must create and show() " <<
|
2003-01-11 19:17:13 +00:00
|
|
|
"an AppWidget for the Application before calling " <<
|
|
|
|
"Application::run().\n";
|
2002-11-16 13:50:59 +00:00
|
|
|
::exit(1);
|
|
|
|
}
|
2002-11-16 14:30:18 +00:00
|
|
|
|
|
|
|
while (_appwidget_count > 0) {
|
2002-11-16 09:59:37 +00:00
|
|
|
dispatchEvents();
|
2002-11-16 12:10:04 +00:00
|
|
|
_timer_manager->fire(); // fire pending events
|
2002-11-16 09:59:37 +00:00
|
|
|
}
|
2002-11-16 02:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|