Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

browsebutton.C

Go to the documentation of this file.
00001 #include "browsebutton.h"
00002 #include "language.h"
00003 #include "mutex.h"
00004 #include "mwindow.h"
00005 #include "theme.h"
00006 
00007 
00008 
00009 
00010 BrowseButton::BrowseButton(MWindow *mwindow, 
00011         BC_WindowBase *parent_window, 
00012         BC_TextBox *textbox, 
00013         int x, 
00014         int y, 
00015         char *init_directory, 
00016         char *title, 
00017         char *caption, 
00018         int want_directory,
00019         const char *recent_prefix)
00020  : BC_Button(x, y, mwindow->theme->get_image_set("magnify_button")), 
00021    Thread()
00022 {
00023         this->parent_window = parent_window;
00024         this->want_directory = want_directory;
00025         this->title = title;
00026         this->caption = caption;
00027         this->init_directory = init_directory;
00028         this->textbox = textbox;
00029         this->mwindow = mwindow;
00030         this->recent_prefix = recent_prefix;
00031         set_tooltip(_("Look for file"));
00032         gui = 0;
00033         startup_lock = new Mutex("BrowseButton::startup_lock");
00034 }
00035 
00036 BrowseButton::~BrowseButton()
00037 {
00038         startup_lock->lock("BrowseButton::~BrowseButton");
00039         if(gui)
00040         {
00041                 gui->lock_window();
00042                 gui->set_done(1);
00043                 gui->unlock_window();
00044         }
00045         startup_lock->unlock();
00046         Thread::join();
00047         delete startup_lock;
00048 }
00049 
00050 int BrowseButton::handle_event()
00051 {
00052         if(Thread::running())
00053         {
00054                 if(gui)
00055                 {
00056                         gui->lock_window();
00057                         gui->raise_window();
00058                         gui->unlock_window();
00059                 }
00060                 return 1;
00061         }
00062 
00063         x = parent_window->get_abs_cursor_x(0);
00064         y = parent_window->get_abs_cursor_y(0);
00065         startup_lock->lock("BrowseButton::handle_event 1");
00066         Thread::start();
00067 
00068         startup_lock->lock("BrowseButton::handle_event 2");
00069         startup_lock->unlock();
00070         return 1;
00071 }
00072 
00073 void BrowseButton::run()
00074 {
00075         BrowseButtonWindow browsewindow(mwindow,
00076                 this,
00077                 parent_window, 
00078                 textbox->get_text(), 
00079                 title, 
00080                 caption, 
00081                 want_directory);
00082         gui = &browsewindow;
00083         startup_lock->unlock();
00084         browsewindow.create_objects();
00085         int result2 = browsewindow.run_window();
00086 
00087         if(!result2)
00088         {
00089 //              if(want_directory)
00090 //              {
00091 //                      textbox->update(browsewindow.get_directory());
00092 //              }
00093 //              else
00094 //              {
00095 //                      textbox->update(browsewindow.get_filename());
00096 //              }
00097 
00098                 textbox->update(browsewindow.get_submitted_path());
00099                 parent_window->flush();
00100                 textbox->handle_event();
00101         }
00102         startup_lock->lock("BrowseButton::run");
00103         gui = 0;
00104         startup_lock->unlock();
00105 }
00106 
00107 
00108 
00109 
00110 
00111 
00112 BrowseButtonWindow::BrowseButtonWindow(MWindow *mwindow, 
00113         BrowseButton *button,
00114         BC_WindowBase *parent_window, 
00115         char *init_directory, 
00116         char *title, 
00117         char *caption, 
00118         int want_directory)
00119  : BC_FileBox(button->x - 
00120               BC_WindowBase::get_resources()->filebox_w / 2, 
00121               button->y - BC_WindowBase::get_resources()->filebox_h / 2,
00122               init_directory, title, caption,
00123               // Set to 1 to get hidden files. 
00124               want_directory,
00125               // Want only directories
00126               want_directory,
00127               0,
00128               mwindow->theme->browse_pad)
00129 {
00130 }
00131 
00132 BrowseButtonWindow::~BrowseButtonWindow() 
00133 {
00134 }

Generated on Sun Jan 8 13:38:50 2006 for Cinelerra-svn by  doxygen 1.4.4