+void SaveProjectWindow::create_objects()
+{
+ int x = 20, y = 20, x1 = get_w()-80;
+ BC_Title *title;
+ add_subwindow(title = new BC_Title(x, y, _("Project Directory:")));
+ y += title->get_h() + 10;
+ add_subwindow(textbox = new SaveProjectTextBox(this, x, y, x1-x));
+ x1 += 10;
+ add_subwindow(recent_project = new BC_RecentList("RECENT_PROJECT",
+ mwindow->defaults, textbox, 10, x1, y, 300, 100));
+ recent_project->load_items("RECENT_PROJECT");
+ x1 += recent_project->get_w() + 10;
+ add_subwindow(browse_button = new BrowseButton(mwindow->theme, this,
+ textbox, x1, y-5, "", "", "", 1));
+ y += textbox->get_h() + 20;
+ add_subwindow(mode_popup = new SaveProjectMode(this, x, y));
+ mode_popup->create_objects();
+ y += mode_popup->get_h() + 10;
+ x1 = x;
+ BC_CheckBox *overwrite_files, *reload_project;
+ add_subwindow(overwrite_files = new BC_CheckBox(x1, y, &overwrite, _("Overwrite files")));
+ x1 += overwrite_files->get_w() + 20;
+ add_subwindow(reload_project = new BC_CheckBox(x1, y, &reload, _("Reload project")));
+ add_subwindow(new BC_OKButton(this));
+ add_subwindow(new BC_CancelButton(this));
+ show_window(1);
+}
+
+SaveProject::SaveProject(MWindow *mwindow)
+ : BC_MenuItem(_("Save Project..."), "Alt-S", 's'), Thread()
+{
+ set_alt(1);
+ this->mwindow = mwindow;
+}
+
+int SaveProject::handle_event()
+{
+ start();
+ return 1;
+}
+
+void SaveProject::run()
+{
+ char dir_path[1024]; sprintf(dir_path, "~");
+ mwindow->defaults->get("PROJECT_DIRECTORY", dir_path);
+ int reload = mwindow->defaults->get("PROJECT_RELOAD", 0);
+ int overwrite = mwindow->defaults->get("PROJECT_OVERWRITE", 0);
+ int save_mode = mwindow->defaults->get("PROJECT_SAVE_MODE", 0);
+
+ SaveProjectWindow window(mwindow, dir_path, save_mode, overwrite, reload);
+ window.lock_window("SaveProject::run");
+ window.create_objects();
+ window.unlock_window();
+ int result = window.run_window();
+ if( result ) return;
+
+ strcpy(dir_path, window.textbox->get_text());
+ window.recent_project->add_item("RECENT_PROJECT", dir_path);
+ reload = window.get_reload();
+ overwrite = window.get_overwrite();
+ save_mode = window.get_save_mode();
+ mwindow->defaults->update("PROJECT_DIRECTORY", dir_path);
+ mwindow->defaults->update("PROJECT_RELOAD", reload);
+ mwindow->defaults->update("PROJECT_OVERWRITE", overwrite);
+ mwindow->defaults->update("PROJECT_SAVE_MODE", save_mode);
+ mwindow->save_project(dir_path, save_mode, overwrite, reload);
+}