/[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 2691 by schoenebeck, Sun Jan 4 19:46:54 2015 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (C) 2006-2014 Andreas Persson   * Copyright (C) 2006-2015 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 217  MainWindow::MainWindow() : Line 217  MainWindow::MainWindow() :
217          sigc::mem_fun(*this, &MainWindow::on_action_warn_user_on_extensions)          sigc::mem_fun(*this, &MainWindow::on_action_warn_user_on_extensions)
218      );      );
219    
220        toggle_action =
221            Gtk::ToggleAction::create("SyncSamplerInstrumentSelection", _("Synchronize sampler's instrument selection"));
222        toggle_action->set_active(Settings::singleton()->syncSamplerInstrumentSelection);
223        actionGroup->add(
224            toggle_action,
225            sigc::mem_fun(*this, &MainWindow::on_action_sync_sampler_instrument_selection)
226        );
227    
228    
229      actionGroup->add(Gtk::Action::create("MenuTools", _("_Tools")));      actionGroup->add(Gtk::Action::create("MenuTools", _("_Tools")));
230    
# Line 336  MainWindow::MainWindow() : Line 344  MainWindow::MainWindow() :
344          "    </menu>"          "    </menu>"
345          "    <menu action='MenuSettings'>"          "    <menu action='MenuSettings'>"
346          "      <menuitem action='WarnUserOnExtensions'/>"          "      <menuitem action='WarnUserOnExtensions'/>"
347            "      <menuitem action='SyncSamplerInstrumentSelection'/>"
348          "    </menu>"          "    </menu>"
349          "    <menu action='MenuHelp'>"          "    <menu action='MenuHelp'>"
350          "      <menuitem action='About'/>"          "      <menuitem action='About'/>"
# Line 397  MainWindow::MainWindow() : Line 406  MainWindow::MainWindow() :
406      }      }
407      {      {
408          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
409                uiManager->get_widget("/MenuBar/MenuSettings/SyncSamplerInstrumentSelection"));
410            item->set_tooltip_text(_("If checked, the sampler's current instrument will automatically be switched whenever another instrument was selected in gigedit (only available in live-mode)."));
411        }
412        {
413            Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
414              uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments"));              uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments"));
415          item->set_tooltip_text(_("Create combi sounds out of individual sounds of this .gig file."));          item->set_tooltip_text(_("Create combi sounds out of individual sounds of this .gig file."));
416      }      }
# Line 453  MainWindow::MainWindow() : Line 467  MainWindow::MainWindow() :
467      {      {
468          Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(0);          Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(0);
469          Gtk::CellRendererText* cellrenderer =          Gtk::CellRendererText* cellrenderer =
470              dynamic_cast<Gtk::CellRendererText*>(column->get_first_cell_renderer());              dynamic_cast<Gtk::CellRendererText*>(column->get_first_cell());
471          column->add_attribute(          column->add_attribute(
472              cellrenderer->property_foreground(), m_SamplesModel.m_color              cellrenderer->property_foreground(), m_SamplesModel.m_color
473          );          );
# Line 461  MainWindow::MainWindow() : Line 475  MainWindow::MainWindow() :
475      {      {
476          Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(1);          Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(1);
477          Gtk::CellRendererText* cellrenderer =          Gtk::CellRendererText* cellrenderer =
478              dynamic_cast<Gtk::CellRendererText*>(column->get_first_cell_renderer());              dynamic_cast<Gtk::CellRendererText*>(column->get_first_cell());
479          column->add_attribute(          column->add_attribute(
480              cellrenderer->property_foreground(), m_SamplesModel.m_color              cellrenderer->property_foreground(), m_SamplesModel.m_color
481          );          );
# Line 478  MainWindow::MainWindow() : Line 492  MainWindow::MainWindow() :
492      m_refScriptsTreeModel = ScriptsTreeStore::create(m_ScriptsModel);      m_refScriptsTreeModel = ScriptsTreeStore::create(m_ScriptsModel);
493      m_TreeViewScripts.set_model(m_refScriptsTreeModel);      m_TreeViewScripts.set_model(m_refScriptsTreeModel);
494      m_TreeViewScripts.set_tooltip_text(_(      m_TreeViewScripts.set_tooltip_text(_(
495            "Use CTRL + double click for editing a script."
496            "\n\n"
497          "Note: instrument scripts are a LinuxSampler extension of the gig "          "Note: instrument scripts are a LinuxSampler extension of the gig "
498          "format. This feature will not work with the GigaStudio software!"          "format. This feature will not work with the GigaStudio software!"
499      ));      ));
# Line 487  MainWindow::MainWindow() : Line 503  MainWindow::MainWindow() :
503      m_TreeViewScripts.signal_button_press_event().connect_notify(      m_TreeViewScripts.signal_button_press_event().connect_notify(
504          sigc::mem_fun(*this, &MainWindow::on_script_treeview_button_release)          sigc::mem_fun(*this, &MainWindow::on_script_treeview_button_release)
505      );      );
506        //FIXME: why the heck does this double click signal_row_activated() only fired while CTRL key is pressed ?
507        m_TreeViewScripts.signal_row_activated().connect(
508            sigc::mem_fun(*this, &MainWindow::script_double_clicked)
509        );
510      m_refScriptsTreeModel->signal_row_changed().connect(      m_refScriptsTreeModel->signal_row_changed().connect(
511          sigc::mem_fun(*this, &MainWindow::script_name_changed)          sigc::mem_fun(*this, &MainWindow::script_name_changed)
512      );      );
# Line 542  MainWindow::MainWindow() : Line 562  MainWindow::MainWindow() :
562          sigc::mem_fun(*this, &MainWindow::on_samples_to_be_removed)          sigc::mem_fun(*this, &MainWindow::on_samples_to_be_removed)
563      );      );
564    
565        dimreg_edit.signal_select_sample().connect(
566            sigc::mem_fun(*this, &MainWindow::select_sample)
567        );
568    
569      m_RegionChooser.signal_instrument_struct_to_be_changed().connect(      m_RegionChooser.signal_instrument_struct_to_be_changed().connect(
570          sigc::hide(          sigc::hide(
571              sigc::bind(              sigc::bind(
# Line 682  void MainWindow::on_sel_change() Line 706  void MainWindow::on_sel_change()
706      }      }
707    
708      m_RegionChooser.set_instrument(get_instrument());      m_RegionChooser.set_instrument(get_instrument());
709    
710        if (Settings::singleton()->syncSamplerInstrumentSelection) {
711            switch_sampler_instrument_signal.emit(get_instrument());
712        }
713  }  }
714    
715  void loader_progress_callback(gig::progress_t* progress)  void loader_progress_callback(gig::progress_t* progress)
# Line 702  void Loader::progress_callback(float fra Line 730  void Loader::progress_callback(float fra
730  void Loader::thread_function()  void Loader::thread_function()
731  {  {
732      printf("thread_function self=%x\n", Glib::Threads::Thread::self());      printf("thread_function self=%x\n", Glib::Threads::Thread::self());
733      printf("Start %s\n", filename);      printf("Start %s\n", filename.c_str());
734      RIFF::File* riff = new RIFF::File(filename);      try {
735      gig = new gig::File(riff);          RIFF::File* riff = new RIFF::File(filename);
736      gig::progress_t progress;          gig = new gig::File(riff);
737      progress.callback = loader_progress_callback;          gig::progress_t progress;
738      progress.custom = this;          progress.callback = loader_progress_callback;
739            progress.custom = this;
740      gig->GetInstrument(0, &progress);  
741      printf("End\n");          gig->GetInstrument(0, &progress);
742      finished_dispatcher();          printf("End\n");
743            finished_dispatcher();
744        } catch (RIFF::Exception e) {
745            error_message = e.Message;
746            error_dispatcher.emit();
747        } catch (...) {
748            error_message = _("Unknown exception occurred");
749            error_dispatcher.emit();
750        }
751  }  }
752    
753  Loader::Loader(const char* filename)  Loader::Loader(const char* filename)
754      : filename(filename), thread(0)      : filename(filename), thread(0), progress(0.f)
755  {  {
756  }  }
757    
# Line 749  Glib::Dispatcher& Loader::signal_finishe Line 785  Glib::Dispatcher& Loader::signal_finishe
785      return finished_dispatcher;      return finished_dispatcher;
786  }  }
787    
788  LoadDialog::LoadDialog(const Glib::ustring& title, Gtk::Window& parent)  Glib::Dispatcher& Loader::signal_error()
789    {
790        return error_dispatcher;
791    }
792    
793    void saver_progress_callback(gig::progress_t* progress)
794    {
795        Saver* saver = static_cast<Saver*>(progress->custom);
796        saver->progress_callback(progress->factor);
797    }
798    
799    void Saver::progress_callback(float fraction)
800    {
801        {
802            Glib::Threads::Mutex::Lock lock(progressMutex);
803            progress = fraction;
804        }
805        progress_dispatcher.emit();
806    }
807    
808    void Saver::thread_function()
809    {
810        printf("thread_function self=%x\n", Glib::Threads::Thread::self());
811        printf("Start %s\n", filename.c_str());
812        try {
813            gig::progress_t progress;
814            progress.callback = saver_progress_callback;
815            progress.custom = this;
816    
817            // if no filename was provided, that means "save", if filename was provided means "save as"
818            if (filename.empty()) {
819                gig->Save(&progress);
820            } else {
821                gig->Save(filename, &progress);
822            }
823    
824            printf("End\n");
825            finished_dispatcher.emit();
826        } catch (RIFF::Exception e) {
827            error_message = e.Message;
828            error_dispatcher.emit();
829        } catch (...) {
830            error_message = _("Unknown exception occurred");
831            error_dispatcher.emit();
832        }
833    }
834    
835    Saver::Saver(gig::File* file, Glib::ustring filename)
836        : gig(file), filename(filename), thread(0), progress(0.f)
837    {
838    }
839    
840    void Saver::launch()
841    {
842    #ifdef OLD_THREADS
843        thread = Glib::Thread::create(sigc::mem_fun(*this, &Saver::thread_function), true);
844    #else
845        thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Saver::thread_function));
846    #endif
847        printf("launch thread=%x\n", thread);
848    }
849    
850    float Saver::get_progress()
851    {
852        float res;
853        {
854            Glib::Threads::Mutex::Lock lock(progressMutex);
855            res = progress;
856        }
857        return res;
858    }
859    
860    Glib::Dispatcher& Saver::signal_progress()
861    {
862        return progress_dispatcher;
863    }
864    
865    Glib::Dispatcher& Saver::signal_finished()
866    {
867        return finished_dispatcher;
868    }
869    
870    Glib::Dispatcher& Saver::signal_error()
871    {
872        return error_dispatcher;
873    }
874    
875    ProgressDialog::ProgressDialog(const Glib::ustring& title, Gtk::Window& parent)
876      : Gtk::Dialog(title, parent, true)      : Gtk::Dialog(title, parent, true)
877  {  {
878      get_vbox()->pack_start(progressBar);      get_vbox()->pack_start(progressBar);
879      show_all_children();      show_all_children();
880        resize(600,50);
881  }  }
882    
883  // Clear all GUI elements / controls. This method is typically called  // Clear all GUI elements / controls. This method is typically called
# Line 822  bool MainWindow::close_confirmation_dial Line 946  bool MainWindow::close_confirmation_dial
946      dialog.set_default_response(Gtk::RESPONSE_YES);      dialog.set_default_response(Gtk::RESPONSE_YES);
947      int response = dialog.run();      int response = dialog.run();
948      dialog.hide();      dialog.hide();
949      if (response == Gtk::RESPONSE_YES) return file_save();  
950      return response != Gtk::RESPONSE_CANCEL;      // TODO: the following return valid is disabled and hard coded instead for
951        // now, due to the fact that saving with progress bar is now implemented
952        // asynchronously, as a result the app does not close automatically anymore
953        // after saving the file has completed
954        //
955        //   if (response == Gtk::RESPONSE_YES) return file_save();
956        //   return response != Gtk::RESPONSE_CANCEL;
957        //
958        if (response == Gtk::RESPONSE_YES) file_save();
959        return false; // always prevent closing the app for now (see comment above)
960  }  }
961    
962  bool MainWindow::leaving_shared_mode_dialog() {  bool MainWindow::leaving_shared_mode_dialog() {
# Line 874  void MainWindow::on_action_file_open() Line 1007  void MainWindow::on_action_file_open()
1007  void MainWindow::load_file(const char* name)  void MainWindow::load_file(const char* name)
1008  {  {
1009      __clear();      __clear();
1010      load_dialog = new LoadDialog(_("Loading..."), *this);  
1011      load_dialog->show_all();      progress_dialog = new ProgressDialog( //FIXME: memory leak!
1012      loader = new Loader(strdup(name));          _("Loading") +  Glib::ustring(" '") +
1013            Glib::filename_display_basename(name) + "' ...",
1014            *this
1015        );
1016        progress_dialog->show_all();
1017        loader = new Loader(name); //FIXME: memory leak!
1018      loader->signal_progress().connect(      loader->signal_progress().connect(
1019          sigc::mem_fun(*this, &MainWindow::on_loader_progress));          sigc::mem_fun(*this, &MainWindow::on_loader_progress));
1020      loader->signal_finished().connect(      loader->signal_finished().connect(
1021          sigc::mem_fun(*this, &MainWindow::on_loader_finished));          sigc::mem_fun(*this, &MainWindow::on_loader_finished));
1022        loader->signal_error().connect(
1023            sigc::mem_fun(*this, &MainWindow::on_loader_error));
1024      loader->launch();      loader->launch();
1025  }  }
1026    
# Line 896  void MainWindow::load_instrument(gig::In Line 1036  void MainWindow::load_instrument(gig::In
1036      // load the instrument      // load the instrument
1037      gig::File* pFile = (gig::File*) instr->GetParent();      gig::File* pFile = (gig::File*) instr->GetParent();
1038      load_gig(pFile, 0 /*file name*/, true /*shared instrument*/);      load_gig(pFile, 0 /*file name*/, true /*shared instrument*/);
1039      //TODO: automatically select the given instrument      // automatically select the given instrument
1040        int i = 0;
1041        for (gig::Instrument* instrument = pFile->GetFirstInstrument(); instrument;
1042             instrument = pFile->GetNextInstrument(), ++i)
1043        {
1044            if (instrument == instr) {
1045                // select item in "instruments" tree view
1046                m_TreeView.get_selection()->select(Gtk::TreePath(ToString(i)));
1047                // make sure the selected item in the "instruments" tree view is
1048                // visible (scroll to it)
1049                m_TreeView.scroll_to_row(Gtk::TreePath(ToString(i)));
1050                // select item in instrument menu
1051                {
1052                    const std::vector<Gtk::Widget*> children =
1053                        instrument_menu->get_children();
1054                    static_cast<Gtk::RadioMenuItem*>(children[i])->set_active();
1055                }
1056                // update region chooser and dimension region chooser
1057                m_RegionChooser.set_instrument(instr);
1058                break;
1059            }
1060        }
1061  }  }
1062    
1063  void MainWindow::on_loader_progress()  void MainWindow::on_loader_progress()
1064  {  {
1065      load_dialog->set_fraction(loader->get_progress());      progress_dialog->set_fraction(loader->get_progress());
1066  }  }
1067    
1068  void MainWindow::on_loader_finished()  void MainWindow::on_loader_finished()
1069  {  {
1070      printf("Loader finished!\n");      printf("Loader finished!\n");
1071      printf("on_loader_finished self=%x\n", Glib::Threads::Thread::self());      printf("on_loader_finished self=%x\n", Glib::Threads::Thread::self());
1072      load_gig(loader->gig, loader->filename);      load_gig(loader->gig, loader->filename.c_str());
1073      load_dialog->hide();      progress_dialog->hide();
1074    }
1075    
1076    void MainWindow::on_loader_error()
1077    {
1078        Glib::ustring txt = _("Could not load file: ") + loader->error_message;
1079        Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);
1080        msg.run();
1081        progress_dialog->hide();
1082  }  }
1083    
1084  void MainWindow::on_action_file_save()  void MainWindow::on_action_file_save()
# Line 948  bool MainWindow::file_save() Line 1117  bool MainWindow::file_save()
1117    
1118      std::cout << "Saving file\n" << std::flush;      std::cout << "Saving file\n" << std::flush;
1119      file_structure_to_be_changed_signal.emit(this->file);      file_structure_to_be_changed_signal.emit(this->file);
1120      try {  
1121          file->Save();      progress_dialog = new ProgressDialog( //FIXME: memory leak!
1122          if (file_is_changed) {          _("Saving") +  Glib::ustring(" '") +
1123              set_title(get_title().substr(1));          Glib::filename_display_basename(this->filename) + "' ...",
1124              file_is_changed = false;          *this
1125          }      );
1126      } catch (RIFF::Exception e) {      progress_dialog->show_all();
1127          file_structure_changed_signal.emit(this->file);      saver = new Saver(this->file); //FIXME: memory leak!
1128          Glib::ustring txt = _("Could not save file: ") + e.Message;      saver->signal_progress().connect(
1129          Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);          sigc::mem_fun(*this, &MainWindow::on_saver_progress));
1130          msg.run();      saver->signal_finished().connect(
1131          return false;          sigc::mem_fun(*this, &MainWindow::on_saver_finished));
1132      }      saver->signal_error().connect(
1133      std::cout << "Saving file done\n" << std::flush;          sigc::mem_fun(*this, &MainWindow::on_saver_error));
1134        saver->launch();
1135    
1136        return true;
1137    }
1138    
1139    void MainWindow::on_saver_progress()
1140    {
1141        progress_dialog->set_fraction(saver->get_progress());
1142    }
1143    
1144    void MainWindow::on_saver_error()
1145    {
1146        file_structure_changed_signal.emit(this->file);
1147        Glib::ustring txt = _("Could not save file: ") + saver->error_message;
1148        Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);
1149        msg.run();
1150    }
1151    
1152    void MainWindow::on_saver_finished()
1153    {
1154        this->file = saver->gig;
1155        this->filename = saver->filename;
1156        current_gig_dir = Glib::path_get_dirname(filename);
1157        set_title(Glib::filename_display_basename(filename));
1158        file_has_name = true;
1159        file_is_changed = false;
1160        std::cout << "Saving file done. Importing queued samples now ...\n" << std::flush;
1161      __import_queued_samples();      __import_queued_samples();
1162        std::cout << "Importing queued samples done.\n" << std::flush;
1163    
1164      file_structure_changed_signal.emit(this->file);      file_structure_changed_signal.emit(this->file);
1165      return true;  
1166        load_gig(this->file, this->filename.c_str());
1167        progress_dialog->hide();
1168  }  }
1169    
1170  void MainWindow::on_action_file_save_as()  void MainWindow::on_action_file_save_as()
# Line 1029  bool MainWindow::file_save_as() Line 1229  bool MainWindow::file_save_as()
1229      descriptionArea.show_all();      descriptionArea.show_all();
1230    
1231      if (dialog.run() == Gtk::RESPONSE_OK) {      if (dialog.run() == Gtk::RESPONSE_OK) {
1232          file_structure_to_be_changed_signal.emit(this->file);          std::string filename = dialog.get_filename();
1233          try {          if (!Glib::str_has_suffix(filename, ".gig")) {
1234              std::string filename = dialog.get_filename();              filename += ".gig";
             if (!Glib::str_has_suffix(filename, ".gig")) {  
                 filename += ".gig";  
             }  
             printf("filename=%s\n", filename.c_str());  
             file->Save(filename);  
             this->filename = filename;  
             current_gig_dir = Glib::path_get_dirname(filename);  
             set_title(Glib::filename_display_basename(filename));  
             file_has_name = true;  
             file_is_changed = false;  
         } catch (RIFF::Exception e) {  
             file_structure_changed_signal.emit(this->file);  
             Glib::ustring txt = _("Could not save file: ") + e.Message;  
             Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);  
             msg.run();  
             return false;  
1235          }          }
1236          __import_queued_samples();          printf("filename=%s\n", filename.c_str());
1237          file_structure_changed_signal.emit(this->file);  
1238            progress_dialog = new ProgressDialog( //FIXME: memory leak!
1239                _("Saving") +  Glib::ustring(" '") +
1240                Glib::filename_display_basename(filename) + "' ...",
1241                *this
1242            );
1243            progress_dialog->show_all();
1244    
1245            saver = new Saver(file, filename); //FIXME: memory leak!
1246            saver->signal_progress().connect(
1247                sigc::mem_fun(*this, &MainWindow::on_saver_progress));
1248            saver->signal_finished().connect(
1249                sigc::mem_fun(*this, &MainWindow::on_saver_finished));
1250            saver->signal_error().connect(
1251                sigc::mem_fun(*this, &MainWindow::on_saver_error));
1252            saver->launch();
1253    
1254          return true;          return true;
1255      }      }
1256      return false;      return false;
# Line 1161  void MainWindow::on_action_warn_user_on_ Line 1361  void MainWindow::on_action_warn_user_on_
1361          !Settings::singleton()->warnUserOnExtensions;          !Settings::singleton()->warnUserOnExtensions;
1362  }  }
1363    
1364    void MainWindow::on_action_sync_sampler_instrument_selection() {
1365        Settings::singleton()->syncSamplerInstrumentSelection =
1366            !Settings::singleton()->syncSamplerInstrumentSelection;
1367    }
1368    
1369  void MainWindow::on_action_help_about()  void MainWindow::on_action_help_about()
1370  {  {
1371      Gtk::AboutDialog dialog;      Gtk::AboutDialog dialog;
# Line 1170  void MainWindow::on_action_help_about() Line 1375  void MainWindow::on_action_help_about()
1375      dialog.set_name("Gigedit");      dialog.set_name("Gigedit");
1376  #endif  #endif
1377      dialog.set_version(VERSION);      dialog.set_version(VERSION);
1378      dialog.set_copyright("Copyright (C) 2006-2014 Andreas Persson");      dialog.set_copyright("Copyright (C) 2006-2015 Andreas Persson");
1379      const std::string sComment =      const std::string sComment =
1380          _("Built " __DATE__ "\nUsing ") +          _("Built " __DATE__ "\nUsing ") +
1381          ::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" +          ::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" +
# Line 1682  void MainWindow::on_instrument_selection Line 1887  void MainWindow::on_instrument_selection
1887      }      }
1888  }  }
1889    
1890    void MainWindow::select_sample(gig::Sample* sample) {
1891        Glib::RefPtr<Gtk::TreeModel> model = m_TreeViewSamples.get_model();
1892        for (int g = 0; g < model->children().size(); ++g) {
1893            Gtk::TreeModel::Row rowGroup = model->children()[g];
1894            for (int s = 0; s < rowGroup.children().size(); ++s) {
1895                Gtk::TreeModel::Row rowSample = rowGroup.children()[s];
1896                if (rowSample[m_SamplesModel.m_col_sample] == sample) {
1897                    show_samples_tab();
1898                    m_TreeViewSamples.get_selection()->select(rowGroup.children()[s]);
1899                    Gtk::TreePath path(
1900                        m_TreeViewSamples.get_selection()->get_selected()
1901                    );
1902                    m_TreeViewSamples.scroll_to_row(path);
1903                    return;
1904                }
1905            }
1906        }
1907    }
1908    
1909  void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) {  void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) {
1910      if (button->type == GDK_BUTTON_PRESS && button->button == 3) {      if (button->type == GDK_BUTTON_PRESS && button->button == 3) {
1911          Gtk::Menu* sample_popup =          Gtk::Menu* sample_popup =
# Line 2564  void MainWindow::script_name_changed(con Line 2788  void MainWindow::script_name_changed(con
2788      }      }
2789  }  }
2790    
2791    void MainWindow::script_double_clicked(const Gtk::TreeModel::Path& path,
2792                                           Gtk::TreeViewColumn* column)
2793    {
2794        Gtk::TreeModel::iterator iter = m_refScriptsTreeModel->get_iter(path);
2795        if (!iter) return;
2796        Gtk::TreeModel::Row row = *iter;
2797        gig::Script* script = row[m_ScriptsModel.m_col_script];
2798        if (!script) return;
2799    
2800        ScriptEditor* editor = new ScriptEditor;
2801        editor->setScript(script);
2802        //editor->reparent(*this);
2803        editor->show();
2804    }
2805    
2806  void MainWindow::instrument_name_changed(const Gtk::TreeModel::Path& path,  void MainWindow::instrument_name_changed(const Gtk::TreeModel::Path& path,
2807                                           const Gtk::TreeModel::iterator& iter) {                                           const Gtk::TreeModel::iterator& iter) {
2808      if (!iter) return;      if (!iter) return;
# Line 2693  void MainWindow::mergeFiles(const std::v Line 2932  void MainWindow::mergeFiles(const std::v
2932          );          );
2933      }      }
2934    
2935      // Note: requires that this file already has a filename !      // Finally save gig file persistently to disk ...
2936      this->file->Save();      //NOTE: requires that this gig file already has a filename !
2937        {
2938            std::cout << "Saving file\n" << std::flush;
2939            file_structure_to_be_changed_signal.emit(this->file);
2940    
2941            progress_dialog = new ProgressDialog( //FIXME: memory leak!
2942                _("Saving") +  Glib::ustring(" '") +
2943                Glib::filename_display_basename(this->filename) + "' ...",
2944                *this
2945            );
2946            progress_dialog->show_all();
2947            saver = new Saver(this->file); //FIXME: memory leak!
2948            saver->signal_progress().connect(
2949                sigc::mem_fun(*this, &MainWindow::on_saver_progress));
2950            saver->signal_finished().connect(
2951                sigc::mem_fun(*this, &MainWindow::on_saver_finished));
2952            saver->signal_error().connect(
2953                sigc::mem_fun(*this, &MainWindow::on_saver_error));
2954            saver->launch();
2955        }
2956  }  }
2957    
2958  void MainWindow::on_action_merge_files() {  void MainWindow::on_action_merge_files() {
# Line 2784  void MainWindow::set_file_is_shared(bool Line 3042  void MainWindow::set_file_is_shared(bool
3042              Gdk::Pixbuf::create_from_xpm_data(status_detached_xpm)              Gdk::Pixbuf::create_from_xpm_data(status_detached_xpm)
3043          );          );
3044      }      }
3045    
3046        {
3047            Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
3048                uiManager->get_widget("/MenuBar/MenuSettings/SyncSamplerInstrumentSelection"));
3049            if (item) item->set_sensitive(b);
3050        }
3051  }  }
3052    
3053  void MainWindow::on_sample_ref_count_incremented(gig::Sample* sample, int offset) {  void MainWindow::on_sample_ref_count_incremented(gig::Sample* sample, int offset) {
# Line 2812  void MainWindow::on_samples_to_be_remove Line 3076  void MainWindow::on_samples_to_be_remove
3076      // 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
3077      // address, which would lead to incorrect refcount if not deleted here      // address, which would lead to incorrect refcount if not deleted here
3078      for (std::list<gig::Sample*>::const_iterator it = samples.begin();      for (std::list<gig::Sample*>::const_iterator it = samples.begin();
3079           it != samples.end(); it != samples.end())           it != samples.end(); ++it)
3080      {      {
3081          sample_ref_count.erase(*it);          sample_ref_count.erase(*it);
3082      }      }
# Line 2885  sigc::signal<void, int/*key*/, int/*velo Line 3149  sigc::signal<void, int/*key*/, int/*velo
3149  sigc::signal<void, int/*key*/, int/*velocity*/>& MainWindow::signal_keyboard_key_released() {  sigc::signal<void, int/*key*/, int/*velocity*/>& MainWindow::signal_keyboard_key_released() {
3150      return m_RegionChooser.signal_keyboard_key_released();      return m_RegionChooser.signal_keyboard_key_released();
3151  }  }
3152    
3153    sigc::signal<void, gig::Instrument*>& MainWindow::signal_switch_sampler_instrument() {
3154        return switch_sampler_instrument_signal;
3155    }

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

  ViewVC Help
Powered by ViewVC