/[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 2694 by schoenebeck, Tue Jan 6 16:08:48 2015 UTC revision 3123 by schoenebeck, Tue Apr 25 20:45:54 2017 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (C) 2006-2015 Andreas Persson   * Copyright (C) 2006-2017 Andreas Persson
3   *   *
4   * This program is free software; you can redistribute it and/or   * This program is free software; you can redistribute it and/or
5   * modify it under the terms of the GNU General Public License as   * modify it under the terms of the GNU General Public License as
# Line 20  Line 20 
20  #include <iostream>  #include <iostream>
21  #include <cstring>  #include <cstring>
22    
23    #include <glibmmconfig.h>
24    // threads.h must be included first to be able to build with
25    // G_DISABLE_DEPRECATED
26    #if (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION == 31 && GLIBMM_MICRO_VERSION >= 2) || \
27        (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION > 31) || GLIBMM_MAJOR_VERSION > 2
28    #include <glibmm/threads.h>
29    #endif
30    
31  #include <glibmm/convert.h>  #include <glibmm/convert.h>
32  #include <glibmm/dispatcher.h>  #include <glibmm/dispatcher.h>
33  #include <glibmm/miscutils.h>  #include <glibmm/miscutils.h>
# Line 27  Line 35 
35  #include <gtkmm/aboutdialog.h>  #include <gtkmm/aboutdialog.h>
36  #include <gtkmm/filechooserdialog.h>  #include <gtkmm/filechooserdialog.h>
37  #include <gtkmm/messagedialog.h>  #include <gtkmm/messagedialog.h>
 #include <gtkmm/stock.h>  
38  #include <gtkmm/targetentry.h>  #include <gtkmm/targetentry.h>
39  #include <gtkmm/main.h>  #include <gtkmm/main.h>
40  #include <gtkmm/toggleaction.h>  #include <gtkmm/toggleaction.h>
# Line 50  Line 57 
57  #include "ReferencesView.h"  #include "ReferencesView.h"
58  #include "../../gfx/status_attached.xpm"  #include "../../gfx/status_attached.xpm"
59  #include "../../gfx/status_detached.xpm"  #include "../../gfx/status_detached.xpm"
60    #include "gfx/builtinpix.h"
61    
62  MainWindow::MainWindow() :  MainWindow::MainWindow() :
63      m_DimRegionChooser(*this),      m_DimRegionChooser(*this),
64      dimreg_label(_("Changes apply to:")),      dimreg_label(_("Changes apply to:")),
65      dimreg_all_regions(_("all regions")),      dimreg_all_regions(_("all regions")),
66      dimreg_all_dimregs(_("all dimension splits")),      dimreg_all_dimregs(_("all dimension splits")),
67      dimreg_stereo(_("both channels"))      dimreg_stereo(_("both channels")),
68        labelLegend(_("Legend:")),
69        labelNoSample(_(" No Sample")),
70        labelMissingSample(_(" Missing some Sample(s)")),
71        labelLooped(_(" Looped")),
72        labelSomeLoops(_(" Some Loop(s)"))
73  {  {
74        loadBuiltInPix();
75    
76  //    set_border_width(5);  //    set_border_width(5);
77  //    set_default_size(400, 200);  //    set_default_size(400, 200);
78    
   
79      add(m_VBox);      add(m_VBox);
80    
81      // Handle selection      // Handle selection
# Line 96  MainWindow::MainWindow() : Line 109  MainWindow::MainWindow() :
109      dimreg_hbox.add(dimreg_stereo);      dimreg_hbox.add(dimreg_stereo);
110      dimreg_vbox.add(dimreg_edit);      dimreg_vbox.add(dimreg_edit);
111      dimreg_vbox.pack_start(dimreg_hbox, Gtk::PACK_SHRINK);      dimreg_vbox.pack_start(dimreg_hbox, Gtk::PACK_SHRINK);
112        {
113            legend_hbox.add(labelLegend);
114    
115            imageNoSample.set(redDot);
116            imageNoSample.set_alignment(Gtk::ALIGN_END);
117            labelNoSample.set_alignment(Gtk::ALIGN_START);
118            legend_hbox.add(imageNoSample);
119            legend_hbox.add(labelNoSample);
120    
121            imageMissingSample.set(yellowDot);
122            imageMissingSample.set_alignment(Gtk::ALIGN_END);
123            labelMissingSample.set_alignment(Gtk::ALIGN_START);
124            legend_hbox.add(imageMissingSample);
125            legend_hbox.add(labelMissingSample);
126    
127            imageLooped.set(blackLoop);
128            imageLooped.set_alignment(Gtk::ALIGN_END);
129            labelLooped.set_alignment(Gtk::ALIGN_START);
130            legend_hbox.add(imageLooped);
131            legend_hbox.add(labelLooped);
132    
133            imageSomeLoops.set(grayLoop);
134            imageSomeLoops.set_alignment(Gtk::ALIGN_END);
135            labelSomeLoops.set_alignment(Gtk::ALIGN_START);
136            legend_hbox.add(imageSomeLoops);
137            legend_hbox.add(labelSomeLoops);
138    
139            legend_hbox.show_all_children();
140        }
141        dimreg_vbox.pack_start(legend_hbox, Gtk::PACK_SHRINK);
142      m_HPaned.add2(dimreg_vbox);      m_HPaned.add2(dimreg_vbox);
143    
144      dimreg_label.set_tooltip_text(_("To automatically apply your changes above globally to the entire instrument, check all 3 check boxes on the right."));      dimreg_label.set_tooltip_text(_("To automatically apply your changes above globally to the entire instrument, check all 3 check boxes on the right."));
# Line 110  MainWindow::MainWindow() : Line 153  MainWindow::MainWindow() :
153      actionGroup = Gtk::ActionGroup::create();      actionGroup = Gtk::ActionGroup::create();
154    
155      actionGroup->add(Gtk::Action::create("MenuFile", _("_File")));      actionGroup->add(Gtk::Action::create("MenuFile", _("_File")));
156      actionGroup->add(Gtk::Action::create("New", Gtk::Stock::NEW),      actionGroup->add(Gtk::Action::create("New", _("_New")),
157                         Gtk::AccelKey("<control>n"),
158                       sigc::mem_fun(                       sigc::mem_fun(
159                           *this, &MainWindow::on_action_file_new));                           *this, &MainWindow::on_action_file_new));
160      Glib::RefPtr<Gtk::Action> action =      actionGroup->add(Gtk::Action::create("Open", _("_Open...")),
161          Gtk::Action::create("Open", Gtk::Stock::OPEN);                       Gtk::AccelKey("<control>o"),
     action->property_label() = action->property_label() + "...";  
     actionGroup->add(action,  
162                       sigc::mem_fun(                       sigc::mem_fun(
163                           *this, &MainWindow::on_action_file_open));                           *this, &MainWindow::on_action_file_open));
164      actionGroup->add(Gtk::Action::create("Save", Gtk::Stock::SAVE),      actionGroup->add(Gtk::Action::create("Save", _("_Save")),
165                         Gtk::AccelKey("<control>s"),
166                       sigc::mem_fun(                       sigc::mem_fun(
167                           *this, &MainWindow::on_action_file_save));                           *this, &MainWindow::on_action_file_save));
168      action = Gtk::Action::create("SaveAs", Gtk::Stock::SAVE_AS);      actionGroup->add(Gtk::Action::create("SaveAs", _("Save _As...")),
     action->property_label() = action->property_label() + "...";  
     actionGroup->add(action,  
169                       Gtk::AccelKey("<shift><control>s"),                       Gtk::AccelKey("<shift><control>s"),
170                       sigc::mem_fun(                       sigc::mem_fun(
171                           *this, &MainWindow::on_action_file_save_as));                           *this, &MainWindow::on_action_file_save_as));
172      actionGroup->add(Gtk::Action::create("Properties",      actionGroup->add(Gtk::Action::create("Properties",
173                                           Gtk::Stock::PROPERTIES),                                           _("_Properties")),
174                       sigc::mem_fun(                       sigc::mem_fun(
175                           *this, &MainWindow::on_action_file_properties));                           *this, &MainWindow::on_action_file_properties));
176      actionGroup->add(Gtk::Action::create("InstrProperties",      actionGroup->add(Gtk::Action::create("InstrProperties",
177                                           Gtk::Stock::PROPERTIES),                                           _("_Properties")),
178                       sigc::mem_fun(                       sigc::mem_fun(
179                           *this, &MainWindow::show_instr_props));                           *this, &MainWindow::show_instr_props));
180      actionGroup->add(Gtk::Action::create("MidiRules",      actionGroup->add(Gtk::Action::create("MidiRules",
# Line 144  MainWindow::MainWindow() : Line 185  MainWindow::MainWindow() :
185                                           _("_Script Slots...")),                                           _("_Script Slots...")),
186                       sigc::mem_fun(                       sigc::mem_fun(
187                           *this, &MainWindow::show_script_slots));                           *this, &MainWindow::show_script_slots));
188      actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT),      actionGroup->add(Gtk::Action::create("Quit", _("_Quit")),
189                         Gtk::AccelKey("<control>q"),
190                       sigc::mem_fun(                       sigc::mem_fun(
191                           *this, &MainWindow::on_action_quit));                           *this, &MainWindow::on_action_quit));
192      actionGroup->add(      actionGroup->add(
# Line 163  MainWindow::MainWindow() : Line 205  MainWindow::MainWindow() :
205    
206      actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit")));      actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit")));
207    
208        const Gdk::ModifierType primaryModifierKey =
209    #if defined(__APPLE__)
210        Gdk::META_MASK; // Cmd key on Mac
211    #else
212        Gdk::CONTROL_MASK; // Ctrl key on all other OSs
213    #endif
214    
215        actionGroup->add(Gtk::Action::create("SelectPrevRegion",
216                                             _("Select Previous Region")),
217                         Gtk::AccelKey(GDK_KEY_Left, primaryModifierKey),
218                         sigc::mem_fun(*this, &MainWindow::select_prev_region));
219    
220        actionGroup->add(Gtk::Action::create("SelectNextRegion",
221                                             _("Select Next Region")),
222                         Gtk::AccelKey(GDK_KEY_Right, primaryModifierKey),
223                         sigc::mem_fun(*this, &MainWindow::select_next_region));
224    
225        actionGroup->add(Gtk::Action::create("SelectPrevDimRgnZone",
226                                             _("Select Previous Dimension Region Zone")),
227                         Gtk::AccelKey(GDK_KEY_Left, Gdk::MOD1_MASK),
228                         sigc::mem_fun(*this, &MainWindow::select_prev_dim_rgn_zone));
229    
230        actionGroup->add(Gtk::Action::create("SelectNextDimRgnZone",
231                                             _("Select Next Dimension Region Zone")),
232                         Gtk::AccelKey(GDK_KEY_Right, Gdk::MOD1_MASK),
233                         sigc::mem_fun(*this, &MainWindow::select_next_dim_rgn_zone));
234    
235        actionGroup->add(Gtk::Action::create("SelectPrevDimension",
236                                             _("Select Previous Dimension")),
237                         Gtk::AccelKey(GDK_KEY_Up, Gdk::MOD1_MASK),
238                         sigc::mem_fun(*this, &MainWindow::select_prev_dimension));
239    
240        actionGroup->add(Gtk::Action::create("SelectNextDimension",
241                                             _("Select Next Dimension")),
242                         Gtk::AccelKey(GDK_KEY_Down, Gdk::MOD1_MASK),
243                         sigc::mem_fun(*this, &MainWindow::select_next_dimension));
244    
245    
246      Glib::RefPtr<Gtk::ToggleAction> toggle_action =      Glib::RefPtr<Gtk::ToggleAction> toggle_action =
247          Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note"));          Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note"));
248      toggle_action->set_active(true);      toggle_action->set_active(true);
# Line 187  MainWindow::MainWindow() : Line 267  MainWindow::MainWindow() :
267                       sigc::mem_fun(                       sigc::mem_fun(
268                           *this, &MainWindow::on_action_view_status_bar));                           *this, &MainWindow::on_action_view_status_bar));
269    
270      action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP);      toggle_action =
271      actionGroup->add(Gtk::Action::create("MenuHelp",          Gtk::ToggleAction::create("AutoRestoreWinDim", _("_Auto Restore Window Dimension"));
272                                           action->property_label()));      toggle_action->set_active(Settings::singleton()->autoRestoreWindowDimension);
273      actionGroup->add(Gtk::Action::create("About", Gtk::Stock::ABOUT),      actionGroup->add(toggle_action,
274                         sigc::mem_fun(
275                             *this, &MainWindow::on_auto_restore_win_dim));
276    
277        toggle_action =
278            Gtk::ToggleAction::create("SaveWithTemporaryFile", _("Save with _temporary file"));
279        toggle_action->set_active(Settings::singleton()->saveWithTemporaryFile);
280        actionGroup->add(toggle_action,
281                         sigc::mem_fun(
282                             *this, &MainWindow::on_save_with_temporary_file));
283    
284        actionGroup->add(
285            Gtk::Action::create("RefreshAll", _("_Refresh All")),
286            sigc::mem_fun(*this, &MainWindow::on_action_refresh_all)
287        );                
288    
289        actionGroup->add(Gtk::Action::create("MenuHelp", _("_Help")));
290        actionGroup->add(Gtk::Action::create("About", _("_About")),
291                       sigc::mem_fun(                       sigc::mem_fun(
292                           *this, &MainWindow::on_action_help_about));                           *this, &MainWindow::on_action_help_about));
293      actionGroup->add(      actionGroup->add(
# Line 202  MainWindow::MainWindow() : Line 299  MainWindow::MainWindow() :
299          sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument)          sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument)
300      );      );
301      actionGroup->add(      actionGroup->add(
302          Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE),          Gtk::Action::create("RemoveInstrument", _("_Remove")),
303          sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument)          sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument)
304      );      );
305    
# Line 225  MainWindow::MainWindow() : Line 322  MainWindow::MainWindow() :
322          sigc::mem_fun(*this, &MainWindow::on_action_sync_sampler_instrument_selection)          sigc::mem_fun(*this, &MainWindow::on_action_sync_sampler_instrument_selection)
323      );      );
324    
325        toggle_action =
326            Gtk::ToggleAction::create("MoveRootNoteWithRegionMoved", _("Move root note with region moved"));
327        toggle_action->set_active(Settings::singleton()->moveRootNoteWithRegionMoved);
328        actionGroup->add(
329            toggle_action,
330            sigc::mem_fun(*this, &MainWindow::on_action_move_root_note_with_region_moved)
331        );
332    
333    
334      actionGroup->add(Gtk::Action::create("MenuTools", _("_Tools")));      actionGroup->add(Gtk::Action::create("MenuTools", _("_Tools")));
335    
# Line 241  MainWindow::MainWindow() : Line 346  MainWindow::MainWindow() :
346    
347      // sample right-click popup actions      // sample right-click popup actions
348      actionGroup->add(      actionGroup->add(
349          Gtk::Action::create("SampleProperties", Gtk::Stock::PROPERTIES),          Gtk::Action::create("SampleProperties", _("_Properties")),
350          sigc::mem_fun(*this, &MainWindow::on_action_sample_properties)          sigc::mem_fun(*this, &MainWindow::on_action_sample_properties)
351      );      );
352      actionGroup->add(      actionGroup->add(
# Line 253  MainWindow::MainWindow() : Line 358  MainWindow::MainWindow() :
358          sigc::mem_fun(*this, &MainWindow::on_action_add_sample)          sigc::mem_fun(*this, &MainWindow::on_action_add_sample)
359      );      );
360      actionGroup->add(      actionGroup->add(
361          Gtk::Action::create("RemoveSample", Gtk::Stock::REMOVE),          Gtk::Action::create("RemoveSample", _("_Remove")),
362          sigc::mem_fun(*this, &MainWindow::on_action_remove_sample)          sigc::mem_fun(*this, &MainWindow::on_action_remove_sample)
363      );      );
364      actionGroup->add(      actionGroup->add(
365            Gtk::Action::create("RemoveUnusedSamples", _("Remove _Unused Samples")),
366            sigc::mem_fun(*this, &MainWindow::on_action_remove_unused_samples)
367        );
368        actionGroup->add(
369          Gtk::Action::create("ShowSampleRefs", _("Show References...")),          Gtk::Action::create("ShowSampleRefs", _("Show References...")),
370          sigc::mem_fun(*this, &MainWindow::on_action_view_references)          sigc::mem_fun(*this, &MainWindow::on_action_view_references)
371      );      );
372      actionGroup->add(      actionGroup->add(
373            Gtk::Action::create("ReplaceSample",
374                                _("Replace Sample...")),
375            sigc::mem_fun(*this, &MainWindow::on_action_replace_sample)
376        );
377        actionGroup->add(
378          Gtk::Action::create("ReplaceAllSamplesInAllGroups",          Gtk::Action::create("ReplaceAllSamplesInAllGroups",
379                              _("Replace All Samples in All Groups...")),                              _("Replace All Samples in All Groups...")),
380          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)
# Line 280  MainWindow::MainWindow() : Line 394  MainWindow::MainWindow() :
394          sigc::mem_fun(*this, &MainWindow::on_action_edit_script)          sigc::mem_fun(*this, &MainWindow::on_action_edit_script)
395      );      );
396      actionGroup->add(      actionGroup->add(
397          Gtk::Action::create("RemoveScript", Gtk::Stock::REMOVE),          Gtk::Action::create("RemoveScript", _("_Remove")),
398          sigc::mem_fun(*this, &MainWindow::on_action_remove_script)          sigc::mem_fun(*this, &MainWindow::on_action_remove_script)
399      );      );
400    
# Line 303  MainWindow::MainWindow() : Line 417  MainWindow::MainWindow() :
417          "      <menuitem action='Quit'/>"          "      <menuitem action='Quit'/>"
418          "    </menu>"          "    </menu>"
419          "    <menu action='MenuEdit'>"          "    <menu action='MenuEdit'>"
420            "      <menuitem action='SelectPrevRegion'/>"
421            "      <menuitem action='SelectNextRegion'/>"
422            "      <separator/>"
423            "      <menuitem action='SelectPrevDimRgnZone'/>"
424            "      <menuitem action='SelectNextDimRgnZone'/>"
425            "      <menuitem action='SelectPrevDimension'/>"
426            "      <menuitem action='SelectNextDimension'/>"
427            "      <separator/>"
428          "      <menuitem action='CopySampleUnity'/>"          "      <menuitem action='CopySampleUnity'/>"
429          "      <menuitem action='CopySampleTune'/>"          "      <menuitem action='CopySampleTune'/>"
430          "      <menuitem action='CopySampleLoop'/>"          "      <menuitem action='CopySampleLoop'/>"
# Line 312  MainWindow::MainWindow() : Line 434  MainWindow::MainWindow() :
434          "      <menuitem action='AddGroup'/>"          "      <menuitem action='AddGroup'/>"
435          "      <menuitem action='AddSample'/>"          "      <menuitem action='AddSample'/>"
436          "      <menuitem action='ShowSampleRefs'/>"          "      <menuitem action='ShowSampleRefs'/>"
437            "      <menuitem action='ReplaceSample' />"
438          "      <menuitem action='ReplaceAllSamplesInAllGroups' />"          "      <menuitem action='ReplaceAllSamplesInAllGroups' />"
439          "      <separator/>"          "      <separator/>"
440          "      <menuitem action='RemoveSample'/>"          "      <menuitem action='RemoveSample'/>"
441            "      <menuitem action='RemoveUnusedSamples'/>"
442          "    </menu>"          "    </menu>"
443          "    <menu action='MenuInstrument'>"          "    <menu action='MenuInstrument'>"
444          "      <menu action='AllInstruments'>"          "      <menu action='AllInstruments'>"
# Line 337  MainWindow::MainWindow() : Line 461  MainWindow::MainWindow() :
461          "    </menu>"          "    </menu>"
462          "    <menu action='MenuView'>"          "    <menu action='MenuView'>"
463          "      <menuitem action='Statusbar'/>"          "      <menuitem action='Statusbar'/>"
464            "      <menuitem action='AutoRestoreWinDim'/>"
465            "      <separator/>"
466            "      <menuitem action='RefreshAll'/>"
467          "    </menu>"          "    </menu>"
468          "    <menu action='MenuTools'>"          "    <menu action='MenuTools'>"
469          "      <menuitem action='CombineInstruments'/>"          "      <menuitem action='CombineInstruments'/>"
# Line 345  MainWindow::MainWindow() : Line 472  MainWindow::MainWindow() :
472          "    <menu action='MenuSettings'>"          "    <menu action='MenuSettings'>"
473          "      <menuitem action='WarnUserOnExtensions'/>"          "      <menuitem action='WarnUserOnExtensions'/>"
474          "      <menuitem action='SyncSamplerInstrumentSelection'/>"          "      <menuitem action='SyncSamplerInstrumentSelection'/>"
475            "      <menuitem action='MoveRootNoteWithRegionMoved'/>"
476            "      <menuitem action='SaveWithTemporaryFile'/>"
477          "    </menu>"          "    </menu>"
478          "    <menu action='MenuHelp'>"          "    <menu action='MenuHelp'>"
479          "      <menuitem action='About'/>"          "      <menuitem action='About'/>"
# Line 364  MainWindow::MainWindow() : Line 493  MainWindow::MainWindow() :
493          "    <menuitem action='AddGroup'/>"          "    <menuitem action='AddGroup'/>"
494          "    <menuitem action='AddSample'/>"          "    <menuitem action='AddSample'/>"
495          "    <menuitem action='ShowSampleRefs'/>"          "    <menuitem action='ShowSampleRefs'/>"
496            "    <menuitem action='ReplaceSample' />"
497          "    <menuitem action='ReplaceAllSamplesInAllGroups' />"          "    <menuitem action='ReplaceAllSamplesInAllGroups' />"
498          "    <separator/>"          "    <separator/>"
499          "    <menuitem action='RemoveSample'/>"          "    <menuitem action='RemoveSample'/>"
500            "    <menuitem action='RemoveUnusedSamples'/>"
501          "  </popup>"          "  </popup>"
502          "  <popup name='ScriptPopupMenu'>"          "  <popup name='ScriptPopupMenu'>"
503          "    <menuitem action='AddScriptGroup'/>"          "    <menuitem action='AddScriptGroup'/>"
# Line 411  MainWindow::MainWindow() : Line 542  MainWindow::MainWindow() :
542      }      }
543      {      {
544          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
545                uiManager->get_widget("/MenuBar/MenuSettings/MoveRootNoteWithRegionMoved"));
546            item->set_tooltip_text(_("If checked, and when a region is moved by dragging it around on the virtual keyboard, the keybord position dependent pitch will move exactly with the amount of semi tones the region was moved around."));
547        }
548        {
549            Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
550                uiManager->get_widget("/MenuBar/MenuSample/RemoveUnusedSamples"));
551            item->set_tooltip_text(_("Removes all samples that are not referenced by any instrument (i.e. red ones)."));
552            // copy tooltip to popup menu
553            Gtk::MenuItem* item2 = dynamic_cast<Gtk::MenuItem*>(
554                uiManager->get_widget("/SamplePopupMenu/RemoveUnusedSamples"));
555            item2->set_tooltip_text(item->get_tooltip_text());
556        }
557        {
558            Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
559                uiManager->get_widget("/MenuBar/MenuView/RefreshAll"));
560            item->set_tooltip_text(_("Reloads the currently open gig file and updates the entire graphical user interface."));
561        }
562        {
563            Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
564                uiManager->get_widget("/MenuBar/MenuView/AutoRestoreWinDim"));
565            item->set_tooltip_text(_("If checked, size and position of all windows will be saved and automatically restored next time."));
566        }
567        {
568            Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
569              uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments"));              uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments"));
570          item->set_tooltip_text(_("Create combi sounds out of individual sounds of this .gig file."));          item->set_tooltip_text(_("Create combi sounds out of individual sounds of this .gig file."));
571      }      }
# Line 448  MainWindow::MainWindow() : Line 603  MainWindow::MainWindow() :
603      // Create the Tree model:      // Create the Tree model:
604      m_refTreeModel = Gtk::ListStore::create(m_Columns);      m_refTreeModel = Gtk::ListStore::create(m_Columns);
605      m_TreeView.set_model(m_refTreeModel);      m_TreeView.set_model(m_refTreeModel);
606      m_TreeView.set_tooltip_text(_("Right click here for actions on instruments & MIDI Rules."));      m_TreeView.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
607        m_TreeView.set_tooltip_text(_("Right click here for actions on instruments & MIDI Rules. Drag & drop to change the order of instruments."));
608      instrument_name_connection = m_refTreeModel->signal_row_changed().connect(      instrument_name_connection = m_refTreeModel->signal_row_changed().connect(
609          sigc::mem_fun(*this, &MainWindow::instrument_name_changed)          sigc::mem_fun(*this, &MainWindow::instrument_name_changed)
610      );      );
611    
612      // Add the TreeView's view columns:      // Add the TreeView's view columns:
613      m_TreeView.append_column_editable("Instrument", m_Columns.m_col_name);      m_TreeView.append_column(_("Nr"), m_Columns.m_col_nr);
614      m_TreeView.set_headers_visible(false);      m_TreeView.append_column_editable(_("Instrument"), m_Columns.m_col_name);
615        m_TreeView.set_headers_visible(true);
616        
617        // establish drag&drop within the instrument tree view, allowing to reorder
618        // the sequence of instruments within the gig file
619        {
620            std::vector<Gtk::TargetEntry> drag_target_instrument;
621            drag_target_instrument.push_back(Gtk::TargetEntry("gig::Instrument"));
622            m_TreeView.drag_source_set(drag_target_instrument);
623            m_TreeView.drag_dest_set(drag_target_instrument);
624            m_TreeView.signal_drag_begin().connect(
625                sigc::mem_fun(*this, &MainWindow::on_instruments_treeview_drag_begin)
626            );
627            m_TreeView.signal_drag_data_get().connect(
628                sigc::mem_fun(*this, &MainWindow::on_instruments_treeview_drag_data_get)
629            );
630            m_TreeView.signal_drag_data_received().connect(
631                sigc::mem_fun(*this, &MainWindow::on_instruments_treeview_drop_drag_data_received)
632            );
633        }
634    
635      // create samples treeview (including its data model)      // create samples treeview (including its data model)
636      m_refSamplesTreeModel = SamplesTreeStore::create(m_SamplesModel);      m_refSamplesTreeModel = SamplesTreeStore::create(m_SamplesModel);
637      m_TreeViewSamples.set_model(m_refSamplesTreeModel);      m_TreeViewSamples.set_model(m_refSamplesTreeModel);
638        m_TreeViewSamples.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
639      m_TreeViewSamples.set_tooltip_text(_("To actually use a sample, drag it from this list view to \"Sample\" -> \"Sample:\" on the region's settings pane on the right.\n\nRight click here for more actions on samples."));      m_TreeViewSamples.set_tooltip_text(_("To actually use a sample, drag it from this list view to \"Sample\" -> \"Sample:\" on the region's settings pane on the right.\n\nRight click here for more actions on samples."));
640      // m_TreeViewSamples.set_reorderable();      // m_TreeViewSamples.set_reorderable();
641      m_TreeViewSamples.append_column_editable(_("Name"), m_SamplesModel.m_col_name);      m_TreeViewSamples.append_column_editable(_("Name"), m_SamplesModel.m_col_name);
# Line 503  MainWindow::MainWindow() : Line 679  MainWindow::MainWindow() :
679      m_TreeViewScripts.signal_button_press_event().connect_notify(      m_TreeViewScripts.signal_button_press_event().connect_notify(
680          sigc::mem_fun(*this, &MainWindow::on_script_treeview_button_release)          sigc::mem_fun(*this, &MainWindow::on_script_treeview_button_release)
681      );      );
682      //FIXME: why the heck does this double click signal_row_activated() only fired while CTRL key is pressed ?      //FIXME: why the heck does this double click signal_row_activated() only fire while CTRL key is pressed ?
683      m_TreeViewScripts.signal_row_activated().connect(      m_TreeViewScripts.signal_row_activated().connect(
684          sigc::mem_fun(*this, &MainWindow::script_double_clicked)          sigc::mem_fun(*this, &MainWindow::script_double_clicked)
685      );      );
# Line 540  MainWindow::MainWindow() : Line 716  MainWindow::MainWindow() :
716          sigc::hide(sigc::mem_fun(*this, &MainWindow::file_changed)));          sigc::hide(sigc::mem_fun(*this, &MainWindow::file_changed)));
717      m_RegionChooser.signal_instrument_changed().connect(      m_RegionChooser.signal_instrument_changed().connect(
718          sigc::mem_fun(*this, &MainWindow::file_changed));          sigc::mem_fun(*this, &MainWindow::file_changed));
719        m_RegionChooser.signal_instrument_changed().connect(
720            sigc::mem_fun(*this, &MainWindow::region_changed));
721      m_DimRegionChooser.signal_region_changed().connect(      m_DimRegionChooser.signal_region_changed().connect(
722          sigc::mem_fun(*this, &MainWindow::file_changed));          sigc::mem_fun(*this, &MainWindow::file_changed));
723      instrumentProps.signal_changed().connect(      instrumentProps.signal_changed().connect(
# Line 635  void MainWindow::region_changed() Line 813  void MainWindow::region_changed()
813  gig::Instrument* MainWindow::get_instrument()  gig::Instrument* MainWindow::get_instrument()
814  {  {
815      gig::Instrument* instrument = 0;      gig::Instrument* instrument = 0;
816      Gtk::TreeModel::const_iterator it =      std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows();
817          m_TreeView.get_selection()->get_selected();      if (rows.empty()) return NULL;
818        Gtk::TreeModel::const_iterator it = m_refTreeModel->get_iter(rows[0]);
819      if (it) {      if (it) {
820          Gtk::TreeModel::Row row = *it;          Gtk::TreeModel::Row row = *it;
821          instrument = row[m_Columns.m_col_instr];          instrument = row[m_Columns.m_col_instr];
# Line 679  void MainWindow::update_dimregs() Line 858  void MainWindow::update_dimregs()
858              add_region_to_dimregs(region, stereo, all_dimregs);              add_region_to_dimregs(region, stereo, all_dimregs);
859          }          }
860      }      }
861    
862        m_DimRegionChooser.setModifyAllRegions(all_regions);
863        m_DimRegionChooser.setModifyAllDimensionRegions(all_dimregs);
864        m_DimRegionChooser.setModifyBothChannels(stereo);
865  }  }
866    
867  void MainWindow::dimreg_all_dimregs_toggled()  void MainWindow::dimreg_all_dimregs_toggled()
# Line 696  void MainWindow::dimreg_changed() Line 879  void MainWindow::dimreg_changed()
879  void MainWindow::on_sel_change()  void MainWindow::on_sel_change()
880  {  {
881      // select item in instrument menu      // select item in instrument menu
882      Gtk::TreeModel::iterator it = m_TreeView.get_selection()->get_selected();      std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows();
883      if (it) {      if (!rows.empty()) {
884          Gtk::TreePath path(it);          Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]);
885          int index = path[0];          if (it) {
886          const std::vector<Gtk::Widget*> children =              Gtk::TreePath path(it);
887              instrument_menu->get_children();              int index = path[0];
888          static_cast<Gtk::RadioMenuItem*>(children[index])->set_active();              const std::vector<Gtk::Widget*> children =
889                    instrument_menu->get_children();
890                static_cast<Gtk::RadioMenuItem*>(children[index])->set_active();
891            }
892      }      }
893    
894      m_RegionChooser.set_instrument(get_instrument());      m_RegionChooser.set_instrument(get_instrument());
# Line 727  void Loader::progress_callback(float fra Line 913  void Loader::progress_callback(float fra
913      progress_dispatcher();      progress_dispatcher();
914  }  }
915    
916    #if defined(WIN32) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2))
917    // make sure stack is 16-byte aligned for SSE instructions
918    __attribute__((force_align_arg_pointer))
919    #endif
920  void Loader::thread_function()  void Loader::thread_function()
921  {  {
922      printf("thread_function self=%x\n", Glib::Threads::Thread::self());      printf("thread_function self=%p\n",
923               static_cast<void*>(Glib::Threads::Thread::self()));
924      printf("Start %s\n", filename.c_str());      printf("Start %s\n", filename.c_str());
925      try {      try {
926          RIFF::File* riff = new RIFF::File(filename);          RIFF::File* riff = new RIFF::File(filename);
# Line 751  void Loader::thread_function() Line 942  void Loader::thread_function()
942  }  }
943    
944  Loader::Loader(const char* filename)  Loader::Loader(const char* filename)
945      : filename(filename), thread(0), progress(0.f)      : filename(filename), gig(0), thread(0), progress(0.f)
946  {  {
947  }  }
948    
# Line 762  void Loader::launch() Line 953  void Loader::launch()
953  #else  #else
954      thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Loader::thread_function));      thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Loader::thread_function));
955  #endif  #endif
956      printf("launch thread=%x\n", thread);      printf("launch thread=%p\n", static_cast<void*>(thread));
957  }  }
958    
959  float Loader::get_progress()  float Loader::get_progress()
# Line 805  void Saver::progress_callback(float frac Line 996  void Saver::progress_callback(float frac
996      progress_dispatcher.emit();      progress_dispatcher.emit();
997  }  }
998    
999    #if defined(WIN32) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2))
1000    // make sure stack is 16-byte aligned for SSE instructions
1001    __attribute__((force_align_arg_pointer))
1002    #endif
1003  void Saver::thread_function()  void Saver::thread_function()
1004  {  {
1005      printf("thread_function self=%x\n", Glib::Threads::Thread::self());      printf("thread_function self=%p\n",
1006               static_cast<void*>(Glib::Threads::Thread::self()));
1007      printf("Start %s\n", filename.c_str());      printf("Start %s\n", filename.c_str());
1008      try {      try {
1009          gig::progress_t progress;          gig::progress_t progress;
# Line 816  void Saver::thread_function() Line 1012  void Saver::thread_function()
1012    
1013          // if no filename was provided, that means "save", if filename was provided means "save as"          // if no filename was provided, that means "save", if filename was provided means "save as"
1014          if (filename.empty()) {          if (filename.empty()) {
1015              gig->Save(&progress);              if (!Settings::singleton()->saveWithTemporaryFile) {
1016                    // save directly over the existing .gig file
1017                    // (requires less disk space than solution below
1018                    // but may be slower)
1019                    gig->Save(&progress);
1020                } else {
1021                    // save the file as separate temporary file first,
1022                    // then move the saved file over the old file
1023                    // (may result in performance speedup during save)
1024                    String tmpname = filename + ".TMP";
1025                    gig->Save(tmpname, &progress);
1026                    #if defined(WIN32)
1027                    if (!DeleteFile(filename.c_str())) {
1028                        throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file).");
1029                    }
1030                    #else // POSIX ...
1031                    if (unlink(filename.c_str())) {
1032                        throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file): " + String(strerror(errno)));
1033                    }
1034                    #endif
1035                    if (rename(tmpname.c_str(), filename.c_str())) {
1036                        #if defined(WIN32)
1037                        throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file).");
1038                        #else
1039                        throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file): " + String(strerror(errno)));
1040                        #endif
1041                    }
1042                }
1043          } else {          } else {
1044              gig->Save(filename, &progress);              gig->Save(filename, &progress);
1045          }          }
# Line 844  void Saver::launch() Line 1067  void Saver::launch()
1067  #else  #else
1068      thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Saver::thread_function));      thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Saver::thread_function));
1069  #endif  #endif
1070      printf("launch thread=%x\n", thread);      printf("launch thread=%p\n", static_cast<void*>(thread));
1071  }  }
1072    
1073  float Saver::get_progress()  float Saver::get_progress()
# Line 941  bool MainWindow::close_confirmation_dial Line 1164  bool MainWindow::close_confirmation_dial
1164      g_free(msg);      g_free(msg);
1165      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."));
1166      dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO);      dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO);
1167      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
1168      dialog.add_button(file_has_name ? Gtk::Stock::SAVE : Gtk::Stock::SAVE_AS, Gtk::RESPONSE_YES);      dialog.add_button(file_has_name ? _("_Save") : _("Save _As"), Gtk::RESPONSE_YES);
1169      dialog.set_default_response(Gtk::RESPONSE_YES);      dialog.set_default_response(Gtk::RESPONSE_YES);
1170      int response = dialog.run();      int response = dialog.run();
1171      dialog.hide();      dialog.hide();
# Line 973  bool MainWindow::leaving_shared_mode_dia Line 1196  bool MainWindow::leaving_shared_mode_dia
1196            "used by the sampler until you tell the sampler explicitly to "            "used by the sampler until you tell the sampler explicitly to "
1197            "load it."));            "load it."));
1198      dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES);      dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES);
1199      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
1200      dialog.set_default_response(Gtk::RESPONSE_CANCEL);      dialog.set_default_response(Gtk::RESPONSE_CANCEL);
1201      int response = dialog.run();      int response = dialog.run();
1202      dialog.hide();      dialog.hide();
# Line 987  void MainWindow::on_action_file_open() Line 1210  void MainWindow::on_action_file_open()
1210      if (file_is_shared && !leaving_shared_mode_dialog()) return;      if (file_is_shared && !leaving_shared_mode_dialog()) return;
1211    
1212      Gtk::FileChooserDialog dialog(*this, _("Open file"));      Gtk::FileChooserDialog dialog(*this, _("Open file"));
1213      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
1214      dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);      dialog.add_button(_("_Open"), Gtk::RESPONSE_OK);
1215      dialog.set_default_response(Gtk::RESPONSE_OK);      dialog.set_default_response(Gtk::RESPONSE_OK);
1216  #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
1217      Gtk::FileFilter filter;      Gtk::FileFilter filter;
# Line 1004  void MainWindow::on_action_file_open() Line 1227  void MainWindow::on_action_file_open()
1227      if (dialog.run() == Gtk::RESPONSE_OK) {      if (dialog.run() == Gtk::RESPONSE_OK) {
1228          std::string filename = dialog.get_filename();          std::string filename = dialog.get_filename();
1229          printf("filename=%s\n", filename.c_str());          printf("filename=%s\n", filename.c_str());
1230          printf("on_action_file_open self=%x\n", Glib::Threads::Thread::self());          printf("on_action_file_open self=%p\n",
1231                   static_cast<void*>(Glib::Threads::Thread::self()));
1232          load_file(filename.c_str());          load_file(filename.c_str());
1233          current_gig_dir = Glib::path_get_dirname(filename);          current_gig_dir = Glib::path_get_dirname(filename);
1234      }      }
# Line 1074  void MainWindow::on_loader_progress() Line 1298  void MainWindow::on_loader_progress()
1298  void MainWindow::on_loader_finished()  void MainWindow::on_loader_finished()
1299  {  {
1300      printf("Loader finished!\n");      printf("Loader finished!\n");
1301      printf("on_loader_finished self=%x\n", Glib::Threads::Thread::self());      printf("on_loader_finished self=%p\n",
1302               static_cast<void*>(Glib::Threads::Thread::self()));
1303      load_gig(loader->gig, loader->filename.c_str());      load_gig(loader->gig, loader->filename.c_str());
1304      progress_dialog->hide();      progress_dialog->hide();
1305  }  }
# Line 1169  void MainWindow::on_saver_finished() Line 1394  void MainWindow::on_saver_finished()
1394    
1395      file_structure_changed_signal.emit(this->file);      file_structure_changed_signal.emit(this->file);
1396    
1397      load_gig(this->file, this->filename.c_str());      __refreshEntireGUI();
1398      progress_dialog->hide();      progress_dialog->hide();
1399  }  }
1400    
# Line 1181  void MainWindow::on_action_file_save_as( Line 1406  void MainWindow::on_action_file_save_as(
1406    
1407  bool MainWindow::file_save_as()  bool MainWindow::file_save_as()
1408  {  {
1409      Gtk::FileChooserDialog dialog(*this, _("Save as"), Gtk::FILE_CHOOSER_ACTION_SAVE);      Gtk::FileChooserDialog dialog(*this, _("Save As"), Gtk::FILE_CHOOSER_ACTION_SAVE);
1410      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
1411      dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);      dialog.add_button(_("_Save"), Gtk::RESPONSE_OK);
1412      dialog.set_default_response(Gtk::RESPONSE_OK);      dialog.set_default_response(Gtk::RESPONSE_OK);
1413      dialog.set_do_overwrite_confirmation();      dialog.set_do_overwrite_confirmation();
1414    
# Line 1214  bool MainWindow::file_save_as() Line 1439  bool MainWindow::file_save_as()
1439      // show warning in the dialog      // show warning in the dialog
1440      Gtk::HBox descriptionArea;      Gtk::HBox descriptionArea;
1441      descriptionArea.set_spacing(15);      descriptionArea.set_spacing(15);
1442      Gtk::Image warningIcon(Gtk::Stock::DIALOG_WARNING, Gtk::IconSize(Gtk::ICON_SIZE_DIALOG));      Gtk::Image warningIcon;
1443        warningIcon.set_from_icon_name("dialog-warning",
1444                                       Gtk::IconSize(Gtk::ICON_SIZE_DIALOG));
1445      descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK);      descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK);
1446  #if GTKMM_MAJOR_VERSION < 3  #if GTKMM_MAJOR_VERSION < 3
1447      view::WrapLabel description;      view::WrapLabel description;
# Line 1266  bool MainWindow::file_save_as() Line 1493  bool MainWindow::file_save_as()
1493  void MainWindow::__import_queued_samples() {  void MainWindow::__import_queued_samples() {
1494      std::cout << "Starting sample import\n" << std::flush;      std::cout << "Starting sample import\n" << std::flush;
1495      Glib::ustring error_files;      Glib::ustring error_files;
1496      printf("Samples to import: %d\n", m_SampleImportQueue.size());      printf("Samples to import: %d\n", int(m_SampleImportQueue.size()));
1497      for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin();      for (std::map<gig::Sample*, SampleImportItem>::iterator iter = m_SampleImportQueue.begin();
1498           iter != m_SampleImportQueue.end(); ) {           iter != m_SampleImportQueue.end(); ) {
1499          printf("Importing sample %s\n",(*iter).sample_path.c_str());          printf("Importing sample %s\n",iter->second.sample_path.c_str());
1500          SF_INFO info;          SF_INFO info;
1501          info.format = 0;          info.format = 0;
1502          SNDFILE* hFile = sf_open((*iter).sample_path.c_str(), SFM_READ, &info);          SNDFILE* hFile = sf_open(iter->second.sample_path.c_str(), SFM_READ, &info);
1503          sf_command(hFile, SFC_SET_SCALE_FLOAT_INT_READ, 0, SF_TRUE);          sf_command(hFile, SFC_SET_SCALE_FLOAT_INT_READ, 0, SF_TRUE);
1504          try {          try {
1505              if (!hFile) throw std::string(_("could not open file"));              if (!hFile) throw std::string(_("could not open file"));
# Line 1295  void MainWindow::__import_queued_samples Line 1522  void MainWindow::__import_queued_samples
1522                      throw std::string(_("format not supported")); // unsupported subformat (yet?)                      throw std::string(_("format not supported")); // unsupported subformat (yet?)
1523              }              }
1524    
1525                // reset write position for sample
1526                iter->first->SetPos(0);
1527    
1528              const int bufsize = 10000;              const int bufsize = 10000;
1529              switch (bitdepth) {              switch (bitdepth) {
1530                  case 16: {                  case 16: {
# Line 1304  void MainWindow::__import_queued_samples Line 1534  void MainWindow::__import_queued_samples
1534                          // libsndfile does the conversion for us (if needed)                          // libsndfile does the conversion for us (if needed)
1535                          int n = sf_readf_short(hFile, buffer, bufsize);                          int n = sf_readf_short(hFile, buffer, bufsize);
1536                          // write from buffer directly (physically) into .gig file                          // write from buffer directly (physically) into .gig file
1537                          iter->gig_sample->Write(buffer, n);                          iter->first->Write(buffer, n);
1538                          cnt -= n;                          cnt -= n;
1539                      }                      }
1540                      delete[] buffer;                      delete[] buffer;
# Line 1324  void MainWindow::__import_queued_samples Line 1554  void MainWindow::__import_queued_samples
1554                              dstbuf[j++] = srcbuf[i] >> 24;                              dstbuf[j++] = srcbuf[i] >> 24;
1555                          }                          }
1556                          // write from buffer directly (physically) into .gig file                          // write from buffer directly (physically) into .gig file
1557                          iter->gig_sample->Write(dstbuf, n);                          iter->first->Write(dstbuf, n);
1558                          cnt -= n;                          cnt -= n;
1559                      }                      }
1560                      delete[] srcbuf;                      delete[] srcbuf;
# Line 1335  void MainWindow::__import_queued_samples Line 1565  void MainWindow::__import_queued_samples
1565              // cleanup              // cleanup
1566              sf_close(hFile);              sf_close(hFile);
1567              // let the sampler re-cache the sample if needed              // let the sampler re-cache the sample if needed
1568              sample_changed_signal.emit(iter->gig_sample);              sample_changed_signal.emit(iter->first);
1569              // on success we remove the sample from the import queue,              // on success we remove the sample from the import queue,
1570              // otherwise keep it, maybe it works the next time ?              // otherwise keep it, maybe it works the next time ?
1571              std::list<SampleImportItem>::iterator cur = iter;              std::map<gig::Sample*, SampleImportItem>::iterator cur = iter;
1572              ++iter;              ++iter;
1573              m_SampleImportQueue.erase(cur);              m_SampleImportQueue.erase(cur);
1574          } catch (std::string what) {          } catch (std::string what) {
1575              // remember the files that made trouble (and their cause)              // remember the files that made trouble (and their cause)
1576              if (!error_files.empty()) error_files += "\n";              if (!error_files.empty()) error_files += "\n";
1577              error_files += (*iter).sample_path += " (" + what + ")";              error_files += iter->second.sample_path += " (" + what + ")";
1578              ++iter;              ++iter;
1579          }          }
1580      }      }
# Line 1372  void MainWindow::on_action_sync_sampler_ Line 1602  void MainWindow::on_action_sync_sampler_
1602          !Settings::singleton()->syncSamplerInstrumentSelection;          !Settings::singleton()->syncSamplerInstrumentSelection;
1603  }  }
1604    
1605    void MainWindow::on_action_move_root_note_with_region_moved() {
1606        Settings::singleton()->moveRootNoteWithRegionMoved =
1607            !Settings::singleton()->moveRootNoteWithRegionMoved;
1608    }
1609    
1610  void MainWindow::on_action_help_about()  void MainWindow::on_action_help_about()
1611  {  {
1612      Gtk::AboutDialog dialog;      Gtk::AboutDialog dialog;
# Line 1381  void MainWindow::on_action_help_about() Line 1616  void MainWindow::on_action_help_about()
1616      dialog.set_name("Gigedit");      dialog.set_name("Gigedit");
1617  #endif  #endif
1618      dialog.set_version(VERSION);      dialog.set_version(VERSION);
1619      dialog.set_copyright("Copyright (C) 2006-2015 Andreas Persson");      dialog.set_copyright("Copyright (C) 2006-2017 Andreas Persson");
1620      const std::string sComment =      const std::string sComment =
1621          _("Built " __DATE__ "\nUsing ") +          _("Built " __DATE__ "\nUsing ") +
1622          ::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" +          ::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" +
# Line 1418  PropDialog::PropDialog() Line 1653  PropDialog::PropDialog()
1653        eSourceForm(_("Source form")),        eSourceForm(_("Source form")),
1654        eCommissioned(_("Commissioned")),        eCommissioned(_("Commissioned")),
1655        eSubject(_("Subject")),        eSubject(_("Subject")),
1656        quitButton(Gtk::Stock::CLOSE),        quitButton(_("_Close"), true),
1657        table(2, 1),        table(2, 1),
1658        m_file(NULL)        m_file(NULL)
1659  {  {
# Line 1541  void InstrumentProps::set_MIDIProgram(ui Line 1776  void InstrumentProps::set_MIDIProgram(ui
1776  }  }
1777    
1778  InstrumentProps::InstrumentProps() :  InstrumentProps::InstrumentProps() :
1779      quitButton(Gtk::Stock::CLOSE),      quitButton(_("_Close"), true),
1780      table(2,1),      table(2,1),
1781      eName(_("Name")),      eName(_("Name")),
1782      eIsDrum(_("Is drum")),      eIsDrum(_("Is drum")),
# Line 1664  void MainWindow::load_gig(gig::File* gig Line 1899  void MainWindow::load_gig(gig::File* gig
1899      file = 0;      file = 0;
1900      set_file_is_shared(isSharedInstrument);      set_file_is_shared(isSharedInstrument);
1901    
1902      this->filename = filename ? filename : _("Unsaved Gig File");      this->filename =
1903            (filename && strlen(filename) > 0) ?
1904                filename : (!gig->GetFileName().empty()) ?
1905                    gig->GetFileName() : _("Unsaved Gig File");
1906      set_title(Glib::filename_display_basename(this->filename));      set_title(Glib::filename_display_basename(this->filename));
1907      file_has_name = filename;      file_has_name = filename;
1908      file_is_changed = false;      file_is_changed = false;
# Line 1673  void MainWindow::load_gig(gig::File* gig Line 1911  void MainWindow::load_gig(gig::File* gig
1911      propDialog.set_info(gig->pInfo);      propDialog.set_info(gig->pInfo);
1912    
1913      instrument_name_connection.block();      instrument_name_connection.block();
1914        int index = 0;
1915      for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ;      for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ;
1916           instrument = gig->GetNextInstrument()) {           instrument = gig->GetNextInstrument(), ++index) {
1917          Glib::ustring name(gig_to_utf8(instrument->pInfo->Name));          Glib::ustring name(gig_to_utf8(instrument->pInfo->Name));
1918    
1919          Gtk::TreeModel::iterator iter = m_refTreeModel->append();          Gtk::TreeModel::iterator iter = m_refTreeModel->append();
1920          Gtk::TreeModel::Row row = *iter;          Gtk::TreeModel::Row row = *iter;
1921            row[m_Columns.m_col_nr] = index;
1922          row[m_Columns.m_col_name] = name;          row[m_Columns.m_col_name] = name;
1923          row[m_Columns.m_col_instr] = instrument;          row[m_Columns.m_col_instr] = instrument;
1924    
# Line 1751  bool MainWindow::instr_props_set_instrum Line 1991  bool MainWindow::instr_props_set_instrum
1991  {  {
1992      instrumentProps.signal_name_changed().clear();      instrumentProps.signal_name_changed().clear();
1993    
1994      Gtk::TreeModel::const_iterator it =      std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows();
1995          m_TreeView.get_selection()->get_selected();      if (rows.empty()) {
1996            instrumentProps.hide();
1997            return false;
1998        }
1999        Gtk::TreeModel::const_iterator it = m_refTreeModel->get_iter(rows[0]);
2000      if (it) {      if (it) {
2001          Gtk::TreeModel::Row row = *it;          Gtk::TreeModel::Row row = *it;
2002          gig::Instrument* instrument = row[m_Columns.m_col_instr];          gig::Instrument* instrument = row[m_Columns.m_col_instr];
# Line 1805  void MainWindow::show_midi_rules() Line 2049  void MainWindow::show_midi_rules()
2049  void MainWindow::show_script_slots() {  void MainWindow::show_script_slots() {
2050      if (!file) return;      if (!file) return;
2051      // get selected instrument      // get selected instrument
2052      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection();      std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows();
2053      Gtk::TreeModel::iterator it = sel->get_selected();      if (rows.empty()) return;
2054        Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]);
2055      if (!it) return;      if (!it) return;
2056      Gtk::TreeModel::Row row = *it;      Gtk::TreeModel::Row row = *it;
2057      gig::Instrument* instrument = row[m_Columns.m_col_instr];      gig::Instrument* instrument = row[m_Columns.m_col_instr];
# Line 1818  void MainWindow::show_script_slots() { Line 2063  void MainWindow::show_script_slots() {
2063      window->show();      window->show();
2064  }  }
2065    
2066    void MainWindow::on_action_refresh_all() {
2067        __refreshEntireGUI();
2068    }
2069    
2070  void MainWindow::on_action_view_status_bar() {  void MainWindow::on_action_view_status_bar() {
2071      Gtk::CheckMenuItem* item =      Gtk::CheckMenuItem* item =
2072          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar"));          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar"));
# Line 1829  void MainWindow::on_action_view_status_b Line 2078  void MainWindow::on_action_view_status_b
2078      else                    m_StatusBar.hide();      else                    m_StatusBar.hide();
2079  }  }
2080    
2081    void MainWindow::on_auto_restore_win_dim() {
2082        Gtk::CheckMenuItem* item =
2083            dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/AutoRestoreWinDim"));
2084        if (!item) {
2085            std::cerr << "/MenuBar/MenuView/AutoRestoreWinDim == NULL\n";
2086            return;
2087        }
2088        Settings::singleton()->autoRestoreWindowDimension = item->get_active();
2089    }
2090    
2091    void MainWindow::on_save_with_temporary_file() {
2092        Gtk::CheckMenuItem* item =
2093            dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuSettings/SaveWithTemporaryFile"));
2094        if (!item) {
2095            std::cerr << "/MenuBar/MenuSettings/SaveWithTemporaryFile == NULL\n";
2096            return;
2097        }
2098        Settings::singleton()->saveWithTemporaryFile = item->get_active();
2099    }
2100    
2101  bool MainWindow::is_copy_samples_unity_note_enabled() const {  bool MainWindow::is_copy_samples_unity_note_enabled() const {
2102      Gtk::CheckMenuItem* item =      Gtk::CheckMenuItem* item =
2103          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity"));          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity"));
# Line 1893  void MainWindow::on_instrument_selection Line 2162  void MainWindow::on_instrument_selection
2162      }      }
2163  }  }
2164    
2165    void MainWindow::select_instrument(gig::Instrument* instrument) {
2166        if (!instrument) return;
2167    
2168        Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model();
2169        for (int i = 0; i < model->children().size(); ++i) {
2170            Gtk::TreeModel::Row row = model->children()[i];
2171            if (row[m_Columns.m_col_instr] == instrument) {
2172                // select and show the respective instrument in the list view
2173                show_intruments_tab();
2174                m_TreeView.get_selection()->unselect_all();
2175                m_TreeView.get_selection()->select(model->children()[i]);
2176                std::vector<Gtk::TreeModel::Path> rows =
2177                    m_TreeView.get_selection()->get_selected_rows();
2178                if (!rows.empty())
2179                    m_TreeView.scroll_to_row(rows[0]);
2180                on_sel_change(); // the regular instrument selection change callback
2181            }
2182        }
2183    }
2184    
2185    /// Returns true if requested dimension region was successfully selected and scrolled to in the list view, false on error.
2186    bool MainWindow::select_dimension_region(gig::DimensionRegion* dimRgn) {
2187        gig::Region* pRegion = (gig::Region*) dimRgn->GetParent();
2188        gig::Instrument* pInstrument = (gig::Instrument*) pRegion->GetParent();
2189    
2190        Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model();
2191        for (int i = 0; i < model->children().size(); ++i) {
2192            Gtk::TreeModel::Row row = model->children()[i];
2193            if (row[m_Columns.m_col_instr] == pInstrument) {
2194                // select and show the respective instrument in the list view
2195                show_intruments_tab();
2196                m_TreeView.get_selection()->unselect_all();
2197                m_TreeView.get_selection()->select(model->children()[i]);
2198                std::vector<Gtk::TreeModel::Path> rows =
2199                    m_TreeView.get_selection()->get_selected_rows();
2200                if (!rows.empty())
2201                    m_TreeView.scroll_to_row(rows[0]);
2202                on_sel_change(); // the regular instrument selection change callback
2203    
2204                // select respective region in the region selector
2205                m_RegionChooser.set_region(pRegion);
2206    
2207                // select and show the respective dimension region in the editor
2208                //update_dimregs();
2209                if (!m_DimRegionChooser.select_dimregion(dimRgn)) return false;
2210                //dimreg_edit.set_dim_region(dimRgn);
2211    
2212                return true;
2213            }
2214        }
2215    
2216        return false;
2217    }
2218    
2219  void MainWindow::select_sample(gig::Sample* sample) {  void MainWindow::select_sample(gig::Sample* sample) {
2220      Glib::RefPtr<Gtk::TreeModel> model = m_TreeViewSamples.get_model();      Glib::RefPtr<Gtk::TreeModel> model = m_TreeViewSamples.get_model();
2221      for (int g = 0; g < model->children().size(); ++g) {      for (int g = 0; g < model->children().size(); ++g) {
# Line 1901  void MainWindow::select_sample(gig::Samp Line 2224  void MainWindow::select_sample(gig::Samp
2224              Gtk::TreeModel::Row rowSample = rowGroup.children()[s];              Gtk::TreeModel::Row rowSample = rowGroup.children()[s];
2225              if (rowSample[m_SamplesModel.m_col_sample] == sample) {              if (rowSample[m_SamplesModel.m_col_sample] == sample) {
2226                  show_samples_tab();                  show_samples_tab();
2227                    m_TreeViewSamples.get_selection()->unselect_all();
2228                  m_TreeViewSamples.get_selection()->select(rowGroup.children()[s]);                  m_TreeViewSamples.get_selection()->select(rowGroup.children()[s]);
2229                  Gtk::TreePath path(                  std::vector<Gtk::TreeModel::Path> rows =
2230                      m_TreeViewSamples.get_selection()->get_selected()                      m_TreeViewSamples.get_selection()->get_selected_rows();
2231                  );                  if (rows.empty()) return;
2232                  m_TreeViewSamples.scroll_to_row(path);                  m_TreeViewSamples.scroll_to_row(rows[0]);
2233                  return;                  return;
2234              }              }
2235          }          }
# Line 1914  void MainWindow::select_sample(gig::Samp Line 2238  void MainWindow::select_sample(gig::Samp
2238    
2239  void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) {  void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) {
2240      if (button->type == GDK_BUTTON_PRESS && button->button == 3) {      if (button->type == GDK_BUTTON_PRESS && button->button == 3) {
2241            // by default if Ctrl keys is pressed down, then a mouse right-click
2242            // does not select the respective row, so we must assure this
2243            // programmatically ...
2244            /*{
2245                Gtk::TreeModel::Path path;
2246                Gtk::TreeViewColumn* pColumn = NULL;
2247                int cellX, cellY;
2248                bool bSuccess = m_TreeViewSamples.get_path_at_pos(
2249                    (int)button->x, (int)button->y,
2250                    path, pColumn, cellX, cellY
2251                );
2252                if (bSuccess) {
2253                    if (m_TreeViewSamples.get_selection()->count_selected_rows() <= 0) {
2254                        printf("not selected !!!\n");
2255                        m_TreeViewSamples.get_selection()->select(path);
2256                    }
2257                }
2258            }*/
2259    
2260          Gtk::Menu* sample_popup =          Gtk::Menu* sample_popup =
2261              dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/SamplePopupMenu"));              dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/SamplePopupMenu"));
2262          // update enabled/disabled state of sample popup items          // update enabled/disabled state of sample popup items
2263          Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();          Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();
2264          Gtk::TreeModel::iterator it = sel->get_selected();          std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
2265          bool group_selected  = false;          const int n = rows.size();
2266          bool sample_selected = false;          int nGroups  = 0;
2267          if (it) {          int nSamples = 0;
2268            for (int r = 0; r < n; ++r) {
2269                Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[r]);
2270                if (!it) continue;
2271              Gtk::TreeModel::Row row = *it;              Gtk::TreeModel::Row row = *it;
2272              group_selected  = row[m_SamplesModel.m_col_group];              if (row[m_SamplesModel.m_col_group]) nGroups++;
2273              sample_selected = row[m_SamplesModel.m_col_sample];              if (row[m_SamplesModel.m_col_sample]) nSamples++;
2274          }          }
2275            
               
2276          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))->
2277              set_sensitive(group_selected || sample_selected);              set_sensitive(n == 1);
2278          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))->
2279              set_sensitive(group_selected || sample_selected);              set_sensitive(n);
2280          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddGroup"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddGroup"))->
2281              set_sensitive(file);              set_sensitive(file);
2282          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/ShowSampleRefs"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/ShowSampleRefs"))->
2283              set_sensitive(sample_selected);              set_sensitive(nSamples == 1);
2284          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))->
2285              set_sensitive(group_selected || sample_selected);              set_sensitive(n);
2286          // show sample popup          // show sample popup
2287          sample_popup->popup(button->button, button->time);          sample_popup->popup(button->button, button->time);
2288    
2289          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/SampleProperties"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/SampleProperties"))->
2290              set_sensitive(group_selected || sample_selected);              set_sensitive(n == 1);
2291          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddSample"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddSample"))->
2292              set_sensitive(group_selected || sample_selected);              set_sensitive(n);
2293          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddGroup"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddGroup"))->
2294              set_sensitive(file);              set_sensitive(file);
2295          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/ShowSampleRefs"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/ShowSampleRefs"))->
2296              set_sensitive(sample_selected);              set_sensitive(nSamples == 1);
2297          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/RemoveSample"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/RemoveSample"))->
2298              set_sensitive(group_selected || sample_selected);              set_sensitive(n);
2299      }      }
2300  }  }
2301    
# Line 2029  void MainWindow::add_instrument(gig::Ins Line 2374  void MainWindow::add_instrument(gig::Ins
2374      instrument_name_connection.block();      instrument_name_connection.block();
2375      Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append();      Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append();
2376      Gtk::TreeModel::Row rowInstr = *iterInstr;      Gtk::TreeModel::Row rowInstr = *iterInstr;
2377        rowInstr[m_Columns.m_col_nr] = m_refTreeModel->children().size() - 1;
2378      rowInstr[m_Columns.m_col_name] = name;      rowInstr[m_Columns.m_col_name] = name;
2379      rowInstr[m_Columns.m_col_instr] = instrument;      rowInstr[m_Columns.m_col_instr] = instrument;
2380      instrument_name_connection.unblock();      instrument_name_connection.unblock();
# Line 2057  void MainWindow::on_action_duplicate_ins Line 2403  void MainWindow::on_action_duplicate_ins
2403      // retrieve the currently selected instrument      // retrieve the currently selected instrument
2404      // (being the original instrument to be duplicated)      // (being the original instrument to be duplicated)
2405      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection();      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection();
2406      Gtk::TreeModel::iterator itSelection = sel->get_selected();      std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
2407      if (!itSelection) return;      for (int r = 0; r < rows.size(); ++r) {
2408      Gtk::TreeModel::Row row = *itSelection;          Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]);
2409      gig::Instrument* instrOrig = row[m_Columns.m_col_instr];          if (it) {
2410      if (!instrOrig) return;              Gtk::TreeModel::Row row = *it;
2411                gig::Instrument* instrOrig = row[m_Columns.m_col_instr];
2412      // duplicate the orginal instrument              if (instrOrig) {
2413      gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig);                  // duplicate the orginal instrument
2414      instrNew->pInfo->Name =                  gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig);
2415          instrOrig->pInfo->Name +                  instrNew->pInfo->Name =
2416          gig_from_utf8(Glib::ustring(" (") + _("Copy") + ")");                      instrOrig->pInfo->Name +
2417                        gig_from_utf8(Glib::ustring(" (") + _("Copy") + ")");
2418    
2419      add_instrument(instrNew);                  add_instrument(instrNew);
2420                }
2421            }
2422        }
2423  }  }
2424    
2425  void MainWindow::on_action_remove_instrument() {  void MainWindow::on_action_remove_instrument() {
# Line 2086  void MainWindow::on_action_remove_instru Line 2436  void MainWindow::on_action_remove_instru
2436      }      }
2437    
2438      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection();      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection();
2439      Gtk::TreeModel::iterator it = sel->get_selected();      std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
2440      if (it) {      for (int r = rows.size() - 1; r >= 0; --r) {
2441            Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]);
2442            if (!it) continue;
2443          Gtk::TreeModel::Row row = *it;          Gtk::TreeModel::Row row = *it;
2444          gig::Instrument* instr = row[m_Columns.m_col_instr];          gig::Instrument* instr = row[m_Columns.m_col_instr];
2445          try {          try {
# Line 2102  void MainWindow::on_action_remove_instru Line 2454  void MainWindow::on_action_remove_instru
2454    
2455              // remove row from instruments tree view              // remove row from instruments tree view
2456              m_refTreeModel->erase(it);              m_refTreeModel->erase(it);
2457                // update "Nr" column of all instrument rows
2458                {
2459                    int index = 0;
2460                    for (Gtk::TreeModel::iterator it = m_refTreeModel->children().begin();
2461                         it != m_refTreeModel->children().end(); ++it, ++index)
2462                    {
2463                        Gtk::TreeModel::Row row = *it;
2464                        row[m_Columns.m_col_nr] = index;
2465                    }
2466                }
2467    
2468  #if GTKMM_MAJOR_VERSION < 3  #if GTKMM_MAJOR_VERSION < 3
2469              // select another instrument (in gtk3 this is done              // select another instrument (in gtk3 this is done
# Line 2199  void MainWindow::on_action_edit_script() Line 2561  void MainWindow::on_action_edit_script()
2561      if (!script) return;      if (!script) return;
2562    
2563      ScriptEditor* editor = new ScriptEditor;      ScriptEditor* editor = new ScriptEditor;
2564        editor->signal_script_to_be_changed.connect(
2565            signal_script_to_be_changed.make_slot()
2566        );
2567        editor->signal_script_changed.connect(
2568            signal_script_changed.make_slot()
2569        );
2570      editor->setScript(script);      editor->setScript(script);
2571      //editor->reparent(*this);      //editor->reparent(*this);
2572      editor->show();      editor->show();
# Line 2264  void MainWindow::on_action_add_group() { Line 2632  void MainWindow::on_action_add_group() {
2632      file_changed();      file_changed();
2633  }  }
2634    
2635    void MainWindow::on_action_replace_sample() {
2636        add_or_replace_sample(true);
2637    }
2638    
2639  void MainWindow::on_action_add_sample() {  void MainWindow::on_action_add_sample() {
2640        add_or_replace_sample(false);
2641    }
2642    
2643    void MainWindow::add_or_replace_sample(bool replace) {
2644      if (!file) return;      if (!file) return;
2645      // get selected group  
2646        // get selected group (and probably selected sample)
2647      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();
2648      Gtk::TreeModel::iterator it = sel->get_selected();      std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
2649        if (rows.empty()) return;
2650        Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]);
2651      if (!it) return;      if (!it) return;
2652      Gtk::TreeModel::Row row = *it;      Gtk::TreeModel::Row row = *it;
2653        gig::Sample* sample = NULL;
2654      gig::Group* group = row[m_SamplesModel.m_col_group];      gig::Group* group = row[m_SamplesModel.m_col_group];
2655      if (!group) { // not a group, but a sample is selected (probably)      if (!group) { // not a group, but a sample is selected (probably)
2656          gig::Sample* sample = row[m_SamplesModel.m_col_sample];          if (replace) sample = row[m_SamplesModel.m_col_sample];
2657          if (!sample) return;          if (!row[m_SamplesModel.m_col_sample]) return;
2658          it = row.parent(); // resolve parent (that is the sample's group)          it = row.parent(); // resolve parent (that is the sample's group)
2659          if (!it) return;          if (!it) return;
2660          row = *it;          if (!replace) row = *it;
2661          group = row[m_SamplesModel.m_col_group];          group = (*it)[m_SamplesModel.m_col_group];
2662          if (!group) return;          if (!group) return;
2663      }      }
2664        if (replace && !sample) return;
2665    
2666      // show 'browse for file' dialog      // show 'browse for file' dialog
2667      Gtk::FileChooserDialog dialog(*this, _("Add Sample(s)"));      Gtk::FileChooserDialog dialog(*this, replace ? _("Replace Sample with") : _("Add Sample(s)"));
2668      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
2669      dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);      dialog.add_button(_("_Open"), Gtk::RESPONSE_OK);
2670      dialog.set_select_multiple(true);      dialog.set_select_multiple(!replace); // allow multi audio file selection only when adding new samples, does not make sense when replacing a specific sample
2671    
2672      // matches all file types supported by libsndfile      // matches all file types supported by libsndfile
2673  #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 2356  void MainWindow::on_action_add_sample() Line 2738  void MainWindow::on_action_add_sample()
2738                          sf_close(hFile); // close sound file                          sf_close(hFile); // close sound file
2739                          throw std::string(_("format not supported")); // unsupported subformat (yet?)                          throw std::string(_("format not supported")); // unsupported subformat (yet?)
2740                  }                  }
2741                  // add a new sample to the .gig file                  // add a new sample to the .gig file (if adding is requested actually)
2742                  gig::Sample* sample = file->AddSample();                  if (!replace) sample = file->AddSample();
2743                  // file name without path                  // file name without path
2744                  Glib::ustring filename = Glib::filename_display_basename(*iter);                  Glib::ustring filename = Glib::filename_display_basename(*iter);
2745                  // remove file extension if there is one                  // remove file extension if there is one
# Line 2408  void MainWindow::on_action_add_sample() Line 2790  void MainWindow::on_action_add_sample()
2790                  // physically when File::Save() is called)                  // physically when File::Save() is called)
2791                  sample->Resize(info.frames);                  sample->Resize(info.frames);
2792                  // make sure sample is part of the selected group                  // make sure sample is part of the selected group
2793                  group->AddSample(sample);                  if (!replace) group->AddSample(sample);
2794                  // schedule that physical resize and sample import                  // schedule that physical resize and sample import
2795                  // (data copying), performed when "Save" is requested                  // (data copying), performed when "Save" is requested
2796                  SampleImportItem sched_item;                  SampleImportItem sched_item;
2797                  sched_item.gig_sample  = sample;                  sched_item.gig_sample  = sample;
2798                  sched_item.sample_path = *iter;                  sched_item.sample_path = *iter;
2799                  m_SampleImportQueue.push_back(sched_item);                  m_SampleImportQueue[sample] = sched_item;
2800                  // add sample to the tree view                  // add sample to the tree view
2801                  Gtk::TreeModel::iterator iterSample =                  if (replace) {
2802                      m_refSamplesTreeModel->append(row.children());                      row[m_SamplesModel.m_col_name] = gig_to_utf8(sample->pInfo->Name);
2803                  Gtk::TreeModel::Row rowSample = *iterSample;                  } else {
2804                  rowSample[m_SamplesModel.m_col_name] =                      Gtk::TreeModel::iterator iterSample =
2805                      gig_to_utf8(sample->pInfo->Name);                          m_refSamplesTreeModel->append(row.children());
2806                  rowSample[m_SamplesModel.m_col_sample] = sample;                      Gtk::TreeModel::Row rowSample = *iterSample;
2807                  rowSample[m_SamplesModel.m_col_group]  = NULL;                      rowSample[m_SamplesModel.m_col_name] =
2808                            gig_to_utf8(sample->pInfo->Name);
2809                        rowSample[m_SamplesModel.m_col_sample] = sample;
2810                        rowSample[m_SamplesModel.m_col_group]  = NULL;
2811                    }
2812                  // close sound file                  // close sound file
2813                  sf_close(hFile);                  sf_close(hFile);
2814                  file_changed();                  file_changed();
# Line 2433  void MainWindow::on_action_add_sample() Line 2819  void MainWindow::on_action_add_sample()
2819          }          }
2820          // show error message box when some file(s) could not be opened / added          // show error message box when some file(s) could not be opened / added
2821          if (!error_files.empty()) {          if (!error_files.empty()) {
2822              Glib::ustring txt = _("Could not add the following sample(s):\n") + error_files;              Glib::ustring txt =
2823                    (replace
2824                        ? _("Failed to replace sample with:\n")
2825                        : _("Could not add the following sample(s):\n"))
2826                    + error_files;
2827              Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);              Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);
2828              msg.run();              msg.run();
2829          }          }
# Line 2476  void MainWindow::on_action_replace_all_s Line 2866  void MainWindow::on_action_replace_all_s
2866      dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK);      dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK);
2867      description.show();      description.show();
2868      entryArea.show_all();      entryArea.show_all();
2869      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
2870      dialog.add_button(_("Select"), Gtk::RESPONSE_OK);      dialog.add_button(_("Select"), Gtk::RESPONSE_OK);
2871      dialog.set_select_multiple(false);      dialog.set_select_multiple(false);
2872      if (current_sample_dir != "") {      if (current_sample_dir != "") {
# Line 2500  void MainWindow::on_action_replace_all_s Line 2890  void MainWindow::on_action_replace_all_s
2890              try              try
2891              {              {
2892                  if (!hFile) throw std::string(_("could not open file"));                  if (!hFile) throw std::string(_("could not open file"));
                 int bitdepth;  
2893                  switch (info.format & 0xff) {                  switch (info.format & 0xff) {
2894                      case SF_FORMAT_PCM_S8:                      case SF_FORMAT_PCM_S8:
2895                      case SF_FORMAT_PCM_16:                      case SF_FORMAT_PCM_16:
2896                      case SF_FORMAT_PCM_U8:                      case SF_FORMAT_PCM_U8:
                         bitdepth = 16;  
                         break;  
2897                      case SF_FORMAT_PCM_24:                      case SF_FORMAT_PCM_24:
2898                      case SF_FORMAT_PCM_32:                      case SF_FORMAT_PCM_32:
2899                      case SF_FORMAT_FLOAT:                      case SF_FORMAT_FLOAT:
2900                      case SF_FORMAT_DOUBLE:                      case SF_FORMAT_DOUBLE:
                         bitdepth = 24;  
2901                          break;                          break;
2902                      default:                      default:
2903                          sf_close(hFile);                          sf_close(hFile);
# Line 2520  void MainWindow::on_action_replace_all_s Line 2906  void MainWindow::on_action_replace_all_s
2906                  SampleImportItem sched_item;                  SampleImportItem sched_item;
2907                  sched_item.gig_sample  = sample;                  sched_item.gig_sample  = sample;
2908                  sched_item.sample_path = filename;                  sched_item.sample_path = filename;
2909                  m_SampleImportQueue.push_back(sched_item);                  m_SampleImportQueue[sample] = sched_item;
2910                  sf_close(hFile);                  sf_close(hFile);
2911                  file_changed();                  file_changed();
2912              }              }
# Line 2544  void MainWindow::on_action_replace_all_s Line 2930  void MainWindow::on_action_replace_all_s
2930  void MainWindow::on_action_remove_sample() {  void MainWindow::on_action_remove_sample() {
2931      if (!file) return;      if (!file) return;
2932      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();
2933      Gtk::TreeModel::iterator it = sel->get_selected();      std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
2934      if (it) {      for (int r = rows.size() - 1; r >= 0; --r) {
2935            Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[r]);
2936            if (!it) continue;
2937          Gtk::TreeModel::Row row = *it;          Gtk::TreeModel::Row row = *it;
2938          gig::Group* group   = row[m_SamplesModel.m_col_group];          gig::Group* group   = row[m_SamplesModel.m_col_group];
2939          gig::Sample* sample = row[m_SamplesModel.m_col_sample];          gig::Sample* sample = row[m_SamplesModel.m_col_sample];
# Line 2570  void MainWindow::on_action_remove_sample Line 2958  void MainWindow::on_action_remove_sample
2958                  // if sample(s) were just previously added, remove                  // if sample(s) were just previously added, remove
2959                  // them from the import queue                  // them from the import queue
2960                  for (std::list<gig::Sample*>::iterator member = members.begin();                  for (std::list<gig::Sample*>::iterator member = members.begin();
2961                       member != members.end(); ++member) {                       member != members.end(); ++member)
2962                      for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin();                  {
2963                           iter != m_SampleImportQueue.end(); ++iter) {                      if (m_SampleImportQueue.count(*member)) {
2964                          if ((*iter).gig_sample == *member) {                          printf("Removing previously added sample '%s' from group '%s'\n",
2965                              printf("Removing previously added sample '%s' from group '%s'\n",                                 m_SampleImportQueue[sample].sample_path.c_str(), name.c_str());
2966                                     (*iter).sample_path.c_str(), name.c_str());                          m_SampleImportQueue.erase(*member);
                             m_SampleImportQueue.erase(iter);  
                             break;  
                         }  
2967                      }                      }
2968                  }                  }
2969                  file_changed();                  file_changed();
# Line 2593  void MainWindow::on_action_remove_sample Line 2978  void MainWindow::on_action_remove_sample
2978                  samples_removed_signal.emit();                  samples_removed_signal.emit();
2979                  // if sample was just previously added, remove it from                  // if sample was just previously added, remove it from
2980                  // the import queue                  // the import queue
2981                  for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin();                  if (m_SampleImportQueue.count(sample)) {
2982                       iter != m_SampleImportQueue.end(); ++iter) {                      printf("Removing previously added sample '%s'\n",
2983                      if ((*iter).gig_sample == sample) {                             m_SampleImportQueue[sample].sample_path.c_str());
2984                          printf("Removing previously added sample '%s'\n",                      m_SampleImportQueue.erase(sample);
                                (*iter).sample_path.c_str());  
                         m_SampleImportQueue.erase(iter);  
                         break;  
                     }  
2985                  }                  }
2986                  dimreg_changed();                  dimreg_changed();
2987                  file_changed();                  file_changed();
# Line 2617  void MainWindow::on_action_remove_sample Line 2998  void MainWindow::on_action_remove_sample
2998      }      }
2999  }  }
3000    
3001    void MainWindow::on_action_remove_unused_samples() {
3002        if (!file) return;
3003    
3004        // collect all samples that are not referenced by any instrument
3005        std::list<gig::Sample*> lsamples;
3006        for (int iSample = 0; file->GetSample(iSample); ++iSample) {
3007            gig::Sample* sample = file->GetSample(iSample);
3008            bool isUsed = false;
3009            for (gig::Instrument* instrument = file->GetFirstInstrument(); instrument;
3010                                  instrument = file->GetNextInstrument())
3011            {
3012                for (gig::Region* rgn = instrument->GetFirstRegion(); rgn;
3013                                  rgn = instrument->GetNextRegion())
3014                {
3015                    for (int i = 0; i < 256; ++i) {
3016                        if (!rgn->pDimensionRegions[i]) continue;
3017                        if (rgn->pDimensionRegions[i]->pSample != sample) continue;
3018                        isUsed = true;
3019                        goto endOfRefSearch;
3020                    }
3021                }
3022            }
3023            endOfRefSearch:
3024            if (!isUsed) lsamples.push_back(sample);
3025        }
3026    
3027        if (lsamples.empty()) return;
3028    
3029        // notify everybody that we're going to remove these samples
3030        samples_to_be_removed_signal.emit(lsamples);
3031    
3032        // remove collected samples
3033        try {
3034            for (std::list<gig::Sample*>::iterator itSample = lsamples.begin();
3035                 itSample != lsamples.end(); ++itSample)
3036            {
3037                gig::Sample* sample = *itSample;
3038                // remove sample from the .gig file
3039                file->DeleteSample(sample);
3040                // if sample was just previously added, remove it from the import queue
3041                if (m_SampleImportQueue.count(sample)) {
3042                    printf("Removing previously added sample '%s'\n",
3043                           m_SampleImportQueue[sample].sample_path.c_str());
3044                    m_SampleImportQueue.erase(sample);
3045                }
3046            }
3047        } catch (RIFF::Exception e) {
3048            // show error message
3049            Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR);
3050            msg.run();
3051        }
3052    
3053        // notify everybody that we're done with removal
3054        samples_removed_signal.emit();
3055    
3056        dimreg_changed();
3057        file_changed();
3058        __refreshEntireGUI();
3059    }
3060    
3061  // see comment on on_sample_treeview_drag_begin()  // see comment on on_sample_treeview_drag_begin()
3062  void MainWindow::on_scripts_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context)  void MainWindow::on_scripts_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context)
3063  {  {
# Line 2643  void MainWindow::on_scripts_treeview_dra Line 3084  void MainWindow::on_scripts_treeview_dra
3084                         sizeof(script)/*length of data in bytes*/);                         sizeof(script)/*length of data in bytes*/);
3085  }  }
3086    
3087    // see comment on on_sample_treeview_drag_begin()
3088    void MainWindow::on_instruments_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context)
3089    {
3090        first_call_to_drag_data_get = true;
3091    }
3092    
3093    void MainWindow::on_instruments_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,
3094                                                           Gtk::SelectionData& selection_data, guint, guint)
3095    {
3096        if (!first_call_to_drag_data_get) return;
3097        first_call_to_drag_data_get = false;
3098    
3099        // get selected source instrument
3100        gig::Instrument* src = NULL;
3101        {
3102            Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection();
3103            std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
3104            if (!rows.empty()) {
3105                Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]);
3106                if (it) {
3107                    Gtk::TreeModel::Row row = *it;
3108                    src = row[m_Columns.m_col_instr];
3109                }
3110            }
3111        }
3112        if (!src) return;
3113    
3114        // pass the source gig::Instrument as pointer
3115        selection_data.set(selection_data.get_target(), 0/*unused*/, (const guchar*)&src,
3116                           sizeof(src)/*length of data in bytes*/);
3117    }
3118    
3119    void MainWindow::on_instruments_treeview_drop_drag_data_received(
3120        const Glib::RefPtr<Gdk::DragContext>& context, int x, int y,
3121        const Gtk::SelectionData& selection_data, guint, guint time)
3122    {
3123        gig::Instrument* src = *((gig::Instrument**) selection_data.get_data());
3124        if (!src || selection_data.get_length() != sizeof(gig::Instrument*))
3125            return;
3126    
3127        gig::Instrument* dst = NULL;
3128        {
3129            Gtk::TreeModel::Path path;
3130            const bool found = m_TreeView.get_path_at_pos(x, y, path);
3131            if (!found) return;
3132    
3133            Gtk::TreeModel::iterator iter = m_refTreeModel->get_iter(path);
3134            if (!iter) return;
3135            Gtk::TreeModel::Row row = *iter;
3136            dst = row[m_Columns.m_col_instr];
3137        }
3138        if (!dst) return;
3139    
3140        //printf("dragdrop received src=%s dst=%s\n", src->pInfo->Name.c_str(), dst->pInfo->Name.c_str());
3141        src->MoveTo(dst);
3142        __refreshEntireGUI();
3143        select_instrument(src);
3144    }
3145    
3146  // For some reason drag_data_get gets called two times for each  // For some reason drag_data_get gets called two times for each
3147  // drag'n'drop (at least when target is an Entry). This work-around  // drag'n'drop (at least when target is an Entry). This work-around
3148  // makes sure the code in drag_data_get and drop_drag_data_received is  // makes sure the code in drag_data_get and drop_drag_data_received is
# Line 2661  void MainWindow::on_sample_treeview_drag Line 3161  void MainWindow::on_sample_treeview_drag
3161      // get selected sample      // get selected sample
3162      gig::Sample* sample = NULL;      gig::Sample* sample = NULL;
3163      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();
3164      Gtk::TreeModel::iterator it = sel->get_selected();      std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
3165      if (it) {      if (!rows.empty()) {
3166          Gtk::TreeModel::Row row = *it;          Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]);
3167          sample = row[m_SamplesModel.m_col_sample];          if (it) {
3168                Gtk::TreeModel::Row row = *it;
3169                sample = row[m_SamplesModel.m_col_sample];
3170            }
3171      }      }
3172      // pass the gig::Sample as pointer      // pass the gig::Sample as pointer
3173      selection_data.set(selection_data.get_target(), 0/*unused*/, (const guchar*)&sample,      selection_data.set(selection_data.get_target(), 0/*unused*/, (const guchar*)&sample,
# Line 2804  void MainWindow::script_double_clicked(c Line 3307  void MainWindow::script_double_clicked(c
3307      if (!script) return;      if (!script) return;
3308    
3309      ScriptEditor* editor = new ScriptEditor;      ScriptEditor* editor = new ScriptEditor;
3310        editor->signal_script_to_be_changed.connect(
3311            signal_script_to_be_changed.make_slot()
3312        );
3313        editor->signal_script_changed.connect(
3314            signal_script_changed.make_slot()
3315        );
3316      editor->setScript(script);      editor->setScript(script);
3317      //editor->reparent(*this);      //editor->reparent(*this);
3318      editor->show();      editor->show();
# Line 2857  void MainWindow::on_action_combine_instr Line 3366  void MainWindow::on_action_combine_instr
3366    
3367  void MainWindow::on_action_view_references() {  void MainWindow::on_action_view_references() {
3368      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();
3369      Gtk::TreeModel::iterator it = sel->get_selected();      std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
3370        if (rows.empty()) return;
3371        Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]);
3372      if (!it) return;      if (!it) return;
3373      Gtk::TreeModel::Row row = *it;      Gtk::TreeModel::Row row = *it;
3374      gig::Sample* sample = row[m_SamplesModel.m_col_sample];      gig::Sample* sample = row[m_SamplesModel.m_col_sample];
# Line 2865  void MainWindow::on_action_view_referenc Line 3376  void MainWindow::on_action_view_referenc
3376    
3377      ReferencesView* d = new ReferencesView(*this);      ReferencesView* d = new ReferencesView(*this);
3378      d->setSample(sample);      d->setSample(sample);
3379        d->dimension_region_selected.connect(
3380            sigc::mem_fun(*this, &MainWindow::select_dimension_region)
3381        );
3382      d->show_all();      d->show_all();
3383      d->resize(500, 400);      d->resize(500, 400);
3384      d->run();      d->run();
# Line 2976  void MainWindow::on_action_merge_files() Line 3490  void MainWindow::on_action_merge_files()
3490      }      }
3491    
3492      Gtk::FileChooserDialog dialog(*this, _("Merge .gig files"));      Gtk::FileChooserDialog dialog(*this, _("Merge .gig files"));
3493      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
3494      dialog.add_button(_("Merge"), Gtk::RESPONSE_OK);      dialog.add_button(_("Merge"), Gtk::RESPONSE_OK);
3495      dialog.set_default_response(Gtk::RESPONSE_CANCEL);      dialog.set_default_response(Gtk::RESPONSE_CANCEL);
3496  #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 2995  void MainWindow::on_action_merge_files() Line 3509  void MainWindow::on_action_merge_files()
3509      // show warning in the file picker dialog      // show warning in the file picker dialog
3510      Gtk::HBox descriptionArea;      Gtk::HBox descriptionArea;
3511      descriptionArea.set_spacing(15);      descriptionArea.set_spacing(15);
3512      Gtk::Image warningIcon(Gtk::Stock::DIALOG_WARNING, Gtk::IconSize(Gtk::ICON_SIZE_DIALOG));      Gtk::Image warningIcon;
3513        warningIcon.set_from_icon_name("dialog-warning",
3514                                       Gtk::IconSize(Gtk::ICON_SIZE_DIALOG));
3515      descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK);      descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK);
3516  #if GTKMM_MAJOR_VERSION < 3  #if GTKMM_MAJOR_VERSION < 3
3517      view::WrapLabel description;      view::WrapLabel description;
# Line 3018  void MainWindow::on_action_merge_files() Line 3534  void MainWindow::on_action_merge_files()
3534      descriptionArea.show_all();      descriptionArea.show_all();
3535    
3536      if (dialog.run() == Gtk::RESPONSE_OK) {      if (dialog.run() == Gtk::RESPONSE_OK) {
3537          printf("on_action_merge_files self=%x\n", Glib::Threads::Thread::self());          printf("on_action_merge_files self=%p\n",
3538                   static_cast<void*>(Glib::Threads::Thread::self()));
3539          std::vector<std::string> filenames = dialog.get_filenames();          std::vector<std::string> filenames = dialog.get_filenames();
3540    
3541          // merge the selected files to the currently open .gig file          // merge the selected files to the currently open .gig file
# Line 3030  void MainWindow::on_action_merge_files() Line 3547  void MainWindow::on_action_merge_files()
3547          }          }
3548    
3549          // update GUI          // update GUI
3550          __refreshEntireGUI();                  __refreshEntireGUI();
3551      }      }
3552  }  }
3553    
# Line 3100  void MainWindow::show_scripts_tab() { Line 3617  void MainWindow::show_scripts_tab() {
3617      m_TreeViewNotebook.set_current_page(2);      m_TreeViewNotebook.set_current_page(2);
3618  }  }
3619    
3620    void MainWindow::select_prev_region() {
3621        m_RegionChooser.select_prev_region();
3622    }
3623    
3624    void MainWindow::select_next_region() {
3625        m_RegionChooser.select_next_region();
3626    }
3627    
3628    void MainWindow::select_next_dim_rgn_zone() {
3629        if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser
3630        m_DimRegionChooser.select_next_dimzone();
3631    }
3632    
3633    void MainWindow::select_prev_dim_rgn_zone() {
3634        if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser
3635        m_DimRegionChooser.select_prev_dimzone();
3636    }
3637    
3638    void MainWindow::select_prev_dimension() {
3639        if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser
3640        m_DimRegionChooser.select_prev_dimension();
3641    }
3642    
3643    void MainWindow::select_next_dimension() {
3644        if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser
3645        m_DimRegionChooser.select_next_dimension();
3646    }
3647    
3648  sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() {  sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() {
3649      return file_structure_to_be_changed_signal;      return file_structure_to_be_changed_signal;
3650  }  }

Legend:
Removed from v.2694  
changed lines
  Added in v.3123

  ViewVC Help
Powered by ViewVC