4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5 * Copyright (C) 2003-2016 Cinelerra CV contributors
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "bcsignals.h"
24 #include "browsebutton.h"
30 BrowseButton::BrowseButton(Theme *theme,
31 BC_WindowBase *parent_window,
35 const char *init_directory,
39 : BC_Button(x, y, theme->get_image_set("magnify_button")),
42 this->parent_window = parent_window;
43 this->want_directory = want_directory;
45 this->caption = caption;
46 this->init_directory = init_directory;
47 this->textbox = textbox;
49 set_tooltip(_("Look for file"));
51 startup_lock = new Mutex("BrowseButton::startup_lock");
54 BrowseButton::~BrowseButton()
56 startup_lock->lock("BrowseButton::~BrowseButton");
63 startup_lock->unlock();
68 int BrowseButton::handle_event()
74 gui->lock_window("BrowseButton::handle_event");
81 x = parent_window->get_abs_cursor_x(0);
82 y = parent_window->get_abs_cursor_y(0);
83 startup_lock->lock("BrowseButton::handle_event 1");
86 startup_lock->lock("BrowseButton::handle_event 2");
87 startup_lock->unlock();
91 void BrowseButton::run()
93 BrowseButtonWindow browsewindow(theme,
94 get_x() - BC_WindowBase::get_resources()->filebox_w / 2,
95 get_y() - BC_WindowBase::get_resources()->filebox_h / 2,
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();
132 BrowseButtonWindow::BrowseButtonWindow(Theme *theme, int x, int y,
133 BC_WindowBase *parent_window, const char *init_directory,
134 const char *title, const char *caption, int want_directory)
135 : BC_FileBox(x, y, init_directory, title, caption,
136 want_directory, // Set to 1 to get hidden files.
137 want_directory, // Want only directories
138 0, theme->browse_pad)
140 // *** CONTEXT_HELP ***
141 context_help_set_keyword("Loading Files");
144 BrowseButtonWindow::~BrowseButtonWindow()