r1005: Increase the number of displayed digits for resample audio dialog box
[cinelerra_cv/mob.git] / cinelerra / browsebutton.C
blob2aa52ac518ac3adfd4a157c124b0eeb413c06c98
1 #include "browsebutton.h"
2 #include "language.h"
3 #include "mutex.h"
4 #include "mwindow.h"
5 #include "theme.h"
10 BrowseButton::BrowseButton(MWindow *mwindow, 
11         BC_WindowBase *parent_window, 
12         BC_TextBox *textbox, 
13         int x, 
14         int y, 
15         char *init_directory, 
16         char *title, 
17         char *caption, 
18         int want_directory,
19         const char *recent_prefix)
20  : BC_Button(x, y, mwindow->theme->get_image_set("magnify_button")), 
21    Thread()
23         this->parent_window = parent_window;
24         this->want_directory = want_directory;
25         this->title = title;
26         this->caption = caption;
27         this->init_directory = init_directory;
28         this->textbox = textbox;
29         this->mwindow = mwindow;
30         this->recent_prefix = recent_prefix;
31         set_tooltip(_("Look for file"));
32         gui = 0;
33         startup_lock = new Mutex("BrowseButton::startup_lock");
36 BrowseButton::~BrowseButton()
38         startup_lock->lock("BrowseButton::~BrowseButton");
39         if(gui)
40         {
41                 gui->lock_window();
42                 gui->set_done(1);
43                 gui->unlock_window();
44         }
45         startup_lock->unlock();
46         Thread::join();
47         delete startup_lock;
50 int BrowseButton::handle_event()
52         if(Thread::running())
53         {
54                 if(gui)
55                 {
56                         gui->lock_window();
57                         gui->raise_window();
58                         gui->unlock_window();
59                 }
60                 return 1;
61         }
63         x = parent_window->get_abs_cursor_x(0);
64         y = parent_window->get_abs_cursor_y(0);
65         startup_lock->lock("BrowseButton::handle_event 1");
66         Thread::start();
68         startup_lock->lock("BrowseButton::handle_event 2");
69         startup_lock->unlock();
70         return 1;
73 void BrowseButton::run()
75         BrowseButtonWindow browsewindow(mwindow,
76                 this,
77                 parent_window, 
78                 textbox->get_text(), 
79                 title, 
80                 caption, 
81                 want_directory);
82         gui = &browsewindow;
83         startup_lock->unlock();
84         browsewindow.create_objects();
85         int result2 = browsewindow.run_window();
87         if(!result2)
88         {
89 //              if(want_directory)
90 //              {
91 //                      textbox->update(browsewindow.get_directory());
92 //              }
93 //              else
94 //              {
95 //                      textbox->update(browsewindow.get_filename());
96 //              }
98                 textbox->update(browsewindow.get_submitted_path());
99                 parent_window->flush();
100                 textbox->handle_event();
101         }
102         startup_lock->lock("BrowseButton::run");
103         gui = 0;
104         startup_lock->unlock();
112 BrowseButtonWindow::BrowseButtonWindow(MWindow *mwindow, 
113         BrowseButton *button,
114         BC_WindowBase *parent_window, 
115         char *init_directory, 
116         char *title, 
117         char *caption, 
118         int want_directory)
119  : BC_FileBox(button->x - 
120                 BC_WindowBase::get_resources()->filebox_w / 2, 
121         button->y - 
122                 BC_WindowBase::get_resources()->filebox_h / 2,
123         init_directory,
124         title,
125         caption,
126 // Set to 1 to get hidden files. 
127         want_directory,
128 // Want only directories
129         want_directory,
130         0,
131         mwindow->theme->browse_pad)
135 BrowseButtonWindow::~BrowseButtonWindow()