add shuttle dev support, use dflt ff_a/v.png icons, mjpegtools typo patch
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / loadfile.C
index 3be7223f77a8f3fbe545f5a4a2110f9488728667..345456d976c996747b79c2852786a5186f816450 100644 (file)
@@ -47,6 +47,7 @@ Load::Load(MWindow *mwindow, MainMenu *mainmenu)
 {
        this->mwindow = mwindow;
        this->mainmenu = mainmenu;
+       this->thread = 0;
 }
 
 Load::~Load()
@@ -77,6 +78,7 @@ LoadFileThread::LoadFileThread(MWindow *mwindow, Load *load)
 {
        this->mwindow = mwindow;
        this->load = load;
+       this->window = 0;
 }
 
 LoadFileThread::~LoadFileThread()
@@ -102,52 +104,40 @@ BC_Window* LoadFileThread::new_gui()
 
 void LoadFileThread::handle_done_event(int result)
 {
-       ArrayList<char*> path_list;
-       path_list.set_array_delete();
+       window->lock_window("LoadFileThread::handle_done_event");
+       window->hide_window();
+       window->unlock_window();
 
-// Collect all selected files
-       if(!result)
-       {
-               char *in_path, *out_path;
-               int i = 0;
-               window->lock_window("LoadFileThread::handle_done_event");
-               window->hide_window();
-               window->unlock_window();
-
-               while((in_path = window->get_path(i)))
-               {
-                       int j;
-                       for(j = 0; j < path_list.total; j++)
-                       {
-                               if(!strcmp(in_path, path_list.values[j])) break;
-                       }
-
-                       if(j == path_list.total)
-                       {
-                               path_list.append(out_path = new char[strlen(in_path) + 1]);
-                               strcpy(out_path, in_path);
-                       }
-                       i++;
-               }
-       }
+       if( !result ) load_apply();
+}
 
+void LoadFileThread::load_apply()
+{
        mwindow->defaults->update("DEFAULT_LOADPATH",
                window->get_submitted_path());
        mwindow->defaults->update("LOAD_MODE",
                load_mode);
 
-// No file selected
-       if(path_list.total == 0 || result == 1)
-       {
-               return;
+       ArrayList<char*> path_list;
+       path_list.set_array_delete();
+
+// Collect all selected files
+       char *in_path;
+       for( int i=0; (in_path = window->get_path(i))!=0; ++i ) {
+               int k = path_list.size();
+               while( --k >= 0 && strcmp(in_path, path_list.values[k]) );
+               if( k < 0 ) path_list.append(cstrdup(in_path));
        }
 
+// No file selected
+       if( !path_list.size() ) return;
+
        if( load_mode == LOADMODE_REPLACE )
                mwindow->set_filename(path_list[0]);
 
        mwindow->interrupt_indexes();
        mwindow->gui->lock_window("LoadFileThread::run");
-       result = mwindow->load_filenames(&path_list, load_mode, 0);
+       mwindow->load_filenames(&path_list, load_mode, 0);
        mwindow->gui->mainmenu->add_load(path_list.values[0]);
        mwindow->gui->unlock_window();
        path_list.remove_all_objects();
@@ -163,7 +153,6 @@ void LoadFileThread::handle_done_event(int result)
 }
 
 
-
 LoadFileWindow::LoadFileWindow(MWindow *mwindow,
        LoadFileThread *thread,
        char *init_directory)
@@ -200,6 +189,7 @@ void LoadFileWindow::create_objects()
                LoadMode::calculate_h(this, mwindow->theme);
        loadmode = new LoadMode(mwindow, this, x, y, &thread->load_mode, 0);
        loadmode->create_objects();
+       add_subwindow(load_file_apply = new LoadFileApply(this));
 
        show_window(1);
        unlock_window();
@@ -208,26 +198,34 @@ void LoadFileWindow::create_objects()
 
 int LoadFileWindow::resize_event(int w, int h)
 {
+       draw_background(0, 0, w, h);
        int x = w / 2 - 200;
        int y = get_cancel_button()->get_y() -
                LoadMode::calculate_h(this, mwindow->theme);
-       draw_background(0, 0, w, h);
-
        loadmode->reposition_window(x, y);
 
+       x = (w - BC_GenericButton::calculate_w(this, _("Apply")))/2;
+       y = h - BC_GenericButton::calculate_h() - 15;
+       load_file_apply->reposition_window(x, y);
+
        return BC_FileBox::resize_event(w, h);
 }
 
 
+LoadFileApply::LoadFileApply(LoadFileWindow *load_file_window)
+ : BC_GenericButton( (load_file_window->get_w() -
+               BC_GenericButton::calculate_w(load_file_window, _("Apply")))/2,
+       load_file_window->get_h() - BC_GenericButton::calculate_h() - 15,
+       _("Apply"))
+{
+       this->load_file_window = load_file_window;
+}
 
-
-
-
-
-
-
-
-
+int LoadFileApply::handle_event()
+{
+       load_file_window->thread->load_apply();
+       return 1;
+}
 
 
 LocateFileWindow::LocateFileWindow(MWindow *mwindow,