4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "bcsignals.h"
24 #include "condition.h"
31 BC_DialogThread::BC_DialogThread()
35 startup_lock = new Condition(1, "BC_DialogThread::startup_lock");
36 window_lock = new Mutex("BC_DialogThread::window_lock");
39 BC_DialogThread::~BC_DialogThread()
41 startup_lock->lock("BC_DialogThread::~BC_DialogThread");
48 startup_lock->unlock();
56 void BC_DialogThread::lock_window(const char *location)
58 window_lock->lock(location);
61 void BC_DialogThread::unlock_window()
63 window_lock->unlock();
66 int BC_DialogThread::is_running()
68 return Thread::running();
71 void BC_DialogThread::start()
75 window_lock->lock("BC_DialogThread::start");
78 gui->lock_window("BC_DialogThread::start");
82 window_lock->unlock();
86 // Don't allow anyone else to create the window
87 startup_lock->lock("BC_DialogThread::start");
91 startup_lock->lock("BC_DialogThread::start");
92 startup_lock->unlock();
96 void BC_DialogThread::run()
99 startup_lock->unlock();
100 int result = gui->run_window();
102 handle_done_event(result);
104 window_lock->lock("BC_DialogThread::run");
107 window_lock->unlock();
109 handle_close_event(result);
112 void BC_DialogThread::lock_gui(const char *location)
114 window_lock->lock(location);
117 void BC_DialogThread::unlock_gui()
119 window_lock->unlock();
123 BC_Window* BC_DialogThread::new_gui()
125 printf("BC_DialogThread::new_gui called\n");
129 BC_Window* BC_DialogThread::get_gui()
134 void BC_DialogThread::handle_done_event(int result)
138 void BC_DialogThread::handle_close_event(int result)
142 void BC_DialogThread::close_window()
144 lock_window("BC_DialogThread::close_window");
147 gui->lock_window("BC_DialogThread::close_window");
149 gui->unlock_window();