18 |
*/ |
*/ |
19 |
|
|
20 |
#include <iostream> |
#include <iostream> |
21 |
|
#include <cstring> |
22 |
|
|
23 |
#include <gtkmm/filechooserdialog.h> |
#include <gtkmm/filechooserdialog.h> |
24 |
#include <gtkmm/messagedialog.h> |
#include <gtkmm/messagedialog.h> |
624 |
Gtk::FileFilter filter; |
Gtk::FileFilter filter; |
625 |
filter.add_pattern("*.gig"); |
filter.add_pattern("*.gig"); |
626 |
dialog.set_filter(filter); |
dialog.set_filter(filter); |
627 |
if (current_dir != "") { |
if (current_gig_dir != "") { |
628 |
dialog.set_current_folder(current_dir); |
dialog.set_current_folder(current_gig_dir); |
629 |
} |
} |
630 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
631 |
std::string filename = dialog.get_filename(); |
std::string filename = dialog.get_filename(); |
632 |
printf("filename=%s\n", filename.c_str()); |
printf("filename=%s\n", filename.c_str()); |
633 |
printf("on_action_file_open self=%x\n", Glib::Thread::self()); |
printf("on_action_file_open self=%x\n", Glib::Thread::self()); |
634 |
load_file(filename.c_str()); |
load_file(filename.c_str()); |
635 |
current_dir = Glib::path_get_dirname(filename); |
current_gig_dir = Glib::path_get_dirname(filename); |
636 |
} |
} |
637 |
} |
} |
638 |
|
|
753 |
filter.add_pattern("*.gig"); |
filter.add_pattern("*.gig"); |
754 |
dialog.set_filter(filter); |
dialog.set_filter(filter); |
755 |
|
|
756 |
if (Glib::path_is_absolute(filename)) { |
// set initial dir and filename of the Save As dialog |
757 |
dialog.set_filename(filename); |
// and prepare that initial filename as a copy of the gig |
758 |
} else if (current_dir != "") { |
{ |
759 |
dialog.set_current_folder(current_dir); |
std::string basename = Glib::path_get_basename(filename); |
760 |
|
std::string dir = Glib::path_get_dirname(filename); |
761 |
|
basename = std::string("copy_of_") + basename; |
762 |
|
Glib::ustring copyFileName = Glib::build_filename(dir, basename); |
763 |
|
if (Glib::path_is_absolute(filename)) { |
764 |
|
dialog.set_filename(copyFileName); |
765 |
|
} else { |
766 |
|
if (current_gig_dir != "") dialog.set_current_folder(current_gig_dir); |
767 |
|
} |
768 |
|
dialog.set_current_name(Glib::filename_display_basename(copyFileName)); |
769 |
} |
} |
770 |
dialog.set_current_name(Glib::filename_display_basename(filename)); |
|
771 |
|
// show warning in the dialog |
772 |
|
Gtk::HBox descriptionArea; |
773 |
|
descriptionArea.set_spacing(15); |
774 |
|
Gtk::Image warningIcon(Gtk::Stock::DIALOG_WARNING, Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); |
775 |
|
descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); |
776 |
|
warningIcon.show(); |
777 |
|
Gtk::Label description; |
778 |
|
description.set_markup( |
779 |
|
_("\n<b>CAUTION:</b> You <b>MUST</b> use the " |
780 |
|
"<span style=\"italic\">\"Save\"</span> dialog instead of " |
781 |
|
"<span style=\"italic\">\"Save As...\"</span> if you want to save " |
782 |
|
"to the same .gig file. Using " |
783 |
|
"<span style=\"italic\">\"Save As...\"</span> for writing to the " |
784 |
|
"same .gig file will end up in corrupted sample wave data!\n") |
785 |
|
); |
786 |
|
description.set_line_wrap(true); |
787 |
|
descriptionArea.pack_start(description, Gtk::PACK_SHRINK); |
788 |
|
description.show(); |
789 |
|
dialog.get_vbox()->pack_start(descriptionArea, Gtk::PACK_SHRINK); |
790 |
|
descriptionArea.show(); |
791 |
|
|
792 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
793 |
file_structure_to_be_changed_signal.emit(this->file); |
file_structure_to_be_changed_signal.emit(this->file); |
799 |
printf("filename=%s\n", filename.c_str()); |
printf("filename=%s\n", filename.c_str()); |
800 |
file->Save(filename); |
file->Save(filename); |
801 |
this->filename = filename; |
this->filename = filename; |
802 |
current_dir = Glib::path_get_dirname(filename); |
current_gig_dir = Glib::path_get_dirname(filename); |
803 |
set_title(Glib::filename_display_basename(filename)); |
set_title(Glib::filename_display_basename(filename)); |
804 |
file_has_name = true; |
file_has_name = true; |
805 |
file_is_changed = false; |
file_is_changed = false; |
1415 |
allpassfilter.set_name("All Files"); |
allpassfilter.set_name("All Files"); |
1416 |
dialog.add_filter(soundfilter); |
dialog.add_filter(soundfilter); |
1417 |
dialog.add_filter(allpassfilter); |
dialog.add_filter(allpassfilter); |
1418 |
|
if (current_sample_dir != "") { |
1419 |
|
dialog.set_current_folder(current_sample_dir); |
1420 |
|
} |
1421 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
1422 |
|
current_sample_dir = dialog.get_current_folder(); |
1423 |
Glib::ustring error_files; |
Glib::ustring error_files; |
1424 |
Glib::SListHandle<Glib::ustring> filenames = dialog.get_filenames(); |
Glib::SListHandle<Glib::ustring> filenames = dialog.get_filenames(); |
1425 |
for (Glib::SListHandle<Glib::ustring>::iterator iter = filenames.begin(); |
for (Glib::SListHandle<Glib::ustring>::iterator iter = filenames.begin(); |
1569 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
1570 |
dialog.add_button(_("Select"), Gtk::RESPONSE_OK); |
dialog.add_button(_("Select"), Gtk::RESPONSE_OK); |
1571 |
dialog.set_select_multiple(false); |
dialog.set_select_multiple(false); |
1572 |
|
if (current_sample_dir != "") { |
1573 |
|
dialog.set_current_folder(current_sample_dir); |
1574 |
|
} |
1575 |
// fix label width (because Gtk by design doesn't |
// fix label width (because Gtk by design doesn't |
1576 |
// know anything about the parent's size) |
// know anything about the parent's size) |
1577 |
#if 0 //FIXME: doesn't work |
#if 0 //FIXME: doesn't work |
1583 |
#endif |
#endif |
1584 |
if (dialog.run() == Gtk::RESPONSE_OK) |
if (dialog.run() == Gtk::RESPONSE_OK) |
1585 |
{ |
{ |
1586 |
|
current_sample_dir = dialog.get_current_folder(); |
1587 |
Glib::ustring error_files; |
Glib::ustring error_files; |
1588 |
Glib::ustring folder = dialog.get_filename(); |
Glib::ustring folder = dialog.get_filename(); |
1589 |
for (gig::Sample* sample = file->GetFirstSample(); |
for (gig::Sample* sample = file->GetFirstSample(); |