/[svn]/gigedit/trunk/src/gigedit/mainwindow.cpp
ViewVC logotype

Diff of /gigedit/trunk/src/gigedit/mainwindow.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3174 by schoenebeck, Wed May 10 23:10:37 2017 UTC revision 3619 by schoenebeck, Tue Oct 1 16:21:28 2019 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (C) 2006-2017 Andreas Persson   * Copyright (C) 2006-2019 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
# Line 20  Line 20 
20  #include <iostream>  #include <iostream>
21  #include <cstring>  #include <cstring>
22    
23  #include <glibmmconfig.h>  #include "compat.h"
 // threads.h must be included first to be able to build with  
 // G_DISABLE_DEPRECATED  
 #if (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION == 31 && GLIBMM_MICRO_VERSION >= 2) || \  
     (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION > 31) || GLIBMM_MAJOR_VERSION > 2  
 #include <glibmm/threads.h>  
 #endif  
24    
25  #include <glibmm/convert.h>  #include <glibmm/convert.h>
26  #include <glibmm/dispatcher.h>  #include <glibmm/dispatcher.h>
27  #include <glibmm/miscutils.h>  #include <glibmm/miscutils.h>
28  #include <glibmm/stringutils.h>  #include <glibmm/stringutils.h>
29    #include <glibmm/regex.h>
30  #include <gtkmm/aboutdialog.h>  #include <gtkmm/aboutdialog.h>
31  #include <gtkmm/filechooserdialog.h>  #include <gtkmm/filechooserdialog.h>
32  #include <gtkmm/messagedialog.h>  #include <gtkmm/messagedialog.h>
33  #include <gtkmm/stock.h>  #if HAS_GTKMM_STOCK
34    # include <gtkmm/stock.h>
35    #endif
36  #include <gtkmm/targetentry.h>  #include <gtkmm/targetentry.h>
37  #include <gtkmm/main.h>  #include <gtkmm/main.h>
38  #include <gtkmm/toggleaction.h>  #if GTKMM_MAJOR_VERSION < 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION < 89)
39    # include <gtkmm/toggleaction.h>
40    #endif
41  #include <gtkmm/accelmap.h>  #include <gtkmm/accelmap.h>
42  #if GTKMM_MAJOR_VERSION < 3  #if GTKMM_MAJOR_VERSION < 3
43  #include "wrapLabel.hh"  #include "wrapLabel.hh"
# Line 48  Line 47 
47  #include "compat.h"  #include "compat.h"
48    
49  #include <stdio.h>  #include <stdio.h>
50  #include <sndfile.h>  #ifdef LIBSNDFILE_HEADER_FILE
51    # include LIBSNDFILE_HEADER_FILE(sndfile.h)
52    #else
53    # include <sndfile.h>
54    #endif
55  #include <assert.h>  #include <assert.h>
56    
57  #include "mainwindow.h"  #include "mainwindow.h"
# Line 62  Line 65 
65  #include "gfx/builtinpix.h"  #include "gfx/builtinpix.h"
66  #include "MacroEditor.h"  #include "MacroEditor.h"
67  #include "MacrosSetup.h"  #include "MacrosSetup.h"
68    #if defined(__APPLE__)
69    # include "MacHelper.h"
70    #endif
71    
72    static const Gdk::ModifierType primaryModifierKey =
73        #if defined(__APPLE__)
74        Gdk::META_MASK; // Cmd key on Mac
75        #else
76        Gdk::CONTROL_MASK; // Ctrl key on all other OSs
77        #endif
78    
79  MainWindow::MainWindow() :  MainWindow::MainWindow() :
80      m_DimRegionChooser(*this),      m_DimRegionChooser(*this),
# Line 77  MainWindow::MainWindow() : Line 90  MainWindow::MainWindow() :
90  {  {
91      loadBuiltInPix();      loadBuiltInPix();
92    
93        this->file = NULL;
94    
95  //    set_border_width(5);  //    set_border_width(5);
96  //    set_default_size(400, 200);  
97        if (!Settings::singleton()->autoRestoreWindowDimension) {
98    #if GTKMM_MAJOR_VERSION >= 3
99            set_default_size(960, 600);
100    #else
101            set_default_size(865, 600);
102    #endif
103            set_position(Gtk::WIN_POS_CENTER);
104        }
105    
106      add(m_VBox);      add(m_VBox);
107    
# Line 88  MainWindow::MainWindow() : Line 111  MainWindow::MainWindow() :
111    
112      // m_TreeView.set_reorderable();      // m_TreeView.set_reorderable();
113    
114    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2
115        m_TreeView.signal_button_press_event().connect(
116            sigc::mem_fun(*this, &MainWindow::on_button_release));
117    #else
118      m_TreeView.signal_button_press_event().connect_notify(      m_TreeView.signal_button_press_event().connect_notify(
119          sigc::mem_fun(*this, &MainWindow::on_button_release));          sigc::mem_fun(*this, &MainWindow::on_button_release));
120    #endif
121    
122      // Add the TreeView tab, inside a ScrolledWindow, with the button underneath:      // Add the TreeView tab, inside a ScrolledWindow, with the button underneath:
123      m_ScrolledWindow.add(m_TreeView);      m_ScrolledWindow.add(m_TreeView);
# Line 102  MainWindow::MainWindow() : Line 130  MainWindow::MainWindow() :
130      m_ScrolledWindowScripts.add(m_TreeViewScripts);      m_ScrolledWindowScripts.add(m_TreeViewScripts);
131      m_ScrolledWindowScripts.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);      m_ScrolledWindowScripts.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
132    
133    #if GTKMM_MAJOR_VERSION < 3
134      m_TreeViewNotebook.set_size_request(300);      m_TreeViewNotebook.set_size_request(300);
135    #endif
136    
137        m_searchLabel.set_text(Glib::ustring(" ") + _("Filter:"));
138        m_searchField.pack_start(m_searchLabel, Gtk::PACK_SHRINK);
139        m_searchField.pack_start(m_searchText);
140        m_searchField.set_spacing(5);
141    
142        m_left_vbox.pack_start(m_TreeViewNotebook);
143        m_left_vbox.pack_start(m_searchField, Gtk::PACK_SHRINK);
144    
145        m_HPaned.add1(m_left_vbox);
146    
     m_HPaned.add1(m_TreeViewNotebook);  
147      dimreg_hbox.add(dimreg_label);      dimreg_hbox.add(dimreg_label);
148      dimreg_hbox.add(dimreg_all_regions);      dimreg_hbox.add(dimreg_all_regions);
149      dimreg_hbox.add(dimreg_all_dimregs);      dimreg_hbox.add(dimreg_all_dimregs);
# Line 117  MainWindow::MainWindow() : Line 155  MainWindow::MainWindow() :
155          legend_hbox.add(labelLegend);          legend_hbox.add(labelLegend);
156    
157          imageNoSample.set(redDot);          imageNoSample.set(redDot);
158    #if HAS_GTKMM_ALIGNMENT
159          imageNoSample.set_alignment(Gtk::ALIGN_END);          imageNoSample.set_alignment(Gtk::ALIGN_END);
160          labelNoSample.set_alignment(Gtk::ALIGN_START);          labelNoSample.set_alignment(Gtk::ALIGN_START);
161    #else
162            imageNoSample.set_halign(Gtk::ALIGN_END);
163            labelNoSample.set_halign(Gtk::ALIGN_START);
164    #endif
165          legend_hbox.add(imageNoSample);          legend_hbox.add(imageNoSample);
166          legend_hbox.add(labelNoSample);          legend_hbox.add(labelNoSample);
167    
168          imageMissingSample.set(yellowDot);          imageMissingSample.set(yellowDot);
169    #if HAS_GTKMM_ALIGNMENT
170          imageMissingSample.set_alignment(Gtk::ALIGN_END);          imageMissingSample.set_alignment(Gtk::ALIGN_END);
171          labelMissingSample.set_alignment(Gtk::ALIGN_START);          labelMissingSample.set_alignment(Gtk::ALIGN_START);
172    #else
173            imageMissingSample.set_halign(Gtk::ALIGN_END);
174            labelMissingSample.set_halign(Gtk::ALIGN_START);
175    #endif
176          legend_hbox.add(imageMissingSample);          legend_hbox.add(imageMissingSample);
177          legend_hbox.add(labelMissingSample);          legend_hbox.add(labelMissingSample);
178    
179          imageLooped.set(blackLoop);          imageLooped.set(blackLoop);
180    #if HAS_GTKMM_ALIGNMENT
181          imageLooped.set_alignment(Gtk::ALIGN_END);          imageLooped.set_alignment(Gtk::ALIGN_END);
182          labelLooped.set_alignment(Gtk::ALIGN_START);          labelLooped.set_alignment(Gtk::ALIGN_START);
183    #else
184            imageLooped.set_halign(Gtk::ALIGN_END);
185            labelLooped.set_halign(Gtk::ALIGN_START);
186    #endif
187          legend_hbox.add(imageLooped);          legend_hbox.add(imageLooped);
188          legend_hbox.add(labelLooped);          legend_hbox.add(labelLooped);
189    
190          imageSomeLoops.set(grayLoop);          imageSomeLoops.set(grayLoop);
191    #if HAS_GTKMM_ALIGNMENT
192          imageSomeLoops.set_alignment(Gtk::ALIGN_END);          imageSomeLoops.set_alignment(Gtk::ALIGN_END);
193          labelSomeLoops.set_alignment(Gtk::ALIGN_START);          labelSomeLoops.set_alignment(Gtk::ALIGN_START);
194    #else
195            imageSomeLoops.set_halign(Gtk::ALIGN_END);
196            labelSomeLoops.set_halign(Gtk::ALIGN_START);
197    #endif
198          legend_hbox.add(imageSomeLoops);          legend_hbox.add(imageSomeLoops);
199          legend_hbox.add(labelSomeLoops);          legend_hbox.add(labelSomeLoops);
200    
201    #if HAS_GTKMM_SHOW_ALL_CHILDREN
202          legend_hbox.show_all_children();          legend_hbox.show_all_children();
203    #endif
204      }      }
205      dimreg_vbox.pack_start(legend_hbox, Gtk::PACK_SHRINK);      dimreg_vbox.pack_start(legend_hbox, Gtk::PACK_SHRINK);
206      m_HPaned.add2(dimreg_vbox);      m_HPaned.add2(dimreg_vbox);
# Line 154  MainWindow::MainWindow() : Line 214  MainWindow::MainWindow() :
214      m_TreeViewNotebook.append_page(m_ScrolledWindow, _("Instruments"));      m_TreeViewNotebook.append_page(m_ScrolledWindow, _("Instruments"));
215      m_TreeViewNotebook.append_page(m_ScrolledWindowScripts, _("Scripts"));      m_TreeViewNotebook.append_page(m_ScrolledWindowScripts, _("Scripts"));
216    
217    #if USE_GLIB_ACTION
218        m_actionGroup = Gio::SimpleActionGroup::create();
219        m_actionGroup->add_action(
220            "New", sigc::mem_fun(*this, &MainWindow::on_action_file_new)
221        );
222        m_actionGroup->add_action(
223            "Open", sigc::mem_fun(*this, &MainWindow::on_action_file_open)
224        );
225        m_actionGroup->add_action(
226            "Save", sigc::mem_fun(*this, &MainWindow::on_action_file_save)
227        );
228        m_actionGroup->add_action(
229            "SaveAs", sigc::mem_fun(*this, &MainWindow::on_action_file_save_as)
230        );
231        m_actionGroup->add_action(
232            "Properties", sigc::mem_fun(*this, &MainWindow::on_action_file_properties)
233        );
234        m_actionGroup->add_action(
235            "InstrProperties", sigc::mem_fun(*this, &MainWindow::show_instr_props)
236        );
237        m_actionMIDIRules = m_actionGroup->add_action(
238            "MidiRules", sigc::mem_fun(*this, &MainWindow::show_midi_rules)
239        );
240        m_actionGroup->add_action(
241            "ScriptSlots", sigc::mem_fun(*this, &MainWindow::show_script_slots)
242        );
243        m_actionGroup->add_action(
244            "Quit", sigc::mem_fun(*this, &MainWindow::on_action_quit)
245        );
246        m_actionGroup->add_action(
247            "MenuSample", sigc::mem_fun(*this, &MainWindow::show_samples_tab)
248        );
249        m_actionGroup->add_action(
250            "MenuInstrument", sigc::mem_fun(*this, &MainWindow::show_intruments_tab)
251        );
252        m_actionGroup->add_action(
253            "MenuScript", sigc::mem_fun(*this, &MainWindow::show_scripts_tab)
254        );
255    #else
256      actionGroup = Gtk::ActionGroup::create();      actionGroup = Gtk::ActionGroup::create();
257    
258      actionGroup->add(Gtk::Action::create("MenuFile", _("_File")));      actionGroup->add(Gtk::Action::create("MenuFile", _("_File")));
# Line 207  MainWindow::MainWindow() : Line 306  MainWindow::MainWindow() :
306          sigc::mem_fun(*this, &MainWindow::show_scripts_tab)          sigc::mem_fun(*this, &MainWindow::show_scripts_tab)
307      );      );
308      actionGroup->add(Gtk::Action::create("AllInstruments", _("_Select")));      actionGroup->add(Gtk::Action::create("AllInstruments", _("_Select")));
309        actionGroup->add(Gtk::Action::create("AssignScripts", _("Assign Script")));
310    
311      actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit")));      actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit")));
312    #endif
313    
314      const Gdk::ModifierType primaryModifierKey =      const Gdk::ModifierType primaryModifierKey =
315  #if defined(__APPLE__)  #if defined(__APPLE__)
# Line 217  MainWindow::MainWindow() : Line 318  MainWindow::MainWindow() :
318      Gdk::CONTROL_MASK; // Ctrl key on all other OSs      Gdk::CONTROL_MASK; // Ctrl key on all other OSs
319  #endif  #endif
320    
321    #if USE_GLIB_ACTION
322        m_actionCopyDimRgn = m_actionGroup->add_action(
323            "CopyDimRgn", sigc::mem_fun(*this, &MainWindow::copy_selected_dimrgn)
324        );
325        m_actionPasteDimRgn = m_actionGroup->add_action(
326            "PasteDimRgn", sigc::mem_fun(*this, &MainWindow::paste_copied_dimrgn)
327        );
328        m_actionAdjustClipboard = m_actionGroup->add_action(
329            "AdjustClipboard", sigc::mem_fun(*this, &MainWindow::adjust_clipboard_content)
330        );
331        m_actionGroup->add_action(
332            "SelectPrevInstr", sigc::mem_fun(*this, &MainWindow::select_prev_instrument)
333        );
334        m_actionGroup->add_action(
335            "SelectNextInstr", sigc::mem_fun(*this, &MainWindow::select_next_instrument)
336        );
337        m_actionGroup->add_action(
338            "SelectPrevRegion", sigc::mem_fun(*this, &MainWindow::select_prev_region)
339        );
340        m_actionGroup->add_action(
341            "SelectNextRegion", sigc::mem_fun(*this, &MainWindow::select_next_region)
342        );
343        m_actionGroup->add_action(
344            "SelectPrevDimRgnZone", sigc::mem_fun(*this, &MainWindow::select_prev_dim_rgn_zone)
345        );
346        m_actionGroup->add_action(
347            "SelectNextDimRgnZone", sigc::mem_fun(*this, &MainWindow::select_next_dim_rgn_zone)
348        );
349        m_actionGroup->add_action(
350            "SelectPrevDimension", sigc::mem_fun(*this, &MainWindow::select_prev_dimension)
351        );
352        m_actionGroup->add_action(
353            "SelectNextDimension", sigc::mem_fun(*this, &MainWindow::select_next_dimension)
354        );
355        m_actionGroup->add_action(
356            "SelectAddPrevDimRgnZone", sigc::mem_fun(*this, &MainWindow::select_add_prev_dim_rgn_zone)
357        );
358        m_actionGroup->add_action(
359            "SelectAddNextDimRgnZone", sigc::mem_fun(*this, &MainWindow::select_add_next_dim_rgn_zone)
360        );
361    #else
362      actionGroup->add(Gtk::Action::create("CopyDimRgn",      actionGroup->add(Gtk::Action::create("CopyDimRgn",
363                                           _("Copy selected dimension region")),                                           _("Copy selected dimension region")),
364                       Gtk::AccelKey(GDK_KEY_c, Gdk::MOD1_MASK),                       Gtk::AccelKey(GDK_KEY_c, Gdk::MOD1_MASK),
# Line 232  MainWindow::MainWindow() : Line 374  MainWindow::MainWindow() :
374                       Gtk::AccelKey(GDK_KEY_x, Gdk::MOD1_MASK),                       Gtk::AccelKey(GDK_KEY_x, Gdk::MOD1_MASK),
375                       sigc::mem_fun(*this, &MainWindow::adjust_clipboard_content));                       sigc::mem_fun(*this, &MainWindow::adjust_clipboard_content));
376    
377        actionGroup->add(Gtk::Action::create("SelectPrevInstr",
378                                             _("Select Previous Instrument")),
379                         Gtk::AccelKey(GDK_KEY_Up, primaryModifierKey),
380                         sigc::mem_fun(*this, &MainWindow::select_prev_instrument));
381    
382        actionGroup->add(Gtk::Action::create("SelectNextInstr",
383                                             _("Select Next Instrument")),
384                         Gtk::AccelKey(GDK_KEY_Down, primaryModifierKey),
385                         sigc::mem_fun(*this, &MainWindow::select_next_instrument));
386    
387      actionGroup->add(Gtk::Action::create("SelectPrevRegion",      actionGroup->add(Gtk::Action::create("SelectPrevRegion",
388                                           _("Select Previous Region")),                                           _("Select Previous Region")),
389                       Gtk::AccelKey(GDK_KEY_Left, primaryModifierKey),                       Gtk::AccelKey(GDK_KEY_Left, primaryModifierKey),
# Line 271  MainWindow::MainWindow() : Line 423  MainWindow::MainWindow() :
423                                           _("Add Next Dimension Region Zone to Selection")),                                           _("Add Next Dimension Region Zone to Selection")),
424                       Gtk::AccelKey(GDK_KEY_Right, Gdk::MOD1_MASK | Gdk::SHIFT_MASK),                       Gtk::AccelKey(GDK_KEY_Right, Gdk::MOD1_MASK | Gdk::SHIFT_MASK),
425                       sigc::mem_fun(*this, &MainWindow::select_add_next_dim_rgn_zone));                       sigc::mem_fun(*this, &MainWindow::select_add_next_dim_rgn_zone));
426    #endif
427    
428    #if USE_GLIB_ACTION
429        m_actionToggleCopySampleUnity = m_actionGroup->add_action_bool("CopySampleUnity", true);
430        m_actionToggleCopySampleTune  = m_actionGroup->add_action_bool("CopySampleTune", true);
431        m_actionToggleCopySampleLoop  = m_actionGroup->add_action_bool("CopySampleLoop", true);
432    #else
433      Glib::RefPtr<Gtk::ToggleAction> toggle_action =      Glib::RefPtr<Gtk::ToggleAction> toggle_action =
434          Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note"));          Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note"));
435      toggle_action->set_active(true);      toggle_action->set_active(true);
# Line 286  MainWindow::MainWindow() : Line 444  MainWindow::MainWindow() :
444          Gtk::ToggleAction::create("CopySampleLoop", _("Copy Sample's _Loop Points"));          Gtk::ToggleAction::create("CopySampleLoop", _("Copy Sample's _Loop Points"));
445      toggle_action->set_active(true);      toggle_action->set_active(true);
446      actionGroup->add(toggle_action);      actionGroup->add(toggle_action);
447    #endif
448    
449    #if USE_GLIB_ACTION
450        m_actionToggleStatusBar =
451            m_actionGroup->add_action_bool("Statusbar", sigc::mem_fun(*this, &MainWindow::on_action_view_status_bar), true);
452        m_actionToggleRestoreWinDim =
453            m_actionGroup->add_action_bool("AutoRestoreWinDim", sigc::mem_fun(*this, &MainWindow::on_auto_restore_win_dim), Settings::singleton()->autoRestoreWindowDimension);
454        m_actionToggleShowTooltips = m_actionGroup->add_action_bool(
455            "ShowTooltips", sigc::mem_fun(*this, &MainWindow::on_action_show_tooltips),
456            Settings::singleton()->showTooltips
457        );
458        m_actionToggleSaveWithTempFile =
459            m_actionGroup->add_action_bool("SaveWithTemporaryFile", sigc::mem_fun(*this, &MainWindow::on_save_with_temporary_file), Settings::singleton()->saveWithTemporaryFile);
460        m_actionGroup->add_action("RefreshAll", sigc::mem_fun(*this, &MainWindow::on_action_refresh_all));
461    #else
462      actionGroup->add(Gtk::Action::create("MenuMacro", _("_Macro")));      actionGroup->add(Gtk::Action::create("MenuMacro", _("_Macro")));
463    
464    
# Line 307  MainWindow::MainWindow() : Line 478  MainWindow::MainWindow() :
478                           *this, &MainWindow::on_auto_restore_win_dim));                           *this, &MainWindow::on_auto_restore_win_dim));
479    
480      toggle_action =      toggle_action =
481            Gtk::ToggleAction::create("ShowTooltips", _("Tooltips for Beginners"));
482        toggle_action->set_active(Settings::singleton()->showTooltips);
483        actionGroup->add(
484            toggle_action,
485            sigc::mem_fun(*this, &MainWindow::on_action_show_tooltips)
486        );
487    
488        toggle_action =
489          Gtk::ToggleAction::create("SaveWithTemporaryFile", _("Save with _temporary file"));          Gtk::ToggleAction::create("SaveWithTemporaryFile", _("Save with _temporary file"));
490      toggle_action->set_active(Settings::singleton()->saveWithTemporaryFile);      toggle_action->set_active(Settings::singleton()->saveWithTemporaryFile);
491      actionGroup->add(toggle_action,      actionGroup->add(toggle_action,
# Line 317  MainWindow::MainWindow() : Line 496  MainWindow::MainWindow() :
496          Gtk::Action::create("RefreshAll", _("_Refresh All")),          Gtk::Action::create("RefreshAll", _("_Refresh All")),
497          sigc::mem_fun(*this, &MainWindow::on_action_refresh_all)          sigc::mem_fun(*this, &MainWindow::on_action_refresh_all)
498      );                      );                
499    #endif
500    
501    #if USE_GLIB_ACTION
502        m_actionGroup->add_action(
503            "About", sigc::mem_fun(*this, &MainWindow::on_action_help_about)
504        );
505        m_actionGroup->add_action(
506            "AddInstrument", sigc::mem_fun(*this, &MainWindow::on_action_add_instrument)
507        );
508        m_actionGroup->add_action(
509            "DupInstrument", sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument)
510        );
511        m_actionGroup->add_action(
512            "CombInstruments", sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments)
513        );
514        m_actionGroup->add_action(
515            "RemoveInstrument", sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument)
516        );
517    #else
518      action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP);      action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP);
519      actionGroup->add(Gtk::Action::create("MenuHelp",      actionGroup->add(Gtk::Action::create("MenuHelp",
520                                           action->property_label()));                                           action->property_label()));
# Line 333  MainWindow::MainWindow() : Line 530  MainWindow::MainWindow() :
530          sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument)          sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument)
531      );      );
532      actionGroup->add(      actionGroup->add(
533            Gtk::Action::create("CombInstruments", _("_Combine Instruments ...")),
534            Gtk::AccelKey(GDK_KEY_j, primaryModifierKey),
535            sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments)
536        );
537        actionGroup->add(
538          Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE),          Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE),
539          sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument)          sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument)
540      );      );
541    #endif
542    
543    #if USE_GLIB_ACTION
544        m_actionToggleWarnOnExtensions = m_actionGroup->add_action_bool(
545            "WarnUserOnExtensions", sigc::mem_fun(*this, &MainWindow::on_action_warn_user_on_extensions),
546            Settings::singleton()->warnUserOnExtensions
547        );
548        m_actionToggleSyncSamplerSelection = m_actionGroup->add_action_bool(
549            "SyncSamplerInstrumentSelection", sigc::mem_fun(*this, &MainWindow::on_action_sync_sampler_instrument_selection),
550            Settings::singleton()->syncSamplerInstrumentSelection
551        );
552        m_actionToggleMoveRootNoteWithRegion = m_actionGroup->add_action_bool(
553            "MoveRootNoteWithRegionMoved", sigc::mem_fun(*this, &MainWindow::on_action_move_root_note_with_region_moved),
554            Settings::singleton()->moveRootNoteWithRegionMoved
555        );
556    #else
557      actionGroup->add(Gtk::Action::create("MenuSettings", _("_Settings")));      actionGroup->add(Gtk::Action::create("MenuSettings", _("_Settings")));
558            
559      toggle_action =      toggle_action =
# Line 363  MainWindow::MainWindow() : Line 579  MainWindow::MainWindow() :
579          toggle_action,          toggle_action,
580          sigc::mem_fun(*this, &MainWindow::on_action_move_root_note_with_region_moved)          sigc::mem_fun(*this, &MainWindow::on_action_move_root_note_with_region_moved)
581      );      );
582    #endif
583    
584    #if USE_GLIB_ACTION
585        m_actionGroup->add_action(
586            "CombineInstruments", sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments)
587        );
588        m_actionGroup->add_action(
589            "MergeFiles", sigc::mem_fun(*this, &MainWindow::on_action_merge_files)
590        );
591    #else
592      actionGroup->add(Gtk::Action::create("MenuTools", _("_Tools")));      actionGroup->add(Gtk::Action::create("MenuTools", _("_Tools")));
593    
594      actionGroup->add(      actionGroup->add(
# Line 376  MainWindow::MainWindow() : Line 600  MainWindow::MainWindow() :
600          Gtk::Action::create("MergeFiles", _("_Merge Files...")),          Gtk::Action::create("MergeFiles", _("_Merge Files...")),
601          sigc::mem_fun(*this, &MainWindow::on_action_merge_files)          sigc::mem_fun(*this, &MainWindow::on_action_merge_files)
602      );      );
603    #endif
604    
605      // sample right-click popup actions      // sample right-click popup actions
606    #if USE_GLIB_ACTION
607        m_actionSampleProperties = m_actionGroup->add_action(
608            "SampleProperties", sigc::mem_fun(*this, &MainWindow::on_action_sample_properties)
609        );
610        m_actionAddSampleGroup = m_actionGroup->add_action(
611            "AddGroup", sigc::mem_fun(*this, &MainWindow::on_action_add_group)
612        );
613        m_actionAddSample = m_actionGroup->add_action(
614            "AddSample", sigc::mem_fun(*this, &MainWindow::on_action_add_sample)
615        );
616        m_actionRemoveSample = m_actionGroup->add_action(
617            "RemoveSample", sigc::mem_fun(*this, &MainWindow::on_action_remove_sample)
618        );
619        m_actionGroup->add_action(
620            "RemoveUnusedSamples", sigc::mem_fun(*this, &MainWindow::on_action_remove_unused_samples)
621        );
622        m_actionViewSampleRefs = m_actionGroup->add_action(
623            "ShowSampleRefs", sigc::mem_fun(*this, &MainWindow::on_action_view_references)
624        );
625        m_actionReplaceSample = m_actionGroup->add_action(
626            "ReplaceSample", sigc::mem_fun(*this, &MainWindow::on_action_replace_sample)
627        );
628        m_actionGroup->add_action(
629            "ReplaceAllSamplesInAllGroups", sigc::mem_fun(*this, &MainWindow::on_action_replace_all_samples_in_all_groups)
630        );
631    #else
632      actionGroup->add(      actionGroup->add(
633          Gtk::Action::create("SampleProperties", Gtk::Stock::PROPERTIES),          Gtk::Action::create("SampleProperties", Gtk::Stock::PROPERTIES),
634          sigc::mem_fun(*this, &MainWindow::on_action_sample_properties)          sigc::mem_fun(*this, &MainWindow::on_action_sample_properties)
# Line 413  MainWindow::MainWindow() : Line 663  MainWindow::MainWindow() :
663                              _("Replace All Samples in All Groups...")),                              _("Replace All Samples in All Groups...")),
664          sigc::mem_fun(*this, &MainWindow::on_action_replace_all_samples_in_all_groups)          sigc::mem_fun(*this, &MainWindow::on_action_replace_all_samples_in_all_groups)
665      );      );
666    #endif
667            
668      // script right-click popup actions      // script right-click popup actions
669    #if USE_GLIB_ACTION
670        m_actionAddScriptGroup = m_actionGroup->add_action(
671            "AddScriptGroup", sigc::mem_fun(*this, &MainWindow::on_action_add_script_group)
672        );
673        m_actionAddScript = m_actionGroup->add_action(
674            "AddScript", sigc::mem_fun(*this, &MainWindow::on_action_add_script)
675        );
676        m_actionEditScript = m_actionGroup->add_action(
677            "EditScript", sigc::mem_fun(*this, &MainWindow::on_action_edit_script)
678        );
679        m_actionRemoveScript = m_actionGroup->add_action(
680            "RemoveScript", sigc::mem_fun(*this, &MainWindow::on_action_remove_script)
681        );
682    #else
683      actionGroup->add(      actionGroup->add(
684          Gtk::Action::create("AddScriptGroup", _("Add _Group")),          Gtk::Action::create("AddScriptGroup", _("Add _Group")),
685          sigc::mem_fun(*this, &MainWindow::on_action_add_script_group)          sigc::mem_fun(*this, &MainWindow::on_action_add_script_group)
# Line 431  MainWindow::MainWindow() : Line 696  MainWindow::MainWindow() :
696          Gtk::Action::create("RemoveScript", Gtk::Stock::REMOVE),          Gtk::Action::create("RemoveScript", Gtk::Stock::REMOVE),
697          sigc::mem_fun(*this, &MainWindow::on_action_remove_script)          sigc::mem_fun(*this, &MainWindow::on_action_remove_script)
698      );      );
699    #endif
700    
701    #if USE_GTKMM_BUILDER
702        insert_action_group("AppMenu", m_actionGroup);
703        
704        m_uiManager = Gtk::Builder::create();
705        Glib::ustring ui_info =
706            "<interface>"
707            "  <menubar id='MenuBar'>"
708            "    <menu id='MenuFile'>"
709            "      <attribute name='label' translatable='yes'>_File</attribute>"
710            "      <section>"
711            "        <item id='New'>"
712            "          <attribute name='label' translatable='yes'>New</attribute>"
713            "          <attribute name='action'>AppMenu.New</attribute>"
714            "        </item>"
715            "        <item id='Open'>"
716            "          <attribute name='label' translatable='yes'>Open</attribute>"
717            "          <attribute name='action'>AppMenu.Open</attribute>"
718            "        </item>"
719            "      </section>"
720            "      <section>"
721            "        <item id='Save'>"
722            "          <attribute name='label' translatable='yes'>Save</attribute>"
723            "          <attribute name='action'>AppMenu.Save</attribute>"
724            "        </item>"
725            "        <item id='SaveAs'>"
726            "          <attribute name='label' translatable='yes'>Save As</attribute>"
727            "          <attribute name='action'>AppMenu.SaveAs</attribute>"
728            "        </item>"
729            "      </section>"
730            "      <section>"
731            "        <item id='Properties'>"
732            "          <attribute name='label' translatable='yes'>Properties</attribute>"
733            "          <attribute name='action'>AppMenu.Properties</attribute>"
734            "        </item>"
735            "      </section>"
736            "      <section>"
737            "        <item id='Quit'>"
738            "          <attribute name='label' translatable='yes'>Quit</attribute>"
739            "          <attribute name='action'>AppMenu.Quit</attribute>"
740            "        </item>"
741            "      </section>"
742            "    </menu>"
743            "    <menu id='MenuEdit'>"
744            "      <attribute name='label' translatable='yes'>Edit</attribute>"
745            "      <section>"
746            "        <item id='CopyDimRgn'>"
747            "          <attribute name='label' translatable='yes'>Copy Dimension Region</attribute>"
748            "          <attribute name='action'>AppMenu.CopyDimRgn</attribute>"
749            "        </item>"
750            "        <item id='AdjustClipboard'>"
751            "          <attribute name='label' translatable='yes'>Adjust Clipboard</attribute>"
752            "          <attribute name='action'>AppMenu.AdjustClipboard</attribute>"
753            "        </item>"
754            "        <item id='PasteDimRgn'>"
755            "          <attribute name='label' translatable='yes'>Paste Dimension Region</attribute>"
756            "          <attribute name='action'>AppMenu.PasteDimRgn</attribute>"
757            "        </item>"
758            "      </section>"
759            "        <item id='SelectPrevInstr'>"
760            "          <attribute name='label' translatable='yes'>Previous Instrument</attribute>"
761            "          <attribute name='action'>AppMenu.SelectPrevInstr</attribute>"
762            "        </item>"
763            "        <item id='SelectNextInstr'>"
764            "          <attribute name='label' translatable='yes'>Next Instrument</attribute>"
765            "          <attribute name='action'>AppMenu.SelectNextInstr</attribute>"
766            "        </item>"
767            "      <section>"
768            "        <item id='SelectPrevRegion'>"
769            "          <attribute name='label' translatable='yes'>Previous Region</attribute>"
770            "          <attribute name='action'>AppMenu.SelectPrevRegion</attribute>"
771            "        </item>"
772            "        <item id='SelectNextRegion'>"
773            "          <attribute name='label' translatable='yes'>Next Region</attribute>"
774            "          <attribute name='action'>AppMenu.SelectNextRegion</attribute>"
775            "        </item>"
776            "      </section>"
777            "        <item id='SelectPrevDimension'>"
778            "          <attribute name='label' translatable='yes'>Previous Dimension</attribute>"
779            "          <attribute name='action'>AppMenu.SelectPrevDimension</attribute>"
780            "        </item>"
781            "        <item id='SelectNextDimension'>"
782            "          <attribute name='label' translatable='yes'>Next Dimension</attribute>"
783            "          <attribute name='action'>AppMenu.SelectNextDimension</attribute>"
784            "        </item>"
785            "        <item id='SelectPrevDimRgnZone'>"
786            "          <attribute name='label' translatable='yes'>Previous Dimension Region Zone</attribute>"
787            "          <attribute name='action'>AppMenu.SelectPrevDimRgnZone</attribute>"
788            "        </item>"
789            "        <item id='SelectNextDimRgnZone'>"
790            "          <attribute name='label' translatable='yes'>Next Dimension Region Zone</attribute>"
791            "          <attribute name='action'>AppMenu.SelectNextDimRgnZone</attribute>"
792            "        </item>"
793            "        <item id='SelectAddPrevDimRgnZone'>"
794            "          <attribute name='label' translatable='yes'>Add Previous Dimension Region Zone</attribute>"
795            "          <attribute name='action'>AppMenu.SelectAddPrevDimRgnZone</attribute>"
796            "        </item>"
797            "        <item id='SelectAddNextDimRgnZone'>"
798            "          <attribute name='label' translatable='yes'>Add Next Dimension Region Zone</attribute>"
799            "          <attribute name='action'>AppMenu.SelectAddNextDimRgnZone</attribute>"
800            "        </item>"
801            "      <section>"
802            "        <item id='CopySampleUnity'>"
803            "          <attribute name='label' translatable='yes'>Copy Sample Unity</attribute>"
804            "          <attribute name='action'>AppMenu.CopySampleUnity</attribute>"
805            "        </item>"
806            "        <item id='CopySampleTune'>"
807            "          <attribute name='label' translatable='yes'>Copy Sample Tune</attribute>"
808            "          <attribute name='action'>AppMenu.CopySampleTune</attribute>"
809            "        </item>"
810            "        <item id='CopySampleLoop'>"
811            "          <attribute name='label' translatable='yes'>Copy Sample Loop</attribute>"
812            "          <attribute name='action'>AppMenu.CopySampleLoop</attribute>"
813            "        </item>"
814            "      </section>"
815            "    </menu>"
816            "    <menu id='MenuMacro'>"
817            "      <attribute name='label' translatable='yes'>Macro</attribute>"
818            "      <section>"
819            "      </section>"
820            "    </menu>"
821            "    <menu id='MenuSample'>"
822            "      <attribute name='label' translatable='yes'>Sample</attribute>"
823            "      <section>"
824            "        <item id='SampleProperties'>"
825            "          <attribute name='label' translatable='yes'>Properties</attribute>"
826            "          <attribute name='action'>AppMenu.SampleProperties</attribute>"
827            "        </item>"
828            "        <item id='AddGroup'>"
829            "          <attribute name='label' translatable='yes'>Add Group</attribute>"
830            "          <attribute name='action'>AppMenu.AddGroup</attribute>"
831            "        </item>"
832            "        <item id='AddSample'>"
833            "          <attribute name='label' translatable='yes'>Add Sample</attribute>"
834            "          <attribute name='action'>AppMenu.AddSample</attribute>"
835            "        </item>"
836            "        <item id='ShowSampleRefs'>"
837            "          <attribute name='label' translatable='yes'>Show Sample References</attribute>"
838            "          <attribute name='action'>AppMenu.ShowSampleRefs</attribute>"
839            "        </item>"
840            "        <item id='ReplaceSample'>"
841            "          <attribute name='label' translatable='yes'>Replace Sample</attribute>"
842            "          <attribute name='action'>AppMenu.ReplaceSample</attribute>"
843            "        </item>"
844            "        <item id='ReplaceAllSamplesInAllGroups'>"
845            "          <attribute name='label' translatable='yes'>Replace all Samples in all Groups</attribute>"
846            "          <attribute name='action'>AppMenu.ReplaceAllSamplesInAllGroups</attribute>"
847            "        </item>"
848            "      </section>"
849            "      <section>"
850            "        <item id='RemoveSample'>"
851            "          <attribute name='label' translatable='yes'>Remove Sample</attribute>"
852            "          <attribute name='action'>AppMenu.RemoveSample</attribute>"
853            "        </item>"
854            "        <item id='RemoveUnusedSamples'>"
855            "          <attribute name='label' translatable='yes'>Remove unused Samples</attribute>"
856            "          <attribute name='action'>AppMenu.RemoveUnusedSamples</attribute>"
857            "        </item>"
858            "      </section>"
859            "    </menu>"
860            "    <menu id='MenuInstrument'>"
861            "      <attribute name='label' translatable='yes'>Instrument</attribute>"
862            "      <section>"
863            "        <item id='InstrProperties'>"
864            "          <attribute name='label' translatable='yes'>Properties</attribute>"
865            "          <attribute name='action'>AppMenu.InstrProperties</attribute>"
866            "        </item>"
867            "        <item id='MidiRules'>"
868            "          <attribute name='label' translatable='yes'>MIDI Rules</attribute>"
869            "          <attribute name='action'>AppMenu.MidiRules</attribute>"
870            "        </item>"
871            "        <item id='ScriptSlots'>"
872            "          <attribute name='label' translatable='yes'>Script Slots</attribute>"
873            "          <attribute name='action'>AppMenu.ScriptSlots</attribute>"
874            "        </item>"
875            "      </section>"
876            "      <submenu id='AssignScripts'>"
877            "        <attribute name='label' translatable='yes'>Assign Scripts</attribute>"
878            "      </submenu>"
879            "      <section>"
880            "        <item id='AddInstrument'>"
881            "          <attribute name='label' translatable='yes'>Add Instrument</attribute>"
882            "          <attribute name='action'>AppMenu.AddInstrument</attribute>"
883            "        </item>"
884            "        <item id='DupInstrument'>"
885            "          <attribute name='label' translatable='yes'>Duplicate Instrument</attribute>"
886            "          <attribute name='action'>AppMenu.DupInstrument</attribute>"
887            "        </item>"
888            "        <item id='CombInstruments'>"
889            "          <attribute name='label' translatable='yes'>Combine Instrument</attribute>"
890            "          <attribute name='action'>AppMenu.CombInstruments</attribute>"
891            "        </item>"
892            "      </section>"
893            "      <section>"
894            "        <item id='RemoveInstrument'>"
895            "          <attribute name='label' translatable='yes'>Remove Instrument</attribute>"
896            "          <attribute name='action'>AppMenu.RemoveInstrument</attribute>"
897            "        </item>"
898            "      </section>"
899            "    </menu>"
900            "    <menu id='MenuScript'>"
901            "      <attribute name='label' translatable='yes'>Script</attribute>"
902            "      <section>"
903            "        <item id='AddScriptGroup'>"
904            "          <attribute name='label' translatable='yes'>Add Script Group</attribute>"
905            "          <attribute name='action'>AppMenu.AddScriptGroup</attribute>"
906            "        </item>"
907            "        <item id='AddScript'>"
908            "          <attribute name='label' translatable='yes'>Add Script</attribute>"
909            "          <attribute name='action'>AppMenu.AddScript</attribute>"
910            "        </item>"
911            "        <item id='EditScript'>"
912            "          <attribute name='label' translatable='yes'>Edit Script</attribute>"
913            "          <attribute name='action'>AppMenu.EditScript</attribute>"
914            "        </item>"
915            "      </section>"
916            "      <section>"
917            "        <item id='RemoveScript'>"
918            "          <attribute name='label' translatable='yes'>Remove Script</attribute>"
919            "          <attribute name='action'>AppMenu.RemoveScript</attribute>"
920            "        </item>"
921            "      </section>"
922            "    </menu>"
923            "    <menu id='MenuView'>"
924            "      <attribute name='label' translatable='yes'>View</attribute>"
925            "      <section>"
926            "        <item id='Statusbar'>"
927            "          <attribute name='label' translatable='yes'>Statusbar</attribute>"
928            "          <attribute name='action'>AppMenu.Statusbar</attribute>"
929            "        </item>"
930            "        <item id='ShowTooltips'>"
931            "          <attribute name='label' translatable='yes'>Tooltips for Beginners</attribute>"
932            "          <attribute name='action'>AppMenu.ShowTooltips</attribute>"
933            "        </item>"
934            "        <item id='AutoRestoreWinDim'>"
935            "          <attribute name='label' translatable='yes'>Auto restore Window Dimensions</attribute>"
936            "          <attribute name='action'>AppMenu.AutoRestoreWinDim</attribute>"
937            "        </item>"
938            "      </section>"
939            "      <section>"
940            "        <item id='RefreshAll'>"
941            "          <attribute name='label' translatable='yes'>Refresh All</attribute>"
942            "          <attribute name='action'>AppMenu.RefreshAll</attribute>"
943            "        </item>"
944            "      </section>"
945            "    </menu>"
946            "    <menu id='MenuTools'>"
947            "      <attribute name='label' translatable='yes'>Tools</attribute>"
948            "      <section>"
949            "        <item id='CombineInstruments'>"
950            "          <attribute name='label' translatable='yes'>Combine Instruments ...</attribute>"
951            "          <attribute name='action'>AppMenu.CombineInstruments</attribute>"
952            "        </item>"
953            "        <item id='MergeFiles'>"
954            "          <attribute name='label' translatable='yes'>Merge Files ...</attribute>"
955            "          <attribute name='action'>AppMenu.MergeFiles</attribute>"
956            "        </item>"
957            "      </section>"
958            "    </menu>"
959            "    <menu id='MenuSettings'>"
960            "      <attribute name='label' translatable='yes'>Settings</attribute>"
961            "      <section>"
962            "        <item id='WarnUserOnExtensions'>"
963            "          <attribute name='label' translatable='yes'>Warning on Format Extensions</attribute>"
964            "          <attribute name='action'>AppMenu.WarnUserOnExtensions</attribute>"
965            "        </item>"
966            "        <item id='SyncSamplerInstrumentSelection'>"
967            "          <attribute name='label' translatable='yes'>Synchronize Sampler Selection</attribute>"
968            "          <attribute name='action'>AppMenu.SyncSamplerInstrumentSelection</attribute>"
969            "        </item>"
970            "        <item id='MoveRootNoteWithRegionMoved'>"
971            "          <attribute name='label' translatable='yes'>Move Root Note with Region moved</attribute>"
972            "          <attribute name='action'>AppMenu.MoveRootNoteWithRegionMoved</attribute>"
973            "        </item>"
974            "        <item id='SaveWithTemporaryFile'>"
975            "          <attribute name='label' translatable='yes'>Save with temporary file</attribute>"
976            "          <attribute name='action'>AppMenu.SaveWithTemporaryFile</attribute>"
977            "        </item>"
978            "      </section>"
979            "    </menu>"
980            "    <menu id='MenuHelp'>"
981            "      <attribute name='label' translatable='yes'>Help</attribute>"
982            "      <section>"
983            "        <item id='About'>"
984            "          <attribute name='label' translatable='yes'>About ...</attribute>"
985            "          <attribute name='action'>AppMenu.About</attribute>"
986            "        </item>"
987            "      </section>"
988            "    </menu>"
989            "  </menubar>"
990            // popups
991            "  <menu id='PopupMenu'>"
992            "    <section>"
993            "      <item id='InstrProperties'>"
994            "        <attribute name='label' translatable='yes'>Instrument Properties</attribute>"
995            "        <attribute name='action'>AppMenu.InstrProperties</attribute>"
996            "      </item>"
997            "      <item id='MidiRules'>"
998            "        <attribute name='label' translatable='yes'>MIDI Rules</attribute>"
999            "        <attribute name='action'>AppMenu.MidiRules</attribute>"
1000            "      </item>"
1001            "      <item id='ScriptSlots'>"
1002            "        <attribute name='label' translatable='yes'>Script Slots</attribute>"
1003            "        <attribute name='action'>AppMenu.ScriptSlots</attribute>"
1004            "      </item>"
1005            "      <item id='AddInstrument'>"
1006            "        <attribute name='label' translatable='yes'>Add Instrument</attribute>"
1007            "        <attribute name='action'>AppMenu.AddInstrument</attribute>"
1008            "      </item>"
1009            "      <item id='DupInstrument'>"
1010            "        <attribute name='label' translatable='yes'>Duplicate Instrument</attribute>"
1011            "        <attribute name='action'>AppMenu.DupInstrument</attribute>"
1012            "      </item>"
1013            "      <item id='CombInstruments'>"
1014            "        <attribute name='label' translatable='yes'>Combine Instruments</attribute>"
1015            "        <attribute name='action'>AppMenu.CombInstruments</attribute>"
1016            "      </item>"
1017            "    </section>"
1018            "    <section>"
1019            "      <item id='RemoveInstrument'>"
1020            "        <attribute name='label' translatable='yes'>Remove Instruments</attribute>"
1021            "        <attribute name='action'>AppMenu.RemoveInstrument</attribute>"
1022            "      </item>"
1023            "    </section>"
1024            "  </menu>"
1025            "  <menu id='SamplePopupMenu'>"
1026            "    <section>"
1027            "      <item id='SampleProperties'>"
1028            "        <attribute name='label' translatable='yes'>Sample Properties</attribute>"
1029            "        <attribute name='action'>AppMenu.SampleProperties</attribute>"
1030            "      </item>"
1031            "      <item id='AddGroup'>"
1032            "        <attribute name='label' translatable='yes'>Add Sample Group</attribute>"
1033            "        <attribute name='action'>AppMenu.AddGroup</attribute>"
1034            "      </item>"
1035            "      <item id='AddSample'>"
1036            "        <attribute name='label' translatable='yes'>Add Sample</attribute>"
1037            "        <attribute name='action'>AppMenu.AddSample</attribute>"
1038            "      </item>"
1039            "      <item id='ShowSampleRefs'>"
1040            "        <attribute name='label' translatable='yes'>Show Sample References ...</attribute>"
1041            "        <attribute name='action'>AppMenu.ShowSampleRefs</attribute>"
1042            "      </item>"
1043            "      <item id='ReplaceSample'>"
1044            "        <attribute name='label' translatable='yes'>Replace Sample</attribute>"
1045            "        <attribute name='action'>AppMenu.ReplaceSample</attribute>"
1046            "      </item>"
1047            "      <item id='ReplaceAllSamplesInAllGroups'>"
1048            "        <attribute name='label' translatable='yes'>Replace all Samples ...</attribute>"
1049            "        <attribute name='action'>AppMenu.ReplaceAllSamplesInAllGroups</attribute>"
1050            "      </item>"
1051            "    </section>"
1052            "    <section>"
1053            "      <item id='RemoveSample'>"
1054            "        <attribute name='label' translatable='yes'>Remove Sample</attribute>"
1055            "        <attribute name='action'>AppMenu.RemoveSample</attribute>"
1056            "      </item>"
1057            "      <item id='RemoveUnusedSamples'>"
1058            "        <attribute name='label' translatable='yes'>Remove unused Samples</attribute>"
1059            "        <attribute name='action'>AppMenu.RemoveUnusedSamples</attribute>"
1060            "      </item>"
1061            "    </section>"
1062            "  </menu>"
1063            "  <menu id='ScriptPopupMenu'>"
1064            "    <section>"
1065            "      <item id='AddScriptGroup'>"
1066            "        <attribute name='label' translatable='yes'>Add Script Group</attribute>"
1067            "        <attribute name='action'>AppMenu.AddScriptGroup</attribute>"
1068            "      </item>"
1069            "      <item id='AddScript'>"
1070            "        <attribute name='label' translatable='yes'>Add Script</attribute>"
1071            "        <attribute name='action'>AppMenu.AddScript</attribute>"
1072            "      </item>"
1073            "      <item id='EditScript'>"
1074            "        <attribute name='label' translatable='yes'>Edit Script</attribute>"
1075            "        <attribute name='action'>AppMenu.EditScript</attribute>"
1076            "      </item>"
1077            "    </section>"
1078            "    <section>"
1079            "      <item id='RemoveScript'>"
1080            "        <attribute name='label' translatable='yes'>Remove Script</attribute>"
1081            "        <attribute name='action'>AppMenu.RemoveScript</attribute>"
1082            "      </item>"
1083            "    </section>"
1084            "  </menu>"
1085            "</interface>";
1086        m_uiManager->add_from_string(ui_info);
1087    #else
1088      uiManager = Gtk::UIManager::create();      uiManager = Gtk::UIManager::create();
1089      uiManager->insert_action_group(actionGroup);      uiManager->insert_action_group(actionGroup);
1090      add_accel_group(uiManager->get_accel_group());      add_accel_group(uiManager->get_accel_group());
# Line 455  MainWindow::MainWindow() : Line 1108  MainWindow::MainWindow() :
1108          "      <menuitem action='AdjustClipboard'/>"          "      <menuitem action='AdjustClipboard'/>"
1109          "      <menuitem action='PasteDimRgn'/>"          "      <menuitem action='PasteDimRgn'/>"
1110          "      <separator/>"          "      <separator/>"
1111            "      <menuitem action='SelectPrevInstr'/>"
1112            "      <menuitem action='SelectNextInstr'/>"
1113            "      <separator/>"
1114          "      <menuitem action='SelectPrevRegion'/>"          "      <menuitem action='SelectPrevRegion'/>"
1115          "      <menuitem action='SelectNextRegion'/>"          "      <menuitem action='SelectNextRegion'/>"
1116          "      <separator/>"          "      <separator/>"
# Line 489  MainWindow::MainWindow() : Line 1145  MainWindow::MainWindow() :
1145          "      <menuitem action='InstrProperties'/>"          "      <menuitem action='InstrProperties'/>"
1146          "      <menuitem action='MidiRules'/>"          "      <menuitem action='MidiRules'/>"
1147          "      <menuitem action='ScriptSlots'/>"          "      <menuitem action='ScriptSlots'/>"
1148            "      <menu action='AssignScripts'/>"
1149          "      <menuitem action='AddInstrument'/>"          "      <menuitem action='AddInstrument'/>"
1150          "      <menuitem action='DupInstrument'/>"          "      <menuitem action='DupInstrument'/>"
1151            "      <menuitem action='CombInstruments'/>"
1152          "      <separator/>"          "      <separator/>"
1153          "      <menuitem action='RemoveInstrument'/>"          "      <menuitem action='RemoveInstrument'/>"
1154          "    </menu>"          "    </menu>"
# Line 503  MainWindow::MainWindow() : Line 1161  MainWindow::MainWindow() :
1161          "    </menu>"          "    </menu>"
1162          "    <menu action='MenuView'>"          "    <menu action='MenuView'>"
1163          "      <menuitem action='Statusbar'/>"          "      <menuitem action='Statusbar'/>"
1164            "      <menuitem action='ShowTooltips'/>"
1165          "      <menuitem action='AutoRestoreWinDim'/>"          "      <menuitem action='AutoRestoreWinDim'/>"
1166          "      <separator/>"          "      <separator/>"
1167          "      <menuitem action='RefreshAll'/>"          "      <menuitem action='RefreshAll'/>"
# Line 527  MainWindow::MainWindow() : Line 1186  MainWindow::MainWindow() :
1186          "    <menuitem action='ScriptSlots'/>"          "    <menuitem action='ScriptSlots'/>"
1187          "    <menuitem action='AddInstrument'/>"          "    <menuitem action='AddInstrument'/>"
1188          "    <menuitem action='DupInstrument'/>"          "    <menuitem action='DupInstrument'/>"
1189            "    <menuitem action='CombInstruments'/>"
1190          "    <separator/>"          "    <separator/>"
1191          "    <menuitem action='RemoveInstrument'/>"          "    <menuitem action='RemoveInstrument'/>"
1192          "  </popup>"          "  </popup>"
# Line 550  MainWindow::MainWindow() : Line 1210  MainWindow::MainWindow() :
1210          "  </popup>"          "  </popup>"
1211          "</ui>";          "</ui>";
1212      uiManager->add_ui_from_string(ui_info);      uiManager->add_ui_from_string(ui_info);
1213    #endif
1214    
1215    #if USE_GTKMM_BUILDER
1216        popup_menu = new Gtk::Menu(
1217            Glib::RefPtr<Gio::Menu>::cast_dynamic(
1218                m_uiManager->get_object("PopupMenu")
1219            )
1220        );
1221        sample_popup = new Gtk::Menu(
1222            Glib::RefPtr<Gio::Menu>::cast_dynamic(
1223                m_uiManager->get_object("SamplePopupMenu")
1224            )
1225        );
1226        script_popup = new Gtk::Menu(
1227            Glib::RefPtr<Gio::Menu>::cast_dynamic(
1228                m_uiManager->get_object("ScriptPopupMenu")
1229            )
1230        );
1231    #else
1232      popup_menu = dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/PopupMenu"));      popup_menu = dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/PopupMenu"));
1233            
1234      // Set tooltips for menu items (for some reason, setting a tooltip on the      // Set tooltips for menu items (for some reason, setting a tooltip on the
# Line 570  MainWindow::MainWindow() : Line 1248  MainWindow::MainWindow() :
1248      {      {
1249          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
1250              uiManager->get_widget("/MenuBar/MenuEdit/CopySampleLoop"));              uiManager->get_widget("/MenuBar/MenuEdit/CopySampleLoop"));
1251          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."));          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 information to be altered by this action."));
1252      }      }
1253      {      {
1254          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
# Line 585  MainWindow::MainWindow() : Line 1263  MainWindow::MainWindow() :
1263      {      {
1264          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
1265              uiManager->get_widget("/MenuBar/MenuSettings/MoveRootNoteWithRegionMoved"));              uiManager->get_widget("/MenuBar/MenuSettings/MoveRootNoteWithRegionMoved"));
1266          item->set_tooltip_text(_("If checked, and when a region is moved by dragging it around on the virtual keyboard, the keybord position dependent pitch will move exactly with the amount of semi tones the region was moved around."));          item->set_tooltip_text(_("If checked, and when a region is moved by dragging it around on the virtual keyboard, the keyboard position dependent pitch will move exactly with the amount of semi tones the region was moved around."));
1267      }      }
1268      {      {
1269          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
# Line 616  MainWindow::MainWindow() : Line 1294  MainWindow::MainWindow() :
1294              uiManager->get_widget("/MenuBar/MenuTools/MergeFiles"));              uiManager->get_widget("/MenuBar/MenuTools/MergeFiles"));
1295          item->set_tooltip_text(_("Add instruments and samples of other .gig files to this .gig file."));          item->set_tooltip_text(_("Add instruments and samples of other .gig files to this .gig file."));
1296      }      }
1297    #endif
1298    
1299    #if USE_GTKMM_BUILDER
1300        assign_scripts_menu = new Gtk::Menu(
1301            Glib::RefPtr<Gio::Menu>::cast_dynamic(
1302                m_uiManager->get_object("AssignScripts")
1303            )
1304        );
1305    #else
1306      instrument_menu = static_cast<Gtk::MenuItem*>(      instrument_menu = static_cast<Gtk::MenuItem*>(
1307          uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments"))->get_submenu();          uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments"))->get_submenu();
1308    
1309        assign_scripts_menu = static_cast<Gtk::MenuItem*>(
1310            uiManager->get_widget("/MenuBar/MenuInstrument/AssignScripts"))->get_submenu();
1311    #endif
1312    
1313    #if USE_GTKMM_BUILDER
1314        Gtk::Widget* menuBar = NULL;
1315        m_uiManager->get_widget("MenuBar", menuBar);
1316    #else
1317      Gtk::Widget* menuBar = uiManager->get_widget("/MenuBar");      Gtk::Widget* menuBar = uiManager->get_widget("/MenuBar");
1318    #endif
1319    
1320      m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK);      m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK);
1321      m_VBox.pack_start(m_HPaned);      m_VBox.pack_start(m_HPaned);
1322      m_VBox.pack_start(m_RegionChooser, Gtk::PACK_SHRINK);      m_VBox.pack_start(m_RegionChooser, Gtk::PACK_SHRINK);
# Line 632  MainWindow::MainWindow() : Line 1327  MainWindow::MainWindow() :
1327      set_file_is_shared(false);      set_file_is_shared(false);
1328    
1329      // Status Bar:      // Status Bar:
1330    #if USE_GTKMM_BOX
1331    # warning No status bar layout for GTKMM 4 yet
1332    #else
1333      m_StatusBar.pack_start(m_AttachedStateLabel, Gtk::PACK_SHRINK);      m_StatusBar.pack_start(m_AttachedStateLabel, Gtk::PACK_SHRINK);
1334      m_StatusBar.pack_start(m_AttachedStateImage, Gtk::PACK_SHRINK);      m_StatusBar.pack_start(m_AttachedStateImage, Gtk::PACK_SHRINK);
1335    #endif
1336      m_StatusBar.show();      m_StatusBar.show();
1337    
1338      m_RegionChooser.signal_region_selected().connect(      m_RegionChooser.signal_region_selected().connect(
# Line 644  MainWindow::MainWindow() : Line 1343  MainWindow::MainWindow() :
1343    
1344      // Create the Tree model:      // Create the Tree model:
1345      m_refTreeModel = Gtk::ListStore::create(m_Columns);      m_refTreeModel = Gtk::ListStore::create(m_Columns);
1346      m_TreeView.set_model(m_refTreeModel);      m_refTreeModelFilter = Gtk::TreeModelFilter::create(m_refTreeModel);
1347        m_refTreeModelFilter->set_visible_func(
1348            sigc::mem_fun(*this, &MainWindow::instrument_row_visible)
1349        );
1350        m_TreeView.set_model(m_refTreeModelFilter);
1351    
1352      m_TreeView.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);      m_TreeView.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
1353      m_TreeView.set_tooltip_text(_("Right click here for actions on instruments & MIDI Rules. Drag & drop to change the order of instruments."));      m_TreeView.set_has_tooltip(true);
1354        m_TreeView.signal_query_tooltip().connect(
1355            sigc::mem_fun(*this, &MainWindow::onQueryTreeViewTooltip)
1356        );
1357      instrument_name_connection = m_refTreeModel->signal_row_changed().connect(      instrument_name_connection = m_refTreeModel->signal_row_changed().connect(
1358          sigc::mem_fun(*this, &MainWindow::instrument_name_changed)          sigc::mem_fun(*this, &MainWindow::instrument_name_changed)
1359      );      );
# Line 654  MainWindow::MainWindow() : Line 1361  MainWindow::MainWindow() :
1361      // Add the TreeView's view columns:      // Add the TreeView's view columns:
1362      m_TreeView.append_column(_("Nr"), m_Columns.m_col_nr);      m_TreeView.append_column(_("Nr"), m_Columns.m_col_nr);
1363      m_TreeView.append_column_editable(_("Instrument"), m_Columns.m_col_name);      m_TreeView.append_column_editable(_("Instrument"), m_Columns.m_col_name);
1364        m_TreeView.append_column(_("Scripts"), m_Columns.m_col_scripts);
1365      m_TreeView.set_headers_visible(true);      m_TreeView.set_headers_visible(true);
1366            
1367      // establish drag&drop within the instrument tree view, allowing to reorder      // establish drag&drop within the instrument tree view, allowing to reorder
# Line 699  MainWindow::MainWindow() : Line 1407  MainWindow::MainWindow() :
1407          );          );
1408      }      }
1409      m_TreeViewSamples.set_headers_visible(true);      m_TreeViewSamples.set_headers_visible(true);
1410    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2
1411        m_TreeViewSamples.signal_button_press_event().connect(
1412            sigc::mem_fun(*this, &MainWindow::on_sample_treeview_button_release)
1413        );
1414    #else
1415      m_TreeViewSamples.signal_button_press_event().connect_notify(      m_TreeViewSamples.signal_button_press_event().connect_notify(
1416          sigc::mem_fun(*this, &MainWindow::on_sample_treeview_button_release)          sigc::mem_fun(*this, &MainWindow::on_sample_treeview_button_release)
1417      );      );
1418    #endif
1419      m_refSamplesTreeModel->signal_row_changed().connect(      m_refSamplesTreeModel->signal_row_changed().connect(
1420          sigc::mem_fun(*this, &MainWindow::sample_name_changed)          sigc::mem_fun(*this, &MainWindow::sample_name_changed)
1421      );      );
# Line 718  MainWindow::MainWindow() : Line 1432  MainWindow::MainWindow() :
1432      // m_TreeViewScripts.set_reorderable();      // m_TreeViewScripts.set_reorderable();
1433      m_TreeViewScripts.append_column_editable("Samples", m_ScriptsModel.m_col_name);      m_TreeViewScripts.append_column_editable("Samples", m_ScriptsModel.m_col_name);
1434      m_TreeViewScripts.set_headers_visible(false);      m_TreeViewScripts.set_headers_visible(false);
1435    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2
1436        m_TreeViewScripts.signal_button_press_event().connect(
1437            sigc::mem_fun(*this, &MainWindow::on_script_treeview_button_release)
1438        );
1439    #else
1440      m_TreeViewScripts.signal_button_press_event().connect_notify(      m_TreeViewScripts.signal_button_press_event().connect_notify(
1441          sigc::mem_fun(*this, &MainWindow::on_script_treeview_button_release)          sigc::mem_fun(*this, &MainWindow::on_script_treeview_button_release)
1442      );      );
1443    #endif
1444      //FIXME: why the heck does this double click signal_row_activated() only fire while CTRL key is pressed ?      //FIXME: why the heck does this double click signal_row_activated() only fire while CTRL key is pressed ?
1445      m_TreeViewScripts.signal_row_activated().connect(      m_TreeViewScripts.signal_row_activated().connect(
1446          sigc::mem_fun(*this, &MainWindow::script_double_clicked)          sigc::mem_fun(*this, &MainWindow::script_double_clicked)
# Line 790  MainWindow::MainWindow() : Line 1510  MainWindow::MainWindow() :
1510          sigc::hide(          sigc::hide(
1511              sigc::bind(              sigc::bind(
1512                  file_structure_to_be_changed_signal.make_slot(),                  file_structure_to_be_changed_signal.make_slot(),
1513    #if SIGCXX_MAJOR_VERSION > 2 || (SIGCXX_MAJOR_VERSION == 2 && SIGCXX_MINOR_VERSION >= 8)
1514                    std::ref(this->file)
1515    #else
1516                  sigc::ref(this->file)                  sigc::ref(this->file)
1517    #endif
1518              )              )
1519          )          )
1520      );      );
# Line 798  MainWindow::MainWindow() : Line 1522  MainWindow::MainWindow() :
1522          sigc::hide(          sigc::hide(
1523              sigc::bind(              sigc::bind(
1524                  file_structure_changed_signal.make_slot(),                  file_structure_changed_signal.make_slot(),
1525    #if SIGCXX_MAJOR_VERSION > 2 || (SIGCXX_MAJOR_VERSION == 2 && SIGCXX_MINOR_VERSION >= 8)
1526                    std::ref(this->file)
1527    #else
1528                  sigc::ref(this->file)                  sigc::ref(this->file)
1529    #endif
1530              )              )
1531          )          )
1532      );      );
# Line 819  MainWindow::MainWindow() : Line 1547  MainWindow::MainWindow() :
1547      dimreg_stereo.signal_toggled().connect(      dimreg_stereo.signal_toggled().connect(
1548          sigc::mem_fun(*this, &MainWindow::update_dimregs));          sigc::mem_fun(*this, &MainWindow::update_dimregs));
1549    
1550        m_searchText.signal_changed().connect(
1551            sigc::mem_fun(*m_refTreeModelFilter.operator->(), &Gtk::TreeModelFilter::refilter)
1552        );
1553    
1554      file = 0;      file = 0;
1555      file_is_changed = false;      file_is_changed = false;
1556    
1557    #if HAS_GTKMM_SHOW_ALL_CHILDREN
1558      show_all_children();      show_all_children();
1559    #endif
1560    
1561      // start with a new gig file by default      // start with a new gig file by default
1562      on_action_file_new();      on_action_file_new();
1563    
1564        m_TreeViewNotebook.signal_switch_page().connect(
1565            sigc::mem_fun(*this, &MainWindow::on_notebook_tab_switched)
1566        );
1567    
1568      // select 'Instruments' tab by default      // select 'Instruments' tab by default
1569      // (gtk allows this only if the tab childs are visible, thats why it's here)      // (gtk allows this only if the tab childs are visible, thats why it's here)
1570      m_TreeViewNotebook.set_current_page(1);      m_TreeViewNotebook.set_current_page(1);
# Line 839  MainWindow::MainWindow() : Line 1577  MainWindow::MainWindow() :
1577    
1578      // setup macros and their keyboard accelerators      // setup macros and their keyboard accelerators
1579      {      {
1580    #if USE_GTKMM_BUILDER
1581            menuMacro = new Gtk::Menu(
1582                Glib::RefPtr<Gio::Menu>::cast_dynamic(
1583                    m_uiManager->get_object("MenuMacro")
1584                )
1585            );
1586    #else
1587          Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>(          Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>(
1588              uiManager->get_widget("/MenuBar/MenuMacro")              uiManager->get_widget("/MenuBar/MenuMacro")
1589          )->get_submenu();          )->get_submenu();
   
         const Gdk::ModifierType primaryModifierKey =  
 #if defined(__APPLE__)  
             Gdk::META_MASK; // Cmd key on Mac  
 #else  
             Gdk::CONTROL_MASK; // Ctrl key on all other OSs  
1590  #endif  #endif
1591    
1592          const Gdk::ModifierType noModifier = (Gdk::ModifierType)0;          const Gdk::ModifierType noModifier = (Gdk::ModifierType)0;
# Line 863  MainWindow::MainWindow() : Line 1602  MainWindow::MainWindow() :
1602          Gtk::AccelMap::add_entry("<Macros>/macro_9", GDK_KEY_F10, noModifier);          Gtk::AccelMap::add_entry("<Macros>/macro_9", GDK_KEY_F10, noModifier);
1603          Gtk::AccelMap::add_entry("<Macros>/macro_10", GDK_KEY_F11, noModifier);          Gtk::AccelMap::add_entry("<Macros>/macro_10", GDK_KEY_F11, noModifier);
1604          Gtk::AccelMap::add_entry("<Macros>/macro_11", GDK_KEY_F12, noModifier);          Gtk::AccelMap::add_entry("<Macros>/macro_11", GDK_KEY_F12, noModifier);
1605            Gtk::AccelMap::add_entry("<Macros>/macro_12", GDK_KEY_F13, noModifier);
1606            Gtk::AccelMap::add_entry("<Macros>/macro_13", GDK_KEY_F14, noModifier);
1607            Gtk::AccelMap::add_entry("<Macros>/macro_14", GDK_KEY_F15, noModifier);
1608            Gtk::AccelMap::add_entry("<Macros>/macro_15", GDK_KEY_F16, noModifier);
1609            Gtk::AccelMap::add_entry("<Macros>/macro_16", GDK_KEY_F17, noModifier);
1610            Gtk::AccelMap::add_entry("<Macros>/macro_17", GDK_KEY_F18, noModifier);
1611            Gtk::AccelMap::add_entry("<Macros>/macro_18", GDK_KEY_F19, noModifier);
1612          Gtk::AccelMap::add_entry("<Macros>/SetupMacros", 'm', primaryModifierKey);          Gtk::AccelMap::add_entry("<Macros>/SetupMacros", 'm', primaryModifierKey);
1613    
1614          Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group();          Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group();
# Line 870  MainWindow::MainWindow() : Line 1616  MainWindow::MainWindow() :
1616    
1617          updateMacroMenu();          updateMacroMenu();
1618      }      }
1619    
1620        // setup "Assign Scripts" keyboard accelerators
1621        {
1622            Gtk::AccelMap::add_entry("<Scripts>/script_0", GDK_KEY_F1, Gdk::SHIFT_MASK);
1623            Gtk::AccelMap::add_entry("<Scripts>/script_1", GDK_KEY_F2, Gdk::SHIFT_MASK);
1624            Gtk::AccelMap::add_entry("<Scripts>/script_2", GDK_KEY_F3, Gdk::SHIFT_MASK);
1625            Gtk::AccelMap::add_entry("<Scripts>/script_3", GDK_KEY_F4, Gdk::SHIFT_MASK);
1626            Gtk::AccelMap::add_entry("<Scripts>/script_4", GDK_KEY_F5, Gdk::SHIFT_MASK);
1627            Gtk::AccelMap::add_entry("<Scripts>/script_5", GDK_KEY_F6, Gdk::SHIFT_MASK);
1628            Gtk::AccelMap::add_entry("<Scripts>/script_6", GDK_KEY_F7, Gdk::SHIFT_MASK);
1629            Gtk::AccelMap::add_entry("<Scripts>/script_7", GDK_KEY_F8, Gdk::SHIFT_MASK);
1630            Gtk::AccelMap::add_entry("<Scripts>/script_8", GDK_KEY_F9, Gdk::SHIFT_MASK);
1631            Gtk::AccelMap::add_entry("<Scripts>/script_9", GDK_KEY_F10, Gdk::SHIFT_MASK);
1632            Gtk::AccelMap::add_entry("<Scripts>/script_10", GDK_KEY_F11, Gdk::SHIFT_MASK);
1633            Gtk::AccelMap::add_entry("<Scripts>/script_11", GDK_KEY_F12, Gdk::SHIFT_MASK);
1634            Gtk::AccelMap::add_entry("<Scripts>/script_12", GDK_KEY_F13, Gdk::SHIFT_MASK);
1635            Gtk::AccelMap::add_entry("<Scripts>/script_13", GDK_KEY_F14, Gdk::SHIFT_MASK);
1636            Gtk::AccelMap::add_entry("<Scripts>/script_14", GDK_KEY_F15, Gdk::SHIFT_MASK);
1637            Gtk::AccelMap::add_entry("<Scripts>/script_15", GDK_KEY_F16, Gdk::SHIFT_MASK);
1638            Gtk::AccelMap::add_entry("<Scripts>/script_16", GDK_KEY_F17, Gdk::SHIFT_MASK);
1639            Gtk::AccelMap::add_entry("<Scripts>/script_17", GDK_KEY_F18, Gdk::SHIFT_MASK);
1640            Gtk::AccelMap::add_entry("<Scripts>/script_18", GDK_KEY_F19, Gdk::SHIFT_MASK);
1641            Gtk::AccelMap::add_entry("<Scripts>/DropAllScriptSlots", GDK_KEY_BackSpace, Gdk::SHIFT_MASK);
1642    
1643            Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group();
1644            assign_scripts_menu->set_accel_group(accelGroup);
1645        }
1646    
1647        on_show_tooltips_changed();
1648    
1649        Glib::signal_idle().connect_once(
1650            sigc::mem_fun(*this, &MainWindow::bringToFront),
1651            200
1652        );
1653  }  }
1654    
1655  MainWindow::~MainWindow()  MainWindow::~MainWindow()
1656  {  {
1657  }  }
1658    
1659    void MainWindow::bringToFront() {
1660        #if defined(__APPLE__)
1661        macRaiseAppWindow();
1662        #endif
1663        raise();
1664        present();
1665    }
1666    
1667  void MainWindow::updateMacroMenu() {  void MainWindow::updateMacroMenu() {
1668    #if !USE_GTKMM_BUILDER
1669      Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>(      Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>(
1670          uiManager->get_widget("/MenuBar/MenuMacro")          uiManager->get_widget("/MenuBar/MenuMacro")
1671      )->get_submenu();      )->get_submenu();
1672    #endif
1673    
1674      // remove all entries from "Macro" menu      // remove all entries from "Macro" menu
1675      {      {
# Line 937  void MainWindow::updateMacroMenu() { Line 1727  void MainWindow::updateMacroMenu() {
1727          item->set_accel_path("<Macros>/SetupMacros");          item->set_accel_path("<Macros>/SetupMacros");
1728      }      }
1729    
1730    #if HAS_GTKMM_SHOW_ALL_CHILDREN
1731      menuMacro->show_all_children();      menuMacro->show_all_children();
1732    #endif
1733  }  }
1734    
1735  void MainWindow::onMacroSelected(int iMacro) {  void MainWindow::onMacroSelected(int iMacro) {
# Line 974  void MainWindow::onMacrosSetupChanged(co Line 1766  void MainWindow::onMacrosSetupChanged(co
1766      updateMacroMenu();      updateMacroMenu();
1767  }  }
1768    
1769    //NOTE: the actual signal's first argument for argument 'page' is on some gtkmm version GtkNotebookPage* and on some Gtk::Widget*. Since we don't need that argument, it is simply void* here for now.
1770    void MainWindow::on_notebook_tab_switched(void* page, guint page_num) {
1771        bool isInstrumentsPage = (page_num == 1);
1772        // so far we only support filtering for the instruments list, so hide the
1773        // filter text entry field if another tab is selected
1774        m_searchField.set_visible(isInstrumentsPage);
1775    }
1776    
1777  bool MainWindow::on_delete_event(GdkEventAny* event)  bool MainWindow::on_delete_event(GdkEventAny* event)
1778  {  {
1779      return !file_is_shared && file_is_changed && !close_confirmation_dialog();      return !file_is_shared && file_is_changed && !close_confirmation_dialog();
# Line 995  gig::Instrument* MainWindow::get_instrum Line 1795  gig::Instrument* MainWindow::get_instrum
1795      gig::Instrument* instrument = 0;      gig::Instrument* instrument = 0;
1796      std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows();      std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows();
1797      if (rows.empty()) return NULL;      if (rows.empty()) return NULL;
1798      Gtk::TreeModel::const_iterator it = m_refTreeModel->get_iter(rows[0]);      //NOTE: was const_iterator before, which did not compile with GTKMM4 development branch, probably going to be fixed before final GTKMM4 release though.
1799        Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]);
1800      if (it) {      if (it) {
1801          Gtk::TreeModel::Row row = *it;          Gtk::TreeModel::Row row = *it;
1802          instrument = row[m_Columns.m_col_instr];          instrument = row[m_Columns.m_col_instr];
# Line 1061  void MainWindow::dimreg_changed() Line 1862  void MainWindow::dimreg_changed()
1862    
1863  void MainWindow::on_sel_change()  void MainWindow::on_sel_change()
1864  {  {
1865    #if !USE_GTKMM_BUILDER
1866      // select item in instrument menu      // select item in instrument menu
1867      std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows();      std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows();
1868      if (!rows.empty()) {      if (!rows.empty()) {
# Line 1073  void MainWindow::on_sel_change() Line 1875  void MainWindow::on_sel_change()
1875              static_cast<Gtk::RadioMenuItem*>(children[index])->set_active();              static_cast<Gtk::RadioMenuItem*>(children[index])->set_active();
1876          }          }
1877      }      }
1878    #endif
1879    
1880        updateScriptListOfMenu();
1881    
1882      m_RegionChooser.set_instrument(get_instrument());      m_RegionChooser.set_instrument(get_instrument());
1883    
# Line 1081  void MainWindow::on_sel_change() Line 1886  void MainWindow::on_sel_change()
1886      }      }
1887  }  }
1888    
1889    
1890    LoaderSaverBase::LoaderSaverBase(const Glib::ustring filename, gig::File* gig) :
1891        filename(filename), gig(gig),
1892    #ifdef GLIB_THREADS
1893        thread(0),
1894    #endif
1895        progress(0.f)
1896    {
1897    }
1898    
1899  void loader_progress_callback(gig::progress_t* progress)  void loader_progress_callback(gig::progress_t* progress)
1900  {  {
1901      Loader* loader = static_cast<Loader*>(progress->custom);      LoaderSaverBase* loader = static_cast<LoaderSaverBase*>(progress->custom);
1902      loader->progress_callback(progress->factor);      loader->progress_callback(progress->factor);
1903  }  }
1904    
1905  void Loader::progress_callback(float fraction)  void LoaderSaverBase::progress_callback(float fraction)
1906  {  {
1907      {      {
1908    #ifdef GLIB_THREADS
1909          Glib::Threads::Mutex::Lock lock(progressMutex);          Glib::Threads::Mutex::Lock lock(progressMutex);
1910    #else
1911            std::lock_guard<std::mutex> lock(progressMutex);
1912    #endif
1913          progress = fraction;          progress = fraction;
1914      }      }
1915      progress_dispatcher();      progress_dispatcher();
# Line 1100  void Loader::progress_callback(float fra Line 1919  void Loader::progress_callback(float fra
1919  // make sure stack is 16-byte aligned for SSE instructions  // make sure stack is 16-byte aligned for SSE instructions
1920  __attribute__((force_align_arg_pointer))  __attribute__((force_align_arg_pointer))
1921  #endif  #endif
1922  void Loader::thread_function()  void LoaderSaverBase::thread_function()
1923  {  {
1924    #ifdef GLIB_THREADS
1925      printf("thread_function self=%p\n",      printf("thread_function self=%p\n",
1926             static_cast<void*>(Glib::Threads::Thread::self()));             static_cast<void*>(Glib::Threads::Thread::self()));
1927    #else
1928        std::cout << "thread_function self=" << std::this_thread::get_id() << "\n";
1929    #endif
1930      printf("Start %s\n", filename.c_str());      printf("Start %s\n", filename.c_str());
1931      try {      try {
         RIFF::File* riff = new RIFF::File(filename);  
         gig = new gig::File(riff);  
1932          gig::progress_t progress;          gig::progress_t progress;
1933          progress.callback = loader_progress_callback;          progress.callback = loader_progress_callback;
1934          progress.custom = this;          progress.custom = this;
1935    
1936          gig->GetInstrument(0, &progress);          thread_function_sub(progress);
1937          printf("End\n");          printf("End\n");
1938          finished_dispatcher();          finished_dispatcher();
1939      } catch (RIFF::Exception e) {      } catch (RIFF::Exception e) {
# Line 1124  void Loader::thread_function() Line 1945  void Loader::thread_function()
1945      }      }
1946  }  }
1947    
1948  Loader::Loader(const char* filename)  void LoaderSaverBase::launch()
     : filename(filename), gig(0), thread(0), progress(0.f)  
 {  
 }  
   
 void Loader::launch()  
1949  {  {
1950    #ifdef GLIB_THREADS
1951  #ifdef OLD_THREADS  #ifdef OLD_THREADS
1952      thread = Glib::Thread::create(sigc::mem_fun(*this, &Loader::thread_function), true);      thread = Glib::Thread::create(sigc::mem_fun(*this, &LoaderSaverBase::thread_function), true);
1953  #else  #else
1954      thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Loader::thread_function));      thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &LoaderSaverBase::thread_function));
1955  #endif  #endif
1956      printf("launch thread=%p\n", static_cast<void*>(thread));      printf("launch thread=%p\n", static_cast<void*>(thread));
1957    #else
1958        thread = std::thread([this](){ thread_function(); });
1959        std::cout << "launch thread=" << thread.get_id() << "\n";
1960    #endif
1961  }  }
1962    
1963  float Loader::get_progress()  float LoaderSaverBase::get_progress()
1964  {  {
1965      float res;  #ifdef GLIB_THREADS
1966      {      Glib::Threads::Mutex::Lock lock(progressMutex);
1967          Glib::Threads::Mutex::Lock lock(progressMutex);  #else
1968          res = progress;      std::lock_guard<std::mutex> lock(progressMutex);
1969      }  #endif
1970      return res;      return progress;
1971  }  }
1972    
1973  Glib::Dispatcher& Loader::signal_progress()  Glib::Dispatcher& LoaderSaverBase::signal_progress()
1974  {  {
1975      return progress_dispatcher;      return progress_dispatcher;
1976  }  }
1977    
1978  Glib::Dispatcher& Loader::signal_finished()  Glib::Dispatcher& LoaderSaverBase::signal_finished()
1979  {  {
1980      return finished_dispatcher;      return finished_dispatcher;
1981  }  }
1982    
1983  Glib::Dispatcher& Loader::signal_error()  Glib::Dispatcher& LoaderSaverBase::signal_error()
1984  {  {
1985      return error_dispatcher;      return error_dispatcher;
1986  }  }
1987    
1988  void saver_progress_callback(gig::progress_t* progress)  void LoaderSaverBase::join() {
1989  {  #ifdef GLIB_THREADS
1990      Saver* saver = static_cast<Saver*>(progress->custom);      thread->join();
1991      saver->progress_callback(progress->factor);  #else
1992        thread.join();
1993    #endif
1994  }  }
1995    
1996  void Saver::progress_callback(float fraction)  
1997    Loader::Loader(const char* filename) :
1998        LoaderSaverBase(filename, 0)
1999  {  {
     {  
         Glib::Threads::Mutex::Lock lock(progressMutex);  
         progress = fraction;  
     }  
     progress_dispatcher.emit();  
2000  }  }
2001    
2002  #if defined(WIN32) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2))  void Loader::thread_function_sub(gig::progress_t& progress)
 // make sure stack is 16-byte aligned for SSE instructions  
 __attribute__((force_align_arg_pointer))  
 #endif  
 void Saver::thread_function()  
