apply sge motion plugin mods
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / confirmsave.C
index 3542a049d5f0be63886eb4654f36523bf33d1049..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;
@@ -84,20 +115,15 @@ int ConfirmSave::test_files(MWindow *mwindow, ArrayList<char*> *paths)
 }
 
 
-
-
-
-
-
-
+#define CSW_W xS(400)
+#define CSW_H yS(150)
 
 ConfirmSaveWindow::ConfirmSaveWindow(MWindow *mwindow,
        ArrayList<BC_ListBoxItem*> *list)
  : BC_Window(_(PROGRAM_NAME ": File Exists"),
-               mwindow->gui->get_abs_cursor_x(1) - 160,
-               mwindow->gui->get_abs_cursor_y(1) - 120,
-               320,
-               320)
+               mwindow->gui->get_abs_cursor_x(1) - CSW_W/2,
+               mwindow->gui->get_abs_cursor_y(1) - CSW_H/2,
+               CSW_W, CSW_H)
 {
        this->list = list;
 }
@@ -109,7 +135,9 @@ ConfirmSaveWindow::~ConfirmSaveWindow()
 
 void ConfirmSaveWindow::create_objects()
 {
-       int x = 10, y = 10;
+       int xs10 = xS(10);
+       int ys10 = yS(10), ys30 = yS(30);
+       int x = xs10, y = ys10;
        lock_window("ConfirmSaveWindow::create_objects");
        add_subwindow(new BC_OKButton(this));
        add_subwindow(new BC_CancelButton(this));
@@ -117,16 +145,13 @@ void ConfirmSaveWindow::create_objects()
        add_subwindow(title = new BC_Title(x,
                y,
                _("The following files exist.  Overwrite them?")));
-       y += 30;
-       add_subwindow(listbox = new BC_ListBox(x,
-               y,
-               get_w() - x - 10,
-               get_h() - y - BC_OKButton::calculate_h() - 10,
+       y += ys30;
+       add_subwindow(listbox = new BC_ListBox(x, y,
+               get_w() - x - xs10,
+               get_h() - y - BC_OKButton::calculate_h() - ys10,
                LISTBOX_TEXT,
                list));
-       y = get_h() - 40;
        add_subwindow(new BC_OKButton(this));
-       x = get_w() - 100;
        add_subwindow(new BC_CancelButton(this));
        show_window(1);
        unlock_window();
@@ -134,18 +159,14 @@ void ConfirmSaveWindow::create_objects()
 
 int ConfirmSaveWindow::resize_event(int w, int h)
 {
-       int x = 10, y = 10;
+       int xs10 = xS(10);
+       int ys10 = yS(10), ys30 = yS(30);
+       int x = xs10, y = ys10;
        title->reposition_window(x, y);
-       y += 30;
-       listbox->reposition_window(x,
-               y,
-               w - x - 10,
-               h - y - 50);
+       y += ys30;
+       listbox->reposition_window(x, y,
+               w - x - xs10,
+               h - y - BC_OKButton::calculate_h() - ys10);
        return 1;
 }
 
-
-
-
-
-