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
22 #include "bcsignals.h"
23 #include "browsebutton.h"
29 BrowseButton::BrowseButton(Theme *theme,
30 BC_WindowBase *parent_window,
34 const char *init_directory,
38 : BC_Button(x, y, theme->get_image_set("magnify_button")),
41 this->parent_window = parent_window;
42 this->want_directory = want_directory;
44 this->caption = caption;
45 this->init_directory = init_directory;
46 this->textbox = textbox;
48 set_tooltip(_("Look for file"));
50 startup_lock = new Mutex("BrowseButton::startup_lock");
53 BrowseButton::~BrowseButton()
55 startup_lock->lock("BrowseButton::~BrowseButton");
62 startup_lock->unlock();
67 int BrowseButton::handle_event()
73 gui->lock_window("BrowseButton::handle_event");
80 x = parent_window->get_abs_cursor_x(0);
81 y = parent_window->get_abs_cursor_y(0);
82 startup_lock->lock("BrowseButton::handle_event 1");
85 startup_lock->lock("BrowseButton::handle_event 2");
86 startup_lock->unlock();
90 void BrowseButton::run()
92 BrowseButtonWindow browsewindow(theme,
93 get_x() - BC_WindowBase::get_resources()->filebox_w / 2,
94 get_y() - BC_WindowBase::get_resources()->filebox_h / 2,
101 startup_lock->unlock();
103 browsewindow.lock_window("BrowseButton::run");
104 browsewindow.create_objects();
105 browsewindow.unlock_window();
106 int result2 = browsewindow.run_window();
110 // if(want_directory)
112 // textbox->update(browsewindow.get_directory());
116 // textbox->update(browsewindow.get_filename());
119 parent_window->lock_window("BrowseButton::run");
120 textbox->update(browsewindow.get_submitted_path());
121 parent_window->flush();
122 textbox->handle_event();
123 parent_window->unlock_window();
126 startup_lock->lock("BrowseButton::run");
128 startup_lock->unlock();
131 BrowseButtonWindow::BrowseButtonWindow(Theme *theme, int x, int y,
132 BC_WindowBase *parent_window, const char *init_directory,
133 const char *title, const char *caption, int want_directory)
134 : BC_FileBox(x, y, init_directory, title, caption,
135 want_directory, // Set to 1 to get hidden files.
136 want_directory, // Want only directories
137 0, theme->browse_pad)
141 BrowseButtonWindow::~BrowseButtonWindow()