6 #include "filesystem.h"
10 #include "localsession.h"
14 #include "mwindowgui.h"
19 #define _(String) gettext(String)
20 #define gettext_noop(String) String
21 #define N_(String) gettext_noop (String)
27 Load::Load(MWindow *mwindow, MainMenu *mainmenu)
28 : BC_MenuItem(_("Load files..."), "o", 'o')
30 this->mwindow = mwindow;
31 this->mainmenu = mainmenu;
39 int Load::create_objects()
41 thread = new LoadFileThread(mwindow, this);
45 int Load::handle_event()
47 //printf("Load::handle_event 1\n");
48 if(!thread->running())
50 //printf("Load::handle_event 2\n");
61 LoadFileThread::LoadFileThread(MWindow *mwindow, Load *load)
64 this->mwindow = mwindow;
68 LoadFileThread::~LoadFileThread()
72 void LoadFileThread::run()
75 ArrayList<BC_ListBoxItem*> *dirlist;
77 ArrayList<char*> path_list;
78 path_list.set_array_delete();
79 char default_path[BCTEXTLEN];
81 sprintf(default_path, "~");
82 mwindow->defaults->get("DEFAULT_LOADPATH", default_path);
83 load_mode = mwindow->defaults->get("LOAD_MODE", LOAD_REPLACE);
86 LoadFileWindow window(mwindow, this, default_path);
87 window.create_objects();
88 result = window.run_window();
90 // Collect all selected files
93 char *in_path, *out_path;
96 while(in_path = window.get_path(i))
99 for(j = 0; j < path_list.total; j++)
101 if(!strcmp(in_path, path_list.values[j])) break;
104 if(j == path_list.total)
106 path_list.append(out_path = new char[strlen(in_path) + 1]);
107 strcpy(out_path, in_path);
113 mwindow->defaults->update("DEFAULT_LOADPATH",
114 window.get_submitted_path());
115 mwindow->defaults->update("LOAD_MODE",
120 if(path_list.total == 0 || result == 1)
125 mwindow->undo->update_undo_before(_("load"), LOAD_ALL);
126 mwindow->interrupt_indexes();
127 mwindow->gui->lock_window();
128 result = mwindow->load_filenames(&path_list, load_mode);
129 mwindow->gui->mainmenu->add_load(path_list.values[0]);
130 mwindow->gui->unlock_window();
131 path_list.remove_all_objects();
134 mwindow->save_backup();
135 mwindow->restart_brender();
136 mwindow->undo->update_undo_after();
147 LoadFileWindow::LoadFileWindow(MWindow *mwindow,
148 LoadFileThread *thread,
149 char *init_directory)
150 : BC_FileBox(mwindow->gui->get_abs_cursor_x(),
151 mwindow->gui->get_abs_cursor_y() - BC_WindowBase::get_resources()->filebox_h / 2,
153 PROGRAM_NAME ": Load",
154 _("Select files to load:"),
158 mwindow->theme->loadfile_pad)
160 this->thread = thread;
161 this->mwindow = mwindow;
164 LoadFileWindow::~LoadFileWindow()
169 int LoadFileWindow::create_objects()
171 BC_FileBox::create_objects();
173 int x = get_w() / 2 - 200;
174 int y = get_h() - 90;
175 loadmode = new LoadMode(mwindow, this, x, y, &thread->load_mode, 0);
176 loadmode->create_objects();
181 int LoadFileWindow::resize_event(int w, int h)
185 draw_background(0, 0, w, h);
187 loadmode->reposition_window(x, y);
189 return BC_FileBox::resize_event(w, h);
198 NewTimeline::NewTimeline(int x, int y, LoadFileWindow *window)
201 window->thread->load_mode == LOAD_REPLACE,
202 _("Replace current project."))
204 this->window = window;
206 int NewTimeline::handle_event()
208 window->newtracks->set_value(0);
209 window->newconcatenate->set_value(0);
210 window->concatenate->set_value(0);
211 window->resourcesonly->set_value(0);
215 NewConcatenate::NewConcatenate(int x, int y, LoadFileWindow *window)
218 window->thread->load_mode == LOAD_REPLACE_CONCATENATE,
219 _("Replace current project and concatenate tracks."))
221 this->window = window;
223 int NewConcatenate::handle_event()
225 window->newtimeline->set_value(0);
226 window->newtracks->set_value(0);
227 window->concatenate->set_value(0);
228 window->resourcesonly->set_value(0);
232 AppendNewTracks::AppendNewTracks(int x, int y, LoadFileWindow *window)
235 window->thread->load_mode == LOAD_NEW_TRACKS,
236 _("Append in new tracks."))
238 this->window = window;
240 int AppendNewTracks::handle_event()
242 window->newtimeline->set_value(0);
243 window->newconcatenate->set_value(0);
244 window->concatenate->set_value(0);
245 window->resourcesonly->set_value(0);
249 EndofTracks::EndofTracks(int x, int y, LoadFileWindow *window)
252 window->thread->load_mode == LOAD_CONCATENATE,
253 _("Concatenate to existing tracks."))
255 this->window = window;
257 int EndofTracks::handle_event()
259 window->newtimeline->set_value(0);
260 window->newconcatenate->set_value(0);
261 window->newtracks->set_value(0);
262 window->resourcesonly->set_value(0);
266 ResourcesOnly::ResourcesOnly(int x, int y, LoadFileWindow *window)
269 window->thread->load_mode == LOAD_RESOURCESONLY,
270 _("Create new resources only."))
272 this->window = window;
274 int ResourcesOnly::handle_event()
277 window->newtimeline->set_value(0);
278 window->newconcatenate->set_value(0);
279 window->newtracks->set_value(0);
280 window->concatenate->set_value(0);
290 LocateFileWindow::LocateFileWindow(MWindow *mwindow,
291 char *init_directory,
293 : BC_FileBox(mwindow->gui->get_abs_cursor_x(),
294 mwindow->gui->get_abs_cursor_y(),
296 PROGRAM_NAME ": Locate file",
299 this->mwindow = mwindow;
302 LocateFileWindow::~LocateFileWindow() {}
310 LoadPrevious::LoadPrevious(MWindow *mwindow, Load *loadfile)
311 : BC_MenuItem(""), Thread()
313 this->mwindow = mwindow;
314 this->loadfile = loadfile;
317 int LoadPrevious::handle_event()
319 ArrayList<char*> path_list;
320 path_list.set_array_delete();
322 int load_mode = mwindow->defaults->get("LOAD_MODE", LOAD_REPLACE);
324 mwindow->undo->update_undo_before(_("load previous"), LOAD_ALL);
326 path_list.append(out_path = new char[strlen(path) + 1]);
327 strcpy(out_path, path);
328 mwindow->load_filenames(&path_list, LOAD_REPLACE);
329 mwindow->gui->mainmenu->add_load(path_list.values[0]);
330 path_list.remove_all_objects();
333 mwindow->defaults->update("LOAD_MODE", load_mode);
334 mwindow->undo->update_undo_after();
335 mwindow->save_backup();
345 void LoadPrevious::run()
347 // loadfile->mwindow->load(path, loadfile->append);
350 int LoadPrevious::set_path(char *path)
352 strcpy(this->path, path);
362 LoadBackup::LoadBackup(MWindow *mwindow)
363 : BC_MenuItem(_("Load backup"))
365 this->mwindow = mwindow;
368 int LoadBackup::handle_event()
370 ArrayList<char*> path_list;
371 path_list.set_array_delete();
373 char string[BCTEXTLEN];
374 strcpy(string, BACKUP_PATH);
376 fs.complete_path(string);
378 path_list.append(out_path = new char[strlen(string) + 1]);
379 strcpy(out_path, string);
381 mwindow->undo->update_undo_before(_("load backup"), LOAD_ALL);
382 mwindow->load_filenames(&path_list, LOAD_REPLACE);
383 mwindow->edl->local_session->clip_title[0] = 0;
384 mwindow->set_filename("");
385 path_list.remove_all_objects();
386 mwindow->undo->update_undo_after();
387 mwindow->save_backup();