/[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 3806 by schoenebeck, Thu Aug 13 13:35:33 2020 UTC revision 3814 by schoenebeck, Fri Aug 14 12:29:01 2020 UTC
# Line 1864  void MainWindow::region_changed() Line 1864  void MainWindow::region_changed()
1864    
1865  gig::Instrument* MainWindow::get_instrument()  gig::Instrument* MainWindow::get_instrument()
1866  {  {
1867      gig::Instrument* instrument = 0;      gig::Instrument* instrument = NULL;
1868    
1869        // get indeces of visual selection
1870      std::vector<Gtk::TreeModel::Path> rows = m_TreeViewInstruments.get_selection()->get_selected_rows();      std::vector<Gtk::TreeModel::Path> rows = m_TreeViewInstruments.get_selection()->get_selected_rows();
1871      if (rows.empty()) return NULL;      if (rows.empty()) return NULL;
1872    
1873        // convert index of visual selection (i.e. if filtered) to index of model
1874        Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_path_to_child_path(rows[0]);
1875        if (!path) return NULL;
1876    
1877      //NOTE: was const_iterator before, which did not compile with GTKMM4 development branch, probably going to be fixed before final GTKMM4 release though.      //NOTE: was const_iterator before, which did not compile with GTKMM4 development branch, probably going to be fixed before final GTKMM4 release though.
1878      Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[0]);      Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(path);
1879      if (it) {      if (it) {
1880          Gtk::TreeModel::Row row = *it;          Gtk::TreeModel::Row row = *it;
1881          instrument = row[m_InstrumentsModel.m_col_instr];          instrument = row[m_InstrumentsModel.m_col_instr];
# Line 1938  void MainWindow::on_sel_change() Line 1945  void MainWindow::on_sel_change()
1945      // select item in instrument menu      // select item in instrument menu
1946      std::vector<Gtk::TreeModel::Path> rows = m_TreeViewInstruments.get_selection()->get_selected_rows();      std::vector<Gtk::TreeModel::Path> rows = m_TreeViewInstruments.get_selection()->get_selected_rows();
1947      if (!rows.empty()) {      if (!rows.empty()) {
1948          Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[0]);          // convert index of visual selection (i.e. if filtered) to index of model
1949            Gtk::TreeModel::Path row = m_refInstrumentsModelFilter->convert_path_to_child_path(rows[0]);
1950            Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(row);
1951          if (it) {          if (it) {
1952              Gtk::TreePath path(it);              Gtk::TreePath path(it);
1953              int index = path[0];              int index = path[0];
# Line 3605  bool MainWindow::instr_props_set_instrum Line 3614  bool MainWindow::instr_props_set_instrum
3614  {  {
3615      instrumentProps.signal_name_changed().clear();      instrumentProps.signal_name_changed().clear();
3616    
3617        // get visual selection
3618      std::vector<Gtk::TreeModel::Path> rows = m_TreeViewInstruments.get_selection()->get_selected_rows();      std::vector<Gtk::TreeModel::Path> rows = m_TreeViewInstruments.get_selection()->get_selected_rows();
3619      if (rows.empty()) {      if (rows.empty()) {
3620          instrumentProps.hide();          instrumentProps.hide();
3621          return false;          return false;
3622      }      }
3623    
3624        // convert index of visual selection (i.e. if filtered) to index of model
3625        Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_path_to_child_path(rows[0]);
3626    
3627      //NOTE: was const_iterator before, which did not compile with GTKMM4 development branch, probably going to be fixed before final GTKMM4 release though.      //NOTE: was const_iterator before, which did not compile with GTKMM4 development branch, probably going to be fixed before final GTKMM4 release though.
3628      Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[0]);      Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(path);
3629      if (it) {      if (it) {
3630          Gtk::TreeModel::Row row = *it;          Gtk::TreeModel::Row row = *it;
3631          gig::Instrument* instrument = row[m_InstrumentsModel.m_col_instr];          gig::Instrument* instrument = row[m_InstrumentsModel.m_col_instr];
# Line 3721  void MainWindow::show_midi_rules() Line 3735  void MainWindow::show_midi_rules()
3735    
3736  void MainWindow::show_script_slots() {  void MainWindow::show_script_slots() {
3737      if (!file) return;      if (!file) return;
3738    
3739      // get selected instrument      // get selected instrument
3740      std::vector<Gtk::TreeModel::Path> rows = m_TreeViewInstruments.get_selection()->get_selected_rows();      gig::Instrument* instrument = get_instrument();
     if (rows.empty()) return;  
     Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[0]);  
     if (!it) return;  
     Gtk::TreeModel::Row row = *it;  
     gig::Instrument* instrument = row[m_InstrumentsModel.m_col_instr];  
3741      if (!instrument) return;      if (!instrument) return;
3742    
3743      ScriptSlots* window = new ScriptSlots;      ScriptSlots* window = new ScriptSlots;
# Line 4409  void MainWindow::on_action_duplicate_ins Line 4419  void MainWindow::on_action_duplicate_ins
4419      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection();      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection();
4420      std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();      std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
4421      for (int r = 0; r < rows.size(); ++r) {      for (int r = 0; r < rows.size(); ++r) {
4422          Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[r]);          // convert index of visual selection (i.e. if filtered) to index of model
4423            Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_path_to_child_path(rows[r]);
4424            Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(path);
4425          if (it) {          if (it) {
4426              Gtk::TreeModel::Row row = *it;              Gtk::TreeModel::Row row = *it;
4427              gig::Instrument* instrOrig = row[m_InstrumentsModel.m_col_instr];              gig::Instrument* instrOrig = row[m_InstrumentsModel.m_col_instr];
# Line 4440  void MainWindow::on_action_remove_instru Line 4452  void MainWindow::on_action_remove_instru
4452      }      }
4453    
4454      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection();      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection();
4455      std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();      std::vector<Gtk::TreeModel::Path> rowsVisual = sel->get_selected_rows();
4456    
4457        // convert indeces of visual selection (i.e. if filtered) to indeces of model
4458        std::vector<Gtk::TreeModel::Path> rows;
4459        for (int rv = 0; rv < rowsVisual.size(); ++rv) {
4460            Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_path_to_child_path(rowsVisual[rv]);
4461            if (path)
4462                rows.push_back(path);
4463        }
4464    
4465      for (int r = rows.size() - 1; r >= 0; --r) {      for (int r = rows.size() - 1; r >= 0; --r) {
4466          Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[r]);          Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[r]);
4467          if (!it) continue;          if (!it) continue;
# Line 5135  void MainWindow::on_instruments_treeview Line 5156  void MainWindow::on_instruments_treeview
5156          Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection();          Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection();
5157          std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();          std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
5158          if (!rows.empty()) {          if (!rows.empty()) {
5159              Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[0]);              // convert index of visual selection (i.e. if filtered) to index of model
5160                Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_path_to_child_path(rows[0]);
5161                Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(path);
5162              if (it) {              if (it) {
5163                  Gtk::TreeModel::Row row = *it;                  Gtk::TreeModel::Row row = *it;
5164                  src = row[m_InstrumentsModel.m_col_instr];                  src = row[m_InstrumentsModel.m_col_instr];
# Line 5163  void MainWindow::on_instruments_treeview Line 5186  void MainWindow::on_instruments_treeview
5186          const bool found = m_TreeViewInstruments.get_path_at_pos(x, y, path);          const bool found = m_TreeViewInstruments.get_path_at_pos(x, y, path);
5187          if (!found) return;          if (!found) return;
5188    
5189            // convert index of visual selection (i.e. if filtered) to index of model
5190            path = m_refInstrumentsModelFilter->convert_path_to_child_path(path);
5191            if (!path) return;
5192    
5193          Gtk::TreeModel::iterator iter = m_refInstrumentsTreeModel->get_iter(path);          Gtk::TreeModel::iterator iter = m_refInstrumentsTreeModel->get_iter(path);
5194          if (!iter) return;          if (!iter) return;
5195          Gtk::TreeModel::Row row = *iter;          Gtk::TreeModel::Row row = *iter;
# Line 5415  void MainWindow::on_action_combine_instr Line 5442  void MainWindow::on_action_combine_instr
5442          Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection();          Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection();
5443          std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();          std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
5444          for (int r = 0; r < rows.size(); ++r) {          for (int r = 0; r < rows.size(); ++r) {
5445              Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[r]);              // convert index of visual selection (i.e. if filtered) to index of model
5446                Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_path_to_child_path(rows[r]);
5447                Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(path);
5448              if (it) {              if (it) {
5449                  Gtk::TreeModel::Row row = *it;                  Gtk::TreeModel::Row row = *it;
5450                  int index = row[m_InstrumentsModel.m_col_nr];                  int index = row[m_InstrumentsModel.m_col_nr];

Legend:
Removed from v.3806  
changed lines
  Added in v.3814

  ViewVC Help
Powered by ViewVC