fix awdw solo vicon crash, fix nested clip for binfolders, open edit edl
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / loadfile.C
index 345456d976c996747b79c2852786a5186f816450..dce124911df4b2bb5b5505ac84350b12940f407d 100644 (file)
@@ -36,6 +36,7 @@
 #include "mainsession.h"
 #include "mwindow.h"
 #include "mwindowgui.h"
+#include "preferences.h"
 #include "theme.h"
 
 
@@ -79,6 +80,8 @@ LoadFileThread::LoadFileThread(MWindow *mwindow, Load *load)
        this->mwindow = mwindow;
        this->load = load;
        this->window = 0;
+       load_mode = LOADMODE_REPLACE;
+       edl_mode = LOADMODE_EDL_CLIP;
 }
 
 LoadFileThread::~LoadFileThread()
@@ -92,7 +95,7 @@ BC_Window* LoadFileThread::new_gui()
 
        sprintf(default_path, "~");
        mwindow->defaults->get("DEFAULT_LOADPATH", default_path);
-       load_mode = mwindow->defaults->get("LOAD_MODE", LOADMODE_REPLACE);
+       load_mode = mwindow->defaults->get("LOAD_MODE", load_mode);
 
        mwindow->gui->lock_window("LoadFileThread::new_gui");
        window = new LoadFileWindow(mwindow, this, default_path);
@@ -113,11 +116,13 @@ void LoadFileThread::handle_done_event(int result)
 
 void LoadFileThread::load_apply()
 {
-       mwindow->defaults->update("DEFAULT_LOADPATH",
-               window->get_submitted_path());
-       mwindow->defaults->update("LOAD_MODE",
-               load_mode);
-
+       mwindow->defaults->update("DEFAULT_LOADPATH", window->get_submitted_path());
+       mwindow->defaults->update("LOAD_MODE", load_mode);
+       if( edl_mode == LOADMODE_EDL_FILEREF )
+               mwindow->show_warning(
+                       &mwindow->preferences->warn_fileref,
+                       _("Other projects can change this project\n"
+                         "and this can become a broken link"));
        ArrayList<char*> path_list;
        path_list.set_array_delete();
 
@@ -131,25 +136,19 @@ void LoadFileThread::load_apply()
 
 // No file selected
        if( !path_list.size() ) return;
-
-       if( load_mode == LOADMODE_REPLACE )
-               mwindow->set_filename(path_list[0]);
+       int replaced = load_mode == LOADMODE_REPLACE ||
+            load_mode == LOADMODE_REPLACE_CONCATENATE ? 1 : 0;
 
        mwindow->interrupt_indexes();
        mwindow->gui->lock_window("LoadFileThread::run");
-       mwindow->load_filenames(&path_list, load_mode, 0);
+       mwindow->load_filenames(&path_list, load_mode, edl_mode, replaced);
        mwindow->gui->mainmenu->add_load(path_list.values[0]);
        mwindow->gui->unlock_window();
        path_list.remove_all_objects();
 
        mwindow->save_backup();
-
        mwindow->restart_brender();
-
-       if(load_mode == LOADMODE_REPLACE || load_mode == LOADMODE_REPLACE_CONCATENATE)
-               mwindow->session->changes_made = 0;
-       else
-               mwindow->session->changes_made = 1;
+       mwindow->session->changes_made = !replaced ? 1 : 0;
 }
 
 
@@ -183,13 +182,17 @@ void LoadFileWindow::create_objects()
        lock_window("LoadFileWindow::create_objects");
        BC_FileBox::create_objects();
 
-       int x = get_w() / 2 -
-               LoadMode::calculate_w(this, mwindow->theme) / 2;
-       int y = get_cancel_button()->get_y() -
-               LoadMode::calculate_h(this, mwindow->theme);
-       loadmode = new LoadMode(mwindow, this, x, y, &thread->load_mode, 0);
+       int x = get_w() / 2 - LoadMode::calculate_w(this, mwindow->theme) / 2;
+       int y = get_y_margin();
+// always start as clip to match historical behavior
+       thread->edl_mode = LOADMODE_EDL_CLIP;
+       loadmode = new LoadMode(mwindow, this, x, y,
+               &thread->load_mode, &thread->edl_mode, 0, 1);
        loadmode->create_objects();
-       add_subwindow(load_file_apply = new LoadFileApply(this));
+       const char *apply =  _("Apply");
+       x = 3*get_w()/4 - BC_GenericButton::calculate_w(this, apply)/2;
+       y = get_h() - BC_CancelButton::calculate_h() - yS(16);
+       add_subwindow(load_file_apply = new LoadFileApply(this, x, y, apply));
 
        show_window(1);
        unlock_window();
@@ -199,24 +202,22 @@ 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);
+       BC_FileBox::resize_event(w, h);
+       int x = w / 2 - LoadMode::calculate_w(this, mwindow->theme) / 2;
+       int y = get_y_margin();
        loadmode->reposition_window(x, y);
-
-       x = (w - BC_GenericButton::calculate_w(this, _("Apply")))/2;
-       y = h - BC_GenericButton::calculate_h() - 15;
+       const char *apply =  load_file_apply->get_text();
+       x = 3*get_w()/4 - BC_GenericButton::calculate_w(this, apply)/2;
+       y = get_h() - BC_CancelButton::calculate_h() - yS(16);
        load_file_apply->reposition_window(x, y);
-
-       return BC_FileBox::resize_event(w, h);
+       flush();
+       return 1;
 }
 
 
-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"))
+LoadFileApply::LoadFileApply(LoadFileWindow *load_file_window,
+               int x, int y, const char *text)
+ : BC_GenericButton(x, y, text)
 {
        this->load_file_window = load_file_window;
 }
@@ -251,7 +252,7 @@ LocateFileWindow::~LocateFileWindow()
 
 
 LoadPrevious::LoadPrevious(MWindow *mwindow, Load *loadfile)
- : BC_MenuItem(""), Thread()
+ : BC_MenuItem("")
 {
        this->mwindow = mwindow;
        this->loadfile = loadfile;
@@ -259,6 +260,7 @@ LoadPrevious::LoadPrevious(MWindow *mwindow, Load *loadfile)
 
 int LoadPrevious::handle_event()
 {
+       if( !path[0] ) return 1;
        ArrayList<char*> path_list;
        path_list.set_array_delete();
        char *out_path;
@@ -277,14 +279,7 @@ int LoadPrevious::handle_event()
        return 1;
 }
 
-
-
-void LoadPrevious::run()
-{
-//     loadfile->mwindow->load(path, loadfile->append);
-}
-
-int LoadPrevious::set_path(char *path)
+int LoadPrevious::set_path(const char *path)
 {
        strcpy(this->path, path);
        return 0;