/[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 3179 by schoenebeck, Sat May 13 18:56:36 2017 UTC revision 3408 by schoenebeck, Fri Jan 19 19:17:41 2018 UTC
# Line 20  Line 20 
20  #include <iostream>  #include <iostream>
21  #include <cstring>  #include <cstring>
22    
23  #include <glibmmconfig.h>  #include "compat.h"
24  // threads.h must be included first to be able to build with  // threads.h must be included first to be able to build with
25  // G_DISABLE_DEPRECATED  // G_DISABLE_DEPRECATED
26  #if (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION == 31 && GLIBMM_MICRO_VERSION >= 2) || \  #if (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION == 31 && GLIBMM_MICRO_VERSION >= 2) || \
# Line 32  Line 32 
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>  #include <gtkmm/accelmap.h>
48  #if GTKMM_MAJOR_VERSION < 3  #if GTKMM_MAJOR_VERSION < 3
49  #include "wrapLabel.hh"  #include "wrapLabel.hh"
# Line 48  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 62  Line 71 
71  #include "gfx/builtinpix.h"  #include "gfx/builtinpix.h"
72  #include "MacroEditor.h"  #include "MacroEditor.h"
73  #include "MacrosSetup.h"  #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),
# Line 77  MainWindow::MainWindow() : Line 96  MainWindow::MainWindow() :
96  {  {
97      loadBuiltInPix();      loadBuiltInPix();
98    
99        this->file = NULL;
100    
101  //    set_border_width(5);  //    set_border_width(5);
102  //    set_default_size(400, 200);  
103        if (!Settings::singleton()->autoRestoreWindowDimension) {
104    #if GTKMM_MAJOR_VERSION >= 3
105            set_default_size(895, 600);
106    #else
107            set_default_size(800, 600);
108    #endif
109            set_position(Gtk::WIN_POS_CENTER);
110        }
111    
112      add(m_VBox);      add(m_VBox);
113    
# Line 88  MainWindow::MainWindow() : Line 117  MainWindow::MainWindow() :
117    
118      // m_TreeView.set_reorderable();      // m_TreeView.set_reorderable();
119    
120    #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
121        m_TreeView.signal_button_press_event().connect(
122            sigc::mem_fun(*this, &MainWindow::on_button_release));
123    #else
124      m_TreeView.signal_button_press_event().connect_notify(      m_TreeView.signal_button_press_event().connect_notify(
125          sigc::mem_fun(*this, &MainWindow::on_button_release));          sigc::mem_fun(*this, &MainWindow::on_button_release));
126    #endif
127    
128      // Add the TreeView tab, inside a ScrolledWindow, with the button underneath:      // Add the TreeView tab, inside a ScrolledWindow, with the button underneath:
129      m_ScrolledWindow.add(m_TreeView);      m_ScrolledWindow.add(m_TreeView);
# Line 102  MainWindow::MainWindow() : Line 136  MainWindow::MainWindow() :
136      m_ScrolledWindowScripts.add(m_TreeViewScripts);      m_ScrolledWindowScripts.add(m_TreeViewScripts);
137      m_ScrolledWindowScripts.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);      m_ScrolledWindowScripts.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
138    
139    #if GTKMM_MAJOR_VERSION < 3
140      m_TreeViewNotebook.set_size_request(300);      m_TreeViewNotebook.set_size_request(300);
141    #endif
142    
143        m_searchLabel.set_text(Glib::ustring(" ") + _("Filter:"));
144        m_searchField.pack_start(m_searchLabel, Gtk::PACK_SHRINK);
145        m_searchField.pack_start(m_searchText);
146        m_searchField.set_spacing(5);
147    
148        m_left_vbox.pack_start(m_TreeViewNotebook);
149        m_left_vbox.pack_start(m_searchField, Gtk::PACK_SHRINK);
150    
151        m_HPaned.add1(m_left_vbox);
152    
     m_HPaned.add1(m_TreeViewNotebook);  
153      dimreg_hbox.add(dimreg_label);      dimreg_hbox.add(dimreg_label);
154      dimreg_hbox.add(dimreg_all_regions);      dimreg_hbox.add(dimreg_all_regions);
155      dimreg_hbox.add(dimreg_all_dimregs);      dimreg_hbox.add(dimreg_all_dimregs);
# Line 117  MainWindow::MainWindow() : Line 161  MainWindow::MainWindow() :
161          legend_hbox.add(labelLegend);          legend_hbox.add(labelLegend);
162    
163          imageNoSample.set(redDot);          imageNoSample.set(redDot);
164    #if HAS_GTKMM_ALIGNMENT
165          imageNoSample.set_alignment(Gtk::ALIGN_END);          imageNoSample.set_alignment(Gtk::ALIGN_END);
166          labelNoSample.set_alignment(Gtk::ALIGN_START);          labelNoSample.set_alignment(Gtk::ALIGN_START);
167    #else
168            imageNoSample.set_halign(Gtk::ALIGN_END);
169            labelNoSample.set_halign(Gtk::ALIGN_START);
170    #endif
171          legend_hbox.add(imageNoSample);          legend_hbox.add(imageNoSample);
172          legend_hbox.add(labelNoSample);          legend_hbox.add(labelNoSample);
173    
174          imageMissingSample.set(yellowDot);          imageMissingSample.set(yellowDot);
175    #if HAS_GTKMM_ALIGNMENT
176          imageMissingSample.set_alignment(Gtk::ALIGN_END);          imageMissingSample.set_alignment(Gtk::ALIGN_END);
177          labelMissingSample.set_alignment(Gtk::ALIGN_START);          labelMissingSample.set_alignment(Gtk::ALIGN_START);
178    #else
179            imageMissingSample.set_halign(Gtk::ALIGN_END);
180            labelMissingSample.set_halign(Gtk::ALIGN_START);
181    #endif
182          legend_hbox.add(imageMissingSample);          legend_hbox.add(imageMissingSample);
183          legend_hbox.add(labelMissingSample);          legend_hbox.add(labelMissingSample);
184    
185          imageLooped.set(blackLoop);          imageLooped.set(blackLoop);
186    #if HAS_GTKMM_ALIGNMENT
187          imageLooped.set_alignment(Gtk::ALIGN_END);          imageLooped.set_alignment(Gtk::ALIGN_END);
188          labelLooped.set_alignment(Gtk::ALIGN_START);          labelLooped.set_alignment(Gtk::ALIGN_START);
189    #else
190            imageLooped.set_halign(Gtk::ALIGN_END);
191            labelLooped.set_halign(Gtk::ALIGN_START);
192    #endif
193          legend_hbox.add(imageLooped);          legend_hbox.add(imageLooped);
194          legend_hbox.add(labelLooped);          legend_hbox.add(labelLooped);
195    
196          imageSomeLoops.set(grayLoop);          imageSomeLoops.set(grayLoop);
197    #if HAS_GTKMM_ALIGNMENT
198          imageSomeLoops.set_alignment(Gtk::ALIGN_END);          imageSomeLoops.set_alignment(Gtk::ALIGN_END);
199          labelSomeLoops.set_alignment(Gtk::ALIGN_START);          labelSomeLoops.set_alignment(Gtk::ALIGN_START);
200    #else
201            imageSomeLoops.set_halign(Gtk::ALIGN_END);
202            labelSomeLoops.set_halign(Gtk::ALIGN_START);
203    #endif
204          legend_hbox.add(imageSomeLoops);          legend_hbox.add(imageSomeLoops);
205          legend_hbox.add(labelSomeLoops);          legend_hbox.add(labelSomeLoops);
206    
207    #if HAS_GTKMM_SHOW_ALL_CHILDREN
208          legend_hbox.show_all_children();          legend_hbox.show_all_children();
209    #endif
210      }      }
211      dimreg_vbox.pack_start(legend_hbox, Gtk::PACK_SHRINK);      dimreg_vbox.pack_start(legend_hbox, Gtk::PACK_SHRINK);
212      m_HPaned.add2(dimreg_vbox);      m_HPaned.add2(dimreg_vbox);
# Line 154  MainWindow::MainWindow() : Line 220  MainWindow::MainWindow() :
220      m_TreeViewNotebook.append_page(m_ScrolledWindow, _("Instruments"));      m_TreeViewNotebook.append_page(m_ScrolledWindow, _("Instruments"));
221      m_TreeViewNotebook.append_page(m_ScrolledWindowScripts, _("Scripts"));      m_TreeViewNotebook.append_page(m_ScrolledWindowScripts, _("Scripts"));
222    
223    #if USE_GLIB_ACTION
224        m_actionGroup = Gio::SimpleActionGroup::create();
225        m_actionGroup->add_action(
226            "New", sigc::mem_fun(*this, &MainWindow::on_action_file_new)
227        );
228        m_actionGroup->add_action(
229            "Open", sigc::mem_fun(*this, &MainWindow::on_action_file_open)
230        );
231        m_actionGroup->add_action(
232            "Save", sigc::mem_fun(*this, &MainWindow::on_action_file_save)
233        );
234        m_actionGroup->add_action(
235            "SaveAs", sigc::mem_fun(*this, &MainWindow::on_action_file_save_as)
236        );
237        m_actionGroup->add_action(
238            "Properties", sigc::mem_fun(*this, &MainWindow::on_action_file_properties)
239        );
240        m_actionGroup->add_action(
241            "InstrProperties", sigc::mem_fun(*this, &MainWindow::show_instr_props)
242        );
243        m_actionMIDIRules = m_actionGroup->add_action(
244            "MidiRules", sigc::mem_fun(*this, &MainWindow::show_midi_rules)
245        );
246        m_actionGroup->add_action(
247            "ScriptSlots", sigc::mem_fun(*this, &MainWindow::show_script_slots)
248        );
249        m_actionGroup->add_action(
250            "Quit", sigc::mem_fun(*this, &MainWindow::on_action_quit)
251        );
252        m_actionGroup->add_action(
253            "MenuSample", sigc::mem_fun(*this, &MainWindow::show_samples_tab)
254        );
255        m_actionGroup->add_action(
256            "MenuInstrument", sigc::mem_fun(*this, &MainWindow::show_intruments_tab)
257        );
258        m_actionGroup->add_action(
259            "MenuScript", sigc::mem_fun(*this, &MainWindow::show_scripts_tab)
260        );
261    #else
262      actionGroup = Gtk::ActionGroup::create();      actionGroup = Gtk::ActionGroup::create();
263    
264      actionGroup->add(Gtk::Action::create("MenuFile", _("_File")));      actionGroup->add(Gtk::Action::create("MenuFile", _("_File")));
# Line 207  MainWindow::MainWindow() : Line 312  MainWindow::MainWindow() :
312          sigc::mem_fun(*this, &MainWindow::show_scripts_tab)          sigc::mem_fun(*this, &MainWindow::show_scripts_tab)
313      );      );
314      actionGroup->add(Gtk::Action::create("AllInstruments", _("_Select")));      actionGroup->add(Gtk::Action::create("AllInstruments", _("_Select")));
315        actionGroup->add(Gtk::Action::create("AssignScripts", _("Assign Script")));
316    
317      actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit")));      actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit")));
318    #endif
319    
320      const Gdk::ModifierType primaryModifierKey =      const Gdk::ModifierType primaryModifierKey =
321  #if defined(__APPLE__)  #if defined(__APPLE__)
# Line 217  MainWindow::MainWindow() : Line 324  MainWindow::MainWindow() :
324      Gdk::CONTROL_MASK; // Ctrl key on all other OSs      Gdk::CONTROL_MASK; // Ctrl key on all other OSs
325  #endif  #endif
326    
327    #if USE_GLIB_ACTION
328        m_actionCopyDimRgn = m_actionGroup->add_action(
329            "CopyDimRgn", sigc::mem_fun(*this, &MainWindow::copy_selected_dimrgn)
330        );
331        m_actionPasteDimRgn = m_actionGroup->add_action(
332            "PasteDimRgn", sigc::mem_fun(*this, &MainWindow::paste_copied_dimrgn)
333        );
334        m_actionAdjustClipboard = m_actionGroup->add_action(
335            "AdjustClipboard", sigc::mem_fun(*this, &MainWindow::adjust_clipboard_content)
336        );
337        m_actionGroup->add_action(
338            "SelectPrevInstr", sigc::mem_fun(*this, &MainWindow::select_prev_instrument)
339        );
340        m_actionGroup->add_action(
341            "SelectNextInstr", sigc::mem_fun(*this, &MainWindow::select_next_instrument)
342        );
343        m_actionGroup->add_action(
344            "SelectPrevRegion", sigc::mem_fun(*this, &MainWindow::select_prev_region)
345        );
346        m_actionGroup->add_action(
347            "SelectNextRegion", sigc::mem_fun(*this, &MainWindow::select_next_region)
348        );
349        m_actionGroup->add_action(
350            "SelectPrevDimRgnZone", sigc::mem_fun(*this, &MainWindow::select_prev_dim_rgn_zone)
351        );
352        m_actionGroup->add_action(
353            "SelectNextDimRgnZone", sigc::mem_fun(*this, &MainWindow::select_next_dim_rgn_zone)
354        );
355        m_actionGroup->add_action(
356            "SelectPrevDimension", sigc::mem_fun(*this, &MainWindow::select_prev_dimension)
357        );
358        m_actionGroup->add_action(
359            "SelectNextDimension", sigc::mem_fun(*this, &MainWindow::select_next_dimension)
360        );
361        m_actionGroup->add_action(
362            "SelectAddPrevDimRgnZone", sigc::mem_fun(*this, &MainWindow::select_add_prev_dim_rgn_zone)
363        );
364        m_actionGroup->add_action(
365            "SelectAddNextDimRgnZone", sigc::mem_fun(*this, &MainWindow::select_add_next_dim_rgn_zone)
366        );
367    #else
368      actionGroup->add(Gtk::Action::create("CopyDimRgn",      actionGroup->add(Gtk::Action::create("CopyDimRgn",
369                                           _("Copy selected dimension region")),                                           _("Copy selected dimension region")),
370                       Gtk::AccelKey(GDK_KEY_c, Gdk::MOD1_MASK),                       Gtk::AccelKey(GDK_KEY_c, Gdk::MOD1_MASK),
# Line 232  MainWindow::MainWindow() : Line 380  MainWindow::MainWindow() :
380                       Gtk::AccelKey(GDK_KEY_x, Gdk::MOD1_MASK),                       Gtk::AccelKey(GDK_KEY_x, Gdk::MOD1_MASK),
381                       sigc::mem_fun(*this, &MainWindow::adjust_clipboard_content));                       sigc::mem_fun(*this, &MainWindow::adjust_clipboard_content));
382    
383        actionGroup->add(Gtk::Action::create("SelectPrevInstr",
384                                             _("Select Previous Instrument")),
385                         Gtk::AccelKey(GDK_KEY_Up, primaryModifierKey),
386                         sigc::mem_fun(*this, &MainWindow::select_prev_instrument));
387    
388        actionGroup->add(Gtk::Action::create("SelectNextInstr",
389                                             _("Select Next Instrument")),
390                         Gtk::AccelKey(GDK_KEY_Down, primaryModifierKey),
391                         sigc::mem_fun(*this, &MainWindow::select_next_instrument));
392    
393      actionGroup->add(Gtk::Action::create("SelectPrevRegion",      actionGroup->add(Gtk::Action::create("SelectPrevRegion",
394                                           _("Select Previous Region")),                                           _("Select Previous Region")),
395                       Gtk::AccelKey(GDK_KEY_Left, primaryModifierKey),                       Gtk::AccelKey(GDK_KEY_Left, primaryModifierKey),
# Line 271  MainWindow::MainWindow() : Line 429  MainWindow::MainWindow() :
429                                           _("Add Next Dimension Region Zone to Selection")),                                           _("Add Next Dimension Region Zone to Selection")),
430                       Gtk::AccelKey(GDK_KEY_Right, Gdk::MOD1_MASK | Gdk::SHIFT_MASK),                       Gtk::AccelKey(GDK_KEY_Right, Gdk::MOD1_MASK | Gdk::SHIFT_MASK),
431                       sigc::mem_fun(*this, &MainWindow::select_add_next_dim_rgn_zone));                       sigc::mem_fun(*this, &MainWindow::select_add_next_dim_rgn_zone));
432    #endif
433    
434    #if USE_GLIB_ACTION
435        m_actionToggleCopySampleUnity = m_actionGroup->add_action_bool("CopySampleUnity", true);
436        m_actionToggleCopySampleTune  = m_actionGroup->add_action_bool("CopySampleTune", true);
437        m_actionToggleCopySampleLoop  = m_actionGroup->add_action_bool("CopySampleLoop", true);
438    #else
439      Glib::RefPtr<Gtk::ToggleAction> toggle_action =      Glib::RefPtr<Gtk::ToggleAction> toggle_action =
440          Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note"));          Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note"));
441      toggle_action->set_active(true);      toggle_action->set_active(true);
# Line 286  MainWindow::MainWindow() : Line 450  MainWindow::MainWindow() :
450          Gtk::ToggleAction::create("CopySampleLoop", _("Copy Sample's _Loop Points"));          Gtk::ToggleAction::create("CopySampleLoop", _("Copy Sample's _Loop Points"));
451      toggle_action->set_active(true);      toggle_action->set_active(true);
452      actionGroup->add(toggle_action);      actionGroup->add(toggle_action);
453    #endif
454    
455    #if USE_GLIB_ACTION
456        m_actionToggleStatusBar =
457            m_actionGroup->add_action_bool("Statusbar", sigc::mem_fun(*this, &MainWindow::on_action_view_status_bar), true);
458        m_actionToggleRestoreWinDim =
459            m_actionGroup->add_action_bool("AutoRestoreWinDim", sigc::mem_fun(*this, &MainWindow::on_auto_restore_win_dim), Settings::singleton()->autoRestoreWindowDimension);
460        m_actionToggleSaveWithTempFile =
461            m_actionGroup->add_action_bool("SaveWithTemporaryFile", sigc::mem_fun(*this, &MainWindow::on_save_with_temporary_file), Settings::singleton()->saveWithTemporaryFile);
462        m_actionGroup->add_action("RefreshAll", sigc::mem_fun(*this, &MainWindow::on_action_refresh_all));
463    #else
464      actionGroup->add(Gtk::Action::create("MenuMacro", _("_Macro")));      actionGroup->add(Gtk::Action::create("MenuMacro", _("_Macro")));
465    
466    
# Line 317  MainWindow::MainWindow() : Line 490  MainWindow::MainWindow() :
490          Gtk::Action::create("RefreshAll", _("_Refresh All")),          Gtk::Action::create("RefreshAll", _("_Refresh All")),
491          sigc::mem_fun(*this, &MainWindow::on_action_refresh_all)          sigc::mem_fun(*this, &MainWindow::on_action_refresh_all)
492      );                      );                
493    #endif
494    
495    #if USE_GLIB_ACTION
496        m_actionGroup->add_action(
497            "About", sigc::mem_fun(*this, &MainWindow::on_action_help_about)
498        );
499        m_actionGroup->add_action(
500            "AddInstrument", sigc::mem_fun(*this, &MainWindow::on_action_add_instrument)
501        );
502        m_actionGroup->add_action(
503            "DupInstrument", sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument)
504        );
505        m_actionGroup->add_action(
506            "CombInstruments", sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments)
507        );
508        m_actionGroup->add_action(
509            "RemoveInstrument", sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument)
510        );
511    #else
512      action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP);      action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP);
513      actionGroup->add(Gtk::Action::create("MenuHelp",      actionGroup->add(Gtk::Action::create("MenuHelp",
514                                           action->property_label()));                                           action->property_label()));
# Line 333  MainWindow::MainWindow() : Line 524  MainWindow::MainWindow() :
524          sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument)          sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument)
525      );      );
526      actionGroup->add(      actionGroup->add(
527            Gtk::Action::create("CombInstruments", _("_Combine Instruments ...")),
528            Gtk::AccelKey(GDK_KEY_j, primaryModifierKey),
529            sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments)
530        );
531        actionGroup->add(
532          Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE),          Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE),
533          sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument)          sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument)
534      );      );
535    #endif
536    
537    #if USE_GLIB_ACTION
538        m_actionToggleWarnOnExtensions = m_actionGroup->add_action_bool(
539            "WarnUserOnExtensions", sigc::mem_fun(*this, &MainWindow::on_action_warn_user_on_extensions),
540            Settings::singleton()->warnUserOnExtensions
541        );
542        m_actionToggleSyncSamplerSelection = m_actionGroup->add_action_bool(
543            "SyncSamplerInstrumentSelection", sigc::mem_fun(*this, &MainWindow::on_action_sync_sampler_instrument_selection),
544            Settings::singleton()->syncSamplerInstrumentSelection
545        );
546        m_actionToggleMoveRootNoteWithRegion = m_actionGroup->add_action_bool(
547            "MoveRootNoteWithRegionMoved", sigc::mem_fun(*this, &MainWindow::on_action_move_root_note_with_region_moved),
548            Settings::singleton()->moveRootNoteWithRegionMoved
549        );
550    #else
551      actionGroup->add(Gtk::Action::create("MenuSettings", _("_Settings")));      actionGroup->add(Gtk::Action::create("MenuSettings", _("_Settings")));
552            
553      toggle_action =      toggle_action =
# Line 363  MainWindow::MainWindow() : Line 573  MainWindow::MainWindow() :
573          toggle_action,          toggle_action,
574          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)
575      );      );
576    #endif
577    
578    #if USE_GLIB_ACTION
579        m_actionGroup->add_action(
580            "CombineInstruments", sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments)
581        );
582        m_actionGroup->add_action(
583            "MergeFiles", sigc::mem_fun(*this, &MainWindow::on_action_merge_files)
584        );
585    #else
586      actionGroup->add(Gtk::Action::create("MenuTools", _("_Tools")));      actionGroup->add(Gtk::Action::create("MenuTools", _("_Tools")));
587    
588      actionGroup->add(      actionGroup->add(
# Line 376  MainWindow::MainWindow() : Line 594  MainWindow::MainWindow() :
594          Gtk::Action::create("MergeFiles", _("_Merge Files...")),          Gtk::Action::create("MergeFiles", _("_Merge Files...")),
595          sigc::mem_fun(*this, &MainWindow::on_action_merge_files)          sigc::mem_fun(*this, &MainWindow::on_action_merge_files)
596      );      );
597    #endif
598    
599      // sample right-click popup actions      // sample right-click popup actions
600    #if USE_GLIB_ACTION
601        m_actionSampleProperties = m_actionGroup->add_action(
602            "SampleProperties", sigc::mem_fun(*this, &MainWindow::on_action_sample_properties)
603        );
604        m_actionAddSampleGroup = m_actionGroup->add_action(
605            "AddGroup", sigc::mem_fun(*this, &MainWindow::on_action_add_group)
606        );
607        m_actionAddSample = m_actionGroup->add_action(
608            "AddSample", sigc::mem_fun(*this, &MainWindow::on_action_add_sample)
609        );
610        m_actionRemoveSample = m_actionGroup->add_action(
611            "RemoveSample", sigc::mem_fun(*this, &MainWindow::on_action_remove_sample)
612        );
613        m_actionGroup->add_action(
614            "RemoveUnusedSamples", sigc::mem_fun(*this, &MainWindow::on_action_remove_unused_samples)
615        );
616        m_actionViewSampleRefs = m_actionGroup->add_action(
617            "ShowSampleRefs", sigc::mem_fun(*this, &MainWindow::on_action_view_references)
618        );
619        m_actionReplaceSample = m_actionGroup->add_action(
620            "ReplaceSample", sigc::mem_fun(*this, &MainWindow::on_action_replace_sample)
621        );
622        m_actionGroup->add_action(
623            "ReplaceAllSamplesInAllGroups", sigc::mem_fun(*this, &MainWindow::on_action_replace_all_samples_in_all_groups)
624        );
625    #else
626      actionGroup->add(      actionGroup->add(
627          Gtk::Action::create("SampleProperties", Gtk::Stock::PROPERTIES),          Gtk::Action::create("SampleProperties", Gtk::Stock::PROPERTIES),
628          sigc::mem_fun(*this, &MainWindow::on_action_sample_properties)          sigc::mem_fun(*this, &MainWindow::on_action_sample_properties)
# Line 413  MainWindow::MainWindow() : Line 657  MainWindow::MainWindow() :
657                              _("Replace All Samples in All Groups...")),                              _("Replace All Samples in All Groups...")),
658          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)
659      );      );
660    #endif
661            
662      // script right-click popup actions      // script right-click popup actions
663    #if USE_GLIB_ACTION
664        m_actionAddScriptGroup = m_actionGroup->add_action(
665            "AddScriptGroup", sigc::mem_fun(*this, &MainWindow::on_action_add_script_group)
666        );
667        m_actionAddScript = m_actionGroup->add_action(
668            "AddScript", sigc::mem_fun(*this, &MainWindow::on_action_add_script)
669        );
670        m_actionEditScript = m_actionGroup->add_action(
671            "EditScript", sigc::mem_fun(*this, &MainWindow::on_action_edit_script)
672        );
673        m_actionRemoveScript = m_actionGroup->add_action(
674            "RemoveScript", sigc::mem_fun(*this, &MainWindow::on_action_remove_script)
675        );
676    #else
677      actionGroup->add(      actionGroup->add(
678          Gtk::Action::create("AddScriptGroup", _("Add _Group")),          Gtk::Action::create("AddScriptGroup", _("Add _Group")),
679          sigc::mem_fun(*this, &MainWindow::on_action_add_script_group)          sigc::mem_fun(*this, &MainWindow::on_action_add_script_group)
# Line 431  MainWindow::MainWindow() : Line 690  MainWindow::MainWindow() :
690          Gtk::Action::create("RemoveScript", Gtk::Stock::REMOVE),          Gtk::Action::create("RemoveScript", Gtk::Stock::REMOVE),
691          sigc::mem_fun(*this, &MainWindow::on_action_remove_script)          sigc::mem_fun(*this, &MainWindow::on_action_remove_script)
692      );      );
693    #endif
694    
695    #if USE_GTKMM_BUILDER
696        insert_action_group("AppMenu", m_actionGroup);
697        
698        m_uiManager = Gtk::Builder::create();
699        Glib::ustring ui_info =
700            "<interface>"
701            "  <menubar id='MenuBar'>"
702            "    <menu id='MenuFile'>"
703            "      <attribute name='label' translatable='yes'>_File</attribute>"
704            "      <section>"
705            "        <item id='New'>"
706            "          <attribute name='label' translatable='yes'>New</attribute>"
707            "          <attribute name='action'>AppMenu.New</attribute>"
708            "        </item>"
709            "        <item id='Open'>"
710            "          <attribute name='label' translatable='yes'>Open</attribute>"
711            "          <attribute name='action'>AppMenu.Open</attribute>"
712            "        </item>"
713            "      </section>"
714            "      <section>"
715            "        <item id='Save'>"
716            "          <attribute name='label' translatable='yes'>Save</attribute>"
717            "          <attribute name='action'>AppMenu.Save</attribute>"
718            "        </item>"
719            "        <item id='SaveAs'>"
720            "          <attribute name='label' translatable='yes'>Save As</attribute>"
721            "          <attribute name='action'>AppMenu.SaveAs</attribute>"
722            "        </item>"
723            "      </section>"
724            "      <section>"
725            "        <item id='Properties'>"
726            "          <attribute name='label' translatable='yes'>Properties</attribute>"
727            "          <attribute name='action'>AppMenu.Properties</attribute>"
728            "        </item>"
729            "      </section>"
730            "      <section>"
731            "        <item id='Quit'>"
732            "          <attribute name='label' translatable='yes'>Quit</attribute>"
733            "          <attribute name='action'>AppMenu.Quit</attribute>"
734            "        </item>"
735            "      </section>"
736            "    </menu>"
737            "    <menu id='MenuEdit'>"
738            "      <attribute name='label' translatable='yes'>Edit</attribute>"
739            "      <section>"
740            "        <item id='CopyDimRgn'>"
741            "          <attribute name='label' translatable='yes'>Copy Dimension Region</attribute>"
742            "          <attribute name='action'>AppMenu.CopyDimRgn</attribute>"
743            "        </item>"
744            "        <item id='AdjustClipboard'>"
745            "          <attribute name='label' translatable='yes'>Adjust Clipboard</attribute>"
746            "          <attribute name='action'>AppMenu.AdjustClipboard</attribute>"
747            "        </item>"
748            "        <item id='PasteDimRgn'>"
749            "          <attribute name='label' translatable='yes'>Paste Dimension Region</attribute>"
750            "          <attribute name='action'>AppMenu.PasteDimRgn</attribute>"
751            "        </item>"
752            "      </section>"
753            "        <item id='SelectPrevInstr'>"
754            "          <attribute name='label' translatable='yes'>Previous Instrument</attribute>"
755            "          <attribute name='action'>AppMenu.SelectPrevInstr</attribute>"
756            "        </item>"
757            "        <item id='SelectNextInstr'>"
758            "          <attribute name='label' translatable='yes'>Next Instrument</attribute>"
759            "          <attribute name='action'>AppMenu.SelectNextInstr</attribute>"
760            "        </item>"
761            "      <section>"
762            "        <item id='SelectPrevRegion'>"
763            "          <attribute name='label' translatable='yes'>Previous Region</attribute>"
764            "          <attribute name='action'>AppMenu.SelectPrevRegion</attribute>"
765            "        </item>"
766            "        <item id='SelectNextRegion'>"
767            "          <attribute name='label' translatable='yes'>Next Region</attribute>"
768            "          <attribute name='action'>AppMenu.SelectNextRegion</attribute>"
769            "        </item>"
770            "      </section>"
771            "        <item id='SelectPrevDimension'>"
772            "          <attribute name='label' translatable='yes'>Previous Dimension</attribute>"
773            "          <attribute name='action'>AppMenu.SelectPrevDimension</attribute>"
774            "        </item>"
775            "        <item id='SelectNextDimension'>"
776            "          <attribute name='label' translatable='yes'>Next Dimension</attribute>"
777            "          <attribute name='action'>AppMenu.SelectNextDimension</attribute>"
778            "        </item>"
779            "        <item id='SelectPrevDimRgnZone'>"
780            "          <attribute name='label' translatable='yes'>Previous Dimension Region Zone</attribute>"
781            "          <attribute name='action'>AppMenu.SelectPrevDimRgnZone</attribute>"
782            "        </item>"
783            "        <item id='SelectNextDimRgnZone'>"
784            "          <attribute name='label' translatable='yes'>Next Dimension Region Zone</attribute>"
785            "          <attribute name='action'>AppMenu.SelectNextDimRgnZone</attribute>"
786            "        </item>"
787            "        <item id='SelectAddPrevDimRgnZone'>"
788            "          <attribute name='label' translatable='yes'>Add Previous Dimension Region Zone</attribute>"
789            "          <attribute name='action'>AppMenu.SelectAddPrevDimRgnZone</attribute>"
790            "        </item>"
791            "        <item id='SelectAddNextDimRgnZone'>"
792            "          <attribute name='label' translatable='yes'>Add Next Dimension Region Zone</attribute>"
793            "          <attribute name='action'>AppMenu.SelectAddNextDimRgnZone</attribute>"
794            "        </item>"
795            "      <section>"
796            "        <item id='CopySampleUnity'>"
797            "          <attribute name='label' translatable='yes'>Copy Sample Unity</attribute>"
798            "          <attribute name='action'>AppMenu.CopySampleUnity</attribute>"
799            "        </item>"
800            "        <item id='CopySampleTune'>"
801            "          <attribute name='label' translatable='yes'>Copy Sample Tune</attribute>"
802            "          <attribute name='action'>AppMenu.CopySampleTune</attribute>"
803            "        </item>"
804            "        <item id='CopySampleLoop'>"
805            "          <attribute name='label' translatable='yes'>Copy Sample Loop</attribute>"
806            "          <attribute name='action'>AppMenu.CopySampleLoop</attribute>"
807            "        </item>"
808            "      </section>"
809            "    </menu>"
810            "    <menu id='MenuMacro'>"
811            "      <attribute name='label' translatable='yes'>Macro</attribute>"
812            "      <section>"
813            "      </section>"
814            "    </menu>"
815            "    <menu id='MenuSample'>"
816            "      <attribute name='label' translatable='yes'>Sample</attribute>"
817            "      <section>"
818            "        <item id='SampleProperties'>"
819            "          <attribute name='label' translatable='yes'>Properties</attribute>"
820            "          <attribute name='action'>AppMenu.SampleProperties</attribute>"
821            "        </item>"
822            "        <item id='AddGroup'>"
823            "          <attribute name='label' translatable='yes'>Add Group</attribute>"
824            "          <attribute name='action'>AppMenu.AddGroup</attribute>"
825            "        </item>"
826            "        <item id='AddSample'>"
827            "          <attribute name='label' translatable='yes'>Add Sample</attribute>"
828            "          <attribute name='action'>AppMenu.AddSample</attribute>"
829            "        </item>"
830            "        <item id='ShowSampleRefs'>"
831            "          <attribute name='label' translatable='yes'>Show Sample References</attribute>"
832            "          <attribute name='action'>AppMenu.ShowSampleRefs</attribute>"
833            "        </item>"
834            "        <item id='ReplaceSample'>"
835            "          <attribute name='label' translatable='yes'>Replace Sample</attribute>"
836            "          <attribute name='action'>AppMenu.ReplaceSample</attribute>"
837            "        </item>"
838            "        <item id='ReplaceAllSamplesInAllGroups'>"
839            "          <attribute name='label' translatable='yes'>Replace all Samples in all Groups</attribute>"
840            "          <attribute name='action'>AppMenu.ReplaceAllSamplesInAllGroups</attribute>"
841            "        </item>"
842            "      </section>"
843            "      <section>"
844            "        <item id='RemoveSample'>"
845            "          <attribute name='label' translatable='yes'>Remove Sample</attribute>"
846            "          <attribute name='action'>AppMenu.RemoveSample</attribute>"
847            "        </item>"
848            "        <item id='RemoveUnusedSamples'>"
849            "          <attribute name='label' translatable='yes'>Remove unused Samples</attribute>"
850            "          <attribute name='action'>AppMenu.RemoveUnusedSamples</attribute>"
851            "        </item>"
852            "      </section>"
853            "    </menu>"
854            "    <menu id='MenuInstrument'>"
855            "      <attribute name='label' translatable='yes'>Instrument</attribute>"
856            "      <section>"
857            "        <item id='InstrProperties'>"
858            "          <attribute name='label' translatable='yes'>Properties</attribute>"
859            "          <attribute name='action'>AppMenu.InstrProperties</attribute>"
860            "        </item>"
861            "        <item id='MidiRules'>"
862            "          <attribute name='label' translatable='yes'>MIDI Rules</attribute>"
863            "          <attribute name='action'>AppMenu.MidiRules</attribute>"
864            "        </item>"
865            "        <item id='ScriptSlots'>"
866            "          <attribute name='label' translatable='yes'>Script Slots</attribute>"
867            "          <attribute name='action'>AppMenu.ScriptSlots</attribute>"
868            "        </item>"
869            "      </section>"
870            "      <submenu id='AssignScripts'>"
871            "        <attribute name='label' translatable='yes'>Assign Scripts</attribute>"
872            "      </submenu>"
873            "      <section>"
874            "        <item id='AddInstrument'>"
875            "          <attribute name='label' translatable='yes'>Add Instrument</attribute>"
876            "          <attribute name='action'>AppMenu.AddInstrument</attribute>"
877            "        </item>"
878            "        <item id='DupInstrument'>"
879            "          <attribute name='label' translatable='yes'>Duplicate Instrument</attribute>"
880            "          <attribute name='action'>AppMenu.DupInstrument</attribute>"
881            "        </item>"
882            "        <item id='CombInstruments'>"
883            "          <attribute name='label' translatable='yes'>Combine Instrument</attribute>"
884            "          <attribute name='action'>AppMenu.CombInstruments</attribute>"
885            "        </item>"
886            "      </section>"
887            "      <section>"
888            "        <item id='RemoveInstrument'>"
889            "          <attribute name='label' translatable='yes'>Remove Instrument</attribute>"
890            "          <attribute name='action'>AppMenu.RemoveInstrument</attribute>"
891            "        </item>"
892            "      </section>"
893            "    </menu>"
894            "    <menu id='MenuScript'>"
895            "      <attribute name='label' translatable='yes'>Script</attribute>"
896            "      <section>"
897            "        <item id='AddScriptGroup'>"
898            "          <attribute name='label' translatable='yes'>Add Script Group</attribute>"
899            "          <attribute name='action'>AppMenu.AddScriptGroup</attribute>"
900            "        </item>"
901            "        <item id='AddScript'>"
902            "          <attribute name='label' translatable='yes'>Add Script</attribute>"
903            "          <attribute name='action'>AppMenu.AddScript</attribute>"
904            "        </item>"
905            "        <item id='EditScript'>"
906            "          <attribute name='label' translatable='yes'>Edit Script</attribute>"
907            "          <attribute name='action'>AppMenu.EditScript</attribute>"
908            "        </item>"
909            "      </section>"
910            "      <section>"
911            "        <item id='RemoveScript'>"
912            "          <attribute name='label' translatable='yes'>Remove Script</attribute>"
913            "          <attribute name='action'>AppMenu.RemoveScript</attribute>"
914            "        </item>"
915            "      </section>"
916            "    </menu>"
917            "    <menu id='MenuView'>"
918            "      <attribute name='label' translatable='yes'>View</attribute>"
919            "      <section>"
920            "        <item id='Statusbar'>"
921            "          <attribute name='label' translatable='yes'>Statusbar</attribute>"
922            "          <attribute name='action'>AppMenu.Statusbar</attribute>"
923            "        </item>"
924            "        <item id='AutoRestoreWinDim'>"
925            "          <attribute name='label' translatable='yes'>Auto restore Window Dimensions</attribute>"
926            "          <attribute name='action'>AppMenu.AutoRestoreWinDim</attribute>"
927            "        </item>"
928            "      </section>"
929            "      <section>"
930            "        <item id='RefreshAll'>"
931            "          <attribute name='label' translatable='yes'>Refresh All</attribute>"
932            "          <attribute name='action'>AppMenu.RefreshAll</attribute>"
933            "        </item>"
934            "      </section>"
935            "    </menu>"
936            "    <menu id='MenuTools'>"
937            "      <attribute name='label' translatable='yes'>Tools</attribute>"
938            "      <section>"
939            "        <item id='CombineInstruments'>"
940            "          <attribute name='label' translatable='yes'>Combine Instruments ...</attribute>"
941            "          <attribute name='action'>AppMenu.CombineInstruments</attribute>"
942            "        </item>"
943            "        <item id='MergeFiles'>"
944            "          <attribute name='label' translatable='yes'>Merge Files ...</attribute>"
945            "          <attribute name='action'>AppMenu.MergeFiles</attribute>"
946            "        </item>"
947            "      </section>"
948            "    </menu>"
949            "    <menu id='MenuSettings'>"
950            "      <attribute name='label' translatable='yes'>Settings</attribute>"
951            "      <section>"
952            "        <item id='WarnUserOnExtensions'>"
953            "          <attribute name='label' translatable='yes'>Warning on Format Extensions</attribute>"
954            "          <attribute name='action'>AppMenu.WarnUserOnExtensions</attribute>"
955            "        </item>"
956            "        <item id='SyncSamplerInstrumentSelection'>"
957            "          <attribute name='label' translatable='yes'>Synchronize Sampler Selection</attribute>"
958            "          <attribute name='action'>AppMenu.SyncSamplerInstrumentSelection</attribute>"
959            "        </item>"
960            "        <item id='MoveRootNoteWithRegionMoved'>"
961            "          <attribute name='label' translatable='yes'>Move Root Note with Region moved</attribute>"
962            "          <attribute name='action'>AppMenu.MoveRootNoteWithRegionMoved</attribute>"
963            "        </item>"
964            "        <item id='SaveWithTemporaryFile'>"
965            "          <attribute name='label' translatable='yes'>Save with temporary file</attribute>"
966            "          <attribute name='action'>AppMenu.SaveWithTemporaryFile</attribute>"
967            "        </item>"
968            "      </section>"
969            "    </menu>"
970            "    <menu id='MenuHelp'>"
971            "      <attribute name='label' translatable='yes'>Help</attribute>"
972            "      <section>"
973            "        <item id='About'>"
974            "          <attribute name='label' translatable='yes'>About ...</attribute>"
975            "          <attribute name='action'>AppMenu.About</attribute>"
976            "        </item>"
977            "      </section>"
978            "    </menu>"
979            "  </menubar>"
980            // popups
981            "  <menu id='PopupMenu'>"
982            "    <section>"
983            "      <item id='InstrProperties'>"
984            "        <attribute name='label' translatable='yes'>Instrument Properties</attribute>"
985            "        <attribute name='action'>AppMenu.InstrProperties</attribute>"
986            "      </item>"
987            "      <item id='MidiRules'>"
988            "        <attribute name='label' translatable='yes'>MIDI Rules</attribute>"
989            "        <attribute name='action'>AppMenu.MidiRules</attribute>"
990            "      </item>"
991            "      <item id='ScriptSlots'>"
992            "        <attribute name='label' translatable='yes'>Script Slots</attribute>"
993            "        <attribute name='action'>AppMenu.ScriptSlots</attribute>"
994            "      </item>"
995            "      <item id='AddInstrument'>"
996            "        <attribute name='label' translatable='yes'>Add Instrument</attribute>"
997            "        <attribute name='action'>AppMenu.AddInstrument</attribute>"
998            "      </item>"
999            "      <item id='DupInstrument'>"
1000            "        <attribute name='label' translatable='yes'>Duplicate Instrument</attribute>"
1001            "        <attribute name='action'>AppMenu.DupInstrument</attribute>"
1002            "      </item>"
1003            "      <item id='CombInstruments'>"
1004            "        <attribute name='label' translatable='yes'>Combine Instruments</attribute>"
1005            "        <attribute name='action'>AppMenu.CombInstruments</attribute>"
1006            "      </item>"
1007            "    </section>"
1008            "    <section>"
1009            "      <item id='RemoveInstrument'>"
1010            "        <attribute name='label' translatable='yes'>Remove Instruments</attribute>"
1011            "        <attribute name='action'>AppMenu.RemoveInstrument</attribute>"
1012            "      </item>"
1013            "    </section>"
1014            "  </menu>"
1015            "  <menu id='SamplePopupMenu'>"
1016            "    <section>"
1017            "      <item id='SampleProperties'>"
1018            "        <attribute name='label' translatable='yes'>Sample Properties</attribute>"
1019            "        <attribute name='action'>AppMenu.SampleProperties</attribute>"
1020            "      </item>"
1021            "      <item id='AddGroup'>"
1022            "        <attribute name='label' translatable='yes'>Add Sample Group</attribute>"
1023            "        <attribute name='action'>AppMenu.AddGroup</attribute>"
1024            "      </item>"
1025            "      <item id='AddSample'>"
1026            "        <attribute name='label' translatable='yes'>Add Sample</attribute>"
1027            "        <attribute name='action'>AppMenu.AddSample</attribute>"
1028            "      </item>"
1029            "      <item id='ShowSampleRefs'>"
1030            "        <attribute name='label' translatable='yes'>Show Sample References ...</attribute>"
1031            "        <attribute name='action'>AppMenu.ShowSampleRefs</attribute>"
1032            "      </item>"
1033            "      <item id='ReplaceSample'>"
1034            "        <attribute name='label' translatable='yes'>Replace Sample</attribute>"
1035            "        <attribute name='action'>AppMenu.ReplaceSample</attribute>"
1036            "      </item>"
1037            "      <item id='ReplaceAllSamplesInAllGroups'>"
1038            "        <attribute name='label' translatable='yes'>Replace all Samples ...</attribute>"
1039            "        <attribute name='action'>AppMenu.ReplaceAllSamplesInAllGroups</attribute>"
1040            "      </item>"
1041            "    </section>"
1042            "    <section>"
1043            "      <item id='RemoveSample'>"
1044            "        <attribute name='label' translatable='yes'>Remove Sample</attribute>"
1045            "        <attribute name='action'>AppMenu.RemoveSample</attribute>"
1046            "      </item>"
1047            "      <item id='RemoveUnusedSamples'>"
1048            "        <attribute name='label' translatable='yes'>Remove unused Samples</attribute>"
1049            "        <attribute name='action'>AppMenu.RemoveUnusedSamples</attribute>"
1050            "      </item>"
1051            "    </section>"
1052            "  </menu>"
1053            "  <menu id='ScriptPopupMenu'>"
1054            "    <section>"
1055            "      <item id='AddScriptGroup'>"
1056            "        <attribute name='label' translatable='yes'>Add Script Group</attribute>"
1057            "        <attribute name='action'>AppMenu.AddScriptGroup</attribute>"
1058            "      </item>"
1059            "      <item id='AddScript'>"
1060            "        <attribute name='label' translatable='yes'>Add Script</attribute>"
1061            "        <attribute name='action'>AppMenu.AddScript</attribute>"
1062            "      </item>"
1063            "      <item id='EditScript'>"
1064            "        <attribute name='label' translatable='yes'>Edit Script</attribute>"
1065            "        <attribute name='action'>AppMenu.EditScript</attribute>"
1066            "      </item>"
1067            "    </section>"
1068            "    <section>"
1069            "      <item id='RemoveScript'>"
1070            "        <attribute name='label' translatable='yes'>Remove Script</attribute>"
1071            "        <attribute name='action'>AppMenu.RemoveScript</attribute>"
1072            "      </item>"
1073            "    </section>"
1074            "  </menu>"
1075            "</interface>";
1076        m_uiManager->add_from_string(ui_info);
1077    #else
1078      uiManager = Gtk::UIManager::create();      uiManager = Gtk::UIManager::create();
1079      uiManager->insert_action_group(actionGroup);      uiManager->insert_action_group(actionGroup);
1080      add_accel_group(uiManager->get_accel_group());      add_accel_group(uiManager->get_accel_group());
# Line 455  MainWindow::MainWindow() : Line 1098  MainWindow::MainWindow() :
1098          "      <menuitem action='AdjustClipboard'/>"          "      <menuitem action='AdjustClipboard'/>"
1099          "      <menuitem action='PasteDimRgn'/>"          "      <menuitem action='PasteDimRgn'/>"
1100          "      <separator/>"          "      <separator/>"
1101            "      <menuitem action='SelectPrevInstr'/>"
1102            "      <menuitem action='SelectNextInstr'/>"
1103            "      <separator/>"
1104          "      <menuitem action='SelectPrevRegion'/>"          "      <menuitem action='SelectPrevRegion'/>"
1105          "      <menuitem action='SelectNextRegion'/>"          "      <menuitem action='SelectNextRegion'/>"
1106          "      <separator/>"          "      <separator/>"
# Line 489  MainWindow::MainWindow() : Line 1135  MainWindow::MainWindow() :
1135          "      <menuitem action='InstrProperties'/>"          "      <menuitem action='InstrProperties'/>"
1136          "      <menuitem action='MidiRules'/>"          "      <menuitem action='MidiRules'/>"
1137          "      <menuitem action='ScriptSlots'/>"          "      <menuitem action='ScriptSlots'/>"
1138            "      <menu action='AssignScripts'/>"
1139          "      <menuitem action='AddInstrument'/>"          "      <menuitem action='AddInstrument'/>"
1140          "      <menuitem action='DupInstrument'/>"          "      <menuitem action='DupInstrument'/>"
1141            "      <menuitem action='CombInstruments'/>"
1142          "      <separator/>"          "      <separator/>"
1143          "      <menuitem action='RemoveInstrument'/>"          "      <menuitem action='RemoveInstrument'/>"
1144          "    </menu>"          "    </menu>"
# Line 527  MainWindow::MainWindow() : Line 1175  MainWindow::MainWindow() :
1175          "    <menuitem action='ScriptSlots'/>"          "    <menuitem action='ScriptSlots'/>"
1176          "    <menuitem action='AddInstrument'/>"          "    <menuitem action='AddInstrument'/>"
1177          "    <menuitem action='DupInstrument'/>"          "    <menuitem action='DupInstrument'/>"
1178            "    <menuitem action='CombInstruments'/>"
1179          "    <separator/>"          "    <separator/>"
1180          "    <menuitem action='RemoveInstrument'/>"          "    <menuitem action='RemoveInstrument'/>"
1181          "  </popup>"          "  </popup>"
# Line 550  MainWindow::MainWindow() : Line 1199  MainWindow::MainWindow() :
1199          "  </popup>"          "  </popup>"
1200          "</ui>";          "</ui>";
1201      uiManager->add_ui_from_string(ui_info);      uiManager->add_ui_from_string(ui_info);
1202    #endif
1203    
1204    #if USE_GTKMM_BUILDER
1205        popup_menu = new Gtk::Menu(
1206            Glib::RefPtr<Gio::Menu>::cast_dynamic(
1207                m_uiManager->get_object("PopupMenu")
1208            )
1209        );
1210        sample_popup = new Gtk::Menu(
1211            Glib::RefPtr<Gio::Menu>::cast_dynamic(
1212                m_uiManager->get_object("SamplePopupMenu")
1213            )
1214        );
1215        script_popup = new Gtk::Menu(
1216            Glib::RefPtr<Gio::Menu>::cast_dynamic(
1217                m_uiManager->get_object("ScriptPopupMenu")
1218            )
1219        );
1220    #else
1221      popup_menu = dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/PopupMenu"));      popup_menu = dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/PopupMenu"));
1222            
1223      // Set tooltips for menu items (for some reason, setting a tooltip on the      // Set tooltips for menu items (for some reason, setting a tooltip on the
# Line 570  MainWindow::MainWindow() : Line 1237  MainWindow::MainWindow() :
1237      {      {
1238          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
1239              uiManager->get_widget("/MenuBar/MenuEdit/CopySampleLoop"));              uiManager->get_widget("/MenuBar/MenuEdit/CopySampleLoop"));
1240          item->set_tooltip_text(_("Used when dragging a sample to a region's sample reference field. You may disable this for example if you want to replace an existing sample in a region with a new sample, but don't want that the region's current loop informations to be altered by this action."));          item->set_tooltip_text(_("Used when dragging a sample to a region's sample reference field. You may disable this for example if you want to replace an existing sample in a region with a new sample, but don't want that the region's current loop information to be altered by this action."));
1241      }      }
1242      {      {
1243          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
# Line 585  MainWindow::MainWindow() : Line 1252  MainWindow::MainWindow() :
1252      {      {
1253          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
1254              uiManager->get_widget("/MenuBar/MenuSettings/MoveRootNoteWithRegionMoved"));              uiManager->get_widget("/MenuBar/MenuSettings/MoveRootNoteWithRegionMoved"));
1255          item->set_tooltip_text(_("If checked, and when a region is moved by dragging it around on the virtual keyboard, the keybord position dependent pitch will move exactly with the amount of semi tones the region was moved around."));          item->set_tooltip_text(_("If checked, and when a region is moved by dragging it around on the virtual keyboard, the keyboard position dependent pitch will move exactly with the amount of semi tones the region was moved around."));
1256      }      }
1257      {      {
1258          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
# Line 616  MainWindow::MainWindow() : Line 1283  MainWindow::MainWindow() :
1283              uiManager->get_widget("/MenuBar/MenuTools/MergeFiles"));              uiManager->get_widget("/MenuBar/MenuTools/MergeFiles"));
1284          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."));
1285      }      }
1286    #endif
1287    
1288    #if USE_GTKMM_BUILDER
1289        assign_scripts_menu = new Gtk::Menu(
1290            Glib::RefPtr<Gio::Menu>::cast_dynamic(
1291                m_uiManager->get_object("AssignScripts")
1292            )
1293        );
1294    #else
1295      instrument_menu = static_cast<Gtk::MenuItem*>(      instrument_menu = static_cast<Gtk::MenuItem*>(
1296          uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments"))->get_submenu();          uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments"))->get_submenu();
1297    
1298        assign_scripts_menu = static_cast<Gtk::MenuItem*>(
1299            uiManager->get_widget("/MenuBar/MenuInstrument/AssignScripts"))->get_submenu();
1300    #endif
1301    
1302    #if USE_GTKMM_BUILDER
1303        Gtk::Widget* menuBar = NULL;
1304        m_uiManager->get_widget("MenuBar", menuBar);
1305    #else
1306      Gtk::Widget* menuBar = uiManager->get_widget("/MenuBar");      Gtk::Widget* menuBar = uiManager->get_widget("/MenuBar");
1307    #endif
1308    
1309      m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK);      m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK);
1310      m_VBox.pack_start(m_HPaned);      m_VBox.pack_start(m_HPaned);
1311      m_VBox.pack_start(m_RegionChooser, Gtk::PACK_SHRINK);      m_VBox.pack_start(m_RegionChooser, Gtk::PACK_SHRINK);
# Line 632  MainWindow::MainWindow() : Line 1316  MainWindow::MainWindow() :
1316      set_file_is_shared(false);      set_file_is_shared(false);
1317    
1318      // Status Bar:      // Status Bar:
1319    #if USE_GTKMM_BOX
1320    # warning No status bar layout for GTKMM 4 yet
1321    #else
1322      m_StatusBar.pack_start(m_AttachedStateLabel, Gtk::PACK_SHRINK);      m_StatusBar.pack_start(m_AttachedStateLabel, Gtk::PACK_SHRINK);
1323      m_StatusBar.pack_start(m_AttachedStateImage, Gtk::PACK_SHRINK);      m_StatusBar.pack_start(m_AttachedStateImage, Gtk::PACK_SHRINK);
1324    #endif
1325      m_StatusBar.show();      m_StatusBar.show();
1326    
1327      m_RegionChooser.signal_region_selected().connect(      m_RegionChooser.signal_region_selected().connect(
# Line 644  MainWindow::MainWindow() : Line 1332  MainWindow::MainWindow() :
1332    
1333      // Create the Tree model:      // Create the Tree model:
1334      m_refTreeModel = Gtk::ListStore::create(m_Columns);      m_refTreeModel = Gtk::ListStore::create(m_Columns);
1335      m_TreeView.set_model(m_refTreeModel);      m_refTreeModelFilter = Gtk::TreeModelFilter::create(m_refTreeModel);
1336        m_refTreeModelFilter->set_visible_func(
1337            sigc::mem_fun(*this, &MainWindow::instrument_row_visible)
1338        );
1339        m_TreeView.set_model(m_refTreeModelFilter);
1340    
1341      m_TreeView.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);      m_TreeView.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
1342      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."));
1343      instrument_name_connection = m_refTreeModel->signal_row_changed().connect(      instrument_name_connection = m_refTreeModel->signal_row_changed().connect(
# Line 654  MainWindow::MainWindow() : Line 1347  MainWindow::MainWindow() :
1347      // Add the TreeView's view columns:      // Add the TreeView's view columns:
1348      m_TreeView.append_column(_("Nr"), m_Columns.m_col_nr);      m_TreeView.append_column(_("Nr"), m_Columns.m_col_nr);
1349      m_TreeView.append_column_editable(_("Instrument"), m_Columns.m_col_name);      m_TreeView.append_column_editable(_("Instrument"), m_Columns.m_col_name);
1350        m_TreeView.append_column(_("Scripts"), m_Columns.m_col_scripts);
1351      m_TreeView.set_headers_visible(true);      m_TreeView.set_headers_visible(true);
1352            
1353      // establish drag&drop within the instrument tree view, allowing to reorder      // establish drag&drop within the instrument tree view, allowing to reorder
# Line 699  MainWindow::MainWindow() : Line 1393  MainWindow::MainWindow() :
1393          );          );
1394      }      }
1395      m_TreeViewSamples.set_headers_visible(true);      m_TreeViewSamples.set_headers_visible(true);
1396    #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
1397        m_TreeViewSamples.signal_button_press_event().connect(
1398            sigc::mem_fun(*this, &MainWindow::on_sample_treeview_button_release)
1399        );
1400    #else
1401      m_TreeViewSamples.signal_button_press_event().connect_notify(      m_TreeViewSamples.signal_button_press_event().connect_notify(
1402          sigc::mem_fun(*this, &MainWindow::on_sample_treeview_button_release)          sigc::mem_fun(*this, &MainWindow::on_sample_treeview_button_release)
1403      );      );
1404    #endif
1405      m_refSamplesTreeModel->signal_row_changed().connect(      m_refSamplesTreeModel->signal_row_changed().connect(
1406          sigc::mem_fun(*this, &MainWindow::sample_name_changed)          sigc::mem_fun(*this, &MainWindow::sample_name_changed)
1407      );      );
# Line 718  MainWindow::MainWindow() : Line 1418  MainWindow::MainWindow() :
1418      // m_TreeViewScripts.set_reorderable();      // m_TreeViewScripts.set_reorderable();
1419      m_TreeViewScripts.append_column_editable("Samples", m_ScriptsModel.m_col_name);      m_TreeViewScripts.append_column_editable("Samples", m_ScriptsModel.m_col_name);
1420      m_TreeViewScripts.set_headers_visible(false);      m_TreeViewScripts.set_headers_visible(false);
1421    #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
1422        m_TreeViewScripts.signal_button_press_event().connect(
1423            sigc::mem_fun(*this, &MainWindow::on_script_treeview_button_release)
1424        );
1425    #else
1426      m_TreeViewScripts.signal_button_press_event().connect_notify(      m_TreeViewScripts.signal_button_press_event().connect_notify(
1427          sigc::mem_fun(*this, &MainWindow::on_script_treeview_button_release)          sigc::mem_fun(*this, &MainWindow::on_script_treeview_button_release)
1428      );      );
1429    #endif
1430      //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 ?
1431      m_TreeViewScripts.signal_row_activated().connect(      m_TreeViewScripts.signal_row_activated().connect(
1432          sigc::mem_fun(*this, &MainWindow::script_double_clicked)          sigc::mem_fun(*this, &MainWindow::script_double_clicked)
# Line 819  MainWindow::MainWindow() : Line 1525  MainWindow::MainWindow() :
1525      dimreg_stereo.signal_toggled().connect(      dimreg_stereo.signal_toggled().connect(
1526          sigc::mem_fun(*this, &MainWindow::update_dimregs));          sigc::mem_fun(*this, &MainWindow::update_dimregs));
1527    
1528        m_searchText.signal_changed().connect(
1529            sigc::mem_fun(m_refTreeModelFilter.operator->(), &Gtk::TreeModelFilter::refilter)
1530        );
1531    
1532      file = 0;      file = 0;
1533      file_is_changed = false;      file_is_changed = false;
1534    
1535    #if HAS_GTKMM_SHOW_ALL_CHILDREN
1536      show_all_children();      show_all_children();
1537    #endif
1538    
1539      // start with a new gig file by default      // start with a new gig file by default
1540      on_action_file_new();      on_action_file_new();
1541    
1542        m_TreeViewNotebook.signal_switch_page().connect(
1543            sigc::mem_fun(*this, &MainWindow::on_notebook_tab_switched)
1544        );
1545    
1546      // select 'Instruments' tab by default      // select 'Instruments' tab by default
1547      // (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)
1548      m_TreeViewNotebook.set_current_page(1);      m_TreeViewNotebook.set_current_page(1);
# Line 839  MainWindow::MainWindow() : Line 1555  MainWindow::MainWindow() :
1555    
1556      // setup macros and their keyboard accelerators      // setup macros and their keyboard accelerators
1557      {      {
1558    #if USE_GTKMM_BUILDER
1559            menuMacro = new Gtk::Menu(
1560                Glib::RefPtr<Gio::Menu>::cast_dynamic(
1561                    m_uiManager->get_object("MenuMacro")
1562                )
1563            );
1564    #else
1565          Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>(          Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>(
1566              uiManager->get_widget("/MenuBar/MenuMacro")              uiManager->get_widget("/MenuBar/MenuMacro")
1567          )->get_submenu();          )->get_submenu();
   
         const Gdk::ModifierType primaryModifierKey =  
 #if defined(__APPLE__)  
             Gdk::META_MASK; // Cmd key on Mac  
 #else  
             Gdk::CONTROL_MASK; // Ctrl key on all other OSs  
1568  #endif  #endif
1569    
1570          const Gdk::ModifierType noModifier = (Gdk::ModifierType)0;          const Gdk::ModifierType noModifier = (Gdk::ModifierType)0;
# Line 870  MainWindow::MainWindow() : Line 1587  MainWindow::MainWindow() :
1587    
1588          updateMacroMenu();          updateMacroMenu();
1589      }      }
1590    
1591        // setup "Assign Scripts" keyboard accelerators
1592        {
1593            Gtk::AccelMap::add_entry("<Scripts>/script_0", GDK_KEY_F1, Gdk::SHIFT_MASK);
1594            Gtk::AccelMap::add_entry("<Scripts>/script_1", GDK_KEY_F2, Gdk::SHIFT_MASK);
1595            Gtk::AccelMap::add_entry("<Scripts>/script_2", GDK_KEY_F3, Gdk::SHIFT_MASK);
1596            Gtk::AccelMap::add_entry("<Scripts>/script_3", GDK_KEY_F4, Gdk::SHIFT_MASK);
1597            Gtk::AccelMap::add_entry("<Scripts>/script_4", GDK_KEY_F5, Gdk::SHIFT_MASK);
1598            Gtk::AccelMap::add_entry("<Scripts>/script_5", GDK_KEY_F6, Gdk::SHIFT_MASK);
1599            Gtk::AccelMap::add_entry("<Scripts>/script_6", GDK_KEY_F7, Gdk::SHIFT_MASK);
1600            Gtk::AccelMap::add_entry("<Scripts>/script_7", GDK_KEY_F8, Gdk::SHIFT_MASK);
1601            Gtk::AccelMap::add_entry("<Scripts>/script_8", GDK_KEY_F9, Gdk::SHIFT_MASK);
1602            Gtk::AccelMap::add_entry("<Scripts>/script_9", GDK_KEY_F10, Gdk::SHIFT_MASK);
1603            Gtk::AccelMap::add_entry("<Scripts>/script_10", GDK_KEY_F11, Gdk::SHIFT_MASK);
1604            Gtk::AccelMap::add_entry("<Scripts>/script_11", GDK_KEY_F12, Gdk::SHIFT_MASK);
1605    
1606            Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group();
1607            assign_scripts_menu->set_accel_group(accelGroup);
1608        }
1609    
1610        Glib::signal_idle().connect_once(
1611            sigc::mem_fun(*this, &MainWindow::bringToFront),
1612            200
1613        );
1614  }  }
1615    
1616  MainWindow::~MainWindow()  MainWindow::~MainWindow()
1617  {  {
1618  }  }
1619    
1620    void MainWindow::bringToFront() {
1621        #if defined(__APPLE__)
1622        macRaiseAppWindow();
1623        #endif
1624        raise();
1625        present();
1626    }
1627    
1628  void MainWindow::updateMacroMenu() {  void MainWindow::updateMacroMenu() {
1629    #if !USE_GTKMM_BUILDER
1630      Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>(      Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>(
1631          uiManager->get_widget("/MenuBar/MenuMacro")          uiManager->get_widget("/MenuBar/MenuMacro")
1632      )->get_submenu();      )->get_submenu();
1633    #endif
1634    
1635      // remove all entries from "Macro" menu      // remove all entries from "Macro" menu
1636      {      {
# Line 937  void MainWindow::updateMacroMenu() { Line 1688  void MainWindow::updateMacroMenu() {
1688          item->set_accel_path("<Macros>/SetupMacros");          item->set_accel_path("<Macros>/SetupMacros");
1689      }      }
1690    
1691    #if HAS_GTKMM_SHOW_ALL_CHILDREN
1692      menuMacro->show_all_children();      menuMacro->show_all_children();
1693    #endif
1694  }  }
1695    
1696  void MainWindow::onMacroSelected(int iMacro) {  void MainWindow::onMacroSelected(int iMacro) {
# Line 974  void MainWindow::onMacrosSetupChanged(co Line 1727  void MainWindow::onMacrosSetupChanged(co
1727      updateMacroMenu();      updateMacroMenu();
1728  }  }
1729    
1730    //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.
1731    void MainWindow::on_notebook_tab_switched(void* page, guint page_num) {
1732        bool isInstrumentsPage = (page_num == 1);
1733        // so far we only support filtering for the instruments list, so hide the
1734        // filter text entry field if another tab is selected
1735        m_searchField.set_visible(isInstrumentsPage);
1736    }
1737    
1738  bool MainWindow::on_delete_event(GdkEventAny* event)  bool MainWindow::on_delete_event(GdkEventAny* event)
1739  {  {
1740      return !file_is_shared && file_is_changed && !close_confirmation_dialog();      return !file_is_shared && file_is_changed && !close_confirmation_dialog();
# Line 995  gig::Instrument* MainWindow::get_instrum Line 1756  gig::Instrument* MainWindow::get_instrum
1756      gig::Instrument* instrument = 0;      gig::Instrument* instrument = 0;
1757      std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows();      std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows();
1758      if (rows.empty()) return NULL;      if (rows.empty()) return NULL;
1759      Gtk::TreeModel::const_iterator it = m_refTreeModel->get_iter(rows[0]);      //NOTE: was const_iterator before, which did not compile with GTKMM4 development branch, probably going to be fixed before final GTKMM4 release though.
1760        Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]);
1761      if (it) {      if (it) {
1762          Gtk::TreeModel::Row row = *it;          Gtk::TreeModel::Row row = *it;
1763          instrument = row[m_Columns.m_col_instr];          instrument = row[m_Columns.m_col_instr];
# Line 1061  void MainWindow::dimreg_changed() Line 1823  void MainWindow::dimreg_changed()
1823    
1824  void MainWindow::on_sel_change()  void MainWindow::on_sel_change()
1825  {  {
1826    #if !USE_GTKMM_BUILDER
1827      // select item in instrument menu      // select item in instrument menu
1828      std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows();      std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows();
1829      if (!rows.empty()) {      if (!rows.empty()) {
# Line 1073  void MainWindow::on_sel_change() Line 1836  void MainWindow::on_sel_change()
1836              static_cast<Gtk::RadioMenuItem*>(children[index])->set_active();              static_cast<Gtk::RadioMenuItem*>(children[index])->set_active();
1837          }          }
1838      }      }
1839    #endif
1840    
1841        updateScriptListOfMenu();
1842    
1843      m_RegionChooser.set_instrument(get_instrument());      m_RegionChooser.set_instrument(get_instrument());
1844    
# Line 1212  void Saver::thread_function() Line 1978  void Saver::thread_function()
1978                  }                  }
1979                  #else // POSIX ...                  #else // POSIX ...
1980                  if (unlink(filename.c_str())) {                  if (unlink(filename.c_str())) {
1981                      throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file): " + String(strerror(errno)));                      throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file): " + gig::String(strerror(errno)));
1982                  }                  }
1983                  #endif                  #endif
1984                  if (rename(tmpname.c_str(), filename.c_str())) {                  if (rename(tmpname.c_str(), filename.c_str())) {
1985                      #if defined(WIN32)                      #if defined(WIN32)
1986                      throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file).");                      throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file).");
1987                      #else                      #else
1988                      throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file): " + String(strerror(errno)));                      throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file): " + gig::String(strerror(errno)));
1989                      #endif                      #endif
1990                  }                  }
1991              }              }
# Line 1281  Glib::Dispatcher& Saver::signal_error() Line 2047  Glib::Dispatcher& Saver::signal_error()
2047  ProgressDialog::ProgressDialog(const Glib::ustring& title, Gtk::Window& parent)  ProgressDialog::ProgressDialog(const Glib::ustring& title, Gtk::Window& parent)
2048      : Gtk::Dialog(title, parent, true)      : Gtk::Dialog(title, parent, true)
2049  {  {
2050    #if USE_GTKMM_BOX
2051        get_content_area()->pack_start(progressBar);
2052    #else
2053      get_vbox()->pack_start(progressBar);      get_vbox()->pack_start(progressBar);
2054    #endif
2055    #if HAS_GTKMM_SHOW_ALL_CHILDREN
2056      show_all_children();      show_all_children();
2057    #endif
2058      resize(600,50);      resize(600,50);
2059  }  }
2060    
# Line 1295  void MainWindow::__clear() { Line 2067  void MainWindow::__clear() {
2067      m_refTreeModel->clear();      m_refTreeModel->clear();
2068      m_refSamplesTreeModel->clear();      m_refSamplesTreeModel->clear();
2069      m_refScriptsTreeModel->clear();      m_refScriptsTreeModel->clear();
2070    #if !USE_GTKMM_BUILDER
2071      // remove all entries from "Instrument" menu      // remove all entries from "Instrument" menu
2072      while (!instrument_menu->get_children().empty()) {      while (!instrument_menu->get_children().empty()) {
2073          remove_instrument_from_menu(0);          remove_instrument_from_menu(0);
2074      }      }
2075    #endif
2076      // free libgig's gig::File instance      // free libgig's gig::File instance
2077      if (file && !file_is_shared) delete file;      if (file && !file_is_shared) delete file;
2078      file = NULL;      file = NULL;
# Line 1310  void MainWindow::__refreshEntireGUI() { Line 2084  void MainWindow::__refreshEntireGUI() {
2084      m_refTreeModel->clear();      m_refTreeModel->clear();
2085      m_refSamplesTreeModel->clear();      m_refSamplesTreeModel->clear();
2086      m_refScriptsTreeModel->clear();      m_refScriptsTreeModel->clear();
2087    #if !USE_GTKMM_BUILDER
2088      // remove all entries from "Instrument" menu      // remove all entries from "Instrument" menu
2089      while (!instrument_menu->get_children().empty()) {      while (!instrument_menu->get_children().empty()) {
2090          remove_instrument_from_menu(0);          remove_instrument_from_menu(0);
2091      }      }
2092    #endif
2093    
2094      if (!this->file) return;      if (!this->file) return;
2095    
# Line 1347  bool MainWindow::close_confirmation_dial Line 2123  bool MainWindow::close_confirmation_dial
2123      g_free(msg);      g_free(msg);
2124      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."));
2125      dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO);      dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO);
2126    #if HAS_GTKMM_STOCK
2127      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
2128      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);
2129    #else
2130        dialog.add_button(_("_OK"), Gtk::RESPONSE_OK);
2131        dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
2132    #endif
2133      dialog.set_default_response(Gtk::RESPONSE_YES);      dialog.set_default_response(Gtk::RESPONSE_YES);
2134      int response = dialog.run();      int response = dialog.run();
2135      dialog.hide();      dialog.hide();
# Line 1379  bool MainWindow::leaving_shared_mode_dia Line 2160  bool MainWindow::leaving_shared_mode_dia
2160            "used by the sampler until you tell the sampler explicitly to "            "used by the sampler until you tell the sampler explicitly to "
2161            "load it."));            "load it."));
2162      dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES);      dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES);
2163    #if HAS_GTKMM_STOCK
2164      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
2165    #else
2166        dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
2167    #endif
2168      dialog.set_default_response(Gtk::RESPONSE_CANCEL);      dialog.set_default_response(Gtk::RESPONSE_CANCEL);
2169      int response = dialog.run();      int response = dialog.run();
2170      dialog.hide();      dialog.hide();
# Line 1393  void MainWindow::on_action_file_open() Line 2178  void MainWindow::on_action_file_open()
2178      if (file_is_shared && !leaving_shared_mode_dialog()) return;      if (file_is_shared && !leaving_shared_mode_dialog()) return;
2179    
2180      Gtk::FileChooserDialog dialog(*this, _("Open file"));      Gtk::FileChooserDialog dialog(*this, _("Open file"));
2181    #if HAS_GTKMM_STOCK
2182      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
2183      dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);      dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
2184    #else
2185        dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
2186        dialog.add_button(_("_Open"), Gtk::RESPONSE_OK);
2187    #endif
2188      dialog.set_default_response(Gtk::RESPONSE_OK);      dialog.set_default_response(Gtk::RESPONSE_OK);
2189  #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
2190      Gtk::FileFilter filter;      Gtk::FileFilter filter;
# Line 1426  void MainWindow::load_file(const char* n Line 2216  void MainWindow::load_file(const char* n
2216          Glib::filename_display_basename(name) + "' ...",          Glib::filename_display_basename(name) + "' ...",
2217          *this          *this
2218      );      );
2219    #if HAS_GTKMM_SHOW_ALL_CHILDREN
2220      progress_dialog->show_all();      progress_dialog->show_all();
2221    #endif
2222      loader = new Loader(name); //FIXME: memory leak!      loader = new Loader(name); //FIXME: memory leak!
2223      loader->signal_progress().connect(      loader->signal_progress().connect(
2224          sigc::mem_fun(*this, &MainWindow::on_loader_progress));          sigc::mem_fun(*this, &MainWindow::on_loader_progress));
# Line 1460  void MainWindow::load_instrument(gig::In Line 2252  void MainWindow::load_instrument(gig::In
2252              // make sure the selected item in the "instruments" tree view is              // make sure the selected item in the "instruments" tree view is
2253              // visible (scroll to it)              // visible (scroll to it)
2254              m_TreeView.scroll_to_row(Gtk::TreePath(ToString(i)));              m_TreeView.scroll_to_row(Gtk::TreePath(ToString(i)));
2255    #if !USE_GTKMM_BUILDER
2256              // select item in instrument menu              // select item in instrument menu
2257              {              {
2258                  const std::vector<Gtk::Widget*> children =                  const std::vector<Gtk::Widget*> children =
2259                      instrument_menu->get_children();                      instrument_menu->get_children();
2260                  static_cast<Gtk::RadioMenuItem*>(children[i])->set_active();                  static_cast<Gtk::RadioMenuItem*>(children[i])->set_active();
2261              }              }
2262    #endif
2263              // update region chooser and dimension region chooser              // update region chooser and dimension region chooser
2264              m_RegionChooser.set_instrument(instr);              m_RegionChooser.set_instrument(instr);
2265              break;              break;
# Line 1537  bool MainWindow::file_save() Line 2331  bool MainWindow::file_save()
2331          Glib::filename_display_basename(this->filename) + "' ...",          Glib::filename_display_basename(this->filename) + "' ...",
2332          *this          *this
2333      );      );
2334    #if HAS_GTKMM_SHOW_ALL_CHILDREN
2335      progress_dialog->show_all();      progress_dialog->show_all();
2336    #endif
2337      saver = new Saver(this->file); //FIXME: memory leak!      saver = new Saver(this->file); //FIXME: memory leak!
2338      saver->signal_progress().connect(      saver->signal_progress().connect(
2339          sigc::mem_fun(*this, &MainWindow::on_saver_progress));          sigc::mem_fun(*this, &MainWindow::on_saver_progress));
# Line 1590  void MainWindow::on_action_file_save_as( Line 2386  void MainWindow::on_action_file_save_as(
2386  bool MainWindow::file_save_as()  bool MainWindow::file_save_as()
2387  {  {
2388      Gtk::FileChooserDialog dialog(*this, _("Save as"), Gtk::FILE_CHOOSER_ACTION_SAVE);      Gtk::FileChooserDialog dialog(*this, _("Save as"), Gtk::FILE_CHOOSER_ACTION_SAVE);
2389    #if HAS_GTKMM_STOCK
2390      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
2391      dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);      dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);
2392    #else
2393        dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
2394        dialog.add_button(_("_Save"), Gtk::RESPONSE_OK);
2395    #endif
2396      dialog.set_default_response(Gtk::RESPONSE_OK);      dialog.set_default_response(Gtk::RESPONSE_OK);
2397      dialog.set_do_overwrite_confirmation();      dialog.set_do_overwrite_confirmation();
2398    
# Line 1620  bool MainWindow::file_save_as() Line 2421  bool MainWindow::file_save_as()
2421      }      }
2422    
2423      // show warning in the dialog      // show warning in the dialog
2424      Gtk::HBox descriptionArea;      HBox descriptionArea;
2425      descriptionArea.set_spacing(15);      descriptionArea.set_spacing(15);
2426      Gtk::Image warningIcon;      Gtk::Image warningIcon;
2427      warningIcon.set_from_icon_name("dialog-warning",      warningIcon.set_from_icon_name("dialog-warning",
# Line 1641  bool MainWindow::file_save_as() Line 2442  bool MainWindow::file_save_as()
2442            "same .gig file will end up in corrupted sample wave data!\n")            "same .gig file will end up in corrupted sample wave data!\n")
2443      );      );
2444      descriptionArea.pack_start(description);      descriptionArea.pack_start(description);
2445    #if USE_GTKMM_BOX
2446        dialog.get_content_area()->pack_start(descriptionArea, Gtk::PACK_SHRINK);
2447    #else
2448      dialog.get_vbox()->pack_start(descriptionArea, Gtk::PACK_SHRINK);      dialog.get_vbox()->pack_start(descriptionArea, Gtk::PACK_SHRINK);
2449    #endif
2450    #if HAS_GTKMM_SHOW_ALL_CHILDREN
2451      descriptionArea.show_all();      descriptionArea.show_all();
2452    #endif
2453    
2454      if (dialog.run() == Gtk::RESPONSE_OK) {      if (dialog.run() == Gtk::RESPONSE_OK) {
2455          std::string filename = dialog.get_filename();          std::string filename = dialog.get_filename();
# Line 1656  bool MainWindow::file_save_as() Line 2463  bool MainWindow::file_save_as()
2463              Glib::filename_display_basename(filename) + "' ...",              Glib::filename_display_basename(filename) + "' ...",
2464              *this              *this
2465          );          );
2466    #if HAS_GTKMM_SHOW_ALL_CHILDREN
2467          progress_dialog->show_all();          progress_dialog->show_all();
2468    #endif
2469    
2470          saver = new Saver(file, filename); //FIXME: memory leak!          saver = new Saver(file, filename); //FIXME: memory leak!
2471          saver->signal_progress().connect(          saver->signal_progress().connect(
# Line 1815  void MainWindow::on_action_help_about() Line 2624  void MainWindow::on_action_help_about()
2624      dialog.set_comments(sComment.c_str());      dialog.set_comments(sComment.c_str());
2625      dialog.set_website("http://www.linuxsampler.org");      dialog.set_website("http://www.linuxsampler.org");
2626      dialog.set_website_label("http://www.linuxsampler.org");      dialog.set_website_label("http://www.linuxsampler.org");
2627        dialog.set_position(Gtk::WIN_POS_CENTER);
2628      dialog.run();      dialog.run();
2629  }  }
2630    
# Line 1836  PropDialog::PropDialog() Line 2646  PropDialog::PropDialog()
2646        eSourceForm(_("Source form")),        eSourceForm(_("Source form")),
2647        eCommissioned(_("Commissioned")),        eCommissioned(_("Commissioned")),
2648        eSubject(_("Subject")),        eSubject(_("Subject")),
2649    #if HAS_GTKMM_STOCK
2650        quitButton(Gtk::Stock::CLOSE),        quitButton(Gtk::Stock::CLOSE),
2651    #else
2652          quitButton(_("_Close")),
2653    #endif
2654        table(2, 1),        table(2, 1),
2655        m_file(NULL)        m_file(NULL)
2656  {  {
2657        if (!Settings::singleton()->autoRestoreWindowDimension) {
2658            set_default_size(470, 390);
2659            set_position(Gtk::WIN_POS_MOUSE);
2660        }
2661    
2662      set_title(_("File Properties"));      set_title(_("File Properties"));
2663      eName.set_width_chars(50);      eName.set_width_chars(50);
2664    
# Line 1878  PropDialog::PropDialog() Line 2697  PropDialog::PropDialog()
2697      table.add(eCommissioned);      table.add(eCommissioned);
2698      table.add(eSubject);      table.add(eSubject);
2699    
2700    #if USE_GTKMM_GRID
2701        table.set_column_spacing(5);
2702    #else
2703      table.set_col_spacings(5);      table.set_col_spacings(5);
2704    #endif
2705    
2706      add(vbox);      add(vbox);
2707    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22)
2708        table.set_margin(5);
2709    #else
2710      table.set_border_width(5);      table.set_border_width(5);
2711    #endif
2712      vbox.add(table);      vbox.add(table);
2713      vbox.pack_start(buttonBox, Gtk::PACK_SHRINK);      vbox.pack_start(buttonBox, Gtk::PACK_SHRINK);
2714      buttonBox.set_layout(Gtk::BUTTONBOX_END);      buttonBox.set_layout(Gtk::BUTTONBOX_END);
2715    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22)
2716        buttonBox.set_margin(5);
2717    #else
2718      buttonBox.set_border_width(5);      buttonBox.set_border_width(5);
2719    #endif
2720      buttonBox.show();      buttonBox.show();
2721      buttonBox.pack_start(quitButton);      buttonBox.pack_start(quitButton);
2722      quitButton.set_can_default();      quitButton.set_can_default();
# Line 1896  PropDialog::PropDialog() Line 2728  PropDialog::PropDialog()
2728    
2729      quitButton.show();      quitButton.show();
2730      vbox.show();      vbox.show();
2731    #if HAS_GTKMM_SHOW_ALL_CHILDREN
2732      show_all_children();      show_all_children();
2733    #endif
2734  }  }
2735    
2736  void PropDialog::set_file(gig::File* file)  void PropDialog::set_file(gig::File* file)
# Line 1959  void InstrumentProps::set_MIDIProgram(ui Line 2793  void InstrumentProps::set_MIDIProgram(ui
2793  }  }
2794    
2795  InstrumentProps::InstrumentProps() :  InstrumentProps::InstrumentProps() :
2796    #if HAS_GTKMM_STOCK
2797      quitButton(Gtk::Stock::CLOSE),      quitButton(Gtk::Stock::CLOSE),
2798    #else
2799        quitButton(_("_Close")),
2800    #endif
2801      table(2,1),      table(2,1),
2802      eName(_("Name")),      eName(_("Name")),
2803      eIsDrum(_("Is drum")),      eIsDrum(_("Is drum")),
# Line 1969  InstrumentProps::InstrumentProps() : Line 2807  InstrumentProps::InstrumentProps() :
2807      eGainPlus6(_("Gain +6dB"), eAttenuation, -6),      eGainPlus6(_("Gain +6dB"), eAttenuation, -6),
2808      eEffectSend(_("Effect send"), 0, 65535),      eEffectSend(_("Effect send"), 0, 65535),
2809      eFineTune(_("Fine tune"), -8400, 8400),      eFineTune(_("Fine tune"), -8400, 8400),
2810      ePitchbendRange(_("Pitchbend range"), 0, 12),      ePitchbendRange(_("Pitchbend range"), 0, 48),
2811      ePianoReleaseMode(_("Piano release mode")),      ePianoReleaseMode(_("Piano release mode")),
2812      eDimensionKeyRangeLow(_("Keyswitching range low")),      eDimensionKeyRangeLow(_("Keyswitching range low")),
2813      eDimensionKeyRangeHigh(_("Keyswitching range high"))      eDimensionKeyRangeHigh(_("Keyswitching range high"))
2814  {  {
2815        if (!Settings::singleton()->autoRestoreWindowDimension) {
2816            //set_default_size(470, 390);
2817            set_position(Gtk::WIN_POS_MOUSE);
2818        }
2819    
2820      set_title(_("Instrument Properties"));      set_title(_("Instrument Properties"));
2821    
2822      eDimensionKeyRangeLow.set_tip(      eDimensionKeyRangeLow.set_tip(
# Line 2000  InstrumentProps::InstrumentProps() : Line 2843  InstrumentProps::InstrumentProps() :
2843    
2844      eName.signal_value_changed().connect(sig_name_changed.make_slot());      eName.signal_value_changed().connect(sig_name_changed.make_slot());
2845    
2846    #if USE_GTKMM_GRID
2847        table.set_column_spacing(5);
2848    #else
2849      table.set_col_spacings(5);      table.set_col_spacings(5);
2850    #endif
2851    
2852      table.add(eName);      table.add(eName);
2853      table.add(eIsDrum);      table.add(eIsDrum);
# Line 2016  InstrumentProps::InstrumentProps() : Line 2863  InstrumentProps::InstrumentProps() :
2863      table.add(eDimensionKeyRangeHigh);      table.add(eDimensionKeyRangeHigh);
2864    
2865      add(vbox);      add(vbox);
2866    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22)
2867        table.set_margin(5);
2868    #else
2869      table.set_border_width(5);      table.set_border_width(5);
2870    #endif
2871      vbox.pack_start(table);      vbox.pack_start(table);
2872      table.show();      table.show();
2873      vbox.pack_start(buttonBox, Gtk::PACK_SHRINK);      vbox.pack_start(buttonBox, Gtk::PACK_SHRINK);
2874      buttonBox.set_layout(Gtk::BUTTONBOX_END);      buttonBox.set_layout(Gtk::BUTTONBOX_END);
2875    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22)
2876        buttonBox.set_margin(5);
2877    #else
2878      buttonBox.set_border_width(5);      buttonBox.set_border_width(5);
2879    #endif
2880      buttonBox.show();      buttonBox.show();
2881      buttonBox.pack_start(quitButton);      buttonBox.pack_start(quitButton);
2882      quitButton.set_can_default();      quitButton.set_can_default();
# Line 2032  InstrumentProps::InstrumentProps() : Line 2887  InstrumentProps::InstrumentProps() :
2887    
2888      quitButton.show();      quitButton.show();
2889      vbox.show();      vbox.show();
2890    #if HAS_GTKMM_SHOW_ALL_CHILDREN
2891      show_all_children();      show_all_children();
2892    #endif
2893  }  }
2894    
2895  void InstrumentProps::set_instrument(gig::Instrument* instrument)  void InstrumentProps::set_instrument(gig::Instrument* instrument)
# Line 2098  void MainWindow::load_gig(gig::File* gig Line 2955  void MainWindow::load_gig(gig::File* gig
2955      for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ;      for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ;
2956           instrument = gig->GetNextInstrument(), ++index) {           instrument = gig->GetNextInstrument(), ++index) {
2957          Glib::ustring name(gig_to_utf8(instrument->pInfo->Name));          Glib::ustring name(gig_to_utf8(instrument->pInfo->Name));
2958            const int iScriptSlots = instrument->ScriptSlotCount();
2959    
2960          Gtk::TreeModel::iterator iter = m_refTreeModel->append();          Gtk::TreeModel::iterator iter = m_refTreeModel->append();
2961          Gtk::TreeModel::Row row = *iter;          Gtk::TreeModel::Row row = *iter;
2962          row[m_Columns.m_col_nr] = index;          row[m_Columns.m_col_nr] = index;
2963          row[m_Columns.m_col_name] = name;          row[m_Columns.m_col_name] = name;
2964          row[m_Columns.m_col_instr] = instrument;          row[m_Columns.m_col_instr] = instrument;
2965            row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : "";
2966    
2967    #if !USE_GTKMM_BUILDER
2968          add_instrument_to_menu(name);          add_instrument_to_menu(name);
2969    #endif
2970      }      }
2971      instrument_name_connection.unblock();      instrument_name_connection.unblock();
2972    #if !USE_GTKMM_BUILDER
2973      uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments")->show();      uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments")->show();
2974    #endif
2975    
2976      updateSampleRefCountMap(gig);      updateSampleRefCountMap(gig);
2977    
# Line 2179  bool MainWindow::instr_props_set_instrum Line 3042  bool MainWindow::instr_props_set_instrum
3042          instrumentProps.hide();          instrumentProps.hide();
3043          return false;          return false;
3044      }      }
3045      Gtk::TreeModel::const_iterator it = m_refTreeModel->get_iter(rows[0]);      //NOTE: was const_iterator before, which did not compile with GTKMM4 development branch, probably going to be fixed before final GTKMM4 release though.
3046        Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]);
3047      if (it) {      if (it) {
3048          Gtk::TreeModel::Row row = *it;          Gtk::TreeModel::Row row = *it;
3049          gig::Instrument* instrument = row[m_Columns.m_col_instr];          gig::Instrument* instrument = row[m_Columns.m_col_instr];
# Line 2196  bool MainWindow::instr_props_set_instrum Line 3060  bool MainWindow::instr_props_set_instrum
3060      } else {      } else {
3061          instrumentProps.hide();          instrumentProps.hide();
3062      }      }
3063      return it;      //NOTE: explicit boolean cast required for GTKMM4 development branch here
3064        return it ? true : false;
3065  }  }
3066    
3067  void MainWindow::show_instr_props()  void MainWindow::show_instr_props()
# Line 2242  void MainWindow::show_script_slots() { Line 3107  void MainWindow::show_script_slots() {
3107    
3108      ScriptSlots* window = new ScriptSlots;      ScriptSlots* window = new ScriptSlots;
3109      window->setInstrument(instrument);      window->setInstrument(instrument);
3110        window->signal_script_slots_changed().connect(
3111            sigc::mem_fun(*this, &MainWindow::onScriptSlotsModified)
3112        );
3113      //window->reparent(*this);      //window->reparent(*this);
3114      window->show();      window->show();
3115  }  }
3116    
3117    void MainWindow::onScriptSlotsModified(gig::Instrument* pInstrument) {
3118        if (!pInstrument) return;
3119        const int iScriptSlots = pInstrument->ScriptSlotCount();
3120    
3121        //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!
3122        //Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model();
3123        Glib::RefPtr<Gtk::TreeModel> model = m_refTreeModelFilter->get_model();
3124    
3125        for (int i = 0; i < model->children().size(); ++i) {
3126            Gtk::TreeModel::Row row = model->children()[i];
3127            if (row[m_Columns.m_col_instr] != pInstrument) continue;
3128            row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : "";
3129            break;
3130        }
3131    
3132        // causes the sampler to reload the instrument with the new script
3133        on_sel_change();
3134    }
3135    
3136    void MainWindow::assignScript(gig::Script* pScript) {
3137        if (!pScript) {
3138            printf("assignScript() : !script\n");
3139            return;
3140        }
3141        printf("assignScript('%s')\n", pScript->Name.c_str());
3142    
3143        gig::Instrument* pInstrument = get_instrument();
3144        if (!pInstrument) {
3145            printf("!instrument\n");
3146            return;
3147        }
3148    
3149        pInstrument->AddScriptSlot(pScript);
3150    
3151        onScriptSlotsModified(pInstrument);
3152    }
3153    
3154  void MainWindow::on_action_refresh_all() {  void MainWindow::on_action_refresh_all() {
3155      __refreshEntireGUI();      __refreshEntireGUI();
3156  }  }
3157    
3158  void MainWindow::on_action_view_status_bar() {  void MainWindow::on_action_view_status_bar() {
3159    #if USE_GLIB_ACTION
3160        bool active = false;
3161        m_actionToggleStatusBar->get_state(active);
3162        // for some reason toggle state does not change automatically
3163        active = !active;
3164        m_actionToggleStatusBar->change_state(active);
3165        if (active)
3166            m_StatusBar.show();
3167        else
3168            m_StatusBar.hide();
3169    #else
3170      Gtk::CheckMenuItem* item =      Gtk::CheckMenuItem* item =
3171          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar"));          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar"));
3172      if (!item) {      if (!item) {
# Line 2259  void MainWindow::on_action_view_status_b Line 3175  void MainWindow::on_action_view_status_b
3175      }      }
3176      if (item->get_active()) m_StatusBar.show();      if (item->get_active()) m_StatusBar.show();
3177      else                    m_StatusBar.hide();      else                    m_StatusBar.hide();
3178    #endif
3179  }  }
3180    
3181  void MainWindow::on_auto_restore_win_dim() {  void MainWindow::on_auto_restore_win_dim() {
3182    #if USE_GLIB_ACTION
3183        bool active = false;
3184        m_actionToggleRestoreWinDim->get_state(active);
3185        // for some reason toggle state does not change automatically
3186        active = !active;
3187        m_actionToggleRestoreWinDim->change_state(active);
3188        Settings::singleton()->autoRestoreWindowDimension = active;
3189    #else
3190      Gtk::CheckMenuItem* item =      Gtk::CheckMenuItem* item =
3191          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/AutoRestoreWinDim"));          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/AutoRestoreWinDim"));
3192      if (!item) {      if (!item) {
# Line 2269  void MainWindow::on_auto_restore_win_dim Line 3194  void MainWindow::on_auto_restore_win_dim
3194          return;          return;
3195      }      }
3196      Settings::singleton()->autoRestoreWindowDimension = item->get_active();      Settings::singleton()->autoRestoreWindowDimension = item->get_active();
3197    #endif
3198  }  }
3199    
3200  void MainWindow::on_save_with_temporary_file() {  void MainWindow::on_save_with_temporary_file() {
3201    #if USE_GLIB_ACTION
3202        bool active = false;
3203        m_actionToggleSaveWithTempFile->get_state(active);
3204        // for some reason toggle state does not change automatically
3205        active = !active;
3206        m_actionToggleSaveWithTempFile->change_state(active);
3207        Settings::singleton()->saveWithTemporaryFile = active;
3208    #else
3209      Gtk::CheckMenuItem* item =      Gtk::CheckMenuItem* item =
3210          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuSettings/SaveWithTemporaryFile"));          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuSettings/SaveWithTemporaryFile"));
3211      if (!item) {      if (!item) {
# Line 2279  void MainWindow::on_save_with_temporary_ Line 3213  void MainWindow::on_save_with_temporary_
3213          return;          return;
3214      }      }
3215      Settings::singleton()->saveWithTemporaryFile = item->get_active();      Settings::singleton()->saveWithTemporaryFile = item->get_active();
3216    #endif
3217  }  }
3218    
3219  bool MainWindow::is_copy_samples_unity_note_enabled() const {  bool MainWindow::is_copy_samples_unity_note_enabled() const {
3220    #if USE_GLIB_ACTION
3221        bool active = false;
3222        m_actionToggleCopySampleUnity->get_state(active);
3223        return active;
3224    #else
3225      Gtk::CheckMenuItem* item =      Gtk::CheckMenuItem* item =
3226          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity"));          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity"));
3227      if (!item) {      if (!item) {
# Line 2289  bool MainWindow::is_copy_samples_unity_n Line 3229  bool MainWindow::is_copy_samples_unity_n
3229          return true;          return true;
3230      }      }
3231      return item->get_active();      return item->get_active();
3232    #endif
3233  }  }
3234    
3235  bool MainWindow::is_copy_samples_fine_tune_enabled() const {  bool MainWindow::is_copy_samples_fine_tune_enabled() const {
3236    #if USE_GLIB_ACTION
3237        bool active = false;
3238        m_actionToggleCopySampleTune->get_state(active);
3239        return active;
3240    #else
3241      Gtk::CheckMenuItem* item =      Gtk::CheckMenuItem* item =
3242          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleTune"));          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleTune"));
3243      if (!item) {      if (!item) {
# Line 2299  bool MainWindow::is_copy_samples_fine_tu Line 3245  bool MainWindow::is_copy_samples_fine_tu
3245          return true;          return true;
3246      }      }
3247      return item->get_active();      return item->get_active();
3248    #endif
3249  }  }
3250    
3251  bool MainWindow::is_copy_samples_loop_enabled() const {  bool MainWindow::is_copy_samples_loop_enabled() const {
3252    #if USE_GLIB_ACTION
3253        bool active = false;
3254        m_actionToggleCopySampleLoop->get_state(active);
3255        return active;
3256    #else
3257      Gtk::CheckMenuItem* item =      Gtk::CheckMenuItem* item =
3258          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleLoop"));          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleLoop"));
3259      if (!item) {      if (!item) {
# Line 2309  bool MainWindow::is_copy_samples_loop_en Line 3261  bool MainWindow::is_copy_samples_loop_en
3261          return true;          return true;
3262      }      }
3263      return item->get_active();      return item->get_active();
3264    #endif
3265  }  }
3266    
3267  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
3268  {  bool MainWindow::on_button_release(Gdk::EventButton& _button) {
3269        GdkEventButton* button = _button.gobj();
3270    #else
3271    void MainWindow::on_button_release(GdkEventButton* button) {
3272    #endif
3273      if (button->type == GDK_2BUTTON_PRESS) {      if (button->type == GDK_2BUTTON_PRESS) {
3274          show_instr_props();          show_instr_props();
3275      } else if (button->type == GDK_BUTTON_PRESS && button->button == 3) {      } else if (button->type == GDK_BUTTON_PRESS && button->button == 3) {
3276          // gig v2 files have no midi rules          // gig v2 files have no midi rules
3277          const bool bEnabled = !(file->pVersion && file->pVersion->major == 2);          const bool bEnabled = !(file->pVersion && file->pVersion->major == 2);
3278    #if USE_GTKMM_BUILDER
3279            m_actionMIDIRules->property_enabled() = bEnabled;
3280    #else
3281          static_cast<Gtk::MenuItem*>(          static_cast<Gtk::MenuItem*>(
3282              uiManager->get_widget("/MenuBar/MenuInstrument/MidiRules"))->set_sensitive(              uiManager->get_widget("/MenuBar/MenuInstrument/MidiRules"))->set_sensitive(
3283                  bEnabled                  bEnabled
# Line 2326  void MainWindow::on_button_release(GdkEv Line 3286  void MainWindow::on_button_release(GdkEv
3286              uiManager->get_widget("/PopupMenu/MidiRules"))->set_sensitive(              uiManager->get_widget("/PopupMenu/MidiRules"))->set_sensitive(
3287                  bEnabled                  bEnabled
3288              );              );
3289    #endif
3290          popup_menu->popup(button->button, button->time);          popup_menu->popup(button->button, button->time);
3291      }      }
3292    #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
3293        return false;
3294    #endif
3295  }  }
3296    
3297    #if !USE_GTKMM_BUILDER
3298  void MainWindow::on_instrument_selection_change(Gtk::RadioMenuItem* item) {  void MainWindow::on_instrument_selection_change(Gtk::RadioMenuItem* item) {
3299      if (item->get_active()) {      if (item->get_active()) {
3300          const std::vector<Gtk::Widget*> children =          const std::vector<Gtk::Widget*> children =
# Line 2344  void MainWindow::on_instrument_selection Line 3309  void MainWindow::on_instrument_selection
3309          }          }
3310      }      }
3311  }  }
3312    #endif
3313    
3314  void MainWindow::select_instrument(gig::Instrument* instrument) {  void MainWindow::select_instrument(gig::Instrument* instrument) {
3315      if (!instrument) return;      if (!instrument) return;
3316    
3317        //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!
3318      Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model();      Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model();
3319        //Glib::RefPtr<Gtk::TreeModel> model = m_refTreeModelFilter->get_model();
3320    
3321      for (int i = 0; i < model->children().size(); ++i) {      for (int i = 0; i < model->children().size(); ++i) {
3322          Gtk::TreeModel::Row row = model->children()[i];          Gtk::TreeModel::Row row = model->children()[i];
3323          if (row[m_Columns.m_col_instr] == instrument) {          if (row[m_Columns.m_col_instr] == instrument) {
3324              // select and show the respective instrument in the list view              // select and show the respective instrument in the list view
3325              show_intruments_tab();              show_intruments_tab();
3326              m_TreeView.get_selection()->unselect_all();              m_TreeView.get_selection()->unselect_all();
3327                
3328    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22)
3329                auto iterSel = model->children()[i].get_iter();
3330                m_TreeView.get_selection()->select(iterSel);
3331    #else
3332              m_TreeView.get_selection()->select(model->children()[i]);              m_TreeView.get_selection()->select(model->children()[i]);
3333    #endif
3334              std::vector<Gtk::TreeModel::Path> rows =              std::vector<Gtk::TreeModel::Path> rows =
3335                  m_TreeView.get_selection()->get_selected_rows();                  m_TreeView.get_selection()->get_selected_rows();
3336              if (!rows.empty())              if (!rows.empty())
# Line 2370  bool MainWindow::select_dimension_region Line 3345  bool MainWindow::select_dimension_region
3345      gig::Region* pRegion = (gig::Region*) dimRgn->GetParent();      gig::Region* pRegion = (gig::Region*) dimRgn->GetParent();
3346      gig::Instrument* pInstrument = (gig::Instrument*) pRegion->GetParent();      gig::Instrument* pInstrument = (gig::Instrument*) pRegion->GetParent();
3347    
3348        //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!
3349      Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model();      Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model();
3350        //Glib::RefPtr<Gtk::TreeModel> model = m_refTreeModelFilter->get_model();
3351    
3352      for (int i = 0; i < model->children().size(); ++i) {      for (int i = 0; i < model->children().size(); ++i) {
3353          Gtk::TreeModel::Row row = model->children()[i];          Gtk::TreeModel::Row row = model->children()[i];
3354          if (row[m_Columns.m_col_instr] == pInstrument) {          if (row[m_Columns.m_col_instr] == pInstrument) {
3355              // select and show the respective instrument in the list view              // select and show the respective instrument in the list view
3356              show_intruments_tab();              show_intruments_tab();
3357              m_TreeView.get_selection()->unselect_all();              m_TreeView.get_selection()->unselect_all();
3358    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22)
3359                auto iterSel = model->children()[i].get_iter();
3360                m_TreeView.get_selection()->select(iterSel);
3361    #else
3362              m_TreeView.get_selection()->select(model->children()[i]);              m_TreeView.get_selection()->select(model->children()[i]);
3363    #endif
3364              std::vector<Gtk::TreeModel::Path> rows =              std::vector<Gtk::TreeModel::Path> rows =
3365                  m_TreeView.get_selection()->get_selected_rows();                  m_TreeView.get_selection()->get_selected_rows();
3366              if (!rows.empty())              if (!rows.empty())
# Line 2408  void MainWindow::select_sample(gig::Samp Line 3391  void MainWindow::select_sample(gig::Samp
3391              if (rowSample[m_SamplesModel.m_col_sample] == sample) {              if (rowSample[m_SamplesModel.m_col_sample] == sample) {
3392                  show_samples_tab();                  show_samples_tab();
3393                  m_TreeViewSamples.get_selection()->unselect_all();                  m_TreeViewSamples.get_selection()->unselect_all();
3394    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22)
3395                    auto iterSel = rowGroup.children()[s].get_iter();
3396                    m_TreeViewSamples.get_selection()->select(iterSel);
3397    #else
3398                  m_TreeViewSamples.get_selection()->select(rowGroup.children()[s]);                  m_TreeViewSamples.get_selection()->select(rowGroup.children()[s]);
3399    #endif
3400                  std::vector<Gtk::TreeModel::Path> rows =                  std::vector<Gtk::TreeModel::Path> rows =
3401                      m_TreeViewSamples.get_selection()->get_selected_rows();                      m_TreeViewSamples.get_selection()->get_selected_rows();
3402                  if (rows.empty()) return;                  if (rows.empty()) return;
# Line 2419  void MainWindow::select_sample(gig::Samp Line 3407  void MainWindow::select_sample(gig::Samp
3407      }      }
3408  }  }
3409    
3410    #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
3411    bool MainWindow::on_sample_treeview_button_release(Gdk::EventButton& _button) {
3412        GdkEventButton* button = _button.gobj();
3413    #else
3414  void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) {  void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) {
3415    #endif
3416      if (button->type == GDK_BUTTON_PRESS && button->button == 3) {      if (button->type == GDK_BUTTON_PRESS && button->button == 3) {
3417          // by default if Ctrl keys is pressed down, then a mouse right-click          // by default if Ctrl keys is pressed down, then a mouse right-click
3418          // does not select the respective row, so we must assure this          // does not select the respective row, so we must assure this
# Line 2440  void MainWindow::on_sample_treeview_butt Line 3433  void MainWindow::on_sample_treeview_butt
3433              }              }
3434          }*/          }*/
3435    
3436    #if !USE_GTKMM_BUILDER
3437          Gtk::Menu* sample_popup =          Gtk::Menu* sample_popup =
3438              dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/SamplePopupMenu"));              dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/SamplePopupMenu"));
3439    #endif
3440    
3441          // update enabled/disabled state of sample popup items          // update enabled/disabled state of sample popup items
3442          Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();          Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();
3443          std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();          std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
# Line 2456  void MainWindow::on_sample_treeview_butt Line 3452  void MainWindow::on_sample_treeview_butt
3452              if (row[m_SamplesModel.m_col_sample]) nSamples++;              if (row[m_SamplesModel.m_col_sample]) nSamples++;
3453          }          }
3454    
3455    #if USE_GTKMM_BUILDER
3456            m_actionSampleProperties->property_enabled() = (n == 1);
3457            m_actionAddSample->property_enabled() = (n);
3458            m_actionAddSampleGroup->property_enabled() = (file);
3459            m_actionViewSampleRefs->property_enabled() = (nSamples == 1);
3460            m_actionRemoveSample->property_enabled() = (n);
3461            m_actionReplaceSample->property_enabled() = (nSamples == 1);
3462    #else
3463          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))->
3464              set_sensitive(n == 1);              set_sensitive(n == 1);
3465          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))->
# Line 2466  void MainWindow::on_sample_treeview_butt Line 3470  void MainWindow::on_sample_treeview_butt
3470              set_sensitive(nSamples == 1);              set_sensitive(nSamples == 1);
3471          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))->
3472              set_sensitive(n);              set_sensitive(n);
3473    #endif
3474          // show sample popup          // show sample popup
3475          sample_popup->popup(button->button, button->time);          sample_popup->popup(button->button, button->time);
3476    
3477    #if !USE_GTKMM_BUILDER
3478          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/SampleProperties"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/SampleProperties"))->
3479              set_sensitive(n == 1);              set_sensitive(n == 1);
3480          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddSample"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddSample"))->
# Line 2479  void MainWindow::on_sample_treeview_butt Line 3485  void MainWindow::on_sample_treeview_butt
3485              set_sensitive(nSamples == 1);              set_sensitive(nSamples == 1);
3486          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/RemoveSample"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/RemoveSample"))->
3487              set_sensitive(n);              set_sensitive(n);
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        return false;
3493    #endif
3494  }  }
3495    
3496    #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
3497    bool MainWindow::on_script_treeview_button_release(Gdk::EventButton& _button) {
3498        GdkEventButton* button = _button.gobj();
3499    #else
3500  void MainWindow::on_script_treeview_button_release(GdkEventButton* button) {  void MainWindow::on_script_treeview_button_release(GdkEventButton* button) {
3501    #endif
3502      if (button->type == GDK_BUTTON_PRESS && button->button == 3) {      if (button->type == GDK_BUTTON_PRESS && button->button == 3) {
3503    #if !USE_GTKMM_BUILDER
3504          Gtk::Menu* script_popup =          Gtk::Menu* script_popup =
3505              dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/ScriptPopupMenu"));              dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/ScriptPopupMenu"));
3506    #endif
3507          // update enabled/disabled state of sample popup items          // update enabled/disabled state of sample popup items
3508          Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewScripts.get_selection();          Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewScripts.get_selection();
3509          Gtk::TreeModel::iterator it = sel->get_selected();          Gtk::TreeModel::iterator it = sel->get_selected();
# Line 2496  void MainWindow::on_script_treeview_butt Line 3514  void MainWindow::on_script_treeview_butt
3514              group_selected  = row[m_ScriptsModel.m_col_group];              group_selected  = row[m_ScriptsModel.m_col_group];
3515              script_selected = row[m_ScriptsModel.m_col_script];              script_selected = row[m_ScriptsModel.m_col_script];
3516          }          }
3517    #if USE_GTKMM_BUILDER
3518            m_actionAddScript->property_enabled() = (group_selected || script_selected);
3519            m_actionAddScriptGroup->property_enabled() = (file);
3520            m_actionEditScript->property_enabled() = (script_selected);
3521            m_actionRemoveScript->property_enabled() = (group_selected || script_selected);
3522    #else
3523          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/AddScript"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/AddScript"))->
3524              set_sensitive(group_selected || script_selected);              set_sensitive(group_selected || script_selected);
3525          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/AddScriptGroup"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/AddScriptGroup"))->
# Line 2504  void MainWindow::on_script_treeview_butt Line 3528  void MainWindow::on_script_treeview_butt
3528              set_sensitive(script_selected);                  set_sensitive(script_selected);    
3529          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/RemoveScript"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/RemoveScript"))->
3530              set_sensitive(group_selected || script_selected);              set_sensitive(group_selected || script_selected);
3531    #endif
3532          // show sample popup          // show sample popup
3533          script_popup->popup(button->button, button->time);          script_popup->popup(button->button, button->time);
3534    
3535    #if !USE_GTKMM_BUILDER
3536          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/AddScript"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/AddScript"))->
3537              set_sensitive(group_selected || script_selected);              set_sensitive(group_selected || script_selected);
3538          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/AddScriptGroup"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/AddScriptGroup"))->
# Line 2515  void MainWindow::on_script_treeview_butt Line 3541  void MainWindow::on_script_treeview_butt
3541              set_sensitive(script_selected);                  set_sensitive(script_selected);    
3542          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/RemoveScript"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/RemoveScript"))->
3543              set_sensitive(group_selected || script_selected);              set_sensitive(group_selected || script_selected);
3544    #endif
3545      }      }
3546    #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
3547        return false;
3548    #endif
3549    }
3550    
3551    void MainWindow::updateScriptListOfMenu() {
3552        // remove all entries from "Assign Script" menu
3553        {
3554            const std::vector<Gtk::Widget*> children = assign_scripts_menu->get_children();
3555            for (int i = 0; i < children.size(); ++i) {
3556                Gtk::Widget* child = children[i];
3557                assign_scripts_menu->remove(*child);
3558                delete child;
3559            }
3560        }
3561    
3562        int iTotalScripts = 0;
3563    
3564        if (!file) goto noScripts;
3565    
3566        // add all configured macros as menu items to the "Macro" menu
3567        for (int iGroup = 0; file->GetScriptGroup(iGroup); ++iGroup) {
3568            gig::ScriptGroup* pGroup = file->GetScriptGroup(iGroup);
3569            for (int iScript = 0; pGroup->GetScript(iScript); ++iScript, ++iTotalScripts) {
3570                gig::Script* pScript = pGroup->GetScript(iScript);
3571                std::string name = pScript->Name;
3572    
3573                Gtk::MenuItem* item = new Gtk::MenuItem(name);
3574                item->signal_activate().connect(
3575                    sigc::bind(
3576                        sigc::mem_fun(*this, &MainWindow::assignScript), pScript
3577                    )
3578                );
3579                assign_scripts_menu->append(*item);
3580                item->set_accel_path("<Scripts>/script_" + ToString(iTotalScripts));
3581                //item->set_tooltip_text(comment);
3582            }
3583        }
3584    
3585        noScripts:
3586    
3587        // if there are no macros configured at all, then show a dummy entry instead
3588        if (!iTotalScripts) {
3589            Gtk::MenuItem* item = new Gtk::MenuItem(_("No Scripts"));
3590            item->set_sensitive(false);
3591            assign_scripts_menu->append(*item);
3592        }
3593    
3594    #if HAS_GTKMM_SHOW_ALL_CHILDREN
3595        assign_scripts_menu->show_all_children();
3596    #endif
3597  }  }
3598    
3599    #if !USE_GTKMM_BUILDER
3600  Gtk::RadioMenuItem* MainWindow::add_instrument_to_menu(  Gtk::RadioMenuItem* MainWindow::add_instrument_to_menu(
3601      const Glib::ustring& name, int position) {      const Glib::ustring& name, int position) {
3602    
# Line 2541  Gtk::RadioMenuItem* MainWindow::add_inst Line 3620  Gtk::RadioMenuItem* MainWindow::add_inst
3620              item));              item));
3621      return item;      return item;
3622  }  }
3623    #endif
3624    
3625    #if !USE_GTKMM_BUILDER
3626  void MainWindow::remove_instrument_from_menu(int index) {  void MainWindow::remove_instrument_from_menu(int index) {
3627      const std::vector<Gtk::Widget*> children =      const std::vector<Gtk::Widget*> children =
3628          instrument_menu->get_children();          instrument_menu->get_children();
# Line 2549  void MainWindow::remove_instrument_from_ Line 3630  void MainWindow::remove_instrument_from_
3630      instrument_menu->remove(*child);      instrument_menu->remove(*child);
3631      delete child;      delete child;
3632  }  }
3633    #endif
3634    
3635  void MainWindow::add_instrument(gig::Instrument* instrument) {  void MainWindow::add_instrument(gig::Instrument* instrument) {
3636      const Glib::ustring name(gig_to_utf8(instrument->pInfo->Name));      const Glib::ustring name(gig_to_utf8(instrument->pInfo->Name));
# Line 2560  void MainWindow::add_instrument(gig::Ins Line 3642  void MainWindow::add_instrument(gig::Ins
3642      rowInstr[m_Columns.m_col_nr] = m_refTreeModel->children().size() - 1;      rowInstr[m_Columns.m_col_nr] = m_refTreeModel->children().size() - 1;
3643      rowInstr[m_Columns.m_col_name] = name;      rowInstr[m_Columns.m_col_name] = name;
3644      rowInstr[m_Columns.m_col_instr] = instrument;      rowInstr[m_Columns.m_col_instr] = instrument;
3645        rowInstr[m_Columns.m_col_scripts] = "";
3646      instrument_name_connection.unblock();      instrument_name_connection.unblock();
3647    
3648    #if !USE_GTKMM_BUILDER
3649      add_instrument_to_menu(name);      add_instrument_to_menu(name);
3650    #endif
3651      m_TreeView.get_selection()->select(iterInstr);      select_instrument(instrument);
   
3652      file_changed();      file_changed();
3653  }  }
3654    
# Line 2633  void MainWindow::on_action_remove_instru Line 3716  void MainWindow::on_action_remove_instru
3716              if (instr) file->DeleteInstrument(instr);              if (instr) file->DeleteInstrument(instr);
3717              file_changed();              file_changed();
3718    
3719    #if !USE_GTKMM_BUILDER
3720              remove_instrument_from_menu(index);              remove_instrument_from_menu(index);
3721    #endif
3722    
3723              // remove row from instruments tree view              // remove row from instruments tree view
3724              m_refTreeModel->erase(it);              m_refTreeModel->erase(it);
# Line 2848  void MainWindow::add_or_replace_sample(b Line 3933  void MainWindow::add_or_replace_sample(b
3933    
3934      // show 'browse for file' dialog      // show 'browse for file' dialog
3935      Gtk::FileChooserDialog dialog(*this, replace ? _("Replace Sample with") : _("Add Sample(s)"));      Gtk::FileChooserDialog dialog(*this, replace ? _("Replace Sample with") : _("Add Sample(s)"));
3936    #if HAS_GTKMM_STOCK
3937      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
3938      dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);      dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
3939    #else
3940        dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
3941        dialog.add_button(_("_Open"), Gtk::RESPONSE_OK);
3942    #endif
3943      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
3944    
3945      // matches all file types supported by libsndfile      // matches all file types supported by libsndfile
# Line 2898  void MainWindow::add_or_replace_sample(b Line 3988  void MainWindow::add_or_replace_sample(b
3988          for (std::vector<std::string>::iterator iter = filenames.begin();          for (std::vector<std::string>::iterator iter = filenames.begin();
3989               iter != filenames.end(); ++iter) {               iter != filenames.end(); ++iter) {
3990              printf("Adding sample %s\n",(*iter).c_str());              printf("Adding sample %s\n",(*iter).c_str());
3991              // use libsndfile to retrieve file informations              // use libsndfile to retrieve file information
3992              SF_INFO info;              SF_INFO info;
3993              info.format = 0;              info.format = 0;
3994              SNDFILE* hFile = sf_open((*iter).c_str(), SFM_READ, &info);              SNDFILE* hFile = sf_open((*iter).c_str(), SFM_READ, &info);
# Line 3039  void MainWindow::on_action_replace_all_s Line 4129  void MainWindow::on_action_replace_all_s
4129      Gtk::Label description(str);      Gtk::Label description(str);
4130      description.set_line_wrap();      description.set_line_wrap();
4131  #endif  #endif
4132      Gtk::HBox entryArea;      HBox entryArea;
4133      Gtk::Label entryLabel( _("Add filename extension: "), Gtk::ALIGN_START);      Gtk::Label entryLabel( _("Add filename extension: "), Gtk::ALIGN_START);
4134      Gtk::Entry postfixEntryBox;      Gtk::Entry postfixEntryBox;
4135      postfixEntryBox.set_text(".wav");      postfixEntryBox.set_text(".wav");
4136      entryArea.pack_start(entryLabel);      entryArea.pack_start(entryLabel);
4137      entryArea.pack_start(postfixEntryBox);      entryArea.pack_start(postfixEntryBox);
4138    #if USE_GTKMM_BOX
4139        dialog.get_content_area()->pack_start(description, Gtk::PACK_SHRINK);
4140        dialog.get_content_area()->pack_start(entryArea, Gtk::PACK_SHRINK);
4141    #else
4142      dialog.get_vbox()->pack_start(description, Gtk::PACK_SHRINK);      dialog.get_vbox()->pack_start(description, Gtk::PACK_SHRINK);
4143      dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK);      dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK);
4144    #endif
4145      description.show();      description.show();
4146    
4147    #if HAS_GTKMM_SHOW_ALL_CHILDREN
4148      entryArea.show_all();      entryArea.show_all();
4149    #else
4150        entryArea.show();
4151    #endif
4152    
4153    #if HAS_GTKMM_STOCK
4154      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
4155    #else
4156        dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
4157    #endif
4158      dialog.add_button(_("Select"), Gtk::RESPONSE_OK);      dialog.add_button(_("Select"), Gtk::RESPONSE_OK);
4159      dialog.set_select_multiple(false);      dialog.set_select_multiple(false);
4160      if (current_sample_dir != "") {      if (current_sample_dir != "") {
# Line 3507  void MainWindow::instrument_name_changed Line 4612  void MainWindow::instrument_name_changed
4612      Gtk::TreeModel::Row row = *iter;      Gtk::TreeModel::Row row = *iter;
4613      Glib::ustring name = row[m_Columns.m_col_name];      Glib::ustring name = row[m_Columns.m_col_name];
4614    
4615    #if !USE_GTKMM_BUILDER
4616      // change name in instrument menu      // change name in instrument menu
4617      int index = path[0];      int index = path[0];
4618      const std::vector<Gtk::Widget*> children = instrument_menu->get_children();      const std::vector<Gtk::Widget*> children = instrument_menu->get_children();
# Line 3519  void MainWindow::instrument_name_changed Line 4625  void MainWindow::instrument_name_changed
4625          item->set_active();          item->set_active();
4626  #endif  #endif
4627      }      }
4628    #endif
4629    
4630      // change name in gig      // change name in gig
4631      gig::Instrument* instrument = row[m_Columns.m_col_instr];      gig::Instrument* instrument = row[m_Columns.m_col_instr];
# Line 3535  void MainWindow::instrument_name_changed Line 4642  void MainWindow::instrument_name_changed
4642      }      }
4643  }  }
4644    
4645    bool MainWindow::instrument_row_visible(const Gtk::TreeModel::const_iterator& iter) {
4646        if (!iter)
4647            return true;
4648    
4649        Glib::ustring pattern = m_searchText.get_text().lowercase();
4650        trim(pattern);
4651        if (pattern.empty()) return true;
4652    
4653    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22)
4654        //HACK: on GTKMM4 development branch const_iterator cannot be easily converted to iterator, probably going to be fixed before final GTKMM4 release though.
4655        Gtk::TreeModel::Row row = **(Gtk::TreeModel::iterator*)(&iter);
4656    #else
4657        Gtk::TreeModel::Row row = *iter;
4658    #endif
4659        Glib::ustring name = row[m_Columns.m_col_name];
4660        name = name.lowercase();
4661    
4662        std::vector<Glib::ustring> tokens = Glib::Regex::split_simple(" ", pattern);
4663        for (int t = 0; t < tokens.size(); ++t)
4664            if (name.find(tokens[t]) == Glib::ustring::npos)
4665                return false;
4666    
4667        return true;
4668    }
4669    
4670  void MainWindow::on_action_combine_instruments() {  void MainWindow::on_action_combine_instruments() {
4671      CombineInstrumentsDialog* d = new CombineInstrumentsDialog(*this, file);      CombineInstrumentsDialog* d = new CombineInstrumentsDialog(*this, file);
4672    
4673        // take over selection from instruments list view for the combine dialog's
4674        // list view as pre-selection
4675        std::set<int> indeces;
4676        {
4677            Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection();
4678            std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
4679            for (int r = 0; r < rows.size(); ++r) {
4680                Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]);
4681                if (it) {
4682                    Gtk::TreeModel::Row row = *it;
4683                    int index = row[m_Columns.m_col_nr];
4684                    indeces.insert(index);
4685                }
4686            }
4687        }
4688        d->setSelectedInstruments(indeces);
4689    
4690    #if HAS_GTKMM_SHOW_ALL_CHILDREN
4691      d->show_all();      d->show_all();
4692      d->resize(500, 400);  #else
4693        d->show();
4694    #endif
4695      d->run();      d->run();
4696      if (d->fileWasChanged()) {      if (d->fileWasChanged()) {
4697          // update GUI with new instrument just created          // update GUI with new instrument just created
# Line 3562  void MainWindow::on_action_view_referenc Line 4715  void MainWindow::on_action_view_referenc
4715      d->dimension_region_selected.connect(      d->dimension_region_selected.connect(
4716          sigc::mem_fun(*this, &MainWindow::select_dimension_region)          sigc::mem_fun(*this, &MainWindow::select_dimension_region)
4717      );      );
4718    #if HAS_GTKMM_SHOW_ALL_CHILDREN
4719      d->show_all();      d->show_all();
4720    #else
4721        d->show();
4722    #endif
4723      d->resize(500, 400);      d->resize(500, 400);
4724      d->run();      d->run();
4725      delete d;      delete d;
# Line 3646  void MainWindow::mergeFiles(const std::v Line 4803  void MainWindow::mergeFiles(const std::v
4803              Glib::filename_display_basename(this->filename) + "' ...",              Glib::filename_display_basename(this->filename) + "' ...",
4804              *this              *this
4805          );          );
4806    #if HAS_GTKMM_SHOW_ALL_CHILDREN
4807          progress_dialog->show_all();          progress_dialog->show_all();
4808    #else
4809            progress_dialog->show();
4810    #endif
4811          saver = new Saver(this->file); //FIXME: memory leak!          saver = new Saver(this->file); //FIXME: memory leak!
4812          saver->signal_progress().connect(          saver->signal_progress().connect(
4813              sigc::mem_fun(*this, &MainWindow::on_saver_progress));              sigc::mem_fun(*this, &MainWindow::on_saver_progress));
# Line 3673  void MainWindow::on_action_merge_files() Line 4834  void MainWindow::on_action_merge_files()
4834      }      }
4835    
4836      Gtk::FileChooserDialog dialog(*this, _("Merge .gig files"));      Gtk::FileChooserDialog dialog(*this, _("Merge .gig files"));
4837    #if HAS_GTKMM_STOCK
4838      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
4839    #else
4840        dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
4841    #endif
4842      dialog.add_button(_("Merge"), Gtk::RESPONSE_OK);      dialog.add_button(_("Merge"), Gtk::RESPONSE_OK);
4843      dialog.set_default_response(Gtk::RESPONSE_CANCEL);      dialog.set_default_response(Gtk::RESPONSE_CANCEL);
4844  #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2  #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
# Line 3690  void MainWindow::on_action_merge_files() Line 4855  void MainWindow::on_action_merge_files()
4855      dialog.set_select_multiple(true);      dialog.set_select_multiple(true);
4856    
4857      // show warning in the file picker dialog      // show warning in the file picker dialog
4858      Gtk::HBox descriptionArea;      HBox descriptionArea;
4859      descriptionArea.set_spacing(15);      descriptionArea.set_spacing(15);
4860      Gtk::Image warningIcon;      Gtk::Image warningIcon;
4861      warningIcon.set_from_icon_name("dialog-warning",      warningIcon.set_from_icon_name("dialog-warning",
# Line 3713  void MainWindow::on_action_merge_files() Line 4878  void MainWindow::on_action_merge_files()
4878          "will accordingly be stored separately in the target .gig file!"          "will accordingly be stored separately in the target .gig file!"
4879      ));      ));
4880      descriptionArea.pack_start(description);      descriptionArea.pack_start(description);
4881    #if USE_GTKMM_BOX
4882    # warning No description area implemented for dialog on GTKMM 3
4883    #else
4884      dialog.get_vbox()->pack_start(descriptionArea, Gtk::PACK_SHRINK);      dialog.get_vbox()->pack_start(descriptionArea, Gtk::PACK_SHRINK);
4885    #endif
4886    #if HAS_GTKMM_SHOW_ALL_CHILDREN
4887      descriptionArea.show_all();      descriptionArea.show_all();
4888    #else
4889        descriptionArea.show();
4890    #endif
4891    
4892      if (dialog.run() == Gtk::RESPONSE_OK) {      if (dialog.run() == Gtk::RESPONSE_OK) {
4893          printf("on_action_merge_files self=%p\n",          printf("on_action_merge_files self=%p\n",
# Line 3750  void MainWindow::set_file_is_shared(bool Line 4923  void MainWindow::set_file_is_shared(bool
4923      }      }
4924    
4925      {      {
4926    #if USE_GTKMM_BUILDER
4927            m_actionToggleSyncSamplerSelection->property_enabled() = b;
4928    #else
4929          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
4930              uiManager->get_widget("/MenuBar/MenuSettings/SyncSamplerInstrumentSelection"));              uiManager->get_widget("/MenuBar/MenuSettings/SyncSamplerInstrumentSelection"));
4931          if (item) item->set_sensitive(b);          if (item) item->set_sensitive(b);
4932    #endif
4933      }      }
4934  }  }
4935    
# Line 3800  void MainWindow::show_scripts_tab() { Line 4977  void MainWindow::show_scripts_tab() {
4977      m_TreeViewNotebook.set_current_page(2);      m_TreeViewNotebook.set_current_page(2);
4978  }  }
4979    
4980    void MainWindow::select_instrument_by_dir(int dir) {
4981        if (!file) return;
4982        gig::Instrument* pInstrument = get_instrument();
4983        if (!pInstrument) {
4984            select_instrument( file->GetInstrument(0) );
4985            return;
4986        }
4987        for (int i = 0; file->GetInstrument(i); ++i) {
4988            if (file->GetInstrument(i) == pInstrument) {
4989                select_instrument( file->GetInstrument(i + dir) );
4990                return;
4991            }
4992        }
4993    }
4994    
4995    void MainWindow::select_prev_instrument() {
4996        select_instrument_by_dir(-1);
4997    }
4998    
4999    void MainWindow::select_next_instrument() {
5000        select_instrument_by_dir(1);
5001    }
5002    
5003  void MainWindow::select_prev_region() {  void MainWindow::select_prev_region() {
5004      m_RegionChooser.select_prev_region();      m_RegionChooser.select_prev_region();
5005  }  }
# Line 3886  void MainWindow::updateClipboardPasteAva Line 5086  void MainWindow::updateClipboardPasteAva
5086    
5087  void MainWindow::updateClipboardCopyAvailable() {  void MainWindow::updateClipboardCopyAvailable() {
5088      bool bDimensionRegionCopyIsPossible = m_DimRegionChooser.get_main_dimregion();      bool bDimensionRegionCopyIsPossible = m_DimRegionChooser.get_main_dimregion();
5089    #if USE_GTKMM_BUILDER
5090        m_actionCopyDimRgn->property_enabled() = bDimensionRegionCopyIsPossible;
5091    #else
5092      static_cast<Gtk::MenuItem*>(      static_cast<Gtk::MenuItem*>(
5093          uiManager->get_widget("/MenuBar/MenuEdit/CopyDimRgn")          uiManager->get_widget("/MenuBar/MenuEdit/CopyDimRgn")
5094      )->set_sensitive(bDimensionRegionCopyIsPossible);      )->set_sensitive(bDimensionRegionCopyIsPossible);
5095    #endif
5096  }  }
5097    
5098    #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
5099    void MainWindow::on_clipboard_owner_change(Gdk::EventOwnerChange& event) {
5100    #else
5101  void MainWindow::on_clipboard_owner_change(GdkEventOwnerChange* event) {  void MainWindow::on_clipboard_owner_change(GdkEventOwnerChange* event) {
5102    #endif
5103      updateClipboardPasteAvailable();      updateClipboardPasteAvailable();
5104  }  }
5105    
# Line 3958  void MainWindow::on_clipboard_received_t Line 5166  void MainWindow::on_clipboard_received_t
5166          std::find(targets.begin(), targets.end(),          std::find(targets.begin(), targets.end(),
5167                    CLIPBOARD_DIMENSIONREGION_TARGET) != targets.end();                    CLIPBOARD_DIMENSIONREGION_TARGET) != targets.end();
5168    
5169    #if USE_GTKMM_BUILDER
5170        m_actionPasteDimRgn->property_enabled() = bDimensionRegionPasteIsPossible;
5171        m_actionAdjustClipboard->property_enabled() = bDimensionRegionPasteIsPossible;
5172    #else
5173      static_cast<Gtk::MenuItem*>(      static_cast<Gtk::MenuItem*>(
5174          uiManager->get_widget("/MenuBar/MenuEdit/PasteDimRgn")          uiManager->get_widget("/MenuBar/MenuEdit/PasteDimRgn")
5175      )->set_sensitive(bDimensionRegionPasteIsPossible);      )->set_sensitive(bDimensionRegionPasteIsPossible);
# Line 3965  void MainWindow::on_clipboard_received_t Line 5177  void MainWindow::on_clipboard_received_t
5177      static_cast<Gtk::MenuItem*>(      static_cast<Gtk::MenuItem*>(
5178          uiManager->get_widget("/MenuBar/MenuEdit/AdjustClipboard")          uiManager->get_widget("/MenuBar/MenuEdit/AdjustClipboard")
5179      )->set_sensitive(bDimensionRegionPasteIsPossible);      )->set_sensitive(bDimensionRegionPasteIsPossible);
5180    #endif
5181  }  }
5182    
5183  sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() {  sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() {

Legend:
Removed from v.3179  
changed lines
  Added in v.3408

  ViewVC Help
Powered by ViewVC