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