/[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 3157 by schoenebeck, Mon May 8 17:30:10 2017 UTC revision 3299 by schoenebeck, Sun Jul 9 12:44:59 2017 UTC
# Line 35  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>
38    #include <gtkmm/stock.h>
39  #include <gtkmm/targetentry.h>  #include <gtkmm/targetentry.h>
40  #include <gtkmm/main.h>  #include <gtkmm/main.h>
41  #include <gtkmm/toggleaction.h>  #include <gtkmm/toggleaction.h>
# Line 61  Line 62 
62  #include "gfx/builtinpix.h"  #include "gfx/builtinpix.h"
63  #include "MacroEditor.h"  #include "MacroEditor.h"
64  #include "MacrosSetup.h"  #include "MacrosSetup.h"
65    #if defined(__APPLE__)
66    # include "MacHelper.h"
67    #endif
68    
69    static const Gdk::ModifierType primaryModifierKey =
70        #if defined(__APPLE__)
71        Gdk::META_MASK; // Cmd key on Mac
72        #else
73        Gdk::CONTROL_MASK; // Ctrl key on all other OSs
74        #endif
75    
76  MainWindow::MainWindow() :  MainWindow::MainWindow() :
77      m_DimRegionChooser(*this),      m_DimRegionChooser(*this),
# Line 77  MainWindow::MainWindow() : Line 88  MainWindow::MainWindow() :
88      loadBuiltInPix();      loadBuiltInPix();
89    
90  //    set_border_width(5);  //    set_border_width(5);
91  //    set_default_size(400, 200);  
92        if (!Settings::singleton()->autoRestoreWindowDimension) {
93            set_default_size(800, 600);
94            set_position(Gtk::WIN_POS_CENTER);
95        }
96    
97      add(m_VBox);      add(m_VBox);
98    
# Line 156  MainWindow::MainWindow() : Line 171  MainWindow::MainWindow() :
171      actionGroup = Gtk::ActionGroup::create();      actionGroup = Gtk::ActionGroup::create();
172    
173      actionGroup->add(Gtk::Action::create("MenuFile", _("_File")));      actionGroup->add(Gtk::Action::create("MenuFile", _("_File")));
174      actionGroup->add(Gtk::Action::create("New", _("_New")),      actionGroup->add(Gtk::Action::create("New", Gtk::Stock::NEW),
                      Gtk::AccelKey("<control>n"),  
175                       sigc::mem_fun(                       sigc::mem_fun(
176                           *this, &MainWindow::on_action_file_new));                           *this, &MainWindow::on_action_file_new));
177      actionGroup->add(Gtk::Action::create("Open", _("_Open...")),      Glib::RefPtr<Gtk::Action> action =
178                       Gtk::AccelKey("<control>o"),          Gtk::Action::create("Open", Gtk::Stock::OPEN);
179        action->property_label() = action->property_label() + "...";
180        actionGroup->add(action,
181                       sigc::mem_fun(                       sigc::mem_fun(
182                           *this, &MainWindow::on_action_file_open));                           *this, &MainWindow::on_action_file_open));
183      actionGroup->add(Gtk::Action::create("Save", _("_Save")),      actionGroup->add(Gtk::Action::create("Save", Gtk::Stock::SAVE),
                      Gtk::AccelKey("<control>s"),  
184                       sigc::mem_fun(                       sigc::mem_fun(
185                           *this, &MainWindow::on_action_file_save));                           *this, &MainWindow::on_action_file_save));
186      actionGroup->add(Gtk::Action::create("SaveAs", _("Save _As...")),      action = Gtk::Action::create("SaveAs", Gtk::Stock::SAVE_AS);
187        action->property_label() = action->property_label() + "...";
188        actionGroup->add(action,
189                       Gtk::AccelKey("<shift><control>s"),                       Gtk::AccelKey("<shift><control>s"),
190                       sigc::mem_fun(                       sigc::mem_fun(
191                           *this, &MainWindow::on_action_file_save_as));                           *this, &MainWindow::on_action_file_save_as));
192      actionGroup->add(Gtk::Action::create("Properties",      actionGroup->add(Gtk::Action::create("Properties",
193                                           _("_Properties")),                                           Gtk::Stock::PROPERTIES),
194                       sigc::mem_fun(                       sigc::mem_fun(
195                           *this, &MainWindow::on_action_file_properties));                           *this, &MainWindow::on_action_file_properties));
196      actionGroup->add(Gtk::Action::create("InstrProperties",      actionGroup->add(Gtk::Action::create("InstrProperties",
197                                           _("_Properties")),                                           Gtk::Stock::PROPERTIES),
198                       sigc::mem_fun(                       sigc::mem_fun(
199                           *this, &MainWindow::show_instr_props));                           *this, &MainWindow::show_instr_props));
200      actionGroup->add(Gtk::Action::create("MidiRules",      actionGroup->add(Gtk::Action::create("MidiRules",
# Line 188  MainWindow::MainWindow() : Line 205  MainWindow::MainWindow() :
205                                           _("_Script Slots...")),                                           _("_Script Slots...")),
206                       sigc::mem_fun(                       sigc::mem_fun(
207                           *this, &MainWindow::show_script_slots));                           *this, &MainWindow::show_script_slots));
208      actionGroup->add(Gtk::Action::create("Quit", _("_Quit")),      actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT),
                      Gtk::AccelKey("<control>q"),  
209                       sigc::mem_fun(                       sigc::mem_fun(
210                           *this, &MainWindow::on_action_quit));                           *this, &MainWindow::on_action_quit));
211      actionGroup->add(      actionGroup->add(
# Line 316  MainWindow::MainWindow() : Line 332  MainWindow::MainWindow() :
332          sigc::mem_fun(*this, &MainWindow::on_action_refresh_all)          sigc::mem_fun(*this, &MainWindow::on_action_refresh_all)
333      );                      );                
334    
335      actionGroup->add(Gtk::Action::create("MenuHelp", _("_Help")));      action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP);
336      actionGroup->add(Gtk::Action::create("About", _("_About")),      actionGroup->add(Gtk::Action::create("MenuHelp",
337                                             action->property_label()));
338        actionGroup->add(Gtk::Action::create("About", Gtk::Stock::ABOUT),
339                       sigc::mem_fun(                       sigc::mem_fun(
340                           *this, &MainWindow::on_action_help_about));                           *this, &MainWindow::on_action_help_about));
341      actionGroup->add(      actionGroup->add(
# Line 329  MainWindow::MainWindow() : Line 347  MainWindow::MainWindow() :
347          sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument)          sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument)
348      );      );
349      actionGroup->add(      actionGroup->add(
350          Gtk::Action::create("RemoveInstrument", _("_Remove")),          Gtk::Action::create("CombInstruments", _("_Combine Instruments ...")),
351            Gtk::AccelKey(GDK_KEY_j, primaryModifierKey),
352            sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments)
353        );
354        actionGroup->add(
355            Gtk::Action::create("RemoveInstrument", Gtk::Stock::REMOVE),
356          sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument)          sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument)
357      );      );
358    
# Line 376  MainWindow::MainWindow() : Line 399  MainWindow::MainWindow() :
399    
400      // sample right-click popup actions      // sample right-click popup actions
401      actionGroup->add(      actionGroup->add(
402          Gtk::Action::create("SampleProperties", _("_Properties")),          Gtk::Action::create("SampleProperties", Gtk::Stock::PROPERTIES),
403          sigc::mem_fun(*this, &MainWindow::on_action_sample_properties)          sigc::mem_fun(*this, &MainWindow::on_action_sample_properties)
404      );      );
405      actionGroup->add(      actionGroup->add(
# Line 388  MainWindow::MainWindow() : Line 411  MainWindow::MainWindow() :
411          sigc::mem_fun(*this, &MainWindow::on_action_add_sample)          sigc::mem_fun(*this, &MainWindow::on_action_add_sample)
412      );      );
413      actionGroup->add(      actionGroup->add(
414          Gtk::Action::create("RemoveSample", _("_Remove")),          Gtk::Action::create("RemoveSample", Gtk::Stock::REMOVE),
415          sigc::mem_fun(*this, &MainWindow::on_action_remove_sample)          sigc::mem_fun(*this, &MainWindow::on_action_remove_sample)
416      );      );
417      actionGroup->add(      actionGroup->add(
# Line 424  MainWindow::MainWindow() : Line 447  MainWindow::MainWindow() :
447          sigc::mem_fun(*this, &MainWindow::on_action_edit_script)          sigc::mem_fun(*this, &MainWindow::on_action_edit_script)
448      );      );
449      actionGroup->add(      actionGroup->add(
450          Gtk::Action::create("RemoveScript", _("_Remove")),          Gtk::Action::create("RemoveScript", Gtk::Stock::REMOVE),
451          sigc::mem_fun(*this, &MainWindow::on_action_remove_script)          sigc::mem_fun(*this, &MainWindow::on_action_remove_script)
452      );      );
453    
# Line 487  MainWindow::MainWindow() : Line 510  MainWindow::MainWindow() :
510          "      <menuitem action='ScriptSlots'/>"          "      <menuitem action='ScriptSlots'/>"
511          "      <menuitem action='AddInstrument'/>"          "      <menuitem action='AddInstrument'/>"
512          "      <menuitem action='DupInstrument'/>"          "      <menuitem action='DupInstrument'/>"
513            "      <menuitem action='CombInstruments'/>"
514          "      <separator/>"          "      <separator/>"
515          "      <menuitem action='RemoveInstrument'/>"          "      <menuitem action='RemoveInstrument'/>"
516          "    </menu>"          "    </menu>"
# Line 523  MainWindow::MainWindow() : Line 547  MainWindow::MainWindow() :
547          "    <menuitem action='ScriptSlots'/>"          "    <menuitem action='ScriptSlots'/>"
548          "    <menuitem action='AddInstrument'/>"          "    <menuitem action='AddInstrument'/>"
549          "    <menuitem action='DupInstrument'/>"          "    <menuitem action='DupInstrument'/>"
550            "    <menuitem action='CombInstruments'/>"
551          "    <separator/>"          "    <separator/>"
552          "    <menuitem action='RemoveInstrument'/>"          "    <menuitem action='RemoveInstrument'/>"
553          "  </popup>"          "  </popup>"
# Line 650  MainWindow::MainWindow() : Line 675  MainWindow::MainWindow() :
675      // Add the TreeView's view columns:      // Add the TreeView's view columns:
676      m_TreeView.append_column(_("Nr"), m_Columns.m_col_nr);      m_TreeView.append_column(_("Nr"), m_Columns.m_col_nr);
677      m_TreeView.append_column_editable(_("Instrument"), m_Columns.m_col_name);      m_TreeView.append_column_editable(_("Instrument"), m_Columns.m_col_name);
678        m_TreeView.append_column(_("Scripts"), m_Columns.m_col_scripts);
679      m_TreeView.set_headers_visible(true);      m_TreeView.set_headers_visible(true);
680            
681      // establish drag&drop within the instrument tree view, allowing to reorder      // establish drag&drop within the instrument tree view, allowing to reorder
# Line 839  MainWindow::MainWindow() : Line 865  MainWindow::MainWindow() :
865              uiManager->get_widget("/MenuBar/MenuMacro")              uiManager->get_widget("/MenuBar/MenuMacro")
866          )->get_submenu();          )->get_submenu();
867    
         const Gdk::ModifierType primaryModifierKey =  
 #if defined(__APPLE__)  
             Gdk::META_MASK; // Cmd key on Mac  
 #else  
             Gdk::CONTROL_MASK; // Ctrl key on all other OSs  
 #endif  
   