2003  {  {
2004      printf("thread_function self=%p\n",      RIFF::File* riff = new RIFF::File(filename);
2005             static_cast<void*>(Glib::Threads::Thread::self()));      gig = new gig::File(riff);
     printf("Start %s\n", filename.c_str());  
     try {  
         gig::progress_t progress;  
         progress.callback = saver_progress_callback;  
         progress.custom = this;  
   
         // if no filename was provided, that means "save", if filename was provided means "save as"  
         if (filename.empty()) {  
             if (!Settings::singleton()->saveWithTemporaryFile) {  
                 // save directly over the existing .gig file  
                 // (requires less disk space than solution below  
                 // but may be slower)  
                 gig->Save(&progress);  
             } else {  
                 // save the file as separate temporary file first,  
                 // then move the saved file over the old file  
                 // (may result in performance speedup during save)  
                 String tmpname = filename + ".TMP";  
                 gig->Save(tmpname, &progress);  
                 #if defined(WIN32)  
                 if (!DeleteFile(filename.c_str())) {  
                     throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file).");  
                 }  
                 #else // POSIX ...  
                 if (unlink(filename.c_str())) {  
                     throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file): " + String(strerror(errno)));  
                 }  
                 #endif  
                 if (rename(tmpname.c_str(), filename.c_str())) {  
                     #if defined(WIN32)  
                     throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file).");  
                     #else  
                     throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file): " + String(strerror(errno)));  
                     #endif  
                 }  
             }  
         } else {  
             gig->Save(filename, &progress);  
         }  
