/[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 2627 by schoenebeck, Thu Jun 12 16:12:55 2014 UTC revision 2666 by schoenebeck, Mon Jul 7 15:01:01 2014 UTC
# Line 453  MainWindow::MainWindow() : Line 453  MainWindow::MainWindow() :
453      {      {
454          Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(0);          Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(0);
455          Gtk::CellRendererText* cellrenderer =          Gtk::CellRendererText* cellrenderer =
456              dynamic_cast<Gtk::CellRendererText*>(column->get_first_cell_renderer());              dynamic_cast<Gtk::CellRendererText*>(column->get_first_cell());
457          column->add_attribute(          column->add_attribute(
458              cellrenderer->property_foreground(), m_SamplesModel.m_color              cellrenderer->property_foreground(), m_SamplesModel.m_color
459          );          );
# Line 461  MainWindow::MainWindow() : Line 461  MainWindow::MainWindow() :
461      {      {
462          Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(1);          Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(1);
463          Gtk::CellRendererText* cellrenderer =          Gtk::CellRendererText* cellrenderer =
464              dynamic_cast<Gtk::CellRendererText*>(column->get_first_cell_renderer());              dynamic_cast<Gtk::CellRendererText*>(column->get_first_cell());
465          column->add_attribute(          column->add_attribute(
466              cellrenderer->property_foreground(), m_SamplesModel.m_color              cellrenderer->property_foreground(), m_SamplesModel.m_color
467          );          );
# Line 478  MainWindow::MainWindow() : Line 478  MainWindow::MainWindow() :
478      m_refScriptsTreeModel = ScriptsTreeStore::create(m_ScriptsModel);      m_refScriptsTreeModel = ScriptsTreeStore::create(m_ScriptsModel);
479      m_TreeViewScripts.set_model(m_refScriptsTreeModel);      m_TreeViewScripts.set_model(m_refScriptsTreeModel);
480      m_TreeViewScripts.set_tooltip_text(_(      m_TreeViewScripts.set_tooltip_text(_(
481            "Use CTRL + double click for editing a script."
482            "\n\n"
483          "Note: instrument scripts are a LinuxSampler extension of the gig "          "Note: instrument scripts are a LinuxSampler extension of the gig "
484          "format. This feature will not work with the GigaStudio software!"          "format. This feature will not work with the GigaStudio software!"
485      ));      ));
# Line 487  MainWindow::MainWindow() : Line 489  MainWindow::MainWindow() :
489      m_TreeViewScripts.signal_button_press_event().connect_notify(      m_TreeViewScripts.signal_button_press_event().connect_notify(
490          sigc::mem_fun(*this, &MainWindow::on_script_treeview_button_release)          sigc::mem_fun(*this, &MainWindow::on_script_treeview_button_release)
491      );      );
492        //FIXME: why the heck does this double click signal_row_activated() only fired while CTRL key is pressed ?
493        m_TreeViewScripts.signal_row_activated().connect(
494            sigc::mem_fun(*this, &MainWindow::script_double_clicked)
495        );
496      m_refScriptsTreeModel->signal_row_changed().connect(      m_refScriptsTreeModel->signal_row_changed().connect(
497          sigc::mem_fun(*this, &MainWindow::script_name_changed)          sigc::mem_fun(*this, &MainWindow::script_name_changed)
498      );      );
# Line 896  void MainWindow::load_instrument(gig::In Line 902  void MainWindow::load_instrument(gig::In
902      // load the instrument      // load the instrument
903      gig::File* pFile = (gig::File*) instr->GetParent();      gig::File* pFile = (gig::File*) instr->GetParent();
904      load_gig(pFile, 0 /*file name*/, true /*shared instrument*/);      load_gig(pFile, 0 /*file name*/, true /*shared instrument*/);
905      //TODO: automatically select the given instrument      // automatically select the given instrument
906        int i = 0;
907        for (gig::Instrument* instrument = pFile->GetFirstInstrument(); instrument;
908             instrument = pFile->GetNextInstrument(), ++i)
909        {
910            if (instrument == instr) {
911                // select item in "instruments" tree view
912                m_TreeView.get_selection()->select(Gtk::TreePath(ToString(i)));
913                // make sure the selected item in the "instruments" tree view is
914                // visible (scroll to it)
915                m_TreeView.scroll_to_row(Gtk::TreePath(ToString(i)));
916                // select item in instrument menu
917                {
918                    const std::vector<Gtk::Widget*> children =
919                        instrument_menu->get_children();
920                    static_cast<Gtk::RadioMenuItem*>(children[i])->set_active();
921                }
922                // update region chooser and dimension region chooser
923                m_RegionChooser.set_instrument(instr);
924                break;
925            }
926        }
927  }  }
928    
929  void MainWindow::on_loader_progress()  void MainWindow::on_loader_progress()
# Line 2564  void MainWindow::script_name_changed(con Line 2591  void MainWindow::script_name_changed(con
2591      }      }
2592  }  }
2593    
2594    void MainWindow::script_double_clicked(const Gtk::TreeModel::Path& path,
2595                                           Gtk::TreeViewColumn* column)
2596    {
2597        Gtk::TreeModel::iterator iter = m_refScriptsTreeModel->get_iter(path);
2598        if (!iter) return;
2599        Gtk::TreeModel::Row row = *iter;
2600        gig::Script* script = row[m_ScriptsModel.m_col_script];
2601        if (!script) return;
2602    
2603        ScriptEditor* editor = new ScriptEditor;
2604        editor->setScript(script);
2605        //editor->reparent(*this);
2606        editor->show();
2607    }
2608    
2609  void MainWindow::instrument_name_changed(const Gtk::TreeModel::Path& path,  void MainWindow::instrument_name_changed(const Gtk::TreeModel::Path& path,
2610                                           const Gtk::TreeModel::iterator& iter) {                                           const Gtk::TreeModel::iterator& iter) {
2611      if (!iter) return;      if (!iter) return;
# Line 2812  void MainWindow::on_samples_to_be_remove Line 2854  void MainWindow::on_samples_to_be_remove
2854      // just in case a new sample is added later with exactly the same memory      // just in case a new sample is added later with exactly the same memory
2855      // address, which would lead to incorrect refcount if not deleted here      // address, which would lead to incorrect refcount if not deleted here
2856      for (std::list<gig::Sample*>::const_iterator it = samples.begin();      for (std::list<gig::Sample*>::const_iterator it = samples.begin();
2857           it != samples.end(); it != samples.end())           it != samples.end(); ++it)
2858      {      {
2859          sample_ref_count.erase(*it);          sample_ref_count.erase(*it);
2860      }      }

Legend:
Removed from v.2627  
changed lines
  Added in v.2666

  ViewVC Help
Powered by ViewVC