/[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 2968 by schoenebeck, Mon Jul 18 11:25:13 2016 UTC revision 3089 by schoenebeck, Sun Jan 15 19:18:39 2017 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (C) 2006-2016 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 521  MainWindow::MainWindow() : Line 521  MainWindow::MainWindow() :
521      // Create the Tree model:      // Create the Tree model:
522      m_refTreeModel = Gtk::ListStore::create(m_Columns);      m_refTreeModel = Gtk::ListStore::create(m_Columns);
523      m_TreeView.set_model(m_refTreeModel);      m_TreeView.set_model(m_refTreeModel);
524        m_TreeView.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
525      m_TreeView.set_tooltip_text(_("Right click here for actions on instruments & MIDI Rules. Drag & drop to change the order of instruments."));      m_TreeView.set_tooltip_text(_("Right click here for actions on instruments & MIDI Rules. Drag & drop to change the order of instruments."));
526      instrument_name_connection = m_refTreeModel->signal_row_changed().connect(      instrument_name_connection = m_refTreeModel->signal_row_changed().connect(
527          sigc::mem_fun(*this, &MainWindow::instrument_name_changed)          sigc::mem_fun(*this, &MainWindow::instrument_name_changed)
528      );      );
529    
530      // Add the TreeView's view columns:      // Add the TreeView's view columns:
531      m_TreeView.append_column_editable("Instrument", m_Columns.m_col_name);      m_TreeView.append_column(_("Nr"), m_Columns.m_col_nr);
532      m_TreeView.set_headers_visible(false);      m_TreeView.append_column_editable(_("Instrument"), m_Columns.m_col_name);
533        m_TreeView.set_headers_visible(true);
534            
535      // establish drag&drop within the instrument tree view, allowing to reorder      // establish drag&drop within the instrument tree view, allowing to reorder
536      // the sequence of instruments within the gig file      // the sequence of instruments within the gig file
# Line 551  MainWindow::MainWindow() : Line 553  MainWindow::MainWindow() :
553      // create samples treeview (including its data model)      // create samples treeview (including its data model)
554      m_refSamplesTreeModel = SamplesTreeStore::create(m_SamplesModel);      m_refSamplesTreeModel = SamplesTreeStore::create(m_SamplesModel);
555      m_TreeViewSamples.set_model(m_refSamplesTreeModel);      m_TreeViewSamples.set_model(m_refSamplesTreeModel);
556        m_TreeViewSamples.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
557      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."));
558      // m_TreeViewSamples.set_reorderable();      // m_TreeViewSamples.set_reorderable();
559      m_TreeViewSamples.append_column_editable(_("Name"), m_SamplesModel.m_col_name);      m_TreeViewSamples.append_column_editable(_("Name"), m_SamplesModel.m_col_name);
# Line 728  void MainWindow::region_changed() Line 731  void MainWindow::region_changed()
731  gig::Instrument* MainWindow::get_instrument()  gig::Instrument* MainWindow::get_instrument()
732  {  {
733      gig::Instrument* instrument = 0;      gig::Instrument* instrument = 0;
734      Gtk::TreeModel::const_iterator it =      std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows();
735          m_TreeView.get_selection()->get_selected();      if (rows.empty()) return NULL;
736        Gtk::TreeModel::const_iterator it = m_refTreeModel->get_iter(rows[0]);
737      if (it) {      if (it) {
738          Gtk::TreeModel::Row row = *it;          Gtk::TreeModel::Row row = *it;
739          instrument = row[m_Columns.m_col_instr];          instrument = row[m_Columns.m_col_instr];
# Line 772  void MainWindow::update_dimregs() Line 776  void MainWindow::update_dimregs()
776              add_region_to_dimregs(region, stereo, all_dimregs);              add_region_to_dimregs(region, stereo, all_dimregs);
777          }          }
778      }      }
779    
780        m_DimRegionChooser.setModifyAllRegions(all_regions);
781        m_DimRegionChooser.setModifyAllDimensionRegions(all_dimregs);
782        m_DimRegionChooser.setModifyBothChannels(stereo);
783  }  }
784    
785  void MainWindow::dimreg_all_dimregs_toggled()  void MainWindow::dimreg_all_dimregs_toggled()
# Line 789  void MainWindow::dimreg_changed() Line 797  void MainWindow::dimreg_changed()
797  void MainWindow::on_sel_change()  void MainWindow::on_sel_change()
798  {  {
799      // select item in instrument menu      // select item in instrument menu
800      Gtk::TreeModel::iterator it = m_TreeView.get_selection()->get_selected();      std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows();
801      if (it) {      if (!rows.empty()) {
802          Gtk::TreePath path(it);          Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]);
803          int index = path[0];          if (it) {
804          const std::vector<Gtk::Widget*> children =              Gtk::TreePath path(it);
805              instrument_menu->get_children();              int index = path[0];
806          static_cast<Gtk::RadioMenuItem*>(children[index])->set_active();              const std::vector<Gtk::Widget*> children =
807                    instrument_menu->get_children();
808                static_cast<Gtk::RadioMenuItem*>(children[index])->set_active();
809            }
810      }      }
811    
812      m_RegionChooser.set_instrument(get_instrument());      m_RegionChooser.set_instrument(get_instrument());
# Line 820  void Loader::progress_callback(float fra Line 831  void Loader::progress_callback(float fra
831      progress_dispatcher();      progress_dispatcher();
832  }  }
833    
834    #if defined(WIN32) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2))
835    // make sure stack is 16-byte aligned for SSE instructions
836    __attribute__((force_align_arg_pointer))
837    #endif
838  void Loader::thread_function()  void Loader::thread_function()
839  {  {
840      printf("thread_function self=%p\n",      printf("thread_function self=%p\n",
# Line 899  void Saver::progress_callback(float frac Line 914  void Saver::progress_callback(float frac
914      progress_dispatcher.emit();      progress_dispatcher.emit();
915  }  }
916    
917    #if defined(WIN32) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2))
918    // make sure stack is 16-byte aligned for SSE instructions
919    __attribute__((force_align_arg_pointer))
920    #endif
921  void Saver::thread_function()  void Saver::thread_function()
922  {  {
923      printf("thread_function self=%p\n",      printf("thread_function self=%p\n",
# Line 1512  void MainWindow::on_action_help_about() Line 1531  void MainWindow::on_action_help_about()
1531      dialog.set_name("Gigedit");      dialog.set_name("Gigedit");
1532  #endif  #endif
1533      dialog.set_version(VERSION);      dialog.set_version(VERSION);
1534      dialog.set_copyright("Copyright (C) 2006-2016 Andreas Persson");      dialog.set_copyright("Copyright (C) 2006-2017 Andreas Persson");
1535      const std::string sComment =      const std::string sComment =
1536          _("Built " __DATE__ "\nUsing ") +          _("Built " __DATE__ "\nUsing ") +
1537          ::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" +          ::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" +
# Line 1807  void MainWindow::load_gig(gig::File* gig Line 1826  void MainWindow::load_gig(gig::File* gig
1826      propDialog.set_info(gig->pInfo);      propDialog.set_info(gig->pInfo);
1827    
1828      instrument_name_connection.block();      instrument_name_connection.block();
1829        int index = 0;
1830      for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ;      for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ;
1831           instrument = gig->GetNextInstrument()) {           instrument = gig->GetNextInstrument(), ++index) {
1832          Glib::ustring name(gig_to_utf8(instrument->pInfo->Name));          Glib::ustring name(gig_to_utf8(instrument->pInfo->Name));
1833    
1834          Gtk::TreeModel::iterator iter = m_refTreeModel->append();          Gtk::TreeModel::iterator iter = m_refTreeModel->append();
1835          Gtk::TreeModel::Row row = *iter;          Gtk::TreeModel::Row row = *iter;
1836            row[m_Columns.m_col_nr] = index;
1837          row[m_Columns.m_col_name] = name;          row[m_Columns.m_col_name] = name;
1838          row[m_Columns.m_col_instr] = instrument;          row[m_Columns.m_col_instr] = instrument;
1839    
# Line 1885  bool MainWindow::instr_props_set_instrum Line 1906  bool MainWindow::instr_props_set_instrum
1906  {  {
1907      instrumentProps.signal_name_changed().clear();      instrumentProps.signal_name_changed().clear();
1908    
1909      Gtk::TreeModel::const_iterator it =      std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows();
1910          m_TreeView.get_selection()->get_selected();      if (rows.empty()) {
1911            instrumentProps.hide();
1912            return false;
1913        }
1914        Gtk::TreeModel::const_iterator it = m_refTreeModel->get_iter(rows[0]);
1915      if (it) {      if (it) {
1916          Gtk::TreeModel::Row row = *it;          Gtk::TreeModel::Row row = *it;
1917          gig::Instrument* instrument = row[m_Columns.m_col_instr];          gig::Instrument* instrument = row[m_Columns.m_col_instr];
# Line 1939  void MainWindow::show_midi_rules() Line 1964  void MainWindow::show_midi_rules()
1964  void MainWindow::show_script_slots() {  void MainWindow::show_script_slots() {
1965      if (!file) return;      if (!file) return;
1966      // get selected instrument      // get selected instrument
1967      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection();      std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows();
1968      Gtk::TreeModel::iterator it = sel->get_selected();      if (rows.empty()) return;
1969        Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]);
1970      if (!it) return;      if (!it) return;
1971      Gtk::TreeModel::Row row = *it;      Gtk::TreeModel::Row row = *it;
1972      gig::Instrument* instrument = row[m_Columns.m_col_instr];      gig::Instrument* instrument = row[m_Columns.m_col_instr];
# Line 2060  void MainWindow::select_instrument(gig:: Line 2086  void MainWindow::select_instrument(gig::
2086          if (row[m_Columns.m_col_instr] == instrument) {          if (row[m_Columns.m_col_instr] == instrument) {
2087              // select and show the respective instrument in the list view              // select and show the respective instrument in the list view
2088              show_intruments_tab();              show_intruments_tab();
2089                m_TreeView.get_selection()->unselect_all();
2090              m_TreeView.get_selection()->select(model->children()[i]);              m_TreeView.get_selection()->select(model->children()[i]);
2091              Gtk::TreePath path(              std::vector<Gtk::TreeModel::Path> rows =
2092                  m_TreeView.get_selection()->get_selected()                  m_TreeView.get_selection()->get_selected_rows();
2093              );              if (!rows.empty())
2094              m_TreeView.scroll_to_row(path);                  m_TreeView.scroll_to_row(rows[0]);
2095              on_sel_change(); // the regular instrument selection change callback              on_sel_change(); // the regular instrument selection change callback
2096          }          }
2097      }      }
# Line 2081  bool MainWindow::select_dimension_region Line 2108  bool MainWindow::select_dimension_region
2108          if (row[m_Columns.m_col_instr] == pInstrument) {          if (row[m_Columns.m_col_instr] == pInstrument) {
2109              // select and show the respective instrument in the list view              // select and show the respective instrument in the list view
2110              show_intruments_tab();              show_intruments_tab();
2111                m_TreeView.get_selection()->unselect_all();
2112              m_TreeView.get_selection()->select(model->children()[i]);              m_TreeView.get_selection()->select(model->children()[i]);
2113              Gtk::TreePath path(              std::vector<Gtk::TreeModel::Path> rows =
2114                  m_TreeView.get_selection()->get_selected()                  m_TreeView.get_selection()->get_selected_rows();
2115              );              if (!rows.empty())
2116              m_TreeView.scroll_to_row(path);                  m_TreeView.scroll_to_row(rows[0]);
2117              on_sel_change(); // the regular instrument selection change callback              on_sel_change(); // the regular instrument selection change callback
2118    
2119              // select respective region in the region selector              // select respective region in the region selector
# Line 2111  void MainWindow::select_sample(gig::Samp Line 2139  void MainWindow::select_sample(gig::Samp
2139              Gtk::TreeModel::Row rowSample = rowGroup.children()[s];              Gtk::TreeModel::Row rowSample = rowGroup.children()[s];
2140              if (rowSample[m_SamplesModel.m_col_sample] == sample) {              if (rowSample[m_SamplesModel.m_col_sample] == sample) {
2141                  show_samples_tab();                  show_samples_tab();
2142                    m_TreeViewSamples.get_selection()->unselect_all();
2143                  m_TreeViewSamples.get_selection()->select(rowGroup.children()[s]);                  m_TreeViewSamples.get_selection()->select(rowGroup.children()[s]);
2144                  Gtk::TreePath path(                  std::vector<Gtk::TreeModel::Path> rows =
2145                      m_TreeViewSamples.get_selection()->get_selected()                      m_TreeViewSamples.get_selection()->get_selected_rows();
2146                  );                  if (rows.empty()) return;
2147                  m_TreeViewSamples.scroll_to_row(path);                  m_TreeViewSamples.scroll_to_row(rows[0]);
2148                  return;                  return;
2149              }              }
2150          }          }
# Line 2124  void MainWindow::select_sample(gig::Samp Line 2153  void MainWindow::select_sample(gig::Samp
2153    
2154  void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) {  void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) {
2155      if (button->type == GDK_BUTTON_PRESS && button->button == 3) {      if (button->type == GDK_BUTTON_PRESS && button->button == 3) {
2156            // by default if Ctrl keys is pressed down, then a mouse right-click
2157            // does not select the respective row, so we must assure this
2158            // programmatically ...
2159            /*{
2160                Gtk::TreeModel::Path path;
2161                Gtk::TreeViewColumn* pColumn = NULL;
2162                int cellX, cellY;
2163                bool bSuccess = m_TreeViewSamples.get_path_at_pos(
2164                    (int)button->x, (int)button->y,
2165                    path, pColumn, cellX, cellY
2166                );
2167                if (bSuccess) {
2168                    if (m_TreeViewSamples.get_selection()->count_selected_rows() <= 0) {
2169                        printf("not selected !!!\n");
2170                        m_TreeViewSamples.get_selection()->select(path);
2171                    }
2172                }
2173            }*/
2174    
2175          Gtk::Menu* sample_popup =          Gtk::Menu* sample_popup =
2176              dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/SamplePopupMenu"));              dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/SamplePopupMenu"));
2177          // update enabled/disabled state of sample popup items          // update enabled/disabled state of sample popup items
2178          Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();          Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();
2179          Gtk::TreeModel::iterator it = sel->get_selected();          std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
2180          bool group_selected  = false;          const int n = rows.size();
2181          bool sample_selected = false;          int nGroups  = 0;
2182          if (it) {          int nSamples = 0;
2183            for (int r = 0; r < n; ++r) {
2184                Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[r]);
2185                if (!it) continue;
2186              Gtk::TreeModel::Row row = *it;              Gtk::TreeModel::Row row = *it;
2187              group_selected  = row[m_SamplesModel.m_col_group];              if (row[m_SamplesModel.m_col_group]) nGroups++;
2188              sample_selected = row[m_SamplesModel.m_col_sample];              if (row[m_SamplesModel.m_col_sample]) nSamples++;
2189          }          }
2190            
               
2191          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))->
2192              set_sensitive(group_selected || sample_selected);              set_sensitive(n == 1);
2193          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))->
2194              set_sensitive(group_selected || sample_selected);              set_sensitive(n);
2195          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddGroup"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddGroup"))->
2196              set_sensitive(file);              set_sensitive(file);
2197          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/ShowSampleRefs"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/ShowSampleRefs"))->
2198              set_sensitive(sample_selected);              set_sensitive(nSamples == 1);
2199          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))->
2200              set_sensitive(group_selected || sample_selected);              set_sensitive(n);
2201          // show sample popup          // show sample popup
2202          sample_popup->popup(button->button, button->time);          sample_popup->popup(button->button, button->time);
2203    
2204          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/SampleProperties"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/SampleProperties"))->
2205              set_sensitive(group_selected || sample_selected);              set_sensitive(n == 1);
2206          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddSample"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddSample"))->
2207              set_sensitive(group_selected || sample_selected);              set_sensitive(n);
2208          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddGroup"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddGroup"))->
2209              set_sensitive(file);              set_sensitive(file);
2210          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/ShowSampleRefs"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/ShowSampleRefs"))->
2211              set_sensitive(sample_selected);              set_sensitive(nSamples == 1);
2212          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/RemoveSample"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/RemoveSample"))->
2213              set_sensitive(group_selected || sample_selected);              set_sensitive(n);
2214      }      }
2215  }  }
2216    
# Line 2239  void MainWindow::add_instrument(gig::Ins Line 2289  void MainWindow::add_instrument(gig::Ins
2289      instrument_name_connection.block();      instrument_name_connection.block();
2290      Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append();      Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append();
2291      Gtk::TreeModel::Row rowInstr = *iterInstr;      Gtk::TreeModel::Row rowInstr = *iterInstr;
2292        rowInstr[m_Columns.m_col_nr] = m_refTreeModel->children().size() - 1;
2293      rowInstr[m_Columns.m_col_name] = name;      rowInstr[m_Columns.m_col_name] = name;
2294      rowInstr[m_Columns.m_col_instr] = instrument;      rowInstr[m_Columns.m_col_instr] = instrument;
2295      instrument_name_connection.unblock();      instrument_name_connection.unblock();
# Line 2267  void MainWindow::on_action_duplicate_ins Line 2318  void MainWindow::on_action_duplicate_ins
2318      // retrieve the currently selected instrument      // retrieve the currently selected instrument
2319      // (being the original instrument to be duplicated)      // (being the original instrument to be duplicated)
2320      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection();      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection();
2321      Gtk::TreeModel::iterator itSelection = sel->get_selected();      std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
2322      if (!itSelection) return;      for (int r = 0; r < rows.size(); ++r) {
2323      Gtk::TreeModel::Row row = *itSelection;          Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]);
2324      gig::Instrument* instrOrig = row[m_Columns.m_col_instr];          if (it) {
2325      if (!instrOrig) return;              Gtk::TreeModel::Row row = *it;
2326                gig::Instrument* instrOrig = row[m_Columns.m_col_instr];
2327      // duplicate the orginal instrument              if (instrOrig) {
2328      gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig);                  // duplicate the orginal instrument
2329      instrNew->pInfo->Name =                  gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig);
2330          instrOrig->pInfo->Name +                  instrNew->pInfo->Name =
2331          gig_from_utf8(Glib::ustring(" (") + _("Copy") + ")");                      instrOrig->pInfo->Name +
2332                        gig_from_utf8(Glib::ustring(" (") + _("Copy") + ")");
2333    
2334      add_instrument(instrNew);                  add_instrument(instrNew);
2335                }
2336            }
2337        }
2338  }  }
2339    
2340  void MainWindow::on_action_remove_instrument() {  void MainWindow::on_action_remove_instrument() {
# Line 2296  void MainWindow::on_action_remove_instru Line 2351  void MainWindow::on_action_remove_instru
2351      }      }
2352    
2353      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection();      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection();
2354      Gtk::TreeModel::iterator it = sel->get_selected();      std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
2355      if (it) {      for (int r = rows.size() - 1; r >= 0; --r) {
2356            Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]);
2357            if (!it) continue;
2358          Gtk::TreeModel::Row row = *it;          Gtk::TreeModel::Row row = *it;
2359          gig::Instrument* instr = row[m_Columns.m_col_instr];          gig::Instrument* instr = row[m_Columns.m_col_instr];
2360          try {          try {
# Line 2312  void MainWindow::on_action_remove_instru Line 2369  void MainWindow::on_action_remove_instru
2369    
2370              // remove row from instruments tree view              // remove row from instruments tree view
2371              m_refTreeModel->erase(it);              m_refTreeModel->erase(it);
2372                // update "Nr" column of all instrument rows
2373                {
2374                    int index = 0;
2375                    for (Gtk::TreeModel::iterator it = m_refTreeModel->children().begin();
2376                         it != m_refTreeModel->children().end(); ++it, ++index)
2377                    {
2378                        Gtk::TreeModel::Row row = *it;
2379                        row[m_Columns.m_col_nr] = index;
2380                    }
2381                }
2382    
2383  #if GTKMM_MAJOR_VERSION < 3  #if GTKMM_MAJOR_VERSION < 3
2384              // select another instrument (in gtk3 this is done              // select another instrument (in gtk3 this is done
# Line 2493  void MainWindow::add_or_replace_sample(b Line 2560  void MainWindow::add_or_replace_sample(b
2560    
2561      // get selected group (and probably selected sample)      // get selected group (and probably selected sample)
2562      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();
2563      Gtk::TreeModel::iterator it = sel->get_selected();      std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
2564        if (rows.empty()) return;
2565        Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]);
2566      if (!it) return;      if (!it) return;
2567      Gtk::TreeModel::Row row = *it;      Gtk::TreeModel::Row row = *it;
2568      gig::Sample* sample = NULL;      gig::Sample* sample = NULL;
# Line 2776  void MainWindow::on_action_replace_all_s Line 2845  void MainWindow::on_action_replace_all_s
2845  void MainWindow::on_action_remove_sample() {  void MainWindow::on_action_remove_sample() {
2846      if (!file) return;      if (!file) return;
2847      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();
2848      Gtk::TreeModel::iterator it = sel->get_selected();      std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
2849      if (it) {      for (int r = rows.size() - 1; r >= 0; --r) {
2850            Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[r]);
2851            if (!it) continue;
2852          Gtk::TreeModel::Row row = *it;          Gtk::TreeModel::Row row = *it;
2853          gig::Group* group   = row[m_SamplesModel.m_col_group];          gig::Group* group   = row[m_SamplesModel.m_col_group];
2854          gig::Sample* sample = row[m_SamplesModel.m_col_sample];          gig::Sample* sample = row[m_SamplesModel.m_col_sample];
# Line 2956  void MainWindow::on_instruments_treeview Line 3027  void MainWindow::on_instruments_treeview
3027      gig::Instrument* src = NULL;      gig::Instrument* src = NULL;
3028      {      {
3029          Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection();          Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection();
3030          Gtk::TreeModel::iterator it = sel->get_selected();          std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
3031          if (it) {          if (!rows.empty()) {
3032              Gtk::TreeModel::Row row = *it;              Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]);
3033              src = row[m_Columns.m_col_instr];              if (it) {
3034                    Gtk::TreeModel::Row row = *it;
3035                    src = row[m_Columns.m_col_instr];
3036                }
3037          }          }
3038      }      }
3039      if (!src) return;      if (!src) return;
# Line 3014  void MainWindow::on_sample_treeview_drag Line 3088  void MainWindow::on_sample_treeview_drag
3088      // get selected sample      // get selected sample
3089      gig::Sample* sample = NULL;      gig::Sample* sample = NULL;
3090      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();
3091      Gtk::TreeModel::iterator it = sel->get_selected();      std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
3092      if (it) {      if (!rows.empty()) {
3093          Gtk::TreeModel::Row row = *it;          Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]);
3094          sample = row[m_SamplesModel.m_col_sample];          if (it) {
3095                Gtk::TreeModel::Row row = *it;
3096                sample = row[m_SamplesModel.m_col_sample];
3097            }
3098      }      }
3099      // pass the gig::Sample as pointer      // pass the gig::Sample as pointer
3100      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 3216  void MainWindow::on_action_combine_instr Line 3293  void MainWindow::on_action_combine_instr
3293    
3294  void MainWindow::on_action_view_references() {  void MainWindow::on_action_view_references() {
3295      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();
3296      Gtk::TreeModel::iterator it = sel->get_selected();      std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
3297        if (rows.empty()) return;
3298        Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]);
3299      if (!it) return;      if (!it) return;
3300      Gtk::TreeModel::Row row = *it;      Gtk::TreeModel::Row row = *it;
3301      gig::Sample* sample = row[m_SamplesModel.m_col_sample];      gig::Sample* sample = row[m_SamplesModel.m_col_sample];

Legend:
Removed from v.2968  
changed lines
  Added in v.3089

  ViewVC Help
Powered by ViewVC