2006    
2007          printf("End\n");      gig->GetInstrument(0, &progress);
         finished_dispatcher.emit();  
     } catch (RIFF::Exception e) {  
         error_message = e.Message;  
         error_dispatcher.emit();  
     } catch (...) {  
         error_message = _("Unknown exception occurred");  
         error_dispatcher.emit();  
     }  
2008  }  }
2009    
2010  Saver::Saver(gig::File* file, Glib::ustring filename)  
2011      : gig(file), filename(filename), thread(0), progress(0.f)  Saver::Saver(gig::File* file, Glib::ustring filename) :
2012        LoaderSaverBase(filename, file)
2013  {  {
2014  }  }
2015    
2016  void Saver::launch()  void Saver::thread_function_sub(gig::progress_t& progress)
2017  {  {
2018  #ifdef OLD_THREADS      // if no filename was provided, that means "save", if filename was provided means "save as"
2019      thread = Glib::Thread::create(sigc::mem_fun(*this, &Saver::thread_function), true);      if (filename.empty()) {
2020            if (!Settings::singleton()->saveWithTemporaryFile) {
2021                // save directly over the existing .gig file
2022                // (requires less disk space than solution below
2023                // but may be slower)
2024                gig->Save(&progress);
2025            } else {
2026                // save the file as separate temporary file first,
2027                // then move the saved file over the old file
2028                // (may result in performance speedup during save)
2029                gig::String tmpname = filename + ".TMP";
2030                gig->Save(tmpname, &progress);
2031    #if defined(WIN32)
2032                if (!DeleteFile(filename.c_str())) {
2033                    throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file).");
2034                }
2035    #else // POSIX ...
2036                if (unlink(filename.c_str())) {
2037                    throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file): " + gig::String(strerror(errno)));
2038                }
2039    #endif
2040                if (rename(tmpname.c_str(), filename.c_str())) {
2041    #if defined(WIN32)
2042                    throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file).");
2043  #else  #else
2044      thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Saver::thread_function));                  throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file): " + gig::String(strerror(errno)));
2045  #endif  #endif
2046      printf("launch thread=%p\n", static_cast<void*>(thread));              }
2047  }          }
2048        } else {
2049  float Saver::get_progress()          gig->Save(filename, &progress);
 {  
     float res;  
     {  
         Glib::Threads::Mutex::Lock lock(progressMutex);  
         res = progress;  
2050      }      }
     return res;  
 }  
   
 Glib::Dispatcher& Saver::signal_progress()  
 {  
     return progress_dispatcher;  
2051  }  }
2052    
 Glib::Dispatcher& Saver::signal_finished()  
 {  
     return finished_dispatcher;  
 }  
   
 Glib::Dispatcher& Saver::signal_error()  
 {  
     return error_dispatcher;  
 }  