868          const Gdk::ModifierType noModifier = (Gdk::ModifierType)0;          const Gdk::ModifierType noModifier = (Gdk::ModifierType)0;
869          Gtk::AccelMap::add_entry("<Macros>/macro_0", GDK_KEY_F1, noModifier);          Gtk::AccelMap::add_entry("<Macros>/macro_0", GDK_KEY_F1, noModifier);
870          Gtk::AccelMap::add_entry("<Macros>/macro_1", GDK_KEY_F2, noModifier);          Gtk::AccelMap::add_entry("<Macros>/macro_1", GDK_KEY_F2, noModifier);
# Line 866  MainWindow::MainWindow() : Line 885  MainWindow::MainWindow() :
885    
886          updateMacroMenu();          updateMacroMenu();
887      }      }
888    
889        Glib::signal_idle().connect_once(
890            sigc::mem_fun(*this, &MainWindow::bringToFront),
891            200
892        );
893  }  }
894    
895  MainWindow::~MainWindow()  MainWindow::~MainWindow()
896  {  {
897  }  }
898    
899    void MainWindow::bringToFront() {
900        #if defined(__APPLE__)
901        macRaiseAppWindow();
902        #endif
903        raise();
904        present();
905    }
906    
907  void MainWindow::updateMacroMenu() {  void MainWindow::updateMacroMenu() {
908      Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>(      Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>(
909          uiManager->get_widget("/MenuBar/MenuMacro")          uiManager->get_widget("/MenuBar/MenuMacro")
# Line 910  void MainWindow::updateMacroMenu() { Line 942  void MainWindow::updateMacroMenu() {
942          );          );
943          menuMacro->append(*item);          menuMacro->append(*item);
944          item->set_accel_path("<Macros>/macro_" + ToString(iMacro));          item->set_accel_path("<Macros>/macro_" + ToString(iMacro));
945            Glib::ustring comment = macro.comment();
946            if (!comment.empty())
947                item->set_tooltip_text(comment);
948      }      }
949      // if there are no macros configured at all, then show a dummy entry instead      // if there are no macros configured at all, then show a dummy entry instead
950      if (m_macros.empty()) {      if (m_macros.empty()) {
# Line 953  void MainWindow::onMacroSelected(int iMa Line 988  void MainWindow::onMacroSelected(int iMa
988    
989  void MainWindow::setupMacros() {  void MainWindow::setupMacros() {
990      MacrosSetup* setup = new MacrosSetup();      MacrosSetup* setup = new MacrosSetup();
991      setup->setMacros(m_macros);      gig::DimensionRegion* pDimRgn = m_DimRegionChooser.get_main_dimregion();
992        setup->setMacros(m_macros, &m_serializationArchive, pDimRgn);
993      setup->signal_macros_changed().connect(      setup->signal_macros_changed().connect(
994          sigc::mem_fun(*this, &MainWindow::onMacrosSetupChanged)          sigc::mem_fun(*this, &MainWindow::onMacrosSetupChanged)
995      );      );
# Line 1196  void Saver::thread_function() Line 1232  void Saver::thread_function()
1232                  // save the file as separate temporary file first,                  // save the file as separate temporary file first,
1233                  // then move the saved file over the old file                  // then move the saved file over the old file
1234                  // (may result in performance speedup during save)                  // (may result in performance speedup during save)
1235                  String tmpname = filename + ".TMP";                  gig::String tmpname = filename + ".TMP";
1236                  gig->Save(tmpname, &progress);                  gig->Save(tmpname, &progress);
1237                  #if defined(WIN32)                  #if defined(WIN32)
1238                  if (!DeleteFile(filename.c_str())) {                  if (!DeleteFile(filename.c_str())) {
# Line 1204  void Saver::thread_function() Line 1240  void Saver::thread_function()
1240                  }                  }
1241                  #else // POSIX ...                  #else // POSIX ...
1242                  if (unlink(filename.c_str())) {                  if (unlink(filename.c_str())) {
1243                      throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file): " + String(strerror(errno)));                      throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file): " + gig::String(strerror(errno)));
1244                  }                  }
1245                  #endif                  #endif
1246                  if (rename(tmpname.c_str(), filename.c_str())) {                  if (rename(tmpname.c_str(), filename.c_str())) {
1247                      #if defined(WIN32)                      #if defined(WIN32)
1248                      throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file).");                      throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file).");
1249                      #else                      #else
1250                      throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file): " + String(strerror(errno)));                      throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file): " + gig::String(strerror(errno)));
1251                      #endif                      #endif
1252                  }                  }
1253              }              }
# Line 1339  bool MainWindow::close_confirmation_dial Line 1375  bool MainWindow::close_confirmation_dial
1375      g_free(msg);      g_free(msg);
1376      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."));
1377      dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO);      dialog.add_button(_("Close _Without Saving"), Gtk::RESPONSE_NO);
1378      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1379      dialog.add_button(file_has_name ? _("_Save") : _("Save _As"), Gtk::RESPONSE_YES);      dialog.add_button(file_has_name ? Gtk::Stock::SAVE : Gtk::Stock::SAVE_AS, Gtk::RESPONSE_YES);
1380      dialog.set_default_response(Gtk::RESPONSE_YES);      dialog.set_default_response(Gtk::RESPONSE_YES);
1381      int response = dialog.run();      int response = dialog.run();
1382      dialog.hide();      dialog.hide();
# Line 1371  bool MainWindow::leaving_shared_mode_dia Line 1407  bool MainWindow::leaving_shared_mode_dia
1407            "used by the sampler until you tell the sampler explicitly to "            "used by the sampler until you tell the sampler explicitly to "
1408            "load it."));            "load it."));
1409      dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES);      dialog.add_button(_("_Yes, Detach"), Gtk::RESPONSE_YES);
1410      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1411      dialog.set_default_response(Gtk::RESPONSE_CANCEL);      dialog.set_default_response(Gtk::RESPONSE_CANCEL);
1412      int response = dialog.run();      int response = dialog.run();
1413      dialog.hide();      dialog.hide();
# Line 1385  void MainWindow::on_action_file_open() Line 1421  void MainWindow::on_action_file_open()
1421      if (file_is_shared && !leaving_shared_mode_dialog()) return;      if (file_is_shared && !leaving_shared_mode_dialog()) return;
1422    
1423      Gtk::FileChooserDialog dialog(*this, _("Open file"));      Gtk::FileChooserDialog dialog(*this, _("Open file"));
1424      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1425      dialog.add_button(_("_Open"), Gtk::RESPONSE_OK);      dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
1426      dialog.set_default_response(Gtk::RESPONSE_OK);      dialog.set_default_response(Gtk::RESPONSE_OK);
1427  #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
1428      Gtk::FileFilter filter;      Gtk::FileFilter filter;
# Line 1581  void MainWindow::on_action_file_save_as( Line 1617  void MainWindow::on_action_file_save_as(
1617    
1618  bool MainWindow::file_save_as()  bool MainWindow::file_save_as()
1619  {  {
1620      Gtk::FileChooserDialog dialog(*this, _("Save As"), Gtk::FILE_CHOOSER_ACTION_SAVE);      Gtk::FileChooserDialog dialog(*this, _("Save as"), Gtk::FILE_CHOOSER_ACTION_SAVE);
1621      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1622      dialog.add_button(_("_Save"), Gtk::RESPONSE_OK);      dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);
1623      dialog.set_default_response(Gtk::RESPONSE_OK);      dialog.set_default_response(Gtk::RESPONSE_OK);
1624      dialog.set_do_overwrite_confirmation();      dialog.set_do_overwrite_confirmation();
1625    
# Line 1807  void MainWindow::on_action_help_about() Line 1843  void MainWindow::on_action_help_about()
1843      dialog.set_comments(sComment.c_str());      dialog.set_comments(sComment.c_str());
1844      dialog.set_website("http://www.linuxsampler.org");      dialog.set_website("http://www.linuxsampler.org");
1845      dialog.set_website_label("http://www.linuxsampler.org");      dialog.set_website_label("http://www.linuxsampler.org");
1846        dialog.set_position(Gtk::WIN_POS_CENTER);
1847      dialog.run();      dialog.run();
1848  }  }
1849    
# Line 1828  PropDialog::PropDialog() Line 1865  PropDialog::PropDialog()
1865        eSourceForm(_("Source form")),        eSourceForm(_("Source form")),
1866        eCommissioned(_("Commissioned")),        eCommissioned(_("Commissioned")),
1867        eSubject(_("Subject")),        eSubject(_("Subject")),
1868        quitButton(_("_Close"), true),        quitButton(Gtk::Stock::CLOSE),
1869        table(2, 1),        table(2, 1),
1870        m_file(NULL)        m_file(NULL)
1871  {  {
1872        if (!Settings::singleton()->autoRestoreWindowDimension) {
1873            set_default_size(470, 390);
1874            set_position(Gtk::WIN_POS_MOUSE);
1875        }
1876    
1877      set_title(_("File Properties"));      set_title(_("File Properties"));
1878      eName.set_width_chars(50);      eName.set_width_chars(50);
1879    
# Line 1951  void InstrumentProps::set_MIDIProgram(ui Line 1993  void InstrumentProps::set_MIDIProgram(ui
1993  }  }
1994    
1995  InstrumentProps::InstrumentProps() :  InstrumentProps::InstrumentProps() :
1996      quitButton(_("_Close"), true),      quitButton(Gtk::Stock::CLOSE),
1997      table(2,1),      table(2,1),
1998      eName(_("Name")),      eName(_("Name")),
1999      eIsDrum(_("Is drum")),      eIsDrum(_("Is drum")),
# Line 1966  InstrumentProps::InstrumentProps() : Line 2008  InstrumentProps::InstrumentProps() :
2008      eDimensionKeyRangeLow(_("Keyswitching range low")),      eDimensionKeyRangeLow(_("Keyswitching range low")),
2009      eDimensionKeyRangeHigh(_("Keyswitching range high"))      eDimensionKeyRangeHigh(_("Keyswitching range high"))
2010  {  {
2011        if (!Settings::singleton()->autoRestoreWindowDimension) {
2012            //set_default_size(470, 390);
2013            set_position(Gtk::WIN_POS_MOUSE);
2014        }
2015    
2016      set_title(_("Instrument Properties"));      set_title(_("Instrument Properties"));
2017    
2018      eDimensionKeyRangeLow.set_tip(      eDimensionKeyRangeLow.set_tip(
# Line 2090  void MainWindow::load_gig(gig::File* gig Line 2137  void MainWindow::load_gig(gig::File* gig
2137      for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ;      for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ;
2138           instrument = gig->GetNextInstrument(), ++index) {           instrument = gig->GetNextInstrument(), ++index) {
2139          Glib::ustring name(gig_to_utf8(instrument->pInfo->Name));          Glib::ustring name(gig_to_utf8(instrument->pInfo->Name));
2140            const int iScriptSlots = instrument->ScriptSlotCount();
2141    
2142          Gtk::TreeModel::iterator iter = m_refTreeModel->append();          Gtk::TreeModel::iterator iter = m_refTreeModel->append();
2143          Gtk::TreeModel::Row row = *iter;          Gtk::TreeModel::Row row = *iter;
2144          row[m_Columns.m_col_nr] = index;          row[m_Columns.m_col_nr] = index;
2145          row[m_Columns.m_col_name] = name;          row[m_Columns.m_col_name] = name;
2146          row[m_Columns.m_col_instr] = instrument;          row[m_Columns.m_col_instr] = instrument;
2147            row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : "";
2148    
2149          add_instrument_to_menu(name);          add_instrument_to_menu(name);
2150      }      }
# Line 2234  void MainWindow::show_script_slots() { Line 2283  void MainWindow::show_script_slots() {
2283    
2284      ScriptSlots* window = new ScriptSlots;      ScriptSlots* window = new ScriptSlots;
2285      window->setInstrument(instrument);      window->setInstrument(instrument);
2286        window->signal_script_slots_changed().connect(
2287            sigc::mem_fun(*this, &MainWindow::onScriptSlotsModified)
2288        );
2289      //window->reparent(*this);      //window->reparent(*this);
2290      window->show();      window->show();
2291  }  }
2292    
2293    void MainWindow::onScriptSlotsModified(gig::Instrument* pInstrument) {
2294        if (!pInstrument) return;
2295        const int iScriptSlots = pInstrument->ScriptSlotCount();
2296    
2297        Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model();
2298        for (int i = 0; i < model->children().size(); ++i) {
2299            Gtk::TreeModel::Row row = model->children()[i];
2300            if (row[m_Columns.m_col_instr] != pInstrument) continue;
2301            row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : "";
2302            break;
2303        }
2304    }
2305    
2306  void MainWindow::on_action_refresh_all() {  void MainWindow::on_action_refresh_all() {
2307      __refreshEntireGUI();      __refreshEntireGUI();
2308  }  }
# Line 2552  void MainWindow::add_instrument(gig::Ins Line 2617  void MainWindow::add_instrument(gig::Ins
2617      rowInstr[m_Columns.m_col_nr] = m_refTreeModel->children().size() - 1;      rowInstr[m_Columns.m_col_nr] = m_refTreeModel->children().size() - 1;
2618      rowInstr[m_Columns.m_col_name] = name;      rowInstr[m_Columns.m_col_name] = name;
2619      rowInstr[m_Columns.m_col_instr] = instrument;      rowInstr[m_Columns.m_col_instr] = instrument;
2620        rowInstr[m_Columns.m_col_scripts] = "";
2621      instrument_name_connection.unblock();      instrument_name_connection.unblock();
2622    
2623      add_instrument_to_menu(name);      add_instrument_to_menu(name);
# Line 2840  void MainWindow::add_or_replace_sample(b Line 2906  void MainWindow::add_or_replace_sample(b
2906    
2907      // show 'browse for file' dialog      // show 'browse for file' dialog
2908      Gtk::FileChooserDialog dialog(*this, replace ? _("Replace Sample with") : _("Add Sample(s)"));      Gtk::FileChooserDialog dialog(*this, replace ? _("Replace Sample with") : _("Add Sample(s)"));
2909      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
2910      dialog.add_button(_("_Open"), Gtk::RESPONSE_OK);      dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
2911      dialog.set_select_multiple(!replace); // allow multi audio file selection only when adding new samples, does not make sense when replacing a specific sample      dialog.set_select_multiple(!replace); // allow multi audio file selection only when adding new samples, does not make sense when replacing a specific sample
2912    
2913      // matches all file types supported by libsndfile      // matches all file types supported by libsndfile
# Line 3041  void MainWindow::on_action_replace_all_s Line 3107  void MainWindow::on_action_replace_all_s
3107      dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK);      dialog.get_vbox()->pack_start(entryArea, Gtk::PACK_SHRINK);
3108      description.show();      description.show();
3109      entryArea.show_all();      entryArea.show_all();
3110      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
3111      dialog.add_button(_("Select"), Gtk::RESPONSE_OK);      dialog.add_button(_("Select"), Gtk::RESPONSE_OK);
3112      dialog.set_select_multiple(false);      dialog.set_select_multiple(false);
3113      if (current_sample_dir != "") {      if (current_sample_dir != "") {
# Line 3529  void MainWindow::instrument_name_changed Line 3595  void MainWindow::instrument_name_changed
3595    
3596  void MainWindow::on_action_combine_instruments() {  void MainWindow::on_action_combine_instruments() {
3597      CombineInstrumentsDialog* d = new CombineInstrumentsDialog(*this, file);      CombineInstrumentsDialog* d = new CombineInstrumentsDialog(*this, file);
3598    
3599        // take over selection from instruments list view for the combine dialog's
3600        // list view as pre-selection
3601        std::set<int> indeces;
3602        {
3603            Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection();
3604            std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
3605            for (int r = 0; r < rows.size(); ++r) {
3606                Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]);
3607                if (it) {
3608                    Gtk::TreeModel::Row row = *it;
3609                    int index = row[m_Columns.m_col_nr];
3610                    indeces.insert(index);
3611                }
3612            }
3613        }
3614        d->setSelectedInstruments(indeces);
3615    
3616      d->show_all();      d->show_all();
     d->resize(500, 400);  
3617      d->run();      d->run();
3618      if (d->fileWasChanged()) {      if (d->fileWasChanged()) {
3619          // update GUI with new instrument just created          // update GUI with new instrument just created
# Line 3665  void MainWindow::on_action_merge_files() Line 3748  void MainWindow::on_action_merge_files()
3748      }      }
3749    
3750      Gtk::FileChooserDialog dialog(*this, _("Merge .gig files"));      Gtk::FileChooserDialog dialog(*this, _("Merge .gig files"));
3751      dialog.add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
3752      dialog.add_button(_("Merge"), Gtk::RESPONSE_OK);      dialog.add_button(_("Merge"), Gtk::RESPONSE_OK);
3753      dialog.set_default_response(Gtk::RESPONSE_CANCEL);      dialog.set_default_response(Gtk::RESPONSE_CANCEL);
3754  #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 3865  void MainWindow::paste_copied_dimrgn() { Line 3948  void MainWindow::paste_copied_dimrgn() {
3948    
3949  void MainWindow::adjust_clipboard_content() {  void MainWindow::adjust_clipboard_content() {
3950      MacroEditor* editor = new MacroEditor();      MacroEditor* editor = new MacroEditor();
3951      editor->setMacro(&m_serializationArchive);      editor->setMacro(&m_serializationArchive, true);
3952      editor->show();      editor->show();
3953  }  }
3954    
# Line 3915  void MainWindow::applyMacro(Serializatio Line 3998  void MainWindow::applyMacro(Serializatio
3998           itDimReg != dimreg_edit.dimregs.end(); ++itDimReg)           itDimReg != dimreg_edit.dimregs.end(); ++itDimReg)
3999      {      {
4000          gig::DimensionRegion* pDimRgn = *itDimReg;          gig::DimensionRegion* pDimRgn = *itDimReg;
4001          dimreg_to_be_changed_signal.emit(pDimRgn);          DimRegionChangeGuard(this, pDimRgn);
4002          m_serializationArchive.deserialize(pDimRgn);          macro.deserialize(pDimRgn);
         dimreg_changed_signal.emit(pDimRgn);  
4003      }      }
4004      //region_changed()      //region_changed()
4005      file_changed();      file_changed();

Legend:
Removed from v.3157  
changed lines
  Added in v.3299

  ViewVC Help
Powered by ViewVC