18 new shapewipe transitions from rafa, rework savefile/confirm for nested edl edits
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / confirmsave.C
index 02fa7bbcb13e9c1a6a10c4887b6b8c78c9e5d648..fe89aff8b886f8c94e7e9a255f571769a7bea8a0 100644 (file)
  */
 
 #include "asset.h"
+#include "bchash.h"
 #include "confirmsave.h"
 #include "language.h"
 #include "mwindow.h"
 #include "mwindowgui.h"
 
 
-
-
 ConfirmSave::ConfirmSave()
 {
 }
@@ -36,6 +35,38 @@ ConfirmSave::~ConfirmSave()
 {
 }
 
+int ConfirmSave::get_save_path(MWindow *mwindow, char *filename)
+{
+       int result = 1;
+       char directory[BCTEXTLEN];
+       sprintf(directory, "~");
+       mwindow->defaults->get("DIRECTORY", directory);
+       while( result ) {
+               int mx, my;  mwindow->gui->get_abs_cursor(mx, my);
+               my -= BC_WindowBase::get_resources()->filebox_h / 2;
+               char string[BCTEXTLEN];
+               sprintf(string, _("Enter a filename to save as"));
+               BC_FileBox *filebox = new BC_FileBox(mx, my, directory,
+                       _(PROGRAM_NAME ": Save"), string);
+               filebox->lock_window("ConfirmSave::get_save_path");
+               filebox->create_objects();
+               filebox->unlock_window();
+               result = filebox->run_window();
+               mwindow->defaults->update("DIRECTORY", filebox->get_submitted_path());
+               strcpy(filename, filebox->get_submitted_path());
+               delete filebox;
+               if( result == 1 ) return 1;     // user cancelled
+               if( !filename[0] ) return 1;    // no filename given
+// Extend the filename with .xml
+               if( strlen(filename) < 4 ||
+                   strcasecmp(&filename[strlen(filename) - 4], ".xml") ) {
+                       strcat(filename, ".xml");
+               }
+               result = ConfirmSave::test_file(mwindow, filename);
+       }
+       return result;
+}
+
 int ConfirmSave::test_file(MWindow *mwindow, char *path)
 {
        ArrayList<char*> paths;