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 "browsebutton.h"
31 BrowseButton::BrowseButton(MWindow *mwindow,
32 BC_WindowBase *parent_window,
36 const char *init_directory,
40 : BC_Button(x, y, mwindow->theme->get_image_set("magnify_button")),
43 this->parent_window = parent_window;
44 this->want_directory = want_directory;
46 this->caption = caption;
47 this->init_directory = init_directory;
48 this->textbox = textbox;
49 this->mwindow = mwindow;
50 set_tooltip(_("Look for file"));
52 startup_lock = new Mutex("BrowseButton::startup_lock");
55 BrowseButton::~BrowseButton()
57 startup_lock->lock("BrowseButton::~BrowseButton");
64 startup_lock->unlock();
69 int BrowseButton::handle_event()
75 gui->lock_window("BrowseButton::handle_event");
82 x = parent_window->get_abs_cursor_x(0);
83 y = parent_window->get_abs_cursor_y(0);
84 startup_lock->lock("BrowseButton::handle_event 1");
87 startup_lock->lock("BrowseButton::handle_event 2");
88 startup_lock->unlock();
92 void BrowseButton::run()
94 BrowseButtonWindow browsewindow(mwindow,
102 startup_lock->unlock();
104 browsewindow.lock_window("BrowseButton::run");
105 browsewindow.create_objects();
106 browsewindow.unlock_window();
107 int result2 = browsewindow.run_window();
111 // if(want_directory)
113 // textbox->update(browsewindow.get_directory());
117 // textbox->update(browsewindow.get_filename());
120 parent_window->lock_window("BrowseButton::run");
121 textbox->update(browsewindow.get_submitted_path());
122 parent_window->flush();
123 textbox->handle_event();
124 parent_window->unlock_window();
127 startup_lock->lock("BrowseButton::run");
129 startup_lock->unlock();
133 BrowseButtonWindow::BrowseButtonWindow(MWindow *mwindow,
134 BrowseButton *button,
135 BC_WindowBase *parent_window,
136 const char *init_directory,
140 : BC_FileBox(button->x - BC_WindowBase::get_resources()->filebox_w / 2,
141 button->y - BC_WindowBase::get_resources()->filebox_h / 2,
142 init_directory, title, caption,
143 want_directory, // Set to 1 to get hidden files.
144 want_directory, // Want only directories
145 0, mwindow->theme->browse_pad)
149 BrowseButtonWindow::~BrowseButtonWindow()