/*
* CINELERRA
* Copyright (C) 2009 Adam Williams <broadcast at earthling dot net>
+ * Copyright (C) 2003-2016 Cinelerra CV contributors
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include "mainsession.h"
#include "mwindow.h"
#include "mwindowgui.h"
+#include "preferences.h"
#include "theme.h"
{
this->mwindow = mwindow;
this->mainmenu = mainmenu;
+ this->thread = 0;
}
Load::~Load()
{
this->mwindow = mwindow;
this->load = load;
+ this->window = 0;
+ load_mode = LOADMODE_RESOURCESONLY;
+ edl_mode = LOADMODE_EDL_CLIP;
}
LoadFileThread::~LoadFileThread()
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);
void LoadFileThread::handle_done_event(int result)
{
+ window->lock_window("LoadFileThread::handle_done_event");
+ window->hide_window();
+ window->unlock_window();
+
+ if( !result ) load_apply();
+}
+
+void LoadFileThread::load_apply()
+{
+ 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();
// 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++;
- }
+ 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));
}
- 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;
- }
-
- if( load_mode == LOADMODE_REPLACE )
- mwindow->set_filename(path_list[0]);
+ if( !path_list.size() ) return;
+ int replaced = load_mode == LOADMODE_REPLACE ||
+ load_mode == LOADMODE_REPLACE_CONCATENATE ? 1 : 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, 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;
}
-
LoadFileWindow::LoadFileWindow(MWindow *mwindow,
LoadFileThread *thread,
char *init_directory)
{
this->thread = thread;
this->mwindow = mwindow;
+// *** CONTEXT_HELP ***
+ context_help_set_keyword("Loading Files");
}
LoadFileWindow::~LoadFileWindow()
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();
+ 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();
int LoadFileWindow::resize_event(int w, int 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);
-
+ 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);
-
- return BC_FileBox::resize_event(w, h);
+ 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);
+ flush();
+ return 1;
}
+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;
+}
-
-
-
-
-
-
-
-
+int LoadFileApply::handle_event()
+{
+ load_file_window->thread->load_apply();
+ return 1;
+}
LocateFileWindow::LocateFileWindow(MWindow *mwindow,
LoadPrevious::LoadPrevious(MWindow *mwindow, Load *loadfile)
- : BC_MenuItem(""), Thread()
+ : BC_MenuItem("")
{
this->mwindow = mwindow;
this->loadfile = loadfile;
int LoadPrevious::handle_event()
{
+ if( !path[0] ) return 1;
ArrayList<char*> path_list;
path_list.set_array_delete();
char *out_path;
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;