1 |
/* |
/* |
2 |
* Copyright (C) 2006-2015 Andreas Persson |
* Copyright (C) 2006-2017 Andreas Persson |
3 |
* |
* |
4 |
* This program is free software; you can redistribute it and/or |
* This program is free software; you can redistribute it and/or |
5 |
* modify it under the terms of the GNU General Public License as |
* modify it under the terms of the GNU General Public License as |
20 |
#include <iostream> |
#include <iostream> |
21 |
#include <cstring> |
#include <cstring> |
22 |
|
|
23 |
|
#include <glibmmconfig.h> |
24 |
|
// threads.h must be included first to be able to build with |
25 |
|
// G_DISABLE_DEPRECATED |
26 |
|
#if (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION == 31 && GLIBMM_MICRO_VERSION >= 2) || \ |
27 |
|
(GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION > 31) || GLIBMM_MAJOR_VERSION > 2 |
28 |
|
#include <glibmm/threads.h> |
29 |
|
#endif |
30 |
|
|
31 |
#include <glibmm/convert.h> |
#include <glibmm/convert.h> |
32 |
#include <glibmm/dispatcher.h> |
#include <glibmm/dispatcher.h> |
33 |
#include <glibmm/miscutils.h> |
#include <glibmm/miscutils.h> |
34 |
#include <glibmm/stringutils.h> |
#include <glibmm/stringutils.h> |
35 |
|
#include <glibmm/regex.h> |
36 |
#include <gtkmm/aboutdialog.h> |
#include <gtkmm/aboutdialog.h> |
37 |
#include <gtkmm/filechooserdialog.h> |
#include <gtkmm/filechooserdialog.h> |
38 |
#include <gtkmm/messagedialog.h> |
#include <gtkmm/messagedialog.h> |
40 |
#include <gtkmm/targetentry.h> |
#include <gtkmm/targetentry.h> |
41 |
#include <gtkmm/main.h> |
#include <gtkmm/main.h> |
42 |
#include <gtkmm/toggleaction.h> |
#include <gtkmm/toggleaction.h> |
43 |
|
#include <gtkmm/accelmap.h> |
44 |
#if GTKMM_MAJOR_VERSION < 3 |
#if GTKMM_MAJOR_VERSION < 3 |
45 |
#include "wrapLabel.hh" |
#include "wrapLabel.hh" |
46 |
#endif |
#endif |
60 |
#include "ReferencesView.h" |
#include "ReferencesView.h" |
61 |
#include "../../gfx/status_attached.xpm" |
#include "../../gfx/status_attached.xpm" |
62 |
#include "../../gfx/status_detached.xpm" |
#include "../../gfx/status_detached.xpm" |
63 |
|
#include "gfx/builtinpix.h" |
64 |
|
#include "MacroEditor.h" |
65 |
|
#include "MacrosSetup.h" |
66 |
|
#if defined(__APPLE__) |
67 |
|
# include "MacHelper.h" |
68 |
|
#endif |
69 |
|
|
70 |
|
static const Gdk::ModifierType primaryModifierKey = |
71 |
|
#if defined(__APPLE__) |
72 |
|
Gdk::META_MASK; // Cmd key on Mac |
73 |
|
#else |
74 |
|
Gdk::CONTROL_MASK; // Ctrl key on all other OSs |
75 |
|
#endif |
76 |
|
|
77 |
MainWindow::MainWindow() : |
MainWindow::MainWindow() : |
78 |
m_DimRegionChooser(*this), |
m_DimRegionChooser(*this), |
79 |
dimreg_label(_("Changes apply to:")), |
dimreg_label(_("Changes apply to:")), |
80 |
dimreg_all_regions(_("all regions")), |
dimreg_all_regions(_("all regions")), |
81 |
dimreg_all_dimregs(_("all dimension splits")), |
dimreg_all_dimregs(_("all dimension splits")), |
82 |
dimreg_stereo(_("both channels")) |
dimreg_stereo(_("both channels")), |
83 |
|
labelLegend(_("Legend:")), |
84 |
|
labelNoSample(_(" No Sample")), |
85 |
|
labelMissingSample(_(" Missing some Sample(s)")), |
86 |
|
labelLooped(_(" Looped")), |
87 |
|
labelSomeLoops(_(" Some Loop(s)")) |
88 |
{ |
{ |
89 |
|
loadBuiltInPix(); |
90 |
|
|
91 |
|
this->file = NULL; |
92 |
|
|
93 |
// set_border_width(5); |
// set_border_width(5); |
|
// set_default_size(400, 200); |
|
94 |
|
|
95 |
|
if (!Settings::singleton()->autoRestoreWindowDimension) { |
96 |
|
set_default_size(800, 600); |
97 |
|
set_position(Gtk::WIN_POS_CENTER); |
98 |
|
} |
99 |
|
|
100 |
add(m_VBox); |
add(m_VBox); |
101 |
|
|
122 |
|
|
123 |
m_TreeViewNotebook.set_size_request(300); |
m_TreeViewNotebook.set_size_request(300); |
124 |
|
|
125 |
m_HPaned.add1(m_TreeViewNotebook); |
m_searchLabel.set_text(Glib::ustring(" ") + _("Filter:")); |
126 |
|
m_searchField.pack_start(m_searchLabel, Gtk::PACK_SHRINK); |
127 |
|
m_searchField.pack_start(m_searchText); |
128 |
|
m_searchField.set_spacing(5); |
129 |
|
|
130 |
|
m_left_vbox.pack_start(m_TreeViewNotebook); |
131 |
|
m_left_vbox.pack_start(m_searchField, Gtk::PACK_SHRINK); |
132 |
|
|
133 |
|
m_HPaned.add1(m_left_vbox); |
134 |
|
|
135 |
dimreg_hbox.add(dimreg_label); |
dimreg_hbox.add(dimreg_label); |
136 |
dimreg_hbox.add(dimreg_all_regions); |
dimreg_hbox.add(dimreg_all_regions); |
137 |
dimreg_hbox.add(dimreg_all_dimregs); |
dimreg_hbox.add(dimreg_all_dimregs); |
139 |
dimreg_hbox.add(dimreg_stereo); |
dimreg_hbox.add(dimreg_stereo); |
140 |
dimreg_vbox.add(dimreg_edit); |
dimreg_vbox.add(dimreg_edit); |
141 |
dimreg_vbox.pack_start(dimreg_hbox, Gtk::PACK_SHRINK); |
dimreg_vbox.pack_start(dimreg_hbox, Gtk::PACK_SHRINK); |
142 |
|
{ |
143 |
|
legend_hbox.add(labelLegend); |
144 |
|
|
145 |
|
imageNoSample.set(redDot); |
146 |
|
imageNoSample.set_alignment(Gtk::ALIGN_END); |
147 |
|
labelNoSample.set_alignment(Gtk::ALIGN_START); |
148 |
|
legend_hbox.add(imageNoSample); |
149 |
|
legend_hbox.add(labelNoSample); |
150 |
|
|
151 |
|
imageMissingSample.set(yellowDot); |
152 |
|
imageMissingSample.set_alignment(Gtk::ALIGN_END); |
153 |
|
labelMissingSample.set_alignment(Gtk::ALIGN_START); |
154 |
|
legend_hbox.add(imageMissingSample); |
155 |
|
legend_hbox.add(labelMissingSample); |
156 |
|
|
157 |
|
imageLooped.set(blackLoop); |
158 |
|
imageLooped.set_alignment(Gtk::ALIGN_END); |
159 |
|
labelLooped.set_alignment(Gtk::ALIGN_START); |
160 |
|
legend_hbox.add(imageLooped); |
161 |
|
legend_hbox.add(labelLooped); |
162 |
|
|
163 |
|
imageSomeLoops.set(grayLoop); |
164 |
|
imageSomeLoops.set_alignment(Gtk::ALIGN_END); |
165 |
|
labelSomeLoops.set_alignment(Gtk::ALIGN_START); |
166 |
|
legend_hbox.add(imageSomeLoops); |
167 |
|
legend_hbox.add(labelSomeLoops); |
168 |
|
|
169 |
|
legend_hbox.show_all_children(); |
170 |
|
} |
171 |
|
dimreg_vbox.pack_start(legend_hbox, Gtk::PACK_SHRINK); |
172 |
m_HPaned.add2(dimreg_vbox); |
m_HPaned.add2(dimreg_vbox); |
173 |
|
|
174 |
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.")); |
229 |
sigc::mem_fun(*this, &MainWindow::show_intruments_tab) |
sigc::mem_fun(*this, &MainWindow::show_intruments_tab) |
230 |
); |
); |
231 |
actionGroup->add( |
actionGroup->add( |
232 |
Gtk::Action::create("MenuScript", _("S_cript")), |
Gtk::Action::create("MenuScript", _("Scr_ipt")), |
233 |
sigc::mem_fun(*this, &MainWindow::show_scripts_tab) |
sigc::mem_fun(*this, &MainWindow::show_scripts_tab) |
234 |
); |
); |
235 |
actionGroup->add(Gtk::Action::create("AllInstruments", _("_Select"))); |
actionGroup->add(Gtk::Action::create("AllInstruments", _("_Select"))); |
236 |
|
actionGroup->add(Gtk::Action::create("AssignScripts", _("Assign Script"))); |
237 |
|
|
238 |
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); |
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); |
239 |
|
|
240 |
|
const Gdk::ModifierType primaryModifierKey = |
241 |
|
#if defined(__APPLE__) |
242 |
|
Gdk::META_MASK; // Cmd key on Mac |
243 |
|
#else |
244 |
|
Gdk::CONTROL_MASK; // Ctrl key on all other OSs |
245 |
|
#endif |
246 |
|
|
247 |
|
actionGroup->add(Gtk::Action::create("CopyDimRgn", |
248 |
|
_("Copy selected dimension region")), |
249 |
|
Gtk::AccelKey(GDK_KEY_c, Gdk::MOD1_MASK), |
250 |
|
sigc::mem_fun(*this, &MainWindow::copy_selected_dimrgn)); |
251 |
|
|
252 |
|
actionGroup->add(Gtk::Action::create("PasteDimRgn", |
253 |
|
_("Paste dimension region")), |
254 |
|
Gtk::AccelKey(GDK_KEY_v, Gdk::MOD1_MASK), |
255 |
|
sigc::mem_fun(*this, &MainWindow::paste_copied_dimrgn)); |
256 |
|
|
257 |
|
actionGroup->add(Gtk::Action::create("AdjustClipboard", |
258 |
|
_("Adjust Clipboard Content")), |
259 |
|
Gtk::AccelKey(GDK_KEY_x, Gdk::MOD1_MASK), |
260 |
|
sigc::mem_fun(*this, &MainWindow::adjust_clipboard_content)); |
261 |
|
|
262 |
|
actionGroup->add(Gtk::Action::create("SelectPrevInstr", |
263 |
|
_("Select Previous Instrument")), |
264 |
|
Gtk::AccelKey(GDK_KEY_Up, primaryModifierKey), |
265 |
|
sigc::mem_fun(*this, &MainWindow::select_prev_instrument)); |
266 |
|
|
267 |
|
actionGroup->add(Gtk::Action::create("SelectNextInstr", |
268 |
|
_("Select Next Instrument")), |
269 |
|
Gtk::AccelKey(GDK_KEY_Down, primaryModifierKey), |
270 |
|
sigc::mem_fun(*this, &MainWindow::select_next_instrument)); |
271 |
|
|
272 |
|
actionGroup->add(Gtk::Action::create("SelectPrevRegion", |
273 |
|
_("Select Previous Region")), |
274 |
|
Gtk::AccelKey(GDK_KEY_Left, primaryModifierKey), |
275 |
|
sigc::mem_fun(*this, &MainWindow::select_prev_region)); |
276 |
|
|
277 |
|
actionGroup->add(Gtk::Action::create("SelectNextRegion", |
278 |
|
_("Select Next Region")), |
279 |
|
Gtk::AccelKey(GDK_KEY_Right, primaryModifierKey), |
280 |
|
sigc::mem_fun(*this, &MainWindow::select_next_region)); |
281 |
|
|
282 |
|
actionGroup->add(Gtk::Action::create("SelectPrevDimRgnZone", |
283 |
|
_("Select Previous Dimension Region Zone")), |
284 |
|
Gtk::AccelKey(GDK_KEY_Left, Gdk::MOD1_MASK), |
285 |
|
sigc::mem_fun(*this, &MainWindow::select_prev_dim_rgn_zone)); |
286 |
|
|
287 |
|
actionGroup->add(Gtk::Action::create("SelectNextDimRgnZone", |
288 |
|
_("Select Next Dimension Region Zone")), |
289 |
|
Gtk::AccelKey(GDK_KEY_Right, Gdk::MOD1_MASK), |
290 |
|
sigc::mem_fun(*this, &MainWindow::select_next_dim_rgn_zone)); |
291 |
|
|
292 |
|
actionGroup->add(Gtk::Action::create("SelectPrevDimension", |
293 |
|
_("Select Previous Dimension")), |
294 |
|
Gtk::AccelKey(GDK_KEY_Up, Gdk::MOD1_MASK), |
295 |
|
sigc::mem_fun(*this, &MainWindow::select_prev_dimension)); |
296 |
|
|
297 |
|
actionGroup->add(Gtk::Action::create("SelectNextDimension", |
298 |
|
_("Select Next Dimension")), |
299 |
|
Gtk::AccelKey(GDK_KEY_Down, Gdk::MOD1_MASK), |
300 |
|
sigc::mem_fun(*this, &MainWindow::select_next_dimension)); |
301 |
|
|
302 |
|
actionGroup->add(Gtk::Action::create("SelectAddPrevDimRgnZone", |
303 |
|
_("Add Previous Dimension Region Zone to Selection")), |
304 |
|
Gtk::AccelKey(GDK_KEY_Left, Gdk::MOD1_MASK | Gdk::SHIFT_MASK), |
305 |
|
sigc::mem_fun(*this, &MainWindow::select_add_prev_dim_rgn_zone)); |
306 |
|
|
307 |
|
actionGroup->add(Gtk::Action::create("SelectAddNextDimRgnZone", |
308 |
|
_("Add Next Dimension Region Zone to Selection")), |
309 |
|
Gtk::AccelKey(GDK_KEY_Right, Gdk::MOD1_MASK | Gdk::SHIFT_MASK), |
310 |
|
sigc::mem_fun(*this, &MainWindow::select_add_next_dim_rgn_zone)); |
311 |
|
|
312 |
Glib::RefPtr<Gtk::ToggleAction> toggle_action = |
Glib::RefPtr<Gtk::ToggleAction> toggle_action = |
313 |
Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note")); |
Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note")); |
314 |
toggle_action->set_active(true); |
toggle_action->set_active(true); |
325 |
actionGroup->add(toggle_action); |
actionGroup->add(toggle_action); |
326 |
|
|
327 |
|
|
328 |
actionGroup->add(Gtk::Action::create("MenuView", _("_View"))); |
actionGroup->add(Gtk::Action::create("MenuMacro", _("_Macro"))); |
329 |
|
|
330 |
|
|
331 |
|
actionGroup->add(Gtk::Action::create("MenuView", _("Vie_w"))); |
332 |
toggle_action = |
toggle_action = |
333 |
Gtk::ToggleAction::create("Statusbar", _("_Statusbar")); |
Gtk::ToggleAction::create("Statusbar", _("_Statusbar")); |
334 |
toggle_action->set_active(true); |
toggle_action->set_active(true); |
335 |
actionGroup->add(toggle_action, |
actionGroup->add(toggle_action, |
336 |
sigc::mem_fun( |
sigc::mem_fun( |
337 |
*this, &MainWindow::on_action_view_status_bar)); |
*this, &MainWindow::on_action_view_status_bar)); |
338 |
|
|
339 |
|
toggle_action = |
340 |
|
Gtk::ToggleAction::create("AutoRestoreWinDim", _("_Auto Restore Window Dimension")); |
341 |
|
toggle_action->set_active(Settings::singleton()->autoRestoreWindowDimension); |
342 |
|
actionGroup->add(toggle_action, |
343 |
|
sigc::mem_fun( |
344 |
|
*this, &MainWindow::on_auto_restore_win_dim)); |
345 |
|
|
346 |
|
toggle_action = |
347 |
|
Gtk::ToggleAction::create("SaveWithTemporaryFile", _("Save with _temporary file")); |
348 |
|
toggle_action->set_active(Settings::singleton()->saveWithTemporaryFile); |
349 |
|
actionGroup->add(toggle_action, |
350 |
|
sigc::mem_fun( |
351 |
|
*this, &MainWindow::on_save_with_temporary_file)); |
352 |
|
|
353 |
actionGroup->add( |
actionGroup->add( |
354 |
Gtk::Action::create("RefreshAll", _("_Refresh All")), |
Gtk::Action::create("RefreshAll", _("_Refresh All")), |
355 |
sigc::mem_fun(*this, &MainWindow::on_action_refresh_all) |
sigc::mem_fun(*this, &MainWindow::on_action_refresh_all) |
370 |
sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument) |
sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument) |
371 |
); |
); |
372 |
actionGroup->add( |
actionGroup->add( |
373 |
|
Gtk::Action::create("CombInstruments", _("_Combine Instruments ...")), |
374 |
|
Gtk::AccelKey(GDK_KEY_j, primaryModifierKey), |
375 |
|
sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments) |
376 |
|
); |
377 |
|
actionGroup->add( |
378 |
Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE), |
Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE), |
379 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument) |
380 |
); |
); |
493 |
" <menuitem action='Quit'/>" |
" <menuitem action='Quit'/>" |
494 |
" </menu>" |
" </menu>" |
495 |
" <menu action='MenuEdit'>" |
" <menu action='MenuEdit'>" |
496 |
|
" <menuitem action='CopyDimRgn'/>" |
497 |
|
" <menuitem action='AdjustClipboard'/>" |
498 |
|
" <menuitem action='PasteDimRgn'/>" |
499 |
|
" <separator/>" |
500 |
|
" <menuitem action='SelectPrevInstr'/>" |
501 |
|
" <menuitem action='SelectNextInstr'/>" |
502 |
|
" <separator/>" |
503 |
|
" <menuitem action='SelectPrevRegion'/>" |
504 |
|
" <menuitem action='SelectNextRegion'/>" |
505 |
|
" <separator/>" |
506 |
|
" <menuitem action='SelectPrevDimension'/>" |
507 |
|
" <menuitem action='SelectNextDimension'/>" |
508 |
|
" <menuitem action='SelectPrevDimRgnZone'/>" |
509 |
|
" <menuitem action='SelectNextDimRgnZone'/>" |
510 |
|
" <menuitem action='SelectAddPrevDimRgnZone'/>" |
511 |
|
" <menuitem action='SelectAddNextDimRgnZone'/>" |
512 |
|
" <separator/>" |
513 |
" <menuitem action='CopySampleUnity'/>" |
" <menuitem action='CopySampleUnity'/>" |
514 |
" <menuitem action='CopySampleTune'/>" |
" <menuitem action='CopySampleTune'/>" |
515 |
" <menuitem action='CopySampleLoop'/>" |
" <menuitem action='CopySampleLoop'/>" |
516 |
" </menu>" |
" </menu>" |
517 |
|
" <menu action='MenuMacro'>" |
518 |
|
" </menu>" |
519 |
" <menu action='MenuSample'>" |
" <menu action='MenuSample'>" |
520 |
" <menuitem action='SampleProperties'/>" |
" <menuitem action='SampleProperties'/>" |
521 |
" <menuitem action='AddGroup'/>" |
" <menuitem action='AddGroup'/>" |
534 |
" <menuitem action='InstrProperties'/>" |
" <menuitem action='InstrProperties'/>" |
535 |
" <menuitem action='MidiRules'/>" |
" <menuitem action='MidiRules'/>" |
536 |
" <menuitem action='ScriptSlots'/>" |
" <menuitem action='ScriptSlots'/>" |
537 |
|
" <menu action='AssignScripts'/>" |
538 |
" <menuitem action='AddInstrument'/>" |
" <menuitem action='AddInstrument'/>" |
539 |
" <menuitem action='DupInstrument'/>" |
" <menuitem action='DupInstrument'/>" |
540 |
|
" <menuitem action='CombInstruments'/>" |
541 |
" <separator/>" |
" <separator/>" |
542 |
" <menuitem action='RemoveInstrument'/>" |
" <menuitem action='RemoveInstrument'/>" |
543 |
" </menu>" |
" </menu>" |
550 |
" </menu>" |
" </menu>" |
551 |
" <menu action='MenuView'>" |
" <menu action='MenuView'>" |
552 |
" <menuitem action='Statusbar'/>" |
" <menuitem action='Statusbar'/>" |
553 |
|
" <menuitem action='AutoRestoreWinDim'/>" |
554 |
" <separator/>" |
" <separator/>" |
555 |
" <menuitem action='RefreshAll'/>" |
" <menuitem action='RefreshAll'/>" |
556 |
" </menu>" |
" </menu>" |
562 |
" <menuitem action='WarnUserOnExtensions'/>" |
" <menuitem action='WarnUserOnExtensions'/>" |
563 |
" <menuitem action='SyncSamplerInstrumentSelection'/>" |
" <menuitem action='SyncSamplerInstrumentSelection'/>" |
564 |
" <menuitem action='MoveRootNoteWithRegionMoved'/>" |
" <menuitem action='MoveRootNoteWithRegionMoved'/>" |
565 |
|
" <menuitem action='SaveWithTemporaryFile'/>" |
566 |
" </menu>" |
" </menu>" |
567 |
" <menu action='MenuHelp'>" |
" <menu action='MenuHelp'>" |
568 |
" <menuitem action='About'/>" |
" <menuitem action='About'/>" |
574 |
" <menuitem action='ScriptSlots'/>" |
" <menuitem action='ScriptSlots'/>" |
575 |
" <menuitem action='AddInstrument'/>" |
" <menuitem action='AddInstrument'/>" |
576 |
" <menuitem action='DupInstrument'/>" |
" <menuitem action='DupInstrument'/>" |
577 |
|
" <menuitem action='CombInstruments'/>" |
578 |
" <separator/>" |
" <separator/>" |
579 |
" <menuitem action='RemoveInstrument'/>" |
" <menuitem action='RemoveInstrument'/>" |
580 |
" </popup>" |
" </popup>" |
651 |
} |
} |
652 |
{ |
{ |
653 |
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
654 |
|
uiManager->get_widget("/MenuBar/MenuView/AutoRestoreWinDim")); |
655 |
|
item->set_tooltip_text(_("If checked, size and position of all windows will be saved and automatically restored next time.")); |
656 |
|
} |
657 |
|
{ |
658 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
659 |
uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments")); |
uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments")); |
660 |
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.")); |
661 |
} |
} |
669 |
instrument_menu = static_cast<Gtk::MenuItem*>( |
instrument_menu = static_cast<Gtk::MenuItem*>( |
670 |
uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments"))->get_submenu(); |
uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments"))->get_submenu(); |
671 |
|
|
672 |
|
assign_scripts_menu = static_cast<Gtk::MenuItem*>( |
673 |
|
uiManager->get_widget("/MenuBar/MenuInstrument/AssignScripts"))->get_submenu(); |
674 |
|
|
675 |
Gtk::Widget* menuBar = uiManager->get_widget("/MenuBar"); |
Gtk::Widget* menuBar = uiManager->get_widget("/MenuBar"); |
676 |
m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK); |
m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK); |
677 |
m_VBox.pack_start(m_HPaned); |
m_VBox.pack_start(m_HPaned); |
695 |
|
|
696 |
// Create the Tree model: |
// Create the Tree model: |
697 |
m_refTreeModel = Gtk::ListStore::create(m_Columns); |
m_refTreeModel = Gtk::ListStore::create(m_Columns); |
698 |
m_TreeView.set_model(m_refTreeModel); |
m_refTreeModelFilter = Gtk::TreeModelFilter::create(m_refTreeModel); |
699 |
|
m_refTreeModelFilter->set_visible_func( |
700 |
|
sigc::mem_fun(*this, &MainWindow::instrument_row_visible) |
701 |
|
); |
702 |
|
m_TreeView.set_model(m_refTreeModelFilter); |
703 |
|
|
704 |
|
m_TreeView.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE); |
705 |
m_TreeView.set_tooltip_text(_("Right click here for actions on instruments & MIDI Rules. Drag & drop to change the order of instruments.")); |
m_TreeView.set_tooltip_text(_("Right click here for actions on instruments & MIDI Rules. Drag & drop to change the order of instruments.")); |
706 |
instrument_name_connection = m_refTreeModel->signal_row_changed().connect( |
instrument_name_connection = m_refTreeModel->signal_row_changed().connect( |
707 |
sigc::mem_fun(*this, &MainWindow::instrument_name_changed) |
sigc::mem_fun(*this, &MainWindow::instrument_name_changed) |
708 |
); |
); |
709 |
|
|
710 |
// Add the TreeView's view columns: |
// Add the TreeView's view columns: |
711 |
m_TreeView.append_column_editable("Instrument", m_Columns.m_col_name); |
m_TreeView.append_column(_("Nr"), m_Columns.m_col_nr); |
712 |
m_TreeView.set_headers_visible(false); |
m_TreeView.append_column_editable(_("Instrument"), m_Columns.m_col_name); |
713 |
|
m_TreeView.append_column(_("Scripts"), m_Columns.m_col_scripts); |
714 |
|
m_TreeView.set_headers_visible(true); |
715 |
|
|
716 |
// establish drag&drop within the instrument tree view, allowing to reorder |
// establish drag&drop within the instrument tree view, allowing to reorder |
717 |
// the sequence of instruments within the gig file |
// the sequence of instruments within the gig file |
734 |
// create samples treeview (including its data model) |
// create samples treeview (including its data model) |
735 |
m_refSamplesTreeModel = SamplesTreeStore::create(m_SamplesModel); |
m_refSamplesTreeModel = SamplesTreeStore::create(m_SamplesModel); |
736 |
m_TreeViewSamples.set_model(m_refSamplesTreeModel); |
m_TreeViewSamples.set_model(m_refSamplesTreeModel); |
737 |
|
m_TreeViewSamples.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE); |
738 |
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.")); |
739 |
// m_TreeViewSamples.set_reorderable(); |
// m_TreeViewSamples.set_reorderable(); |
740 |
m_TreeViewSamples.append_column_editable(_("Name"), m_SamplesModel.m_col_name); |
m_TreeViewSamples.append_column_editable(_("Name"), m_SamplesModel.m_col_name); |
876 |
dimreg_stereo.signal_toggled().connect( |
dimreg_stereo.signal_toggled().connect( |
877 |
sigc::mem_fun(*this, &MainWindow::update_dimregs)); |
sigc::mem_fun(*this, &MainWindow::update_dimregs)); |
878 |
|
|
879 |
|
m_searchText.signal_changed().connect( |
880 |
|
sigc::mem_fun(m_refTreeModelFilter.operator->(), &Gtk::TreeModelFilter::refilter) |
881 |
|
); |
882 |
|
|
883 |
file = 0; |
file = 0; |
884 |
file_is_changed = false; |
file_is_changed = false; |
885 |
|
|
888 |
// start with a new gig file by default |
// start with a new gig file by default |
889 |
on_action_file_new(); |
on_action_file_new(); |
890 |
|
|
891 |
|
m_TreeViewNotebook.signal_switch_page().connect( |
892 |
|
sigc::mem_fun(*this, &MainWindow::on_notebook_tab_switched) |
893 |
|
); |
894 |
|
|
895 |
// select 'Instruments' tab by default |
// select 'Instruments' tab by default |
896 |
// (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) |
897 |
m_TreeViewNotebook.set_current_page(1); |
m_TreeViewNotebook.set_current_page(1); |
898 |
|
|
899 |
|
Gtk::Clipboard::get()->signal_owner_change().connect( |
900 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_owner_change) |
901 |
|
); |
902 |
|
updateClipboardPasteAvailable(); |
903 |
|
updateClipboardCopyAvailable(); |
904 |
|
|
905 |
|
// setup macros and their keyboard accelerators |
906 |
|
{ |
907 |
|
Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>( |
908 |
|
uiManager->get_widget("/MenuBar/MenuMacro") |
909 |
|
)->get_submenu(); |
910 |
|
|
911 |
|
const Gdk::ModifierType noModifier = (Gdk::ModifierType)0; |
912 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_0", GDK_KEY_F1, noModifier); |
913 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_1", GDK_KEY_F2, noModifier); |
914 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_2", GDK_KEY_F3, noModifier); |
915 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_3", GDK_KEY_F4, noModifier); |
916 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_4", GDK_KEY_F5, noModifier); |
917 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_5", GDK_KEY_F6, noModifier); |
918 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_6", GDK_KEY_F7, noModifier); |
919 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_7", GDK_KEY_F8, noModifier); |
920 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_8", GDK_KEY_F9, noModifier); |
921 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_9", GDK_KEY_F10, noModifier); |
922 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_10", GDK_KEY_F11, noModifier); |
923 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_11", GDK_KEY_F12, noModifier); |
924 |
|
Gtk::AccelMap::add_entry("<Macros>/SetupMacros", 'm', primaryModifierKey); |
925 |
|
|
926 |
|
Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group(); |
927 |
|
menuMacro->set_accel_group(accelGroup); |
928 |
|
|
929 |
|
updateMacroMenu(); |
930 |
|
} |
931 |
|
|
932 |
|
// setup "Assign Scripts" keyboard accelerators |
933 |
|
{ |
934 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_0", GDK_KEY_F1, Gdk::SHIFT_MASK); |
935 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_1", GDK_KEY_F2, Gdk::SHIFT_MASK); |
936 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_2", GDK_KEY_F3, Gdk::SHIFT_MASK); |
937 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_3", GDK_KEY_F4, Gdk::SHIFT_MASK); |
938 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_4", GDK_KEY_F5, Gdk::SHIFT_MASK); |
939 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_5", GDK_KEY_F6, Gdk::SHIFT_MASK); |
940 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_6", GDK_KEY_F7, Gdk::SHIFT_MASK); |
941 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_7", GDK_KEY_F8, Gdk::SHIFT_MASK); |
942 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_8", GDK_KEY_F9, Gdk::SHIFT_MASK); |
943 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_9", GDK_KEY_F10, Gdk::SHIFT_MASK); |
944 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_10", GDK_KEY_F11, Gdk::SHIFT_MASK); |
945 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_11", GDK_KEY_F12, Gdk::SHIFT_MASK); |
946 |
|
|
947 |
|
Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group(); |
948 |
|
assign_scripts_menu->set_accel_group(accelGroup); |
949 |
|
} |
950 |
|
|
951 |
|
Glib::signal_idle().connect_once( |
952 |
|
sigc::mem_fun(*this, &MainWindow::bringToFront), |
953 |
|
200 |
954 |
|
); |
955 |
} |
} |
956 |
|
|
957 |
MainWindow::~MainWindow() |
MainWindow::~MainWindow() |
958 |
{ |
{ |
959 |
} |
} |
960 |
|
|
961 |
|
void MainWindow::bringToFront() { |
962 |
|
#if defined(__APPLE__) |
963 |
|
macRaiseAppWindow(); |
964 |
|
#endif |
965 |
|
raise(); |
966 |
|
present(); |
967 |
|
} |
968 |
|
|
969 |
|
void MainWindow::updateMacroMenu() { |
970 |
|
Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>( |
971 |
|
uiManager->get_widget("/MenuBar/MenuMacro") |
972 |
|
)->get_submenu(); |
973 |
|
|
974 |
|
// remove all entries from "Macro" menu |
975 |
|
{ |
976 |
|
const std::vector<Gtk::Widget*> children = menuMacro->get_children(); |
977 |
|
for (int i = 0; i < children.size(); ++i) { |
978 |
|
Gtk::Widget* child = children[i]; |
979 |
|
menuMacro->remove(*child); |
980 |
|
delete child; |
981 |
|
} |
982 |
|
} |
983 |
|
|
984 |
|
// (re)load all macros from config file |
985 |
|
try { |
986 |
|
Settings::singleton()->loadMacros(m_macros); |
987 |
|
} catch (Serialization::Exception e) { |
988 |
|
std::cerr << "Exception while loading macros: " << e.Message << std::endl; |
989 |
|
} catch (...) { |
990 |
|
std::cerr << "Unknown exception while loading macros!" << std::endl; |
991 |
|
} |
992 |
|
|
993 |
|
// add all configured macros as menu items to the "Macro" menu |
994 |
|
for (int iMacro = 0; iMacro < m_macros.size(); ++iMacro) { |
995 |
|
const Serialization::Archive& macro = m_macros[iMacro]; |
996 |
|
std::string name = |
997 |
|
macro.name().empty() ? |
998 |
|
(std::string(_("Unnamed Macro")) + " " + ToString(iMacro+1)) : macro.name(); |
999 |
|
Gtk::MenuItem* item = new Gtk::MenuItem(name); |
1000 |
|
item->signal_activate().connect( |
1001 |
|
sigc::bind( |
1002 |
|
sigc::mem_fun(*this, &MainWindow::onMacroSelected), iMacro |
1003 |
|
) |
1004 |
|
); |
1005 |
|
menuMacro->append(*item); |
1006 |
|
item->set_accel_path("<Macros>/macro_" + ToString(iMacro)); |
1007 |
|
Glib::ustring comment = macro.comment(); |
1008 |
|
if (!comment.empty()) |
1009 |
|
item->set_tooltip_text(comment); |
1010 |
|
} |
1011 |
|
// if there are no macros configured at all, then show a dummy entry instead |
1012 |
|
if (m_macros.empty()) { |
1013 |
|
Gtk::MenuItem* item = new Gtk::MenuItem(_("No Macros")); |
1014 |
|
item->set_sensitive(false); |
1015 |
|
menuMacro->append(*item); |
1016 |
|
} |
1017 |
|
|
1018 |
|
// add separator line to menu |
1019 |
|
menuMacro->append(*new Gtk::SeparatorMenuItem); |
1020 |
|
|
1021 |
|
{ |
1022 |
|
Gtk::MenuItem* item = new Gtk::MenuItem(_("Setup Macros ...")); |
1023 |
|
item->signal_activate().connect( |
1024 |
|
sigc::mem_fun(*this, &MainWindow::setupMacros) |
1025 |
|
); |
1026 |
|
menuMacro->append(*item); |
1027 |
|
item->set_accel_path("<Macros>/SetupMacros"); |
1028 |
|
} |
1029 |
|
|
1030 |
|
menuMacro->show_all_children(); |
1031 |
|
} |
1032 |
|
|
1033 |
|
void MainWindow::onMacroSelected(int iMacro) { |
1034 |
|
printf("onMacroSelected(%d)\n", iMacro); |
1035 |
|
if (iMacro < 0 || iMacro >= m_macros.size()) return; |
1036 |
|
Glib::ustring errorText; |
1037 |
|
try { |
1038 |
|
applyMacro(m_macros[iMacro]); |
1039 |
|
} catch (Serialization::Exception e) { |
1040 |
|
errorText = e.Message; |
1041 |
|
} catch (...) { |
1042 |
|
errorText = _("Unknown exception while applying macro"); |
1043 |
|
} |
1044 |
|
if (!errorText.empty()) { |
1045 |
|
Glib::ustring txt = _("Applying macro failed:\n") + errorText; |
1046 |
|
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
1047 |
|
msg.run(); |
1048 |
|
} |
1049 |
|
} |
1050 |
|
|
1051 |
|
void MainWindow::setupMacros() { |
1052 |
|
MacrosSetup* setup = new MacrosSetup(); |
1053 |
|
gig::DimensionRegion* pDimRgn = m_DimRegionChooser.get_main_dimregion(); |
1054 |
|
setup->setMacros(m_macros, &m_serializationArchive, pDimRgn); |
1055 |
|
setup->signal_macros_changed().connect( |
1056 |
|
sigc::mem_fun(*this, &MainWindow::onMacrosSetupChanged) |
1057 |
|
); |
1058 |
|
setup->show(); |
1059 |
|
} |
1060 |
|
|
1061 |
|
void MainWindow::onMacrosSetupChanged(const std::vector<Serialization::Archive>& macros) { |
1062 |
|
m_macros = macros; |
1063 |
|
Settings::singleton()->saveMacros(m_macros); |
1064 |
|
updateMacroMenu(); |
1065 |
|
} |
1066 |
|
|
1067 |
|
//NOTE: the actual signal's first argument for argument 'page' is on some gtkmm version GtkNotebookPage* and on some Gtk::Widget*. Since we don't need that argument, it is simply void* here for now. |
1068 |
|
void MainWindow::on_notebook_tab_switched(void* page, guint page_num) { |
1069 |
|
bool isInstrumentsPage = (page_num == 1); |
1070 |
|
// so far we only support filtering for the instruments list, so hide the |
1071 |
|
// filter text entry field if another tab is selected |
1072 |
|
m_searchField.set_visible(isInstrumentsPage); |
1073 |
|
} |
1074 |
|
|
1075 |
bool MainWindow::on_delete_event(GdkEventAny* event) |
bool MainWindow::on_delete_event(GdkEventAny* event) |
1076 |
{ |
{ |
1077 |
return !file_is_shared && file_is_changed && !close_confirmation_dialog(); |
return !file_is_shared && file_is_changed && !close_confirmation_dialog(); |
1091 |
gig::Instrument* MainWindow::get_instrument() |
gig::Instrument* MainWindow::get_instrument() |
1092 |
{ |
{ |
1093 |
gig::Instrument* instrument = 0; |
gig::Instrument* instrument = 0; |
1094 |
Gtk::TreeModel::const_iterator it = |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
1095 |
m_TreeView.get_selection()->get_selected(); |
if (rows.empty()) return NULL; |
1096 |
|
Gtk::TreeModel::const_iterator it = m_refTreeModel->get_iter(rows[0]); |
1097 |
if (it) { |
if (it) { |
1098 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
1099 |
instrument = row[m_Columns.m_col_instr]; |
instrument = row[m_Columns.m_col_instr]; |
1136 |
add_region_to_dimregs(region, stereo, all_dimregs); |
add_region_to_dimregs(region, stereo, all_dimregs); |
1137 |
} |
} |
1138 |
} |
} |
1139 |
|
|
1140 |
|
m_RegionChooser.setModifyAllRegions(all_regions); |
1141 |
|
m_DimRegionChooser.setModifyAllRegions(all_regions); |
1142 |
|
m_DimRegionChooser.setModifyAllDimensionRegions(all_dimregs); |
1143 |
|
m_DimRegionChooser.setModifyBothChannels(stereo); |
1144 |
|
|
1145 |
|
updateClipboardCopyAvailable(); |
1146 |
} |
} |
1147 |
|
|
1148 |
void MainWindow::dimreg_all_dimregs_toggled() |
void MainWindow::dimreg_all_dimregs_toggled() |
1160 |
void MainWindow::on_sel_change() |
void MainWindow::on_sel_change() |
1161 |
{ |
{ |
1162 |
// select item in instrument menu |
// select item in instrument menu |
1163 |
Gtk::TreeModel::iterator it = m_TreeView.get_selection()->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
1164 |
if (it) { |
if (!rows.empty()) { |
1165 |
Gtk::TreePath path(it); |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
1166 |
int index = path[0]; |
if (it) { |
1167 |
const std::vector<Gtk::Widget*> children = |
Gtk::TreePath path(it); |
1168 |
instrument_menu->get_children(); |
int index = path[0]; |
1169 |
static_cast<Gtk::RadioMenuItem*>(children[index])->set_active(); |
const std::vector<Gtk::Widget*> children = |
1170 |
|
instrument_menu->get_children(); |
1171 |
|
static_cast<Gtk::RadioMenuItem*>(children[index])->set_active(); |
1172 |
|
} |
1173 |
} |
} |
1174 |
|
|
1175 |
|
updateScriptListOfMenu(); |
1176 |
|
|
1177 |
m_RegionChooser.set_instrument(get_instrument()); |
m_RegionChooser.set_instrument(get_instrument()); |
1178 |
|
|
1179 |
if (Settings::singleton()->syncSamplerInstrumentSelection) { |
if (Settings::singleton()->syncSamplerInstrumentSelection) { |
1196 |
progress_dispatcher(); |
progress_dispatcher(); |
1197 |
} |
} |
1198 |
|
|
1199 |
|
#if defined(WIN32) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) |
1200 |
|
// make sure stack is 16-byte aligned for SSE instructions |
1201 |
|
__attribute__((force_align_arg_pointer)) |
1202 |
|
#endif |
1203 |
void Loader::thread_function() |
void Loader::thread_function() |
1204 |
{ |
{ |
1205 |
printf("thread_function self=%x\n", Glib::Threads::Thread::self()); |
printf("thread_function self=%p\n", |
1206 |
|
static_cast<void*>(Glib::Threads::Thread::self())); |
1207 |
printf("Start %s\n", filename.c_str()); |
printf("Start %s\n", filename.c_str()); |
1208 |
try { |
try { |
1209 |
RIFF::File* riff = new RIFF::File(filename); |
RIFF::File* riff = new RIFF::File(filename); |
1225 |
} |
} |
1226 |
|
|
1227 |
Loader::Loader(const char* filename) |
Loader::Loader(const char* filename) |
1228 |
: filename(filename), thread(0), progress(0.f) |
: filename(filename), gig(0), thread(0), progress(0.f) |
1229 |
{ |
{ |
1230 |
} |
} |
1231 |
|
|
1236 |
#else |
#else |
1237 |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Loader::thread_function)); |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Loader::thread_function)); |
1238 |
#endif |
#endif |
1239 |
printf("launch thread=%x\n", thread); |
printf("launch thread=%p\n", static_cast<void*>(thread)); |
1240 |
} |
} |
1241 |
|
|
1242 |
float Loader::get_progress() |
float Loader::get_progress() |
1279 |
progress_dispatcher.emit(); |
progress_dispatcher.emit(); |
1280 |
} |
} |
1281 |
|
|
1282 |
|
#if defined(WIN32) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) |
1283 |
|
// make sure stack is 16-byte aligned for SSE instructions |
1284 |
|
__attribute__((force_align_arg_pointer)) |
1285 |
|
#endif |
1286 |
void Saver::thread_function() |
void Saver::thread_function() |
1287 |
{ |
{ |
1288 |
printf("thread_function self=%x\n", Glib::Threads::Thread::self()); |
printf("thread_function self=%p\n", |
1289 |
|
static_cast<void*>(Glib::Threads::Thread::self())); |
1290 |
printf("Start %s\n", filename.c_str()); |
printf("Start %s\n", filename.c_str()); |
1291 |
try { |
try { |
1292 |
gig::progress_t progress; |
gig::progress_t progress; |
1295 |
|
|
1296 |
// 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" |
1297 |
if (filename.empty()) { |
if (filename.empty()) { |
1298 |
gig->Save(&progress); |
if (!Settings::singleton()->saveWithTemporaryFile) { |
1299 |
|
// save directly over the existing .gig file |
1300 |
|
// (requires less disk space than solution below |
1301 |
|
// but may be slower) |
1302 |
|
gig->Save(&progress); |
1303 |
|
} else { |
1304 |
|
// save the file as separate temporary file first, |
1305 |
|
// then move the saved file over the old file |
1306 |
|
// (may result in performance speedup during save) |
1307 |
|
gig::String tmpname = filename + ".TMP"; |
1308 |
|
gig->Save(tmpname, &progress); |
1309 |
|
#if defined(WIN32) |
1310 |
|
if (!DeleteFile(filename.c_str())) { |
1311 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file)."); |
1312 |
|
} |
1313 |
|
#else // POSIX ... |
1314 |
|
if (unlink(filename.c_str())) { |
1315 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file): " + gig::String(strerror(errno))); |
1316 |
|
} |
1317 |
|
#endif |
1318 |
|
if (rename(tmpname.c_str(), filename.c_str())) { |
1319 |
|
#if defined(WIN32) |
1320 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file)."); |
1321 |
|
#else |
1322 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file): " + gig::String(strerror(errno))); |
1323 |
|
#endif |
1324 |
|
} |
1325 |
|
} |
1326 |
} else { |
} else { |
1327 |
gig->Save(filename, &progress); |
gig->Save(filename, &progress); |
1328 |
} |
} |
1350 |
#else |
#else |
1351 |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Saver::thread_function)); |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Saver::thread_function)); |
1352 |
#endif |
#endif |
1353 |
printf("launch thread=%x\n", thread); |
printf("launch thread=%p\n", static_cast<void*>(thread)); |
1354 |
} |
} |
1355 |
|
|
1356 |
float Saver::get_progress() |
float Saver::get_progress() |
1510 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
1511 |
std::string filename = dialog.get_filename(); |
std::string filename = dialog.get_filename(); |
1512 |
printf("filename=%s\n", filename.c_str()); |
printf("filename=%s\n", filename.c_str()); |
1513 |
printf("on_action_file_open self=%x\n", Glib::Threads::Thread::self()); |
printf("on_action_file_open self=%p\n", |
1514 |
|
static_cast<void*>(Glib::Threads::Thread::self())); |
1515 |
load_file(filename.c_str()); |
load_file(filename.c_str()); |
1516 |
current_gig_dir = Glib::path_get_dirname(filename); |
current_gig_dir = Glib::path_get_dirname(filename); |
1517 |
} |
} |
1581 |
void MainWindow::on_loader_finished() |
void MainWindow::on_loader_finished() |
1582 |
{ |
{ |
1583 |
printf("Loader finished!\n"); |
printf("Loader finished!\n"); |
1584 |
printf("on_loader_finished self=%x\n", Glib::Threads::Thread::self()); |
printf("on_loader_finished self=%p\n", |
1585 |
|
static_cast<void*>(Glib::Threads::Thread::self())); |
1586 |
load_gig(loader->gig, loader->filename.c_str()); |
load_gig(loader->gig, loader->filename.c_str()); |
1587 |
progress_dialog->hide(); |
progress_dialog->hide(); |
1588 |
} |
} |
1722 |
// show warning in the dialog |
// show warning in the dialog |
1723 |
Gtk::HBox descriptionArea; |
Gtk::HBox descriptionArea; |
1724 |
descriptionArea.set_spacing(15); |
descriptionArea.set_spacing(15); |
1725 |
Gtk::Image warningIcon(Gtk::Stock::DIALOG_WARNING, Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); |
Gtk::Image warningIcon; |
1726 |
|
warningIcon.set_from_icon_name("dialog-warning", |
1727 |
|
Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); |
1728 |
descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); |
descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); |
1729 |
#if GTKMM_MAJOR_VERSION < 3 |
#if GTKMM_MAJOR_VERSION < 3 |
1730 |
view::WrapLabel description; |
view::WrapLabel description; |
1776 |
void MainWindow::__import_queued_samples() { |
void MainWindow::__import_queued_samples() { |
1777 |
std::cout << "Starting sample import\n" << std::flush; |
std::cout << "Starting sample import\n" << std::flush; |
1778 |
Glib::ustring error_files; |
Glib::ustring error_files; |
1779 |
printf("Samples to import: %d\n", m_SampleImportQueue.size()); |
printf("Samples to import: %d\n", int(m_SampleImportQueue.size())); |
1780 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
for (std::map<gig::Sample*, SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
1781 |
iter != m_SampleImportQueue.end(); ) { |
iter != m_SampleImportQueue.end(); ) { |
1782 |
printf("Importing sample %s\n",(*iter).sample_path.c_str()); |
printf("Importing sample %s\n",iter->second.sample_path.c_str()); |
1783 |
SF_INFO info; |
SF_INFO info; |
1784 |
info.format = 0; |
info.format = 0; |
1785 |
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); |
1786 |
sf_command(hFile, SFC_SET_SCALE_FLOAT_INT_READ, 0, SF_TRUE); |
sf_command(hFile, SFC_SET_SCALE_FLOAT_INT_READ, 0, SF_TRUE); |
1787 |
try { |
try { |
1788 |
if (!hFile) throw std::string(_("could not open file")); |
if (!hFile) throw std::string(_("could not open file")); |
1805 |
throw std::string(_("format not supported")); // unsupported subformat (yet?) |
throw std::string(_("format not supported")); // unsupported subformat (yet?) |
1806 |
} |
} |
1807 |
|
|
1808 |
|
// reset write position for sample |
1809 |
|
iter->first->SetPos(0); |
1810 |
|
|
1811 |
const int bufsize = 10000; |
const int bufsize = 10000; |
1812 |
switch (bitdepth) { |
switch (bitdepth) { |
1813 |
case 16: { |
case 16: { |
1817 |
// libsndfile does the conversion for us (if needed) |
// libsndfile does the conversion for us (if needed) |
1818 |
int n = sf_readf_short(hFile, buffer, bufsize); |
int n = sf_readf_short(hFile, buffer, bufsize); |
1819 |
// write from buffer directly (physically) into .gig file |
// write from buffer directly (physically) into .gig file |
1820 |
iter->gig_sample->Write(buffer, n); |
iter->first->Write(buffer, n); |
1821 |
cnt -= n; |
cnt -= n; |
1822 |
} |
} |
1823 |
delete[] buffer; |
delete[] buffer; |
1837 |
dstbuf[j++] = srcbuf[i] >> 24; |
dstbuf[j++] = srcbuf[i] >> 24; |
1838 |
} |
} |
1839 |
// write from buffer directly (physically) into .gig file |
// write from buffer directly (physically) into .gig file |
1840 |
iter->gig_sample->Write(dstbuf, n); |
iter->first->Write(dstbuf, n); |
1841 |
cnt -= n; |
cnt -= n; |
1842 |
} |
} |
1843 |
delete[] srcbuf; |
delete[] srcbuf; |
1848 |
// cleanup |
// cleanup |
1849 |
sf_close(hFile); |
sf_close(hFile); |
1850 |
// let the sampler re-cache the sample if needed |
// let the sampler re-cache the sample if needed |
1851 |
sample_changed_signal.emit(iter->gig_sample); |
sample_changed_signal.emit(iter->first); |
1852 |
// on success we remove the sample from the import queue, |
// on success we remove the sample from the import queue, |
1853 |
// otherwise keep it, maybe it works the next time ? |
// otherwise keep it, maybe it works the next time ? |
1854 |
std::list<SampleImportItem>::iterator cur = iter; |
std::map<gig::Sample*, SampleImportItem>::iterator cur = iter; |
1855 |
++iter; |
++iter; |
1856 |
m_SampleImportQueue.erase(cur); |
m_SampleImportQueue.erase(cur); |
1857 |
} catch (std::string what) { |
} catch (std::string what) { |
1858 |
// remember the files that made trouble (and their cause) |
// remember the files that made trouble (and their cause) |
1859 |
if (!error_files.empty()) error_files += "\n"; |
if (!error_files.empty()) error_files += "\n"; |
1860 |
error_files += (*iter).sample_path += " (" + what + ")"; |
error_files += iter->second.sample_path += " (" + what + ")"; |
1861 |
++iter; |
++iter; |
1862 |
} |
} |
1863 |
} |
} |
1899 |
dialog.set_name("Gigedit"); |
dialog.set_name("Gigedit"); |
1900 |
#endif |
#endif |
1901 |
dialog.set_version(VERSION); |
dialog.set_version(VERSION); |
1902 |
dialog.set_copyright("Copyright (C) 2006-2015 Andreas Persson"); |
dialog.set_copyright("Copyright (C) 2006-2017 Andreas Persson"); |
1903 |
const std::string sComment = |
const std::string sComment = |
1904 |
_("Built " __DATE__ "\nUsing ") + |
_("Built " __DATE__ "\nUsing ") + |
1905 |
::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" + |
::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" + |
1915 |
dialog.set_comments(sComment.c_str()); |
dialog.set_comments(sComment.c_str()); |
1916 |
dialog.set_website("http://www.linuxsampler.org"); |
dialog.set_website("http://www.linuxsampler.org"); |
1917 |
dialog.set_website_label("http://www.linuxsampler.org"); |
dialog.set_website_label("http://www.linuxsampler.org"); |
1918 |
|
dialog.set_position(Gtk::WIN_POS_CENTER); |
1919 |
dialog.run(); |
dialog.run(); |
1920 |
} |
} |
1921 |
|
|
1941 |
table(2, 1), |
table(2, 1), |
1942 |
m_file(NULL) |
m_file(NULL) |
1943 |
{ |
{ |
1944 |
|
if (!Settings::singleton()->autoRestoreWindowDimension) { |
1945 |
|
set_default_size(470, 390); |
1946 |
|
set_position(Gtk::WIN_POS_MOUSE); |
1947 |
|
} |
1948 |
|
|
1949 |
set_title(_("File Properties")); |
set_title(_("File Properties")); |
1950 |
eName.set_width_chars(50); |
eName.set_width_chars(50); |
1951 |
|
|
2075 |
eGainPlus6(_("Gain +6dB"), eAttenuation, -6), |
eGainPlus6(_("Gain +6dB"), eAttenuation, -6), |
2076 |
eEffectSend(_("Effect send"), 0, 65535), |
eEffectSend(_("Effect send"), 0, 65535), |
2077 |
eFineTune(_("Fine tune"), -8400, 8400), |
eFineTune(_("Fine tune"), -8400, 8400), |
2078 |
ePitchbendRange(_("Pitchbend range"), 0, 12), |
ePitchbendRange(_("Pitchbend range"), 0, 48), |
2079 |
ePianoReleaseMode(_("Piano release mode")), |
ePianoReleaseMode(_("Piano release mode")), |
2080 |
eDimensionKeyRangeLow(_("Keyswitching range low")), |
eDimensionKeyRangeLow(_("Keyswitching range low")), |
2081 |
eDimensionKeyRangeHigh(_("Keyswitching range high")) |
eDimensionKeyRangeHigh(_("Keyswitching range high")) |
2082 |
{ |
{ |
2083 |
|
if (!Settings::singleton()->autoRestoreWindowDimension) { |
2084 |
|
//set_default_size(470, 390); |
2085 |
|
set_position(Gtk::WIN_POS_MOUSE); |
2086 |
|
} |
2087 |
|
|
2088 |
set_title(_("Instrument Properties")); |
set_title(_("Instrument Properties")); |
2089 |
|
|
2090 |
eDimensionKeyRangeLow.set_tip( |
eDimensionKeyRangeLow.set_tip( |
2205 |
propDialog.set_info(gig->pInfo); |
propDialog.set_info(gig->pInfo); |
2206 |
|
|
2207 |
instrument_name_connection.block(); |
instrument_name_connection.block(); |
2208 |
|
int index = 0; |
2209 |
for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ; |
for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ; |
2210 |
instrument = gig->GetNextInstrument()) { |
instrument = gig->GetNextInstrument(), ++index) { |
2211 |
Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
2212 |
|
const int iScriptSlots = instrument->ScriptSlotCount(); |
2213 |
|
|
2214 |
Gtk::TreeModel::iterator iter = m_refTreeModel->append(); |
Gtk::TreeModel::iterator iter = m_refTreeModel->append(); |
2215 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
2216 |
|
row[m_Columns.m_col_nr] = index; |
2217 |
row[m_Columns.m_col_name] = name; |
row[m_Columns.m_col_name] = name; |
2218 |
row[m_Columns.m_col_instr] = instrument; |
row[m_Columns.m_col_instr] = instrument; |
2219 |
|
row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; |
2220 |
|
|
2221 |
add_instrument_to_menu(name); |
add_instrument_to_menu(name); |
2222 |
} |
} |
2287 |
{ |
{ |
2288 |
instrumentProps.signal_name_changed().clear(); |
instrumentProps.signal_name_changed().clear(); |
2289 |
|
|
2290 |
Gtk::TreeModel::const_iterator it = |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
2291 |
m_TreeView.get_selection()->get_selected(); |
if (rows.empty()) { |
2292 |
|
instrumentProps.hide(); |
2293 |
|
return false; |
2294 |
|
} |
2295 |
|
Gtk::TreeModel::const_iterator it = m_refTreeModel->get_iter(rows[0]); |
2296 |
if (it) { |
if (it) { |
2297 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
2298 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
2345 |
void MainWindow::show_script_slots() { |
void MainWindow::show_script_slots() { |
2346 |
if (!file) return; |
if (!file) return; |
2347 |
// get selected instrument |
// get selected instrument |
2348 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
2349 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
if (rows.empty()) return; |
2350 |
|
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
2351 |
if (!it) return; |
if (!it) return; |
2352 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
2353 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
2355 |
|
|
2356 |
ScriptSlots* window = new ScriptSlots; |
ScriptSlots* window = new ScriptSlots; |
2357 |
window->setInstrument(instrument); |
window->setInstrument(instrument); |
2358 |
|
window->signal_script_slots_changed().connect( |
2359 |
|
sigc::mem_fun(*this, &MainWindow::onScriptSlotsModified) |
2360 |
|
); |
2361 |
//window->reparent(*this); |
//window->reparent(*this); |
2362 |
window->show(); |
window->show(); |
2363 |
} |
} |
2364 |
|
|
2365 |
|
void MainWindow::onScriptSlotsModified(gig::Instrument* pInstrument) { |
2366 |
|
if (!pInstrument) return; |
2367 |
|
const int iScriptSlots = pInstrument->ScriptSlotCount(); |
2368 |
|
|
2369 |
|
//NOTE: This is a big mess! Sometimes GTK requires m_TreeView.get_model(), here we need m_refTreeModelFilter->get_model(), otherwise accessing children below causes an error! |
2370 |
|
//Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
2371 |
|
Glib::RefPtr<Gtk::TreeModel> model = m_refTreeModelFilter->get_model(); |
2372 |
|
|
2373 |
|
for (int i = 0; i < model->children().size(); ++i) { |
2374 |
|
Gtk::TreeModel::Row row = model->children()[i]; |
2375 |
|
if (row[m_Columns.m_col_instr] != pInstrument) continue; |
2376 |
|
row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; |
2377 |
|
break; |
2378 |
|
} |
2379 |
|
|
2380 |
|
// causes the sampler to reload the instrument with the new script |
2381 |
|
on_sel_change(); |
2382 |
|
} |
2383 |
|
|
2384 |
|
void MainWindow::assignScript(gig::Script* pScript) { |
2385 |
|
if (!pScript) { |
2386 |
|
printf("assignScript() : !script\n"); |
2387 |
|
return; |
2388 |
|
} |
2389 |
|
printf("assignScript('%s')\n", pScript->Name.c_str()); |
2390 |
|
|
2391 |
|
gig::Instrument* pInstrument = get_instrument(); |
2392 |
|
if (!pInstrument) { |
2393 |
|
printf("!instrument\n"); |
2394 |
|
return; |
2395 |
|
} |
2396 |
|
|
2397 |
|
pInstrument->AddScriptSlot(pScript); |
2398 |
|
|
2399 |
|
onScriptSlotsModified(pInstrument); |
2400 |
|
} |
2401 |
|
|
2402 |
void MainWindow::on_action_refresh_all() { |
void MainWindow::on_action_refresh_all() { |
2403 |
__refreshEntireGUI(); |
__refreshEntireGUI(); |
2404 |
} |
} |
2414 |
else m_StatusBar.hide(); |
else m_StatusBar.hide(); |
2415 |
} |
} |
2416 |
|
|
2417 |
|
void MainWindow::on_auto_restore_win_dim() { |
2418 |
|
Gtk::CheckMenuItem* item = |
2419 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/AutoRestoreWinDim")); |
2420 |
|
if (!item) { |
2421 |
|
std::cerr << "/MenuBar/MenuView/AutoRestoreWinDim == NULL\n"; |
2422 |
|
return; |
2423 |
|
} |
2424 |
|
Settings::singleton()->autoRestoreWindowDimension = item->get_active(); |
2425 |
|
} |
2426 |
|
|
2427 |
|
void MainWindow::on_save_with_temporary_file() { |
2428 |
|
Gtk::CheckMenuItem* item = |
2429 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuSettings/SaveWithTemporaryFile")); |
2430 |
|
if (!item) { |
2431 |
|
std::cerr << "/MenuBar/MenuSettings/SaveWithTemporaryFile == NULL\n"; |
2432 |
|
return; |
2433 |
|
} |
2434 |
|
Settings::singleton()->saveWithTemporaryFile = item->get_active(); |
2435 |
|
} |
2436 |
|
|
2437 |
bool MainWindow::is_copy_samples_unity_note_enabled() const { |
bool MainWindow::is_copy_samples_unity_note_enabled() const { |
2438 |
Gtk::CheckMenuItem* item = |
Gtk::CheckMenuItem* item = |
2439 |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity")); |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity")); |
2501 |
void MainWindow::select_instrument(gig::Instrument* instrument) { |
void MainWindow::select_instrument(gig::Instrument* instrument) { |
2502 |
if (!instrument) return; |
if (!instrument) return; |
2503 |
|
|
2504 |
|
//NOTE: This is a big mess! Sometimes GTK requires m_refTreeModelFilter->get_model(), here we need m_TreeView.get_model(), otherwise treeview selection below causes an error! |
2505 |
Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
2506 |
|
//Glib::RefPtr<Gtk::TreeModel> model = m_refTreeModelFilter->get_model(); |
2507 |
|
|
2508 |
for (int i = 0; i < model->children().size(); ++i) { |
for (int i = 0; i < model->children().size(); ++i) { |
2509 |
Gtk::TreeModel::Row row = model->children()[i]; |
Gtk::TreeModel::Row row = model->children()[i]; |
2510 |
if (row[m_Columns.m_col_instr] == instrument) { |
if (row[m_Columns.m_col_instr] == instrument) { |
2511 |
// select and show the respective instrument in the list view |
// select and show the respective instrument in the list view |
2512 |
show_intruments_tab(); |
show_intruments_tab(); |
2513 |
|
m_TreeView.get_selection()->unselect_all(); |
2514 |
m_TreeView.get_selection()->select(model->children()[i]); |
m_TreeView.get_selection()->select(model->children()[i]); |
2515 |
Gtk::TreePath path( |
std::vector<Gtk::TreeModel::Path> rows = |
2516 |
m_TreeView.get_selection()->get_selected() |
m_TreeView.get_selection()->get_selected_rows(); |
2517 |
); |
if (!rows.empty()) |
2518 |
m_TreeView.scroll_to_row(path); |
m_TreeView.scroll_to_row(rows[0]); |
2519 |
on_sel_change(); // the regular instrument selection change callback |
on_sel_change(); // the regular instrument selection change callback |
2520 |
} |
} |
2521 |
} |
} |
2526 |
gig::Region* pRegion = (gig::Region*) dimRgn->GetParent(); |
gig::Region* pRegion = (gig::Region*) dimRgn->GetParent(); |
2527 |
gig::Instrument* pInstrument = (gig::Instrument*) pRegion->GetParent(); |
gig::Instrument* pInstrument = (gig::Instrument*) pRegion->GetParent(); |
2528 |
|
|
2529 |
|
//NOTE: This is a big mess! Sometimes GTK requires m_refTreeModelFilter->get_model(), here we need m_TreeView.get_model(), otherwise treeview selection below causes an error! |
2530 |
Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
2531 |
|
//Glib::RefPtr<Gtk::TreeModel> model = m_refTreeModelFilter->get_model(); |
2532 |
|
|
2533 |
for (int i = 0; i < model->children().size(); ++i) { |
for (int i = 0; i < model->children().size(); ++i) { |
2534 |
Gtk::TreeModel::Row row = model->children()[i]; |
Gtk::TreeModel::Row row = model->children()[i]; |
2535 |
if (row[m_Columns.m_col_instr] == pInstrument) { |
if (row[m_Columns.m_col_instr] == pInstrument) { |
2536 |
// select and show the respective instrument in the list view |
// select and show the respective instrument in the list view |
2537 |
show_intruments_tab(); |
show_intruments_tab(); |
2538 |
|
m_TreeView.get_selection()->unselect_all(); |
2539 |
m_TreeView.get_selection()->select(model->children()[i]); |
m_TreeView.get_selection()->select(model->children()[i]); |
2540 |
Gtk::TreePath path( |
std::vector<Gtk::TreeModel::Path> rows = |
2541 |
m_TreeView.get_selection()->get_selected() |
m_TreeView.get_selection()->get_selected_rows(); |
2542 |
); |
if (!rows.empty()) |
2543 |
m_TreeView.scroll_to_row(path); |
m_TreeView.scroll_to_row(rows[0]); |
2544 |
on_sel_change(); // the regular instrument selection change callback |
on_sel_change(); // the regular instrument selection change callback |
2545 |
|
|
2546 |
// select respective region in the region selector |
// select respective region in the region selector |
2566 |
Gtk::TreeModel::Row rowSample = rowGroup.children()[s]; |
Gtk::TreeModel::Row rowSample = rowGroup.children()[s]; |
2567 |
if (rowSample[m_SamplesModel.m_col_sample] == sample) { |
if (rowSample[m_SamplesModel.m_col_sample] == sample) { |
2568 |
show_samples_tab(); |
show_samples_tab(); |
2569 |
|
m_TreeViewSamples.get_selection()->unselect_all(); |
2570 |
m_TreeViewSamples.get_selection()->select(rowGroup.children()[s]); |
m_TreeViewSamples.get_selection()->select(rowGroup.children()[s]); |
2571 |
Gtk::TreePath path( |
std::vector<Gtk::TreeModel::Path> rows = |
2572 |
m_TreeViewSamples.get_selection()->get_selected() |
m_TreeViewSamples.get_selection()->get_selected_rows(); |
2573 |
); |
if (rows.empty()) return; |
2574 |
m_TreeViewSamples.scroll_to_row(path); |
m_TreeViewSamples.scroll_to_row(rows[0]); |
2575 |
return; |
return; |
2576 |
} |
} |
2577 |
} |
} |
2580 |
|
|
2581 |
void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) { |
void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) { |
2582 |
if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
2583 |
|
// by default if Ctrl keys is pressed down, then a mouse right-click |
2584 |
|
// does not select the respective row, so we must assure this |
2585 |
|
// programmatically ... |
2586 |
|
/*{ |
2587 |
|
Gtk::TreeModel::Path path; |
2588 |
|
Gtk::TreeViewColumn* pColumn = NULL; |
2589 |
|
int cellX, cellY; |
2590 |
|
bool bSuccess = m_TreeViewSamples.get_path_at_pos( |
2591 |
|
(int)button->x, (int)button->y, |
2592 |
|
path, pColumn, cellX, cellY |
2593 |
|
); |
2594 |
|
if (bSuccess) { |
2595 |
|
if (m_TreeViewSamples.get_selection()->count_selected_rows() <= 0) { |
2596 |
|
printf("not selected !!!\n"); |
2597 |
|
m_TreeViewSamples.get_selection()->select(path); |
2598 |
|
} |
2599 |
|
} |
2600 |
|
}*/ |
2601 |
|
|
2602 |
Gtk::Menu* sample_popup = |
Gtk::Menu* sample_popup = |
2603 |
dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/SamplePopupMenu")); |
dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/SamplePopupMenu")); |
2604 |
// update enabled/disabled state of sample popup items |
// update enabled/disabled state of sample popup items |
2605 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
2606 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
2607 |
bool group_selected = false; |
const int n = rows.size(); |
2608 |
bool sample_selected = false; |
int nGroups = 0; |
2609 |
if (it) { |
int nSamples = 0; |
2610 |
|
for (int r = 0; r < n; ++r) { |
2611 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[r]); |
2612 |
|
if (!it) continue; |
2613 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
2614 |
group_selected = row[m_SamplesModel.m_col_group]; |
if (row[m_SamplesModel.m_col_group]) nGroups++; |
2615 |
sample_selected = row[m_SamplesModel.m_col_sample]; |
if (row[m_SamplesModel.m_col_sample]) nSamples++; |
2616 |
} |
} |
2617 |
|
|
|
|
|
2618 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))-> |
2619 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n == 1); |
2620 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))-> |
2621 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n); |
2622 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddGroup"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddGroup"))-> |
2623 |
set_sensitive(file); |
set_sensitive(file); |
2624 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/ShowSampleRefs"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/ShowSampleRefs"))-> |
2625 |
set_sensitive(sample_selected); |
set_sensitive(nSamples == 1); |
2626 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))-> |
2627 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n); |
2628 |
// show sample popup |
// show sample popup |
2629 |
sample_popup->popup(button->button, button->time); |
sample_popup->popup(button->button, button->time); |
2630 |
|
|
2631 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/SampleProperties"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/SampleProperties"))-> |
2632 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n == 1); |
2633 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddSample"))-> |
2634 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n); |
2635 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddGroup"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddGroup"))-> |
2636 |
set_sensitive(file); |
set_sensitive(file); |
2637 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/ShowSampleRefs"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/ShowSampleRefs"))-> |
2638 |
set_sensitive(sample_selected); |
set_sensitive(nSamples == 1); |
2639 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/RemoveSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/RemoveSample"))-> |
2640 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n); |
2641 |
} |
} |
2642 |
} |
} |
2643 |
|
|
2677 |
} |
} |
2678 |
} |
} |
2679 |
|
|
2680 |
|
void MainWindow::updateScriptListOfMenu() { |
2681 |
|
// remove all entries from "Assign Script" menu |
2682 |
|
{ |
2683 |
|
const std::vector<Gtk::Widget*> children = assign_scripts_menu->get_children(); |
2684 |
|
for (int i = 0; i < children.size(); ++i) { |
2685 |
|
Gtk::Widget* child = children[i]; |
2686 |
|
assign_scripts_menu->remove(*child); |
2687 |
|
delete child; |
2688 |
|
} |
2689 |
|
} |
2690 |
|
|
2691 |
|
int iTotalScripts = 0; |
2692 |
|
|
2693 |
|
if (!file) goto noScripts; |
2694 |
|
|
2695 |
|
// add all configured macros as menu items to the "Macro" menu |
2696 |
|
for (int iGroup = 0; file->GetScriptGroup(iGroup); ++iGroup) { |
2697 |
|
gig::ScriptGroup* pGroup = file->GetScriptGroup(iGroup); |
2698 |
|
for (int iScript = 0; pGroup->GetScript(iScript); ++iScript, ++iTotalScripts) { |
2699 |
|
gig::Script* pScript = pGroup->GetScript(iScript); |
2700 |
|
std::string name = pScript->Name; |
2701 |
|
|
2702 |
|
Gtk::MenuItem* item = new Gtk::MenuItem(name); |
2703 |
|
item->signal_activate().connect( |
2704 |
|
sigc::bind( |
2705 |
|
sigc::mem_fun(*this, &MainWindow::assignScript), pScript |
2706 |
|
) |
2707 |
|
); |
2708 |
|
assign_scripts_menu->append(*item); |
2709 |
|
item->set_accel_path("<Scripts>/script_" + ToString(iTotalScripts)); |
2710 |
|
//item->set_tooltip_text(comment); |
2711 |
|
} |
2712 |
|
} |
2713 |
|
|
2714 |
|
noScripts: |
2715 |
|
|
2716 |
|
// if there are no macros configured at all, then show a dummy entry instead |
2717 |
|
if (!iTotalScripts) { |
2718 |
|
Gtk::MenuItem* item = new Gtk::MenuItem(_("No Scripts")); |
2719 |
|
item->set_sensitive(false); |
2720 |
|
assign_scripts_menu->append(*item); |
2721 |
|
} |
2722 |
|
|
2723 |
|
assign_scripts_menu->show_all_children(); |
2724 |
|
} |
2725 |
|
|
2726 |
Gtk::RadioMenuItem* MainWindow::add_instrument_to_menu( |
Gtk::RadioMenuItem* MainWindow::add_instrument_to_menu( |
2727 |
const Glib::ustring& name, int position) { |
const Glib::ustring& name, int position) { |
2728 |
|
|
2762 |
instrument_name_connection.block(); |
instrument_name_connection.block(); |
2763 |
Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append(); |
Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append(); |
2764 |
Gtk::TreeModel::Row rowInstr = *iterInstr; |
Gtk::TreeModel::Row rowInstr = *iterInstr; |
2765 |
|
rowInstr[m_Columns.m_col_nr] = m_refTreeModel->children().size() - 1; |
2766 |
rowInstr[m_Columns.m_col_name] = name; |
rowInstr[m_Columns.m_col_name] = name; |
2767 |
rowInstr[m_Columns.m_col_instr] = instrument; |
rowInstr[m_Columns.m_col_instr] = instrument; |
2768 |
|
rowInstr[m_Columns.m_col_scripts] = ""; |
2769 |
instrument_name_connection.unblock(); |
instrument_name_connection.unblock(); |
2770 |
|
|
2771 |
add_instrument_to_menu(name); |
add_instrument_to_menu(name); |
2772 |
|
select_instrument(instrument); |
|
m_TreeView.get_selection()->select(iterInstr); |
|
|
|
|
2773 |
file_changed(); |
file_changed(); |
2774 |
} |
} |
2775 |
|
|
2790 |
// retrieve the currently selected instrument |
// retrieve the currently selected instrument |
2791 |
// (being the original instrument to be duplicated) |
// (being the original instrument to be duplicated) |
2792 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
2793 |
Gtk::TreeModel::iterator itSelection = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
2794 |
if (!itSelection) return; |
for (int r = 0; r < rows.size(); ++r) { |
2795 |
Gtk::TreeModel::Row row = *itSelection; |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]); |
2796 |
gig::Instrument* instrOrig = row[m_Columns.m_col_instr]; |
if (it) { |
2797 |
if (!instrOrig) return; |
Gtk::TreeModel::Row row = *it; |
2798 |
|
gig::Instrument* instrOrig = row[m_Columns.m_col_instr]; |
2799 |
// duplicate the orginal instrument |
if (instrOrig) { |
2800 |
gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); |
// duplicate the orginal instrument |
2801 |
instrNew->pInfo->Name = |
gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); |
2802 |
instrOrig->pInfo->Name + |
instrNew->pInfo->Name = |
2803 |
gig_from_utf8(Glib::ustring(" (") + _("Copy") + ")"); |
instrOrig->pInfo->Name + |
2804 |
|
gig_from_utf8(Glib::ustring(" (") + _("Copy") + ")"); |
2805 |
|
|
2806 |
add_instrument(instrNew); |
add_instrument(instrNew); |
2807 |
|
} |
2808 |
|
} |
2809 |
|
} |
2810 |
} |
} |
2811 |
|
|
2812 |
void MainWindow::on_action_remove_instrument() { |
void MainWindow::on_action_remove_instrument() { |
2823 |
} |
} |
2824 |
|
|
2825 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
2826 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
2827 |
if (it) { |
for (int r = rows.size() - 1; r >= 0; --r) { |
2828 |
|
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]); |
2829 |
|
if (!it) continue; |
2830 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
2831 |
gig::Instrument* instr = row[m_Columns.m_col_instr]; |
gig::Instrument* instr = row[m_Columns.m_col_instr]; |
2832 |
try { |
try { |
2841 |
|
|
2842 |
// remove row from instruments tree view |
// remove row from instruments tree view |
2843 |
m_refTreeModel->erase(it); |
m_refTreeModel->erase(it); |
2844 |
|
// update "Nr" column of all instrument rows |
2845 |
|
{ |
2846 |
|
int index = 0; |
2847 |
|
for (Gtk::TreeModel::iterator it = m_refTreeModel->children().begin(); |
2848 |
|
it != m_refTreeModel->children().end(); ++it, ++index) |
2849 |
|
{ |
2850 |
|
Gtk::TreeModel::Row row = *it; |
2851 |
|
row[m_Columns.m_col_nr] = index; |
2852 |
|
} |
2853 |
|
} |
2854 |
|
|
2855 |
#if GTKMM_MAJOR_VERSION < 3 |
#if GTKMM_MAJOR_VERSION < 3 |
2856 |
// select another instrument (in gtk3 this is done |
// select another instrument (in gtk3 this is done |
2948 |
if (!script) return; |
if (!script) return; |
2949 |
|
|
2950 |
ScriptEditor* editor = new ScriptEditor; |
ScriptEditor* editor = new ScriptEditor; |
2951 |
|
editor->signal_script_to_be_changed.connect( |
2952 |
|
signal_script_to_be_changed.make_slot() |
2953 |
|
); |
2954 |
|
editor->signal_script_changed.connect( |
2955 |
|
signal_script_changed.make_slot() |
2956 |
|
); |
2957 |
editor->setScript(script); |
editor->setScript(script); |
2958 |
//editor->reparent(*this); |
//editor->reparent(*this); |
2959 |
editor->show(); |
editor->show(); |
3032 |
|
|
3033 |
// get selected group (and probably selected sample) |
// get selected group (and probably selected sample) |
3034 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
3035 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
3036 |
|
if (rows.empty()) return; |
3037 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]); |
3038 |
if (!it) return; |
if (!it) return; |
3039 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
3040 |
gig::Sample* sample = NULL; |
gig::Sample* sample = NULL; |
3183 |
SampleImportItem sched_item; |
SampleImportItem sched_item; |
3184 |
sched_item.gig_sample = sample; |
sched_item.gig_sample = sample; |
3185 |
sched_item.sample_path = *iter; |
sched_item.sample_path = *iter; |
3186 |
m_SampleImportQueue.push_back(sched_item); |
m_SampleImportQueue[sample] = sched_item; |
3187 |
// add sample to the tree view |
// add sample to the tree view |
3188 |
if (replace) { |
if (replace) { |
3189 |
row[m_SamplesModel.m_col_name] = gig_to_utf8(sample->pInfo->Name); |
row[m_SamplesModel.m_col_name] = gig_to_utf8(sample->pInfo->Name); |
3277 |
try |
try |
3278 |
{ |
{ |
3279 |
if (!hFile) throw std::string(_("could not open file")); |
if (!hFile) throw std::string(_("could not open file")); |
|
int bitdepth; |
|
3280 |
switch (info.format & 0xff) { |
switch (info.format & 0xff) { |
3281 |
case SF_FORMAT_PCM_S8: |
case SF_FORMAT_PCM_S8: |
3282 |
case SF_FORMAT_PCM_16: |
case SF_FORMAT_PCM_16: |
3283 |
case SF_FORMAT_PCM_U8: |
case SF_FORMAT_PCM_U8: |
|
bitdepth = 16; |
|
|
break; |
|
3284 |
case SF_FORMAT_PCM_24: |
case SF_FORMAT_PCM_24: |
3285 |
case SF_FORMAT_PCM_32: |
case SF_FORMAT_PCM_32: |
3286 |
case SF_FORMAT_FLOAT: |
case SF_FORMAT_FLOAT: |
3287 |
case SF_FORMAT_DOUBLE: |
case SF_FORMAT_DOUBLE: |
|
bitdepth = 24; |
|
3288 |
break; |
break; |
3289 |
default: |
default: |
3290 |
sf_close(hFile); |
sf_close(hFile); |
3293 |
SampleImportItem sched_item; |
SampleImportItem sched_item; |
3294 |
sched_item.gig_sample = sample; |
sched_item.gig_sample = sample; |
3295 |
sched_item.sample_path = filename; |
sched_item.sample_path = filename; |
3296 |
m_SampleImportQueue.push_back(sched_item); |
m_SampleImportQueue[sample] = sched_item; |
3297 |
sf_close(hFile); |
sf_close(hFile); |
3298 |
file_changed(); |
file_changed(); |
3299 |
} |
} |
3317 |
void MainWindow::on_action_remove_sample() { |
void MainWindow::on_action_remove_sample() { |
3318 |
if (!file) return; |
if (!file) return; |
3319 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
3320 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
3321 |
if (it) { |
for (int r = rows.size() - 1; r >= 0; --r) { |
3322 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[r]); |
3323 |
|
if (!it) continue; |
3324 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
3325 |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
3326 |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
3345 |
// if sample(s) were just previously added, remove |
// if sample(s) were just previously added, remove |
3346 |
// them from the import queue |
// them from the import queue |
3347 |
for (std::list<gig::Sample*>::iterator member = members.begin(); |
for (std::list<gig::Sample*>::iterator member = members.begin(); |
3348 |
member != members.end(); ++member) { |
member != members.end(); ++member) |
3349 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
{ |
3350 |
iter != m_SampleImportQueue.end(); ++iter) { |
if (m_SampleImportQueue.count(*member)) { |
3351 |
if ((*iter).gig_sample == *member) { |
printf("Removing previously added sample '%s' from group '%s'\n", |
3352 |
printf("Removing previously added sample '%s' from group '%s'\n", |
m_SampleImportQueue[sample].sample_path.c_str(), name.c_str()); |
3353 |
(*iter).sample_path.c_str(), name.c_str()); |
m_SampleImportQueue.erase(*member); |
|
m_SampleImportQueue.erase(iter); |
|
|
break; |
|
|
} |
|
3354 |
} |
} |
3355 |
} |
} |
3356 |
file_changed(); |
file_changed(); |
3365 |
samples_removed_signal.emit(); |
samples_removed_signal.emit(); |
3366 |
// if sample was just previously added, remove it from |
// if sample was just previously added, remove it from |
3367 |
// the import queue |
// the import queue |
3368 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
if (m_SampleImportQueue.count(sample)) { |
3369 |
iter != m_SampleImportQueue.end(); ++iter) { |
printf("Removing previously added sample '%s'\n", |
3370 |
if ((*iter).gig_sample == sample) { |
m_SampleImportQueue[sample].sample_path.c_str()); |
3371 |
printf("Removing previously added sample '%s'\n", |
m_SampleImportQueue.erase(sample); |
|
(*iter).sample_path.c_str()); |
|
|
m_SampleImportQueue.erase(iter); |
|
|
break; |
|
|
} |
|
3372 |
} |
} |
3373 |
dimreg_changed(); |
dimreg_changed(); |
3374 |
file_changed(); |
file_changed(); |
3424 |
gig::Sample* sample = *itSample; |
gig::Sample* sample = *itSample; |
3425 |
// remove sample from the .gig file |
// remove sample from the .gig file |
3426 |
file->DeleteSample(sample); |
file->DeleteSample(sample); |
3427 |
// if sample was just previously added, remove it fro the import queue |
// if sample was just previously added, remove it from the import queue |
3428 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
if (m_SampleImportQueue.count(sample)) { |
3429 |
iter != m_SampleImportQueue.end(); ++iter) |
printf("Removing previously added sample '%s'\n", |
3430 |
{ |
m_SampleImportQueue[sample].sample_path.c_str()); |
3431 |
if ((*iter).gig_sample == sample) { |
m_SampleImportQueue.erase(sample); |
|
printf("Removing previously added sample '%s'\n", |
|
|
(*iter).sample_path.c_str()); |
|
|
m_SampleImportQueue.erase(iter); |
|
|
break; |
|
|
} |
|
3432 |
} |
} |
3433 |
} |
} |
3434 |
} catch (RIFF::Exception e) { |
} catch (RIFF::Exception e) { |
3487 |
gig::Instrument* src = NULL; |
gig::Instrument* src = NULL; |
3488 |
{ |
{ |
3489 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
3490 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
3491 |
if (it) { |
if (!rows.empty()) { |
3492 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
3493 |
src = row[m_Columns.m_col_instr]; |
if (it) { |
3494 |
|
Gtk::TreeModel::Row row = *it; |
3495 |
|
src = row[m_Columns.m_col_instr]; |
3496 |
|
} |
3497 |
} |
} |
3498 |
} |
} |
3499 |
if (!src) return; |
if (!src) return; |
3548 |
// get selected sample |
// get selected sample |
3549 |
gig::Sample* sample = NULL; |
gig::Sample* sample = NULL; |
3550 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
3551 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
3552 |
if (it) { |
if (!rows.empty()) { |
3553 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]); |
3554 |
sample = row[m_SamplesModel.m_col_sample]; |
if (it) { |
3555 |
|
Gtk::TreeModel::Row row = *it; |
3556 |
|
sample = row[m_SamplesModel.m_col_sample]; |
3557 |
|
} |
3558 |
} |
} |
3559 |
// pass the gig::Sample as pointer |
// pass the gig::Sample as pointer |
3560 |
selection_data.set(selection_data.get_target(), 0/*unused*/, (const guchar*)&sample, |
selection_data.set(selection_data.get_target(), 0/*unused*/, (const guchar*)&sample, |
3694 |
if (!script) return; |
if (!script) return; |
3695 |
|
|
3696 |
ScriptEditor* editor = new ScriptEditor; |
ScriptEditor* editor = new ScriptEditor; |
3697 |
|
editor->signal_script_to_be_changed.connect( |
3698 |
|
signal_script_to_be_changed.make_slot() |
3699 |
|
); |
3700 |
|
editor->signal_script_changed.connect( |
3701 |
|
signal_script_changed.make_slot() |
3702 |
|
); |
3703 |
editor->setScript(script); |
editor->setScript(script); |
3704 |
//editor->reparent(*this); |
//editor->reparent(*this); |
3705 |
editor->show(); |
editor->show(); |
3739 |
} |
} |
3740 |
} |
} |
3741 |
|
|
3742 |
|
bool MainWindow::instrument_row_visible(const Gtk::TreeModel::const_iterator& iter) { |
3743 |
|
if (!iter) |
3744 |
|
return true; |
3745 |
|
|
3746 |
|
Glib::ustring pattern = m_searchText.get_text().lowercase(); |
3747 |
|
trim(pattern); |
3748 |
|
if (pattern.empty()) return true; |
3749 |
|
|
3750 |
|
Gtk::TreeModel::Row row = *iter; |
3751 |
|
Glib::ustring name = row[m_Columns.m_col_name]; |
3752 |
|
name = name.lowercase(); |
3753 |
|
|
3754 |
|
std::vector<Glib::ustring> tokens = Glib::Regex::split_simple(" ", pattern); |
3755 |
|
for (int t = 0; t < tokens.size(); ++t) |
3756 |
|
if (name.find(tokens[t]) == Glib::ustring::npos) |
3757 |
|
return false; |
3758 |
|
|
3759 |
|
return true; |
3760 |
|
} |
3761 |
|
|
3762 |
void MainWindow::on_action_combine_instruments() { |
void MainWindow::on_action_combine_instruments() { |
3763 |
CombineInstrumentsDialog* d = new CombineInstrumentsDialog(*this, file); |
CombineInstrumentsDialog* d = new CombineInstrumentsDialog(*this, file); |
3764 |
|
|
3765 |
|
// take over selection from instruments list view for the combine dialog's |
3766 |
|
// list view as pre-selection |
3767 |
|
std::set<int> indeces; |
3768 |
|
{ |
3769 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
3770 |
|
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
3771 |
|
for (int r = 0; r < rows.size(); ++r) { |
3772 |
|
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]); |
3773 |
|
if (it) { |
3774 |
|
Gtk::TreeModel::Row row = *it; |
3775 |
|
int index = row[m_Columns.m_col_nr]; |
3776 |
|
indeces.insert(index); |
3777 |
|
} |
3778 |
|
} |
3779 |
|
} |
3780 |
|
d->setSelectedInstruments(indeces); |
3781 |
|
|
3782 |
d->show_all(); |
d->show_all(); |
|
d->resize(500, 400); |
|
3783 |
d->run(); |
d->run(); |
3784 |
if (d->fileWasChanged()) { |
if (d->fileWasChanged()) { |
3785 |
// update GUI with new instrument just created |
// update GUI with new instrument just created |
3790 |
|
|
3791 |
void MainWindow::on_action_view_references() { |
void MainWindow::on_action_view_references() { |
3792 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
3793 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
3794 |
|
if (rows.empty()) return; |
3795 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]); |
3796 |
if (!it) return; |
if (!it) return; |
3797 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
3798 |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
3933 |
// show warning in the file picker dialog |
// show warning in the file picker dialog |
3934 |
Gtk::HBox descriptionArea; |
Gtk::HBox descriptionArea; |
3935 |
descriptionArea.set_spacing(15); |
descriptionArea.set_spacing(15); |
3936 |
Gtk::Image warningIcon(Gtk::Stock::DIALOG_WARNING, Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); |
Gtk::Image warningIcon; |
3937 |
|
warningIcon.set_from_icon_name("dialog-warning", |
3938 |
|
Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); |
3939 |
descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); |
descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); |
3940 |
#if GTKMM_MAJOR_VERSION < 3 |
#if GTKMM_MAJOR_VERSION < 3 |
3941 |
view::WrapLabel description; |
view::WrapLabel description; |
3958 |
descriptionArea.show_all(); |
descriptionArea.show_all(); |
3959 |
|
|
3960 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
3961 |
printf("on_action_merge_files self=%x\n", Glib::Threads::Thread::self()); |
printf("on_action_merge_files self=%p\n", |
3962 |
|
static_cast<void*>(Glib::Threads::Thread::self())); |
3963 |
std::vector<std::string> filenames = dialog.get_filenames(); |
std::vector<std::string> filenames = dialog.get_filenames(); |
3964 |
|
|
3965 |
// merge the selected files to the currently open .gig file |
// merge the selected files to the currently open .gig file |
4041 |
m_TreeViewNotebook.set_current_page(2); |
m_TreeViewNotebook.set_current_page(2); |
4042 |
} |
} |
4043 |
|
|
4044 |
|
void MainWindow::select_instrument_by_dir(int dir) { |
4045 |
|
if (!file) return; |
4046 |
|
gig::Instrument* pInstrument = get_instrument(); |
4047 |
|
if (!pInstrument) { |
4048 |
|
select_instrument( file->GetInstrument(0) ); |
4049 |
|
return; |
4050 |
|
} |
4051 |
|
for (int i = 0; file->GetInstrument(i); ++i) { |
4052 |
|
if (file->GetInstrument(i) == pInstrument) { |
4053 |
|
select_instrument( file->GetInstrument(i + dir) ); |
4054 |
|
return; |
4055 |
|
} |
4056 |
|
} |
4057 |
|
} |
4058 |
|
|
4059 |
|
void MainWindow::select_prev_instrument() { |
4060 |
|
select_instrument_by_dir(-1); |
4061 |
|
} |
4062 |
|
|
4063 |
|
void MainWindow::select_next_instrument() { |
4064 |
|
select_instrument_by_dir(1); |
4065 |
|
} |
4066 |
|
|
4067 |
|
void MainWindow::select_prev_region() { |
4068 |
|
m_RegionChooser.select_prev_region(); |
4069 |
|
} |
4070 |
|
|
4071 |
|
void MainWindow::select_next_region() { |
4072 |
|
m_RegionChooser.select_next_region(); |
4073 |
|
} |
4074 |
|
|
4075 |
|
void MainWindow::select_next_dim_rgn_zone() { |
4076 |
|
if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser |
4077 |
|
m_DimRegionChooser.select_next_dimzone(); |
4078 |
|
} |
4079 |
|
|
4080 |
|
void MainWindow::select_prev_dim_rgn_zone() { |
4081 |
|
if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser |
4082 |
|
m_DimRegionChooser.select_prev_dimzone(); |
4083 |
|
} |
4084 |
|
|
4085 |
|
void MainWindow::select_add_next_dim_rgn_zone() { |
4086 |
|
m_DimRegionChooser.select_next_dimzone(true); |
4087 |
|
} |
4088 |
|
|
4089 |
|
void MainWindow::select_add_prev_dim_rgn_zone() { |
4090 |
|
m_DimRegionChooser.select_prev_dimzone(true); |
4091 |
|
} |
4092 |
|
|
4093 |
|
void MainWindow::select_prev_dimension() { |
4094 |
|
if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser |
4095 |
|
m_DimRegionChooser.select_prev_dimension(); |
4096 |
|
} |
4097 |
|
|
4098 |
|
void MainWindow::select_next_dimension() { |
4099 |
|
if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser |
4100 |
|
m_DimRegionChooser.select_next_dimension(); |
4101 |
|
} |
4102 |
|
|
4103 |
|
#define CLIPBOARD_DIMENSIONREGION_TARGET \ |
4104 |
|
("libgig.DimensionRegion." + m_serializationArchive.rawDataFormat()) |
4105 |
|
|
4106 |
|
void MainWindow::copy_selected_dimrgn() { |
4107 |
|
gig::DimensionRegion* pDimRgn = m_DimRegionChooser.get_main_dimregion(); |
4108 |
|
if (!pDimRgn) { |
4109 |
|
updateClipboardPasteAvailable(); |
4110 |
|
updateClipboardCopyAvailable(); |
4111 |
|
return; |
4112 |
|
} |
4113 |
|
|
4114 |
|
std::vector<Gtk::TargetEntry> targets; |
4115 |
|
targets.push_back( Gtk::TargetEntry(CLIPBOARD_DIMENSIONREGION_TARGET) ); |
4116 |
|
|
4117 |
|
Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); |
4118 |
|
clipboard->set( |
4119 |
|
targets, |
4120 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_get), |
4121 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_clear) |
4122 |
|
); |
4123 |
|
|
4124 |
|
m_serializationArchive.serialize(pDimRgn); |
4125 |
|
|
4126 |
|
updateClipboardPasteAvailable(); |
4127 |
|
} |
4128 |
|
|
4129 |
|
void MainWindow::paste_copied_dimrgn() { |
4130 |
|
Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); |
4131 |
|
clipboard->request_contents( |
4132 |
|
CLIPBOARD_DIMENSIONREGION_TARGET, |
4133 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_received) |
4134 |
|
); |
4135 |
|
updateClipboardPasteAvailable(); |
4136 |
|
} |
4137 |
|
|
4138 |
|
void MainWindow::adjust_clipboard_content() { |
4139 |
|
MacroEditor* editor = new MacroEditor(); |
4140 |
|
editor->setMacro(&m_serializationArchive, true); |
4141 |
|
editor->show(); |
4142 |
|
} |
4143 |
|
|
4144 |
|
void MainWindow::updateClipboardPasteAvailable() { |
4145 |
|
Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); |
4146 |
|
clipboard->request_targets( |
4147 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_received_targets) |
4148 |
|
); |
4149 |
|
} |
4150 |
|
|
4151 |
|
void MainWindow::updateClipboardCopyAvailable() { |
4152 |
|
bool bDimensionRegionCopyIsPossible = m_DimRegionChooser.get_main_dimregion(); |
4153 |
|
static_cast<Gtk::MenuItem*>( |
4154 |
|
uiManager->get_widget("/MenuBar/MenuEdit/CopyDimRgn") |
4155 |
|
)->set_sensitive(bDimensionRegionCopyIsPossible); |
4156 |
|
} |
4157 |
|
|
4158 |
|
void MainWindow::on_clipboard_owner_change(GdkEventOwnerChange* event) { |
4159 |
|
updateClipboardPasteAvailable(); |
4160 |
|
} |
4161 |
|
|
4162 |
|
void MainWindow::on_clipboard_get(Gtk::SelectionData& selection_data, guint /*info*/) { |
4163 |
|
const std::string target = selection_data.get_target(); |
4164 |
|
if (target == CLIPBOARD_DIMENSIONREGION_TARGET) { |
4165 |
|
selection_data.set( |
4166 |
|
CLIPBOARD_DIMENSIONREGION_TARGET, 8 /* "format": probably unused*/, |
4167 |
|
&m_serializationArchive.rawData()[0], |
4168 |
|
m_serializationArchive.rawData().size() |
4169 |
|
); |
4170 |
|
} else { |
4171 |
|
std::cerr << "Clipboard: content for unknown target '" << target << "' requested\n"; |
4172 |
|
} |
4173 |
|
} |
4174 |
|
|
4175 |
|
void MainWindow::on_clipboard_clear() { |
4176 |
|
m_serializationArchive.clear(); |
4177 |
|
updateClipboardPasteAvailable(); |
4178 |
|
updateClipboardCopyAvailable(); |
4179 |
|
} |
4180 |
|
|
4181 |
|
//NOTE: Might throw exception !!! |
4182 |
|
void MainWindow::applyMacro(Serialization::Archive& macro) { |
4183 |
|
gig::DimensionRegion* pDimRgn = m_DimRegionChooser.get_main_dimregion(); |
4184 |
|
if (!pDimRgn) return; |
4185 |
|
|
4186 |
|
for (std::set<gig::DimensionRegion*>::iterator itDimReg = dimreg_edit.dimregs.begin(); |
4187 |
|
itDimReg != dimreg_edit.dimregs.end(); ++itDimReg) |
4188 |
|
{ |
4189 |
|
gig::DimensionRegion* pDimRgn = *itDimReg; |
4190 |
|
DimRegionChangeGuard(this, pDimRgn); |
4191 |
|
macro.deserialize(pDimRgn); |
4192 |
|
} |
4193 |
|
//region_changed() |
4194 |
|
file_changed(); |
4195 |
|
dimreg_changed(); |
4196 |
|
} |
4197 |
|
|
4198 |
|
void MainWindow::on_clipboard_received(const Gtk::SelectionData& selection_data) { |
4199 |
|
const std::string target = selection_data.get_target(); |
4200 |
|
if (target == CLIPBOARD_DIMENSIONREGION_TARGET) { |
4201 |
|
Glib::ustring errorText; |
4202 |
|
try { |
4203 |
|
m_serializationArchive.decode( |
4204 |
|
selection_data.get_data(), selection_data.get_length() |
4205 |
|
); |
4206 |
|
applyMacro(m_serializationArchive); |
4207 |
|
} catch (Serialization::Exception e) { |
4208 |
|
errorText = e.Message; |
4209 |
|
} catch (...) { |
4210 |
|
errorText = _("Unknown exception while pasting DimensionRegion"); |
4211 |
|
} |
4212 |
|
if (!errorText.empty()) { |
4213 |
|
Glib::ustring txt = _("Pasting DimensionRegion failed:\n") + errorText; |
4214 |
|
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
4215 |
|
msg.run(); |
4216 |
|
} |
4217 |
|
} |
4218 |
|
} |
4219 |
|
|
4220 |
|
void MainWindow::on_clipboard_received_targets(const std::vector<Glib::ustring>& targets) { |
4221 |
|
const bool bDimensionRegionPasteIsPossible = |
4222 |
|
std::find(targets.begin(), targets.end(), |
4223 |
|
CLIPBOARD_DIMENSIONREGION_TARGET) != targets.end(); |
4224 |
|
|
4225 |
|
static_cast<Gtk::MenuItem*>( |
4226 |
|
uiManager->get_widget("/MenuBar/MenuEdit/PasteDimRgn") |
4227 |
|
)->set_sensitive(bDimensionRegionPasteIsPossible); |
4228 |
|
|
4229 |
|
static_cast<Gtk::MenuItem*>( |
4230 |
|
uiManager->get_widget("/MenuBar/MenuEdit/AdjustClipboard") |
4231 |
|
)->set_sensitive(bDimensionRegionPasteIsPossible); |
4232 |
|
} |
4233 |
|
|
4234 |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
4235 |
return file_structure_to_be_changed_signal; |
return file_structure_to_be_changed_signal; |
4236 |
} |
} |