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 <glibmmconfig.h> |
24 |
|
// threads.h must be included first to be able to build with |
25 |
|
// G_DISABLE_DEPRECATED |
26 |
|
#if (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION == 31 && GLIBMM_MICRO_VERSION >= 2) || \ |
27 |
|
(GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION > 31) || GLIBMM_MAJOR_VERSION > 2 |
28 |
|
#include <glibmm/threads.h> |
29 |
|
#endif |
30 |
|
|
31 |
#include <glibmm/convert.h> |
#include <glibmm/convert.h> |
32 |
#include <glibmm/dispatcher.h> |
#include <glibmm/dispatcher.h> |
33 |
#include <glibmm/miscutils.h> |
#include <glibmm/miscutils.h> |
39 |
#include <gtkmm/targetentry.h> |
#include <gtkmm/targetentry.h> |
40 |
#include <gtkmm/main.h> |
#include <gtkmm/main.h> |
41 |
#include <gtkmm/toggleaction.h> |
#include <gtkmm/toggleaction.h> |
42 |
|
#include <gtkmm/accelmap.h> |
43 |
#if GTKMM_MAJOR_VERSION < 3 |
#if GTKMM_MAJOR_VERSION < 3 |
44 |
#include "wrapLabel.hh" |
#include "wrapLabel.hh" |
45 |
#endif |
#endif |
59 |
#include "ReferencesView.h" |
#include "ReferencesView.h" |
60 |
#include "../../gfx/status_attached.xpm" |
#include "../../gfx/status_attached.xpm" |
61 |
#include "../../gfx/status_detached.xpm" |
#include "../../gfx/status_detached.xpm" |
62 |
|
#include "gfx/builtinpix.h" |
63 |
|
#include "MacroEditor.h" |
64 |
|
#include "MacrosSetup.h" |
65 |
|
|
66 |
MainWindow::MainWindow() : |
MainWindow::MainWindow() : |
67 |
m_DimRegionChooser(*this), |
m_DimRegionChooser(*this), |
68 |
dimreg_label(_("Changes apply to:")), |
dimreg_label(_("Changes apply to:")), |
69 |
dimreg_all_regions(_("all regions")), |
dimreg_all_regions(_("all regions")), |
70 |
dimreg_all_dimregs(_("all dimension splits")), |
dimreg_all_dimregs(_("all dimension splits")), |
71 |
dimreg_stereo(_("both channels")) |
dimreg_stereo(_("both channels")), |
72 |
|
labelLegend(_("Legend:")), |
73 |
|
labelNoSample(_(" No Sample")), |
74 |
|
labelMissingSample(_(" Missing some Sample(s)")), |
75 |
|
labelLooped(_(" Looped")), |
76 |
|
labelSomeLoops(_(" Some Loop(s)")) |
77 |
{ |
{ |
78 |
|
loadBuiltInPix(); |
79 |
|
|
80 |
// set_border_width(5); |
// set_border_width(5); |
|
// set_default_size(400, 200); |
|
81 |
|
|
82 |
|
if (!Settings::singleton()->autoRestoreWindowDimension) { |
83 |
|
set_default_size(800, 600); |
84 |
|
set_position(Gtk::WIN_POS_CENTER); |
85 |
|
} |
86 |
|
|
87 |
add(m_VBox); |
add(m_VBox); |
88 |
|
|
117 |
dimreg_hbox.add(dimreg_stereo); |
dimreg_hbox.add(dimreg_stereo); |
118 |
dimreg_vbox.add(dimreg_edit); |
dimreg_vbox.add(dimreg_edit); |
119 |
dimreg_vbox.pack_start(dimreg_hbox, Gtk::PACK_SHRINK); |
dimreg_vbox.pack_start(dimreg_hbox, Gtk::PACK_SHRINK); |
120 |
|
{ |
121 |
|
legend_hbox.add(labelLegend); |
122 |
|
|
123 |
|
imageNoSample.set(redDot); |
124 |
|
imageNoSample.set_alignment(Gtk::ALIGN_END); |
125 |
|
labelNoSample.set_alignment(Gtk::ALIGN_START); |
126 |
|
legend_hbox.add(imageNoSample); |
127 |
|
legend_hbox.add(labelNoSample); |
128 |
|
|
129 |
|
imageMissingSample.set(yellowDot); |
130 |
|
imageMissingSample.set_alignment(Gtk::ALIGN_END); |
131 |
|
labelMissingSample.set_alignment(Gtk::ALIGN_START); |
132 |
|
legend_hbox.add(imageMissingSample); |
133 |
|
legend_hbox.add(labelMissingSample); |
134 |
|
|
135 |
|
imageLooped.set(blackLoop); |
136 |
|
imageLooped.set_alignment(Gtk::ALIGN_END); |
137 |
|
labelLooped.set_alignment(Gtk::ALIGN_START); |
138 |
|
legend_hbox.add(imageLooped); |
139 |
|
legend_hbox.add(labelLooped); |
140 |
|
|
141 |
|
imageSomeLoops.set(grayLoop); |
142 |
|
imageSomeLoops.set_alignment(Gtk::ALIGN_END); |
143 |
|
labelSomeLoops.set_alignment(Gtk::ALIGN_START); |
144 |
|
legend_hbox.add(imageSomeLoops); |
145 |
|
legend_hbox.add(labelSomeLoops); |
146 |
|
|
147 |
|
legend_hbox.show_all_children(); |
148 |
|
} |
149 |
|
dimreg_vbox.pack_start(legend_hbox, Gtk::PACK_SHRINK); |
150 |
m_HPaned.add2(dimreg_vbox); |
m_HPaned.add2(dimreg_vbox); |
151 |
|
|
152 |
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.")); |
207 |
sigc::mem_fun(*this, &MainWindow::show_intruments_tab) |
sigc::mem_fun(*this, &MainWindow::show_intruments_tab) |
208 |
); |
); |
209 |
actionGroup->add( |
actionGroup->add( |
210 |
Gtk::Action::create("MenuScript", _("S_cript")), |
Gtk::Action::create("MenuScript", _("Scr_ipt")), |
211 |
sigc::mem_fun(*this, &MainWindow::show_scripts_tab) |
sigc::mem_fun(*this, &MainWindow::show_scripts_tab) |
212 |
); |
); |
213 |
actionGroup->add(Gtk::Action::create("AllInstruments", _("_Select"))); |
actionGroup->add(Gtk::Action::create("AllInstruments", _("_Select"))); |
214 |
|
|
215 |
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); |
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); |
216 |
|
|
217 |
|
const Gdk::ModifierType primaryModifierKey = |
218 |
|
#if defined(__APPLE__) |
219 |
|
Gdk::META_MASK; // Cmd key on Mac |
220 |
|
#else |
221 |
|
Gdk::CONTROL_MASK; // Ctrl key on all other OSs |
222 |
|
#endif |
223 |
|
|
224 |
|
actionGroup->add(Gtk::Action::create("CopyDimRgn", |
225 |
|
_("Copy selected dimension region")), |
226 |
|
Gtk::AccelKey(GDK_KEY_c, Gdk::MOD1_MASK), |
227 |
|
sigc::mem_fun(*this, &MainWindow::copy_selected_dimrgn)); |
228 |
|
|
229 |
|
actionGroup->add(Gtk::Action::create("PasteDimRgn", |
230 |
|
_("Paste dimension region")), |
231 |
|
Gtk::AccelKey(GDK_KEY_v, Gdk::MOD1_MASK), |
232 |
|
sigc::mem_fun(*this, &MainWindow::paste_copied_dimrgn)); |
233 |
|
|
234 |
|
actionGroup->add(Gtk::Action::create("AdjustClipboard", |
235 |
|
_("Adjust Clipboard Content")), |
236 |
|
Gtk::AccelKey(GDK_KEY_x, Gdk::MOD1_MASK), |
237 |
|
sigc::mem_fun(*this, &MainWindow::adjust_clipboard_content)); |
238 |
|
|
239 |
|
actionGroup->add(Gtk::Action::create("SelectPrevRegion", |
240 |
|
_("Select Previous Region")), |
241 |
|
Gtk::AccelKey(GDK_KEY_Left, primaryModifierKey), |
242 |
|
sigc::mem_fun(*this, &MainWindow::select_prev_region)); |
243 |
|
|
244 |
|
actionGroup->add(Gtk::Action::create("SelectNextRegion", |
245 |
|
_("Select Next Region")), |
246 |
|
Gtk::AccelKey(GDK_KEY_Right, primaryModifierKey), |
247 |
|
sigc::mem_fun(*this, &MainWindow::select_next_region)); |
248 |
|
|
249 |
|
actionGroup->add(Gtk::Action::create("SelectPrevDimRgnZone", |
250 |
|
_("Select Previous Dimension Region Zone")), |
251 |
|
Gtk::AccelKey(GDK_KEY_Left, Gdk::MOD1_MASK), |
252 |
|
sigc::mem_fun(*this, &MainWindow::select_prev_dim_rgn_zone)); |
253 |
|
|
254 |
|
actionGroup->add(Gtk::Action::create("SelectNextDimRgnZone", |
255 |
|
_("Select Next Dimension Region Zone")), |
256 |
|
Gtk::AccelKey(GDK_KEY_Right, Gdk::MOD1_MASK), |
257 |
|
sigc::mem_fun(*this, &MainWindow::select_next_dim_rgn_zone)); |
258 |
|
|
259 |
|
actionGroup->add(Gtk::Action::create("SelectPrevDimension", |
260 |
|
_("Select Previous Dimension")), |
261 |
|
Gtk::AccelKey(GDK_KEY_Up, Gdk::MOD1_MASK), |
262 |
|
sigc::mem_fun(*this, &MainWindow::select_prev_dimension)); |
263 |
|
|
264 |
|
actionGroup->add(Gtk::Action::create("SelectNextDimension", |
265 |
|
_("Select Next Dimension")), |
266 |
|
Gtk::AccelKey(GDK_KEY_Down, Gdk::MOD1_MASK), |
267 |
|
sigc::mem_fun(*this, &MainWindow::select_next_dimension)); |
268 |
|
|
269 |
|
actionGroup->add(Gtk::Action::create("SelectAddPrevDimRgnZone", |
270 |
|
_("Add Previous Dimension Region Zone to Selection")), |
271 |
|
Gtk::AccelKey(GDK_KEY_Left, Gdk::MOD1_MASK | Gdk::SHIFT_MASK), |
272 |
|
sigc::mem_fun(*this, &MainWindow::select_add_prev_dim_rgn_zone)); |
273 |
|
|
274 |
|
actionGroup->add(Gtk::Action::create("SelectAddNextDimRgnZone", |
275 |
|
_("Add Next Dimension Region Zone to Selection")), |
276 |
|
Gtk::AccelKey(GDK_KEY_Right, Gdk::MOD1_MASK | Gdk::SHIFT_MASK), |
277 |
|
sigc::mem_fun(*this, &MainWindow::select_add_next_dim_rgn_zone)); |
278 |
|
|
279 |
Glib::RefPtr<Gtk::ToggleAction> toggle_action = |
Glib::RefPtr<Gtk::ToggleAction> toggle_action = |
280 |
Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note")); |
Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note")); |
281 |
toggle_action->set_active(true); |
toggle_action->set_active(true); |
292 |
actionGroup->add(toggle_action); |
actionGroup->add(toggle_action); |
293 |
|
|
294 |
|
|
295 |
actionGroup->add(Gtk::Action::create("MenuView", _("_View"))); |
actionGroup->add(Gtk::Action::create("MenuMacro", _("_Macro"))); |
296 |
|
|
297 |
|
|
298 |
|
actionGroup->add(Gtk::Action::create("MenuView", _("Vie_w"))); |
299 |
toggle_action = |
toggle_action = |
300 |
Gtk::ToggleAction::create("Statusbar", _("_Statusbar")); |
Gtk::ToggleAction::create("Statusbar", _("_Statusbar")); |
301 |
toggle_action->set_active(true); |
toggle_action->set_active(true); |
303 |
sigc::mem_fun( |
sigc::mem_fun( |
304 |
*this, &MainWindow::on_action_view_status_bar)); |
*this, &MainWindow::on_action_view_status_bar)); |
305 |
|
|
306 |
|
toggle_action = |
307 |
|
Gtk::ToggleAction::create("AutoRestoreWinDim", _("_Auto Restore Window Dimension")); |
308 |
|
toggle_action->set_active(Settings::singleton()->autoRestoreWindowDimension); |
309 |
|
actionGroup->add(toggle_action, |
310 |
|
sigc::mem_fun( |
311 |
|
*this, &MainWindow::on_auto_restore_win_dim)); |
312 |
|
|
313 |
|
toggle_action = |
314 |
|
Gtk::ToggleAction::create("SaveWithTemporaryFile", _("Save with _temporary file")); |
315 |
|
toggle_action->set_active(Settings::singleton()->saveWithTemporaryFile); |
316 |
|
actionGroup->add(toggle_action, |
317 |
|
sigc::mem_fun( |
318 |
|
*this, &MainWindow::on_save_with_temporary_file)); |
319 |
|
|
320 |
|
actionGroup->add( |
321 |
|
Gtk::Action::create("RefreshAll", _("_Refresh All")), |
322 |
|
sigc::mem_fun(*this, &MainWindow::on_action_refresh_all) |
323 |
|
); |
324 |
|
|
325 |
action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP); |
action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP); |
326 |
actionGroup->add(Gtk::Action::create("MenuHelp", |
actionGroup->add(Gtk::Action::create("MenuHelp", |
327 |
action->property_label())); |
action->property_label())); |
352 |
sigc::mem_fun(*this, &MainWindow::on_action_warn_user_on_extensions) |
sigc::mem_fun(*this, &MainWindow::on_action_warn_user_on_extensions) |
353 |
); |
); |
354 |
|
|
355 |
|
toggle_action = |
356 |
|
Gtk::ToggleAction::create("SyncSamplerInstrumentSelection", _("Synchronize sampler's instrument selection")); |
357 |
|
toggle_action->set_active(Settings::singleton()->syncSamplerInstrumentSelection); |
358 |
|
actionGroup->add( |
359 |
|
toggle_action, |
360 |
|
sigc::mem_fun(*this, &MainWindow::on_action_sync_sampler_instrument_selection) |
361 |
|
); |
362 |
|
|
363 |
|
toggle_action = |
364 |
|
Gtk::ToggleAction::create("MoveRootNoteWithRegionMoved", _("Move root note with region moved")); |
365 |
|
toggle_action->set_active(Settings::singleton()->moveRootNoteWithRegionMoved); |
366 |
|
actionGroup->add( |
367 |
|
toggle_action, |
368 |
|
sigc::mem_fun(*this, &MainWindow::on_action_move_root_note_with_region_moved) |
369 |
|
); |
370 |
|
|
371 |
|
|
372 |
actionGroup->add(Gtk::Action::create("MenuTools", _("_Tools"))); |
actionGroup->add(Gtk::Action::create("MenuTools", _("_Tools"))); |
373 |
|
|
400 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_sample) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_sample) |
401 |
); |
); |
402 |
actionGroup->add( |
actionGroup->add( |
403 |
|
Gtk::Action::create("RemoveUnusedSamples", _("Remove _Unused Samples")), |
404 |
|
sigc::mem_fun(*this, &MainWindow::on_action_remove_unused_samples) |
405 |
|
); |
406 |
|
actionGroup->add( |
407 |
Gtk::Action::create("ShowSampleRefs", _("Show References...")), |
Gtk::Action::create("ShowSampleRefs", _("Show References...")), |
408 |
sigc::mem_fun(*this, &MainWindow::on_action_view_references) |
sigc::mem_fun(*this, &MainWindow::on_action_view_references) |
409 |
); |
); |
410 |
actionGroup->add( |
actionGroup->add( |
411 |
|
Gtk::Action::create("ReplaceSample", |
412 |
|
_("Replace Sample...")), |
413 |
|
sigc::mem_fun(*this, &MainWindow::on_action_replace_sample) |
414 |
|
); |
415 |
|
actionGroup->add( |
416 |
Gtk::Action::create("ReplaceAllSamplesInAllGroups", |
Gtk::Action::create("ReplaceAllSamplesInAllGroups", |
417 |
_("Replace All Samples in All Groups...")), |
_("Replace All Samples in All Groups...")), |
418 |
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) |
455 |
" <menuitem action='Quit'/>" |
" <menuitem action='Quit'/>" |
456 |
" </menu>" |
" </menu>" |
457 |
" <menu action='MenuEdit'>" |
" <menu action='MenuEdit'>" |
458 |
|
" <menuitem action='CopyDimRgn'/>" |
459 |
|
" <menuitem action='AdjustClipboard'/>" |
460 |
|
" <menuitem action='PasteDimRgn'/>" |
461 |
|
" <separator/>" |
462 |
|
" <menuitem action='SelectPrevRegion'/>" |
463 |
|
" <menuitem action='SelectNextRegion'/>" |
464 |
|
" <separator/>" |
465 |
|
" <menuitem action='SelectPrevDimension'/>" |
466 |
|
" <menuitem action='SelectNextDimension'/>" |
467 |
|
" <menuitem action='SelectPrevDimRgnZone'/>" |
468 |
|
" <menuitem action='SelectNextDimRgnZone'/>" |
469 |
|
" <menuitem action='SelectAddPrevDimRgnZone'/>" |
470 |
|
" <menuitem action='SelectAddNextDimRgnZone'/>" |
471 |
|
" <separator/>" |
472 |
" <menuitem action='CopySampleUnity'/>" |
" <menuitem action='CopySampleUnity'/>" |
473 |
" <menuitem action='CopySampleTune'/>" |
" <menuitem action='CopySampleTune'/>" |
474 |
" <menuitem action='CopySampleLoop'/>" |
" <menuitem action='CopySampleLoop'/>" |
475 |
" </menu>" |
" </menu>" |
476 |
|
" <menu action='MenuMacro'>" |
477 |
|
" </menu>" |
478 |
" <menu action='MenuSample'>" |
" <menu action='MenuSample'>" |
479 |
" <menuitem action='SampleProperties'/>" |
" <menuitem action='SampleProperties'/>" |
480 |
" <menuitem action='AddGroup'/>" |
" <menuitem action='AddGroup'/>" |
481 |
" <menuitem action='AddSample'/>" |
" <menuitem action='AddSample'/>" |
482 |
" <menuitem action='ShowSampleRefs'/>" |
" <menuitem action='ShowSampleRefs'/>" |
483 |
|
" <menuitem action='ReplaceSample' />" |
484 |
" <menuitem action='ReplaceAllSamplesInAllGroups' />" |
" <menuitem action='ReplaceAllSamplesInAllGroups' />" |
485 |
" <separator/>" |
" <separator/>" |
486 |
" <menuitem action='RemoveSample'/>" |
" <menuitem action='RemoveSample'/>" |
487 |
|
" <menuitem action='RemoveUnusedSamples'/>" |
488 |
" </menu>" |
" </menu>" |
489 |
" <menu action='MenuInstrument'>" |
" <menu action='MenuInstrument'>" |
490 |
" <menu action='AllInstruments'>" |
" <menu action='AllInstruments'>" |
507 |
" </menu>" |
" </menu>" |
508 |
" <menu action='MenuView'>" |
" <menu action='MenuView'>" |
509 |
" <menuitem action='Statusbar'/>" |
" <menuitem action='Statusbar'/>" |
510 |
|
" <menuitem action='AutoRestoreWinDim'/>" |
511 |
|
" <separator/>" |
512 |
|
" <menuitem action='RefreshAll'/>" |
513 |
" </menu>" |
" </menu>" |
514 |
" <menu action='MenuTools'>" |
" <menu action='MenuTools'>" |
515 |
" <menuitem action='CombineInstruments'/>" |
" <menuitem action='CombineInstruments'/>" |
517 |
" </menu>" |
" </menu>" |
518 |
" <menu action='MenuSettings'>" |
" <menu action='MenuSettings'>" |
519 |
" <menuitem action='WarnUserOnExtensions'/>" |
" <menuitem action='WarnUserOnExtensions'/>" |
520 |
|
" <menuitem action='SyncSamplerInstrumentSelection'/>" |
521 |
|
" <menuitem action='MoveRootNoteWithRegionMoved'/>" |
522 |
|
" <menuitem action='SaveWithTemporaryFile'/>" |
523 |
" </menu>" |
" </menu>" |
524 |
" <menu action='MenuHelp'>" |
" <menu action='MenuHelp'>" |
525 |
" <menuitem action='About'/>" |
" <menuitem action='About'/>" |
539 |
" <menuitem action='AddGroup'/>" |
" <menuitem action='AddGroup'/>" |
540 |
" <menuitem action='AddSample'/>" |
" <menuitem action='AddSample'/>" |
541 |
" <menuitem action='ShowSampleRefs'/>" |
" <menuitem action='ShowSampleRefs'/>" |
542 |
|
" <menuitem action='ReplaceSample' />" |
543 |
" <menuitem action='ReplaceAllSamplesInAllGroups' />" |
" <menuitem action='ReplaceAllSamplesInAllGroups' />" |
544 |
" <separator/>" |
" <separator/>" |
545 |
" <menuitem action='RemoveSample'/>" |
" <menuitem action='RemoveSample'/>" |
546 |
|
" <menuitem action='RemoveUnusedSamples'/>" |
547 |
" </popup>" |
" </popup>" |
548 |
" <popup name='ScriptPopupMenu'>" |
" <popup name='ScriptPopupMenu'>" |
549 |
" <menuitem action='AddScriptGroup'/>" |
" <menuitem action='AddScriptGroup'/>" |
583 |
} |
} |
584 |
{ |
{ |
585 |
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
586 |
|
uiManager->get_widget("/MenuBar/MenuSettings/SyncSamplerInstrumentSelection")); |
587 |
|
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).")); |
588 |
|
} |
589 |
|
{ |
590 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
591 |
|
uiManager->get_widget("/MenuBar/MenuSettings/MoveRootNoteWithRegionMoved")); |
592 |
|
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.")); |
593 |
|
} |
594 |
|
{ |
595 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
596 |
|
uiManager->get_widget("/MenuBar/MenuSample/RemoveUnusedSamples")); |
597 |
|
item->set_tooltip_text(_("Removes all samples that are not referenced by any instrument (i.e. red ones).")); |
598 |
|
// copy tooltip to popup menu |
599 |
|
Gtk::MenuItem* item2 = dynamic_cast<Gtk::MenuItem*>( |
600 |
|
uiManager->get_widget("/SamplePopupMenu/RemoveUnusedSamples")); |
601 |
|
item2->set_tooltip_text(item->get_tooltip_text()); |
602 |
|
} |
603 |
|
{ |
604 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
605 |
|
uiManager->get_widget("/MenuBar/MenuView/RefreshAll")); |
606 |
|
item->set_tooltip_text(_("Reloads the currently open gig file and updates the entire graphical user interface.")); |
607 |
|
} |
608 |
|
{ |
609 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
610 |
|
uiManager->get_widget("/MenuBar/MenuView/AutoRestoreWinDim")); |
611 |
|
item->set_tooltip_text(_("If checked, size and position of all windows will be saved and automatically restored next time.")); |
612 |
|
} |
613 |
|
{ |
614 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
615 |
uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments")); |
uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments")); |
616 |
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.")); |
617 |
} |
} |
649 |
// Create the Tree model: |
// Create the Tree model: |
650 |
m_refTreeModel = Gtk::ListStore::create(m_Columns); |
m_refTreeModel = Gtk::ListStore::create(m_Columns); |
651 |
m_TreeView.set_model(m_refTreeModel); |
m_TreeView.set_model(m_refTreeModel); |
652 |
m_TreeView.set_tooltip_text(_("Right click here for actions on instruments & MIDI Rules.")); |
m_TreeView.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE); |
653 |
|
m_TreeView.set_tooltip_text(_("Right click here for actions on instruments & MIDI Rules. Drag & drop to change the order of instruments.")); |
654 |
instrument_name_connection = m_refTreeModel->signal_row_changed().connect( |
instrument_name_connection = m_refTreeModel->signal_row_changed().connect( |
655 |
sigc::mem_fun(*this, &MainWindow::instrument_name_changed) |
sigc::mem_fun(*this, &MainWindow::instrument_name_changed) |
656 |
); |
); |
657 |
|
|
658 |
// Add the TreeView's view columns: |
// Add the TreeView's view columns: |
659 |
m_TreeView.append_column_editable("Instrument", m_Columns.m_col_name); |
m_TreeView.append_column(_("Nr"), m_Columns.m_col_nr); |
660 |
m_TreeView.set_headers_visible(false); |
m_TreeView.append_column_editable(_("Instrument"), m_Columns.m_col_name); |
661 |
|
m_TreeView.append_column(_("Scripts"), m_Columns.m_col_scripts); |
662 |
|
m_TreeView.set_headers_visible(true); |
663 |
|
|
664 |
|
// establish drag&drop within the instrument tree view, allowing to reorder |
665 |
|
// the sequence of instruments within the gig file |
666 |
|
{ |
667 |
|
std::vector<Gtk::TargetEntry> drag_target_instrument; |
668 |
|
drag_target_instrument.push_back(Gtk::TargetEntry("gig::Instrument")); |
669 |
|
m_TreeView.drag_source_set(drag_target_instrument); |
670 |
|
m_TreeView.drag_dest_set(drag_target_instrument); |
671 |
|
m_TreeView.signal_drag_begin().connect( |
672 |
|
sigc::mem_fun(*this, &MainWindow::on_instruments_treeview_drag_begin) |
673 |
|
); |
674 |
|
m_TreeView.signal_drag_data_get().connect( |
675 |
|
sigc::mem_fun(*this, &MainWindow::on_instruments_treeview_drag_data_get) |
676 |
|
); |
677 |
|
m_TreeView.signal_drag_data_received().connect( |
678 |
|
sigc::mem_fun(*this, &MainWindow::on_instruments_treeview_drop_drag_data_received) |
679 |
|
); |
680 |
|
} |
681 |
|
|
682 |
// create samples treeview (including its data model) |
// create samples treeview (including its data model) |
683 |
m_refSamplesTreeModel = SamplesTreeStore::create(m_SamplesModel); |
m_refSamplesTreeModel = SamplesTreeStore::create(m_SamplesModel); |
684 |
m_TreeViewSamples.set_model(m_refSamplesTreeModel); |
m_TreeViewSamples.set_model(m_refSamplesTreeModel); |
685 |
|
m_TreeViewSamples.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE); |
686 |
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.")); |
687 |
// m_TreeViewSamples.set_reorderable(); |
// m_TreeViewSamples.set_reorderable(); |
688 |
m_TreeViewSamples.append_column_editable(_("Name"), m_SamplesModel.m_col_name); |
m_TreeViewSamples.append_column_editable(_("Name"), m_SamplesModel.m_col_name); |
726 |
m_TreeViewScripts.signal_button_press_event().connect_notify( |
m_TreeViewScripts.signal_button_press_event().connect_notify( |
727 |
sigc::mem_fun(*this, &MainWindow::on_script_treeview_button_release) |
sigc::mem_fun(*this, &MainWindow::on_script_treeview_button_release) |
728 |
); |
); |
729 |
//FIXME: why the heck does this double click signal_row_activated() only fired while CTRL key is pressed ? |
//FIXME: why the heck does this double click signal_row_activated() only fire while CTRL key is pressed ? |
730 |
m_TreeViewScripts.signal_row_activated().connect( |
m_TreeViewScripts.signal_row_activated().connect( |
731 |
sigc::mem_fun(*this, &MainWindow::script_double_clicked) |
sigc::mem_fun(*this, &MainWindow::script_double_clicked) |
732 |
); |
); |
763 |
sigc::hide(sigc::mem_fun(*this, &MainWindow::file_changed))); |
sigc::hide(sigc::mem_fun(*this, &MainWindow::file_changed))); |
764 |
m_RegionChooser.signal_instrument_changed().connect( |
m_RegionChooser.signal_instrument_changed().connect( |
765 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
766 |
|
m_RegionChooser.signal_instrument_changed().connect( |
767 |
|
sigc::mem_fun(*this, &MainWindow::region_changed)); |
768 |
m_DimRegionChooser.signal_region_changed().connect( |
m_DimRegionChooser.signal_region_changed().connect( |
769 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
770 |
instrumentProps.signal_changed().connect( |
instrumentProps.signal_changed().connect( |
787 |
sigc::mem_fun(*this, &MainWindow::on_samples_to_be_removed) |
sigc::mem_fun(*this, &MainWindow::on_samples_to_be_removed) |
788 |
); |
); |
789 |
|
|
790 |
|
dimreg_edit.signal_select_sample().connect( |
791 |
|
sigc::mem_fun(*this, &MainWindow::select_sample) |
792 |
|
); |
793 |
|
|
794 |
m_RegionChooser.signal_instrument_struct_to_be_changed().connect( |
m_RegionChooser.signal_instrument_struct_to_be_changed().connect( |
795 |
sigc::hide( |
sigc::hide( |
796 |
sigc::bind( |
sigc::bind( |
834 |
|
|
835 |
// select 'Instruments' tab by default |
// select 'Instruments' tab by default |
836 |
// (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) |
837 |
m_TreeViewNotebook.set_current_page(1); |
m_TreeViewNotebook.set_current_page(1); |
838 |
|
|
839 |
|
Gtk::Clipboard::get()->signal_owner_change().connect( |
840 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_owner_change) |
841 |
|
); |
842 |
|
updateClipboardPasteAvailable(); |
843 |
|
updateClipboardCopyAvailable(); |
844 |
|
|
845 |
|
// setup macros and their keyboard accelerators |
846 |
|
{ |
847 |
|
Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>( |
848 |
|
uiManager->get_widget("/MenuBar/MenuMacro") |
849 |
|
)->get_submenu(); |
850 |
|
|
851 |
|
const Gdk::ModifierType primaryModifierKey = |
852 |
|
#if defined(__APPLE__) |
853 |
|
Gdk::META_MASK; // Cmd key on Mac |
854 |
|
#else |
855 |
|
Gdk::CONTROL_MASK; // Ctrl key on all other OSs |
856 |
|
#endif |
857 |
|
|
858 |
|
const Gdk::ModifierType noModifier = (Gdk::ModifierType)0; |
859 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_0", GDK_KEY_F1, noModifier); |
860 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_1", GDK_KEY_F2, noModifier); |
861 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_2", GDK_KEY_F3, noModifier); |
862 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_3", GDK_KEY_F4, noModifier); |
863 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_4", GDK_KEY_F5, noModifier); |
864 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_5", GDK_KEY_F6, noModifier); |
865 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_6", GDK_KEY_F7, noModifier); |
866 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_7", GDK_KEY_F8, noModifier); |
867 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_8", GDK_KEY_F9, noModifier); |
868 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_9", GDK_KEY_F10, noModifier); |
869 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_10", GDK_KEY_F11, noModifier); |
870 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_11", GDK_KEY_F12, noModifier); |
871 |
|
Gtk::AccelMap::add_entry("<Macros>/SetupMacros", 'm', primaryModifierKey); |
872 |
|
|
873 |
|
Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group(); |
874 |
|
menuMacro->set_accel_group(accelGroup); |
875 |
|
|
876 |
|
updateMacroMenu(); |
877 |
|
} |
878 |
} |
} |
879 |
|
|
880 |
MainWindow::~MainWindow() |
MainWindow::~MainWindow() |
881 |
{ |
{ |
882 |
} |
} |
883 |
|
|
884 |
|
void MainWindow::updateMacroMenu() { |
885 |
|
Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>( |
886 |
|
uiManager->get_widget("/MenuBar/MenuMacro") |
887 |
|
)->get_submenu(); |
888 |
|
|
889 |
|
// remove all entries from "Macro" menu |
890 |
|
{ |
891 |
|
const std::vector<Gtk::Widget*> children = menuMacro->get_children(); |
892 |
|
for (int i = 0; i < children.size(); ++i) { |
893 |
|
Gtk::Widget* child = children[i]; |
894 |
|
menuMacro->remove(*child); |
895 |
|
delete child; |
896 |
|
} |
897 |
|
} |
898 |
|
|
899 |
|
// (re)load all macros from config file |
900 |
|
try { |
901 |
|
Settings::singleton()->loadMacros(m_macros); |
902 |
|
} catch (Serialization::Exception e) { |
903 |
|
std::cerr << "Exception while loading macros: " << e.Message << std::endl; |
904 |
|
} catch (...) { |
905 |
|
std::cerr << "Unknown exception while loading macros!" << std::endl; |
906 |
|
} |
907 |
|
|
908 |
|
// add all configured macros as menu items to the "Macro" menu |
909 |
|
for (int iMacro = 0; iMacro < m_macros.size(); ++iMacro) { |
910 |
|
const Serialization::Archive& macro = m_macros[iMacro]; |
911 |
|
std::string name = |
912 |
|
macro.name().empty() ? |
913 |
|
(std::string(_("Unnamed Macro")) + " " + ToString(iMacro+1)) : macro.name(); |
914 |
|
Gtk::MenuItem* item = new Gtk::MenuItem(name); |
915 |
|
item->signal_activate().connect( |
916 |
|
sigc::bind( |
917 |
|
sigc::mem_fun(*this, &MainWindow::onMacroSelected), iMacro |
918 |
|
) |
919 |
|
); |
920 |
|
menuMacro->append(*item); |
921 |
|
item->set_accel_path("<Macros>/macro_" + ToString(iMacro)); |
922 |
|
Glib::ustring comment = macro.comment(); |
923 |
|
if (!comment.empty()) |
924 |
|
item->set_tooltip_text(comment); |
925 |
|
} |
926 |
|
// if there are no macros configured at all, then show a dummy entry instead |
927 |
|
if (m_macros.empty()) { |
928 |
|
Gtk::MenuItem* item = new Gtk::MenuItem(_("No Macros")); |
929 |
|
item->set_sensitive(false); |
930 |
|
menuMacro->append(*item); |
931 |
|
} |
932 |
|
|
933 |
|
// add separator line to menu |
934 |
|
menuMacro->append(*new Gtk::SeparatorMenuItem); |
935 |
|
|
936 |
|
{ |
937 |
|
Gtk::MenuItem* item = new Gtk::MenuItem(_("Setup Macros ...")); |
938 |
|
item->signal_activate().connect( |
939 |
|
sigc::mem_fun(*this, &MainWindow::setupMacros) |
940 |
|
); |
941 |
|
menuMacro->append(*item); |
942 |
|
item->set_accel_path("<Macros>/SetupMacros"); |
943 |
|
} |
944 |
|
|
945 |
|
menuMacro->show_all_children(); |
946 |
|
} |
947 |
|
|
948 |
|
void MainWindow::onMacroSelected(int iMacro) { |
949 |
|
printf("onMacroSelected(%d)\n", iMacro); |
950 |
|
if (iMacro < 0 || iMacro >= m_macros.size()) return; |
951 |
|
Glib::ustring errorText; |
952 |
|
try { |
953 |
|
applyMacro(m_macros[iMacro]); |
954 |
|
} catch (Serialization::Exception e) { |
955 |
|
errorText = e.Message; |
956 |
|
} catch (...) { |
957 |
|
errorText = _("Unknown exception while applying macro"); |
958 |
|
} |
959 |
|
if (!errorText.empty()) { |
960 |
|
Glib::ustring txt = _("Applying macro failed:\n") + errorText; |
961 |
|
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
962 |
|
msg.run(); |
963 |
|
} |
964 |
|
} |
965 |
|
|
966 |
|
void MainWindow::setupMacros() { |
967 |
|
MacrosSetup* setup = new MacrosSetup(); |
968 |
|
gig::DimensionRegion* pDimRgn = m_DimRegionChooser.get_main_dimregion(); |
969 |
|
setup->setMacros(m_macros, &m_serializationArchive, pDimRgn); |
970 |
|
setup->signal_macros_changed().connect( |
971 |
|
sigc::mem_fun(*this, &MainWindow::onMacrosSetupChanged) |
972 |
|
); |
973 |
|
setup->show(); |
974 |
|
} |
975 |
|
|
976 |
|
void MainWindow::onMacrosSetupChanged(const std::vector<Serialization::Archive>& macros) { |
977 |
|
m_macros = macros; |
978 |
|
Settings::singleton()->saveMacros(m_macros); |
979 |
|
updateMacroMenu(); |
980 |
|
} |
981 |
|
|
982 |
bool MainWindow::on_delete_event(GdkEventAny* event) |
bool MainWindow::on_delete_event(GdkEventAny* event) |
983 |
{ |
{ |
984 |
return !file_is_shared && file_is_changed && !close_confirmation_dialog(); |
return !file_is_shared && file_is_changed && !close_confirmation_dialog(); |
998 |
gig::Instrument* MainWindow::get_instrument() |
gig::Instrument* MainWindow::get_instrument() |
999 |
{ |
{ |
1000 |
gig::Instrument* instrument = 0; |
gig::Instrument* instrument = 0; |
1001 |
Gtk::TreeModel::const_iterator it = |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
1002 |
m_TreeView.get_selection()->get_selected(); |
if (rows.empty()) return NULL; |
1003 |
|
Gtk::TreeModel::const_iterator it = m_refTreeModel->get_iter(rows[0]); |
1004 |
if (it) { |
if (it) { |
1005 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
1006 |
instrument = row[m_Columns.m_col_instr]; |
instrument = row[m_Columns.m_col_instr]; |
1043 |
add_region_to_dimregs(region, stereo, all_dimregs); |
add_region_to_dimregs(region, stereo, all_dimregs); |
1044 |
} |
} |
1045 |
} |
} |
1046 |
|
|
1047 |
|
m_RegionChooser.setModifyAllRegions(all_regions); |
1048 |
|
m_DimRegionChooser.setModifyAllRegions(all_regions); |
1049 |
|
m_DimRegionChooser.setModifyAllDimensionRegions(all_dimregs); |
1050 |
|
m_DimRegionChooser.setModifyBothChannels(stereo); |
1051 |
|
|
1052 |
|
updateClipboardCopyAvailable(); |
1053 |
} |
} |
1054 |
|
|
1055 |
void MainWindow::dimreg_all_dimregs_toggled() |
void MainWindow::dimreg_all_dimregs_toggled() |
1067 |
void MainWindow::on_sel_change() |
void MainWindow::on_sel_change() |
1068 |
{ |
{ |
1069 |
// select item in instrument menu |
// select item in instrument menu |
1070 |
Gtk::TreeModel::iterator it = m_TreeView.get_selection()->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
1071 |
if (it) { |
if (!rows.empty()) { |
1072 |
Gtk::TreePath path(it); |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
1073 |
int index = path[0]; |
if (it) { |
1074 |
const std::vector<Gtk::Widget*> children = |
Gtk::TreePath path(it); |
1075 |
instrument_menu->get_children(); |
int index = path[0]; |
1076 |
static_cast<Gtk::RadioMenuItem*>(children[index])->set_active(); |
const std::vector<Gtk::Widget*> children = |
1077 |
|
instrument_menu->get_children(); |
1078 |
|
static_cast<Gtk::RadioMenuItem*>(children[index])->set_active(); |
1079 |
|
} |
1080 |
} |
} |
1081 |
|
|
1082 |
m_RegionChooser.set_instrument(get_instrument()); |
m_RegionChooser.set_instrument(get_instrument()); |
1083 |
|
|
1084 |
|
if (Settings::singleton()->syncSamplerInstrumentSelection) { |
1085 |
|
switch_sampler_instrument_signal.emit(get_instrument()); |
1086 |
|
} |
1087 |
} |
} |
1088 |
|
|
1089 |
void loader_progress_callback(gig::progress_t* progress) |
void loader_progress_callback(gig::progress_t* progress) |
1101 |
progress_dispatcher(); |
progress_dispatcher(); |
1102 |
} |
} |
1103 |
|
|
1104 |
|
#if defined(WIN32) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) |
1105 |
|
// make sure stack is 16-byte aligned for SSE instructions |
1106 |
|
__attribute__((force_align_arg_pointer)) |
1107 |
|
#endif |
1108 |
void Loader::thread_function() |
void Loader::thread_function() |
1109 |
{ |
{ |
1110 |
printf("thread_function self=%x\n", Glib::Threads::Thread::self()); |
printf("thread_function self=%p\n", |
1111 |
|
static_cast<void*>(Glib::Threads::Thread::self())); |
1112 |
printf("Start %s\n", filename.c_str()); |
printf("Start %s\n", filename.c_str()); |
1113 |
try { |
try { |
1114 |
RIFF::File* riff = new RIFF::File(filename); |
RIFF::File* riff = new RIFF::File(filename); |
1130 |
} |
} |
1131 |
|
|
1132 |
Loader::Loader(const char* filename) |
Loader::Loader(const char* filename) |
1133 |
: filename(filename), thread(0), progress(0.f) |
: filename(filename), gig(0), thread(0), progress(0.f) |
1134 |
{ |
{ |
1135 |
} |
} |
1136 |
|
|
1141 |
#else |
#else |
1142 |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Loader::thread_function)); |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Loader::thread_function)); |
1143 |
#endif |
#endif |
1144 |
printf("launch thread=%x\n", thread); |
printf("launch thread=%p\n", static_cast<void*>(thread)); |
1145 |
} |
} |
1146 |
|
|
1147 |
float Loader::get_progress() |
float Loader::get_progress() |
1184 |
progress_dispatcher.emit(); |
progress_dispatcher.emit(); |
1185 |
} |
} |
1186 |
|
|
1187 |
|
#if defined(WIN32) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) |
1188 |
|
// make sure stack is 16-byte aligned for SSE instructions |
1189 |
|
__attribute__((force_align_arg_pointer)) |
1190 |
|
#endif |
1191 |
void Saver::thread_function() |
void Saver::thread_function() |
1192 |
{ |
{ |
1193 |
printf("thread_function self=%x\n", Glib::Threads::Thread::self()); |
printf("thread_function self=%p\n", |
1194 |
|
static_cast<void*>(Glib::Threads::Thread::self())); |
1195 |
printf("Start %s\n", filename.c_str()); |
printf("Start %s\n", filename.c_str()); |
1196 |
try { |
try { |
1197 |
gig::progress_t progress; |
gig::progress_t progress; |
1200 |
|
|
1201 |
// if no filename was provided, that means "save", if filename was provided means "save as" |
// if no filename was provided, that means "save", if filename was provided means "save as" |
1202 |
if (filename.empty()) { |
if (filename.empty()) { |
1203 |
gig->Save(&progress); |
if (!Settings::singleton()->saveWithTemporaryFile) { |
1204 |
|
// save directly over the existing .gig file |
1205 |
|
// (requires less disk space than solution below |
1206 |
|
// but may be slower) |
1207 |
|
gig->Save(&progress); |
1208 |
|
} else { |
1209 |
|
// save the file as separate temporary file first, |
1210 |
|
// then move the saved file over the old file |
1211 |
|
// (may result in performance speedup during save) |
1212 |
|
gig::String tmpname = filename + ".TMP"; |
1213 |
|
gig->Save(tmpname, &progress); |
1214 |
|
#if defined(WIN32) |
1215 |
|
if (!DeleteFile(filename.c_str())) { |
1216 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file)."); |
1217 |
|
} |
1218 |
|
#else // POSIX ... |
1219 |
|
if (unlink(filename.c_str())) { |
1220 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file): " + gig::String(strerror(errno))); |
1221 |
|
} |
1222 |
|
#endif |
1223 |
|
if (rename(tmpname.c_str(), filename.c_str())) { |
1224 |
|
#if defined(WIN32) |
1225 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file)."); |
1226 |
|
#else |
1227 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file): " + gig::String(strerror(errno))); |
1228 |
|
#endif |
1229 |
|
} |
1230 |
|
} |
1231 |
} else { |
} else { |
1232 |
gig->Save(filename, &progress); |
gig->Save(filename, &progress); |
1233 |
} |
} |
1255 |
#else |
#else |
1256 |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Saver::thread_function)); |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Saver::thread_function)); |
1257 |
#endif |
#endif |
1258 |
printf("launch thread=%x\n", thread); |
printf("launch thread=%p\n", static_cast<void*>(thread)); |
1259 |
} |
} |
1260 |
|
|
1261 |
float Saver::get_progress() |
float Saver::get_progress() |
1358 |
int response = dialog.run(); |
int response = dialog.run(); |
1359 |
dialog.hide(); |
dialog.hide(); |
1360 |
|
|
1361 |
|
// user decided to exit app without saving |
1362 |
|
if (response == Gtk::RESPONSE_NO) return true; |
1363 |
|
|
1364 |
|
// user cancelled dialog, thus don't close app |
1365 |
|
if (response == Gtk::RESPONSE_CANCEL) return false; |
1366 |
|
|
1367 |
// TODO: the following return valid is disabled and hard coded instead for |
// TODO: the following return valid is disabled and hard coded instead for |
1368 |
// now, due to the fact that saving with progress bar is now implemented |
// now, due to the fact that saving with progress bar is now implemented |
1369 |
// asynchronously, as a result the app does not close automatically anymore |
// asynchronously, as a result the app does not close automatically anymore |
1415 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
1416 |
std::string filename = dialog.get_filename(); |
std::string filename = dialog.get_filename(); |
1417 |
printf("filename=%s\n", filename.c_str()); |
printf("filename=%s\n", filename.c_str()); |
1418 |
printf("on_action_file_open self=%x\n", Glib::Threads::Thread::self()); |
printf("on_action_file_open self=%p\n", |
1419 |
|
static_cast<void*>(Glib::Threads::Thread::self())); |
1420 |
load_file(filename.c_str()); |
load_file(filename.c_str()); |
1421 |
current_gig_dir = Glib::path_get_dirname(filename); |
current_gig_dir = Glib::path_get_dirname(filename); |
1422 |
} |
} |
1486 |
void MainWindow::on_loader_finished() |
void MainWindow::on_loader_finished() |
1487 |
{ |
{ |
1488 |
printf("Loader finished!\n"); |
printf("Loader finished!\n"); |
1489 |
printf("on_loader_finished self=%x\n", Glib::Threads::Thread::self()); |
printf("on_loader_finished self=%p\n", |
1490 |
|
static_cast<void*>(Glib::Threads::Thread::self())); |
1491 |
load_gig(loader->gig, loader->filename.c_str()); |
load_gig(loader->gig, loader->filename.c_str()); |
1492 |
progress_dialog->hide(); |
progress_dialog->hide(); |
1493 |
} |
} |
1582 |
|
|
1583 |
file_structure_changed_signal.emit(this->file); |
file_structure_changed_signal.emit(this->file); |
1584 |
|
|
1585 |
load_gig(this->file, this->filename.c_str()); |
__refreshEntireGUI(); |
1586 |
progress_dialog->hide(); |
progress_dialog->hide(); |
1587 |
} |
} |
1588 |
|
|
1627 |
// show warning in the dialog |
// show warning in the dialog |
1628 |
Gtk::HBox descriptionArea; |
Gtk::HBox descriptionArea; |
1629 |
descriptionArea.set_spacing(15); |
descriptionArea.set_spacing(15); |
1630 |
Gtk::Image warningIcon(Gtk::Stock::DIALOG_WARNING, Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); |
Gtk::Image warningIcon; |
1631 |
|
warningIcon.set_from_icon_name("dialog-warning", |
1632 |
|
Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); |
1633 |
descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); |
descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); |
1634 |
#if GTKMM_MAJOR_VERSION < 3 |
#if GTKMM_MAJOR_VERSION < 3 |
1635 |
view::WrapLabel description; |
view::WrapLabel description; |
1681 |
void MainWindow::__import_queued_samples() { |
void MainWindow::__import_queued_samples() { |
1682 |
std::cout << "Starting sample import\n" << std::flush; |
std::cout << "Starting sample import\n" << std::flush; |
1683 |
Glib::ustring error_files; |
Glib::ustring error_files; |
1684 |
printf("Samples to import: %d\n", m_SampleImportQueue.size()); |
printf("Samples to import: %d\n", int(m_SampleImportQueue.size())); |
1685 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
for (std::map<gig::Sample*, SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
1686 |
iter != m_SampleImportQueue.end(); ) { |
iter != m_SampleImportQueue.end(); ) { |
1687 |
printf("Importing sample %s\n",(*iter).sample_path.c_str()); |
printf("Importing sample %s\n",iter->second.sample_path.c_str()); |
1688 |
SF_INFO info; |
SF_INFO info; |
1689 |
info.format = 0; |
info.format = 0; |
1690 |
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); |
1691 |
sf_command(hFile, SFC_SET_SCALE_FLOAT_INT_READ, 0, SF_TRUE); |
sf_command(hFile, SFC_SET_SCALE_FLOAT_INT_READ, 0, SF_TRUE); |
1692 |
try { |
try { |
1693 |
if (!hFile) throw std::string(_("could not open file")); |
if (!hFile) throw std::string(_("could not open file")); |
1710 |
throw std::string(_("format not supported")); // unsupported subformat (yet?) |
throw std::string(_("format not supported")); // unsupported subformat (yet?) |
1711 |
} |
} |
1712 |
|
|
1713 |
|
// reset write position for sample |
1714 |
|
iter->first->SetPos(0); |
1715 |
|
|
1716 |
const int bufsize = 10000; |
const int bufsize = 10000; |
1717 |
switch (bitdepth) { |
switch (bitdepth) { |
1718 |
case 16: { |
case 16: { |
1722 |
// libsndfile does the conversion for us (if needed) |
// libsndfile does the conversion for us (if needed) |
1723 |
int n = sf_readf_short(hFile, buffer, bufsize); |
int n = sf_readf_short(hFile, buffer, bufsize); |
1724 |
// write from buffer directly (physically) into .gig file |
// write from buffer directly (physically) into .gig file |
1725 |
iter->gig_sample->Write(buffer, n); |
iter->first->Write(buffer, n); |
1726 |
cnt -= n; |
cnt -= n; |
1727 |
} |
} |
1728 |
delete[] buffer; |
delete[] buffer; |
1742 |
dstbuf[j++] = srcbuf[i] >> 24; |
dstbuf[j++] = srcbuf[i] >> 24; |
1743 |
} |
} |
1744 |
// write from buffer directly (physically) into .gig file |
// write from buffer directly (physically) into .gig file |
1745 |
iter->gig_sample->Write(dstbuf, n); |
iter->first->Write(dstbuf, n); |
1746 |
cnt -= n; |
cnt -= n; |
1747 |
} |
} |
1748 |
delete[] srcbuf; |
delete[] srcbuf; |
1753 |
// cleanup |
// cleanup |
1754 |
sf_close(hFile); |
sf_close(hFile); |
1755 |
// let the sampler re-cache the sample if needed |
// let the sampler re-cache the sample if needed |
1756 |
sample_changed_signal.emit(iter->gig_sample); |
sample_changed_signal.emit(iter->first); |
1757 |
// on success we remove the sample from the import queue, |
// on success we remove the sample from the import queue, |
1758 |
// otherwise keep it, maybe it works the next time ? |
// otherwise keep it, maybe it works the next time ? |
1759 |
std::list<SampleImportItem>::iterator cur = iter; |
std::map<gig::Sample*, SampleImportItem>::iterator cur = iter; |
1760 |
++iter; |
++iter; |
1761 |
m_SampleImportQueue.erase(cur); |
m_SampleImportQueue.erase(cur); |
1762 |
} catch (std::string what) { |
} catch (std::string what) { |
1763 |
// remember the files that made trouble (and their cause) |
// remember the files that made trouble (and their cause) |
1764 |
if (!error_files.empty()) error_files += "\n"; |
if (!error_files.empty()) error_files += "\n"; |
1765 |
error_files += (*iter).sample_path += " (" + what + ")"; |
error_files += iter->second.sample_path += " (" + what + ")"; |
1766 |
++iter; |
++iter; |
1767 |
} |
} |
1768 |
} |
} |
1785 |
!Settings::singleton()->warnUserOnExtensions; |
!Settings::singleton()->warnUserOnExtensions; |
1786 |
} |
} |
1787 |
|
|
1788 |
|
void MainWindow::on_action_sync_sampler_instrument_selection() { |
1789 |
|
Settings::singleton()->syncSamplerInstrumentSelection = |
1790 |
|
!Settings::singleton()->syncSamplerInstrumentSelection; |
1791 |
|
} |
1792 |
|
|
1793 |
|
void MainWindow::on_action_move_root_note_with_region_moved() { |
1794 |
|
Settings::singleton()->moveRootNoteWithRegionMoved = |
1795 |
|
!Settings::singleton()->moveRootNoteWithRegionMoved; |
1796 |
|
} |
1797 |
|
|
1798 |
void MainWindow::on_action_help_about() |
void MainWindow::on_action_help_about() |
1799 |
{ |
{ |
1800 |
Gtk::AboutDialog dialog; |
Gtk::AboutDialog dialog; |
1804 |
dialog.set_name("Gigedit"); |
dialog.set_name("Gigedit"); |
1805 |
#endif |
#endif |
1806 |
dialog.set_version(VERSION); |
dialog.set_version(VERSION); |
1807 |
dialog.set_copyright("Copyright (C) 2006-2014 Andreas Persson"); |
dialog.set_copyright("Copyright (C) 2006-2017 Andreas Persson"); |
1808 |
const std::string sComment = |
const std::string sComment = |
1809 |
_("Built " __DATE__ "\nUsing ") + |
_("Built " __DATE__ "\nUsing ") + |
1810 |
::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" + |
::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" + |
1820 |
dialog.set_comments(sComment.c_str()); |
dialog.set_comments(sComment.c_str()); |
1821 |
dialog.set_website("http://www.linuxsampler.org"); |
dialog.set_website("http://www.linuxsampler.org"); |
1822 |
dialog.set_website_label("http://www.linuxsampler.org"); |
dialog.set_website_label("http://www.linuxsampler.org"); |
1823 |
|
dialog.set_position(Gtk::WIN_POS_CENTER); |
1824 |
dialog.run(); |
dialog.run(); |
1825 |
} |
} |
1826 |
|
|
1846 |
table(2, 1), |
table(2, 1), |
1847 |
m_file(NULL) |
m_file(NULL) |
1848 |
{ |
{ |
1849 |
|
if (!Settings::singleton()->autoRestoreWindowDimension) { |
1850 |
|
set_default_size(470, 390); |
1851 |
|
set_position(Gtk::WIN_POS_MOUSE); |
1852 |
|
} |
1853 |
|
|
1854 |
set_title(_("File Properties")); |
set_title(_("File Properties")); |
1855 |
eName.set_width_chars(50); |
eName.set_width_chars(50); |
1856 |
|
|
1985 |
eDimensionKeyRangeLow(_("Keyswitching range low")), |
eDimensionKeyRangeLow(_("Keyswitching range low")), |
1986 |
eDimensionKeyRangeHigh(_("Keyswitching range high")) |
eDimensionKeyRangeHigh(_("Keyswitching range high")) |
1987 |
{ |
{ |
1988 |
|
if (!Settings::singleton()->autoRestoreWindowDimension) { |
1989 |
|
//set_default_size(470, 390); |
1990 |
|
set_position(Gtk::WIN_POS_MOUSE); |
1991 |
|
} |
1992 |
|
|
1993 |
set_title(_("Instrument Properties")); |
set_title(_("Instrument Properties")); |
1994 |
|
|
1995 |
eDimensionKeyRangeLow.set_tip( |
eDimensionKeyRangeLow.set_tip( |
2098 |
file = 0; |
file = 0; |
2099 |
set_file_is_shared(isSharedInstrument); |
set_file_is_shared(isSharedInstrument); |
2100 |
|
|
2101 |
this->filename = filename ? filename : _("Unsaved Gig File"); |
this->filename = |
2102 |
|
(filename && strlen(filename) > 0) ? |
2103 |
|
filename : (!gig->GetFileName().empty()) ? |
2104 |
|
gig->GetFileName() : _("Unsaved Gig File"); |
2105 |
set_title(Glib::filename_display_basename(this->filename)); |
set_title(Glib::filename_display_basename(this->filename)); |
2106 |
file_has_name = filename; |
file_has_name = filename; |
2107 |
file_is_changed = false; |
file_is_changed = false; |
2110 |
propDialog.set_info(gig->pInfo); |
propDialog.set_info(gig->pInfo); |
2111 |
|
|
2112 |
instrument_name_connection.block(); |
instrument_name_connection.block(); |
2113 |
|
int index = 0; |
2114 |
for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ; |
for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ; |
2115 |
instrument = gig->GetNextInstrument()) { |
instrument = gig->GetNextInstrument(), ++index) { |
2116 |
Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
2117 |
|
const int iScriptSlots = instrument->ScriptSlotCount(); |
2118 |
|
|
2119 |
Gtk::TreeModel::iterator iter = m_refTreeModel->append(); |
Gtk::TreeModel::iterator iter = m_refTreeModel->append(); |
2120 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
2121 |
|
row[m_Columns.m_col_nr] = index; |
2122 |
row[m_Columns.m_col_name] = name; |
row[m_Columns.m_col_name] = name; |
2123 |
row[m_Columns.m_col_instr] = instrument; |
row[m_Columns.m_col_instr] = instrument; |
2124 |
|
row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; |
2125 |
|
|
2126 |
add_instrument_to_menu(name); |
add_instrument_to_menu(name); |
2127 |
} |
} |
2192 |
{ |
{ |
2193 |
instrumentProps.signal_name_changed().clear(); |
instrumentProps.signal_name_changed().clear(); |
2194 |
|
|
2195 |
Gtk::TreeModel::const_iterator it = |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
2196 |
m_TreeView.get_selection()->get_selected(); |
if (rows.empty()) { |
2197 |
|
instrumentProps.hide(); |
2198 |
|
return false; |
2199 |
|
} |
2200 |
|
Gtk::TreeModel::const_iterator it = m_refTreeModel->get_iter(rows[0]); |
2201 |
if (it) { |
if (it) { |
2202 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
2203 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
2250 |
void MainWindow::show_script_slots() { |
void MainWindow::show_script_slots() { |
2251 |
if (!file) return; |
if (!file) return; |
2252 |
// get selected instrument |
// get selected instrument |
2253 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
2254 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
if (rows.empty()) return; |
2255 |
|
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
2256 |
if (!it) return; |
if (!it) return; |
2257 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
2258 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
2260 |
|
|
2261 |
ScriptSlots* window = new ScriptSlots; |
ScriptSlots* window = new ScriptSlots; |
2262 |
window->setInstrument(instrument); |
window->setInstrument(instrument); |
2263 |
|
window->signal_script_slots_changed().connect( |
2264 |
|
sigc::mem_fun(*this, &MainWindow::onScriptSlotsModified) |
2265 |
|
); |
2266 |
//window->reparent(*this); |
//window->reparent(*this); |
2267 |
window->show(); |
window->show(); |
2268 |
} |
} |
2269 |
|
|
2270 |
|
void MainWindow::onScriptSlotsModified(gig::Instrument* pInstrument) { |
2271 |
|
if (!pInstrument) return; |
2272 |
|
const int iScriptSlots = pInstrument->ScriptSlotCount(); |
2273 |
|
|
2274 |
|
Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
2275 |
|
for (int i = 0; i < model->children().size(); ++i) { |
2276 |
|
Gtk::TreeModel::Row row = model->children()[i]; |
2277 |
|
if (row[m_Columns.m_col_instr] != pInstrument) continue; |
2278 |
|
row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; |
2279 |
|
break; |
2280 |
|
} |
2281 |
|
} |
2282 |
|
|
2283 |
|
void MainWindow::on_action_refresh_all() { |
2284 |
|
__refreshEntireGUI(); |
2285 |
|
} |
2286 |
|
|
2287 |
void MainWindow::on_action_view_status_bar() { |
void MainWindow::on_action_view_status_bar() { |
2288 |
Gtk::CheckMenuItem* item = |
Gtk::CheckMenuItem* item = |
2289 |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar")); |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar")); |
2295 |
else m_StatusBar.hide(); |
else m_StatusBar.hide(); |
2296 |
} |
} |
2297 |
|
|
2298 |
|
void MainWindow::on_auto_restore_win_dim() { |
2299 |
|
Gtk::CheckMenuItem* item = |
2300 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/AutoRestoreWinDim")); |
2301 |
|
if (!item) { |
2302 |
|
std::cerr << "/MenuBar/MenuView/AutoRestoreWinDim == NULL\n"; |
2303 |
|
return; |
2304 |
|
} |
2305 |
|
Settings::singleton()->autoRestoreWindowDimension = item->get_active(); |
2306 |
|
} |
2307 |
|
|
2308 |
|
void MainWindow::on_save_with_temporary_file() { |
2309 |
|
Gtk::CheckMenuItem* item = |
2310 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuSettings/SaveWithTemporaryFile")); |
2311 |
|
if (!item) { |
2312 |
|
std::cerr << "/MenuBar/MenuSettings/SaveWithTemporaryFile == NULL\n"; |
2313 |
|
return; |
2314 |
|
} |
2315 |
|
Settings::singleton()->saveWithTemporaryFile = item->get_active(); |
2316 |
|
} |
2317 |
|
|
2318 |
bool MainWindow::is_copy_samples_unity_note_enabled() const { |
bool MainWindow::is_copy_samples_unity_note_enabled() const { |
2319 |
Gtk::CheckMenuItem* item = |
Gtk::CheckMenuItem* item = |
2320 |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity")); |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity")); |
2379 |
} |
} |
2380 |
} |
} |
2381 |
|
|
2382 |
|
void MainWindow::select_instrument(gig::Instrument* instrument) { |
2383 |
|
if (!instrument) return; |
2384 |
|
|
2385 |
|
Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
2386 |
|
for (int i = 0; i < model->children().size(); ++i) { |
2387 |
|
Gtk::TreeModel::Row row = model->children()[i]; |
2388 |
|
if (row[m_Columns.m_col_instr] == instrument) { |
2389 |
|
// select and show the respective instrument in the list view |
2390 |
|
show_intruments_tab(); |
2391 |
|
m_TreeView.get_selection()->unselect_all(); |
2392 |
|
m_TreeView.get_selection()->select(model->children()[i]); |
2393 |
|
std::vector<Gtk::TreeModel::Path> rows = |
2394 |
|
m_TreeView.get_selection()->get_selected_rows(); |
2395 |
|
if (!rows.empty()) |
2396 |
|
m_TreeView.scroll_to_row(rows[0]); |
2397 |
|
on_sel_change(); // the regular instrument selection change callback |
2398 |
|
} |
2399 |
|
} |
2400 |
|
} |
2401 |
|
|
2402 |
|
/// Returns true if requested dimension region was successfully selected and scrolled to in the list view, false on error. |
2403 |
|
bool MainWindow::select_dimension_region(gig::DimensionRegion* dimRgn) { |
2404 |
|
gig::Region* pRegion = (gig::Region*) dimRgn->GetParent(); |
2405 |
|
gig::Instrument* pInstrument = (gig::Instrument*) pRegion->GetParent(); |
2406 |
|
|
2407 |
|
Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
2408 |
|
for (int i = 0; i < model->children().size(); ++i) { |
2409 |
|
Gtk::TreeModel::Row row = model->children()[i]; |
2410 |
|
if (row[m_Columns.m_col_instr] == pInstrument) { |
2411 |
|
// select and show the respective instrument in the list view |
2412 |
|
show_intruments_tab(); |
2413 |
|
m_TreeView.get_selection()->unselect_all(); |
2414 |
|
m_TreeView.get_selection()->select(model->children()[i]); |
2415 |
|
std::vector<Gtk::TreeModel::Path> rows = |
2416 |
|
m_TreeView.get_selection()->get_selected_rows(); |
2417 |
|
if (!rows.empty()) |
2418 |
|
m_TreeView.scroll_to_row(rows[0]); |
2419 |
|
on_sel_change(); // the regular instrument selection change callback |
2420 |
|
|
2421 |
|
// select respective region in the region selector |
2422 |
|
m_RegionChooser.set_region(pRegion); |
2423 |
|
|
2424 |
|
// select and show the respective dimension region in the editor |
2425 |
|
//update_dimregs(); |
2426 |
|
if (!m_DimRegionChooser.select_dimregion(dimRgn)) return false; |
2427 |
|
//dimreg_edit.set_dim_region(dimRgn); |
2428 |
|
|
2429 |
|
return true; |
2430 |
|
} |
2431 |
|
} |
2432 |
|
|
2433 |
|
return false; |
2434 |
|
} |
2435 |
|
|
2436 |
|
void MainWindow::select_sample(gig::Sample* sample) { |
2437 |
|
Glib::RefPtr<Gtk::TreeModel> model = m_TreeViewSamples.get_model(); |
2438 |
|
for (int g = 0; g < model->children().size(); ++g) { |
2439 |
|
Gtk::TreeModel::Row rowGroup = model->children()[g]; |
2440 |
|
for (int s = 0; s < rowGroup.children().size(); ++s) { |
2441 |
|
Gtk::TreeModel::Row rowSample = rowGroup.children()[s]; |
2442 |
|
if (rowSample[m_SamplesModel.m_col_sample] == sample) { |
2443 |
|
show_samples_tab(); |
2444 |
|
m_TreeViewSamples.get_selection()->unselect_all(); |
2445 |
|
m_TreeViewSamples.get_selection()->select(rowGroup.children()[s]); |
2446 |
|
std::vector<Gtk::TreeModel::Path> rows = |
2447 |
|
m_TreeViewSamples.get_selection()->get_selected_rows(); |
2448 |
|
if (rows.empty()) return; |
2449 |
|
m_TreeViewSamples.scroll_to_row(rows[0]); |
2450 |
|
return; |
2451 |
|
} |
2452 |
|
} |
2453 |
|
} |
2454 |
|
} |
2455 |
|
|
2456 |
void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) { |
void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) { |
2457 |
if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
2458 |
|
// by default if Ctrl keys is pressed down, then a mouse right-click |
2459 |
|
// does not select the respective row, so we must assure this |
2460 |
|
// programmatically ... |
2461 |
|
/*{ |
2462 |
|
Gtk::TreeModel::Path path; |
2463 |
|
Gtk::TreeViewColumn* pColumn = NULL; |
2464 |
|
int cellX, cellY; |
2465 |
|
bool bSuccess = m_TreeViewSamples.get_path_at_pos( |
2466 |
|
(int)button->x, (int)button->y, |
2467 |
|
path, pColumn, cellX, cellY |
2468 |
|
); |
2469 |
|
if (bSuccess) { |
2470 |
|
if (m_TreeViewSamples.get_selection()->count_selected_rows() <= 0) { |
2471 |
|
printf("not selected !!!\n"); |
2472 |
|
m_TreeViewSamples.get_selection()->select(path); |
2473 |
|
} |
2474 |
|
} |
2475 |
|
}*/ |
2476 |
|
|
2477 |
Gtk::Menu* sample_popup = |
Gtk::Menu* sample_popup = |
2478 |
dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/SamplePopupMenu")); |
dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/SamplePopupMenu")); |
2479 |
// update enabled/disabled state of sample popup items |
// update enabled/disabled state of sample popup items |
2480 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
2481 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
2482 |
bool group_selected = false; |
const int n = rows.size(); |
2483 |
bool sample_selected = false; |
int nGroups = 0; |
2484 |
if (it) { |
int nSamples = 0; |
2485 |
|
for (int r = 0; r < n; ++r) { |
2486 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[r]); |
2487 |
|
if (!it) continue; |
2488 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
2489 |
group_selected = row[m_SamplesModel.m_col_group]; |
if (row[m_SamplesModel.m_col_group]) nGroups++; |
2490 |
sample_selected = row[m_SamplesModel.m_col_sample]; |
if (row[m_SamplesModel.m_col_sample]) nSamples++; |
2491 |
} |
} |
2492 |
|
|
|
|
|
2493 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))-> |
2494 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n == 1); |
2495 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))-> |
2496 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n); |
2497 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddGroup"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddGroup"))-> |
2498 |
set_sensitive(file); |
set_sensitive(file); |
2499 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/ShowSampleRefs"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/ShowSampleRefs"))-> |
2500 |
set_sensitive(sample_selected); |
set_sensitive(nSamples == 1); |
2501 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))-> |
2502 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n); |
2503 |
// show sample popup |
// show sample popup |
2504 |
sample_popup->popup(button->button, button->time); |
sample_popup->popup(button->button, button->time); |
2505 |
|
|
2506 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/SampleProperties"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/SampleProperties"))-> |
2507 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n == 1); |
2508 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddSample"))-> |
2509 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n); |
2510 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddGroup"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddGroup"))-> |
2511 |
set_sensitive(file); |
set_sensitive(file); |
2512 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/ShowSampleRefs"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/ShowSampleRefs"))-> |
2513 |
set_sensitive(sample_selected); |
set_sensitive(nSamples == 1); |
2514 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/RemoveSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/RemoveSample"))-> |
2515 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n); |
2516 |
} |
} |
2517 |
} |
} |
2518 |
|
|
2591 |
instrument_name_connection.block(); |
instrument_name_connection.block(); |
2592 |
Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append(); |
Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append(); |
2593 |
Gtk::TreeModel::Row rowInstr = *iterInstr; |
Gtk::TreeModel::Row rowInstr = *iterInstr; |
2594 |
|
rowInstr[m_Columns.m_col_nr] = m_refTreeModel->children().size() - 1; |
2595 |
rowInstr[m_Columns.m_col_name] = name; |
rowInstr[m_Columns.m_col_name] = name; |
2596 |
rowInstr[m_Columns.m_col_instr] = instrument; |
rowInstr[m_Columns.m_col_instr] = instrument; |
2597 |
|
rowInstr[m_Columns.m_col_scripts] = ""; |
2598 |
instrument_name_connection.unblock(); |
instrument_name_connection.unblock(); |
2599 |
|
|
2600 |
add_instrument_to_menu(name); |
add_instrument_to_menu(name); |
2621 |
// retrieve the currently selected instrument |
// retrieve the currently selected instrument |
2622 |
// (being the original instrument to be duplicated) |
// (being the original instrument to be duplicated) |
2623 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
2624 |
Gtk::TreeModel::iterator itSelection = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
2625 |
if (!itSelection) return; |
for (int r = 0; r < rows.size(); ++r) { |
2626 |
Gtk::TreeModel::Row row = *itSelection; |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]); |
2627 |
gig::Instrument* instrOrig = row[m_Columns.m_col_instr]; |
if (it) { |
2628 |
if (!instrOrig) return; |
Gtk::TreeModel::Row row = *it; |
2629 |
|
gig::Instrument* instrOrig = row[m_Columns.m_col_instr]; |
2630 |
// duplicate the orginal instrument |
if (instrOrig) { |
2631 |
gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); |
// duplicate the orginal instrument |
2632 |
instrNew->pInfo->Name = |
gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); |
2633 |
instrOrig->pInfo->Name + |
instrNew->pInfo->Name = |
2634 |
gig_from_utf8(Glib::ustring(" (") + _("Copy") + ")"); |
instrOrig->pInfo->Name + |
2635 |
|
gig_from_utf8(Glib::ustring(" (") + _("Copy") + ")"); |
2636 |
|
|
2637 |
add_instrument(instrNew); |
add_instrument(instrNew); |
2638 |
|
} |
2639 |
|
} |
2640 |
|
} |
2641 |
} |
} |
2642 |
|
|
2643 |
void MainWindow::on_action_remove_instrument() { |
void MainWindow::on_action_remove_instrument() { |
2654 |
} |
} |
2655 |
|
|
2656 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
2657 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
2658 |
if (it) { |
for (int r = rows.size() - 1; r >= 0; --r) { |
2659 |
|
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]); |
2660 |
|
if (!it) continue; |
2661 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
2662 |
gig::Instrument* instr = row[m_Columns.m_col_instr]; |
gig::Instrument* instr = row[m_Columns.m_col_instr]; |
2663 |
try { |
try { |
2672 |
|
|
2673 |
// remove row from instruments tree view |
// remove row from instruments tree view |
2674 |
m_refTreeModel->erase(it); |
m_refTreeModel->erase(it); |
2675 |
|
// update "Nr" column of all instrument rows |
2676 |
|
{ |
2677 |
|
int index = 0; |
2678 |
|
for (Gtk::TreeModel::iterator it = m_refTreeModel->children().begin(); |
2679 |
|
it != m_refTreeModel->children().end(); ++it, ++index) |
2680 |
|
{ |
2681 |
|
Gtk::TreeModel::Row row = *it; |
2682 |
|
row[m_Columns.m_col_nr] = index; |
2683 |
|
} |
2684 |
|
} |
2685 |
|
|
2686 |
#if GTKMM_MAJOR_VERSION < 3 |
#if GTKMM_MAJOR_VERSION < 3 |
2687 |
// select another instrument (in gtk3 this is done |
// select another instrument (in gtk3 this is done |
2779 |
if (!script) return; |
if (!script) return; |
2780 |
|
|
2781 |
ScriptEditor* editor = new ScriptEditor; |
ScriptEditor* editor = new ScriptEditor; |
2782 |
|
editor->signal_script_to_be_changed.connect( |
2783 |
|
signal_script_to_be_changed.make_slot() |
2784 |
|
); |
2785 |
|
editor->signal_script_changed.connect( |
2786 |
|
signal_script_changed.make_slot() |
2787 |
|
); |
2788 |
editor->setScript(script); |
editor->setScript(script); |
2789 |
//editor->reparent(*this); |
//editor->reparent(*this); |
2790 |
editor->show(); |
editor->show(); |
2850 |
file_changed(); |
file_changed(); |
2851 |
} |
} |
2852 |
|
|
2853 |
|
void MainWindow::on_action_replace_sample() { |
2854 |
|
add_or_replace_sample(true); |
2855 |
|
} |
2856 |
|
|
2857 |
void MainWindow::on_action_add_sample() { |
void MainWindow::on_action_add_sample() { |
2858 |
|
add_or_replace_sample(false); |
2859 |
|
} |
2860 |
|
|
2861 |
|
void MainWindow::add_or_replace_sample(bool replace) { |
2862 |
if (!file) return; |
if (!file) return; |
2863 |
// get selected group |
|
2864 |
|
// get selected group (and probably selected sample) |
2865 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
2866 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
2867 |
|
if (rows.empty()) return; |
2868 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]); |
2869 |
if (!it) return; |
if (!it) return; |
2870 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
2871 |
|
gig::Sample* sample = NULL; |
2872 |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
2873 |
if (!group) { // not a group, but a sample is selected (probably) |
if (!group) { // not a group, but a sample is selected (probably) |
2874 |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
if (replace) sample = row[m_SamplesModel.m_col_sample]; |
2875 |
if (!sample) return; |
if (!row[m_SamplesModel.m_col_sample]) return; |
2876 |
it = row.parent(); // resolve parent (that is the sample's group) |
it = row.parent(); // resolve parent (that is the sample's group) |
2877 |
if (!it) return; |
if (!it) return; |
2878 |
row = *it; |
if (!replace) row = *it; |
2879 |
group = row[m_SamplesModel.m_col_group]; |
group = (*it)[m_SamplesModel.m_col_group]; |
2880 |
if (!group) return; |
if (!group) return; |
2881 |
} |
} |
2882 |
|
if (replace && !sample) return; |
2883 |
|
|
2884 |
// show 'browse for file' dialog |
// show 'browse for file' dialog |
2885 |
Gtk::FileChooserDialog dialog(*this, _("Add Sample(s)")); |
Gtk::FileChooserDialog dialog(*this, replace ? _("Replace Sample with") : _("Add Sample(s)")); |
2886 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
2887 |
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); |
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); |
2888 |
dialog.set_select_multiple(true); |
dialog.set_select_multiple(!replace); // allow multi audio file selection only when adding new samples, does not make sense when replacing a specific sample |
2889 |
|
|
2890 |
// matches all file types supported by libsndfile |
// matches all file types supported by libsndfile |
2891 |
#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 |
2956 |
sf_close(hFile); // close sound file |
sf_close(hFile); // close sound file |
2957 |
throw std::string(_("format not supported")); // unsupported subformat (yet?) |
throw std::string(_("format not supported")); // unsupported subformat (yet?) |
2958 |
} |
} |
2959 |
// add a new sample to the .gig file |
// add a new sample to the .gig file (if adding is requested actually) |
2960 |
gig::Sample* sample = file->AddSample(); |
if (!replace) sample = file->AddSample(); |
2961 |
// file name without path |
// file name without path |
2962 |
Glib::ustring filename = Glib::filename_display_basename(*iter); |
Glib::ustring filename = Glib::filename_display_basename(*iter); |
2963 |
// remove file extension if there is one |
// remove file extension if there is one |
3008 |
// physically when File::Save() is called) |
// physically when File::Save() is called) |
3009 |
sample->Resize(info.frames); |
sample->Resize(info.frames); |
3010 |
// make sure sample is part of the selected group |
// make sure sample is part of the selected group |
3011 |
group->AddSample(sample); |
if (!replace) group->AddSample(sample); |
3012 |
// schedule that physical resize and sample import |
// schedule that physical resize and sample import |
3013 |
// (data copying), performed when "Save" is requested |
// (data copying), performed when "Save" is requested |
3014 |
SampleImportItem sched_item; |
SampleImportItem sched_item; |
3015 |
sched_item.gig_sample = sample; |
sched_item.gig_sample = sample; |
3016 |
sched_item.sample_path = *iter; |
sched_item.sample_path = *iter; |
3017 |
m_SampleImportQueue.push_back(sched_item); |
m_SampleImportQueue[sample] = sched_item; |
3018 |
// add sample to the tree view |
// add sample to the tree view |
3019 |
Gtk::TreeModel::iterator iterSample = |
if (replace) { |
3020 |
m_refSamplesTreeModel->append(row.children()); |
row[m_SamplesModel.m_col_name] = gig_to_utf8(sample->pInfo->Name); |
3021 |
Gtk::TreeModel::Row rowSample = *iterSample; |
} else { |
3022 |
rowSample[m_SamplesModel.m_col_name] = |
Gtk::TreeModel::iterator iterSample = |
3023 |
gig_to_utf8(sample->pInfo->Name); |
m_refSamplesTreeModel->append(row.children()); |
3024 |
rowSample[m_SamplesModel.m_col_sample] = sample; |
Gtk::TreeModel::Row rowSample = *iterSample; |
3025 |
rowSample[m_SamplesModel.m_col_group] = NULL; |
rowSample[m_SamplesModel.m_col_name] = |
3026 |
|
gig_to_utf8(sample->pInfo->Name); |
3027 |
|
rowSample[m_SamplesModel.m_col_sample] = sample; |
3028 |
|
rowSample[m_SamplesModel.m_col_group] = NULL; |
3029 |
|
} |
3030 |
// close sound file |
// close sound file |
3031 |
sf_close(hFile); |
sf_close(hFile); |
3032 |
file_changed(); |
file_changed(); |
3037 |
} |
} |
3038 |
// 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 |
3039 |
if (!error_files.empty()) { |
if (!error_files.empty()) { |
3040 |
Glib::ustring txt = _("Could not add the following sample(s):\n") + error_files; |
Glib::ustring txt = |
3041 |
|
(replace |
3042 |
|
? _("Failed to replace sample with:\n") |
3043 |
|
: _("Could not add the following sample(s):\n")) |
3044 |
|
+ error_files; |
3045 |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
3046 |
msg.run(); |
msg.run(); |
3047 |
} |
} |
3108 |
try |
try |
3109 |
{ |
{ |
3110 |
if (!hFile) throw std::string(_("could not open file")); |
if (!hFile) throw std::string(_("could not open file")); |
|
int bitdepth; |
|
3111 |
switch (info.format & 0xff) { |
switch (info.format & 0xff) { |
3112 |
case SF_FORMAT_PCM_S8: |
case SF_FORMAT_PCM_S8: |
3113 |
case SF_FORMAT_PCM_16: |
case SF_FORMAT_PCM_16: |
3114 |
case SF_FORMAT_PCM_U8: |
case SF_FORMAT_PCM_U8: |
|
bitdepth = 16; |
|
|
break; |
|
3115 |
case SF_FORMAT_PCM_24: |
case SF_FORMAT_PCM_24: |
3116 |
case SF_FORMAT_PCM_32: |
case SF_FORMAT_PCM_32: |
3117 |
case SF_FORMAT_FLOAT: |
case SF_FORMAT_FLOAT: |
3118 |
case SF_FORMAT_DOUBLE: |
case SF_FORMAT_DOUBLE: |
|
bitdepth = 24; |
|
3119 |
break; |
break; |
3120 |
default: |
default: |
3121 |
sf_close(hFile); |
sf_close(hFile); |
3124 |
SampleImportItem sched_item; |
SampleImportItem sched_item; |
3125 |
sched_item.gig_sample = sample; |
sched_item.gig_sample = sample; |
3126 |
sched_item.sample_path = filename; |
sched_item.sample_path = filename; |
3127 |
m_SampleImportQueue.push_back(sched_item); |
m_SampleImportQueue[sample] = sched_item; |
3128 |
sf_close(hFile); |
sf_close(hFile); |
3129 |
file_changed(); |
file_changed(); |
3130 |
} |
} |
3148 |
void MainWindow::on_action_remove_sample() { |
void MainWindow::on_action_remove_sample() { |
3149 |
if (!file) return; |
if (!file) return; |
3150 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
3151 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
3152 |
if (it) { |
for (int r = rows.size() - 1; r >= 0; --r) { |
3153 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[r]); |
3154 |
|
if (!it) continue; |
3155 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
3156 |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
3157 |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
3176 |
// if sample(s) were just previously added, remove |
// if sample(s) were just previously added, remove |
3177 |
// them from the import queue |
// them from the import queue |
3178 |
for (std::list<gig::Sample*>::iterator member = members.begin(); |
for (std::list<gig::Sample*>::iterator member = members.begin(); |
3179 |
member != members.end(); ++member) { |
member != members.end(); ++member) |
3180 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
{ |
3181 |
iter != m_SampleImportQueue.end(); ++iter) { |
if (m_SampleImportQueue.count(*member)) { |
3182 |
if ((*iter).gig_sample == *member) { |
printf("Removing previously added sample '%s' from group '%s'\n", |
3183 |
printf("Removing previously added sample '%s' from group '%s'\n", |
m_SampleImportQueue[sample].sample_path.c_str(), name.c_str()); |
3184 |
(*iter).sample_path.c_str(), name.c_str()); |
m_SampleImportQueue.erase(*member); |
|
m_SampleImportQueue.erase(iter); |
|
|
break; |
|
|
} |
|
3185 |
} |
} |
3186 |
} |
} |
3187 |
file_changed(); |
file_changed(); |
3196 |
samples_removed_signal.emit(); |
samples_removed_signal.emit(); |
3197 |
// if sample was just previously added, remove it from |
// if sample was just previously added, remove it from |
3198 |
// the import queue |
// the import queue |
3199 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
if (m_SampleImportQueue.count(sample)) { |
3200 |
iter != m_SampleImportQueue.end(); ++iter) { |
printf("Removing previously added sample '%s'\n", |
3201 |
if ((*iter).gig_sample == sample) { |
m_SampleImportQueue[sample].sample_path.c_str()); |
3202 |
printf("Removing previously added sample '%s'\n", |
m_SampleImportQueue.erase(sample); |
|
(*iter).sample_path.c_str()); |
|
|
m_SampleImportQueue.erase(iter); |
|
|
break; |
|
|
} |
|
3203 |
} |
} |
3204 |
dimreg_changed(); |
dimreg_changed(); |
3205 |
file_changed(); |
file_changed(); |
3216 |
} |
} |
3217 |
} |
} |
3218 |
|
|
3219 |
|
void MainWindow::on_action_remove_unused_samples() { |
3220 |
|
if (!file) return; |
3221 |
|
|
3222 |
|
// collect all samples that are not referenced by any instrument |
3223 |
|
std::list<gig::Sample*> lsamples; |
3224 |
|
for (int iSample = 0; file->GetSample(iSample); ++iSample) { |
3225 |
|
gig::Sample* sample = file->GetSample(iSample); |
3226 |
|
bool isUsed = false; |
3227 |
|
for (gig::Instrument* instrument = file->GetFirstInstrument(); instrument; |
3228 |
|
instrument = file->GetNextInstrument()) |
3229 |
|
{ |
3230 |
|
for (gig::Region* rgn = instrument->GetFirstRegion(); rgn; |
3231 |
|
rgn = instrument->GetNextRegion()) |
3232 |
|
{ |
3233 |
|
for (int i = 0; i < 256; ++i) { |
3234 |
|
if (!rgn->pDimensionRegions[i]) continue; |
3235 |
|
if (rgn->pDimensionRegions[i]->pSample != sample) continue; |
3236 |
|
isUsed = true; |
3237 |
|
goto endOfRefSearch; |
3238 |
|
} |
3239 |
|
} |
3240 |
|
} |
3241 |
|
endOfRefSearch: |
3242 |
|
if (!isUsed) lsamples.push_back(sample); |
3243 |
|
} |
3244 |
|
|
3245 |
|
if (lsamples.empty()) return; |
3246 |
|
|
3247 |
|
// notify everybody that we're going to remove these samples |
3248 |
|
samples_to_be_removed_signal.emit(lsamples); |
3249 |
|
|
3250 |
|
// remove collected samples |
3251 |
|
try { |
3252 |
|
for (std::list<gig::Sample*>::iterator itSample = lsamples.begin(); |
3253 |
|
itSample != lsamples.end(); ++itSample) |
3254 |
|
{ |
3255 |
|
gig::Sample* sample = *itSample; |
3256 |
|
// remove sample from the .gig file |
3257 |
|
file->DeleteSample(sample); |
3258 |
|
// if sample was just previously added, remove it from the import queue |
3259 |
|
if (m_SampleImportQueue.count(sample)) { |
3260 |
|
printf("Removing previously added sample '%s'\n", |
3261 |
|
m_SampleImportQueue[sample].sample_path.c_str()); |
3262 |
|
m_SampleImportQueue.erase(sample); |
3263 |
|
} |
3264 |
|
} |
3265 |
|
} catch (RIFF::Exception e) { |
3266 |
|
// show error message |
3267 |
|
Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR); |
3268 |
|
msg.run(); |
3269 |
|
} |
3270 |
|
|
3271 |
|
// notify everybody that we're done with removal |
3272 |
|
samples_removed_signal.emit(); |
3273 |
|
|
3274 |
|
dimreg_changed(); |
3275 |
|
file_changed(); |
3276 |
|
__refreshEntireGUI(); |
3277 |
|
} |
3278 |
|
|
3279 |
// see comment on on_sample_treeview_drag_begin() |
// see comment on on_sample_treeview_drag_begin() |
3280 |
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) |
3281 |
{ |
{ |
3302 |
sizeof(script)/*length of data in bytes*/); |
sizeof(script)/*length of data in bytes*/); |
3303 |
} |
} |
3304 |
|
|
3305 |
|
// see comment on on_sample_treeview_drag_begin() |
3306 |
|
void MainWindow::on_instruments_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context) |
3307 |
|
{ |
3308 |
|
first_call_to_drag_data_get = true; |
3309 |
|
} |
3310 |
|
|
3311 |
|
void MainWindow::on_instruments_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&, |
3312 |
|
Gtk::SelectionData& selection_data, guint, guint) |
3313 |
|
{ |
3314 |
|
if (!first_call_to_drag_data_get) return; |
3315 |
|
first_call_to_drag_data_get = false; |
3316 |
|
|
3317 |
|
// get selected source instrument |
3318 |
|
gig::Instrument* src = NULL; |
3319 |
|
{ |
3320 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
3321 |
|
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
3322 |
|
if (!rows.empty()) { |
3323 |
|
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
3324 |
|
if (it) { |
3325 |
|
Gtk::TreeModel::Row row = *it; |
3326 |
|
src = row[m_Columns.m_col_instr]; |
3327 |
|
} |
3328 |
|
} |
3329 |
|
} |
3330 |
|
if (!src) return; |
3331 |
|
|
3332 |
|
// pass the source gig::Instrument as pointer |
3333 |
|
selection_data.set(selection_data.get_target(), 0/*unused*/, (const guchar*)&src, |
3334 |
|
sizeof(src)/*length of data in bytes*/); |
3335 |
|
} |
3336 |
|
|
3337 |
|
void MainWindow::on_instruments_treeview_drop_drag_data_received( |
3338 |
|
const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, |
3339 |
|
const Gtk::SelectionData& selection_data, guint, guint time) |
3340 |
|
{ |
3341 |
|
gig::Instrument* src = *((gig::Instrument**) selection_data.get_data()); |
3342 |
|
if (!src || selection_data.get_length() != sizeof(gig::Instrument*)) |
3343 |
|
return; |
3344 |
|
|
3345 |
|
gig::Instrument* dst = NULL; |
3346 |
|
{ |
3347 |
|
Gtk::TreeModel::Path path; |
3348 |
|
const bool found = m_TreeView.get_path_at_pos(x, y, path); |
3349 |
|
if (!found) return; |
3350 |
|
|
3351 |
|
Gtk::TreeModel::iterator iter = m_refTreeModel->get_iter(path); |
3352 |
|
if (!iter) return; |
3353 |
|
Gtk::TreeModel::Row row = *iter; |
3354 |
|
dst = row[m_Columns.m_col_instr]; |
3355 |
|
} |
3356 |
|
if (!dst) return; |
3357 |
|
|
3358 |
|
//printf("dragdrop received src=%s dst=%s\n", src->pInfo->Name.c_str(), dst->pInfo->Name.c_str()); |
3359 |
|
src->MoveTo(dst); |
3360 |
|
__refreshEntireGUI(); |
3361 |
|
select_instrument(src); |
3362 |
|
} |
3363 |
|
|
3364 |
// For some reason drag_data_get gets called two times for each |
// For some reason drag_data_get gets called two times for each |
3365 |
// 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 |
3366 |
// 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 |
3379 |
// get selected sample |
// get selected sample |
3380 |
gig::Sample* sample = NULL; |
gig::Sample* sample = NULL; |
3381 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
3382 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
3383 |
if (it) { |
if (!rows.empty()) { |
3384 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]); |
3385 |
sample = row[m_SamplesModel.m_col_sample]; |
if (it) { |
3386 |
|
Gtk::TreeModel::Row row = *it; |
3387 |
|
sample = row[m_SamplesModel.m_col_sample]; |
3388 |
|
} |
3389 |
} |
} |
3390 |
// pass the gig::Sample as pointer |
// pass the gig::Sample as pointer |
3391 |
selection_data.set(selection_data.get_target(), 0/*unused*/, (const guchar*)&sample, |
selection_data.set(selection_data.get_target(), 0/*unused*/, (const guchar*)&sample, |
3525 |
if (!script) return; |
if (!script) return; |
3526 |
|
|
3527 |
ScriptEditor* editor = new ScriptEditor; |
ScriptEditor* editor = new ScriptEditor; |
3528 |
|
editor->signal_script_to_be_changed.connect( |
3529 |
|
signal_script_to_be_changed.make_slot() |
3530 |
|
); |
3531 |
|
editor->signal_script_changed.connect( |
3532 |
|
signal_script_changed.make_slot() |
3533 |
|
); |
3534 |
editor->setScript(script); |
editor->setScript(script); |
3535 |
//editor->reparent(*this); |
//editor->reparent(*this); |
3536 |
editor->show(); |
editor->show(); |
3573 |
void MainWindow::on_action_combine_instruments() { |
void MainWindow::on_action_combine_instruments() { |
3574 |
CombineInstrumentsDialog* d = new CombineInstrumentsDialog(*this, file); |
CombineInstrumentsDialog* d = new CombineInstrumentsDialog(*this, file); |
3575 |
d->show_all(); |
d->show_all(); |
|
d->resize(500, 400); |
|
3576 |
d->run(); |
d->run(); |
3577 |
if (d->fileWasChanged()) { |
if (d->fileWasChanged()) { |
3578 |
// update GUI with new instrument just created |
// update GUI with new instrument just created |
3583 |
|
|
3584 |
void MainWindow::on_action_view_references() { |
void MainWindow::on_action_view_references() { |
3585 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
3586 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
3587 |
|
if (rows.empty()) return; |
3588 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]); |
3589 |
if (!it) return; |
if (!it) return; |
3590 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
3591 |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
3593 |
|
|
3594 |
ReferencesView* d = new ReferencesView(*this); |
ReferencesView* d = new ReferencesView(*this); |
3595 |
d->setSample(sample); |
d->setSample(sample); |
3596 |
|
d->dimension_region_selected.connect( |
3597 |
|
sigc::mem_fun(*this, &MainWindow::select_dimension_region) |
3598 |
|
); |
3599 |
d->show_all(); |
d->show_all(); |
3600 |
d->resize(500, 400); |
d->resize(500, 400); |
3601 |
d->run(); |
d->run(); |
3726 |
// show warning in the file picker dialog |
// show warning in the file picker dialog |
3727 |
Gtk::HBox descriptionArea; |
Gtk::HBox descriptionArea; |
3728 |
descriptionArea.set_spacing(15); |
descriptionArea.set_spacing(15); |
3729 |
Gtk::Image warningIcon(Gtk::Stock::DIALOG_WARNING, Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); |
Gtk::Image warningIcon; |
3730 |
|
warningIcon.set_from_icon_name("dialog-warning", |
3731 |
|
Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); |
3732 |
descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); |
descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); |
3733 |
#if GTKMM_MAJOR_VERSION < 3 |
#if GTKMM_MAJOR_VERSION < 3 |
3734 |
view::WrapLabel description; |
view::WrapLabel description; |
3751 |
descriptionArea.show_all(); |
descriptionArea.show_all(); |
3752 |
|
|
3753 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
3754 |
printf("on_action_merge_files self=%x\n", Glib::Threads::Thread::self()); |
printf("on_action_merge_files self=%p\n", |
3755 |
|
static_cast<void*>(Glib::Threads::Thread::self())); |
3756 |
std::vector<std::string> filenames = dialog.get_filenames(); |
std::vector<std::string> filenames = dialog.get_filenames(); |
3757 |
|
|
3758 |
// merge the selected files to the currently open .gig file |
// merge the selected files to the currently open .gig file |
3764 |
} |
} |
3765 |
|
|
3766 |
// update GUI |
// update GUI |
3767 |
__refreshEntireGUI(); |
__refreshEntireGUI(); |
3768 |
} |
} |
3769 |
} |
} |
3770 |
|
|
3782 |
Gdk::Pixbuf::create_from_xpm_data(status_detached_xpm) |
Gdk::Pixbuf::create_from_xpm_data(status_detached_xpm) |
3783 |
); |
); |
3784 |
} |
} |
3785 |
|
|
3786 |
|
{ |
3787 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
3788 |
|
uiManager->get_widget("/MenuBar/MenuSettings/SyncSamplerInstrumentSelection")); |
3789 |
|
if (item) item->set_sensitive(b); |
3790 |
|
} |
3791 |
} |
} |
3792 |
|
|
3793 |
void MainWindow::on_sample_ref_count_incremented(gig::Sample* sample, int offset) { |
void MainWindow::on_sample_ref_count_incremented(gig::Sample* sample, int offset) { |
3834 |
m_TreeViewNotebook.set_current_page(2); |
m_TreeViewNotebook.set_current_page(2); |
3835 |
} |
} |
3836 |
|
|
3837 |
|
void MainWindow::select_prev_region() { |
3838 |
|
m_RegionChooser.select_prev_region(); |
3839 |
|
} |
3840 |
|
|
3841 |
|
void MainWindow::select_next_region() { |
3842 |
|
m_RegionChooser.select_next_region(); |
3843 |
|
} |
3844 |
|
|
3845 |
|
void MainWindow::select_next_dim_rgn_zone() { |
3846 |
|
if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser |
3847 |
|
m_DimRegionChooser.select_next_dimzone(); |
3848 |
|
} |
3849 |
|
|
3850 |
|
void MainWindow::select_prev_dim_rgn_zone() { |
3851 |
|
if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser |
3852 |
|
m_DimRegionChooser.select_prev_dimzone(); |
3853 |
|
} |
3854 |
|
|
3855 |
|
void MainWindow::select_add_next_dim_rgn_zone() { |
3856 |
|
m_DimRegionChooser.select_next_dimzone(true); |
3857 |
|
} |
3858 |
|
|
3859 |
|
void MainWindow::select_add_prev_dim_rgn_zone() { |
3860 |
|
m_DimRegionChooser.select_prev_dimzone(true); |
3861 |
|
} |
3862 |
|
|
3863 |
|
void MainWindow::select_prev_dimension() { |
3864 |
|
if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser |
3865 |
|
m_DimRegionChooser.select_prev_dimension(); |
3866 |
|
} |
3867 |
|
|
3868 |
|
void MainWindow::select_next_dimension() { |
3869 |
|
if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser |
3870 |
|
m_DimRegionChooser.select_next_dimension(); |
3871 |
|
} |
3872 |
|
|
3873 |
|
#define CLIPBOARD_DIMENSIONREGION_TARGET \ |
3874 |
|
("libgig.DimensionRegion." + m_serializationArchive.rawDataFormat()) |
3875 |
|
|
3876 |
|
void MainWindow::copy_selected_dimrgn() { |
3877 |
|
gig::DimensionRegion* pDimRgn = m_DimRegionChooser.get_main_dimregion(); |
3878 |
|
if (!pDimRgn) { |
3879 |
|
updateClipboardPasteAvailable(); |
3880 |
|
updateClipboardCopyAvailable(); |
3881 |
|
return; |
3882 |
|
} |
3883 |
|
|
3884 |
|
std::vector<Gtk::TargetEntry> targets; |
3885 |
|
targets.push_back( Gtk::TargetEntry(CLIPBOARD_DIMENSIONREGION_TARGET) ); |
3886 |
|
|
3887 |
|
Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); |
3888 |
|
clipboard->set( |
3889 |
|
targets, |
3890 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_get), |
3891 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_clear) |
3892 |
|
); |
3893 |
|
|
3894 |
|
m_serializationArchive.serialize(pDimRgn); |
3895 |
|
|
3896 |
|
updateClipboardPasteAvailable(); |
3897 |
|
} |
3898 |
|
|
3899 |
|
void MainWindow::paste_copied_dimrgn() { |
3900 |
|
Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); |
3901 |
|
clipboard->request_contents( |
3902 |
|
CLIPBOARD_DIMENSIONREGION_TARGET, |
3903 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_received) |
3904 |
|
); |
3905 |
|
updateClipboardPasteAvailable(); |
3906 |
|
} |
3907 |
|
|
3908 |
|
void MainWindow::adjust_clipboard_content() { |
3909 |
|
MacroEditor* editor = new MacroEditor(); |
3910 |
|
editor->setMacro(&m_serializationArchive, true); |
3911 |
|
editor->show(); |
3912 |
|
} |
3913 |
|
|
3914 |
|
void MainWindow::updateClipboardPasteAvailable() { |
3915 |
|
Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); |
3916 |
|
clipboard->request_targets( |
3917 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_received_targets) |
3918 |
|
); |
3919 |
|
} |
3920 |
|
|
3921 |
|
void MainWindow::updateClipboardCopyAvailable() { |
3922 |
|
bool bDimensionRegionCopyIsPossible = m_DimRegionChooser.get_main_dimregion(); |
3923 |
|
static_cast<Gtk::MenuItem*>( |
3924 |
|
uiManager->get_widget("/MenuBar/MenuEdit/CopyDimRgn") |
3925 |
|
)->set_sensitive(bDimensionRegionCopyIsPossible); |
3926 |
|
} |
3927 |
|
|
3928 |
|
void MainWindow::on_clipboard_owner_change(GdkEventOwnerChange* event) { |
3929 |
|
updateClipboardPasteAvailable(); |
3930 |
|
} |
3931 |
|
|
3932 |
|
void MainWindow::on_clipboard_get(Gtk::SelectionData& selection_data, guint /*info*/) { |
3933 |
|
const std::string target = selection_data.get_target(); |
3934 |
|
if (target == CLIPBOARD_DIMENSIONREGION_TARGET) { |
3935 |
|
selection_data.set( |
3936 |
|
CLIPBOARD_DIMENSIONREGION_TARGET, 8 /* "format": probably unused*/, |
3937 |
|
&m_serializationArchive.rawData()[0], |
3938 |
|
m_serializationArchive.rawData().size() |
3939 |
|
); |
3940 |
|
} else { |
3941 |
|
std::cerr << "Clipboard: content for unknown target '" << target << "' requested\n"; |
3942 |
|
} |
3943 |
|
} |
3944 |
|
|
3945 |
|
void MainWindow::on_clipboard_clear() { |
3946 |
|
m_serializationArchive.clear(); |
3947 |
|
updateClipboardPasteAvailable(); |
3948 |
|
updateClipboardCopyAvailable(); |
3949 |
|
} |
3950 |
|
|
3951 |
|
//NOTE: Might throw exception !!! |
3952 |
|
void MainWindow::applyMacro(Serialization::Archive& macro) { |
3953 |
|
gig::DimensionRegion* pDimRgn = m_DimRegionChooser.get_main_dimregion(); |
3954 |
|
if (!pDimRgn) return; |
3955 |
|
|
3956 |
|
for (std::set<gig::DimensionRegion*>::iterator itDimReg = dimreg_edit.dimregs.begin(); |
3957 |
|
itDimReg != dimreg_edit.dimregs.end(); ++itDimReg) |
3958 |
|
{ |
3959 |
|
gig::DimensionRegion* pDimRgn = *itDimReg; |
3960 |
|
DimRegionChangeGuard(this, pDimRgn); |
3961 |
|
macro.deserialize(pDimRgn); |
3962 |
|
} |
3963 |
|
//region_changed() |
3964 |
|
file_changed(); |
3965 |
|
dimreg_changed(); |
3966 |
|
} |
3967 |
|
|
3968 |
|
void MainWindow::on_clipboard_received(const Gtk::SelectionData& selection_data) { |
3969 |
|
const std::string target = selection_data.get_target(); |
3970 |
|
if (target == CLIPBOARD_DIMENSIONREGION_TARGET) { |
3971 |
|
Glib::ustring errorText; |
3972 |
|
try { |
3973 |
|
m_serializationArchive.decode( |
3974 |
|
selection_data.get_data(), selection_data.get_length() |
3975 |
|
); |
3976 |
|
applyMacro(m_serializationArchive); |
3977 |
|
} catch (Serialization::Exception e) { |
3978 |
|
errorText = e.Message; |
3979 |
|
} catch (...) { |
3980 |
|
errorText = _("Unknown exception while pasting DimensionRegion"); |
3981 |
|
} |
3982 |
|
if (!errorText.empty()) { |
3983 |
|
Glib::ustring txt = _("Pasting DimensionRegion failed:\n") + errorText; |
3984 |
|
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
3985 |
|
msg.run(); |
3986 |
|
} |
3987 |
|
} |
3988 |
|
} |
3989 |
|
|
3990 |
|
void MainWindow::on_clipboard_received_targets(const std::vector<Glib::ustring>& targets) { |
3991 |
|
const bool bDimensionRegionPasteIsPossible = |
3992 |
|
std::find(targets.begin(), targets.end(), |
3993 |
|
CLIPBOARD_DIMENSIONREGION_TARGET) != targets.end(); |
3994 |
|
|
3995 |
|
static_cast<Gtk::MenuItem*>( |
3996 |
|
uiManager->get_widget("/MenuBar/MenuEdit/PasteDimRgn") |
3997 |
|
)->set_sensitive(bDimensionRegionPasteIsPossible); |
3998 |
|
|
3999 |
|
static_cast<Gtk::MenuItem*>( |
4000 |
|
uiManager->get_widget("/MenuBar/MenuEdit/AdjustClipboard") |
4001 |
|
)->set_sensitive(bDimensionRegionPasteIsPossible); |
4002 |
|
} |
4003 |
|
|
4004 |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
4005 |
return file_structure_to_be_changed_signal; |
return file_structure_to_be_changed_signal; |
4006 |
} |
} |
4056 |
sigc::signal<void, int/*key*/, int/*velocity*/>& MainWindow::signal_keyboard_key_released() { |
sigc::signal<void, int/*key*/, int/*velocity*/>& MainWindow::signal_keyboard_key_released() { |
4057 |
return m_RegionChooser.signal_keyboard_key_released(); |
return m_RegionChooser.signal_keyboard_key_released(); |
4058 |
} |
} |
4059 |
|
|
4060 |
|
sigc::signal<void, gig::Instrument*>& MainWindow::signal_switch_sampler_instrument() { |
4061 |
|
return switch_sampler_instrument_signal; |
4062 |
|
} |