2053    
2054  ProgressDialog::ProgressDialog(const Glib::ustring& title, Gtk::Window& parent)  ProgressDialog::ProgressDialog(const Glib::ustring& title, Gtk::Window& parent)
2055      : Gtk::Dialog(title, parent, true)      : Gtk::Dialog(title, parent, true)
2056  {  {
2057    #if USE_GTKMM_BOX
2058        get_content_area()->pack_start(progressBar);
2059    #else
2060      get_vbox()->pack_start(progressBar);      get_vbox()->pack_start(progressBar);
2061    #endif
2062    #if HAS_GTKMM_SHOW_ALL_CHILDREN
2063      show_all_children();      show_all_children();
2064    #endif
2065      resize(600,50);      resize(600,50);
2066  }  }
2067    
# Line 1295  void MainWindow::__clear() { Line 2074  void MainWindow::__clear() {
2074      m_refTreeModel->clear();      m_refTreeModel->clear();
2075      m_refSamplesTreeModel->clear();      m_refSamplesTreeModel->clear();
2076      m_refScriptsTreeModel->clear();      m_refScriptsTreeModel->clear();
2077    #if !USE_GTKMM_BUILDER
2078      // remove all entries from "Instrument" menu      // remove all entries from "Instrument" menu
2079      while (!instrument_menu->get_children().empty()) {      while (!instrument_menu->get_children().empty()) {
2080          remove_instrument_from_menu(0);          remove_instrument_from_menu(0);
2081      }      }
2082    #endif
2083      // free libgig's gig::File instance      // free libgig's gig::File instance
2084      if (file && !file_is_shared) delete file;      if (file && !file_is_shared) delete file;
2085      file = NULL;      file = NULL;
# Line 1310  void MainWindow::__refreshEntireGUI() { Line 2091  void MainWindow::__refreshEntireGUI() {
2091      m_refTreeModel->clear();      m_refTreeModel->clear();
2092      m_refSamplesTreeModel->clear();      m_refSamplesTreeModel->clear();
2093      m_refScriptsTreeModel->clear();      m_refScriptsTreeModel->clear();
2094    #if !USE_GTKMM_BUILDER
2095      // remove all entries from "Instrument" menu      // remove all entries from "Instrument" menu
2096      while (!instrument_menu->get_children().empty()) {      while (!instrument_menu->get_children().empty()) {
2097          remove_instrument_from_menu(0);          remove_instrument_from_menu(0);
2098      }      }
2099    #endif
2100    
2101      if (!this->file) return;      if (!this->file) return;
2102    
# Line 1347  bool MainWindow::close_confirmation_dial Line 2130  bool MainWindow::close_confirmation_dial
2130      g_free(msg);      g_free(msg);
2131      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."));
2132      dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO);      dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO);
2133    #if HAS_GTKMM_STOCK
2134      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
2135      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);
2136    #else
2137        dialog.add_button(_("_OK"), Gtk::RESPONSE_OK);
2138        dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
2139    #endif
2140      dialog.set_default_response(Gtk::RESPONSE_YES);      dialog.set_default_response(Gtk::RESPONSE_YES);
2141      int response = dialog.run();      int response = dialog.run();
2142      dialog.hide();      dialog.hide();
# Line 1379  bool MainWindow::leaving_shared_mode_dia Line 2167  bool MainWindow::leaving_shared_mode_dia
2167            "used by the sampler until you tell the sampler explicitly to "            "used by the sampler until you tell the sampler explicitly to "
2168            "load it."));            "load it."));
2169      dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES);      dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES);
2170    #if HAS_GTKMM_STOCK
2171      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
2172    #else
2173        dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
2174    #endif
2175      dialog.set_default_response(Gtk::RESPONSE_CANCEL);      dialog.set_default_response(Gtk::RESPONSE_CANCEL);
2176      int response = dialog.run();      int response = dialog.run();
2177      dialog.hide();      dialog.hide();
# Line 1393  void MainWindow::on_action_file_open() Line 2185  void MainWindow::on_action_file_open()
2185      if (file_is_shared && !leaving_shared_mode_dialog()) return;      if (file_is_shared && !leaving_shared_mode_dialog()) return;
2186    
2187      Gtk::FileChooserDialog dialog(*this, _("Open file"));      Gtk::FileChooserDialog dialog(*this, _("Open file"));
2188    #if HAS_GTKMM_STOCK
2189      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
2190      dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);      dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
2191    #else
2192        dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
2193        dialog.add_button(_("_Open"), Gtk::RESPONSE_OK);
2194    #endif
2195      dialog.set_default_response(Gtk::RESPONSE_OK);      dialog.set_default_response(Gtk::RESPONSE_OK);
2196  #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2  #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
2197      Gtk::FileFilter filter;      Gtk::FileFilter filter;
# Line 1408  void MainWindow::on_action_file_open() Line 2205  void MainWindow::on_action_file_open()
2205          dialog.set_current_folder(current_gig_dir);          dialog.set_current_folder(current_gig_dir);
2206      }      }
2207      if (dialog.run() == Gtk::RESPONSE_OK) {      if (dialog.run() == Gtk::RESPONSE_OK) {
2208            dialog.hide();
2209          std::string filename = dialog.get_filename();          std::string filename = dialog.get_filename();
2210          printf("filename=%s\n", filename.c_str());          printf("filename=%s\n", filename.c_str());
2211    #ifdef GLIB_THREADS
2212          printf("on_action_file_open self=%p\n",          printf("on_action_file_open self=%p\n",
2213                 static_cast<void*>(Glib::Threads::Thread::self()));                 static_cast<void*>(Glib::Threads::Thread::self()));
2214    #else
2215            std::cout << "on_action_file_open self=" <<
2216                std::this_thread::get_id() << "\n";
2217    #endif
2218          load_file(filename.c_str());          load_file(filename.c_str());
2219          current_gig_dir = Glib::path_get_dirname(filename);          current_gig_dir = Glib::path_get_dirname(filename);
2220      }      }
# Line 1426  void MainWindow::load_file(const char* n Line 2229  void MainWindow::load_file(const char* n
2229          Glib::filename_display_basename(name) + "' ...",          Glib::filename_display_basename(name) + "' ...",
2230          *this          *this
2231      );      );
2232    #if HAS_GTKMM_SHOW_ALL_CHILDREN
2233      progress_dialog->show_all();      progress_dialog->show_all();
2234    #endif
2235      loader = new Loader(name); //FIXME: memory leak!      loader = new Loader(name); //FIXME: memory leak!
2236      loader->signal_progress().connect(      loader->signal_progress().connect(
2237          sigc::mem_fun(*this, &MainWindow::on_loader_progress));          sigc::mem_fun(*this, &MainWindow::on_loader_progress));
# Line 1460  void MainWindow::load_instrument(gig::In Line 2265  void MainWindow::load_instrument(gig::In
2265              // make sure the selected item in the "instruments" tree view is              // make sure the selected item in the "instruments" tree view is
2266              // visible (scroll to it)              // visible (scroll to it)
2267              m_TreeView.scroll_to_row(Gtk::TreePath(ToString(i)));              m_TreeView.scroll_to_row(Gtk::TreePath(ToString(i)));
2268    #if !USE_GTKMM_BUILDER
2269              // select item in instrument menu              // select item in instrument menu
2270              {              {
2271                  const std::vector<Gtk::Widget*> children =                  const std::vector<Gtk::Widget*> children =
2272                      instrument_menu->get_children();                      instrument_menu->get_children();
2273                  static_cast<Gtk::RadioMenuItem*>(children[i])->set_active();                  static_cast<Gtk::RadioMenuItem*>(children[i])->set_active();
2274              }              }
2275    #endif
2276              // update region chooser and dimension region chooser              // update region chooser and dimension region chooser
2277              m_RegionChooser.set_instrument(instr);              m_RegionChooser.set_instrument(instr);
2278              break;              break;
# Line 1480  void MainWindow::on_loader_progress() Line 2287  void MainWindow::on_loader_progress()
2287    
2288  void MainWindow::on_loader_finished()  void MainWindow::on_loader_finished()
2289  {  {
2290        loader->join();
2291      printf("Loader finished!\n");      printf("Loader finished!\n");
2292    #ifdef GLIB_THREADS
2293      printf("on_loader_finished self=%p\n",      printf("on_loader_finished self=%p\n",
2294             static_cast<void*>(Glib::Threads::Thread::self()));             static_cast<void*>(Glib::Threads::Thread::self()));
2295    #else
2296        std::cout << "on_loader_finished self=" <<
2297            std::this_thread::get_id() << "\n";
2298    #endif
2299      load_gig(loader->gig, loader->filename.c_str());      load_gig(loader->gig, loader->filename.c_str());
2300      progress_dialog->hide();      progress_dialog->hide();
2301  }  }
2302    
2303  void MainWindow::on_loader_error()  void MainWindow::on_loader_error()
2304  {  {
2305        loader->join();
2306      Glib::ustring txt = _("Could not load file: ") + loader->error_message;      Glib::ustring txt = _("Could not load file: ") + loader->error_message;
2307      Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);      Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);
2308      msg.run();      msg.run();
# Line 1537  bool MainWindow::file_save() Line 2351  bool MainWindow::file_save()
2351          Glib::filename_display_basename(this->filename) + "' ...",          Glib::filename_display_basename(this->filename) + "' ...",
2352          *this          *this
2353      );      );
2354    #if HAS_GTKMM_SHOW_ALL_CHILDREN
2355      progress_dialog->show_all();      progress_dialog->show_all();
2356    #endif
2357      saver = new Saver(this->file); //FIXME: memory leak!      saver = new Saver(this->file); //FIXME: memory leak!
2358      saver->signal_progress().connect(      saver->signal_progress().connect(
2359          sigc::mem_fun(*this, &MainWindow::on_saver_progress));          sigc::mem_fun(*this, &MainWindow::on_saver_progress));
# Line 1557  void MainWindow::on_saver_progress() Line 2373  void MainWindow::on_saver_progress()
2373    
2374  void MainWindow::on_saver_error()  void MainWindow::on_saver_error()
2375  {  {
2376        saver->join();
2377      file_structure_changed_signal.emit(this->file);      file_structure_changed_signal.emit(this->file);
2378      Glib::ustring txt = _("Could not save file: ") + saver->error_message;      Glib::ustring txt = _("Could not save file: ") + saver->error_message;
2379      Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);      Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);
# Line 1565  void MainWindow::on_saver_error() Line 2382  void MainWindow::on_saver_error()
2382    
2383  void MainWindow::on_saver_finished()  void MainWindow::on_saver_finished()
2384  {  {
2385        saver->join();
2386      this->file = saver->gig;      this->file = saver->gig;
2387      this->filename = saver->filename;      this->filename = saver->filename;
2388      current_gig_dir = Glib::path_get_dirname(filename);      current_gig_dir = Glib::path_get_dirname(filename);
# Line 1590  void MainWindow::on_action_file_save_as( Line 2408  void MainWindow::on_action_file_save_as(
2408  bool MainWindow::file_save_as()  bool MainWindow::file_save_as()
2409  {  {
2410      Gtk::FileChooserDialog dialog(*this, _("Save as"), Gtk::FILE_CHOOSER_ACTION_SAVE);      Gtk::FileChooserDialog dialog(*this, _("Save as"), Gtk::FILE_CHOOSER_ACTION_SAVE);
2411    #if HAS_GTKMM_STOCK
2412      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
2413      dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);      dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);
2414    #else
2415        dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
2416        dialog.add_button(_("_Save"), Gtk::RESPONSE_OK);
2417    #endif
2418      dialog.set_default_response(Gtk::RESPONSE_OK);      dialog.set_default_response(Gtk::RESPONSE_OK);
2419      dialog.set_do_overwrite_confirmation();      dialog.set_do_overwrite_confirmation();
2420    
# Line 1620  bool MainWindow::file_save_as() Line 2443  bool MainWindow::file_save_as()
2443      }      }
2444    
2445      // show warning in the dialog      // show warning in the dialog
2446      Gtk::HBox descriptionArea;      HBox descriptionArea;
2447      descriptionArea.set_spacing(15);      descriptionArea.set_spacing(15);
2448      Gtk::Image warningIcon;      Gtk::Image warningIcon;
2449      warningIcon.set_from_icon_name("dialog-warning",      warningIcon.set_from_icon_name("dialog-warning",
# Line 1641  bool MainWindow::file_save_as() Line 2464  bool MainWindow::file_save_as()
2464            "same .gig file will end up in corrupted sample wave data!\n")            "same .gig file will end up in corrupted sample wave data!\n")
2465      );      );
2466      descriptionArea.pack_start(description);      descriptionArea.pack_start(description);
2467    #if USE_GTKMM_BOX
2468        dialog.get_content_area()->pack_start(descriptionArea, Gtk::PACK_SHRINK);
2469    #else
2470      dialog.get_vbox()->pack_start(descriptionArea, Gtk::PACK_SHRINK);      dialog.get_vbox()->pack_start(descriptionArea, Gtk::PACK_SHRINK);
2471    #endif
2472    #if HAS_GTKMM_SHOW_ALL_CHILDREN
2473      descriptionArea.show_all();      descriptionArea.show_all();
2474    #endif
2475    
2476      if (dialog.run() == Gtk::RESPONSE_OK) {      if (dialog.run() == Gtk::RESPONSE_OK) {
2477            dialog.hide();
2478          std::string filename = dialog.get_filename();          std::string filename = dialog.get_filename();
2479          if (!Glib::str_has_suffix(filename, ".gig")) {          if (!Glib::str_has_suffix(filename, ".gig")) {
2480              filename += ".gig";              filename += ".gig";
# Line 1656  bool MainWindow::file_save_as() Line 2486  bool MainWindow::file_save_as()
2486              Glib::filename_display_basename(filename) + "' ...",              Glib::filename_display_basename(filename) + "' ...",
2487              *this              *this
2488          );          );
2489    #if HAS_GTKMM_SHOW_ALL_CHILDREN
2490          progress_dialog->show_all();          progress_dialog->show_all();
2491    #endif
2492    
2493          saver = new Saver(file, filename); //FIXME: memory leak!          saver = new Saver(file, filename); //FIXME: memory leak!
2494          saver->signal_progress().connect(          saver->signal_progress().connect(
# Line 1780  void MainWindow::on_action_warn_user_on_ Line 2612  void MainWindow::on_action_warn_user_on_
2612          !Settings::singleton()->warnUserOnExtensions;          !Settings::singleton()->warnUserOnExtensions;
2613  }  }
2614    
2615    void MainWindow::on_action_show_tooltips() {
2616        Settings::singleton()->showTooltips =
2617            !Settings::singleton()->showTooltips;
2618    
2619        on_show_tooltips_changed();
2620    }
2621    
2622    void MainWindow::on_show_tooltips_changed() {
2623        const bool b = Settings::singleton()->showTooltips;
2624    
2625        dimreg_label.set_has_tooltip(b);
2626        dimreg_all_regions.set_has_tooltip(b);
2627        dimreg_all_dimregs.set_has_tooltip(b);
2628        dimreg_stereo.set_has_tooltip(b);
2629    
2630        // Not doing this here, we let onQueryTreeViewTooltip() handle this per cell
2631        //m_TreeView.set_has_tooltip(b);
2632    
2633        m_TreeViewSamples.set_has_tooltip(b);
2634        m_TreeViewScripts.set_has_tooltip(b);
2635    
2636        set_has_tooltip(b);
2637    }
2638    
2639  void MainWindow::on_action_sync_sampler_instrument_selection() {  void MainWindow::on_action_sync_sampler_instrument_selection() {
2640      Settings::singleton()->syncSamplerInstrumentSelection =      Settings::singleton()->syncSamplerInstrumentSelection =
2641          !Settings::singleton()->syncSamplerInstrumentSelection;          !Settings::singleton()->syncSamplerInstrumentSelection;
# Line 1799  void MainWindow::on_action_help_about() Line 2655  void MainWindow::on_action_help_about()
2655      dialog.set_name("Gigedit");      dialog.set_name("Gigedit");
2656  #endif  #endif
2657      dialog.set_version(VERSION);      dialog.set_version(VERSION);
2658      dialog.set_copyright("Copyright (C) 2006-2017 Andreas Persson");      dialog.set_copyright("Copyright (C) 2006-2019 Andreas Persson");
2659      const std::string sComment =      const std::string sComment =
2660          _("Built " __DATE__ "\nUsing ") +          _("Built " __DATE__ "\nUsing ") +
2661          ::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" +          ::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" +
# Line 1810  void MainWindow::on_action_help_about() Line 2666  void MainWindow::on_action_help_about()
2666              "backup your Gigasampler/GigaStudio files before editing them with "              "backup your Gigasampler/GigaStudio files before editing them with "
2667              "this application.\n"              "this application.\n"
2668              "\n"              "\n"
2669              "Please report bugs to: http://bugs.linuxsampler.org"              "Please report bugs to: https://bugs.linuxsampler.org"
2670          );          );
2671      dialog.set_comments(sComment.c_str());      dialog.set_comments(sComment.c_str());
2672      dialog.set_website("http://www.linuxsampler.org");      dialog.set_website("https://www.linuxsampler.org");
2673      dialog.set_website_label("http://www.linuxsampler.org");      dialog.set_website_label("https://www.linuxsampler.org");
2674        dialog.set_position(Gtk::WIN_POS_CENTER);
2675      dialog.run();      dialog.run();
2676  }  }
2677    
# Line 1836  PropDialog::PropDialog() Line 2693  PropDialog::PropDialog()
2693        eSourceForm(_("Source form")),        eSourceForm(_("Source form")),
2694        eCommissioned(_("Commissioned")),        eCommissioned(_("Commissioned")),
2695        eSubject(_("Subject")),        eSubject(_("Subject")),
2696    #if HAS_GTKMM_STOCK
2697        quitButton(Gtk::Stock::CLOSE),        quitButton(Gtk::Stock::CLOSE),
2698    #else
2699          quitButton(_("_Close")),
2700    #endif
2701        table(2, 1),        table(2, 1),
2702        m_file(NULL)        m_file(NULL)
2703  {  {
2704        if (!Settings::singleton()->autoRestoreWindowDimension) {
2705            set_default_size(470, 390);
2706            set_position(Gtk::WIN_POS_MOUSE);
2707        }
2708    
2709      set_title(_("File Properties"));      set_title(_("File Properties"));
2710      eName.set_width_chars(50);      eName.set_width_chars(50);
2711    
2712        connect(eFileFormat, &PropDialog::set_FileFormat);
2713      connect(eName, &DLS::Info::Name);      connect(eName, &DLS::Info::Name);
2714      connect(eCreationDate, &DLS::Info::CreationDate);      connect(eCreationDate, &DLS::Info::CreationDate);
2715      connect(eComments, &DLS::Info::Comments);      connect(eComments, &DLS::Info::Comments);
# Line 1878  PropDialog::PropDialog() Line 2745  PropDialog::PropDialog()
2745      table.add(eCommissioned);      table.add(eCommissioned);
2746      table.add(eSubject);      table.add(eSubject);
2747    
2748    #if USE_GTKMM_GRID
2749        table.set_column_spacing(5);
2750    #else
2751      table.set_col_spacings(5);      table.set_col_spacings(5);
2752    #endif
2753    
2754      add(vbox);      add(vbox);
2755    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24)
2756        table.set_margin(5);
2757    #else
2758      table.set_border_width(5);      table.set_border_width(5);
2759    #endif
2760      vbox.add(table);      vbox.add(table);
2761      vbox.pack_start(buttonBox, Gtk::PACK_SHRINK);      vbox.pack_start(buttonBox, Gtk::PACK_SHRINK);
2762      buttonBox.set_layout(Gtk::BUTTONBOX_END);      buttonBox.set_layout(Gtk::BUTTONBOX_END);
2763    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24)
2764        buttonBox.set_margin(5);
2765    #else
2766      buttonBox.set_border_width(5);      buttonBox.set_border_width(5);
2767    #endif
2768      buttonBox.show();      buttonBox.show();
2769      buttonBox.pack_start(quitButton);      buttonBox.pack_start(quitButton);
2770      quitButton.set_can_default();      quitButton.set_can_default();
2771      quitButton.grab_focus();      quitButton.grab_focus();
2772      quitButton.signal_clicked().connect(      quitButton.signal_clicked().connect(
2773          sigc::mem_fun(*this, &PropDialog::hide));          sigc::mem_fun(*this, &PropDialog::hide));
     eFileFormat.signal_value_changed().connect(  
         sigc::mem_fun(*this, &PropDialog::onFileFormatChanged));  
