1 |
/* |
/* |
2 |
* Copyright (C) 2006-2014 Andreas Persson |
* Copyright (C) 2006-2017 Andreas Persson |
3 |
* |
* |
4 |
* This program is free software; you can redistribute it and/or |
* This program is free software; you can redistribute it and/or |
5 |
* modify it under the terms of the GNU General Public License as |
* modify it under the terms of the GNU General Public License as |
20 |
#include <iostream> |
#include <iostream> |
21 |
#include <cstring> |
#include <cstring> |
22 |
|
|
23 |
|
#include "compat.h" |
24 |
|
// threads.h must be included first to be able to build with |
25 |
|
// G_DISABLE_DEPRECATED |
26 |
|
#if (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION == 31 && GLIBMM_MICRO_VERSION >= 2) || \ |
27 |
|
(GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION > 31) || GLIBMM_MAJOR_VERSION > 2 |
28 |
|
#include <glibmm/threads.h> |
29 |
|
#endif |
30 |
|
|
31 |
#include <glibmm/convert.h> |
#include <glibmm/convert.h> |
32 |
#include <glibmm/dispatcher.h> |
#include <glibmm/dispatcher.h> |
33 |
#include <glibmm/miscutils.h> |
#include <glibmm/miscutils.h> |
34 |
#include <glibmm/stringutils.h> |
#include <glibmm/stringutils.h> |
35 |
|
#include <glibmm/regex.h> |
36 |
#include <gtkmm/aboutdialog.h> |
#include <gtkmm/aboutdialog.h> |
37 |
#include <gtkmm/filechooserdialog.h> |
#include <gtkmm/filechooserdialog.h> |
38 |
#include <gtkmm/messagedialog.h> |
#include <gtkmm/messagedialog.h> |
39 |
#include <gtkmm/stock.h> |
#if HAS_GTKMM_STOCK |
40 |
|
# include <gtkmm/stock.h> |
41 |
|
#endif |
42 |
#include <gtkmm/targetentry.h> |
#include <gtkmm/targetentry.h> |
43 |
#include <gtkmm/main.h> |
#include <gtkmm/main.h> |
44 |
#include <gtkmm/toggleaction.h> |
#if GTKMM_MAJOR_VERSION < 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION < 89) |
45 |
|
# include <gtkmm/toggleaction.h> |
46 |
|
#endif |
47 |
|
#include <gtkmm/accelmap.h> |
48 |
#if GTKMM_MAJOR_VERSION < 3 |
#if GTKMM_MAJOR_VERSION < 3 |
49 |
#include "wrapLabel.hh" |
#include "wrapLabel.hh" |
50 |
#endif |
#endif |
53 |
#include "compat.h" |
#include "compat.h" |
54 |
|
|
55 |
#include <stdio.h> |
#include <stdio.h> |
56 |
#include <sndfile.h> |
#ifdef LIBSNDFILE_HEADER_FILE |
57 |
|
# include LIBSNDFILE_HEADER_FILE(sndfile.h) |
58 |
|
#else |
59 |
|
# include <sndfile.h> |
60 |
|
#endif |
61 |
#include <assert.h> |
#include <assert.h> |
62 |
|
|
63 |
#include "mainwindow.h" |
#include "mainwindow.h" |
68 |
#include "ReferencesView.h" |
#include "ReferencesView.h" |
69 |
#include "../../gfx/status_attached.xpm" |
#include "../../gfx/status_attached.xpm" |
70 |
#include "../../gfx/status_detached.xpm" |
#include "../../gfx/status_detached.xpm" |
71 |
|
#include "gfx/builtinpix.h" |
72 |
|
#include "MacroEditor.h" |
73 |
|
#include "MacrosSetup.h" |
74 |
|
#if defined(__APPLE__) |
75 |
|
# include "MacHelper.h" |
76 |
|
#endif |
77 |
|
|
78 |
|
static const Gdk::ModifierType primaryModifierKey = |
79 |
|
#if defined(__APPLE__) |
80 |
|
Gdk::META_MASK; // Cmd key on Mac |
81 |
|
#else |
82 |
|
Gdk::CONTROL_MASK; // Ctrl key on all other OSs |
83 |
|
#endif |
84 |
|
|
85 |
MainWindow::MainWindow() : |
MainWindow::MainWindow() : |
86 |
m_DimRegionChooser(*this), |
m_DimRegionChooser(*this), |
87 |
dimreg_label(_("Changes apply to:")), |
dimreg_label(_("Changes apply to:")), |
88 |
dimreg_all_regions(_("all regions")), |
dimreg_all_regions(_("all regions")), |
89 |
dimreg_all_dimregs(_("all dimension splits")), |
dimreg_all_dimregs(_("all dimension splits")), |
90 |
dimreg_stereo(_("both channels")) |
dimreg_stereo(_("both channels")), |
91 |
|
labelLegend(_("Legend:")), |
92 |
|
labelNoSample(_(" No Sample")), |
93 |
|
labelMissingSample(_(" Missing some Sample(s)")), |
94 |
|
labelLooped(_(" Looped")), |
95 |
|
labelSomeLoops(_(" Some Loop(s)")) |
96 |
{ |
{ |
97 |
|
loadBuiltInPix(); |
98 |
|
|
99 |
|
this->file = NULL; |
100 |
|
|
101 |
// set_border_width(5); |
// set_border_width(5); |
|
// set_default_size(400, 200); |
|
102 |
|
|
103 |
|
if (!Settings::singleton()->autoRestoreWindowDimension) { |
104 |
|
set_default_size(800, 600); |
105 |
|
set_position(Gtk::WIN_POS_CENTER); |
106 |
|
} |
107 |
|
|
108 |
add(m_VBox); |
add(m_VBox); |
109 |
|
|
113 |
|
|
114 |
// m_TreeView.set_reorderable(); |
// m_TreeView.set_reorderable(); |
115 |
|
|
116 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2 |
117 |
|
m_TreeView.signal_button_press_event().connect( |
118 |
|
sigc::mem_fun(*this, &MainWindow::on_button_release)); |
119 |
|
#else |
120 |
m_TreeView.signal_button_press_event().connect_notify( |
m_TreeView.signal_button_press_event().connect_notify( |
121 |
sigc::mem_fun(*this, &MainWindow::on_button_release)); |
sigc::mem_fun(*this, &MainWindow::on_button_release)); |
122 |
|
#endif |
123 |
|
|
124 |
// Add the TreeView tab, inside a ScrolledWindow, with the button underneath: |
// Add the TreeView tab, inside a ScrolledWindow, with the button underneath: |
125 |
m_ScrolledWindow.add(m_TreeView); |
m_ScrolledWindow.add(m_TreeView); |
135 |
|
|
136 |
m_TreeViewNotebook.set_size_request(300); |
m_TreeViewNotebook.set_size_request(300); |
137 |
|
|
138 |
m_HPaned.add1(m_TreeViewNotebook); |
m_searchLabel.set_text(Glib::ustring(" ") + _("Filter:")); |
139 |
|
m_searchField.pack_start(m_searchLabel, Gtk::PACK_SHRINK); |
140 |
|
m_searchField.pack_start(m_searchText); |
141 |
|
m_searchField.set_spacing(5); |
142 |
|
|
143 |
|
m_left_vbox.pack_start(m_TreeViewNotebook); |
144 |
|
m_left_vbox.pack_start(m_searchField, Gtk::PACK_SHRINK); |
145 |
|
|
146 |
|
m_HPaned.add1(m_left_vbox); |
147 |
|
|
148 |
dimreg_hbox.add(dimreg_label); |
dimreg_hbox.add(dimreg_label); |
149 |
dimreg_hbox.add(dimreg_all_regions); |
dimreg_hbox.add(dimreg_all_regions); |
150 |
dimreg_hbox.add(dimreg_all_dimregs); |
dimreg_hbox.add(dimreg_all_dimregs); |
152 |
dimreg_hbox.add(dimreg_stereo); |
dimreg_hbox.add(dimreg_stereo); |
153 |
dimreg_vbox.add(dimreg_edit); |
dimreg_vbox.add(dimreg_edit); |
154 |
dimreg_vbox.pack_start(dimreg_hbox, Gtk::PACK_SHRINK); |
dimreg_vbox.pack_start(dimreg_hbox, Gtk::PACK_SHRINK); |
155 |
|
{ |
156 |
|
legend_hbox.add(labelLegend); |
157 |
|
|
158 |
|
imageNoSample.set(redDot); |
159 |
|
#if HAS_GTKMM_ALIGNMENT |
160 |
|
imageNoSample.set_alignment(Gtk::ALIGN_END); |
161 |
|
labelNoSample.set_alignment(Gtk::ALIGN_START); |
162 |
|
#else |
163 |
|
imageNoSample.set_halign(Gtk::ALIGN_END); |
164 |
|
labelNoSample.set_halign(Gtk::ALIGN_START); |
165 |
|
#endif |
166 |
|
legend_hbox.add(imageNoSample); |
167 |
|
legend_hbox.add(labelNoSample); |
168 |
|
|
169 |
|
imageMissingSample.set(yellowDot); |
170 |
|
#if HAS_GTKMM_ALIGNMENT |
171 |
|
imageMissingSample.set_alignment(Gtk::ALIGN_END); |
172 |
|
labelMissingSample.set_alignment(Gtk::ALIGN_START); |
173 |
|
#else |
174 |
|
imageMissingSample.set_halign(Gtk::ALIGN_END); |
175 |
|
labelMissingSample.set_halign(Gtk::ALIGN_START); |
176 |
|
#endif |
177 |
|
legend_hbox.add(imageMissingSample); |
178 |
|
legend_hbox.add(labelMissingSample); |
179 |
|
|
180 |
|
imageLooped.set(blackLoop); |
181 |
|
#if HAS_GTKMM_ALIGNMENT |
182 |
|
imageLooped.set_alignment(Gtk::ALIGN_END); |
183 |
|
labelLooped.set_alignment(Gtk::ALIGN_START); |
184 |
|
#else |
185 |
|
imageLooped.set_halign(Gtk::ALIGN_END); |
186 |
|
labelLooped.set_halign(Gtk::ALIGN_START); |
187 |
|
#endif |
188 |
|
legend_hbox.add(imageLooped); |
189 |
|
legend_hbox.add(labelLooped); |
190 |
|
|
191 |
|
imageSomeLoops.set(grayLoop); |
192 |
|
#if HAS_GTKMM_ALIGNMENT |
193 |
|
imageSomeLoops.set_alignment(Gtk::ALIGN_END); |
194 |
|
labelSomeLoops.set_alignment(Gtk::ALIGN_START); |
195 |
|
#else |
196 |
|
imageSomeLoops.set_halign(Gtk::ALIGN_END); |
197 |
|
labelSomeLoops.set_halign(Gtk::ALIGN_START); |
198 |
|
#endif |
199 |
|
legend_hbox.add(imageSomeLoops); |
200 |
|
legend_hbox.add(labelSomeLoops); |
201 |
|
|
202 |
|
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
203 |
|
legend_hbox.show_all_children(); |
204 |
|
#endif |
205 |
|
} |
206 |
|
dimreg_vbox.pack_start(legend_hbox, Gtk::PACK_SHRINK); |
207 |
m_HPaned.add2(dimreg_vbox); |
m_HPaned.add2(dimreg_vbox); |
208 |
|
|
209 |
dimreg_label.set_tooltip_text(_("To automatically apply your changes above globally to the entire instrument, check all 3 check boxes on the right.")); |
dimreg_label.set_tooltip_text(_("To automatically apply your changes above globally to the entire instrument, check all 3 check boxes on the right.")); |
215 |
m_TreeViewNotebook.append_page(m_ScrolledWindow, _("Instruments")); |
m_TreeViewNotebook.append_page(m_ScrolledWindow, _("Instruments")); |
216 |
m_TreeViewNotebook.append_page(m_ScrolledWindowScripts, _("Scripts")); |
m_TreeViewNotebook.append_page(m_ScrolledWindowScripts, _("Scripts")); |
217 |
|
|
218 |
|
#if USE_GLIB_ACTION |
219 |
|
m_actionGroup = Gio::SimpleActionGroup::create(); |
220 |
|
m_actionGroup->add_action( |
221 |
|
"New", sigc::mem_fun(*this, &MainWindow::on_action_file_new) |
222 |
|
); |
223 |
|
m_actionGroup->add_action( |
224 |
|
"Open", sigc::mem_fun(*this, &MainWindow::on_action_file_open) |
225 |
|
); |
226 |
|
m_actionGroup->add_action( |
227 |
|
"Save", sigc::mem_fun(*this, &MainWindow::on_action_file_save) |
228 |
|
); |
229 |
|
m_actionGroup->add_action( |
230 |
|
"SaveAs", sigc::mem_fun(*this, &MainWindow::on_action_file_save_as) |
231 |
|
); |
232 |
|
m_actionGroup->add_action( |
233 |
|
"Properties", sigc::mem_fun(*this, &MainWindow::on_action_file_properties) |
234 |
|
); |
235 |
|
m_actionGroup->add_action( |
236 |
|
"InstrProperties", sigc::mem_fun(*this, &MainWindow::show_instr_props) |
237 |
|
); |
238 |
|
m_actionMIDIRules = m_actionGroup->add_action( |
239 |
|
"MidiRules", sigc::mem_fun(*this, &MainWindow::show_midi_rules) |
240 |
|
); |
241 |
|
m_actionGroup->add_action( |
242 |
|
"ScriptSlots", sigc::mem_fun(*this, &MainWindow::show_script_slots) |
243 |
|
); |
244 |
|
m_actionGroup->add_action( |
245 |
|
"Quit", sigc::mem_fun(*this, &MainWindow::on_action_quit) |
246 |
|
); |
247 |
|
m_actionGroup->add_action( |
248 |
|
"MenuSample", sigc::mem_fun(*this, &MainWindow::show_samples_tab) |
249 |
|
); |
250 |
|
m_actionGroup->add_action( |
251 |
|
"MenuInstrument", sigc::mem_fun(*this, &MainWindow::show_intruments_tab) |
252 |
|
); |
253 |
|
m_actionGroup->add_action( |
254 |
|
"MenuScript", sigc::mem_fun(*this, &MainWindow::show_scripts_tab) |
255 |
|
); |
256 |
|
#else |
257 |
actionGroup = Gtk::ActionGroup::create(); |
actionGroup = Gtk::ActionGroup::create(); |
258 |
|
|
259 |
actionGroup->add(Gtk::Action::create("MenuFile", _("_File"))); |
actionGroup->add(Gtk::Action::create("MenuFile", _("_File"))); |
303 |
sigc::mem_fun(*this, &MainWindow::show_intruments_tab) |
sigc::mem_fun(*this, &MainWindow::show_intruments_tab) |
304 |
); |
); |
305 |
actionGroup->add( |
actionGroup->add( |
306 |
Gtk::Action::create("MenuScript", _("S_cript")), |
Gtk::Action::create("MenuScript", _("Scr_ipt")), |
307 |
sigc::mem_fun(*this, &MainWindow::show_scripts_tab) |
sigc::mem_fun(*this, &MainWindow::show_scripts_tab) |
308 |
); |
); |
309 |
actionGroup->add(Gtk::Action::create("AllInstruments", _("_Select"))); |
actionGroup->add(Gtk::Action::create("AllInstruments", _("_Select"))); |
310 |
|
actionGroup->add(Gtk::Action::create("AssignScripts", _("Assign Script"))); |
311 |
|
|
312 |
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); |
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); |
313 |
|
#endif |
314 |
|
|
315 |
|
const Gdk::ModifierType primaryModifierKey = |
316 |
|
#if defined(__APPLE__) |
317 |
|
Gdk::META_MASK; // Cmd key on Mac |
318 |
|
#else |
319 |
|
Gdk::CONTROL_MASK; // Ctrl key on all other OSs |
320 |
|
#endif |
321 |
|
|
322 |
|
#if USE_GLIB_ACTION |
323 |
|
m_actionCopyDimRgn = m_actionGroup->add_action( |
324 |
|
"CopyDimRgn", sigc::mem_fun(*this, &MainWindow::copy_selected_dimrgn) |
325 |
|
); |
326 |
|
m_actionPasteDimRgn = m_actionGroup->add_action( |
327 |
|
"PasteDimRgn", sigc::mem_fun(*this, &MainWindow::paste_copied_dimrgn) |
328 |
|
); |
329 |
|
m_actionAdjustClipboard = m_actionGroup->add_action( |
330 |
|
"AdjustClipboard", sigc::mem_fun(*this, &MainWindow::adjust_clipboard_content) |
331 |
|
); |
332 |
|
m_actionGroup->add_action( |
333 |
|
"SelectPrevInstr", sigc::mem_fun(*this, &MainWindow::select_prev_instrument) |
334 |
|
); |
335 |
|
m_actionGroup->add_action( |
336 |
|
"SelectNextInstr", sigc::mem_fun(*this, &MainWindow::select_next_instrument) |
337 |
|
); |
338 |
|
m_actionGroup->add_action( |
339 |
|
"SelectPrevRegion", sigc::mem_fun(*this, &MainWindow::select_prev_region) |
340 |
|
); |
341 |
|
m_actionGroup->add_action( |
342 |
|
"SelectNextRegion", sigc::mem_fun(*this, &MainWindow::select_next_region) |
343 |
|
); |
344 |
|
m_actionGroup->add_action( |
345 |
|
"SelectPrevDimRgnZone", sigc::mem_fun(*this, &MainWindow::select_prev_dim_rgn_zone) |
346 |
|
); |
347 |
|
m_actionGroup->add_action( |
348 |
|
"SelectNextDimRgnZone", sigc::mem_fun(*this, &MainWindow::select_next_dim_rgn_zone) |
349 |
|
); |
350 |
|
m_actionGroup->add_action( |
351 |
|
"SelectPrevDimension", sigc::mem_fun(*this, &MainWindow::select_prev_dimension) |
352 |
|
); |
353 |
|
m_actionGroup->add_action( |
354 |
|
"SelectNextDimension", sigc::mem_fun(*this, &MainWindow::select_next_dimension) |
355 |
|
); |
356 |
|
m_actionGroup->add_action( |
357 |
|
"SelectAddPrevDimRgnZone", sigc::mem_fun(*this, &MainWindow::select_add_prev_dim_rgn_zone) |
358 |
|
); |
359 |
|
m_actionGroup->add_action( |
360 |
|
"SelectAddNextDimRgnZone", sigc::mem_fun(*this, &MainWindow::select_add_next_dim_rgn_zone) |
361 |
|
); |
362 |
|
#else |
363 |
|
actionGroup->add(Gtk::Action::create("CopyDimRgn", |
364 |
|
_("Copy selected dimension region")), |
365 |
|
Gtk::AccelKey(GDK_KEY_c, Gdk::MOD1_MASK), |
366 |
|
sigc::mem_fun(*this, &MainWindow::copy_selected_dimrgn)); |
367 |
|
|
368 |
|
actionGroup->add(Gtk::Action::create("PasteDimRgn", |
369 |
|
_("Paste dimension region")), |
370 |
|
Gtk::AccelKey(GDK_KEY_v, Gdk::MOD1_MASK), |
371 |
|
sigc::mem_fun(*this, &MainWindow::paste_copied_dimrgn)); |
372 |
|
|
373 |
|
actionGroup->add(Gtk::Action::create("AdjustClipboard", |
374 |
|
_("Adjust Clipboard Content")), |
375 |
|
Gtk::AccelKey(GDK_KEY_x, Gdk::MOD1_MASK), |
376 |
|
sigc::mem_fun(*this, &MainWindow::adjust_clipboard_content)); |
377 |
|
|
378 |
|
actionGroup->add(Gtk::Action::create("SelectPrevInstr", |
379 |
|
_("Select Previous Instrument")), |
380 |
|
Gtk::AccelKey(GDK_KEY_Up, primaryModifierKey), |
381 |
|
sigc::mem_fun(*this, &MainWindow::select_prev_instrument)); |
382 |
|
|
383 |
|
actionGroup->add(Gtk::Action::create("SelectNextInstr", |
384 |
|
_("Select Next Instrument")), |
385 |
|
Gtk::AccelKey(GDK_KEY_Down, primaryModifierKey), |
386 |
|
sigc::mem_fun(*this, &MainWindow::select_next_instrument)); |
387 |
|
|
388 |
|
actionGroup->add(Gtk::Action::create("SelectPrevRegion", |
389 |
|
_("Select Previous Region")), |
390 |
|
Gtk::AccelKey(GDK_KEY_Left, primaryModifierKey), |
391 |
|
sigc::mem_fun(*this, &MainWindow::select_prev_region)); |
392 |
|
|
393 |
|
actionGroup->add(Gtk::Action::create("SelectNextRegion", |
394 |
|
_("Select Next Region")), |
395 |
|
Gtk::AccelKey(GDK_KEY_Right, primaryModifierKey), |
396 |
|
sigc::mem_fun(*this, &MainWindow::select_next_region)); |
397 |
|
|
398 |
|
actionGroup->add(Gtk::Action::create("SelectPrevDimRgnZone", |
399 |
|
_("Select Previous Dimension Region Zone")), |
400 |
|
Gtk::AccelKey(GDK_KEY_Left, Gdk::MOD1_MASK), |
401 |
|
sigc::mem_fun(*this, &MainWindow::select_prev_dim_rgn_zone)); |
402 |
|
|
403 |
|
actionGroup->add(Gtk::Action::create("SelectNextDimRgnZone", |
404 |
|
_("Select Next Dimension Region Zone")), |
405 |
|
Gtk::AccelKey(GDK_KEY_Right, Gdk::MOD1_MASK), |
406 |
|
sigc::mem_fun(*this, &MainWindow::select_next_dim_rgn_zone)); |
407 |
|
|
408 |
|
actionGroup->add(Gtk::Action::create("SelectPrevDimension", |
409 |
|
_("Select Previous Dimension")), |
410 |
|
Gtk::AccelKey(GDK_KEY_Up, Gdk::MOD1_MASK), |
411 |
|
sigc::mem_fun(*this, &MainWindow::select_prev_dimension)); |
412 |
|
|
413 |
|
actionGroup->add(Gtk::Action::create("SelectNextDimension", |
414 |
|
_("Select Next Dimension")), |
415 |
|
Gtk::AccelKey(GDK_KEY_Down, Gdk::MOD1_MASK), |
416 |
|
sigc::mem_fun(*this, &MainWindow::select_next_dimension)); |
417 |
|
|
418 |
|
actionGroup->add(Gtk::Action::create("SelectAddPrevDimRgnZone", |
419 |
|
_("Add Previous Dimension Region Zone to Selection")), |
420 |
|
Gtk::AccelKey(GDK_KEY_Left, Gdk::MOD1_MASK | Gdk::SHIFT_MASK), |
421 |
|
sigc::mem_fun(*this, &MainWindow::select_add_prev_dim_rgn_zone)); |
422 |
|
|
423 |
|
actionGroup->add(Gtk::Action::create("SelectAddNextDimRgnZone", |
424 |
|
_("Add Next Dimension Region Zone to Selection")), |
425 |
|
Gtk::AccelKey(GDK_KEY_Right, Gdk::MOD1_MASK | Gdk::SHIFT_MASK), |
426 |
|
sigc::mem_fun(*this, &MainWindow::select_add_next_dim_rgn_zone)); |
427 |
|
#endif |
428 |
|
|
429 |
|
#if USE_GLIB_ACTION |
430 |
|
m_actionToggleCopySampleUnity = m_actionGroup->add_action_bool("CopySampleUnity", true); |
431 |
|
m_actionToggleCopySampleTune = m_actionGroup->add_action_bool("CopySampleTune", true); |
432 |
|
m_actionToggleCopySampleLoop = m_actionGroup->add_action_bool("CopySampleLoop", true); |
433 |
|
#else |
434 |
Glib::RefPtr<Gtk::ToggleAction> toggle_action = |
Glib::RefPtr<Gtk::ToggleAction> toggle_action = |
435 |
Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note")); |
Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note")); |
436 |
toggle_action->set_active(true); |
toggle_action->set_active(true); |
445 |
Gtk::ToggleAction::create("CopySampleLoop", _("Copy Sample's _Loop Points")); |
Gtk::ToggleAction::create("CopySampleLoop", _("Copy Sample's _Loop Points")); |
446 |
toggle_action->set_active(true); |
toggle_action->set_active(true); |
447 |
actionGroup->add(toggle_action); |
actionGroup->add(toggle_action); |
448 |
|
#endif |
449 |
|
|
450 |
|
#if USE_GLIB_ACTION |
451 |
|
m_actionToggleStatusBar = |
452 |
|
m_actionGroup->add_action_bool("Statusbar", sigc::mem_fun(*this, &MainWindow::on_action_view_status_bar), true); |
453 |
|
m_actionToggleRestoreWinDim = |
454 |
|
m_actionGroup->add_action_bool("AutoRestoreWinDim", sigc::mem_fun(*this, &MainWindow::on_auto_restore_win_dim), Settings::singleton()->autoRestoreWindowDimension); |
455 |
|
m_actionToggleSaveWithTempFile = |
456 |
|
m_actionGroup->add_action_bool("SaveWithTemporaryFile", sigc::mem_fun(*this, &MainWindow::on_save_with_temporary_file), Settings::singleton()->saveWithTemporaryFile); |
457 |
|
m_actionGroup->add_action("RefreshAll", sigc::mem_fun(*this, &MainWindow::on_action_refresh_all)); |
458 |
|
#else |
459 |
|
actionGroup->add(Gtk::Action::create("MenuMacro", _("_Macro"))); |
460 |
|
|
461 |
actionGroup->add(Gtk::Action::create("MenuView", _("_View"))); |
|
462 |
|
actionGroup->add(Gtk::Action::create("MenuView", _("Vie_w"))); |
463 |
toggle_action = |
toggle_action = |
464 |
Gtk::ToggleAction::create("Statusbar", _("_Statusbar")); |
Gtk::ToggleAction::create("Statusbar", _("_Statusbar")); |
465 |
toggle_action->set_active(true); |
toggle_action->set_active(true); |
467 |
sigc::mem_fun( |
sigc::mem_fun( |
468 |
*this, &MainWindow::on_action_view_status_bar)); |
*this, &MainWindow::on_action_view_status_bar)); |
469 |
|
|
470 |
|
toggle_action = |
471 |
|
Gtk::ToggleAction::create("AutoRestoreWinDim", _("_Auto Restore Window Dimension")); |
472 |
|
toggle_action->set_active(Settings::singleton()->autoRestoreWindowDimension); |
473 |
|
actionGroup->add(toggle_action, |
474 |
|
sigc::mem_fun( |
475 |
|
*this, &MainWindow::on_auto_restore_win_dim)); |
476 |
|
|
477 |
|
toggle_action = |
478 |
|
Gtk::ToggleAction::create("SaveWithTemporaryFile", _("Save with _temporary file")); |
479 |
|
toggle_action->set_active(Settings::singleton()->saveWithTemporaryFile); |
480 |
|
actionGroup->add(toggle_action, |
481 |
|
sigc::mem_fun( |
482 |
|
*this, &MainWindow::on_save_with_temporary_file)); |
483 |
|
|
484 |
|
actionGroup->add( |
485 |
|
Gtk::Action::create("RefreshAll", _("_Refresh All")), |
486 |
|
sigc::mem_fun(*this, &MainWindow::on_action_refresh_all) |
487 |
|
); |
488 |
|
#endif |
489 |
|
|
490 |
|
#if USE_GLIB_ACTION |
491 |
|
m_actionGroup->add_action( |
492 |
|
"About", sigc::mem_fun(*this, &MainWindow::on_action_help_about) |
493 |
|
); |
494 |
|
m_actionGroup->add_action( |
495 |
|
"AddInstrument", sigc::mem_fun(*this, &MainWindow::on_action_add_instrument) |
496 |
|
); |
497 |
|
m_actionGroup->add_action( |
498 |
|
"DupInstrument", sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument) |
499 |
|
); |
500 |
|
m_actionGroup->add_action( |
501 |
|
"CombInstruments", sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments) |
502 |
|
); |
503 |
|
m_actionGroup->add_action( |
504 |
|
"RemoveInstrument", sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument) |
505 |
|
); |
506 |
|
#else |
507 |
action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP); |
action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP); |
508 |
actionGroup->add(Gtk::Action::create("MenuHelp", |
actionGroup->add(Gtk::Action::create("MenuHelp", |
509 |
action->property_label())); |
action->property_label())); |
519 |
sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument) |
sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument) |
520 |
); |
); |
521 |
actionGroup->add( |
actionGroup->add( |
522 |
|
Gtk::Action::create("CombInstruments", _("_Combine Instruments ...")), |
523 |
|
Gtk::AccelKey(GDK_KEY_j, primaryModifierKey), |
524 |
|
sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments) |
525 |
|
); |
526 |
|
actionGroup->add( |
527 |
Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE), |
Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE), |
528 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument) |
529 |
); |
); |
530 |
|
#endif |
531 |
|
|
532 |
|
#if USE_GLIB_ACTION |
533 |
|
m_actionToggleWarnOnExtensions = m_actionGroup->add_action_bool( |
534 |
|
"WarnUserOnExtensions", sigc::mem_fun(*this, &MainWindow::on_action_warn_user_on_extensions), |
535 |
|
Settings::singleton()->warnUserOnExtensions |
536 |
|
); |
537 |
|
m_actionToggleSyncSamplerSelection = m_actionGroup->add_action_bool( |
538 |
|
"SyncSamplerInstrumentSelection", sigc::mem_fun(*this, &MainWindow::on_action_sync_sampler_instrument_selection), |
539 |
|
Settings::singleton()->syncSamplerInstrumentSelection |
540 |
|
); |
541 |
|
m_actionToggleMoveRootNoteWithRegion = m_actionGroup->add_action_bool( |
542 |
|
"MoveRootNoteWithRegionMoved", sigc::mem_fun(*this, &MainWindow::on_action_move_root_note_with_region_moved), |
543 |
|
Settings::singleton()->moveRootNoteWithRegionMoved |
544 |
|
); |
545 |
|
#else |
546 |
actionGroup->add(Gtk::Action::create("MenuSettings", _("_Settings"))); |
actionGroup->add(Gtk::Action::create("MenuSettings", _("_Settings"))); |
547 |
|
|
548 |
toggle_action = |
toggle_action = |
553 |
sigc::mem_fun(*this, &MainWindow::on_action_warn_user_on_extensions) |
sigc::mem_fun(*this, &MainWindow::on_action_warn_user_on_extensions) |
554 |
); |
); |
555 |
|
|
556 |
|
toggle_action = |
557 |
|
Gtk::ToggleAction::create("SyncSamplerInstrumentSelection", _("Synchronize sampler's instrument selection")); |
558 |
|
toggle_action->set_active(Settings::singleton()->syncSamplerInstrumentSelection); |
559 |
|
actionGroup->add( |
560 |
|
toggle_action, |
561 |
|
sigc::mem_fun(*this, &MainWindow::on_action_sync_sampler_instrument_selection) |
562 |
|
); |
563 |
|
|
564 |
|
toggle_action = |
565 |
|
Gtk::ToggleAction::create("MoveRootNoteWithRegionMoved", _("Move root note with region moved")); |
566 |
|
toggle_action->set_active(Settings::singleton()->moveRootNoteWithRegionMoved); |
567 |
|
actionGroup->add( |
568 |
|
toggle_action, |
569 |
|
sigc::mem_fun(*this, &MainWindow::on_action_move_root_note_with_region_moved) |
570 |
|
); |
571 |
|
#endif |
572 |
|
|
573 |
|
#if USE_GLIB_ACTION |
574 |
|
m_actionGroup->add_action( |
575 |
|
"CombineInstruments", sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments) |
576 |
|
); |
577 |
|
m_actionGroup->add_action( |
578 |
|
"MergeFiles", sigc::mem_fun(*this, &MainWindow::on_action_merge_files) |
579 |
|
); |
580 |
|
#else |
581 |
actionGroup->add(Gtk::Action::create("MenuTools", _("_Tools"))); |
actionGroup->add(Gtk::Action::create("MenuTools", _("_Tools"))); |
582 |
|
|
583 |
actionGroup->add( |
actionGroup->add( |
589 |
Gtk::Action::create("MergeFiles", _("_Merge Files...")), |
Gtk::Action::create("MergeFiles", _("_Merge Files...")), |
590 |
sigc::mem_fun(*this, &MainWindow::on_action_merge_files) |
sigc::mem_fun(*this, &MainWindow::on_action_merge_files) |
591 |
); |
); |
592 |
|
#endif |
593 |
|
|
594 |
// sample right-click popup actions |
// sample right-click popup actions |
595 |
|
#if USE_GLIB_ACTION |
596 |
|
m_actionSampleProperties = m_actionGroup->add_action( |
597 |
|
"SampleProperties", sigc::mem_fun(*this, &MainWindow::on_action_sample_properties) |
598 |
|
); |
599 |
|
m_actionAddSampleGroup = m_actionGroup->add_action( |
600 |
|
"AddGroup", sigc::mem_fun(*this, &MainWindow::on_action_add_group) |
601 |
|
); |
602 |
|
m_actionAddSample = m_actionGroup->add_action( |
603 |
|
"AddSample", sigc::mem_fun(*this, &MainWindow::on_action_add_sample) |
604 |
|
); |
605 |
|
m_actionRemoveSample = m_actionGroup->add_action( |
606 |
|
"RemoveSample", sigc::mem_fun(*this, &MainWindow::on_action_remove_sample) |
607 |
|
); |
608 |
|
m_actionGroup->add_action( |
609 |
|
"RemoveUnusedSamples", sigc::mem_fun(*this, &MainWindow::on_action_remove_unused_samples) |
610 |
|
); |
611 |
|
m_actionViewSampleRefs = m_actionGroup->add_action( |
612 |
|
"ShowSampleRefs", sigc::mem_fun(*this, &MainWindow::on_action_view_references) |
613 |
|
); |
614 |
|
m_actionReplaceSample = m_actionGroup->add_action( |
615 |
|
"ReplaceSample", sigc::mem_fun(*this, &MainWindow::on_action_replace_sample) |
616 |
|
); |
617 |
|
m_actionGroup->add_action( |
618 |
|
"ReplaceAllSamplesInAllGroups", sigc::mem_fun(*this, &MainWindow::on_action_replace_all_samples_in_all_groups) |
619 |
|
); |
620 |
|
#else |
621 |
actionGroup->add( |
actionGroup->add( |
622 |
Gtk::Action::create("SampleProperties", Gtk::Stock::PROPERTIES), |
Gtk::Action::create("SampleProperties", Gtk::Stock::PROPERTIES), |
623 |
sigc::mem_fun(*this, &MainWindow::on_action_sample_properties) |
sigc::mem_fun(*this, &MainWindow::on_action_sample_properties) |
635 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_sample) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_sample) |
636 |
); |
); |
637 |
actionGroup->add( |
actionGroup->add( |
638 |
|
Gtk::Action::create("RemoveUnusedSamples", _("Remove _Unused Samples")), |
639 |
|
sigc::mem_fun(*this, &MainWindow::on_action_remove_unused_samples) |
640 |
|
); |
641 |
|
actionGroup->add( |
642 |
Gtk::Action::create("ShowSampleRefs", _("Show References...")), |
Gtk::Action::create("ShowSampleRefs", _("Show References...")), |
643 |
sigc::mem_fun(*this, &MainWindow::on_action_view_references) |
sigc::mem_fun(*this, &MainWindow::on_action_view_references) |
644 |
); |
); |
645 |
actionGroup->add( |
actionGroup->add( |
646 |
|
Gtk::Action::create("ReplaceSample", |
647 |
|
_("Replace Sample...")), |
648 |
|
sigc::mem_fun(*this, &MainWindow::on_action_replace_sample) |
649 |
|
); |
650 |
|
actionGroup->add( |
651 |
Gtk::Action::create("ReplaceAllSamplesInAllGroups", |
Gtk::Action::create("ReplaceAllSamplesInAllGroups", |
652 |
_("Replace All Samples in All Groups...")), |
_("Replace All Samples in All Groups...")), |
653 |
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) |
654 |
); |
); |
655 |
|
#endif |
656 |
|
|
657 |
// script right-click popup actions |
// script right-click popup actions |
658 |
|
#if USE_GLIB_ACTION |
659 |
|
m_actionAddScriptGroup = m_actionGroup->add_action( |
660 |
|
"AddScriptGroup", sigc::mem_fun(*this, &MainWindow::on_action_add_script_group) |
661 |
|
); |
662 |
|
m_actionAddScript = m_actionGroup->add_action( |
663 |
|
"AddScript", sigc::mem_fun(*this, &MainWindow::on_action_add_script) |
664 |
|
); |
665 |
|
m_actionEditScript = m_actionGroup->add_action( |
666 |
|
"EditScript", sigc::mem_fun(*this, &MainWindow::on_action_edit_script) |
667 |
|
); |
668 |
|
m_actionRemoveScript = m_actionGroup->add_action( |
669 |
|
"RemoveScript", sigc::mem_fun(*this, &MainWindow::on_action_remove_script) |
670 |
|
); |
671 |
|
#else |
672 |
actionGroup->add( |
actionGroup->add( |
673 |
Gtk::Action::create("AddScriptGroup", _("Add _Group")), |
Gtk::Action::create("AddScriptGroup", _("Add _Group")), |
674 |
sigc::mem_fun(*this, &MainWindow::on_action_add_script_group) |
sigc::mem_fun(*this, &MainWindow::on_action_add_script_group) |
685 |
Gtk::Action::create("RemoveScript", Gtk::Stock::REMOVE), |
Gtk::Action::create("RemoveScript", Gtk::Stock::REMOVE), |
686 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_script) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_script) |
687 |
); |
); |
688 |
|
#endif |
689 |
|
|
690 |
|
#if USE_GTKMM_BUILDER |
691 |
|
insert_action_group("AppMenu", m_actionGroup); |
692 |
|
|
693 |
|
m_uiManager = Gtk::Builder::create(); |
694 |
|
Glib::ustring ui_info = |
695 |
|
"<interface>" |
696 |
|
" <menubar id='MenuBar'>" |
697 |
|
" <menu id='MenuFile'>" |
698 |
|
" <attribute name='label' translatable='yes'>_File</attribute>" |
699 |
|
" <section>" |
700 |
|
" <item id='New'>" |
701 |
|
" <attribute name='label' translatable='yes'>New</attribute>" |
702 |
|
" <attribute name='action'>AppMenu.New</attribute>" |
703 |
|
" </item>" |
704 |
|
" <item id='Open'>" |
705 |
|
" <attribute name='label' translatable='yes'>Open</attribute>" |
706 |
|
" <attribute name='action'>AppMenu.Open</attribute>" |
707 |
|
" </item>" |
708 |
|
" </section>" |
709 |
|
" <section>" |
710 |
|
" <item id='Save'>" |
711 |
|
" <attribute name='label' translatable='yes'>Save</attribute>" |
712 |
|
" <attribute name='action'>AppMenu.Save</attribute>" |
713 |
|
" </item>" |
714 |
|
" <item id='SaveAs'>" |
715 |
|
" <attribute name='label' translatable='yes'>Save As</attribute>" |
716 |
|
" <attribute name='action'>AppMenu.SaveAs</attribute>" |
717 |
|
" </item>" |
718 |
|
" </section>" |
719 |
|
" <section>" |
720 |
|
" <item id='Properties'>" |
721 |
|
" <attribute name='label' translatable='yes'>Properties</attribute>" |
722 |
|
" <attribute name='action'>AppMenu.Properties</attribute>" |
723 |
|
" </item>" |
724 |
|
" </section>" |
725 |
|
" <section>" |
726 |
|
" <item id='Quit'>" |
727 |
|
" <attribute name='label' translatable='yes'>Quit</attribute>" |
728 |
|
" <attribute name='action'>AppMenu.Quit</attribute>" |
729 |
|
" </item>" |
730 |
|
" </section>" |
731 |
|
" </menu>" |
732 |
|
" <menu id='MenuEdit'>" |
733 |
|
" <attribute name='label' translatable='yes'>Edit</attribute>" |
734 |
|
" <section>" |
735 |
|
" <item id='CopyDimRgn'>" |
736 |
|
" <attribute name='label' translatable='yes'>Copy Dimension Region</attribute>" |
737 |
|
" <attribute name='action'>AppMenu.CopyDimRgn</attribute>" |
738 |
|
" </item>" |
739 |
|
" <item id='AdjustClipboard'>" |
740 |
|
" <attribute name='label' translatable='yes'>Adjust Clipboard</attribute>" |
741 |
|
" <attribute name='action'>AppMenu.AdjustClipboard</attribute>" |
742 |
|
" </item>" |
743 |
|
" <item id='PasteDimRgn'>" |
744 |
|
" <attribute name='label' translatable='yes'>Paste Dimension Region</attribute>" |
745 |
|
" <attribute name='action'>AppMenu.PasteDimRgn</attribute>" |
746 |
|
" </item>" |
747 |
|
" </section>" |
748 |
|
" <item id='SelectPrevInstr'>" |
749 |
|
" <attribute name='label' translatable='yes'>Previous Instrument</attribute>" |
750 |
|
" <attribute name='action'>AppMenu.SelectPrevInstr</attribute>" |
751 |
|
" </item>" |
752 |
|
" <item id='SelectNextInstr'>" |
753 |
|
" <attribute name='label' translatable='yes'>Next Instrument</attribute>" |
754 |
|
" <attribute name='action'>AppMenu.SelectNextInstr</attribute>" |
755 |
|
" </item>" |
756 |
|
" <section>" |
757 |
|
" <item id='SelectPrevRegion'>" |
758 |
|
" <attribute name='label' translatable='yes'>Previous Region</attribute>" |
759 |
|
" <attribute name='action'>AppMenu.SelectPrevRegion</attribute>" |
760 |
|
" </item>" |
761 |
|
" <item id='SelectNextRegion'>" |
762 |
|
" <attribute name='label' translatable='yes'>Next Region</attribute>" |
763 |
|
" <attribute name='action'>AppMenu.SelectNextRegion</attribute>" |
764 |
|
" </item>" |
765 |
|
" </section>" |
766 |
|
" <item id='SelectPrevDimension'>" |
767 |
|
" <attribute name='label' translatable='yes'>Previous Dimension</attribute>" |
768 |
|
" <attribute name='action'>AppMenu.SelectPrevDimension</attribute>" |
769 |
|
" </item>" |
770 |
|
" <item id='SelectNextDimension'>" |
771 |
|
" <attribute name='label' translatable='yes'>Next Dimension</attribute>" |
772 |
|
" <attribute name='action'>AppMenu.SelectNextDimension</attribute>" |
773 |
|
" </item>" |
774 |
|
" <item id='SelectPrevDimRgnZone'>" |
775 |
|
" <attribute name='label' translatable='yes'>Previous Dimension Region Zone</attribute>" |
776 |
|
" <attribute name='action'>AppMenu.SelectPrevDimRgnZone</attribute>" |
777 |
|
" </item>" |
778 |
|
" <item id='SelectNextDimRgnZone'>" |
779 |
|
" <attribute name='label' translatable='yes'>Next Dimension Region Zone</attribute>" |
780 |
|
" <attribute name='action'>AppMenu.SelectNextDimRgnZone</attribute>" |
781 |
|
" </item>" |
782 |
|
" <item id='SelectAddPrevDimRgnZone'>" |
783 |
|
" <attribute name='label' translatable='yes'>Add Previous Dimension Region Zone</attribute>" |
784 |
|
" <attribute name='action'>AppMenu.SelectAddPrevDimRgnZone</attribute>" |
785 |
|
" </item>" |
786 |
|
" <item id='SelectAddNextDimRgnZone'>" |
787 |
|
" <attribute name='label' translatable='yes'>Add Next Dimension Region Zone</attribute>" |
788 |
|
" <attribute name='action'>AppMenu.SelectAddNextDimRgnZone</attribute>" |
789 |
|
" </item>" |
790 |
|
" <section>" |
791 |
|
" <item id='CopySampleUnity'>" |
792 |
|
" <attribute name='label' translatable='yes'>Copy Sample Unity</attribute>" |
793 |
|
" <attribute name='action'>AppMenu.CopySampleUnity</attribute>" |
794 |
|
" </item>" |
795 |
|
" <item id='CopySampleTune'>" |
796 |
|
" <attribute name='label' translatable='yes'>Copy Sample Tune</attribute>" |
797 |
|
" <attribute name='action'>AppMenu.CopySampleTune</attribute>" |
798 |
|
" </item>" |
799 |
|
" <item id='CopySampleLoop'>" |
800 |
|
" <attribute name='label' translatable='yes'>Copy Sample Loop</attribute>" |
801 |
|
" <attribute name='action'>AppMenu.CopySampleLoop</attribute>" |
802 |
|
" </item>" |
803 |
|
" </section>" |
804 |
|
" </menu>" |
805 |
|
" <menu id='MenuMacro'>" |
806 |
|
" <attribute name='label' translatable='yes'>Macro</attribute>" |
807 |
|
" <section>" |
808 |
|
" </section>" |
809 |
|
" </menu>" |
810 |
|
" <menu id='MenuSample'>" |
811 |
|
" <attribute name='label' translatable='yes'>Sample</attribute>" |
812 |
|
" <section>" |
813 |
|
" <item id='SampleProperties'>" |
814 |
|
" <attribute name='label' translatable='yes'>Properties</attribute>" |
815 |
|
" <attribute name='action'>AppMenu.SampleProperties</attribute>" |
816 |
|
" </item>" |
817 |
|
" <item id='AddGroup'>" |
818 |
|
" <attribute name='label' translatable='yes'>Add Group</attribute>" |
819 |
|
" <attribute name='action'>AppMenu.AddGroup</attribute>" |
820 |
|
" </item>" |
821 |
|
" <item id='AddSample'>" |
822 |
|
" <attribute name='label' translatable='yes'>Add Sample</attribute>" |
823 |
|
" <attribute name='action'>AppMenu.AddSample</attribute>" |
824 |
|
" </item>" |
825 |
|
" <item id='ShowSampleRefs'>" |
826 |
|
" <attribute name='label' translatable='yes'>Show Sample References</attribute>" |
827 |
|
" <attribute name='action'>AppMenu.ShowSampleRefs</attribute>" |
828 |
|
" </item>" |
829 |
|
" <item id='ReplaceSample'>" |
830 |
|
" <attribute name='label' translatable='yes'>Replace Sample</attribute>" |
831 |
|
" <attribute name='action'>AppMenu.ReplaceSample</attribute>" |
832 |
|
" </item>" |
833 |
|
" <item id='ReplaceAllSamplesInAllGroups'>" |
834 |
|
" <attribute name='label' translatable='yes'>Replace all Samples in all Groups</attribute>" |
835 |
|
" <attribute name='action'>AppMenu.ReplaceAllSamplesInAllGroups</attribute>" |
836 |
|
" </item>" |
837 |
|
" </section>" |
838 |
|
" <section>" |
839 |
|
" <item id='RemoveSample'>" |
840 |
|
" <attribute name='label' translatable='yes'>Remove Sample</attribute>" |
841 |
|
" <attribute name='action'>AppMenu.RemoveSample</attribute>" |
842 |
|
" </item>" |
843 |
|
" <item id='RemoveUnusedSamples'>" |
844 |
|
" <attribute name='label' translatable='yes'>Remove unused Samples</attribute>" |
845 |
|
" <attribute name='action'>AppMenu.RemoveUnusedSamples</attribute>" |
846 |
|
" </item>" |
847 |
|
" </section>" |
848 |
|
" </menu>" |
849 |
|
" <menu id='MenuInstrument'>" |
850 |
|
" <attribute name='label' translatable='yes'>Instrument</attribute>" |
851 |
|
" <section>" |
852 |
|
" <item id='InstrProperties'>" |
853 |
|
" <attribute name='label' translatable='yes'>Properties</attribute>" |
854 |
|
" <attribute name='action'>AppMenu.InstrProperties</attribute>" |
855 |
|
" </item>" |
856 |
|
" <item id='MidiRules'>" |
857 |
|
" <attribute name='label' translatable='yes'>MIDI Rules</attribute>" |
858 |
|
" <attribute name='action'>AppMenu.MidiRules</attribute>" |
859 |
|
" </item>" |
860 |
|
" <item id='ScriptSlots'>" |
861 |
|
" <attribute name='label' translatable='yes'>Script Slots</attribute>" |
862 |
|
" <attribute name='action'>AppMenu.ScriptSlots</attribute>" |
863 |
|
" </item>" |
864 |
|
" </section>" |
865 |
|
" <submenu id='AssignScripts'>" |
866 |
|
" <attribute name='label' translatable='yes'>Assign Scripts</attribute>" |
867 |
|
" </submenu>" |
868 |
|
" <section>" |
869 |
|
" <item id='AddInstrument'>" |
870 |
|
" <attribute name='label' translatable='yes'>Add Instrument</attribute>" |
871 |
|
" <attribute name='action'>AppMenu.AddInstrument</attribute>" |
872 |
|
" </item>" |
873 |
|
" <item id='DupInstrument'>" |
874 |
|
" <attribute name='label' translatable='yes'>Duplicate Instrument</attribute>" |
875 |
|
" <attribute name='action'>AppMenu.DupInstrument</attribute>" |
876 |
|
" </item>" |
877 |
|
" <item id='CombInstruments'>" |
878 |
|
" <attribute name='label' translatable='yes'>Combine Instrument</attribute>" |
879 |
|
" <attribute name='action'>AppMenu.CombInstruments</attribute>" |
880 |
|
" </item>" |
881 |
|
" </section>" |
882 |
|
" <section>" |
883 |
|
" <item id='RemoveInstrument'>" |
884 |
|
" <attribute name='label' translatable='yes'>Remove Instrument</attribute>" |
885 |
|
" <attribute name='action'>AppMenu.RemoveInstrument</attribute>" |
886 |
|
" </item>" |
887 |
|
" </section>" |
888 |
|
" </menu>" |
889 |
|
" <menu id='MenuScript'>" |
890 |
|
" <attribute name='label' translatable='yes'>Script</attribute>" |
891 |
|
" <section>" |
892 |
|
" <item id='AddScriptGroup'>" |
893 |
|
" <attribute name='label' translatable='yes'>Add Script Group</attribute>" |
894 |
|
" <attribute name='action'>AppMenu.AddScriptGroup</attribute>" |
895 |
|
" </item>" |
896 |
|
" <item id='AddScript'>" |
897 |
|
" <attribute name='label' translatable='yes'>Add Script</attribute>" |
898 |
|
" <attribute name='action'>AppMenu.AddScript</attribute>" |
899 |
|
" </item>" |
900 |
|
" <item id='EditScript'>" |
901 |
|
" <attribute name='label' translatable='yes'>Edit Script</attribute>" |
902 |
|
" <attribute name='action'>AppMenu.EditScript</attribute>" |
903 |
|
" </item>" |
904 |
|
" </section>" |
905 |
|
" <section>" |
906 |
|
" <item id='RemoveScript'>" |
907 |
|
" <attribute name='label' translatable='yes'>Remove Script</attribute>" |
908 |
|
" <attribute name='action'>AppMenu.RemoveScript</attribute>" |
909 |
|
" </item>" |
910 |
|
" </section>" |
911 |
|
" </menu>" |
912 |
|
" <menu id='MenuView'>" |
913 |
|
" <attribute name='label' translatable='yes'>View</attribute>" |
914 |
|
" <section>" |
915 |
|
" <item id='Statusbar'>" |
916 |
|
" <attribute name='label' translatable='yes'>Statusbar</attribute>" |
917 |
|
" <attribute name='action'>AppMenu.Statusbar</attribute>" |
918 |
|
" </item>" |
919 |
|
" <item id='AutoRestoreWinDim'>" |
920 |
|
" <attribute name='label' translatable='yes'>Auto restore Window Dimensions</attribute>" |
921 |
|
" <attribute name='action'>AppMenu.AutoRestoreWinDim</attribute>" |
922 |
|
" </item>" |
923 |
|
" </section>" |
924 |
|
" <section>" |
925 |
|
" <item id='RefreshAll'>" |
926 |
|
" <attribute name='label' translatable='yes'>Refresh All</attribute>" |
927 |
|
" <attribute name='action'>AppMenu.RefreshAll</attribute>" |
928 |
|
" </item>" |
929 |
|
" </section>" |
930 |
|
" </menu>" |
931 |
|
" <menu id='MenuTools'>" |
932 |
|
" <attribute name='label' translatable='yes'>Tools</attribute>" |
933 |
|
" <section>" |
934 |
|
" <item id='CombineInstruments'>" |
935 |
|
" <attribute name='label' translatable='yes'>Combine Instruments ...</attribute>" |
936 |
|
" <attribute name='action'>AppMenu.CombineInstruments</attribute>" |
937 |
|
" </item>" |
938 |
|
" <item id='MergeFiles'>" |
939 |
|
" <attribute name='label' translatable='yes'>Merge Files ...</attribute>" |
940 |
|
" <attribute name='action'>AppMenu.MergeFiles</attribute>" |
941 |
|
" </item>" |
942 |
|
" </section>" |
943 |
|
" </menu>" |
944 |
|
" <menu id='MenuSettings'>" |
945 |
|
" <attribute name='label' translatable='yes'>Settings</attribute>" |
946 |
|
" <section>" |
947 |
|
" <item id='WarnUserOnExtensions'>" |
948 |
|
" <attribute name='label' translatable='yes'>Warning on Format Extensions</attribute>" |
949 |
|
" <attribute name='action'>AppMenu.WarnUserOnExtensions</attribute>" |
950 |
|
" </item>" |
951 |
|
" <item id='SyncSamplerInstrumentSelection'>" |
952 |
|
" <attribute name='label' translatable='yes'>Synchronize Sampler Selection</attribute>" |
953 |
|
" <attribute name='action'>AppMenu.SyncSamplerInstrumentSelection</attribute>" |
954 |
|
" </item>" |
955 |
|
" <item id='MoveRootNoteWithRegionMoved'>" |
956 |
|
" <attribute name='label' translatable='yes'>Move Root Note with Region moved</attribute>" |
957 |
|
" <attribute name='action'>AppMenu.MoveRootNoteWithRegionMoved</attribute>" |
958 |
|
" </item>" |
959 |
|
" <item id='SaveWithTemporaryFile'>" |
960 |
|
" <attribute name='label' translatable='yes'>Save with temporary file</attribute>" |
961 |
|
" <attribute name='action'>AppMenu.SaveWithTemporaryFile</attribute>" |
962 |
|
" </item>" |
963 |
|
" </section>" |
964 |
|
" </menu>" |
965 |
|
" <menu id='MenuHelp'>" |
966 |
|
" <attribute name='label' translatable='yes'>Help</attribute>" |
967 |
|
" <section>" |
968 |
|
" <item id='About'>" |
969 |
|
" <attribute name='label' translatable='yes'>About ...</attribute>" |
970 |
|
" <attribute name='action'>AppMenu.About</attribute>" |
971 |
|
" </item>" |
972 |
|
" </section>" |
973 |
|
" </menu>" |
974 |
|
" </menubar>" |
975 |
|
// popups |
976 |
|
" <menu id='PopupMenu'>" |
977 |
|
" <section>" |
978 |
|
" <item id='InstrProperties'>" |
979 |
|
" <attribute name='label' translatable='yes'>Instrument Properties</attribute>" |
980 |
|
" <attribute name='action'>AppMenu.InstrProperties</attribute>" |
981 |
|
" </item>" |
982 |
|
" <item id='MidiRules'>" |
983 |
|
" <attribute name='label' translatable='yes'>MIDI Rules</attribute>" |
984 |
|
" <attribute name='action'>AppMenu.MidiRules</attribute>" |
985 |
|
" </item>" |
986 |
|
" <item id='ScriptSlots'>" |
987 |
|
" <attribute name='label' translatable='yes'>Script Slots</attribute>" |
988 |
|
" <attribute name='action'>AppMenu.ScriptSlots</attribute>" |
989 |
|
" </item>" |
990 |
|
" <item id='AddInstrument'>" |
991 |
|
" <attribute name='label' translatable='yes'>Add Instrument</attribute>" |
992 |
|
" <attribute name='action'>AppMenu.AddInstrument</attribute>" |
993 |
|
" </item>" |
994 |
|
" <item id='DupInstrument'>" |
995 |
|
" <attribute name='label' translatable='yes'>Duplicate Instrument</attribute>" |
996 |
|
" <attribute name='action'>AppMenu.DupInstrument</attribute>" |
997 |
|
" </item>" |
998 |
|
" <item id='CombInstruments'>" |
999 |
|
" <attribute name='label' translatable='yes'>Combine Instruments</attribute>" |
1000 |
|
" <attribute name='action'>AppMenu.CombInstruments</attribute>" |
1001 |
|
" </item>" |
1002 |
|
" </section>" |
1003 |
|
" <section>" |
1004 |
|
" <item id='RemoveInstrument'>" |
1005 |
|
" <attribute name='label' translatable='yes'>Remove Instruments</attribute>" |
1006 |
|
" <attribute name='action'>AppMenu.RemoveInstrument</attribute>" |
1007 |
|
" </item>" |
1008 |
|
" </section>" |
1009 |
|
" </menu>" |
1010 |
|
" <menu id='SamplePopupMenu'>" |
1011 |
|
" <section>" |
1012 |
|
" <item id='SampleProperties'>" |
1013 |
|
" <attribute name='label' translatable='yes'>Sample Properties</attribute>" |
1014 |
|
" <attribute name='action'>AppMenu.SampleProperties</attribute>" |
1015 |
|
" </item>" |
1016 |
|
" <item id='AddGroup'>" |
1017 |
|
" <attribute name='label' translatable='yes'>Add Sample Group</attribute>" |
1018 |
|
" <attribute name='action'>AppMenu.AddGroup</attribute>" |
1019 |
|
" </item>" |
1020 |
|
" <item id='AddSample'>" |
1021 |
|
" <attribute name='label' translatable='yes'>Add Sample</attribute>" |
1022 |
|
" <attribute name='action'>AppMenu.AddSample</attribute>" |
1023 |
|
" </item>" |
1024 |
|
" <item id='ShowSampleRefs'>" |
1025 |
|
" <attribute name='label' translatable='yes'>Show Sample References ...</attribute>" |
1026 |
|
" <attribute name='action'>AppMenu.ShowSampleRefs</attribute>" |
1027 |
|
" </item>" |
1028 |
|
" <item id='ReplaceSample'>" |
1029 |
|
" <attribute name='label' translatable='yes'>Replace Sample</attribute>" |
1030 |
|
" <attribute name='action'>AppMenu.ReplaceSample</attribute>" |
1031 |
|
" </item>" |
1032 |
|
" <item id='ReplaceAllSamplesInAllGroups'>" |
1033 |
|
" <attribute name='label' translatable='yes'>Replace all Samples ...</attribute>" |
1034 |
|
" <attribute name='action'>AppMenu.ReplaceAllSamplesInAllGroups</attribute>" |
1035 |
|
" </item>" |
1036 |
|
" </section>" |
1037 |
|
" <section>" |
1038 |
|
" <item id='RemoveSample'>" |
1039 |
|
" <attribute name='label' translatable='yes'>Remove Sample</attribute>" |
1040 |
|
" <attribute name='action'>AppMenu.RemoveSample</attribute>" |
1041 |
|
" </item>" |
1042 |
|
" <item id='RemoveUnusedSamples'>" |
1043 |
|
" <attribute name='label' translatable='yes'>Remove unused Samples</attribute>" |
1044 |
|
" <attribute name='action'>AppMenu.RemoveUnusedSamples</attribute>" |
1045 |
|
" </item>" |
1046 |
|
" </section>" |
1047 |
|
" </menu>" |
1048 |
|
" <menu id='ScriptPopupMenu'>" |
1049 |
|
" <section>" |
1050 |
|
" <item id='AddScriptGroup'>" |
1051 |
|
" <attribute name='label' translatable='yes'>Add Script Group</attribute>" |
1052 |
|
" <attribute name='action'>AppMenu.AddScriptGroup</attribute>" |
1053 |
|
" </item>" |
1054 |
|
" <item id='AddScript'>" |
1055 |
|
" <attribute name='label' translatable='yes'>Add Script</attribute>" |
1056 |
|
" <attribute name='action'>AppMenu.AddScript</attribute>" |
1057 |
|
" </item>" |
1058 |
|
" <item id='EditScript'>" |
1059 |
|
" <attribute name='label' translatable='yes'>Edit Script</attribute>" |
1060 |
|
" <attribute name='action'>AppMenu.EditScript</attribute>" |
1061 |
|
" </item>" |
1062 |
|
" </section>" |
1063 |
|
" <section>" |
1064 |
|
" <item id='RemoveScript'>" |
1065 |
|
" <attribute name='label' translatable='yes'>Remove Script</attribute>" |
1066 |
|
" <attribute name='action'>AppMenu.RemoveScript</attribute>" |
1067 |
|
" </item>" |
1068 |
|
" </section>" |
1069 |
|
" </menu>" |
1070 |
|
"</interface>"; |
1071 |
|
m_uiManager->add_from_string(ui_info); |
1072 |
|
#else |
1073 |
uiManager = Gtk::UIManager::create(); |
uiManager = Gtk::UIManager::create(); |
1074 |
uiManager->insert_action_group(actionGroup); |
uiManager->insert_action_group(actionGroup); |
1075 |
add_accel_group(uiManager->get_accel_group()); |
add_accel_group(uiManager->get_accel_group()); |
1089 |
" <menuitem action='Quit'/>" |
" <menuitem action='Quit'/>" |
1090 |
" </menu>" |
" </menu>" |
1091 |
" <menu action='MenuEdit'>" |
" <menu action='MenuEdit'>" |
1092 |
|
" <menuitem action='CopyDimRgn'/>" |
1093 |
|
" <menuitem action='AdjustClipboard'/>" |
1094 |
|
" <menuitem action='PasteDimRgn'/>" |
1095 |
|
" <separator/>" |
1096 |
|
" <menuitem action='SelectPrevInstr'/>" |
1097 |
|
" <menuitem action='SelectNextInstr'/>" |
1098 |
|
" <separator/>" |
1099 |
|
" <menuitem action='SelectPrevRegion'/>" |
1100 |
|
" <menuitem action='SelectNextRegion'/>" |
1101 |
|
" <separator/>" |
1102 |
|
" <menuitem action='SelectPrevDimension'/>" |
1103 |
|
" <menuitem action='SelectNextDimension'/>" |
1104 |
|
" <menuitem action='SelectPrevDimRgnZone'/>" |
1105 |
|
" <menuitem action='SelectNextDimRgnZone'/>" |
1106 |
|
" <menuitem action='SelectAddPrevDimRgnZone'/>" |
1107 |
|
" <menuitem action='SelectAddNextDimRgnZone'/>" |
1108 |
|
" <separator/>" |
1109 |
" <menuitem action='CopySampleUnity'/>" |
" <menuitem action='CopySampleUnity'/>" |
1110 |
" <menuitem action='CopySampleTune'/>" |
" <menuitem action='CopySampleTune'/>" |
1111 |
" <menuitem action='CopySampleLoop'/>" |
" <menuitem action='CopySampleLoop'/>" |
1112 |
" </menu>" |
" </menu>" |
1113 |
|
" <menu action='MenuMacro'>" |
1114 |
|
" </menu>" |
1115 |
" <menu action='MenuSample'>" |
" <menu action='MenuSample'>" |
1116 |
" <menuitem action='SampleProperties'/>" |
" <menuitem action='SampleProperties'/>" |
1117 |
" <menuitem action='AddGroup'/>" |
" <menuitem action='AddGroup'/>" |
1118 |
" <menuitem action='AddSample'/>" |
" <menuitem action='AddSample'/>" |
1119 |
" <menuitem action='ShowSampleRefs'/>" |
" <menuitem action='ShowSampleRefs'/>" |
1120 |
|
" <menuitem action='ReplaceSample' />" |
1121 |
" <menuitem action='ReplaceAllSamplesInAllGroups' />" |
" <menuitem action='ReplaceAllSamplesInAllGroups' />" |
1122 |
" <separator/>" |
" <separator/>" |
1123 |
" <menuitem action='RemoveSample'/>" |
" <menuitem action='RemoveSample'/>" |
1124 |
|
" <menuitem action='RemoveUnusedSamples'/>" |
1125 |
" </menu>" |
" </menu>" |
1126 |
" <menu action='MenuInstrument'>" |
" <menu action='MenuInstrument'>" |
1127 |
" <menu action='AllInstruments'>" |
" <menu action='AllInstruments'>" |
1130 |
" <menuitem action='InstrProperties'/>" |
" <menuitem action='InstrProperties'/>" |
1131 |
" <menuitem action='MidiRules'/>" |
" <menuitem action='MidiRules'/>" |
1132 |
" <menuitem action='ScriptSlots'/>" |
" <menuitem action='ScriptSlots'/>" |
1133 |
|
" <menu action='AssignScripts'/>" |
1134 |
" <menuitem action='AddInstrument'/>" |
" <menuitem action='AddInstrument'/>" |
1135 |
" <menuitem action='DupInstrument'/>" |
" <menuitem action='DupInstrument'/>" |
1136 |
|
" <menuitem action='CombInstruments'/>" |
1137 |
" <separator/>" |
" <separator/>" |
1138 |
" <menuitem action='RemoveInstrument'/>" |
" <menuitem action='RemoveInstrument'/>" |
1139 |
" </menu>" |
" </menu>" |
1146 |
" </menu>" |
" </menu>" |
1147 |
" <menu action='MenuView'>" |
" <menu action='MenuView'>" |
1148 |
" <menuitem action='Statusbar'/>" |
" <menuitem action='Statusbar'/>" |
1149 |
|
" <menuitem action='AutoRestoreWinDim'/>" |
1150 |
|
" <separator/>" |
1151 |
|
" <menuitem action='RefreshAll'/>" |
1152 |
" </menu>" |
" </menu>" |
1153 |
" <menu action='MenuTools'>" |
" <menu action='MenuTools'>" |
1154 |
" <menuitem action='CombineInstruments'/>" |
" <menuitem action='CombineInstruments'/>" |
1156 |
" </menu>" |
" </menu>" |
1157 |
" <menu action='MenuSettings'>" |
" <menu action='MenuSettings'>" |
1158 |
" <menuitem action='WarnUserOnExtensions'/>" |
" <menuitem action='WarnUserOnExtensions'/>" |
1159 |
|
" <menuitem action='SyncSamplerInstrumentSelection'/>" |
1160 |
|
" <menuitem action='MoveRootNoteWithRegionMoved'/>" |
1161 |
|
" <menuitem action='SaveWithTemporaryFile'/>" |
1162 |
" </menu>" |
" </menu>" |
1163 |
" <menu action='MenuHelp'>" |
" <menu action='MenuHelp'>" |
1164 |
" <menuitem action='About'/>" |
" <menuitem action='About'/>" |
1170 |
" <menuitem action='ScriptSlots'/>" |
" <menuitem action='ScriptSlots'/>" |
1171 |
" <menuitem action='AddInstrument'/>" |
" <menuitem action='AddInstrument'/>" |
1172 |
" <menuitem action='DupInstrument'/>" |
" <menuitem action='DupInstrument'/>" |
1173 |
|
" <menuitem action='CombInstruments'/>" |
1174 |
" <separator/>" |
" <separator/>" |
1175 |
" <menuitem action='RemoveInstrument'/>" |
" <menuitem action='RemoveInstrument'/>" |
1176 |
" </popup>" |
" </popup>" |
1179 |
" <menuitem action='AddGroup'/>" |
" <menuitem action='AddGroup'/>" |
1180 |
" <menuitem action='AddSample'/>" |
" <menuitem action='AddSample'/>" |
1181 |
" <menuitem action='ShowSampleRefs'/>" |
" <menuitem action='ShowSampleRefs'/>" |
1182 |
|
" <menuitem action='ReplaceSample' />" |
1183 |
" <menuitem action='ReplaceAllSamplesInAllGroups' />" |
" <menuitem action='ReplaceAllSamplesInAllGroups' />" |
1184 |
" <separator/>" |
" <separator/>" |
1185 |
" <menuitem action='RemoveSample'/>" |
" <menuitem action='RemoveSample'/>" |
1186 |
|
" <menuitem action='RemoveUnusedSamples'/>" |
1187 |
" </popup>" |
" </popup>" |
1188 |
" <popup name='ScriptPopupMenu'>" |
" <popup name='ScriptPopupMenu'>" |
1189 |
" <menuitem action='AddScriptGroup'/>" |
" <menuitem action='AddScriptGroup'/>" |
1194 |
" </popup>" |
" </popup>" |
1195 |
"</ui>"; |
"</ui>"; |
1196 |
uiManager->add_ui_from_string(ui_info); |
uiManager->add_ui_from_string(ui_info); |
1197 |
|
#endif |
1198 |
|
|
1199 |
|
#if USE_GTKMM_BUILDER |
1200 |
|
popup_menu = new Gtk::Menu( |
1201 |
|
Glib::RefPtr<Gio::Menu>::cast_dynamic( |
1202 |
|
m_uiManager->get_object("PopupMenu") |
1203 |
|
) |
1204 |
|
); |
1205 |
|
sample_popup = new Gtk::Menu( |
1206 |
|
Glib::RefPtr<Gio::Menu>::cast_dynamic( |
1207 |
|
m_uiManager->get_object("SamplePopupMenu") |
1208 |
|
) |
1209 |
|
); |
1210 |
|
script_popup = new Gtk::Menu( |
1211 |
|
Glib::RefPtr<Gio::Menu>::cast_dynamic( |
1212 |
|
m_uiManager->get_object("ScriptPopupMenu") |
1213 |
|
) |
1214 |
|
); |
1215 |
|
#else |
1216 |
popup_menu = dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/PopupMenu")); |
popup_menu = dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/PopupMenu")); |
1217 |
|
|
1218 |
// Set tooltips for menu items (for some reason, setting a tooltip on the |
// Set tooltips for menu items (for some reason, setting a tooltip on the |
1241 |
} |
} |
1242 |
{ |
{ |
1243 |
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
1244 |
|
uiManager->get_widget("/MenuBar/MenuSettings/SyncSamplerInstrumentSelection")); |
1245 |
|
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).")); |
1246 |
|
} |
1247 |
|
{ |
1248 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
1249 |
|
uiManager->get_widget("/MenuBar/MenuSettings/MoveRootNoteWithRegionMoved")); |
1250 |
|
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.")); |
1251 |
|
} |
1252 |
|
{ |
1253 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
1254 |
|
uiManager->get_widget("/MenuBar/MenuSample/RemoveUnusedSamples")); |
1255 |
|
item->set_tooltip_text(_("Removes all samples that are not referenced by any instrument (i.e. red ones).")); |
1256 |
|
// copy tooltip to popup menu |
1257 |
|
Gtk::MenuItem* item2 = dynamic_cast<Gtk::MenuItem*>( |
1258 |
|
uiManager->get_widget("/SamplePopupMenu/RemoveUnusedSamples")); |
1259 |
|
item2->set_tooltip_text(item->get_tooltip_text()); |
1260 |
|
} |
1261 |
|
{ |
1262 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
1263 |
|
uiManager->get_widget("/MenuBar/MenuView/RefreshAll")); |
1264 |
|
item->set_tooltip_text(_("Reloads the currently open gig file and updates the entire graphical user interface.")); |
1265 |
|
} |
1266 |
|
{ |
1267 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
1268 |
|
uiManager->get_widget("/MenuBar/MenuView/AutoRestoreWinDim")); |
1269 |
|
item->set_tooltip_text(_("If checked, size and position of all windows will be saved and automatically restored next time.")); |
1270 |
|
} |
1271 |
|
{ |
1272 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
1273 |
uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments")); |
uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments")); |
1274 |
item->set_tooltip_text(_("Create combi sounds out of individual sounds of this .gig file.")); |
item->set_tooltip_text(_("Create combi sounds out of individual sounds of this .gig file.")); |
1275 |
} |
} |
1278 |
uiManager->get_widget("/MenuBar/MenuTools/MergeFiles")); |
uiManager->get_widget("/MenuBar/MenuTools/MergeFiles")); |
1279 |
item->set_tooltip_text(_("Add instruments and samples of other .gig files to this .gig file.")); |
item->set_tooltip_text(_("Add instruments and samples of other .gig files to this .gig file.")); |
1280 |
} |
} |
1281 |
|
#endif |
1282 |
|
|
1283 |
|
#if USE_GTKMM_BUILDER |
1284 |
|
assign_scripts_menu = new Gtk::Menu( |
1285 |
|
Glib::RefPtr<Gio::Menu>::cast_dynamic( |
1286 |
|
m_uiManager->get_object("AssignScripts") |
1287 |
|
) |
1288 |
|
); |
1289 |
|
#else |
1290 |
instrument_menu = static_cast<Gtk::MenuItem*>( |
instrument_menu = static_cast<Gtk::MenuItem*>( |
1291 |
uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments"))->get_submenu(); |
uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments"))->get_submenu(); |
1292 |
|
|
1293 |
|
assign_scripts_menu = static_cast<Gtk::MenuItem*>( |
1294 |
|
uiManager->get_widget("/MenuBar/MenuInstrument/AssignScripts"))->get_submenu(); |
1295 |
|
#endif |
1296 |
|
|
1297 |
|
#if USE_GTKMM_BUILDER |
1298 |
|
Gtk::Widget* menuBar = NULL; |
1299 |
|
m_uiManager->get_widget("MenuBar", menuBar); |
1300 |
|
#else |
1301 |
Gtk::Widget* menuBar = uiManager->get_widget("/MenuBar"); |
Gtk::Widget* menuBar = uiManager->get_widget("/MenuBar"); |
1302 |
|
#endif |
1303 |
|
|
1304 |
m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK); |
m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK); |
1305 |
m_VBox.pack_start(m_HPaned); |
m_VBox.pack_start(m_HPaned); |
1306 |
m_VBox.pack_start(m_RegionChooser, Gtk::PACK_SHRINK); |
m_VBox.pack_start(m_RegionChooser, Gtk::PACK_SHRINK); |
1311 |
set_file_is_shared(false); |
set_file_is_shared(false); |
1312 |
|
|
1313 |
// Status Bar: |
// Status Bar: |
1314 |
|
#if USE_GTKMM_BOX |
1315 |
|
# warning No status bar layout for GTKMM 4 yet |
1316 |
|
#else |
1317 |
m_StatusBar.pack_start(m_AttachedStateLabel, Gtk::PACK_SHRINK); |
m_StatusBar.pack_start(m_AttachedStateLabel, Gtk::PACK_SHRINK); |
1318 |
m_StatusBar.pack_start(m_AttachedStateImage, Gtk::PACK_SHRINK); |
m_StatusBar.pack_start(m_AttachedStateImage, Gtk::PACK_SHRINK); |
1319 |
|
#endif |
1320 |
m_StatusBar.show(); |
m_StatusBar.show(); |
1321 |
|
|
1322 |
m_RegionChooser.signal_region_selected().connect( |
m_RegionChooser.signal_region_selected().connect( |
1327 |
|
|
1328 |
// Create the Tree model: |
// Create the Tree model: |
1329 |
m_refTreeModel = Gtk::ListStore::create(m_Columns); |
m_refTreeModel = Gtk::ListStore::create(m_Columns); |
1330 |
m_TreeView.set_model(m_refTreeModel); |
m_refTreeModelFilter = Gtk::TreeModelFilter::create(m_refTreeModel); |
1331 |
m_TreeView.set_tooltip_text(_("Right click here for actions on instruments & MIDI Rules.")); |
m_refTreeModelFilter->set_visible_func( |
1332 |
|
sigc::mem_fun(*this, &MainWindow::instrument_row_visible) |
1333 |
|
); |
1334 |
|
m_TreeView.set_model(m_refTreeModelFilter); |
1335 |
|
|
1336 |
|
m_TreeView.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE); |
1337 |
|
m_TreeView.set_tooltip_text(_("Right click here for actions on instruments & MIDI Rules. Drag & drop to change the order of instruments.")); |
1338 |
instrument_name_connection = m_refTreeModel->signal_row_changed().connect( |
instrument_name_connection = m_refTreeModel->signal_row_changed().connect( |
1339 |
sigc::mem_fun(*this, &MainWindow::instrument_name_changed) |
sigc::mem_fun(*this, &MainWindow::instrument_name_changed) |
1340 |
); |
); |
1341 |
|
|
1342 |
// Add the TreeView's view columns: |
// Add the TreeView's view columns: |
1343 |
m_TreeView.append_column_editable("Instrument", m_Columns.m_col_name); |
m_TreeView.append_column(_("Nr"), m_Columns.m_col_nr); |
1344 |
m_TreeView.set_headers_visible(false); |
m_TreeView.append_column_editable(_("Instrument"), m_Columns.m_col_name); |
1345 |
|
m_TreeView.append_column(_("Scripts"), m_Columns.m_col_scripts); |
1346 |
|
m_TreeView.set_headers_visible(true); |
1347 |
|
|
1348 |
|
// establish drag&drop within the instrument tree view, allowing to reorder |
1349 |
|
// the sequence of instruments within the gig file |
1350 |
|
{ |
1351 |
|
std::vector<Gtk::TargetEntry> drag_target_instrument; |
1352 |
|
drag_target_instrument.push_back(Gtk::TargetEntry("gig::Instrument")); |
1353 |
|
m_TreeView.drag_source_set(drag_target_instrument); |
1354 |
|
m_TreeView.drag_dest_set(drag_target_instrument); |
1355 |
|
m_TreeView.signal_drag_begin().connect( |
1356 |
|
sigc::mem_fun(*this, &MainWindow::on_instruments_treeview_drag_begin) |
1357 |
|
); |
1358 |
|
m_TreeView.signal_drag_data_get().connect( |
1359 |
|
sigc::mem_fun(*this, &MainWindow::on_instruments_treeview_drag_data_get) |
1360 |
|
); |
1361 |
|
m_TreeView.signal_drag_data_received().connect( |
1362 |
|
sigc::mem_fun(*this, &MainWindow::on_instruments_treeview_drop_drag_data_received) |
1363 |
|
); |
1364 |
|
} |
1365 |
|
|
1366 |
// create samples treeview (including its data model) |
// create samples treeview (including its data model) |
1367 |
m_refSamplesTreeModel = SamplesTreeStore::create(m_SamplesModel); |
m_refSamplesTreeModel = SamplesTreeStore::create(m_SamplesModel); |
1368 |
m_TreeViewSamples.set_model(m_refSamplesTreeModel); |
m_TreeViewSamples.set_model(m_refSamplesTreeModel); |
1369 |
|
m_TreeViewSamples.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE); |
1370 |
m_TreeViewSamples.set_tooltip_text(_("To actually use a sample, drag it from this list view to \"Sample\" -> \"Sample:\" on the region's settings pane on the right.\n\nRight click here for more actions on samples.")); |
m_TreeViewSamples.set_tooltip_text(_("To actually use a sample, drag it from this list view to \"Sample\" -> \"Sample:\" on the region's settings pane on the right.\n\nRight click here for more actions on samples.")); |
1371 |
// m_TreeViewSamples.set_reorderable(); |
// m_TreeViewSamples.set_reorderable(); |
1372 |
m_TreeViewSamples.append_column_editable(_("Name"), m_SamplesModel.m_col_name); |
m_TreeViewSamples.append_column_editable(_("Name"), m_SamplesModel.m_col_name); |
1374 |
{ |
{ |
1375 |
Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(0); |
Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(0); |
1376 |
Gtk::CellRendererText* cellrenderer = |
Gtk::CellRendererText* cellrenderer = |
1377 |
dynamic_cast<Gtk::CellRendererText*>(column->get_first_cell_renderer()); |
dynamic_cast<Gtk::CellRendererText*>(column->get_first_cell()); |
1378 |
column->add_attribute( |
column->add_attribute( |
1379 |
cellrenderer->property_foreground(), m_SamplesModel.m_color |
cellrenderer->property_foreground(), m_SamplesModel.m_color |
1380 |
); |
); |
1382 |
{ |
{ |
1383 |
Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(1); |
Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(1); |
1384 |
Gtk::CellRendererText* cellrenderer = |
Gtk::CellRendererText* cellrenderer = |
1385 |
dynamic_cast<Gtk::CellRendererText*>(column->get_first_cell_renderer()); |
dynamic_cast<Gtk::CellRendererText*>(column->get_first_cell()); |
1386 |
column->add_attribute( |
column->add_attribute( |
1387 |
cellrenderer->property_foreground(), m_SamplesModel.m_color |
cellrenderer->property_foreground(), m_SamplesModel.m_color |
1388 |
); |
); |
1389 |
} |
} |
1390 |
m_TreeViewSamples.set_headers_visible(true); |
m_TreeViewSamples.set_headers_visible(true); |
1391 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2 |
1392 |
|
m_TreeViewSamples.signal_button_press_event().connect( |
1393 |
|
sigc::mem_fun(*this, &MainWindow::on_sample_treeview_button_release) |
1394 |
|
); |
1395 |
|
#else |
1396 |
m_TreeViewSamples.signal_button_press_event().connect_notify( |
m_TreeViewSamples.signal_button_press_event().connect_notify( |
1397 |
sigc::mem_fun(*this, &MainWindow::on_sample_treeview_button_release) |
sigc::mem_fun(*this, &MainWindow::on_sample_treeview_button_release) |
1398 |
); |
); |
1399 |
|
#endif |
1400 |
m_refSamplesTreeModel->signal_row_changed().connect( |
m_refSamplesTreeModel->signal_row_changed().connect( |
1401 |
sigc::mem_fun(*this, &MainWindow::sample_name_changed) |
sigc::mem_fun(*this, &MainWindow::sample_name_changed) |
1402 |
); |
); |
1405 |
m_refScriptsTreeModel = ScriptsTreeStore::create(m_ScriptsModel); |
m_refScriptsTreeModel = ScriptsTreeStore::create(m_ScriptsModel); |
1406 |
m_TreeViewScripts.set_model(m_refScriptsTreeModel); |
m_TreeViewScripts.set_model(m_refScriptsTreeModel); |
1407 |
m_TreeViewScripts.set_tooltip_text(_( |
m_TreeViewScripts.set_tooltip_text(_( |
1408 |
|
"Use CTRL + double click for editing a script." |
1409 |
|
"\n\n" |
1410 |
"Note: instrument scripts are a LinuxSampler extension of the gig " |
"Note: instrument scripts are a LinuxSampler extension of the gig " |
1411 |
"format. This feature will not work with the GigaStudio software!" |
"format. This feature will not work with the GigaStudio software!" |
1412 |
)); |
)); |
1413 |
// m_TreeViewScripts.set_reorderable(); |
// m_TreeViewScripts.set_reorderable(); |
1414 |
m_TreeViewScripts.append_column_editable("Samples", m_ScriptsModel.m_col_name); |
m_TreeViewScripts.append_column_editable("Samples", m_ScriptsModel.m_col_name); |
1415 |
m_TreeViewScripts.set_headers_visible(false); |
m_TreeViewScripts.set_headers_visible(false); |
1416 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2 |
1417 |
|
m_TreeViewScripts.signal_button_press_event().connect( |
1418 |
|
sigc::mem_fun(*this, &MainWindow::on_script_treeview_button_release) |
1419 |
|
); |
1420 |
|
#else |
1421 |
m_TreeViewScripts.signal_button_press_event().connect_notify( |
m_TreeViewScripts.signal_button_press_event().connect_notify( |
1422 |
sigc::mem_fun(*this, &MainWindow::on_script_treeview_button_release) |
sigc::mem_fun(*this, &MainWindow::on_script_treeview_button_release) |
1423 |
); |
); |
1424 |
|
#endif |
1425 |
|
//FIXME: why the heck does this double click signal_row_activated() only fire while CTRL key is pressed ? |
1426 |
|
m_TreeViewScripts.signal_row_activated().connect( |
1427 |
|
sigc::mem_fun(*this, &MainWindow::script_double_clicked) |
1428 |
|
); |
1429 |
m_refScriptsTreeModel->signal_row_changed().connect( |
m_refScriptsTreeModel->signal_row_changed().connect( |
1430 |
sigc::mem_fun(*this, &MainWindow::script_name_changed) |
sigc::mem_fun(*this, &MainWindow::script_name_changed) |
1431 |
); |
); |
1459 |
sigc::hide(sigc::mem_fun(*this, &MainWindow::file_changed))); |
sigc::hide(sigc::mem_fun(*this, &MainWindow::file_changed))); |
1460 |
m_RegionChooser.signal_instrument_changed().connect( |
m_RegionChooser.signal_instrument_changed().connect( |
1461 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
1462 |
|
m_RegionChooser.signal_instrument_changed().connect( |
1463 |
|
sigc::mem_fun(*this, &MainWindow::region_changed)); |
1464 |
m_DimRegionChooser.signal_region_changed().connect( |
m_DimRegionChooser.signal_region_changed().connect( |
1465 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
1466 |
instrumentProps.signal_changed().connect( |
instrumentProps.signal_changed().connect( |
1483 |
sigc::mem_fun(*this, &MainWindow::on_samples_to_be_removed) |
sigc::mem_fun(*this, &MainWindow::on_samples_to_be_removed) |
1484 |
); |
); |
1485 |
|
|
1486 |
|
dimreg_edit.signal_select_sample().connect( |
1487 |
|
sigc::mem_fun(*this, &MainWindow::select_sample) |
1488 |
|
); |
1489 |
|
|
1490 |
m_RegionChooser.signal_instrument_struct_to_be_changed().connect( |
m_RegionChooser.signal_instrument_struct_to_be_changed().connect( |
1491 |
sigc::hide( |
sigc::hide( |
1492 |
sigc::bind( |
sigc::bind( |
1520 |
dimreg_stereo.signal_toggled().connect( |
dimreg_stereo.signal_toggled().connect( |
1521 |
sigc::mem_fun(*this, &MainWindow::update_dimregs)); |
sigc::mem_fun(*this, &MainWindow::update_dimregs)); |
1522 |
|
|
1523 |
|
m_searchText.signal_changed().connect( |
1524 |
|
sigc::mem_fun(m_refTreeModelFilter.operator->(), &Gtk::TreeModelFilter::refilter) |
1525 |
|
); |
1526 |
|
|
1527 |
file = 0; |
file = 0; |
1528 |
file_is_changed = false; |
file_is_changed = false; |
1529 |
|
|
1530 |
|
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
1531 |
show_all_children(); |
show_all_children(); |
1532 |
|
#endif |
1533 |
|
|
1534 |
// start with a new gig file by default |
// start with a new gig file by default |
1535 |
on_action_file_new(); |
on_action_file_new(); |
1536 |
|
|
1537 |
|
m_TreeViewNotebook.signal_switch_page().connect( |
1538 |
|
sigc::mem_fun(*this, &MainWindow::on_notebook_tab_switched) |
1539 |
|
); |
1540 |
|
|
1541 |
// select 'Instruments' tab by default |
// select 'Instruments' tab by default |
1542 |
// (gtk allows this only if the tab childs are visible, thats why it's here) |
// (gtk allows this only if the tab childs are visible, thats why it's here) |
1543 |
m_TreeViewNotebook.set_current_page(1); |
m_TreeViewNotebook.set_current_page(1); |
1544 |
|
|
1545 |
|
Gtk::Clipboard::get()->signal_owner_change().connect( |
1546 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_owner_change) |
1547 |
|
); |
1548 |
|
updateClipboardPasteAvailable(); |
1549 |
|
updateClipboardCopyAvailable(); |
1550 |
|
|
1551 |
|
// setup macros and their keyboard accelerators |
1552 |
|
{ |
1553 |
|
#if USE_GTKMM_BUILDER |
1554 |
|
menuMacro = new Gtk::Menu( |
1555 |
|
Glib::RefPtr<Gio::Menu>::cast_dynamic( |
1556 |
|
m_uiManager->get_object("MenuMacro") |
1557 |
|
) |
1558 |
|
); |
1559 |
|
#else |
1560 |
|
Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>( |
1561 |
|
uiManager->get_widget("/MenuBar/MenuMacro") |
1562 |
|
)->get_submenu(); |
1563 |
|
#endif |
1564 |
|
|
1565 |
|
const Gdk::ModifierType noModifier = (Gdk::ModifierType)0; |
1566 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_0", GDK_KEY_F1, noModifier); |
1567 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_1", GDK_KEY_F2, noModifier); |
1568 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_2", GDK_KEY_F3, noModifier); |
1569 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_3", GDK_KEY_F4, noModifier); |
1570 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_4", GDK_KEY_F5, noModifier); |
1571 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_5", GDK_KEY_F6, noModifier); |
1572 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_6", GDK_KEY_F7, noModifier); |
1573 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_7", GDK_KEY_F8, noModifier); |
1574 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_8", GDK_KEY_F9, noModifier); |
1575 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_9", GDK_KEY_F10, noModifier); |
1576 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_10", GDK_KEY_F11, noModifier); |
1577 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_11", GDK_KEY_F12, noModifier); |
1578 |
|
Gtk::AccelMap::add_entry("<Macros>/SetupMacros", 'm', primaryModifierKey); |
1579 |
|
|
1580 |
|
Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group(); |
1581 |
|
menuMacro->set_accel_group(accelGroup); |
1582 |
|
|
1583 |
|
updateMacroMenu(); |
1584 |
|
} |
1585 |
|
|
1586 |
|
// setup "Assign Scripts" keyboard accelerators |
1587 |
|
{ |
1588 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_0", GDK_KEY_F1, Gdk::SHIFT_MASK); |
1589 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_1", GDK_KEY_F2, Gdk::SHIFT_MASK); |
1590 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_2", GDK_KEY_F3, Gdk::SHIFT_MASK); |
1591 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_3", GDK_KEY_F4, Gdk::SHIFT_MASK); |
1592 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_4", GDK_KEY_F5, Gdk::SHIFT_MASK); |
1593 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_5", GDK_KEY_F6, Gdk::SHIFT_MASK); |
1594 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_6", GDK_KEY_F7, Gdk::SHIFT_MASK); |
1595 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_7", GDK_KEY_F8, Gdk::SHIFT_MASK); |
1596 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_8", GDK_KEY_F9, Gdk::SHIFT_MASK); |
1597 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_9", GDK_KEY_F10, Gdk::SHIFT_MASK); |
1598 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_10", GDK_KEY_F11, Gdk::SHIFT_MASK); |
1599 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_11", GDK_KEY_F12, Gdk::SHIFT_MASK); |
1600 |
|
|
1601 |
|
Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group(); |
1602 |
|
assign_scripts_menu->set_accel_group(accelGroup); |
1603 |
|
} |
1604 |
|
|
1605 |
|
Glib::signal_idle().connect_once( |
1606 |
|
sigc::mem_fun(*this, &MainWindow::bringToFront), |
1607 |
|
200 |
1608 |
|
); |
1609 |
} |
} |
1610 |
|
|
1611 |
MainWindow::~MainWindow() |
MainWindow::~MainWindow() |
1612 |
{ |
{ |
1613 |
} |
} |
1614 |
|
|
1615 |
|
void MainWindow::bringToFront() { |
1616 |
|
#if defined(__APPLE__) |
1617 |
|
macRaiseAppWindow(); |
1618 |
|
#endif |
1619 |
|
raise(); |
1620 |
|
present(); |
1621 |
|
} |
1622 |
|
|
1623 |
|
void MainWindow::updateMacroMenu() { |
1624 |
|
#if !USE_GTKMM_BUILDER |
1625 |
|
Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>( |
1626 |
|
uiManager->get_widget("/MenuBar/MenuMacro") |
1627 |
|
)->get_submenu(); |
1628 |
|
#endif |
1629 |
|
|
1630 |
|
// remove all entries from "Macro" menu |
1631 |
|
{ |
1632 |
|
const std::vector<Gtk::Widget*> children = menuMacro->get_children(); |
1633 |
|
for (int i = 0; i < children.size(); ++i) { |
1634 |
|
Gtk::Widget* child = children[i]; |
1635 |
|
menuMacro->remove(*child); |
1636 |
|
delete child; |
1637 |
|
} |
1638 |
|
} |
1639 |
|
|
1640 |
|
// (re)load all macros from config file |
1641 |
|
try { |
1642 |
|
Settings::singleton()->loadMacros(m_macros); |
1643 |
|
} catch (Serialization::Exception e) { |
1644 |
|
std::cerr << "Exception while loading macros: " << e.Message << std::endl; |
1645 |
|
} catch (...) { |
1646 |
|
std::cerr << "Unknown exception while loading macros!" << std::endl; |
1647 |
|
} |
1648 |
|
|
1649 |
|
// add all configured macros as menu items to the "Macro" menu |
1650 |
|
for (int iMacro = 0; iMacro < m_macros.size(); ++iMacro) { |
1651 |
|
const Serialization::Archive& macro = m_macros[iMacro]; |
1652 |
|
std::string name = |
1653 |
|
macro.name().empty() ? |
1654 |
|
(std::string(_("Unnamed Macro")) + " " + ToString(iMacro+1)) : macro.name(); |
1655 |
|
Gtk::MenuItem* item = new Gtk::MenuItem(name); |
1656 |
|
item->signal_activate().connect( |
1657 |
|
sigc::bind( |
1658 |
|
sigc::mem_fun(*this, &MainWindow::onMacroSelected), iMacro |
1659 |
|
) |
1660 |
|
); |
1661 |
|
menuMacro->append(*item); |
1662 |
|
item->set_accel_path("<Macros>/macro_" + ToString(iMacro)); |
1663 |
|
Glib::ustring comment = macro.comment(); |
1664 |
|
if (!comment.empty()) |
1665 |
|
item->set_tooltip_text(comment); |
1666 |
|
} |
1667 |
|
// if there are no macros configured at all, then show a dummy entry instead |
1668 |
|
if (m_macros.empty()) { |
1669 |
|
Gtk::MenuItem* item = new Gtk::MenuItem(_("No Macros")); |
1670 |
|
item->set_sensitive(false); |
1671 |
|
menuMacro->append(*item); |
1672 |
|
} |
1673 |
|
|
1674 |
|
// add separator line to menu |
1675 |
|
menuMacro->append(*new Gtk::SeparatorMenuItem); |
1676 |
|
|
1677 |
|
{ |
1678 |
|
Gtk::MenuItem* item = new Gtk::MenuItem(_("Setup Macros ...")); |
1679 |
|
item->signal_activate().connect( |
1680 |
|
sigc::mem_fun(*this, &MainWindow::setupMacros) |
1681 |
|
); |
1682 |
|
menuMacro->append(*item); |
1683 |
|
item->set_accel_path("<Macros>/SetupMacros"); |
1684 |
|
} |
1685 |
|
|
1686 |
|
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
1687 |
|
menuMacro->show_all_children(); |
1688 |
|
#endif |
1689 |
|
} |
1690 |
|
|
1691 |
|
void MainWindow::onMacroSelected(int iMacro) { |
1692 |
|
printf("onMacroSelected(%d)\n", iMacro); |
1693 |
|
if (iMacro < 0 || iMacro >= m_macros.size()) return; |
1694 |
|
Glib::ustring errorText; |
1695 |
|
try { |
1696 |
|
applyMacro(m_macros[iMacro]); |
1697 |
|
} catch (Serialization::Exception e) { |
1698 |
|
errorText = e.Message; |
1699 |
|
} catch (...) { |
1700 |
|
errorText = _("Unknown exception while applying macro"); |
1701 |
|
} |
1702 |
|
if (!errorText.empty()) { |
1703 |
|
Glib::ustring txt = _("Applying macro failed:\n") + errorText; |
1704 |
|
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
1705 |
|
msg.run(); |
1706 |
|
} |
1707 |
|
} |
1708 |
|
|
1709 |
|
void MainWindow::setupMacros() { |
1710 |
|
MacrosSetup* setup = new MacrosSetup(); |
1711 |
|
gig::DimensionRegion* pDimRgn = m_DimRegionChooser.get_main_dimregion(); |
1712 |
|
setup->setMacros(m_macros, &m_serializationArchive, pDimRgn); |
1713 |
|
setup->signal_macros_changed().connect( |
1714 |
|
sigc::mem_fun(*this, &MainWindow::onMacrosSetupChanged) |
1715 |
|
); |
1716 |
|
setup->show(); |
1717 |
|
} |
1718 |
|
|
1719 |
|
void MainWindow::onMacrosSetupChanged(const std::vector<Serialization::Archive>& macros) { |
1720 |
|
m_macros = macros; |
1721 |
|
Settings::singleton()->saveMacros(m_macros); |
1722 |
|
updateMacroMenu(); |
1723 |
|
} |
1724 |
|
|
1725 |
|
//NOTE: the actual signal's first argument for argument 'page' is on some gtkmm version GtkNotebookPage* and on some Gtk::Widget*. Since we don't need that argument, it is simply void* here for now. |
1726 |
|
void MainWindow::on_notebook_tab_switched(void* page, guint page_num) { |
1727 |
|
bool isInstrumentsPage = (page_num == 1); |
1728 |
|
// so far we only support filtering for the instruments list, so hide the |
1729 |
|
// filter text entry field if another tab is selected |
1730 |
|
m_searchField.set_visible(isInstrumentsPage); |
1731 |
|
} |
1732 |
|
|
1733 |
bool MainWindow::on_delete_event(GdkEventAny* event) |
bool MainWindow::on_delete_event(GdkEventAny* event) |
1734 |
{ |
{ |
1735 |
return !file_is_shared && file_is_changed && !close_confirmation_dialog(); |
return !file_is_shared && file_is_changed && !close_confirmation_dialog(); |
1749 |
gig::Instrument* MainWindow::get_instrument() |
gig::Instrument* MainWindow::get_instrument() |
1750 |
{ |
{ |
1751 |
gig::Instrument* instrument = 0; |
gig::Instrument* instrument = 0; |
1752 |
Gtk::TreeModel::const_iterator it = |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
1753 |
m_TreeView.get_selection()->get_selected(); |
if (rows.empty()) return NULL; |
1754 |
|
//NOTE: was const_iterator before, which did not compile with GTKMM4 development branch, probably going to be fixed before final GTKMM4 release though. |
1755 |
|
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
1756 |
if (it) { |
if (it) { |
1757 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
1758 |
instrument = row[m_Columns.m_col_instr]; |
instrument = row[m_Columns.m_col_instr]; |
1795 |
add_region_to_dimregs(region, stereo, all_dimregs); |
add_region_to_dimregs(region, stereo, all_dimregs); |
1796 |
} |
} |
1797 |
} |
} |
1798 |
|
|
1799 |
|
m_RegionChooser.setModifyAllRegions(all_regions); |
1800 |
|
m_DimRegionChooser.setModifyAllRegions(all_regions); |
1801 |
|
m_DimRegionChooser.setModifyAllDimensionRegions(all_dimregs); |
1802 |
|
m_DimRegionChooser.setModifyBothChannels(stereo); |
1803 |
|
|
1804 |
|
updateClipboardCopyAvailable(); |
1805 |
} |
} |
1806 |
|
|
1807 |
void MainWindow::dimreg_all_dimregs_toggled() |
void MainWindow::dimreg_all_dimregs_toggled() |
1818 |
|
|
1819 |
void MainWindow::on_sel_change() |
void MainWindow::on_sel_change() |
1820 |
{ |
{ |
1821 |
|
#if !USE_GTKMM_BUILDER |
1822 |
// select item in instrument menu |
// select item in instrument menu |
1823 |
Gtk::TreeModel::iterator it = m_TreeView.get_selection()->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
1824 |
if (it) { |
if (!rows.empty()) { |
1825 |
Gtk::TreePath path(it); |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
1826 |
int index = path[0]; |
if (it) { |
1827 |
const std::vector<Gtk::Widget*> children = |
Gtk::TreePath path(it); |
1828 |
instrument_menu->get_children(); |
int index = path[0]; |
1829 |
static_cast<Gtk::RadioMenuItem*>(children[index])->set_active(); |
const std::vector<Gtk::Widget*> children = |
1830 |
|
instrument_menu->get_children(); |
1831 |
|
static_cast<Gtk::RadioMenuItem*>(children[index])->set_active(); |
1832 |
|
} |
1833 |
} |
} |
1834 |
|
#endif |
1835 |
|
|
1836 |
|
updateScriptListOfMenu(); |
1837 |
|
|
1838 |
m_RegionChooser.set_instrument(get_instrument()); |
m_RegionChooser.set_instrument(get_instrument()); |
1839 |
|
|
1840 |
|
if (Settings::singleton()->syncSamplerInstrumentSelection) { |
1841 |
|
switch_sampler_instrument_signal.emit(get_instrument()); |
1842 |
|
} |
1843 |
} |
} |
1844 |
|
|
1845 |
void loader_progress_callback(gig::progress_t* progress) |
void loader_progress_callback(gig::progress_t* progress) |
1857 |
progress_dispatcher(); |
progress_dispatcher(); |
1858 |
} |
} |
1859 |
|
|
1860 |
|
#if defined(WIN32) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) |
1861 |
|
// make sure stack is 16-byte aligned for SSE instructions |
1862 |
|
__attribute__((force_align_arg_pointer)) |
1863 |
|
#endif |
1864 |
void Loader::thread_function() |
void Loader::thread_function() |
1865 |
{ |
{ |
1866 |
printf("thread_function self=%x\n", Glib::Threads::Thread::self()); |
printf("thread_function self=%p\n", |
1867 |
printf("Start %s\n", filename); |
static_cast<void*>(Glib::Threads::Thread::self())); |
1868 |
RIFF::File* riff = new RIFF::File(filename); |
printf("Start %s\n", filename.c_str()); |
1869 |
gig = new gig::File(riff); |
try { |
1870 |
gig::progress_t progress; |
RIFF::File* riff = new RIFF::File(filename); |
1871 |
progress.callback = loader_progress_callback; |
gig = new gig::File(riff); |
1872 |
progress.custom = this; |
gig::progress_t progress; |
1873 |
|
progress.callback = loader_progress_callback; |
1874 |
gig->GetInstrument(0, &progress); |
progress.custom = this; |
1875 |
printf("End\n"); |
|
1876 |
finished_dispatcher(); |
gig->GetInstrument(0, &progress); |
1877 |
|
printf("End\n"); |
1878 |
|
finished_dispatcher(); |
1879 |
|
} catch (RIFF::Exception e) { |
1880 |
|
error_message = e.Message; |
1881 |
|
error_dispatcher.emit(); |
1882 |
|
} catch (...) { |
1883 |
|
error_message = _("Unknown exception occurred"); |
1884 |
|
error_dispatcher.emit(); |
1885 |
|
} |
1886 |
} |
} |
1887 |
|
|
1888 |
Loader::Loader(const char* filename) |
Loader::Loader(const char* filename) |
1889 |
: filename(filename), thread(0) |
: filename(filename), gig(0), thread(0), progress(0.f) |
1890 |
{ |
{ |
1891 |
} |
} |
1892 |
|
|
1897 |
#else |
#else |
1898 |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Loader::thread_function)); |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Loader::thread_function)); |
1899 |
#endif |
#endif |
1900 |
printf("launch thread=%x\n", thread); |
printf("launch thread=%p\n", static_cast<void*>(thread)); |
1901 |
} |
} |
1902 |
|
|
1903 |
float Loader::get_progress() |
float Loader::get_progress() |
1920 |
return finished_dispatcher; |
return finished_dispatcher; |
1921 |
} |
} |
1922 |
|
|
1923 |
LoadDialog::LoadDialog(const Glib::ustring& title, Gtk::Window& parent) |
Glib::Dispatcher& Loader::signal_error() |
1924 |
|
{ |
1925 |
|
return error_dispatcher; |
1926 |
|
} |
1927 |
|
|
1928 |
|
void saver_progress_callback(gig::progress_t* progress) |
1929 |
|
{ |
1930 |
|
Saver* saver = static_cast<Saver*>(progress->custom); |
1931 |
|
saver->progress_callback(progress->factor); |
1932 |
|
} |
1933 |
|
|
1934 |
|
void Saver::progress_callback(float fraction) |
1935 |
|
{ |
1936 |
|
{ |
1937 |
|
Glib::Threads::Mutex::Lock lock(progressMutex); |
1938 |
|
progress = fraction; |
1939 |
|
} |
1940 |
|
progress_dispatcher.emit(); |
1941 |
|
} |
1942 |
|
|
1943 |
|
#if defined(WIN32) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) |
1944 |
|
// make sure stack is 16-byte aligned for SSE instructions |
1945 |
|
__attribute__((force_align_arg_pointer)) |
1946 |
|
#endif |
1947 |
|
void Saver::thread_function() |
1948 |
|
{ |
1949 |
|
printf("thread_function self=%p\n", |
1950 |
|
static_cast<void*>(Glib::Threads::Thread::self())); |
1951 |
|
printf("Start %s\n", filename.c_str()); |
1952 |
|
try { |
1953 |
|
gig::progress_t progress; |
1954 |
|
progress.callback = saver_progress_callback; |
1955 |
|
progress.custom = this; |
1956 |
|
|
1957 |
|
// if no filename was provided, that means "save", if filename was provided means "save as" |
1958 |
|
if (filename.empty()) { |
1959 |
|
if (!Settings::singleton()->saveWithTemporaryFile) { |
1960 |
|
// save directly over the existing .gig file |
1961 |
|
// (requires less disk space than solution below |
1962 |
|
// but may be slower) |
1963 |
|
gig->Save(&progress); |
1964 |
|
} else { |
1965 |
|
// save the file as separate temporary file first, |
1966 |
|
// then move the saved file over the old file |
1967 |
|
// (may result in performance speedup during save) |
1968 |
|
gig::String tmpname = filename + ".TMP"; |
1969 |
|
gig->Save(tmpname, &progress); |
1970 |
|
#if defined(WIN32) |
1971 |
|
if (!DeleteFile(filename.c_str())) { |
1972 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file)."); |
1973 |
|
} |
1974 |
|
#else // POSIX ... |
1975 |
|
if (unlink(filename.c_str())) { |
1976 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file): " + gig::String(strerror(errno))); |
1977 |
|
} |
1978 |
|
#endif |
1979 |
|
if (rename(tmpname.c_str(), filename.c_str())) { |
1980 |
|
#if defined(WIN32) |
1981 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file)."); |
1982 |
|
#else |
1983 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file): " + gig::String(strerror(errno))); |
1984 |
|
#endif |
1985 |
|
} |
1986 |
|
} |
1987 |
|
} else { |
1988 |
|
gig->Save(filename, &progress); |
1989 |
|
} |
1990 |
|
|
1991 |
|
printf("End\n"); |
1992 |
|
finished_dispatcher.emit(); |
1993 |
|
} catch (RIFF::Exception e) { |
1994 |
|
error_message = e.Message; |
1995 |
|
error_dispatcher.emit(); |
1996 |
|
} catch (...) { |
1997 |
|
error_message = _("Unknown exception occurred"); |
1998 |
|
error_dispatcher.emit(); |
1999 |
|
} |
2000 |
|
} |
2001 |
|
|
2002 |
|
Saver::Saver(gig::File* file, Glib::ustring filename) |
2003 |
|
: gig(file), filename(filename), thread(0), progress(0.f) |
2004 |
|
{ |
2005 |
|
} |
2006 |
|
|
2007 |
|
void Saver::launch() |
2008 |
|
{ |
2009 |
|
#ifdef OLD_THREADS |
2010 |
|
thread = Glib::Thread::create(sigc::mem_fun(*this, &Saver::thread_function), true); |
2011 |
|
#else |
2012 |
|
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Saver::thread_function)); |
2013 |
|
#endif |
2014 |
|
printf("launch thread=%p\n", static_cast<void*>(thread)); |
2015 |
|
} |
2016 |
|
|
2017 |
|
float Saver::get_progress() |
2018 |
|
{ |
2019 |
|
float res; |
2020 |
|
{ |
2021 |
|
Glib::Threads::Mutex::Lock lock(progressMutex); |
2022 |
|
res = progress; |
2023 |
|
} |
2024 |
|
return res; |
2025 |
|
} |
2026 |
|
|
2027 |
|
Glib::Dispatcher& Saver::signal_progress() |
2028 |
|
{ |
2029 |
|
return progress_dispatcher; |
2030 |
|
} |
2031 |
|
|
2032 |
|
Glib::Dispatcher& Saver::signal_finished() |
2033 |
|
{ |
2034 |
|
return finished_dispatcher; |
2035 |
|
} |
2036 |
|
|
2037 |
|
Glib::Dispatcher& Saver::signal_error() |
2038 |
|
{ |
2039 |
|
return error_dispatcher; |
2040 |
|
} |
2041 |
|
|
2042 |
|
ProgressDialog::ProgressDialog(const Glib::ustring& title, Gtk::Window& parent) |
2043 |
: Gtk::Dialog(title, parent, true) |
: Gtk::Dialog(title, parent, true) |
2044 |
{ |
{ |
2045 |
|
#if USE_GTKMM_BOX |
2046 |
|
get_content_area()->pack_start(progressBar); |
2047 |
|
#else |
2048 |
get_vbox()->pack_start(progressBar); |
get_vbox()->pack_start(progressBar); |
2049 |
|
#endif |
2050 |
|
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
2051 |
show_all_children(); |
show_all_children(); |
2052 |
|
#endif |
2053 |
|
resize(600,50); |
2054 |
} |
} |
2055 |
|
|
2056 |
// Clear all GUI elements / controls. This method is typically called |
// Clear all GUI elements / controls. This method is typically called |
2062 |
m_refTreeModel->clear(); |
m_refTreeModel->clear(); |
2063 |
m_refSamplesTreeModel->clear(); |
m_refSamplesTreeModel->clear(); |
2064 |
m_refScriptsTreeModel->clear(); |
m_refScriptsTreeModel->clear(); |
2065 |
|
#if !USE_GTKMM_BUILDER |
2066 |
// remove all entries from "Instrument" menu |
// remove all entries from "Instrument" menu |
2067 |
while (!instrument_menu->get_children().empty()) { |
while (!instrument_menu->get_children().empty()) { |
2068 |
remove_instrument_from_menu(0); |
remove_instrument_from_menu(0); |
2069 |
} |
} |
2070 |
|
#endif |
2071 |
// free libgig's gig::File instance |
// free libgig's gig::File instance |
2072 |
if (file && !file_is_shared) delete file; |
if (file && !file_is_shared) delete file; |
2073 |
file = NULL; |
file = NULL; |
2079 |
m_refTreeModel->clear(); |
m_refTreeModel->clear(); |
2080 |
m_refSamplesTreeModel->clear(); |
m_refSamplesTreeModel->clear(); |
2081 |
m_refScriptsTreeModel->clear(); |
m_refScriptsTreeModel->clear(); |
2082 |
|
#if !USE_GTKMM_BUILDER |
2083 |
// remove all entries from "Instrument" menu |
// remove all entries from "Instrument" menu |
2084 |
while (!instrument_menu->get_children().empty()) { |
while (!instrument_menu->get_children().empty()) { |
2085 |
remove_instrument_from_menu(0); |
remove_instrument_from_menu(0); |
2086 |
} |
} |
2087 |
|
#endif |
2088 |
|
|
2089 |
if (!this->file) return; |
if (!this->file) return; |
2090 |
|
|
2118 |
g_free(msg); |
g_free(msg); |
2119 |
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.")); |
2120 |
dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO); |
dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO); |
2121 |
|
#if HAS_GTKMM_STOCK |
2122 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
2123 |
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); |
2124 |
|
#else |
2125 |
|
dialog.add_button(_("_OK"), Gtk::RESPONSE_OK); |
2126 |
|
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
2127 |
|
#endif |
2128 |
dialog.set_default_response(Gtk::RESPONSE_YES); |
dialog.set_default_response(Gtk::RESPONSE_YES); |
2129 |
int response = dialog.run(); |
int response = dialog.run(); |
2130 |
dialog.hide(); |
dialog.hide(); |
2131 |
if (response == Gtk::RESPONSE_YES) return file_save(); |
|
2132 |
return response != Gtk::RESPONSE_CANCEL; |
// user decided to exit app without saving |
2133 |
|
if (response == Gtk::RESPONSE_NO) return true; |
2134 |
|
|
2135 |
|
// user cancelled dialog, thus don't close app |
2136 |
|
if (response == Gtk::RESPONSE_CANCEL) return false; |
2137 |
|
|
2138 |
|
// TODO: the following return valid is disabled and hard coded instead for |
2139 |
|
// now, due to the fact that saving with progress bar is now implemented |
2140 |
|
// asynchronously, as a result the app does not close automatically anymore |
2141 |
|
// after saving the file has completed |
2142 |
|
// |
2143 |
|
// if (response == Gtk::RESPONSE_YES) return file_save(); |
2144 |
|
// return response != Gtk::RESPONSE_CANCEL; |
2145 |
|
// |
2146 |
|
if (response == Gtk::RESPONSE_YES) file_save(); |
2147 |
|
return false; // always prevent closing the app for now (see comment above) |
2148 |
} |
} |
2149 |
|
|
2150 |
bool MainWindow::leaving_shared_mode_dialog() { |
bool MainWindow::leaving_shared_mode_dialog() { |
2155 |
"used by the sampler until you tell the sampler explicitly to " |
"used by the sampler until you tell the sampler explicitly to " |
2156 |
"load it.")); |
"load it.")); |
2157 |
dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES); |
dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES); |
2158 |
|
#if HAS_GTKMM_STOCK |
2159 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
2160 |
|
#else |
2161 |
|
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
2162 |
|
#endif |
2163 |
dialog.set_default_response(Gtk::RESPONSE_CANCEL); |
dialog.set_default_response(Gtk::RESPONSE_CANCEL); |
2164 |
int response = dialog.run(); |
int response = dialog.run(); |
2165 |
dialog.hide(); |
dialog.hide(); |
2173 |
if (file_is_shared && !leaving_shared_mode_dialog()) return; |
if (file_is_shared && !leaving_shared_mode_dialog()) return; |
2174 |
|
|
2175 |
Gtk::FileChooserDialog dialog(*this, _("Open file")); |
Gtk::FileChooserDialog dialog(*this, _("Open file")); |
2176 |
|
#if HAS_GTKMM_STOCK |
2177 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
2178 |
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); |
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); |
2179 |
|
#else |
2180 |
|
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
2181 |
|
dialog.add_button(_("_Open"), Gtk::RESPONSE_OK); |
2182 |
|
#endif |
2183 |
dialog.set_default_response(Gtk::RESPONSE_OK); |
dialog.set_default_response(Gtk::RESPONSE_OK); |
2184 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
2185 |
Gtk::FileFilter filter; |
Gtk::FileFilter filter; |
2195 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
2196 |
std::string filename = dialog.get_filename(); |
std::string filename = dialog.get_filename(); |
2197 |
printf("filename=%s\n", filename.c_str()); |
printf("filename=%s\n", filename.c_str()); |
2198 |
printf("on_action_file_open self=%x\n", Glib::Threads::Thread::self()); |
printf("on_action_file_open self=%p\n", |
2199 |
|
static_cast<void*>(Glib::Threads::Thread::self())); |
2200 |
load_file(filename.c_str()); |
load_file(filename.c_str()); |
2201 |
current_gig_dir = Glib::path_get_dirname(filename); |
current_gig_dir = Glib::path_get_dirname(filename); |
2202 |
} |
} |
2205 |
void MainWindow::load_file(const char* name) |
void MainWindow::load_file(const char* name) |
2206 |
{ |
{ |
2207 |
__clear(); |
__clear(); |
2208 |
load_dialog = new LoadDialog(_("Loading..."), *this); |
|
2209 |
load_dialog->show_all(); |
progress_dialog = new ProgressDialog( //FIXME: memory leak! |
2210 |
loader = new Loader(strdup(name)); |
_("Loading") + Glib::ustring(" '") + |
2211 |
|
Glib::filename_display_basename(name) + "' ...", |
2212 |
|
*this |
2213 |
|
); |
2214 |
|
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
2215 |
|
progress_dialog->show_all(); |
2216 |
|
#endif |
2217 |
|
loader = new Loader(name); //FIXME: memory leak! |
2218 |
loader->signal_progress().connect( |
loader->signal_progress().connect( |
2219 |
sigc::mem_fun(*this, &MainWindow::on_loader_progress)); |
sigc::mem_fun(*this, &MainWindow::on_loader_progress)); |
2220 |
loader->signal_finished().connect( |
loader->signal_finished().connect( |
2221 |
sigc::mem_fun(*this, &MainWindow::on_loader_finished)); |
sigc::mem_fun(*this, &MainWindow::on_loader_finished)); |
2222 |
|
loader->signal_error().connect( |
2223 |
|
sigc::mem_fun(*this, &MainWindow::on_loader_error)); |
2224 |
loader->launch(); |
loader->launch(); |
2225 |
} |
} |
2226 |
|
|
2236 |
// load the instrument |
// load the instrument |
2237 |
gig::File* pFile = (gig::File*) instr->GetParent(); |
gig::File* pFile = (gig::File*) instr->GetParent(); |
2238 |
load_gig(pFile, 0 /*file name*/, true /*shared instrument*/); |
load_gig(pFile, 0 /*file name*/, true /*shared instrument*/); |
2239 |
//TODO: automatically select the given instrument |
// automatically select the given instrument |
2240 |
|
int i = 0; |
2241 |
|
for (gig::Instrument* instrument = pFile->GetFirstInstrument(); instrument; |
2242 |
|
instrument = pFile->GetNextInstrument(), ++i) |
2243 |
|
{ |
2244 |
|
if (instrument == instr) { |
2245 |
|
// select item in "instruments" tree view |
2246 |
|
m_TreeView.get_selection()->select(Gtk::TreePath(ToString(i))); |
2247 |
|
// make sure the selected item in the "instruments" tree view is |
2248 |
|
// visible (scroll to it) |
2249 |
|
m_TreeView.scroll_to_row(Gtk::TreePath(ToString(i))); |
2250 |
|
#if !USE_GTKMM_BUILDER |
2251 |
|
// select item in instrument menu |
2252 |
|
{ |
2253 |
|
const std::vector<Gtk::Widget*> children = |
2254 |
|
instrument_menu->get_children(); |
2255 |
|
static_cast<Gtk::RadioMenuItem*>(children[i])->set_active(); |
2256 |
|
} |
2257 |
|
#endif |
2258 |
|
// update region chooser and dimension region chooser |
2259 |
|
m_RegionChooser.set_instrument(instr); |
2260 |
|
break; |
2261 |
|
} |
2262 |
|
} |
2263 |
} |
} |
2264 |
|
|
2265 |
void MainWindow::on_loader_progress() |
void MainWindow::on_loader_progress() |
2266 |
{ |
{ |
2267 |
load_dialog->set_fraction(loader->get_progress()); |
progress_dialog->set_fraction(loader->get_progress()); |
2268 |
} |
} |
2269 |
|
|
2270 |
void MainWindow::on_loader_finished() |
void MainWindow::on_loader_finished() |
2271 |
{ |
{ |
2272 |
printf("Loader finished!\n"); |
printf("Loader finished!\n"); |
2273 |
printf("on_loader_finished self=%x\n", Glib::Threads::Thread::self()); |
printf("on_loader_finished self=%p\n", |
2274 |
load_gig(loader->gig, loader->filename); |
static_cast<void*>(Glib::Threads::Thread::self())); |
2275 |
load_dialog->hide(); |
load_gig(loader->gig, loader->filename.c_str()); |
2276 |
|
progress_dialog->hide(); |
2277 |
|
} |
2278 |
|
|
2279 |
|
void MainWindow::on_loader_error() |
2280 |
|
{ |
2281 |
|
Glib::ustring txt = _("Could not load file: ") + loader->error_message; |
2282 |
|
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
2283 |
|
msg.run(); |
2284 |
|
progress_dialog->hide(); |
2285 |
} |
} |
2286 |
|
|
2287 |
void MainWindow::on_action_file_save() |
void MainWindow::on_action_file_save() |
2320 |
|
|
2321 |
std::cout << "Saving file\n" << std::flush; |
std::cout << "Saving file\n" << std::flush; |
2322 |
file_structure_to_be_changed_signal.emit(this->file); |
file_structure_to_be_changed_signal.emit(this->file); |
2323 |
try { |
|
2324 |
file->Save(); |
progress_dialog = new ProgressDialog( //FIXME: memory leak! |
2325 |
if (file_is_changed) { |
_("Saving") + Glib::ustring(" '") + |
2326 |
set_title(get_title().substr(1)); |
Glib::filename_display_basename(this->filename) + "' ...", |
2327 |
file_is_changed = false; |
*this |
2328 |
} |
); |
2329 |
} catch (RIFF::Exception e) { |
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
2330 |
file_structure_changed_signal.emit(this->file); |
progress_dialog->show_all(); |
2331 |
Glib::ustring txt = _("Could not save file: ") + e.Message; |
#endif |
2332 |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
saver = new Saver(this->file); //FIXME: memory leak! |
2333 |
msg.run(); |
saver->signal_progress().connect( |
2334 |
return false; |
sigc::mem_fun(*this, &MainWindow::on_saver_progress)); |
2335 |
} |
saver->signal_finished().connect( |
2336 |
std::cout << "Saving file done\n" << std::flush; |
sigc::mem_fun(*this, &MainWindow::on_saver_finished)); |
2337 |
|
saver->signal_error().connect( |
2338 |
|
sigc::mem_fun(*this, &MainWindow::on_saver_error)); |
2339 |
|
saver->launch(); |
2340 |
|
|
2341 |
|
return true; |
2342 |
|
} |
2343 |
|
|
2344 |
|
void MainWindow::on_saver_progress() |
2345 |
|
{ |
2346 |
|
progress_dialog->set_fraction(saver->get_progress()); |
2347 |
|
} |
2348 |
|
|
2349 |
|
void MainWindow::on_saver_error() |
2350 |
|
{ |
2351 |
|
file_structure_changed_signal.emit(this->file); |
2352 |
|
Glib::ustring txt = _("Could not save file: ") + saver->error_message; |
2353 |
|
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
2354 |
|
msg.run(); |
2355 |
|
} |
2356 |
|
|
2357 |
|
void MainWindow::on_saver_finished() |
2358 |
|
{ |
2359 |
|
this->file = saver->gig; |
2360 |
|
this->filename = saver->filename; |
2361 |
|
current_gig_dir = Glib::path_get_dirname(filename); |
2362 |
|
set_title(Glib::filename_display_basename(filename)); |
2363 |
|
file_has_name = true; |
2364 |
|
file_is_changed = false; |
2365 |
|
std::cout << "Saving file done. Importing queued samples now ...\n" << std::flush; |
2366 |
__import_queued_samples(); |
__import_queued_samples(); |
2367 |
|
std::cout << "Importing queued samples done.\n" << std::flush; |
2368 |
|
|
2369 |
file_structure_changed_signal.emit(this->file); |
file_structure_changed_signal.emit(this->file); |
2370 |
return true; |
|
2371 |
|
__refreshEntireGUI(); |
2372 |
|
progress_dialog->hide(); |
2373 |
} |
} |
2374 |
|
|
2375 |
void MainWindow::on_action_file_save_as() |
void MainWindow::on_action_file_save_as() |
2381 |
bool MainWindow::file_save_as() |
bool MainWindow::file_save_as() |
2382 |
{ |
{ |
2383 |
Gtk::FileChooserDialog dialog(*this, _("Save as"), Gtk::FILE_CHOOSER_ACTION_SAVE); |
Gtk::FileChooserDialog dialog(*this, _("Save as"), Gtk::FILE_CHOOSER_ACTION_SAVE); |
2384 |
|
#if HAS_GTKMM_STOCK |
2385 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
2386 |
dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK); |
dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK); |
2387 |
|
#else |
2388 |
|
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
2389 |
|
dialog.add_button(_("_Save"), Gtk::RESPONSE_OK); |
2390 |
|
#endif |
2391 |
dialog.set_default_response(Gtk::RESPONSE_OK); |
dialog.set_default_response(Gtk::RESPONSE_OK); |
2392 |
dialog.set_do_overwrite_confirmation(); |
dialog.set_do_overwrite_confirmation(); |
2393 |
|
|
2416 |
} |
} |
2417 |
|
|
2418 |
// show warning in the dialog |
// show warning in the dialog |
2419 |
Gtk::HBox descriptionArea; |
HBox descriptionArea; |
2420 |
descriptionArea.set_spacing(15); |
descriptionArea.set_spacing(15); |
2421 |
Gtk::Image warningIcon(Gtk::Stock::DIALOG_WARNING, Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); |
Gtk::Image warningIcon; |
2422 |
|
warningIcon.set_from_icon_name("dialog-warning", |
2423 |
|
Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); |
2424 |
descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); |
descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); |
2425 |
#if GTKMM_MAJOR_VERSION < 3 |
#if GTKMM_MAJOR_VERSION < 3 |
2426 |
view::WrapLabel description; |
view::WrapLabel description; |
2437 |
"same .gig file will end up in corrupted sample wave data!\n") |
"same .gig file will end up in corrupted sample wave data!\n") |
2438 |
); |
); |
2439 |
descriptionArea.pack_start(description); |
descriptionArea.pack_start(description); |
2440 |
|
#if USE_GTKMM_BOX |
2441 |
|
dialog.get_content_area()->pack_start(descriptionArea, Gtk::PACK_SHRINK); |
2442 |
|
#else |
2443 |
dialog.get_vbox()->pack_start(descriptionArea, Gtk::PACK_SHRINK); |
dialog.get_vbox()->pack_start(descriptionArea, Gtk::PACK_SHRINK); |
2444 |
|
#endif |
2445 |
|
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
2446 |
descriptionArea.show_all(); |
descriptionArea.show_all(); |
2447 |
|
#endif |
2448 |
|
|
2449 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
2450 |
file_structure_to_be_changed_signal.emit(this->file); |
std::string filename = dialog.get_filename(); |
2451 |
try { |
if (!Glib::str_has_suffix(filename, ".gig")) { |
2452 |
std::string filename = dialog.get_filename(); |
filename += ".gig"; |
|
if (!Glib::str_has_suffix(filename, ".gig")) { |
|
|
filename += ".gig"; |
|
|
} |
|
|
printf("filename=%s\n", filename.c_str()); |
|
|
file->Save(filename); |
|
|
this->filename = filename; |
|
|
current_gig_dir = Glib::path_get_dirname(filename); |
|
|
set_title(Glib::filename_display_basename(filename)); |
|
|
file_has_name = true; |
|
|
file_is_changed = false; |
|
|
} catch (RIFF::Exception e) { |
|
|
file_structure_changed_signal.emit(this->file); |
|
|
Glib::ustring txt = _("Could not save file: ") + e.Message; |
|
|
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
|
|
msg.run(); |
|
|
return false; |
|
2453 |
} |
} |
2454 |
__import_queued_samples(); |
printf("filename=%s\n", filename.c_str()); |
2455 |
file_structure_changed_signal.emit(this->file); |
|
2456 |
|
progress_dialog = new ProgressDialog( //FIXME: memory leak! |
2457 |
|
_("Saving") + Glib::ustring(" '") + |
2458 |
|
Glib::filename_display_basename(filename) + "' ...", |
2459 |
|
*this |
2460 |
|
); |
2461 |
|
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
2462 |
|
progress_dialog->show_all(); |
2463 |
|
#endif |
2464 |
|
|
2465 |
|
saver = new Saver(file, filename); //FIXME: memory leak! |
2466 |
|
saver->signal_progress().connect( |
2467 |
|
sigc::mem_fun(*this, &MainWindow::on_saver_progress)); |
2468 |
|
saver->signal_finished().connect( |
2469 |
|
sigc::mem_fun(*this, &MainWindow::on_saver_finished)); |
2470 |
|
saver->signal_error().connect( |
2471 |
|
sigc::mem_fun(*this, &MainWindow::on_saver_error)); |
2472 |
|
saver->launch(); |
2473 |
|
|
2474 |
return true; |
return true; |
2475 |
} |
} |
2476 |
return false; |
return false; |
2480 |
void MainWindow::__import_queued_samples() { |
void MainWindow::__import_queued_samples() { |
2481 |
std::cout << "Starting sample import\n" << std::flush; |
std::cout << "Starting sample import\n" << std::flush; |
2482 |
Glib::ustring error_files; |
Glib::ustring error_files; |
2483 |
printf("Samples to import: %d\n", m_SampleImportQueue.size()); |
printf("Samples to import: %d\n", int(m_SampleImportQueue.size())); |
2484 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
for (std::map<gig::Sample*, SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
2485 |
iter != m_SampleImportQueue.end(); ) { |
iter != m_SampleImportQueue.end(); ) { |
2486 |
printf("Importing sample %s\n",(*iter).sample_path.c_str()); |
printf("Importing sample %s\n",iter->second.sample_path.c_str()); |
2487 |
SF_INFO info; |
SF_INFO info; |
2488 |
info.format = 0; |
info.format = 0; |
2489 |
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); |
2490 |
sf_command(hFile, SFC_SET_SCALE_FLOAT_INT_READ, 0, SF_TRUE); |
sf_command(hFile, SFC_SET_SCALE_FLOAT_INT_READ, 0, SF_TRUE); |
2491 |
try { |
try { |
2492 |
if (!hFile) throw std::string(_("could not open file")); |
if (!hFile) throw std::string(_("could not open file")); |
2509 |
throw std::string(_("format not supported")); // unsupported subformat (yet?) |
throw std::string(_("format not supported")); // unsupported subformat (yet?) |
2510 |
} |
} |
2511 |
|
|
2512 |
|
// reset write position for sample |
2513 |
|
iter->first->SetPos(0); |
2514 |
|
|
2515 |
const int bufsize = 10000; |
const int bufsize = 10000; |
2516 |
switch (bitdepth) { |
switch (bitdepth) { |
2517 |
case 16: { |
case 16: { |
2521 |
// libsndfile does the conversion for us (if needed) |
// libsndfile does the conversion for us (if needed) |
2522 |
int n = sf_readf_short(hFile, buffer, bufsize); |
int n = sf_readf_short(hFile, buffer, bufsize); |
2523 |
// write from buffer directly (physically) into .gig file |
// write from buffer directly (physically) into .gig file |
2524 |
iter->gig_sample->Write(buffer, n); |
iter->first->Write(buffer, n); |
2525 |
cnt -= n; |
cnt -= n; |
2526 |
} |
} |
2527 |
delete[] buffer; |
delete[] buffer; |
2541 |
dstbuf[j++] = srcbuf[i] >> 24; |
dstbuf[j++] = srcbuf[i] >> 24; |
2542 |
} |
} |
2543 |
// write from buffer directly (physically) into .gig file |
// write from buffer directly (physically) into .gig file |
2544 |
iter->gig_sample->Write(dstbuf, n); |
iter->first->Write(dstbuf, n); |
2545 |
cnt -= n; |
cnt -= n; |
2546 |
} |
} |
2547 |
delete[] srcbuf; |
delete[] srcbuf; |
2552 |
// cleanup |
// cleanup |
2553 |
sf_close(hFile); |
sf_close(hFile); |
2554 |
// let the sampler re-cache the sample if needed |
// let the sampler re-cache the sample if needed |
2555 |
sample_changed_signal.emit(iter->gig_sample); |
sample_changed_signal.emit(iter->first); |
2556 |
// on success we remove the sample from the import queue, |
// on success we remove the sample from the import queue, |
2557 |
// otherwise keep it, maybe it works the next time ? |
// otherwise keep it, maybe it works the next time ? |
2558 |
std::list<SampleImportItem>::iterator cur = iter; |
std::map<gig::Sample*, SampleImportItem>::iterator cur = iter; |
2559 |
++iter; |
++iter; |
2560 |
m_SampleImportQueue.erase(cur); |
m_SampleImportQueue.erase(cur); |
2561 |
} catch (std::string what) { |
} catch (std::string what) { |
2562 |
// remember the files that made trouble (and their cause) |
// remember the files that made trouble (and their cause) |
2563 |
if (!error_files.empty()) error_files += "\n"; |
if (!error_files.empty()) error_files += "\n"; |
2564 |
error_files += (*iter).sample_path += " (" + what + ")"; |
error_files += iter->second.sample_path += " (" + what + ")"; |
2565 |
++iter; |
++iter; |
2566 |
} |
} |
2567 |
} |
} |
2584 |
!Settings::singleton()->warnUserOnExtensions; |
!Settings::singleton()->warnUserOnExtensions; |
2585 |
} |
} |
2586 |
|
|
2587 |
|
void MainWindow::on_action_sync_sampler_instrument_selection() { |
2588 |
|
Settings::singleton()->syncSamplerInstrumentSelection = |
2589 |
|
!Settings::singleton()->syncSamplerInstrumentSelection; |
2590 |
|
} |
2591 |
|
|
2592 |
|
void MainWindow::on_action_move_root_note_with_region_moved() { |
2593 |
|
Settings::singleton()->moveRootNoteWithRegionMoved = |
2594 |
|
!Settings::singleton()->moveRootNoteWithRegionMoved; |
2595 |
|
} |
2596 |
|
|
2597 |
void MainWindow::on_action_help_about() |
void MainWindow::on_action_help_about() |
2598 |
{ |
{ |
2599 |
Gtk::AboutDialog dialog; |
Gtk::AboutDialog dialog; |
2603 |
dialog.set_name("Gigedit"); |
dialog.set_name("Gigedit"); |
2604 |
#endif |
#endif |
2605 |
dialog.set_version(VERSION); |
dialog.set_version(VERSION); |
2606 |
dialog.set_copyright("Copyright (C) 2006-2014 Andreas Persson"); |
dialog.set_copyright("Copyright (C) 2006-2017 Andreas Persson"); |
2607 |
const std::string sComment = |
const std::string sComment = |
2608 |
_("Built " __DATE__ "\nUsing ") + |
_("Built " __DATE__ "\nUsing ") + |
2609 |
::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" + |
::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" + |
2610 |
_( |
_( |
2611 |
"Gigedit is released under the GNU General Public License.\n" |
"Gigedit is released under the GNU General Public License.\n" |
2612 |
"\n" |
"\n" |
2613 |
"Please notice that this is still a very young instrument editor. " |
"This program is distributed WITHOUT ANY WARRANTY; So better " |
2614 |
"So better backup your Gigasampler files before editing them with " |
"backup your Gigasampler/GigaStudio files before editing them with " |
2615 |
"this application.\n" |
"this application.\n" |
2616 |
"\n" |
"\n" |
2617 |
"Please report bugs to: http://bugs.linuxsampler.org" |
"Please report bugs to: http://bugs.linuxsampler.org" |
2619 |
dialog.set_comments(sComment.c_str()); |
dialog.set_comments(sComment.c_str()); |
2620 |
dialog.set_website("http://www.linuxsampler.org"); |
dialog.set_website("http://www.linuxsampler.org"); |
2621 |
dialog.set_website_label("http://www.linuxsampler.org"); |
dialog.set_website_label("http://www.linuxsampler.org"); |
2622 |
|
dialog.set_position(Gtk::WIN_POS_CENTER); |
2623 |
dialog.run(); |
dialog.run(); |
2624 |
} |
} |
2625 |
|
|
2641 |
eSourceForm(_("Source form")), |
eSourceForm(_("Source form")), |
2642 |
eCommissioned(_("Commissioned")), |
eCommissioned(_("Commissioned")), |
2643 |
eSubject(_("Subject")), |
eSubject(_("Subject")), |
2644 |
|
#if HAS_GTKMM_STOCK |
2645 |
quitButton(Gtk::Stock::CLOSE), |
quitButton(Gtk::Stock::CLOSE), |
2646 |
|
#else |
2647 |
|
quitButton(_("_Close")), |
2648 |
|
#endif |
2649 |
table(2, 1), |
table(2, 1), |
2650 |
m_file(NULL) |
m_file(NULL) |
2651 |
{ |
{ |
2652 |
|
if (!Settings::singleton()->autoRestoreWindowDimension) { |
2653 |
|
set_default_size(470, 390); |
2654 |
|
set_position(Gtk::WIN_POS_MOUSE); |
2655 |
|
} |
2656 |
|
|
2657 |
set_title(_("File Properties")); |
set_title(_("File Properties")); |
2658 |
eName.set_width_chars(50); |
eName.set_width_chars(50); |
2659 |
|
|
2692 |
table.add(eCommissioned); |
table.add(eCommissioned); |
2693 |
table.add(eSubject); |
table.add(eSubject); |
2694 |
|
|
2695 |
|
#if USE_GTKMM_GRID |
2696 |
|
table.set_column_spacing(5); |
2697 |
|
#else |
2698 |
table.set_col_spacings(5); |
table.set_col_spacings(5); |
2699 |
|
#endif |
2700 |
|
|
2701 |
add(vbox); |
add(vbox); |
2702 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22) |
2703 |
|
table.set_margin(5); |
2704 |
|
#else |
2705 |
table.set_border_width(5); |
table.set_border_width(5); |
2706 |
|
#endif |
2707 |
vbox.add(table); |
vbox.add(table); |
2708 |
vbox.pack_start(buttonBox, Gtk::PACK_SHRINK); |
vbox.pack_start(buttonBox, Gtk::PACK_SHRINK); |
2709 |
buttonBox.set_layout(Gtk::BUTTONBOX_END); |
buttonBox.set_layout(Gtk::BUTTONBOX_END); |
2710 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22) |
2711 |
|
buttonBox.set_margin(5); |
2712 |
|
#else |
2713 |
buttonBox.set_border_width(5); |
buttonBox.set_border_width(5); |
2714 |
|
#endif |
2715 |
buttonBox.show(); |
buttonBox.show(); |
2716 |
buttonBox.pack_start(quitButton); |
buttonBox.pack_start(quitButton); |
2717 |
quitButton.set_can_default(); |
quitButton.set_can_default(); |
2723 |
|
|
2724 |
quitButton.show(); |
quitButton.show(); |
2725 |
vbox.show(); |
vbox.show(); |
2726 |
|
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
2727 |
show_all_children(); |
show_all_children(); |
2728 |
|
#endif |
2729 |
} |
} |
2730 |
|
|
2731 |
void PropDialog::set_file(gig::File* file) |
void PropDialog::set_file(gig::File* file) |
2788 |
} |
} |
2789 |
|
|
2790 |
InstrumentProps::InstrumentProps() : |
InstrumentProps::InstrumentProps() : |
2791 |
|
#if HAS_GTKMM_STOCK |
2792 |
quitButton(Gtk::Stock::CLOSE), |
quitButton(Gtk::Stock::CLOSE), |
2793 |
|
#else |
2794 |
|
quitButton(_("_Close")), |
2795 |
|
#endif |
2796 |
table(2,1), |
table(2,1), |
2797 |
eName(_("Name")), |
eName(_("Name")), |
2798 |
eIsDrum(_("Is drum")), |
eIsDrum(_("Is drum")), |
2802 |
eGainPlus6(_("Gain +6dB"), eAttenuation, -6), |
eGainPlus6(_("Gain +6dB"), eAttenuation, -6), |
2803 |
eEffectSend(_("Effect send"), 0, 65535), |
eEffectSend(_("Effect send"), 0, 65535), |
2804 |
eFineTune(_("Fine tune"), -8400, 8400), |
eFineTune(_("Fine tune"), -8400, 8400), |
2805 |
ePitchbendRange(_("Pitchbend range"), 0, 12), |
ePitchbendRange(_("Pitchbend range"), 0, 48), |
2806 |
ePianoReleaseMode(_("Piano release mode")), |
ePianoReleaseMode(_("Piano release mode")), |
2807 |
eDimensionKeyRangeLow(_("Keyswitching range low")), |
eDimensionKeyRangeLow(_("Keyswitching range low")), |
2808 |
eDimensionKeyRangeHigh(_("Keyswitching range high")) |
eDimensionKeyRangeHigh(_("Keyswitching range high")) |
2809 |
{ |
{ |
2810 |
|
if (!Settings::singleton()->autoRestoreWindowDimension) { |
2811 |
|
//set_default_size(470, 390); |
2812 |
|
set_position(Gtk::WIN_POS_MOUSE); |
2813 |
|
} |
2814 |
|
|
2815 |
set_title(_("Instrument Properties")); |
set_title(_("Instrument Properties")); |
2816 |
|
|
2817 |
eDimensionKeyRangeLow.set_tip( |
eDimensionKeyRangeLow.set_tip( |
2838 |
|
|
2839 |
eName.signal_value_changed().connect(sig_name_changed.make_slot()); |
eName.signal_value_changed().connect(sig_name_changed.make_slot()); |
2840 |
|
|
2841 |
|
#if USE_GTKMM_GRID |
2842 |
|
table.set_column_spacing(5); |
2843 |
|
#else |
2844 |
table.set_col_spacings(5); |
table.set_col_spacings(5); |
2845 |
|
#endif |
2846 |
|
|
2847 |
table.add(eName); |
table.add(eName); |
2848 |
table.add(eIsDrum); |
table.add(eIsDrum); |
2858 |
table.add(eDimensionKeyRangeHigh); |
table.add(eDimensionKeyRangeHigh); |
2859 |
|
|
2860 |
add(vbox); |
add(vbox); |
2861 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22) |
2862 |
|
table.set_margin(5); |
2863 |
|
#else |
2864 |
table.set_border_width(5); |
table.set_border_width(5); |
2865 |
|
#endif |
2866 |
vbox.pack_start(table); |
vbox.pack_start(table); |
2867 |
table.show(); |
table.show(); |
2868 |
vbox.pack_start(buttonBox, Gtk::PACK_SHRINK); |
vbox.pack_start(buttonBox, Gtk::PACK_SHRINK); |
2869 |
buttonBox.set_layout(Gtk::BUTTONBOX_END); |
buttonBox.set_layout(Gtk::BUTTONBOX_END); |
2870 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22) |
2871 |
|
buttonBox.set_margin(5); |
2872 |
|
#else |
2873 |
buttonBox.set_border_width(5); |
buttonBox.set_border_width(5); |
2874 |
|
#endif |
2875 |
buttonBox.show(); |
buttonBox.show(); |
2876 |
buttonBox.pack_start(quitButton); |
buttonBox.pack_start(quitButton); |
2877 |
quitButton.set_can_default(); |
quitButton.set_can_default(); |
2882 |
|
|
2883 |
quitButton.show(); |
quitButton.show(); |
2884 |
vbox.show(); |
vbox.show(); |
2885 |
|
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
2886 |
show_all_children(); |
show_all_children(); |
2887 |
|
#endif |
2888 |
} |
} |
2889 |
|
|
2890 |
void InstrumentProps::set_instrument(gig::Instrument* instrument) |
void InstrumentProps::set_instrument(gig::Instrument* instrument) |
2934 |
file = 0; |
file = 0; |
2935 |
set_file_is_shared(isSharedInstrument); |
set_file_is_shared(isSharedInstrument); |
2936 |
|
|
2937 |
this->filename = filename ? filename : _("Unsaved Gig File"); |
this->filename = |
2938 |
|
(filename && strlen(filename) > 0) ? |
2939 |
|
filename : (!gig->GetFileName().empty()) ? |
2940 |
|
gig->GetFileName() : _("Unsaved Gig File"); |
2941 |
set_title(Glib::filename_display_basename(this->filename)); |
set_title(Glib::filename_display_basename(this->filename)); |
2942 |
file_has_name = filename; |
file_has_name = filename; |
2943 |
file_is_changed = false; |
file_is_changed = false; |
2946 |
propDialog.set_info(gig->pInfo); |
propDialog.set_info(gig->pInfo); |
2947 |
|
|
2948 |
instrument_name_connection.block(); |
instrument_name_connection.block(); |
2949 |
|
int index = 0; |
2950 |
for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ; |
for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ; |
2951 |
instrument = gig->GetNextInstrument()) { |
instrument = gig->GetNextInstrument(), ++index) { |
2952 |
Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
2953 |
|
const int iScriptSlots = instrument->ScriptSlotCount(); |
2954 |
|
|
2955 |
Gtk::TreeModel::iterator iter = m_refTreeModel->append(); |
Gtk::TreeModel::iterator iter = m_refTreeModel->append(); |
2956 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
2957 |
|
row[m_Columns.m_col_nr] = index; |
2958 |
row[m_Columns.m_col_name] = name; |
row[m_Columns.m_col_name] = name; |
2959 |
row[m_Columns.m_col_instr] = instrument; |
row[m_Columns.m_col_instr] = instrument; |
2960 |
|
row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; |
2961 |
|
|
2962 |
|
#if !USE_GTKMM_BUILDER |
2963 |
add_instrument_to_menu(name); |
add_instrument_to_menu(name); |
2964 |
|
#endif |
2965 |
} |
} |
2966 |
instrument_name_connection.unblock(); |
instrument_name_connection.unblock(); |
2967 |
|
#if !USE_GTKMM_BUILDER |
2968 |
uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments")->show(); |
uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments")->show(); |
2969 |
|
#endif |
2970 |
|
|
2971 |
updateSampleRefCountMap(gig); |
updateSampleRefCountMap(gig); |
2972 |
|
|
3032 |
{ |
{ |
3033 |
instrumentProps.signal_name_changed().clear(); |
instrumentProps.signal_name_changed().clear(); |
3034 |
|
|
3035 |
Gtk::TreeModel::const_iterator it = |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
3036 |
m_TreeView.get_selection()->get_selected(); |
if (rows.empty()) { |
3037 |
|
instrumentProps.hide(); |
3038 |
|
return false; |
3039 |
|
} |
3040 |
|
//NOTE: was const_iterator before, which did not compile with GTKMM4 development branch, probably going to be fixed before final GTKMM4 release though. |
3041 |
|
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
3042 |
if (it) { |
if (it) { |
3043 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
3044 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
3055 |
} else { |
} else { |
3056 |
instrumentProps.hide(); |
instrumentProps.hide(); |
3057 |
} |
} |
3058 |
return it; |
//NOTE: explicit boolean cast required for GTKMM4 development branch here |
3059 |
|
return it ? true : false; |
3060 |
} |
} |
3061 |
|
|
3062 |
void MainWindow::show_instr_props() |
void MainWindow::show_instr_props() |
3092 |
void MainWindow::show_script_slots() { |
void MainWindow::show_script_slots() { |
3093 |
if (!file) return; |
if (!file) return; |
3094 |
// get selected instrument |
// get selected instrument |
3095 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
3096 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
if (rows.empty()) return; |
3097 |
|
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
3098 |
if (!it) return; |
if (!it) return; |
3099 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
3100 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
3102 |
|
|
3103 |
ScriptSlots* window = new ScriptSlots; |
ScriptSlots* window = new ScriptSlots; |
3104 |
window->setInstrument(instrument); |
window->setInstrument(instrument); |
3105 |
|
window->signal_script_slots_changed().connect( |
3106 |
|
sigc::mem_fun(*this, &MainWindow::onScriptSlotsModified) |
3107 |
|
); |
3108 |
//window->reparent(*this); |
//window->reparent(*this); |
3109 |
window->show(); |
window->show(); |
3110 |
} |
} |
3111 |
|
|
3112 |
|
void MainWindow::onScriptSlotsModified(gig::Instrument* pInstrument) { |
3113 |
|
if (!pInstrument) return; |
3114 |
|
const int iScriptSlots = pInstrument->ScriptSlotCount(); |
3115 |
|
|
3116 |
|
//NOTE: This is a big mess! Sometimes GTK requires m_TreeView.get_model(), here we need m_refTreeModelFilter->get_model(), otherwise accessing children below causes an error! |
3117 |
|
//Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
3118 |
|
Glib::RefPtr<Gtk::TreeModel> model = m_refTreeModelFilter->get_model(); |
3119 |
|
|
3120 |
|
for (int i = 0; i < model->children().size(); ++i) { |
3121 |
|
Gtk::TreeModel::Row row = model->children()[i]; |
3122 |
|
if (row[m_Columns.m_col_instr] != pInstrument) continue; |
3123 |
|
row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; |
3124 |
|
break; |
3125 |
|
} |
3126 |
|
|
3127 |
|
// causes the sampler to reload the instrument with the new script |
3128 |
|
on_sel_change(); |
3129 |
|
} |
3130 |
|
|
3131 |
|
void MainWindow::assignScript(gig::Script* pScript) { |
3132 |
|
if (!pScript) { |
3133 |
|
printf("assignScript() : !script\n"); |
3134 |
|
return; |
3135 |
|
} |
3136 |
|
printf("assignScript('%s')\n", pScript->Name.c_str()); |
3137 |
|
|
3138 |
|
gig::Instrument* pInstrument = get_instrument(); |
3139 |
|
if (!pInstrument) { |
3140 |
|
printf("!instrument\n"); |
3141 |
|
return; |
3142 |
|
} |
3143 |
|
|
3144 |
|
pInstrument->AddScriptSlot(pScript); |
3145 |
|
|
3146 |
|
onScriptSlotsModified(pInstrument); |
3147 |
|
} |
3148 |
|
|
3149 |
|
void MainWindow::on_action_refresh_all() { |
3150 |
|
__refreshEntireGUI(); |
3151 |
|
} |
3152 |
|
|
3153 |
void MainWindow::on_action_view_status_bar() { |
void MainWindow::on_action_view_status_bar() { |
3154 |
|
#if USE_GLIB_ACTION |
3155 |
|
bool active = false; |
3156 |
|
m_actionToggleStatusBar->get_state(active); |
3157 |
|
// for some reason toggle state does not change automatically |
3158 |
|
active = !active; |
3159 |
|
m_actionToggleStatusBar->change_state(active); |
3160 |
|
if (active) |
3161 |
|
m_StatusBar.show(); |
3162 |
|
else |
3163 |
|
m_StatusBar.hide(); |
3164 |
|
#else |
3165 |
Gtk::CheckMenuItem* item = |
Gtk::CheckMenuItem* item = |
3166 |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar")); |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar")); |
3167 |
if (!item) { |
if (!item) { |
3170 |
} |
} |
3171 |
if (item->get_active()) m_StatusBar.show(); |
if (item->get_active()) m_StatusBar.show(); |
3172 |
else m_StatusBar.hide(); |
else m_StatusBar.hide(); |
3173 |
|
#endif |
3174 |
|
} |
3175 |
|
|
3176 |
|
void MainWindow::on_auto_restore_win_dim() { |
3177 |
|
#if USE_GLIB_ACTION |
3178 |
|
bool active = false; |
3179 |
|
m_actionToggleRestoreWinDim->get_state(active); |
3180 |
|
// for some reason toggle state does not change automatically |
3181 |
|
active = !active; |
3182 |
|
m_actionToggleRestoreWinDim->change_state(active); |
3183 |
|
Settings::singleton()->autoRestoreWindowDimension = active; |
3184 |
|
#else |
3185 |
|
Gtk::CheckMenuItem* item = |
3186 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/AutoRestoreWinDim")); |
3187 |
|
if (!item) { |
3188 |
|
std::cerr << "/MenuBar/MenuView/AutoRestoreWinDim == NULL\n"; |
3189 |
|
return; |
3190 |
|
} |
3191 |
|
Settings::singleton()->autoRestoreWindowDimension = item->get_active(); |
3192 |
|
#endif |
3193 |
|
} |
3194 |
|
|
3195 |
|
void MainWindow::on_save_with_temporary_file() { |
3196 |
|
#if USE_GLIB_ACTION |
3197 |
|
bool active = false; |
3198 |
|
m_actionToggleSaveWithTempFile->get_state(active); |
3199 |
|
// for some reason toggle state does not change automatically |
3200 |
|
active = !active; |
3201 |
|
m_actionToggleSaveWithTempFile->change_state(active); |
3202 |
|
Settings::singleton()->saveWithTemporaryFile = active; |
3203 |
|
#else |
3204 |
|
Gtk::CheckMenuItem* item = |
3205 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuSettings/SaveWithTemporaryFile")); |
3206 |
|
if (!item) { |
3207 |
|
std::cerr << "/MenuBar/MenuSettings/SaveWithTemporaryFile == NULL\n"; |
3208 |
|
return; |
3209 |
|
} |
3210 |
|
Settings::singleton()->saveWithTemporaryFile = item->get_active(); |
3211 |
|
#endif |
3212 |
} |
} |
3213 |
|
|
3214 |
bool MainWindow::is_copy_samples_unity_note_enabled() const { |
bool MainWindow::is_copy_samples_unity_note_enabled() const { |
3215 |
|
#if USE_GLIB_ACTION |
3216 |
|
bool active = false; |
3217 |
|
m_actionToggleCopySampleUnity->get_state(active); |
3218 |
|
return active; |
3219 |
|
#else |
3220 |
Gtk::CheckMenuItem* item = |
Gtk::CheckMenuItem* item = |
3221 |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity")); |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity")); |
3222 |
if (!item) { |
if (!item) { |
3224 |
return true; |
return true; |
3225 |
} |
} |
3226 |
return item->get_active(); |
return item->get_active(); |
3227 |
|
#endif |
3228 |
} |
} |
3229 |
|
|
3230 |
bool MainWindow::is_copy_samples_fine_tune_enabled() const { |
bool MainWindow::is_copy_samples_fine_tune_enabled() const { |
3231 |
|
#if USE_GLIB_ACTION |
3232 |
|
bool active = false; |
3233 |
|
m_actionToggleCopySampleTune->get_state(active); |
3234 |
|
return active; |
3235 |
|
#else |
3236 |
Gtk::CheckMenuItem* item = |
Gtk::CheckMenuItem* item = |
3237 |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleTune")); |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleTune")); |
3238 |
if (!item) { |
if (!item) { |
3240 |
return true; |
return true; |
3241 |
} |
} |
3242 |
return item->get_active(); |
return item->get_active(); |
3243 |
|
#endif |
3244 |
} |
} |
3245 |
|
|
3246 |
bool MainWindow::is_copy_samples_loop_enabled() const { |
bool MainWindow::is_copy_samples_loop_enabled() const { |
3247 |
|
#if USE_GLIB_ACTION |
3248 |
|
bool active = false; |
3249 |
|
m_actionToggleCopySampleLoop->get_state(active); |
3250 |
|
return active; |
3251 |
|
#else |
3252 |
Gtk::CheckMenuItem* item = |
Gtk::CheckMenuItem* item = |
3253 |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleLoop")); |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleLoop")); |
3254 |
if (!item) { |
if (!item) { |
3256 |
return true; |
return true; |
3257 |
} |
} |
3258 |
return item->get_active(); |
return item->get_active(); |
3259 |
|
#endif |
3260 |
} |
} |
3261 |
|
|
3262 |
void MainWindow::on_button_release(GdkEventButton* button) |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2 |
3263 |
{ |
bool MainWindow::on_button_release(Gdk::EventButton& _button) { |
3264 |
|
GdkEventButton* button = _button.gobj(); |
3265 |
|
#else |
3266 |
|
void MainWindow::on_button_release(GdkEventButton* button) { |
3267 |
|
#endif |
3268 |
if (button->type == GDK_2BUTTON_PRESS) { |
if (button->type == GDK_2BUTTON_PRESS) { |
3269 |
show_instr_props(); |
show_instr_props(); |
3270 |
} else if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
} else if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
3271 |
// gig v2 files have no midi rules |
// gig v2 files have no midi rules |
3272 |
const bool bEnabled = !(file->pVersion && file->pVersion->major == 2); |
const bool bEnabled = !(file->pVersion && file->pVersion->major == 2); |
3273 |
|
#if USE_GTKMM_BUILDER |
3274 |
|
m_actionMIDIRules->property_enabled() = bEnabled; |
3275 |
|
#else |
3276 |
static_cast<Gtk::MenuItem*>( |
static_cast<Gtk::MenuItem*>( |
3277 |
uiManager->get_widget("/MenuBar/MenuInstrument/MidiRules"))->set_sensitive( |
uiManager->get_widget("/MenuBar/MenuInstrument/MidiRules"))->set_sensitive( |
3278 |
bEnabled |
bEnabled |
3281 |
uiManager->get_widget("/PopupMenu/MidiRules"))->set_sensitive( |
uiManager->get_widget("/PopupMenu/MidiRules"))->set_sensitive( |
3282 |
bEnabled |
bEnabled |
3283 |
); |
); |
3284 |
|
#endif |
3285 |
popup_menu->popup(button->button, button->time); |
popup_menu->popup(button->button, button->time); |
3286 |
} |
} |
3287 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2 |
3288 |
|
return false; |
3289 |
|
#endif |
3290 |
} |
} |
3291 |
|
|
3292 |
|
#if !USE_GTKMM_BUILDER |
3293 |
void MainWindow::on_instrument_selection_change(Gtk::RadioMenuItem* item) { |
void MainWindow::on_instrument_selection_change(Gtk::RadioMenuItem* item) { |
3294 |
if (item->get_active()) { |
if (item->get_active()) { |
3295 |
const std::vector<Gtk::Widget*> children = |
const std::vector<Gtk::Widget*> children = |
3304 |
} |
} |
3305 |
} |
} |
3306 |
} |
} |
3307 |
|
#endif |
3308 |
|
|
3309 |
|
void MainWindow::select_instrument(gig::Instrument* instrument) { |
3310 |
|
if (!instrument) return; |
3311 |
|
|
3312 |
|
//NOTE: This is a big mess! Sometimes GTK requires m_refTreeModelFilter->get_model(), here we need m_TreeView.get_model(), otherwise treeview selection below causes an error! |
3313 |
|
Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
3314 |
|
//Glib::RefPtr<Gtk::TreeModel> model = m_refTreeModelFilter->get_model(); |
3315 |
|
|
3316 |
|
for (int i = 0; i < model->children().size(); ++i) { |
3317 |
|
Gtk::TreeModel::Row row = model->children()[i]; |
3318 |
|
if (row[m_Columns.m_col_instr] == instrument) { |
3319 |
|
// select and show the respective instrument in the list view |
3320 |
|
show_intruments_tab(); |
3321 |
|
m_TreeView.get_selection()->unselect_all(); |
3322 |
|
|
3323 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22) |
3324 |
|
auto iterSel = model->children()[i].get_iter(); |
3325 |
|
m_TreeView.get_selection()->select(iterSel); |
3326 |
|
#else |
3327 |
|
m_TreeView.get_selection()->select(model->children()[i]); |
3328 |
|
#endif |
3329 |
|
std::vector<Gtk::TreeModel::Path> rows = |
3330 |
|
m_TreeView.get_selection()->get_selected_rows(); |
3331 |
|
if (!rows.empty()) |
3332 |
|
m_TreeView.scroll_to_row(rows[0]); |
3333 |
|
on_sel_change(); // the regular instrument selection change callback |
3334 |
|
} |
3335 |
|
} |
3336 |
|
} |
3337 |
|
|
3338 |
|
/// Returns true if requested dimension region was successfully selected and scrolled to in the list view, false on error. |
3339 |
|
bool MainWindow::select_dimension_region(gig::DimensionRegion* dimRgn) { |
3340 |
|
gig::Region* pRegion = (gig::Region*) dimRgn->GetParent(); |
3341 |
|
gig::Instrument* pInstrument = (gig::Instrument*) pRegion->GetParent(); |
3342 |
|
|
3343 |
|
//NOTE: This is a big mess! Sometimes GTK requires m_refTreeModelFilter->get_model(), here we need m_TreeView.get_model(), otherwise treeview selection below causes an error! |
3344 |
|
Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
3345 |
|
//Glib::RefPtr<Gtk::TreeModel> model = m_refTreeModelFilter->get_model(); |
3346 |
|
|
3347 |
|
for (int i = 0; i < model->children().size(); ++i) { |
3348 |
|
Gtk::TreeModel::Row row = model->children()[i]; |
3349 |
|
if (row[m_Columns.m_col_instr] == pInstrument) { |
3350 |
|
// select and show the respective instrument in the list view |
3351 |
|
show_intruments_tab(); |
3352 |
|
m_TreeView.get_selection()->unselect_all(); |
3353 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22) |
3354 |
|
auto iterSel = model->children()[i].get_iter(); |
3355 |
|
m_TreeView.get_selection()->select(iterSel); |
3356 |
|
#else |
3357 |
|
m_TreeView.get_selection()->select(model->children()[i]); |
3358 |
|
#endif |
3359 |
|
std::vector<Gtk::TreeModel::Path> rows = |
3360 |
|
m_TreeView.get_selection()->get_selected_rows(); |
3361 |
|
if (!rows.empty()) |
3362 |
|
m_TreeView.scroll_to_row(rows[0]); |
3363 |
|
on_sel_change(); // the regular instrument selection change callback |
3364 |
|
|
3365 |
|
// select respective region in the region selector |
3366 |
|
m_RegionChooser.set_region(pRegion); |
3367 |
|
|
3368 |
|
// select and show the respective dimension region in the editor |
3369 |
|
//update_dimregs(); |
3370 |
|
if (!m_DimRegionChooser.select_dimregion(dimRgn)) return false; |
3371 |
|
//dimreg_edit.set_dim_region(dimRgn); |
3372 |
|
|
3373 |
|
return true; |
3374 |
|
} |
3375 |
|
} |
3376 |
|
|
3377 |
|
return false; |
3378 |
|
} |
3379 |
|
|
3380 |
|
void MainWindow::select_sample(gig::Sample* sample) { |
3381 |
|
Glib::RefPtr<Gtk::TreeModel> model = m_TreeViewSamples.get_model(); |
3382 |
|
for (int g = 0; g < model->children().size(); ++g) { |
3383 |
|
Gtk::TreeModel::Row rowGroup = model->children()[g]; |
3384 |
|
for (int s = 0; s < rowGroup.children().size(); ++s) { |
3385 |
|
Gtk::TreeModel::Row rowSample = rowGroup.children()[s]; |
3386 |
|
if (rowSample[m_SamplesModel.m_col_sample] == sample) { |
3387 |
|
show_samples_tab(); |
3388 |
|
m_TreeViewSamples.get_selection()->unselect_all(); |
3389 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22) |
3390 |
|
auto iterSel = rowGroup.children()[s].get_iter(); |
3391 |
|
m_TreeViewSamples.get_selection()->select(iterSel); |
3392 |
|
#else |
3393 |
|
m_TreeViewSamples.get_selection()->select(rowGroup.children()[s]); |
3394 |
|
#endif |
3395 |
|
std::vector<Gtk::TreeModel::Path> rows = |
3396 |
|
m_TreeViewSamples.get_selection()->get_selected_rows(); |
3397 |
|
if (rows.empty()) return; |
3398 |
|
m_TreeViewSamples.scroll_to_row(rows[0]); |
3399 |
|
return; |
3400 |
|
} |
3401 |
|
} |
3402 |
|
} |
3403 |
|
} |
3404 |
|
|
3405 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2 |
3406 |
|
bool MainWindow::on_sample_treeview_button_release(Gdk::EventButton& _button) { |
3407 |
|
GdkEventButton* button = _button.gobj(); |
3408 |
|
#else |
3409 |
void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) { |
void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) { |
3410 |
|
#endif |
3411 |
if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
3412 |
|
// by default if Ctrl keys is pressed down, then a mouse right-click |
3413 |
|
// does not select the respective row, so we must assure this |
3414 |
|
// programmatically ... |
3415 |
|
/*{ |
3416 |
|
Gtk::TreeModel::Path path; |
3417 |
|
Gtk::TreeViewColumn* pColumn = NULL; |
3418 |
|
int cellX, cellY; |
3419 |
|
bool bSuccess = m_TreeViewSamples.get_path_at_pos( |
3420 |
|
(int)button->x, (int)button->y, |
3421 |
|
path, pColumn, cellX, cellY |
3422 |
|
); |
3423 |
|
if (bSuccess) { |
3424 |
|
if (m_TreeViewSamples.get_selection()->count_selected_rows() <= 0) { |
3425 |
|
printf("not selected !!!\n"); |
3426 |
|
m_TreeViewSamples.get_selection()->select(path); |
3427 |
|
} |
3428 |
|
} |
3429 |
|
}*/ |
3430 |
|
|
3431 |
|
#if !USE_GTKMM_BUILDER |
3432 |
Gtk::Menu* sample_popup = |
Gtk::Menu* sample_popup = |
3433 |
dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/SamplePopupMenu")); |
dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/SamplePopupMenu")); |
3434 |
|
#endif |
3435 |
|
|
3436 |
// update enabled/disabled state of sample popup items |
// update enabled/disabled state of sample popup items |
3437 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
3438 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
3439 |
bool group_selected = false; |
const int n = rows.size(); |
3440 |
bool sample_selected = false; |
int nGroups = 0; |
3441 |
if (it) { |
int nSamples = 0; |
3442 |
|
for (int r = 0; r < n; ++r) { |
3443 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[r]); |
3444 |
|
if (!it) continue; |
3445 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
3446 |
group_selected = row[m_SamplesModel.m_col_group]; |
if (row[m_SamplesModel.m_col_group]) nGroups++; |
3447 |
sample_selected = row[m_SamplesModel.m_col_sample]; |
if (row[m_SamplesModel.m_col_sample]) nSamples++; |
3448 |
} |
} |
3449 |
|
|
3450 |
|
#if USE_GTKMM_BUILDER |
3451 |
|
m_actionSampleProperties->property_enabled() = (n == 1); |
3452 |
|
m_actionAddSample->property_enabled() = (n); |
3453 |
|
m_actionAddSampleGroup->property_enabled() = (file); |
3454 |
|
m_actionViewSampleRefs->property_enabled() = (nSamples == 1); |
3455 |
|
m_actionRemoveSample->property_enabled() = (n); |
3456 |
|
m_actionReplaceSample->property_enabled() = (nSamples == 1); |
3457 |
|
#else |
3458 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))-> |
3459 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n == 1); |
3460 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))-> |
3461 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n); |
3462 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddGroup"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddGroup"))-> |
3463 |
set_sensitive(file); |
set_sensitive(file); |
3464 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/ShowSampleRefs"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/ShowSampleRefs"))-> |
3465 |
set_sensitive(sample_selected); |
set_sensitive(nSamples == 1); |
3466 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))-> |
3467 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n); |
3468 |
|
#endif |
3469 |
// show sample popup |
// show sample popup |
3470 |
sample_popup->popup(button->button, button->time); |
sample_popup->popup(button->button, button->time); |
3471 |
|
|
3472 |
|
#if !USE_GTKMM_BUILDER |
3473 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/SampleProperties"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/SampleProperties"))-> |
3474 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n == 1); |
3475 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddSample"))-> |
3476 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n); |
3477 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddGroup"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddGroup"))-> |
3478 |
set_sensitive(file); |
set_sensitive(file); |
3479 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/ShowSampleRefs"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/ShowSampleRefs"))-> |
3480 |
set_sensitive(sample_selected); |
set_sensitive(nSamples == 1); |
3481 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/RemoveSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/RemoveSample"))-> |
3482 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n); |
3483 |
|
#endif |
3484 |
} |
} |
3485 |
|
|
3486 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2 |
3487 |
|
return false; |
3488 |
|
#endif |
3489 |
} |
} |
3490 |
|
|
3491 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2 |
3492 |
|
bool MainWindow::on_script_treeview_button_release(Gdk::EventButton& _button) { |
3493 |
|
GdkEventButton* button = _button.gobj(); |
3494 |
|
#else |
3495 |
void MainWindow::on_script_treeview_button_release(GdkEventButton* button) { |
void MainWindow::on_script_treeview_button_release(GdkEventButton* button) { |
3496 |
|
#endif |
3497 |
if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
3498 |
|
#if !USE_GTKMM_BUILDER |
3499 |
Gtk::Menu* script_popup = |
Gtk::Menu* script_popup = |
3500 |
dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/ScriptPopupMenu")); |
dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/ScriptPopupMenu")); |
3501 |
|
#endif |
3502 |
// update enabled/disabled state of sample popup items |
// update enabled/disabled state of sample popup items |
3503 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewScripts.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewScripts.get_selection(); |
3504 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
Gtk::TreeModel::iterator it = sel->get_selected(); |
3509 |
group_selected = row[m_ScriptsModel.m_col_group]; |
group_selected = row[m_ScriptsModel.m_col_group]; |
3510 |
script_selected = row[m_ScriptsModel.m_col_script]; |
script_selected = row[m_ScriptsModel.m_col_script]; |
3511 |
} |
} |
3512 |
|
#if USE_GTKMM_BUILDER |
3513 |
|
m_actionAddScript->property_enabled() = (group_selected || script_selected); |
3514 |
|
m_actionAddScriptGroup->property_enabled() = (file); |
3515 |
|
m_actionEditScript->property_enabled() = (script_selected); |
3516 |
|
m_actionRemoveScript->property_enabled() = (group_selected || script_selected); |
3517 |
|
#else |
3518 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/AddScript"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/AddScript"))-> |
3519 |
set_sensitive(group_selected || script_selected); |
set_sensitive(group_selected || script_selected); |
3520 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/AddScriptGroup"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/AddScriptGroup"))-> |
3523 |
set_sensitive(script_selected); |
set_sensitive(script_selected); |
3524 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/RemoveScript"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/RemoveScript"))-> |
3525 |
set_sensitive(group_selected || script_selected); |
set_sensitive(group_selected || script_selected); |
3526 |
|
#endif |
3527 |
// show sample popup |
// show sample popup |
3528 |
script_popup->popup(button->button, button->time); |
script_popup->popup(button->button, button->time); |
3529 |
|
|
3530 |
|
#if !USE_GTKMM_BUILDER |
3531 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/AddScript"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/AddScript"))-> |
3532 |
set_sensitive(group_selected || script_selected); |
set_sensitive(group_selected || script_selected); |
3533 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/AddScriptGroup"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/AddScriptGroup"))-> |
3536 |
set_sensitive(script_selected); |
set_sensitive(script_selected); |
3537 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/RemoveScript"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/RemoveScript"))-> |
3538 |
set_sensitive(group_selected || script_selected); |
set_sensitive(group_selected || script_selected); |
3539 |
|
#endif |
3540 |
|
} |
3541 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2 |
3542 |
|
return false; |
3543 |
|
#endif |
3544 |
|
} |
3545 |
|
|
3546 |
|
void MainWindow::updateScriptListOfMenu() { |
3547 |
|
// remove all entries from "Assign Script" menu |
3548 |
|
{ |
3549 |
|
const std::vector<Gtk::Widget*> children = assign_scripts_menu->get_children(); |
3550 |
|
for (int i = 0; i < children.size(); ++i) { |
3551 |
|
Gtk::Widget* child = children[i]; |
3552 |
|
assign_scripts_menu->remove(*child); |
3553 |
|
delete child; |
3554 |
|
} |
3555 |
|
} |
3556 |
|
|
3557 |
|
int iTotalScripts = 0; |
3558 |
|
|
3559 |
|
if (!file) goto noScripts; |
3560 |
|
|
3561 |
|
// add all configured macros as menu items to the "Macro" menu |
3562 |
|
for (int iGroup = 0; file->GetScriptGroup(iGroup); ++iGroup) { |
3563 |
|
gig::ScriptGroup* pGroup = file->GetScriptGroup(iGroup); |
3564 |
|
for (int iScript = 0; pGroup->GetScript(iScript); ++iScript, ++iTotalScripts) { |
3565 |
|
gig::Script* pScript = pGroup->GetScript(iScript); |
3566 |
|
std::string name = pScript->Name; |
3567 |
|
|
3568 |
|
Gtk::MenuItem* item = new Gtk::MenuItem(name); |
3569 |
|
item->signal_activate().connect( |
3570 |
|
sigc::bind( |
3571 |
|
sigc::mem_fun(*this, &MainWindow::assignScript), pScript |
3572 |
|
) |
3573 |
|
); |
3574 |
|
assign_scripts_menu->append(*item); |
3575 |
|
item->set_accel_path("<Scripts>/script_" + ToString(iTotalScripts)); |
3576 |
|
//item->set_tooltip_text(comment); |
3577 |
|
} |
3578 |
|
} |
3579 |
|
|
3580 |
|
noScripts: |
3581 |
|
|
3582 |
|
// if there are no macros configured at all, then show a dummy entry instead |
3583 |
|
if (!iTotalScripts) { |
3584 |
|
Gtk::MenuItem* item = new Gtk::MenuItem(_("No Scripts")); |
3585 |
|
item->set_sensitive(false); |
3586 |
|
assign_scripts_menu->append(*item); |
3587 |
} |
} |
3588 |
|
|
3589 |
|
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
3590 |
|
assign_scripts_menu->show_all_children(); |
3591 |
|
#endif |
3592 |
} |
} |
3593 |
|
|
3594 |
|
#if !USE_GTKMM_BUILDER |
3595 |
Gtk::RadioMenuItem* MainWindow::add_instrument_to_menu( |
Gtk::RadioMenuItem* MainWindow::add_instrument_to_menu( |
3596 |
const Glib::ustring& name, int position) { |
const Glib::ustring& name, int position) { |
3597 |
|
|
3615 |
item)); |
item)); |
3616 |
return item; |
return item; |
3617 |
} |
} |
3618 |
|
#endif |
3619 |
|
|
3620 |
|
#if !USE_GTKMM_BUILDER |
3621 |
void MainWindow::remove_instrument_from_menu(int index) { |
void MainWindow::remove_instrument_from_menu(int index) { |
3622 |
const std::vector<Gtk::Widget*> children = |
const std::vector<Gtk::Widget*> children = |
3623 |
instrument_menu->get_children(); |
instrument_menu->get_children(); |
3625 |
instrument_menu->remove(*child); |
instrument_menu->remove(*child); |
3626 |
delete child; |
delete child; |
3627 |
} |
} |
3628 |
|
#endif |
3629 |
|
|
3630 |
void MainWindow::add_instrument(gig::Instrument* instrument) { |
void MainWindow::add_instrument(gig::Instrument* instrument) { |
3631 |
const Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
const Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
3634 |
instrument_name_connection.block(); |
instrument_name_connection.block(); |
3635 |
Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append(); |
Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append(); |
3636 |
Gtk::TreeModel::Row rowInstr = *iterInstr; |
Gtk::TreeModel::Row rowInstr = *iterInstr; |
3637 |
|
rowInstr[m_Columns.m_col_nr] = m_refTreeModel->children().size() - 1; |
3638 |
rowInstr[m_Columns.m_col_name] = name; |
rowInstr[m_Columns.m_col_name] = name; |
3639 |
rowInstr[m_Columns.m_col_instr] = instrument; |
rowInstr[m_Columns.m_col_instr] = instrument; |
3640 |
|
rowInstr[m_Columns.m_col_scripts] = ""; |
3641 |
instrument_name_connection.unblock(); |
instrument_name_connection.unblock(); |
3642 |
|
|
3643 |
|
#if !USE_GTKMM_BUILDER |
3644 |
add_instrument_to_menu(name); |
add_instrument_to_menu(name); |
3645 |
|
#endif |
3646 |
m_TreeView.get_selection()->select(iterInstr); |
select_instrument(instrument); |
|
|
|
3647 |
file_changed(); |
file_changed(); |
3648 |
} |
} |
3649 |
|
|
3664 |
// retrieve the currently selected instrument |
// retrieve the currently selected instrument |
3665 |
// (being the original instrument to be duplicated) |
// (being the original instrument to be duplicated) |
3666 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
3667 |
Gtk::TreeModel::iterator itSelection = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
3668 |
if (!itSelection) return; |
for (int r = 0; r < rows.size(); ++r) { |
3669 |
Gtk::TreeModel::Row row = *itSelection; |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]); |
3670 |
gig::Instrument* instrOrig = row[m_Columns.m_col_instr]; |
if (it) { |
3671 |
if (!instrOrig) return; |
Gtk::TreeModel::Row row = *it; |
3672 |
|
gig::Instrument* instrOrig = row[m_Columns.m_col_instr]; |
3673 |
// duplicate the orginal instrument |
if (instrOrig) { |
3674 |
gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); |
// duplicate the orginal instrument |
3675 |
instrNew->pInfo->Name = |
gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); |
3676 |
instrOrig->pInfo->Name + |
instrNew->pInfo->Name = |
3677 |
gig_from_utf8(Glib::ustring(" (") + _("Copy") + ")"); |
instrOrig->pInfo->Name + |
3678 |
|
gig_from_utf8(Glib::ustring(" (") + _("Copy") + ")"); |
3679 |
|
|
3680 |
add_instrument(instrNew); |
add_instrument(instrNew); |
3681 |
|
} |
3682 |
|
} |
3683 |
|
} |
3684 |
} |
} |
3685 |
|
|
3686 |
void MainWindow::on_action_remove_instrument() { |
void MainWindow::on_action_remove_instrument() { |
3697 |
} |
} |
3698 |
|
|
3699 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
3700 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
3701 |
if (it) { |
for (int r = rows.size() - 1; r >= 0; --r) { |
3702 |
|
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]); |
3703 |
|
if (!it) continue; |
3704 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
3705 |
gig::Instrument* instr = row[m_Columns.m_col_instr]; |
gig::Instrument* instr = row[m_Columns.m_col_instr]; |
3706 |
try { |
try { |
3711 |
if (instr) file->DeleteInstrument(instr); |
if (instr) file->DeleteInstrument(instr); |
3712 |
file_changed(); |
file_changed(); |
3713 |
|
|
3714 |
|
#if !USE_GTKMM_BUILDER |
3715 |
remove_instrument_from_menu(index); |
remove_instrument_from_menu(index); |
3716 |
|
#endif |
3717 |
|
|
3718 |
// remove row from instruments tree view |
// remove row from instruments tree view |
3719 |
m_refTreeModel->erase(it); |
m_refTreeModel->erase(it); |
3720 |
|
// update "Nr" column of all instrument rows |
3721 |
|
{ |
3722 |
|
int index = 0; |
3723 |
|
for (Gtk::TreeModel::iterator it = m_refTreeModel->children().begin(); |
3724 |
|
it != m_refTreeModel->children().end(); ++it, ++index) |
3725 |
|
{ |
3726 |
|
Gtk::TreeModel::Row row = *it; |
3727 |
|
row[m_Columns.m_col_nr] = index; |
3728 |
|
} |
3729 |
|
} |
3730 |
|
|
3731 |
#if GTKMM_MAJOR_VERSION < 3 |
#if GTKMM_MAJOR_VERSION < 3 |
3732 |
// select another instrument (in gtk3 this is done |
// select another instrument (in gtk3 this is done |
3824 |
if (!script) return; |
if (!script) return; |
3825 |
|
|
3826 |
ScriptEditor* editor = new ScriptEditor; |
ScriptEditor* editor = new ScriptEditor; |
3827 |
|
editor->signal_script_to_be_changed.connect( |
3828 |
|
signal_script_to_be_changed.make_slot() |
3829 |
|
); |
3830 |
|
editor->signal_script_changed.connect( |
3831 |
|
signal_script_changed.make_slot() |
3832 |
|
); |
3833 |
editor->setScript(script); |
editor->setScript(script); |
3834 |
//editor->reparent(*this); |
//editor->reparent(*this); |
3835 |
editor->show(); |
editor->show(); |
3895 |
file_changed(); |
file_changed(); |
3896 |
} |
} |
3897 |
|
|
3898 |
|
void MainWindow::on_action_replace_sample() { |
3899 |
|
add_or_replace_sample(true); |
3900 |
|
} |
3901 |
|
|
3902 |
void MainWindow::on_action_add_sample() { |
void MainWindow::on_action_add_sample() { |
3903 |
|
add_or_replace_sample(false); |
3904 |
|
} |
3905 |
|
|
3906 |
|
void MainWindow::add_or_replace_sample(bool replace) { |
3907 |
if (!file) return; |
if (!file) return; |
3908 |
// get selected group |
|
3909 |
|
// get selected group (and probably selected sample) |
3910 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
3911 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
3912 |
|
if (rows.empty()) return; |
3913 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]); |
3914 |
if (!it) return; |
if (!it) return; |
3915 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
3916 |
|
gig::Sample* sample = NULL; |
3917 |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
3918 |
if (!group) { // not a group, but a sample is selected (probably) |
if (!group) { // not a group, but a sample is selected (probably) |
3919 |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
if (replace) sample = row[m_SamplesModel.m_col_sample]; |
3920 |
if (!sample) return; |
if (!row[m_SamplesModel.m_col_sample]) return; |
3921 |
it = row.parent(); // resolve parent (that is the sample's group) |
it = row.parent(); // resolve parent (that is the sample's group) |
3922 |
if (!it) return; |
if (!it) return; |
3923 |
row = *it; |
if (!replace) row = *it; |
3924 |
group = row[m_SamplesModel.m_col_group]; |
group = (*it)[m_SamplesModel.m_col_group]; |
3925 |
if (!group) return; |
if (!group) return; |
3926 |
} |
} |
3927 |
|
if (replace && !sample) return; |
3928 |
|
|
3929 |
// show 'browse for file' dialog |
// show 'browse for file' dialog |
3930 |
Gtk::FileChooserDialog dialog(*this, _("Add Sample(s)")); |
Gtk::FileChooserDialog dialog(*this, replace ? _("Replace Sample with") : _("Add Sample(s)")); |
3931 |
|
#if HAS_GTKMM_STOCK |
3932 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
3933 |
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); |
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); |
3934 |
dialog.set_select_multiple(true); |
#else |
3935 |
|
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
3936 |
|
dialog.add_button(_("_Open"), Gtk::RESPONSE_OK); |
3937 |
|
#endif |
3938 |
|
dialog.set_select_multiple(!replace); // allow multi audio file selection only when adding new samples, does not make sense when replacing a specific sample |
3939 |
|
|
3940 |
// matches all file types supported by libsndfile |
// matches all file types supported by libsndfile |
3941 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
4006 |
sf_close(hFile); // close sound file |
sf_close(hFile); // close sound file |
4007 |
throw std::string(_("format not supported")); // unsupported subformat (yet?) |
throw std::string(_("format not supported")); // unsupported subformat (yet?) |
4008 |
} |
} |
4009 |
// add a new sample to the .gig file |
// add a new sample to the .gig file (if adding is requested actually) |
4010 |
gig::Sample* sample = file->AddSample(); |
if (!replace) sample = file->AddSample(); |
4011 |
// file name without path |
// file name without path |
4012 |
Glib::ustring filename = Glib::filename_display_basename(*iter); |
Glib::ustring filename = Glib::filename_display_basename(*iter); |
4013 |
// remove file extension if there is one |
// remove file extension if there is one |
4058 |
// physically when File::Save() is called) |
// physically when File::Save() is called) |
4059 |
sample->Resize(info.frames); |
sample->Resize(info.frames); |
4060 |
// make sure sample is part of the selected group |
// make sure sample is part of the selected group |
4061 |
group->AddSample(sample); |
if (!replace) group->AddSample(sample); |
4062 |
// schedule that physical resize and sample import |
// schedule that physical resize and sample import |
4063 |
// (data copying), performed when "Save" is requested |
// (data copying), performed when "Save" is requested |
4064 |
SampleImportItem sched_item; |
SampleImportItem sched_item; |
4065 |
sched_item.gig_sample = sample; |
sched_item.gig_sample = sample; |
4066 |
sched_item.sample_path = *iter; |
sched_item.sample_path = *iter; |
4067 |
m_SampleImportQueue.push_back(sched_item); |
m_SampleImportQueue[sample] = sched_item; |
4068 |
// add sample to the tree view |
// add sample to the tree view |
4069 |
Gtk::TreeModel::iterator iterSample = |
if (replace) { |
4070 |
m_refSamplesTreeModel->append(row.children()); |
row[m_SamplesModel.m_col_name] = gig_to_utf8(sample->pInfo->Name); |
4071 |
Gtk::TreeModel::Row rowSample = *iterSample; |
} else { |
4072 |
rowSample[m_SamplesModel.m_col_name] = |
Gtk::TreeModel::iterator iterSample = |
4073 |
gig_to_utf8(sample->pInfo->Name); |
m_refSamplesTreeModel->append(row.children()); |
4074 |
rowSample[m_SamplesModel.m_col_sample] = sample; |
Gtk::TreeModel::Row rowSample = *iterSample; |
4075 |
rowSample[m_SamplesModel.m_col_group] = NULL; |
rowSample[m_SamplesModel.m_col_name] = |
4076 |
|
gig_to_utf8(sample->pInfo->Name); |
4077 |
|
rowSample[m_SamplesModel.m_col_sample] = sample; |
4078 |
|
rowSample[m_SamplesModel.m_col_group] = NULL; |
4079 |
|
} |
4080 |
// close sound file |
// close sound file |
4081 |
sf_close(hFile); |
sf_close(hFile); |
4082 |
file_changed(); |
file_changed(); |
4087 |
} |
} |
4088 |
// 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 |
4089 |
if (!error_files.empty()) { |
if (!error_files.empty()) { |
4090 |
Glib::ustring txt = _("Could not add the following sample(s):\n") + error_files; |
Glib::ustring txt = |
4091 |
|
(replace |
4092 |
|
? _("Failed to replace sample with:\n") |
4093 |
|
: _("Could not add the following sample(s):\n")) |
4094 |
|
+ error_files; |
4095 |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
4096 |
msg.run(); |
msg.run(); |
4097 |
} |
} |
4124 |
Gtk::Label description(str); |
Gtk::Label description(str); |
4125 |
description.set_line_wrap(); |
description.set_line_wrap(); |
4126 |
#endif |
#endif |
4127 |
Gtk::HBox entryArea; |
HBox entryArea; |
4128 |
Gtk::Label entryLabel( _("Add filename extension: "), Gtk::ALIGN_START); |
Gtk::Label entryLabel( _("Add filename extension: "), Gtk::ALIGN_START); |
4129 |
Gtk::Entry postfixEntryBox; |
Gtk::Entry postfixEntryBox; |
4130 |
postfixEntryBox.set_text(".wav"); |
postfixEntryBox.set_text(".wav"); |
4131 |
entryArea.pack_start(entryLabel); |
entryArea.pack_start(entryLabel); |
4132 |
entryArea.pack_start(postfixEntryBox); |
entryArea.pack_start(postfixEntryBox); |
4133 |
|
#if USE_GTKMM_BOX |
4134 |
|
dialog.get_content_area()->pack_start(description, Gtk::PACK_SHRINK); |
4135 |
|
dialog.get_content_area()->pack_start(entryArea, Gtk::PACK_SHRINK); |
4136 |
|
#else |
4137 |
dialog.get_vbox()->pack_start(description, Gtk::PACK_SHRINK); |
dialog.get_vbox()->pack_start(description, Gtk::PACK_SHRINK); |
4138 |
dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK); |
dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK); |
4139 |
|
#endif |
4140 |
description.show(); |
description.show(); |
4141 |
|
|
4142 |
|
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
4143 |
entryArea.show_all(); |
entryArea.show_all(); |
4144 |
|
#else |
4145 |
|
entryArea.show(); |
4146 |
|
#endif |
4147 |
|
|
4148 |
|
#if HAS_GTKMM_STOCK |
4149 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
4150 |
|
#else |
4151 |
|
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
4152 |
|
#endif |
4153 |
dialog.add_button(_("Select"), Gtk::RESPONSE_OK); |
dialog.add_button(_("Select"), Gtk::RESPONSE_OK); |
4154 |
dialog.set_select_multiple(false); |
dialog.set_select_multiple(false); |
4155 |
if (current_sample_dir != "") { |
if (current_sample_dir != "") { |
4173 |
try |
try |
4174 |
{ |
{ |
4175 |
if (!hFile) throw std::string(_("could not open file")); |
if (!hFile) throw std::string(_("could not open file")); |
|
int bitdepth; |
|
4176 |
switch (info.format & 0xff) { |
switch (info.format & 0xff) { |
4177 |
case SF_FORMAT_PCM_S8: |
case SF_FORMAT_PCM_S8: |
4178 |
case SF_FORMAT_PCM_16: |
case SF_FORMAT_PCM_16: |
4179 |
case SF_FORMAT_PCM_U8: |
case SF_FORMAT_PCM_U8: |
|
bitdepth = 16; |
|
|
break; |
|
4180 |
case SF_FORMAT_PCM_24: |
case SF_FORMAT_PCM_24: |
4181 |
case SF_FORMAT_PCM_32: |
case SF_FORMAT_PCM_32: |
4182 |
case SF_FORMAT_FLOAT: |
case SF_FORMAT_FLOAT: |
4183 |
case SF_FORMAT_DOUBLE: |
case SF_FORMAT_DOUBLE: |
|
bitdepth = 24; |
|
4184 |
break; |
break; |
4185 |
default: |
default: |
4186 |
sf_close(hFile); |
sf_close(hFile); |
4189 |
SampleImportItem sched_item; |
SampleImportItem sched_item; |
4190 |
sched_item.gig_sample = sample; |
sched_item.gig_sample = sample; |
4191 |
sched_item.sample_path = filename; |
sched_item.sample_path = filename; |
4192 |
m_SampleImportQueue.push_back(sched_item); |
m_SampleImportQueue[sample] = sched_item; |
4193 |
sf_close(hFile); |
sf_close(hFile); |
4194 |
file_changed(); |
file_changed(); |
4195 |
} |
} |
4213 |
void MainWindow::on_action_remove_sample() { |
void MainWindow::on_action_remove_sample() { |
4214 |
if (!file) return; |
if (!file) return; |
4215 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
4216 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
4217 |
if (it) { |
for (int r = rows.size() - 1; r >= 0; --r) { |
4218 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[r]); |
4219 |
|
if (!it) continue; |
4220 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
4221 |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
4222 |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
4241 |
// if sample(s) were just previously added, remove |
// if sample(s) were just previously added, remove |
4242 |
// them from the import queue |
// them from the import queue |
4243 |
for (std::list<gig::Sample*>::iterator member = members.begin(); |
for (std::list<gig::Sample*>::iterator member = members.begin(); |
4244 |
member != members.end(); ++member) { |
member != members.end(); ++member) |
4245 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
{ |
4246 |
iter != m_SampleImportQueue.end(); ++iter) { |
if (m_SampleImportQueue.count(*member)) { |
4247 |
if ((*iter).gig_sample == *member) { |
printf("Removing previously added sample '%s' from group '%s'\n", |
4248 |
printf("Removing previously added sample '%s' from group '%s'\n", |
m_SampleImportQueue[sample].sample_path.c_str(), name.c_str()); |
4249 |
(*iter).sample_path.c_str(), name.c_str()); |
m_SampleImportQueue.erase(*member); |
|
m_SampleImportQueue.erase(iter); |
|
|
break; |
|
|
} |
|
4250 |
} |
} |
4251 |
} |
} |
4252 |
file_changed(); |
file_changed(); |
4261 |
samples_removed_signal.emit(); |
samples_removed_signal.emit(); |
4262 |
// if sample was just previously added, remove it from |
// if sample was just previously added, remove it from |
4263 |
// the import queue |
// the import queue |
4264 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
if (m_SampleImportQueue.count(sample)) { |
4265 |
iter != m_SampleImportQueue.end(); ++iter) { |
printf("Removing previously added sample '%s'\n", |
4266 |
if ((*iter).gig_sample == sample) { |
m_SampleImportQueue[sample].sample_path.c_str()); |
4267 |
printf("Removing previously added sample '%s'\n", |
m_SampleImportQueue.erase(sample); |
|
(*iter).sample_path.c_str()); |
|
|
m_SampleImportQueue.erase(iter); |
|
|
break; |
|
|
} |
|
4268 |
} |
} |
4269 |
dimreg_changed(); |
dimreg_changed(); |
4270 |
file_changed(); |
file_changed(); |
4281 |
} |
} |
4282 |
} |
} |
4283 |
|
|
4284 |
|
void MainWindow::on_action_remove_unused_samples() { |
4285 |
|
if (!file) return; |
4286 |
|
|
4287 |
|
// collect all samples that are not referenced by any instrument |
4288 |
|
std::list<gig::Sample*> lsamples; |
4289 |
|
for (int iSample = 0; file->GetSample(iSample); ++iSample) { |
4290 |
|
gig::Sample* sample = file->GetSample(iSample); |
4291 |
|
bool isUsed = false; |
4292 |
|
for (gig::Instrument* instrument = file->GetFirstInstrument(); instrument; |
4293 |
|
instrument = file->GetNextInstrument()) |
4294 |
|
{ |
4295 |
|
for (gig::Region* rgn = instrument->GetFirstRegion(); rgn; |
4296 |
|
rgn = instrument->GetNextRegion()) |
4297 |
|
{ |
4298 |
|
for (int i = 0; i < 256; ++i) { |
4299 |
|
if (!rgn->pDimensionRegions[i]) continue; |
4300 |
|
if (rgn->pDimensionRegions[i]->pSample != sample) continue; |
4301 |
|
isUsed = true; |
4302 |
|
goto endOfRefSearch; |
4303 |
|
} |
4304 |
|
} |
4305 |
|
} |
4306 |
|
endOfRefSearch: |
4307 |
|
if (!isUsed) lsamples.push_back(sample); |
4308 |
|
} |
4309 |
|
|
4310 |
|
if (lsamples.empty()) return; |
4311 |
|
|
4312 |
|
// notify everybody that we're going to remove these samples |
4313 |
|
samples_to_be_removed_signal.emit(lsamples); |
4314 |
|
|
4315 |
|
// remove collected samples |
4316 |
|
try { |
4317 |
|
for (std::list<gig::Sample*>::iterator itSample = lsamples.begin(); |
4318 |
|
itSample != lsamples.end(); ++itSample) |
4319 |
|
{ |
4320 |
|
gig::Sample* sample = *itSample; |
4321 |
|
// remove sample from the .gig file |
4322 |
|
file->DeleteSample(sample); |
4323 |
|
// if sample was just previously added, remove it from the import queue |
4324 |
|
if (m_SampleImportQueue.count(sample)) { |
4325 |
|
printf("Removing previously added sample '%s'\n", |
4326 |
|
m_SampleImportQueue[sample].sample_path.c_str()); |
4327 |
|
m_SampleImportQueue.erase(sample); |
4328 |
|
} |
4329 |
|
} |
4330 |
|
} catch (RIFF::Exception e) { |
4331 |
|
// show error message |
4332 |
|
Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR); |
4333 |
|
msg.run(); |
4334 |
|
} |
4335 |
|
|
4336 |
|
// notify everybody that we're done with removal |
4337 |
|
samples_removed_signal.emit(); |
4338 |
|
|
4339 |
|
dimreg_changed(); |
4340 |
|
file_changed(); |
4341 |
|
__refreshEntireGUI(); |
4342 |
|
} |
4343 |
|
|
4344 |
// see comment on on_sample_treeview_drag_begin() |
// see comment on on_sample_treeview_drag_begin() |
4345 |
void MainWindow::on_scripts_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context) |
void MainWindow::on_scripts_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context) |
4346 |
{ |
{ |
4367 |
sizeof(script)/*length of data in bytes*/); |
sizeof(script)/*length of data in bytes*/); |
4368 |
} |
} |
4369 |
|
|
4370 |
|
// see comment on on_sample_treeview_drag_begin() |
4371 |
|
void MainWindow::on_instruments_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context) |
4372 |
|
{ |
4373 |
|
first_call_to_drag_data_get = true; |
4374 |
|
} |
4375 |
|
|
4376 |
|
void MainWindow::on_instruments_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&, |
4377 |
|
Gtk::SelectionData& selection_data, guint, guint) |
4378 |
|
{ |
4379 |
|
if (!first_call_to_drag_data_get) return; |
4380 |
|
first_call_to_drag_data_get = false; |
4381 |
|
|
4382 |
|
// get selected source instrument |
4383 |
|
gig::Instrument* src = NULL; |
4384 |
|
{ |
4385 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
4386 |
|
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
4387 |
|
if (!rows.empty()) { |
4388 |
|
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
4389 |
|
if (it) { |
4390 |
|
Gtk::TreeModel::Row row = *it; |
4391 |
|
src = row[m_Columns.m_col_instr]; |
4392 |
|
} |
4393 |
|
} |
4394 |
|
} |
4395 |
|
if (!src) return; |
4396 |
|
|
4397 |
|
// pass the source gig::Instrument as pointer |
4398 |
|
selection_data.set(selection_data.get_target(), 0/*unused*/, (const guchar*)&src, |
4399 |
|
sizeof(src)/*length of data in bytes*/); |
4400 |
|
} |
4401 |
|
|
4402 |
|
void MainWindow::on_instruments_treeview_drop_drag_data_received( |
4403 |
|
const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, |
4404 |
|
const Gtk::SelectionData& selection_data, guint, guint time) |
4405 |
|
{ |
4406 |
|
gig::Instrument* src = *((gig::Instrument**) selection_data.get_data()); |
4407 |
|
if (!src || selection_data.get_length() != sizeof(gig::Instrument*)) |
4408 |
|
return; |
4409 |
|
|
4410 |
|
gig::Instrument* dst = NULL; |
4411 |
|
{ |
4412 |
|
Gtk::TreeModel::Path path; |
4413 |
|
const bool found = m_TreeView.get_path_at_pos(x, y, path); |
4414 |
|
if (!found) return; |
4415 |
|
|
4416 |
|
Gtk::TreeModel::iterator iter = m_refTreeModel->get_iter(path); |
4417 |
|
if (!iter) return; |
4418 |
|
Gtk::TreeModel::Row row = *iter; |
4419 |
|
dst = row[m_Columns.m_col_instr]; |
4420 |
|
} |
4421 |
|
if (!dst) return; |
4422 |
|
|
4423 |
|
//printf("dragdrop received src=%s dst=%s\n", src->pInfo->Name.c_str(), dst->pInfo->Name.c_str()); |
4424 |
|
src->MoveTo(dst); |
4425 |
|
__refreshEntireGUI(); |
4426 |
|
select_instrument(src); |
4427 |
|
} |
4428 |
|
|
4429 |
// For some reason drag_data_get gets called two times for each |
// For some reason drag_data_get gets called two times for each |
4430 |
// 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 |
4431 |
// 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 |
4444 |
// get selected sample |
// get selected sample |
4445 |
gig::Sample* sample = NULL; |
gig::Sample* sample = NULL; |
4446 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
4447 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
4448 |
if (it) { |
if (!rows.empty()) { |
4449 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]); |
4450 |
sample = row[m_SamplesModel.m_col_sample]; |
if (it) { |
4451 |
|
Gtk::TreeModel::Row row = *it; |
4452 |
|
sample = row[m_SamplesModel.m_col_sample]; |
4453 |
|
} |
4454 |
} |
} |
4455 |
// pass the gig::Sample as pointer |
// pass the gig::Sample as pointer |
4456 |
selection_data.set(selection_data.get_target(), 0/*unused*/, (const guchar*)&sample, |
selection_data.set(selection_data.get_target(), 0/*unused*/, (const guchar*)&sample, |
4580 |
} |
} |
4581 |
} |
} |
4582 |
|
|
4583 |
|
void MainWindow::script_double_clicked(const Gtk::TreeModel::Path& path, |
4584 |
|
Gtk::TreeViewColumn* column) |
4585 |
|
{ |
4586 |
|
Gtk::TreeModel::iterator iter = m_refScriptsTreeModel->get_iter(path); |
4587 |
|
if (!iter) return; |
4588 |
|
Gtk::TreeModel::Row row = *iter; |
4589 |
|
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
4590 |
|
if (!script) return; |
4591 |
|
|
4592 |
|
ScriptEditor* editor = new ScriptEditor; |
4593 |
|
editor->signal_script_to_be_changed.connect( |
4594 |
|
signal_script_to_be_changed.make_slot() |
4595 |
|
); |
4596 |
|
editor->signal_script_changed.connect( |
4597 |
|
signal_script_changed.make_slot() |
4598 |
|
); |
4599 |
|
editor->setScript(script); |
4600 |
|
//editor->reparent(*this); |
4601 |
|
editor->show(); |
4602 |
|
} |
4603 |
|
|
4604 |
void MainWindow::instrument_name_changed(const Gtk::TreeModel::Path& path, |
void MainWindow::instrument_name_changed(const Gtk::TreeModel::Path& path, |
4605 |
const Gtk::TreeModel::iterator& iter) { |
const Gtk::TreeModel::iterator& iter) { |
4606 |
if (!iter) return; |
if (!iter) return; |
4607 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
4608 |
Glib::ustring name = row[m_Columns.m_col_name]; |
Glib::ustring name = row[m_Columns.m_col_name]; |
4609 |
|
|
4610 |
|
#if !USE_GTKMM_BUILDER |
4611 |
// change name in instrument menu |
// change name in instrument menu |
4612 |
int index = path[0]; |
int index = path[0]; |
4613 |
const std::vector<Gtk::Widget*> children = instrument_menu->get_children(); |
const std::vector<Gtk::Widget*> children = instrument_menu->get_children(); |
4620 |
item->set_active(); |
item->set_active(); |
4621 |
#endif |
#endif |
4622 |
} |
} |
4623 |
|
#endif |
4624 |
|
|
4625 |
// change name in gig |
// change name in gig |
4626 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
4637 |
} |
} |
4638 |
} |
} |
4639 |
|
|
4640 |
|
bool MainWindow::instrument_row_visible(const Gtk::TreeModel::const_iterator& iter) { |
4641 |
|
if (!iter) |
4642 |
|
return true; |
4643 |
|
|
4644 |
|
Glib::ustring pattern = m_searchText.get_text().lowercase(); |
4645 |
|
trim(pattern); |
4646 |
|
if (pattern.empty()) return true; |
4647 |
|
|
4648 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22) |
4649 |
|
//HACK: on GTKMM4 development branch const_iterator cannot be easily converted to iterator, probably going to be fixed before final GTKMM4 release though. |
4650 |
|
Gtk::TreeModel::Row row = **(Gtk::TreeModel::iterator*)(&iter); |
4651 |
|
#else |
4652 |
|
Gtk::TreeModel::Row row = *iter; |
4653 |
|
#endif |
4654 |
|
Glib::ustring name = row[m_Columns.m_col_name]; |
4655 |
|
name = name.lowercase(); |
4656 |
|
|
4657 |
|
std::vector<Glib::ustring> tokens = Glib::Regex::split_simple(" ", pattern); |
4658 |
|
for (int t = 0; t < tokens.size(); ++t) |
4659 |
|
if (name.find(tokens[t]) == Glib::ustring::npos) |
4660 |
|
return false; |
4661 |
|
|
4662 |
|
return true; |
4663 |
|
} |
4664 |
|
|
4665 |
void MainWindow::on_action_combine_instruments() { |
void MainWindow::on_action_combine_instruments() { |
4666 |
CombineInstrumentsDialog* d = new CombineInstrumentsDialog(*this, file); |
CombineInstrumentsDialog* d = new CombineInstrumentsDialog(*this, file); |
4667 |
|
|
4668 |
|
// take over selection from instruments list view for the combine dialog's |
4669 |
|
// list view as pre-selection |
4670 |
|
std::set<int> indeces; |
4671 |
|
{ |
4672 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
4673 |
|
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
4674 |
|
for (int r = 0; r < rows.size(); ++r) { |
4675 |
|
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]); |
4676 |
|
if (it) { |
4677 |
|
Gtk::TreeModel::Row row = *it; |
4678 |
|
int index = row[m_Columns.m_col_nr]; |
4679 |
|
indeces.insert(index); |
4680 |
|
} |
4681 |
|
} |
4682 |
|
} |
4683 |
|
d->setSelectedInstruments(indeces); |
4684 |
|
|
4685 |
|
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
4686 |
d->show_all(); |
d->show_all(); |
4687 |
d->resize(500, 400); |
#else |
4688 |
|
d->show(); |
4689 |
|
#endif |
4690 |
d->run(); |
d->run(); |
4691 |
if (d->fileWasChanged()) { |
if (d->fileWasChanged()) { |
4692 |
// update GUI with new instrument just created |
// update GUI with new instrument just created |
4697 |
|
|
4698 |
void MainWindow::on_action_view_references() { |
void MainWindow::on_action_view_references() { |
4699 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
4700 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
4701 |
|
if (rows.empty()) return; |
4702 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]); |
4703 |
if (!it) return; |
if (!it) return; |
4704 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
4705 |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
4707 |
|
|
4708 |
ReferencesView* d = new ReferencesView(*this); |
ReferencesView* d = new ReferencesView(*this); |
4709 |
d->setSample(sample); |
d->setSample(sample); |
4710 |
|
d->dimension_region_selected.connect( |
4711 |
|
sigc::mem_fun(*this, &MainWindow::select_dimension_region) |
4712 |
|
); |
4713 |
|
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
4714 |
d->show_all(); |
d->show_all(); |
4715 |
|
#else |
4716 |
|
d->show(); |
4717 |
|
#endif |
4718 |
d->resize(500, 400); |
d->resize(500, 400); |
4719 |
d->run(); |
d->run(); |
4720 |
delete d; |
delete d; |
4787 |
); |
); |
4788 |
} |
} |
4789 |
|
|
4790 |
// Note: requires that this file already has a filename ! |
// Finally save gig file persistently to disk ... |
4791 |
this->file->Save(); |
//NOTE: requires that this gig file already has a filename ! |
4792 |
|
{ |
4793 |
|
std::cout << "Saving file\n" << std::flush; |
4794 |
|
file_structure_to_be_changed_signal.emit(this->file); |
4795 |
|
|
4796 |
|
progress_dialog = new ProgressDialog( //FIXME: memory leak! |
4797 |
|
_("Saving") + Glib::ustring(" '") + |
4798 |
|
Glib::filename_display_basename(this->filename) + "' ...", |
4799 |
|
*this |
4800 |
|
); |
4801 |
|
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
4802 |
|
progress_dialog->show_all(); |
4803 |
|
#else |
4804 |
|
progress_dialog->show(); |
4805 |
|
#endif |
4806 |
|
saver = new Saver(this->file); //FIXME: memory leak! |
4807 |
|
saver->signal_progress().connect( |
4808 |
|
sigc::mem_fun(*this, &MainWindow::on_saver_progress)); |
4809 |
|
saver->signal_finished().connect( |
4810 |
|
sigc::mem_fun(*this, &MainWindow::on_saver_finished)); |
4811 |
|
saver->signal_error().connect( |
4812 |
|
sigc::mem_fun(*this, &MainWindow::on_saver_error)); |
4813 |
|
saver->launch(); |
4814 |
|
} |
4815 |
} |
} |
4816 |
|
|
4817 |
void MainWindow::on_action_merge_files() { |
void MainWindow::on_action_merge_files() { |
4829 |
} |
} |
4830 |
|
|
4831 |
Gtk::FileChooserDialog dialog(*this, _("Merge .gig files")); |
Gtk::FileChooserDialog dialog(*this, _("Merge .gig files")); |
4832 |
|
#if HAS_GTKMM_STOCK |
4833 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
4834 |
|
#else |
4835 |
|
dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL); |
4836 |
|
#endif |
4837 |
dialog.add_button(_("Merge"), Gtk::RESPONSE_OK); |
dialog.add_button(_("Merge"), Gtk::RESPONSE_OK); |
4838 |
dialog.set_default_response(Gtk::RESPONSE_CANCEL); |
dialog.set_default_response(Gtk::RESPONSE_CANCEL); |
4839 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
4850 |
dialog.set_select_multiple(true); |
dialog.set_select_multiple(true); |
4851 |
|
|
4852 |
// show warning in the file picker dialog |
// show warning in the file picker dialog |
4853 |
Gtk::HBox descriptionArea; |
HBox descriptionArea; |
4854 |
descriptionArea.set_spacing(15); |
descriptionArea.set_spacing(15); |
4855 |
Gtk::Image warningIcon(Gtk::Stock::DIALOG_WARNING, Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); |
Gtk::Image warningIcon; |
4856 |
|
warningIcon.set_from_icon_name("dialog-warning", |
4857 |
|
Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); |
4858 |
descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); |
descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); |
4859 |
#if GTKMM_MAJOR_VERSION < 3 |
#if GTKMM_MAJOR_VERSION < 3 |
4860 |
view::WrapLabel description; |
view::WrapLabel description; |
4873 |
"will accordingly be stored separately in the target .gig file!" |
"will accordingly be stored separately in the target .gig file!" |
4874 |
)); |
)); |
4875 |
descriptionArea.pack_start(description); |
descriptionArea.pack_start(description); |
4876 |
|
#if USE_GTKMM_BOX |
4877 |
|
# warning No description area implemented for dialog on GTKMM 3 |
4878 |
|
#else |
4879 |
dialog.get_vbox()->pack_start(descriptionArea, Gtk::PACK_SHRINK); |
dialog.get_vbox()->pack_start(descriptionArea, Gtk::PACK_SHRINK); |
4880 |
|
#endif |
4881 |
|
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
4882 |
descriptionArea.show_all(); |
descriptionArea.show_all(); |
4883 |
|
#else |
4884 |
|
descriptionArea.show(); |
4885 |
|
#endif |
4886 |
|
|
4887 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
4888 |
printf("on_action_merge_files self=%x\n", Glib::Threads::Thread::self()); |
printf("on_action_merge_files self=%p\n", |
4889 |
|
static_cast<void*>(Glib::Threads::Thread::self())); |
4890 |
std::vector<std::string> filenames = dialog.get_filenames(); |
std::vector<std::string> filenames = dialog.get_filenames(); |
4891 |
|
|
4892 |
// merge the selected files to the currently open .gig file |
// merge the selected files to the currently open .gig file |
4898 |
} |
} |
4899 |
|
|
4900 |
// update GUI |
// update GUI |
4901 |
__refreshEntireGUI(); |
__refreshEntireGUI(); |
4902 |
} |
} |
4903 |
} |
} |
4904 |
|
|
4916 |
Gdk::Pixbuf::create_from_xpm_data(status_detached_xpm) |
Gdk::Pixbuf::create_from_xpm_data(status_detached_xpm) |
4917 |
); |
); |
4918 |
} |
} |
4919 |
|
|
4920 |
|
{ |
4921 |
|
#if USE_GTKMM_BUILDER |
4922 |
|
m_actionToggleSyncSamplerSelection->property_enabled() = b; |
4923 |
|
#else |
4924 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
4925 |
|
uiManager->get_widget("/MenuBar/MenuSettings/SyncSamplerInstrumentSelection")); |
4926 |
|
if (item) item->set_sensitive(b); |
4927 |
|
#endif |
4928 |
|
} |
4929 |
} |
} |
4930 |
|
|
4931 |
void MainWindow::on_sample_ref_count_incremented(gig::Sample* sample, int offset) { |
void MainWindow::on_sample_ref_count_incremented(gig::Sample* sample, int offset) { |
4954 |
// just in case a new sample is added later with exactly the same memory |
// just in case a new sample is added later with exactly the same memory |
4955 |
// address, which would lead to incorrect refcount if not deleted here |
// address, which would lead to incorrect refcount if not deleted here |
4956 |
for (std::list<gig::Sample*>::const_iterator it = samples.begin(); |
for (std::list<gig::Sample*>::const_iterator it = samples.begin(); |
4957 |
it != samples.end(); it != samples.end()) |
it != samples.end(); ++it) |
4958 |
{ |
{ |
4959 |
sample_ref_count.erase(*it); |
sample_ref_count.erase(*it); |
4960 |
} |
} |
4972 |
m_TreeViewNotebook.set_current_page(2); |
m_TreeViewNotebook.set_current_page(2); |
4973 |
} |
} |
4974 |
|
|
4975 |
|
void MainWindow::select_instrument_by_dir(int dir) { |
4976 |
|
if (!file) return; |
4977 |
|
gig::Instrument* pInstrument = get_instrument(); |
4978 |
|
if (!pInstrument) { |
4979 |
|
select_instrument( file->GetInstrument(0) ); |
4980 |
|
return; |
4981 |
|
} |
4982 |
|
for (int i = 0; file->GetInstrument(i); ++i) { |
4983 |
|
if (file->GetInstrument(i) == pInstrument) { |
4984 |
|
select_instrument( file->GetInstrument(i + dir) ); |
4985 |
|
return; |
4986 |
|
} |
4987 |
|
} |
4988 |
|
} |
4989 |
|
|
4990 |
|
void MainWindow::select_prev_instrument() { |
4991 |
|
select_instrument_by_dir(-1); |
4992 |
|
} |
4993 |
|
|
4994 |
|
void MainWindow::select_next_instrument() { |
4995 |
|
select_instrument_by_dir(1); |
4996 |
|
} |
4997 |
|
|
4998 |
|
void MainWindow::select_prev_region() { |
4999 |
|
m_RegionChooser.select_prev_region(); |
5000 |
|
} |
5001 |
|
|
5002 |
|
void MainWindow::select_next_region() { |
5003 |
|
m_RegionChooser.select_next_region(); |
5004 |
|
} |
5005 |
|
|
5006 |
|
void MainWindow::select_next_dim_rgn_zone() { |
5007 |
|
if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser |
5008 |
|
m_DimRegionChooser.select_next_dimzone(); |
5009 |
|
} |
5010 |
|
|
5011 |
|
void MainWindow::select_prev_dim_rgn_zone() { |
5012 |
|
if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser |
5013 |
|
m_DimRegionChooser.select_prev_dimzone(); |
5014 |
|
} |
5015 |
|
|
5016 |
|
void MainWindow::select_add_next_dim_rgn_zone() { |
5017 |
|
m_DimRegionChooser.select_next_dimzone(true); |
5018 |
|
} |
5019 |
|
|
5020 |
|
void MainWindow::select_add_prev_dim_rgn_zone() { |
5021 |
|
m_DimRegionChooser.select_prev_dimzone(true); |
5022 |
|
} |
5023 |
|
|
5024 |
|
void MainWindow::select_prev_dimension() { |
5025 |
|
if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser |
5026 |
|
m_DimRegionChooser.select_prev_dimension(); |
5027 |
|
} |
5028 |
|
|
5029 |
|
void MainWindow::select_next_dimension() { |
5030 |
|
if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser |
5031 |
|
m_DimRegionChooser.select_next_dimension(); |
5032 |
|
} |
5033 |
|
|
5034 |
|
#define CLIPBOARD_DIMENSIONREGION_TARGET \ |
5035 |
|
("libgig.DimensionRegion." + m_serializationArchive.rawDataFormat()) |
5036 |
|
|
5037 |
|
void MainWindow::copy_selected_dimrgn() { |
5038 |
|
gig::DimensionRegion* pDimRgn = m_DimRegionChooser.get_main_dimregion(); |
5039 |
|
if (!pDimRgn) { |
5040 |
|
updateClipboardPasteAvailable(); |
5041 |
|
updateClipboardCopyAvailable(); |
5042 |
|
return; |
5043 |
|
} |
5044 |
|
|
5045 |
|
std::vector<Gtk::TargetEntry> targets; |
5046 |
|
targets.push_back( Gtk::TargetEntry(CLIPBOARD_DIMENSIONREGION_TARGET) ); |
5047 |
|
|
5048 |
|
Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); |
5049 |
|
clipboard->set( |
5050 |
|
targets, |
5051 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_get), |
5052 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_clear) |
5053 |
|
); |
5054 |
|
|
5055 |
|
m_serializationArchive.serialize(pDimRgn); |
5056 |
|
|
5057 |
|
updateClipboardPasteAvailable(); |
5058 |
|
} |
5059 |
|
|
5060 |
|
void MainWindow::paste_copied_dimrgn() { |
5061 |
|
Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); |
5062 |
|
clipboard->request_contents( |
5063 |
|
CLIPBOARD_DIMENSIONREGION_TARGET, |
5064 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_received) |
5065 |
|
); |
5066 |
|
updateClipboardPasteAvailable(); |
5067 |
|
} |
5068 |
|
|
5069 |
|
void MainWindow::adjust_clipboard_content() { |
5070 |
|
MacroEditor* editor = new MacroEditor(); |
5071 |
|
editor->setMacro(&m_serializationArchive, true); |
5072 |
|
editor->show(); |
5073 |
|
} |
5074 |
|
|
5075 |
|
void MainWindow::updateClipboardPasteAvailable() { |
5076 |
|
Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); |
5077 |
|
clipboard->request_targets( |
5078 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_received_targets) |
5079 |
|
); |
5080 |
|
} |
5081 |
|
|
5082 |
|
void MainWindow::updateClipboardCopyAvailable() { |
5083 |
|
bool bDimensionRegionCopyIsPossible = m_DimRegionChooser.get_main_dimregion(); |
5084 |
|
#if USE_GTKMM_BUILDER |
5085 |
|
m_actionCopyDimRgn->property_enabled() = bDimensionRegionCopyIsPossible; |
5086 |
|
#else |
5087 |
|
static_cast<Gtk::MenuItem*>( |
5088 |
|
uiManager->get_widget("/MenuBar/MenuEdit/CopyDimRgn") |
5089 |
|
)->set_sensitive(bDimensionRegionCopyIsPossible); |
5090 |
|
#endif |
5091 |
|
} |
5092 |
|
|
5093 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2 |
5094 |
|
void MainWindow::on_clipboard_owner_change(Gdk::EventOwnerChange& event) { |
5095 |
|
#else |
5096 |
|
void MainWindow::on_clipboard_owner_change(GdkEventOwnerChange* event) { |
5097 |
|
#endif |
5098 |
|
updateClipboardPasteAvailable(); |
5099 |
|
} |
5100 |
|
|
5101 |
|
void MainWindow::on_clipboard_get(Gtk::SelectionData& selection_data, guint /*info*/) { |
5102 |
|
const std::string target = selection_data.get_target(); |
5103 |
|
if (target == CLIPBOARD_DIMENSIONREGION_TARGET) { |
5104 |
|
selection_data.set( |
5105 |
|
CLIPBOARD_DIMENSIONREGION_TARGET, 8 /* "format": probably unused*/, |
5106 |
|
&m_serializationArchive.rawData()[0], |
5107 |
|
m_serializationArchive.rawData().size() |
5108 |
|
); |
5109 |
|
} else { |
5110 |
|
std::cerr << "Clipboard: content for unknown target '" << target << "' requested\n"; |
5111 |
|
} |
5112 |
|
} |
5113 |
|
|
5114 |
|
void MainWindow::on_clipboard_clear() { |
5115 |
|
m_serializationArchive.clear(); |
5116 |
|
updateClipboardPasteAvailable(); |
5117 |
|
updateClipboardCopyAvailable(); |
5118 |
|
} |
5119 |
|
|
5120 |
|
//NOTE: Might throw exception !!! |
5121 |
|
void MainWindow::applyMacro(Serialization::Archive& macro) { |
5122 |
|
gig::DimensionRegion* pDimRgn = m_DimRegionChooser.get_main_dimregion(); |
5123 |
|
if (!pDimRgn) return; |
5124 |
|
|
5125 |
|
for (std::set<gig::DimensionRegion*>::iterator itDimReg = dimreg_edit.dimregs.begin(); |
5126 |
|
itDimReg != dimreg_edit.dimregs.end(); ++itDimReg) |
5127 |
|
{ |
5128 |
|
gig::DimensionRegion* pDimRgn = *itDimReg; |
5129 |
|
DimRegionChangeGuard(this, pDimRgn); |
5130 |
|
macro.deserialize(pDimRgn); |
5131 |
|
} |
5132 |
|
//region_changed() |
5133 |
|
file_changed(); |
5134 |
|
dimreg_changed(); |
5135 |
|
} |
5136 |
|
|
5137 |
|
void MainWindow::on_clipboard_received(const Gtk::SelectionData& selection_data) { |
5138 |
|
const std::string target = selection_data.get_target(); |
5139 |
|
if (target == CLIPBOARD_DIMENSIONREGION_TARGET) { |
5140 |
|
Glib::ustring errorText; |
5141 |
|
try { |
5142 |
|
m_serializationArchive.decode( |
5143 |
|
selection_data.get_data(), selection_data.get_length() |
5144 |
|
); |
5145 |
|
applyMacro(m_serializationArchive); |
5146 |
|
} catch (Serialization::Exception e) { |
5147 |
|
errorText = e.Message; |
5148 |
|
} catch (...) { |
5149 |
|
errorText = _("Unknown exception while pasting DimensionRegion"); |
5150 |
|
} |
5151 |
|
if (!errorText.empty()) { |
5152 |
|
Glib::ustring txt = _("Pasting DimensionRegion failed:\n") + errorText; |
5153 |
|
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
5154 |
|
msg.run(); |
5155 |
|
} |
5156 |
|
} |
5157 |
|
} |
5158 |
|
|
5159 |
|
void MainWindow::on_clipboard_received_targets(const std::vector<Glib::ustring>& targets) { |
5160 |
|
const bool bDimensionRegionPasteIsPossible = |
5161 |
|
std::find(targets.begin(), targets.end(), |
5162 |
|
CLIPBOARD_DIMENSIONREGION_TARGET) != targets.end(); |
5163 |
|
|
5164 |
|
#if USE_GTKMM_BUILDER |
5165 |
|
m_actionPasteDimRgn->property_enabled() = bDimensionRegionPasteIsPossible; |
5166 |
|
m_actionAdjustClipboard->property_enabled() = bDimensionRegionPasteIsPossible; |
5167 |
|
#else |
5168 |
|
static_cast<Gtk::MenuItem*>( |
5169 |
|
uiManager->get_widget("/MenuBar/MenuEdit/PasteDimRgn") |
5170 |
|
)->set_sensitive(bDimensionRegionPasteIsPossible); |
5171 |
|
|
5172 |
|
static_cast<Gtk::MenuItem*>( |
5173 |
|
uiManager->get_widget("/MenuBar/MenuEdit/AdjustClipboard") |
5174 |
|
)->set_sensitive(bDimensionRegionPasteIsPossible); |
5175 |
|
#endif |
5176 |
|
} |
5177 |
|
|
5178 |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
5179 |
return file_structure_to_be_changed_signal; |
return file_structure_to_be_changed_signal; |
5180 |
} |
} |
5230 |
sigc::signal<void, int/*key*/, int/*velocity*/>& MainWindow::signal_keyboard_key_released() { |
sigc::signal<void, int/*key*/, int/*velocity*/>& MainWindow::signal_keyboard_key_released() { |
5231 |
return m_RegionChooser.signal_keyboard_key_released(); |
return m_RegionChooser.signal_keyboard_key_released(); |
5232 |
} |
} |
5233 |
|
|
5234 |
|
sigc::signal<void, gig::Instrument*>& MainWindow::signal_switch_sampler_instrument() { |
5235 |
|
return switch_sampler_instrument_signal; |
5236 |
|
} |