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"
32 BrowseButton::BrowseButton(MWindow *mwindow,
33 BC_WindowBase *parent_window,
37 const char *init_directory,
41 : BC_Button(x, y, mwindow->theme->get_image_set("magnify_button")),
44 this->parent_window = parent_window;
45 this->want_directory = want_directory;
47 this->caption = caption;
48 this->init_directory = init_directory;
49 this->textbox = textbox;
50 this->mwindow = mwindow;
51 set_tooltip(_("Look for file"));
53 startup_lock = new Mutex("BrowseButton::startup_lock");
56 BrowseButton::~BrowseButton()
58 startup_lock->lock("BrowseButton::~BrowseButton");
65 startup_lock->unlock();
70 int BrowseButton::handle_event()
76 gui->lock_window("BrowseButton::handle_event");
83 x = parent_window->get_abs_cursor_x(0);
84 y = parent_window->get_abs_cursor_y(0);
85 startup_lock->lock("BrowseButton::handle_event 1");
88 startup_lock->lock("BrowseButton::handle_event 2");
89 startup_lock->unlock();
93 void BrowseButton::run()
95 BrowseButtonWindow browsewindow(mwindow,
103 startup_lock->unlock();
105 browsewindow.lock_window("BrowseButton::run");
106 browsewindow.create_objects();
107 browsewindow.unlock_window();
108 int result2 = browsewindow.run_window();
112 // if(want_directory)
114 // textbox->update(browsewindow.get_directory());
118 // textbox->update(browsewindow.get_filename());
121 parent_window->lock_window("BrowseButton::run");
122 textbox->update(browsewindow.get_submitted_path());
123 parent_window->flush();
124 textbox->handle_event();
125 parent_window->unlock_window();
128 startup_lock->lock("BrowseButton::run");
130 startup_lock->unlock();
138 BrowseButtonWindow::BrowseButtonWindow(MWindow *mwindow,
139 BrowseButton *button,
140 BC_WindowBase *parent_window,
141 const char *init_directory,
145 : BC_FileBox(button->x -
146 BC_WindowBase::get_resources()->filebox_w / 2,
148 BC_WindowBase::get_resources()->filebox_h / 2,
152 // Set to 1 to get hidden files.
154 // Want only directories
157 mwindow->theme->browse_pad)
161 BrowseButtonWindow::~BrowseButtonWindow()