r370: Heroine Virutal's official release 1.2.1
[cinelerra_cv/mob.git] / hvirtual / cinelerra / browsebutton.C
blob9a2c0fd377e243c69fb8ee833f31026dbc89e8fa
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  : BC_Button(x, y, mwindow->theme->magnify_button_data), 
20    Thread()
22         this->parent_window = parent_window;
23         this->want_directory = want_directory;
24         this->title = title;
25         this->caption = caption;
26         this->init_directory = init_directory;
27         this->textbox = textbox;
28         this->mwindow = mwindow;
29         set_tooltip(_("Look for file"));
30         gui = 0;
31         startup_lock = new Mutex("BrowseButton::startup_lock");
34 BrowseButton::~BrowseButton()
36         startup_lock->lock("BrowseButton::~BrowseButton");
37         if(gui)
38         {
39                 gui->lock_window();
40                 gui->set_done(1);
41                 gui->unlock_window();
42         }
43         startup_lock->unlock();
44         Thread::join();
45         delete startup_lock;
48 int BrowseButton::handle_event()
50         if(Thread::running())
51         {
52                 if(gui)
53                 {
54                         gui->lock_window();
55                         gui->raise_window();
56                         gui->unlock_window();
57                 }
58                 return 1;
59         }
61         x = parent_window->get_abs_cursor_x(0);
62         y = parent_window->get_abs_cursor_y(0);
63         startup_lock->lock("BrowseButton::handle_event 1");
64         Thread::start();
66         startup_lock->lock("BrowseButton::handle_event 2");
67         startup_lock->unlock();
68         return 1;
71 void BrowseButton::run()
73         BrowseButtonWindow browsewindow(mwindow,
74                 this,
75                 parent_window, 
76                 textbox->get_text(), 
77                 title, 
78                 caption, 
79                 want_directory);
80         gui = &browsewindow;
81         startup_lock->unlock();
82         browsewindow.create_objects();
83         int result2 = browsewindow.run_window();
85         if(!result2)
86         {
87 //              if(want_directory)
88 //              {
89 //                      textbox->update(browsewindow.get_directory());
90 //              }
91 //              else
92 //              {
93 //                      textbox->update(browsewindow.get_filename());
94 //              }
96                 textbox->update(browsewindow.get_submitted_path());
97                 parent_window->flush();
98                 textbox->handle_event();
99         }
100         startup_lock->lock("BrowseButton::run");
101         gui = 0;
102         startup_lock->unlock();
110 BrowseButtonWindow::BrowseButtonWindow(MWindow *mwindow, 
111         BrowseButton *button,
112         BC_WindowBase *parent_window, 
113         char *init_directory, 
114         char *title, 
115         char *caption, 
116         int want_directory)
117  : BC_FileBox(button->x - 
118                 BC_WindowBase::get_resources()->filebox_w / 2, 
119         button->y - 
120                 BC_WindowBase::get_resources()->filebox_h / 2,
121         init_directory,
122         title,
123         caption,
124 // Set to 1 to get hidden files. 
125         want_directory,
126 // Want only directories
127         want_directory,
128         0,
129         mwindow->theme->browse_pad)
133 BrowseButtonWindow::~BrowseButtonWindow()