--- gigedit/trunk/src/gigedit/mainwindow.cpp 2008/02/06 22:08:29 1673 +++ gigedit/trunk/src/gigedit/mainwindow.cpp 2008/12/06 13:49:26 1799 @@ -18,6 +18,7 @@ */ #include +#include #include #include @@ -25,6 +26,7 @@ #include #include #include +#include "wrapLabel.hh" #include "global.h" @@ -201,7 +203,7 @@ sigc::mem_fun(*this, &MainWindow::on_action_add_group) ); actionGroup->add( - Gtk::Action::create("AddSample", _("Add _Sample(s)")), + Gtk::Action::create("AddSample", _("Add _Sample(s)...")), sigc::mem_fun(*this, &MainWindow::on_action_add_sample) ); actionGroup->add( @@ -209,7 +211,8 @@ sigc::mem_fun(*this, &MainWindow::on_action_remove_sample) ); actionGroup->add( - Gtk::Action::create("ReplaceAllSamplesInAllGroups", _("Replace All Samples In All Groups")), + Gtk::Action::create("ReplaceAllSamplesInAllGroups", + _("Replace All Samples in All Groups...")), sigc::mem_fun(*this, &MainWindow::on_action_replace_all_samples_in_all_groups) ); @@ -623,15 +626,15 @@ Gtk::FileFilter filter; filter.add_pattern("*.gig"); dialog.set_filter(filter); - if (current_dir != "") { - dialog.set_current_folder(current_dir); + if (current_gig_dir != "") { + dialog.set_current_folder(current_gig_dir); } if (dialog.run() == Gtk::RESPONSE_OK) { std::string filename = dialog.get_filename(); printf("filename=%s\n", filename.c_str()); printf("on_action_file_open self=%x\n", Glib::Thread::self()); load_file(filename.c_str()); - current_dir = Glib::path_get_dirname(filename); + current_gig_dir = Glib::path_get_dirname(filename); } } @@ -752,12 +755,38 @@ filter.add_pattern("*.gig"); dialog.set_filter(filter); - if (Glib::path_is_absolute(filename)) { - dialog.set_filename(filename); - } else if (current_dir != "") { - dialog.set_current_folder(current_dir); + // set initial dir and filename of the Save As dialog + // and prepare that initial filename as a copy of the gig + { + std::string basename = Glib::path_get_basename(filename); + std::string dir = Glib::path_get_dirname(filename); + basename = std::string("copy_of_") + basename; + Glib::ustring copyFileName = Glib::build_filename(dir, basename); + if (Glib::path_is_absolute(filename)) { + dialog.set_filename(copyFileName); + } else { + if (current_gig_dir != "") dialog.set_current_folder(current_gig_dir); + } + dialog.set_current_name(Glib::filename_display_basename(copyFileName)); } - dialog.set_current_name(Glib::filename_display_basename(filename)); + + // show warning in the dialog + Gtk::HBox descriptionArea; + descriptionArea.set_spacing(15); + Gtk::Image warningIcon(Gtk::Stock::DIALOG_WARNING, Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); + descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); + view::WrapLabel description; + description.set_markup( + _("\nCAUTION: You MUST use the " + "\"Save\" dialog instead of " + "\"Save As...\" if you want to save " + "to the same .gig file. Using " + "\"Save As...\" for writing to the " + "same .gig file will end up in corrupted sample wave data!\n") + ); + descriptionArea.pack_start(description); + dialog.get_vbox()->pack_start(descriptionArea, Gtk::PACK_SHRINK); + descriptionArea.show_all(); if (dialog.run() == Gtk::RESPONSE_OK) { file_structure_to_be_changed_signal.emit(this->file); @@ -769,7 +798,7 @@ printf("filename=%s\n", filename.c_str()); file->Save(filename); this->filename = filename; - current_dir = Glib::path_get_dirname(filename); + current_gig_dir = Glib::path_get_dirname(filename); set_title(Glib::filename_display_basename(filename)); file_has_name = true; file_is_changed = false; @@ -1385,7 +1414,11 @@ allpassfilter.set_name("All Files"); dialog.add_filter(soundfilter); dialog.add_filter(allpassfilter); + if (current_sample_dir != "") { + dialog.set_current_folder(current_sample_dir); + } if (dialog.run() == Gtk::RESPONSE_OK) { + current_sample_dir = dialog.get_current_folder(); Glib::ustring error_files; Glib::SListHandle filenames = dialog.get_filenames(); for (Glib::SListHandle::iterator iter = filenames.begin(); @@ -1503,25 +1536,24 @@ if (!file) return; Gtk::FileChooserDialog dialog(*this, _("Select Folder"), Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER); - Gtk::Label description( + view::WrapLabel description( _("This is a very specific function. It tries to replace all samples " - "in the current gig file by samples located in the directory chosen " - "by you above.\n\n" - "It works like this: For each sample in the gig file it tries to " + "in the current gig file by samples located in the chosen " + "directory.\n\n" + "It works like this: For each sample in the gig file, it tries to " "find a sample file in the selected directory with the same name as " - "the sample in the gig file. Optionally you can add a filename " - "postfix below, which will be added to the filename expected to be " + "the sample in the gig file. Optionally, you can add a filename " + "extension below, which will be added to the filename expected to be " "found. That is, assume you have a gig file with a sample called " "'Snare', if you enter '.wav' below (like it's done by default), it " - "assumes to find a sample file called 'Snare.wav' and will replace " - "the sample in the gig file accordingly. If you don't need such a " - "postfix, blank the field below. Any gig sample where no " - "appropriate sample file could be found, will be reported and left " - "untouched.\n\n") + "expects to find a sample file called 'Snare.wav' and will replace " + "the sample in the gig file accordingly. If you don't need an " + "extension, blank the field below. Any gig sample where no " + "appropriate sample file could be found will be reported and left " + "untouched.\n") ); - description.set_line_wrap(true); Gtk::HBox entryArea; - Gtk::Label entryLabel( _("Add Filename Extension: "), Gtk::ALIGN_RIGHT); + Gtk::Label entryLabel( _("Add filename extension: "), Gtk::ALIGN_RIGHT); Gtk::Entry postfixEntryBox; postfixEntryBox.set_text(".wav"); entryArea.pack_start(entryLabel); @@ -1529,23 +1561,16 @@ dialog.get_vbox()->pack_start(description, Gtk::PACK_SHRINK); dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK); description.show(); - entryLabel.show(); - postfixEntryBox.show(); - entryArea.show(); + entryArea.show_all(); dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); dialog.add_button(_("Select"), Gtk::RESPONSE_OK); dialog.set_select_multiple(false); - // fix label width (because Gtk by design doesn't - // know anything about the parent's size) -#if 0 //FIXME: doesn't work - int dialogW, dialogH, labelW, labelH; - dialog.get_size_request(dialogW, dialogH); - description.get_size_request(labelW, labelH); - std::cout << "dialog(" << dialogW << "," << dialogH << ")\nlabel(" << labelW << "," << labelH << ")\n" << std::flush; - description.set_size_request(dialogW, labelH); -#endif + if (current_sample_dir != "") { + dialog.set_current_folder(current_sample_dir); + } if (dialog.run() == Gtk::RESPONSE_OK) { + current_sample_dir = dialog.get_current_folder(); Glib::ustring error_files; Glib::ustring folder = dialog.get_filename(); for (gig::Sample* sample = file->GetFirstSample();