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", window.get_path());
114 mwindow->defaults->update("LOAD_MODE", load_mode);
118 if(path_list.total == 0 || result == 1)
123 mwindow->undo->update_undo_before(_("load"), LOAD_ALL);
124 mwindow->interrupt_indexes();
125 mwindow->gui->lock_window();
126 result = mwindow->load_filenames(&path_list, load_mode);
127 mwindow->gui->mainmenu->add_load(path_list.values[0]);
128 mwindow->gui->unlock_window();
129 path_list.remove_all_objects();
132 mwindow->save_backup();
133 mwindow->restart_brender();
134 mwindow->undo->update_undo_after();
145 LoadFileWindow::LoadFileWindow(MWindow *mwindow,
146 LoadFileThread *thread,
147 char *init_directory)
148 : BC_FileBox(mwindow->gui->get_abs_cursor_x(),
149 mwindow->gui->get_abs_cursor_y() - BC_WindowBase::get_resources()->filebox_h / 2,
151 PROGRAM_NAME ": Load",
152 _("Select files to load:"),
156 mwindow->theme->loadfile_pad)
158 this->thread = thread;
159 this->mwindow = mwindow;
162 LoadFileWindow::~LoadFileWindow()
167 int LoadFileWindow::create_objects()
169 BC_FileBox::create_objects();
171 int x = get_w() / 2 - 200;
172 int y = get_h() - 90;
173 loadmode = new LoadMode(mwindow, this, x, y, &thread->load_mode, 0);
174 loadmode->create_objects();
179 int LoadFileWindow::resize_event(int w, int h)
183 draw_background(0, 0, w, h);
185 loadmode->reposition_window(x, y);
187 return BC_FileBox::resize_event(w, h);
191 NewTimeline::NewTimeline(int x, int y, LoadFileWindow *window)
194 window->thread->load_mode == LOAD_REPLACE,
195 _("Replace current project."))
197 this->window = window;
199 int NewTimeline::handle_event()
201 window->newtracks->set_value(0);
202 window->newconcatenate->set_value(0);
203 window->concatenate->set_value(0);
204 window->resourcesonly->set_value(0);
208 NewConcatenate::NewConcatenate(int x, int y, LoadFileWindow *window)
211 window->thread->load_mode == LOAD_REPLACE_CONCATENATE,
212 _("Replace current project and concatenate tracks."))
214 this->window = window;
216 int NewConcatenate::handle_event()
218 window->newtimeline->set_value(0);
219 window->newtracks->set_value(0);
220 window->concatenate->set_value(0);
221 window->resourcesonly->set_value(0);
225 AppendNewTracks::AppendNewTracks(int x, int y, LoadFileWindow *window)
228 window->thread->load_mode == LOAD_NEW_TRACKS,
229 _("Append in new tracks."))
231 this->window = window;
233 int AppendNewTracks::handle_event()
235 window->newtimeline->set_value(0);
236 window->newconcatenate->set_value(0);
237 window->concatenate->set_value(0);
238 window->resourcesonly->set_value(0);
242 EndofTracks::EndofTracks(int x, int y, LoadFileWindow *window)
245 window->thread->load_mode == LOAD_CONCATENATE,
246 _("Concatenate to existing tracks."))
248 this->window = window;
250 int EndofTracks::handle_event()
252 window->newtimeline->set_value(0);
253 window->newconcatenate->set_value(0);
254 window->newtracks->set_value(0);
255 window->resourcesonly->set_value(0);
259 ResourcesOnly::ResourcesOnly(int x, int y, LoadFileWindow *window)
262 window->thread->load_mode == LOAD_RESOURCESONLY,
263 _("Create new resources only."))
265 this->window = window;
267 int ResourcesOnly::handle_event()
270 window->newtimeline->set_value(0);
271 window->newconcatenate->set_value(0);
272 window->newtracks->set_value(0);
273 window->concatenate->set_value(0);
283 LocateFileWindow::LocateFileWindow(MWindow *mwindow,
284 char *init_directory,
286 : BC_FileBox(mwindow->gui->get_abs_cursor_x(),
287 mwindow->gui->get_abs_cursor_y(),
289 PROGRAM_NAME ": Locate file",
292 this->mwindow = mwindow;
295 LocateFileWindow::~LocateFileWindow() {}
303 LoadPrevious::LoadPrevious(MWindow *mwindow, Load *loadfile)
304 : BC_MenuItem(""), Thread()
306 this->mwindow = mwindow;
307 this->loadfile = loadfile;
310 int LoadPrevious::handle_event()
312 ArrayList<char*> path_list;
313 path_list.set_array_delete();
315 int load_mode = mwindow->defaults->get("LOAD_MODE", LOAD_REPLACE);
317 mwindow->undo->update_undo_before(_("load previous"), LOAD_ALL);
319 path_list.append(out_path = new char[strlen(path) + 1]);
320 strcpy(out_path, path);
321 //printf("LoadPrevious::LoadPrevious 1\n");
322 mwindow->load_filenames(&path_list, LOAD_REPLACE);
323 //printf("LoadPrevious::LoadPrevious 2\n");
324 mwindow->gui->mainmenu->add_load(path_list.values[0]);
325 //printf("LoadPrevious::LoadPrevious 3\n");
326 path_list.remove_all_objects();
327 //printf("LoadPrevious::LoadPrevious 4\n");
330 mwindow->defaults->update("LOAD_MODE", load_mode);
331 mwindow->undo->update_undo_after();
332 mwindow->save_backup();
342 void LoadPrevious::run()
344 // loadfile->mwindow->load(path, loadfile->append);
347 int LoadPrevious::set_path(char *path)
349 strcpy(this->path, path);
359 LoadBackup::LoadBackup(MWindow *mwindow)
360 : BC_MenuItem(_("Load backup"))
362 this->mwindow = mwindow;
365 int LoadBackup::handle_event()
367 ArrayList<char*> path_list;
368 path_list.set_array_delete();
370 char string[BCTEXTLEN];
371 strcpy(string, BACKUP_PATH);
373 fs.complete_path(string);
375 path_list.append(out_path = new char[strlen(string) + 1]);
376 strcpy(out_path, string);
378 mwindow->undo->update_undo_before(_("load backup"), LOAD_ALL);
379 mwindow->load_filenames(&path_list, LOAD_REPLACE);
380 mwindow->edl->local_session->clip_title[0] = 0;
381 mwindow->set_filename("");
382 path_list.remove_all_objects();
383 mwindow->undo->update_undo_after();
384 mwindow->save_backup();