1 |
/* |
/* |
2 |
* Copyright (C) 2006, 2007 Andreas Persson |
* Copyright (C) 2006-2014 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 |
17 |
* 02110-1301 USA. |
* 02110-1301 USA. |
18 |
*/ |
*/ |
19 |
|
|
|
#include <libintl.h> |
|
20 |
#include <iostream> |
#include <iostream> |
21 |
|
#include <cstring> |
22 |
|
|
23 |
|
#include <glibmm/convert.h> |
24 |
|
#include <glibmm/dispatcher.h> |
25 |
|
#include <glibmm/miscutils.h> |
26 |
|
#include <glibmm/stringutils.h> |
27 |
|
#include <gtkmm/aboutdialog.h> |
28 |
#include <gtkmm/filechooserdialog.h> |
#include <gtkmm/filechooserdialog.h> |
29 |
#include <gtkmm/messagedialog.h> |
#include <gtkmm/messagedialog.h> |
30 |
#include <gtkmm/stock.h> |
#include <gtkmm/stock.h> |
31 |
#include <gtkmm/targetentry.h> |
#include <gtkmm/targetentry.h> |
32 |
#include <gtkmm/main.h> |
#include <gtkmm/main.h> |
33 |
|
#include <gtkmm/toggleaction.h> |
34 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 6) || GTKMM_MAJOR_VERSION > 2 |
#if GTKMM_MAJOR_VERSION < 3 |
35 |
#define ABOUT_DIALOG |
#include "wrapLabel.hh" |
|
#include <gtkmm/aboutdialog.h> |
|
36 |
#endif |
#endif |
37 |
|
|
38 |
#if (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION < 6) || GLIBMM_MAJOR_VERSION < 2 |
#include "global.h" |
39 |
namespace Glib { |
#include "compat.h" |
|
Glib::ustring filename_display_basename(const std::string& filename) |
|
|
{ |
|
|
gchar* gstr = g_path_get_basename(filename.c_str()); |
|
|
Glib::ustring str(gstr); |
|
|
g_free(gstr); |
|
|
return Glib::filename_to_utf8(str); |
|
|
} |
|
|
} |
|
|
#endif |
|
40 |
|
|
41 |
#include <stdio.h> |
#include <stdio.h> |
42 |
#include <sndfile.h> |
#include <sndfile.h> |
43 |
|
#include <assert.h> |
44 |
|
|
45 |
#include "mainwindow.h" |
#include "mainwindow.h" |
46 |
|
#include "Settings.h" |
47 |
|
#include "CombineInstrumentsDialog.h" |
48 |
|
#include "../../gfx/status_attached.xpm" |
49 |
|
#include "../../gfx/status_detached.xpm" |
50 |
|
|
|
#define _(String) gettext(String) |
|
51 |
|
|
52 |
template<class T> inline std::string ToString(T o) { |
MainWindow::MainWindow() : |
53 |
std::stringstream ss; |
dimreg_label(_("Changes apply to:")), |
54 |
ss << o; |
dimreg_all_regions(_("all regions")), |
55 |
return ss.str(); |
dimreg_all_dimregs(_("all dimension splits")), |
56 |
} |
dimreg_stereo(_("both channels")) |
|
|
|
|
MainWindow::MainWindow() |
|
57 |
{ |
{ |
58 |
// set_border_width(5); |
// set_border_width(5); |
59 |
// set_default_size(400, 200); |
// set_default_size(400, 200); |
62 |
add(m_VBox); |
add(m_VBox); |
63 |
|
|
64 |
// Handle selection |
// Handle selection |
65 |
Glib::RefPtr<Gtk::TreeSelection> tree_sel_ref = m_TreeView.get_selection(); |
m_TreeView.get_selection()->signal_changed().connect( |
|
tree_sel_ref->signal_changed().connect( |
|
66 |
sigc::mem_fun(*this, &MainWindow::on_sel_change)); |
sigc::mem_fun(*this, &MainWindow::on_sel_change)); |
67 |
|
|
68 |
// m_TreeView.set_reorderable(); |
// m_TreeView.set_reorderable(); |
82 |
m_TreeViewNotebook.set_size_request(300); |
m_TreeViewNotebook.set_size_request(300); |
83 |
|
|
84 |
m_HPaned.add1(m_TreeViewNotebook); |
m_HPaned.add1(m_TreeViewNotebook); |
85 |
m_HPaned.add2(dimreg_edit); |
dimreg_hbox.add(dimreg_label); |
86 |
|
dimreg_hbox.add(dimreg_all_regions); |
87 |
|
dimreg_hbox.add(dimreg_all_dimregs); |
88 |
|
dimreg_stereo.set_active(); |
89 |
|
dimreg_hbox.add(dimreg_stereo); |
90 |
|
dimreg_vbox.add(dimreg_edit); |
91 |
|
dimreg_vbox.pack_start(dimreg_hbox, Gtk::PACK_SHRINK); |
92 |
|
m_HPaned.add2(dimreg_vbox); |
93 |
|
|
94 |
|
dimreg_label.set_tooltip_text(_("To automatically apply your changes above globally to the entire instrument, check all 3 check boxes on the right.")); |
95 |
|
dimreg_all_regions.set_tooltip_text(_("If checked: all changes you perform above will automatically be applied to all regions of this instrument as well.")); |
96 |
|
dimreg_all_dimregs.set_tooltip_text(_("If checked: all changes you perform above will automatically be applied as well to all dimension splits of the region selected below.")); |
97 |
|
dimreg_stereo.set_tooltip_text(_("If checked: all changes you perform above will automatically be applied to both audio channel splits (only if a \"stereo\" dimension is defined below).")); |
98 |
|
|
99 |
m_TreeViewNotebook.append_page(m_ScrolledWindowSamples, "Samples"); |
m_TreeViewNotebook.append_page(m_ScrolledWindowSamples, _("Samples")); |
100 |
m_TreeViewNotebook.append_page(m_ScrolledWindow, "Instruments"); |
m_TreeViewNotebook.append_page(m_ScrolledWindow, _("Instruments")); |
101 |
|
|
102 |
|
|
103 |
actionGroup = Gtk::ActionGroup::create(); |
actionGroup = Gtk::ActionGroup::create(); |
129 |
Gtk::Stock::PROPERTIES), |
Gtk::Stock::PROPERTIES), |
130 |
sigc::mem_fun( |
sigc::mem_fun( |
131 |
*this, &MainWindow::show_instr_props)); |
*this, &MainWindow::show_instr_props)); |
132 |
|
actionGroup->add(Gtk::Action::create("MidiRules", |
133 |
|
_("_Midi Rules")), |
134 |
|
sigc::mem_fun( |
135 |
|
*this, &MainWindow::show_midi_rules)); |
136 |
actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT), |
actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT), |
137 |
sigc::mem_fun( |
sigc::mem_fun( |
138 |
*this, &MainWindow::on_action_quit)); |
*this, &MainWindow::on_action_quit)); |
139 |
actionGroup->add(Gtk::Action::create("MenuInstrument", _("_Instrument"))); |
actionGroup->add(Gtk::Action::create("MenuInstrument", _("_Instrument"))); |
140 |
|
|
141 |
|
|
142 |
|
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); |
143 |
|
|
144 |
|
Glib::RefPtr<Gtk::ToggleAction> toggle_action = |
145 |
|
Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note")); |
146 |
|
toggle_action->set_active(true); |
147 |
|
actionGroup->add(toggle_action); |
148 |
|
|
149 |
|
toggle_action = |
150 |
|
Gtk::ToggleAction::create("CopySampleTune", _("Copy Sample's _Fine Tune")); |
151 |
|
toggle_action->set_active(true); |
152 |
|
actionGroup->add(toggle_action); |
153 |
|
|
154 |
|
toggle_action = |
155 |
|
Gtk::ToggleAction::create("CopySampleLoop", _("Copy Sample's _Loop Points")); |
156 |
|
toggle_action->set_active(true); |
157 |
|
actionGroup->add(toggle_action); |
158 |
|
|
159 |
|
|
160 |
|
actionGroup->add(Gtk::Action::create("MenuView", _("_View"))); |
161 |
|
toggle_action = |
162 |
|
Gtk::ToggleAction::create("Statusbar", _("_Statusbar")); |
163 |
|
toggle_action->set_active(true); |
164 |
|
actionGroup->add(toggle_action, |
165 |
|
sigc::mem_fun( |
166 |
|
*this, &MainWindow::on_action_view_status_bar)); |
167 |
|
|
168 |
action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP); |
action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP); |
169 |
actionGroup->add(Gtk::Action::create("MenuHelp", |
actionGroup->add(Gtk::Action::create("MenuHelp", |
170 |
action->property_label())); |
action->property_label())); |
|
#ifdef ABOUT_DIALOG |
|
171 |
actionGroup->add(Gtk::Action::create("About", Gtk::Stock::ABOUT), |
actionGroup->add(Gtk::Action::create("About", Gtk::Stock::ABOUT), |
172 |
sigc::mem_fun( |
sigc::mem_fun( |
173 |
*this, &MainWindow::on_action_help_about)); |
*this, &MainWindow::on_action_help_about)); |
|
#endif |
|
174 |
actionGroup->add( |
actionGroup->add( |
175 |
Gtk::Action::create("AddInstrument", _("Add _Instrument")), |
Gtk::Action::create("AddInstrument", _("Add _Instrument")), |
176 |
sigc::mem_fun(*this, &MainWindow::on_action_add_instrument) |
sigc::mem_fun(*this, &MainWindow::on_action_add_instrument) |
177 |
); |
); |
178 |
actionGroup->add( |
actionGroup->add( |
179 |
|
Gtk::Action::create("DupInstrument", _("_Duplicate Instrument")), |
180 |
|
sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument) |
181 |
|
); |
182 |
|
actionGroup->add( |
183 |
Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE), |
Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE), |
184 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument) |
185 |
); |
); |
186 |
|
|
187 |
|
|
188 |
|
actionGroup->add(Gtk::Action::create("MenuSettings", _("_Settings"))); |
189 |
|
|
190 |
|
toggle_action = |
191 |
|
Gtk::ToggleAction::create("WarnUserOnExtensions", _("Show warning on format _extensions")); |
192 |
|
toggle_action->set_active(Settings::singleton()->warnUserOnExtensions); |
193 |
|
actionGroup->add( |
194 |
|
toggle_action, |
195 |
|
sigc::mem_fun(*this, &MainWindow::on_action_warn_user_on_extensions) |
196 |
|
); |
197 |
|
|
198 |
|
|
199 |
|
actionGroup->add(Gtk::Action::create("MenuTools", _("_Tools"))); |
200 |
|
|
201 |
|
actionGroup->add( |
202 |
|
Gtk::Action::create("CombineInstruments", _("_Combine Instruments...")), |
203 |
|
sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments) |
204 |
|
); |
205 |
|
|
206 |
|
actionGroup->add( |
207 |
|
Gtk::Action::create("MergeFiles", _("_Merge Files...")), |
208 |
|
sigc::mem_fun(*this, &MainWindow::on_action_merge_files) |
209 |
|
); |
210 |
|
|
211 |
|
|
212 |
// sample right-click popup actions |
// sample right-click popup actions |
213 |
actionGroup->add( |
actionGroup->add( |
214 |
Gtk::Action::create("SampleProperties", Gtk::Stock::PROPERTIES), |
Gtk::Action::create("SampleProperties", Gtk::Stock::PROPERTIES), |
219 |
sigc::mem_fun(*this, &MainWindow::on_action_add_group) |
sigc::mem_fun(*this, &MainWindow::on_action_add_group) |
220 |
); |
); |
221 |
actionGroup->add( |
actionGroup->add( |
222 |
Gtk::Action::create("AddSample", _("Add _Sample(s)")), |
Gtk::Action::create("AddSample", _("Add _Sample(s)...")), |
223 |
sigc::mem_fun(*this, &MainWindow::on_action_add_sample) |
sigc::mem_fun(*this, &MainWindow::on_action_add_sample) |
224 |
); |
); |
225 |
actionGroup->add( |
actionGroup->add( |
226 |
Gtk::Action::create("RemoveSample", Gtk::Stock::REMOVE), |
Gtk::Action::create("RemoveSample", Gtk::Stock::REMOVE), |
227 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_sample) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_sample) |
228 |
); |
); |
229 |
|
actionGroup->add( |
230 |
|
Gtk::Action::create("ReplaceAllSamplesInAllGroups", |
231 |
|
_("Replace All Samples in All Groups...")), |
232 |
|
sigc::mem_fun(*this, &MainWindow::on_action_replace_all_samples_in_all_groups) |
233 |
|
); |
234 |
|
|
235 |
uiManager = Gtk::UIManager::create(); |
uiManager = Gtk::UIManager::create(); |
236 |
uiManager->insert_action_group(actionGroup); |
uiManager->insert_action_group(actionGroup); |
250 |
" <separator/>" |
" <separator/>" |
251 |
" <menuitem action='Quit'/>" |
" <menuitem action='Quit'/>" |
252 |
" </menu>" |
" </menu>" |
253 |
|
" <menu action='MenuEdit'>" |
254 |
|
" <menuitem action='CopySampleUnity'/>" |
255 |
|
" <menuitem action='CopySampleTune'/>" |
256 |
|
" <menuitem action='CopySampleLoop'/>" |
257 |
|
" </menu>" |
258 |
" <menu action='MenuInstrument'>" |
" <menu action='MenuInstrument'>" |
259 |
" </menu>" |
" </menu>" |
260 |
#ifdef ABOUT_DIALOG |
" <menu action='MenuView'>" |
261 |
|
" <menuitem action='Statusbar'/>" |
262 |
|
" </menu>" |
263 |
|
" <menu action='MenuTools'>" |
264 |
|
" <menuitem action='CombineInstruments'/>" |
265 |
|
" <menuitem action='MergeFiles'/>" |
266 |
|
" </menu>" |
267 |
|
" <menu action='MenuSettings'>" |
268 |
|
" <menuitem action='WarnUserOnExtensions'/>" |
269 |
|
" </menu>" |
270 |
" <menu action='MenuHelp'>" |
" <menu action='MenuHelp'>" |
271 |
" <menuitem action='About'/>" |
" <menuitem action='About'/>" |
272 |
" </menu>" |
" </menu>" |
|
#endif |
|
273 |
" </menubar>" |
" </menubar>" |
274 |
" <popup name='PopupMenu'>" |
" <popup name='PopupMenu'>" |
275 |
" <menuitem action='InstrProperties'/>" |
" <menuitem action='InstrProperties'/>" |
276 |
|
" <menuitem action='MidiRules'/>" |
277 |
" <menuitem action='AddInstrument'/>" |
" <menuitem action='AddInstrument'/>" |
278 |
|
" <menuitem action='DupInstrument'/>" |
279 |
" <separator/>" |
" <separator/>" |
280 |
" <menuitem action='RemoveInstrument'/>" |
" <menuitem action='RemoveInstrument'/>" |
281 |
" </popup>" |
" </popup>" |
283 |
" <menuitem action='SampleProperties'/>" |
" <menuitem action='SampleProperties'/>" |
284 |
" <menuitem action='AddGroup'/>" |
" <menuitem action='AddGroup'/>" |
285 |
" <menuitem action='AddSample'/>" |
" <menuitem action='AddSample'/>" |
286 |
|
" <menuitem action='ReplaceAllSamplesInAllGroups' />" |
287 |
" <separator/>" |
" <separator/>" |
288 |
" <menuitem action='RemoveSample'/>" |
" <menuitem action='RemoveSample'/>" |
289 |
" </popup>" |
" </popup>" |
291 |
uiManager->add_ui_from_string(ui_info); |
uiManager->add_ui_from_string(ui_info); |
292 |
|
|
293 |
popup_menu = dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/PopupMenu")); |
popup_menu = dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/PopupMenu")); |
294 |
|
|
295 |
|
// Set tooltips for menu items (for some reason, setting a tooltip on the |
296 |
|
// respective Gtk::Action objects above will simply be ignored, no matter |
297 |
|
// if using Gtk::Action::set_tooltip() or passing the tooltip string on |
298 |
|
// Gtk::Action::create()). |
299 |
|
{ |
300 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
301 |
|
uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity")); |
302 |
|
item->set_tooltip_text(_("Used when dragging a sample to a region's sample reference field. You may disable this for example if you want to replace an existing sample in a region with a new sample, but don't want that the region's current unity note setting will be altered by this action.")); |
303 |
|
} |
304 |
|
{ |
305 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
306 |
|
uiManager->get_widget("/MenuBar/MenuEdit/CopySampleTune")); |
307 |
|
item->set_tooltip_text(_("Used when dragging a sample to a region's sample reference field. You may disable this for example if you want to replace an existing sample in a region with a new sample, but don't want that the region's current sample playback tuning will be altered by this action.")); |
308 |
|
} |
309 |
|
{ |
310 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
311 |
|
uiManager->get_widget("/MenuBar/MenuEdit/CopySampleLoop")); |
312 |
|
item->set_tooltip_text(_("Used when dragging a sample to a region's sample reference field. You may disable this for example if you want to replace an existing sample in a region with a new sample, but don't want that the region's current loop informations to be altered by this action.")); |
313 |
|
} |
314 |
|
{ |
315 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
316 |
|
uiManager->get_widget("/MenuBar/MenuSettings/WarnUserOnExtensions")); |
317 |
|
item->set_tooltip_text(_("If checked, a warning will be shown whenever you try to use a feature which is based on a LinuxSampler extension ontop of the original gig format, which would not work with the Gigasampler/GigaStudio application.")); |
318 |
|
} |
319 |
|
{ |
320 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
321 |
|
uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments")); |
322 |
|
item->set_tooltip_text(_("Create combi sounds out of individual sounds of this .gig file.")); |
323 |
|
} |
324 |
|
{ |
325 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
326 |
|
uiManager->get_widget("/MenuBar/MenuTools/MergeFiles")); |
327 |
|
item->set_tooltip_text(_("Add instruments and samples of other .gig files to this .gig file.")); |
328 |
|
} |
329 |
|
|
330 |
|
|
331 |
|
instrument_menu = static_cast<Gtk::MenuItem*>( |
332 |
|
uiManager->get_widget("/MenuBar/MenuInstrument"))->get_submenu(); |
333 |
|
|
334 |
Gtk::Widget* menuBar = uiManager->get_widget("/MenuBar"); |
Gtk::Widget* menuBar = uiManager->get_widget("/MenuBar"); |
335 |
m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK); |
m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK); |
336 |
m_VBox.pack_start(m_HPaned); |
m_VBox.pack_start(m_HPaned); |
337 |
m_VBox.pack_start(m_RegionChooser, Gtk::PACK_SHRINK); |
m_VBox.pack_start(m_RegionChooser, Gtk::PACK_SHRINK); |
338 |
|
m_VBox.pack_start(m_RegionChooser.m_VirtKeybPropsBox, Gtk::PACK_SHRINK); |
339 |
m_VBox.pack_start(m_DimRegionChooser, Gtk::PACK_SHRINK); |
m_VBox.pack_start(m_DimRegionChooser, Gtk::PACK_SHRINK); |
340 |
|
m_VBox.pack_start(m_StatusBar, Gtk::PACK_SHRINK); |
341 |
|
|
342 |
|
set_file_is_shared(false); |
343 |
|
|
344 |
|
// Status Bar: |
345 |
|
m_StatusBar.pack_start(m_AttachedStateLabel, Gtk::PACK_SHRINK); |
346 |
|
m_StatusBar.pack_start(m_AttachedStateImage, Gtk::PACK_SHRINK); |
347 |
|
m_StatusBar.show(); |
348 |
|
|
349 |
m_RegionChooser.signal_region_selected().connect( |
m_RegionChooser.signal_region_selected().connect( |
350 |
sigc::mem_fun(*this, &MainWindow::region_changed) ); |
sigc::mem_fun(*this, &MainWindow::region_changed) ); |
355 |
// Create the Tree model: |
// Create the Tree model: |
356 |
m_refTreeModel = Gtk::ListStore::create(m_Columns); |
m_refTreeModel = Gtk::ListStore::create(m_Columns); |
357 |
m_TreeView.set_model(m_refTreeModel); |
m_TreeView.set_model(m_refTreeModel); |
358 |
m_refTreeModel->signal_row_changed().connect( |
m_TreeView.set_tooltip_text(_("Right click here for actions on instruments & MIDI Rules.")); |
359 |
|
instrument_name_connection = m_refTreeModel->signal_row_changed().connect( |
360 |
sigc::mem_fun(*this, &MainWindow::instrument_name_changed) |
sigc::mem_fun(*this, &MainWindow::instrument_name_changed) |
361 |
); |
); |
362 |
|
|
367 |
// create samples treeview (including its data model) |
// create samples treeview (including its data model) |
368 |
m_refSamplesTreeModel = SamplesTreeStore::create(m_SamplesModel); |
m_refSamplesTreeModel = SamplesTreeStore::create(m_SamplesModel); |
369 |
m_TreeViewSamples.set_model(m_refSamplesTreeModel); |
m_TreeViewSamples.set_model(m_refSamplesTreeModel); |
370 |
|
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.")); |
371 |
// m_TreeViewSamples.set_reorderable(); |
// m_TreeViewSamples.set_reorderable(); |
372 |
m_TreeViewSamples.append_column_editable("Samples", m_SamplesModel.m_col_name); |
m_TreeViewSamples.append_column_editable("Samples", m_SamplesModel.m_col_name); |
373 |
m_TreeViewSamples.set_headers_visible(false); |
m_TreeViewSamples.set_headers_visible(false); |
379 |
); |
); |
380 |
|
|
381 |
// establish drag&drop between samples tree view and dimension region 'Sample' text entry |
// establish drag&drop between samples tree view and dimension region 'Sample' text entry |
382 |
std::list<Gtk::TargetEntry> drag_target_gig_sample; |
std::vector<Gtk::TargetEntry> drag_target_gig_sample; |
383 |
drag_target_gig_sample.push_back( Gtk::TargetEntry("gig::Sample") ); |
drag_target_gig_sample.push_back(Gtk::TargetEntry("gig::Sample")); |
384 |
m_TreeViewSamples.drag_source_set(drag_target_gig_sample); |
m_TreeViewSamples.drag_source_set(drag_target_gig_sample); |
385 |
m_TreeViewSamples.signal_drag_begin().connect( |
m_TreeViewSamples.signal_drag_begin().connect( |
386 |
sigc::mem_fun(*this, &MainWindow::on_sample_treeview_drag_begin) |
sigc::mem_fun(*this, &MainWindow::on_sample_treeview_drag_begin) |
398 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
399 |
m_DimRegionChooser.signal_region_changed().connect( |
m_DimRegionChooser.signal_region_changed().connect( |
400 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
401 |
instrumentProps.signal_instrument_changed().connect( |
instrumentProps.signal_changed().connect( |
402 |
|
sigc::mem_fun(*this, &MainWindow::file_changed)); |
403 |
|
propDialog.signal_changed().connect( |
404 |
|
sigc::mem_fun(*this, &MainWindow::file_changed)); |
405 |
|
midiRules.signal_changed().connect( |
406 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
407 |
|
|
408 |
dimreg_edit.signal_dimreg_to_be_changed().connect( |
dimreg_edit.signal_dimreg_to_be_changed().connect( |
433 |
m_RegionChooser.signal_region_changed_signal().connect( |
m_RegionChooser.signal_region_changed_signal().connect( |
434 |
region_changed_signal.make_slot()); |
region_changed_signal.make_slot()); |
435 |
|
|
436 |
|
note_on_signal.connect( |
437 |
|
sigc::mem_fun(m_RegionChooser, &RegionChooser::on_note_on_event)); |
438 |
|
note_off_signal.connect( |
439 |
|
sigc::mem_fun(m_RegionChooser, &RegionChooser::on_note_off_event)); |
440 |
|
|
441 |
|
dimreg_all_regions.signal_toggled().connect( |
442 |
|
sigc::mem_fun(*this, &MainWindow::update_dimregs)); |
443 |
|
dimreg_all_dimregs.signal_toggled().connect( |
444 |
|
sigc::mem_fun(*this, &MainWindow::dimreg_all_dimregs_toggled)); |
445 |
|
dimreg_stereo.signal_toggled().connect( |
446 |
|
sigc::mem_fun(*this, &MainWindow::update_dimregs)); |
447 |
|
|
448 |
file = 0; |
file = 0; |
449 |
file_is_changed = false; |
file_is_changed = false; |
|
file_is_shared = false; |
|
450 |
|
|
451 |
show_all_children(); |
show_all_children(); |
452 |
|
|
453 |
// start with a new gig file by default |
// start with a new gig file by default |
454 |
on_action_file_new(); |
on_action_file_new(); |
455 |
|
|
456 |
|
// select 'Instruments' tab by default |
457 |
|
// (gtk allows this only if the tab childs are visible, thats why it's here) |
458 |
|
m_TreeViewNotebook.set_current_page(1); |
459 |
} |
} |
460 |
|
|
461 |
MainWindow::~MainWindow() |
MainWindow::~MainWindow() |
478 |
m_DimRegionChooser.set_region(m_RegionChooser.get_region()); |
m_DimRegionChooser.set_region(m_RegionChooser.get_region()); |
479 |
} |
} |
480 |
|
|
481 |
|
gig::Instrument* MainWindow::get_instrument() |
482 |
|
{ |
483 |
|
gig::Instrument* instrument = 0; |
484 |
|
Gtk::TreeModel::const_iterator it = |
485 |
|
m_TreeView.get_selection()->get_selected(); |
486 |
|
if (it) { |
487 |
|
Gtk::TreeModel::Row row = *it; |
488 |
|
instrument = row[m_Columns.m_col_instr]; |
489 |
|
} |
490 |
|
return instrument; |
491 |
|
} |
492 |
|
|
493 |
|
void MainWindow::add_region_to_dimregs(gig::Region* region, bool stereo, bool all_dimregs) |
494 |
|
{ |
495 |
|
if (all_dimregs) { |
496 |
|
for (int i = 0 ; i < region->DimensionRegions ; i++) { |
497 |
|
if (region->pDimensionRegions[i]) { |
498 |
|
dimreg_edit.dimregs.insert(region->pDimensionRegions[i]); |
499 |
|
} |
500 |
|
} |
501 |
|
} else { |
502 |
|
m_DimRegionChooser.get_dimregions(region, stereo, dimreg_edit.dimregs); |
503 |
|
} |
504 |
|
} |
505 |
|
|
506 |
|
void MainWindow::update_dimregs() |
507 |
|
{ |
508 |
|
dimreg_edit.dimregs.clear(); |
509 |
|
bool all_regions = dimreg_all_regions.get_active(); |
510 |
|
bool stereo = dimreg_stereo.get_active(); |
511 |
|
bool all_dimregs = dimreg_all_dimregs.get_active(); |
512 |
|
|
513 |
|
if (all_regions) { |
514 |
|
gig::Instrument* instrument = get_instrument(); |
515 |
|
if (instrument) { |
516 |
|
for (gig::Region* region = instrument->GetFirstRegion() ; |
517 |
|
region ; |
518 |
|
region = instrument->GetNextRegion()) { |
519 |
|
add_region_to_dimregs(region, stereo, all_dimregs); |
520 |
|
} |
521 |
|
} |
522 |
|
} else { |
523 |
|
gig::Region* region = m_RegionChooser.get_region(); |
524 |
|
if (region) { |
525 |
|
add_region_to_dimregs(region, stereo, all_dimregs); |
526 |
|
} |
527 |
|
} |
528 |
|
} |
529 |
|
|
530 |
|
void MainWindow::dimreg_all_dimregs_toggled() |
531 |
|
{ |
532 |
|
dimreg_stereo.set_sensitive(!dimreg_all_dimregs.get_active()); |
533 |
|
update_dimregs(); |
534 |
|
} |
535 |
|
|
536 |
void MainWindow::dimreg_changed() |
void MainWindow::dimreg_changed() |
537 |
{ |
{ |
538 |
|
update_dimregs(); |
539 |
dimreg_edit.set_dim_region(m_DimRegionChooser.get_dimregion()); |
dimreg_edit.set_dim_region(m_DimRegionChooser.get_dimregion()); |
540 |
} |
} |
541 |
|
|
542 |
void MainWindow::on_sel_change() |
void MainWindow::on_sel_change() |
543 |
{ |
{ |
544 |
Glib::RefPtr<Gtk::TreeSelection> tree_sel_ref = m_TreeView.get_selection(); |
// select item in instrument menu |
545 |
|
Gtk::TreeModel::iterator it = m_TreeView.get_selection()->get_selected(); |
|
Gtk::TreeModel::iterator it = tree_sel_ref->get_selected(); |
|
546 |
if (it) { |
if (it) { |
547 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreePath path(it); |
548 |
std::cout << row[m_Columns.m_col_name] << std::endl; |
int index = path[0]; |
549 |
|
const std::vector<Gtk::Widget*> children = |
550 |
m_RegionChooser.set_instrument(row[m_Columns.m_col_instr]); |
instrument_menu->get_children(); |
551 |
} else { |
static_cast<Gtk::RadioMenuItem*>(children[index])->set_active(); |
|
m_RegionChooser.set_instrument(0); |
|
552 |
} |
} |
553 |
|
|
554 |
|
m_RegionChooser.set_instrument(get_instrument()); |
555 |
} |
} |
556 |
|
|
557 |
void loader_progress_callback(gig::progress_t* progress) |
void loader_progress_callback(gig::progress_t* progress) |
563 |
void Loader::progress_callback(float fraction) |
void Loader::progress_callback(float fraction) |
564 |
{ |
{ |
565 |
{ |
{ |
566 |
Glib::Mutex::Lock lock(progressMutex); |
Glib::Threads::Mutex::Lock lock(progressMutex); |
567 |
progress = fraction; |
progress = fraction; |
568 |
} |
} |
569 |
progress_dispatcher(); |
progress_dispatcher(); |
571 |
|
|
572 |
void Loader::thread_function() |
void Loader::thread_function() |
573 |
{ |
{ |
574 |
printf("thread_function self=%x\n", Glib::Thread::self()); |
printf("thread_function self=%x\n", Glib::Threads::Thread::self()); |
575 |
printf("Start %s\n", filename); |
printf("Start %s\n", filename); |
576 |
RIFF::File* riff = new RIFF::File(filename); |
RIFF::File* riff = new RIFF::File(filename); |
577 |
gig = new gig::File(riff); |
gig = new gig::File(riff); |
585 |
} |
} |
586 |
|
|
587 |
Loader::Loader(const char* filename) |
Loader::Loader(const char* filename) |
588 |
: thread(0), filename(filename) |
: filename(filename), thread(0) |
589 |
{ |
{ |
590 |
} |
} |
591 |
|
|
592 |
void Loader::launch() |
void Loader::launch() |
593 |
{ |
{ |
594 |
|
#ifdef OLD_THREADS |
595 |
thread = Glib::Thread::create(sigc::mem_fun(*this, &Loader::thread_function), true); |
thread = Glib::Thread::create(sigc::mem_fun(*this, &Loader::thread_function), true); |
596 |
|
#else |
597 |
|
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Loader::thread_function)); |
598 |
|
#endif |
599 |
printf("launch thread=%x\n", thread); |
printf("launch thread=%x\n", thread); |
600 |
} |
} |
601 |
|
|
603 |
{ |
{ |
604 |
float res; |
float res; |
605 |
{ |
{ |
606 |
Glib::Mutex::Lock lock(progressMutex); |
Glib::Threads::Mutex::Lock lock(progressMutex); |
607 |
res = progress; |
res = progress; |
608 |
} |
} |
609 |
return res; |
return res; |
629 |
// Clear all GUI elements / controls. This method is typically called |
// Clear all GUI elements / controls. This method is typically called |
630 |
// before a new .gig file is to be created or to be loaded. |
// before a new .gig file is to be created or to be loaded. |
631 |
void MainWindow::__clear() { |
void MainWindow::__clear() { |
|
// remove all entries from "Instrument" menu |
|
|
Gtk::MenuItem* instrument_menu = |
|
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuInstrument")); |
|
|
instrument_menu->hide(); |
|
|
for (int i = 0; i < instrument_menu->get_submenu()->items().size(); i++) { |
|
|
delete &instrument_menu->get_submenu()->items()[i]; |
|
|
} |
|
|
instrument_menu->get_submenu()->items().clear(); |
|
632 |
// forget all samples that ought to be imported |
// forget all samples that ought to be imported |
633 |
m_SampleImportQueue.clear(); |
m_SampleImportQueue.clear(); |
634 |
// clear the samples and instruments tree views |
// clear the samples and instruments tree views |
635 |
m_refTreeModel->clear(); |
m_refTreeModel->clear(); |
636 |
m_refSamplesTreeModel->clear(); |
m_refSamplesTreeModel->clear(); |
637 |
|
// remove all entries from "Instrument" menu |
638 |
|
while (!instrument_menu->get_children().empty()) { |
639 |
|
remove_instrument_from_menu(0); |
640 |
|
} |
641 |
// free libgig's gig::File instance |
// free libgig's gig::File instance |
642 |
if (file && !file_is_shared) delete file; |
if (file && !file_is_shared) delete file; |
643 |
file = NULL; |
file = NULL; |
644 |
file_is_shared = false; |
set_file_is_shared(false); |
645 |
|
} |
646 |
|
|
647 |
|
void MainWindow::__refreshEntireGUI() { |
648 |
|
// clear the samples and instruments tree views |
649 |
|
m_refTreeModel->clear(); |
650 |
|
m_refSamplesTreeModel->clear(); |
651 |
|
// remove all entries from "Instrument" menu |
652 |
|
while (!instrument_menu->get_children().empty()) { |
653 |
|
remove_instrument_from_menu(0); |
654 |
|
} |
655 |
|
|
656 |
|
if (!this->file) return; |
657 |
|
|
658 |
|
load_gig( |
659 |
|
this->file, this->file->pInfo->Name.c_str(), this->file_is_shared |
660 |
|
); |
661 |
} |
} |
662 |
|
|
663 |
void MainWindow::on_action_file_new() |
void MainWindow::on_action_file_new() |
672 |
gig::File* pFile = new gig::File; |
gig::File* pFile = new gig::File; |
673 |
// already add one new instrument by default |
// already add one new instrument by default |
674 |
gig::Instrument* pInstrument = pFile->AddInstrument(); |
gig::Instrument* pInstrument = pFile->AddInstrument(); |
675 |
pInstrument->pInfo->Name = "Unnamed Instrument"; |
pInstrument->pInfo->Name = gig_from_utf8(_("Unnamed Instrument")); |
676 |
// update GUI with that new gig::File |
// update GUI with that new gig::File |
677 |
load_gig(pFile, 0 /*no file name yet*/); |
load_gig(pFile, 0 /*no file name yet*/); |
678 |
} |
} |
683 |
Glib::filename_display_basename(filename).c_str()); |
Glib::filename_display_basename(filename).c_str()); |
684 |
Gtk::MessageDialog dialog(*this, msg, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE); |
Gtk::MessageDialog dialog(*this, msg, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE); |
685 |
g_free(msg); |
g_free(msg); |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 6) || GTKMM_MAJOR_VERSION > 2 |
|
686 |
dialog.set_secondary_text(_("If you close without saving, your changes will be lost.")); |
dialog.set_secondary_text(_("If you close without saving, your changes will be lost.")); |
|
#endif |
|
687 |
dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO); |
dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO); |
688 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
689 |
dialog.add_button(file_has_name ? Gtk::Stock::SAVE : Gtk::Stock::SAVE_AS, Gtk::RESPONSE_YES); |
dialog.add_button(file_has_name ? Gtk::Stock::SAVE : Gtk::Stock::SAVE_AS, Gtk::RESPONSE_YES); |
697 |
bool MainWindow::leaving_shared_mode_dialog() { |
bool MainWindow::leaving_shared_mode_dialog() { |
698 |
Glib::ustring msg = _("Detach from sampler and proceed working stand-alone?"); |
Glib::ustring msg = _("Detach from sampler and proceed working stand-alone?"); |
699 |
Gtk::MessageDialog dialog(*this, msg, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE); |
Gtk::MessageDialog dialog(*this, msg, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE); |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 6) || GTKMM_MAJOR_VERSION > 2 |
|
700 |
dialog.set_secondary_text( |
dialog.set_secondary_text( |
701 |
_("If you proceed to work on another instrument file, it won't be " |
_("If you proceed to work on another instrument file, it won't be " |
702 |
"used by the sampler until you tell the sampler explicitly to " |
"used by the sampler until you tell the sampler explicitly to " |
703 |
"load it.") |
"load it.")); |
|
); |
|
|
#endif |
|
704 |
dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES); |
dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES); |
705 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
706 |
dialog.set_default_response(Gtk::RESPONSE_CANCEL); |
dialog.set_default_response(Gtk::RESPONSE_CANCEL); |
719 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
720 |
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); |
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); |
721 |
dialog.set_default_response(Gtk::RESPONSE_OK); |
dialog.set_default_response(Gtk::RESPONSE_OK); |
722 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
723 |
Gtk::FileFilter filter; |
Gtk::FileFilter filter; |
724 |
filter.add_pattern("*.gig"); |
filter.add_pattern("*.gig"); |
725 |
|
#else |
726 |
|
Glib::RefPtr<Gtk::FileFilter> filter = Gtk::FileFilter::create(); |
727 |
|
filter->add_pattern("*.gig"); |
728 |
|
#endif |
729 |
dialog.set_filter(filter); |
dialog.set_filter(filter); |
730 |
if (current_dir != "") { |
if (current_gig_dir != "") { |
731 |
dialog.set_current_folder(current_dir); |
dialog.set_current_folder(current_gig_dir); |
732 |
} |
} |
733 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
734 |
std::string filename = dialog.get_filename(); |
std::string filename = dialog.get_filename(); |
735 |
printf("filename=%s\n", filename.c_str()); |
printf("filename=%s\n", filename.c_str()); |
736 |
printf("on_action_file_open self=%x\n", Glib::Thread::self()); |
printf("on_action_file_open self=%x\n", Glib::Threads::Thread::self()); |
737 |
load_file(filename.c_str()); |
load_file(filename.c_str()); |
738 |
current_dir = Glib::path_get_dirname(filename); |
current_gig_dir = Glib::path_get_dirname(filename); |
739 |
} |
} |
740 |
} |
} |
741 |
|
|
742 |
void MainWindow::load_file(const char* name) |
void MainWindow::load_file(const char* name) |
743 |
{ |
{ |
744 |
__clear(); |
__clear(); |
745 |
load_dialog = new LoadDialog("Loading...", *this); |
load_dialog = new LoadDialog(_("Loading..."), *this); |
746 |
load_dialog->show_all(); |
load_dialog->show_all(); |
747 |
loader = new Loader(strdup(name)); |
loader = new Loader(strdup(name)); |
748 |
loader->signal_progress().connect( |
loader->signal_progress().connect( |
775 |
void MainWindow::on_loader_finished() |
void MainWindow::on_loader_finished() |
776 |
{ |
{ |
777 |
printf("Loader finished!\n"); |
printf("Loader finished!\n"); |
778 |
printf("on_loader_finished self=%x\n", Glib::Thread::self()); |
printf("on_loader_finished self=%x\n", Glib::Threads::Thread::self()); |
779 |
load_gig(loader->gig, loader->filename); |
load_gig(loader->gig, loader->filename); |
780 |
load_dialog->hide(); |
load_dialog->hide(); |
781 |
} |
} |
847 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
848 |
dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK); |
dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK); |
849 |
dialog.set_default_response(Gtk::RESPONSE_OK); |
dialog.set_default_response(Gtk::RESPONSE_OK); |
|
|
|
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 8) || GTKMM_MAJOR_VERSION > 2 |
|
850 |
dialog.set_do_overwrite_confirmation(); |
dialog.set_do_overwrite_confirmation(); |
851 |
// TODO: an overwrite dialog for gtkmm < 2.8 |
|
852 |
#endif |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
853 |
Gtk::FileFilter filter; |
Gtk::FileFilter filter; |
854 |
filter.add_pattern("*.gig"); |
filter.add_pattern("*.gig"); |
855 |
|
#else |
856 |
|
Glib::RefPtr<Gtk::FileFilter> filter = Gtk::FileFilter::create(); |
857 |
|
filter->add_pattern("*.gig"); |
858 |
|
#endif |
859 |
dialog.set_filter(filter); |
dialog.set_filter(filter); |
860 |
|
|
861 |
if (Glib::path_is_absolute(filename)) { |
// set initial dir and filename of the Save As dialog |
862 |
dialog.set_filename(filename); |
// and prepare that initial filename as a copy of the gig |
863 |
} else if (current_dir != "") { |
{ |
864 |
dialog.set_current_folder(current_dir); |
std::string basename = Glib::path_get_basename(filename); |
865 |
|
std::string dir = Glib::path_get_dirname(filename); |
866 |
|
basename = std::string(_("copy_of_")) + basename; |
867 |
|
Glib::ustring copyFileName = Glib::build_filename(dir, basename); |
868 |
|
if (Glib::path_is_absolute(filename)) { |
869 |
|
dialog.set_filename(copyFileName); |
870 |
|
} else { |
871 |
|
if (current_gig_dir != "") dialog.set_current_folder(current_gig_dir); |
872 |
|
} |
873 |
|
dialog.set_current_name(Glib::filename_display_basename(copyFileName)); |
874 |
} |
} |
875 |
dialog.set_current_name(Glib::filename_display_basename(filename)); |
|
876 |
|
// show warning in the dialog |
877 |
|
Gtk::HBox descriptionArea; |
878 |
|
descriptionArea.set_spacing(15); |
879 |
|
Gtk::Image warningIcon(Gtk::Stock::DIALOG_WARNING, Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); |
880 |
|
descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); |
881 |
|
#if GTKMM_MAJOR_VERSION < 3 |
882 |
|
view::WrapLabel description; |
883 |
|
#else |
884 |
|
Gtk::Label description; |
885 |
|
description.set_line_wrap(); |
886 |
|
#endif |
887 |
|
description.set_markup( |
888 |
|
_("\n<b>CAUTION:</b> You <b>MUST</b> use the " |
889 |
|
"<span style=\"italic\">\"Save\"</span> dialog instead of " |
890 |
|
"<span style=\"italic\">\"Save As...\"</span> if you want to save " |
891 |
|
"to the same .gig file. Using " |
892 |
|
"<span style=\"italic\">\"Save As...\"</span> for writing to the " |
893 |
|
"same .gig file will end up in corrupted sample wave data!\n") |
894 |
|
); |
895 |
|
descriptionArea.pack_start(description); |
896 |
|
dialog.get_vbox()->pack_start(descriptionArea, Gtk::PACK_SHRINK); |
897 |
|
descriptionArea.show_all(); |
898 |
|
|
899 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
900 |
file_structure_to_be_changed_signal.emit(this->file); |
file_structure_to_be_changed_signal.emit(this->file); |
906 |
printf("filename=%s\n", filename.c_str()); |
printf("filename=%s\n", filename.c_str()); |
907 |
file->Save(filename); |
file->Save(filename); |
908 |
this->filename = filename; |
this->filename = filename; |
909 |
current_dir = Glib::path_get_dirname(filename); |
current_gig_dir = Glib::path_get_dirname(filename); |
910 |
set_title(Glib::filename_display_basename(filename)); |
set_title(Glib::filename_display_basename(filename)); |
911 |
file_has_name = true; |
file_has_name = true; |
912 |
file_is_changed = false; |
file_is_changed = false; |
935 |
SF_INFO info; |
SF_INFO info; |
936 |
info.format = 0; |
info.format = 0; |
937 |
SNDFILE* hFile = sf_open((*iter).sample_path.c_str(), SFM_READ, &info); |
SNDFILE* hFile = sf_open((*iter).sample_path.c_str(), SFM_READ, &info); |
938 |
|
sf_command(hFile, SFC_SET_SCALE_FLOAT_INT_READ, 0, SF_TRUE); |
939 |
try { |
try { |
940 |
if (!hFile) throw std::string("could not open file"); |
if (!hFile) throw std::string(_("could not open file")); |
941 |
// determine sample's bit depth |
// determine sample's bit depth |
942 |
int bitdepth; |
int bitdepth; |
943 |
switch (info.format & 0xff) { |
switch (info.format & 0xff) { |
954 |
break; |
break; |
955 |
default: |
default: |
956 |
sf_close(hFile); // close sound file |
sf_close(hFile); // close sound file |
957 |
throw std::string("format not supported"); // unsupported subformat (yet?) |
throw std::string(_("format not supported")); // unsupported subformat (yet?) |
958 |
} |
} |
959 |
|
|
960 |
const int bufsize = 10000; |
const int bufsize = 10000; |
996 |
} |
} |
997 |
// cleanup |
// cleanup |
998 |
sf_close(hFile); |
sf_close(hFile); |
999 |
|
// let the sampler re-cache the sample if needed |
1000 |
|
sample_changed_signal.emit(iter->gig_sample); |
1001 |
// on success we remove the sample from the import queue, |
// on success we remove the sample from the import queue, |
1002 |
// otherwise keep it, maybe it works the next time ? |
// otherwise keep it, maybe it works the next time ? |
1003 |
std::list<SampleImportItem>::iterator cur = iter; |
std::list<SampleImportItem>::iterator cur = iter; |
1005 |
m_SampleImportQueue.erase(cur); |
m_SampleImportQueue.erase(cur); |
1006 |
} catch (std::string what) { |
} catch (std::string what) { |
1007 |
// remember the files that made trouble (and their cause) |
// remember the files that made trouble (and their cause) |
1008 |
if (error_files.size()) error_files += "\n"; |
if (!error_files.empty()) error_files += "\n"; |
1009 |
error_files += (*iter).sample_path += " (" + what + ")"; |
error_files += (*iter).sample_path += " (" + what + ")"; |
1010 |
++iter; |
++iter; |
1011 |
} |
} |
1012 |
} |
} |
1013 |
// show error message box when some sample(s) could not be imported |
// show error message box when some sample(s) could not be imported |
1014 |
if (error_files.size()) { |
if (!error_files.empty()) { |
1015 |
Glib::ustring txt = _("Could not import the following sample(s):\n") + error_files; |
Glib::ustring txt = _("Could not import the following sample(s):\n") + error_files; |
1016 |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
1017 |
msg.run(); |
msg.run(); |
1024 |
propDialog.deiconify(); |
propDialog.deiconify(); |
1025 |
} |
} |
1026 |
|
|
1027 |
|
void MainWindow::on_action_warn_user_on_extensions() { |
1028 |
|
Settings::singleton()->warnUserOnExtensions = |
1029 |
|
!Settings::singleton()->warnUserOnExtensions; |
1030 |
|
} |
1031 |
|
|
1032 |
void MainWindow::on_action_help_about() |
void MainWindow::on_action_help_about() |
1033 |
{ |
{ |
|
#ifdef ABOUT_DIALOG |
|
1034 |
Gtk::AboutDialog dialog; |
Gtk::AboutDialog dialog; |
1035 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 12) || GTKMM_MAJOR_VERSION > 2 |
1036 |
|
dialog.set_program_name("Gigedit"); |
1037 |
|
#else |
1038 |
|
dialog.set_name("Gigedit"); |
1039 |
|
#endif |
1040 |
dialog.set_version(VERSION); |
dialog.set_version(VERSION); |
1041 |
|
dialog.set_copyright("Copyright (C) 2006-2014 Andreas Persson"); |
1042 |
|
const std::string sComment = |
1043 |
|
_("Built " __DATE__ "\nUsing ") + |
1044 |
|
::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" + |
1045 |
|
_( |
1046 |
|
"Gigedit is released under the GNU General Public License.\n" |
1047 |
|
"\n" |
1048 |
|
"Please notice that this is still a very young instrument editor. " |
1049 |
|
"So better backup your Gigasampler files before editing them with " |
1050 |
|
"this application.\n" |
1051 |
|
"\n" |
1052 |
|
"Please report bugs to: http://bugs.linuxsampler.org" |
1053 |
|
); |
1054 |
|
dialog.set_comments(sComment.c_str()); |
1055 |
|
dialog.set_website("http://www.linuxsampler.org"); |
1056 |
|
dialog.set_website_label("http://www.linuxsampler.org"); |
1057 |
dialog.run(); |
dialog.run(); |
|
#endif |
|
1058 |
} |
} |
1059 |
|
|
1060 |
PropDialog::PropDialog() |
PropDialog::PropDialog() |
1061 |
: table(2,1) |
: eName(_("Name")), |
1062 |
|
eCreationDate(_("Creation date")), |
1063 |
|
eComments(_("Comments")), |
1064 |
|
eProduct(_("Product")), |
1065 |
|
eCopyright(_("Copyright")), |
1066 |
|
eArtists(_("Artists")), |
1067 |
|
eGenre(_("Genre")), |
1068 |
|
eKeywords(_("Keywords")), |
1069 |
|
eEngineer(_("Engineer")), |
1070 |
|
eTechnician(_("Technician")), |
1071 |
|
eSoftware(_("Software")), |
1072 |
|
eMedium(_("Medium")), |
1073 |
|
eSource(_("Source")), |
1074 |
|
eSourceForm(_("Source form")), |
1075 |
|
eCommissioned(_("Commissioned")), |
1076 |
|
eSubject(_("Subject")), |
1077 |
|
quitButton(Gtk::Stock::CLOSE), |
1078 |
|
table(2, 1) |
1079 |
{ |
{ |
1080 |
|
set_title(_("File Properties")); |
1081 |
|
eName.set_width_chars(50); |
1082 |
|
|
1083 |
|
connect(eName, &DLS::Info::Name); |
1084 |
|
connect(eCreationDate, &DLS::Info::CreationDate); |
1085 |
|
connect(eComments, &DLS::Info::Comments); |
1086 |
|
connect(eProduct, &DLS::Info::Product); |
1087 |
|
connect(eCopyright, &DLS::Info::Copyright); |
1088 |
|
connect(eArtists, &DLS::Info::Artists); |
1089 |
|
connect(eGenre, &DLS::Info::Genre); |
1090 |
|
connect(eKeywords, &DLS::Info::Keywords); |
1091 |
|
connect(eEngineer, &DLS::Info::Engineer); |
1092 |
|
connect(eTechnician, &DLS::Info::Technician); |
1093 |
|
connect(eSoftware, &DLS::Info::Software); |
1094 |
|
connect(eMedium, &DLS::Info::Medium); |
1095 |
|
connect(eSource, &DLS::Info::Source); |
1096 |
|
connect(eSourceForm, &DLS::Info::SourceForm); |
1097 |
|
connect(eCommissioned, &DLS::Info::Commissioned); |
1098 |
|
connect(eSubject, &DLS::Info::Subject); |
1099 |
|
|
1100 |
|
table.add(eName); |
1101 |
|
table.add(eCreationDate); |
1102 |
|
table.add(eComments); |
1103 |
|
table.add(eProduct); |
1104 |
|
table.add(eCopyright); |
1105 |
|
table.add(eArtists); |
1106 |
|
table.add(eGenre); |
1107 |
|
table.add(eKeywords); |
1108 |
|
table.add(eEngineer); |
1109 |
|
table.add(eTechnician); |
1110 |
|
table.add(eSoftware); |
1111 |
|
table.add(eMedium); |
1112 |
|
table.add(eSource); |
1113 |
|
table.add(eSourceForm); |
1114 |
|
table.add(eCommissioned); |
1115 |
|
table.add(eSubject); |
1116 |
|
|
1117 |
table.set_col_spacings(5); |
table.set_col_spacings(5); |
1118 |
const char* propLabels[] = { |
add(vbox); |
1119 |
"Name:", |
table.set_border_width(5); |
1120 |
"CreationDate:", |
vbox.add(table); |
1121 |
"Comments:", // TODO: multiline |
vbox.pack_start(buttonBox, Gtk::PACK_SHRINK); |
1122 |
"Product:", |
buttonBox.set_layout(Gtk::BUTTONBOX_END); |
1123 |
"Copyright:", |
buttonBox.set_border_width(5); |
1124 |
"Artists:", |
buttonBox.show(); |
1125 |
"Genre:", |
buttonBox.pack_start(quitButton); |
1126 |
"Keywords:", |
quitButton.set_can_default(); |
1127 |
"Engineer:", |
quitButton.grab_focus(); |
1128 |
"Technician:", |
quitButton.signal_clicked().connect( |
1129 |
"Software:", // TODO: readonly |
sigc::mem_fun(*this, &PropDialog::hide)); |
|
"Medium:", |
|
|
"Source:", |
|
|
"SourceForm:", |
|
|
"Commissioned:", |
|
|
"Subject:" |
|
|
}; |
|
|
for (int i = 0 ; i < sizeof(propLabels) / sizeof(char*) ; i++) { |
|
|
label[i].set_text(propLabels[i]); |
|
|
label[i].set_alignment(Gtk::ALIGN_LEFT); |
|
|
table.attach(label[i], 0, 1, i, i + 1, Gtk::FILL, Gtk::SHRINK); |
|
|
table.attach(entry[i], 1, 2, i, i + 1, Gtk::FILL | Gtk::EXPAND, |
|
|
Gtk::SHRINK); |
|
|
} |
|
1130 |
|
|
1131 |
add(table); |
quitButton.show(); |
1132 |
// add_button(Gtk::Stock::CANCEL, 0); |
vbox.show(); |
|
// add_button(Gtk::Stock::OK, 1); |
|
1133 |
show_all_children(); |
show_all_children(); |
1134 |
} |
} |
1135 |
|
|
1136 |
void PropDialog::set_info(DLS::Info* info) |
void PropDialog::set_info(DLS::Info* info) |
1137 |
{ |
{ |
1138 |
entry[0].set_text(info->Name); |
update(info); |
|
entry[1].set_text(info->CreationDate); |
|
|
entry[2].set_text(Glib::convert(info->Comments, "UTF-8", "ISO-8859-1")); |
|
|
entry[3].set_text(info->Product); |
|
|
entry[4].set_text(info->Copyright); |
|
|
entry[5].set_text(info->Artists); |
|
|
entry[6].set_text(info->Genre); |
|
|
entry[7].set_text(info->Keywords); |
|
|
entry[8].set_text(info->Engineer); |
|
|
entry[9].set_text(info->Technician); |
|
|
entry[10].set_text(info->Software); |
|
|
entry[11].set_text(info->Medium); |
|
|
entry[12].set_text(info->Source); |
|
|
entry[13].set_text(info->SourceForm); |
|
|
entry[14].set_text(info->Commissioned); |
|
|
entry[15].set_text(info->Subject); |
|
|
} |
|
|
|
|
|
void InstrumentProps::add_prop(BoolEntry& boolentry) |
|
|
{ |
|
|
table.attach(boolentry.widget, 0, 2, rowno, rowno + 1, |
|
|
Gtk::FILL, Gtk::SHRINK); |
|
|
rowno++; |
|
|
boolentry.signal_changed_by_user().connect(instrument_changed.make_slot()); |
|
|
} |
|
|
|
|
|
void InstrumentProps::add_prop(BoolEntryPlus6& boolentry) |
|
|
{ |
|
|
table.attach(boolentry.widget, 0, 2, rowno, rowno + 1, |
|
|
Gtk::FILL, Gtk::SHRINK); |
|
|
rowno++; |
|
|
boolentry.signal_changed_by_user().connect(instrument_changed.make_slot()); |
|
|
} |
|
|
|
|
|
void InstrumentProps::add_prop(LabelWidget& prop) |
|
|
{ |
|
|
table.attach(prop.label, 0, 1, rowno, rowno + 1, |
|
|
Gtk::FILL, Gtk::SHRINK); |
|
|
table.attach(prop.widget, 1, 2, rowno, rowno + 1, |
|
|
Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK); |
|
|
rowno++; |
|
|
prop.signal_changed_by_user().connect(instrument_changed.make_slot()); |
|
1139 |
} |
} |
1140 |
|
|
1141 |
InstrumentProps::InstrumentProps() |
|
1142 |
: table(2,1), |
void InstrumentProps::set_Name(const gig::String& name) |
1143 |
quitButton(Gtk::Stock::CLOSE), |
{ |
1144 |
eName("Name"), |
m->pInfo->Name = name; |
1145 |
eIsDrum("Is drum"), |
} |
1146 |
eMIDIBank("MIDI bank", 0, 16383), |
|
1147 |
eMIDIProgram("MIDI program"), |
void InstrumentProps::update_name() |
1148 |
eAttenuation("Attenuation", 0, 96, 0, 1), |
{ |
1149 |
eGainPlus6("Gain +6dB", eAttenuation, -6), |
update_model++; |
1150 |
eEffectSend("Effect send", 0, 65535), |
eName.set_value(m->pInfo->Name); |
1151 |
eFineTune("Fine tune", -8400, 8400), |
update_model--; |
1152 |
ePitchbendRange("Pitchbend range", 0, 12), |
} |
1153 |
ePianoReleaseMode("Piano release mode"), |
|
1154 |
eDimensionKeyRangeLow("Dimension key range low"), |
void InstrumentProps::set_IsDrum(bool value) |
|
eDimensionKeyRangeHigh("Dimension key range high") |
|
1155 |
{ |
{ |
1156 |
set_title("Instrument properties"); |
m->IsDrum = value; |
1157 |
|
} |
1158 |
|
|
1159 |
|
void InstrumentProps::set_MIDIBank(uint16_t value) |
1160 |
|
{ |
1161 |
|
m->MIDIBank = value; |
1162 |
|
} |
1163 |
|
|
1164 |
|
void InstrumentProps::set_MIDIProgram(uint32_t value) |
1165 |
|
{ |
1166 |
|
m->MIDIProgram = value; |
1167 |
|
} |
1168 |
|
|
1169 |
|
InstrumentProps::InstrumentProps() : |
1170 |
|
quitButton(Gtk::Stock::CLOSE), |
1171 |
|
table(2,1), |
1172 |
|
eName(_("Name")), |
1173 |
|
eIsDrum(_("Is drum")), |
1174 |
|
eMIDIBank(_("MIDI bank"), 0, 16383), |
1175 |
|
eMIDIProgram(_("MIDI program")), |
1176 |
|
eAttenuation(_("Attenuation"), 0, 96, 0, 1), |
1177 |
|
eGainPlus6(_("Gain +6dB"), eAttenuation, -6), |
1178 |
|
eEffectSend(_("Effect send"), 0, 65535), |
1179 |
|
eFineTune(_("Fine tune"), -8400, 8400), |
1180 |
|
ePitchbendRange(_("Pitchbend range"), 0, 12), |
1181 |
|
ePianoReleaseMode(_("Piano release mode")), |
1182 |
|
eDimensionKeyRangeLow(_("Keyswitching range low")), |
1183 |
|
eDimensionKeyRangeHigh(_("Keyswitching range high")) |
1184 |
|
{ |
1185 |
|
set_title(_("Instrument Properties")); |
1186 |
|
|
1187 |
|
eDimensionKeyRangeLow.set_tip( |
1188 |
|
_("start of the keyboard area which should switch the " |
1189 |
|
"\"keyswitching\" dimension") |
1190 |
|
); |
1191 |
|
eDimensionKeyRangeHigh.set_tip( |
1192 |
|
_("end of the keyboard area which should switch the " |
1193 |
|
"\"keyswitching\" dimension") |
1194 |
|
); |
1195 |
|
|
1196 |
|
connect(eName, &InstrumentProps::set_Name); |
1197 |
|
connect(eIsDrum, &InstrumentProps::set_IsDrum); |
1198 |
|
connect(eMIDIBank, &InstrumentProps::set_MIDIBank); |
1199 |
|
connect(eMIDIProgram, &InstrumentProps::set_MIDIProgram); |
1200 |
|
connect(eAttenuation, &gig::Instrument::Attenuation); |
1201 |
|
connect(eGainPlus6, &gig::Instrument::Attenuation); |
1202 |
|
connect(eEffectSend, &gig::Instrument::EffectSend); |
1203 |
|
connect(eFineTune, &gig::Instrument::FineTune); |
1204 |
|
connect(ePitchbendRange, &gig::Instrument::PitchbendRange); |
1205 |
|
connect(ePianoReleaseMode, &gig::Instrument::PianoReleaseMode); |
1206 |
|
connect(eDimensionKeyRangeLow, eDimensionKeyRangeHigh, |
1207 |
|
&gig::Instrument::DimensionKeyRange); |
1208 |
|
|
1209 |
|
eName.signal_value_changed().connect(sig_name_changed.make_slot()); |
1210 |
|
|
|
rowno = 0; |
|
1211 |
table.set_col_spacings(5); |
table.set_col_spacings(5); |
1212 |
|
|
1213 |
add_prop(eName); |
table.add(eName); |
1214 |
add_prop(eIsDrum); |
table.add(eIsDrum); |
1215 |
add_prop(eMIDIBank); |
table.add(eMIDIBank); |
1216 |
add_prop(eMIDIProgram); |
table.add(eMIDIProgram); |
1217 |
add_prop(eAttenuation); |
table.add(eAttenuation); |
1218 |
add_prop(eGainPlus6); |
table.add(eGainPlus6); |
1219 |
add_prop(eEffectSend); |
table.add(eEffectSend); |
1220 |
add_prop(eFineTune); |
table.add(eFineTune); |
1221 |
add_prop(ePitchbendRange); |
table.add(ePitchbendRange); |
1222 |
add_prop(ePianoReleaseMode); |
table.add(ePianoReleaseMode); |
1223 |
add_prop(eDimensionKeyRangeLow); |
table.add(eDimensionKeyRangeLow); |
1224 |
add_prop(eDimensionKeyRangeHigh); |
table.add(eDimensionKeyRangeHigh); |
|
|
|
|
eDimensionKeyRangeLow.signal_changed_by_user().connect( |
|
|
sigc::mem_fun(*this, &InstrumentProps::key_range_low_changed)); |
|
|
eDimensionKeyRangeHigh.signal_changed_by_user().connect( |
|
|
sigc::mem_fun(*this, &InstrumentProps::key_range_high_changed)); |
|
1225 |
|
|
1226 |
add(vbox); |
add(vbox); |
1227 |
table.set_border_width(5); |
table.set_border_width(5); |
1232 |
buttonBox.set_border_width(5); |
buttonBox.set_border_width(5); |
1233 |
buttonBox.show(); |
buttonBox.show(); |
1234 |
buttonBox.pack_start(quitButton); |
buttonBox.pack_start(quitButton); |
1235 |
quitButton.set_flags(Gtk::CAN_DEFAULT); |
quitButton.set_can_default(); |
1236 |
quitButton.grab_focus(); |
quitButton.grab_focus(); |
1237 |
|
|
1238 |
quitButton.signal_clicked().connect( |
quitButton.signal_clicked().connect( |
1245 |
|
|
1246 |
void InstrumentProps::set_instrument(gig::Instrument* instrument) |
void InstrumentProps::set_instrument(gig::Instrument* instrument) |
1247 |
{ |
{ |
1248 |
eName.set_ptr(&instrument->pInfo->Name); |
update(instrument); |
|
eIsDrum.set_ptr(&instrument->IsDrum); |
|
|
eMIDIBank.set_ptr(&instrument->MIDIBank); |
|
|
eMIDIProgram.set_ptr(&instrument->MIDIProgram); |
|
|
eAttenuation.set_ptr(&instrument->Attenuation); |
|
|
eGainPlus6.set_ptr(&instrument->Attenuation); |
|
|
eEffectSend.set_ptr(&instrument->EffectSend); |
|
|
eFineTune.set_ptr(&instrument->FineTune); |
|
|
ePitchbendRange.set_ptr(&instrument->PitchbendRange); |
|
|
ePianoReleaseMode.set_ptr(&instrument->PianoReleaseMode); |
|
|
eDimensionKeyRangeLow.set_ptr(0); |
|
|
eDimensionKeyRangeHigh.set_ptr(0); |
|
|
eDimensionKeyRangeLow.set_ptr(&instrument->DimensionKeyRange.low); |
|
|
eDimensionKeyRangeHigh.set_ptr(&instrument->DimensionKeyRange.high); |
|
|
} |
|
|
|
|
|
void InstrumentProps::key_range_low_changed() |
|
|
{ |
|
|
double l = eDimensionKeyRangeLow.get_value(); |
|
|
double h = eDimensionKeyRangeHigh.get_value(); |
|
|
if (h < l) eDimensionKeyRangeHigh.set_value(l); |
|
|
} |
|
1249 |
|
|
1250 |
void InstrumentProps::key_range_high_changed() |
update_model++; |
1251 |
{ |
eName.set_value(instrument->pInfo->Name); |
1252 |
double l = eDimensionKeyRangeLow.get_value(); |
eIsDrum.set_value(instrument->IsDrum); |
1253 |
double h = eDimensionKeyRangeHigh.get_value(); |
eMIDIBank.set_value(instrument->MIDIBank); |
1254 |
if (h < l) eDimensionKeyRangeLow.set_value(h); |
eMIDIProgram.set_value(instrument->MIDIProgram); |
1255 |
|
update_model--; |
1256 |
} |
} |
1257 |
|
|
|
sigc::signal<void>& InstrumentProps::signal_instrument_changed() |
|
|
{ |
|
|
return instrument_changed; |
|
|
} |
|
1258 |
|
|
1259 |
void MainWindow::file_changed() |
void MainWindow::file_changed() |
1260 |
{ |
{ |
1267 |
void MainWindow::load_gig(gig::File* gig, const char* filename, bool isSharedInstrument) |
void MainWindow::load_gig(gig::File* gig, const char* filename, bool isSharedInstrument) |
1268 |
{ |
{ |
1269 |
file = 0; |
file = 0; |
1270 |
file_is_shared = isSharedInstrument; |
set_file_is_shared(isSharedInstrument); |
1271 |
|
|
1272 |
this->filename = filename ? filename : _("Unsaved Gig File"); |
this->filename = filename ? filename : _("Unsaved Gig File"); |
1273 |
set_title(Glib::filename_display_basename(this->filename)); |
set_title(Glib::filename_display_basename(this->filename)); |
1276 |
|
|
1277 |
propDialog.set_info(gig->pInfo); |
propDialog.set_info(gig->pInfo); |
1278 |
|
|
1279 |
Gtk::MenuItem* instrument_menu = |
instrument_name_connection.block(); |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuInstrument")); |
|
|
|
|
|
int instrument_index = 0; |
|
|
Gtk::RadioMenuItem::Group instrument_group; |
|
1280 |
for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ; |
for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ; |
1281 |
instrument = gig->GetNextInstrument()) { |
instrument = gig->GetNextInstrument()) { |
1282 |
|
Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
1283 |
|
|
1284 |
Gtk::TreeModel::iterator iter = m_refTreeModel->append(); |
Gtk::TreeModel::iterator iter = m_refTreeModel->append(); |
1285 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
1286 |
row[m_Columns.m_col_name] = instrument->pInfo->Name.c_str(); |
row[m_Columns.m_col_name] = name; |
1287 |
row[m_Columns.m_col_instr] = instrument; |
row[m_Columns.m_col_instr] = instrument; |
1288 |
// create a menu item for this instrument |
|
1289 |
Gtk::RadioMenuItem* item = |
add_instrument_to_menu(name); |
|
new Gtk::RadioMenuItem(instrument_group, instrument->pInfo->Name.c_str()); |
|
|
instrument_menu->get_submenu()->append(*item); |
|
|
item->signal_activate().connect( |
|
|
sigc::bind( |
|
|
sigc::mem_fun(*this, &MainWindow::on_instrument_selection_change), |
|
|
instrument_index |
|
|
) |
|
|
); |
|
|
instrument_index++; |
|
1290 |
} |
} |
1291 |
instrument_menu->show(); |
instrument_name_connection.unblock(); |
1292 |
instrument_menu->get_submenu()->show_all_children(); |
uiManager->get_widget("/MenuBar/MenuInstrument")->show(); |
1293 |
|
|
1294 |
for (gig::Group* group = gig->GetFirstGroup(); group; group = gig->GetNextGroup()) { |
for (gig::Group* group = gig->GetFirstGroup(); group; group = gig->GetNextGroup()) { |
1295 |
if (group->Name != "") { |
if (group->Name != "") { |
1296 |
Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append(); |
Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append(); |
1297 |
Gtk::TreeModel::Row rowGroup = *iterGroup; |
Gtk::TreeModel::Row rowGroup = *iterGroup; |
1298 |
rowGroup[m_SamplesModel.m_col_name] = group->Name.c_str(); |
rowGroup[m_SamplesModel.m_col_name] = gig_to_utf8(group->Name); |
1299 |
rowGroup[m_SamplesModel.m_col_group] = group; |
rowGroup[m_SamplesModel.m_col_group] = group; |
1300 |
rowGroup[m_SamplesModel.m_col_sample] = NULL; |
rowGroup[m_SamplesModel.m_col_sample] = NULL; |
1301 |
for (gig::Sample* sample = group->GetFirstSample(); |
for (gig::Sample* sample = group->GetFirstSample(); |
1303 |
Gtk::TreeModel::iterator iterSample = |
Gtk::TreeModel::iterator iterSample = |
1304 |
m_refSamplesTreeModel->append(rowGroup.children()); |
m_refSamplesTreeModel->append(rowGroup.children()); |
1305 |
Gtk::TreeModel::Row rowSample = *iterSample; |
Gtk::TreeModel::Row rowSample = *iterSample; |
1306 |
rowSample[m_SamplesModel.m_col_name] = sample->pInfo->Name.c_str(); |
rowSample[m_SamplesModel.m_col_name] = |
1307 |
|
gig_to_utf8(sample->pInfo->Name); |
1308 |
rowSample[m_SamplesModel.m_col_sample] = sample; |
rowSample[m_SamplesModel.m_col_sample] = sample; |
1309 |
rowSample[m_SamplesModel.m_col_group] = NULL; |
rowSample[m_SamplesModel.m_col_group] = NULL; |
1310 |
} |
} |
1314 |
file = gig; |
file = gig; |
1315 |
|
|
1316 |
// select the first instrument |
// select the first instrument |
1317 |
Glib::RefPtr<Gtk::TreeSelection> tree_sel_ref = m_TreeView.get_selection(); |
m_TreeView.get_selection()->select(Gtk::TreePath("0")); |
1318 |
tree_sel_ref->select(Gtk::TreePath("0")); |
|
1319 |
|
instr_props_set_instrument(); |
1320 |
|
gig::Instrument* instrument = get_instrument(); |
1321 |
|
if (instrument) { |
1322 |
|
midiRules.set_instrument(instrument); |
1323 |
|
} |
1324 |
|
} |
1325 |
|
|
1326 |
|
bool MainWindow::instr_props_set_instrument() |
1327 |
|
{ |
1328 |
|
instrumentProps.signal_name_changed().clear(); |
1329 |
|
|
1330 |
|
Gtk::TreeModel::const_iterator it = |
1331 |
|
m_TreeView.get_selection()->get_selected(); |
1332 |
|
if (it) { |
1333 |
|
Gtk::TreeModel::Row row = *it; |
1334 |
|
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
1335 |
|
|
1336 |
|
instrumentProps.set_instrument(instrument); |
1337 |
|
|
1338 |
|
// make sure instrument tree is updated when user changes the |
1339 |
|
// instrument name in instrument properties window |
1340 |
|
instrumentProps.signal_name_changed().connect( |
1341 |
|
sigc::bind( |
1342 |
|
sigc::mem_fun(*this, |
1343 |
|
&MainWindow::instr_name_changed_by_instr_props), |
1344 |
|
it)); |
1345 |
|
} else { |
1346 |
|
instrumentProps.hide(); |
1347 |
|
} |
1348 |
|
return it; |
1349 |
} |
} |
1350 |
|
|
1351 |
void MainWindow::show_instr_props() |
void MainWindow::show_instr_props() |
1352 |
{ |
{ |
1353 |
Glib::RefPtr<Gtk::TreeSelection> tree_sel_ref = m_TreeView.get_selection(); |
if (instr_props_set_instrument()) { |
1354 |
Gtk::TreeModel::iterator it = tree_sel_ref->get_selected(); |
instrumentProps.show(); |
1355 |
if (it) |
instrumentProps.deiconify(); |
1356 |
|
} |
1357 |
|
} |
1358 |
|
|
1359 |
|
void MainWindow::instr_name_changed_by_instr_props(Gtk::TreeModel::iterator& it) |
1360 |
|
{ |
1361 |
|
Gtk::TreeModel::Row row = *it; |
1362 |
|
Glib::ustring name = row[m_Columns.m_col_name]; |
1363 |
|
|
1364 |
|
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
1365 |
|
Glib::ustring gigname(gig_to_utf8(instrument->pInfo->Name)); |
1366 |
|
if (gigname != name) { |
1367 |
|
row[m_Columns.m_col_name] = gigname; |
1368 |
|
} |
1369 |
|
} |
1370 |
|
|
1371 |
|
void MainWindow::show_midi_rules() |
1372 |
|
{ |
1373 |
|
if (gig::Instrument* instrument = get_instrument()) |
1374 |
{ |
{ |
1375 |
Gtk::TreeModel::Row row = *it; |
midiRules.set_instrument(instrument); |
1376 |
if (row[m_Columns.m_col_instr]) |
midiRules.show(); |
1377 |
{ |
midiRules.deiconify(); |
1378 |
instrumentProps.set_instrument(row[m_Columns.m_col_instr]); |
} |
1379 |
instrumentProps.show(); |
} |
1380 |
instrumentProps.deiconify(); |
|
1381 |
} |
void MainWindow::on_action_view_status_bar() { |
1382 |
|
Gtk::CheckMenuItem* item = |
1383 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar")); |
1384 |
|
if (!item) { |
1385 |
|
std::cerr << "/MenuBar/MenuView/Statusbar == NULL\n"; |
1386 |
|
return; |
1387 |
|
} |
1388 |
|
if (item->get_active()) m_StatusBar.show(); |
1389 |
|
else m_StatusBar.hide(); |
1390 |
|
} |
1391 |
|
|
1392 |
|
bool MainWindow::is_copy_samples_unity_note_enabled() const { |
1393 |
|
Gtk::CheckMenuItem* item = |
1394 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity")); |
1395 |
|
if (!item) { |
1396 |
|
std::cerr << "/MenuBar/MenuEdit/CopySampleUnity == NULL\n"; |
1397 |
|
return true; |
1398 |
|
} |
1399 |
|
return item->get_active(); |
1400 |
|
} |
1401 |
|
|
1402 |
|
bool MainWindow::is_copy_samples_fine_tune_enabled() const { |
1403 |
|
Gtk::CheckMenuItem* item = |
1404 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleTune")); |
1405 |
|
if (!item) { |
1406 |
|
std::cerr << "/MenuBar/MenuEdit/CopySampleTune == NULL\n"; |
1407 |
|
return true; |
1408 |
|
} |
1409 |
|
return item->get_active(); |
1410 |
|
} |
1411 |
|
|
1412 |
|
bool MainWindow::is_copy_samples_loop_enabled() const { |
1413 |
|
Gtk::CheckMenuItem* item = |
1414 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleLoop")); |
1415 |
|
if (!item) { |
1416 |
|
std::cerr << "/MenuBar/MenuEdit/CopySampleLoop == NULL\n"; |
1417 |
|
return true; |
1418 |
} |
} |
1419 |
|
return item->get_active(); |
1420 |
} |
} |
1421 |
|
|
1422 |
void MainWindow::on_button_release(GdkEventButton* button) |
void MainWindow::on_button_release(GdkEventButton* button) |
1424 |
if (button->type == GDK_2BUTTON_PRESS) { |
if (button->type == GDK_2BUTTON_PRESS) { |
1425 |
show_instr_props(); |
show_instr_props(); |
1426 |
} else if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
} else if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
1427 |
|
// gig v2 files have no midi rules |
1428 |
|
static_cast<Gtk::MenuItem*>( |
1429 |
|
uiManager->get_widget("/PopupMenu/MidiRules"))->set_sensitive( |
1430 |
|
!(file->pVersion && file->pVersion->major == 2)); |
1431 |
popup_menu->popup(button->button, button->time); |
popup_menu->popup(button->button, button->time); |
1432 |
} |
} |
1433 |
} |
} |
1434 |
|
|
1435 |
void MainWindow::on_instrument_selection_change(int index) { |
void MainWindow::on_instrument_selection_change(Gtk::RadioMenuItem* item) { |
1436 |
m_RegionChooser.set_instrument(file->GetInstrument(index)); |
if (item->get_active()) { |
1437 |
|
const std::vector<Gtk::Widget*> children = |
1438 |
|
instrument_menu->get_children(); |
1439 |
|
std::vector<Gtk::Widget*>::const_iterator it = |
1440 |
|
find(children.begin(), children.end(), item); |
1441 |
|
if (it != children.end()) { |
1442 |
|
int index = it - children.begin(); |
1443 |
|
m_TreeView.get_selection()->select(Gtk::TreePath(ToString(index))); |
1444 |
|
|
1445 |
|
m_RegionChooser.set_instrument(file->GetInstrument(index)); |
1446 |
|
} |
1447 |
|
} |
1448 |
} |
} |
1449 |
|
|
1450 |
void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) { |
void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) { |
1474 |
} |
} |
1475 |
} |
} |
1476 |
|
|
1477 |
void MainWindow::on_action_add_instrument() { |
|
1478 |
static int __instrument_indexer = 0; |
Gtk::RadioMenuItem* MainWindow::add_instrument_to_menu( |
1479 |
if (!file) return; |
const Glib::ustring& name, int position) { |
1480 |
gig::Instrument* instrument = file->AddInstrument(); |
|
1481 |
__instrument_indexer++; |
Gtk::RadioMenuItem::Group instrument_group; |
1482 |
instrument->pInfo->Name = |
const std::vector<Gtk::Widget*> children = instrument_menu->get_children(); |
1483 |
"Unnamed Instrument " + ToString(__instrument_indexer); |
if (!children.empty()) { |
1484 |
|
instrument_group = |
1485 |
|
static_cast<Gtk::RadioMenuItem*>(children[0])->get_group(); |
1486 |
|
} |
1487 |
|
Gtk::RadioMenuItem* item = |
1488 |
|
new Gtk::RadioMenuItem(instrument_group, name); |
1489 |
|
if (position < 0) { |
1490 |
|
instrument_menu->append(*item); |
1491 |
|
} else { |
1492 |
|
instrument_menu->insert(*item, position); |
1493 |
|
} |
1494 |
|
item->show(); |
1495 |
|
item->signal_activate().connect( |
1496 |
|
sigc::bind( |
1497 |
|
sigc::mem_fun(*this, &MainWindow::on_instrument_selection_change), |
1498 |
|
item)); |
1499 |
|
return item; |
1500 |
|
} |
1501 |
|
|
1502 |
|
void MainWindow::remove_instrument_from_menu(int index) { |
1503 |
|
const std::vector<Gtk::Widget*> children = |
1504 |
|
instrument_menu->get_children(); |
1505 |
|
Gtk::Widget* child = children[index]; |
1506 |
|
instrument_menu->remove(*child); |
1507 |
|
delete child; |
1508 |
|
} |
1509 |
|
|
1510 |
|
void MainWindow::add_instrument(gig::Instrument* instrument) { |
1511 |
|
const Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
1512 |
|
|
1513 |
// update instrument tree view |
// update instrument tree view |
1514 |
|
instrument_name_connection.block(); |
1515 |
Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append(); |
Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append(); |
1516 |
Gtk::TreeModel::Row rowInstr = *iterInstr; |
Gtk::TreeModel::Row rowInstr = *iterInstr; |
1517 |
rowInstr[m_Columns.m_col_name] = instrument->pInfo->Name.c_str(); |
rowInstr[m_Columns.m_col_name] = name; |
1518 |
rowInstr[m_Columns.m_col_instr] = instrument; |
rowInstr[m_Columns.m_col_instr] = instrument; |
1519 |
|
instrument_name_connection.unblock(); |
1520 |
|
|
1521 |
|
add_instrument_to_menu(name); |
1522 |
|
|
1523 |
|
m_TreeView.get_selection()->select(iterInstr); |
1524 |
|
|
1525 |
file_changed(); |
file_changed(); |
1526 |
} |
} |
1527 |
|
|
1528 |
|
void MainWindow::on_action_add_instrument() { |
1529 |
|
static int __instrument_indexer = 0; |
1530 |
|
if (!file) return; |
1531 |
|
gig::Instrument* instrument = file->AddInstrument(); |
1532 |
|
__instrument_indexer++; |
1533 |
|
instrument->pInfo->Name = gig_from_utf8(_("Unnamed Instrument ") + |
1534 |
|
ToString(__instrument_indexer)); |
1535 |
|
|
1536 |
|
add_instrument(instrument); |
1537 |
|
} |
1538 |
|
|
1539 |
|
void MainWindow::on_action_duplicate_instrument() { |
1540 |
|
if (!file) return; |
1541 |
|
|
1542 |
|
// retrieve the currently selected instrument |
1543 |
|
// (being the original instrument to be duplicated) |
1544 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
1545 |
|
Gtk::TreeModel::iterator itSelection = sel->get_selected(); |
1546 |
|
if (!itSelection) return; |
1547 |
|
Gtk::TreeModel::Row row = *itSelection; |
1548 |
|
gig::Instrument* instrOrig = row[m_Columns.m_col_instr]; |
1549 |
|
if (!instrOrig) return; |
1550 |
|
|
1551 |
|
// duplicate the orginal instrument |
1552 |
|
gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); |
1553 |
|
instrNew->pInfo->Name = |
1554 |
|
instrOrig->pInfo->Name + |
1555 |
|
gig_from_utf8(Glib::ustring(" (") + _("Copy") + ")"); |
1556 |
|
|
1557 |
|
add_instrument(instrNew); |
1558 |
|
} |
1559 |
|
|
1560 |
void MainWindow::on_action_remove_instrument() { |
void MainWindow::on_action_remove_instrument() { |
1561 |
if (!file) return; |
if (!file) return; |
1562 |
if (file_is_shared) { |
if (file_is_shared) { |
1576 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
1577 |
gig::Instrument* instr = row[m_Columns.m_col_instr]; |
gig::Instrument* instr = row[m_Columns.m_col_instr]; |
1578 |
try { |
try { |
1579 |
|
Gtk::TreePath path(it); |
1580 |
|
int index = path[0]; |
1581 |
|
|
1582 |
// remove instrument from the gig file |
// remove instrument from the gig file |
1583 |
if (instr) file->DeleteInstrument(instr); |
if (instr) file->DeleteInstrument(instr); |
|
// remove respective row from instruments tree view |
|
|
m_refTreeModel->erase(it); |
|
1584 |
file_changed(); |
file_changed(); |
1585 |
|
|
1586 |
|
remove_instrument_from_menu(index); |
1587 |
|
|
1588 |
|
// remove row from instruments tree view |
1589 |
|
m_refTreeModel->erase(it); |
1590 |
|
|
1591 |
|
#if GTKMM_MAJOR_VERSION < 3 |
1592 |
|
// select another instrument (in gtk3 this is done |
1593 |
|
// automatically) |
1594 |
|
if (!m_refTreeModel->children().empty()) { |
1595 |
|
if (index == m_refTreeModel->children().size()) { |
1596 |
|
index--; |
1597 |
|
} |
1598 |
|
m_TreeView.get_selection()->select( |
1599 |
|
Gtk::TreePath(ToString(index))); |
1600 |
|
} |
1601 |
|
#endif |
1602 |
|
instr_props_set_instrument(); |
1603 |
|
instr = get_instrument(); |
1604 |
|
if (instr) { |
1605 |
|
midiRules.set_instrument(instr); |
1606 |
|
} else { |
1607 |
|
midiRules.hide(); |
1608 |
|
} |
1609 |
} catch (RIFF::Exception e) { |
} catch (RIFF::Exception e) { |
1610 |
Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR); |
Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR); |
1611 |
msg.run(); |
msg.run(); |
1616 |
void MainWindow::on_action_sample_properties() { |
void MainWindow::on_action_sample_properties() { |
1617 |
//TODO: show a dialog where the selected sample's properties can be edited |
//TODO: show a dialog where the selected sample's properties can be edited |
1618 |
Gtk::MessageDialog msg( |
Gtk::MessageDialog msg( |
1619 |
*this, "Sorry, yet to be implemented!", false, Gtk::MESSAGE_INFO |
*this, _("Sorry, yet to be implemented!"), false, Gtk::MESSAGE_INFO |
1620 |
); |
); |
1621 |
msg.run(); |
msg.run(); |
1622 |
} |
} |
1625 |
static int __sample_indexer = 0; |
static int __sample_indexer = 0; |
1626 |
if (!file) return; |
if (!file) return; |
1627 |
gig::Group* group = file->AddGroup(); |
gig::Group* group = file->AddGroup(); |
1628 |
group->Name = "Unnamed Group"; |
group->Name = gig_from_utf8(_("Unnamed Group")); |
1629 |
if (__sample_indexer) group->Name += " " + ToString(__sample_indexer); |
if (__sample_indexer) group->Name += " " + ToString(__sample_indexer); |
1630 |
__sample_indexer++; |
__sample_indexer++; |
1631 |
// update sample tree view |
// update sample tree view |
1632 |
Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append(); |
Gtk::TreeModel::iterator iterGroup = m_refSamplesTreeModel->append(); |
1633 |
Gtk::TreeModel::Row rowGroup = *iterGroup; |
Gtk::TreeModel::Row rowGroup = *iterGroup; |
1634 |
rowGroup[m_SamplesModel.m_col_name] = group->Name.c_str(); |
rowGroup[m_SamplesModel.m_col_name] = gig_to_utf8(group->Name); |
1635 |
rowGroup[m_SamplesModel.m_col_sample] = NULL; |
rowGroup[m_SamplesModel.m_col_sample] = NULL; |
1636 |
rowGroup[m_SamplesModel.m_col_group] = group; |
rowGroup[m_SamplesModel.m_col_group] = group; |
1637 |
file_changed(); |
file_changed(); |
1659 |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
1660 |
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); |
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); |
1661 |
dialog.set_select_multiple(true); |
dialog.set_select_multiple(true); |
1662 |
Gtk::FileFilter soundfilter; // matches all file types supported by libsndfile |
|
1663 |
|
// matches all file types supported by libsndfile |
1664 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
1665 |
|
Gtk::FileFilter soundfilter; |
1666 |
|
#else |
1667 |
|
Glib::RefPtr<Gtk::FileFilter> soundfilter = Gtk::FileFilter::create(); |
1668 |
|
#endif |
1669 |
const char* const supportedFileTypes[] = { |
const char* const supportedFileTypes[] = { |
1670 |
"*.wav", "*.WAV", "*.aiff", "*.AIFF", "*.aifc", "*.AIFC", "*.snd", |
"*.wav", "*.WAV", "*.aiff", "*.AIFF", "*.aifc", "*.AIFC", "*.snd", |
1671 |
"*.SND", "*.au", "*.AU", "*.paf", "*.PAF", "*.iff", "*.IFF", |
"*.SND", "*.au", "*.AU", "*.paf", "*.PAF", "*.iff", "*.IFF", |
1673 |
"*.W64", "*.pvf", "*.PVF", "*.xi", "*.XI", "*.htk", "*.HTK", |
"*.W64", "*.pvf", "*.PVF", "*.xi", "*.XI", "*.htk", "*.HTK", |
1674 |
"*.caf", "*.CAF", NULL |
"*.caf", "*.CAF", NULL |
1675 |
}; |
}; |
1676 |
|
const char* soundfiles = _("Sound Files"); |
1677 |
|
const char* allfiles = _("All Files"); |
1678 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
1679 |
for (int i = 0; supportedFileTypes[i]; i++) |
for (int i = 0; supportedFileTypes[i]; i++) |
1680 |
soundfilter.add_pattern(supportedFileTypes[i]); |
soundfilter.add_pattern(supportedFileTypes[i]); |
1681 |
soundfilter.set_name("Sound Files"); |
soundfilter.set_name(soundfiles); |
1682 |
Gtk::FileFilter allpassfilter; // matches every file |
|
1683 |
|
// matches every file |
1684 |
|
Gtk::FileFilter allpassfilter; |
1685 |
allpassfilter.add_pattern("*.*"); |
allpassfilter.add_pattern("*.*"); |
1686 |
allpassfilter.set_name("All Files"); |
allpassfilter.set_name(allfiles); |
1687 |
|
#else |
1688 |
|
for (int i = 0; supportedFileTypes[i]; i++) |
1689 |
|
soundfilter->add_pattern(supportedFileTypes[i]); |
1690 |
|
soundfilter->set_name(soundfiles); |
1691 |
|
|
1692 |
|
// matches every file |
1693 |
|
Glib::RefPtr<Gtk::FileFilter> allpassfilter = Gtk::FileFilter::create(); |
1694 |
|
allpassfilter->add_pattern("*.*"); |
1695 |
|
allpassfilter->set_name(allfiles); |
1696 |
|
#endif |
1697 |
dialog.add_filter(soundfilter); |
dialog.add_filter(soundfilter); |
1698 |
dialog.add_filter(allpassfilter); |
dialog.add_filter(allpassfilter); |
1699 |
|
if (current_sample_dir != "") { |
1700 |
|
dialog.set_current_folder(current_sample_dir); |
1701 |
|
} |
1702 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
1703 |
|
current_sample_dir = dialog.get_current_folder(); |
1704 |
Glib::ustring error_files; |
Glib::ustring error_files; |
1705 |
Glib::SListHandle<Glib::ustring> filenames = dialog.get_filenames(); |
std::vector<std::string> filenames = dialog.get_filenames(); |
1706 |
for (Glib::SListHandle<Glib::ustring>::iterator iter = filenames.begin(); |
for (std::vector<std::string>::iterator iter = filenames.begin(); |
1707 |
iter != filenames.end(); ++iter) { |
iter != filenames.end(); ++iter) { |
1708 |
printf("Adding sample %s\n",(*iter).c_str()); |
printf("Adding sample %s\n",(*iter).c_str()); |
1709 |
// use libsndfile to retrieve file informations |
// use libsndfile to retrieve file informations |
1711 |
info.format = 0; |
info.format = 0; |
1712 |
SNDFILE* hFile = sf_open((*iter).c_str(), SFM_READ, &info); |
SNDFILE* hFile = sf_open((*iter).c_str(), SFM_READ, &info); |
1713 |
try { |
try { |
1714 |
if (!hFile) throw std::string("could not open file"); |
if (!hFile) throw std::string(_("could not open file")); |
1715 |
int bitdepth; |
int bitdepth; |
1716 |
switch (info.format & 0xff) { |
switch (info.format & 0xff) { |
1717 |
case SF_FORMAT_PCM_S8: |
case SF_FORMAT_PCM_S8: |
1727 |
break; |
break; |
1728 |
default: |
default: |
1729 |
sf_close(hFile); // close sound file |
sf_close(hFile); // close sound file |
1730 |
throw std::string("format not supported"); // unsupported subformat (yet?) |
throw std::string(_("format not supported")); // unsupported subformat (yet?) |
1731 |
} |
} |
1732 |
// add a new sample to the .gig file |
// add a new sample to the .gig file |
1733 |
gig::Sample* sample = file->AddSample(); |
gig::Sample* sample = file->AddSample(); |
1740 |
break; |
break; |
1741 |
} |
} |
1742 |
} |
} |
1743 |
sample->pInfo->Name = filename; |
sample->pInfo->Name = gig_from_utf8(filename); |
1744 |
sample->Channels = info.channels; |
sample->Channels = info.channels; |
1745 |
sample->BitDepth = bitdepth; |
sample->BitDepth = bitdepth; |
1746 |
sample->FrameSize = bitdepth / 8/*1 byte are 8 bits*/ * info.channels; |
sample->FrameSize = bitdepth / 8/*1 byte are 8 bits*/ * info.channels; |
1754 |
&instrument, sizeof(instrument)) != SF_FALSE) |
&instrument, sizeof(instrument)) != SF_FALSE) |
1755 |
{ |
{ |
1756 |
sample->MIDIUnityNote = instrument.basenote; |
sample->MIDIUnityNote = instrument.basenote; |
1757 |
|
sample->FineTune = instrument.detune; |
1758 |
|
|
|
#if HAVE_SF_INSTRUMENT_LOOPS |
|
1759 |
if (instrument.loop_count && instrument.loops[0].mode != SF_LOOP_NONE) { |
if (instrument.loop_count && instrument.loops[0].mode != SF_LOOP_NONE) { |
1760 |
sample->Loops = 1; |
sample->Loops = 1; |
1761 |
|
|
1775 |
sample->LoopPlayCount = instrument.loops[0].count; |
sample->LoopPlayCount = instrument.loops[0].count; |
1776 |
sample->LoopSize = sample->LoopEnd - sample->LoopStart + 1; |
sample->LoopSize = sample->LoopEnd - sample->LoopStart + 1; |
1777 |
} |
} |
|
#endif |
|
1778 |
} |
} |
1779 |
|
|
1780 |
// schedule resizing the sample (which will be done |
// schedule resizing the sample (which will be done |
1792 |
Gtk::TreeModel::iterator iterSample = |
Gtk::TreeModel::iterator iterSample = |
1793 |
m_refSamplesTreeModel->append(row.children()); |
m_refSamplesTreeModel->append(row.children()); |
1794 |
Gtk::TreeModel::Row rowSample = *iterSample; |
Gtk::TreeModel::Row rowSample = *iterSample; |
1795 |
rowSample[m_SamplesModel.m_col_name] = filename; |
rowSample[m_SamplesModel.m_col_name] = |
1796 |
|
gig_to_utf8(sample->pInfo->Name); |
1797 |
rowSample[m_SamplesModel.m_col_sample] = sample; |
rowSample[m_SamplesModel.m_col_sample] = sample; |
1798 |
rowSample[m_SamplesModel.m_col_group] = NULL; |
rowSample[m_SamplesModel.m_col_group] = NULL; |
1799 |
// close sound file |
// close sound file |
1800 |
sf_close(hFile); |
sf_close(hFile); |
1801 |
file_changed(); |
file_changed(); |
1802 |
} catch (std::string what) { // remember the files that made trouble (and their cause) |
} catch (std::string what) { // remember the files that made trouble (and their cause) |
1803 |
if (error_files.size()) error_files += "\n"; |
if (!error_files.empty()) error_files += "\n"; |
1804 |
error_files += *iter += " (" + what + ")"; |
error_files += *iter += " (" + what + ")"; |
1805 |
} |
} |
1806 |
} |
} |
1807 |
// 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 |
1808 |
if (error_files.size()) { |
if (!error_files.empty()) { |
1809 |
Glib::ustring txt = _("Could not add the following sample(s):\n") + error_files; |
Glib::ustring txt = _("Could not add the following sample(s):\n") + error_files; |
1810 |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
1811 |
msg.run(); |
msg.run(); |
1813 |
} |
} |
1814 |
} |
} |
1815 |
|
|
1816 |
|
void MainWindow::on_action_replace_all_samples_in_all_groups() |
1817 |
|
{ |
1818 |
|
if (!file) return; |
1819 |
|
Gtk::FileChooserDialog dialog(*this, _("Select Folder"), |
1820 |
|
Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER); |
1821 |
|
const char* str = |
1822 |
|
_("This is a very specific function. It tries to replace all samples " |
1823 |
|
"in the current gig file by samples located in the chosen " |
1824 |
|
"directory.\n\n" |
1825 |
|
"It works like this: For each sample in the gig file, it tries to " |
1826 |
|
"find a sample file in the selected directory with the same name as " |
1827 |
|
"the sample in the gig file. Optionally, you can add a filename " |
1828 |
|
"extension below, which will be added to the filename expected to be " |
1829 |
|
"found. That is, assume you have a gig file with a sample called " |
1830 |
|
"'Snare', if you enter '.wav' below (like it's done by default), it " |
1831 |
|
"expects to find a sample file called 'Snare.wav' and will replace " |
1832 |
|
"the sample in the gig file accordingly. If you don't need an " |
1833 |
|
"extension, blank the field below. Any gig sample where no " |
1834 |
|
"appropriate sample file could be found will be reported and left " |
1835 |
|
"untouched.\n"); |
1836 |
|
#if GTKMM_MAJOR_VERSION < 3 |
1837 |
|
view::WrapLabel description(str); |
1838 |
|
#else |
1839 |
|
Gtk::Label description(str); |
1840 |
|
description.set_line_wrap(); |
1841 |
|
#endif |
1842 |
|
Gtk::HBox entryArea; |
1843 |
|
Gtk::Label entryLabel( _("Add filename extension: "), Gtk::ALIGN_START); |
1844 |
|
Gtk::Entry postfixEntryBox; |
1845 |
|
postfixEntryBox.set_text(".wav"); |
1846 |
|
entryArea.pack_start(entryLabel); |
1847 |
|
entryArea.pack_start(postfixEntryBox); |
1848 |
|
dialog.get_vbox()->pack_start(description, Gtk::PACK_SHRINK); |
1849 |
|
dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK); |
1850 |
|
description.show(); |
1851 |
|
entryArea.show_all(); |
1852 |
|
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
1853 |
|
dialog.add_button(_("Select"), Gtk::RESPONSE_OK); |
1854 |
|
dialog.set_select_multiple(false); |
1855 |
|
if (current_sample_dir != "") { |
1856 |
|
dialog.set_current_folder(current_sample_dir); |
1857 |
|
} |
1858 |
|
if (dialog.run() == Gtk::RESPONSE_OK) |
1859 |
|
{ |
1860 |
|
current_sample_dir = dialog.get_current_folder(); |
1861 |
|
Glib::ustring error_files; |
1862 |
|
std::string folder = dialog.get_filename(); |
1863 |
|
for (gig::Sample* sample = file->GetFirstSample(); |
1864 |
|
sample; sample = file->GetNextSample()) |
1865 |
|
{ |
1866 |
|
std::string filename = |
1867 |
|
folder + G_DIR_SEPARATOR_S + |
1868 |
|
Glib::filename_from_utf8(gig_to_utf8(sample->pInfo->Name) + |
1869 |
|
postfixEntryBox.get_text()); |
1870 |
|
SF_INFO info; |
1871 |
|
info.format = 0; |
1872 |
|
SNDFILE* hFile = sf_open(filename.c_str(), SFM_READ, &info); |
1873 |
|
try |
1874 |
|
{ |
1875 |
|
if (!hFile) throw std::string(_("could not open file")); |
1876 |
|
int bitdepth; |
1877 |
|
switch (info.format & 0xff) { |
1878 |
|
case SF_FORMAT_PCM_S8: |
1879 |
|
case SF_FORMAT_PCM_16: |
1880 |
|
case SF_FORMAT_PCM_U8: |
1881 |
|
bitdepth = 16; |
1882 |
|
break; |
1883 |
|
case SF_FORMAT_PCM_24: |
1884 |
|
case SF_FORMAT_PCM_32: |
1885 |
|
case SF_FORMAT_FLOAT: |
1886 |
|
case SF_FORMAT_DOUBLE: |
1887 |
|
bitdepth = 24; |
1888 |
|
break; |
1889 |
|
default: |
1890 |
|
sf_close(hFile); |
1891 |
|
throw std::string(_("format not supported")); |
1892 |
|
} |
1893 |
|
SampleImportItem sched_item; |
1894 |
|
sched_item.gig_sample = sample; |
1895 |
|
sched_item.sample_path = filename; |
1896 |
|
m_SampleImportQueue.push_back(sched_item); |
1897 |
|
sf_close(hFile); |
1898 |
|
file_changed(); |
1899 |
|
} |
1900 |
|
catch (std::string what) |
1901 |
|
{ |
1902 |
|
if (!error_files.empty()) error_files += "\n"; |
1903 |
|
error_files += Glib::filename_to_utf8(filename) + |
1904 |
|
" (" + what + ")"; |
1905 |
|
} |
1906 |
|
} |
1907 |
|
// show error message box when some file(s) could not be opened / added |
1908 |
|
if (!error_files.empty()) { |
1909 |
|
Glib::ustring txt = |
1910 |
|
_("Could not replace the following sample(s):\n") + error_files; |
1911 |
|
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
1912 |
|
msg.run(); |
1913 |
|
} |
1914 |
|
} |
1915 |
|
} |
1916 |
|
|
1917 |
void MainWindow::on_action_remove_sample() { |
void MainWindow::on_action_remove_sample() { |
1918 |
if (!file) return; |
if (!file) return; |
1919 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
1926 |
try { |
try { |
1927 |
// remove group or sample from the gig file |
// remove group or sample from the gig file |
1928 |
if (group) { |
if (group) { |
1929 |
// temporarily remember the samples that bolong to |
// temporarily remember the samples that belong to |
1930 |
// that group (we need that to clean the queue) |
// that group (we need that to clean the queue) |
1931 |
std::list<gig::Sample*> members; |
std::list<gig::Sample*> members; |
1932 |
for (gig::Sample* pSample = group->GetFirstSample(); |
for (gig::Sample* pSample = group->GetFirstSample(); |
2048 |
bool channels_changed = false; |
bool channels_changed = false; |
2049 |
if (sample->Channels == 1 && stereo_dimension) { |
if (sample->Channels == 1 && stereo_dimension) { |
2050 |
// remove the samplechannel dimension |
// remove the samplechannel dimension |
2051 |
|
/* commented out, because it makes it impossible building up an instrument from scratch using two separate L/R samples |
2052 |
region->DeleteDimension(stereo_dimension); |
region->DeleteDimension(stereo_dimension); |
2053 |
channels_changed = true; |
channels_changed = true; |
2054 |
region_changed(); |
region_changed(); |
2055 |
|
*/ |
2056 |
} |
} |
2057 |
dimreg_edit.set_sample(sample); |
dimreg_edit.set_sample( |
2058 |
|
sample, |
2059 |
|
is_copy_samples_unity_note_enabled(), |
2060 |
|
is_copy_samples_fine_tune_enabled(), |
2061 |
|
is_copy_samples_loop_enabled() |
2062 |
|
); |
2063 |
|
|
2064 |
if (sample->Channels == 2 && !stereo_dimension) { |
if (sample->Channels == 2 && !stereo_dimension) { |
2065 |
// add samplechannel dimension |
// add samplechannel dimension |
2087 |
// notify we're done with altering |
// notify we're done with altering |
2088 |
region_changed_signal.emit(region); |
region_changed_signal.emit(region); |
2089 |
|
|
2090 |
|
file_changed(); |
2091 |
|
|
2092 |
return; |
return; |
2093 |
} |
} |
2094 |
// drop failed |
// drop failed |
2102 |
Glib::ustring name = row[m_SamplesModel.m_col_name]; |
Glib::ustring name = row[m_SamplesModel.m_col_name]; |
2103 |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
2104 |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
2105 |
|
gig::String gigname(gig_from_utf8(name)); |
2106 |
if (group) { |
if (group) { |
2107 |
if (group->Name != name) { |
if (group->Name != gigname) { |
2108 |
group->Name = name; |
group->Name = gigname; |
2109 |
printf("group name changed\n"); |
printf("group name changed\n"); |
2110 |
file_changed(); |
file_changed(); |
2111 |
} |
} |
2112 |
} else if (sample) { |
} else if (sample) { |
2113 |
if (sample->pInfo->Name != name.raw()) { |
if (sample->pInfo->Name != gigname) { |
2114 |
sample->pInfo->Name = name.raw(); |
sample->pInfo->Name = gigname; |
2115 |
printf("sample name changed\n"); |
printf("sample name changed\n"); |
2116 |
file_changed(); |
file_changed(); |
2117 |
} |
} |
2123 |
if (!iter) return; |
if (!iter) return; |
2124 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
2125 |
Glib::ustring name = row[m_Columns.m_col_name]; |
Glib::ustring name = row[m_Columns.m_col_name]; |
2126 |
|
|
2127 |
|
// change name in instrument menu |
2128 |
|
int index = path[0]; |
2129 |
|
const std::vector<Gtk::Widget*> children = instrument_menu->get_children(); |
2130 |
|
if (index < children.size()) { |
2131 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 16) || GTKMM_MAJOR_VERSION > 2 |
2132 |
|
static_cast<Gtk::RadioMenuItem*>(children[index])->set_label(name); |
2133 |
|
#else |
2134 |
|
remove_instrument_from_menu(index); |
2135 |
|
Gtk::RadioMenuItem* item = add_instrument_to_menu(name, index); |
2136 |
|
item->set_active(); |
2137 |
|
#endif |
2138 |
|
} |
2139 |
|
|
2140 |
|
// change name in gig |
2141 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
2142 |
if (instrument && instrument->pInfo->Name != name.raw()) { |
gig::String gigname(gig_from_utf8(name)); |
2143 |
instrument->pInfo->Name = name.raw(); |
if (instrument && instrument->pInfo->Name != gigname) { |
2144 |
|
instrument->pInfo->Name = gigname; |
2145 |
|
|
2146 |
|
// change name in the instrument properties window |
2147 |
|
if (instrumentProps.get_instrument() == instrument) { |
2148 |
|
instrumentProps.update_name(); |
2149 |
|
} |
2150 |
|
|
2151 |
file_changed(); |
file_changed(); |
2152 |
} |
} |
2153 |
} |
} |
2154 |
|
|
2155 |
|
void MainWindow::on_action_combine_instruments() { |
2156 |
|
CombineInstrumentsDialog* d = new CombineInstrumentsDialog(*this, file); |
2157 |
|
d->show_all(); |
2158 |
|
d->resize(500, 400); |
2159 |
|
d->run(); |
2160 |
|
if (d->fileWasChanged()) { |
2161 |
|
// update GUI with new instrument just created |
2162 |
|
add_instrument(d->newCombinedInstrument()); |
2163 |
|
} |
2164 |
|
delete d; |
2165 |
|
} |
2166 |
|
|
2167 |
|
void MainWindow::mergeFiles(const std::vector<std::string>& filenames) { |
2168 |
|
struct _Source { |
2169 |
|
std::vector<RIFF::File*> riffs; |
2170 |
|
std::vector<gig::File*> gigs; |
2171 |
|
|
2172 |
|
~_Source() { |
2173 |
|
for (int k = 0; k < gigs.size(); ++k) delete gigs[k]; |
2174 |
|
for (int k = 0; k < riffs.size(); ++k) delete riffs[k]; |
2175 |
|
riffs.clear(); |
2176 |
|
gigs.clear(); |
2177 |
|
} |
2178 |
|
} sources; |
2179 |
|
|
2180 |
|
if (filenames.empty()) |
2181 |
|
throw RIFF::Exception(_("No files selected, so nothing done.")); |
2182 |
|
|
2183 |
|
// first open all input files (to avoid output file corruption) |
2184 |
|
int i; |
2185 |
|
try { |
2186 |
|
for (i = 0; i < filenames.size(); ++i) { |
2187 |
|
const std::string& filename = filenames[i]; |
2188 |
|
printf("opening file=%s\n", filename.c_str()); |
2189 |
|
|
2190 |
|
RIFF::File* riff = new RIFF::File(filename); |
2191 |
|
sources.riffs.push_back(riff); |
2192 |
|
|
2193 |
|
gig::File* gig = new gig::File(riff); |
2194 |
|
sources.gigs.push_back(gig); |
2195 |
|
} |
2196 |
|
} catch (RIFF::Exception e) { |
2197 |
|
throw RIFF::Exception( |
2198 |
|
_("Error occurred while opening '") + |
2199 |
|
filenames[i] + |
2200 |
|
"': " + |
2201 |
|
e.Message |
2202 |
|
); |
2203 |
|
} catch (...) { |
2204 |
|
throw RIFF::Exception( |
2205 |
|
_("Unknown exception occurred while opening '") + |
2206 |
|
filenames[i] + "'" |
2207 |
|
); |
2208 |
|
} |
2209 |
|
|
2210 |
|
// now merge the opened .gig files to the main .gig file currently being |
2211 |
|
// open in gigedit |
2212 |
|
try { |
2213 |
|
for (i = 0; i < filenames.size(); ++i) { |
2214 |
|
const std::string& filename = filenames[i]; |
2215 |
|
printf("merging file=%s\n", filename.c_str()); |
2216 |
|
assert(i < sources.gigs.size()); |
2217 |
|
|
2218 |
|
this->file->AddContentOf(sources.gigs[i]); |
2219 |
|
} |
2220 |
|
} catch (RIFF::Exception e) { |
2221 |
|
throw RIFF::Exception( |
2222 |
|
_("Error occurred while merging '") + |
2223 |
|
filenames[i] + |
2224 |
|
"': " + |
2225 |
|
e.Message |
2226 |
|
); |
2227 |
|
} catch (...) { |
2228 |
|
throw RIFF::Exception( |
2229 |
|
_("Unknown exception occurred while merging '") + |
2230 |
|
filenames[i] + "'" |
2231 |
|
); |
2232 |
|
} |
2233 |
|
|
2234 |
|
// Note: requires that this file already has a filename ! |
2235 |
|
this->file->Save(); |
2236 |
|
} |
2237 |
|
|
2238 |
|
void MainWindow::on_action_merge_files() { |
2239 |
|
if (this->file->GetFileName().empty()) { |
2240 |
|
Glib::ustring txt = _( |
2241 |
|
"You seem to have a new .gig file open that has not been saved " |
2242 |
|
"yet. You must save it somewhere before starting to merge it with " |
2243 |
|
"other .gig files though, because during the merge operation the " |
2244 |
|
"other files' sample data must be written on file level to the " |
2245 |
|
"target .gig file." |
2246 |
|
); |
2247 |
|
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
2248 |
|
msg.run(); |
2249 |
|
return; |
2250 |
|
} |
2251 |
|
|
2252 |
|
Gtk::FileChooserDialog dialog(*this, _("Merge .gig files")); |
2253 |
|
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
2254 |
|
dialog.add_button(_("Merge"), Gtk::RESPONSE_OK); |
2255 |
|
dialog.set_default_response(Gtk::RESPONSE_CANCEL); |
2256 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
2257 |
|
Gtk::FileFilter filter; |
2258 |
|
filter.add_pattern("*.gig"); |
2259 |
|
#else |
2260 |
|
Glib::RefPtr<Gtk::FileFilter> filter = Gtk::FileFilter::create(); |
2261 |
|
filter->add_pattern("*.gig"); |
2262 |
|
#endif |
2263 |
|
dialog.set_filter(filter); |
2264 |
|
if (current_gig_dir != "") { |
2265 |
|
dialog.set_current_folder(current_gig_dir); |
2266 |
|
} |
2267 |
|
dialog.set_select_multiple(true); |
2268 |
|
|
2269 |
|
// show warning in the file picker dialog |
2270 |
|
Gtk::HBox descriptionArea; |
2271 |
|
descriptionArea.set_spacing(15); |
2272 |
|
Gtk::Image warningIcon(Gtk::Stock::DIALOG_WARNING, Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); |
2273 |
|
descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); |
2274 |
|
#if GTKMM_MAJOR_VERSION < 3 |
2275 |
|
view::WrapLabel description; |
2276 |
|
#else |
2277 |
|
Gtk::Label description; |
2278 |
|
description.set_line_wrap(); |
2279 |
|
#endif |
2280 |
|
description.set_markup(_( |
2281 |
|
"\nSelect at least one .gig file that shall be merged to the .gig file " |
2282 |
|
"currently being open in gigedit.\n\n" |
2283 |
|
"<b>Please Note:</b> Merging with other files will modify your " |
2284 |
|
"currently open .gig file on file level! And be aware that the current " |
2285 |
|
"merge algorithm does not detect duplicate samples yet. So if you are " |
2286 |
|
"merging files which are using equivalent sample data, those " |
2287 |
|
"equivalent samples will currently be treated as separate samples and " |
2288 |
|
"will accordingly be stored separately in the target .gig file!" |
2289 |
|
)); |
2290 |
|
descriptionArea.pack_start(description); |
2291 |
|
dialog.get_vbox()->pack_start(descriptionArea, Gtk::PACK_SHRINK); |
2292 |
|
descriptionArea.show_all(); |
2293 |
|
|
2294 |
|
if (dialog.run() == Gtk::RESPONSE_OK) { |
2295 |
|
printf("on_action_merge_files self=%x\n", Glib::Threads::Thread::self()); |
2296 |
|
std::vector<std::string> filenames = dialog.get_filenames(); |
2297 |
|
|
2298 |
|
// merge the selected files to the currently open .gig file |
2299 |
|
try { |
2300 |
|
mergeFiles(filenames); |
2301 |
|
} catch (RIFF::Exception e) { |
2302 |
|
Gtk::MessageDialog msg(*this, e.Message, false, Gtk::MESSAGE_ERROR); |
2303 |
|
msg.run(); |
2304 |
|
} |
2305 |
|
|
2306 |
|
// update GUI |
2307 |
|
__refreshEntireGUI(); |
2308 |
|
} |
2309 |
|
} |
2310 |
|
|
2311 |
|
void MainWindow::set_file_is_shared(bool b) { |
2312 |
|
this->file_is_shared = b; |
2313 |
|
|
2314 |
|
if (file_is_shared) { |
2315 |
|
m_AttachedStateLabel.set_label(_("live-mode")); |
2316 |
|
m_AttachedStateImage.set( |
2317 |
|
Gdk::Pixbuf::create_from_xpm_data(status_attached_xpm) |
2318 |
|
); |
2319 |
|
} else { |
2320 |
|
m_AttachedStateLabel.set_label(_("stand-alone")); |
2321 |
|
m_AttachedStateImage.set( |
2322 |
|
Gdk::Pixbuf::create_from_xpm_data(status_detached_xpm) |
2323 |
|
); |
2324 |
|
} |
2325 |
|
} |
2326 |
|
|
2327 |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
2328 |
return file_structure_to_be_changed_signal; |
return file_structure_to_be_changed_signal; |
2329 |
} |
} |
2348 |
return region_changed_signal; |
return region_changed_signal; |
2349 |
} |
} |
2350 |
|
|
2351 |
|
sigc::signal<void, gig::Sample*>& MainWindow::signal_sample_changed() { |
2352 |
|
return sample_changed_signal; |
2353 |
|
} |
2354 |
|
|
2355 |
sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& MainWindow::signal_sample_ref_changed() { |
sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& MainWindow::signal_sample_ref_changed() { |
2356 |
return sample_ref_changed_signal; |
return sample_ref_changed_signal; |
2357 |
} |
} |
2363 |
sigc::signal<void, gig::DimensionRegion*>& MainWindow::signal_dimreg_changed() { |
sigc::signal<void, gig::DimensionRegion*>& MainWindow::signal_dimreg_changed() { |
2364 |
return dimreg_changed_signal; |
return dimreg_changed_signal; |
2365 |
} |
} |
2366 |
|
|
2367 |
|
sigc::signal<void, int/*key*/, int/*velocity*/>& MainWindow::signal_note_on() { |
2368 |
|
return note_on_signal; |
2369 |
|
} |
2370 |
|
|
2371 |
|
sigc::signal<void, int/*key*/, int/*velocity*/>& MainWindow::signal_note_off() { |
2372 |
|
return note_off_signal; |
2373 |
|
} |
2374 |
|
|
2375 |
|
sigc::signal<void, int/*key*/, int/*velocity*/>& MainWindow::signal_keyboard_key_hit() { |
2376 |
|
return m_RegionChooser.signal_keyboard_key_hit(); |
2377 |
|
} |
2378 |
|
|
2379 |
|
sigc::signal<void, int/*key*/, int/*velocity*/>& MainWindow::signal_keyboard_key_released() { |
2380 |
|
return m_RegionChooser.signal_keyboard_key_released(); |
2381 |
|
} |