2774    
2775      quitButton.show();      quitButton.show();
2776      vbox.show();      vbox.show();
2777    #if HAS_GTKMM_SHOW_ALL_CHILDREN
2778      show_all_children();      show_all_children();
2779    #endif
2780  }  }
2781    
2782  void PropDialog::set_file(gig::File* file)  void PropDialog::set_file(gig::File* file)
2783  {  {
2784      m_file = file;      m_file = file;
2785        update(file->pInfo);
2786    
2787      // update file format version combo box      // update file format version combo box
2788      const std::string sGiga = "Gigasampler/GigaStudio v";      const std::string sGiga = "Gigasampler/GigaStudio v";
# Line 1909  void PropDialog::set_file(gig::File* fil Line 2790  void PropDialog::set_file(gig::File* fil
2790      std::vector<std::string> txts;      std::vector<std::string> txts;
2791      std::vector<int> values;      std::vector<int> values;
2792      txts.push_back(sGiga + "2"); values.push_back(2);      txts.push_back(sGiga + "2"); values.push_back(2);
2793      txts.push_back(sGiga + "3/v4"); values.push_back(3);      txts.push_back(sGiga + "3"); values.push_back(3);
2794      if (major != 2 && major != 3) {      txts.push_back(sGiga + "4"); values.push_back(4);
2795        if (major < 2 || major > 4) {
2796          txts.push_back(sGiga + ToString(major)); values.push_back(major);          txts.push_back(sGiga + ToString(major)); values.push_back(major);
2797      }      }
2798      std::vector<const char*> texts;      std::vector<const char*> texts;
2799      for (int i = 0; i < txts.size(); ++i) texts.push_back(txts[i].c_str());      for (int i = 0; i < txts.size(); ++i) texts.push_back(txts[i].c_str());
2800      texts.push_back(NULL); values.push_back(0);      texts.push_back(NULL); values.push_back(0);
2801    
2802        update_model++;
2803      eFileFormat.set_choices(&texts[0], &values[0]);      eFileFormat.set_choices(&texts[0], &values[0]);
2804      eFileFormat.set_value(major);      eFileFormat.set_value(major);
2805        update_model--;
2806  }  }
2807    
2808  void PropDialog::onFileFormatChanged() {  void PropDialog::set_FileFormat(int value)
     const int major = eFileFormat.get_value();  
     if (m_file) m_file->pVersion->major = major;  
 }  
   
 void PropDialog::set_info(DLS::Info* info)  
