/[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 2994 by schoenebeck, Sat Sep 24 23:34:37 2016 UTC
# 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 789  void MainWindow::dimreg_changed() Line 793  void MainWindow::dimreg_changed()
793  void MainWindow::on_sel_change()  void MainWindow::on_sel_change()
794  {  {
795      // select item in instrument menu      // select item in instrument menu
796      Gtk::TreeModel::iterator it = m_TreeView.get_selection()->get_selected();      std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows();
797      if (it) {      if (!rows.empty()) {
798          Gtk::TreePath path(it);          Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]);
799          int index = path[0];          if (it) {
800          const std::vector<Gtk::Widget*> children =              Gtk::TreePath path(it);
801              instrument_menu->get_children();              int index = path[0];
802          static_cast<Gtk::RadioMenuItem*>(children[index])->set_active();              const std::vector<Gtk::Widget*> children =
803                    instrument_menu->get_children();
804                static_cast<Gtk::RadioMenuItem*>(children[index])->set_active();
805            }
806      }      }
807    
808      m_RegionChooser.set_instrument(get_instrument());      m_RegionChooser.set_instrument(get_instrument());
# Line 1807  void MainWindow::load_gig(gig::File* gig Line 1814  void MainWindow::load_gig(gig::File* gig
1814      propDialog.set_info(gig->pInfo);      propDialog.set_info(gig->pInfo);
1815    
1816      instrument_name_connection.block();      instrument_name_connection.block();
1817        int index = 0;
1818      for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ;      for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ;
1819           instrument = gig->GetNextInstrument()) {           instrument = gig->GetNextInstrument(), ++index) {
1820          Glib::ustring name(gig_to_utf8(instrument->pInfo->Name));          Glib::ustring name(gig_to_utf8(instrument->pInfo->Name));
1821    
1822          Gtk::TreeModel::iterator iter = m_refTreeModel->append();          Gtk::TreeModel::iterator iter = m_refTreeModel->append();
1823          Gtk::TreeModel::Row row = *iter;          Gtk::TreeModel::Row row = *iter;
1824            row[m_Columns.m_col_nr] = index;
1825          row[m_Columns.m_col_name] = name;          row[m_Columns.m_col_name] = name;
1826          row[m_Columns.m_col_instr] = instrument;          row[m_Columns.m_col_instr] = instrument;
1827    
# Line 1885  bool MainWindow::instr_props_set_instrum Line 1894  bool MainWindow::instr_props_set_instrum
1894  {  {
1895      instrumentProps.signal_name_changed().clear();      instrumentProps.signal_name_changed().clear();
1896    
1897      Gtk::TreeModel::const_iterator it =      std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows();
1898          m_TreeView.get_selection()->get_selected();      if (rows.empty()) {
1899            instrumentProps.hide();
1900            return false;
1901        }
1902        Gtk::TreeModel::const_iterator it = m_refTreeModel->get_iter(rows[0]);
1903      if (it) {      if (it) {
1904          Gtk::TreeModel::Row row = *it;          Gtk::TreeModel::Row row = *it;
1905          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 1952  void MainWindow::show_midi_rules()
1952  void MainWindow::show_script_slots() {  void MainWindow::show_script_slots() {
1953      if (!file) return;      if (!file) return;
1954      // get selected instrument      // get selected instrument
1955      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection();      std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows();
1956      Gtk::TreeModel::iterator it = sel->get_selected();      if (rows.empty()) return;
1957        Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]);
1958      if (!it) return;      if (!it) return;
1959      Gtk::TreeModel::Row row = *it;      Gtk::TreeModel::Row row = *it;
1960      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 2074  void MainWindow::select_instrument(gig::
2074          if (row[m_Columns.m_col_instr] == instrument) {          if (row[m_Columns.m_col_instr] == instrument) {
2075              // select and show the respective instrument in the list view              // select and show the respective instrument in the list view
2076              show_intruments_tab();              show_intruments_tab();
2077                m_TreeView.get_selection()->unselect_all();
2078              m_TreeView.get_selection()->select(model->children()[i]);              m_TreeView.get_selection()->select(model->children()[i]);
2079              Gtk::TreePath path(              std::vector<Gtk::TreeModel::Path> rows =
2080                  m_TreeView.get_selection()->get_selected()                  m_TreeView.get_selection()->get_selected_rows();
2081              );              if (!rows.empty())
2082              m_TreeView.scroll_to_row(path);                  m_TreeView.scroll_to_row(rows[0]);
2083              on_sel_change(); // the regular instrument selection change callback              on_sel_change(); // the regular instrument selection change callback
2084          }          }
2085      }      }
# Line 2081  bool MainWindow::select_dimension_region Line 2096  bool MainWindow::select_dimension_region
2096          if (row[m_Columns.m_col_instr] == pInstrument) {          if (row[m_Columns.m_col_instr] == pInstrument) {
2097              // select and show the respective instrument in the list view              // select and show the respective instrument in the list view
2098              show_intruments_tab();              show_intruments_tab();
2099                m_TreeView.get_selection()->unselect_all();
2100              m_TreeView.get_selection()->select(model->children()[i]);              m_TreeView.get_selection()->select(model->children()[i]);
2101              Gtk::TreePath path(              std::vector<Gtk::TreeModel::Path> rows =
2102                  m_TreeView.get_selection()->get_selected()                  m_TreeView.get_selection()->get_selected_rows();
2103              );              if (!rows.empty())
2104              m_TreeView.scroll_to_row(path);                  m_TreeView.scroll_to_row(rows[0]);
2105              on_sel_change(); // the regular instrument selection change callback              on_sel_change(); // the regular instrument selection change callback
2106    
2107              // select respective region in the region selector              // select respective region in the region selector
# Line 2111  void MainWindow::select_sample(gig::Samp Line 2127  void MainWindow::select_sample(gig::Samp
2127              Gtk::TreeModel::Row rowSample = rowGroup.children()[s];              Gtk::TreeModel::Row rowSample = rowGroup.children()[s];
2128              if (rowSample[m_SamplesModel.m_col_sample] == sample) {              if (rowSample[m_SamplesModel.m_col_sample] == sample) {
2129                  show_samples_tab();                  show_samples_tab();
2130                    m_TreeViewSamples.get_selection()->unselect_all();
2131                  m_TreeViewSamples.get_selection()->select(rowGroup.children()[s]);                  m_TreeViewSamples.get_selection()->select(rowGroup.children()[s]);
2132                  Gtk::TreePath path(                  std::vector<Gtk::TreeModel::Path> rows =
2133                      m_TreeViewSamples.get_selection()->get_selected()                      m_TreeViewSamples.get_selection()->get_selected_rows();
2134                  );                  if (rows.empty()) return;
2135                  m_TreeViewSamples.scroll_to_row(path);                  m_TreeViewSamples.scroll_to_row(rows[0]);
2136                  return;                  return;
2137              }              }
2138          }          }
# Line 2124  void MainWindow::select_sample(gig::Samp Line 2141  void MainWindow::select_sample(gig::Samp
2141    
2142  void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) {  void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) {
2143      if (button->type == GDK_BUTTON_PRESS && button->button == 3) {      if (button->type == GDK_BUTTON_PRESS && button->button == 3) {
2144            // by default if Ctrl keys is pressed down, then a mouse right-click
2145            // does not select the respective row, so we must assure this
2146            // programmatically ...
2147            /*{
2148                Gtk::TreeModel::Path path;
2149                Gtk::TreeViewColumn* pColumn = NULL;
2150                int cellX, cellY;
2151                bool bSuccess = m_TreeViewSamples.get_path_at_pos(
2152                    (int)button->x, (int)button->y,
2153                    path, pColumn, cellX, cellY
2154                );
2155                if (bSuccess) {
2156                    if (m_TreeViewSamples.get_selection()->count_selected_rows() <= 0) {
2157                        printf("not selected !!!\n");
2158                        m_TreeViewSamples.get_selection()->select(path);
2159                    }
2160                }
2161            }*/
2162    
2163          Gtk::Menu* sample_popup =          Gtk::Menu* sample_popup =
2164              dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/SamplePopupMenu"));              dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/SamplePopupMenu"));
2165          // update enabled/disabled state of sample popup items          // update enabled/disabled state of sample popup items
2166          Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();          Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();
2167          Gtk::TreeModel::iterator it = sel->get_selected();          std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
2168          bool group_selected  = false;          const int n = rows.size();
2169          bool sample_selected = false;          int nGroups  = 0;
2170          if (it) {          int nSamples = 0;
2171            for (int r = 0; r < n; ++r) {
2172                Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[r]);
2173                if (!it) continue;
2174              Gtk::TreeModel::Row row = *it;              Gtk::TreeModel::Row row = *it;
2175              group_selected  = row[m_SamplesModel.m_col_group];              if (row[m_SamplesModel.m_col_group]) nGroups++;
2176              sample_selected = row[m_SamplesModel.m_col_sample];              if (row[m_SamplesModel.m_col_sample]) nSamples++;
2177          }          }
2178            
               
2179          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))->
2180              set_sensitive(group_selected || sample_selected);              set_sensitive(n == 1);
2181          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))->
2182              set_sensitive(group_selected || sample_selected);              set_sensitive(n);
2183          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddGroup"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddGroup"))->
2184              set_sensitive(file);              set_sensitive(file);
2185          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/ShowSampleRefs"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/ShowSampleRefs"))->
2186              set_sensitive(sample_selected);              set_sensitive(nSamples == 1);
2187          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))->
2188              set_sensitive(group_selected || sample_selected);              set_sensitive(n);
2189          // show sample popup          // show sample popup
2190          sample_popup->popup(button->button, button->time);          sample_popup->popup(button->button, button->time);
2191    
2192          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/SampleProperties"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/SampleProperties"))->
2193              set_sensitive(group_selected || sample_selected);              set_sensitive(n == 1);
2194          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddSample"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddSample"))->
2195              set_sensitive(group_selected || sample_selected);              set_sensitive(n);
2196          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddGroup"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddGroup"))->
2197              set_sensitive(file);              set_sensitive(file);
2198          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/ShowSampleRefs"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/ShowSampleRefs"))->
2199              set_sensitive(sample_selected);              set_sensitive(nSamples == 1);
2200          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/RemoveSample"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/RemoveSample"))->
2201              set_sensitive(group_selected || sample_selected);              set_sensitive(n);
2202      }      }
2203  }  }
2204    
# Line 2239  void MainWindow::add_instrument(gig::Ins Line 2277  void MainWindow::add_instrument(gig::Ins
2277      instrument_name_connection.block();      instrument_name_connection.block();
2278      Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append();      Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append();
2279      Gtk::TreeModel::Row rowInstr = *iterInstr;      Gtk::TreeModel::Row rowInstr = *iterInstr;
2280        rowInstr[m_Columns.m_col_nr] = m_refTreeModel->children().size() - 1;
2281      rowInstr[m_Columns.m_col_name] = name;      rowInstr[m_Columns.m_col_name] = name;
2282      rowInstr[m_Columns.m_col_instr] = instrument;      rowInstr[m_Columns.m_col_instr] = instrument;
2283      instrument_name_connection.unblock();      instrument_name_connection.unblock();
# Line 2267  void MainWindow::on_action_duplicate_ins Line 2306  void MainWindow::on_action_duplicate_ins
2306      // retrieve the currently selected instrument      // retrieve the currently selected instrument
2307      // (being the original instrument to be duplicated)      // (being the original instrument to be duplicated)
2308      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection();      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection();
2309      Gtk::TreeModel::iterator itSelection = sel->get_selected();      std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
2310      if (!itSelection) return;      for (int r = 0; r < rows.size(); ++r) {
2311      Gtk::TreeModel::Row row = *itSelection;          Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]);
2312      gig::Instrument* instrOrig = row[m_Columns.m_col_instr];          if (it) {
2313      if (!instrOrig) return;              Gtk::TreeModel::Row row = *it;
2314                gig::Instrument* instrOrig = row[m_Columns.m_col_instr];
2315      // duplicate the orginal instrument              if (instrOrig) {
2316      gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig);                  // duplicate the orginal instrument
2317      instrNew->pInfo->Name =                  gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig);
2318          instrOrig->pInfo->Name +                  instrNew->pInfo->Name =
2319          gig_from_utf8(Glib::ustring(" (") + _("Copy") + ")");                      instrOrig->pInfo->Name +
2320                        gig_from_utf8(Glib::ustring(" (") + _("Copy") + ")");
2321    
2322      add_instrument(instrNew);                  add_instrument(instrNew);
2323                }
2324            }
2325        }
2326  }  }
2327    
2328  void MainWindow::on_action_remove_instrument() {  void MainWindow::on_action_remove_instrument() {
# Line 2296  void MainWindow::on_action_remove_instru Line 2339  void MainWindow::on_action_remove_instru
2339      }      }
2340    
2341      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection();      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection();
2342      Gtk::TreeModel::iterator it = sel->get_selected();      std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
2343      if (it) {      for (int r = rows.size() - 1; r >= 0; --r) {
2344            Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]);
2345            if (!it) continue;
2346          Gtk::TreeModel::Row row = *it;          Gtk::TreeModel::Row row = *it;
2347          gig::Instrument* instr = row[m_Columns.m_col_instr];          gig::Instrument* instr = row[m_Columns.m_col_instr];
2348          try {          try {
# Line 2312  void MainWindow::on_action_remove_instru Line 2357  void MainWindow::on_action_remove_instru
2357    
2358              // remove row from instruments tree view              // remove row from instruments tree view
2359              m_refTreeModel->erase(it);              m_refTreeModel->erase(it);
2360                // update "Nr" column of all instrument rows
2361                {
2362                    int index = 0;
2363                    for (Gtk::TreeModel::iterator it = m_refTreeModel->children().begin();
2364                         it != m_refTreeModel->children().end(); ++it, ++index)
2365                    {
2366                        Gtk::TreeModel::Row row = *it;
2367                        row[m_Columns.m_col_nr] = index;
2368                    }
2369                }
2370    
2371  #if GTKMM_MAJOR_VERSION < 3  #if GTKMM_MAJOR_VERSION < 3
2372              // 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 2548  void MainWindow::add_or_replace_sample(b
2548    
2549      // get selected group (and probably selected sample)      // get selected group (and probably selected sample)
2550      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();
2551      Gtk::TreeModel::iterator it = sel->get_selected();      std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
2552        if (rows.empty()) return;
2553        Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]);
2554      if (!it) return;      if (!it) return;
2555      Gtk::TreeModel::Row row = *it;      Gtk::TreeModel::Row row = *it;
2556      gig::Sample* sample = NULL;      gig::Sample* sample = NULL;
# Line 2776  void MainWindow::on_action_replace_all_s Line 2833  void MainWindow::on_action_replace_all_s
2833  void MainWindow::on_action_remove_sample() {  void MainWindow::on_action_remove_sample() {
2834      if (!file) return;      if (!file) return;
2835      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();
2836      Gtk::TreeModel::iterator it = sel->get_selected();      std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
2837      if (it) {      for (int r = rows.size() - 1; r >= 0; --r) {
2838            Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[r]);
2839            if (!it) continue;
2840          Gtk::TreeModel::Row row = *it;          Gtk::TreeModel::Row row = *it;
2841          gig::Group* group   = row[m_SamplesModel.m_col_group];          gig::Group* group   = row[m_SamplesModel.m_col_group];
2842          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 3015  void MainWindow::on_instruments_treeview
3015      gig::Instrument* src = NULL;      gig::Instrument* src = NULL;
3016      {      {
3017          Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection();          Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection();
3018          Gtk::TreeModel::iterator it = sel->get_selected();          std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
3019          if (it) {          if (!rows.empty()) {
3020              Gtk::TreeModel::Row row = *it;              Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]);
3021              src = row[m_Columns.m_col_instr];              if (it) {
3022                    Gtk::TreeModel::Row row = *it;
3023                    src = row[m_Columns.m_col_instr];
3024                }
3025          }          }
3026      }      }
3027      if (!src) return;      if (!src) return;
# Line 3014  void MainWindow::on_sample_treeview_drag Line 3076  void MainWindow::on_sample_treeview_drag
3076      // get selected sample      // get selected sample
3077      gig::Sample* sample = NULL;      gig::Sample* sample = NULL;
3078      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();
3079      Gtk::TreeModel::iterator it = sel->get_selected();      std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
3080      if (it) {      if (!rows.empty()) {
3081          Gtk::TreeModel::Row row = *it;          Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]);
3082          sample = row[m_SamplesModel.m_col_sample];          if (it) {
3083                Gtk::TreeModel::Row row = *it;
3084                sample = row[m_SamplesModel.m_col_sample];
3085            }
3086      }      }
3087      // pass the gig::Sample as pointer      // pass the gig::Sample as pointer
3088      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 3281  void MainWindow::on_action_combine_instr
3281    
3282  void MainWindow::on_action_view_references() {  void MainWindow::on_action_view_references() {
3283      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();
3284      Gtk::TreeModel::iterator it = sel->get_selected();      std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
3285        if (rows.empty()) return;
3286        Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]);
3287      if (!it) return;      if (!it) return;
3288      Gtk::TreeModel::Row row = *it;      Gtk::TreeModel::Row row = *it;
3289      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.2994

  ViewVC Help
Powered by ViewVC