1 |
/* |
/* |
2 |
* Copyright (C) 2006-2009 Andreas Persson |
* Copyright (C) 2006-2013 Andreas Persson |
3 |
* |
* |
4 |
* This program is free software; you can redistribute it and/or |
* This program is free software; you can redistribute it and/or |
5 |
* modify it under the terms of the GNU General Public License as |
* modify it under the terms of the GNU General Public License as |
20 |
#include <iostream> |
#include <iostream> |
21 |
#include <cstring> |
#include <cstring> |
22 |
|
|
23 |
|
#include <glibmm/convert.h> |
24 |
|
#include <glibmm/dispatcher.h> |
25 |
|
#include <glibmm/miscutils.h> |
26 |
|
#include <glibmm/stringutils.h> |
27 |
|
#include <gtkmm/aboutdialog.h> |
28 |
#include <gtkmm/filechooserdialog.h> |
#include <gtkmm/filechooserdialog.h> |
29 |
#include <gtkmm/messagedialog.h> |
#include <gtkmm/messagedialog.h> |
30 |
#include <gtkmm/stock.h> |
#include <gtkmm/stock.h> |
31 |
#include <gtkmm/targetentry.h> |
#include <gtkmm/targetentry.h> |
32 |
#include <gtkmm/main.h> |
#include <gtkmm/main.h> |
33 |
|
#include <gtkmm/radiomenuitem.h> |
34 |
#include <gtkmm/toggleaction.h> |
#include <gtkmm/toggleaction.h> |
35 |
|
#if GTKMM_MAJOR_VERSION < 3 |
36 |
#include "wrapLabel.hh" |
#include "wrapLabel.hh" |
|
|
|
|
#include "global.h" |
|
|
|
|
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 6) || GTKMM_MAJOR_VERSION > 2 |
|
|
#define ABOUT_DIALOG |
|
|
#include <gtkmm/aboutdialog.h> |
|
37 |
#endif |
#endif |
38 |
|
|
39 |
#if (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION < 6) || GLIBMM_MAJOR_VERSION < 2 |
#include "global.h" |
40 |
namespace Glib { |
#include "compat.h" |
|
Glib::ustring filename_display_basename(const std::string& filename) |
|
|
{ |
|
|
gchar* gstr = g_path_get_basename(filename.c_str()); |
|
|
Glib::ustring str(gstr); |
|
|
g_free(gstr); |
|
|
return Glib::filename_to_utf8(str); |
|
|
} |
|
|
} |
|
|
#endif |
|
41 |
|
|
42 |
#include <stdio.h> |
#include <stdio.h> |
43 |
#include <sndfile.h> |
#include <sndfile.h> |
171 |
action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP); |
action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP); |
172 |
actionGroup->add(Gtk::Action::create("MenuHelp", |
actionGroup->add(Gtk::Action::create("MenuHelp", |
173 |
action->property_label())); |
action->property_label())); |
|
#ifdef ABOUT_DIALOG |
|
174 |
actionGroup->add(Gtk::Action::create("About", Gtk::Stock::ABOUT), |
actionGroup->add(Gtk::Action::create("About", Gtk::Stock::ABOUT), |
175 |
sigc::mem_fun( |
sigc::mem_fun( |
176 |
*this, &MainWindow::on_action_help_about)); |
*this, &MainWindow::on_action_help_about)); |
|
#endif |
|
177 |
actionGroup->add( |
actionGroup->add( |
178 |
Gtk::Action::create("AddInstrument", _("Add _Instrument")), |
Gtk::Action::create("AddInstrument", _("Add _Instrument")), |
179 |
sigc::mem_fun(*this, &MainWindow::on_action_add_instrument) |
sigc::mem_fun(*this, &MainWindow::on_action_add_instrument) |
180 |
); |
); |
181 |
actionGroup->add( |
actionGroup->add( |
182 |
|
Gtk::Action::create("DupInstrument", _("_Duplicate Instrument")), |
183 |
|
sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument) |
184 |
|
); |
185 |
|
actionGroup->add( |
186 |
Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE), |
Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE), |
187 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument) |
188 |
); |
); |
233 |
" <menu action='MenuView'>" |
" <menu action='MenuView'>" |
234 |
" <menuitem action='Statusbar'/>" |
" <menuitem action='Statusbar'/>" |
235 |
" </menu>" |
" </menu>" |
|
#ifdef ABOUT_DIALOG |
|
236 |
" <menu action='MenuHelp'>" |
" <menu action='MenuHelp'>" |
237 |
" <menuitem action='About'/>" |
" <menuitem action='About'/>" |
238 |
" </menu>" |
" </menu>" |
|
#endif |
|
239 |
" </menubar>" |
" </menubar>" |
240 |
" <popup name='PopupMenu'>" |
" <popup name='PopupMenu'>" |
241 |
" <menuitem action='InstrProperties'/>" |
" <menuitem action='InstrProperties'/>" |
242 |
" <menuitem action='AddInstrument'/>" |
" <menuitem action='AddInstrument'/>" |
243 |
|
" <menuitem action='DupInstrument'/>" |
244 |
" <separator/>" |
" <separator/>" |
245 |
" <menuitem action='RemoveInstrument'/>" |
" <menuitem action='RemoveInstrument'/>" |
246 |
" </popup>" |
" </popup>" |
265 |
m_VBox.pack_start(m_DimRegionChooser, Gtk::PACK_SHRINK); |
m_VBox.pack_start(m_DimRegionChooser, Gtk::PACK_SHRINK); |
266 |
m_VBox.pack_start(m_StatusBar, Gtk::PACK_SHRINK); |
m_VBox.pack_start(m_StatusBar, Gtk::PACK_SHRINK); |
267 |
|
|
268 |
|
set_file_is_shared(false); |
269 |
|
|
270 |
// Status Bar: |
// Status Bar: |
271 |
m_StatusBar.pack_start(m_AttachedStateLabel, Gtk::PACK_SHRINK); |
m_StatusBar.pack_start(m_AttachedStateLabel, Gtk::PACK_SHRINK); |
272 |
m_StatusBar.pack_start(m_AttachedStateImage, Gtk::PACK_SHRINK); |
m_StatusBar.pack_start(m_AttachedStateImage, Gtk::PACK_SHRINK); |
303 |
); |
); |
304 |
|
|
305 |
// establish drag&drop between samples tree view and dimension region 'Sample' text entry |
// establish drag&drop between samples tree view and dimension region 'Sample' text entry |
306 |
std::list<Gtk::TargetEntry> drag_target_gig_sample; |
std::vector<Gtk::TargetEntry> drag_target_gig_sample; |
307 |
drag_target_gig_sample.push_back( Gtk::TargetEntry("gig::Sample") ); |
drag_target_gig_sample.push_back(Gtk::TargetEntry("gig::Sample")); |
308 |
m_TreeViewSamples.drag_source_set(drag_target_gig_sample); |
m_TreeViewSamples.drag_source_set(drag_target_gig_sample); |
309 |
m_TreeViewSamples.signal_drag_begin().connect( |
m_TreeViewSamples.signal_drag_begin().connect( |
310 |
sigc::mem_fun(*this, &MainWindow::on_sample_treeview_drag_begin) |
sigc::mem_fun(*this, &MainWindow::on_sample_treeview_drag_begin) |
369 |
|
|
370 |
file = 0; |
file = 0; |
371 |
file_is_changed = false; |
file_is_changed = false; |
|
set_file_is_shared(false); |
|
372 |
|
|
373 |
show_all_children(); |
show_all_children(); |
374 |
|
|
472 |
void Loader::progress_callback(float fraction) |
void Loader::progress_callback(float fraction) |
473 |
{ |
{ |
474 |
{ |
{ |
475 |
Glib::Mutex::Lock lock(progressMutex); |
Glib::Threads::Mutex::Lock lock(progressMutex); |
476 |
progress = fraction; |
progress = fraction; |
477 |
} |
} |
478 |
progress_dispatcher(); |
progress_dispatcher(); |
480 |
|
|
481 |
void Loader::thread_function() |
void Loader::thread_function() |
482 |
{ |
{ |
483 |
printf("thread_function self=%x\n", Glib::Thread::self()); |
printf("thread_function self=%x\n", Glib::Threads::Thread::self()); |
484 |
printf("Start %s\n", filename); |
printf("Start %s\n", filename); |
485 |
RIFF::File* riff = new RIFF::File(filename); |
RIFF::File* riff = new RIFF::File(filename); |
486 |
gig = new gig::File(riff); |
gig = new gig::File(riff); |
494 |
} |
} |
495 |
|
|
496 |
Loader::Loader(const char* filename) |
Loader::Loader(const char* filename) |
497 |
: thread(0), filename(filename) |
: filename(filename), thread(0) |
498 |
{ |
{ |
499 |
} |
} |
500 |
|
|
501 |
void Loader::launch() |
void Loader::launch() |
502 |
{ |
{ |
503 |
|
#ifdef OLD_THREADS |
504 |
thread = Glib::Thread::create(sigc::mem_fun(*this, &Loader::thread_function), true); |
thread = Glib::Thread::create(sigc::mem_fun(*this, &Loader::thread_function), true); |
505 |
|
#else |
506 |
|
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Loader::thread_function)); |
507 |
|
#endif |
508 |
printf("launch thread=%x\n", thread); |
printf("launch thread=%x\n", thread); |
509 |
} |
} |
510 |
|
|
512 |
{ |
{ |
513 |
float res; |
float res; |
514 |
{ |
{ |
515 |
Glib::Mutex::Lock lock(progressMutex); |
Glib::Threads::Mutex::Lock lock(progressMutex); |
516 |
res = progress; |
res = progress; |
517 |
} |
} |
518 |
return res; |
return res; |
542 |
Gtk::MenuItem* instrument_menu = |
Gtk::MenuItem* instrument_menu = |
543 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuInstrument")); |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuInstrument")); |
544 |
instrument_menu->hide(); |
instrument_menu->hide(); |
545 |
for (int i = 0; i < instrument_menu->get_submenu()->items().size(); i++) { |
Gtk::Menu* menu = instrument_menu->get_submenu(); |
546 |
delete &instrument_menu->get_submenu()->items()[i]; |
while (menu->get_children().size()) { |
547 |
|
Gtk::Widget* child = *menu->get_children().begin(); |
548 |
|
menu->remove(*child); |
549 |
|
delete child; |
550 |
} |
} |
|
instrument_menu->get_submenu()->items().clear(); |
|
551 |
// forget all samples that ought to be imported |
// forget all samples that ought to be imported |
552 |
m_SampleImportQueue.clear(); |
m_SampleImportQueue.clear(); |
553 |
// clear the samples and instruments tree views |
// clear the samples and instruments tree views |
582 |
Glib::filename_display_basename(filename).c_str()); |
Glib::filename_display_basename(filename).c_str()); |
583 |
Gtk::MessageDialog dialog(*this, msg, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE); |
Gtk::MessageDialog dialog(*this, msg, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE); |
584 |
g_free(msg); |
g_free(msg); |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 6) || GTKMM_MAJOR_VERSION > 2 |
|
585 |
dialog.set_secondary_text(_("If you close without saving, your changes will be lost.")); |
dialog.set_secondary_text(_("If you close without saving, your changes will be lost.")); |
|
#endif |
|
586 |
dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO); |
dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO); |
587 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
588 |
dialog.add_button(file_has_name ? Gtk::Stock::SAVE : Gtk::Stock::SAVE_AS, Gtk::RESPONSE_YES); |
dialog.add_button(file_has_name ? Gtk::Stock::SAVE : Gtk::Stock::SAVE_AS, Gtk::RESPONSE_YES); |
596 |
bool MainWindow::leaving_shared_mode_dialog() { |
bool MainWindow::leaving_shared_mode_dialog() { |
597 |
Glib::ustring msg = _("Detach from sampler and proceed working stand-alone?"); |
Glib::ustring msg = _("Detach from sampler and proceed working stand-alone?"); |
598 |
Gtk::MessageDialog dialog(*this, msg, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE); |
Gtk::MessageDialog dialog(*this, msg, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE); |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 6) || GTKMM_MAJOR_VERSION > 2 |
|
599 |
dialog.set_secondary_text( |
dialog.set_secondary_text( |
600 |
_("If you proceed to work on another instrument file, it won't be " |
_("If you proceed to work on another instrument file, it won't be " |
601 |
"used by the sampler until you tell the sampler explicitly to " |
"used by the sampler until you tell the sampler explicitly to " |
602 |
"load it.") |
"load it.")); |
|
); |
|
|
#endif |
|
603 |
dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES); |
dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES); |
604 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
605 |
dialog.set_default_response(Gtk::RESPONSE_CANCEL); |
dialog.set_default_response(Gtk::RESPONSE_CANCEL); |
618 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
619 |
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); |
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); |
620 |
dialog.set_default_response(Gtk::RESPONSE_OK); |
dialog.set_default_response(Gtk::RESPONSE_OK); |
621 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
622 |
Gtk::FileFilter filter; |
Gtk::FileFilter filter; |
623 |
filter.add_pattern("*.gig"); |
filter.add_pattern("*.gig"); |
624 |
|
#else |
625 |
|
Glib::RefPtr<Gtk::FileFilter> filter = Gtk::FileFilter::create(); |
626 |
|
filter->add_pattern("*.gig"); |
627 |
|
#endif |
628 |
dialog.set_filter(filter); |
dialog.set_filter(filter); |
629 |
if (current_gig_dir != "") { |
if (current_gig_dir != "") { |
630 |
dialog.set_current_folder(current_gig_dir); |
dialog.set_current_folder(current_gig_dir); |
632 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
633 |
std::string filename = dialog.get_filename(); |
std::string filename = dialog.get_filename(); |
634 |
printf("filename=%s\n", filename.c_str()); |
printf("filename=%s\n", filename.c_str()); |
635 |
printf("on_action_file_open self=%x\n", Glib::Thread::self()); |
printf("on_action_file_open self=%x\n", Glib::Threads::Thread::self()); |
636 |
load_file(filename.c_str()); |
load_file(filename.c_str()); |
637 |
current_gig_dir = Glib::path_get_dirname(filename); |
current_gig_dir = Glib::path_get_dirname(filename); |
638 |
} |
} |
674 |
void MainWindow::on_loader_finished() |
void MainWindow::on_loader_finished() |
675 |
{ |
{ |
676 |
printf("Loader finished!\n"); |
printf("Loader finished!\n"); |
677 |
printf("on_loader_finished self=%x\n", Glib::Thread::self()); |
printf("on_loader_finished self=%x\n", Glib::Threads::Thread::self()); |
678 |
load_gig(loader->gig, loader->filename); |
load_gig(loader->gig, loader->filename); |
679 |
load_dialog->hide(); |
load_dialog->hide(); |
680 |
} |
} |
746 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
747 |
dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK); |
dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK); |
748 |
dialog.set_default_response(Gtk::RESPONSE_OK); |
dialog.set_default_response(Gtk::RESPONSE_OK); |
|
|
|
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 8) || GTKMM_MAJOR_VERSION > 2 |
|
749 |
dialog.set_do_overwrite_confirmation(); |
dialog.set_do_overwrite_confirmation(); |
750 |
// TODO: an overwrite dialog for gtkmm < 2.8 |
|
751 |
#endif |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
752 |
Gtk::FileFilter filter; |
Gtk::FileFilter filter; |
753 |
filter.add_pattern("*.gig"); |
filter.add_pattern("*.gig"); |
754 |
|
#else |
755 |
|
Glib::RefPtr<Gtk::FileFilter> filter = Gtk::FileFilter::create(); |
756 |
|
filter->add_pattern("*.gig"); |
757 |
|
#endif |
758 |
dialog.set_filter(filter); |
dialog.set_filter(filter); |
759 |
|
|
760 |
// set initial dir and filename of the Save As dialog |
// set initial dir and filename of the Save As dialog |
777 |
descriptionArea.set_spacing(15); |
descriptionArea.set_spacing(15); |
778 |
Gtk::Image warningIcon(Gtk::Stock::DIALOG_WARNING, Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); |
Gtk::Image warningIcon(Gtk::Stock::DIALOG_WARNING, Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); |
779 |
descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); |
descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); |
780 |
|
#if GTKMM_MAJOR_VERSION < 3 |
781 |
view::WrapLabel description; |
view::WrapLabel description; |
782 |
|
#else |
783 |
|
Gtk::Label description; |
784 |
|
description.set_line_wrap(); |
785 |
|
#endif |
786 |
description.set_markup( |
description.set_markup( |
787 |
_("\n<b>CAUTION:</b> You <b>MUST</b> use the " |
_("\n<b>CAUTION:</b> You <b>MUST</b> use the " |
788 |
"<span style=\"italic\">\"Save\"</span> dialog instead of " |
"<span style=\"italic\">\"Save\"</span> dialog instead of " |
894 |
} |
} |
895 |
// cleanup |
// cleanup |
896 |
sf_close(hFile); |
sf_close(hFile); |
897 |
|
// let the sampler re-cache the sample if needed |
898 |
|
sample_changed_signal.emit(iter->gig_sample); |
899 |
// on success we remove the sample from the import queue, |
// on success we remove the sample from the import queue, |
900 |
// otherwise keep it, maybe it works the next time ? |
// otherwise keep it, maybe it works the next time ? |
901 |
std::list<SampleImportItem>::iterator cur = iter; |
std::list<SampleImportItem>::iterator cur = iter; |
924 |
|
|
925 |
void MainWindow::on_action_help_about() |
void MainWindow::on_action_help_about() |
926 |
{ |
{ |
|
#ifdef ABOUT_DIALOG |
|
927 |
Gtk::AboutDialog dialog; |
Gtk::AboutDialog dialog; |
928 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 12) || GTKMM_MAJOR_VERSION > 2 |
929 |
|
dialog.set_program_name("Gigedit"); |
930 |
|
#else |
931 |
|
dialog.set_name("Gigedit"); |
932 |
|
#endif |
933 |
dialog.set_version(VERSION); |
dialog.set_version(VERSION); |
934 |
dialog.set_copyright("Copyright (C) 2006-2009 Andreas Persson"); |
dialog.set_copyright("Copyright (C) 2006-2013 Andreas Persson"); |
935 |
dialog.set_comments(_( |
dialog.set_comments(_( |
936 |
"Released under the GNU General Public License.\n" |
"Released under the GNU General Public License.\n" |
937 |
"\n" |
"\n" |
944 |
dialog.set_website("http://www.linuxsampler.org"); |
dialog.set_website("http://www.linuxsampler.org"); |
945 |
dialog.set_website_label("http://www.linuxsampler.org"); |
dialog.set_website_label("http://www.linuxsampler.org"); |
946 |
dialog.run(); |
dialog.run(); |
|
#endif |
|
947 |
} |
} |
948 |
|
|
949 |
PropDialog::PropDialog() |
PropDialog::PropDialog() |
950 |
: table(2,1), |
: eName(_("Name")), |
|
eName(_("Name")), |
|
951 |
eCreationDate(_("Creation date")), |
eCreationDate(_("Creation date")), |
952 |
eComments(_("Comments")), |
eComments(_("Comments")), |
953 |
eProduct(_("Product")), |
eProduct(_("Product")), |
964 |
eCommissioned(_("Commissioned")), |
eCommissioned(_("Commissioned")), |
965 |
eSubject(_("Subject")), |
eSubject(_("Subject")), |
966 |
quitButton(Gtk::Stock::CLOSE), |
quitButton(Gtk::Stock::CLOSE), |
967 |
|
table(2, 1), |
968 |
update_model(0) |
update_model(0) |
969 |
{ |
{ |
970 |
set_title(_("File Properties")); |
set_title(_("File Properties")); |
1013 |
buttonBox.set_border_width(5); |
buttonBox.set_border_width(5); |
1014 |
buttonBox.show(); |
buttonBox.show(); |
1015 |
buttonBox.pack_start(quitButton); |
buttonBox.pack_start(quitButton); |
1016 |
quitButton.set_flags(Gtk::CAN_DEFAULT); |
quitButton.set_can_default(); |
1017 |
quitButton.grab_focus(); |
quitButton.grab_focus(); |
1018 |
quitButton.signal_clicked().connect( |
quitButton.signal_clicked().connect( |
1019 |
sigc::mem_fun(*this, &PropDialog::hide)); |
sigc::mem_fun(*this, &PropDialog::hide)); |
1083 |
} |
} |
1084 |
|
|
1085 |
InstrumentProps::InstrumentProps() |
InstrumentProps::InstrumentProps() |
1086 |
: table(2,1), |
: update_model(0), |
1087 |
quitButton(Gtk::Stock::CLOSE), |
quitButton(Gtk::Stock::CLOSE), |
1088 |
|
table(2,1), |
1089 |
eName(_("Name")), |
eName(_("Name")), |
1090 |
eIsDrum(_("Is drum")), |
eIsDrum(_("Is drum")), |
1091 |
eMIDIBank(_("MIDI bank"), 0, 16383), |
eMIDIBank(_("MIDI bank"), 0, 16383), |
1097 |
ePitchbendRange(_("Pitchbend range"), 0, 12), |
ePitchbendRange(_("Pitchbend range"), 0, 12), |
1098 |
ePianoReleaseMode(_("Piano release mode")), |
ePianoReleaseMode(_("Piano release mode")), |
1099 |
eDimensionKeyRangeLow(_("Keyswitching range low")), |
eDimensionKeyRangeLow(_("Keyswitching range low")), |
1100 |
eDimensionKeyRangeHigh(_("Keyswitching range high")), |
eDimensionKeyRangeHigh(_("Keyswitching range high")) |
|
update_model(0) |
|
1101 |
{ |
{ |
1102 |
set_title(_("Instrument Properties")); |
set_title(_("Instrument Properties")); |
1103 |
|
|
1148 |
buttonBox.set_border_width(5); |
buttonBox.set_border_width(5); |
1149 |
buttonBox.show(); |
buttonBox.show(); |
1150 |
buttonBox.pack_start(quitButton); |
buttonBox.pack_start(quitButton); |
1151 |
quitButton.set_flags(Gtk::CAN_DEFAULT); |
quitButton.set_can_default(); |
1152 |
quitButton.grab_focus(); |
quitButton.grab_focus(); |
1153 |
|
|
1154 |
quitButton.signal_clicked().connect( |
quitButton.signal_clicked().connect( |
1333 |
file_changed(); |
file_changed(); |
1334 |
} |
} |
1335 |
|
|
1336 |
|
void MainWindow::on_action_duplicate_instrument() { |
1337 |
|
if (!file) return; |
1338 |
|
|
1339 |
|
// retrieve the currently selected instrument |
1340 |
|
// (being the original instrument to be duplicated) |
1341 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
1342 |
|
Gtk::TreeModel::iterator itSelection = sel->get_selected(); |
1343 |
|
if (!itSelection) return; |
1344 |
|
Gtk::TreeModel::Row row = *itSelection; |
1345 |
|
gig::Instrument* instrOrig = row[m_Columns.m_col_instr]; |
1346 |
|
if (!instrOrig) return; |
1347 |
|
|
1348 |
|
// duplicate the orginal instrument |
1349 |
|
gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); |
1350 |
|
instrNew->pInfo->Name = |
1351 |
|
instrOrig->pInfo->Name + " (" + _("Copy") + ")"; |
1352 |
|
|
1353 |
|
// update instrument tree view |
1354 |
|
Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append(); |
1355 |
|
Gtk::TreeModel::Row rowInstr = *iterInstr; |
1356 |
|
rowInstr[m_Columns.m_col_name] = instrNew->pInfo->Name.c_str(); |
1357 |
|
rowInstr[m_Columns.m_col_instr] = instrNew; |
1358 |
|
file_changed(); |
1359 |
|
} |
1360 |
|
|
1361 |
void MainWindow::on_action_remove_instrument() { |
void MainWindow::on_action_remove_instrument() { |
1362 |
if (!file) return; |
if (!file) return; |
1363 |
if (file_is_shared) { |
if (file_is_shared) { |
1435 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
1436 |
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); |
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); |
1437 |
dialog.set_select_multiple(true); |
dialog.set_select_multiple(true); |
1438 |
Gtk::FileFilter soundfilter; // matches all file types supported by libsndfile |
|
1439 |
|
// matches all file types supported by libsndfile |
1440 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
1441 |
|
Gtk::FileFilter soundfilter; |
1442 |
|
#else |
1443 |
|
Glib::RefPtr<Gtk::FileFilter> soundfilter = Gtk::FileFilter::create(); |
1444 |
|
#endif |
1445 |
const char* const supportedFileTypes[] = { |
const char* const supportedFileTypes[] = { |
1446 |
"*.wav", "*.WAV", "*.aiff", "*.AIFF", "*.aifc", "*.AIFC", "*.snd", |
"*.wav", "*.WAV", "*.aiff", "*.AIFF", "*.aifc", "*.AIFC", "*.snd", |
1447 |
"*.SND", "*.au", "*.AU", "*.paf", "*.PAF", "*.iff", "*.IFF", |
"*.SND", "*.au", "*.AU", "*.paf", "*.PAF", "*.iff", "*.IFF", |
1449 |
"*.W64", "*.pvf", "*.PVF", "*.xi", "*.XI", "*.htk", "*.HTK", |
"*.W64", "*.pvf", "*.PVF", "*.xi", "*.XI", "*.htk", "*.HTK", |
1450 |
"*.caf", "*.CAF", NULL |
"*.caf", "*.CAF", NULL |
1451 |
}; |
}; |
1452 |
|
const char* soundfiles = _("Sound Files"); |
1453 |
|
const char* allfiles = _("All Files"); |
1454 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
1455 |
for (int i = 0; supportedFileTypes[i]; i++) |
for (int i = 0; supportedFileTypes[i]; i++) |
1456 |
soundfilter.add_pattern(supportedFileTypes[i]); |
soundfilter.add_pattern(supportedFileTypes[i]); |
1457 |
soundfilter.set_name(_("Sound Files")); |
soundfilter.set_name(soundfiles); |
1458 |
Gtk::FileFilter allpassfilter; // matches every file |
|
1459 |
|
// matches every file |
1460 |
|
Gtk::FileFilter allpassfilter; |
1461 |
allpassfilter.add_pattern("*.*"); |
allpassfilter.add_pattern("*.*"); |
1462 |
allpassfilter.set_name(_("All Files")); |
allpassfilter.set_name(allfiles); |
1463 |
|
#else |
1464 |
|
for (int i = 0; supportedFileTypes[i]; i++) |
1465 |
|
soundfilter->add_pattern(supportedFileTypes[i]); |
1466 |
|
soundfilter->set_name(soundfiles); |
1467 |
|
|
1468 |
|
// matches every file |
1469 |
|
Glib::RefPtr<Gtk::FileFilter> allpassfilter = Gtk::FileFilter::create(); |
1470 |
|
allpassfilter->add_pattern("*.*"); |
1471 |
|
allpassfilter->set_name(allfiles); |
1472 |
|
#endif |
1473 |
dialog.add_filter(soundfilter); |
dialog.add_filter(soundfilter); |
1474 |
dialog.add_filter(allpassfilter); |
dialog.add_filter(allpassfilter); |
1475 |
if (current_sample_dir != "") { |
if (current_sample_dir != "") { |
1478 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
1479 |
current_sample_dir = dialog.get_current_folder(); |
current_sample_dir = dialog.get_current_folder(); |
1480 |
Glib::ustring error_files; |
Glib::ustring error_files; |
1481 |
Glib::SListHandle<Glib::ustring> filenames = dialog.get_filenames(); |
std::vector<std::string> filenames = dialog.get_filenames(); |
1482 |
for (Glib::SListHandle<Glib::ustring>::iterator iter = filenames.begin(); |
for (std::vector<std::string>::iterator iter = filenames.begin(); |
1483 |
iter != filenames.end(); ++iter) { |
iter != filenames.end(); ++iter) { |
1484 |
printf("Adding sample %s\n",(*iter).c_str()); |
printf("Adding sample %s\n",(*iter).c_str()); |
1485 |
// use libsndfile to retrieve file informations |
// use libsndfile to retrieve file informations |
1594 |
if (!file) return; |
if (!file) return; |
1595 |
Gtk::FileChooserDialog dialog(*this, _("Select Folder"), |
Gtk::FileChooserDialog dialog(*this, _("Select Folder"), |
1596 |
Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER); |
Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER); |
1597 |
view::WrapLabel description( |
const char* str = |
1598 |
_("This is a very specific function. It tries to replace all samples " |
_("This is a very specific function. It tries to replace all samples " |
1599 |
"in the current gig file by samples located in the chosen " |
"in the current gig file by samples located in the chosen " |
1600 |
"directory.\n\n" |
"directory.\n\n" |
1608 |
"the sample in the gig file accordingly. If you don't need an " |
"the sample in the gig file accordingly. If you don't need an " |
1609 |
"extension, blank the field below. Any gig sample where no " |
"extension, blank the field below. Any gig sample where no " |
1610 |
"appropriate sample file could be found will be reported and left " |
"appropriate sample file could be found will be reported and left " |
1611 |
"untouched.\n") |
"untouched.\n"); |
1612 |
); |
#if GTKMM_MAJOR_VERSION < 3 |
1613 |
|
view::WrapLabel description(str); |
1614 |
|
#else |
1615 |
|
Gtk::Label description(str); |
1616 |
|
description.set_line_wrap(); |
1617 |
|
#endif |
1618 |
Gtk::HBox entryArea; |
Gtk::HBox entryArea; |
1619 |
Gtk::Label entryLabel( _("Add filename extension: "), Gtk::ALIGN_RIGHT); |
Gtk::Label entryLabel( _("Add filename extension: "), Gtk::ALIGN_START); |
1620 |
Gtk::Entry postfixEntryBox; |
Gtk::Entry postfixEntryBox; |
1621 |
postfixEntryBox.set_text(".wav"); |
postfixEntryBox.set_text(".wav"); |
1622 |
entryArea.pack_start(entryLabel); |
entryArea.pack_start(entryLabel); |
1635 |
{ |
{ |
1636 |
current_sample_dir = dialog.get_current_folder(); |
current_sample_dir = dialog.get_current_folder(); |
1637 |
Glib::ustring error_files; |
Glib::ustring error_files; |
1638 |
Glib::ustring folder = dialog.get_filename(); |
std::string folder = dialog.get_filename(); |
1639 |
for (gig::Sample* sample = file->GetFirstSample(); |
for (gig::Sample* sample = file->GetFirstSample(); |
1640 |
sample; sample = file->GetNextSample()) |
sample; sample = file->GetNextSample()) |
1641 |
{ |
{ |
1936 |
return region_changed_signal; |
return region_changed_signal; |
1937 |
} |
} |
1938 |
|
|
1939 |
|
sigc::signal<void, gig::Sample*>& MainWindow::signal_sample_changed() { |
1940 |
|
return sample_changed_signal; |
1941 |
|
} |
1942 |
|
|
1943 |
sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& MainWindow::signal_sample_ref_changed() { |
sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& MainWindow::signal_sample_ref_changed() { |
1944 |
return sample_ref_changed_signal; |
return sample_ref_changed_signal; |
1945 |
} |
} |