1 |
/* |
/* |
2 |
* Copyright (C) 2006-2015 Andreas Persson |
* Copyright (C) 2006-2017 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 <glibmmconfig.h> |
24 |
|
// threads.h must be included first to be able to build with |
25 |
|
// G_DISABLE_DEPRECATED |
26 |
|
#if (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION == 31 && GLIBMM_MICRO_VERSION >= 2) || \ |
27 |
|
(GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION > 31) || GLIBMM_MAJOR_VERSION > 2 |
28 |
|
#include <glibmm/threads.h> |
29 |
|
#endif |
30 |
|
|
31 |
#include <glibmm/convert.h> |
#include <glibmm/convert.h> |
32 |
#include <glibmm/dispatcher.h> |
#include <glibmm/dispatcher.h> |
33 |
#include <glibmm/miscutils.h> |
#include <glibmm/miscutils.h> |
35 |
#include <gtkmm/aboutdialog.h> |
#include <gtkmm/aboutdialog.h> |
36 |
#include <gtkmm/filechooserdialog.h> |
#include <gtkmm/filechooserdialog.h> |
37 |
#include <gtkmm/messagedialog.h> |
#include <gtkmm/messagedialog.h> |
|
#include <gtkmm/stock.h> |
|
38 |
#include <gtkmm/targetentry.h> |
#include <gtkmm/targetentry.h> |
39 |
#include <gtkmm/main.h> |
#include <gtkmm/main.h> |
40 |
#include <gtkmm/toggleaction.h> |
#include <gtkmm/toggleaction.h> |
57 |
#include "ReferencesView.h" |
#include "ReferencesView.h" |
58 |
#include "../../gfx/status_attached.xpm" |
#include "../../gfx/status_attached.xpm" |
59 |
#include "../../gfx/status_detached.xpm" |
#include "../../gfx/status_detached.xpm" |
60 |
|
#include "gfx/builtinpix.h" |
61 |
|
|
62 |
MainWindow::MainWindow() : |
MainWindow::MainWindow() : |
63 |
m_DimRegionChooser(*this), |
m_DimRegionChooser(*this), |
64 |
dimreg_label(_("Changes apply to:")), |
dimreg_label(_("Changes apply to:")), |
65 |
dimreg_all_regions(_("all regions")), |
dimreg_all_regions(_("all regions")), |
66 |
dimreg_all_dimregs(_("all dimension splits")), |
dimreg_all_dimregs(_("all dimension splits")), |
67 |
dimreg_stereo(_("both channels")) |
dimreg_stereo(_("both channels")), |
68 |
|
labelLegend(_("Legend:")), |
69 |
|
labelNoSample(_(" No Sample")), |
70 |
|
labelMissingSample(_(" Missing some Sample(s)")), |
71 |
|
labelLooped(_(" Looped")), |
72 |
|
labelSomeLoops(_(" Some Loop(s)")) |
73 |
{ |
{ |
74 |
|
loadBuiltInPix(); |
75 |
|
|
76 |
// set_border_width(5); |
// set_border_width(5); |
77 |
// set_default_size(400, 200); |
// set_default_size(400, 200); |
78 |
|
|
|
|
|
79 |
add(m_VBox); |
add(m_VBox); |
80 |
|
|
81 |
// Handle selection |
// Handle selection |
109 |
dimreg_hbox.add(dimreg_stereo); |
dimreg_hbox.add(dimreg_stereo); |
110 |
dimreg_vbox.add(dimreg_edit); |
dimreg_vbox.add(dimreg_edit); |
111 |
dimreg_vbox.pack_start(dimreg_hbox, Gtk::PACK_SHRINK); |
dimreg_vbox.pack_start(dimreg_hbox, Gtk::PACK_SHRINK); |
112 |
|
{ |
113 |
|
legend_hbox.add(labelLegend); |
114 |
|
|
115 |
|
imageNoSample.set(redDot); |
116 |
|
imageNoSample.set_alignment(Gtk::ALIGN_END); |
117 |
|
labelNoSample.set_alignment(Gtk::ALIGN_START); |
118 |
|
legend_hbox.add(imageNoSample); |
119 |
|
legend_hbox.add(labelNoSample); |
120 |
|
|
121 |
|
imageMissingSample.set(yellowDot); |
122 |
|
imageMissingSample.set_alignment(Gtk::ALIGN_END); |
123 |
|
labelMissingSample.set_alignment(Gtk::ALIGN_START); |
124 |
|
legend_hbox.add(imageMissingSample); |
125 |
|
legend_hbox.add(labelMissingSample); |
126 |
|
|
127 |
|
imageLooped.set(blackLoop); |
128 |
|
imageLooped.set_alignment(Gtk::ALIGN_END); |
129 |
|
labelLooped.set_alignment(Gtk::ALIGN_START); |
130 |
|
legend_hbox.add(imageLooped); |
131 |
|
legend_hbox.add(labelLooped); |
132 |
|
|
133 |
|
imageSomeLoops.set(grayLoop); |
134 |
|
imageSomeLoops.set_alignment(Gtk::ALIGN_END); |
135 |
|
labelSomeLoops.set_alignment(Gtk::ALIGN_START); |
136 |
|
legend_hbox.add(imageSomeLoops); |
137 |
|
legend_hbox.add(labelSomeLoops); |
138 |
|
|
139 |
|
legend_hbox.show_all_children(); |
140 |
|
} |
141 |
|
dimreg_vbox.pack_start(legend_hbox, Gtk::PACK_SHRINK); |
142 |
m_HPaned.add2(dimreg_vbox); |
m_HPaned.add2(dimreg_vbox); |
143 |
|
|
144 |
dimreg_label.set_tooltip_text(_("To automatically apply your changes above globally to the entire instrument, check all 3 check boxes on the right.")); |
dimreg_label.set_tooltip_text(_("To automatically apply your changes above globally to the entire instrument, check all 3 check boxes on the right.")); |
153 |
actionGroup = Gtk::ActionGroup::create(); |
actionGroup = Gtk::ActionGroup::create(); |
154 |
|
|
155 |
actionGroup->add(Gtk::Action::create("MenuFile", _("_File"))); |
actionGroup->add(Gtk::Action::create("MenuFile", _("_File"))); |
156 |
actionGroup->add(Gtk::Action::create("New", Gtk::Stock::NEW), |
actionGroup->add(Gtk::Action::create("New", _("_New")), |
157 |
|
Gtk::AccelKey("<control>n"), |
158 |
sigc::mem_fun( |
sigc::mem_fun( |
159 |
*this, &MainWindow::on_action_file_new)); |
*this, &MainWindow::on_action_file_new)); |
160 |
Glib::RefPtr<Gtk::Action> action = |
actionGroup->add(Gtk::Action::create("Open", _("_Open...")), |
161 |
Gtk::Action::create("Open", Gtk::Stock::OPEN); |
Gtk::AccelKey("<control>o"), |
|
action->property_label() = action->property_label() + "..."; |
|
|
actionGroup->add(action, |
|
162 |
sigc::mem_fun( |
sigc::mem_fun( |
163 |
*this, &MainWindow::on_action_file_open)); |
*this, &MainWindow::on_action_file_open)); |
164 |
actionGroup->add(Gtk::Action::create("Save", Gtk::Stock::SAVE), |
actionGroup->add(Gtk::Action::create("Save", _("_Save")), |
165 |
|
Gtk::AccelKey("<control>s"), |
166 |
sigc::mem_fun( |
sigc::mem_fun( |
167 |
*this, &MainWindow::on_action_file_save)); |
*this, &MainWindow::on_action_file_save)); |
168 |
action = Gtk::Action::create("SaveAs", Gtk::Stock::SAVE_AS); |
actionGroup->add(Gtk::Action::create("SaveAs", _("Save _As...")), |
|
action->property_label() = action->property_label() + "..."; |
|
|
actionGroup->add(action, |
|
169 |
Gtk::AccelKey("<shift><control>s"), |
Gtk::AccelKey("<shift><control>s"), |
170 |
sigc::mem_fun( |
sigc::mem_fun( |
171 |
*this, &MainWindow::on_action_file_save_as)); |
*this, &MainWindow::on_action_file_save_as)); |
172 |
actionGroup->add(Gtk::Action::create("Properties", |
actionGroup->add(Gtk::Action::create("Properties", |
173 |
Gtk::Stock::PROPERTIES), |
_("_Properties")), |
174 |
sigc::mem_fun( |
sigc::mem_fun( |
175 |
*this, &MainWindow::on_action_file_properties)); |
*this, &MainWindow::on_action_file_properties)); |
176 |
actionGroup->add(Gtk::Action::create("InstrProperties", |
actionGroup->add(Gtk::Action::create("InstrProperties", |
177 |
Gtk::Stock::PROPERTIES), |
_("_Properties")), |
178 |
sigc::mem_fun( |
sigc::mem_fun( |
179 |
*this, &MainWindow::show_instr_props)); |
*this, &MainWindow::show_instr_props)); |
180 |
actionGroup->add(Gtk::Action::create("MidiRules", |
actionGroup->add(Gtk::Action::create("MidiRules", |
185 |
_("_Script Slots...")), |
_("_Script Slots...")), |
186 |
sigc::mem_fun( |
sigc::mem_fun( |
187 |
*this, &MainWindow::show_script_slots)); |
*this, &MainWindow::show_script_slots)); |
188 |
actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT), |
actionGroup->add(Gtk::Action::create("Quit", _("_Quit")), |
189 |
|
Gtk::AccelKey("<control>q"), |
190 |
sigc::mem_fun( |
sigc::mem_fun( |
191 |
*this, &MainWindow::on_action_quit)); |
*this, &MainWindow::on_action_quit)); |
192 |
actionGroup->add( |
actionGroup->add( |
205 |
|
|
206 |
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); |
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); |
207 |
|
|
208 |
|
const Gdk::ModifierType primaryModifierKey = |
209 |
|
#if defined(__APPLE__) |
210 |
|
Gdk::META_MASK; // Cmd key on Mac |
211 |
|
#else |
212 |
|
Gdk::CONTROL_MASK; // Ctrl key on all other OSs |
213 |
|
#endif |
214 |
|
|
215 |
|
actionGroup->add(Gtk::Action::create("SelectPrevRegion", |
216 |
|
_("Select Previous Region")), |
217 |
|
Gtk::AccelKey(GDK_KEY_Left, primaryModifierKey), |
218 |
|
sigc::mem_fun(*this, &MainWindow::select_prev_region)); |
219 |
|
|
220 |
|
actionGroup->add(Gtk::Action::create("SelectNextRegion", |
221 |
|
_("Select Next Region")), |
222 |
|
Gtk::AccelKey(GDK_KEY_Right, primaryModifierKey), |
223 |
|
sigc::mem_fun(*this, &MainWindow::select_next_region)); |
224 |
|
|
225 |
|
actionGroup->add(Gtk::Action::create("SelectPrevDimRgnZone", |
226 |
|
_("Select Previous Dimension Region Zone")), |
227 |
|
Gtk::AccelKey(GDK_KEY_Left, Gdk::MOD1_MASK), |
228 |
|
sigc::mem_fun(*this, &MainWindow::select_prev_dim_rgn_zone)); |
229 |
|
|
230 |
|
actionGroup->add(Gtk::Action::create("SelectNextDimRgnZone", |
231 |
|
_("Select Next Dimension Region Zone")), |
232 |
|
Gtk::AccelKey(GDK_KEY_Right, Gdk::MOD1_MASK), |
233 |
|
sigc::mem_fun(*this, &MainWindow::select_next_dim_rgn_zone)); |
234 |
|
|
235 |
|
actionGroup->add(Gtk::Action::create("SelectPrevDimension", |
236 |
|
_("Select Previous Dimension")), |
237 |
|
Gtk::AccelKey(GDK_KEY_Up, Gdk::MOD1_MASK), |
238 |
|
sigc::mem_fun(*this, &MainWindow::select_prev_dimension)); |
239 |
|
|
240 |
|
actionGroup->add(Gtk::Action::create("SelectNextDimension", |
241 |
|
_("Select Next Dimension")), |
242 |
|
Gtk::AccelKey(GDK_KEY_Down, Gdk::MOD1_MASK), |
243 |
|
sigc::mem_fun(*this, &MainWindow::select_next_dimension)); |
244 |
|
|
245 |
|
actionGroup->add(Gtk::Action::create("SelectAddPrevDimRgnZone", |
246 |
|
_("Add Previous Dimension Region Zone to Selection")), |
247 |
|
Gtk::AccelKey(GDK_KEY_Left, Gdk::MOD1_MASK | Gdk::SHIFT_MASK), |
248 |
|
sigc::mem_fun(*this, &MainWindow::select_add_prev_dim_rgn_zone)); |
249 |
|
|
250 |
|
actionGroup->add(Gtk::Action::create("SelectAddNextDimRgnZone", |
251 |
|
_("Add Next Dimension Region Zone to Selection")), |
252 |
|
Gtk::AccelKey(GDK_KEY_Right, Gdk::MOD1_MASK | Gdk::SHIFT_MASK), |
253 |
|
sigc::mem_fun(*this, &MainWindow::select_add_next_dim_rgn_zone)); |
254 |
|
|
255 |
Glib::RefPtr<Gtk::ToggleAction> toggle_action = |
Glib::RefPtr<Gtk::ToggleAction> toggle_action = |
256 |
Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note")); |
Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note")); |
257 |
toggle_action->set_active(true); |
toggle_action->set_active(true); |
275 |
actionGroup->add(toggle_action, |
actionGroup->add(toggle_action, |
276 |
sigc::mem_fun( |
sigc::mem_fun( |
277 |
*this, &MainWindow::on_action_view_status_bar)); |
*this, &MainWindow::on_action_view_status_bar)); |
278 |
|
|
279 |
|
toggle_action = |
280 |
|
Gtk::ToggleAction::create("AutoRestoreWinDim", _("_Auto Restore Window Dimension")); |
281 |
|
toggle_action->set_active(Settings::singleton()->autoRestoreWindowDimension); |
282 |
|
actionGroup->add(toggle_action, |
283 |
|
sigc::mem_fun( |
284 |
|
*this, &MainWindow::on_auto_restore_win_dim)); |
285 |
|
|
286 |
|
toggle_action = |
287 |
|
Gtk::ToggleAction::create("SaveWithTemporaryFile", _("Save with _temporary file")); |
288 |
|
toggle_action->set_active(Settings::singleton()->saveWithTemporaryFile); |
289 |
|
actionGroup->add(toggle_action, |
290 |
|
sigc::mem_fun( |
291 |
|
*this, &MainWindow::on_save_with_temporary_file)); |
292 |
|
|
293 |
actionGroup->add( |
actionGroup->add( |
294 |
Gtk::Action::create("RefreshAll", _("_Refresh All")), |
Gtk::Action::create("RefreshAll", _("_Refresh All")), |
295 |
sigc::mem_fun(*this, &MainWindow::on_action_refresh_all) |
sigc::mem_fun(*this, &MainWindow::on_action_refresh_all) |
296 |
); |
); |
297 |
|
|
298 |
action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP); |
actionGroup->add(Gtk::Action::create("MenuHelp", _("_Help"))); |
299 |
actionGroup->add(Gtk::Action::create("MenuHelp", |
actionGroup->add(Gtk::Action::create("About", _("_About")), |
|
action->property_label())); |
|
|
actionGroup->add(Gtk::Action::create("About", Gtk::Stock::ABOUT), |
|
300 |
sigc::mem_fun( |
sigc::mem_fun( |
301 |
*this, &MainWindow::on_action_help_about)); |
*this, &MainWindow::on_action_help_about)); |
302 |
actionGroup->add( |
actionGroup->add( |
308 |
sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument) |
sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument) |
309 |
); |
); |
310 |
actionGroup->add( |
actionGroup->add( |
311 |
Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE), |
Gtk::Action::create("RemoveInstrument", _("_Remove")), |
312 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument) |
313 |
); |
); |
314 |
|
|
355 |
|
|
356 |
// sample right-click popup actions |
// sample right-click popup actions |
357 |
actionGroup->add( |
actionGroup->add( |
358 |
Gtk::Action::create("SampleProperties", Gtk::Stock::PROPERTIES), |
Gtk::Action::create("SampleProperties", _("_Properties")), |
359 |
sigc::mem_fun(*this, &MainWindow::on_action_sample_properties) |
sigc::mem_fun(*this, &MainWindow::on_action_sample_properties) |
360 |
); |
); |
361 |
actionGroup->add( |
actionGroup->add( |
367 |
sigc::mem_fun(*this, &MainWindow::on_action_add_sample) |
sigc::mem_fun(*this, &MainWindow::on_action_add_sample) |
368 |
); |
); |
369 |
actionGroup->add( |
actionGroup->add( |
370 |
Gtk::Action::create("RemoveSample", Gtk::Stock::REMOVE), |
Gtk::Action::create("RemoveSample", _("_Remove")), |
371 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_sample) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_sample) |
372 |
); |
); |
373 |
actionGroup->add( |
actionGroup->add( |
403 |
sigc::mem_fun(*this, &MainWindow::on_action_edit_script) |
sigc::mem_fun(*this, &MainWindow::on_action_edit_script) |
404 |
); |
); |
405 |
actionGroup->add( |
actionGroup->add( |
406 |
Gtk::Action::create("RemoveScript", Gtk::Stock::REMOVE), |
Gtk::Action::create("RemoveScript", _("_Remove")), |
407 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_script) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_script) |
408 |
); |
); |
409 |
|
|
426 |
" <menuitem action='Quit'/>" |
" <menuitem action='Quit'/>" |
427 |
" </menu>" |
" </menu>" |
428 |
" <menu action='MenuEdit'>" |
" <menu action='MenuEdit'>" |
429 |
|
" <menuitem action='SelectPrevRegion'/>" |
430 |
|
" <menuitem action='SelectNextRegion'/>" |
431 |
|
" <separator/>" |
432 |
|
" <menuitem action='SelectPrevDimension'/>" |
433 |
|
" <menuitem action='SelectNextDimension'/>" |
434 |
|
" <menuitem action='SelectPrevDimRgnZone'/>" |
435 |
|
" <menuitem action='SelectNextDimRgnZone'/>" |
436 |
|
" <menuitem action='SelectAddPrevDimRgnZone'/>" |
437 |
|
" <menuitem action='SelectAddNextDimRgnZone'/>" |
438 |
|
" <separator/>" |
439 |
" <menuitem action='CopySampleUnity'/>" |
" <menuitem action='CopySampleUnity'/>" |
440 |
" <menuitem action='CopySampleTune'/>" |
" <menuitem action='CopySampleTune'/>" |
441 |
" <menuitem action='CopySampleLoop'/>" |
" <menuitem action='CopySampleLoop'/>" |
472 |
" </menu>" |
" </menu>" |
473 |
" <menu action='MenuView'>" |
" <menu action='MenuView'>" |
474 |
" <menuitem action='Statusbar'/>" |
" <menuitem action='Statusbar'/>" |
475 |
|
" <menuitem action='AutoRestoreWinDim'/>" |
476 |
" <separator/>" |
" <separator/>" |
477 |
" <menuitem action='RefreshAll'/>" |
" <menuitem action='RefreshAll'/>" |
478 |
" </menu>" |
" </menu>" |
484 |
" <menuitem action='WarnUserOnExtensions'/>" |
" <menuitem action='WarnUserOnExtensions'/>" |
485 |
" <menuitem action='SyncSamplerInstrumentSelection'/>" |
" <menuitem action='SyncSamplerInstrumentSelection'/>" |
486 |
" <menuitem action='MoveRootNoteWithRegionMoved'/>" |
" <menuitem action='MoveRootNoteWithRegionMoved'/>" |
487 |
|
" <menuitem action='SaveWithTemporaryFile'/>" |
488 |
" </menu>" |
" </menu>" |
489 |
" <menu action='MenuHelp'>" |
" <menu action='MenuHelp'>" |
490 |
" <menuitem action='About'/>" |
" <menuitem action='About'/>" |
572 |
} |
} |
573 |
{ |
{ |
574 |
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
575 |
|
uiManager->get_widget("/MenuBar/MenuView/AutoRestoreWinDim")); |
576 |
|
item->set_tooltip_text(_("If checked, size and position of all windows will be saved and automatically restored next time.")); |
577 |
|
} |
578 |
|
{ |
579 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
580 |
uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments")); |
uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments")); |
581 |
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.")); |
582 |
} |
} |
614 |
// Create the Tree model: |
// Create the Tree model: |
615 |
m_refTreeModel = Gtk::ListStore::create(m_Columns); |
m_refTreeModel = Gtk::ListStore::create(m_Columns); |
616 |
m_TreeView.set_model(m_refTreeModel); |
m_TreeView.set_model(m_refTreeModel); |
617 |
|
m_TreeView.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE); |
618 |
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.")); |
619 |
instrument_name_connection = m_refTreeModel->signal_row_changed().connect( |
instrument_name_connection = m_refTreeModel->signal_row_changed().connect( |
620 |
sigc::mem_fun(*this, &MainWindow::instrument_name_changed) |
sigc::mem_fun(*this, &MainWindow::instrument_name_changed) |
621 |
); |
); |
622 |
|
|
623 |
// Add the TreeView's view columns: |
// Add the TreeView's view columns: |
624 |
m_TreeView.append_column_editable("Instrument", m_Columns.m_col_name); |
m_TreeView.append_column(_("Nr"), m_Columns.m_col_nr); |
625 |
m_TreeView.set_headers_visible(false); |
m_TreeView.append_column_editable(_("Instrument"), m_Columns.m_col_name); |
626 |
|
m_TreeView.set_headers_visible(true); |
627 |
|
|
628 |
// establish drag&drop within the instrument tree view, allowing to reorder |
// establish drag&drop within the instrument tree view, allowing to reorder |
629 |
// the sequence of instruments within the gig file |
// the sequence of instruments within the gig file |
646 |
// create samples treeview (including its data model) |
// create samples treeview (including its data model) |
647 |
m_refSamplesTreeModel = SamplesTreeStore::create(m_SamplesModel); |
m_refSamplesTreeModel = SamplesTreeStore::create(m_SamplesModel); |
648 |
m_TreeViewSamples.set_model(m_refSamplesTreeModel); |
m_TreeViewSamples.set_model(m_refSamplesTreeModel); |
649 |
|
m_TreeViewSamples.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE); |
650 |
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.")); |
651 |
// m_TreeViewSamples.set_reorderable(); |
// m_TreeViewSamples.set_reorderable(); |
652 |
m_TreeViewSamples.append_column_editable(_("Name"), m_SamplesModel.m_col_name); |
m_TreeViewSamples.append_column_editable(_("Name"), m_SamplesModel.m_col_name); |
824 |
gig::Instrument* MainWindow::get_instrument() |
gig::Instrument* MainWindow::get_instrument() |
825 |
{ |
{ |
826 |
gig::Instrument* instrument = 0; |
gig::Instrument* instrument = 0; |
827 |
Gtk::TreeModel::const_iterator it = |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
828 |
m_TreeView.get_selection()->get_selected(); |
if (rows.empty()) return NULL; |
829 |
|
Gtk::TreeModel::const_iterator it = m_refTreeModel->get_iter(rows[0]); |
830 |
if (it) { |
if (it) { |
831 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
832 |
instrument = row[m_Columns.m_col_instr]; |
instrument = row[m_Columns.m_col_instr]; |
869 |
add_region_to_dimregs(region, stereo, all_dimregs); |
add_region_to_dimregs(region, stereo, all_dimregs); |
870 |
} |
} |
871 |
} |
} |
872 |
|
|
873 |
|
m_DimRegionChooser.setModifyAllRegions(all_regions); |
874 |
|
m_DimRegionChooser.setModifyAllDimensionRegions(all_dimregs); |
875 |
|
m_DimRegionChooser.setModifyBothChannels(stereo); |
876 |
} |
} |
877 |
|
|
878 |
void MainWindow::dimreg_all_dimregs_toggled() |
void MainWindow::dimreg_all_dimregs_toggled() |
890 |
void MainWindow::on_sel_change() |
void MainWindow::on_sel_change() |
891 |
{ |
{ |
892 |
// select item in instrument menu |
// select item in instrument menu |
893 |
Gtk::TreeModel::iterator it = m_TreeView.get_selection()->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
894 |
if (it) { |
if (!rows.empty()) { |
895 |
Gtk::TreePath path(it); |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
896 |
int index = path[0]; |
if (it) { |
897 |
const std::vector<Gtk::Widget*> children = |
Gtk::TreePath path(it); |
898 |
instrument_menu->get_children(); |
int index = path[0]; |
899 |
static_cast<Gtk::RadioMenuItem*>(children[index])->set_active(); |
const std::vector<Gtk::Widget*> children = |
900 |
|
instrument_menu->get_children(); |
901 |
|
static_cast<Gtk::RadioMenuItem*>(children[index])->set_active(); |
902 |
|
} |
903 |
} |
} |
904 |
|
|
905 |
m_RegionChooser.set_instrument(get_instrument()); |
m_RegionChooser.set_instrument(get_instrument()); |
924 |
progress_dispatcher(); |
progress_dispatcher(); |
925 |
} |
} |
926 |
|
|
927 |
|
#if defined(WIN32) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) |
928 |
|
// make sure stack is 16-byte aligned for SSE instructions |
929 |
|
__attribute__((force_align_arg_pointer)) |
930 |
|
#endif |
931 |
void Loader::thread_function() |
void Loader::thread_function() |
932 |
{ |
{ |
933 |
printf("thread_function self=%x\n", Glib::Threads::Thread::self()); |
printf("thread_function self=%p\n", |
934 |
|
static_cast<void*>(Glib::Threads::Thread::self())); |
935 |
printf("Start %s\n", filename.c_str()); |
printf("Start %s\n", filename.c_str()); |
936 |
try { |
try { |
937 |
RIFF::File* riff = new RIFF::File(filename); |
RIFF::File* riff = new RIFF::File(filename); |
953 |
} |
} |
954 |
|
|
955 |
Loader::Loader(const char* filename) |
Loader::Loader(const char* filename) |
956 |
: filename(filename), thread(0), progress(0.f) |
: filename(filename), gig(0), thread(0), progress(0.f) |
957 |
{ |
{ |
958 |
} |
} |
959 |
|
|
964 |
#else |
#else |
965 |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Loader::thread_function)); |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Loader::thread_function)); |
966 |
#endif |
#endif |
967 |
printf("launch thread=%x\n", thread); |
printf("launch thread=%p\n", static_cast<void*>(thread)); |
968 |
} |
} |
969 |
|
|
970 |
float Loader::get_progress() |
float Loader::get_progress() |
1007 |
progress_dispatcher.emit(); |
progress_dispatcher.emit(); |
1008 |
} |
} |
1009 |
|
|
1010 |
|
#if defined(WIN32) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) |
1011 |
|
// make sure stack is 16-byte aligned for SSE instructions |
1012 |
|
__attribute__((force_align_arg_pointer)) |
1013 |
|
#endif |
1014 |
void Saver::thread_function() |
void Saver::thread_function() |
1015 |
{ |
{ |
1016 |
printf("thread_function self=%x\n", Glib::Threads::Thread::self()); |
printf("thread_function self=%p\n", |
1017 |
|
static_cast<void*>(Glib::Threads::Thread::self())); |
1018 |
printf("Start %s\n", filename.c_str()); |
printf("Start %s\n", filename.c_str()); |
1019 |
try { |
try { |
1020 |
gig::progress_t progress; |
gig::progress_t progress; |
1023 |
|
|
1024 |
// 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" |
1025 |
if (filename.empty()) { |
if (filename.empty()) { |
1026 |
gig->Save(&progress); |
if (!Settings::singleton()->saveWithTemporaryFile) { |
1027 |
|
// save directly over the existing .gig file |
1028 |
|
// (requires less disk space than solution below |
1029 |
|
// but may be slower) |
1030 |
|
gig->Save(&progress); |
1031 |
|
} else { |
1032 |
|
// save the file as separate temporary file first, |
1033 |
|
// then move the saved file over the old file |
1034 |
|
// (may result in performance speedup during save) |
1035 |
|
String tmpname = filename + ".TMP"; |
1036 |
|
gig->Save(tmpname, &progress); |
1037 |
|
#if defined(WIN32) |
1038 |
|
if (!DeleteFile(filename.c_str())) { |
1039 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file)."); |
1040 |
|
} |
1041 |
|
#else // POSIX ... |
1042 |
|
if (unlink(filename.c_str())) { |
1043 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file): " + String(strerror(errno))); |
1044 |
|
} |
1045 |
|
#endif |
1046 |
|
if (rename(tmpname.c_str(), filename.c_str())) { |
1047 |
|
#if defined(WIN32) |
1048 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file)."); |
1049 |
|
#else |
1050 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file): " + String(strerror(errno))); |
1051 |
|
#endif |
1052 |
|
} |
1053 |
|
} |
1054 |
} else { |
} else { |
1055 |
gig->Save(filename, &progress); |
gig->Save(filename, &progress); |
1056 |
} |
} |
1078 |
#else |
#else |
1079 |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Saver::thread_function)); |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Saver::thread_function)); |
1080 |
#endif |
#endif |
1081 |
printf("launch thread=%x\n", thread); |
printf("launch thread=%p\n", static_cast<void*>(thread)); |
1082 |
} |
} |
1083 |
|
|
1084 |
float Saver::get_progress() |
float Saver::get_progress() |
1175 |
g_free(msg); |
g_free(msg); |
1176 |
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.")); |
1177 |
dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO); |
dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO); |
1178 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
1179 |
dialog.add_button(file_has_name ? Gtk::Stock::SAVE : Gtk::Stock::SAVE_AS, Gtk::RESPONSE_YES); |
dialog.add_button(file_has_name ? _("_Save") : _("Save _As"), Gtk::RESPONSE_YES); |
1180 |
dialog.set_default_response(Gtk::RESPONSE_YES); |
dialog.set_default_response(Gtk::RESPONSE_YES); |
1181 |
int response = dialog.run(); |
int response = dialog.run(); |
1182 |
dialog.hide(); |
dialog.hide(); |
1207 |
"used by the sampler until you tell the sampler explicitly to " |
"used by the sampler until you tell the sampler explicitly to " |
1208 |
"load it.")); |
"load it.")); |
1209 |
dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES); |
dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES); |
1210 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
1211 |
dialog.set_default_response(Gtk::RESPONSE_CANCEL); |
dialog.set_default_response(Gtk::RESPONSE_CANCEL); |
1212 |
int response = dialog.run(); |
int response = dialog.run(); |
1213 |
dialog.hide(); |
dialog.hide(); |
1221 |
if (file_is_shared && !leaving_shared_mode_dialog()) return; |
if (file_is_shared && !leaving_shared_mode_dialog()) return; |
1222 |
|
|
1223 |
Gtk::FileChooserDialog dialog(*this, _("Open file")); |
Gtk::FileChooserDialog dialog(*this, _("Open file")); |
1224 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
1225 |
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); |
dialog.add_button(_("_Open"), Gtk::RESPONSE_OK); |
1226 |
dialog.set_default_response(Gtk::RESPONSE_OK); |
dialog.set_default_response(Gtk::RESPONSE_OK); |
1227 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
1228 |
Gtk::FileFilter filter; |
Gtk::FileFilter filter; |
1238 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
1239 |
std::string filename = dialog.get_filename(); |
std::string filename = dialog.get_filename(); |
1240 |
printf("filename=%s\n", filename.c_str()); |
printf("filename=%s\n", filename.c_str()); |
1241 |
printf("on_action_file_open self=%x\n", Glib::Threads::Thread::self()); |
printf("on_action_file_open self=%p\n", |
1242 |
|
static_cast<void*>(Glib::Threads::Thread::self())); |
1243 |
load_file(filename.c_str()); |
load_file(filename.c_str()); |
1244 |
current_gig_dir = Glib::path_get_dirname(filename); |
current_gig_dir = Glib::path_get_dirname(filename); |
1245 |
} |
} |
1309 |
void MainWindow::on_loader_finished() |
void MainWindow::on_loader_finished() |
1310 |
{ |
{ |
1311 |
printf("Loader finished!\n"); |
printf("Loader finished!\n"); |
1312 |
printf("on_loader_finished self=%x\n", Glib::Threads::Thread::self()); |
printf("on_loader_finished self=%p\n", |
1313 |
|
static_cast<void*>(Glib::Threads::Thread::self())); |
1314 |
load_gig(loader->gig, loader->filename.c_str()); |
load_gig(loader->gig, loader->filename.c_str()); |
1315 |
progress_dialog->hide(); |
progress_dialog->hide(); |
1316 |
} |
} |
1417 |
|
|
1418 |
bool MainWindow::file_save_as() |
bool MainWindow::file_save_as() |
1419 |
{ |
{ |
1420 |
Gtk::FileChooserDialog dialog(*this, _("Save as"), Gtk::FILE_CHOOSER_ACTION_SAVE); |
Gtk::FileChooserDialog dialog(*this, _("Save As"), Gtk::FILE_CHOOSER_ACTION_SAVE); |
1421 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
1422 |
dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK); |
dialog.add_button(_("_Save"), Gtk::RESPONSE_OK); |
1423 |
dialog.set_default_response(Gtk::RESPONSE_OK); |
dialog.set_default_response(Gtk::RESPONSE_OK); |
1424 |
dialog.set_do_overwrite_confirmation(); |
dialog.set_do_overwrite_confirmation(); |
1425 |
|
|
1450 |
// show warning in the dialog |
// show warning in the dialog |
1451 |
Gtk::HBox descriptionArea; |
Gtk::HBox descriptionArea; |
1452 |
descriptionArea.set_spacing(15); |
descriptionArea.set_spacing(15); |
1453 |
Gtk::Image warningIcon(Gtk::Stock::DIALOG_WARNING, Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); |
Gtk::Image warningIcon; |
1454 |
|
warningIcon.set_from_icon_name("dialog-warning", |
1455 |
|
Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); |
1456 |
descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); |
descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); |
1457 |
#if GTKMM_MAJOR_VERSION < 3 |
#if GTKMM_MAJOR_VERSION < 3 |
1458 |
view::WrapLabel description; |
view::WrapLabel description; |
1504 |
void MainWindow::__import_queued_samples() { |
void MainWindow::__import_queued_samples() { |
1505 |
std::cout << "Starting sample import\n" << std::flush; |
std::cout << "Starting sample import\n" << std::flush; |
1506 |
Glib::ustring error_files; |
Glib::ustring error_files; |
1507 |
printf("Samples to import: %d\n", m_SampleImportQueue.size()); |
printf("Samples to import: %d\n", int(m_SampleImportQueue.size())); |
1508 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
for (std::map<gig::Sample*, SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
1509 |
iter != m_SampleImportQueue.end(); ) { |
iter != m_SampleImportQueue.end(); ) { |
1510 |
printf("Importing sample %s\n",(*iter).sample_path.c_str()); |
printf("Importing sample %s\n",iter->second.sample_path.c_str()); |
1511 |
SF_INFO info; |
SF_INFO info; |
1512 |
info.format = 0; |
info.format = 0; |
1513 |
SNDFILE* hFile = sf_open((*iter).sample_path.c_str(), SFM_READ, &info); |
SNDFILE* hFile = sf_open(iter->second.sample_path.c_str(), SFM_READ, &info); |
1514 |
sf_command(hFile, SFC_SET_SCALE_FLOAT_INT_READ, 0, SF_TRUE); |
sf_command(hFile, SFC_SET_SCALE_FLOAT_INT_READ, 0, SF_TRUE); |
1515 |
try { |
try { |
1516 |
if (!hFile) throw std::string(_("could not open file")); |
if (!hFile) throw std::string(_("could not open file")); |
1533 |
throw std::string(_("format not supported")); // unsupported subformat (yet?) |
throw std::string(_("format not supported")); // unsupported subformat (yet?) |
1534 |
} |
} |
1535 |
|
|
1536 |
|
// reset write position for sample |
1537 |
|
iter->first->SetPos(0); |
1538 |
|
|
1539 |
const int bufsize = 10000; |
const int bufsize = 10000; |
1540 |
switch (bitdepth) { |
switch (bitdepth) { |
1541 |
case 16: { |
case 16: { |
1545 |
// libsndfile does the conversion for us (if needed) |
// libsndfile does the conversion for us (if needed) |
1546 |
int n = sf_readf_short(hFile, buffer, bufsize); |
int n = sf_readf_short(hFile, buffer, bufsize); |
1547 |
// write from buffer directly (physically) into .gig file |
// write from buffer directly (physically) into .gig file |
1548 |
iter->gig_sample->Write(buffer, n); |
iter->first->Write(buffer, n); |
1549 |
cnt -= n; |
cnt -= n; |
1550 |
} |
} |
1551 |
delete[] buffer; |
delete[] buffer; |
1565 |
dstbuf[j++] = srcbuf[i] >> 24; |
dstbuf[j++] = srcbuf[i] >> 24; |
1566 |
} |
} |
1567 |
// write from buffer directly (physically) into .gig file |
// write from buffer directly (physically) into .gig file |
1568 |
iter->gig_sample->Write(dstbuf, n); |
iter->first->Write(dstbuf, n); |
1569 |
cnt -= n; |
cnt -= n; |
1570 |
} |
} |
1571 |
delete[] srcbuf; |
delete[] srcbuf; |
1576 |
// cleanup |
// cleanup |
1577 |
sf_close(hFile); |
sf_close(hFile); |
1578 |
// let the sampler re-cache the sample if needed |
// let the sampler re-cache the sample if needed |
1579 |
sample_changed_signal.emit(iter->gig_sample); |
sample_changed_signal.emit(iter->first); |
1580 |
// on success we remove the sample from the import queue, |
// on success we remove the sample from the import queue, |
1581 |
// otherwise keep it, maybe it works the next time ? |
// otherwise keep it, maybe it works the next time ? |
1582 |
std::list<SampleImportItem>::iterator cur = iter; |
std::map<gig::Sample*, SampleImportItem>::iterator cur = iter; |
1583 |
++iter; |
++iter; |
1584 |
m_SampleImportQueue.erase(cur); |
m_SampleImportQueue.erase(cur); |
1585 |
} catch (std::string what) { |
} catch (std::string what) { |
1586 |
// remember the files that made trouble (and their cause) |
// remember the files that made trouble (and their cause) |
1587 |
if (!error_files.empty()) error_files += "\n"; |
if (!error_files.empty()) error_files += "\n"; |
1588 |
error_files += (*iter).sample_path += " (" + what + ")"; |
error_files += iter->second.sample_path += " (" + what + ")"; |
1589 |
++iter; |
++iter; |
1590 |
} |
} |
1591 |
} |
} |
1627 |
dialog.set_name("Gigedit"); |
dialog.set_name("Gigedit"); |
1628 |
#endif |
#endif |
1629 |
dialog.set_version(VERSION); |
dialog.set_version(VERSION); |
1630 |
dialog.set_copyright("Copyright (C) 2006-2015 Andreas Persson"); |
dialog.set_copyright("Copyright (C) 2006-2017 Andreas Persson"); |
1631 |
const std::string sComment = |
const std::string sComment = |
1632 |
_("Built " __DATE__ "\nUsing ") + |
_("Built " __DATE__ "\nUsing ") + |
1633 |
::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" + |
::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" + |
1664 |
eSourceForm(_("Source form")), |
eSourceForm(_("Source form")), |
1665 |
eCommissioned(_("Commissioned")), |
eCommissioned(_("Commissioned")), |
1666 |
eSubject(_("Subject")), |
eSubject(_("Subject")), |
1667 |
quitButton(Gtk::Stock::CLOSE), |
quitButton(_("_Close"), true), |
1668 |
table(2, 1), |
table(2, 1), |
1669 |
m_file(NULL) |
m_file(NULL) |
1670 |
{ |
{ |
1787 |
} |
} |
1788 |
|
|
1789 |
InstrumentProps::InstrumentProps() : |
InstrumentProps::InstrumentProps() : |
1790 |
quitButton(Gtk::Stock::CLOSE), |
quitButton(_("_Close"), true), |
1791 |
table(2,1), |
table(2,1), |
1792 |
eName(_("Name")), |
eName(_("Name")), |
1793 |
eIsDrum(_("Is drum")), |
eIsDrum(_("Is drum")), |
1922 |
propDialog.set_info(gig->pInfo); |
propDialog.set_info(gig->pInfo); |
1923 |
|
|
1924 |
instrument_name_connection.block(); |
instrument_name_connection.block(); |
1925 |
|
int index = 0; |
1926 |
for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ; |
for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ; |
1927 |
instrument = gig->GetNextInstrument()) { |
instrument = gig->GetNextInstrument(), ++index) { |
1928 |
Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
1929 |
|
|
1930 |
Gtk::TreeModel::iterator iter = m_refTreeModel->append(); |
Gtk::TreeModel::iterator iter = m_refTreeModel->append(); |
1931 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
1932 |
|
row[m_Columns.m_col_nr] = index; |
1933 |
row[m_Columns.m_col_name] = name; |
row[m_Columns.m_col_name] = name; |
1934 |
row[m_Columns.m_col_instr] = instrument; |
row[m_Columns.m_col_instr] = instrument; |
1935 |
|
|
2002 |
{ |
{ |
2003 |
instrumentProps.signal_name_changed().clear(); |
instrumentProps.signal_name_changed().clear(); |
2004 |
|
|
2005 |
Gtk::TreeModel::const_iterator it = |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
2006 |
m_TreeView.get_selection()->get_selected(); |
if (rows.empty()) { |
2007 |
|
instrumentProps.hide(); |
2008 |
|
return false; |
2009 |
|
} |
2010 |
|
Gtk::TreeModel::const_iterator it = m_refTreeModel->get_iter(rows[0]); |
2011 |
if (it) { |
if (it) { |
2012 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
2013 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
2060 |
void MainWindow::show_script_slots() { |
void MainWindow::show_script_slots() { |
2061 |
if (!file) return; |
if (!file) return; |
2062 |
// get selected instrument |
// get selected instrument |
2063 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
2064 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
if (rows.empty()) return; |
2065 |
|
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
2066 |
if (!it) return; |
if (!it) return; |
2067 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
2068 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
2089 |
else m_StatusBar.hide(); |
else m_StatusBar.hide(); |
2090 |
} |
} |
2091 |
|
|
2092 |
|
void MainWindow::on_auto_restore_win_dim() { |
2093 |
|
Gtk::CheckMenuItem* item = |
2094 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/AutoRestoreWinDim")); |
2095 |
|
if (!item) { |
2096 |
|
std::cerr << "/MenuBar/MenuView/AutoRestoreWinDim == NULL\n"; |
2097 |
|
return; |
2098 |
|
} |
2099 |
|
Settings::singleton()->autoRestoreWindowDimension = item->get_active(); |
2100 |
|
} |
2101 |
|
|
2102 |
|
void MainWindow::on_save_with_temporary_file() { |
2103 |
|
Gtk::CheckMenuItem* item = |
2104 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuSettings/SaveWithTemporaryFile")); |
2105 |
|
if (!item) { |
2106 |
|
std::cerr << "/MenuBar/MenuSettings/SaveWithTemporaryFile == NULL\n"; |
2107 |
|
return; |
2108 |
|
} |
2109 |
|
Settings::singleton()->saveWithTemporaryFile = item->get_active(); |
2110 |
|
} |
2111 |
|
|
2112 |
bool MainWindow::is_copy_samples_unity_note_enabled() const { |
bool MainWindow::is_copy_samples_unity_note_enabled() const { |
2113 |
Gtk::CheckMenuItem* item = |
Gtk::CheckMenuItem* item = |
2114 |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity")); |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity")); |
2182 |
if (row[m_Columns.m_col_instr] == instrument) { |
if (row[m_Columns.m_col_instr] == instrument) { |
2183 |
// select and show the respective instrument in the list view |
// select and show the respective instrument in the list view |
2184 |
show_intruments_tab(); |
show_intruments_tab(); |
2185 |
|
m_TreeView.get_selection()->unselect_all(); |
2186 |
m_TreeView.get_selection()->select(model->children()[i]); |
m_TreeView.get_selection()->select(model->children()[i]); |
2187 |
Gtk::TreePath path( |
std::vector<Gtk::TreeModel::Path> rows = |
2188 |
m_TreeView.get_selection()->get_selected() |
m_TreeView.get_selection()->get_selected_rows(); |
2189 |
); |
if (!rows.empty()) |
2190 |
m_TreeView.scroll_to_row(path); |
m_TreeView.scroll_to_row(rows[0]); |
2191 |
on_sel_change(); // the regular instrument selection change callback |
on_sel_change(); // the regular instrument selection change callback |
2192 |
} |
} |
2193 |
} |
} |
2204 |
if (row[m_Columns.m_col_instr] == pInstrument) { |
if (row[m_Columns.m_col_instr] == pInstrument) { |
2205 |
// select and show the respective instrument in the list view |
// select and show the respective instrument in the list view |
2206 |
show_intruments_tab(); |
show_intruments_tab(); |
2207 |
|
m_TreeView.get_selection()->unselect_all(); |
2208 |
m_TreeView.get_selection()->select(model->children()[i]); |
m_TreeView.get_selection()->select(model->children()[i]); |
2209 |
Gtk::TreePath path( |
std::vector<Gtk::TreeModel::Path> rows = |
2210 |
m_TreeView.get_selection()->get_selected() |
m_TreeView.get_selection()->get_selected_rows(); |
2211 |
); |
if (!rows.empty()) |
2212 |
m_TreeView.scroll_to_row(path); |
m_TreeView.scroll_to_row(rows[0]); |
2213 |
on_sel_change(); // the regular instrument selection change callback |
on_sel_change(); // the regular instrument selection change callback |
2214 |
|
|
2215 |
// select respective region in the region selector |
// select respective region in the region selector |
2235 |
Gtk::TreeModel::Row rowSample = rowGroup.children()[s]; |
Gtk::TreeModel::Row rowSample = rowGroup.children()[s]; |
2236 |
if (rowSample[m_SamplesModel.m_col_sample] == sample) { |
if (rowSample[m_SamplesModel.m_col_sample] == sample) { |
2237 |
show_samples_tab(); |
show_samples_tab(); |
2238 |
|
m_TreeViewSamples.get_selection()->unselect_all(); |
2239 |
m_TreeViewSamples.get_selection()->select(rowGroup.children()[s]); |
m_TreeViewSamples.get_selection()->select(rowGroup.children()[s]); |
2240 |
Gtk::TreePath path( |
std::vector<Gtk::TreeModel::Path> rows = |
2241 |
m_TreeViewSamples.get_selection()->get_selected() |
m_TreeViewSamples.get_selection()->get_selected_rows(); |
2242 |
); |
if (rows.empty()) return; |
2243 |
m_TreeViewSamples.scroll_to_row(path); |
m_TreeViewSamples.scroll_to_row(rows[0]); |
2244 |
return; |
return; |
2245 |
} |
} |
2246 |
} |
} |
2249 |
|
|
2250 |
void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) { |
void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) { |
2251 |
if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
2252 |
|
// by default if Ctrl keys is pressed down, then a mouse right-click |
2253 |
|
// does not select the respective row, so we must assure this |
2254 |
|
// programmatically ... |
2255 |
|
/*{ |
2256 |
|
Gtk::TreeModel::Path path; |
2257 |
|
Gtk::TreeViewColumn* pColumn = NULL; |
2258 |
|
int cellX, cellY; |
2259 |
|
bool bSuccess = m_TreeViewSamples.get_path_at_pos( |
2260 |
|
(int)button->x, (int)button->y, |
2261 |
|
path, pColumn, cellX, cellY |
2262 |
|
); |
2263 |
|
if (bSuccess) { |
2264 |
|
if (m_TreeViewSamples.get_selection()->count_selected_rows() <= 0) { |
2265 |
|
printf("not selected !!!\n"); |
2266 |
|
m_TreeViewSamples.get_selection()->select(path); |
2267 |
|
} |
2268 |
|
} |
2269 |
|
}*/ |
2270 |
|
|
2271 |
Gtk::Menu* sample_popup = |
Gtk::Menu* sample_popup = |
2272 |
dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/SamplePopupMenu")); |
dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/SamplePopupMenu")); |
2273 |
// update enabled/disabled state of sample popup items |
// update enabled/disabled state of sample popup items |
2274 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
2275 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
2276 |
bool group_selected = false; |
const int n = rows.size(); |
2277 |
bool sample_selected = false; |
int nGroups = 0; |
2278 |
if (it) { |
int nSamples = 0; |
2279 |
|
for (int r = 0; r < n; ++r) { |
2280 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[r]); |
2281 |
|
if (!it) continue; |
2282 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
2283 |
group_selected = row[m_SamplesModel.m_col_group]; |
if (row[m_SamplesModel.m_col_group]) nGroups++; |
2284 |
sample_selected = row[m_SamplesModel.m_col_sample]; |
if (row[m_SamplesModel.m_col_sample]) nSamples++; |
2285 |
} |
} |
2286 |
|
|
|
|
|
2287 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))-> |
2288 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n == 1); |
2289 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))-> |
2290 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n); |
2291 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddGroup"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddGroup"))-> |
2292 |
set_sensitive(file); |
set_sensitive(file); |
2293 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/ShowSampleRefs"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/ShowSampleRefs"))-> |
2294 |
set_sensitive(sample_selected); |
set_sensitive(nSamples == 1); |
2295 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))-> |
2296 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n); |
2297 |
// show sample popup |
// show sample popup |
2298 |
sample_popup->popup(button->button, button->time); |
sample_popup->popup(button->button, button->time); |
2299 |
|
|
2300 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/SampleProperties"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/SampleProperties"))-> |
2301 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n == 1); |
2302 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddSample"))-> |
2303 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n); |
2304 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddGroup"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddGroup"))-> |
2305 |
set_sensitive(file); |
set_sensitive(file); |
2306 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/ShowSampleRefs"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/ShowSampleRefs"))-> |
2307 |
set_sensitive(sample_selected); |
set_sensitive(nSamples == 1); |
2308 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/RemoveSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/RemoveSample"))-> |
2309 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n); |
2310 |
} |
} |
2311 |
} |
} |
2312 |
|
|
2385 |
instrument_name_connection.block(); |
instrument_name_connection.block(); |
2386 |
Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append(); |
Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append(); |
2387 |
Gtk::TreeModel::Row rowInstr = *iterInstr; |
Gtk::TreeModel::Row rowInstr = *iterInstr; |
2388 |
|
rowInstr[m_Columns.m_col_nr] = m_refTreeModel->children().size() - 1; |
2389 |
rowInstr[m_Columns.m_col_name] = name; |
rowInstr[m_Columns.m_col_name] = name; |
2390 |
rowInstr[m_Columns.m_col_instr] = instrument; |
rowInstr[m_Columns.m_col_instr] = instrument; |
2391 |
instrument_name_connection.unblock(); |
instrument_name_connection.unblock(); |
2414 |
// retrieve the currently selected instrument |
// retrieve the currently selected instrument |
2415 |
// (being the original instrument to be duplicated) |
// (being the original instrument to be duplicated) |
2416 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
2417 |
Gtk::TreeModel::iterator itSelection = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
2418 |
if (!itSelection) return; |
for (int r = 0; r < rows.size(); ++r) { |
2419 |
Gtk::TreeModel::Row row = *itSelection; |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]); |
2420 |
gig::Instrument* instrOrig = row[m_Columns.m_col_instr]; |
if (it) { |
2421 |
if (!instrOrig) return; |
Gtk::TreeModel::Row row = *it; |
2422 |
|
gig::Instrument* instrOrig = row[m_Columns.m_col_instr]; |
2423 |
// duplicate the orginal instrument |
if (instrOrig) { |
2424 |
gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); |
// duplicate the orginal instrument |
2425 |
instrNew->pInfo->Name = |
gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); |
2426 |
instrOrig->pInfo->Name + |
instrNew->pInfo->Name = |
2427 |
gig_from_utf8(Glib::ustring(" (") + _("Copy") + ")"); |
instrOrig->pInfo->Name + |
2428 |
|
gig_from_utf8(Glib::ustring(" (") + _("Copy") + ")"); |
2429 |
|
|
2430 |
add_instrument(instrNew); |
add_instrument(instrNew); |
2431 |
|
} |
2432 |
|
} |
2433 |
|
} |
2434 |
} |
} |
2435 |
|
|
2436 |
void MainWindow::on_action_remove_instrument() { |
void MainWindow::on_action_remove_instrument() { |
2447 |
} |
} |
2448 |
|
|
2449 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
2450 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
2451 |
if (it) { |
for (int r = rows.size() - 1; r >= 0; --r) { |
2452 |
|
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]); |
2453 |
|
if (!it) continue; |
2454 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
2455 |
gig::Instrument* instr = row[m_Columns.m_col_instr]; |
gig::Instrument* instr = row[m_Columns.m_col_instr]; |
2456 |
try { |
try { |
2465 |
|
|
2466 |
// remove row from instruments tree view |
// remove row from instruments tree view |
2467 |
m_refTreeModel->erase(it); |
m_refTreeModel->erase(it); |
2468 |
|
// update "Nr" column of all instrument rows |
2469 |
|
{ |
2470 |
|
int index = 0; |
2471 |
|
for (Gtk::TreeModel::iterator it = m_refTreeModel->children().begin(); |
2472 |
|
it != m_refTreeModel->children().end(); ++it, ++index) |
2473 |
|
{ |
2474 |
|
Gtk::TreeModel::Row row = *it; |
2475 |
|
row[m_Columns.m_col_nr] = index; |
2476 |
|
} |
2477 |
|
} |
2478 |
|
|
2479 |
#if GTKMM_MAJOR_VERSION < 3 |
#if GTKMM_MAJOR_VERSION < 3 |
2480 |
// select another instrument (in gtk3 this is done |
// select another instrument (in gtk3 this is done |
2572 |
if (!script) return; |
if (!script) return; |
2573 |
|
|
2574 |
ScriptEditor* editor = new ScriptEditor; |
ScriptEditor* editor = new ScriptEditor; |
2575 |
|
editor->signal_script_to_be_changed.connect( |
2576 |
|
signal_script_to_be_changed.make_slot() |
2577 |
|
); |
2578 |
|
editor->signal_script_changed.connect( |
2579 |
|
signal_script_changed.make_slot() |
2580 |
|
); |
2581 |
editor->setScript(script); |
editor->setScript(script); |
2582 |
//editor->reparent(*this); |
//editor->reparent(*this); |
2583 |
editor->show(); |
editor->show(); |
2656 |
|
|
2657 |
// get selected group (and probably selected sample) |
// get selected group (and probably selected sample) |
2658 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
2659 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
2660 |
|
if (rows.empty()) return; |
2661 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]); |
2662 |
if (!it) return; |
if (!it) return; |
2663 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
2664 |
gig::Sample* sample = NULL; |
gig::Sample* sample = NULL; |
2676 |
|
|
2677 |
// show 'browse for file' dialog |
// show 'browse for file' dialog |
2678 |
Gtk::FileChooserDialog dialog(*this, replace ? _("Replace Sample with") : _("Add Sample(s)")); |
Gtk::FileChooserDialog dialog(*this, replace ? _("Replace Sample with") : _("Add Sample(s)")); |
2679 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
2680 |
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); |
dialog.add_button(_("_Open"), Gtk::RESPONSE_OK); |
2681 |
dialog.set_select_multiple(!replace); // allow multi audio file selection only when adding new samples, does not make sense when replacing a specific sample |
dialog.set_select_multiple(!replace); // allow multi audio file selection only when adding new samples, does not make sense when replacing a specific sample |
2682 |
|
|
2683 |
// matches all file types supported by libsndfile |
// matches all file types supported by libsndfile |
2807 |
SampleImportItem sched_item; |
SampleImportItem sched_item; |
2808 |
sched_item.gig_sample = sample; |
sched_item.gig_sample = sample; |
2809 |
sched_item.sample_path = *iter; |
sched_item.sample_path = *iter; |
2810 |
m_SampleImportQueue.push_back(sched_item); |
m_SampleImportQueue[sample] = sched_item; |
2811 |
// add sample to the tree view |
// add sample to the tree view |
2812 |
if (replace) { |
if (replace) { |
2813 |
row[m_SamplesModel.m_col_name] = gig_to_utf8(sample->pInfo->Name); |
row[m_SamplesModel.m_col_name] = gig_to_utf8(sample->pInfo->Name); |
2877 |
dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK); |
dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK); |
2878 |
description.show(); |
description.show(); |
2879 |
entryArea.show_all(); |
entryArea.show_all(); |
2880 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
2881 |
dialog.add_button(_("Select"), Gtk::RESPONSE_OK); |
dialog.add_button(_("Select"), Gtk::RESPONSE_OK); |
2882 |
dialog.set_select_multiple(false); |
dialog.set_select_multiple(false); |
2883 |
if (current_sample_dir != "") { |
if (current_sample_dir != "") { |
2901 |
try |
try |
2902 |
{ |
{ |
2903 |
if (!hFile) throw std::string(_("could not open file")); |
if (!hFile) throw std::string(_("could not open file")); |
|
int bitdepth; |
|
2904 |
switch (info.format & 0xff) { |
switch (info.format & 0xff) { |
2905 |
case SF_FORMAT_PCM_S8: |
case SF_FORMAT_PCM_S8: |
2906 |
case SF_FORMAT_PCM_16: |
case SF_FORMAT_PCM_16: |
2907 |
case SF_FORMAT_PCM_U8: |
case SF_FORMAT_PCM_U8: |
|
bitdepth = 16; |
|
|
break; |
|
2908 |
case SF_FORMAT_PCM_24: |
case SF_FORMAT_PCM_24: |
2909 |
case SF_FORMAT_PCM_32: |
case SF_FORMAT_PCM_32: |
2910 |
case SF_FORMAT_FLOAT: |
case SF_FORMAT_FLOAT: |
2911 |
case SF_FORMAT_DOUBLE: |
case SF_FORMAT_DOUBLE: |
|
bitdepth = 24; |
|
2912 |
break; |
break; |
2913 |
default: |
default: |
2914 |
sf_close(hFile); |
sf_close(hFile); |
2917 |
SampleImportItem sched_item; |
SampleImportItem sched_item; |
2918 |
sched_item.gig_sample = sample; |
sched_item.gig_sample = sample; |
2919 |
sched_item.sample_path = filename; |
sched_item.sample_path = filename; |
2920 |
m_SampleImportQueue.push_back(sched_item); |
m_SampleImportQueue[sample] = sched_item; |
2921 |
sf_close(hFile); |
sf_close(hFile); |
2922 |
file_changed(); |
file_changed(); |
2923 |
} |
} |
2941 |
void MainWindow::on_action_remove_sample() { |
void MainWindow::on_action_remove_sample() { |
2942 |
if (!file) return; |
if (!file) return; |
2943 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
2944 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
2945 |
if (it) { |
for (int r = rows.size() - 1; r >= 0; --r) { |
2946 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[r]); |
2947 |
|
if (!it) continue; |
2948 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
2949 |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
2950 |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
2969 |
// if sample(s) were just previously added, remove |
// if sample(s) were just previously added, remove |
2970 |
// them from the import queue |
// them from the import queue |
2971 |
for (std::list<gig::Sample*>::iterator member = members.begin(); |
for (std::list<gig::Sample*>::iterator member = members.begin(); |
2972 |
member != members.end(); ++member) { |
member != members.end(); ++member) |
2973 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
{ |
2974 |
iter != m_SampleImportQueue.end(); ++iter) { |
if (m_SampleImportQueue.count(*member)) { |
2975 |
if ((*iter).gig_sample == *member) { |
printf("Removing previously added sample '%s' from group '%s'\n", |
2976 |
printf("Removing previously added sample '%s' from group '%s'\n", |
m_SampleImportQueue[sample].sample_path.c_str(), name.c_str()); |
2977 |
(*iter).sample_path.c_str(), name.c_str()); |
m_SampleImportQueue.erase(*member); |
|
m_SampleImportQueue.erase(iter); |
|
|
break; |
|
|
} |
|
2978 |
} |
} |
2979 |
} |
} |
2980 |
file_changed(); |
file_changed(); |
2989 |
samples_removed_signal.emit(); |
samples_removed_signal.emit(); |
2990 |
// if sample was just previously added, remove it from |
// if sample was just previously added, remove it from |
2991 |
// the import queue |
// the import queue |
2992 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
if (m_SampleImportQueue.count(sample)) { |
2993 |
iter != m_SampleImportQueue.end(); ++iter) { |
printf("Removing previously added sample '%s'\n", |
2994 |
if ((*iter).gig_sample == sample) { |
m_SampleImportQueue[sample].sample_path.c_str()); |
2995 |
printf("Removing previously added sample '%s'\n", |
m_SampleImportQueue.erase(sample); |
|
(*iter).sample_path.c_str()); |
|
|
m_SampleImportQueue.erase(iter); |
|
|
break; |
|
|
} |
|
2996 |
} |
} |
2997 |
dimreg_changed(); |
dimreg_changed(); |
2998 |
file_changed(); |
file_changed(); |
3048 |
gig::Sample* sample = *itSample; |
gig::Sample* sample = *itSample; |
3049 |
// remove sample from the .gig file |
// remove sample from the .gig file |
3050 |
file->DeleteSample(sample); |
file->DeleteSample(sample); |
3051 |
// if sample was just previously added, remove it fro the import queue |
// if sample was just previously added, remove it from the import queue |
3052 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
if (m_SampleImportQueue.count(sample)) { |
3053 |
iter != m_SampleImportQueue.end(); ++iter) |
printf("Removing previously added sample '%s'\n", |
3054 |
{ |
m_SampleImportQueue[sample].sample_path.c_str()); |
3055 |
if ((*iter).gig_sample == sample) { |
m_SampleImportQueue.erase(sample); |
|
printf("Removing previously added sample '%s'\n", |
|
|
(*iter).sample_path.c_str()); |
|
|
m_SampleImportQueue.erase(iter); |
|
|
break; |
|
|
} |
|
3056 |
} |
} |
3057 |
} |
} |
3058 |
} catch (RIFF::Exception e) { |
} catch (RIFF::Exception e) { |
3111 |
gig::Instrument* src = NULL; |
gig::Instrument* src = NULL; |
3112 |
{ |
{ |
3113 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
3114 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
3115 |
if (it) { |
if (!rows.empty()) { |
3116 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
3117 |
src = row[m_Columns.m_col_instr]; |
if (it) { |
3118 |
|
Gtk::TreeModel::Row row = *it; |
3119 |
|
src = row[m_Columns.m_col_instr]; |
3120 |
|
} |
3121 |
} |
} |
3122 |
} |
} |
3123 |
if (!src) return; |
if (!src) return; |
3172 |
// get selected sample |
// get selected sample |
3173 |
gig::Sample* sample = NULL; |
gig::Sample* sample = NULL; |
3174 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
3175 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
3176 |
if (it) { |
if (!rows.empty()) { |
3177 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]); |
3178 |
sample = row[m_SamplesModel.m_col_sample]; |
if (it) { |
3179 |
|
Gtk::TreeModel::Row row = *it; |
3180 |
|
sample = row[m_SamplesModel.m_col_sample]; |
3181 |
|
} |
3182 |
} |
} |
3183 |
// pass the gig::Sample as pointer |
// pass the gig::Sample as pointer |
3184 |
selection_data.set(selection_data.get_target(), 0/*unused*/, (const guchar*)&sample, |
selection_data.set(selection_data.get_target(), 0/*unused*/, (const guchar*)&sample, |
3318 |
if (!script) return; |
if (!script) return; |
3319 |
|
|
3320 |
ScriptEditor* editor = new ScriptEditor; |
ScriptEditor* editor = new ScriptEditor; |
3321 |
|
editor->signal_script_to_be_changed.connect( |
3322 |
|
signal_script_to_be_changed.make_slot() |
3323 |
|
); |
3324 |
|
editor->signal_script_changed.connect( |
3325 |
|
signal_script_changed.make_slot() |
3326 |
|
); |
3327 |
editor->setScript(script); |
editor->setScript(script); |
3328 |
//editor->reparent(*this); |
//editor->reparent(*this); |
3329 |
editor->show(); |
editor->show(); |
3377 |
|
|
3378 |
void MainWindow::on_action_view_references() { |
void MainWindow::on_action_view_references() { |
3379 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
3380 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
3381 |
|
if (rows.empty()) return; |
3382 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]); |
3383 |
if (!it) return; |
if (!it) return; |
3384 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
3385 |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
3501 |
} |
} |
3502 |
|
|
3503 |
Gtk::FileChooserDialog dialog(*this, _("Merge .gig files")); |
Gtk::FileChooserDialog dialog(*this, _("Merge .gig files")); |
3504 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
3505 |
dialog.add_button(_("Merge"), Gtk::RESPONSE_OK); |
dialog.add_button(_("Merge"), Gtk::RESPONSE_OK); |
3506 |
dialog.set_default_response(Gtk::RESPONSE_CANCEL); |
dialog.set_default_response(Gtk::RESPONSE_CANCEL); |
3507 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
3520 |
// show warning in the file picker dialog |
// show warning in the file picker dialog |
3521 |
Gtk::HBox descriptionArea; |
Gtk::HBox descriptionArea; |
3522 |
descriptionArea.set_spacing(15); |
descriptionArea.set_spacing(15); |
3523 |
Gtk::Image warningIcon(Gtk::Stock::DIALOG_WARNING, Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); |
Gtk::Image warningIcon; |
3524 |
|
warningIcon.set_from_icon_name("dialog-warning", |
3525 |
|
Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); |
3526 |
descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); |
descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); |
3527 |
#if GTKMM_MAJOR_VERSION < 3 |
#if GTKMM_MAJOR_VERSION < 3 |
3528 |
view::WrapLabel description; |
view::WrapLabel description; |
3545 |
descriptionArea.show_all(); |
descriptionArea.show_all(); |
3546 |
|
|
3547 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
3548 |
printf("on_action_merge_files self=%x\n", Glib::Threads::Thread::self()); |
printf("on_action_merge_files self=%p\n", |
3549 |
|
static_cast<void*>(Glib::Threads::Thread::self())); |
3550 |
std::vector<std::string> filenames = dialog.get_filenames(); |
std::vector<std::string> filenames = dialog.get_filenames(); |
3551 |
|
|
3552 |
// merge the selected files to the currently open .gig file |
// merge the selected files to the currently open .gig file |
3628 |
m_TreeViewNotebook.set_current_page(2); |
m_TreeViewNotebook.set_current_page(2); |
3629 |
} |
} |
3630 |
|
|
3631 |
|
void MainWindow::select_prev_region() { |
3632 |
|
m_RegionChooser.select_prev_region(); |
3633 |
|
} |
3634 |
|
|
3635 |
|
void MainWindow::select_next_region() { |
3636 |
|
m_RegionChooser.select_next_region(); |
3637 |
|
} |
3638 |
|
|
3639 |
|
void MainWindow::select_next_dim_rgn_zone() { |
3640 |
|
if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser |
3641 |
|
m_DimRegionChooser.select_next_dimzone(); |
3642 |
|
} |
3643 |
|
|
3644 |
|
void MainWindow::select_prev_dim_rgn_zone() { |
3645 |
|
if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser |
3646 |
|
m_DimRegionChooser.select_prev_dimzone(); |
3647 |
|
} |
3648 |
|
|
3649 |
|
void MainWindow::select_add_next_dim_rgn_zone() { |
3650 |
|
m_DimRegionChooser.select_next_dimzone(true); |
3651 |
|
} |
3652 |
|
|
3653 |
|
void MainWindow::select_add_prev_dim_rgn_zone() { |
3654 |
|
m_DimRegionChooser.select_prev_dimzone(true); |
3655 |
|
} |
3656 |
|
|
3657 |
|
void MainWindow::select_prev_dimension() { |
3658 |
|
if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser |
3659 |
|
m_DimRegionChooser.select_prev_dimension(); |
3660 |
|
} |
3661 |
|
|
3662 |
|
void MainWindow::select_next_dimension() { |
3663 |
|
if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser |
3664 |
|
m_DimRegionChooser.select_next_dimension(); |
3665 |
|
} |
3666 |
|
|
3667 |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
3668 |
return file_structure_to_be_changed_signal; |
return file_structure_to_be_changed_signal; |
3669 |
} |
} |