2809  {  {
2810      update(info);      m_file->pVersion->major = value;
2811  }  }
2812    
2813    
# Line 1959  void InstrumentProps::set_MIDIProgram(ui Line 2839  void InstrumentProps::set_MIDIProgram(ui
2839  }  }
2840    
2841  InstrumentProps::InstrumentProps() :  InstrumentProps::InstrumentProps() :
2842    #if HAS_GTKMM_STOCK
2843      quitButton(Gtk::Stock::CLOSE),      quitButton(Gtk::Stock::CLOSE),
2844    #else
2845        quitButton(_("_Close")),
2846    #endif
2847      table(2,1),      table(2,1),
2848      eName(_("Name")),      eName(_("Name")),
2849      eIsDrum(_("Is drum")),      eIsDrum(_("Is drum")),
# Line 1969  InstrumentProps::InstrumentProps() : Line 2853  InstrumentProps::InstrumentProps() :
2853      eGainPlus6(_("Gain +6dB"), eAttenuation, -6),      eGainPlus6(_("Gain +6dB"), eAttenuation, -6),
2854      eEffectSend(_("Effect send"), 0, 65535),      eEffectSend(_("Effect send"), 0, 65535),
2855      eFineTune(_("Fine tune"), -8400, 8400),      eFineTune(_("Fine tune"), -8400, 8400),
2856      ePitchbendRange(_("Pitchbend range"), 0, 12),      ePitchbendRange(_("Pitchbend range"), 0, 48),
2857      ePianoReleaseMode(_("Piano release mode")),      ePianoReleaseMode(_("Piano release mode")),
2858      eDimensionKeyRangeLow(_("Keyswitching range low")),      eDimensionKeyRangeLow(_("Keyswitching range low")),
2859      eDimensionKeyRangeHigh(_("Keyswitching range high"))      eDimensionKeyRangeHigh(_("Keyswitching range high"))
2860  {  {
2861        if (!Settings::singleton()->autoRestoreWindowDimension) {
2862            //set_default_size(470, 390);
2863            set_position(Gtk::WIN_POS_MOUSE);
2864        }
2865    
2866      set_title(_("Instrument Properties"));      set_title(_("Instrument Properties"));
2867    
2868      eDimensionKeyRangeLow.set_tip(      eDimensionKeyRangeLow.set_tip(
# Line 2000  InstrumentProps::InstrumentProps() : Line 2889  InstrumentProps::InstrumentProps() :
2889    
2890      eName.signal_value_changed().connect(sig_name_changed.make_slot());      eName.signal_value_changed().connect(sig_name_changed.make_slot());
2891    
2892    #if USE_GTKMM_GRID
2893        table.set_column_spacing(5);
2894    #else
2895      table.set_col_spacings(5);      table.set_col_spacings(5);
2896    #endif
2897    
2898      table.add(eName);      table.add(eName);
2899      table.add(eIsDrum);      table.add(eIsDrum);
# Line 2016  InstrumentProps::InstrumentProps() : Line 2909  InstrumentProps::InstrumentProps() :
2909      table.add(eDimensionKeyRangeHigh);      table.add(eDimensionKeyRangeHigh);
2910    
2911      add(vbox);      add(vbox);
2912    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24)
2913        table.set_margin(5);
2914    #else
2915      table.set_border_width(5);      table.set_border_width(5);
2916    #endif
2917      vbox.pack_start(table);      vbox.pack_start(table);
2918      table.show();      table.show();
2919      vbox.pack_start(buttonBox, Gtk::PACK_SHRINK);      vbox.pack_start(buttonBox, Gtk::PACK_SHRINK);
2920      buttonBox.set_layout(Gtk::BUTTONBOX_END);      buttonBox.set_layout(Gtk::BUTTONBOX_END);
2921    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24)
2922        buttonBox.set_margin(5);
2923    #else
2924      buttonBox.set_border_width(5);      buttonBox.set_border_width(5);
2925    #endif
2926      buttonBox.show();      buttonBox.show();
2927      buttonBox.pack_start(quitButton);      buttonBox.pack_start(quitButton);
2928      quitButton.set_can_default();      quitButton.set_can_default();
# Line 2032  InstrumentProps::InstrumentProps() : Line 2933  InstrumentProps::InstrumentProps() :
2933    
2934      quitButton.show();      quitButton.show();
2935      vbox.show();      vbox.show();
2936    #if HAS_GTKMM_SHOW_ALL_CHILDREN
2937      show_all_children();      show_all_children();
2938    #endif
2939  }  }
2940    
2941  void InstrumentProps::set_instrument(gig::Instrument* instrument)  void InstrumentProps::set_instrument(gig::Instrument* instrument)
# Line 2077  void MainWindow::updateSampleRefCountMap Line 2980  void MainWindow::updateSampleRefCountMap
2980      }      }
2981  }  }
2982    
2983    bool MainWindow::onQueryTreeViewTooltip(int x, int y, bool keyboardTip, const Glib::RefPtr<Gtk::Tooltip>& tooltip) {
2984        Gtk::TreeModel::iterator iter;
2985        if (!m_TreeView.get_tooltip_context_iter(x, y, keyboardTip, iter)) {
2986            return false;
2987        }
2988        Gtk::TreeModel::Path path(iter);
2989        Gtk::TreeModel::Row row = *iter;
2990        Gtk::TreeViewColumn* pointedColumn = NULL;
2991        // resolve the precise table column the mouse points to
2992        {
2993            Gtk::TreeModel::Path path; // unused
2994            int cellX, cellY; // unused
2995            m_TreeView.get_path_at_pos(x, y, path, pointedColumn, cellX, cellY);
2996        }
2997        Gtk::TreeViewColumn* scriptsColumn = m_TreeView.get_column(2);
2998        if (pointedColumn == scriptsColumn) { // mouse hovers scripts column ...
2999            // show the script(s) assigned to the hovered instrument as tooltip
3000            tooltip->set_markup( row[m_Columns.m_col_tooltip] );
3001            m_TreeView.set_tooltip_cell(tooltip, &path, scriptsColumn, NULL);
3002        } else {
3003            // if beginners' tooltips is disabled then don't show the following one
3004            if (!Settings::singleton()->showTooltips)
3005                return false;
3006            // yeah, a beginners tooltip
3007            tooltip->set_text(_(
3008                "Right click here for actions on instruments & MIDI Rules. "
3009                "Drag & drop to change the order of instruments."
3010            ));
3011            m_TreeView.set_tooltip_cell(tooltip, &path, pointedColumn, NULL);
3012        }
3013        return true;
3014    }
3015    
3016    static Glib::ustring scriptTooltipFor(gig::Instrument* instrument, int index) {
3017        Glib::ustring name(gig_to_utf8(instrument->pInfo->Name));
3018        const int iScriptSlots = instrument->ScriptSlotCount();
3019        Glib::ustring tooltip = "<u>(" + ToString(index) + ") “"  + name + "”</u>\n\n";
3020        if (!iScriptSlots)
3021            tooltip += "<span foreground='red'><i>No script assigned</i></span>";
3022        else {
3023            for (int i = 0; i < iScriptSlots; ++i) {
3024                tooltip += "• " + ToString(i+1) + ". Script: “<span foreground='#46DEFF'><b>" +
3025                           instrument->GetScriptOfSlot(i)->Name + "</b></span>”";
3026                if (i + 1 < iScriptSlots) tooltip += "\n\n";
3027            }
3028        }
3029        return tooltip;
3030    }
3031    
3032  void MainWindow::load_gig(gig::File* gig, const char* filename, bool isSharedInstrument)  void MainWindow::load_gig(gig::File* gig, const char* filename, bool isSharedInstrument)
3033  {  {
3034      file = 0;      file = 0;
# Line 2091  void MainWindow::load_gig(gig::File* gig Line 3043  void MainWindow::load_gig(gig::File* gig
3043      file_is_changed = false;      file_is_changed = false;
3044    
3045      propDialog.set_file(gig);      propDialog.set_file(gig);
     propDialog.set_info(gig->pInfo);  
3046    
3047      instrument_name_connection.block();      instrument_name_connection.block();
3048      int index = 0;      int index = 0;
3049      for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ;      for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ;
3050           instrument = gig->GetNextInstrument(), ++index) {           instrument = gig->GetNextInstrument(), ++index) {
3051          Glib::ustring name(gig_to_utf8(instrument->pInfo->Name));          Glib::ustring name(gig_to_utf8(instrument->pInfo->Name));
3052            const int iScriptSlots = instrument->ScriptSlotCount();
3053    
3054          Gtk::TreeModel::iterator iter = m_refTreeModel->append();          Gtk::TreeModel::iterator iter = m_refTreeModel->append();
3055          Gtk::TreeModel::Row row = *iter;          Gtk::TreeModel::Row row = *iter;
3056          row[m_Columns.m_col_nr] = index;          row[m_Columns.m_col_nr] = index;
3057          row[m_Columns.m_col_name] = name;          row[m_Columns.m_col_name] = name;
3058          row[m_Columns.m_col_instr] = instrument;          row[m_Columns.m_col_instr] = instrument;
3059            row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : "";
3060            row[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index);
3061    
3062    #if !USE_GTKMM_BUILDER
3063          add_instrument_to_menu(name);          add_instrument_to_menu(name);
3064    #endif
3065      }      }
3066      instrument_name_connection.unblock();      instrument_name_connection.unblock();
3067    #if !USE_GTKMM_BUILDER
3068      uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments")->show();      uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments")->show();
3069    #endif
3070    
3071      updateSampleRefCountMap(gig);      updateSampleRefCountMap(gig);
3072    
# Line 2179  bool MainWindow::instr_props_set_instrum Line 3137  bool MainWindow::instr_props_set_instrum
3137          instrumentProps.hide();          instrumentProps.hide();
3138          return false;          return false;
3139      }      }
3140      Gtk::TreeModel::const_iterator it = m_refTreeModel->get_iter(rows[0]);      //NOTE: was const_iterator before, which did not compile with GTKMM4 development branch, probably going to be fixed before final GTKMM4 release though.
3141        Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]);
3142      if (it) {      if (it) {
3143          Gtk::TreeModel::Row row = *it;          Gtk::TreeModel::Row row = *it;
3144          gig::Instrument* instrument = row[m_Columns.m_col_instr];          gig::Instrument* instrument = row[m_Columns.m_col_instr];
# Line 2196  bool MainWindow::instr_props_set_instrum Line 3155  bool MainWindow::instr_props_set_instrum
3155      } else {      } else {
3156          instrumentProps.hide();          instrumentProps.hide();
3157      }      }
3158      return it;      //NOTE: explicit boolean cast required for GTKMM4 development branch here
3159        return it ? true : false;
3160  }  }
3161    
3162  void MainWindow::show_instr_props()  void MainWindow::show_instr_props()
# Line 2215  void MainWindow::instr_name_changed_by_i Line 3175  void MainWindow::instr_name_changed_by_i
3175      gig::Instrument* instrument = row[m_Columns.m_col_instr];      gig::Instrument* instrument = row[m_Columns.m_col_instr];
3176      Glib::ustring gigname(gig_to_utf8(instrument->pInfo->Name));      Glib::ustring gigname(gig_to_utf8(instrument->pInfo->Name));
3177      if (gigname != name) {      if (gigname != name) {
3178            Gtk::TreeModel::Path path(*it);
3179            const int index = path[0];
3180          row[m_Columns.m_col_name] = gigname;          row[m_Columns.m_col_name] = gigname;
3181            row[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index);
3182      }      }
3183  }  }
3184    
# Line 2242  void MainWindow::show_script_slots() { Line 3205  void MainWindow::show_script_slots() {
3205    
3206      ScriptSlots* window = new ScriptSlots;      ScriptSlots* window = new ScriptSlots;
3207      window->setInstrument(instrument);      window->setInstrument(instrument);
3208        window->signal_script_slots_changed().connect(
3209            sigc::mem_fun(*this, &MainWindow::onScriptSlotsModified)
3210        );
3211      //window->reparent(*this);      //window->reparent(*this);
3212      window->show();      window->show();
3213  }  }
3214    
3215    void MainWindow::onScriptSlotsModified(gig::Instrument* pInstrument) {
3216        if (!pInstrument) return;
3217        const int iScriptSlots = pInstrument->ScriptSlotCount();
3218    
3219        //NOTE: This is a big mess! Sometimes GTK requires m_TreeView.get_model(), here we need m_refTreeModelFilter->get_model(), otherwise accessing children below causes an error!
3220        //Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model();
3221        Glib::RefPtr<Gtk::TreeModel> model = m_refTreeModelFilter->get_model();
3222    
3223        for (int i = 0; i < model->children().size(); ++i) {
3224            Gtk::TreeModel::Row row = model->children()[i];
3225            if (row[m_Columns.m_col_instr] != pInstrument) continue;
3226            row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : "";
3227            row[m_Columns.m_col_tooltip] = scriptTooltipFor(pInstrument, i);
3228            break;
3229        }
3230    
3231        // causes the sampler to reload the instrument with the new script
3232        on_sel_change();
3233    }
3234    
3235    void MainWindow::assignScript(gig::Script* pScript) {
3236        if (!pScript) {
3237            printf("assignScript() : !script\n");
3238            return;
3239        }
3240        printf("assignScript('%s')\n", pScript->Name.c_str());
3241    
3242        gig::Instrument* pInstrument = get_instrument();
3243        if (!pInstrument) {
3244            printf("!instrument\n");
3245            return;
3246        }
3247    
3248        pInstrument->AddScriptSlot(pScript);
3249    
3250        onScriptSlotsModified(pInstrument);
3251    }
3252    
3253    void MainWindow::dropAllScriptSlots() {
3254        gig::Instrument* pInstrument = get_instrument();
3255        if (!pInstrument) {
3256            printf("!instrument\n");
3257            return;
3258        }
3259    
3260        const int iScriptSlots = pInstrument->ScriptSlotCount();
3261        for (int i = iScriptSlots - 1; i >= 0; --i)
3262            pInstrument->RemoveScriptSlot(i);
3263    
3264        onScriptSlotsModified(pInstrument);
3265    }
3266    
3267  void MainWindow::on_action_refresh_all() {  void MainWindow::on_action_refresh_all() {
3268      __refreshEntireGUI();      __refreshEntireGUI();
3269  }  }
3270    
3271  void MainWindow::on_action_view_status_bar() {  void MainWindow::on_action_view_status_bar() {
3272    #if USE_GLIB_ACTION
3273        bool active = false;
3274        m_actionToggleStatusBar->get_state(active);
3275        // for some reason toggle state does not change automatically
3276        active = !active;
3277        m_actionToggleStatusBar->change_state(active);
3278        if (active)
3279            m_StatusBar.show();
3280        else
3281            m_StatusBar.hide();
3282    #else
3283      Gtk::CheckMenuItem* item =      Gtk::CheckMenuItem* item =
3284          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar"));          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar"));
3285      if (!item) {      if (!item) {
# Line 2259  void MainWindow::on_action_view_status_b Line 3288  void MainWindow::on_action_view_status_b
3288      }      }
3289      if (item->get_active()) m_StatusBar.show();      if (item->get_active()) m_StatusBar.show();
3290      else                    m_StatusBar.hide();      else                    m_StatusBar.hide();
3291    #endif
3292  }  }
3293    
3294  void MainWindow::on_auto_restore_win_dim() {  void MainWindow::on_auto_restore_win_dim() {
3295    #if USE_GLIB_ACTION
3296        bool active = false;
3297        m_actionToggleRestoreWinDim->get_state(active);
3298        // for some reason toggle state does not change automatically
3299        active = !active;
3300        m_actionToggleRestoreWinDim->change_state(active);
3301        Settings::singleton()->autoRestoreWindowDimension = active;
3302    #else
3303      Gtk::CheckMenuItem* item =      Gtk::CheckMenuItem* item =
3304          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/AutoRestoreWinDim"));          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/AutoRestoreWinDim"));
3305      if (!item) {      if (!item) {
# Line 2269  void MainWindow::on_auto_restore_win_dim Line 3307  void MainWindow::on_auto_restore_win_dim
3307          return;          return;
3308      }      }
3309      Settings::singleton()->autoRestoreWindowDimension = item->get_active();      Settings::singleton()->autoRestoreWindowDimension = item->get_active();
3310    #endif
3311  }  }
3312    
3313  void MainWindow::on_save_with_temporary_file() {  void MainWindow::on_save_with_temporary_file() {
3314    #if USE_GLIB_ACTION
3315        bool active = false;
3316        m_actionToggleSaveWithTempFile->get_state(active);
3317        // for some reason toggle state does not change automatically
3318        active = !active;
3319        m_actionToggleSaveWithTempFile->change_state(active);
3320        Settings::singleton()->saveWithTemporaryFile = active;
3321    #else
3322      Gtk::CheckMenuItem* item =      Gtk::CheckMenuItem* item =
3323          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuSettings/SaveWithTemporaryFile"));          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuSettings/SaveWithTemporaryFile"));
3324      if (!item) {      if (!item) {
# Line 2279  void MainWindow::on_save_with_temporary_ Line 3326  void MainWindow::on_save_with_temporary_
3326          return;          return;
3327      }      }
3328      Settings::singleton()->saveWithTemporaryFile = item->get_active();      Settings::singleton()->saveWithTemporaryFile = item->get_active();
3329    #endif
3330  }  }
3331    
3332  bool MainWindow::is_copy_samples_unity_note_enabled() const {  bool MainWindow::is_copy_samples_unity_note_enabled() const {
3333    #if USE_GLIB_ACTION
3334        bool active = false;
3335        m_actionToggleCopySampleUnity->get_state(active);
3336        return active;
3337    #else
3338      Gtk::CheckMenuItem* item =      Gtk::CheckMenuItem* item =
3339          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity"));          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity"));
3340      if (!item) {      if (!item) {
# Line 2289  bool MainWindow::is_copy_samples_unity_n Line 3342  bool MainWindow::is_copy_samples_unity_n
3342          return true;          return true;
3343      }      }
3344      return item->get_active();      return item->get_active();
3345    #endif
3346  }  }
3347    
3348  bool MainWindow::is_copy_samples_fine_tune_enabled() const {  bool MainWindow::is_copy_samples_fine_tune_enabled() const {
3349    #if USE_GLIB_ACTION
3350        bool active = false;
3351        m_actionToggleCopySampleTune->get_state(active);
3352        return active;
3353    #else
3354      Gtk::CheckMenuItem* item =      Gtk::CheckMenuItem* item =
3355          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleTune"));          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleTune"));
3356      if (!item) {      if (!item) {
# Line 2299  bool MainWindow::is_copy_samples_fine_tu Line 3358  bool MainWindow::is_copy_samples_fine_tu
3358          return true;          return true;
3359      }      }
3360      return item->get_active();      return item->get_active();
3361    #endif
3362  }  }
3363    
3364  bool MainWindow::is_copy_samples_loop_enabled() const {  bool MainWindow::is_copy_samples_loop_enabled() const {
3365    #if USE_GLIB_ACTION
3366        bool active = false;
3367        m_actionToggleCopySampleLoop->get_state(active);
3368        return active;
3369    #else
3370      Gtk::CheckMenuItem* item =      Gtk::CheckMenuItem* item =
3371          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleLoop"));          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleLoop"));
3372      if (!item) {      if (!item) {
# Line 2309  bool MainWindow::is_copy_samples_loop_en Line 3374  bool MainWindow::is_copy_samples_loop_en
3374          return true;          return true;
3375      }      }
3376      return item->get_active();      return item->get_active();
3377    #endif
3378  }  }
3379    
3380  void MainWindow::on_button_release(GdkEventButton* button)  #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2
3381  {  bool MainWindow::on_button_release(Gdk::EventButton& _button) {
3382        GdkEventButton* button = _button.gobj();
3383    #else
3384    void MainWindow::on_button_release(GdkEventButton* button) {
3385    #endif
3386      if (button->type == GDK_2BUTTON_PRESS) {      if (button->type == GDK_2BUTTON_PRESS) {
3387          show_instr_props();          show_instr_props();
3388      } else if (button->type == GDK_BUTTON_PRESS && button->button == 3) {      } else if (button->type == GDK_BUTTON_PRESS && button->button == 3) {
3389          // gig v2 files have no midi rules          // gig v2 files have no midi rules
3390          const bool bEnabled = !(file->pVersion && file->pVersion->major == 2);          const bool bEnabled = !(file->pVersion && file->pVersion->major == 2);
3391    #if USE_GTKMM_BUILDER
3392            m_actionMIDIRules->property_enabled() = bEnabled;
3393    #else
3394          static_cast<Gtk::MenuItem*>(          static_cast<Gtk::MenuItem*>(
3395              uiManager->get_widget("/MenuBar/MenuInstrument/MidiRules"))->set_sensitive(              uiManager->get_widget("/MenuBar/MenuInstrument/MidiRules"))->set_sensitive(
3396                  bEnabled                  bEnabled
# Line 2326  void MainWindow::on_button_release(GdkEv Line 3399  void MainWindow::on_button_release(GdkEv
3399              uiManager->get_widget("/PopupMenu/MidiRules"))->set_sensitive(              uiManager->get_widget("/PopupMenu/MidiRules"))->set_sensitive(
3400                  bEnabled                  bEnabled
3401              );              );
3402    #endif
3403          popup_menu->popup(button->button, button->time);          popup_menu->popup(button->button, button->time);
3404      }      }
3405    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2
3406        return false;
3407    #endif
3408  }  }
3409    
3410    #if !USE_GTKMM_BUILDER
3411  void MainWindow::on_instrument_selection_change(Gtk::RadioMenuItem* item) {  void MainWindow::on_instrument_selection_change(Gtk::RadioMenuItem* item) {
3412      if (item->get_active()) {      if (item->get_active()) {
3413          const std::vector<Gtk::Widget*> children =          const std::vector<Gtk::Widget*> children =
# Line 2344  void MainWindow::on_instrument_selection Line 3422  void MainWindow::on_instrument_selection
3422          }          }
3423      }      }
3424  }  }
3425    #endif
3426    
3427  void MainWindow::select_instrument(gig::Instrument* instrument) {  void MainWindow::select_instrument(gig::Instrument* instrument) {
3428      if (!instrument) return;      if (!instrument) return;
3429    
3430        //NOTE: This is a big mess! Sometimes GTK requires m_refTreeModelFilter->get_model(), here we need m_TreeView.get_model(), otherwise treeview selection below causes an error!
3431      Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model();      Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model();
3432        //Glib::RefPtr<Gtk::TreeModel> model = m_refTreeModelFilter->get_model();
3433    
3434      for (int i = 0; i < model->children().size(); ++i) {      for (int i = 0; i < model->children().size(); ++i) {
3435          Gtk::TreeModel::Row row = model->children()[i];          Gtk::TreeModel::Row row = model->children()[i];
3436          if (row[m_Columns.m_col_instr] == instrument) {          if (row[m_Columns.m_col_instr] == instrument) {
3437              // select and show the respective instrument in the list view              // select and show the respective instrument in the list view
3438              show_intruments_tab();              show_intruments_tab();
3439              m_TreeView.get_selection()->unselect_all();              m_TreeView.get_selection()->unselect_all();
3440                
3441    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24)
3442                auto iterSel = model->children()[i].get_iter();
3443                m_TreeView.get_selection()->select(iterSel);
3444    #else
3445              m_TreeView.get_selection()->select(model->children()[i]);              m_TreeView.get_selection()->select(model->children()[i]);
3446    #endif
3447              std::vector<Gtk::TreeModel::Path> rows =              std::vector<Gtk::TreeModel::Path> rows =
3448                  m_TreeView.get_selection()->get_selected_rows();                  m_TreeView.get_selection()->get_selected_rows();
3449              if (!rows.empty())              if (!rows.empty())
# Line 2370  bool MainWindow::select_dimension_region Line 3458  bool MainWindow::select_dimension_region
3458      gig::Region* pRegion = (gig::Region*) dimRgn->GetParent();      gig::Region* pRegion = (gig::Region*) dimRgn->GetParent();
3459      gig::Instrument* pInstrument = (gig::Instrument*) pRegion->GetParent();      gig::Instrument* pInstrument = (gig::Instrument*) pRegion->GetParent();
3460    
3461        //NOTE: This is a big mess! Sometimes GTK requires m_refTreeModelFilter->get_model(), here we need m_TreeView.get_model(), otherwise treeview selection below causes an error!
3462      Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model();      Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model();
3463        //Glib::RefPtr<Gtk::TreeModel> model = m_refTreeModelFilter->get_model();
3464    
3465      for (int i = 0; i < model->children().size(); ++i) {      for (int i = 0; i < model->children().size(); ++i) {
3466          Gtk::TreeModel::Row row = model->children()[i];          Gtk::TreeModel::Row row = model->children()[i];
3467          if (row[m_Columns.m_col_instr] == pInstrument) {          if (row[m_Columns.m_col_instr] == pInstrument) {
3468              // select and show the respective instrument in the list view              // select and show the respective instrument in the list view
3469              show_intruments_tab();              show_intruments_tab();
3470              m_TreeView.get_selection()->unselect_all();              m_TreeView.get_selection()->unselect_all();
3471    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24)
3472                auto iterSel = model->children()[i].get_iter();
3473                m_TreeView.get_selection()->select(iterSel);
3474    #else
3475              m_TreeView.get_selection()->select(model->children()[i]);              m_TreeView.get_selection()->select(model->children()[i]);
3476    #endif
3477              std::vector<Gtk::TreeModel::Path> rows =              std::vector<Gtk::TreeModel::Path> rows =
3478                  m_TreeView.get_selection()->get_selected_rows();                  m_TreeView.get_selection()->get_selected_rows();
3479              if (!rows.empty())              if (!rows.empty())
# Line 2408  void MainWindow::select_sample(gig::Samp Line 3504  void MainWindow::select_sample(gig::Samp
3504              if (rowSample[m_SamplesModel.m_col_sample] == sample) {              if (rowSample[m_SamplesModel.m_col_sample] == sample) {
3505                  show_samples_tab();                  show_samples_tab();
3506                  m_TreeViewSamples.get_selection()->unselect_all();                  m_TreeViewSamples.get_selection()->unselect_all();
3507    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24)
3508                    auto iterSel = rowGroup.children()[s].get_iter();
3509                    m_TreeViewSamples.get_selection()->select(iterSel);
3510    #else
3511                  m_TreeViewSamples.get_selection()->select(rowGroup.children()[s]);                  m_TreeViewSamples.get_selection()->select(rowGroup.children()[s]);
3512    #endif
3513                  std::vector<Gtk::TreeModel::Path> rows =                  std::vector<Gtk::TreeModel::Path> rows =
3514                      m_TreeViewSamples.get_selection()->get_selected_rows();                      m_TreeViewSamples.get_selection()->get_selected_rows();
3515                  if (rows.empty()) return;                  if (rows.empty()) return;
# Line 2419  void MainWindow::select_sample(gig::Samp Line 3520  void MainWindow::select_sample(gig::Samp
3520      }      }
3521  }  }
3522    
3523    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2
3524    bool MainWindow::on_sample_treeview_button_release(Gdk::EventButton& _button) {
3525        GdkEventButton* button = _button.gobj();
3526    #else
3527  void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) {  void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) {
3528    #endif
3529      if (button->type == GDK_BUTTON_PRESS && button->button == 3) {      if (button->type == GDK_BUTTON_PRESS && button->button == 3) {
3530          // by default if Ctrl keys is pressed down, then a mouse right-click          // by default if Ctrl keys is pressed down, then a mouse right-click
3531          // does not select the respective row, so we must assure this          // does not select the respective row, so we must assure this
# Line 2440  void MainWindow::on_sample_treeview_butt Line 3546  void MainWindow::on_sample_treeview_butt
3546              }              }
3547          }*/          }*/
3548    
3549    #if !USE_GTKMM_BUILDER
3550          Gtk::Menu* sample_popup =          Gtk::Menu* sample_popup =
3551              dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/SamplePopupMenu"));              dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/SamplePopupMenu"));
3552    #endif
3553    
3554          // update enabled/disabled state of sample popup items          // update enabled/disabled state of sample popup items
3555          Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();          Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();
3556          std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();          std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
# Line 2456  void MainWindow::on_sample_treeview_butt Line 3565  void MainWindow::on_sample_treeview_butt
3565              if (row[m_SamplesModel.m_col_sample]) nSamples++;              if (row[m_SamplesModel.m_col_sample]) nSamples++;
3566          }          }
3567    
3568    #if USE_GTKMM_BUILDER
3569            m_actionSampleProperties->property_enabled() = (n == 1);
3570            m_actionAddSample->property_enabled() = (n);
3571            m_actionAddSampleGroup->property_enabled() = (file);
3572            m_actionViewSampleRefs->property_enabled() = (nSamples == 1);
3573            m_actionRemoveSample->property_enabled() = (n);
3574            m_actionReplaceSample->property_enabled() = (nSamples == 1);
3575    #else
3576          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))->
3577              set_sensitive(n == 1);              set_sensitive(n == 1);
3578          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))->
# Line 2466  void MainWindow::on_sample_treeview_butt Line 3583  void MainWindow::on_sample_treeview_butt
3583              set_sensitive(nSamples == 1);              set_sensitive(nSamples == 1);
3584          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))->
3585              set_sensitive(n);              set_sensitive(n);
3586    #endif
3587          // show sample popup          // show sample popup
3588          sample_popup->popup(button->button, button->time);          sample_popup->popup(button->button, button->time);
3589    
3590    #if !USE_GTKMM_BUILDER
3591          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/SampleProperties"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/SampleProperties"))->
3592              set_sensitive(n == 1);              set_sensitive(n == 1);
3593          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddSample"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddSample"))->
# Line 2479  void MainWindow::on_sample_treeview_butt Line 3598  void MainWindow::on_sample_treeview_butt
3598              set_sensitive(nSamples == 1);              set_sensitive(nSamples == 1);
3599          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/RemoveSample"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/RemoveSample"))->
3600              set_sensitive(n);              set_sensitive(n);
3601    #endif
3602      }      }
3603        
3604    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2
3605        return false;
3606    #endif
3607  }  }
3608    
3609    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2
3610    bool MainWindow::on_script_treeview_button_release(Gdk::EventButton& _button) {
3611        GdkEventButton* button = _button.gobj();
3612    #else
3613  void MainWindow::on_script_treeview_button_release(GdkEventButton* button) {  void MainWindow::on_script_treeview_button_release(GdkEventButton* button) {
3614    #endif
3615      if (button->type == GDK_BUTTON_PRESS && button->button == 3) {      if (button->type == GDK_BUTTON_PRESS && button->button == 3) {
3616    #if !USE_GTKMM_BUILDER
3617          Gtk::Menu* script_popup =          Gtk::Menu* script_popup =
3618              dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/ScriptPopupMenu"));              dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/ScriptPopupMenu"));
3619    #endif
3620          // update enabled/disabled state of sample popup items          // update enabled/disabled state of sample popup items
3621          Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewScripts.get_selection();          Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewScripts.get_selection();
3622          Gtk::TreeModel::iterator it = sel->get_selected();          Gtk::TreeModel::iterator it = sel->get_selected();
# Line 2496  void MainWindow::on_script_treeview_butt Line 3627  void MainWindow::on_script_treeview_butt
3627              group_selected  = row[m_ScriptsModel.m_col_group];              group_selected  = row[m_ScriptsModel.m_col_group];
3628              script_selected = row[m_ScriptsModel.m_col_script];              script_selected = row[m_ScriptsModel.m_col_script];
3629          }          }
3630    #if USE_GTKMM_BUILDER
3631            m_actionAddScript->property_enabled() = (group_selected || script_selected);
3632            m_actionAddScriptGroup->property_enabled() = (file);
3633            m_actionEditScript->property_enabled() = (script_selected);
3634            m_actionRemoveScript->property_enabled() = (group_selected || script_selected);
3635    #else
3636          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/AddScript"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/AddScript"))->
3637              set_sensitive(group_selected || script_selected);              set_sensitive(group_selected || script_selected);
3638          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/AddScriptGroup"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/AddScriptGroup"))->
# Line 2504  void MainWindow::on_script_treeview_butt Line 3641  void MainWindow::on_script_treeview_butt
3641              set_sensitive(script_selected);                  set_sensitive(script_selected);    
3642          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/RemoveScript"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/RemoveScript"))->
3643              set_sensitive(group_selected || script_selected);              set_sensitive(group_selected || script_selected);
3644    #endif
3645          // show sample popup          // show sample popup
3646          script_popup->popup(button->button, button->time);          script_popup->popup(button->button, button->time);
3647    
3648    #if !USE_GTKMM_BUILDER
3649          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/AddScript"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/AddScript"))->
3650              set_sensitive(group_selected || script_selected);              set_sensitive(group_selected || script_selected);
3651          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/AddScriptGroup"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/AddScriptGroup"))->
# Line 2515  void MainWindow::on_script_treeview_butt Line 3654  void MainWindow::on_script_treeview_butt
3654              set_sensitive(script_selected);                  set_sensitive(script_selected);    
3655          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/RemoveScript"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/RemoveScript"))->
3656              set_sensitive(group_selected || script_selected);              set_sensitive(group_selected || script_selected);
3657    #endif
3658      }      }
3659    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2
3660        return false;
3661    #endif
3662  }  }
3663    
3664    void MainWindow::updateScriptListOfMenu() {
3665        // remove all entries from "Assign Script" menu
3666        {
3667            const std::vector<Gtk::Widget*> children = assign_scripts_menu->get_children();
3668            for (int i = 0; i < children.size(); ++i) {
3669                Gtk::Widget* child = children[i];
3670                assign_scripts_menu->remove(*child);
3671                delete child;
3672            }
3673        }
3674    
3675        int iTotalScripts = 0;
3676    
3677        if (!file) goto noScripts;
3678    
3679        // add all configured macros as menu items to the "Macro" menu
3680        for (int iGroup = 0; file->GetScriptGroup(iGroup); ++iGroup) {
3681            gig::ScriptGroup* pGroup = file->GetScriptGroup(iGroup);
3682            for (int iScript = 0; pGroup->GetScript(iScript); ++iScript, ++iTotalScripts) {
3683                gig::Script* pScript = pGroup->GetScript(iScript);
3684                std::string name = pScript->Name;
3685    
3686                Gtk::MenuItem* item = new Gtk::MenuItem(name);
3687                item->signal_activate().connect(
3688                    sigc::bind(
3689                        sigc::mem_fun(*this, &MainWindow::assignScript), pScript
3690                    )
3691                );
3692                assign_scripts_menu->append(*item);
3693                item->set_accel_path("<Scripts>/script_" + ToString(iTotalScripts));
3694                //item->set_tooltip_text(comment);
3695            }
3696        }
3697    
3698        noScripts:
3699    
3700        // if there are no macros configured at all, then show a dummy entry instead
3701        if (!iTotalScripts) {
3702            Gtk::MenuItem* item = new Gtk::MenuItem(_("No Scripts"));
3703            item->set_sensitive(false);
3704            assign_scripts_menu->append(*item);
3705        }
3706    
3707        // add separator line to menu
3708        assign_scripts_menu->append(*new Gtk::SeparatorMenuItem);
3709    
3710        {
3711            Gtk::MenuItem* item = new Gtk::MenuItem(_("Unassign All Scripts"));
3712            item->signal_activate().connect(
3713                sigc::mem_fun(*this, &MainWindow::dropAllScriptSlots)
3714            );
3715            assign_scripts_menu->append(*item);
3716            item->set_accel_path("<Scripts>/DropAllScriptSlots");
3717        }
3718    
3719    #if HAS_GTKMM_SHOW_ALL_CHILDREN
3720        assign_scripts_menu->show_all_children();
3721    #endif
3722    }
3723    
3724    #if !USE_GTKMM_BUILDER
3725  Gtk::RadioMenuItem* MainWindow::add_instrument_to_menu(  Gtk::RadioMenuItem* MainWindow::add_instrument_to_menu(
3726      const Glib::ustring& name, int position) {      const Glib::ustring& name, int position) {
3727    
# Line 2541  Gtk::RadioMenuItem* MainWindow::add_inst Line 3745  Gtk::RadioMenuItem* MainWindow::add_inst
3745              item));              item));
3746      return item;      return item;
3747  }  }
3748    #endif
3749    
3750    #if !USE_GTKMM_BUILDER
3751  void MainWindow::remove_instrument_from_menu(int index) {  void MainWindow::remove_instrument_from_menu(int index) {
3752      const std::vector<Gtk::Widget*> children =      const std::vector<Gtk::Widget*> children =
3753          instrument_menu->get_children();          instrument_menu->get_children();
# Line 2549  void MainWindow::remove_instrument_from_ Line 3755  void MainWindow::remove_instrument_from_
3755      instrument_menu->remove(*child);      instrument_menu->remove(*child);
3756      delete child;      delete child;
3757  }  }
3758    #endif
3759    
3760  void MainWindow::add_instrument(gig::Instrument* instrument) {  void MainWindow::add_instrument(gig::Instrument* instrument) {
3761      const Glib::ustring name(gig_to_utf8(instrument->pInfo->Name));      const Glib::ustring name(gig_to_utf8(instrument->pInfo->Name));
# Line 2557  void MainWindow::add_instrument(gig::Ins Line 3764  void MainWindow::add_instrument(gig::Ins
3764      instrument_name_connection.block();      instrument_name_connection.block();
3765      Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append();      Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append();
3766      Gtk::TreeModel::Row rowInstr = *iterInstr;      Gtk::TreeModel::Row rowInstr = *iterInstr;
3767      rowInstr[m_Columns.m_col_nr] = m_refTreeModel->children().size() - 1;      const int index = m_refTreeModel->children().size() - 1;
3768        rowInstr[m_Columns.m_col_nr] = index;
3769      rowInstr[m_Columns.m_col_name] = name;      rowInstr[m_Columns.m_col_name] = name;
3770      rowInstr[m_Columns.m_col_instr] = instrument;      rowInstr[m_Columns.m_col_instr] = instrument;
3771        rowInstr[m_Columns.m_col_scripts] = "";
3772        rowInstr[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index);
3773      instrument_name_connection.unblock();      instrument_name_connection.unblock();
3774    
3775    #if !USE_GTKMM_BUILDER
3776      add_instrument_to_menu(name);      add_instrument_to_menu(name);
3777    #endif
3778      m_TreeView.get_selection()->select(iterInstr);      select_instrument(instrument);
   
3779      file_changed();      file_changed();
3780  }  }
3781    
# Line 2633  void MainWindow::on_action_remove_instru Line 3843  void MainWindow::on_action_remove_instru
3843              if (instr) file->DeleteInstrument(instr);              if (instr) file->DeleteInstrument(instr);
3844              file_changed();              file_changed();
3845    
3846    #if !USE_GTKMM_BUILDER
3847              remove_instrument_from_menu(index);              remove_instrument_from_menu(index);
3848    #endif
3849    
3850              // remove row from instruments tree view              // remove row from instruments tree view
3851              m_refTreeModel->erase(it);              m_refTreeModel->erase(it);
# Line 2644  void MainWindow::on_action_remove_instru Line 3856  void MainWindow::on_action_remove_instru
3856                       it != m_refTreeModel->children().end(); ++it, ++index)                       it != m_refTreeModel->children().end(); ++it, ++index)
3857                  {                  {
3858                      Gtk::TreeModel::Row row = *it;                      Gtk::TreeModel::Row row = *it;
3859                        gig::Instrument* instrument = row[m_Columns.m_col_instr];
3860                      row[m_Columns.m_col_nr] = index;                      row[m_Columns.m_col_nr] = index;
3861                        row[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index);
3862                  }                  }
3863              }              }
3864    
# Line 2848  void MainWindow::add_or_replace_sample(b Line 4062  void MainWindow::add_or_replace_sample(b
4062    
4063      // show 'browse for file' dialog      // show 'browse for file' dialog
4064      Gtk::FileChooserDialog dialog(*this, replace ? _("Replace Sample with") : _("Add Sample(s)"));      Gtk::FileChooserDialog dialog(*this, replace ? _("Replace Sample with") : _("Add Sample(s)"));
4065    #if HAS_GTKMM_STOCK
4066      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
4067      dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);      dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
4068    #else
4069        dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
4070        dialog.add_button(_("_Open"), Gtk::RESPONSE_OK);
4071    #endif
4072      dialog.set_select_multiple(!replace); // allow multi audio file selection only when adding new samples, does not make sense when replacing a specific sample      dialog.set_select_multiple(!replace); // allow multi audio file selection only when adding new samples, does not make sense when replacing a specific sample
4073    
4074      // matches all file types supported by libsndfile      // matches all file types supported by libsndfile
# Line 2892  void MainWindow::add_or_replace_sample(b Line 4111  void MainWindow::add_or_replace_sample(b
4111          dialog.set_current_folder(current_sample_dir);          dialog.set_current_folder(current_sample_dir);
4112      }      }
4113      if (dialog.run() == Gtk::RESPONSE_OK) {      if (dialog.run() == Gtk::RESPONSE_OK) {
4114            dialog.hide();
4115          current_sample_dir = dialog.get_current_folder();          current_sample_dir = dialog.get_current_folder();
4116          Glib::ustring error_files;          Glib::ustring error_files;
4117          std::vector<std::string> filenames = dialog.get_filenames();          std::vector<std::string> filenames = dialog.get_filenames();
4118          for (std::vector<std::string>::iterator iter = filenames.begin();          for (std::vector<std::string>::iterator iter = filenames.begin();
4119               iter != filenames.end(); ++iter) {               iter != filenames.end(); ++iter) {
4120              printf("Adding sample %s\n",(*iter).c_str());              printf("Adding sample %s\n",(*iter).c_str());
4121              // use libsndfile to retrieve file informations              // use libsndfile to retrieve file information
4122              SF_INFO info;              SF_INFO info;
4123              info.format = 0;              info.format = 0;
4124              SNDFILE* hFile = sf_open((*iter).c_str(), SFM_READ, &info);              SNDFILE* hFile = sf_open((*iter).c_str(), SFM_READ, &info);
# Line 3039  void MainWindow::on_action_replace_all_s Line 4259  void MainWindow::on_action_replace_all_s
4259      Gtk::Label description(str);      Gtk::Label description(str);
4260      description.set_line_wrap();      description.set_line_wrap();
4261  #endif  #endif
4262      Gtk::HBox entryArea;      HBox entryArea;
4263      Gtk::Label entryLabel( _("Add filename extension: "), Gtk::ALIGN_START);      Gtk::Label entryLabel( _("Add filename extension: "), Gtk::ALIGN_START);
4264      Gtk::Entry postfixEntryBox;      Gtk::Entry postfixEntryBox;
4265      postfixEntryBox.set_text(".wav");      postfixEntryBox.set_text(".wav");
4266      entryArea.pack_start(entryLabel);      entryArea.pack_start(entryLabel);
4267      entryArea.pack_start(postfixEntryBox);      entryArea.pack_start(postfixEntryBox);
4268    #if USE_GTKMM_BOX
4269        dialog.get_content_area()->pack_start(description, Gtk::PACK_SHRINK);
4270        dialog.get_content_area()->pack_start(entryArea, Gtk::PACK_SHRINK);
4271    #else
4272      dialog.get_vbox()->pack_start(description, Gtk::PACK_SHRINK);      dialog.get_vbox()->pack_start(description, Gtk::PACK_SHRINK);
4273      dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK);      dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK);
4274    #endif
4275      description.show();      description.show();
4276    
4277    #if HAS_GTKMM_SHOW_ALL_CHILDREN
4278      entryArea.show_all();      entryArea.show_all();
4279    #else
4280        entryArea.show();
4281    #endif
4282    
4283    #if HAS_GTKMM_STOCK
4284      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
4285    #else
4286        dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
4287    #endif
4288      dialog.add_button(_("Select"), Gtk::RESPONSE_OK);      dialog.add_button(_("Select"), Gtk::RESPONSE_OK);
4289      dialog.set_select_multiple(false);      dialog.set_select_multiple(false);
4290      if (current_sample_dir != "") {      if (current_sample_dir != "") {
# Line 3057  void MainWindow::on_action_replace_all_s Line 4292  void MainWindow::on_action_replace_all_s
4292      }      }
4293      if (dialog.run() == Gtk::RESPONSE_OK)      if (dialog.run() == Gtk::RESPONSE_OK)
4294      {      {
4295            dialog.hide();
4296          current_sample_dir = dialog.get_current_folder();          current_sample_dir = dialog.get_current_folder();
4297          Glib::ustring error_files;          Glib::ustring error_files;
4298          std::string folder = dialog.get_filename();          std::string folder = dialog.get_filename();
# Line 3507  void MainWindow::instrument_name_changed Line 4743  void MainWindow::instrument_name_changed
4743      Gtk::TreeModel::Row row = *iter;      Gtk::TreeModel::Row row = *iter;
4744      Glib::ustring name = row[m_Columns.m_col_name];      Glib::ustring name = row[m_Columns.m_col_name];
4745    
4746    #if !USE_GTKMM_BUILDER
4747      // change name in instrument menu      // change name in instrument menu
4748      int index = path[0];      int index = path[0];
4749      const std::vector<Gtk::Widget*> children = instrument_menu->get_children();      const std::vector<Gtk::Widget*> children = instrument_menu->get_children();
# Line 3519  void MainWindow::instrument_name_changed Line 4756  void MainWindow::instrument_name_changed
4756          item->set_active();          item->set_active();
4757  #endif  #endif
4758      }      }
4759    #endif
4760    
4761      // change name in gig      // change name in gig
4762      gig::Instrument* instrument = row[m_Columns.m_col_instr];      gig::Instrument* instrument = row[m_Columns.m_col_instr];
# Line 3535  void MainWindow::instrument_name_changed Line 4773  void MainWindow::instrument_name_changed
4773      }      }
4774  }  }
4775    
4776    bool MainWindow::instrument_row_visible(const Gtk::TreeModel::const_iterator& iter) {
4777        if (!iter)
4778            return true;
4779    
4780        Glib::ustring pattern = m_searchText.get_text().lowercase();
4781        trim(pattern);
4782        if (pattern.empty()) return true;
4783    
4784    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24)
4785        //HACK: on GTKMM4 development branch const_iterator cannot be easily converted to iterator, probably going to be fixed before final GTKMM4 release though.
4786        Gtk::TreeModel::Row row = **(Gtk::TreeModel::iterator*)(&iter);
4787    #else
4788        Gtk::TreeModel::Row row = *iter;
4789    #endif
4790        Glib::ustring name = row[m_Columns.m_col_name];
4791        name = name.lowercase();
4792    
4793        std::vector<Glib::ustring> tokens = Glib::Regex::split_simple(" ", pattern);
4794        for (int t = 0; t < tokens.size(); ++t)
4795            if (name.find(tokens[t]) == Glib::ustring::npos)
4796                return false;
4797    
4798        return true;
4799    }
4800    
4801  void MainWindow::on_action_combine_instruments() {  void MainWindow::on_action_combine_instruments() {
4802      CombineInstrumentsDialog* d = new CombineInstrumentsDialog(*this, file);      CombineInstrumentsDialog* d = new CombineInstrumentsDialog(*this, file);
4803    
4804        // take over selection from instruments list view for the combine dialog's
4805        // list view as pre-selection
4806        std::set<int> indeces;
4807        {
4808            Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection();
4809            std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
4810            for (int r = 0; r < rows.size(); ++r) {
4811                Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]);
4812                if (it) {
4813                    Gtk::TreeModel::Row row = *it;
4814                    int index = row[m_Columns.m_col_nr];
4815                    indeces.insert(index);
4816                }
4817            }
4818        }
4819        d->setSelectedInstruments(indeces);
4820    
4821    #if HAS_GTKMM_SHOW_ALL_CHILDREN
4822      d->show_all();      d->show_all();
4823      d->resize(500, 400);  #else
4824        d->show();
4825    #endif
4826      d->run();      d->run();
4827      if (d->fileWasChanged()) {      if (d->fileWasChanged()) {
4828          // update GUI with new instrument just created          // update GUI with new instrument just created
# Line 3562  void MainWindow::on_action_view_referenc Line 4846  void MainWindow::on_action_view_referenc
4846      d->dimension_region_selected.connect(      d->dimension_region_selected.connect(
4847          sigc::mem_fun(*this, &MainWindow::select_dimension_region)          sigc::mem_fun(*this, &MainWindow::select_dimension_region)
4848      );      );
4849    #if HAS_GTKMM_SHOW_ALL_CHILDREN
4850      d->show_all();      d->show_all();
4851    #else
4852        d->show();
4853    #endif
4854      d->resize(500, 400);      d->resize(500, 400);
4855      d->run();      d->run();
4856      delete d;      delete d;
# Line 3646  void MainWindow::mergeFiles(const std::v Line 4934  void MainWindow::mergeFiles(const std::v
4934              Glib::filename_display_basename(this->filename) + "' ...",              Glib::filename_display_basename(this->filename) + "' ...",
4935              *this              *this
4936          );          );
4937    #if HAS_GTKMM_SHOW_ALL_CHILDREN
4938          progress_dialog->show_all();          progress_dialog->show_all();
4939    #else
4940            progress_dialog->show();
4941    #endif
4942          saver = new Saver(this->file); //FIXME: memory leak!          saver = new Saver(this->file); //FIXME: memory leak!
4943          saver->signal_progress().connect(          saver->signal_progress().connect(
4944              sigc::mem_fun(*this, &MainWindow::on_saver_progress));              sigc::mem_fun(*this, &MainWindow::on_saver_progress));
# Line 3673  void MainWindow::on_action_merge_files() Line 4965  void MainWindow::on_action_merge_files()
4965      }      }
4966    
4967      Gtk::FileChooserDialog dialog(*this, _("Merge .gig files"));      Gtk::FileChooserDialog dialog(*this, _("Merge .gig files"));
4968    #if HAS_GTKMM_STOCK
4969      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
4970    #else
4971        dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
4972    #endif
4973      dialog.add_button(_("Merge"), Gtk::RESPONSE_OK);      dialog.add_button(_("Merge"), Gtk::RESPONSE_OK);
4974      dialog.set_default_response(Gtk::RESPONSE_CANCEL);      dialog.set_default_response(Gtk::RESPONSE_CANCEL);
4975  #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2  #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
# Line 3690  void MainWindow::on_action_merge_files() Line 4986  void MainWindow::on_action_merge_files()
4986      dialog.set_select_multiple(true);      dialog.set_select_multiple(true);
4987    
4988      // show warning in the file picker dialog      // show warning in the file picker dialog
4989      Gtk::HBox descriptionArea;      HBox descriptionArea;
4990      descriptionArea.set_spacing(15);      descriptionArea.set_spacing(15);
4991      Gtk::Image warningIcon;      Gtk::Image warningIcon;
4992      warningIcon.set_from_icon_name("dialog-warning",      warningIcon.set_from_icon_name("dialog-warning",
# Line 3713  void MainWindow::on_action_merge_files() Line 5009  void MainWindow::on_action_merge_files()
5009          "will accordingly be stored separately in the target .gig file!"          "will accordingly be stored separately in the target .gig file!"
5010      ));      ));
5011      descriptionArea.pack_start(description);      descriptionArea.pack_start(description);
5012    #if USE_GTKMM_BOX
5013    # warning No description area implemented for dialog on GTKMM 3
5014    #else
5015      dialog.get_vbox()->pack_start(descriptionArea, Gtk::PACK_SHRINK);      dialog.get_vbox()->pack_start(descriptionArea, Gtk::PACK_SHRINK);
5016    #endif
5017    #if HAS_GTKMM_SHOW_ALL_CHILDREN
5018      descriptionArea.show_all();      descriptionArea.show_all();
5019    #else
5020        descriptionArea.show();
5021    #endif
5022    
5023      if (dialog.run() == Gtk::RESPONSE_OK) {      if (dialog.run() == Gtk::RESPONSE_OK) {
5024            dialog.hide();
5025    #ifdef GLIB_THREADS
5026          printf("on_action_merge_files self=%p\n",          printf("on_action_merge_files self=%p\n",
5027                 static_cast<void*>(Glib::Threads::Thread::self()));                 static_cast<void*>(Glib::Threads::Thread::self()));
5028    #else
5029            std::cout << "on_action_merge_files self=" <<
5030                std::this_thread::get_id() << "\n";
5031    #endif
5032          std::vector<std::string> filenames = dialog.get_filenames();          std::vector<std::string> filenames = dialog.get_filenames();
5033    
5034          // merge the selected files to the currently open .gig file          // merge the selected files to the currently open .gig file
# Line 3750  void MainWindow::set_file_is_shared(bool Line 5060  void MainWindow::set_file_is_shared(bool
5060      }      }
5061    
5062      {      {
5063    #if USE_GTKMM_BUILDER
5064            m_actionToggleSyncSamplerSelection->property_enabled() = b;
5065    #else
5066          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
5067              uiManager->get_widget("/MenuBar/MenuSettings/SyncSamplerInstrumentSelection"));              uiManager->get_widget("/MenuBar/MenuSettings/SyncSamplerInstrumentSelection"));
5068          if (item) item->set_sensitive(b);          if (item) item->set_sensitive(b);
5069    #endif
5070      }      }
5071  }  }
5072    
# Line 3800  void MainWindow::show_scripts_tab() { Line 5114  void MainWindow::show_scripts_tab() {
5114      m_TreeViewNotebook.set_current_page(2);      m_TreeViewNotebook.set_current_page(2);
5115  }  }
5116    
5117    void MainWindow::select_instrument_by_dir(int dir) {
5118        if (!file) return;
5119        gig::Instrument* pInstrument = get_instrument();
5120        if (!pInstrument) {
5121            select_instrument( file->GetInstrument(0) );
5122            return;
5123        }
5124        for (int i = 0; file->GetInstrument(i); ++i) {
5125            if (file->GetInstrument(i) == pInstrument) {
5126                select_instrument( file->GetInstrument(i + dir) );
5127                return;
5128            }
5129        }
5130    }
5131    
5132    void MainWindow::select_prev_instrument() {
5133        select_instrument_by_dir(-1);
5134    }
5135    
5136    void MainWindow::select_next_instrument() {
5137        select_instrument_by_dir(1);
5138    }
5139    
5140  void MainWindow::select_prev_region() {  void MainWindow::select_prev_region() {
5141      m_RegionChooser.select_prev_region();      m_RegionChooser.select_prev_region();
5142  }  }
# Line 3886  void MainWindow::updateClipboardPasteAva Line 5223  void MainWindow::updateClipboardPasteAva
5223    
5224  void MainWindow::updateClipboardCopyAvailable() {  void MainWindow::updateClipboardCopyAvailable() {
5225      bool bDimensionRegionCopyIsPossible = m_DimRegionChooser.get_main_dimregion();      bool bDimensionRegionCopyIsPossible = m_DimRegionChooser.get_main_dimregion();
5226    #if USE_GTKMM_BUILDER
5227        m_actionCopyDimRgn->property_enabled() = bDimensionRegionCopyIsPossible;
5228    #else
5229      static_cast<Gtk::MenuItem*>(      static_cast<Gtk::MenuItem*>(
5230          uiManager->get_widget("/MenuBar/MenuEdit/CopyDimRgn")          uiManager->get_widget("/MenuBar/MenuEdit/CopyDimRgn")
5231      )->set_sensitive(bDimensionRegionCopyIsPossible);      )->set_sensitive(bDimensionRegionCopyIsPossible);
5232    #endif
5233  }  }
5234    
5235    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2
5236    void MainWindow::on_clipboard_owner_change(Gdk::EventOwnerChange& event) {
5237    #else
5238  void MainWindow::on_clipboard_owner_change(GdkEventOwnerChange* event) {  void MainWindow::on_clipboard_owner_change(GdkEventOwnerChange* event) {
5239    #endif
5240      updateClipboardPasteAvailable();      updateClipboardPasteAvailable();
5241  }  }
5242    
# Line 3923  void MainWindow::applyMacro(Serializatio Line 5268  void MainWindow::applyMacro(Serializatio
5268           itDimReg != dimreg_edit.dimregs.end(); ++itDimReg)           itDimReg != dimreg_edit.dimregs.end(); ++itDimReg)
5269      {      {
5270          gig::DimensionRegion* pDimRgn = *itDimReg;          gig::DimensionRegion* pDimRgn = *itDimReg;
5271          dimreg_to_be_changed_signal.emit(pDimRgn);          DimRegionChangeGuard(this, pDimRgn);
5272          macro.deserialize(pDimRgn);          macro.deserialize(pDimRgn);
         dimreg_changed_signal.emit(pDimRgn);  
5273      }      }
5274      //region_changed()      //region_changed()
5275      file_changed();      file_changed();
# Line 3959  void MainWindow::on_clipboard_received_t Line 5303  void MainWindow::on_clipboard_received_t
5303          std::find(targets.begin(), targets.end(),          std::find(targets.begin(), targets.end(),
5304                    CLIPBOARD_DIMENSIONREGION_TARGET) != targets.end();                    CLIPBOARD_DIMENSIONREGION_TARGET) != targets.end();
5305    
5306    #if USE_GTKMM_BUILDER
5307        m_actionPasteDimRgn->property_enabled() = bDimensionRegionPasteIsPossible;
5308        m_actionAdjustClipboard->property_enabled() = bDimensionRegionPasteIsPossible;
5309    #else
5310      static_cast<Gtk::MenuItem*>(      static_cast<Gtk::MenuItem*>(
5311          uiManager->get_widget("/MenuBar/MenuEdit/PasteDimRgn")          uiManager->get_widget("/MenuBar/MenuEdit/PasteDimRgn")
5312      )->set_sensitive(bDimensionRegionPasteIsPossible);      )->set_sensitive(bDimensionRegionPasteIsPossible);
# Line 3966  void MainWindow::on_clipboard_received_t Line 5314  void MainWindow::on_clipboard_received_t
5314      static_cast<Gtk::MenuItem*>(      static_cast<Gtk::MenuItem*>(
5315          uiManager->get_widget("/MenuBar/MenuEdit/AdjustClipboard")          uiManager->get_widget("/MenuBar/MenuEdit/AdjustClipboard")
5316      )->set_sensitive(bDimensionRegionPasteIsPossible);      )->set_sensitive(bDimensionRegionPasteIsPossible);
5317    #endif
5318  }  }
5319    
5320  sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() {  sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() {

Legend:
Removed from v.3174  
changed lines
  Added in v.3619

  ViewVC Help
Powered by ViewVC