/[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 3363 by schoenebeck, Sat Oct 28 11:20:46 2017 UTC revision 3364 by schoenebeck, Tue Nov 14 18:07:25 2017 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 36  Line 36 
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 49  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 105  MainWindow::MainWindow() : Line 113  MainWindow::MainWindow() :
113    
114      // m_TreeView.set_reorderable();      // m_TreeView.set_reorderable();
115    
116    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2
117        m_TreeView.signal_button_press_event().connect(
118            sigc::mem_fun(*this, &MainWindow::on_button_release));
119    #else
120      m_TreeView.signal_button_press_event().connect_notify(      m_TreeView.signal_button_press_event().connect_notify(
121          sigc::mem_fun(*this, &MainWindow::on_button_release));          sigc::mem_fun(*this, &MainWindow::on_button_release));
122    #endif
123    
124      // Add the TreeView tab, inside a ScrolledWindow, with the button underneath:      // Add the TreeView tab, inside a ScrolledWindow, with the button underneath:
125      m_ScrolledWindow.add(m_TreeView);      m_ScrolledWindow.add(m_TreeView);
# Line 143  MainWindow::MainWindow() : Line 156  MainWindow::MainWindow() :
156          legend_hbox.add(labelLegend);          legend_hbox.add(labelLegend);
157    
158          imageNoSample.set(redDot);          imageNoSample.set(redDot);
159    #if HAS_GTKMM_ALIGNMENT
160          imageNoSample.set_alignment(Gtk::ALIGN_END);          imageNoSample.set_alignment(Gtk::ALIGN_END);
161          labelNoSample.set_alignment(Gtk::ALIGN_START);          labelNoSample.set_alignment(Gtk::ALIGN_START);
162    #else
163            imageNoSample.set_halign(Gtk::ALIGN_END);
164            labelNoSample.set_halign(Gtk::ALIGN_START);
165    #endif
166          legend_hbox.add(imageNoSample);          legend_hbox.add(imageNoSample);
167          legend_hbox.add(labelNoSample);          legend_hbox.add(labelNoSample);
168    
169          imageMissingSample.set(yellowDot);          imageMissingSample.set(yellowDot);
170    #if HAS_GTKMM_ALIGNMENT
171          imageMissingSample.set_alignment(Gtk::ALIGN_END);          imageMissingSample.set_alignment(Gtk::ALIGN_END);
172          labelMissingSample.set_alignment(Gtk::ALIGN_START);          labelMissingSample.set_alignment(Gtk::ALIGN_START);
173    #else
174            imageMissingSample.set_halign(Gtk::ALIGN_END);
175            labelMissingSample.set_halign(Gtk::ALIGN_START);
176    #endif
177          legend_hbox.add(imageMissingSample);          legend_hbox.add(imageMissingSample);
178          legend_hbox.add(labelMissingSample);          legend_hbox.add(labelMissingSample);
179    
180          imageLooped.set(blackLoop);          imageLooped.set(blackLoop);
181    #if HAS_GTKMM_ALIGNMENT
182          imageLooped.set_alignment(Gtk::ALIGN_END);          imageLooped.set_alignment(Gtk::ALIGN_END);
183          labelLooped.set_alignment(Gtk::ALIGN_START);          labelLooped.set_alignment(Gtk::ALIGN_START);
184    #else
185            imageLooped.set_halign(Gtk::ALIGN_END);
186            labelLooped.set_halign(Gtk::ALIGN_START);
187    #endif
188          legend_hbox.add(imageLooped);          legend_hbox.add(imageLooped);
189          legend_hbox.add(labelLooped);          legend_hbox.add(labelLooped);
190    
191          imageSomeLoops.set(grayLoop);          imageSomeLoops.set(grayLoop);
192    #if HAS_GTKMM_ALIGNMENT
193          imageSomeLoops.set_alignment(Gtk::ALIGN_END);          imageSomeLoops.set_alignment(Gtk::ALIGN_END);
194          labelSomeLoops.set_alignment(Gtk::ALIGN_START);          labelSomeLoops.set_alignment(Gtk::ALIGN_START);
195    #else
196            imageSomeLoops.set_halign(Gtk::ALIGN_END);
197            labelSomeLoops.set_halign(Gtk::ALIGN_START);
198    #endif
199          legend_hbox.add(imageSomeLoops);          legend_hbox.add(imageSomeLoops);
200          legend_hbox.add(labelSomeLoops);          legend_hbox.add(labelSomeLoops);
201    
202    #if HAS_GTKMM_SHOW_ALL_CHILDREN
203          legend_hbox.show_all_children();          legend_hbox.show_all_children();
204    #endif
205      }      }
206      dimreg_vbox.pack_start(legend_hbox, Gtk::PACK_SHRINK);      dimreg_vbox.pack_start(legend_hbox, Gtk::PACK_SHRINK);
207      m_HPaned.add2(dimreg_vbox);      m_HPaned.add2(dimreg_vbox);
# Line 180  MainWindow::MainWindow() : Line 215  MainWindow::MainWindow() :
215      m_TreeViewNotebook.append_page(m_ScrolledWindow, _("Instruments"));      m_TreeViewNotebook.append_page(m_ScrolledWindow, _("Instruments"));
216      m_TreeViewNotebook.append_page(m_ScrolledWindowScripts, _("Scripts"));      m_TreeViewNotebook.append_page(m_ScrolledWindowScripts, _("Scripts"));
217    
218    #if USE_GLIB_ACTION
219        m_actionGroup = Gio::SimpleActionGroup::create();
220        m_actionGroup->add_action(
221            "New", sigc::mem_fun(*this, &MainWindow::on_action_file_new)
222        );
223        m_actionGroup->add_action(
224            "Open", sigc::mem_fun(*this, &MainWindow::on_action_file_open)
225        );
226        m_actionGroup->add_action(
227            "Save", sigc::mem_fun(*this, &MainWindow::on_action_file_save)
228        );
229        m_actionGroup->add_action(
230            "SaveAs", sigc::mem_fun(*this, &MainWindow::on_action_file_save_as)
231        );
232        m_actionGroup->add_action(
233            "Properties", sigc::mem_fun(*this, &MainWindow::on_action_file_properties)
234        );
235        m_actionGroup->add_action(
236            "InstrProperties", sigc::mem_fun(*this, &MainWindow::show_instr_props)
237        );
238        m_actionMIDIRules = m_actionGroup->add_action(
239            "MidiRules", sigc::mem_fun(*this, &MainWindow::show_midi_rules)
240        );
241        m_actionGroup->add_action(
242            "ScriptSlots", sigc::mem_fun(*this, &MainWindow::show_script_slots)
243        );
244        m_actionGroup->add_action(
245            "Quit", sigc::mem_fun(*this, &MainWindow::on_action_quit)
246        );
247        m_actionGroup->add_action(
248            "MenuSample", sigc::mem_fun(*this, &MainWindow::show_samples_tab)
249        );
250        m_actionGroup->add_action(
251            "MenuInstrument", sigc::mem_fun(*this, &MainWindow::show_intruments_tab)
252        );
253        m_actionGroup->add_action(
254            "MenuScript", sigc::mem_fun(*this, &MainWindow::show_scripts_tab)
255        );
256    #else
257      actionGroup = Gtk::ActionGroup::create();      actionGroup = Gtk::ActionGroup::create();
258    
259      actionGroup->add(Gtk::Action::create("MenuFile", _("_File")));      actionGroup->add(Gtk::Action::create("MenuFile", _("_File")));
# Line 236  MainWindow::MainWindow() : Line 310  MainWindow::MainWindow() :
310      actionGroup->add(Gtk::Action::create("AssignScripts", _("Assign Script")));      actionGroup->add(Gtk::Action::create("AssignScripts", _("Assign Script")));
311    
312      actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit")));      actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit")));
313    #endif
314    
315      const Gdk::ModifierType primaryModifierKey =      const Gdk::ModifierType primaryModifierKey =
316  #if defined(__APPLE__)  #if defined(__APPLE__)
# Line 244  MainWindow::MainWindow() : Line 319  MainWindow::MainWindow() :
319      Gdk::CONTROL_MASK; // Ctrl key on all other OSs      Gdk::CONTROL_MASK; // Ctrl key on all other OSs
320  #endif  #endif
321    
322    #if USE_GLIB_ACTION
323        m_actionCopyDimRgn = m_actionGroup->add_action(
324            "CopyDimRgn", sigc::mem_fun(*this, &MainWindow::copy_selected_dimrgn)
325        );
326        m_actionPasteDimRgn = m_actionGroup->add_action(
327            "PasteDimRgn", sigc::mem_fun(*this, &MainWindow::paste_copied_dimrgn)
328        );
329        m_actionAdjustClipboard = m_actionGroup->add_action(
330            "AdjustClipboard", sigc::mem_fun(*this, &MainWindow::adjust_clipboard_content)
331        );
332        m_actionGroup->add_action(
333            "SelectPrevInstr", sigc::mem_fun(*this, &MainWindow::select_prev_instrument)
334        );
335        m_actionGroup->add_action(
336            "SelectNextInstr", sigc::mem_fun(*this, &MainWindow::select_next_instrument)
337        );
338        m_actionGroup->add_action(
339            "SelectPrevRegion", sigc::mem_fun(*this, &MainWindow::select_prev_region)
340        );
341        m_actionGroup->add_action(
342            "SelectNextRegion", sigc::mem_fun(*this, &MainWindow::select_next_region)
343        );
344        m_actionGroup->add_action(
345            "SelectPrevDimRgnZone", sigc::mem_fun(*this, &MainWindow::select_prev_dim_rgn_zone)
346        );
347        m_actionGroup->add_action(
348            "SelectNextDimRgnZone", sigc::mem_fun(*this, &MainWindow::select_next_dim_rgn_zone)
349        );
350        m_actionGroup->add_action(
351            "SelectPrevDimension", sigc::mem_fun(*this, &MainWindow::select_prev_dimension)
352        );
353        m_actionGroup->add_action(
354            "SelectNextDimension", sigc::mem_fun(*this, &MainWindow::select_next_dimension)
355        );
356        m_actionGroup->add_action(
357            "SelectAddPrevDimRgnZone", sigc::mem_fun(*this, &MainWindow::select_add_prev_dim_rgn_zone)
358        );
359        m_actionGroup->add_action(
360            "SelectAddNextDimRgnZone", sigc::mem_fun(*this, &MainWindow::select_add_next_dim_rgn_zone)
361        );
362    #else
363      actionGroup->add(Gtk::Action::create("CopyDimRgn",      actionGroup->add(Gtk::Action::create("CopyDimRgn",
364                                           _("Copy selected dimension region")),                                           _("Copy selected dimension region")),
365                       Gtk::AccelKey(GDK_KEY_c, Gdk::MOD1_MASK),                       Gtk::AccelKey(GDK_KEY_c, Gdk::MOD1_MASK),
# Line 308  MainWindow::MainWindow() : Line 424  MainWindow::MainWindow() :
424                                           _("Add Next Dimension Region Zone to Selection")),                                           _("Add Next Dimension Region Zone to Selection")),
425                       Gtk::AccelKey(GDK_KEY_Right, Gdk::MOD1_MASK | Gdk::SHIFT_MASK),                       Gtk::AccelKey(GDK_KEY_Right, Gdk::MOD1_MASK | Gdk::SHIFT_MASK),
426                       sigc::mem_fun(*this, &MainWindow::select_add_next_dim_rgn_zone));                       sigc::mem_fun(*this, &MainWindow::select_add_next_dim_rgn_zone));
427    #endif
428    
429    #if USE_GLIB_ACTION
430        m_actionToggleCopySampleUnity = m_actionGroup->add_action_bool("CopySampleUnity", true);
431        m_actionToggleCopySampleTune  = m_actionGroup->add_action_bool("CopySampleTune", true);
432        m_actionToggleCopySampleLoop  = m_actionGroup->add_action_bool("CopySampleLoop", true);
433    #else
434      Glib::RefPtr<Gtk::ToggleAction> toggle_action =      Glib::RefPtr<Gtk::ToggleAction> toggle_action =
435          Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note"));          Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note"));
436      toggle_action->set_active(true);      toggle_action->set_active(true);
# Line 323  MainWindow::MainWindow() : Line 445  MainWindow::MainWindow() :
445          Gtk::ToggleAction::create("CopySampleLoop", _("Copy Sample's _Loop Points"));          Gtk::ToggleAction::create("CopySampleLoop", _("Copy Sample's _Loop Points"));
446      toggle_action->set_active(true);      toggle_action->set_active(true);
447      actionGroup->add(toggle_action);      actionGroup->add(toggle_action);
448    #endif
449    
450    #if USE_GLIB_ACTION
451        m_actionToggleStatusBar =
452            m_actionGroup->add_action_bool("Statusbar", sigc::mem_fun(*this, &MainWindow::on_action_view_status_bar), true);
453        m_actionToggleRestoreWinDim =
454            m_actionGroup->add_action_bool("AutoRestoreWinDim", sigc::mem_fun(*this, &MainWindow::on_auto_restore_win_dim), Settings::singleton()->autoRestoreWindowDimension);
455        m_actionToggleSaveWithTempFile =
456            m_actionGroup->add_action_bool("SaveWithTemporaryFile", sigc::mem_fun(*this, &MainWindow::on_save_with_temporary_file), Settings::singleton()->saveWithTemporaryFile);
457        m_actionGroup->add_action("RefreshAll", sigc::mem_fun(*this, &MainWindow::on_action_refresh_all));
458    #else
459      actionGroup->add(Gtk::Action::create("MenuMacro", _("_Macro")));      actionGroup->add(Gtk::Action::create("MenuMacro", _("_Macro")));
460    
461    
# Line 354  MainWindow::MainWindow() : Line 485  MainWindow::MainWindow() :
485          Gtk::Action::create("RefreshAll", _("_Refresh All")),          Gtk::Action::create("RefreshAll", _("_Refresh All")),
486          sigc::mem_fun(*this, &MainWindow::on_action_refresh_all)          sigc::mem_fun(*this, &MainWindow::on_action_refresh_all)
487      );                      );                
488    #endif
489    
490    #if USE_GLIB_ACTION
491        m_actionGroup->add_action(
492            "About", sigc::mem_fun(*this, &MainWindow::on_action_help_about)
493        );
494        m_actionGroup->add_action(
495            "AddInstrument", sigc::mem_fun(*this, &MainWindow::on_action_add_instrument)
496        );
497        m_actionGroup->add_action(
498            "DupInstrument", sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument)
499        );
500        m_actionGroup->add_action(
501            "CombInstruments", sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments)
502        );
503        m_actionGroup->add_action(
504            "RemoveInstrument", sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument)
505        );
506    #else
507      action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP);      action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP);
508      actionGroup->add(Gtk::Action::create("MenuHelp",      actionGroup->add(Gtk::Action::create("MenuHelp",
509                                           action->property_label()));                                           action->property_label()));
# Line 378  MainWindow::MainWindow() : Line 527  MainWindow::MainWindow() :
527          Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE),          Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE),
528          sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument)          sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument)
529      );      );
530    #endif
531    
532    #if USE_GLIB_ACTION
533        m_actionToggleWarnOnExtensions = m_actionGroup->add_action_bool(
534            "WarnUserOnExtensions", sigc::mem_fun(*this, &MainWindow::on_action_warn_user_on_extensions),
535            Settings::singleton()->warnUserOnExtensions
536        );
537        m_actionToggleSyncSamplerSelection = m_actionGroup->add_action_bool(
538            "SyncSamplerInstrumentSelection", sigc::mem_fun(*this, &MainWindow::on_action_sync_sampler_instrument_selection),
539            Settings::singleton()->syncSamplerInstrumentSelection
540        );
541        m_actionToggleMoveRootNoteWithRegion = m_actionGroup->add_action_bool(
542            "MoveRootNoteWithRegionMoved", sigc::mem_fun(*this, &MainWindow::on_action_move_root_note_with_region_moved),
543            Settings::singleton()->moveRootNoteWithRegionMoved
544        );
545    #else
546      actionGroup->add(Gtk::Action::create("MenuSettings", _("_Settings")));      actionGroup->add(Gtk::Action::create("MenuSettings", _("_Settings")));
547            
548      toggle_action =      toggle_action =
# Line 405  MainWindow::MainWindow() : Line 568  MainWindow::MainWindow() :
568          toggle_action,          toggle_action,
569          sigc::mem_fun(*this, &MainWindow::on_action_move_root_note_with_region_moved)          sigc::mem_fun(*this, &MainWindow::on_action_move_root_note_with_region_moved)
570      );      );
571    #endif
572    
573    #if USE_GLIB_ACTION
574        m_actionGroup->add_action(
575            "CombineInstruments", sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments)
576        );
577        m_actionGroup->add_action(
578            "MergeFiles", sigc::mem_fun(*this, &MainWindow::on_action_merge_files)
579        );
580    #else
581      actionGroup->add(Gtk::Action::create("MenuTools", _("_Tools")));      actionGroup->add(Gtk::Action::create("MenuTools", _("_Tools")));
582    
583      actionGroup->add(      actionGroup->add(
# Line 418  MainWindow::MainWindow() : Line 589  MainWindow::MainWindow() :
589          Gtk::Action::create("MergeFiles", _("_Merge Files...")),          Gtk::Action::create("MergeFiles", _("_Merge Files...")),
590          sigc::mem_fun(*this, &MainWindow::on_action_merge_files)          sigc::mem_fun(*this, &MainWindow::on_action_merge_files)
591      );      );
592    #endif
593    
594      // sample right-click popup actions      // sample right-click popup actions
595    #if USE_GLIB_ACTION
596        m_actionSampleProperties = m_actionGroup->add_action(
597            "SampleProperties", sigc::mem_fun(*this, &MainWindow::on_action_sample_properties)
598        );
599        m_actionAddSampleGroup = m_actionGroup->add_action(
600            "AddGroup", sigc::mem_fun(*this, &MainWindow::on_action_add_group)
601        );
602        m_actionAddSample = m_actionGroup->add_action(
603            "AddSample", sigc::mem_fun(*this, &MainWindow::on_action_add_sample)
604        );
605        m_actionRemoveSample = m_actionGroup->add_action(
606            "RemoveSample", sigc::mem_fun(*this, &MainWindow::on_action_remove_sample)
607        );
608        m_actionGroup->add_action(
609            "RemoveUnusedSamples", sigc::mem_fun(*this, &MainWindow::on_action_remove_unused_samples)
610        );
611        m_actionViewSampleRefs = m_actionGroup->add_action(
612            "ShowSampleRefs", sigc::mem_fun(*this, &MainWindow::on_action_view_references)
613        );
614        m_actionReplaceSample = m_actionGroup->add_action(
615            "ReplaceSample", sigc::mem_fun(*this, &MainWindow::on_action_replace_sample)
616        );
617        m_actionGroup->add_action(
618            "ReplaceAllSamplesInAllGroups", sigc::mem_fun(*this, &MainWindow::on_action_replace_all_samples_in_all_groups)
619        );
620    #else
621      actionGroup->add(      actionGroup->add(
622          Gtk::Action::create("SampleProperties", Gtk::Stock::PROPERTIES),          Gtk::Action::create("SampleProperties", Gtk::Stock::PROPERTIES),
623          sigc::mem_fun(*this, &MainWindow::on_action_sample_properties)          sigc::mem_fun(*this, &MainWindow::on_action_sample_properties)
# Line 455  MainWindow::MainWindow() : Line 652  MainWindow::MainWindow() :
652                              _("Replace All Samples in All Groups...")),                              _("Replace All Samples in All Groups...")),
653          sigc::mem_fun(*this, &MainWindow::on_action_replace_all_samples_in_all_groups)          sigc::mem_fun(*this, &MainWindow::on_action_replace_all_samples_in_all_groups)
654      );      );
655    #endif
656            
657      // script right-click popup actions      // script right-click popup actions
658    #if USE_GLIB_ACTION
659        m_actionAddScriptGroup = m_actionGroup->add_action(
660            "AddScriptGroup", sigc::mem_fun(*this, &MainWindow::on_action_add_script_group)
661        );
662        m_actionAddScript = m_actionGroup->add_action(
663            "AddScript", sigc::mem_fun(*this, &MainWindow::on_action_add_script)
664        );
665        m_actionEditScript = m_actionGroup->add_action(
666            "EditScript", sigc::mem_fun(*this, &MainWindow::on_action_edit_script)
667        );
668        m_actionRemoveScript = m_actionGroup->add_action(
669            "RemoveScript", sigc::mem_fun(*this, &MainWindow::on_action_remove_script)
670        );
671    #else
672      actionGroup->add(      actionGroup->add(
673          Gtk::Action::create("AddScriptGroup", _("Add _Group")),          Gtk::Action::create("AddScriptGroup", _("Add _Group")),
674          sigc::mem_fun(*this, &MainWindow::on_action_add_script_group)          sigc::mem_fun(*this, &MainWindow::on_action_add_script_group)
# Line 473  MainWindow::MainWindow() : Line 685  MainWindow::MainWindow() :
685          Gtk::Action::create("RemoveScript", Gtk::Stock::REMOVE),          Gtk::Action::create("RemoveScript", Gtk::Stock::REMOVE),
686          sigc::mem_fun(*this, &MainWindow::on_action_remove_script)          sigc::mem_fun(*this, &MainWindow::on_action_remove_script)
687      );      );
688    #endif
689    
690    #if USE_GTKMM_BUILDER
691        insert_action_group("AppMenu", m_actionGroup);
692        
693        m_uiManager = Gtk::Builder::create();
694        Glib::ustring ui_info =
695            "<interface>"
696            "  <menubar id='MenuBar'>"
697            "    <menu id='MenuFile'>"
698            "      <attribute name='label' translatable='yes'>_File</attribute>"
699            "      <section>"
700            "        <item id='New'>"
701            "          <attribute name='label' translatable='yes'>New</attribute>"
702            "          <attribute name='action'>AppMenu.New</attribute>"
703            "        </item>"
704            "        <item id='Open'>"
705            "          <attribute name='label' translatable='yes'>Open</attribute>"
706            "          <attribute name='action'>AppMenu.Open</attribute>"
707            "        </item>"
708            "      </section>"
709            "      <section>"
710            "        <item id='Save'>"
711            "          <attribute name='label' translatable='yes'>Save</attribute>"
712            "          <attribute name='action'>AppMenu.Save</attribute>"
713            "        </item>"
714            "        <item id='SaveAs'>"
715            "          <attribute name='label' translatable='yes'>Save As</attribute>"
716            "          <attribute name='action'>AppMenu.SaveAs</attribute>"
717            "        </item>"
718            "      </section>"
719            "      <section>"
720            "        <item id='Properties'>"
721            "          <attribute name='label' translatable='yes'>Properties</attribute>"
722            "          <attribute name='action'>AppMenu.Properties</attribute>"
723            "        </item>"
724            "      </section>"
725            "      <section>"
726            "        <item id='Quit'>"
727            "          <attribute name='label' translatable='yes'>Quit</attribute>"
728            "          <attribute name='action'>AppMenu.Quit</attribute>"
729            "        </item>"
730            "      </section>"
731            "    </menu>"
732            "    <menu id='MenuEdit'>"
733            "      <attribute name='label' translatable='yes'>Edit</attribute>"
734            "      <section>"
735            "        <item id='CopyDimRgn'>"
736            "          <attribute name='label' translatable='yes'>Copy Dimension Region</attribute>"
737            "          <attribute name='action'>AppMenu.CopyDimRgn</attribute>"
738            "        </item>"
739            "        <item id='AdjustClipboard'>"
740            "          <attribute name='label' translatable='yes'>Adjust Clipboard</attribute>"
741            "          <attribute name='action'>AppMenu.AdjustClipboard</attribute>"
742            "        </item>"
743            "        <item id='PasteDimRgn'>"
744            "          <attribute name='label' translatable='yes'>Paste Dimension Region</attribute>"
745            "          <attribute name='action'>AppMenu.PasteDimRgn</attribute>"
746            "        </item>"
747            "      </section>"
748            "        <item id='SelectPrevInstr'>"
749            "          <attribute name='label' translatable='yes'>Previous Instrument</attribute>"
750            "          <attribute name='action'>AppMenu.SelectPrevInstr</attribute>"
751            "        </item>"
752            "        <item id='SelectNextInstr'>"
753            "          <attribute name='label' translatable='yes'>Next Instrument</attribute>"
754            "          <attribute name='action'>AppMenu.SelectNextInstr</attribute>"
755            "        </item>"
756            "      <section>"
757            "        <item id='SelectPrevRegion'>"
758            "          <attribute name='label' translatable='yes'>Previous Region</attribute>"
759            "          <attribute name='action'>AppMenu.SelectPrevRegion</attribute>"
760            "        </item>"
761            "        <item id='SelectNextRegion'>"
762            "          <attribute name='label' translatable='yes'>Next Region</attribute>"
763            "          <attribute name='action'>AppMenu.SelectNextRegion</attribute>"
764            "        </item>"
765            "      </section>"
766            "        <item id='SelectPrevDimension'>"
767            "          <attribute name='label' translatable='yes'>Previous Dimension</attribute>"
768            "          <attribute name='action'>AppMenu.SelectPrevDimension</attribute>"
769            "        </item>"
770            "        <item id='SelectNextDimension'>"
771            "          <attribute name='label' translatable='yes'>Next Dimension</attribute>"
772            "          <attribute name='action'>AppMenu.SelectNextDimension</attribute>"
773            "        </item>"
774            "        <item id='SelectPrevDimRgnZone'>"
775            "          <attribute name='label' translatable='yes'>Previous Dimension Region Zone</attribute>"
776            "          <attribute name='action'>AppMenu.SelectPrevDimRgnZone</attribute>"
777            "        </item>"
778            "        <item id='SelectNextDimRgnZone'>"
779            "          <attribute name='label' translatable='yes'>Next Dimension Region Zone</attribute>"
780            "          <attribute name='action'>AppMenu.SelectNextDimRgnZone</attribute>"
781            "        </item>"
782            "        <item id='SelectAddPrevDimRgnZone'>"
783            "          <attribute name='label' translatable='yes'>Add Previous Dimension Region Zone</attribute>"
784            "          <attribute name='action'>AppMenu.SelectAddPrevDimRgnZone</attribute>"
785            "        </item>"
786            "        <item id='SelectAddNextDimRgnZone'>"
787            "          <attribute name='label' translatable='yes'>Add Next Dimension Region Zone</attribute>"
788            "          <attribute name='action'>AppMenu.SelectAddNextDimRgnZone</attribute>"
789            "        </item>"
790            "      <section>"
791            "        <item id='CopySampleUnity'>"
792            "          <attribute name='label' translatable='yes'>Copy Sample Unity</attribute>"
793            "          <attribute name='action'>AppMenu.CopySampleUnity</attribute>"
794            "        </item>"
795            "        <item id='CopySampleTune'>"
796            "          <attribute name='label' translatable='yes'>Copy Sample Tune</attribute>"
797            "          <attribute name='action'>AppMenu.CopySampleTune</attribute>"
798            "        </item>"
799            "        <item id='CopySampleLoop'>"
800            "          <attribute name='label' translatable='yes'>Copy Sample Loop</attribute>"
801            "          <attribute name='action'>AppMenu.CopySampleLoop</attribute>"
802            "        </item>"
803            "      </section>"
804            "    </menu>"
805            "    <menu id='MenuMacro'>"
806            "      <attribute name='label' translatable='yes'>Macro</attribute>"
807            "      <section>"
808            "      </section>"
809            "    </menu>"
810            "    <menu id='MenuSample'>"
811            "      <attribute name='label' translatable='yes'>Sample</attribute>"
812            "      <section>"
813            "        <item id='SampleProperties'>"
814            "          <attribute name='label' translatable='yes'>Properties</attribute>"
815            "          <attribute name='action'>AppMenu.SampleProperties</attribute>"
816            "        </item>"
817            "        <item id='AddGroup'>"
818            "          <attribute name='label' translatable='yes'>Add Group</attribute>"
819            "          <attribute name='action'>AppMenu.AddGroup</attribute>"
820            "        </item>"
821            "        <item id='AddSample'>"
822            "          <attribute name='label' translatable='yes'>Add Sample</attribute>"
823            "          <attribute name='action'>AppMenu.AddSample</attribute>"
824            "        </item>"
825            "        <item id='ShowSampleRefs'>"
826            "          <attribute name='label' translatable='yes'>Show Sample References</attribute>"
827            "          <attribute name='action'>AppMenu.ShowSampleRefs</attribute>"
828            "        </item>"
829            "        <item id='ReplaceSample'>"
830            "          <attribute name='label' translatable='yes'>Replace Sample</attribute>"
831            "          <attribute name='action'>AppMenu.ReplaceSample</attribute>"
832            "        </item>"
833            "        <item id='ReplaceAllSamplesInAllGroups'>"
834            "          <attribute name='label' translatable='yes'>Replace all Samples in all Groups</attribute>"
835            "          <attribute name='action'>AppMenu.ReplaceAllSamplesInAllGroups</attribute>"
836            "        </item>"
837            "      </section>"
838            "      <section>"
839            "        <item id='RemoveSample'>"
840            "          <attribute name='label' translatable='yes'>Remove Sample</attribute>"
841            "          <attribute name='action'>AppMenu.RemoveSample</attribute>"
842            "        </item>"
843            "        <item id='RemoveUnusedSamples'>"
844            "          <attribute name='label' translatable='yes'>Remove unused Samples</attribute>"
845            "          <attribute name='action'>AppMenu.RemoveUnusedSamples</attribute>"
846            "        </item>"
847            "      </section>"
848            "    </menu>"
849            "    <menu id='MenuInstrument'>"
850            "      <attribute name='label' translatable='yes'>Instrument</attribute>"
851            "      <section>"
852            "        <item id='InstrProperties'>"
853            "          <attribute name='label' translatable='yes'>Properties</attribute>"
854            "          <attribute name='action'>AppMenu.InstrProperties</attribute>"
855            "        </item>"
856            "        <item id='MidiRules'>"
857            "          <attribute name='label' translatable='yes'>MIDI Rules</attribute>"
858            "          <attribute name='action'>AppMenu.MidiRules</attribute>"
859            "        </item>"
860            "        <item id='ScriptSlots'>"
861            "          <attribute name='label' translatable='yes'>Script Slots</attribute>"
862            "          <attribute name='action'>AppMenu.ScriptSlots</attribute>"
863            "        </item>"
864            "      </section>"
865            "      <submenu id='AssignScripts'>"
866            "        <attribute name='label' translatable='yes'>Assign Scripts</attribute>"
867            "      </submenu>"
868            "      <section>"
869            "        <item id='AddInstrument'>"
870            "          <attribute name='label' translatable='yes'>Add Instrument</attribute>"
871            "          <attribute name='action'>AppMenu.AddInstrument</attribute>"
872            "        </item>"
873            "        <item id='DupInstrument'>"
874            "          <attribute name='label' translatable='yes'>Duplicate Instrument</attribute>"
875            "          <attribute name='action'>AppMenu.DupInstrument</attribute>"
876            "        </item>"
877            "        <item id='CombInstruments'>"
878            "          <attribute name='label' translatable='yes'>Combine Instrument</attribute>"
879            "          <attribute name='action'>AppMenu.CombInstruments</attribute>"
880            "        </item>"
881            "      </section>"
882            "      <section>"
883            "        <item id='RemoveInstrument'>"
884            "          <attribute name='label' translatable='yes'>Remove Instrument</attribute>"
885            "          <attribute name='action'>AppMenu.RemoveInstrument</attribute>"
886            "        </item>"
887            "      </section>"
888            "    </menu>"
889            "    <menu id='MenuScript'>"
890            "      <attribute name='label' translatable='yes'>Script</attribute>"
891            "      <section>"
892            "        <item id='AddScriptGroup'>"
893            "          <attribute name='label' translatable='yes'>Add Script Group</attribute>"
894            "          <attribute name='action'>AppMenu.AddScriptGroup</attribute>"
895            "        </item>"
896            "        <item id='AddScript'>"
897            "          <attribute name='label' translatable='yes'>Add Script</attribute>"
898            "          <attribute name='action'>AppMenu.AddScript</attribute>"
899            "        </item>"
900            "        <item id='EditScript'>"
901            "          <attribute name='label' translatable='yes'>Edit Script</attribute>"
902            "          <attribute name='action'>AppMenu.EditScript</attribute>"
903            "        </item>"
904            "      </section>"
905            "      <section>"
906            "        <item id='RemoveScript'>"
907            "          <attribute name='label' translatable='yes'>Remove Script</attribute>"
908            "          <attribute name='action'>AppMenu.RemoveScript</attribute>"
909            "        </item>"
910            "      </section>"
911            "    </menu>"
912            "    <menu id='MenuView'>"
913            "      <attribute name='label' translatable='yes'>View</attribute>"
914            "      <section>"
915            "        <item id='Statusbar'>"
916            "          <attribute name='label' translatable='yes'>Statusbar</attribute>"
917            "          <attribute name='action'>AppMenu.Statusbar</attribute>"
918            "        </item>"
919            "        <item id='AutoRestoreWinDim'>"
920            "          <attribute name='label' translatable='yes'>Auto restore Window Dimensions</attribute>"
921            "          <attribute name='action'>AppMenu.AutoRestoreWinDim</attribute>"
922            "        </item>"
923            "      </section>"
924            "      <section>"
925            "        <item id='RefreshAll'>"
926            "          <attribute name='label' translatable='yes'>Refresh All</attribute>"
927            "          <attribute name='action'>AppMenu.RefreshAll</attribute>"
928            "        </item>"
929            "      </section>"
930            "    </menu>"
931            "    <menu id='MenuTools'>"
932            "      <attribute name='label' translatable='yes'>Tools</attribute>"
933            "      <section>"
934            "        <item id='CombineInstruments'>"
935            "          <attribute name='label' translatable='yes'>Combine Instruments ...</attribute>"
936            "          <attribute name='action'>AppMenu.CombineInstruments</attribute>"
937            "        </item>"
938            "        <item id='MergeFiles'>"
939            "          <attribute name='label' translatable='yes'>Merge Files ...</attribute>"
940            "          <attribute name='action'>AppMenu.MergeFiles</attribute>"
941            "        </item>"
942            "      </section>"
943            "    </menu>"
944            "    <menu id='MenuSettings'>"
945            "      <attribute name='label' translatable='yes'>Settings</attribute>"
946            "      <section>"
947            "        <item id='WarnUserOnExtensions'>"
948            "          <attribute name='label' translatable='yes'>Warning on Format Extensions</attribute>"
949            "          <attribute name='action'>AppMenu.WarnUserOnExtensions</attribute>"
950            "        </item>"
951            "        <item id='SyncSamplerInstrumentSelection'>"
952            "          <attribute name='label' translatable='yes'>Synchronize Sampler Selection</attribute>"
953            "          <attribute name='action'>AppMenu.SyncSamplerInstrumentSelection</attribute>"
954            "        </item>"
955            "        <item id='MoveRootNoteWithRegionMoved'>"
956            "          <attribute name='label' translatable='yes'>Move Root Note with Region moved</attribute>"
957            "          <attribute name='action'>AppMenu.MoveRootNoteWithRegionMoved</attribute>"
958            "        </item>"
959            "        <item id='SaveWithTemporaryFile'>"
960            "          <attribute name='label' translatable='yes'>Save with temporary file</attribute>"
961            "          <attribute name='action'>AppMenu.SaveWithTemporaryFile</attribute>"
962            "        </item>"
963            "      </section>"
964            "    </menu>"
965            "    <menu id='MenuHelp'>"
966            "      <attribute name='label' translatable='yes'>Help</attribute>"
967            "      <section>"
968            "        <item id='About'>"
969            "          <attribute name='label' translatable='yes'>About ...</attribute>"
970            "          <attribute name='action'>AppMenu.About</attribute>"
971            "        </item>"
972            "      </section>"
973            "    </menu>"
974            "  </menubar>"
975            // popups
976            "  <menu id='PopupMenu'>"
977            "    <section>"
978            "      <item id='InstrProperties'>"
979            "        <attribute name='label' translatable='yes'>Instrument Properties</attribute>"
980            "        <attribute name='action'>AppMenu.InstrProperties</attribute>"
981            "      </item>"
982            "      <item id='MidiRules'>"
983            "        <attribute name='label' translatable='yes'>MIDI Rules</attribute>"
984            "        <attribute name='action'>AppMenu.MidiRules</attribute>"
985            "      </item>"
986            "      <item id='ScriptSlots'>"
987            "        <attribute name='label' translatable='yes'>Script Slots</attribute>"
988            "        <attribute name='action'>AppMenu.ScriptSlots</attribute>"
989            "      </item>"
990            "      <item id='AddInstrument'>"
991            "        <attribute name='label' translatable='yes'>Add Instrument</attribute>"
992            "        <attribute name='action'>AppMenu.AddInstrument</attribute>"
993            "      </item>"
994            "      <item id='DupInstrument'>"
995            "        <attribute name='label' translatable='yes'>Duplicate Instrument</attribute>"
996            "        <attribute name='action'>AppMenu.DupInstrument</attribute>"
997            "      </item>"
998            "      <item id='CombInstruments'>"
999            "        <attribute name='label' translatable='yes'>Combine Instruments</attribute>"
1000            "        <attribute name='action'>AppMenu.CombInstruments</attribute>"
1001            "      </item>"
1002            "    </section>"
1003            "    <section>"
1004            "      <item id='RemoveInstrument'>"
1005            "        <attribute name='label' translatable='yes'>Remove Instruments</attribute>"
1006            "        <attribute name='action'>AppMenu.RemoveInstrument</attribute>"
1007            "      </item>"
1008            "    </section>"
1009            "  </menu>"
1010            "  <menu id='SamplePopupMenu'>"
1011            "    <section>"
1012            "      <item id='SampleProperties'>"
1013            "        <attribute name='label' translatable='yes'>Sample Properties</attribute>"
1014            "        <attribute name='action'>AppMenu.SampleProperties</attribute>"
1015            "      </item>"
1016            "      <item id='AddGroup'>"
1017            "        <attribute name='label' translatable='yes'>Add Sample Group</attribute>"
1018            "        <attribute name='action'>AppMenu.AddGroup</attribute>"
1019            "      </item>"
1020            "      <item id='AddSample'>"
1021            "        <attribute name='label' translatable='yes'>Add Sample</attribute>"
1022            "        <attribute name='action'>AppMenu.AddSample</attribute>"
1023            "      </item>"
1024            "      <item id='ShowSampleRefs'>"
1025            "        <attribute name='label' translatable='yes'>Show Sample References ...</attribute>"
1026            "        <attribute name='action'>AppMenu.ShowSampleRefs</attribute>"
1027            "      </item>"
1028            "      <item id='ReplaceSample'>"
1029            "        <attribute name='label' translatable='yes'>Replace Sample</attribute>"
1030            "        <attribute name='action'>AppMenu.ReplaceSample</attribute>"
1031            "      </item>"
1032            "      <item id='ReplaceAllSamplesInAllGroups'>"
1033            "        <attribute name='label' translatable='yes'>Replace all Samples ...</attribute>"
1034            "        <attribute name='action'>AppMenu.ReplaceAllSamplesInAllGroups</attribute>"
1035            "      </item>"
1036            "    </section>"
1037            "    <section>"
1038            "      <item id='RemoveSample'>"
1039            "        <attribute name='label' translatable='yes'>Remove Sample</attribute>"
1040            "        <attribute name='action'>AppMenu.RemoveSample</attribute>"
1041            "      </item>"
1042            "      <item id='RemoveUnusedSamples'>"
1043            "        <attribute name='label' translatable='yes'>Remove unused Samples</attribute>"
1044            "        <attribute name='action'>AppMenu.RemoveUnusedSamples</attribute>"
1045            "      </item>"
1046            "    </section>"
1047            "  </menu>"
1048            "  <menu id='ScriptPopupMenu'>"
1049            "    <section>"
1050            "      <item id='AddScriptGroup'>"
1051            "        <attribute name='label' translatable='yes'>Add Script Group</attribute>"
1052            "        <attribute name='action'>AppMenu.AddScriptGroup</attribute>"
1053            "      </item>"
1054            "      <item id='AddScript'>"
1055            "        <attribute name='label' translatable='yes'>Add Script</attribute>"
1056            "        <attribute name='action'>AppMenu.AddScript</attribute>"
1057            "      </item>"
1058            "      <item id='EditScript'>"
1059            "        <attribute name='label' translatable='yes'>Edit Script</attribute>"
1060            "        <attribute name='action'>AppMenu.EditScript</attribute>"
1061            "      </item>"
1062            "    </section>"
1063            "    <section>"
1064            "      <item id='RemoveScript'>"
1065            "        <attribute name='label' translatable='yes'>Remove Script</attribute>"
1066            "        <attribute name='action'>AppMenu.RemoveScript</attribute>"
1067            "      </item>"
1068            "    </section>"
1069            "  </menu>"
1070            "</interface>";
1071        m_uiManager->add_from_string(ui_info);
1072    #else
1073      uiManager = Gtk::UIManager::create();      uiManager = Gtk::UIManager::create();
1074      uiManager->insert_action_group(actionGroup);      uiManager->insert_action_group(actionGroup);
1075      add_accel_group(uiManager->get_accel_group());      add_accel_group(uiManager->get_accel_group());
# Line 598  MainWindow::MainWindow() : Line 1194  MainWindow::MainWindow() :
1194          "  </popup>"          "  </popup>"
1195          "</ui>";          "</ui>";
1196      uiManager->add_ui_from_string(ui_info);      uiManager->add_ui_from_string(ui_info);
1197    #endif
1198    
1199    #if USE_GTKMM_BUILDER
1200        popup_menu = new Gtk::Menu(
1201            Glib::RefPtr<Gio::Menu>::cast_dynamic(
1202                m_uiManager->get_object("PopupMenu")
1203            )
1204        );
1205        sample_popup = new Gtk::Menu(
1206            Glib::RefPtr<Gio::Menu>::cast_dynamic(
1207                m_uiManager->get_object("SamplePopupMenu")
1208            )
1209        );
1210        script_popup = new Gtk::Menu(
1211            Glib::RefPtr<Gio::Menu>::cast_dynamic(
1212                m_uiManager->get_object("ScriptPopupMenu")
1213            )
1214        );
1215    #else
1216      popup_menu = dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/PopupMenu"));      popup_menu = dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/PopupMenu"));
1217            
1218      // Set tooltips for menu items (for some reason, setting a tooltip on the      // Set tooltips for menu items (for some reason, setting a tooltip on the
# Line 664  MainWindow::MainWindow() : Line 1278  MainWindow::MainWindow() :
1278              uiManager->get_widget("/MenuBar/MenuTools/MergeFiles"));              uiManager->get_widget("/MenuBar/MenuTools/MergeFiles"));
1279          item->set_tooltip_text(_("Add instruments and samples of other .gig files to this .gig file."));          item->set_tooltip_text(_("Add instruments and samples of other .gig files to this .gig file."));
1280      }      }
1281    #endif
1282    
1283    #if USE_GTKMM_BUILDER
1284        assign_scripts_menu = new Gtk::Menu(
1285            Glib::RefPtr<Gio::Menu>::cast_dynamic(
1286                m_uiManager->get_object("AssignScripts")
1287            )
1288        );
1289    #else
1290      instrument_menu = static_cast<Gtk::MenuItem*>(      instrument_menu = static_cast<Gtk::MenuItem*>(
1291          uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments"))->get_submenu();          uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments"))->get_submenu();
1292    
1293      assign_scripts_menu = static_cast<Gtk::MenuItem*>(      assign_scripts_menu = static_cast<Gtk::MenuItem*>(
1294          uiManager->get_widget("/MenuBar/MenuInstrument/AssignScripts"))->get_submenu();          uiManager->get_widget("/MenuBar/MenuInstrument/AssignScripts"))->get_submenu();
1295    #endif
1296    
1297    #if USE_GTKMM_BUILDER
1298        Gtk::Widget* menuBar = NULL;
1299        m_uiManager->get_widget("MenuBar", menuBar);
1300    #else
1301      Gtk::Widget* menuBar = uiManager->get_widget("/MenuBar");      Gtk::Widget* menuBar = uiManager->get_widget("/MenuBar");
1302    #endif
1303    
1304      m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK);      m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK);
1305      m_VBox.pack_start(m_HPaned);      m_VBox.pack_start(m_HPaned);
1306      m_VBox.pack_start(m_RegionChooser, Gtk::PACK_SHRINK);      m_VBox.pack_start(m_RegionChooser, Gtk::PACK_SHRINK);
# Line 683  MainWindow::MainWindow() : Line 1311  MainWindow::MainWindow() :
1311      set_file_is_shared(false);      set_file_is_shared(false);
1312    
1313      // Status Bar:      // Status Bar:
1314    #if USE_GTKMM_BOX
1315    # warning No status bar layout for GTKMM 4 yet
1316    #else
1317      m_StatusBar.pack_start(m_AttachedStateLabel, Gtk::PACK_SHRINK);      m_StatusBar.pack_start(m_AttachedStateLabel, Gtk::PACK_SHRINK);
1318      m_StatusBar.pack_start(m_AttachedStateImage, Gtk::PACK_SHRINK);      m_StatusBar.pack_start(m_AttachedStateImage, Gtk::PACK_SHRINK);
1319    #endif
1320      m_StatusBar.show();      m_StatusBar.show();
1321    
1322      m_RegionChooser.signal_region_selected().connect(      m_RegionChooser.signal_region_selected().connect(
# Line 756  MainWindow::MainWindow() : Line 1388  MainWindow::MainWindow() :
1388          );          );
1389      }      }
1390      m_TreeViewSamples.set_headers_visible(true);      m_TreeViewSamples.set_headers_visible(true);
1391    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2
1392        m_TreeViewSamples.signal_button_press_event().connect(
1393            sigc::mem_fun(*this, &MainWindow::on_sample_treeview_button_release)
1394        );
1395    #else
1396      m_TreeViewSamples.signal_button_press_event().connect_notify(      m_TreeViewSamples.signal_button_press_event().connect_notify(
1397          sigc::mem_fun(*this, &MainWindow::on_sample_treeview_button_release)          sigc::mem_fun(*this, &MainWindow::on_sample_treeview_button_release)
1398      );      );
1399    #endif
1400      m_refSamplesTreeModel->signal_row_changed().connect(      m_refSamplesTreeModel->signal_row_changed().connect(
1401          sigc::mem_fun(*this, &MainWindow::sample_name_changed)          sigc::mem_fun(*this, &MainWindow::sample_name_changed)
1402      );      );
# Line 775  MainWindow::MainWindow() : Line 1413  MainWindow::MainWindow() :
1413      // m_TreeViewScripts.set_reorderable();      // m_TreeViewScripts.set_reorderable();
1414      m_TreeViewScripts.append_column_editable("Samples", m_ScriptsModel.m_col_name);      m_TreeViewScripts.append_column_editable("Samples", m_ScriptsModel.m_col_name);
1415      m_TreeViewScripts.set_headers_visible(false);      m_TreeViewScripts.set_headers_visible(false);
1416    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2
1417        m_TreeViewScripts.signal_button_press_event().connect(
1418            sigc::mem_fun(*this, &MainWindow::on_script_treeview_button_release)
1419        );
1420    #else
1421      m_TreeViewScripts.signal_button_press_event().connect_notify(      m_TreeViewScripts.signal_button_press_event().connect_notify(
1422          sigc::mem_fun(*this, &MainWindow::on_script_treeview_button_release)          sigc::mem_fun(*this, &MainWindow::on_script_treeview_button_release)
1423      );      );
1424    #endif
1425      //FIXME: why the heck does this double click signal_row_activated() only fire while CTRL key is pressed ?      //FIXME: why the heck does this double click signal_row_activated() only fire while CTRL key is pressed ?
1426      m_TreeViewScripts.signal_row_activated().connect(      m_TreeViewScripts.signal_row_activated().connect(
1427          sigc::mem_fun(*this, &MainWindow::script_double_clicked)          sigc::mem_fun(*this, &MainWindow::script_double_clicked)
# Line 883  MainWindow::MainWindow() : Line 1527  MainWindow::MainWindow() :
1527      file = 0;      file = 0;
1528      file_is_changed = false;      file_is_changed = false;
1529    
1530    #if HAS_GTKMM_SHOW_ALL_CHILDREN
1531      show_all_children();      show_all_children();
1532    #endif
1533    
1534      // start with a new gig file by default      // start with a new gig file by default
1535      on_action_file_new();      on_action_file_new();
# Line 904  MainWindow::MainWindow() : Line 1550  MainWindow::MainWindow() :
1550    
1551      // setup macros and their keyboard accelerators      // setup macros and their keyboard accelerators
1552      {      {
1553    #if USE_GTKMM_BUILDER
1554            menuMacro = new Gtk::Menu(
1555                Glib::RefPtr<Gio::Menu>::cast_dynamic(
1556                    m_uiManager->get_object("MenuMacro")
1557                )
1558            );
1559    #else
1560          Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>(          Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>(
1561              uiManager->get_widget("/MenuBar/MenuMacro")              uiManager->get_widget("/MenuBar/MenuMacro")
1562          )->get_submenu();          )->get_submenu();
1563    #endif
1564    
1565          const Gdk::ModifierType noModifier = (Gdk::ModifierType)0;          const Gdk::ModifierType noModifier = (Gdk::ModifierType)0;
1566          Gtk::AccelMap::add_entry("<Macros>/macro_0", GDK_KEY_F1, noModifier);          Gtk::AccelMap::add_entry("<Macros>/macro_0", GDK_KEY_F1, noModifier);
# Line 967  void MainWindow::bringToFront() { Line 1621  void MainWindow::bringToFront() {
1621  }  }
1622    
1623  void MainWindow::updateMacroMenu() {  void MainWindow::updateMacroMenu() {
1624    #if !USE_GTKMM_BUILDER
1625      Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>(      Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>(
1626          uiManager->get_widget("/MenuBar/MenuMacro")          uiManager->get_widget("/MenuBar/MenuMacro")
1627      )->get_submenu();      )->get_submenu();
1628    #endif
1629    
1630      // remove all entries from "Macro" menu      // remove all entries from "Macro" menu
1631      {      {
# Line 1027  void MainWindow::updateMacroMenu() { Line 1683  void MainWindow::updateMacroMenu() {
1683          item->set_accel_path("<Macros>/SetupMacros");          item->set_accel_path("<Macros>/SetupMacros");
1684      }      }
1685    
1686    #if HAS_GTKMM_SHOW_ALL_CHILDREN
1687      menuMacro->show_all_children();      menuMacro->show_all_children();
1688    #endif
1689  }  }
1690    
1691  void MainWindow::onMacroSelected(int iMacro) {  void MainWindow::onMacroSelected(int iMacro) {
# Line 1093  gig::Instrument* MainWindow::get_instrum Line 1751  gig::Instrument* MainWindow::get_instrum
1751      gig::Instrument* instrument = 0;      gig::Instrument* instrument = 0;
1752      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();
1753      if (rows.empty()) return NULL;      if (rows.empty()) return NULL;
1754      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.
1755        Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]);
1756      if (it) {      if (it) {
1757          Gtk::TreeModel::Row row = *it;          Gtk::TreeModel::Row row = *it;
1758          instrument = row[m_Columns.m_col_instr];          instrument = row[m_Columns.m_col_instr];
# Line 1159  void MainWindow::dimreg_changed() Line 1818  void MainWindow::dimreg_changed()
1818    
1819  void MainWindow::on_sel_change()  void MainWindow::on_sel_change()
1820  {  {
1821    #if !USE_GTKMM_BUILDER
1822      // select item in instrument menu      // select item in instrument menu
1823      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();
1824      if (!rows.empty()) {      if (!rows.empty()) {
# Line 1171  void MainWindow::on_sel_change() Line 1831  void MainWindow::on_sel_change()
1831              static_cast<Gtk::RadioMenuItem*>(children[index])->set_active();              static_cast<Gtk::RadioMenuItem*>(children[index])->set_active();
1832          }          }
1833      }      }
1834    #endif
1835    
1836      updateScriptListOfMenu();      updateScriptListOfMenu();
1837    
# Line 1381  Glib::Dispatcher& Saver::signal_error() Line 2042  Glib::Dispatcher& Saver::signal_error()
2042  ProgressDialog::ProgressDialog(const Glib::ustring& title, Gtk::Window& parent)  ProgressDialog::ProgressDialog(const Glib::ustring& title, Gtk::Window& parent)
2043      : Gtk::Dialog(title, parent, true)      : Gtk::Dialog(title, parent, true)
2044  {  {
2045    #if USE_GTKMM_BOX
2046        get_content_area()->pack_start(progressBar);
2047    #else
2048      get_vbox()->pack_start(progressBar);      get_vbox()->pack_start(progressBar);
2049    #endif
2050    #if HAS_GTKMM_SHOW_ALL_CHILDREN
2051      show_all_children();      show_all_children();
2052    #endif
2053      resize(600,50);      resize(600,50);
2054  }  }
2055    
# Line 1395  void MainWindow::__clear() { Line 2062  void MainWindow::__clear() {
2062      m_refTreeModel->clear();      m_refTreeModel->clear();
2063      m_refSamplesTreeModel->clear();      m_refSamplesTreeModel->clear();
2064      m_refScriptsTreeModel->clear();      m_refScriptsTreeModel->clear();
2065    #if !USE_GTKMM_BUILDER
2066      // remove all entries from "Instrument" menu      // remove all entries from "Instrument" menu
2067      while (!instrument_menu->get_children().empty()) {      while (!instrument_menu->get_children().empty()) {
2068          remove_instrument_from_menu(0);          remove_instrument_from_menu(0);
2069      }      }
2070    #endif
2071      // free libgig's gig::File instance      // free libgig's gig::File instance
2072      if (file && !file_is_shared) delete file;      if (file && !file_is_shared) delete file;
2073      file = NULL;      file = NULL;
# Line 1410  void MainWindow::__refreshEntireGUI() { Line 2079  void MainWindow::__refreshEntireGUI() {
2079      m_refTreeModel->clear();      m_refTreeModel->clear();
2080      m_refSamplesTreeModel->clear();      m_refSamplesTreeModel->clear();
2081      m_refScriptsTreeModel->clear();      m_refScriptsTreeModel->clear();
2082    #if !USE_GTKMM_BUILDER
2083      // remove all entries from "Instrument" menu      // remove all entries from "Instrument" menu
2084      while (!instrument_menu->get_children().empty()) {      while (!instrument_menu->get_children().empty()) {
2085          remove_instrument_from_menu(0);          remove_instrument_from_menu(0);
2086      }      }
2087    #endif
2088    
2089      if (!this->file) return;      if (!this->file) return;
2090    
# Line 1447  bool MainWindow::close_confirmation_dial Line 2118  bool MainWindow::close_confirmation_dial
2118      g_free(msg);      g_free(msg);
2119      dialog.set_secondary_text(_("If you close without saving, your changes will be lost."));      dialog.set_secondary_text(_("If you close without saving, your changes will be lost."));
2120      dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO);      dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO);
2121    #if HAS_GTKMM_STOCK
2122      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
2123      dialog.add_button(file_has_name ? Gtk::Stock::SAVE : Gtk::Stock::SAVE_AS, Gtk::RESPONSE_YES);      dialog.add_button(file_has_name ? Gtk::Stock::SAVE : Gtk::Stock::SAVE_AS, Gtk::RESPONSE_YES);
2124    #else
2125        dialog.add_button(_("_OK"), Gtk::RESPONSE_OK);
2126        dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
2127    #endif
2128      dialog.set_default_response(Gtk::RESPONSE_YES);      dialog.set_default_response(Gtk::RESPONSE_YES);
2129      int response = dialog.run();      int response = dialog.run();
2130      dialog.hide();      dialog.hide();
# Line 1479  bool MainWindow::leaving_shared_mode_dia Line 2155  bool MainWindow::leaving_shared_mode_dia
2155            "used by the sampler until you tell the sampler explicitly to "            "used by the sampler until you tell the sampler explicitly to "
2156            "load it."));            "load it."));
2157      dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES);      dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES);
2158    #if HAS_GTKMM_STOCK
2159      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
2160    #else
2161        dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
2162    #endif
2163      dialog.set_default_response(Gtk::RESPONSE_CANCEL);      dialog.set_default_response(Gtk::RESPONSE_CANCEL);
2164      int response = dialog.run();      int response = dialog.run();
2165      dialog.hide();      dialog.hide();
# Line 1493  void MainWindow::on_action_file_open() Line 2173  void MainWindow::on_action_file_open()
2173      if (file_is_shared && !leaving_shared_mode_dialog()) return;      if (file_is_shared && !leaving_shared_mode_dialog()) return;
2174    
2175      Gtk::FileChooserDialog dialog(*this, _("Open file"));      Gtk::FileChooserDialog dialog(*this, _("Open file"));
2176    #if HAS_GTKMM_STOCK
2177      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
2178      dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);      dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
2179    #else
2180        dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
2181        dialog.add_button(_("_Open"), Gtk::RESPONSE_OK);
2182    #endif
2183      dialog.set_default_response(Gtk::RESPONSE_OK);      dialog.set_default_response(Gtk::RESPONSE_OK);
2184  #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2  #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
2185      Gtk::FileFilter filter;      Gtk::FileFilter filter;
# Line 1526  void MainWindow::load_file(const char* n Line 2211  void MainWindow::load_file(const char* n
2211          Glib::filename_display_basename(name) + "' ...",          Glib::filename_display_basename(name) + "' ...",
2212          *this          *this
2213      );      );
2214    #if HAS_GTKMM_SHOW_ALL_CHILDREN
2215      progress_dialog->show_all();      progress_dialog->show_all();
2216    #endif
2217      loader = new Loader(name); //FIXME: memory leak!      loader = new Loader(name); //FIXME: memory leak!
2218      loader->signal_progress().connect(      loader->signal_progress().connect(
2219          sigc::mem_fun(*this, &MainWindow::on_loader_progress));          sigc::mem_fun(*this, &MainWindow::on_loader_progress));
# Line 1560  void MainWindow::load_instrument(gig::In Line 2247  void MainWindow::load_instrument(gig::In
2247              // make sure the selected item in the "instruments" tree view is              // make sure the selected item in the "instruments" tree view is
2248              // visible (scroll to it)              // visible (scroll to it)
2249              m_TreeView.scroll_to_row(Gtk::TreePath(ToString(i)));              m_TreeView.scroll_to_row(Gtk::TreePath(ToString(i)));
2250    #if !USE_GTKMM_BUILDER
2251              // select item in instrument menu              // select item in instrument menu
2252              {              {
2253                  const std::vector<Gtk::Widget*> children =                  const std::vector<Gtk::Widget*> children =
2254                      instrument_menu->get_children();                      instrument_menu->get_children();
2255                  static_cast<Gtk::RadioMenuItem*>(children[i])->set_active();                  static_cast<Gtk::RadioMenuItem*>(children[i])->set_active();
2256              }              }
2257    #endif
2258              // update region chooser and dimension region chooser              // update region chooser and dimension region chooser
2259              m_RegionChooser.set_instrument(instr);              m_RegionChooser.set_instrument(instr);
2260              break;              break;
# Line 1637  bool MainWindow::file_save() Line 2326  bool MainWindow::file_save()
2326          Glib::filename_display_basename(this->filename) + "' ...",          Glib::filename_display_basename(this->filename) + "' ...",
2327          *this          *this
2328      );      );
2329    #if HAS_GTKMM_SHOW_ALL_CHILDREN
2330      progress_dialog->show_all();      progress_dialog->show_all();
2331    #endif
2332      saver = new Saver(this->file); //FIXME: memory leak!      saver = new Saver(this->file); //FIXME: memory leak!
2333      saver->signal_progress().connect(      saver->signal_progress().connect(
2334          sigc::mem_fun(*this, &MainWindow::on_saver_progress));          sigc::mem_fun(*this, &MainWindow::on_saver_progress));
# Line 1690  void MainWindow::on_action_file_save_as( Line 2381  void MainWindow::on_action_file_save_as(
2381  bool MainWindow::file_save_as()  bool MainWindow::file_save_as()
2382  {  {
2383      Gtk::FileChooserDialog dialog(*this, _("Save as"), Gtk::FILE_CHOOSER_ACTION_SAVE);      Gtk::FileChooserDialog dialog(*this, _("Save as"), Gtk::FILE_CHOOSER_ACTION_SAVE);
2384    #if HAS_GTKMM_STOCK
2385      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
2386      dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);      dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);
2387    #else
2388        dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
2389        dialog.add_button(_("_Save"), Gtk::RESPONSE_OK);
2390    #endif
2391      dialog.set_default_response(Gtk::RESPONSE_OK);      dialog.set_default_response(Gtk::RESPONSE_OK);
2392      dialog.set_do_overwrite_confirmation();      dialog.set_do_overwrite_confirmation();
2393    
# Line 1720  bool MainWindow::file_save_as() Line 2416  bool MainWindow::file_save_as()
2416      }      }
2417    
2418      // show warning in the dialog      // show warning in the dialog
2419      Gtk::HBox descriptionArea;      HBox descriptionArea;
2420      descriptionArea.set_spacing(15);      descriptionArea.set_spacing(15);
2421      Gtk::Image warningIcon;      Gtk::Image warningIcon;
2422      warningIcon.set_from_icon_name("dialog-warning",      warningIcon.set_from_icon_name("dialog-warning",
# Line 1741  bool MainWindow::file_save_as() Line 2437  bool MainWindow::file_save_as()
2437            "same .gig file will end up in corrupted sample wave data!\n")            "same .gig file will end up in corrupted sample wave data!\n")
2438      );      );
2439      descriptionArea.pack_start(description);      descriptionArea.pack_start(description);
2440    #if USE_GTKMM_BOX
2441        dialog.get_content_area()->pack_start(descriptionArea, Gtk::PACK_SHRINK);
2442    #else
2443      dialog.get_vbox()->pack_start(descriptionArea, Gtk::PACK_SHRINK);      dialog.get_vbox()->pack_start(descriptionArea, Gtk::PACK_SHRINK);
2444    #endif
2445    #if HAS_GTKMM_SHOW_ALL_CHILDREN
2446      descriptionArea.show_all();      descriptionArea.show_all();
2447    #endif
2448    
2449      if (dialog.run() == Gtk::RESPONSE_OK) {      if (dialog.run() == Gtk::RESPONSE_OK) {
2450          std::string filename = dialog.get_filename();          std::string filename = dialog.get_filename();
# Line 1756  bool MainWindow::file_save_as() Line 2458  bool MainWindow::file_save_as()
2458              Glib::filename_display_basename(filename) + "' ...",              Glib::filename_display_basename(filename) + "' ...",
2459              *this              *this
2460          );          );
2461    #if HAS_GTKMM_SHOW_ALL_CHILDREN
2462          progress_dialog->show_all();          progress_dialog->show_all();
2463    #endif
2464    
2465          saver = new Saver(file, filename); //FIXME: memory leak!          saver = new Saver(file, filename); //FIXME: memory leak!
2466          saver->signal_progress().connect(          saver->signal_progress().connect(
# Line 1937  PropDialog::PropDialog() Line 2641  PropDialog::PropDialog()
2641        eSourceForm(_("Source form")),        eSourceForm(_("Source form")),
2642        eCommissioned(_("Commissioned")),        eCommissioned(_("Commissioned")),
2643        eSubject(_("Subject")),        eSubject(_("Subject")),
2644    #if HAS_GTKMM_STOCK
2645        quitButton(Gtk::Stock::CLOSE),        quitButton(Gtk::Stock::CLOSE),
2646    #else
2647          quitButton(_("_Close")),
2648    #endif
2649        table(2, 1),        table(2, 1),
2650        m_file(NULL)        m_file(NULL)
2651  {  {
# Line 1984  PropDialog::PropDialog() Line 2692  PropDialog::PropDialog()
2692      table.add(eCommissioned);      table.add(eCommissioned);
2693      table.add(eSubject);      table.add(eSubject);
2694    
2695    #if USE_GTKMM_GRID
2696        table.set_column_spacing(5);
2697    #else
2698      table.set_col_spacings(5);      table.set_col_spacings(5);
2699    #endif
2700    
2701      add(vbox);      add(vbox);
2702    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22)
2703        table.set_margin(5);
2704    #else
2705      table.set_border_width(5);      table.set_border_width(5);
2706    #endif
2707      vbox.add(table);      vbox.add(table);
2708      vbox.pack_start(buttonBox, Gtk::PACK_SHRINK);      vbox.pack_start(buttonBox, Gtk::PACK_SHRINK);
2709      buttonBox.set_layout(Gtk::BUTTONBOX_END);      buttonBox.set_layout(Gtk::BUTTONBOX_END);
2710    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22)
2711        buttonBox.set_margin(5);
2712    #else
2713      buttonBox.set_border_width(5);      buttonBox.set_border_width(5);
2714    #endif
2715      buttonBox.show();      buttonBox.show();
2716      buttonBox.pack_start(quitButton);      buttonBox.pack_start(quitButton);
2717      quitButton.set_can_default();      quitButton.set_can_default();
# Line 2002  PropDialog::PropDialog() Line 2723  PropDialog::PropDialog()
2723    
2724      quitButton.show();      quitButton.show();
2725      vbox.show();      vbox.show();
2726    #if HAS_GTKMM_SHOW_ALL_CHILDREN
2727      show_all_children();      show_all_children();
2728    #endif
2729  }  }
2730    
2731  void PropDialog::set_file(gig::File* file)  void PropDialog::set_file(gig::File* file)
# Line 2065  void InstrumentProps::set_MIDIProgram(ui Line 2788  void InstrumentProps::set_MIDIProgram(ui
2788  }  }
2789    
2790  InstrumentProps::InstrumentProps() :  InstrumentProps::InstrumentProps() :
2791    #if HAS_GTKMM_STOCK
2792      quitButton(Gtk::Stock::CLOSE),      quitButton(Gtk::Stock::CLOSE),
2793    #else
2794        quitButton(_("_Close")),
2795    #endif
2796      table(2,1),      table(2,1),
2797      eName(_("Name")),      eName(_("Name")),
2798      eIsDrum(_("Is drum")),      eIsDrum(_("Is drum")),
# Line 2111  InstrumentProps::InstrumentProps() : Line 2838  InstrumentProps::InstrumentProps() :
2838    
2839      eName.signal_value_changed().connect(sig_name_changed.make_slot());      eName.signal_value_changed().connect(sig_name_changed.make_slot());
2840    
2841    #if USE_GTKMM_GRID
2842        table.set_column_spacing(5);
2843    #else
2844      table.set_col_spacings(5);      table.set_col_spacings(5);
2845    #endif
2846    
2847      table.add(eName);      table.add(eName);
2848      table.add(eIsDrum);      table.add(eIsDrum);
# Line 2127  InstrumentProps::InstrumentProps() : Line 2858  InstrumentProps::InstrumentProps() :
2858      table.add(eDimensionKeyRangeHigh);      table.add(eDimensionKeyRangeHigh);
2859    
2860      add(vbox);      add(vbox);
2861    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22)
2862        table.set_margin(5);
2863    #else
2864      table.set_border_width(5);      table.set_border_width(5);
2865    #endif
2866      vbox.pack_start(table);      vbox.pack_start(table);
2867      table.show();      table.show();
2868      vbox.pack_start(buttonBox, Gtk::PACK_SHRINK);      vbox.pack_start(buttonBox, Gtk::PACK_SHRINK);
2869      buttonBox.set_layout(Gtk::BUTTONBOX_END);      buttonBox.set_layout(Gtk::BUTTONBOX_END);
2870    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22)
2871        buttonBox.set_margin(5);
2872    #else
2873      buttonBox.set_border_width(5);      buttonBox.set_border_width(5);
2874    #endif
2875      buttonBox.show();      buttonBox.show();
2876      buttonBox.pack_start(quitButton);      buttonBox.pack_start(quitButton);
2877      quitButton.set_can_default();      quitButton.set_can_default();
# Line 2143  InstrumentProps::InstrumentProps() : Line 2882  InstrumentProps::InstrumentProps() :
2882    
2883      quitButton.show();      quitButton.show();
2884      vbox.show();      vbox.show();
2885    #if HAS_GTKMM_SHOW_ALL_CHILDREN
2886      show_all_children();      show_all_children();
2887    #endif
2888  }  }
2889    
2890  void InstrumentProps::set_instrument(gig::Instrument* instrument)  void InstrumentProps::set_instrument(gig::Instrument* instrument)
# Line 2218  void MainWindow::load_gig(gig::File* gig Line 2959  void MainWindow::load_gig(gig::File* gig
2959          row[m_Columns.m_col_instr] = instrument;          row[m_Columns.m_col_instr] = instrument;
2960          row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : "";          row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : "";
2961    
2962    #if !USE_GTKMM_BUILDER
2963          add_instrument_to_menu(name);          add_instrument_to_menu(name);
2964    #endif
2965      }      }
2966      instrument_name_connection.unblock();      instrument_name_connection.unblock();
2967    #if !USE_GTKMM_BUILDER
2968      uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments")->show();      uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments")->show();
2969    #endif
2970    
2971      updateSampleRefCountMap(gig);      updateSampleRefCountMap(gig);
2972    
# Line 2292  bool MainWindow::instr_props_set_instrum Line 3037  bool MainWindow::instr_props_set_instrum
3037          instrumentProps.hide();          instrumentProps.hide();
3038          return false;          return false;
3039      }      }
3040      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.
3041        Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]);
3042      if (it) {      if (it) {
3043          Gtk::TreeModel::Row row = *it;          Gtk::TreeModel::Row row = *it;
3044          gig::Instrument* instrument = row[m_Columns.m_col_instr];          gig::Instrument* instrument = row[m_Columns.m_col_instr];
# Line 2309  bool MainWindow::instr_props_set_instrum Line 3055  bool MainWindow::instr_props_set_instrum
3055      } else {      } else {
3056          instrumentProps.hide();          instrumentProps.hide();
3057      }      }
3058      return it;      //NOTE: explicit boolean cast required for GTKMM4 development branch here
3059        return it ? true : false;
3060  }  }
3061    
3062  void MainWindow::show_instr_props()  void MainWindow::show_instr_props()
# Line 2404  void MainWindow::on_action_refresh_all() Line 3151  void MainWindow::on_action_refresh_all()
3151  }  }
3152    
3153  void MainWindow::on_action_view_status_bar() {  void MainWindow::on_action_view_status_bar() {
3154    #if USE_GLIB_ACTION
3155        bool active = false;
3156        m_actionToggleStatusBar->get_state(active);
3157        // for some reason toggle state does not change automatically
3158        active = !active;
3159        m_actionToggleStatusBar->change_state(active);
3160        if (active)
3161            m_StatusBar.show();
3162        else
3163            m_StatusBar.hide();
3164    #else
3165      Gtk::CheckMenuItem* item =      Gtk::CheckMenuItem* item =
3166          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar"));          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar"));
3167      if (!item) {      if (!item) {
# Line 2412  void MainWindow::on_action_view_status_b Line 3170  void MainWindow::on_action_view_status_b
3170      }      }
3171      if (item->get_active()) m_StatusBar.show();      if (item->get_active()) m_StatusBar.show();
3172      else                    m_StatusBar.hide();      else                    m_StatusBar.hide();
3173    #endif
3174  }  }
3175    
3176  void MainWindow::on_auto_restore_win_dim() {  void MainWindow::on_auto_restore_win_dim() {
3177    #if USE_GLIB_ACTION
3178        bool active = false;
3179        m_actionToggleRestoreWinDim->get_state(active);
3180        // for some reason toggle state does not change automatically
3181        active = !active;
3182        m_actionToggleRestoreWinDim->change_state(active);
3183        Settings::singleton()->autoRestoreWindowDimension = active;
3184    #else
3185      Gtk::CheckMenuItem* item =      Gtk::CheckMenuItem* item =
3186          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/AutoRestoreWinDim"));          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/AutoRestoreWinDim"));
3187      if (!item) {      if (!item) {
# Line 2422  void MainWindow::on_auto_restore_win_dim Line 3189  void MainWindow::on_auto_restore_win_dim
3189          return;          return;
3190      }      }
3191      Settings::singleton()->autoRestoreWindowDimension = item->get_active();      Settings::singleton()->autoRestoreWindowDimension = item->get_active();
3192    #endif
3193  }  }
3194    
3195  void MainWindow::on_save_with_temporary_file() {  void MainWindow::on_save_with_temporary_file() {
3196    #if USE_GLIB_ACTION
3197        bool active = false;
3198        m_actionToggleSaveWithTempFile->get_state(active);
3199        // for some reason toggle state does not change automatically
3200        active = !active;
3201        m_actionToggleSaveWithTempFile->change_state(active);
3202        Settings::singleton()->saveWithTemporaryFile = active;
3203    #else
3204      Gtk::CheckMenuItem* item =      Gtk::CheckMenuItem* item =
3205          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuSettings/SaveWithTemporaryFile"));          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuSettings/SaveWithTemporaryFile"));
3206      if (!item) {      if (!item) {
# Line 2432  void MainWindow::on_save_with_temporary_ Line 3208  void MainWindow::on_save_with_temporary_
3208          return;          return;
3209      }      }
3210      Settings::singleton()->saveWithTemporaryFile = item->get_active();      Settings::singleton()->saveWithTemporaryFile = item->get_active();
3211    #endif
3212  }  }
3213    
3214  bool MainWindow::is_copy_samples_unity_note_enabled() const {  bool MainWindow::is_copy_samples_unity_note_enabled() const {
3215    #if USE_GLIB_ACTION
3216        bool active = false;
3217        m_actionToggleCopySampleUnity->get_state(active);
3218        return active;
3219    #else
3220      Gtk::CheckMenuItem* item =      Gtk::CheckMenuItem* item =
3221          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity"));          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity"));
3222      if (!item) {      if (!item) {
# Line 2442  bool MainWindow::is_copy_samples_unity_n Line 3224  bool MainWindow::is_copy_samples_unity_n
3224          return true;          return true;
3225      }      }
3226      return item->get_active();      return item->get_active();
3227    #endif
3228  }  }
3229    
3230  bool MainWindow::is_copy_samples_fine_tune_enabled() const {  bool MainWindow::is_copy_samples_fine_tune_enabled() const {
3231    #if USE_GLIB_ACTION
3232        bool active = false;
3233        m_actionToggleCopySampleTune->get_state(active);
3234        return active;
3235    #else
3236      Gtk::CheckMenuItem* item =      Gtk::CheckMenuItem* item =
3237          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleTune"));          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleTune"));
3238      if (!item) {      if (!item) {
# Line 2452  bool MainWindow::is_copy_samples_fine_tu Line 3240  bool MainWindow::is_copy_samples_fine_tu
3240          return true;          return true;
3241      }      }
3242      return item->get_active();      return item->get_active();
3243    #endif
3244  }  }
3245    
3246  bool MainWindow::is_copy_samples_loop_enabled() const {  bool MainWindow::is_copy_samples_loop_enabled() const {
3247    #if USE_GLIB_ACTION
3248        bool active = false;
3249        m_actionToggleCopySampleLoop->get_state(active);
3250        return active;
3251    #else
3252      Gtk::CheckMenuItem* item =      Gtk::CheckMenuItem* item =
3253          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleLoop"));          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleLoop"));
3254      if (!item) {      if (!item) {
# Line 2462  bool MainWindow::is_copy_samples_loop_en Line 3256  bool MainWindow::is_copy_samples_loop_en
3256          return true;          return true;
3257      }      }
3258      return item->get_active();      return item->get_active();
3259    #endif
3260  }  }
3261    
3262  void MainWindow::on_button_release(GdkEventButton* button)  #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2
3263  {  bool MainWindow::on_button_release(Gdk::EventButton& _button) {
3264        GdkEventButton* button = _button.gobj();
3265    #else
3266    void MainWindow::on_button_release(GdkEventButton* button) {
3267    #endif
3268      if (button->type == GDK_2BUTTON_PRESS) {      if (button->type == GDK_2BUTTON_PRESS) {
3269          show_instr_props();          show_instr_props();
3270      } else if (button->type == GDK_BUTTON_PRESS && button->button == 3) {      } else if (button->type == GDK_BUTTON_PRESS && button->button == 3) {
3271          // gig v2 files have no midi rules          // gig v2 files have no midi rules
3272          const bool bEnabled = !(file->pVersion && file->pVersion->major == 2);          const bool bEnabled = !(file->pVersion && file->pVersion->major == 2);
3273    #if USE_GTKMM_BUILDER
3274            m_actionMIDIRules->property_enabled() = bEnabled;
3275    #else
3276          static_cast<Gtk::MenuItem*>(          static_cast<Gtk::MenuItem*>(
3277              uiManager->get_widget("/MenuBar/MenuInstrument/MidiRules"))->set_sensitive(              uiManager->get_widget("/MenuBar/MenuInstrument/MidiRules"))->set_sensitive(
3278                  bEnabled                  bEnabled
# Line 2479  void MainWindow::on_button_release(GdkEv Line 3281  void MainWindow::on_button_release(GdkEv
3281              uiManager->get_widget("/PopupMenu/MidiRules"))->set_sensitive(              uiManager->get_widget("/PopupMenu/MidiRules"))->set_sensitive(
3282                  bEnabled                  bEnabled
3283              );              );
3284    #endif
3285          popup_menu->popup(button->button, button->time);          popup_menu->popup(button->button, button->time);
3286      }      }
3287    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2
3288        return false;
3289    #endif
3290  }  }
3291    
3292    #if !USE_GTKMM_BUILDER
3293  void MainWindow::on_instrument_selection_change(Gtk::RadioMenuItem* item) {  void MainWindow::on_instrument_selection_change(Gtk::RadioMenuItem* item) {
3294      if (item->get_active()) {      if (item->get_active()) {
3295          const std::vector<Gtk::Widget*> children =          const std::vector<Gtk::Widget*> children =
# Line 2497  void MainWindow::on_instrument_selection Line 3304  void MainWindow::on_instrument_selection
3304          }          }
3305      }      }
3306  }  }
3307    #endif
3308    
3309  void MainWindow::select_instrument(gig::Instrument* instrument) {  void MainWindow::select_instrument(gig::Instrument* instrument) {
3310      if (!instrument) return;      if (!instrument) return;
# Line 2511  void MainWindow::select_instrument(gig:: Line 3319  void MainWindow::select_instrument(gig::
3319              // select and show the respective instrument in the list view              // select and show the respective instrument in the list view
3320              show_intruments_tab();              show_intruments_tab();
3321              m_TreeView.get_selection()->unselect_all();              m_TreeView.get_selection()->unselect_all();
3322                
3323    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22)
3324                auto iterSel = model->children()[i].get_iter();
3325                m_TreeView.get_selection()->select(iterSel);
3326    #else
3327              m_TreeView.get_selection()->select(model->children()[i]);              m_TreeView.get_selection()->select(model->children()[i]);
3328    #endif
3329              std::vector<Gtk::TreeModel::Path> rows =              std::vector<Gtk::TreeModel::Path> rows =
3330                  m_TreeView.get_selection()->get_selected_rows();                  m_TreeView.get_selection()->get_selected_rows();
3331              if (!rows.empty())              if (!rows.empty())
# Line 2536  bool MainWindow::select_dimension_region Line 3350  bool MainWindow::select_dimension_region
3350              // select and show the respective instrument in the list view              // select and show the respective instrument in the list view
3351              show_intruments_tab();              show_intruments_tab();
3352              m_TreeView.get_selection()->unselect_all();              m_TreeView.get_selection()->unselect_all();
3353    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22)
3354                auto iterSel = model->children()[i].get_iter();
3355                m_TreeView.get_selection()->select(iterSel);
3356    #else
3357              m_TreeView.get_selection()->select(model->children()[i]);              m_TreeView.get_selection()->select(model->children()[i]);
3358    #endif
3359              std::vector<Gtk::TreeModel::Path> rows =              std::vector<Gtk::TreeModel::Path> rows =
3360                  m_TreeView.get_selection()->get_selected_rows();                  m_TreeView.get_selection()->get_selected_rows();
3361              if (!rows.empty())              if (!rows.empty())
# Line 2567  void MainWindow::select_sample(gig::Samp Line 3386  void MainWindow::select_sample(gig::Samp
3386              if (rowSample[m_SamplesModel.m_col_sample] == sample) {              if (rowSample[m_SamplesModel.m_col_sample] == sample) {
3387                  show_samples_tab();                  show_samples_tab();
3388                  m_TreeViewSamples.get_selection()->unselect_all();                  m_TreeViewSamples.get_selection()->unselect_all();
3389    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22)
3390                    auto iterSel = rowGroup.children()[s].get_iter();
3391                    m_TreeViewSamples.get_selection()->select(iterSel);
3392    #else
3393                  m_TreeViewSamples.get_selection()->select(rowGroup.children()[s]);                  m_TreeViewSamples.get_selection()->select(rowGroup.children()[s]);
3394    #endif
3395                  std::vector<Gtk::TreeModel::Path> rows =                  std::vector<Gtk::TreeModel::Path> rows =
3396                      m_TreeViewSamples.get_selection()->get_selected_rows();                      m_TreeViewSamples.get_selection()->get_selected_rows();
3397                  if (rows.empty()) return;                  if (rows.empty()) return;
# Line 2578  void MainWindow::select_sample(gig::Samp Line 3402  void MainWindow::select_sample(gig::Samp
3402      }      }
3403  }  }
3404    
3405    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2
3406    bool MainWindow::on_sample_treeview_button_release(Gdk::EventButton& _button) {
3407        GdkEventButton* button = _button.gobj();
3408    #else
3409  void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) {  void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) {
3410    #endif
3411      if (button->type == GDK_BUTTON_PRESS && button->button == 3) {      if (button->type == GDK_BUTTON_PRESS && button->button == 3) {
3412          // by default if Ctrl keys is pressed down, then a mouse right-click          // by default if Ctrl keys is pressed down, then a mouse right-click
3413          // does not select the respective row, so we must assure this          // does not select the respective row, so we must assure this
# Line 2599  void MainWindow::on_sample_treeview_butt Line 3428  void MainWindow::on_sample_treeview_butt
3428              }              }
3429          }*/          }*/
3430    
3431    #if !USE_GTKMM_BUILDER
3432          Gtk::Menu* sample_popup =          Gtk::Menu* sample_popup =
3433              dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/SamplePopupMenu"));              dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/SamplePopupMenu"));
3434    #endif
3435    
3436          // update enabled/disabled state of sample popup items          // update enabled/disabled state of sample popup items
3437          Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();          Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();
3438          std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();          std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
# Line 2615  void MainWindow::on_sample_treeview_butt Line 3447  void MainWindow::on_sample_treeview_butt
3447              if (row[m_SamplesModel.m_col_sample]) nSamples++;              if (row[m_SamplesModel.m_col_sample]) nSamples++;
3448          }          }
3449    
3450    #if USE_GTKMM_BUILDER
3451            m_actionSampleProperties->property_enabled() = (n == 1);
3452            m_actionAddSample->property_enabled() = (n);
3453            m_actionAddSampleGroup->property_enabled() = (file);
3454            m_actionViewSampleRefs->property_enabled() = (nSamples == 1);
3455            m_actionRemoveSample->property_enabled() = (n);
3456            m_actionReplaceSample->property_enabled() = (nSamples == 1);
3457    #else
3458          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))->
3459              set_sensitive(n == 1);              set_sensitive(n == 1);
3460          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))->
# Line 2625  void MainWindow::on_sample_treeview_butt Line 3465  void MainWindow::on_sample_treeview_butt
3465              set_sensitive(nSamples == 1);              set_sensitive(nSamples == 1);
3466          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))->
3467              set_sensitive(n);              set_sensitive(n);
3468    #endif
3469          // show sample popup          // show sample popup
3470          sample_popup->popup(button->button, button->time);          sample_popup->popup(button->button, button->time);
3471    
3472    #if !USE_GTKMM_BUILDER
3473          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/SampleProperties"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/SampleProperties"))->
3474              set_sensitive(n == 1);              set_sensitive(n == 1);
3475          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddSample"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddSample"))->
# Line 2638  void MainWindow::on_sample_treeview_butt Line 3480  void MainWindow::on_sample_treeview_butt
3480              set_sensitive(nSamples == 1);              set_sensitive(nSamples == 1);
3481          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/RemoveSample"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/RemoveSample"))->
3482              set_sensitive(n);              set_sensitive(n);
3483    #endif
3484      }      }
3485        
3486    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2
3487        return false;
3488    #endif
3489  }  }
3490    
3491    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2
3492    bool MainWindow::on_script_treeview_button_release(Gdk::EventButton& _button) {
3493        GdkEventButton* button = _button.gobj();
3494    #else
3495  void MainWindow::on_script_treeview_button_release(GdkEventButton* button) {  void MainWindow::on_script_treeview_button_release(GdkEventButton* button) {
3496    #endif
3497      if (button->type == GDK_BUTTON_PRESS && button->button == 3) {      if (button->type == GDK_BUTTON_PRESS && button->button == 3) {
3498    #if !USE_GTKMM_BUILDER
3499          Gtk::Menu* script_popup =          Gtk::Menu* script_popup =
3500              dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/ScriptPopupMenu"));              dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/ScriptPopupMenu"));
3501    #endif
3502          // update enabled/disabled state of sample popup items          // update enabled/disabled state of sample popup items
3503          Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewScripts.get_selection();          Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewScripts.get_selection();
3504          Gtk::TreeModel::iterator it = sel->get_selected();          Gtk::TreeModel::iterator it = sel->get_selected();
# Line 2655  void MainWindow::on_script_treeview_butt Line 3509  void MainWindow::on_script_treeview_butt
3509              group_selected  = row[m_ScriptsModel.m_col_group];              group_selected  = row[m_ScriptsModel.m_col_group];
3510              script_selected = row[m_ScriptsModel.m_col_script];              script_selected = row[m_ScriptsModel.m_col_script];
3511          }          }
3512    #if USE_GTKMM_BUILDER
3513            m_actionAddScript->property_enabled() = (group_selected || script_selected);
3514            m_actionAddScriptGroup->property_enabled() = (file);
3515            m_actionEditScript->property_enabled() = (script_selected);
3516            m_actionRemoveScript->property_enabled() = (group_selected || script_selected);
3517    #else
3518          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/AddScript"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/AddScript"))->
3519              set_sensitive(group_selected || script_selected);              set_sensitive(group_selected || script_selected);
3520          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/AddScriptGroup"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/AddScriptGroup"))->
# Line 2663  void MainWindow::on_script_treeview_butt Line 3523  void MainWindow::on_script_treeview_butt
3523              set_sensitive(script_selected);                  set_sensitive(script_selected);    
3524          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/RemoveScript"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/ScriptPopupMenu/RemoveScript"))->
3525              set_sensitive(group_selected || script_selected);              set_sensitive(group_selected || script_selected);
3526    #endif
3527          // show sample popup          // show sample popup
3528          script_popup->popup(button->button, button->time);          script_popup->popup(button->button, button->time);
3529    
3530    #if !USE_GTKMM_BUILDER
3531          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/AddScript"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/AddScript"))->
3532              set_sensitive(group_selected || script_selected);              set_sensitive(group_selected || script_selected);
3533          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/AddScriptGroup"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/AddScriptGroup"))->
# Line 2674  void MainWindow::on_script_treeview_butt Line 3536  void MainWindow::on_script_treeview_butt
3536              set_sensitive(script_selected);                  set_sensitive(script_selected);    
3537          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/RemoveScript"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/RemoveScript"))->
3538              set_sensitive(group_selected || script_selected);              set_sensitive(group_selected || script_selected);
3539    #endif
3540      }      }
3541    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2
3542        return false;
3543    #endif
3544  }  }
3545    
3546  void MainWindow::updateScriptListOfMenu() {  void MainWindow::updateScriptListOfMenu() {
# Line 2720  void MainWindow::updateScriptListOfMenu( Line 3586  void MainWindow::updateScriptListOfMenu(
3586          assign_scripts_menu->append(*item);          assign_scripts_menu->append(*item);
3587      }      }
3588    
3589    #if HAS_GTKMM_SHOW_ALL_CHILDREN
3590      assign_scripts_menu->show_all_children();      assign_scripts_menu->show_all_children();
3591    #endif
3592  }  }
3593    
3594    #if !USE_GTKMM_BUILDER
3595  Gtk::RadioMenuItem* MainWindow::add_instrument_to_menu(  Gtk::RadioMenuItem* MainWindow::add_instrument_to_menu(
3596      const Glib::ustring& name, int position) {      const Glib::ustring& name, int position) {
3597    
# Line 2746  Gtk::RadioMenuItem* MainWindow::add_inst Line 3615  Gtk::RadioMenuItem* MainWindow::add_inst
3615              item));              item));
3616      return item;      return item;
3617  }  }
3618    #endif
3619    
3620    #if !USE_GTKMM_BUILDER
3621  void MainWindow::remove_instrument_from_menu(int index) {  void MainWindow::remove_instrument_from_menu(int index) {
3622      const std::vector<Gtk::Widget*> children =      const std::vector<Gtk::Widget*> children =
3623          instrument_menu->get_children();          instrument_menu->get_children();
# Line 2754  void MainWindow::remove_instrument_from_ Line 3625  void MainWindow::remove_instrument_from_
3625      instrument_menu->remove(*child);      instrument_menu->remove(*child);
3626      delete child;      delete child;
3627  }  }
3628    #endif
3629    
3630  void MainWindow::add_instrument(gig::Instrument* instrument) {  void MainWindow::add_instrument(gig::Instrument* instrument) {
3631      const Glib::ustring name(gig_to_utf8(instrument->pInfo->Name));      const Glib::ustring name(gig_to_utf8(instrument->pInfo->Name));
# Line 2768  void MainWindow::add_instrument(gig::Ins Line 3640  void MainWindow::add_instrument(gig::Ins
3640      rowInstr[m_Columns.m_col_scripts] = "";      rowInstr[m_Columns.m_col_scripts] = "";
3641      instrument_name_connection.unblock();      instrument_name_connection.unblock();
3642    
3643    #if !USE_GTKMM_BUILDER
3644      add_instrument_to_menu(name);      add_instrument_to_menu(name);
3645    #endif
3646      select_instrument(instrument);      select_instrument(instrument);
3647      file_changed();      file_changed();
3648  }  }
# Line 2837  void MainWindow::on_action_remove_instru Line 3711  void MainWindow::on_action_remove_instru
3711              if (instr) file->DeleteInstrument(instr);              if (instr) file->DeleteInstrument(instr);
3712              file_changed();              file_changed();
3713    
3714    #if !USE_GTKMM_BUILDER
3715              remove_instrument_from_menu(index);              remove_instrument_from_menu(index);
3716    #endif
3717    
3718              // remove row from instruments tree view              // remove row from instruments tree view
3719              m_refTreeModel->erase(it);              m_refTreeModel->erase(it);
# Line 3052  void MainWindow::add_or_replace_sample(b Line 3928  void MainWindow::add_or_replace_sample(b
3928    
3929      // show 'browse for file' dialog      // show 'browse for file' dialog
3930      Gtk::FileChooserDialog dialog(*this, replace ? _("Replace Sample with") : _("Add Sample(s)"));      Gtk::FileChooserDialog dialog(*this, replace ? _("Replace Sample with") : _("Add Sample(s)"));
3931    #if HAS_GTKMM_STOCK
3932      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
3933      dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);      dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
3934    #else
3935        dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
3936        dialog.add_button(_("_Open"), Gtk::RESPONSE_OK);
3937    #endif
3938      dialog.set_select_multiple(!replace); // allow multi audio file selection only when adding new samples, does not make sense when replacing a specific sample      dialog.set_select_multiple(!replace); // allow multi audio file selection only when adding new samples, does not make sense when replacing a specific sample
3939    
3940      // matches all file types supported by libsndfile      // matches all file types supported by libsndfile
# Line 3243  void MainWindow::on_action_replace_all_s Line 4124  void MainWindow::on_action_replace_all_s
4124      Gtk::Label description(str);      Gtk::Label description(str);
4125      description.set_line_wrap();      description.set_line_wrap();
4126  #endif  #endif
4127      Gtk::HBox entryArea;      HBox entryArea;
4128      Gtk::Label entryLabel( _("Add filename extension: "), Gtk::ALIGN_START);      Gtk::Label entryLabel( _("Add filename extension: "), Gtk::ALIGN_START);
4129      Gtk::Entry postfixEntryBox;      Gtk::Entry postfixEntryBox;
4130      postfixEntryBox.set_text(".wav");      postfixEntryBox.set_text(".wav");
4131      entryArea.pack_start(entryLabel);      entryArea.pack_start(entryLabel);
4132      entryArea.pack_start(postfixEntryBox);      entryArea.pack_start(postfixEntryBox);
4133    #if USE_GTKMM_BOX
4134        dialog.get_content_area()->pack_start(description, Gtk::PACK_SHRINK);
4135        dialog.get_content_area()->pack_start(entryArea, Gtk::PACK_SHRINK);
4136    #else
4137      dialog.get_vbox()->pack_start(description, Gtk::PACK_SHRINK);      dialog.get_vbox()->pack_start(description, Gtk::PACK_SHRINK);
4138      dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK);      dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK);
4139    #endif
4140      description.show();      description.show();
4141    
4142    #if HAS_GTKMM_SHOW_ALL_CHILDREN
4143      entryArea.show_all();      entryArea.show_all();
4144    #else
4145        entryArea.show();
4146    #endif
4147    
4148    #if HAS_GTKMM_STOCK
4149      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
4150    #else
4151        dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
4152    #endif
4153      dialog.add_button(_("Select"), Gtk::RESPONSE_OK);      dialog.add_button(_("Select"), Gtk::RESPONSE_OK);
4154      dialog.set_select_multiple(false);      dialog.set_select_multiple(false);
4155      if (current_sample_dir != "") {      if (current_sample_dir != "") {
# Line 3711  void MainWindow::instrument_name_changed Line 4607  void MainWindow::instrument_name_changed
4607      Gtk::TreeModel::Row row = *iter;      Gtk::TreeModel::Row row = *iter;
4608      Glib::ustring name = row[m_Columns.m_col_name];      Glib::ustring name = row[m_Columns.m_col_name];
4609    
4610    #if !USE_GTKMM_BUILDER
4611      // change name in instrument menu      // change name in instrument menu
4612      int index = path[0];      int index = path[0];
4613      const std::vector<Gtk::Widget*> children = instrument_menu->get_children();      const std::vector<Gtk::Widget*> children = instrument_menu->get_children();
# Line 3723  void MainWindow::instrument_name_changed Line 4620  void MainWindow::instrument_name_changed
4620          item->set_active();          item->set_active();
4621  #endif  #endif
4622      }      }
4623    #endif
4624    
4625      // change name in gig      // change name in gig
4626      gig::Instrument* instrument = row[m_Columns.m_col_instr];      gig::Instrument* instrument = row[m_Columns.m_col_instr];
# Line 3747  bool MainWindow::instrument_row_visible( Line 4645  bool MainWindow::instrument_row_visible(
4645      trim(pattern);      trim(pattern);
4646      if (pattern.empty()) return true;      if (pattern.empty()) return true;
4647    
4648    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22)
4649        //HACK: on GTKMM4 development branch const_iterator cannot be easily converted to iterator, probably going to be fixed before final GTKMM4 release though.
4650        Gtk::TreeModel::Row row = **(Gtk::TreeModel::iterator*)(&iter);
4651    #else
4652      Gtk::TreeModel::Row row = *iter;      Gtk::TreeModel::Row row = *iter;
4653    #endif
4654      Glib::ustring name = row[m_Columns.m_col_name];      Glib::ustring name = row[m_Columns.m_col_name];
4655      name = name.lowercase();      name = name.lowercase();
4656    
# Line 3779  void MainWindow::on_action_combine_instr Line 4682  void MainWindow::on_action_combine_instr
4682      }      }
4683      d->setSelectedInstruments(indeces);      d->setSelectedInstruments(indeces);
4684    
4685    #if HAS_GTKMM_SHOW_ALL_CHILDREN
4686      d->show_all();      d->show_all();
4687    #else
4688        d->show();
4689    #endif
4690      d->run();      d->run();
4691      if (d->fileWasChanged()) {      if (d->fileWasChanged()) {
4692          // update GUI with new instrument just created          // update GUI with new instrument just created
# Line 3803  void MainWindow::on_action_view_referenc Line 4710  void MainWindow::on_action_view_referenc
4710      d->dimension_region_selected.connect(      d->dimension_region_selected.connect(
4711          sigc::mem_fun(*this, &MainWindow::select_dimension_region)          sigc::mem_fun(*this, &MainWindow::select_dimension_region)
4712      );      );
4713    #if HAS_GTKMM_SHOW_ALL_CHILDREN
4714      d->show_all();      d->show_all();
4715    #else
4716        d->show();
4717    #endif
4718      d->resize(500, 400);      d->resize(500, 400);
4719      d->run();      d->run();
4720      delete d;      delete d;
# Line 3887  void MainWindow::mergeFiles(const std::v Line 4798  void MainWindow::mergeFiles(const std::v
4798              Glib::filename_display_basename(this->filename) + "' ...",              Glib::filename_display_basename(this->filename) + "' ...",
4799              *this              *this
4800          );          );
4801    #if HAS_GTKMM_SHOW_ALL_CHILDREN
4802          progress_dialog->show_all();          progress_dialog->show_all();
4803    #else
4804            progress_dialog->show();
4805    #endif
4806          saver = new Saver(this->file); //FIXME: memory leak!          saver = new Saver(this->file); //FIXME: memory leak!
4807          saver->signal_progress().connect(          saver->signal_progress().connect(
4808              sigc::mem_fun(*this, &MainWindow::on_saver_progress));              sigc::mem_fun(*this, &MainWindow::on_saver_progress));
# Line 3914  void MainWindow::on_action_merge_files() Line 4829  void MainWindow::on_action_merge_files()
4829      }      }
4830    
4831      Gtk::FileChooserDialog dialog(*this, _("Merge .gig files"));      Gtk::FileChooserDialog dialog(*this, _("Merge .gig files"));
4832    #if HAS_GTKMM_STOCK
4833      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
4834    #else
4835        dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
4836    #endif
4837      dialog.add_button(_("Merge"), Gtk::RESPONSE_OK);      dialog.add_button(_("Merge"), Gtk::RESPONSE_OK);
4838      dialog.set_default_response(Gtk::RESPONSE_CANCEL);      dialog.set_default_response(Gtk::RESPONSE_CANCEL);
4839  #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2  #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
# Line 3931  void MainWindow::on_action_merge_files() Line 4850  void MainWindow::on_action_merge_files()
4850      dialog.set_select_multiple(true);      dialog.set_select_multiple(true);
4851    
4852      // show warning in the file picker dialog      // show warning in the file picker dialog
4853      Gtk::HBox descriptionArea;      HBox descriptionArea;
4854      descriptionArea.set_spacing(15);      descriptionArea.set_spacing(15);
4855      Gtk::Image warningIcon;      Gtk::Image warningIcon;
4856      warningIcon.set_from_icon_name("dialog-warning",      warningIcon.set_from_icon_name("dialog-warning",
# Line 3954  void MainWindow::on_action_merge_files() Line 4873  void MainWindow::on_action_merge_files()
4873          "will accordingly be stored separately in the target .gig file!"          "will accordingly be stored separately in the target .gig file!"
4874      ));      ));
4875      descriptionArea.pack_start(description);      descriptionArea.pack_start(description);
4876    #if USE_GTKMM_BOX
4877    # warning No description area implemented for dialog on GTKMM 3
4878    #else
4879      dialog.get_vbox()->pack_start(descriptionArea, Gtk::PACK_SHRINK);      dialog.get_vbox()->pack_start(descriptionArea, Gtk::PACK_SHRINK);
4880    #endif
4881    #if HAS_GTKMM_SHOW_ALL_CHILDREN
4882      descriptionArea.show_all();      descriptionArea.show_all();
4883    #else
4884        descriptionArea.show();
4885    #endif
4886    
4887      if (dialog.run() == Gtk::RESPONSE_OK) {      if (dialog.run() == Gtk::RESPONSE_OK) {
4888          printf("on_action_merge_files self=%p\n",          printf("on_action_merge_files self=%p\n",
# Line 3991  void MainWindow::set_file_is_shared(bool Line 4918  void MainWindow::set_file_is_shared(bool
4918      }      }
4919    
4920      {      {
4921    #if USE_GTKMM_BUILDER
4922            m_actionToggleSyncSamplerSelection->property_enabled() = b;
4923    #else
4924          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
4925              uiManager->get_widget("/MenuBar/MenuSettings/SyncSamplerInstrumentSelection"));              uiManager->get_widget("/MenuBar/MenuSettings/SyncSamplerInstrumentSelection"));
4926          if (item) item->set_sensitive(b);          if (item) item->set_sensitive(b);
4927    #endif
4928      }      }
4929  }  }
4930    
# Line 4150  void MainWindow::updateClipboardPasteAva Line 5081  void MainWindow::updateClipboardPasteAva
5081    
5082  void MainWindow::updateClipboardCopyAvailable() {  void MainWindow::updateClipboardCopyAvailable() {
5083      bool bDimensionRegionCopyIsPossible = m_DimRegionChooser.get_main_dimregion();      bool bDimensionRegionCopyIsPossible = m_DimRegionChooser.get_main_dimregion();
5084    #if USE_GTKMM_BUILDER
5085        m_actionCopyDimRgn->property_enabled() = bDimensionRegionCopyIsPossible;
5086    #else
5087      static_cast<Gtk::MenuItem*>(      static_cast<Gtk::MenuItem*>(
5088          uiManager->get_widget("/MenuBar/MenuEdit/CopyDimRgn")          uiManager->get_widget("/MenuBar/MenuEdit/CopyDimRgn")
5089      )->set_sensitive(bDimensionRegionCopyIsPossible);      )->set_sensitive(bDimensionRegionCopyIsPossible);
5090    #endif
5091  }  }
5092    
5093    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2
5094    void MainWindow::on_clipboard_owner_change(Gdk::EventOwnerChange& event) {
5095    #else
5096  void MainWindow::on_clipboard_owner_change(GdkEventOwnerChange* event) {  void MainWindow::on_clipboard_owner_change(GdkEventOwnerChange* event) {
5097    #endif
5098      updateClipboardPasteAvailable();      updateClipboardPasteAvailable();
5099  }  }
5100    
# Line 4222  void MainWindow::on_clipboard_received_t Line 5161  void MainWindow::on_clipboard_received_t
5161          std::find(targets.begin(), targets.end(),          std::find(targets.begin(), targets.end(),
5162                    CLIPBOARD_DIMENSIONREGION_TARGET) != targets.end();                    CLIPBOARD_DIMENSIONREGION_TARGET) != targets.end();
5163    
5164    #if USE_GTKMM_BUILDER
5165        m_actionPasteDimRgn->property_enabled() = bDimensionRegionPasteIsPossible;
5166        m_actionAdjustClipboard->property_enabled() = bDimensionRegionPasteIsPossible;
5167    #else
5168      static_cast<Gtk::MenuItem*>(      static_cast<Gtk::MenuItem*>(
5169          uiManager->get_widget("/MenuBar/MenuEdit/PasteDimRgn")          uiManager->get_widget("/MenuBar/MenuEdit/PasteDimRgn")
5170      )->set_sensitive(bDimensionRegionPasteIsPossible);      )->set_sensitive(bDimensionRegionPasteIsPossible);
# Line 4229  void MainWindow::on_clipboard_received_t Line 5172  void MainWindow::on_clipboard_received_t
5172      static_cast<Gtk::MenuItem*>(      static_cast<Gtk::MenuItem*>(
5173          uiManager->get_widget("/MenuBar/MenuEdit/AdjustClipboard")          uiManager->get_widget("/MenuBar/MenuEdit/AdjustClipboard")
5174      )->set_sensitive(bDimensionRegionPasteIsPossible);      )->set_sensitive(bDimensionRegionPasteIsPossible);
5175    #endif
5176  }  }
5177    
5178  sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() {  sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() {

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

  ViewVC Help
Powered by ViewVC