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

Legend:
Removed from v.2773  
changed lines
  Added in v.3364

  ViewVC Help
Powered by ViewVC