/[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 2845 by persson, Sun Sep 20 10:18:22 2015 UTC revision 2968 by schoenebeck, Mon Jul 18 11:25:13 2016 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (C) 2006-2015 Andreas Persson   * Copyright (C) 2006-2016 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 192  MainWindow::MainWindow() : Line 192  MainWindow::MainWindow() :
192      actionGroup->add(toggle_action,      actionGroup->add(toggle_action,
193                       sigc::mem_fun(                       sigc::mem_fun(
194                           *this, &MainWindow::on_action_view_status_bar));                           *this, &MainWindow::on_action_view_status_bar));
195    
196        toggle_action =
197            Gtk::ToggleAction::create("AutoRestoreWinDim", _("_Auto Restore Window Dimension"));
198        toggle_action->set_active(Settings::singleton()->autoRestoreWindowDimension);
199        actionGroup->add(toggle_action,
200                         sigc::mem_fun(
201                             *this, &MainWindow::on_auto_restore_win_dim));
202    
203        toggle_action =
204            Gtk::ToggleAction::create("SaveWithTemporaryFile", _("Save with _temporary file"));
205        toggle_action->set_active(Settings::singleton()->saveWithTemporaryFile);
206        actionGroup->add(toggle_action,
207                         sigc::mem_fun(
208                             *this, &MainWindow::on_save_with_temporary_file));
209    
210      actionGroup->add(      actionGroup->add(
211          Gtk::Action::create("RefreshAll", _("_Refresh All")),          Gtk::Action::create("RefreshAll", _("_Refresh All")),
212          sigc::mem_fun(*this, &MainWindow::on_action_refresh_all)          sigc::mem_fun(*this, &MainWindow::on_action_refresh_all)
# Line 364  MainWindow::MainWindow() : Line 379  MainWindow::MainWindow() :
379          "    </menu>"          "    </menu>"
380          "    <menu action='MenuView'>"          "    <menu action='MenuView'>"
381          "      <menuitem action='Statusbar'/>"          "      <menuitem action='Statusbar'/>"
382            "      <menuitem action='AutoRestoreWinDim'/>"
383          "      <separator/>"          "      <separator/>"
384          "      <menuitem action='RefreshAll'/>"          "      <menuitem action='RefreshAll'/>"
385          "    </menu>"          "    </menu>"
# Line 375  MainWindow::MainWindow() : Line 391  MainWindow::MainWindow() :
391          "      <menuitem action='WarnUserOnExtensions'/>"          "      <menuitem action='WarnUserOnExtensions'/>"
392          "      <menuitem action='SyncSamplerInstrumentSelection'/>"          "      <menuitem action='SyncSamplerInstrumentSelection'/>"
393          "      <menuitem action='MoveRootNoteWithRegionMoved'/>"          "      <menuitem action='MoveRootNoteWithRegionMoved'/>"
394            "      <menuitem action='SaveWithTemporaryFile'/>"
395          "    </menu>"          "    </menu>"
396          "    <menu action='MenuHelp'>"          "    <menu action='MenuHelp'>"
397          "      <menuitem action='About'/>"          "      <menuitem action='About'/>"
# Line 462  MainWindow::MainWindow() : Line 479  MainWindow::MainWindow() :
479      }      }
480      {      {
481          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
482                uiManager->get_widget("/MenuBar/MenuView/AutoRestoreWinDim"));
483            item->set_tooltip_text(_("If checked, size and position of all windows will be saved and automatically restored next time."));
484        }
485        {
486            Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
487              uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments"));              uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments"));
488          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."));
489      }      }
# Line 889  void Saver::thread_function() Line 911  void Saver::thread_function()
911    
912          // if no filename was provided, that means "save", if filename was provided means "save as"          // if no filename was provided, that means "save", if filename was provided means "save as"
913          if (filename.empty()) {          if (filename.empty()) {
914              gig->Save(&progress);              if (!Settings::singleton()->saveWithTemporaryFile) {
915                    // save directly over the existing .gig file
916                    // (requires less disk space than solution below
917                    // but may be slower)
918                    gig->Save(&progress);
919                } else {
920                    // save the file as separate temporary file first,
921                    // then move the saved file over the old file
922                    // (may result in performance speedup during save)
923                    String tmpname = filename + ".TMP";
924                    gig->Save(tmpname, &progress);
925                    #if defined(WIN32)
926                    if (!DeleteFile(filename.c_str())) {
927                        throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file).");
928                    }
929                    #else // POSIX ...
930                    if (unlink(filename.c_str())) {
931                        throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file): " + String(strerror(errno)));
932                    }
933                    #endif
934                    if (rename(tmpname.c_str(), filename.c_str())) {
935                        #if defined(WIN32)
936                        throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file).");
937                        #else
938                        throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file): " + String(strerror(errno)));
939                        #endif
940                    }
941                }
942          } else {          } else {
943              gig->Save(filename, &progress);              gig->Save(filename, &progress);
944          }          }
# Line 1463  void MainWindow::on_action_help_about() Line 1512  void MainWindow::on_action_help_about()
1512      dialog.set_name("Gigedit");      dialog.set_name("Gigedit");
1513  #endif  #endif
1514      dialog.set_version(VERSION);      dialog.set_version(VERSION);
1515      dialog.set_copyright("Copyright (C) 2006-2015 Andreas Persson");      dialog.set_copyright("Copyright (C) 2006-2016 Andreas Persson");
1516      const std::string sComment =      const std::string sComment =
1517          _("Built " __DATE__ "\nUsing ") +          _("Built " __DATE__ "\nUsing ") +
1518          ::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" +          ::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" +
# Line 1918  void MainWindow::on_action_view_status_b Line 1967  void MainWindow::on_action_view_status_b
1967      else                    m_StatusBar.hide();      else                    m_StatusBar.hide();
1968  }  }
1969    
1970    void MainWindow::on_auto_restore_win_dim() {
1971        Gtk::CheckMenuItem* item =
1972            dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/AutoRestoreWinDim"));
1973        if (!item) {
1974            std::cerr << "/MenuBar/MenuView/AutoRestoreWinDim == NULL\n";
1975            return;
1976        }
1977        Settings::singleton()->autoRestoreWindowDimension = item->get_active();
1978    }
1979    
1980    void MainWindow::on_save_with_temporary_file() {
1981        Gtk::CheckMenuItem* item =
1982            dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuSettings/SaveWithTemporaryFile"));
1983        if (!item) {
1984            std::cerr << "/MenuBar/MenuSettings/SaveWithTemporaryFile == NULL\n";
1985            return;
1986        }
1987        Settings::singleton()->saveWithTemporaryFile = item->get_active();
1988    }
1989    
1990  bool MainWindow::is_copy_samples_unity_note_enabled() const {  bool MainWindow::is_copy_samples_unity_note_enabled() const {
1991      Gtk::CheckMenuItem* item =      Gtk::CheckMenuItem* item =
1992          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity"));          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity"));
# Line 2340  void MainWindow::on_action_edit_script() Line 2409  void MainWindow::on_action_edit_script()
2409      if (!script) return;      if (!script) return;
2410    
2411      ScriptEditor* editor = new ScriptEditor;      ScriptEditor* editor = new ScriptEditor;
2412        editor->signal_script_to_be_changed.connect(
2413            signal_script_to_be_changed.make_slot()
2414        );
2415        editor->signal_script_changed.connect(
2416            signal_script_changed.make_slot()
2417        );
2418      editor->setScript(script);      editor->setScript(script);
2419      //editor->reparent(*this);      //editor->reparent(*this);
2420      editor->show();      editor->show();
# Line 3082  void MainWindow::script_double_clicked(c Line 3157  void MainWindow::script_double_clicked(c
3157      if (!script) return;      if (!script) return;
3158    
3159      ScriptEditor* editor = new ScriptEditor;      ScriptEditor* editor = new ScriptEditor;
3160        editor->signal_script_to_be_changed.connect(
3161            signal_script_to_be_changed.make_slot()
3162        );
3163        editor->signal_script_changed.connect(
3164            signal_script_changed.make_slot()
3165        );
3166      editor->setScript(script);      editor->setScript(script);
3167      //editor->reparent(*this);      //editor->reparent(*this);
3168      editor->show();      editor->show();

Legend:
Removed from v.2845  
changed lines
  Added in v.2968

  ViewVC Help
Powered by ViewVC