1 |
/* |
/* |
2 |
* Copyright (C) 2006-2013 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> |
38 |
#include <gtkmm/stock.h> |
#include <gtkmm/stock.h> |
39 |
#include <gtkmm/targetentry.h> |
#include <gtkmm/targetentry.h> |
40 |
#include <gtkmm/main.h> |
#include <gtkmm/main.h> |
|
#include <gtkmm/radiomenuitem.h> |
|
41 |
#include <gtkmm/toggleaction.h> |
#include <gtkmm/toggleaction.h> |
42 |
|
#include <gtkmm/accelmap.h> |
43 |
#if GTKMM_MAJOR_VERSION < 3 |
#if GTKMM_MAJOR_VERSION < 3 |
44 |
#include "wrapLabel.hh" |
#include "wrapLabel.hh" |
45 |
#endif |
#endif |
49 |
|
|
50 |
#include <stdio.h> |
#include <stdio.h> |
51 |
#include <sndfile.h> |
#include <sndfile.h> |
52 |
|
#include <assert.h> |
53 |
|
|
54 |
#include "mainwindow.h" |
#include "mainwindow.h" |
55 |
|
#include "Settings.h" |
56 |
|
#include "CombineInstrumentsDialog.h" |
57 |
|
#include "scripteditor.h" |
58 |
|
#include "scriptslots.h" |
59 |
|
#include "ReferencesView.h" |
60 |
#include "../../gfx/status_attached.xpm" |
#include "../../gfx/status_attached.xpm" |
61 |
#include "../../gfx/status_detached.xpm" |
#include "../../gfx/status_detached.xpm" |
62 |
|
#include "gfx/builtinpix.h" |
63 |
|
#include "MacroEditor.h" |
64 |
|
#include "MacrosSetup.h" |
65 |
|
#if defined(__APPLE__) |
66 |
|
# include "MacHelper.h" |
67 |
|
#endif |
68 |
|
|
69 |
template<class T> inline std::string ToString(T o) { |
static const Gdk::ModifierType primaryModifierKey = |
70 |
std::stringstream ss; |
#if defined(__APPLE__) |
71 |
ss << o; |
Gdk::META_MASK; // Cmd key on Mac |
72 |
return ss.str(); |
#else |
73 |
} |
Gdk::CONTROL_MASK; // Ctrl key on all other OSs |
74 |
|
#endif |
|
Table::Table(int x, int y) : Gtk::Table(x, y), rowno(0) { } |
|
|
|
|
|
void Table::add(BoolEntry& boolentry) |
|
|
{ |
|
|
attach(boolentry.widget, 0, 2, rowno, rowno + 1, |
|
|
Gtk::FILL, Gtk::SHRINK); |
|
|
rowno++; |
|
|
} |
|
|
|
|
|
void Table::add(BoolEntryPlus6& boolentry) |
|
|
{ |
|
|
attach(boolentry.widget, 0, 2, rowno, rowno + 1, |
|
|
Gtk::FILL, Gtk::SHRINK); |
|
|
rowno++; |
|
|
} |
|
|
|
|
|
void Table::add(LabelWidget& prop) |
|
|
{ |
|
|
attach(prop.label, 1, 2, rowno, rowno + 1, |
|
|
Gtk::FILL, Gtk::SHRINK); |
|
|
attach(prop.widget, 2, 3, rowno, rowno + 1, |
|
|
Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK); |
|
|
rowno++; |
|
|
} |
|
75 |
|
|
76 |
MainWindow::MainWindow() : |
MainWindow::MainWindow() : |
77 |
|
m_DimRegionChooser(*this), |
78 |
dimreg_label(_("Changes apply to:")), |
dimreg_label(_("Changes apply to:")), |
79 |
dimreg_all_regions(_("all regions")), |
dimreg_all_regions(_("all regions")), |
80 |
dimreg_all_dimregs(_("all dimension splits")), |
dimreg_all_dimregs(_("all dimension splits")), |
81 |
dimreg_stereo(_("both channels")) |
dimreg_stereo(_("both channels")), |
82 |
|
labelLegend(_("Legend:")), |
83 |
|
labelNoSample(_(" No Sample")), |
84 |
|
labelMissingSample(_(" Missing some Sample(s)")), |
85 |
|
labelLooped(_(" Looped")), |
86 |
|
labelSomeLoops(_(" Some Loop(s)")) |
87 |
{ |
{ |
88 |
|
loadBuiltInPix(); |
89 |
|
|
90 |
// set_border_width(5); |
// set_border_width(5); |
|
// set_default_size(400, 200); |
|
91 |
|
|
92 |
|
if (!Settings::singleton()->autoRestoreWindowDimension) { |
93 |
|
set_default_size(800, 600); |
94 |
|
set_position(Gtk::WIN_POS_CENTER); |
95 |
|
} |
96 |
|
|
97 |
add(m_VBox); |
add(m_VBox); |
98 |
|
|
99 |
// Handle selection |
// Handle selection |
100 |
Glib::RefPtr<Gtk::TreeSelection> tree_sel_ref = m_TreeView.get_selection(); |
m_TreeView.get_selection()->signal_changed().connect( |
|
tree_sel_ref->signal_changed().connect( |
|
101 |
sigc::mem_fun(*this, &MainWindow::on_sel_change)); |
sigc::mem_fun(*this, &MainWindow::on_sel_change)); |
102 |
|
|
103 |
// m_TreeView.set_reorderable(); |
// m_TreeView.set_reorderable(); |
113 |
m_ScrolledWindowSamples.add(m_TreeViewSamples); |
m_ScrolledWindowSamples.add(m_TreeViewSamples); |
114 |
m_ScrolledWindowSamples.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); |
m_ScrolledWindowSamples.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); |
115 |
|
|
116 |
|
m_ScrolledWindowScripts.add(m_TreeViewScripts); |
117 |
|
m_ScrolledWindowScripts.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); |
118 |
|
|
119 |
|
|
120 |
m_TreeViewNotebook.set_size_request(300); |
m_TreeViewNotebook.set_size_request(300); |
121 |
|
|
127 |
dimreg_hbox.add(dimreg_stereo); |
dimreg_hbox.add(dimreg_stereo); |
128 |
dimreg_vbox.add(dimreg_edit); |
dimreg_vbox.add(dimreg_edit); |
129 |
dimreg_vbox.pack_start(dimreg_hbox, Gtk::PACK_SHRINK); |
dimreg_vbox.pack_start(dimreg_hbox, Gtk::PACK_SHRINK); |
130 |
|
{ |
131 |
|
legend_hbox.add(labelLegend); |
132 |
|
|
133 |
|
imageNoSample.set(redDot); |
134 |
|
imageNoSample.set_alignment(Gtk::ALIGN_END); |
135 |
|
labelNoSample.set_alignment(Gtk::ALIGN_START); |
136 |
|
legend_hbox.add(imageNoSample); |
137 |
|
legend_hbox.add(labelNoSample); |
138 |
|
|
139 |
|
imageMissingSample.set(yellowDot); |
140 |
|
imageMissingSample.set_alignment(Gtk::ALIGN_END); |
141 |
|
labelMissingSample.set_alignment(Gtk::ALIGN_START); |
142 |
|
legend_hbox.add(imageMissingSample); |
143 |
|
legend_hbox.add(labelMissingSample); |
144 |
|
|
145 |
|
imageLooped.set(blackLoop); |
146 |
|
imageLooped.set_alignment(Gtk::ALIGN_END); |
147 |
|
labelLooped.set_alignment(Gtk::ALIGN_START); |
148 |
|
legend_hbox.add(imageLooped); |
149 |
|
legend_hbox.add(labelLooped); |
150 |
|
|
151 |
|
imageSomeLoops.set(grayLoop); |
152 |
|
imageSomeLoops.set_alignment(Gtk::ALIGN_END); |
153 |
|
labelSomeLoops.set_alignment(Gtk::ALIGN_START); |
154 |
|
legend_hbox.add(imageSomeLoops); |
155 |
|
legend_hbox.add(labelSomeLoops); |
156 |
|
|
157 |
|
legend_hbox.show_all_children(); |
158 |
|
} |
159 |
|
dimreg_vbox.pack_start(legend_hbox, Gtk::PACK_SHRINK); |
160 |
m_HPaned.add2(dimreg_vbox); |
m_HPaned.add2(dimreg_vbox); |
161 |
|
|
162 |
|
dimreg_label.set_tooltip_text(_("To automatically apply your changes above globally to the entire instrument, check all 3 check boxes on the right.")); |
163 |
|
dimreg_all_regions.set_tooltip_text(_("If checked: all changes you perform above will automatically be applied to all regions of this instrument as well.")); |
164 |
|
dimreg_all_dimregs.set_tooltip_text(_("If checked: all changes you perform above will automatically be applied as well to all dimension splits of the region selected below.")); |
165 |
|
dimreg_stereo.set_tooltip_text(_("If checked: all changes you perform above will automatically be applied to both audio channel splits (only if a \"stereo\" dimension is defined below).")); |
166 |
|
|
167 |
m_TreeViewNotebook.append_page(m_ScrolledWindowSamples, _("Samples")); |
m_TreeViewNotebook.append_page(m_ScrolledWindowSamples, _("Samples")); |
168 |
m_TreeViewNotebook.append_page(m_ScrolledWindow, _("Instruments")); |
m_TreeViewNotebook.append_page(m_ScrolledWindow, _("Instruments")); |
169 |
|
m_TreeViewNotebook.append_page(m_ScrolledWindowScripts, _("Scripts")); |
170 |
|
|
171 |
actionGroup = Gtk::ActionGroup::create(); |
actionGroup = Gtk::ActionGroup::create(); |
172 |
|
|
197 |
Gtk::Stock::PROPERTIES), |
Gtk::Stock::PROPERTIES), |
198 |
sigc::mem_fun( |
sigc::mem_fun( |
199 |
*this, &MainWindow::show_instr_props)); |
*this, &MainWindow::show_instr_props)); |
200 |
|
actionGroup->add(Gtk::Action::create("MidiRules", |
201 |
|
_("_Midi Rules...")), |
202 |
|
sigc::mem_fun( |
203 |
|
*this, &MainWindow::show_midi_rules)); |
204 |
|
actionGroup->add(Gtk::Action::create("ScriptSlots", |
205 |
|
_("_Script Slots...")), |
206 |
|
sigc::mem_fun( |
207 |
|
*this, &MainWindow::show_script_slots)); |
208 |
actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT), |
actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT), |
209 |
sigc::mem_fun( |
sigc::mem_fun( |
210 |
*this, &MainWindow::on_action_quit)); |
*this, &MainWindow::on_action_quit)); |
211 |
actionGroup->add(Gtk::Action::create("MenuInstrument", _("_Instrument"))); |
actionGroup->add( |
212 |
|
Gtk::Action::create("MenuSample", _("_Sample")), |
213 |
|
sigc::mem_fun(*this, &MainWindow::show_samples_tab) |
214 |
|
); |
215 |
|
actionGroup->add( |
216 |
|
Gtk::Action::create("MenuInstrument", _("_Instrument")), |
217 |
|
sigc::mem_fun(*this, &MainWindow::show_intruments_tab) |
218 |
|
); |
219 |
|
actionGroup->add( |
220 |
|
Gtk::Action::create("MenuScript", _("Scr_ipt")), |
221 |
|
sigc::mem_fun(*this, &MainWindow::show_scripts_tab) |
222 |
|
); |
223 |
|
actionGroup->add(Gtk::Action::create("AllInstruments", _("_Select"))); |
224 |
|
|
225 |
|
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); |
226 |
|
|
227 |
|
const Gdk::ModifierType primaryModifierKey = |
228 |
|
#if defined(__APPLE__) |
229 |
|
Gdk::META_MASK; // Cmd key on Mac |
230 |
|
#else |
231 |
|
Gdk::CONTROL_MASK; // Ctrl key on all other OSs |
232 |
|
#endif |
233 |
|
|
234 |
|
actionGroup->add(Gtk::Action::create("CopyDimRgn", |
235 |
|
_("Copy selected dimension region")), |
236 |
|
Gtk::AccelKey(GDK_KEY_c, Gdk::MOD1_MASK), |
237 |
|
sigc::mem_fun(*this, &MainWindow::copy_selected_dimrgn)); |
238 |
|
|
239 |
|
actionGroup->add(Gtk::Action::create("PasteDimRgn", |
240 |
|
_("Paste dimension region")), |
241 |
|
Gtk::AccelKey(GDK_KEY_v, Gdk::MOD1_MASK), |
242 |
|
sigc::mem_fun(*this, &MainWindow::paste_copied_dimrgn)); |
243 |
|
|
244 |
|
actionGroup->add(Gtk::Action::create("AdjustClipboard", |
245 |
|
_("Adjust Clipboard Content")), |
246 |
|
Gtk::AccelKey(GDK_KEY_x, Gdk::MOD1_MASK), |
247 |
|
sigc::mem_fun(*this, &MainWindow::adjust_clipboard_content)); |
248 |
|
|
249 |
|
actionGroup->add(Gtk::Action::create("SelectPrevRegion", |
250 |
|
_("Select Previous Region")), |
251 |
|
Gtk::AccelKey(GDK_KEY_Left, primaryModifierKey), |
252 |
|
sigc::mem_fun(*this, &MainWindow::select_prev_region)); |
253 |
|
|
254 |
|
actionGroup->add(Gtk::Action::create("SelectNextRegion", |
255 |
|
_("Select Next Region")), |
256 |
|
Gtk::AccelKey(GDK_KEY_Right, primaryModifierKey), |
257 |
|
sigc::mem_fun(*this, &MainWindow::select_next_region)); |
258 |
|
|
259 |
|
actionGroup->add(Gtk::Action::create("SelectPrevDimRgnZone", |
260 |
|
_("Select Previous Dimension Region Zone")), |
261 |
|
Gtk::AccelKey(GDK_KEY_Left, Gdk::MOD1_MASK), |
262 |
|
sigc::mem_fun(*this, &MainWindow::select_prev_dim_rgn_zone)); |
263 |
|
|
264 |
|
actionGroup->add(Gtk::Action::create("SelectNextDimRgnZone", |
265 |
|
_("Select Next Dimension Region Zone")), |
266 |
|
Gtk::AccelKey(GDK_KEY_Right, Gdk::MOD1_MASK), |
267 |
|
sigc::mem_fun(*this, &MainWindow::select_next_dim_rgn_zone)); |
268 |
|
|
269 |
|
actionGroup->add(Gtk::Action::create("SelectPrevDimension", |
270 |
|
_("Select Previous Dimension")), |
271 |
|
Gtk::AccelKey(GDK_KEY_Up, Gdk::MOD1_MASK), |
272 |
|
sigc::mem_fun(*this, &MainWindow::select_prev_dimension)); |
273 |
|
|
274 |
|
actionGroup->add(Gtk::Action::create("SelectNextDimension", |
275 |
|
_("Select Next Dimension")), |
276 |
|
Gtk::AccelKey(GDK_KEY_Down, Gdk::MOD1_MASK), |
277 |
|
sigc::mem_fun(*this, &MainWindow::select_next_dimension)); |
278 |
|
|
279 |
|
actionGroup->add(Gtk::Action::create("SelectAddPrevDimRgnZone", |
280 |
|
_("Add Previous Dimension Region Zone to Selection")), |
281 |
|
Gtk::AccelKey(GDK_KEY_Left, Gdk::MOD1_MASK | Gdk::SHIFT_MASK), |
282 |
|
sigc::mem_fun(*this, &MainWindow::select_add_prev_dim_rgn_zone)); |
283 |
|
|
284 |
|
actionGroup->add(Gtk::Action::create("SelectAddNextDimRgnZone", |
285 |
|
_("Add Next Dimension Region Zone to Selection")), |
286 |
|
Gtk::AccelKey(GDK_KEY_Right, Gdk::MOD1_MASK | Gdk::SHIFT_MASK), |
287 |
|
sigc::mem_fun(*this, &MainWindow::select_add_next_dim_rgn_zone)); |
288 |
|
|
|
actionGroup->add(Gtk::Action::create("MenuView", _("_View"))); |
|
289 |
Glib::RefPtr<Gtk::ToggleAction> toggle_action = |
Glib::RefPtr<Gtk::ToggleAction> toggle_action = |
290 |
|
Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note")); |
291 |
|
toggle_action->set_active(true); |
292 |
|
actionGroup->add(toggle_action); |
293 |
|
|
294 |
|
toggle_action = |
295 |
|
Gtk::ToggleAction::create("CopySampleTune", _("Copy Sample's _Fine Tune")); |
296 |
|
toggle_action->set_active(true); |
297 |
|
actionGroup->add(toggle_action); |
298 |
|
|
299 |
|
toggle_action = |
300 |
|
Gtk::ToggleAction::create("CopySampleLoop", _("Copy Sample's _Loop Points")); |
301 |
|
toggle_action->set_active(true); |
302 |
|
actionGroup->add(toggle_action); |
303 |
|
|
304 |
|
|
305 |
|
actionGroup->add(Gtk::Action::create("MenuMacro", _("_Macro"))); |
306 |
|
|
307 |
|
|
308 |
|
actionGroup->add(Gtk::Action::create("MenuView", _("Vie_w"))); |
309 |
|
toggle_action = |
310 |
Gtk::ToggleAction::create("Statusbar", _("_Statusbar")); |
Gtk::ToggleAction::create("Statusbar", _("_Statusbar")); |
311 |
toggle_action->set_active(true); |
toggle_action->set_active(true); |
312 |
actionGroup->add(toggle_action, |
actionGroup->add(toggle_action, |
313 |
sigc::mem_fun( |
sigc::mem_fun( |
314 |
*this, &MainWindow::on_action_view_status_bar)); |
*this, &MainWindow::on_action_view_status_bar)); |
315 |
|
|
316 |
|
toggle_action = |
317 |
|
Gtk::ToggleAction::create("AutoRestoreWinDim", _("_Auto Restore Window Dimension")); |
318 |
|
toggle_action->set_active(Settings::singleton()->autoRestoreWindowDimension); |
319 |
|
actionGroup->add(toggle_action, |
320 |
|
sigc::mem_fun( |
321 |
|
*this, &MainWindow::on_auto_restore_win_dim)); |
322 |
|
|
323 |
|
toggle_action = |
324 |
|
Gtk::ToggleAction::create("SaveWithTemporaryFile", _("Save with _temporary file")); |
325 |
|
toggle_action->set_active(Settings::singleton()->saveWithTemporaryFile); |
326 |
|
actionGroup->add(toggle_action, |
327 |
|
sigc::mem_fun( |
328 |
|
*this, &MainWindow::on_save_with_temporary_file)); |
329 |
|
|
330 |
|
actionGroup->add( |
331 |
|
Gtk::Action::create("RefreshAll", _("_Refresh All")), |
332 |
|
sigc::mem_fun(*this, &MainWindow::on_action_refresh_all) |
333 |
|
); |
334 |
|
|
335 |
action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP); |
action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP); |
336 |
actionGroup->add(Gtk::Action::create("MenuHelp", |
actionGroup->add(Gtk::Action::create("MenuHelp", |
337 |
action->property_label())); |
action->property_label())); |
347 |
sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument) |
sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument) |
348 |
); |
); |
349 |
actionGroup->add( |
actionGroup->add( |
350 |
|
Gtk::Action::create("CombInstruments", _("_Combine Instruments ...")), |
351 |
|
Gtk::AccelKey(GDK_KEY_j, primaryModifierKey), |
352 |
|
sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments) |
353 |
|
); |
354 |
|
actionGroup->add( |
355 |
Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE), |
Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE), |
356 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument) |
357 |
); |
); |
358 |
|
|
359 |
|
|
360 |
|
actionGroup->add(Gtk::Action::create("MenuSettings", _("_Settings"))); |
361 |
|
|
362 |
|
toggle_action = |
363 |
|
Gtk::ToggleAction::create("WarnUserOnExtensions", _("Show warning on format _extensions")); |
364 |
|
toggle_action->set_active(Settings::singleton()->warnUserOnExtensions); |
365 |
|
actionGroup->add( |
366 |
|
toggle_action, |
367 |
|
sigc::mem_fun(*this, &MainWindow::on_action_warn_user_on_extensions) |
368 |
|
); |
369 |
|
|
370 |
|
toggle_action = |
371 |
|
Gtk::ToggleAction::create("SyncSamplerInstrumentSelection", _("Synchronize sampler's instrument selection")); |
372 |
|
toggle_action->set_active(Settings::singleton()->syncSamplerInstrumentSelection); |
373 |
|
actionGroup->add( |
374 |
|
toggle_action, |
375 |
|
sigc::mem_fun(*this, &MainWindow::on_action_sync_sampler_instrument_selection) |
376 |
|
); |
377 |
|
|
378 |
|
toggle_action = |
379 |
|
Gtk::ToggleAction::create("MoveRootNoteWithRegionMoved", _("Move root note with region moved")); |
380 |
|
toggle_action->set_active(Settings::singleton()->moveRootNoteWithRegionMoved); |
381 |
|
actionGroup->add( |
382 |
|
toggle_action, |
383 |
|
sigc::mem_fun(*this, &MainWindow::on_action_move_root_note_with_region_moved) |
384 |
|
); |
385 |
|
|
386 |
|
|
387 |
|
actionGroup->add(Gtk::Action::create("MenuTools", _("_Tools"))); |
388 |
|
|
389 |
|
actionGroup->add( |
390 |
|
Gtk::Action::create("CombineInstruments", _("_Combine Instruments...")), |
391 |
|
sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments) |
392 |
|
); |
393 |
|
|
394 |
|
actionGroup->add( |
395 |
|
Gtk::Action::create("MergeFiles", _("_Merge Files...")), |
396 |
|
sigc::mem_fun(*this, &MainWindow::on_action_merge_files) |
397 |
|
); |
398 |
|
|
399 |
|
|
400 |
// sample right-click popup actions |
// sample right-click popup actions |
401 |
actionGroup->add( |
actionGroup->add( |
402 |
Gtk::Action::create("SampleProperties", Gtk::Stock::PROPERTIES), |
Gtk::Action::create("SampleProperties", Gtk::Stock::PROPERTIES), |
415 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_sample) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_sample) |
416 |
); |
); |
417 |
actionGroup->add( |
actionGroup->add( |
418 |
|
Gtk::Action::create("RemoveUnusedSamples", _("Remove _Unused Samples")), |
419 |
|
sigc::mem_fun(*this, &MainWindow::on_action_remove_unused_samples) |
420 |
|
); |
421 |
|
actionGroup->add( |
422 |
|
Gtk::Action::create("ShowSampleRefs", _("Show References...")), |
423 |
|
sigc::mem_fun(*this, &MainWindow::on_action_view_references) |
424 |
|
); |
425 |
|
actionGroup->add( |
426 |
|
Gtk::Action::create("ReplaceSample", |
427 |
|
_("Replace Sample...")), |
428 |
|
sigc::mem_fun(*this, &MainWindow::on_action_replace_sample) |
429 |
|
); |
430 |
|
actionGroup->add( |
431 |
Gtk::Action::create("ReplaceAllSamplesInAllGroups", |
Gtk::Action::create("ReplaceAllSamplesInAllGroups", |
432 |
_("Replace All Samples in All Groups...")), |
_("Replace All Samples in All Groups...")), |
433 |
sigc::mem_fun(*this, &MainWindow::on_action_replace_all_samples_in_all_groups) |
sigc::mem_fun(*this, &MainWindow::on_action_replace_all_samples_in_all_groups) |
434 |
); |
); |
435 |
|
|
436 |
|
// script right-click popup actions |
437 |
|
actionGroup->add( |
438 |
|
Gtk::Action::create("AddScriptGroup", _("Add _Group")), |
439 |
|
sigc::mem_fun(*this, &MainWindow::on_action_add_script_group) |
440 |
|
); |
441 |
|
actionGroup->add( |
442 |
|
Gtk::Action::create("AddScript", _("Add _Script")), |
443 |
|
sigc::mem_fun(*this, &MainWindow::on_action_add_script) |
444 |
|
); |
445 |
|
actionGroup->add( |
446 |
|
Gtk::Action::create("EditScript", _("_Edit Script...")), |
447 |
|
sigc::mem_fun(*this, &MainWindow::on_action_edit_script) |
448 |
|
); |
449 |
|
actionGroup->add( |
450 |
|
Gtk::Action::create("RemoveScript", Gtk::Stock::REMOVE), |
451 |
|
sigc::mem_fun(*this, &MainWindow::on_action_remove_script) |
452 |
|
); |
453 |
|
|
454 |
uiManager = Gtk::UIManager::create(); |
uiManager = Gtk::UIManager::create(); |
455 |
uiManager->insert_action_group(actionGroup); |
uiManager->insert_action_group(actionGroup); |
469 |
" <separator/>" |
" <separator/>" |
470 |
" <menuitem action='Quit'/>" |
" <menuitem action='Quit'/>" |
471 |
" </menu>" |
" </menu>" |
472 |
|
" <menu action='MenuEdit'>" |
473 |
|
" <menuitem action='CopyDimRgn'/>" |
474 |
|
" <menuitem action='AdjustClipboard'/>" |
475 |
|
" <menuitem action='PasteDimRgn'/>" |
476 |
|
" <separator/>" |
477 |
|
" <menuitem action='SelectPrevRegion'/>" |
478 |
|
" <menuitem action='SelectNextRegion'/>" |
479 |
|
" <separator/>" |
480 |
|
" <menuitem action='SelectPrevDimension'/>" |
481 |
|
" <menuitem action='SelectNextDimension'/>" |
482 |
|
" <menuitem action='SelectPrevDimRgnZone'/>" |
483 |
|
" <menuitem action='SelectNextDimRgnZone'/>" |
484 |
|
" <menuitem action='SelectAddPrevDimRgnZone'/>" |
485 |
|
" <menuitem action='SelectAddNextDimRgnZone'/>" |
486 |
|
" <separator/>" |
487 |
|
" <menuitem action='CopySampleUnity'/>" |
488 |
|
" <menuitem action='CopySampleTune'/>" |
489 |
|
" <menuitem action='CopySampleLoop'/>" |
490 |
|
" </menu>" |
491 |
|
" <menu action='MenuMacro'>" |
492 |
|
" </menu>" |
493 |
|
" <menu action='MenuSample'>" |
494 |
|
" <menuitem action='SampleProperties'/>" |
495 |
|
" <menuitem action='AddGroup'/>" |
496 |
|
" <menuitem action='AddSample'/>" |
497 |
|
" <menuitem action='ShowSampleRefs'/>" |
498 |
|
" <menuitem action='ReplaceSample' />" |
499 |
|
" <menuitem action='ReplaceAllSamplesInAllGroups' />" |
500 |
|
" <separator/>" |
501 |
|
" <menuitem action='RemoveSample'/>" |
502 |
|
" <menuitem action='RemoveUnusedSamples'/>" |
503 |
|
" </menu>" |
504 |
" <menu action='MenuInstrument'>" |
" <menu action='MenuInstrument'>" |
505 |
|
" <menu action='AllInstruments'>" |
506 |
|
" </menu>" |
507 |
|
" <separator/>" |
508 |
|
" <menuitem action='InstrProperties'/>" |
509 |
|
" <menuitem action='MidiRules'/>" |
510 |
|
" <menuitem action='ScriptSlots'/>" |
511 |
|
" <menuitem action='AddInstrument'/>" |
512 |
|
" <menuitem action='DupInstrument'/>" |
513 |
|
" <menuitem action='CombInstruments'/>" |
514 |
|
" <separator/>" |
515 |
|
" <menuitem action='RemoveInstrument'/>" |
516 |
|
" </menu>" |
517 |
|
" <menu action='MenuScript'>" |
518 |
|
" <menuitem action='AddScriptGroup'/>" |
519 |
|
" <menuitem action='AddScript'/>" |
520 |
|
" <menuitem action='EditScript'/>" |
521 |
|
" <separator/>" |
522 |
|
" <menuitem action='RemoveScript'/>" |
523 |
" </menu>" |
" </menu>" |
524 |
" <menu action='MenuView'>" |
" <menu action='MenuView'>" |
525 |
" <menuitem action='Statusbar'/>" |
" <menuitem action='Statusbar'/>" |
526 |
|
" <menuitem action='AutoRestoreWinDim'/>" |
527 |
|
" <separator/>" |
528 |
|
" <menuitem action='RefreshAll'/>" |
529 |
|
" </menu>" |
530 |
|
" <menu action='MenuTools'>" |
531 |
|
" <menuitem action='CombineInstruments'/>" |
532 |
|
" <menuitem action='MergeFiles'/>" |
533 |
|
" </menu>" |
534 |
|
" <menu action='MenuSettings'>" |
535 |
|
" <menuitem action='WarnUserOnExtensions'/>" |
536 |
|
" <menuitem action='SyncSamplerInstrumentSelection'/>" |
537 |
|
" <menuitem action='MoveRootNoteWithRegionMoved'/>" |
538 |
|
" <menuitem action='SaveWithTemporaryFile'/>" |
539 |
" </menu>" |
" </menu>" |
540 |
" <menu action='MenuHelp'>" |
" <menu action='MenuHelp'>" |
541 |
" <menuitem action='About'/>" |
" <menuitem action='About'/>" |
543 |
" </menubar>" |
" </menubar>" |
544 |
" <popup name='PopupMenu'>" |
" <popup name='PopupMenu'>" |
545 |
" <menuitem action='InstrProperties'/>" |
" <menuitem action='InstrProperties'/>" |
546 |
|
" <menuitem action='MidiRules'/>" |
547 |
|
" <menuitem action='ScriptSlots'/>" |
548 |
" <menuitem action='AddInstrument'/>" |
" <menuitem action='AddInstrument'/>" |
549 |
" <menuitem action='DupInstrument'/>" |
" <menuitem action='DupInstrument'/>" |
550 |
|
" <menuitem action='CombInstruments'/>" |
551 |
" <separator/>" |
" <separator/>" |
552 |
" <menuitem action='RemoveInstrument'/>" |
" <menuitem action='RemoveInstrument'/>" |
553 |
" </popup>" |
" </popup>" |
555 |
" <menuitem action='SampleProperties'/>" |
" <menuitem action='SampleProperties'/>" |
556 |
" <menuitem action='AddGroup'/>" |
" <menuitem action='AddGroup'/>" |
557 |
" <menuitem action='AddSample'/>" |
" <menuitem action='AddSample'/>" |
558 |
" <menuitem action='ReplaceAllSamplesInAllGroups' />" |
" <menuitem action='ShowSampleRefs'/>" |
559 |
|
" <menuitem action='ReplaceSample' />" |
560 |
|
" <menuitem action='ReplaceAllSamplesInAllGroups' />" |
561 |
" <separator/>" |
" <separator/>" |
562 |
" <menuitem action='RemoveSample'/>" |
" <menuitem action='RemoveSample'/>" |
563 |
|
" <menuitem action='RemoveUnusedSamples'/>" |
564 |
|
" </popup>" |
565 |
|
" <popup name='ScriptPopupMenu'>" |
566 |
|
" <menuitem action='AddScriptGroup'/>" |
567 |
|
" <menuitem action='AddScript'/>" |
568 |
|
" <menuitem action='EditScript'/>" |
569 |
|
" <separator/>" |
570 |
|
" <menuitem action='RemoveScript'/>" |
571 |
" </popup>" |
" </popup>" |
572 |
"</ui>"; |
"</ui>"; |
573 |
uiManager->add_ui_from_string(ui_info); |
uiManager->add_ui_from_string(ui_info); |
574 |
|
|
575 |
popup_menu = dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/PopupMenu")); |
popup_menu = dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/PopupMenu")); |
576 |
|
|
577 |
|
// Set tooltips for menu items (for some reason, setting a tooltip on the |
578 |
|
// respective Gtk::Action objects above will simply be ignored, no matter |
579 |
|
// if using Gtk::Action::set_tooltip() or passing the tooltip string on |
580 |
|
// Gtk::Action::create()). |
581 |
|
{ |
582 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
583 |
|
uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity")); |
584 |
|
item->set_tooltip_text(_("Used when dragging a sample to a region's sample reference field. You may disable this for example if you want to replace an existing sample in a region with a new sample, but don't want that the region's current unity note setting will be altered by this action.")); |
585 |
|
} |
586 |
|
{ |
587 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
588 |
|
uiManager->get_widget("/MenuBar/MenuEdit/CopySampleTune")); |
589 |
|
item->set_tooltip_text(_("Used when dragging a sample to a region's sample reference field. You may disable this for example if you want to replace an existing sample in a region with a new sample, but don't want that the region's current sample playback tuning will be altered by this action.")); |
590 |
|
} |
591 |
|
{ |
592 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
593 |
|
uiManager->get_widget("/MenuBar/MenuEdit/CopySampleLoop")); |
594 |
|
item->set_tooltip_text(_("Used when dragging a sample to a region's sample reference field. You may disable this for example if you want to replace an existing sample in a region with a new sample, but don't want that the region's current loop informations to be altered by this action.")); |
595 |
|
} |
596 |
|
{ |
597 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
598 |
|
uiManager->get_widget("/MenuBar/MenuSettings/WarnUserOnExtensions")); |
599 |
|
item->set_tooltip_text(_("If checked, a warning will be shown whenever you try to use a feature which is based on a LinuxSampler extension ontop of the original gig format, which would not work with the Gigasampler/GigaStudio application.")); |
600 |
|
} |
601 |
|
{ |
602 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
603 |
|
uiManager->get_widget("/MenuBar/MenuSettings/SyncSamplerInstrumentSelection")); |
604 |
|
item->set_tooltip_text(_("If checked, the sampler's current instrument will automatically be switched whenever another instrument was selected in gigedit (only available in live-mode).")); |
605 |
|
} |
606 |
|
{ |
607 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
608 |
|
uiManager->get_widget("/MenuBar/MenuSettings/MoveRootNoteWithRegionMoved")); |
609 |
|
item->set_tooltip_text(_("If checked, and when a region is moved by dragging it around on the virtual keyboard, the keybord position dependent pitch will move exactly with the amount of semi tones the region was moved around.")); |
610 |
|
} |
611 |
|
{ |
612 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
613 |
|
uiManager->get_widget("/MenuBar/MenuSample/RemoveUnusedSamples")); |
614 |
|
item->set_tooltip_text(_("Removes all samples that are not referenced by any instrument (i.e. red ones).")); |
615 |
|
// copy tooltip to popup menu |
616 |
|
Gtk::MenuItem* item2 = dynamic_cast<Gtk::MenuItem*>( |
617 |
|
uiManager->get_widget("/SamplePopupMenu/RemoveUnusedSamples")); |
618 |
|
item2->set_tooltip_text(item->get_tooltip_text()); |
619 |
|
} |
620 |
|
{ |
621 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
622 |
|
uiManager->get_widget("/MenuBar/MenuView/RefreshAll")); |
623 |
|
item->set_tooltip_text(_("Reloads the currently open gig file and updates the entire graphical user interface.")); |
624 |
|
} |
625 |
|
{ |
626 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
627 |
|
uiManager->get_widget("/MenuBar/MenuView/AutoRestoreWinDim")); |
628 |
|
item->set_tooltip_text(_("If checked, size and position of all windows will be saved and automatically restored next time.")); |
629 |
|
} |
630 |
|
{ |
631 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
632 |
|
uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments")); |
633 |
|
item->set_tooltip_text(_("Create combi sounds out of individual sounds of this .gig file.")); |
634 |
|
} |
635 |
|
{ |
636 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
637 |
|
uiManager->get_widget("/MenuBar/MenuTools/MergeFiles")); |
638 |
|
item->set_tooltip_text(_("Add instruments and samples of other .gig files to this .gig file.")); |
639 |
|
} |
640 |
|
|
641 |
|
|
642 |
|
instrument_menu = static_cast<Gtk::MenuItem*>( |
643 |
|
uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments"))->get_submenu(); |
644 |
|
|
645 |
Gtk::Widget* menuBar = uiManager->get_widget("/MenuBar"); |
Gtk::Widget* menuBar = uiManager->get_widget("/MenuBar"); |
646 |
m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK); |
m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK); |
666 |
// Create the Tree model: |
// Create the Tree model: |
667 |
m_refTreeModel = Gtk::ListStore::create(m_Columns); |
m_refTreeModel = Gtk::ListStore::create(m_Columns); |
668 |
m_TreeView.set_model(m_refTreeModel); |
m_TreeView.set_model(m_refTreeModel); |
669 |
m_refTreeModel->signal_row_changed().connect( |
m_TreeView.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE); |
670 |
|
m_TreeView.set_tooltip_text(_("Right click here for actions on instruments & MIDI Rules. Drag & drop to change the order of instruments.")); |
671 |
|
instrument_name_connection = m_refTreeModel->signal_row_changed().connect( |
672 |
sigc::mem_fun(*this, &MainWindow::instrument_name_changed) |
sigc::mem_fun(*this, &MainWindow::instrument_name_changed) |
673 |
); |
); |
674 |
|
|
675 |
// Add the TreeView's view columns: |
// Add the TreeView's view columns: |
676 |
m_TreeView.append_column_editable("Instrument", m_Columns.m_col_name); |
m_TreeView.append_column(_("Nr"), m_Columns.m_col_nr); |
677 |
m_TreeView.set_headers_visible(false); |
m_TreeView.append_column_editable(_("Instrument"), m_Columns.m_col_name); |
678 |
|
m_TreeView.append_column(_("Scripts"), m_Columns.m_col_scripts); |
679 |
|
m_TreeView.set_headers_visible(true); |
680 |
|
|
681 |
|
// establish drag&drop within the instrument tree view, allowing to reorder |
682 |
|
// the sequence of instruments within the gig file |
683 |
|
{ |
684 |
|
std::vector<Gtk::TargetEntry> drag_target_instrument; |
685 |
|
drag_target_instrument.push_back(Gtk::TargetEntry("gig::Instrument")); |
686 |
|
m_TreeView.drag_source_set(drag_target_instrument); |
687 |
|
m_TreeView.drag_dest_set(drag_target_instrument); |
688 |
|
m_TreeView.signal_drag_begin().connect( |
689 |
|
sigc::mem_fun(*this, &MainWindow::on_instruments_treeview_drag_begin) |
690 |
|
); |
691 |
|
m_TreeView.signal_drag_data_get().connect( |
692 |
|
sigc::mem_fun(*this, &MainWindow::on_instruments_treeview_drag_data_get) |
693 |
|
); |
694 |
|
m_TreeView.signal_drag_data_received().connect( |
695 |
|
sigc::mem_fun(*this, &MainWindow::on_instruments_treeview_drop_drag_data_received) |
696 |
|
); |
697 |
|
} |
698 |
|
|
699 |
// create samples treeview (including its data model) |
// create samples treeview (including its data model) |
700 |
m_refSamplesTreeModel = SamplesTreeStore::create(m_SamplesModel); |
m_refSamplesTreeModel = SamplesTreeStore::create(m_SamplesModel); |
701 |
m_TreeViewSamples.set_model(m_refSamplesTreeModel); |
m_TreeViewSamples.set_model(m_refSamplesTreeModel); |
702 |
|
m_TreeViewSamples.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE); |
703 |
|
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.")); |
704 |
// m_TreeViewSamples.set_reorderable(); |
// m_TreeViewSamples.set_reorderable(); |
705 |
m_TreeViewSamples.append_column_editable("Samples", m_SamplesModel.m_col_name); |
m_TreeViewSamples.append_column_editable(_("Name"), m_SamplesModel.m_col_name); |
706 |
m_TreeViewSamples.set_headers_visible(false); |
m_TreeViewSamples.append_column(_("Referenced"), m_SamplesModel.m_col_refcount); |
707 |
|
{ |
708 |
|
Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(0); |
709 |
|
Gtk::CellRendererText* cellrenderer = |
710 |
|
dynamic_cast<Gtk::CellRendererText*>(column->get_first_cell()); |
711 |
|
column->add_attribute( |
712 |
|
cellrenderer->property_foreground(), m_SamplesModel.m_color |
713 |
|
); |
714 |
|
} |
715 |
|
{ |
716 |
|
Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(1); |
717 |
|
Gtk::CellRendererText* cellrenderer = |
718 |
|
dynamic_cast<Gtk::CellRendererText*>(column->get_first_cell()); |
719 |
|
column->add_attribute( |
720 |
|
cellrenderer->property_foreground(), m_SamplesModel.m_color |
721 |
|
); |
722 |
|
} |
723 |
|
m_TreeViewSamples.set_headers_visible(true); |
724 |
m_TreeViewSamples.signal_button_press_event().connect_notify( |
m_TreeViewSamples.signal_button_press_event().connect_notify( |
725 |
sigc::mem_fun(*this, &MainWindow::on_sample_treeview_button_release) |
sigc::mem_fun(*this, &MainWindow::on_sample_treeview_button_release) |
726 |
); |
); |
728 |
sigc::mem_fun(*this, &MainWindow::sample_name_changed) |
sigc::mem_fun(*this, &MainWindow::sample_name_changed) |
729 |
); |
); |
730 |
|
|
731 |
|
// create scripts treeview (including its data model) |
732 |
|
m_refScriptsTreeModel = ScriptsTreeStore::create(m_ScriptsModel); |
733 |
|
m_TreeViewScripts.set_model(m_refScriptsTreeModel); |
734 |
|
m_TreeViewScripts.set_tooltip_text(_( |
735 |
|
"Use CTRL + double click for editing a script." |
736 |
|
"\n\n" |
737 |
|
"Note: instrument scripts are a LinuxSampler extension of the gig " |
738 |
|
"format. This feature will not work with the GigaStudio software!" |
739 |
|
)); |
740 |
|
// m_TreeViewScripts.set_reorderable(); |
741 |
|
m_TreeViewScripts.append_column_editable("Samples", m_ScriptsModel.m_col_name); |
742 |
|
m_TreeViewScripts.set_headers_visible(false); |
743 |
|
m_TreeViewScripts.signal_button_press_event().connect_notify( |
744 |
|
sigc::mem_fun(*this, &MainWindow::on_script_treeview_button_release) |
745 |
|
); |
746 |
|
//FIXME: why the heck does this double click signal_row_activated() only fire while CTRL key is pressed ? |
747 |
|
m_TreeViewScripts.signal_row_activated().connect( |
748 |
|
sigc::mem_fun(*this, &MainWindow::script_double_clicked) |
749 |
|
); |
750 |
|
m_refScriptsTreeModel->signal_row_changed().connect( |
751 |
|
sigc::mem_fun(*this, &MainWindow::script_name_changed) |
752 |
|
); |
753 |
|
|
754 |
|
// establish drag&drop between scripts tree view and ScriptSlots window |
755 |
|
std::vector<Gtk::TargetEntry> drag_target_gig_script; |
756 |
|
drag_target_gig_script.push_back(Gtk::TargetEntry("gig::Script")); |
757 |
|
m_TreeViewScripts.drag_source_set(drag_target_gig_script); |
758 |
|
m_TreeViewScripts.signal_drag_begin().connect( |
759 |
|
sigc::mem_fun(*this, &MainWindow::on_scripts_treeview_drag_begin) |
760 |
|
); |
761 |
|
m_TreeViewScripts.signal_drag_data_get().connect( |
762 |
|
sigc::mem_fun(*this, &MainWindow::on_scripts_treeview_drag_data_get) |
763 |
|
); |
764 |
|
|
765 |
// establish drag&drop between samples tree view and dimension region 'Sample' text entry |
// establish drag&drop between samples tree view and dimension region 'Sample' text entry |
766 |
std::vector<Gtk::TargetEntry> drag_target_gig_sample; |
std::vector<Gtk::TargetEntry> drag_target_gig_sample; |
767 |
drag_target_gig_sample.push_back(Gtk::TargetEntry("gig::Sample")); |
drag_target_gig_sample.push_back(Gtk::TargetEntry("gig::Sample")); |
780 |
sigc::hide(sigc::mem_fun(*this, &MainWindow::file_changed))); |
sigc::hide(sigc::mem_fun(*this, &MainWindow::file_changed))); |
781 |
m_RegionChooser.signal_instrument_changed().connect( |
m_RegionChooser.signal_instrument_changed().connect( |
782 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
783 |
|
m_RegionChooser.signal_instrument_changed().connect( |
784 |
|
sigc::mem_fun(*this, &MainWindow::region_changed)); |
785 |
m_DimRegionChooser.signal_region_changed().connect( |
m_DimRegionChooser.signal_region_changed().connect( |
786 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
787 |
instrumentProps.signal_instrument_changed().connect( |
instrumentProps.signal_changed().connect( |
788 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
789 |
propDialog.signal_info_changed().connect( |
propDialog.signal_changed().connect( |
790 |
|
sigc::mem_fun(*this, &MainWindow::file_changed)); |
791 |
|
midiRules.signal_changed().connect( |
792 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
793 |
|
|
794 |
dimreg_edit.signal_dimreg_to_be_changed().connect( |
dimreg_edit.signal_dimreg_to_be_changed().connect( |
797 |
dimreg_changed_signal.make_slot()); |
dimreg_changed_signal.make_slot()); |
798 |
dimreg_edit.signal_sample_ref_changed().connect( |
dimreg_edit.signal_sample_ref_changed().connect( |
799 |
sample_ref_changed_signal.make_slot()); |
sample_ref_changed_signal.make_slot()); |
800 |
|
sample_ref_changed_signal.connect( |
801 |
|
sigc::mem_fun(*this, &MainWindow::on_sample_ref_changed) |
802 |
|
); |
803 |
|
samples_to_be_removed_signal.connect( |
804 |
|
sigc::mem_fun(*this, &MainWindow::on_samples_to_be_removed) |
805 |
|
); |
806 |
|
|
807 |
|
dimreg_edit.signal_select_sample().connect( |
808 |
|
sigc::mem_fun(*this, &MainWindow::select_sample) |
809 |
|
); |
810 |
|
|
811 |
m_RegionChooser.signal_instrument_struct_to_be_changed().connect( |
m_RegionChooser.signal_instrument_struct_to_be_changed().connect( |
812 |
sigc::hide( |
sigc::hide( |
848 |
|
|
849 |
// start with a new gig file by default |
// start with a new gig file by default |
850 |
on_action_file_new(); |
on_action_file_new(); |
851 |
|
|
852 |
|
// select 'Instruments' tab by default |
853 |
|
// (gtk allows this only if the tab childs are visible, thats why it's here) |
854 |
|
m_TreeViewNotebook.set_current_page(1); |
855 |
|
|
856 |
|
Gtk::Clipboard::get()->signal_owner_change().connect( |
857 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_owner_change) |
858 |
|
); |
859 |
|
updateClipboardPasteAvailable(); |
860 |
|
updateClipboardCopyAvailable(); |
861 |
|
|
862 |
|
// setup macros and their keyboard accelerators |
863 |
|
{ |
864 |
|
Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>( |
865 |
|
uiManager->get_widget("/MenuBar/MenuMacro") |
866 |
|
)->get_submenu(); |
867 |
|
|
868 |
|
const Gdk::ModifierType noModifier = (Gdk::ModifierType)0; |
869 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_0", GDK_KEY_F1, noModifier); |
870 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_1", GDK_KEY_F2, noModifier); |
871 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_2", GDK_KEY_F3, noModifier); |
872 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_3", GDK_KEY_F4, noModifier); |
873 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_4", GDK_KEY_F5, noModifier); |
874 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_5", GDK_KEY_F6, noModifier); |
875 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_6", GDK_KEY_F7, noModifier); |
876 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_7", GDK_KEY_F8, noModifier); |
877 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_8", GDK_KEY_F9, noModifier); |
878 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_9", GDK_KEY_F10, noModifier); |
879 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_10", GDK_KEY_F11, noModifier); |
880 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_11", GDK_KEY_F12, noModifier); |
881 |
|
Gtk::AccelMap::add_entry("<Macros>/SetupMacros", 'm', primaryModifierKey); |
882 |
|
|
883 |
|
Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group(); |
884 |
|
menuMacro->set_accel_group(accelGroup); |
885 |
|
|
886 |
|
updateMacroMenu(); |
887 |
|
} |
888 |
|
|
889 |
|
Glib::signal_idle().connect_once( |
890 |
|
sigc::mem_fun(*this, &MainWindow::bringToFront), |
891 |
|
200 |
892 |
|
); |
893 |
} |
} |
894 |
|
|
895 |
MainWindow::~MainWindow() |
MainWindow::~MainWindow() |
896 |
{ |
{ |
897 |
} |
} |
898 |
|
|
899 |
|
void MainWindow::bringToFront() { |
900 |
|
#if defined(__APPLE__) |
901 |
|
macRaiseAppWindow(); |
902 |
|
#endif |
903 |
|
raise(); |
904 |
|
present(); |
905 |
|
} |
906 |
|
|
907 |
|
void MainWindow::updateMacroMenu() { |
908 |
|
Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>( |
909 |
|
uiManager->get_widget("/MenuBar/MenuMacro") |
910 |
|
)->get_submenu(); |
911 |
|
|
912 |
|
// remove all entries from "Macro" menu |
913 |
|
{ |
914 |
|
const std::vector<Gtk::Widget*> children = menuMacro->get_children(); |
915 |
|
for (int i = 0; i < children.size(); ++i) { |
916 |
|
Gtk::Widget* child = children[i]; |
917 |
|
menuMacro->remove(*child); |
918 |
|
delete child; |
919 |
|
} |
920 |
|
} |
921 |
|
|
922 |
|
// (re)load all macros from config file |
923 |
|
try { |
924 |
|
Settings::singleton()->loadMacros(m_macros); |
925 |
|
} catch (Serialization::Exception e) { |
926 |
|
std::cerr << "Exception while loading macros: " << e.Message << std::endl; |
927 |
|
} catch (...) { |
928 |
|
std::cerr << "Unknown exception while loading macros!" << std::endl; |
929 |
|
} |
930 |
|
|
931 |
|
// add all configured macros as menu items to the "Macro" menu |
932 |
|
for (int iMacro = 0; iMacro < m_macros.size(); ++iMacro) { |
933 |
|
const Serialization::Archive& macro = m_macros[iMacro]; |
934 |
|
std::string name = |
935 |
|
macro.name().empty() ? |
936 |
|
(std::string(_("Unnamed Macro")) + " " + ToString(iMacro+1)) : macro.name(); |
937 |
|
Gtk::MenuItem* item = new Gtk::MenuItem(name); |
938 |
|
item->signal_activate().connect( |
939 |
|
sigc::bind( |
940 |
|
sigc::mem_fun(*this, &MainWindow::onMacroSelected), iMacro |
941 |
|
) |
942 |
|
); |
943 |
|
menuMacro->append(*item); |
944 |
|
item->set_accel_path("<Macros>/macro_" + ToString(iMacro)); |
945 |
|
Glib::ustring comment = macro.comment(); |
946 |
|
if (!comment.empty()) |
947 |
|
item->set_tooltip_text(comment); |
948 |
|
} |
949 |
|
// if there are no macros configured at all, then show a dummy entry instead |
950 |
|
if (m_macros.empty()) { |
951 |
|
Gtk::MenuItem* item = new Gtk::MenuItem(_("No Macros")); |
952 |
|
item->set_sensitive(false); |
953 |
|
menuMacro->append(*item); |
954 |
|
} |
955 |
|
|
956 |
|
// add separator line to menu |
957 |
|
menuMacro->append(*new Gtk::SeparatorMenuItem); |
958 |
|
|
959 |
|
{ |
960 |
|
Gtk::MenuItem* item = new Gtk::MenuItem(_("Setup Macros ...")); |
961 |
|
item->signal_activate().connect( |
962 |
|
sigc::mem_fun(*this, &MainWindow::setupMacros) |
963 |
|
); |
964 |
|
menuMacro->append(*item); |
965 |
|
item->set_accel_path("<Macros>/SetupMacros"); |
966 |
|
} |
967 |
|
|
968 |
|
menuMacro->show_all_children(); |
969 |
|
} |
970 |
|
|
971 |
|
void MainWindow::onMacroSelected(int iMacro) { |
972 |
|
printf("onMacroSelected(%d)\n", iMacro); |
973 |
|
if (iMacro < 0 || iMacro >= m_macros.size()) return; |
974 |
|
Glib::ustring errorText; |
975 |
|
try { |
976 |
|
applyMacro(m_macros[iMacro]); |
977 |
|
} catch (Serialization::Exception e) { |
978 |
|
errorText = e.Message; |
979 |
|
} catch (...) { |
980 |
|
errorText = _("Unknown exception while applying macro"); |
981 |
|
} |
982 |
|
if (!errorText.empty()) { |
983 |
|
Glib::ustring txt = _("Applying macro failed:\n") + errorText; |
984 |
|
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
985 |
|
msg.run(); |
986 |
|
} |
987 |
|
} |
988 |
|
|
989 |
|
void MainWindow::setupMacros() { |
990 |
|
MacrosSetup* setup = new MacrosSetup(); |
991 |
|
gig::DimensionRegion* pDimRgn = m_DimRegionChooser.get_main_dimregion(); |
992 |
|
setup->setMacros(m_macros, &m_serializationArchive, pDimRgn); |
993 |
|
setup->signal_macros_changed().connect( |
994 |
|
sigc::mem_fun(*this, &MainWindow::onMacrosSetupChanged) |
995 |
|
); |
996 |
|
setup->show(); |
997 |
|
} |
998 |
|
|
999 |
|
void MainWindow::onMacrosSetupChanged(const std::vector<Serialization::Archive>& macros) { |
1000 |
|
m_macros = macros; |
1001 |
|
Settings::singleton()->saveMacros(m_macros); |
1002 |
|
updateMacroMenu(); |
1003 |
|
} |
1004 |
|
|
1005 |
bool MainWindow::on_delete_event(GdkEventAny* event) |
bool MainWindow::on_delete_event(GdkEventAny* event) |
1006 |
{ |
{ |
1007 |
return !file_is_shared && file_is_changed && !close_confirmation_dialog(); |
return !file_is_shared && file_is_changed && !close_confirmation_dialog(); |
1021 |
gig::Instrument* MainWindow::get_instrument() |
gig::Instrument* MainWindow::get_instrument() |
1022 |
{ |
{ |
1023 |
gig::Instrument* instrument = 0; |
gig::Instrument* instrument = 0; |
1024 |
Glib::RefPtr<Gtk::TreeSelection> tree_sel_ref = m_TreeView.get_selection(); |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
1025 |
|
if (rows.empty()) return NULL; |
1026 |
Gtk::TreeModel::iterator it = tree_sel_ref->get_selected(); |
Gtk::TreeModel::const_iterator it = m_refTreeModel->get_iter(rows[0]); |
1027 |
if (it) { |
if (it) { |
1028 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
1029 |
instrument = row[m_Columns.m_col_instr]; |
instrument = row[m_Columns.m_col_instr]; |
1066 |
add_region_to_dimregs(region, stereo, all_dimregs); |
add_region_to_dimregs(region, stereo, all_dimregs); |
1067 |
} |
} |
1068 |
} |
} |
1069 |
|
|
1070 |
|
m_RegionChooser.setModifyAllRegions(all_regions); |
1071 |
|
m_DimRegionChooser.setModifyAllRegions(all_regions); |
1072 |
|
m_DimRegionChooser.setModifyAllDimensionRegions(all_dimregs); |
1073 |
|
m_DimRegionChooser.setModifyBothChannels(stereo); |
1074 |
|
|
1075 |
|
updateClipboardCopyAvailable(); |
1076 |
} |
} |
1077 |
|
|
1078 |
void MainWindow::dimreg_all_dimregs_toggled() |
void MainWindow::dimreg_all_dimregs_toggled() |
1084 |
void MainWindow::dimreg_changed() |
void MainWindow::dimreg_changed() |
1085 |
{ |
{ |
1086 |
update_dimregs(); |
update_dimregs(); |
1087 |
dimreg_edit.set_dim_region(m_DimRegionChooser.get_dimregion()); |
dimreg_edit.set_dim_region(m_DimRegionChooser.get_main_dimregion()); |
1088 |
} |
} |
1089 |
|
|
1090 |
void MainWindow::on_sel_change() |
void MainWindow::on_sel_change() |
1091 |
{ |
{ |
1092 |
|
// select item in instrument menu |
1093 |
|
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
1094 |
|
if (!rows.empty()) { |
1095 |
|
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
1096 |
|
if (it) { |
1097 |
|
Gtk::TreePath path(it); |
1098 |
|
int index = path[0]; |
1099 |
|
const std::vector<Gtk::Widget*> children = |
1100 |
|
instrument_menu->get_children(); |
1101 |
|
static_cast<Gtk::RadioMenuItem*>(children[index])->set_active(); |
1102 |
|
} |
1103 |
|
} |
1104 |
|
|
1105 |
m_RegionChooser.set_instrument(get_instrument()); |
m_RegionChooser.set_instrument(get_instrument()); |
1106 |
|
|
1107 |
|
if (Settings::singleton()->syncSamplerInstrumentSelection) { |
1108 |
|
switch_sampler_instrument_signal.emit(get_instrument()); |
1109 |
|
} |
1110 |
} |
} |
1111 |
|
|
1112 |
void loader_progress_callback(gig::progress_t* progress) |
void loader_progress_callback(gig::progress_t* progress) |
1124 |
progress_dispatcher(); |
progress_dispatcher(); |
1125 |
} |
} |
1126 |
|
|
1127 |
|
#if defined(WIN32) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) |
1128 |
|
// make sure stack is 16-byte aligned for SSE instructions |
1129 |
|
__attribute__((force_align_arg_pointer)) |
1130 |
|
#endif |
1131 |
void Loader::thread_function() |
void Loader::thread_function() |
1132 |
{ |
{ |
1133 |
printf("thread_function self=%x\n", Glib::Threads::Thread::self()); |
printf("thread_function self=%p\n", |
1134 |
printf("Start %s\n", filename); |
static_cast<void*>(Glib::Threads::Thread::self())); |
1135 |
RIFF::File* riff = new RIFF::File(filename); |
printf("Start %s\n", filename.c_str()); |
1136 |
gig = new gig::File(riff); |
try { |
1137 |
gig::progress_t progress; |
RIFF::File* riff = new RIFF::File(filename); |
1138 |
progress.callback = loader_progress_callback; |
gig = new gig::File(riff); |
1139 |
progress.custom = this; |
gig::progress_t progress; |
1140 |
|
progress.callback = loader_progress_callback; |
1141 |
gig->GetInstrument(0, &progress); |
progress.custom = this; |
1142 |
printf("End\n"); |
|
1143 |
finished_dispatcher(); |
gig->GetInstrument(0, &progress); |
1144 |
|
printf("End\n"); |
1145 |
|
finished_dispatcher(); |
1146 |
|
} catch (RIFF::Exception e) { |
1147 |
|
error_message = e.Message; |
1148 |
|
error_dispatcher.emit(); |
1149 |
|
} catch (...) { |
1150 |
|
error_message = _("Unknown exception occurred"); |
1151 |
|
error_dispatcher.emit(); |
1152 |
|
} |
1153 |
} |
} |
1154 |
|
|
1155 |
Loader::Loader(const char* filename) |
Loader::Loader(const char* filename) |
1156 |
: filename(filename), thread(0) |
: filename(filename), gig(0), thread(0), progress(0.f) |
1157 |
{ |
{ |
1158 |
} |
} |
1159 |
|
|
1164 |
#else |
#else |
1165 |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Loader::thread_function)); |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Loader::thread_function)); |
1166 |
#endif |
#endif |
1167 |
printf("launch thread=%x\n", thread); |
printf("launch thread=%p\n", static_cast<void*>(thread)); |
1168 |
} |
} |
1169 |
|
|
1170 |
float Loader::get_progress() |
float Loader::get_progress() |
1187 |
return finished_dispatcher; |
return finished_dispatcher; |
1188 |
} |
} |
1189 |
|
|
1190 |
LoadDialog::LoadDialog(const Glib::ustring& title, Gtk::Window& parent) |
Glib::Dispatcher& Loader::signal_error() |
1191 |
|
{ |
1192 |
|
return error_dispatcher; |
1193 |
|
} |
1194 |
|
|
1195 |
|
void saver_progress_callback(gig::progress_t* progress) |
1196 |
|
{ |
1197 |
|
Saver* saver = static_cast<Saver*>(progress->custom); |
1198 |
|
saver->progress_callback(progress->factor); |
1199 |
|
} |
1200 |
|
|
1201 |
|
void Saver::progress_callback(float fraction) |
1202 |
|
{ |
1203 |
|
{ |
1204 |
|
Glib::Threads::Mutex::Lock lock(progressMutex); |
1205 |
|
progress = fraction; |
1206 |
|
} |
1207 |
|
progress_dispatcher.emit(); |
1208 |
|
} |
1209 |
|
|
1210 |
|
#if defined(WIN32) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) |
1211 |
|
// make sure stack is 16-byte aligned for SSE instructions |
1212 |
|
__attribute__((force_align_arg_pointer)) |
1213 |
|
#endif |
1214 |
|
void Saver::thread_function() |
1215 |
|
{ |
1216 |
|
printf("thread_function self=%p\n", |
1217 |
|
static_cast<void*>(Glib::Threads::Thread::self())); |
1218 |
|
printf("Start %s\n", filename.c_str()); |
1219 |
|
try { |
1220 |
|
gig::progress_t progress; |
1221 |
|
progress.callback = saver_progress_callback; |
1222 |
|
progress.custom = this; |
1223 |
|
|
1224 |
|
// if no filename was provided, that means "save", if filename was provided means "save as" |
1225 |
|
if (filename.empty()) { |
1226 |
|
if (!Settings::singleton()->saveWithTemporaryFile) { |
1227 |
|
// save directly over the existing .gig file |
1228 |
|
// (requires less disk space than solution below |
1229 |
|
// but may be slower) |
1230 |
|
gig->Save(&progress); |
1231 |
|
} else { |
1232 |
|
// save the file as separate temporary file first, |
1233 |
|
// then move the saved file over the old file |
1234 |
|
// (may result in performance speedup during save) |
1235 |
|
gig::String tmpname = filename + ".TMP"; |
1236 |
|
gig->Save(tmpname, &progress); |
1237 |
|
#if defined(WIN32) |
1238 |
|
if (!DeleteFile(filename.c_str())) { |
1239 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file)."); |
1240 |
|
} |
1241 |
|
#else // POSIX ... |
1242 |
|
if (unlink(filename.c_str())) { |
1243 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file): " + gig::String(strerror(errno))); |
1244 |
|
} |
1245 |
|
#endif |
1246 |
|
if (rename(tmpname.c_str(), filename.c_str())) { |
1247 |
|
#if defined(WIN32) |
1248 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file)."); |
1249 |
|
#else |
1250 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file): " + gig::String(strerror(errno))); |
1251 |
|
#endif |
1252 |
|
} |
1253 |
|
} |
1254 |
|
} else { |
1255 |
|
gig->Save(filename, &progress); |
1256 |
|
} |
1257 |
|
|
1258 |
|
printf("End\n"); |
1259 |
|
finished_dispatcher.emit(); |
1260 |
|
} catch (RIFF::Exception e) { |
1261 |
|
error_message = e.Message; |
1262 |
|
error_dispatcher.emit(); |
1263 |
|
} catch (...) { |
1264 |
|
error_message = _("Unknown exception occurred"); |
1265 |
|
error_dispatcher.emit(); |
1266 |
|
} |
1267 |
|
} |
1268 |
|
|
1269 |
|
Saver::Saver(gig::File* file, Glib::ustring filename) |
1270 |
|
: gig(file), filename(filename), thread(0), progress(0.f) |
1271 |
|
{ |
1272 |
|
} |
1273 |
|
|
1274 |
|
void Saver::launch() |
1275 |
|
{ |
1276 |
|
#ifdef OLD_THREADS |
1277 |
|
thread = Glib::Thread::create(sigc::mem_fun(*this, &Saver::thread_function), true); |
1278 |
|
#else |
1279 |
|
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Saver::thread_function)); |
1280 |
|
#endif |
1281 |
|
printf("launch thread=%p\n", static_cast<void*>(thread)); |
1282 |
|
} |
1283 |
|
|
1284 |
|
float Saver::get_progress() |
1285 |
|
{ |
1286 |
|
float res; |
1287 |
|
{ |
1288 |
|
Glib::Threads::Mutex::Lock lock(progressMutex); |
1289 |
|
res = progress; |
1290 |
|
} |
1291 |
|
return res; |
1292 |
|
} |
1293 |
|
|
1294 |
|
Glib::Dispatcher& Saver::signal_progress() |
1295 |
|
{ |
1296 |
|
return progress_dispatcher; |
1297 |
|
} |
1298 |
|
|
1299 |
|
Glib::Dispatcher& Saver::signal_finished() |
1300 |
|
{ |
1301 |
|
return finished_dispatcher; |
1302 |
|
} |
1303 |
|
|
1304 |
|
Glib::Dispatcher& Saver::signal_error() |
1305 |
|
{ |
1306 |
|
return error_dispatcher; |
1307 |
|
} |
1308 |
|
|
1309 |
|
ProgressDialog::ProgressDialog(const Glib::ustring& title, Gtk::Window& parent) |
1310 |
: Gtk::Dialog(title, parent, true) |
: Gtk::Dialog(title, parent, true) |
1311 |
{ |
{ |
1312 |
get_vbox()->pack_start(progressBar); |
get_vbox()->pack_start(progressBar); |
1313 |
show_all_children(); |
show_all_children(); |
1314 |
|
resize(600,50); |
1315 |
} |
} |
1316 |
|
|
1317 |
// Clear all GUI elements / controls. This method is typically called |
// Clear all GUI elements / controls. This method is typically called |
1318 |
// before a new .gig file is to be created or to be loaded. |
// before a new .gig file is to be created or to be loaded. |
1319 |
void MainWindow::__clear() { |
void MainWindow::__clear() { |
|
// remove all entries from "Instrument" menu |
|
|
Gtk::MenuItem* instrument_menu = |
|
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuInstrument")); |
|
|
instrument_menu->hide(); |
|
|
Gtk::Menu* menu = instrument_menu->get_submenu(); |
|
|
while (menu->get_children().size()) { |
|
|
Gtk::Widget* child = *menu->get_children().begin(); |
|
|
menu->remove(*child); |
|
|
delete child; |
|
|
} |
|
1320 |
// forget all samples that ought to be imported |
// forget all samples that ought to be imported |
1321 |
m_SampleImportQueue.clear(); |
m_SampleImportQueue.clear(); |
1322 |
// clear the samples and instruments tree views |
// clear the samples and instruments tree views |
1323 |
m_refTreeModel->clear(); |
m_refTreeModel->clear(); |
1324 |
m_refSamplesTreeModel->clear(); |
m_refSamplesTreeModel->clear(); |
1325 |
|
m_refScriptsTreeModel->clear(); |
1326 |
|
// remove all entries from "Instrument" menu |
1327 |
|
while (!instrument_menu->get_children().empty()) { |
1328 |
|
remove_instrument_from_menu(0); |
1329 |
|
} |
1330 |
// free libgig's gig::File instance |
// free libgig's gig::File instance |
1331 |
if (file && !file_is_shared) delete file; |
if (file && !file_is_shared) delete file; |
1332 |
file = NULL; |
file = NULL; |
1333 |
set_file_is_shared(false); |
set_file_is_shared(false); |
1334 |
} |
} |
1335 |
|
|
1336 |
|
void MainWindow::__refreshEntireGUI() { |
1337 |
|
// clear the samples and instruments tree views |
1338 |
|
m_refTreeModel->clear(); |
1339 |
|
m_refSamplesTreeModel->clear(); |
1340 |
|
m_refScriptsTreeModel->clear(); |
1341 |
|
// remove all entries from "Instrument" menu |
1342 |
|
while (!instrument_menu->get_children().empty()) { |
1343 |
|
remove_instrument_from_menu(0); |
1344 |
|
} |
1345 |
|
|
1346 |
|
if (!this->file) return; |
1347 |
|
|
1348 |
|
load_gig( |
1349 |
|
this->file, this->file->pInfo->Name.c_str(), this->file_is_shared |
1350 |
|
); |
1351 |
|
} |
1352 |
|
|
1353 |
void MainWindow::on_action_file_new() |
void MainWindow::on_action_file_new() |
1354 |
{ |
{ |
1355 |
if (!file_is_shared && file_is_changed && !close_confirmation_dialog()) return; |
if (!file_is_shared && file_is_changed && !close_confirmation_dialog()) return; |
1362 |
gig::File* pFile = new gig::File; |
gig::File* pFile = new gig::File; |
1363 |
// already add one new instrument by default |
// already add one new instrument by default |
1364 |
gig::Instrument* pInstrument = pFile->AddInstrument(); |
gig::Instrument* pInstrument = pFile->AddInstrument(); |
1365 |
pInstrument->pInfo->Name = _("Unnamed Instrument"); |
pInstrument->pInfo->Name = gig_from_utf8(_("Unnamed Instrument")); |
1366 |
// update GUI with that new gig::File |
// update GUI with that new gig::File |
1367 |
load_gig(pFile, 0 /*no file name yet*/); |
load_gig(pFile, 0 /*no file name yet*/); |
1368 |
} |
} |
1380 |
dialog.set_default_response(Gtk::RESPONSE_YES); |
dialog.set_default_response(Gtk::RESPONSE_YES); |
1381 |
int response = dialog.run(); |
int response = dialog.run(); |
1382 |
dialog.hide(); |
dialog.hide(); |
1383 |
if (response == Gtk::RESPONSE_YES) return file_save(); |
|
1384 |
return response != Gtk::RESPONSE_CANCEL; |
// user decided to exit app without saving |
1385 |
|
if (response == Gtk::RESPONSE_NO) return true; |
1386 |
|
|
1387 |
|
// user cancelled dialog, thus don't close app |
1388 |
|
if (response == Gtk::RESPONSE_CANCEL) return false; |
1389 |
|
|
1390 |
|
// TODO: the following return valid is disabled and hard coded instead for |
1391 |
|
// now, due to the fact that saving with progress bar is now implemented |
1392 |
|
// asynchronously, as a result the app does not close automatically anymore |
1393 |
|
// after saving the file has completed |
1394 |
|
// |
1395 |
|
// if (response == Gtk::RESPONSE_YES) return file_save(); |
1396 |
|
// return response != Gtk::RESPONSE_CANCEL; |
1397 |
|
// |
1398 |
|
if (response == Gtk::RESPONSE_YES) file_save(); |
1399 |
|
return false; // always prevent closing the app for now (see comment above) |
1400 |
} |
} |
1401 |
|
|
1402 |
bool MainWindow::leaving_shared_mode_dialog() { |
bool MainWindow::leaving_shared_mode_dialog() { |
1438 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
1439 |
std::string filename = dialog.get_filename(); |
std::string filename = dialog.get_filename(); |
1440 |
printf("filename=%s\n", filename.c_str()); |
printf("filename=%s\n", filename.c_str()); |
1441 |
printf("on_action_file_open self=%x\n", Glib::Threads::Thread::self()); |
printf("on_action_file_open self=%p\n", |
1442 |
|
static_cast<void*>(Glib::Threads::Thread::self())); |
1443 |
load_file(filename.c_str()); |
load_file(filename.c_str()); |
1444 |
current_gig_dir = Glib::path_get_dirname(filename); |
current_gig_dir = Glib::path_get_dirname(filename); |
1445 |
} |
} |
1448 |
void MainWindow::load_file(const char* name) |
void MainWindow::load_file(const char* name) |
1449 |
{ |
{ |
1450 |
__clear(); |
__clear(); |
1451 |
load_dialog = new LoadDialog(_("Loading..."), *this); |
|
1452 |
load_dialog->show_all(); |
progress_dialog = new ProgressDialog( //FIXME: memory leak! |
1453 |
loader = new Loader(strdup(name)); |
_("Loading") + Glib::ustring(" '") + |
1454 |
|
Glib::filename_display_basename(name) + "' ...", |
1455 |
|
*this |
1456 |
|
); |
1457 |
|
progress_dialog->show_all(); |
1458 |
|
loader = new Loader(name); //FIXME: memory leak! |
1459 |
loader->signal_progress().connect( |
loader->signal_progress().connect( |
1460 |
sigc::mem_fun(*this, &MainWindow::on_loader_progress)); |
sigc::mem_fun(*this, &MainWindow::on_loader_progress)); |
1461 |
loader->signal_finished().connect( |
loader->signal_finished().connect( |
1462 |
sigc::mem_fun(*this, &MainWindow::on_loader_finished)); |
sigc::mem_fun(*this, &MainWindow::on_loader_finished)); |
1463 |
|
loader->signal_error().connect( |
1464 |
|
sigc::mem_fun(*this, &MainWindow::on_loader_error)); |
1465 |
loader->launch(); |
loader->launch(); |
1466 |
} |
} |
1467 |
|
|
1477 |
// load the instrument |
// load the instrument |
1478 |
gig::File* pFile = (gig::File*) instr->GetParent(); |
gig::File* pFile = (gig::File*) instr->GetParent(); |
1479 |
load_gig(pFile, 0 /*file name*/, true /*shared instrument*/); |
load_gig(pFile, 0 /*file name*/, true /*shared instrument*/); |
1480 |
//TODO: automatically select the given instrument |
// automatically select the given instrument |
1481 |
|
int i = 0; |
1482 |
|
for (gig::Instrument* instrument = pFile->GetFirstInstrument(); instrument; |
1483 |
|
instrument = pFile->GetNextInstrument(), ++i) |
1484 |
|
{ |
1485 |
|
if (instrument == instr) { |
1486 |
|
// select item in "instruments" tree view |
1487 |
|
m_TreeView.get_selection()->select(Gtk::TreePath(ToString(i))); |
1488 |
|
// make sure the selected item in the "instruments" tree view is |
1489 |
|
// visible (scroll to it) |
1490 |
|
m_TreeView.scroll_to_row(Gtk::TreePath(ToString(i))); |
1491 |
|
// select item in instrument menu |
1492 |
|
{ |
1493 |
|
const std::vector<Gtk::Widget*> children = |
1494 |
|
instrument_menu->get_children(); |
1495 |
|
static_cast<Gtk::RadioMenuItem*>(children[i])->set_active(); |
1496 |
|
} |
1497 |
|
// update region chooser and dimension region chooser |
1498 |
|
m_RegionChooser.set_instrument(instr); |
1499 |
|
break; |
1500 |
|
} |
1501 |
|
} |
1502 |
} |
} |
1503 |
|
|
1504 |
void MainWindow::on_loader_progress() |
void MainWindow::on_loader_progress() |
1505 |
{ |
{ |
1506 |
load_dialog->set_fraction(loader->get_progress()); |
progress_dialog->set_fraction(loader->get_progress()); |
1507 |
} |
} |
1508 |
|
|
1509 |
void MainWindow::on_loader_finished() |
void MainWindow::on_loader_finished() |
1510 |
{ |
{ |
1511 |
printf("Loader finished!\n"); |
printf("Loader finished!\n"); |
1512 |
printf("on_loader_finished self=%x\n", Glib::Threads::Thread::self()); |
printf("on_loader_finished self=%p\n", |
1513 |
load_gig(loader->gig, loader->filename); |
static_cast<void*>(Glib::Threads::Thread::self())); |
1514 |
load_dialog->hide(); |
load_gig(loader->gig, loader->filename.c_str()); |
1515 |
|
progress_dialog->hide(); |
1516 |
|
} |
1517 |
|
|
1518 |
|
void MainWindow::on_loader_error() |
1519 |
|
{ |
1520 |
|
Glib::ustring txt = _("Could not load file: ") + loader->error_message; |
1521 |
|
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
1522 |
|
msg.run(); |
1523 |
|
progress_dialog->hide(); |
1524 |
} |
} |
1525 |
|
|
1526 |
void MainWindow::on_action_file_save() |
void MainWindow::on_action_file_save() |
1559 |
|
|
1560 |
std::cout << "Saving file\n" << std::flush; |
std::cout << "Saving file\n" << std::flush; |
1561 |
file_structure_to_be_changed_signal.emit(this->file); |
file_structure_to_be_changed_signal.emit(this->file); |
1562 |
try { |
|
1563 |
file->Save(); |
progress_dialog = new ProgressDialog( //FIXME: memory leak! |
1564 |
if (file_is_changed) { |
_("Saving") + Glib::ustring(" '") + |
1565 |
set_title(get_title().substr(1)); |
Glib::filename_display_basename(this->filename) + "' ...", |
1566 |
file_is_changed = false; |
*this |
1567 |
} |
); |
1568 |
} catch (RIFF::Exception e) { |
progress_dialog->show_all(); |
1569 |
file_structure_changed_signal.emit(this->file); |
saver = new Saver(this->file); //FIXME: memory leak! |
1570 |
Glib::ustring txt = _("Could not save file: ") + e.Message; |
saver->signal_progress().connect( |
1571 |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
sigc::mem_fun(*this, &MainWindow::on_saver_progress)); |
1572 |
msg.run(); |
saver->signal_finished().connect( |
1573 |
return false; |
sigc::mem_fun(*this, &MainWindow::on_saver_finished)); |
1574 |
} |
saver->signal_error().connect( |
1575 |
std::cout << "Saving file done\n" << std::flush; |
sigc::mem_fun(*this, &MainWindow::on_saver_error)); |
1576 |
|
saver->launch(); |
1577 |
|
|
1578 |
|
return true; |
1579 |
|
} |
1580 |
|
|
1581 |
|
void MainWindow::on_saver_progress() |
1582 |
|
{ |
1583 |
|
progress_dialog->set_fraction(saver->get_progress()); |
1584 |
|
} |
1585 |
|
|
1586 |
|
void MainWindow::on_saver_error() |
1587 |
|
{ |
1588 |
|
file_structure_changed_signal.emit(this->file); |
1589 |
|
Glib::ustring txt = _("Could not save file: ") + saver->error_message; |
1590 |
|
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
1591 |
|
msg.run(); |
1592 |
|
} |
1593 |
|
|
1594 |
|
void MainWindow::on_saver_finished() |
1595 |
|
{ |
1596 |
|
this->file = saver->gig; |
1597 |
|
this->filename = saver->filename; |
1598 |
|
current_gig_dir = Glib::path_get_dirname(filename); |
1599 |
|
set_title(Glib::filename_display_basename(filename)); |
1600 |
|
file_has_name = true; |
1601 |
|
file_is_changed = false; |
1602 |
|
std::cout << "Saving file done. Importing queued samples now ...\n" << std::flush; |
1603 |
__import_queued_samples(); |
__import_queued_samples(); |
1604 |
|
std::cout << "Importing queued samples done.\n" << std::flush; |
1605 |
|
|
1606 |
file_structure_changed_signal.emit(this->file); |
file_structure_changed_signal.emit(this->file); |
1607 |
return true; |
|
1608 |
|
__refreshEntireGUI(); |
1609 |
|
progress_dialog->hide(); |
1610 |
} |
} |
1611 |
|
|
1612 |
void MainWindow::on_action_file_save_as() |
void MainWindow::on_action_file_save_as() |
1650 |
// show warning in the dialog |
// show warning in the dialog |
1651 |
Gtk::HBox descriptionArea; |
Gtk::HBox descriptionArea; |
1652 |
descriptionArea.set_spacing(15); |
descriptionArea.set_spacing(15); |
1653 |
Gtk::Image warningIcon(Gtk::Stock::DIALOG_WARNING, Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); |
Gtk::Image warningIcon; |
1654 |
|
warningIcon.set_from_icon_name("dialog-warning", |
1655 |
|
Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); |
1656 |
descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); |
descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); |
1657 |
#if GTKMM_MAJOR_VERSION < 3 |
#if GTKMM_MAJOR_VERSION < 3 |
1658 |
view::WrapLabel description; |
view::WrapLabel description; |
1673 |
descriptionArea.show_all(); |
descriptionArea.show_all(); |
1674 |
|
|
1675 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
1676 |
file_structure_to_be_changed_signal.emit(this->file); |
std::string filename = dialog.get_filename(); |
1677 |
try { |
if (!Glib::str_has_suffix(filename, ".gig")) { |
1678 |
std::string filename = dialog.get_filename(); |
filename += ".gig"; |
|
if (!Glib::str_has_suffix(filename, ".gig")) { |
|
|
filename += ".gig"; |
|
|
} |
|
|
printf("filename=%s\n", filename.c_str()); |
|
|
file->Save(filename); |
|
|
this->filename = filename; |
|
|
current_gig_dir = Glib::path_get_dirname(filename); |
|
|
set_title(Glib::filename_display_basename(filename)); |
|
|
file_has_name = true; |
|
|
file_is_changed = false; |
|
|
} catch (RIFF::Exception e) { |
|
|
file_structure_changed_signal.emit(this->file); |
|
|
Glib::ustring txt = _("Could not save file: ") + e.Message; |
|
|
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
|
|
msg.run(); |
|
|
return false; |
|
1679 |
} |
} |
1680 |
__import_queued_samples(); |
printf("filename=%s\n", filename.c_str()); |
1681 |
file_structure_changed_signal.emit(this->file); |
|
1682 |
|
progress_dialog = new ProgressDialog( //FIXME: memory leak! |
1683 |
|
_("Saving") + Glib::ustring(" '") + |
1684 |
|
Glib::filename_display_basename(filename) + "' ...", |
1685 |
|
*this |
1686 |
|
); |
1687 |
|
progress_dialog->show_all(); |
1688 |
|
|
1689 |
|
saver = new Saver(file, filename); //FIXME: memory leak! |
1690 |
|
saver->signal_progress().connect( |
1691 |
|
sigc::mem_fun(*this, &MainWindow::on_saver_progress)); |
1692 |
|
saver->signal_finished().connect( |
1693 |
|
sigc::mem_fun(*this, &MainWindow::on_saver_finished)); |
1694 |
|
saver->signal_error().connect( |
1695 |
|
sigc::mem_fun(*this, &MainWindow::on_saver_error)); |
1696 |
|
saver->launch(); |
1697 |
|
|
1698 |
return true; |
return true; |
1699 |
} |
} |
1700 |
return false; |
return false; |
1704 |
void MainWindow::__import_queued_samples() { |
void MainWindow::__import_queued_samples() { |
1705 |
std::cout << "Starting sample import\n" << std::flush; |
std::cout << "Starting sample import\n" << std::flush; |
1706 |
Glib::ustring error_files; |
Glib::ustring error_files; |
1707 |
printf("Samples to import: %d\n", m_SampleImportQueue.size()); |
printf("Samples to import: %d\n", int(m_SampleImportQueue.size())); |
1708 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
for (std::map<gig::Sample*, SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
1709 |
iter != m_SampleImportQueue.end(); ) { |
iter != m_SampleImportQueue.end(); ) { |
1710 |
printf("Importing sample %s\n",(*iter).sample_path.c_str()); |
printf("Importing sample %s\n",iter->second.sample_path.c_str()); |
1711 |
SF_INFO info; |
SF_INFO info; |
1712 |
info.format = 0; |
info.format = 0; |
1713 |
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); |
1714 |
|
sf_command(hFile, SFC_SET_SCALE_FLOAT_INT_READ, 0, SF_TRUE); |
1715 |
try { |
try { |
1716 |
if (!hFile) throw std::string(_("could not open file")); |
if (!hFile) throw std::string(_("could not open file")); |
1717 |
// determine sample's bit depth |
// determine sample's bit depth |
1733 |
throw std::string(_("format not supported")); // unsupported subformat (yet?) |
throw std::string(_("format not supported")); // unsupported subformat (yet?) |
1734 |
} |
} |
1735 |
|
|
1736 |
|
// reset write position for sample |
1737 |
|
iter->first->SetPos(0); |
1738 |
|
|
1739 |
const int bufsize = 10000; |
const int bufsize = 10000; |
1740 |
switch (bitdepth) { |
switch (bitdepth) { |
1741 |
case 16: { |
case 16: { |
1745 |
// libsndfile does the conversion for us (if needed) |
// libsndfile does the conversion for us (if needed) |
1746 |
int n = sf_readf_short(hFile, buffer, bufsize); |
int n = sf_readf_short(hFile, buffer, bufsize); |
1747 |
// write from buffer directly (physically) into .gig file |
// write from buffer directly (physically) into .gig file |
1748 |
iter->gig_sample->Write(buffer, n); |
iter->first->Write(buffer, n); |
1749 |
cnt -= n; |
cnt -= n; |
1750 |
} |
} |
1751 |
delete[] buffer; |
delete[] buffer; |
1765 |
dstbuf[j++] = srcbuf[i] >> 24; |
dstbuf[j++] = srcbuf[i] >> 24; |
1766 |
} |
} |
1767 |
// write from buffer directly (physically) into .gig file |
// write from buffer directly (physically) into .gig file |
1768 |
iter->gig_sample->Write(dstbuf, n); |
iter->first->Write(dstbuf, n); |
1769 |
cnt -= n; |
cnt -= n; |
1770 |
} |
} |
1771 |
delete[] srcbuf; |
delete[] srcbuf; |
1776 |
// cleanup |
// cleanup |
1777 |
sf_close(hFile); |
sf_close(hFile); |
1778 |
// let the sampler re-cache the sample if needed |
// let the sampler re-cache the sample if needed |
1779 |
sample_changed_signal.emit(iter->gig_sample); |
sample_changed_signal.emit(iter->first); |
1780 |
// on success we remove the sample from the import queue, |
// on success we remove the sample from the import queue, |
1781 |
// otherwise keep it, maybe it works the next time ? |
// otherwise keep it, maybe it works the next time ? |
1782 |
std::list<SampleImportItem>::iterator cur = iter; |
std::map<gig::Sample*, SampleImportItem>::iterator cur = iter; |
1783 |
++iter; |
++iter; |
1784 |
m_SampleImportQueue.erase(cur); |
m_SampleImportQueue.erase(cur); |
1785 |
} catch (std::string what) { |
} catch (std::string what) { |
1786 |
// remember the files that made trouble (and their cause) |
// remember the files that made trouble (and their cause) |
1787 |
if (error_files.size()) error_files += "\n"; |
if (!error_files.empty()) error_files += "\n"; |
1788 |
error_files += (*iter).sample_path += " (" + what + ")"; |
error_files += iter->second.sample_path += " (" + what + ")"; |
1789 |
++iter; |
++iter; |
1790 |
} |
} |
1791 |
} |
} |
1792 |
// show error message box when some sample(s) could not be imported |
// show error message box when some sample(s) could not be imported |
1793 |
if (error_files.size()) { |
if (!error_files.empty()) { |
1794 |
Glib::ustring txt = _("Could not import the following sample(s):\n") + error_files; |
Glib::ustring txt = _("Could not import the following sample(s):\n") + error_files; |
1795 |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
1796 |
msg.run(); |
msg.run(); |
1803 |
propDialog.deiconify(); |
propDialog.deiconify(); |
1804 |
} |
} |
1805 |
|
|
1806 |
|
void MainWindow::on_action_warn_user_on_extensions() { |
1807 |
|
Settings::singleton()->warnUserOnExtensions = |
1808 |
|
!Settings::singleton()->warnUserOnExtensions; |
1809 |
|
} |
1810 |
|
|
1811 |
|
void MainWindow::on_action_sync_sampler_instrument_selection() { |
1812 |
|
Settings::singleton()->syncSamplerInstrumentSelection = |
1813 |
|
!Settings::singleton()->syncSamplerInstrumentSelection; |
1814 |
|
} |
1815 |
|
|
1816 |
|
void MainWindow::on_action_move_root_note_with_region_moved() { |
1817 |
|
Settings::singleton()->moveRootNoteWithRegionMoved = |
1818 |
|
!Settings::singleton()->moveRootNoteWithRegionMoved; |
1819 |
|
} |
1820 |
|
|
1821 |
void MainWindow::on_action_help_about() |
void MainWindow::on_action_help_about() |
1822 |
{ |
{ |
1823 |
Gtk::AboutDialog dialog; |
Gtk::AboutDialog dialog; |
1827 |
dialog.set_name("Gigedit"); |
dialog.set_name("Gigedit"); |
1828 |
#endif |
#endif |
1829 |
dialog.set_version(VERSION); |
dialog.set_version(VERSION); |
1830 |
dialog.set_copyright("Copyright (C) 2006-2013 Andreas Persson"); |
dialog.set_copyright("Copyright (C) 2006-2017 Andreas Persson"); |
1831 |
dialog.set_comments(_( |
const std::string sComment = |
1832 |
"Released under the GNU General Public License.\n" |
_("Built " __DATE__ "\nUsing ") + |
1833 |
"\n" |
::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" + |
1834 |
"Please notice that this is still a very young instrument editor. " |
_( |
1835 |
"So better backup your Gigasampler files before editing them with " |
"Gigedit is released under the GNU General Public License.\n" |
1836 |
"this application.\n" |
"\n" |
1837 |
"\n" |
"This program is distributed WITHOUT ANY WARRANTY; So better " |
1838 |
"Please report bugs to: http://bugs.linuxsampler.org") |
"backup your Gigasampler/GigaStudio files before editing them with " |
1839 |
); |
"this application.\n" |
1840 |
|
"\n" |
1841 |
|
"Please report bugs to: http://bugs.linuxsampler.org" |
1842 |
|
); |
1843 |
|
dialog.set_comments(sComment.c_str()); |
1844 |
dialog.set_website("http://www.linuxsampler.org"); |
dialog.set_website("http://www.linuxsampler.org"); |
1845 |
dialog.set_website_label("http://www.linuxsampler.org"); |
dialog.set_website_label("http://www.linuxsampler.org"); |
1846 |
|
dialog.set_position(Gtk::WIN_POS_CENTER); |
1847 |
dialog.run(); |
dialog.run(); |
1848 |
} |
} |
1849 |
|
|
1850 |
PropDialog::PropDialog() |
PropDialog::PropDialog() |
1851 |
: eName(_("Name")), |
: eFileFormat(_("File Format")), |
1852 |
|
eName(_("Name")), |
1853 |
eCreationDate(_("Creation date")), |
eCreationDate(_("Creation date")), |
1854 |
eComments(_("Comments")), |
eComments(_("Comments")), |
1855 |
eProduct(_("Product")), |
eProduct(_("Product")), |
1867 |
eSubject(_("Subject")), |
eSubject(_("Subject")), |
1868 |
quitButton(Gtk::Stock::CLOSE), |
quitButton(Gtk::Stock::CLOSE), |
1869 |
table(2, 1), |
table(2, 1), |
1870 |
update_model(0) |
m_file(NULL) |
1871 |
{ |
{ |
1872 |
|
if (!Settings::singleton()->autoRestoreWindowDimension) { |
1873 |
|
set_default_size(470, 390); |
1874 |
|
set_position(Gtk::WIN_POS_MOUSE); |
1875 |
|
} |
1876 |
|
|
1877 |
set_title(_("File Properties")); |
set_title(_("File Properties")); |
1878 |
eName.set_width_chars(50); |
eName.set_width_chars(50); |
1879 |
|
|
1894 |
connect(eCommissioned, &DLS::Info::Commissioned); |
connect(eCommissioned, &DLS::Info::Commissioned); |
1895 |
connect(eSubject, &DLS::Info::Subject); |
connect(eSubject, &DLS::Info::Subject); |
1896 |
|
|
1897 |
|
table.add(eFileFormat); |
1898 |
table.add(eName); |
table.add(eName); |
1899 |
table.add(eCreationDate); |
table.add(eCreationDate); |
1900 |
table.add(eComments); |
table.add(eComments); |
1925 |
quitButton.grab_focus(); |
quitButton.grab_focus(); |
1926 |
quitButton.signal_clicked().connect( |
quitButton.signal_clicked().connect( |
1927 |
sigc::mem_fun(*this, &PropDialog::hide)); |
sigc::mem_fun(*this, &PropDialog::hide)); |
1928 |
|
eFileFormat.signal_value_changed().connect( |
1929 |
|
sigc::mem_fun(*this, &PropDialog::onFileFormatChanged)); |
1930 |
|
|
1931 |
quitButton.show(); |
quitButton.show(); |
1932 |
vbox.show(); |
vbox.show(); |
1933 |
show_all_children(); |
show_all_children(); |
1934 |
} |
} |
1935 |
|
|
1936 |
void PropDialog::set_info(DLS::Info* info) |
void PropDialog::set_file(gig::File* file) |
1937 |
{ |
{ |
1938 |
this->info = info; |
m_file = file; |
1939 |
update_model++; |
|
1940 |
eName.set_value(info->Name); |
// update file format version combo box |
1941 |
eCreationDate.set_value(info->CreationDate); |
const std::string sGiga = "Gigasampler/GigaStudio v"; |
1942 |
eComments.set_value(info->Comments); |
const int major = file->pVersion->major; |
1943 |
eProduct.set_value(info->Product); |
std::vector<std::string> txts; |
1944 |
eCopyright.set_value(info->Copyright); |
std::vector<int> values; |
1945 |
eArtists.set_value(info->Artists); |
txts.push_back(sGiga + "2"); values.push_back(2); |
1946 |
eGenre.set_value(info->Genre); |
txts.push_back(sGiga + "3/v4"); values.push_back(3); |
1947 |
eKeywords.set_value(info->Keywords); |
if (major != 2 && major != 3) { |
1948 |
eEngineer.set_value(info->Engineer); |
txts.push_back(sGiga + ToString(major)); values.push_back(major); |
1949 |
eTechnician.set_value(info->Technician); |
} |
1950 |
eSoftware.set_value(info->Software); |
std::vector<const char*> texts; |
1951 |
eMedium.set_value(info->Medium); |
for (int i = 0; i < txts.size(); ++i) texts.push_back(txts[i].c_str()); |
1952 |
eSource.set_value(info->Source); |
texts.push_back(NULL); values.push_back(0); |
1953 |
eSourceForm.set_value(info->SourceForm); |
eFileFormat.set_choices(&texts[0], &values[0]); |
1954 |
eCommissioned.set_value(info->Commissioned); |
eFileFormat.set_value(major); |
|
eSubject.set_value(info->Subject); |
|
|
update_model--; |
|
1955 |
} |
} |
1956 |
|
|
1957 |
sigc::signal<void>& PropDialog::signal_info_changed() |
void PropDialog::onFileFormatChanged() { |
1958 |
{ |
const int major = eFileFormat.get_value(); |
1959 |
return info_changed; |
if (m_file) m_file->pVersion->major = major; |
1960 |
} |
} |
1961 |
|
|
1962 |
void InstrumentProps::set_IsDrum(bool value) |
void PropDialog::set_info(DLS::Info* info) |
1963 |
{ |
{ |
1964 |
instrument->IsDrum = value; |
update(info); |
1965 |
} |
} |
1966 |
|
|
1967 |
void InstrumentProps::set_MIDIBank(uint16_t value) |
|
1968 |
|
void InstrumentProps::set_Name(const gig::String& name) |
1969 |
{ |
{ |
1970 |
instrument->MIDIBank = value; |
m->pInfo->Name = name; |
1971 |
} |
} |
1972 |
|
|
1973 |
void InstrumentProps::set_MIDIProgram(uint32_t value) |
void InstrumentProps::update_name() |
1974 |
{ |
{ |
1975 |
instrument->MIDIProgram = value; |
update_model++; |
1976 |
|
eName.set_value(m->pInfo->Name); |
1977 |
|
update_model--; |
1978 |
} |
} |
1979 |
|
|
1980 |
void InstrumentProps::set_DimensionKeyRange_low(uint8_t value) |
void InstrumentProps::set_IsDrum(bool value) |
1981 |
{ |
{ |
1982 |
instrument->DimensionKeyRange.low = value; |
m->IsDrum = value; |
|
if (value > instrument->DimensionKeyRange.high) { |
|
|
eDimensionKeyRangeHigh.set_value(value); |
|
|
} |
|
1983 |
} |
} |
1984 |
|
|
1985 |
void InstrumentProps::set_DimensionKeyRange_high(uint8_t value) |
void InstrumentProps::set_MIDIBank(uint16_t value) |
1986 |
{ |
{ |
1987 |
instrument->DimensionKeyRange.high = value; |
m->MIDIBank = value; |
|
if (value < instrument->DimensionKeyRange.low) { |
|
|
eDimensionKeyRangeLow.set_value(value); |
|
|
} |
|
1988 |
} |
} |
1989 |
|
|
1990 |
InstrumentProps::InstrumentProps() |
void InstrumentProps::set_MIDIProgram(uint32_t value) |
|
: update_model(0), |
|
|
quitButton(Gtk::Stock::CLOSE), |
|
|
table(2,1), |
|
|
eName(_("Name")), |
|
|
eIsDrum(_("Is drum")), |
|
|
eMIDIBank(_("MIDI bank"), 0, 16383), |
|
|
eMIDIProgram(_("MIDI program")), |
|
|
eAttenuation(_("Attenuation"), 0, 96, 0, 1), |
|
|
eGainPlus6(_("Gain +6dB"), eAttenuation, -6), |
|
|
eEffectSend(_("Effect send"), 0, 65535), |
|
|
eFineTune(_("Fine tune"), -8400, 8400), |
|
|
ePitchbendRange(_("Pitchbend range"), 0, 12), |
|
|
ePianoReleaseMode(_("Piano release mode")), |
|
|
eDimensionKeyRangeLow(_("Keyswitching range low")), |
|
|
eDimensionKeyRangeHigh(_("Keyswitching range high")) |
|
1991 |
{ |
{ |
1992 |
|
m->MIDIProgram = value; |
1993 |
|
} |
1994 |
|
|
1995 |
|
InstrumentProps::InstrumentProps() : |
1996 |
|
quitButton(Gtk::Stock::CLOSE), |
1997 |
|
table(2,1), |
1998 |
|
eName(_("Name")), |
1999 |
|
eIsDrum(_("Is drum")), |
2000 |
|
eMIDIBank(_("MIDI bank"), 0, 16383), |
2001 |
|
eMIDIProgram(_("MIDI program")), |
2002 |
|
eAttenuation(_("Attenuation"), 0, 96, 0, 1), |
2003 |
|
eGainPlus6(_("Gain +6dB"), eAttenuation, -6), |
2004 |
|
eEffectSend(_("Effect send"), 0, 65535), |
2005 |
|
eFineTune(_("Fine tune"), -8400, 8400), |
2006 |
|
ePitchbendRange(_("Pitchbend range"), 0, 12), |
2007 |
|
ePianoReleaseMode(_("Piano release mode")), |
2008 |
|
eDimensionKeyRangeLow(_("Keyswitching range low")), |
2009 |
|
eDimensionKeyRangeHigh(_("Keyswitching range high")) |
2010 |
|
{ |
2011 |
|
if (!Settings::singleton()->autoRestoreWindowDimension) { |
2012 |
|
//set_default_size(470, 390); |
2013 |
|
set_position(Gtk::WIN_POS_MOUSE); |
2014 |
|
} |
2015 |
|
|
2016 |
set_title(_("Instrument Properties")); |
set_title(_("Instrument Properties")); |
2017 |
|
|
2018 |
eDimensionKeyRangeLow.set_tip( |
eDimensionKeyRangeLow.set_tip( |
2024 |
"\"keyswitching\" dimension") |
"\"keyswitching\" dimension") |
2025 |
); |
); |
2026 |
|
|
2027 |
|
connect(eName, &InstrumentProps::set_Name); |
2028 |
connect(eIsDrum, &InstrumentProps::set_IsDrum); |
connect(eIsDrum, &InstrumentProps::set_IsDrum); |
2029 |
connect(eMIDIBank, &InstrumentProps::set_MIDIBank); |
connect(eMIDIBank, &InstrumentProps::set_MIDIBank); |
2030 |
connect(eMIDIProgram, &InstrumentProps::set_MIDIProgram); |
connect(eMIDIProgram, &InstrumentProps::set_MIDIProgram); |
2034 |
connect(eFineTune, &gig::Instrument::FineTune); |
connect(eFineTune, &gig::Instrument::FineTune); |
2035 |
connect(ePitchbendRange, &gig::Instrument::PitchbendRange); |
connect(ePitchbendRange, &gig::Instrument::PitchbendRange); |
2036 |
connect(ePianoReleaseMode, &gig::Instrument::PianoReleaseMode); |
connect(ePianoReleaseMode, &gig::Instrument::PianoReleaseMode); |
2037 |
connect(eDimensionKeyRangeLow, |
connect(eDimensionKeyRangeLow, eDimensionKeyRangeHigh, |
2038 |
&InstrumentProps::set_DimensionKeyRange_low); |
&gig::Instrument::DimensionKeyRange); |
2039 |
connect(eDimensionKeyRangeHigh, |
|
2040 |
&InstrumentProps::set_DimensionKeyRange_high); |
eName.signal_value_changed().connect(sig_name_changed.make_slot()); |
2041 |
|
|
2042 |
table.set_col_spacings(5); |
table.set_col_spacings(5); |
2043 |
|
|
2076 |
|
|
2077 |
void InstrumentProps::set_instrument(gig::Instrument* instrument) |
void InstrumentProps::set_instrument(gig::Instrument* instrument) |
2078 |
{ |
{ |
2079 |
this->instrument = instrument; |
update(instrument); |
2080 |
|
|
2081 |
update_model++; |
update_model++; |
2082 |
eName.set_value(instrument->pInfo->Name); |
eName.set_value(instrument->pInfo->Name); |
2083 |
eIsDrum.set_value(instrument->IsDrum); |
eIsDrum.set_value(instrument->IsDrum); |
2084 |
eMIDIBank.set_value(instrument->MIDIBank); |
eMIDIBank.set_value(instrument->MIDIBank); |
2085 |
eMIDIProgram.set_value(instrument->MIDIProgram); |
eMIDIProgram.set_value(instrument->MIDIProgram); |
|
eAttenuation.set_value(instrument->Attenuation); |
|
|
eGainPlus6.set_value(instrument->Attenuation); |
|
|
eEffectSend.set_value(instrument->EffectSend); |
|
|
eFineTune.set_value(instrument->FineTune); |
|
|
ePitchbendRange.set_value(instrument->PitchbendRange); |
|
|
ePianoReleaseMode.set_value(instrument->PianoReleaseMode); |
|
|
eDimensionKeyRangeLow.set_value(instrument->DimensionKeyRange.low); |
|
|
eDimensionKeyRangeHigh.set_value(instrument->DimensionKeyRange.high); |
|
2086 |
update_model--; |
update_model--; |
2087 |
} |
} |
2088 |
|
|
|
sigc::signal<void>& InstrumentProps::signal_instrument_changed() |
|
|
{ |
|
|
return instrument_changed; |
|
|
} |
|
2089 |
|
|
2090 |
void MainWindow::file_changed() |
void MainWindow::file_changed() |
2091 |
{ |
{ |
2095 |
} |
} |
2096 |
} |
} |
2097 |
|
|
2098 |
|
void MainWindow::updateSampleRefCountMap(gig::File* gig) { |
2099 |
|
sample_ref_count.clear(); |
2100 |
|
|
2101 |
|
if (!gig) return; |
2102 |
|
|
2103 |
|
for (gig::Instrument* instrument = gig->GetFirstInstrument(); instrument; |
2104 |
|
instrument = gig->GetNextInstrument()) |
2105 |
|
{ |
2106 |
|
for (gig::Region* rgn = instrument->GetFirstRegion(); rgn; |
2107 |
|
rgn = instrument->GetNextRegion()) |
2108 |
|
{ |
2109 |
|
for (int i = 0; i < 256; ++i) { |
2110 |
|
if (!rgn->pDimensionRegions[i]) continue; |
2111 |
|
if (rgn->pDimensionRegions[i]->pSample) { |
2112 |
|
sample_ref_count[rgn->pDimensionRegions[i]->pSample]++; |
2113 |
|
} |
2114 |
|
} |
2115 |
|
} |
2116 |
|
} |
2117 |
|
} |
2118 |
|
|
2119 |
void MainWindow::load_gig(gig::File* gig, const char* filename, bool isSharedInstrument) |
void MainWindow::load_gig(gig::File* gig, const char* filename, bool isSharedInstrument) |
2120 |
{ |
{ |
2121 |
file = 0; |
file = 0; |
2122 |
set_file_is_shared(isSharedInstrument); |
set_file_is_shared(isSharedInstrument); |
2123 |
|
|
2124 |
this->filename = filename ? filename : _("Unsaved Gig File"); |
this->filename = |
2125 |
|
(filename && strlen(filename) > 0) ? |
2126 |
|
filename : (!gig->GetFileName().empty()) ? |
2127 |
|
gig->GetFileName() : _("Unsaved Gig File"); |
2128 |
set_title(Glib::filename_display_basename(this->filename)); |
set_title(Glib::filename_display_basename(this->filename)); |
2129 |
file_has_name = filename; |
file_has_name = filename; |
2130 |
file_is_changed = false; |
file_is_changed = false; |
2131 |
|
|
2132 |
|
propDialog.set_file(gig); |
2133 |
propDialog.set_info(gig->pInfo); |
propDialog.set_info(gig->pInfo); |
2134 |
|
|
2135 |
Gtk::MenuItem* instrument_menu = |
instrument_name_connection.block(); |
2136 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuInstrument")); |
int index = 0; |
|
|
|
|
int instrument_index = 0; |
|
|
Gtk::RadioMenuItem::Group instrument_group; |
|
2137 |
for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ; |
for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ; |
2138 |
instrument = gig->GetNextInstrument()) { |
instrument = gig->GetNextInstrument(), ++index) { |
2139 |
|
Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
2140 |
|
const int iScriptSlots = instrument->ScriptSlotCount(); |
2141 |
|
|
2142 |
Gtk::TreeModel::iterator iter = m_refTreeModel->append(); |
Gtk::TreeModel::iterator iter = m_refTreeModel->append(); |
2143 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
2144 |
row[m_Columns.m_col_name] = instrument->pInfo->Name.c_str(); |
row[m_Columns.m_col_nr] = index; |
2145 |
|
row[m_Columns.m_col_name] = name; |
2146 |
row[m_Columns.m_col_instr] = instrument; |
row[m_Columns.m_col_instr] = instrument; |
2147 |
// create a menu item for this instrument |
row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; |
2148 |
Gtk::RadioMenuItem* item = |
|
2149 |
new Gtk::RadioMenuItem(instrument_group, instrument->pInfo->Name.c_str()); |
add_instrument_to_menu(name); |
|
instrument_menu->get_submenu()->append(*item); |
|
|
item->signal_activate().connect( |
|
|
sigc::bind( |
|
|
sigc::mem_fun(*this, &MainWindow::on_instrument_selection_change), |
|
|
instrument_index |
|
|
) |
|
|
); |
|
|
instrument_index++; |
|
2150 |
} |
} |
2151 |
instrument_menu->show(); |
instrument_name_connection.unblock(); |
2152 |
instrument_menu->get_submenu()->show_all_children(); |
uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments")->show(); |
2153 |
|
|
2154 |
|
updateSampleRefCountMap(gig); |
2155 |
|
|
2156 |
for (gig::Group* group = gig->GetFirstGroup(); group; group = gig->GetNextGroup()) { |
for (gig::Group* group = gig->GetFirstGroup(); group; group = gig->GetNextGroup()) { |
2157 |
if (group->Name != "") { |
if (group->Name != "") { |
2158 |
Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append(); |
Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append(); |
2159 |
Gtk::TreeModel::Row rowGroup = *iterGroup; |
Gtk::TreeModel::Row rowGroup = *iterGroup; |
2160 |
rowGroup[m_SamplesModel.m_col_name] = group->Name.c_str(); |
rowGroup[m_SamplesModel.m_col_name] = gig_to_utf8(group->Name); |
2161 |
rowGroup[m_SamplesModel.m_col_group] = group; |
rowGroup[m_SamplesModel.m_col_group] = group; |
2162 |
rowGroup[m_SamplesModel.m_col_sample] = NULL; |
rowGroup[m_SamplesModel.m_col_sample] = NULL; |
2163 |
for (gig::Sample* sample = group->GetFirstSample(); |
for (gig::Sample* sample = group->GetFirstSample(); |
2165 |
Gtk::TreeModel::iterator iterSample = |
Gtk::TreeModel::iterator iterSample = |
2166 |
m_refSamplesTreeModel->append(rowGroup.children()); |
m_refSamplesTreeModel->append(rowGroup.children()); |
2167 |
Gtk::TreeModel::Row rowSample = *iterSample; |
Gtk::TreeModel::Row rowSample = *iterSample; |
2168 |
rowSample[m_SamplesModel.m_col_name] = sample->pInfo->Name.c_str(); |
rowSample[m_SamplesModel.m_col_name] = |
2169 |
|
gig_to_utf8(sample->pInfo->Name); |
2170 |
rowSample[m_SamplesModel.m_col_sample] = sample; |
rowSample[m_SamplesModel.m_col_sample] = sample; |
2171 |
rowSample[m_SamplesModel.m_col_group] = NULL; |
rowSample[m_SamplesModel.m_col_group] = NULL; |
2172 |
|
int refcount = sample_ref_count.count(sample) ? sample_ref_count[sample] : 0; |
2173 |
|
rowSample[m_SamplesModel.m_col_refcount] = ToString(refcount) + " " + _("Refs."); |
2174 |
|
rowSample[m_SamplesModel.m_color] = refcount ? "black" : "red"; |
2175 |
} |
} |
2176 |
} |
} |
2177 |
} |
} |
2178 |
|
|
2179 |
|
for (int i = 0; gig->GetScriptGroup(i); ++i) { |
2180 |
|
gig::ScriptGroup* group = gig->GetScriptGroup(i); |
2181 |
|
|
2182 |
|
Gtk::TreeModel::iterator iterGroup = m_refScriptsTreeModel->append(); |
2183 |
|
Gtk::TreeModel::Row rowGroup = *iterGroup; |
2184 |
|
rowGroup[m_ScriptsModel.m_col_name] = gig_to_utf8(group->Name); |
2185 |
|
rowGroup[m_ScriptsModel.m_col_group] = group; |
2186 |
|
rowGroup[m_ScriptsModel.m_col_script] = NULL; |
2187 |
|
for (int s = 0; group->GetScript(s); ++s) { |
2188 |
|
gig::Script* script = group->GetScript(s); |
2189 |
|
|
2190 |
|
Gtk::TreeModel::iterator iterScript = |
2191 |
|
m_refScriptsTreeModel->append(rowGroup.children()); |
2192 |
|
Gtk::TreeModel::Row rowScript = *iterScript; |
2193 |
|
rowScript[m_ScriptsModel.m_col_name] = gig_to_utf8(script->Name); |
2194 |
|
rowScript[m_ScriptsModel.m_col_script] = script; |
2195 |
|
rowScript[m_ScriptsModel.m_col_group] = NULL; |
2196 |
|
} |
2197 |
|
} |
2198 |
|
// unfold all sample groups & script groups by default |
2199 |
|
m_TreeViewSamples.expand_all(); |
2200 |
|
m_TreeViewScripts.expand_all(); |
2201 |
|
|
2202 |
file = gig; |
file = gig; |
2203 |
|
|
2204 |
// select the first instrument |
// select the first instrument |
2205 |
Glib::RefPtr<Gtk::TreeSelection> tree_sel_ref = m_TreeView.get_selection(); |
m_TreeView.get_selection()->select(Gtk::TreePath("0")); |
2206 |
tree_sel_ref->select(Gtk::TreePath("0")); |
|
2207 |
|
instr_props_set_instrument(); |
2208 |
|
gig::Instrument* instrument = get_instrument(); |
2209 |
|
if (instrument) { |
2210 |
|
midiRules.set_instrument(instrument); |
2211 |
|
} |
2212 |
} |
} |
2213 |
|
|
2214 |
void MainWindow::show_instr_props() |
bool MainWindow::instr_props_set_instrument() |
2215 |
{ |
{ |
2216 |
gig::Instrument* instrument = get_instrument(); |
instrumentProps.signal_name_changed().clear(); |
2217 |
if (instrument) |
|
2218 |
{ |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
2219 |
|
if (rows.empty()) { |
2220 |
|
instrumentProps.hide(); |
2221 |
|
return false; |
2222 |
|
} |
2223 |
|
Gtk::TreeModel::const_iterator it = m_refTreeModel->get_iter(rows[0]); |
2224 |
|
if (it) { |
2225 |
|
Gtk::TreeModel::Row row = *it; |
2226 |
|
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
2227 |
|
|
2228 |
instrumentProps.set_instrument(instrument); |
instrumentProps.set_instrument(instrument); |
2229 |
|
|
2230 |
|
// make sure instrument tree is updated when user changes the |
2231 |
|
// instrument name in instrument properties window |
2232 |
|
instrumentProps.signal_name_changed().connect( |
2233 |
|
sigc::bind( |
2234 |
|
sigc::mem_fun(*this, |
2235 |
|
&MainWindow::instr_name_changed_by_instr_props), |
2236 |
|
it)); |
2237 |
|
} else { |
2238 |
|
instrumentProps.hide(); |
2239 |
|
} |
2240 |
|
return it; |
2241 |
|
} |
2242 |
|
|
2243 |
|
void MainWindow::show_instr_props() |
2244 |
|
{ |
2245 |
|
if (instr_props_set_instrument()) { |
2246 |
instrumentProps.show(); |
instrumentProps.show(); |
2247 |
instrumentProps.deiconify(); |
instrumentProps.deiconify(); |
2248 |
} |
} |
2249 |
} |
} |
2250 |
|
|
2251 |
|
void MainWindow::instr_name_changed_by_instr_props(Gtk::TreeModel::iterator& it) |
2252 |
|
{ |
2253 |
|
Gtk::TreeModel::Row row = *it; |
2254 |
|
Glib::ustring name = row[m_Columns.m_col_name]; |
2255 |
|
|
2256 |
|
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
2257 |
|
Glib::ustring gigname(gig_to_utf8(instrument->pInfo->Name)); |
2258 |
|
if (gigname != name) { |
2259 |
|
row[m_Columns.m_col_name] = gigname; |
2260 |
|
} |
2261 |
|
} |
2262 |
|
|
2263 |
|
void MainWindow::show_midi_rules() |
2264 |
|
{ |
2265 |
|
if (gig::Instrument* instrument = get_instrument()) |
2266 |
|
{ |
2267 |
|
midiRules.set_instrument(instrument); |
2268 |
|
midiRules.show(); |
2269 |
|
midiRules.deiconify(); |
2270 |
|
} |
2271 |
|
} |
2272 |
|
|
2273 |
|
void MainWindow::show_script_slots() { |
2274 |
|
if (!file) return; |
2275 |
|
// get selected instrument |
2276 |
|
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
2277 |
|
if (rows.empty()) return; |
2278 |
|
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
2279 |
|
if (!it) return; |
2280 |
|
Gtk::TreeModel::Row row = *it; |
2281 |
|
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
2282 |
|
if (!instrument) return; |
2283 |
|
|
2284 |
|
ScriptSlots* window = new ScriptSlots; |
2285 |
|
window->setInstrument(instrument); |
2286 |
|
window->signal_script_slots_changed().connect( |
2287 |
|
sigc::mem_fun(*this, &MainWindow::onScriptSlotsModified) |
2288 |
|
); |
2289 |
|
//window->reparent(*this); |
2290 |
|
window->show(); |
2291 |
|
} |
2292 |
|
|
2293 |
|
void MainWindow::onScriptSlotsModified(gig::Instrument* pInstrument) { |
2294 |
|
if (!pInstrument) return; |
2295 |
|
const int iScriptSlots = pInstrument->ScriptSlotCount(); |
2296 |
|
|
2297 |
|
Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
2298 |
|
for (int i = 0; i < model->children().size(); ++i) { |
2299 |
|
Gtk::TreeModel::Row row = model->children()[i]; |
2300 |
|
if (row[m_Columns.m_col_instr] != pInstrument) continue; |
2301 |
|
row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; |
2302 |
|
break; |
2303 |
|
} |
2304 |
|
} |
2305 |
|
|
2306 |
|
void MainWindow::on_action_refresh_all() { |
2307 |
|
__refreshEntireGUI(); |
2308 |
|
} |
2309 |
|
|
2310 |
void MainWindow::on_action_view_status_bar() { |
void MainWindow::on_action_view_status_bar() { |
2311 |
Gtk::CheckMenuItem* item = |
Gtk::CheckMenuItem* item = |
2312 |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar")); |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar")); |
2318 |
else m_StatusBar.hide(); |
else m_StatusBar.hide(); |
2319 |
} |
} |
2320 |
|
|
2321 |
|
void MainWindow::on_auto_restore_win_dim() { |
2322 |
|
Gtk::CheckMenuItem* item = |
2323 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/AutoRestoreWinDim")); |
2324 |
|
if (!item) { |
2325 |
|
std::cerr << "/MenuBar/MenuView/AutoRestoreWinDim == NULL\n"; |
2326 |
|
return; |
2327 |
|
} |
2328 |
|
Settings::singleton()->autoRestoreWindowDimension = item->get_active(); |
2329 |
|
} |
2330 |
|
|
2331 |
|
void MainWindow::on_save_with_temporary_file() { |
2332 |
|
Gtk::CheckMenuItem* item = |
2333 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuSettings/SaveWithTemporaryFile")); |
2334 |
|
if (!item) { |
2335 |
|
std::cerr << "/MenuBar/MenuSettings/SaveWithTemporaryFile == NULL\n"; |
2336 |
|
return; |
2337 |
|
} |
2338 |
|
Settings::singleton()->saveWithTemporaryFile = item->get_active(); |
2339 |
|
} |
2340 |
|
|
2341 |
|
bool MainWindow::is_copy_samples_unity_note_enabled() const { |
2342 |
|
Gtk::CheckMenuItem* item = |
2343 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity")); |
2344 |
|
if (!item) { |
2345 |
|
std::cerr << "/MenuBar/MenuEdit/CopySampleUnity == NULL\n"; |
2346 |
|
return true; |
2347 |
|
} |
2348 |
|
return item->get_active(); |
2349 |
|
} |
2350 |
|
|
2351 |
|
bool MainWindow::is_copy_samples_fine_tune_enabled() const { |
2352 |
|
Gtk::CheckMenuItem* item = |
2353 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleTune")); |
2354 |
|
if (!item) { |
2355 |
|
std::cerr << "/MenuBar/MenuEdit/CopySampleTune == NULL\n"; |
2356 |
|
return true; |
2357 |
|
} |
2358 |
|
return item->get_active(); |
2359 |
|
} |
2360 |
|
|
2361 |
|
bool MainWindow::is_copy_samples_loop_enabled() const { |
2362 |
|
Gtk::CheckMenuItem* item = |
2363 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleLoop")); |
2364 |
|
if (!item) { |
2365 |
|
std::cerr << "/MenuBar/MenuEdit/CopySampleLoop == NULL\n"; |
2366 |
|
return true; |
2367 |
|
} |
2368 |
|
return item->get_active(); |
2369 |
|
} |
2370 |
|
|
2371 |
void MainWindow::on_button_release(GdkEventButton* button) |
void MainWindow::on_button_release(GdkEventButton* button) |
2372 |
{ |
{ |
2373 |
if (button->type == GDK_2BUTTON_PRESS) { |
if (button->type == GDK_2BUTTON_PRESS) { |
2374 |
show_instr_props(); |
show_instr_props(); |
2375 |
} else if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
} else if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
2376 |
|
// gig v2 files have no midi rules |
2377 |
|
const bool bEnabled = !(file->pVersion && file->pVersion->major == 2); |
2378 |
|
static_cast<Gtk::MenuItem*>( |
2379 |
|
uiManager->get_widget("/MenuBar/MenuInstrument/MidiRules"))->set_sensitive( |
2380 |
|
bEnabled |
2381 |
|
); |
2382 |
|
static_cast<Gtk::MenuItem*>( |
2383 |
|
uiManager->get_widget("/PopupMenu/MidiRules"))->set_sensitive( |
2384 |
|
bEnabled |
2385 |
|
); |
2386 |
popup_menu->popup(button->button, button->time); |
popup_menu->popup(button->button, button->time); |
2387 |
} |
} |
2388 |
} |
} |
2389 |
|
|
2390 |
void MainWindow::on_instrument_selection_change(int index) { |
void MainWindow::on_instrument_selection_change(Gtk::RadioMenuItem* item) { |
2391 |
m_RegionChooser.set_instrument(file->GetInstrument(index)); |
if (item->get_active()) { |
2392 |
|
const std::vector<Gtk::Widget*> children = |
2393 |
|
instrument_menu->get_children(); |
2394 |
|
std::vector<Gtk::Widget*>::const_iterator it = |
2395 |
|
find(children.begin(), children.end(), item); |
2396 |
|
if (it != children.end()) { |
2397 |
|
int index = it - children.begin(); |
2398 |
|
m_TreeView.get_selection()->select(Gtk::TreePath(ToString(index))); |
2399 |
|
|
2400 |
|
m_RegionChooser.set_instrument(file->GetInstrument(index)); |
2401 |
|
} |
2402 |
|
} |
2403 |
|
} |
2404 |
|
|
2405 |
|
void MainWindow::select_instrument(gig::Instrument* instrument) { |
2406 |
|
if (!instrument) return; |
2407 |
|
|
2408 |
|
Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
2409 |
|
for (int i = 0; i < model->children().size(); ++i) { |
2410 |
|
Gtk::TreeModel::Row row = model->children()[i]; |
2411 |
|
if (row[m_Columns.m_col_instr] == instrument) { |
2412 |
|
// select and show the respective instrument in the list view |
2413 |
|
show_intruments_tab(); |
2414 |
|
m_TreeView.get_selection()->unselect_all(); |
2415 |
|
m_TreeView.get_selection()->select(model->children()[i]); |
2416 |
|
std::vector<Gtk::TreeModel::Path> rows = |
2417 |
|
m_TreeView.get_selection()->get_selected_rows(); |
2418 |
|
if (!rows.empty()) |
2419 |
|
m_TreeView.scroll_to_row(rows[0]); |
2420 |
|
on_sel_change(); // the regular instrument selection change callback |
2421 |
|
} |
2422 |
|
} |
2423 |
|
} |
2424 |
|
|
2425 |
|
/// Returns true if requested dimension region was successfully selected and scrolled to in the list view, false on error. |
2426 |
|
bool MainWindow::select_dimension_region(gig::DimensionRegion* dimRgn) { |
2427 |
|
gig::Region* pRegion = (gig::Region*) dimRgn->GetParent(); |
2428 |
|
gig::Instrument* pInstrument = (gig::Instrument*) pRegion->GetParent(); |
2429 |
|
|
2430 |
|
Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
2431 |
|
for (int i = 0; i < model->children().size(); ++i) { |
2432 |
|
Gtk::TreeModel::Row row = model->children()[i]; |
2433 |
|
if (row[m_Columns.m_col_instr] == pInstrument) { |
2434 |
|
// select and show the respective instrument in the list view |
2435 |
|
show_intruments_tab(); |
2436 |
|
m_TreeView.get_selection()->unselect_all(); |
2437 |
|
m_TreeView.get_selection()->select(model->children()[i]); |
2438 |
|
std::vector<Gtk::TreeModel::Path> rows = |
2439 |
|
m_TreeView.get_selection()->get_selected_rows(); |
2440 |
|
if (!rows.empty()) |
2441 |
|
m_TreeView.scroll_to_row(rows[0]); |
2442 |
|
on_sel_change(); // the regular instrument selection change callback |
2443 |
|
|
2444 |
|
// select respective region in the region selector |
2445 |
|
m_RegionChooser.set_region(pRegion); |
2446 |
|
|
2447 |
|
// select and show the respective dimension region in the editor |
2448 |
|
//update_dimregs(); |
2449 |
|
if (!m_DimRegionChooser.select_dimregion(dimRgn)) return false; |
2450 |
|
//dimreg_edit.set_dim_region(dimRgn); |
2451 |
|
|
2452 |
|
return true; |
2453 |
|
} |
2454 |
|
} |
2455 |
|
|
2456 |
|
return false; |
2457 |
|
} |
2458 |
|
|
2459 |
|
void MainWindow::select_sample(gig::Sample* sample) { |
2460 |
|
Glib::RefPtr<Gtk::TreeModel> model = m_TreeViewSamples.get_model(); |
2461 |
|
for (int g = 0; g < model->children().size(); ++g) { |
2462 |
|
Gtk::TreeModel::Row rowGroup = model->children()[g]; |
2463 |
|
for (int s = 0; s < rowGroup.children().size(); ++s) { |
2464 |
|
Gtk::TreeModel::Row rowSample = rowGroup.children()[s]; |
2465 |
|
if (rowSample[m_SamplesModel.m_col_sample] == sample) { |
2466 |
|
show_samples_tab(); |
2467 |
|
m_TreeViewSamples.get_selection()->unselect_all(); |
2468 |
|
m_TreeViewSamples.get_selection()->select(rowGroup.children()[s]); |
2469 |
|
std::vector<Gtk::TreeModel::Path> rows = |
2470 |
|
m_TreeViewSamples.get_selection()->get_selected_rows(); |
2471 |
|
if (rows.empty()) return; |
2472 |
|
m_TreeViewSamples.scroll_to_row(rows[0]); |
2473 |
|
return; |
2474 |
|
} |
2475 |
|
} |
2476 |
|
} |
2477 |
} |
} |
2478 |
|
|
2479 |
void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) { |
void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) { |
2480 |
if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
2481 |
|
// by default if Ctrl keys is pressed down, then a mouse right-click |
2482 |
|
// does not select the respective row, so we must assure this |
2483 |
|
// programmatically ... |
2484 |
|
/*{ |
2485 |
|
Gtk::TreeModel::Path path; |
2486 |
|
Gtk::TreeViewColumn* pColumn = NULL; |
2487 |
|
int cellX, cellY; |
2488 |
|
bool bSuccess = m_TreeViewSamples.get_path_at_pos( |
2489 |
|
(int)button->x, (int)button->y, |
2490 |
|
path, pColumn, cellX, cellY |
2491 |
|
); |
2492 |
|
if (bSuccess) { |
2493 |
|
if (m_TreeViewSamples.get_selection()->count_selected_rows() <= 0) { |
2494 |
|
printf("not selected !!!\n"); |
2495 |
|
m_TreeViewSamples.get_selection()->select(path); |
2496 |
|
} |
2497 |
|
} |
2498 |
|
}*/ |
2499 |
|
|
2500 |
Gtk::Menu* sample_popup = |
Gtk::Menu* sample_popup = |
2501 |
dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/SamplePopupMenu")); |
dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/SamplePopupMenu")); |
2502 |
// update enabled/disabled state of sample popup items |
// update enabled/disabled state of sample popup items |
2503 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
2504 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
2505 |
bool group_selected = false; |
const int n = rows.size(); |
2506 |
bool sample_selected = false; |
int nGroups = 0; |
2507 |
if (it) { |
int nSamples = 0; |
2508 |
|
for (int r = 0; r < n; ++r) { |
2509 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[r]); |
2510 |
|
if (!it) continue; |
2511 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
2512 |
group_selected = row[m_SamplesModel.m_col_group]; |
if (row[m_SamplesModel.m_col_group]) nGroups++; |
2513 |
sample_selected = row[m_SamplesModel.m_col_sample]; |
if (row[m_SamplesModel.m_col_sample]) nSamples++; |
2514 |
} |
} |
2515 |
|
|
2516 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))-> |
2517 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n == 1); |
2518 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))-> |
2519 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n); |
2520 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddGroup"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddGroup"))-> |
2521 |
set_sensitive(file); |
set_sensitive(file); |
2522 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/ShowSampleRefs"))-> |
2523 |
|
set_sensitive(nSamples == 1); |
2524 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))-> |
2525 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n); |
2526 |
// show sample popup |
// show sample popup |
2527 |
sample_popup->popup(button->button, button->time); |
sample_popup->popup(button->button, button->time); |
2528 |
|
|
2529 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/SampleProperties"))-> |
2530 |
|
set_sensitive(n == 1); |
2531 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddSample"))-> |
2532 |
|
set_sensitive(n); |
2533 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddGroup"))-> |
2534 |
|
set_sensitive(file); |
2535 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/ShowSampleRefs"))-> |
2536 |
|
set_sensitive(nSamples == 1); |
2537 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/RemoveSample"))-> |
2538 |
|
set_sensitive(n); |
2539 |
} |
} |
2540 |
} |
} |
2541 |
|
|
2542 |
void MainWindow::on_action_add_instrument() { |
void MainWindow::on_script_treeview_button_release(GdkEventButton* button) { |
2543 |
static int __instrument_indexer = 0; |
if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
2544 |
if (!file) return; |
Gtk::Menu* script_popup = |
2545 |
gig::Instrument* instrument = file->AddInstrument(); |
dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/ScriptPopupMenu")); |
2546 |
__instrument_indexer++; |
// update enabled/disabled state of sample popup items |
2547 |
instrument->pInfo->Name = |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewScripts.get_selection(); |
2548 |
_("Unnamed Instrument ") + ToString(__instrument_indexer); |
Gtk::TreeModel::iterator it = sel->get_selected(); |
2549 |
|
bool group_selected = false; |
2550 |
|
bool script_selected = false; |
2551 |
|
if (it) { |
2552 |
|
Gtk::TreeModel::Row row = *it; |
2553 |
|
group_selected = row[m_ScriptsModel.m_col_group]; |
2554 |
|
script_selected = row[m_ScriptsModel.m_col_script]; |
2555 |
|
} |
2556 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/AddScript"))-> |
2557 |
|
set_sensitive(group_selected || script_selected); |
2558 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/AddScriptGroup"))-> |
2559 |
|
set_sensitive(file); |
2560 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/EditScript"))-> |
2561 |
|
set_sensitive(script_selected); |
2562 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/RemoveScript"))-> |
2563 |
|
set_sensitive(group_selected || script_selected); |
2564 |
|
// show sample popup |
2565 |
|
script_popup->popup(button->button, button->time); |
2566 |
|
|
2567 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/AddScript"))-> |
2568 |
|
set_sensitive(group_selected || script_selected); |
2569 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/AddScriptGroup"))-> |
2570 |
|
set_sensitive(file); |
2571 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/EditScript"))-> |
2572 |
|
set_sensitive(script_selected); |
2573 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/RemoveScript"))-> |
2574 |
|
set_sensitive(group_selected || script_selected); |
2575 |
|
} |
2576 |
|
} |
2577 |
|
|
2578 |
|
Gtk::RadioMenuItem* MainWindow::add_instrument_to_menu( |
2579 |
|
const Glib::ustring& name, int position) { |
2580 |
|
|
2581 |
|
Gtk::RadioMenuItem::Group instrument_group; |
2582 |
|
const std::vector<Gtk::Widget*> children = instrument_menu->get_children(); |
2583 |
|
if (!children.empty()) { |
2584 |
|
instrument_group = |
2585 |
|
static_cast<Gtk::RadioMenuItem*>(children[0])->get_group(); |
2586 |
|
} |
2587 |
|
Gtk::RadioMenuItem* item = |
2588 |
|
new Gtk::RadioMenuItem(instrument_group, name); |
2589 |
|
if (position < 0) { |
2590 |
|
instrument_menu->append(*item); |
2591 |
|
} else { |
2592 |
|
instrument_menu->insert(*item, position); |
2593 |
|
} |
2594 |
|
item->show(); |
2595 |
|
item->signal_activate().connect( |
2596 |
|
sigc::bind( |
2597 |
|
sigc::mem_fun(*this, &MainWindow::on_instrument_selection_change), |
2598 |
|
item)); |
2599 |
|
return item; |
2600 |
|
} |
2601 |
|
|
2602 |
|
void MainWindow::remove_instrument_from_menu(int index) { |
2603 |
|
const std::vector<Gtk::Widget*> children = |
2604 |
|
instrument_menu->get_children(); |
2605 |
|
Gtk::Widget* child = children[index]; |
2606 |
|
instrument_menu->remove(*child); |
2607 |
|
delete child; |
2608 |
|
} |
2609 |
|
|
2610 |
|
void MainWindow::add_instrument(gig::Instrument* instrument) { |
2611 |
|
const Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
2612 |
|
|
2613 |
// update instrument tree view |
// update instrument tree view |
2614 |
|
instrument_name_connection.block(); |
2615 |
Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append(); |
Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append(); |
2616 |
Gtk::TreeModel::Row rowInstr = *iterInstr; |
Gtk::TreeModel::Row rowInstr = *iterInstr; |
2617 |
rowInstr[m_Columns.m_col_name] = instrument->pInfo->Name.c_str(); |
rowInstr[m_Columns.m_col_nr] = m_refTreeModel->children().size() - 1; |
2618 |
|
rowInstr[m_Columns.m_col_name] = name; |
2619 |
rowInstr[m_Columns.m_col_instr] = instrument; |
rowInstr[m_Columns.m_col_instr] = instrument; |
2620 |
|
rowInstr[m_Columns.m_col_scripts] = ""; |
2621 |
|
instrument_name_connection.unblock(); |
2622 |
|
|
2623 |
|
add_instrument_to_menu(name); |
2624 |
|
|
2625 |
|
m_TreeView.get_selection()->select(iterInstr); |
2626 |
|
|
2627 |
file_changed(); |
file_changed(); |
2628 |
} |
} |
2629 |
|
|
2630 |
|
void MainWindow::on_action_add_instrument() { |
2631 |
|
static int __instrument_indexer = 0; |
2632 |
|
if (!file) return; |
2633 |
|
gig::Instrument* instrument = file->AddInstrument(); |
2634 |
|
__instrument_indexer++; |
2635 |
|
instrument->pInfo->Name = gig_from_utf8(_("Unnamed Instrument ") + |
2636 |
|
ToString(__instrument_indexer)); |
2637 |
|
|
2638 |
|
add_instrument(instrument); |
2639 |
|
} |
2640 |
|
|
2641 |
void MainWindow::on_action_duplicate_instrument() { |
void MainWindow::on_action_duplicate_instrument() { |
2642 |
if (!file) return; |
if (!file) return; |
2643 |
|
|
2644 |
// retrieve the currently selected instrument |
// retrieve the currently selected instrument |
2645 |
// (being the original instrument to be duplicated) |
// (being the original instrument to be duplicated) |
2646 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
2647 |
Gtk::TreeModel::iterator itSelection = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
2648 |
if (!itSelection) return; |
for (int r = 0; r < rows.size(); ++r) { |
2649 |
Gtk::TreeModel::Row row = *itSelection; |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]); |
2650 |
gig::Instrument* instrOrig = row[m_Columns.m_col_instr]; |
if (it) { |
2651 |
if (!instrOrig) return; |
Gtk::TreeModel::Row row = *it; |
2652 |
|
gig::Instrument* instrOrig = row[m_Columns.m_col_instr]; |
2653 |
// duplicate the orginal instrument |
if (instrOrig) { |
2654 |
gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); |
// duplicate the orginal instrument |
2655 |
instrNew->pInfo->Name = |
gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); |
2656 |
instrOrig->pInfo->Name + " (" + _("Copy") + ")"; |
instrNew->pInfo->Name = |
2657 |
|
instrOrig->pInfo->Name + |
2658 |
// update instrument tree view |
gig_from_utf8(Glib::ustring(" (") + _("Copy") + ")"); |
2659 |
Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append(); |
|
2660 |
Gtk::TreeModel::Row rowInstr = *iterInstr; |
add_instrument(instrNew); |
2661 |
rowInstr[m_Columns.m_col_name] = instrNew->pInfo->Name.c_str(); |
} |
2662 |
rowInstr[m_Columns.m_col_instr] = instrNew; |
} |
2663 |
file_changed(); |
} |
2664 |
} |
} |
2665 |
|
|
2666 |
void MainWindow::on_action_remove_instrument() { |
void MainWindow::on_action_remove_instrument() { |
2677 |
} |
} |
2678 |
|
|
2679 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
2680 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
2681 |
if (it) { |
for (int r = rows.size() - 1; r >= 0; --r) { |
2682 |
|
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]); |
2683 |
|
if (!it) continue; |
2684 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
2685 |
gig::Instrument* instr = row[m_Columns.m_col_instr]; |
gig::Instrument* instr = row[m_Columns.m_col_instr]; |
2686 |
try { |
try { |
2687 |
|
Gtk::TreePath path(it); |
2688 |
|
int index = path[0]; |
2689 |
|
|
2690 |
// remove instrument from the gig file |
// remove instrument from the gig file |
2691 |
if (instr) file->DeleteInstrument(instr); |
if (instr) file->DeleteInstrument(instr); |
|
// remove respective row from instruments tree view |
|
|
m_refTreeModel->erase(it); |
|
2692 |
file_changed(); |
file_changed(); |
2693 |
|
|
2694 |
|
remove_instrument_from_menu(index); |
2695 |
|
|
2696 |
|
// remove row from instruments tree view |
2697 |
|
m_refTreeModel->erase(it); |
2698 |
|
// update "Nr" column of all instrument rows |
2699 |
|
{ |
2700 |
|
int index = 0; |
2701 |
|
for (Gtk::TreeModel::iterator it = m_refTreeModel->children().begin(); |
2702 |
|
it != m_refTreeModel->children().end(); ++it, ++index) |
2703 |
|
{ |
2704 |
|
Gtk::TreeModel::Row row = *it; |
2705 |
|
row[m_Columns.m_col_nr] = index; |
2706 |
|
} |
2707 |
|
} |
2708 |
|
|
2709 |
|
#if GTKMM_MAJOR_VERSION < 3 |
2710 |
|
// select another instrument (in gtk3 this is done |
2711 |
|
// automatically) |
2712 |
|
if (!m_refTreeModel->children().empty()) { |
2713 |
|
if (index == m_refTreeModel->children().size()) { |
2714 |
|
index--; |
2715 |
|
} |
2716 |
|
m_TreeView.get_selection()->select( |
2717 |
|
Gtk::TreePath(ToString(index))); |
2718 |
|
} |
2719 |
|
#endif |
2720 |
|
instr_props_set_instrument(); |
2721 |
|
instr = get_instrument(); |
2722 |
|
if (instr) { |
2723 |
|
midiRules.set_instrument(instr); |
2724 |
|
} else { |
2725 |
|
midiRules.hide(); |
2726 |
|
} |
2727 |
} catch (RIFF::Exception e) { |
} catch (RIFF::Exception e) { |
2728 |
Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR); |
Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR); |
2729 |
msg.run(); |
msg.run(); |
2739 |
msg.run(); |
msg.run(); |
2740 |
} |
} |
2741 |
|
|
2742 |
|
void MainWindow::on_action_add_script_group() { |
2743 |
|
static int __script_indexer = 0; |
2744 |
|
if (!file) return; |
2745 |
|
gig::ScriptGroup* group = file->AddScriptGroup(); |
2746 |
|
group->Name = gig_from_utf8(_("Unnamed Group")); |
2747 |
|
if (__script_indexer) group->Name += " " + ToString(__script_indexer); |
2748 |
|
__script_indexer++; |
2749 |
|
// update sample tree view |
2750 |
|
Gtk::TreeModel::iterator iterGroup = m_refScriptsTreeModel->append(); |
2751 |
|
Gtk::TreeModel::Row rowGroup = *iterGroup; |
2752 |
|
rowGroup[m_ScriptsModel.m_col_name] = gig_to_utf8(group->Name); |
2753 |
|
rowGroup[m_ScriptsModel.m_col_script] = NULL; |
2754 |
|
rowGroup[m_ScriptsModel.m_col_group] = group; |
2755 |
|
file_changed(); |
2756 |
|
} |
2757 |
|
|
2758 |
|
void MainWindow::on_action_add_script() { |
2759 |
|
if (!file) return; |
2760 |
|
// get selected group |
2761 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewScripts.get_selection(); |
2762 |
|
Gtk::TreeModel::iterator it = sel->get_selected(); |
2763 |
|
if (!it) return; |
2764 |
|
Gtk::TreeModel::Row row = *it; |
2765 |
|
gig::ScriptGroup* group = row[m_ScriptsModel.m_col_group]; |
2766 |
|
if (!group) { // not a group, but a script is selected (probably) |
2767 |
|
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
2768 |
|
if (!script) return; |
2769 |
|
it = row.parent(); // resolve parent (that is the script's group) |
2770 |
|
if (!it) return; |
2771 |
|
row = *it; |
2772 |
|
group = row[m_ScriptsModel.m_col_group]; |
2773 |
|
if (!group) return; |
2774 |
|
} |
2775 |
|
|
2776 |
|
// add a new script to the .gig file |
2777 |
|
gig::Script* script = group->AddScript(); |
2778 |
|
Glib::ustring name = _("Unnamed Script"); |
2779 |
|
script->Name = gig_from_utf8(name); |
2780 |
|
|
2781 |
|
// add script to the tree view |
2782 |
|
Gtk::TreeModel::iterator iterScript = |
2783 |
|
m_refScriptsTreeModel->append(row.children()); |
2784 |
|
Gtk::TreeModel::Row rowScript = *iterScript; |
2785 |
|
rowScript[m_ScriptsModel.m_col_name] = name; |
2786 |
|
rowScript[m_ScriptsModel.m_col_script] = script; |
2787 |
|
rowScript[m_ScriptsModel.m_col_group] = NULL; |
2788 |
|
|
2789 |
|
// unfold group of new script item in treeview |
2790 |
|
Gtk::TreeModel::Path path(iterScript); |
2791 |
|
m_TreeViewScripts.expand_to_path(path); |
2792 |
|
} |
2793 |
|
|
2794 |
|
void MainWindow::on_action_edit_script() { |
2795 |
|
if (!file) return; |
2796 |
|
// get selected script |
2797 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewScripts.get_selection(); |
2798 |
|
Gtk::TreeModel::iterator it = sel->get_selected(); |
2799 |
|
if (!it) return; |
2800 |
|
Gtk::TreeModel::Row row = *it; |
2801 |
|
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
2802 |
|
if (!script) return; |
2803 |
|
|
2804 |
|
ScriptEditor* editor = new ScriptEditor; |
2805 |
|
editor->signal_script_to_be_changed.connect( |
2806 |
|
signal_script_to_be_changed.make_slot() |
2807 |
|
); |
2808 |
|
editor->signal_script_changed.connect( |
2809 |
|
signal_script_changed.make_slot() |
2810 |
|
); |
2811 |
|
editor->setScript(script); |
2812 |
|
//editor->reparent(*this); |
2813 |
|
editor->show(); |
2814 |
|
} |
2815 |
|
|
2816 |
|
void MainWindow::on_action_remove_script() { |
2817 |
|
if (!file) return; |
2818 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewScripts.get_selection(); |
2819 |
|
Gtk::TreeModel::iterator it = sel->get_selected(); |
2820 |
|
if (it) { |
2821 |
|
Gtk::TreeModel::Row row = *it; |
2822 |
|
gig::ScriptGroup* group = row[m_ScriptsModel.m_col_group]; |
2823 |
|
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
2824 |
|
Glib::ustring name = row[m_ScriptsModel.m_col_name]; |
2825 |
|
try { |
2826 |
|
// remove script group or script from the gig file |
2827 |
|
if (group) { |
2828 |
|
// notify everybody that we're going to remove these samples |
2829 |
|
//TODO: scripts_to_be_removed_signal.emit(members); |
2830 |
|
// delete the group in the .gig file including the |
2831 |
|
// samples that belong to the group |
2832 |
|
file->DeleteScriptGroup(group); |
2833 |
|
// notify that we're done with removal |
2834 |
|
//TODO: scripts_removed_signal.emit(); |
2835 |
|
file_changed(); |
2836 |
|
} else if (script) { |
2837 |
|
// notify everybody that we're going to remove this sample |
2838 |
|
//TODO: std::list<gig::Script*> lscripts; |
2839 |
|
//TODO: lscripts.push_back(script); |
2840 |
|
//TODO: scripts_to_be_removed_signal.emit(lscripts); |
2841 |
|
// remove sample from the .gig file |
2842 |
|
script->GetGroup()->DeleteScript(script); |
2843 |
|
// notify that we're done with removal |
2844 |
|
//TODO: scripts_removed_signal.emit(); |
2845 |
|
dimreg_changed(); |
2846 |
|
file_changed(); |
2847 |
|
} |
2848 |
|
// remove respective row(s) from samples tree view |
2849 |
|
m_refScriptsTreeModel->erase(it); |
2850 |
|
} catch (RIFF::Exception e) { |
2851 |
|
// pretend we're done with removal (i.e. to avoid dead locks) |
2852 |
|
//TODO: scripts_removed_signal.emit(); |
2853 |
|
// show error message |
2854 |
|
Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR); |
2855 |
|
msg.run(); |
2856 |
|
} |
2857 |
|
} |
2858 |
|
} |
2859 |
|
|
2860 |
void MainWindow::on_action_add_group() { |
void MainWindow::on_action_add_group() { |
2861 |
static int __sample_indexer = 0; |
static int __sample_indexer = 0; |
2862 |
if (!file) return; |
if (!file) return; |
2863 |
gig::Group* group = file->AddGroup(); |
gig::Group* group = file->AddGroup(); |
2864 |
group->Name = _("Unnamed Group"); |
group->Name = gig_from_utf8(_("Unnamed Group")); |
2865 |
if (__sample_indexer) group->Name += " " + ToString(__sample_indexer); |
if (__sample_indexer) group->Name += " " + ToString(__sample_indexer); |
2866 |
__sample_indexer++; |
__sample_indexer++; |
2867 |
// update sample tree view |
// update sample tree view |
2868 |
Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append(); |
Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append(); |
2869 |
Gtk::TreeModel::Row rowGroup = *iterGroup; |
Gtk::TreeModel::Row rowGroup = *iterGroup; |
2870 |
rowGroup[m_SamplesModel.m_col_name] = group->Name.c_str(); |
rowGroup[m_SamplesModel.m_col_name] = gig_to_utf8(group->Name); |
2871 |
rowGroup[m_SamplesModel.m_col_sample] = NULL; |
rowGroup[m_SamplesModel.m_col_sample] = NULL; |
2872 |
rowGroup[m_SamplesModel.m_col_group] = group; |
rowGroup[m_SamplesModel.m_col_group] = group; |
2873 |
file_changed(); |
file_changed(); |
2874 |
} |
} |
2875 |
|
|
2876 |
|
void MainWindow::on_action_replace_sample() { |
2877 |
|
add_or_replace_sample(true); |
2878 |
|
} |
2879 |
|
|
2880 |
void MainWindow::on_action_add_sample() { |
void MainWindow::on_action_add_sample() { |
2881 |
|
add_or_replace_sample(false); |
2882 |
|
} |
2883 |
|
|
2884 |
|
void MainWindow::add_or_replace_sample(bool replace) { |
2885 |
if (!file) return; |
if (!file) return; |
2886 |
// get selected group |
|
2887 |
|
// get selected group (and probably selected sample) |
2888 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
2889 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
2890 |
|
if (rows.empty()) return; |
2891 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]); |
2892 |
if (!it) return; |
if (!it) return; |
2893 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
2894 |
|
gig::Sample* sample = NULL; |
2895 |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
2896 |
if (!group) { // not a group, but a sample is selected (probably) |
if (!group) { // not a group, but a sample is selected (probably) |
2897 |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
if (replace) sample = row[m_SamplesModel.m_col_sample]; |
2898 |
if (!sample) return; |
if (!row[m_SamplesModel.m_col_sample]) return; |
2899 |
it = row.parent(); // resolve parent (that is the sample's group) |
it = row.parent(); // resolve parent (that is the sample's group) |
2900 |
if (!it) return; |
if (!it) return; |
2901 |
row = *it; |
if (!replace) row = *it; |
2902 |
group = row[m_SamplesModel.m_col_group]; |
group = (*it)[m_SamplesModel.m_col_group]; |
2903 |
if (!group) return; |
if (!group) return; |
2904 |
} |
} |
2905 |
|
if (replace && !sample) return; |
2906 |
|
|
2907 |
// show 'browse for file' dialog |
// show 'browse for file' dialog |
2908 |
Gtk::FileChooserDialog dialog(*this, _("Add Sample(s)")); |
Gtk::FileChooserDialog dialog(*this, replace ? _("Replace Sample with") : _("Add Sample(s)")); |
2909 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
2910 |
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); |
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); |
2911 |
dialog.set_select_multiple(true); |
dialog.set_select_multiple(!replace); // allow multi audio file selection only when adding new samples, does not make sense when replacing a specific sample |
2912 |
|
|
2913 |
// matches all file types supported by libsndfile |
// matches all file types supported by libsndfile |
2914 |
#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 |
2979 |
sf_close(hFile); // close sound file |
sf_close(hFile); // close sound file |
2980 |
throw std::string(_("format not supported")); // unsupported subformat (yet?) |
throw std::string(_("format not supported")); // unsupported subformat (yet?) |
2981 |
} |
} |
2982 |
// add a new sample to the .gig file |
// add a new sample to the .gig file (if adding is requested actually) |
2983 |
gig::Sample* sample = file->AddSample(); |
if (!replace) sample = file->AddSample(); |
2984 |
// file name without path |
// file name without path |
2985 |
Glib::ustring filename = Glib::filename_display_basename(*iter); |
Glib::ustring filename = Glib::filename_display_basename(*iter); |
2986 |
// remove file extension if there is one |
// remove file extension if there is one |
2990 |
break; |
break; |
2991 |
} |
} |
2992 |
} |
} |
2993 |
sample->pInfo->Name = filename; |
sample->pInfo->Name = gig_from_utf8(filename); |
2994 |
sample->Channels = info.channels; |
sample->Channels = info.channels; |
2995 |
sample->BitDepth = bitdepth; |
sample->BitDepth = bitdepth; |
2996 |
sample->FrameSize = bitdepth / 8/*1 byte are 8 bits*/ * info.channels; |
sample->FrameSize = bitdepth / 8/*1 byte are 8 bits*/ * info.channels; |
3004 |
&instrument, sizeof(instrument)) != SF_FALSE) |
&instrument, sizeof(instrument)) != SF_FALSE) |
3005 |
{ |
{ |
3006 |
sample->MIDIUnityNote = instrument.basenote; |
sample->MIDIUnityNote = instrument.basenote; |
3007 |
|
sample->FineTune = instrument.detune; |
3008 |
|
|
|
#if HAVE_SF_INSTRUMENT_LOOPS |
|
3009 |
if (instrument.loop_count && instrument.loops[0].mode != SF_LOOP_NONE) { |
if (instrument.loop_count && instrument.loops[0].mode != SF_LOOP_NONE) { |
3010 |
sample->Loops = 1; |
sample->Loops = 1; |
3011 |
|
|
3025 |
sample->LoopPlayCount = instrument.loops[0].count; |
sample->LoopPlayCount = instrument.loops[0].count; |
3026 |
sample->LoopSize = sample->LoopEnd - sample->LoopStart + 1; |
sample->LoopSize = sample->LoopEnd - sample->LoopStart + 1; |
3027 |
} |
} |
|
#endif |
|
3028 |
} |
} |
3029 |
|
|
3030 |
// schedule resizing the sample (which will be done |
// schedule resizing the sample (which will be done |
3031 |
// physically when File::Save() is called) |
// physically when File::Save() is called) |
3032 |
sample->Resize(info.frames); |
sample->Resize(info.frames); |
3033 |
// make sure sample is part of the selected group |
// make sure sample is part of the selected group |
3034 |
group->AddSample(sample); |
if (!replace) group->AddSample(sample); |
3035 |
// schedule that physical resize and sample import |
// schedule that physical resize and sample import |
3036 |
// (data copying), performed when "Save" is requested |
// (data copying), performed when "Save" is requested |
3037 |
SampleImportItem sched_item; |
SampleImportItem sched_item; |
3038 |
sched_item.gig_sample = sample; |
sched_item.gig_sample = sample; |
3039 |
sched_item.sample_path = *iter; |
sched_item.sample_path = *iter; |
3040 |
m_SampleImportQueue.push_back(sched_item); |
m_SampleImportQueue[sample] = sched_item; |
3041 |
// add sample to the tree view |
// add sample to the tree view |
3042 |
Gtk::TreeModel::iterator iterSample = |
if (replace) { |
3043 |
m_refSamplesTreeModel->append(row.children()); |
row[m_SamplesModel.m_col_name] = gig_to_utf8(sample->pInfo->Name); |
3044 |
Gtk::TreeModel::Row rowSample = *iterSample; |
} else { |
3045 |
rowSample[m_SamplesModel.m_col_name] = filename; |
Gtk::TreeModel::iterator iterSample = |
3046 |
rowSample[m_SamplesModel.m_col_sample] = sample; |
m_refSamplesTreeModel->append(row.children()); |
3047 |
rowSample[m_SamplesModel.m_col_group] = NULL; |
Gtk::TreeModel::Row rowSample = *iterSample; |
3048 |
|
rowSample[m_SamplesModel.m_col_name] = |
3049 |
|
gig_to_utf8(sample->pInfo->Name); |
3050 |
|
rowSample[m_SamplesModel.m_col_sample] = sample; |
3051 |
|
rowSample[m_SamplesModel.m_col_group] = NULL; |
3052 |
|
} |
3053 |
// close sound file |
// close sound file |
3054 |
sf_close(hFile); |
sf_close(hFile); |
3055 |
file_changed(); |
file_changed(); |
3056 |
} catch (std::string what) { // remember the files that made trouble (and their cause) |
} catch (std::string what) { // remember the files that made trouble (and their cause) |
3057 |
if (error_files.size()) error_files += "\n"; |
if (!error_files.empty()) error_files += "\n"; |
3058 |
error_files += *iter += " (" + what + ")"; |
error_files += *iter += " (" + what + ")"; |
3059 |
} |
} |
3060 |
} |
} |
3061 |
// show error message box when some file(s) could not be opened / added |
// show error message box when some file(s) could not be opened / added |
3062 |
if (error_files.size()) { |
if (!error_files.empty()) { |
3063 |
Glib::ustring txt = _("Could not add the following sample(s):\n") + error_files; |
Glib::ustring txt = |
3064 |
|
(replace |
3065 |
|
? _("Failed to replace sample with:\n") |
3066 |
|
: _("Could not add the following sample(s):\n")) |
3067 |
|
+ error_files; |
3068 |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
3069 |
msg.run(); |
msg.run(); |
3070 |
} |
} |
3076 |
if (!file) return; |
if (!file) return; |
3077 |
Gtk::FileChooserDialog dialog(*this, _("Select Folder"), |
Gtk::FileChooserDialog dialog(*this, _("Select Folder"), |
3078 |
Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER); |
Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER); |
3079 |
const char* str = |
const char* str = |
3080 |
_("This is a very specific function. It tries to replace all samples " |
_("This is a very specific function. It tries to replace all samples " |
3081 |
"in the current gig file by samples located in the chosen " |
"in the current gig file by samples located in the chosen " |
3082 |
"directory.\n\n" |
"directory.\n\n" |
3122 |
sample; sample = file->GetNextSample()) |
sample; sample = file->GetNextSample()) |
3123 |
{ |
{ |
3124 |
std::string filename = |
std::string filename = |
3125 |
folder + G_DIR_SEPARATOR_S + sample->pInfo->Name + |
folder + G_DIR_SEPARATOR_S + |
3126 |
postfixEntryBox.get_text().raw(); |
Glib::filename_from_utf8(gig_to_utf8(sample->pInfo->Name) + |
3127 |
|
postfixEntryBox.get_text()); |
3128 |
SF_INFO info; |
SF_INFO info; |
3129 |
info.format = 0; |
info.format = 0; |
3130 |
SNDFILE* hFile = sf_open(filename.c_str(), SFM_READ, &info); |
SNDFILE* hFile = sf_open(filename.c_str(), SFM_READ, &info); |
3131 |
try |
try |
3132 |
{ |
{ |
3133 |
if (!hFile) throw std::string(_("could not open file")); |
if (!hFile) throw std::string(_("could not open file")); |
|
int bitdepth; |
|
3134 |
switch (info.format & 0xff) { |
switch (info.format & 0xff) { |
3135 |
case SF_FORMAT_PCM_S8: |
case SF_FORMAT_PCM_S8: |
3136 |
case SF_FORMAT_PCM_16: |
case SF_FORMAT_PCM_16: |
3137 |
case SF_FORMAT_PCM_U8: |
case SF_FORMAT_PCM_U8: |
|
bitdepth = 16; |
|
|
break; |
|
3138 |
case SF_FORMAT_PCM_24: |
case SF_FORMAT_PCM_24: |
3139 |
case SF_FORMAT_PCM_32: |
case SF_FORMAT_PCM_32: |
3140 |
case SF_FORMAT_FLOAT: |
case SF_FORMAT_FLOAT: |
3141 |
case SF_FORMAT_DOUBLE: |
case SF_FORMAT_DOUBLE: |
|
bitdepth = 24; |
|
3142 |
break; |
break; |
3143 |
default: |
default: |
3144 |
sf_close(hFile); |
sf_close(hFile); |
3147 |
SampleImportItem sched_item; |
SampleImportItem sched_item; |
3148 |
sched_item.gig_sample = sample; |
sched_item.gig_sample = sample; |
3149 |
sched_item.sample_path = filename; |
sched_item.sample_path = filename; |
3150 |
m_SampleImportQueue.push_back(sched_item); |
m_SampleImportQueue[sample] = sched_item; |
3151 |
sf_close(hFile); |
sf_close(hFile); |
3152 |
file_changed(); |
file_changed(); |
3153 |
} |
} |
3154 |
catch (std::string what) |
catch (std::string what) |
3155 |
{ |
{ |
3156 |
if (error_files.size()) error_files += "\n"; |
if (!error_files.empty()) error_files += "\n"; |
3157 |
error_files += filename += " (" + what + ")"; |
error_files += Glib::filename_to_utf8(filename) + |
3158 |
|
" (" + what + ")"; |
3159 |
} |
} |
3160 |
} |
} |
3161 |
// show error message box when some file(s) could not be opened / added |
// show error message box when some file(s) could not be opened / added |
3162 |
if (error_files.size()) { |
if (!error_files.empty()) { |
3163 |
Glib::ustring txt = |
Glib::ustring txt = |
3164 |
_("Could not replace the following sample(s):\n") + error_files; |
_("Could not replace the following sample(s):\n") + error_files; |
3165 |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
3171 |
void MainWindow::on_action_remove_sample() { |
void MainWindow::on_action_remove_sample() { |
3172 |
if (!file) return; |
if (!file) return; |
3173 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
3174 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
3175 |
if (it) { |
for (int r = rows.size() - 1; r >= 0; --r) { |
3176 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[r]); |
3177 |
|
if (!it) continue; |
3178 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
3179 |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
3180 |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
3182 |
try { |
try { |
3183 |
// remove group or sample from the gig file |
// remove group or sample from the gig file |
3184 |
if (group) { |
if (group) { |
3185 |
// temporarily remember the samples that bolong to |
// temporarily remember the samples that belong to |
3186 |
// that group (we need that to clean the queue) |
// that group (we need that to clean the queue) |
3187 |
std::list<gig::Sample*> members; |
std::list<gig::Sample*> members; |
3188 |
for (gig::Sample* pSample = group->GetFirstSample(); |
for (gig::Sample* pSample = group->GetFirstSample(); |
3199 |
// if sample(s) were just previously added, remove |
// if sample(s) were just previously added, remove |
3200 |
// them from the import queue |
// them from the import queue |
3201 |
for (std::list<gig::Sample*>::iterator member = members.begin(); |
for (std::list<gig::Sample*>::iterator member = members.begin(); |
3202 |
member != members.end(); ++member) { |
member != members.end(); ++member) |
3203 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
{ |
3204 |
iter != m_SampleImportQueue.end(); ++iter) { |
if (m_SampleImportQueue.count(*member)) { |
3205 |
if ((*iter).gig_sample == *member) { |
printf("Removing previously added sample '%s' from group '%s'\n", |
3206 |
printf("Removing previously added sample '%s' from group '%s'\n", |
m_SampleImportQueue[sample].sample_path.c_str(), name.c_str()); |
3207 |
(*iter).sample_path.c_str(), name.c_str()); |
m_SampleImportQueue.erase(*member); |
|
m_SampleImportQueue.erase(iter); |
|
|
break; |
|
|
} |
|
3208 |
} |
} |
3209 |
} |
} |
3210 |
file_changed(); |
file_changed(); |
3219 |
samples_removed_signal.emit(); |
samples_removed_signal.emit(); |
3220 |
// if sample was just previously added, remove it from |
// if sample was just previously added, remove it from |
3221 |
// the import queue |
// the import queue |
3222 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
if (m_SampleImportQueue.count(sample)) { |
3223 |
iter != m_SampleImportQueue.end(); ++iter) { |
printf("Removing previously added sample '%s'\n", |
3224 |
if ((*iter).gig_sample == sample) { |
m_SampleImportQueue[sample].sample_path.c_str()); |
3225 |
printf("Removing previously added sample '%s'\n", |
m_SampleImportQueue.erase(sample); |
|
(*iter).sample_path.c_str()); |
|
|
m_SampleImportQueue.erase(iter); |
|
|
break; |
|
|
} |
|
3226 |
} |
} |
3227 |
dimreg_changed(); |
dimreg_changed(); |
3228 |
file_changed(); |
file_changed(); |
3239 |
} |
} |
3240 |
} |
} |
3241 |
|
|
3242 |
|
void MainWindow::on_action_remove_unused_samples() { |
3243 |
|
if (!file) return; |
3244 |
|
|
3245 |
|
// collect all samples that are not referenced by any instrument |
3246 |
|
std::list<gig::Sample*> lsamples; |
3247 |
|
for (int iSample = 0; file->GetSample(iSample); ++iSample) { |
3248 |
|
gig::Sample* sample = file->GetSample(iSample); |
3249 |
|
bool isUsed = false; |
3250 |
|
for (gig::Instrument* instrument = file->GetFirstInstrument(); instrument; |
3251 |
|
instrument = file->GetNextInstrument()) |
3252 |
|
{ |
3253 |
|
for (gig::Region* rgn = instrument->GetFirstRegion(); rgn; |
3254 |
|
rgn = instrument->GetNextRegion()) |
3255 |
|
{ |
3256 |
|
for (int i = 0; i < 256; ++i) { |
3257 |
|
if (!rgn->pDimensionRegions[i]) continue; |
3258 |
|
if (rgn->pDimensionRegions[i]->pSample != sample) continue; |
3259 |
|
isUsed = true; |
3260 |
|
goto endOfRefSearch; |
3261 |
|
} |
3262 |
|
} |
3263 |
|
} |
3264 |
|
endOfRefSearch: |
3265 |
|
if (!isUsed) lsamples.push_back(sample); |
3266 |
|
} |
3267 |
|
|
3268 |
|
if (lsamples.empty()) return; |
3269 |
|
|
3270 |
|
// notify everybody that we're going to remove these samples |
3271 |
|
samples_to_be_removed_signal.emit(lsamples); |
3272 |
|
|
3273 |
|
// remove collected samples |
3274 |
|
try { |
3275 |
|
for (std::list<gig::Sample*>::iterator itSample = lsamples.begin(); |
3276 |
|
itSample != lsamples.end(); ++itSample) |
3277 |
|
{ |
3278 |
|
gig::Sample* sample = *itSample; |
3279 |
|
// remove sample from the .gig file |
3280 |
|
file->DeleteSample(sample); |
3281 |
|
// if sample was just previously added, remove it from the import queue |
3282 |
|
if (m_SampleImportQueue.count(sample)) { |
3283 |
|
printf("Removing previously added sample '%s'\n", |
3284 |
|
m_SampleImportQueue[sample].sample_path.c_str()); |
3285 |
|
m_SampleImportQueue.erase(sample); |
3286 |
|
} |
3287 |
|
} |
3288 |
|
} catch (RIFF::Exception e) { |
3289 |
|
// show error message |
3290 |
|
Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR); |
3291 |
|
msg.run(); |
3292 |
|
} |
3293 |
|
|
3294 |
|
// notify everybody that we're done with removal |
3295 |
|
samples_removed_signal.emit(); |
3296 |
|
|
3297 |
|
dimreg_changed(); |
3298 |
|
file_changed(); |
3299 |
|
__refreshEntireGUI(); |
3300 |
|
} |
3301 |
|
|
3302 |
|
// see comment on on_sample_treeview_drag_begin() |
3303 |
|
void MainWindow::on_scripts_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context) |
3304 |
|
{ |
3305 |
|
first_call_to_drag_data_get = true; |
3306 |
|
} |
3307 |
|
|
3308 |
|
void MainWindow::on_scripts_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&, |
3309 |
|
Gtk::SelectionData& selection_data, guint, guint) |
3310 |
|
{ |
3311 |
|
if (!first_call_to_drag_data_get) return; |
3312 |
|
first_call_to_drag_data_get = false; |
3313 |
|
|
3314 |
|
// get selected script |
3315 |
|
gig::Script* script = NULL; |
3316 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewScripts.get_selection(); |
3317 |
|
Gtk::TreeModel::iterator it = sel->get_selected(); |
3318 |
|
if (it) { |
3319 |
|
Gtk::TreeModel::Row row = *it; |
3320 |
|
script = row[m_ScriptsModel.m_col_script]; |
3321 |
|
} |
3322 |
|
// pass the gig::Script as pointer |
3323 |
|
selection_data.set(selection_data.get_target(), 0/*unused*/, |
3324 |
|
(const guchar*)&script, |
3325 |
|
sizeof(script)/*length of data in bytes*/); |
3326 |
|
} |
3327 |
|
|
3328 |
|
// see comment on on_sample_treeview_drag_begin() |
3329 |
|
void MainWindow::on_instruments_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context) |
3330 |
|
{ |
3331 |
|
first_call_to_drag_data_get = true; |
3332 |
|
} |
3333 |
|
|
3334 |
|
void MainWindow::on_instruments_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&, |
3335 |
|
Gtk::SelectionData& selection_data, guint, guint) |
3336 |
|
{ |
3337 |
|
if (!first_call_to_drag_data_get) return; |
3338 |
|
first_call_to_drag_data_get = false; |
3339 |
|
|
3340 |
|
// get selected source instrument |
3341 |
|
gig::Instrument* src = NULL; |
3342 |
|
{ |
3343 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
3344 |
|
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
3345 |
|
if (!rows.empty()) { |
3346 |
|
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
3347 |
|
if (it) { |
3348 |
|
Gtk::TreeModel::Row row = *it; |
3349 |
|
src = row[m_Columns.m_col_instr]; |
3350 |
|
} |
3351 |
|
} |
3352 |
|
} |
3353 |
|
if (!src) return; |
3354 |
|
|
3355 |
|
// pass the source gig::Instrument as pointer |
3356 |
|
selection_data.set(selection_data.get_target(), 0/*unused*/, (const guchar*)&src, |
3357 |
|
sizeof(src)/*length of data in bytes*/); |
3358 |
|
} |
3359 |
|
|
3360 |
|
void MainWindow::on_instruments_treeview_drop_drag_data_received( |
3361 |
|
const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, |
3362 |
|
const Gtk::SelectionData& selection_data, guint, guint time) |
3363 |
|
{ |
3364 |
|
gig::Instrument* src = *((gig::Instrument**) selection_data.get_data()); |
3365 |
|
if (!src || selection_data.get_length() != sizeof(gig::Instrument*)) |
3366 |
|
return; |
3367 |
|
|
3368 |
|
gig::Instrument* dst = NULL; |
3369 |
|
{ |
3370 |
|
Gtk::TreeModel::Path path; |
3371 |
|
const bool found = m_TreeView.get_path_at_pos(x, y, path); |
3372 |
|
if (!found) return; |
3373 |
|
|
3374 |
|
Gtk::TreeModel::iterator iter = m_refTreeModel->get_iter(path); |
3375 |
|
if (!iter) return; |
3376 |
|
Gtk::TreeModel::Row row = *iter; |
3377 |
|
dst = row[m_Columns.m_col_instr]; |
3378 |
|
} |
3379 |
|
if (!dst) return; |
3380 |
|
|
3381 |
|
//printf("dragdrop received src=%s dst=%s\n", src->pInfo->Name.c_str(), dst->pInfo->Name.c_str()); |
3382 |
|
src->MoveTo(dst); |
3383 |
|
__refreshEntireGUI(); |
3384 |
|
select_instrument(src); |
3385 |
|
} |
3386 |
|
|
3387 |
// For some reason drag_data_get gets called two times for each |
// For some reason drag_data_get gets called two times for each |
3388 |
// drag'n'drop (at least when target is an Entry). This work-around |
// drag'n'drop (at least when target is an Entry). This work-around |
3389 |
// makes sure the code in drag_data_get and drop_drag_data_received is |
// makes sure the code in drag_data_get and drop_drag_data_received is |
3402 |
// get selected sample |
// get selected sample |
3403 |
gig::Sample* sample = NULL; |
gig::Sample* sample = NULL; |
3404 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
3405 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
3406 |
if (it) { |
if (!rows.empty()) { |
3407 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]); |
3408 |
sample = row[m_SamplesModel.m_col_sample]; |
if (it) { |
3409 |
|
Gtk::TreeModel::Row row = *it; |
3410 |
|
sample = row[m_SamplesModel.m_col_sample]; |
3411 |
|
} |
3412 |
} |
} |
3413 |
// pass the gig::Sample as pointer |
// pass the gig::Sample as pointer |
3414 |
selection_data.set(selection_data.get_target(), 0/*unused*/, (const guchar*)&sample, |
selection_data.set(selection_data.get_target(), 0/*unused*/, (const guchar*)&sample, |
3445 |
bool channels_changed = false; |
bool channels_changed = false; |
3446 |
if (sample->Channels == 1 && stereo_dimension) { |
if (sample->Channels == 1 && stereo_dimension) { |
3447 |
// remove the samplechannel dimension |
// remove the samplechannel dimension |
3448 |
|
/* commented out, because it makes it impossible building up an instrument from scratch using two separate L/R samples |
3449 |
region->DeleteDimension(stereo_dimension); |
region->DeleteDimension(stereo_dimension); |
3450 |
channels_changed = true; |
channels_changed = true; |
3451 |
region_changed(); |
region_changed(); |
3452 |
|
*/ |
3453 |
} |
} |
3454 |
dimreg_edit.set_sample(sample); |
dimreg_edit.set_sample( |
3455 |
|
sample, |
3456 |
|
is_copy_samples_unity_note_enabled(), |
3457 |
|
is_copy_samples_fine_tune_enabled(), |
3458 |
|
is_copy_samples_loop_enabled() |
3459 |
|
); |
3460 |
|
|
3461 |
if (sample->Channels == 2 && !stereo_dimension) { |
if (sample->Channels == 2 && !stereo_dimension) { |
3462 |
// add samplechannel dimension |
// add samplechannel dimension |
3499 |
Glib::ustring name = row[m_SamplesModel.m_col_name]; |
Glib::ustring name = row[m_SamplesModel.m_col_name]; |
3500 |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
3501 |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
3502 |
|
gig::String gigname(gig_from_utf8(name)); |
3503 |
if (group) { |
if (group) { |
3504 |
if (group->Name != name) { |
if (group->Name != gigname) { |
3505 |
group->Name = name; |
group->Name = gigname; |
3506 |
printf("group name changed\n"); |
printf("group name changed\n"); |
3507 |
file_changed(); |
file_changed(); |
3508 |
} |
} |
3509 |
} else if (sample) { |
} else if (sample) { |
3510 |
if (sample->pInfo->Name != name.raw()) { |
if (sample->pInfo->Name != gigname) { |
3511 |
sample->pInfo->Name = name.raw(); |
sample->pInfo->Name = gigname; |
3512 |
printf("sample name changed\n"); |
printf("sample name changed\n"); |
3513 |
file_changed(); |
file_changed(); |
3514 |
} |
} |
3515 |
} |
} |
3516 |
} |
} |
3517 |
|
|
3518 |
|
void MainWindow::script_name_changed(const Gtk::TreeModel::Path& path, |
3519 |
|
const Gtk::TreeModel::iterator& iter) { |
3520 |
|
if (!iter) return; |
3521 |
|
Gtk::TreeModel::Row row = *iter; |
3522 |
|
Glib::ustring name = row[m_ScriptsModel.m_col_name]; |
3523 |
|
gig::ScriptGroup* group = row[m_ScriptsModel.m_col_group]; |
3524 |
|
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
3525 |
|
gig::String gigname(gig_from_utf8(name)); |
3526 |
|
if (group) { |
3527 |
|
if (group->Name != gigname) { |
3528 |
|
group->Name = gigname; |
3529 |
|
printf("script group name changed\n"); |
3530 |
|
file_changed(); |
3531 |
|
} |
3532 |
|
} else if (script) { |
3533 |
|
if (script->Name != gigname) { |
3534 |
|
script->Name = gigname; |
3535 |
|
printf("script name changed\n"); |
3536 |
|
file_changed(); |
3537 |
|
} |
3538 |
|
} |
3539 |
|
} |
3540 |
|
|
3541 |
|
void MainWindow::script_double_clicked(const Gtk::TreeModel::Path& path, |
3542 |
|
Gtk::TreeViewColumn* column) |
3543 |
|
{ |
3544 |
|
Gtk::TreeModel::iterator iter = m_refScriptsTreeModel->get_iter(path); |
3545 |
|
if (!iter) return; |
3546 |
|
Gtk::TreeModel::Row row = *iter; |
3547 |
|
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
3548 |
|
if (!script) return; |
3549 |
|
|
3550 |
|
ScriptEditor* editor = new ScriptEditor; |
3551 |
|
editor->signal_script_to_be_changed.connect( |
3552 |
|
signal_script_to_be_changed.make_slot() |
3553 |
|
); |
3554 |
|
editor->signal_script_changed.connect( |
3555 |
|
signal_script_changed.make_slot() |
3556 |
|
); |
3557 |
|
editor->setScript(script); |
3558 |
|
//editor->reparent(*this); |
3559 |
|
editor->show(); |
3560 |
|
} |
3561 |
|
|
3562 |
void MainWindow::instrument_name_changed(const Gtk::TreeModel::Path& path, |
void MainWindow::instrument_name_changed(const Gtk::TreeModel::Path& path, |
3563 |
const Gtk::TreeModel::iterator& iter) { |
const Gtk::TreeModel::iterator& iter) { |
3564 |
if (!iter) return; |
if (!iter) return; |
3565 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
3566 |
Glib::ustring name = row[m_Columns.m_col_name]; |
Glib::ustring name = row[m_Columns.m_col_name]; |
3567 |
|
|
3568 |
|
// change name in instrument menu |
3569 |
|
int index = path[0]; |
3570 |
|
const std::vector<Gtk::Widget*> children = instrument_menu->get_children(); |
3571 |
|
if (index < children.size()) { |
3572 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 16) || GTKMM_MAJOR_VERSION > 2 |
3573 |
|
static_cast<Gtk::RadioMenuItem*>(children[index])->set_label(name); |
3574 |
|
#else |
3575 |
|
remove_instrument_from_menu(index); |
3576 |
|
Gtk::RadioMenuItem* item = add_instrument_to_menu(name, index); |
3577 |
|
item->set_active(); |
3578 |
|
#endif |
3579 |
|
} |
3580 |
|
|
3581 |
|
// change name in gig |
3582 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
3583 |
if (instrument && instrument->pInfo->Name != name.raw()) { |
gig::String gigname(gig_from_utf8(name)); |
3584 |
instrument->pInfo->Name = name.raw(); |
if (instrument && instrument->pInfo->Name != gigname) { |
3585 |
|
instrument->pInfo->Name = gigname; |
3586 |
|
|
3587 |
|
// change name in the instrument properties window |
3588 |
|
if (instrumentProps.get_instrument() == instrument) { |
3589 |
|
instrumentProps.update_name(); |
3590 |
|
} |
3591 |
|
|
3592 |
file_changed(); |
file_changed(); |
3593 |
} |
} |
3594 |
} |
} |
3595 |
|
|
3596 |
|
void MainWindow::on_action_combine_instruments() { |
3597 |
|
CombineInstrumentsDialog* d = new CombineInstrumentsDialog(*this, file); |
3598 |
|
|
3599 |
|
// take over selection from instruments list view for the combine dialog's |
3600 |
|
// list view as pre-selection |
3601 |
|
std::set<int> indeces; |
3602 |
|
{ |
3603 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
3604 |
|
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
3605 |
|
for (int r = 0; r < rows.size(); ++r) { |
3606 |
|
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]); |
3607 |
|
if (it) { |
3608 |
|
Gtk::TreeModel::Row row = *it; |
3609 |
|
int index = row[m_Columns.m_col_nr]; |
3610 |
|
indeces.insert(index); |
3611 |
|
} |
3612 |
|
} |
3613 |
|
} |
3614 |
|
d->setSelectedInstruments(indeces); |
3615 |
|
|
3616 |
|
d->show_all(); |
3617 |
|
d->run(); |
3618 |
|
if (d->fileWasChanged()) { |
3619 |
|
// update GUI with new instrument just created |
3620 |
|
add_instrument(d->newCombinedInstrument()); |
3621 |
|
} |
3622 |
|
delete d; |
3623 |
|
} |
3624 |
|
|
3625 |
|
void MainWindow::on_action_view_references() { |
3626 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
3627 |
|
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
3628 |
|
if (rows.empty()) return; |
3629 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]); |
3630 |
|
if (!it) return; |
3631 |
|
Gtk::TreeModel::Row row = *it; |
3632 |
|
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
3633 |
|
if (!sample) return; |
3634 |
|
|
3635 |
|
ReferencesView* d = new ReferencesView(*this); |
3636 |
|
d->setSample(sample); |
3637 |
|
d->dimension_region_selected.connect( |
3638 |
|
sigc::mem_fun(*this, &MainWindow::select_dimension_region) |
3639 |
|
); |
3640 |
|
d->show_all(); |
3641 |
|
d->resize(500, 400); |
3642 |
|
d->run(); |
3643 |
|
delete d; |
3644 |
|
} |
3645 |
|
|
3646 |
|
void MainWindow::mergeFiles(const std::vector<std::string>& filenames) { |
3647 |
|
struct _Source { |
3648 |
|
std::vector<RIFF::File*> riffs; |
3649 |
|
std::vector<gig::File*> gigs; |
3650 |
|
|
3651 |
|
~_Source() { |
3652 |
|
for (int k = 0; k < gigs.size(); ++k) delete gigs[k]; |
3653 |
|
for (int k = 0; k < riffs.size(); ++k) delete riffs[k]; |
3654 |
|
riffs.clear(); |
3655 |
|
gigs.clear(); |
3656 |
|
} |
3657 |
|
} sources; |
3658 |
|
|
3659 |
|
if (filenames.empty()) |
3660 |
|
throw RIFF::Exception(_("No files selected, so nothing done.")); |
3661 |
|
|
3662 |
|
// first open all input files (to avoid output file corruption) |
3663 |
|
int i; |
3664 |
|
try { |
3665 |
|
for (i = 0; i < filenames.size(); ++i) { |
3666 |
|
const std::string& filename = filenames[i]; |
3667 |
|
printf("opening file=%s\n", filename.c_str()); |
3668 |
|
|
3669 |
|
RIFF::File* riff = new RIFF::File(filename); |
3670 |
|
sources.riffs.push_back(riff); |
3671 |
|
|
3672 |
|
gig::File* gig = new gig::File(riff); |
3673 |
|
sources.gigs.push_back(gig); |
3674 |
|
} |
3675 |
|
} catch (RIFF::Exception e) { |
3676 |
|
throw RIFF::Exception( |
3677 |
|
_("Error occurred while opening '") + |
3678 |
|
filenames[i] + |
3679 |
|
"': " + |
3680 |
|
e.Message |
3681 |
|
); |
3682 |
|
} catch (...) { |
3683 |
|
throw RIFF::Exception( |
3684 |
|
_("Unknown exception occurred while opening '") + |
3685 |
|
filenames[i] + "'" |
3686 |
|
); |
3687 |
|
} |
3688 |
|
|
3689 |
|
// now merge the opened .gig files to the main .gig file currently being |
3690 |
|
// open in gigedit |
3691 |
|
try { |
3692 |
|
for (i = 0; i < filenames.size(); ++i) { |
3693 |
|
const std::string& filename = filenames[i]; |
3694 |
|
printf("merging file=%s\n", filename.c_str()); |
3695 |
|
assert(i < sources.gigs.size()); |
3696 |
|
|
3697 |
|
this->file->AddContentOf(sources.gigs[i]); |
3698 |
|
} |
3699 |
|
} catch (RIFF::Exception e) { |
3700 |
|
throw RIFF::Exception( |
3701 |
|
_("Error occurred while merging '") + |
3702 |
|
filenames[i] + |
3703 |
|
"': " + |
3704 |
|
e.Message |
3705 |
|
); |
3706 |
|
} catch (...) { |
3707 |
|
throw RIFF::Exception( |
3708 |
|
_("Unknown exception occurred while merging '") + |
3709 |
|
filenames[i] + "'" |
3710 |
|
); |
3711 |
|
} |
3712 |
|
|
3713 |
|
// Finally save gig file persistently to disk ... |
3714 |
|
//NOTE: requires that this gig file already has a filename ! |
3715 |
|
{ |
3716 |
|
std::cout << "Saving file\n" << std::flush; |
3717 |
|
file_structure_to_be_changed_signal.emit(this->file); |
3718 |
|
|
3719 |
|
progress_dialog = new ProgressDialog( //FIXME: memory leak! |
3720 |
|
_("Saving") + Glib::ustring(" '") + |
3721 |
|
Glib::filename_display_basename(this->filename) + "' ...", |
3722 |
|
*this |
3723 |
|
); |
3724 |
|
progress_dialog->show_all(); |
3725 |
|
saver = new Saver(this->file); //FIXME: memory leak! |
3726 |
|
saver->signal_progress().connect( |
3727 |
|
sigc::mem_fun(*this, &MainWindow::on_saver_progress)); |
3728 |
|
saver->signal_finished().connect( |
3729 |
|
sigc::mem_fun(*this, &MainWindow::on_saver_finished)); |
3730 |
|
saver->signal_error().connect( |
3731 |
|
sigc::mem_fun(*this, &MainWindow::on_saver_error)); |
3732 |
|
saver->launch(); |
3733 |
|
} |
3734 |
|
} |
3735 |
|
|
3736 |
|
void MainWindow::on_action_merge_files() { |
3737 |
|
if (this->file->GetFileName().empty()) { |
3738 |
|
Glib::ustring txt = _( |
3739 |
|
"You seem to have a new .gig file open that has not been saved " |
3740 |
|
"yet. You must save it somewhere before starting to merge it with " |
3741 |
|
"other .gig files though, because during the merge operation the " |
3742 |
|
"other files' sample data must be written on file level to the " |
3743 |
|
"target .gig file." |
3744 |
|
); |
3745 |
|
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
3746 |
|
msg.run(); |
3747 |
|
return; |
3748 |
|
} |
3749 |
|
|
3750 |
|
Gtk::FileChooserDialog dialog(*this, _("Merge .gig files")); |
3751 |
|
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
3752 |
|
dialog.add_button(_("Merge"), Gtk::RESPONSE_OK); |
3753 |
|
dialog.set_default_response(Gtk::RESPONSE_CANCEL); |
3754 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
3755 |
|
Gtk::FileFilter filter; |
3756 |
|
filter.add_pattern("*.gig"); |
3757 |
|
#else |
3758 |
|
Glib::RefPtr<Gtk::FileFilter> filter = Gtk::FileFilter::create(); |
3759 |
|
filter->add_pattern("*.gig"); |
3760 |
|
#endif |
3761 |
|
dialog.set_filter(filter); |
3762 |
|
if (current_gig_dir != "") { |
3763 |
|
dialog.set_current_folder(current_gig_dir); |
3764 |
|
} |
3765 |
|
dialog.set_select_multiple(true); |
3766 |
|
|
3767 |
|
// show warning in the file picker dialog |
3768 |
|
Gtk::HBox descriptionArea; |
3769 |
|
descriptionArea.set_spacing(15); |
3770 |
|
Gtk::Image warningIcon; |
3771 |
|
warningIcon.set_from_icon_name("dialog-warning", |
3772 |
|
Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); |
3773 |
|
descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); |
3774 |
|
#if GTKMM_MAJOR_VERSION < 3 |
3775 |
|
view::WrapLabel description; |
3776 |
|
#else |
3777 |
|
Gtk::Label description; |
3778 |
|
description.set_line_wrap(); |
3779 |
|
#endif |
3780 |
|
description.set_markup(_( |
3781 |
|
"\nSelect at least one .gig file that shall be merged to the .gig file " |
3782 |
|
"currently being open in gigedit.\n\n" |
3783 |
|
"<b>Please Note:</b> Merging with other files will modify your " |
3784 |
|
"currently open .gig file on file level! And be aware that the current " |
3785 |
|
"merge algorithm does not detect duplicate samples yet. So if you are " |
3786 |
|
"merging files which are using equivalent sample data, those " |
3787 |
|
"equivalent samples will currently be treated as separate samples and " |
3788 |
|
"will accordingly be stored separately in the target .gig file!" |
3789 |
|
)); |
3790 |
|
descriptionArea.pack_start(description); |
3791 |
|
dialog.get_vbox()->pack_start(descriptionArea, Gtk::PACK_SHRINK); |
3792 |
|
descriptionArea.show_all(); |
3793 |
|
|
3794 |
|
if (dialog.run() == Gtk::RESPONSE_OK) { |
3795 |
|
printf("on_action_merge_files self=%p\n", |
3796 |
|
static_cast<void*>(Glib::Threads::Thread::self())); |
3797 |
|
std::vector<std::string> filenames = dialog.get_filenames(); |
3798 |
|
|
3799 |
|
// merge the selected files to the currently open .gig file |
3800 |
|
try { |
3801 |
|
mergeFiles(filenames); |
3802 |
|
} catch (RIFF::Exception e) { |
3803 |
|
Gtk::MessageDialog msg(*this, e.Message, false, Gtk::MESSAGE_ERROR); |
3804 |
|
msg.run(); |
3805 |
|
} |
3806 |
|
|
3807 |
|
// update GUI |
3808 |
|
__refreshEntireGUI(); |
3809 |
|
} |
3810 |
|
} |
3811 |
|
|
3812 |
void MainWindow::set_file_is_shared(bool b) { |
void MainWindow::set_file_is_shared(bool b) { |
3813 |
this->file_is_shared = b; |
this->file_is_shared = b; |
3814 |
|
|
3823 |
Gdk::Pixbuf::create_from_xpm_data(status_detached_xpm) |
Gdk::Pixbuf::create_from_xpm_data(status_detached_xpm) |
3824 |
); |
); |
3825 |
} |
} |
3826 |
|
|
3827 |
|
{ |
3828 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
3829 |
|
uiManager->get_widget("/MenuBar/MenuSettings/SyncSamplerInstrumentSelection")); |
3830 |
|
if (item) item->set_sensitive(b); |
3831 |
|
} |
3832 |
|
} |
3833 |
|
|
3834 |
|
void MainWindow::on_sample_ref_count_incremented(gig::Sample* sample, int offset) { |
3835 |
|
if (!sample) return; |
3836 |
|
sample_ref_count[sample] += offset; |
3837 |
|
const int refcount = sample_ref_count[sample]; |
3838 |
|
|
3839 |
|
Glib::RefPtr<Gtk::TreeModel> model = m_TreeViewSamples.get_model(); |
3840 |
|
for (int g = 0; g < model->children().size(); ++g) { |
3841 |
|
Gtk::TreeModel::Row rowGroup = model->children()[g]; |
3842 |
|
for (int s = 0; s < rowGroup.children().size(); ++s) { |
3843 |
|
Gtk::TreeModel::Row rowSample = rowGroup.children()[s]; |
3844 |
|
if (rowSample[m_SamplesModel.m_col_sample] != sample) continue; |
3845 |
|
rowSample[m_SamplesModel.m_col_refcount] = ToString(refcount) + " " + _("Refs."); |
3846 |
|
rowSample[m_SamplesModel.m_color] = refcount ? "black" : "red"; |
3847 |
|
} |
3848 |
|
} |
3849 |
|
} |
3850 |
|
|
3851 |
|
void MainWindow::on_sample_ref_changed(gig::Sample* oldSample, gig::Sample* newSample) { |
3852 |
|
on_sample_ref_count_incremented(oldSample, -1); |
3853 |
|
on_sample_ref_count_incremented(newSample, +1); |
3854 |
|
} |
3855 |
|
|
3856 |
|
void MainWindow::on_samples_to_be_removed(std::list<gig::Sample*> samples) { |
3857 |
|
// just in case a new sample is added later with exactly the same memory |
3858 |
|
// address, which would lead to incorrect refcount if not deleted here |
3859 |
|
for (std::list<gig::Sample*>::const_iterator it = samples.begin(); |
3860 |
|
it != samples.end(); ++it) |
3861 |
|
{ |
3862 |
|
sample_ref_count.erase(*it); |
3863 |
|
} |
3864 |
|
} |
3865 |
|
|
3866 |
|
void MainWindow::show_samples_tab() { |
3867 |
|
m_TreeViewNotebook.set_current_page(0); |
3868 |
|
} |
3869 |
|
|
3870 |
|
void MainWindow::show_intruments_tab() { |
3871 |
|
m_TreeViewNotebook.set_current_page(1); |
3872 |
|
} |
3873 |
|
|
3874 |
|
void MainWindow::show_scripts_tab() { |
3875 |
|
m_TreeViewNotebook.set_current_page(2); |
3876 |
|
} |
3877 |
|
|
3878 |
|
void MainWindow::select_prev_region() { |
3879 |
|
m_RegionChooser.select_prev_region(); |
3880 |
|
} |
3881 |
|
|
3882 |
|
void MainWindow::select_next_region() { |
3883 |
|
m_RegionChooser.select_next_region(); |
3884 |
|
} |
3885 |
|
|
3886 |
|
void MainWindow::select_next_dim_rgn_zone() { |
3887 |
|
if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser |
3888 |
|
m_DimRegionChooser.select_next_dimzone(); |
3889 |
|
} |
3890 |
|
|
3891 |
|
void MainWindow::select_prev_dim_rgn_zone() { |
3892 |
|
if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser |
3893 |
|
m_DimRegionChooser.select_prev_dimzone(); |
3894 |
|
} |
3895 |
|
|
3896 |
|
void MainWindow::select_add_next_dim_rgn_zone() { |
3897 |
|
m_DimRegionChooser.select_next_dimzone(true); |
3898 |
|
} |
3899 |
|
|
3900 |
|
void MainWindow::select_add_prev_dim_rgn_zone() { |
3901 |
|
m_DimRegionChooser.select_prev_dimzone(true); |
3902 |
|
} |
3903 |
|
|
3904 |
|
void MainWindow::select_prev_dimension() { |
3905 |
|
if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser |
3906 |
|
m_DimRegionChooser.select_prev_dimension(); |
3907 |
|
} |
3908 |
|
|
3909 |
|
void MainWindow::select_next_dimension() { |
3910 |
|
if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser |
3911 |
|
m_DimRegionChooser.select_next_dimension(); |
3912 |
|
} |
3913 |
|
|
3914 |
|
#define CLIPBOARD_DIMENSIONREGION_TARGET \ |
3915 |
|
("libgig.DimensionRegion." + m_serializationArchive.rawDataFormat()) |
3916 |
|
|
3917 |
|
void MainWindow::copy_selected_dimrgn() { |
3918 |
|
gig::DimensionRegion* pDimRgn = m_DimRegionChooser.get_main_dimregion(); |
3919 |
|
if (!pDimRgn) { |
3920 |
|
updateClipboardPasteAvailable(); |
3921 |
|
updateClipboardCopyAvailable(); |
3922 |
|
return; |
3923 |
|
} |
3924 |
|
|
3925 |
|
std::vector<Gtk::TargetEntry> targets; |
3926 |
|
targets.push_back( Gtk::TargetEntry(CLIPBOARD_DIMENSIONREGION_TARGET) ); |
3927 |
|
|
3928 |
|
Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); |
3929 |
|
clipboard->set( |
3930 |
|
targets, |
3931 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_get), |
3932 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_clear) |
3933 |
|
); |
3934 |
|
|
3935 |
|
m_serializationArchive.serialize(pDimRgn); |
3936 |
|
|
3937 |
|
updateClipboardPasteAvailable(); |
3938 |
|
} |
3939 |
|
|
3940 |
|
void MainWindow::paste_copied_dimrgn() { |
3941 |
|
Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); |
3942 |
|
clipboard->request_contents( |
3943 |
|
CLIPBOARD_DIMENSIONREGION_TARGET, |
3944 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_received) |
3945 |
|
); |
3946 |
|
updateClipboardPasteAvailable(); |
3947 |
|
} |
3948 |
|
|
3949 |
|
void MainWindow::adjust_clipboard_content() { |
3950 |
|
MacroEditor* editor = new MacroEditor(); |
3951 |
|
editor->setMacro(&m_serializationArchive, true); |
3952 |
|
editor->show(); |
3953 |
|
} |
3954 |
|
|
3955 |
|
void MainWindow::updateClipboardPasteAvailable() { |
3956 |
|
Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); |
3957 |
|
clipboard->request_targets( |
3958 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_received_targets) |
3959 |
|
); |
3960 |
|
} |
3961 |
|
|
3962 |
|
void MainWindow::updateClipboardCopyAvailable() { |
3963 |
|
bool bDimensionRegionCopyIsPossible = m_DimRegionChooser.get_main_dimregion(); |
3964 |
|
static_cast<Gtk::MenuItem*>( |
3965 |
|
uiManager->get_widget("/MenuBar/MenuEdit/CopyDimRgn") |
3966 |
|
)->set_sensitive(bDimensionRegionCopyIsPossible); |
3967 |
|
} |
3968 |
|
|
3969 |
|
void MainWindow::on_clipboard_owner_change(GdkEventOwnerChange* event) { |
3970 |
|
updateClipboardPasteAvailable(); |
3971 |
|
} |
3972 |
|
|
3973 |
|
void MainWindow::on_clipboard_get(Gtk::SelectionData& selection_data, guint /*info*/) { |
3974 |
|
const std::string target = selection_data.get_target(); |
3975 |
|
if (target == CLIPBOARD_DIMENSIONREGION_TARGET) { |
3976 |
|
selection_data.set( |
3977 |
|
CLIPBOARD_DIMENSIONREGION_TARGET, 8 /* "format": probably unused*/, |
3978 |
|
&m_serializationArchive.rawData()[0], |
3979 |
|
m_serializationArchive.rawData().size() |
3980 |
|
); |
3981 |
|
} else { |
3982 |
|
std::cerr << "Clipboard: content for unknown target '" << target << "' requested\n"; |
3983 |
|
} |
3984 |
|
} |
3985 |
|
|
3986 |
|
void MainWindow::on_clipboard_clear() { |
3987 |
|
m_serializationArchive.clear(); |
3988 |
|
updateClipboardPasteAvailable(); |
3989 |
|
updateClipboardCopyAvailable(); |
3990 |
|
} |
3991 |
|
|
3992 |
|
//NOTE: Might throw exception !!! |
3993 |
|
void MainWindow::applyMacro(Serialization::Archive& macro) { |
3994 |
|
gig::DimensionRegion* pDimRgn = m_DimRegionChooser.get_main_dimregion(); |
3995 |
|
if (!pDimRgn) return; |
3996 |
|
|
3997 |
|
for (std::set<gig::DimensionRegion*>::iterator itDimReg = dimreg_edit.dimregs.begin(); |
3998 |
|
itDimReg != dimreg_edit.dimregs.end(); ++itDimReg) |
3999 |
|
{ |
4000 |
|
gig::DimensionRegion* pDimRgn = *itDimReg; |
4001 |
|
DimRegionChangeGuard(this, pDimRgn); |
4002 |
|
macro.deserialize(pDimRgn); |
4003 |
|
} |
4004 |
|
//region_changed() |
4005 |
|
file_changed(); |
4006 |
|
dimreg_changed(); |
4007 |
|
} |
4008 |
|
|
4009 |
|
void MainWindow::on_clipboard_received(const Gtk::SelectionData& selection_data) { |
4010 |
|
const std::string target = selection_data.get_target(); |
4011 |
|
if (target == CLIPBOARD_DIMENSIONREGION_TARGET) { |
4012 |
|
Glib::ustring errorText; |
4013 |
|
try { |
4014 |
|
m_serializationArchive.decode( |
4015 |
|
selection_data.get_data(), selection_data.get_length() |
4016 |
|
); |
4017 |
|
applyMacro(m_serializationArchive); |
4018 |
|
} catch (Serialization::Exception e) { |
4019 |
|
errorText = e.Message; |
4020 |
|
} catch (...) { |
4021 |
|
errorText = _("Unknown exception while pasting DimensionRegion"); |
4022 |
|
} |
4023 |
|
if (!errorText.empty()) { |
4024 |
|
Glib::ustring txt = _("Pasting DimensionRegion failed:\n") + errorText; |
4025 |
|
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
4026 |
|
msg.run(); |
4027 |
|
} |
4028 |
|
} |
4029 |
|
} |
4030 |
|
|
4031 |
|
void MainWindow::on_clipboard_received_targets(const std::vector<Glib::ustring>& targets) { |
4032 |
|
const bool bDimensionRegionPasteIsPossible = |
4033 |
|
std::find(targets.begin(), targets.end(), |
4034 |
|
CLIPBOARD_DIMENSIONREGION_TARGET) != targets.end(); |
4035 |
|
|
4036 |
|
static_cast<Gtk::MenuItem*>( |
4037 |
|
uiManager->get_widget("/MenuBar/MenuEdit/PasteDimRgn") |
4038 |
|
)->set_sensitive(bDimensionRegionPasteIsPossible); |
4039 |
|
|
4040 |
|
static_cast<Gtk::MenuItem*>( |
4041 |
|
uiManager->get_widget("/MenuBar/MenuEdit/AdjustClipboard") |
4042 |
|
)->set_sensitive(bDimensionRegionPasteIsPossible); |
4043 |
} |
} |
4044 |
|
|
4045 |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
4097 |
sigc::signal<void, int/*key*/, int/*velocity*/>& MainWindow::signal_keyboard_key_released() { |
sigc::signal<void, int/*key*/, int/*velocity*/>& MainWindow::signal_keyboard_key_released() { |
4098 |
return m_RegionChooser.signal_keyboard_key_released(); |
return m_RegionChooser.signal_keyboard_key_released(); |
4099 |
} |
} |
4100 |
|
|
4101 |
|
sigc::signal<void, gig::Instrument*>& MainWindow::signal_switch_sampler_instrument() { |
4102 |
|
return switch_sampler_instrument_signal; |
4103 |
|
} |