/[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 2610 by schoenebeck, Sun Jun 8 19:09:26 2014 UTC revision 2666 by schoenebeck, Mon Jul 7 15:01:01 2014 UTC
# Line 47  Line 47 
47  #include "CombineInstrumentsDialog.h"  #include "CombineInstrumentsDialog.h"
48  #include "scripteditor.h"  #include "scripteditor.h"
49  #include "scriptslots.h"  #include "scriptslots.h"
50    #include "ReferencesView.h"
51  #include "../../gfx/status_attached.xpm"  #include "../../gfx/status_attached.xpm"
52  #include "../../gfx/status_detached.xpm"  #include "../../gfx/status_detached.xpm"
53    
54    
55  MainWindow::MainWindow() :  MainWindow::MainWindow() :
56        m_DimRegionChooser(*this),
57      dimreg_label(_("Changes apply to:")),      dimreg_label(_("Changes apply to:")),
58      dimreg_all_regions(_("all regions")),      dimreg_all_regions(_("all regions")),
59      dimreg_all_dimregs(_("all dimension splits")),      dimreg_all_dimregs(_("all dimension splits")),
# Line 145  MainWindow::MainWindow() : Line 147  MainWindow::MainWindow() :
147      actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT),      actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT),
148                       sigc::mem_fun(                       sigc::mem_fun(
149                           *this, &MainWindow::on_action_quit));                           *this, &MainWindow::on_action_quit));
150      actionGroup->add(Gtk::Action::create("MenuInstrument", _("_Instrument")));      actionGroup->add(
151            Gtk::Action::create("MenuSample", _("_Sample")),
152            sigc::mem_fun(*this, &MainWindow::show_samples_tab)
153        );
154        actionGroup->add(
155            Gtk::Action::create("MenuInstrument", _("_Instrument")),
156            sigc::mem_fun(*this, &MainWindow::show_intruments_tab)
157        );
158        actionGroup->add(
159            Gtk::Action::create("MenuScript", _("S_cript")),
160            sigc::mem_fun(*this, &MainWindow::show_scripts_tab)
161        );
162        actionGroup->add(Gtk::Action::create("AllInstruments", _("_Select")));
163    
164      actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit")));      actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit")));
165    
# Line 236  MainWindow::MainWindow() : Line 249  MainWindow::MainWindow() :
249          sigc::mem_fun(*this, &MainWindow::on_action_remove_sample)          sigc::mem_fun(*this, &MainWindow::on_action_remove_sample)
250      );      );
251      actionGroup->add(      actionGroup->add(
252            Gtk::Action::create("ShowSampleRefs", _("Show References...")),
253            sigc::mem_fun(*this, &MainWindow::on_action_view_references)
254        );
255        actionGroup->add(
256          Gtk::Action::create("ReplaceAllSamplesInAllGroups",          Gtk::Action::create("ReplaceAllSamplesInAllGroups",
257                              _("Replace All Samples in All Groups...")),                              _("Replace All Samples in All Groups...")),
258          sigc::mem_fun(*this, &MainWindow::on_action_replace_all_samples_in_all_groups)          sigc::mem_fun(*this, &MainWindow::on_action_replace_all_samples_in_all_groups)
# Line 282  MainWindow::MainWindow() : Line 299  MainWindow::MainWindow() :
299          "      <menuitem action='CopySampleTune'/>"          "      <menuitem action='CopySampleTune'/>"
300          "      <menuitem action='CopySampleLoop'/>"          "      <menuitem action='CopySampleLoop'/>"
301          "    </menu>"          "    </menu>"
302            "    <menu action='MenuSample'>"
303            "      <menuitem action='SampleProperties'/>"
304            "      <menuitem action='AddGroup'/>"
305            "      <menuitem action='AddSample'/>"
306            "      <menuitem action='ShowSampleRefs'/>"
307            "      <menuitem action='ReplaceAllSamplesInAllGroups' />"
308            "      <separator/>"
309            "      <menuitem action='RemoveSample'/>"
310            "    </menu>"
311          "    <menu action='MenuInstrument'>"          "    <menu action='MenuInstrument'>"
312            "      <menu action='AllInstruments'>"
313            "      </menu>"
314            "      <separator/>"
315            "      <menuitem action='InstrProperties'/>"
316            "      <menuitem action='MidiRules'/>"
317            "      <menuitem action='ScriptSlots'/>"
318            "      <menuitem action='AddInstrument'/>"
319            "      <menuitem action='DupInstrument'/>"
320            "      <separator/>"
321            "      <menuitem action='RemoveInstrument'/>"
322            "    </menu>"
323            "    <menu action='MenuScript'>"
324            "      <menuitem action='AddScriptGroup'/>"
325            "      <menuitem action='AddScript'/>"
326            "      <menuitem action='EditScript'/>"
327            "      <separator/>"
328            "      <menuitem action='RemoveScript'/>"
329          "    </menu>"          "    </menu>"
330          "    <menu action='MenuView'>"          "    <menu action='MenuView'>"
331          "      <menuitem action='Statusbar'/>"          "      <menuitem action='Statusbar'/>"
# Line 311  MainWindow::MainWindow() : Line 354  MainWindow::MainWindow() :
354          "    <menuitem action='SampleProperties'/>"          "    <menuitem action='SampleProperties'/>"
355          "    <menuitem action='AddGroup'/>"          "    <menuitem action='AddGroup'/>"
356          "    <menuitem action='AddSample'/>"          "    <menuitem action='AddSample'/>"
357            "    <menuitem action='ShowSampleRefs'/>"
358          "    <menuitem action='ReplaceAllSamplesInAllGroups' />"          "    <menuitem action='ReplaceAllSamplesInAllGroups' />"
359          "    <separator/>"          "    <separator/>"
360          "    <menuitem action='RemoveSample'/>"          "    <menuitem action='RemoveSample'/>"
# Line 364  MainWindow::MainWindow() : Line 408  MainWindow::MainWindow() :
408    
409    
410      instrument_menu = static_cast<Gtk::MenuItem*>(      instrument_menu = static_cast<Gtk::MenuItem*>(
411          uiManager->get_widget("/MenuBar/MenuInstrument"))->get_submenu();          uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments"))->get_submenu();
412    
413      Gtk::Widget* menuBar = uiManager->get_widget("/MenuBar");      Gtk::Widget* menuBar = uiManager->get_widget("/MenuBar");
414      m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK);      m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK);
# Line 404  MainWindow::MainWindow() : Line 448  MainWindow::MainWindow() :
448      m_TreeViewSamples.set_model(m_refSamplesTreeModel);      m_TreeViewSamples.set_model(m_refSamplesTreeModel);
449      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."));
450      // m_TreeViewSamples.set_reorderable();      // m_TreeViewSamples.set_reorderable();
451      m_TreeViewSamples.append_column_editable("Samples", m_SamplesModel.m_col_name);      m_TreeViewSamples.append_column_editable(_("Name"), m_SamplesModel.m_col_name);
452      m_TreeViewSamples.set_headers_visible(false);      m_TreeViewSamples.append_column(_("Referenced"), m_SamplesModel.m_col_refcount);
453        {
454            Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(0);
455            Gtk::CellRendererText* cellrenderer =
456                dynamic_cast<Gtk::CellRendererText*>(column->get_first_cell());
457            column->add_attribute(
458                cellrenderer->property_foreground(), m_SamplesModel.m_color
459            );
460        }
461        {
462            Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(1);
463            Gtk::CellRendererText* cellrenderer =
464                dynamic_cast<Gtk::CellRendererText*>(column->get_first_cell());
465            column->add_attribute(
466                cellrenderer->property_foreground(), m_SamplesModel.m_color
467            );
468        }
469        m_TreeViewSamples.set_headers_visible(true);
470      m_TreeViewSamples.signal_button_press_event().connect_notify(      m_TreeViewSamples.signal_button_press_event().connect_notify(
471          sigc::mem_fun(*this, &MainWindow::on_sample_treeview_button_release)          sigc::mem_fun(*this, &MainWindow::on_sample_treeview_button_release)
472      );      );
# Line 417  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 426  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 474  MainWindow::MainWindow() : Line 541  MainWindow::MainWindow() :
541          dimreg_changed_signal.make_slot());          dimreg_changed_signal.make_slot());
542      dimreg_edit.signal_sample_ref_changed().connect(      dimreg_edit.signal_sample_ref_changed().connect(
543          sample_ref_changed_signal.make_slot());          sample_ref_changed_signal.make_slot());
544        sample_ref_changed_signal.connect(
545            sigc::mem_fun(*this, &MainWindow::on_sample_ref_changed)
546        );
547        samples_to_be_removed_signal.connect(
548            sigc::mem_fun(*this, &MainWindow::on_samples_to_be_removed)
549        );
550    
551      m_RegionChooser.signal_instrument_struct_to_be_changed().connect(      m_RegionChooser.signal_instrument_struct_to_be_changed().connect(
552          sigc::hide(          sigc::hide(
# Line 599  void MainWindow::dimreg_all_dimregs_togg Line 672  void MainWindow::dimreg_all_dimregs_togg
672  void MainWindow::dimreg_changed()  void MainWindow::dimreg_changed()
673  {  {
674      update_dimregs();      update_dimregs();
675      dimreg_edit.set_dim_region(m_DimRegionChooser.get_dimregion());      dimreg_edit.set_dim_region(m_DimRegionChooser.get_main_dimregion());
676  }  }
677    
678  void MainWindow::on_sel_change()  void MainWindow::on_sel_change()
# Line 697  void MainWindow::__clear() { Line 770  void MainWindow::__clear() {
770      // clear the samples and instruments tree views      // clear the samples and instruments tree views
771      m_refTreeModel->clear();      m_refTreeModel->clear();
772      m_refSamplesTreeModel->clear();      m_refSamplesTreeModel->clear();
773        m_refScriptsTreeModel->clear();
774      // remove all entries from "Instrument" menu      // remove all entries from "Instrument" menu
775      while (!instrument_menu->get_children().empty()) {      while (!instrument_menu->get_children().empty()) {
776          remove_instrument_from_menu(0);          remove_instrument_from_menu(0);
# Line 711  void MainWindow::__refreshEntireGUI() { Line 785  void MainWindow::__refreshEntireGUI() {
785      // clear the samples and instruments tree views      // clear the samples and instruments tree views
786      m_refTreeModel->clear();      m_refTreeModel->clear();
787      m_refSamplesTreeModel->clear();      m_refSamplesTreeModel->clear();
788        m_refScriptsTreeModel->clear();
789      // remove all entries from "Instrument" menu      // remove all entries from "Instrument" menu
790      while (!instrument_menu->get_children().empty()) {      while (!instrument_menu->get_children().empty()) {
791          remove_instrument_from_menu(0);          remove_instrument_from_menu(0);
# Line 827  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 1108  void MainWindow::on_action_help_about() Line 1204  void MainWindow::on_action_help_about()
1204          _(          _(
1205              "Gigedit is released under the GNU General Public License.\n"              "Gigedit is released under the GNU General Public License.\n"
1206              "\n"              "\n"
1207              "Please notice that this is still a very young instrument editor. "              "This program is distributed WITHOUT ANY WARRANTY; So better "
1208              "So better backup your Gigasampler files before editing them with "              "backup your Gigasampler/GigaStudio files before editing them with "
1209              "this application.\n"              "this application.\n"
1210              "\n"              "\n"
1211              "Please report bugs to: http://bugs.linuxsampler.org"              "Please report bugs to: http://bugs.linuxsampler.org"
# Line 1358  void MainWindow::file_changed() Line 1454  void MainWindow::file_changed()
1454      }      }
1455  }  }
1456    
1457    void MainWindow::updateSampleRefCountMap(gig::File* gig) {
1458        sample_ref_count.clear();
1459        
1460        if (!gig) return;
1461    
1462        for (gig::Instrument* instrument = gig->GetFirstInstrument(); instrument;
1463             instrument = gig->GetNextInstrument())
1464        {
1465            for (gig::Region* rgn = instrument->GetFirstRegion(); rgn;
1466                 rgn = instrument->GetNextRegion())
1467            {
1468                for (int i = 0; i < 256; ++i) {
1469                    if (!rgn->pDimensionRegions[i]) continue;
1470                    if (rgn->pDimensionRegions[i]->pSample) {
1471                        sample_ref_count[rgn->pDimensionRegions[i]->pSample]++;
1472                    }
1473                }
1474            }
1475        }
1476    }
1477    
1478  void MainWindow::load_gig(gig::File* gig, const char* filename, bool isSharedInstrument)  void MainWindow::load_gig(gig::File* gig, const char* filename, bool isSharedInstrument)
1479  {  {
1480      file = 0;      file = 0;
# Line 1384  void MainWindow::load_gig(gig::File* gig Line 1501  void MainWindow::load_gig(gig::File* gig
1501          add_instrument_to_menu(name);          add_instrument_to_menu(name);
1502      }      }
1503      instrument_name_connection.unblock();      instrument_name_connection.unblock();
1504      uiManager->get_widget("/MenuBar/MenuInstrument")->show();      uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments")->show();
1505    
1506        updateSampleRefCountMap(gig);
1507    
1508      for (gig::Group* group = gig->GetFirstGroup(); group; group = gig->GetNextGroup()) {      for (gig::Group* group = gig->GetFirstGroup(); group; group = gig->GetNextGroup()) {
1509          if (group->Name != "") {          if (group->Name != "") {
# Line 1402  void MainWindow::load_gig(gig::File* gig Line 1521  void MainWindow::load_gig(gig::File* gig
1521                      gig_to_utf8(sample->pInfo->Name);                      gig_to_utf8(sample->pInfo->Name);
1522                  rowSample[m_SamplesModel.m_col_sample] = sample;                  rowSample[m_SamplesModel.m_col_sample] = sample;
1523                  rowSample[m_SamplesModel.m_col_group]  = NULL;                  rowSample[m_SamplesModel.m_col_group]  = NULL;
1524                    int refcount = sample_ref_count.count(sample) ? sample_ref_count[sample] : 0;
1525                    rowSample[m_SamplesModel.m_col_refcount] = ToString(refcount) + " " + _("Refs.");
1526                    rowSample[m_SamplesModel.m_color] = refcount ? "black" : "red";
1527              }              }
1528          }          }
1529      }      }
# Line 1425  void MainWindow::load_gig(gig::File* gig Line 1547  void MainWindow::load_gig(gig::File* gig
1547              rowScript[m_ScriptsModel.m_col_group]  = NULL;              rowScript[m_ScriptsModel.m_col_group]  = NULL;
1548          }          }
1549      }      }
1550      // unfold all script groups by default      // unfold all sample groups & script groups by default
1551        m_TreeViewSamples.expand_all();
1552      m_TreeViewScripts.expand_all();      m_TreeViewScripts.expand_all();
1553    
1554      file = gig;      file = gig;
# Line 1558  void MainWindow::on_button_release(GdkEv Line 1681  void MainWindow::on_button_release(GdkEv
1681          show_instr_props();          show_instr_props();
1682      } else if (button->type == GDK_BUTTON_PRESS && button->button == 3) {      } else if (button->type == GDK_BUTTON_PRESS && button->button == 3) {
1683          // gig v2 files have no midi rules          // gig v2 files have no midi rules
1684            const bool bEnabled = !(file->pVersion && file->pVersion->major == 2);
1685            static_cast<Gtk::MenuItem*>(
1686                uiManager->get_widget("/MenuBar/MenuInstrument/MidiRules"))->set_sensitive(
1687                    bEnabled
1688                );
1689          static_cast<Gtk::MenuItem*>(          static_cast<Gtk::MenuItem*>(
1690              uiManager->get_widget("/PopupMenu/MidiRules"))->set_sensitive(              uiManager->get_widget("/PopupMenu/MidiRules"))->set_sensitive(
1691                  !(file->pVersion && file->pVersion->major == 2));                  bEnabled
1692                );
1693          popup_menu->popup(button->button, button->time);          popup_menu->popup(button->button, button->time);
1694      }      }
1695  }  }
# Line 1594  void MainWindow::on_sample_treeview_butt Line 1723  void MainWindow::on_sample_treeview_butt
1723              group_selected  = row[m_SamplesModel.m_col_group];              group_selected  = row[m_SamplesModel.m_col_group];
1724              sample_selected = row[m_SamplesModel.m_col_sample];              sample_selected = row[m_SamplesModel.m_col_sample];
1725          }          }
1726            
1727                
1728          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))->
1729              set_sensitive(group_selected || sample_selected);              set_sensitive(group_selected || sample_selected);
1730          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))->
1731              set_sensitive(group_selected || sample_selected);              set_sensitive(group_selected || sample_selected);
1732          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddGroup"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddGroup"))->
1733              set_sensitive(file);              set_sensitive(file);
1734            dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/ShowSampleRefs"))->
1735                set_sensitive(sample_selected);
1736          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))->          dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))->
1737              set_sensitive(group_selected || sample_selected);              set_sensitive(group_selected || sample_selected);
1738          // show sample popup          // show sample popup
1739          sample_popup->popup(button->button, button->time);          sample_popup->popup(button->button, button->time);
1740    
1741            dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/SampleProperties"))->
1742                set_sensitive(group_selected || sample_selected);
1743            dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddSample"))->
1744                set_sensitive(group_selected || sample_selected);
1745            dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddGroup"))->
1746                set_sensitive(file);
1747            dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/ShowSampleRefs"))->
1748                set_sensitive(sample_selected);
1749            dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/RemoveSample"))->
1750                set_sensitive(group_selected || sample_selected);
1751      }      }
1752  }  }
1753    
# Line 1631  void MainWindow::on_script_treeview_butt Line 1775  void MainWindow::on_script_treeview_butt
1775              set_sensitive(group_selected || script_selected);              set_sensitive(group_selected || script_selected);
1776          // show sample popup          // show sample popup
1777          script_popup->popup(button->button, button->time);          script_popup->popup(button->button, button->time);
1778    
1779            dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/AddScript"))->
1780                set_sensitive(group_selected || script_selected);
1781            dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/AddScriptGroup"))->
1782                set_sensitive(file);
1783            dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/EditScript"))->
1784                set_sensitive(script_selected);    
1785            dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/RemoveScript"))->
1786                set_sensitive(group_selected || script_selected);
1787      }      }
1788  }  }
1789    
# Line 2438  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 2484  void MainWindow::on_action_combine_instr Line 2652  void MainWindow::on_action_combine_instr
2652      delete d;      delete d;
2653  }  }
2654    
2655    void MainWindow::on_action_view_references() {
2656        Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();
2657        Gtk::TreeModel::iterator it = sel->get_selected();
2658        if (!it) return;
2659        Gtk::TreeModel::Row row = *it;
2660        gig::Sample* sample = row[m_SamplesModel.m_col_sample];
2661        if (!sample) return;
2662    
2663        ReferencesView* d = new ReferencesView(*this);
2664        d->setSample(sample);
2665        d->show_all();
2666        d->resize(500, 400);
2667        d->run();
2668        delete d;
2669    }
2670    
2671  void MainWindow::mergeFiles(const std::vector<std::string>& filenames) {  void MainWindow::mergeFiles(const std::vector<std::string>& filenames) {
2672      struct _Source {      struct _Source {
2673          std::vector<RIFF::File*> riffs;          std::vector<RIFF::File*> riffs;
# Line 2644  void MainWindow::set_file_is_shared(bool Line 2828  void MainWindow::set_file_is_shared(bool
2828      }      }
2829  }  }
2830    
2831    void MainWindow::on_sample_ref_count_incremented(gig::Sample* sample, int offset) {
2832        if (!sample) return;
2833        sample_ref_count[sample] += offset;
2834        const int refcount = sample_ref_count[sample];
2835    
2836        Glib::RefPtr<Gtk::TreeModel> model = m_TreeViewSamples.get_model();
2837        for (int g = 0; g < model->children().size(); ++g) {
2838            Gtk::TreeModel::Row rowGroup = model->children()[g];
2839            for (int s = 0; s < rowGroup.children().size(); ++s) {
2840                Gtk::TreeModel::Row rowSample = rowGroup.children()[s];
2841                if (rowSample[m_SamplesModel.m_col_sample] != sample) continue;
2842                rowSample[m_SamplesModel.m_col_refcount] = ToString(refcount) + " " + _("Refs.");
2843                rowSample[m_SamplesModel.m_color] = refcount ? "black" : "red";
2844            }
2845        }
2846    }
2847    
2848    void MainWindow::on_sample_ref_changed(gig::Sample* oldSample, gig::Sample* newSample) {
2849        on_sample_ref_count_incremented(oldSample, -1);
2850        on_sample_ref_count_incremented(newSample, +1);
2851    }
2852    
2853    void MainWindow::on_samples_to_be_removed(std::list<gig::Sample*> samples) {
2854        // 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
2856        for (std::list<gig::Sample*>::const_iterator it = samples.begin();
2857             it != samples.end(); ++it)
2858        {
2859            sample_ref_count.erase(*it);
2860        }
2861    }
2862    
2863    void MainWindow::show_samples_tab() {
2864        m_TreeViewNotebook.set_current_page(0);
2865    }
2866    
2867    void MainWindow::show_intruments_tab() {
2868        m_TreeViewNotebook.set_current_page(1);
2869    }
2870    
2871    void MainWindow::show_scripts_tab() {
2872        m_TreeViewNotebook.set_current_page(2);
2873    }
2874    
2875  sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() {  sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() {
2876      return file_structure_to_be_changed_signal;      return file_structure_to_be_changed_signal;
2877  }  }

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

  ViewVC Help
Powered by ViewVC