192 |
actionGroup->add(toggle_action, |
actionGroup->add(toggle_action, |
193 |
sigc::mem_fun( |
sigc::mem_fun( |
194 |
*this, &MainWindow::on_action_view_status_bar)); |
*this, &MainWindow::on_action_view_status_bar)); |
195 |
|
|
196 |
|
toggle_action = |
197 |
|
Gtk::ToggleAction::create("AutoRestoreWinDim", _("_Auto Restore Window Dimension")); |
198 |
|
toggle_action->set_active(Settings::singleton()->autoRestoreWindowDimension); |
199 |
|
actionGroup->add(toggle_action, |
200 |
|
sigc::mem_fun( |
201 |
|
*this, &MainWindow::on_auto_restore_win_dim)); |
202 |
|
|
203 |
|
toggle_action = |
204 |
|
Gtk::ToggleAction::create("SaveWithTemporaryFile", _("Save with _temporary file")); |
205 |
|
toggle_action->set_active(Settings::singleton()->saveWithTemporaryFile); |
206 |
|
actionGroup->add(toggle_action, |
207 |
|
sigc::mem_fun( |
208 |
|
*this, &MainWindow::on_save_with_temporary_file)); |
209 |
|
|
210 |
actionGroup->add( |
actionGroup->add( |
211 |
Gtk::Action::create("RefreshAll", _("_Refresh All")), |
Gtk::Action::create("RefreshAll", _("_Refresh All")), |
212 |
sigc::mem_fun(*this, &MainWindow::on_action_refresh_all) |
sigc::mem_fun(*this, &MainWindow::on_action_refresh_all) |
379 |
" </menu>" |
" </menu>" |
380 |
" <menu action='MenuView'>" |
" <menu action='MenuView'>" |
381 |
" <menuitem action='Statusbar'/>" |
" <menuitem action='Statusbar'/>" |
382 |
|
" <menuitem action='AutoRestoreWinDim'/>" |
383 |
" <separator/>" |
" <separator/>" |
384 |
" <menuitem action='RefreshAll'/>" |
" <menuitem action='RefreshAll'/>" |
385 |
" </menu>" |
" </menu>" |
391 |
" <menuitem action='WarnUserOnExtensions'/>" |
" <menuitem action='WarnUserOnExtensions'/>" |
392 |
" <menuitem action='SyncSamplerInstrumentSelection'/>" |
" <menuitem action='SyncSamplerInstrumentSelection'/>" |
393 |
" <menuitem action='MoveRootNoteWithRegionMoved'/>" |
" <menuitem action='MoveRootNoteWithRegionMoved'/>" |
394 |
|
" <menuitem action='SaveWithTemporaryFile'/>" |
395 |
" </menu>" |
" </menu>" |
396 |
" <menu action='MenuHelp'>" |
" <menu action='MenuHelp'>" |
397 |
" <menuitem action='About'/>" |
" <menuitem action='About'/>" |
479 |
} |
} |
480 |
{ |
{ |
481 |
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
482 |
|
uiManager->get_widget("/MenuBar/MenuView/AutoRestoreWinDim")); |
483 |
|
item->set_tooltip_text(_("If checked, size and position of all windows will be saved and automatically restored next time.")); |
484 |
|
} |
485 |
|
{ |
486 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
487 |
uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments")); |
uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments")); |
488 |
item->set_tooltip_text(_("Create combi sounds out of individual sounds of this .gig file.")); |
item->set_tooltip_text(_("Create combi sounds out of individual sounds of this .gig file.")); |
489 |
} |
} |
521 |
// Create the Tree model: |
// Create the Tree model: |
522 |
m_refTreeModel = Gtk::ListStore::create(m_Columns); |
m_refTreeModel = Gtk::ListStore::create(m_Columns); |
523 |
m_TreeView.set_model(m_refTreeModel); |
m_TreeView.set_model(m_refTreeModel); |
524 |
|
m_TreeView.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE); |
525 |
m_TreeView.set_tooltip_text(_("Right click here for actions on instruments & MIDI Rules. Drag & drop to change the order of instruments.")); |
m_TreeView.set_tooltip_text(_("Right click here for actions on instruments & MIDI Rules. Drag & drop to change the order of instruments.")); |
526 |
instrument_name_connection = m_refTreeModel->signal_row_changed().connect( |
instrument_name_connection = m_refTreeModel->signal_row_changed().connect( |
527 |
sigc::mem_fun(*this, &MainWindow::instrument_name_changed) |
sigc::mem_fun(*this, &MainWindow::instrument_name_changed) |
528 |
); |
); |
529 |
|
|
530 |
// Add the TreeView's view columns: |
// Add the TreeView's view columns: |
531 |
m_TreeView.append_column_editable("Instrument", m_Columns.m_col_name); |
m_TreeView.append_column(_("Nr"), m_Columns.m_col_nr); |
532 |
m_TreeView.set_headers_visible(false); |
m_TreeView.append_column_editable(_("Instrument"), m_Columns.m_col_name); |
533 |
|
m_TreeView.set_headers_visible(true); |
534 |
|
|
535 |
// establish drag&drop within the instrument tree view, allowing to reorder |
// establish drag&drop within the instrument tree view, allowing to reorder |
536 |
// the sequence of instruments within the gig file |
// the sequence of instruments within the gig file |
553 |
// create samples treeview (including its data model) |
// create samples treeview (including its data model) |
554 |
m_refSamplesTreeModel = SamplesTreeStore::create(m_SamplesModel); |
m_refSamplesTreeModel = SamplesTreeStore::create(m_SamplesModel); |
555 |
m_TreeViewSamples.set_model(m_refSamplesTreeModel); |
m_TreeViewSamples.set_model(m_refSamplesTreeModel); |
556 |
|
m_TreeViewSamples.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE); |
557 |
m_TreeViewSamples.set_tooltip_text(_("To actually use a sample, drag it from this list view to \"Sample\" -> \"Sample:\" on the region's settings pane on the right.\n\nRight click here for more actions on samples.")); |
m_TreeViewSamples.set_tooltip_text(_("To actually use a sample, drag it from this list view to \"Sample\" -> \"Sample:\" on the region's settings pane on the right.\n\nRight click here for more actions on samples.")); |
558 |
// m_TreeViewSamples.set_reorderable(); |
// m_TreeViewSamples.set_reorderable(); |
559 |
m_TreeViewSamples.append_column_editable(_("Name"), m_SamplesModel.m_col_name); |
m_TreeViewSamples.append_column_editable(_("Name"), m_SamplesModel.m_col_name); |
731 |
gig::Instrument* MainWindow::get_instrument() |
gig::Instrument* MainWindow::get_instrument() |
732 |
{ |
{ |
733 |
gig::Instrument* instrument = 0; |
gig::Instrument* instrument = 0; |
734 |
Gtk::TreeModel::const_iterator it = |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
735 |
m_TreeView.get_selection()->get_selected(); |
if (rows.empty()) return NULL; |
736 |
|
Gtk::TreeModel::const_iterator it = m_refTreeModel->get_iter(rows[0]); |
737 |
if (it) { |
if (it) { |
738 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
739 |
instrument = row[m_Columns.m_col_instr]; |
instrument = row[m_Columns.m_col_instr]; |
793 |
void MainWindow::on_sel_change() |
void MainWindow::on_sel_change() |
794 |
{ |
{ |
795 |
// select item in instrument menu |
// select item in instrument menu |
796 |
Gtk::TreeModel::iterator it = m_TreeView.get_selection()->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
797 |
if (it) { |
if (!rows.empty()) { |
798 |
Gtk::TreePath path(it); |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
799 |
int index = path[0]; |
if (it) { |
800 |
const std::vector<Gtk::Widget*> children = |
Gtk::TreePath path(it); |
801 |
instrument_menu->get_children(); |
int index = path[0]; |
802 |
static_cast<Gtk::RadioMenuItem*>(children[index])->set_active(); |
const std::vector<Gtk::Widget*> children = |
803 |
|
instrument_menu->get_children(); |
804 |
|
static_cast<Gtk::RadioMenuItem*>(children[index])->set_active(); |
805 |
|
} |
806 |
} |
} |
807 |
|
|
808 |
m_RegionChooser.set_instrument(get_instrument()); |
m_RegionChooser.set_instrument(get_instrument()); |
918 |
|
|
919 |
// if no filename was provided, that means "save", if filename was provided means "save as" |
// if no filename was provided, that means "save", if filename was provided means "save as" |
920 |
if (filename.empty()) { |
if (filename.empty()) { |
921 |
gig->Save(&progress); |
if (!Settings::singleton()->saveWithTemporaryFile) { |
922 |
|
// save directly over the existing .gig file |
923 |
|
// (requires less disk space than solution below |
924 |
|
// but may be slower) |
925 |
|
gig->Save(&progress); |
926 |
|
} else { |
927 |
|
// save the file as separate temporary file first, |
928 |
|
// then move the saved file over the old file |
929 |
|
// (may result in performance speedup during save) |
930 |
|
String tmpname = filename + ".TMP"; |
931 |
|
gig->Save(tmpname, &progress); |
932 |
|
#if defined(WIN32) |
933 |
|
if (!DeleteFile(filename.c_str())) { |
934 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file)."); |
935 |
|
} |
936 |
|
#else // POSIX ... |
937 |
|
if (unlink(filename.c_str())) { |
938 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file): " + String(strerror(errno))); |
939 |
|
} |
940 |
|
#endif |
941 |
|
if (rename(tmpname.c_str(), filename.c_str())) { |
942 |
|
#if defined(WIN32) |
943 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file)."); |
944 |
|
#else |
945 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file): " + String(strerror(errno))); |
946 |
|
#endif |
947 |
|
} |
948 |
|
} |
949 |
} else { |
} else { |
950 |
gig->Save(filename, &progress); |
gig->Save(filename, &progress); |
951 |
} |
} |
1814 |
propDialog.set_info(gig->pInfo); |
propDialog.set_info(gig->pInfo); |
1815 |
|
|
1816 |
instrument_name_connection.block(); |
instrument_name_connection.block(); |
1817 |
|
int index = 0; |
1818 |
for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ; |
for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ; |
1819 |
instrument = gig->GetNextInstrument()) { |
instrument = gig->GetNextInstrument(), ++index) { |
1820 |
Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
1821 |
|
|
1822 |
Gtk::TreeModel::iterator iter = m_refTreeModel->append(); |
Gtk::TreeModel::iterator iter = m_refTreeModel->append(); |
1823 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
1824 |
|
row[m_Columns.m_col_nr] = index; |
1825 |
row[m_Columns.m_col_name] = name; |
row[m_Columns.m_col_name] = name; |
1826 |
row[m_Columns.m_col_instr] = instrument; |
row[m_Columns.m_col_instr] = instrument; |
1827 |
|
|
1894 |
{ |
{ |
1895 |
instrumentProps.signal_name_changed().clear(); |
instrumentProps.signal_name_changed().clear(); |
1896 |
|
|
1897 |
Gtk::TreeModel::const_iterator it = |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
1898 |
m_TreeView.get_selection()->get_selected(); |
if (rows.empty()) { |
1899 |
|
instrumentProps.hide(); |
1900 |
|
return false; |
1901 |
|
} |
1902 |
|
Gtk::TreeModel::const_iterator it = m_refTreeModel->get_iter(rows[0]); |
1903 |
if (it) { |
if (it) { |
1904 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
1905 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
1952 |
void MainWindow::show_script_slots() { |
void MainWindow::show_script_slots() { |
1953 |
if (!file) return; |
if (!file) return; |
1954 |
// get selected instrument |
// get selected instrument |
1955 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
1956 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
if (rows.empty()) return; |
1957 |
|
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
1958 |
if (!it) return; |
if (!it) return; |
1959 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
1960 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
1981 |
else m_StatusBar.hide(); |
else m_StatusBar.hide(); |
1982 |
} |
} |
1983 |
|
|
1984 |
|
void MainWindow::on_auto_restore_win_dim() { |
1985 |
|
Gtk::CheckMenuItem* item = |
1986 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/AutoRestoreWinDim")); |
1987 |
|
if (!item) { |
1988 |
|
std::cerr << "/MenuBar/MenuView/AutoRestoreWinDim == NULL\n"; |
1989 |
|
return; |
1990 |
|
} |
1991 |
|
Settings::singleton()->autoRestoreWindowDimension = item->get_active(); |
1992 |
|
} |
1993 |
|
|
1994 |
|
void MainWindow::on_save_with_temporary_file() { |
1995 |
|
Gtk::CheckMenuItem* item = |
1996 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuSettings/SaveWithTemporaryFile")); |
1997 |
|
if (!item) { |
1998 |
|
std::cerr << "/MenuBar/MenuSettings/SaveWithTemporaryFile == NULL\n"; |
1999 |
|
return; |
2000 |
|
} |
2001 |
|
Settings::singleton()->saveWithTemporaryFile = item->get_active(); |
2002 |
|
} |
2003 |
|
|
2004 |
bool MainWindow::is_copy_samples_unity_note_enabled() const { |
bool MainWindow::is_copy_samples_unity_note_enabled() const { |
2005 |
Gtk::CheckMenuItem* item = |
Gtk::CheckMenuItem* item = |
2006 |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity")); |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity")); |
2074 |
if (row[m_Columns.m_col_instr] == instrument) { |
if (row[m_Columns.m_col_instr] == instrument) { |
2075 |
// select and show the respective instrument in the list view |
// select and show the respective instrument in the list view |
2076 |
show_intruments_tab(); |
show_intruments_tab(); |
2077 |
|
m_TreeView.get_selection()->unselect_all(); |
2078 |
m_TreeView.get_selection()->select(model->children()[i]); |
m_TreeView.get_selection()->select(model->children()[i]); |
2079 |
Gtk::TreePath path( |
std::vector<Gtk::TreeModel::Path> rows = |
2080 |
m_TreeView.get_selection()->get_selected() |
m_TreeView.get_selection()->get_selected_rows(); |
2081 |
); |
if (!rows.empty()) |
2082 |
m_TreeView.scroll_to_row(path); |
m_TreeView.scroll_to_row(rows[0]); |
2083 |
on_sel_change(); // the regular instrument selection change callback |
on_sel_change(); // the regular instrument selection change callback |
2084 |
} |
} |
2085 |
} |
} |
2096 |
if (row[m_Columns.m_col_instr] == pInstrument) { |
if (row[m_Columns.m_col_instr] == pInstrument) { |
2097 |
// select and show the respective instrument in the list view |
// select and show the respective instrument in the list view |
2098 |
show_intruments_tab(); |
show_intruments_tab(); |
2099 |
|
m_TreeView.get_selection()->unselect_all(); |
2100 |
m_TreeView.get_selection()->select(model->children()[i]); |
m_TreeView.get_selection()->select(model->children()[i]); |
2101 |
Gtk::TreePath path( |
std::vector<Gtk::TreeModel::Path> rows = |
2102 |
m_TreeView.get_selection()->get_selected() |
m_TreeView.get_selection()->get_selected_rows(); |
2103 |
); |
if (!rows.empty()) |
2104 |
m_TreeView.scroll_to_row(path); |
m_TreeView.scroll_to_row(rows[0]); |
2105 |
on_sel_change(); // the regular instrument selection change callback |
on_sel_change(); // the regular instrument selection change callback |
2106 |
|
|
2107 |
// select respective region in the region selector |
// select respective region in the region selector |
2127 |
Gtk::TreeModel::Row rowSample = rowGroup.children()[s]; |
Gtk::TreeModel::Row rowSample = rowGroup.children()[s]; |
2128 |
if (rowSample[m_SamplesModel.m_col_sample] == sample) { |
if (rowSample[m_SamplesModel.m_col_sample] == sample) { |
2129 |
show_samples_tab(); |
show_samples_tab(); |
2130 |
|
m_TreeViewSamples.get_selection()->unselect_all(); |
2131 |
m_TreeViewSamples.get_selection()->select(rowGroup.children()[s]); |
m_TreeViewSamples.get_selection()->select(rowGroup.children()[s]); |
2132 |
Gtk::TreePath path( |
std::vector<Gtk::TreeModel::Path> rows = |
2133 |
m_TreeViewSamples.get_selection()->get_selected() |
m_TreeViewSamples.get_selection()->get_selected_rows(); |
2134 |
); |
if (rows.empty()) return; |
2135 |
m_TreeViewSamples.scroll_to_row(path); |
m_TreeViewSamples.scroll_to_row(rows[0]); |
2136 |
return; |
return; |
2137 |
} |
} |
2138 |
} |
} |
2141 |
|
|
2142 |
void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) { |
void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) { |
2143 |
if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
2144 |
|
// by default if Ctrl keys is pressed down, then a mouse right-click |
2145 |
|
// does not select the respective row, so we must assure this |
2146 |
|
// programmatically ... |
2147 |
|
/*{ |
2148 |
|
Gtk::TreeModel::Path path; |
2149 |
|
Gtk::TreeViewColumn* pColumn = NULL; |
2150 |
|
int cellX, cellY; |
2151 |
|
bool bSuccess = m_TreeViewSamples.get_path_at_pos( |
2152 |
|
(int)button->x, (int)button->y, |
2153 |
|
path, pColumn, cellX, cellY |
2154 |
|
); |
2155 |
|
if (bSuccess) { |
2156 |
|
if (m_TreeViewSamples.get_selection()->count_selected_rows() <= 0) { |
2157 |
|
printf("not selected !!!\n"); |
2158 |
|
m_TreeViewSamples.get_selection()->select(path); |
2159 |
|
} |
2160 |
|
} |
2161 |
|
}*/ |
2162 |
|
|
2163 |
Gtk::Menu* sample_popup = |
Gtk::Menu* sample_popup = |
2164 |
dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/SamplePopupMenu")); |
dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/SamplePopupMenu")); |
2165 |
// update enabled/disabled state of sample popup items |
// update enabled/disabled state of sample popup items |
2166 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
2167 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
2168 |
bool group_selected = false; |
const int n = rows.size(); |
2169 |
bool sample_selected = false; |
int nGroups = 0; |
2170 |
if (it) { |
int nSamples = 0; |
2171 |
|
for (int r = 0; r < n; ++r) { |
2172 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[r]); |
2173 |
|
if (!it) continue; |
2174 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
2175 |
group_selected = row[m_SamplesModel.m_col_group]; |
if (row[m_SamplesModel.m_col_group]) nGroups++; |
2176 |
sample_selected = row[m_SamplesModel.m_col_sample]; |
if (row[m_SamplesModel.m_col_sample]) nSamples++; |
2177 |
} |
} |
2178 |
|
|
|
|
|
2179 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))-> |
2180 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n == 1); |
2181 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))-> |
2182 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n); |
2183 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddGroup"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddGroup"))-> |
2184 |
set_sensitive(file); |
set_sensitive(file); |
2185 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/ShowSampleRefs"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/ShowSampleRefs"))-> |
2186 |
set_sensitive(sample_selected); |
set_sensitive(nSamples == 1); |
2187 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))-> |
2188 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n); |
2189 |
// show sample popup |
// show sample popup |
2190 |
sample_popup->popup(button->button, button->time); |
sample_popup->popup(button->button, button->time); |
2191 |
|
|
2192 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/SampleProperties"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/SampleProperties"))-> |
2193 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n == 1); |
2194 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddSample"))-> |
2195 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n); |
2196 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddGroup"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddGroup"))-> |
2197 |
set_sensitive(file); |
set_sensitive(file); |
2198 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/ShowSampleRefs"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/ShowSampleRefs"))-> |
2199 |
set_sensitive(sample_selected); |
set_sensitive(nSamples == 1); |
2200 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/RemoveSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/RemoveSample"))-> |
2201 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n); |
2202 |
} |
} |
2203 |
} |
} |
2204 |
|
|
2277 |
instrument_name_connection.block(); |
instrument_name_connection.block(); |
2278 |
Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append(); |
Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append(); |
2279 |
Gtk::TreeModel::Row rowInstr = *iterInstr; |
Gtk::TreeModel::Row rowInstr = *iterInstr; |
2280 |
|
rowInstr[m_Columns.m_col_nr] = m_refTreeModel->children().size() - 1; |
2281 |
rowInstr[m_Columns.m_col_name] = name; |
rowInstr[m_Columns.m_col_name] = name; |
2282 |
rowInstr[m_Columns.m_col_instr] = instrument; |
rowInstr[m_Columns.m_col_instr] = instrument; |
2283 |
instrument_name_connection.unblock(); |
instrument_name_connection.unblock(); |
2306 |
// retrieve the currently selected instrument |
// retrieve the currently selected instrument |
2307 |
// (being the original instrument to be duplicated) |
// (being the original instrument to be duplicated) |
2308 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
2309 |
Gtk::TreeModel::iterator itSelection = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
2310 |
if (!itSelection) return; |
for (int r = 0; r < rows.size(); ++r) { |
2311 |
Gtk::TreeModel::Row row = *itSelection; |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]); |
2312 |
gig::Instrument* instrOrig = row[m_Columns.m_col_instr]; |
if (it) { |
2313 |
if (!instrOrig) return; |
Gtk::TreeModel::Row row = *it; |
2314 |
|
gig::Instrument* instrOrig = row[m_Columns.m_col_instr]; |
2315 |
// duplicate the orginal instrument |
if (instrOrig) { |
2316 |
gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); |
// duplicate the orginal instrument |
2317 |
instrNew->pInfo->Name = |
gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); |
2318 |
instrOrig->pInfo->Name + |
instrNew->pInfo->Name = |
2319 |
gig_from_utf8(Glib::ustring(" (") + _("Copy") + ")"); |
instrOrig->pInfo->Name + |
2320 |
|
gig_from_utf8(Glib::ustring(" (") + _("Copy") + ")"); |
2321 |
|
|
2322 |
add_instrument(instrNew); |
add_instrument(instrNew); |
2323 |
|
} |
2324 |
|
} |
2325 |
|
} |
2326 |
} |
} |
2327 |
|
|
2328 |
void MainWindow::on_action_remove_instrument() { |
void MainWindow::on_action_remove_instrument() { |
2339 |
} |
} |
2340 |
|
|
2341 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
2342 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
2343 |
if (it) { |
for (int r = rows.size() - 1; r >= 0; --r) { |
2344 |
|
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]); |
2345 |
|
if (!it) continue; |
2346 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
2347 |
gig::Instrument* instr = row[m_Columns.m_col_instr]; |
gig::Instrument* instr = row[m_Columns.m_col_instr]; |
2348 |
try { |
try { |
2357 |
|
|
2358 |
// remove row from instruments tree view |
// remove row from instruments tree view |
2359 |
m_refTreeModel->erase(it); |
m_refTreeModel->erase(it); |
2360 |
|
// update "Nr" column of all instrument rows |
2361 |
|
{ |
2362 |
|
int index = 0; |
2363 |
|
for (Gtk::TreeModel::iterator it = m_refTreeModel->children().begin(); |
2364 |
|
it != m_refTreeModel->children().end(); ++it, ++index) |
2365 |
|
{ |
2366 |
|
Gtk::TreeModel::Row row = *it; |
2367 |
|
row[m_Columns.m_col_nr] = index; |
2368 |
|
} |
2369 |
|
} |
2370 |
|
|
2371 |
#if GTKMM_MAJOR_VERSION < 3 |
#if GTKMM_MAJOR_VERSION < 3 |
2372 |
// select another instrument (in gtk3 this is done |
// select another instrument (in gtk3 this is done |
2548 |
|
|
2549 |
// get selected group (and probably selected sample) |
// get selected group (and probably selected sample) |
2550 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
2551 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
2552 |
|
if (rows.empty()) return; |
2553 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]); |
2554 |
if (!it) return; |
if (!it) return; |
2555 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
2556 |
gig::Sample* sample = NULL; |
gig::Sample* sample = NULL; |
2833 |
void MainWindow::on_action_remove_sample() { |
void MainWindow::on_action_remove_sample() { |
2834 |
if (!file) return; |
if (!file) return; |
2835 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
2836 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
2837 |
if (it) { |
for (int r = rows.size() - 1; r >= 0; --r) { |
2838 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[r]); |
2839 |
|
if (!it) continue; |
2840 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
2841 |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
2842 |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
3015 |
gig::Instrument* src = NULL; |
gig::Instrument* src = NULL; |
3016 |
{ |
{ |
3017 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
3018 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
3019 |
if (it) { |
if (!rows.empty()) { |
3020 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
3021 |
src = row[m_Columns.m_col_instr]; |
if (it) { |
3022 |
|
Gtk::TreeModel::Row row = *it; |
3023 |
|
src = row[m_Columns.m_col_instr]; |
3024 |
|
} |
3025 |
} |
} |
3026 |
} |
} |
3027 |
if (!src) return; |
if (!src) return; |
3076 |
// get selected sample |
// get selected sample |
3077 |
gig::Sample* sample = NULL; |
gig::Sample* sample = NULL; |
3078 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
3079 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
3080 |
if (it) { |
if (!rows.empty()) { |
3081 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]); |
3082 |
sample = row[m_SamplesModel.m_col_sample]; |
if (it) { |
3083 |
|
Gtk::TreeModel::Row row = *it; |
3084 |
|
sample = row[m_SamplesModel.m_col_sample]; |
3085 |
|
} |
3086 |
} |
} |
3087 |
// pass the gig::Sample as pointer |
// pass the gig::Sample as pointer |
3088 |
selection_data.set(selection_data.get_target(), 0/*unused*/, (const guchar*)&sample, |
selection_data.set(selection_data.get_target(), 0/*unused*/, (const guchar*)&sample, |
3281 |
|
|
3282 |
void MainWindow::on_action_view_references() { |
void MainWindow::on_action_view_references() { |
3283 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
3284 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
3285 |
|
if (rows.empty()) return; |
3286 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]); |
3287 |
if (!it) return; |
if (!it) return; |
3288 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
3289 |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |