/[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 3408 by schoenebeck, Fri Jan 19 19:17:41 2018 UTC revision 3619 by schoenebeck, Tue Oct 1 16:21:28 2019 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (C) 2006-2017 Andreas Persson   * Copyright (C) 2006-2019 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 21  Line 21 
21  #include <cstring>  #include <cstring>
22    
23  #include "compat.h"  #include "compat.h"
 // threads.h must be included first to be able to build with  
 // G_DISABLE_DEPRECATED  
 #if (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION == 31 && GLIBMM_MICRO_VERSION >= 2) || \  
     (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION > 31) || GLIBMM_MAJOR_VERSION > 2  
 #include <glibmm/threads.h>  
 #endif  
24    
25  #include <glibmm/convert.h>  #include <glibmm/convert.h>
26  #include <glibmm/dispatcher.h>  #include <glibmm/dispatcher.h>
# Line 102  MainWindow::MainWindow() : Line 96  MainWindow::MainWindow() :
96    
97      if (!Settings::singleton()->autoRestoreWindowDimension) {      if (!Settings::singleton()->autoRestoreWindowDimension) {
98  #if GTKMM_MAJOR_VERSION >= 3  #if GTKMM_MAJOR_VERSION >= 3
99          set_default_size(895, 600);          set_default_size(960, 600);
100  #else  #else
101          set_default_size(800, 600);          set_default_size(865, 600);
102  #endif  #endif
103          set_position(Gtk::WIN_POS_CENTER);          set_position(Gtk::WIN_POS_CENTER);
104      }      }
# Line 457  MainWindow::MainWindow() : Line 451  MainWindow::MainWindow() :
451          m_actionGroup->add_action_bool("Statusbar", sigc::mem_fun(*this, &MainWindow::on_action_view_status_bar), true);          m_actionGroup->add_action_bool("Statusbar", sigc::mem_fun(*this, &MainWindow::on_action_view_status_bar), true);
452      m_actionToggleRestoreWinDim =      m_actionToggleRestoreWinDim =
453          m_actionGroup->add_action_bool("AutoRestoreWinDim", sigc::mem_fun(*this, &MainWindow::on_auto_restore_win_dim), Settings::singleton()->autoRestoreWindowDimension);          m_actionGroup->add_action_bool("AutoRestoreWinDim", sigc::mem_fun(*this, &MainWindow::on_auto_restore_win_dim), Settings::singleton()->autoRestoreWindowDimension);
454        m_actionToggleShowTooltips = m_actionGroup->add_action_bool(
455            "ShowTooltips", sigc::mem_fun(*this, &MainWindow::on_action_show_tooltips),
456            Settings::singleton()->showTooltips
457        );
458      m_actionToggleSaveWithTempFile =      m_actionToggleSaveWithTempFile =
459          m_actionGroup->add_action_bool("SaveWithTemporaryFile", sigc::mem_fun(*this, &MainWindow::on_save_with_temporary_file), Settings::singleton()->saveWithTemporaryFile);          m_actionGroup->add_action_bool("SaveWithTemporaryFile", sigc::mem_fun(*this, &MainWindow::on_save_with_temporary_file), Settings::singleton()->saveWithTemporaryFile);
460      m_actionGroup->add_action("RefreshAll", sigc::mem_fun(*this, &MainWindow::on_action_refresh_all));      m_actionGroup->add_action("RefreshAll", sigc::mem_fun(*this, &MainWindow::on_action_refresh_all));
# Line 480  MainWindow::MainWindow() : Line 478  MainWindow::MainWindow() :
478                           *this, &MainWindow::on_auto_restore_win_dim));                           *this, &MainWindow::on_auto_restore_win_dim));
479    
480      toggle_action =      toggle_action =
481            Gtk::ToggleAction::create("ShowTooltips", _("Tooltips for Beginners"));
482        toggle_action->set_active(Settings::singleton()->showTooltips);
483        actionGroup->add(
484            toggle_action,
485            sigc::mem_fun(*this, &MainWindow::on_action_show_tooltips)
486        );
487    
488        toggle_action =
489          Gtk::ToggleAction::create("SaveWithTemporaryFile", _("Save with _temporary file"));          Gtk::ToggleAction::create("SaveWithTemporaryFile", _("Save with _temporary file"));
490      toggle_action->set_active(Settings::singleton()->saveWithTemporaryFile);      toggle_action->set_active(Settings::singleton()->saveWithTemporaryFile);
491      actionGroup->add(toggle_action,      actionGroup->add(toggle_action,
# Line 921  MainWindow::MainWindow() : Line 927  MainWindow::MainWindow() :
927          "          <attribute name='label' translatable='yes'>Statusbar</attribute>"          "          <attribute name='label' translatable='yes'>Statusbar</attribute>"
928          "          <attribute name='action'>AppMenu.Statusbar</attribute>"          "          <attribute name='action'>AppMenu.Statusbar</attribute>"
929          "        </item>"          "        </item>"
930            "        <item id='ShowTooltips'>"
931            "          <attribute name='label' translatable='yes'>Tooltips for Beginners</attribute>"
932            "          <attribute name='action'>AppMenu.ShowTooltips</attribute>"
933            "        </item>"
934          "        <item id='AutoRestoreWinDim'>"          "        <item id='AutoRestoreWinDim'>"
935          "          <attribute name='label' translatable='yes'>Auto restore Window Dimensions</attribute>"          "          <attribute name='label' translatable='yes'>Auto restore Window Dimensions</attribute>"
936          "          <attribute name='action'>AppMenu.AutoRestoreWinDim</attribute>"          "          <attribute name='action'>AppMenu.AutoRestoreWinDim</attribute>"
# Line 1151  MainWindow::MainWindow() : Line 1161  MainWindow::MainWindow() :
1161          "    </menu>"          "    </menu>"
1162          "    <menu action='MenuView'>"          "    <menu action='MenuView'>"
1163          "      <menuitem action='Statusbar'/>"          "      <menuitem action='Statusbar'/>"
1164            "      <menuitem action='ShowTooltips'/>"
1165          "      <menuitem action='AutoRestoreWinDim'/>"          "      <menuitem action='AutoRestoreWinDim'/>"
1166          "      <separator/>"          "      <separator/>"
1167          "      <menuitem action='RefreshAll'/>"          "      <menuitem action='RefreshAll'/>"
# Line 1339  MainWindow::MainWindow() : Line 1350  MainWindow::MainWindow() :
1350      m_TreeView.set_model(m_refTreeModelFilter);      m_TreeView.set_model(m_refTreeModelFilter);
1351    
1352      m_TreeView.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);      m_TreeView.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
1353      m_TreeView.set_tooltip_text(_("Right click here for actions on instruments & MIDI Rules. Drag & drop to change the order of instruments."));      m_TreeView.set_has_tooltip(true);
1354        m_TreeView.signal_query_tooltip().connect(
1355            sigc::mem_fun(*this, &MainWindow::onQueryTreeViewTooltip)
1356        );
1357      instrument_name_connection = m_refTreeModel->signal_row_changed().connect(      instrument_name_connection = m_refTreeModel->signal_row_changed().connect(
1358          sigc::mem_fun(*this, &MainWindow::instrument_name_changed)          sigc::mem_fun(*this, &MainWindow::instrument_name_changed)
1359      );      );
# Line 1496  MainWindow::MainWindow() : Line 1510  MainWindow::MainWindow() :
1510          sigc::hide(          sigc::hide(
1511              sigc::bind(              sigc::bind(
1512                  file_structure_to_be_changed_signal.make_slot(),                  file_structure_to_be_changed_signal.make_slot(),
1513    #if SIGCXX_MAJOR_VERSION > 2 || (SIGCXX_MAJOR_VERSION == 2 && SIGCXX_MINOR_VERSION >= 8)
1514                    std::ref(this->file)
1515    #else
1516                  sigc::ref(this->file)                  sigc::ref(this->file)
1517    #endif
1518              )              )
1519          )          )
1520      );      );
# Line 1504  MainWindow::MainWindow() : Line 1522  MainWindow::MainWindow() :
1522          sigc::hide(          sigc::hide(
1523              sigc::bind(              sigc::bind(
1524                  file_structure_changed_signal.make_slot(),                  file_structure_changed_signal.make_slot(),
1525    #if SIGCXX_MAJOR_VERSION > 2 || (SIGCXX_MAJOR_VERSION == 2 && SIGCXX_MINOR_VERSION >= 8)
1526                    std::ref(this->file)
1527    #else
1528                  sigc::ref(this->file)                  sigc::ref(this->file)
1529    #endif
1530              )              )
1531          )          )
1532      );      );
# Line 1526  MainWindow::MainWindow() : Line 1548  MainWindow::MainWindow() :
1548          sigc::mem_fun(*this, &MainWindow::update_dimregs));          sigc::mem_fun(*this, &MainWindow::update_dimregs));
1549    
1550      m_searchText.signal_changed().connect(      m_searchText.signal_changed().connect(
1551          sigc::mem_fun(m_refTreeModelFilter.operator->(), &Gtk::TreeModelFilter::refilter)          sigc::mem_fun(*m_refTreeModelFilter.operator->(), &Gtk::TreeModelFilter::refilter)
1552      );      );
1553    
1554      file = 0;      file = 0;
# Line 1580  MainWindow::MainWindow() : Line 1602  MainWindow::MainWindow() :
1602          Gtk::AccelMap::add_entry("<Macros>/macro_9", GDK_KEY_F10, noModifier);          Gtk::AccelMap::add_entry("<Macros>/macro_9", GDK_KEY_F10, noModifier);
1603          Gtk::AccelMap::add_entry("<Macros>/macro_10", GDK_KEY_F11, noModifier);          Gtk::AccelMap::add_entry("<Macros>/macro_10", GDK_KEY_F11, noModifier);
1604          Gtk::AccelMap::add_entry("<Macros>/macro_11", GDK_KEY_F12, noModifier);          Gtk::AccelMap::add_entry("<Macros>/macro_11", GDK_KEY_F12, noModifier);
1605            Gtk::AccelMap::add_entry("<Macros>/macro_12", GDK_KEY_F13, noModifier);
1606            Gtk::AccelMap::add_entry("<Macros>/macro_13", GDK_KEY_F14, noModifier);
1607            Gtk::AccelMap::add_entry("<Macros>/macro_14", GDK_KEY_F15, noModifier);
1608            Gtk::AccelMap::add_entry("<Macros>/macro_15", GDK_KEY_F16, noModifier);
1609            Gtk::AccelMap::add_entry("<Macros>/macro_16", GDK_KEY_F17, noModifier);
1610            Gtk::AccelMap::add_entry("<Macros>/macro_17", GDK_KEY_F18, noModifier);
1611            Gtk::AccelMap::add_entry("<Macros>/macro_18", GDK_KEY_F19, noModifier);
1612          Gtk::AccelMap::add_entry("<Macros>/SetupMacros", 'm', primaryModifierKey);          Gtk::AccelMap::add_entry("<Macros>/SetupMacros", 'm', primaryModifierKey);
1613    
1614          Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group();          Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group();
# Line 1602  MainWindow::MainWindow() : Line 1631  MainWindow::MainWindow() :
1631          Gtk::AccelMap::add_entry("<Scripts>/script_9", GDK_KEY_F10, Gdk::SHIFT_MASK);          Gtk::AccelMap::add_entry("<Scripts>/script_9", GDK_KEY_F10, Gdk::SHIFT_MASK);
1632          Gtk::AccelMap::add_entry("<Scripts>/script_10", GDK_KEY_F11, Gdk::SHIFT_MASK);          Gtk::AccelMap::add_entry("<Scripts>/script_10", GDK_KEY_F11, Gdk::SHIFT_MASK);
1633          Gtk::AccelMap::add_entry("<Scripts>/script_11", GDK_KEY_F12, Gdk::SHIFT_MASK);          Gtk::AccelMap::add_entry("<Scripts>/script_11", GDK_KEY_F12, Gdk::SHIFT_MASK);
1634            Gtk::AccelMap::add_entry("<Scripts>/script_12", GDK_KEY_F13, Gdk::SHIFT_MASK);
1635            Gtk::AccelMap::add_entry("<Scripts>/script_13", GDK_KEY_F14, Gdk::SHIFT_MASK);
1636            Gtk::AccelMap::add_entry("<Scripts>/script_14", GDK_KEY_F15, Gdk::SHIFT_MASK);
1637            Gtk::AccelMap::add_entry("<Scripts>/script_15", GDK_KEY_F16, Gdk::SHIFT_MASK);
1638            Gtk::AccelMap::add_entry("<Scripts>/script_16", GDK_KEY_F17, Gdk::SHIFT_MASK);
1639            Gtk::AccelMap::add_entry("<Scripts>/script_17", GDK_KEY_F18, Gdk::SHIFT_MASK);
1640            Gtk::AccelMap::add_entry("<Scripts>/script_18", GDK_KEY_F19, Gdk::SHIFT_MASK);
1641            Gtk::AccelMap::add_entry("<Scripts>/DropAllScriptSlots", GDK_KEY_BackSpace, Gdk::SHIFT_MASK);
1642    
1643          Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group();          Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group();
1644          assign_scripts_menu->set_accel_group(accelGroup);          assign_scripts_menu->set_accel_group(accelGroup);
1645      }      }
1646    
1647        on_show_tooltips_changed();
1648    
1649      Glib::signal_idle().connect_once(      Glib::signal_idle().connect_once(
1650          sigc::mem_fun(*this, &MainWindow::bringToFront),          sigc::mem_fun(*this, &MainWindow::bringToFront),
1651          200          200
# Line 1847  void MainWindow::on_sel_change() Line 1886  void MainWindow::on_sel_change()
1886      }      }
1887  }  }
1888    
1889    
1890    LoaderSaverBase::LoaderSaverBase(const Glib::ustring filename, gig::File* gig) :
1891        filename(filename), gig(gig),
1892    #ifdef GLIB_THREADS
1893        thread(0),
1894    #endif
1895        progress(0.f)
1896    {
1897    }
1898    
1899  void loader_progress_callback(gig::progress_t* progress)  void loader_progress_callback(gig::progress_t* progress)
1900  {  {
1901      Loader* loader = static_cast<Loader*>(progress->custom);      LoaderSaverBase* loader = static_cast<LoaderSaverBase*>(progress->custom);
1902      loader->progress_callback(progress->factor);      loader->progress_callback(progress->factor);
1903  }  }
1904    
1905  void Loader::progress_callback(float fraction)  void LoaderSaverBase::progress_callback(float fraction)
1906  {  {
1907      {      {
1908    #ifdef GLIB_THREADS
1909          Glib::Threads::Mutex::Lock lock(progressMutex);          Glib::Threads::Mutex::Lock lock(progressMutex);
1910    #else
1911            std::lock_guard<std::mutex> lock(progressMutex);
1912    #endif
1913          progress = fraction;          progress = fraction;
1914      }      }
1915      progress_dispatcher();      progress_dispatcher();
# Line 1866  void Loader::progress_callback(float fra Line 1919  void Loader::progress_callback(float fra
1919  // make sure stack is 16-byte aligned for SSE instructions  // make sure stack is 16-byte aligned for SSE instructions
1920  __attribute__((force_align_arg_pointer))  __attribute__((force_align_arg_pointer))
1921  #endif  #endif
1922  void Loader::thread_function()  void LoaderSaverBase::thread_function()
1923  {  {
1924    #ifdef GLIB_THREADS
1925      printf("thread_function self=%p\n",      printf("thread_function self=%p\n",
1926             static_cast<void*>(Glib::Threads::Thread::self()));             static_cast<void*>(Glib::Threads::Thread::self()));
1927    #else
1928        std::cout << "thread_function self=" << std::this_thread::get_id() << "\n";
1929    #endif
1930      printf("Start %s\n", filename.c_str());      printf("Start %s\n", filename.c_str());
1931      try {      try {
         RIFF::File* riff = new RIFF::File(filename);  
         gig = new gig::File(riff);  
1932          gig::progress_t progress;          gig::progress_t progress;
1933          progress.callback = loader_progress_callback;          progress.callback = loader_progress_callback;
1934          progress.custom = this;          progress.custom = this;
1935    
1936          gig->GetInstrument(0, &progress);          thread_function_sub(progress);
1937          printf("End\n");          printf("End\n");
1938          finished_dispatcher();          finished_dispatcher();
1939      } catch (RIFF::Exception e) {      } catch (RIFF::Exception e) {
# Line 1890  void Loader::thread_function() Line 1945  void Loader::thread_function()
1945      }      }
1946  }  }
1947    
1948  Loader::Loader(const char* filename)  void LoaderSaverBase::launch()
     : filename(filename), gig(0), thread(0), progress(0.f)  
 {  
 }  
   
 void Loader::launch()  
1949  {  {
1950    #ifdef GLIB_THREADS
1951  #ifdef OLD_THREADS  #ifdef OLD_THREADS
1952      thread = Glib::Thread::create(sigc::mem_fun(*this, &Loader::thread_function), true);      thread = Glib::Thread::create(sigc::mem_fun(*this, &LoaderSaverBase::thread_function), true);
1953  #else  #else
1954      thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Loader::thread_function));      thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &LoaderSaverBase::thread_function));
1955  #endif  #endif
1956      printf("launch thread=%p\n", static_cast<void*>(thread));      printf("launch thread=%p\n", static_cast<void*>(thread));
1957    #else
1958        thread = std::thread([this](){ thread_function(); });
1959        std::cout << "launch thread=" << thread.get_id() << "\n";
1960    #endif
1961  }  }
1962    
1963  float Loader::get_progress()  float LoaderSaverBase::get_progress()
1964  {  {
1965      float res;  #ifdef GLIB_THREADS
1966      {      Glib::Threads::Mutex::Lock lock(progressMutex);
1967          Glib::Threads::Mutex::Lock lock(progressMutex);  #else
1968          res = progress;      std::lock_guard<std::mutex> lock(progressMutex);
1969      }  #endif
1970      return res;      return progress;
1971  }  }
1972    
1973  Glib::Dispatcher& Loader::signal_progress()  Glib::Dispatcher& LoaderSaverBase::signal_progress()
1974  {  {
1975      return progress_dispatcher;      return progress_dispatcher;
1976  }  }
1977    
1978  Glib::Dispatcher& Loader::signal_finished()  Glib::Dispatcher& LoaderSaverBase::signal_finished()
1979  {  {
1980      return finished_dispatcher;      return finished_dispatcher;
1981  }  }
1982    
1983  Glib::Dispatcher& Loader::signal_error()  Glib::Dispatcher& LoaderSaverBase::signal_error()
1984  {  {
1985      return error_dispatcher;      return error_dispatcher;
1986  }  }
1987    
1988  void saver_progress_callback(gig::progress_t* progress)  void LoaderSaverBase::join() {
1989  {  #ifdef GLIB_THREADS
1990      Saver* saver = static_cast<Saver*>(progress->custom);      thread->join();
1991      saver->progress_callback(progress->factor);  #else
1992        thread.join();
1993    #endif
1994  }  }
1995    
1996  void Saver::progress_callback(float fraction)  
1997    Loader::Loader(const char* filename) :
1998        LoaderSaverBase(filename, 0)
1999  {  {
     {  
         Glib::Threads::Mutex::Lock lock(progressMutex);  
         progress = fraction;  
     }  
     progress_dispatcher.emit();  
2000  }  }
2001    
2002  #if defined(WIN32) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2))  void Loader::thread_function_sub(gig::progress_t& progress)
 // make sure stack is 16-byte aligned for SSE instructions  
 __attribute__((force_align_arg_pointer))  
 #endif  
 void Saver::thread_function()  
2003  {  {
2004      printf("thread_function self=%p\n",      RIFF::File* riff = new RIFF::File(filename);
2005             static_cast<void*>(Glib::Threads::Thread::self()));      gig = new gig::File(riff);
     printf("Start %s\n", filename.c_str());  
     try {  
         gig::progress_t progress;  
         progress.callback = saver_progress_callback;  
         progress.custom = this;  
   
         // if no filename was provided, that means "save", if filename was provided means "save as"  
         if (filename.empty()) {  
             if (!Settings::singleton()->saveWithTemporaryFile) {  
                 // save directly over the existing .gig file  
                 // (requires less disk space than solution below  
                 // but may be slower)  
                 gig->Save(&progress);  
             } else {  
                 // save the file as separate temporary file first,  
                 // then move the saved file over the old file  
                 // (may result in performance speedup during save)  
                 gig::String tmpname = filename + ".TMP";  
                 gig->Save(tmpname, &progress);  
                 #if defined(WIN32)  
                 if (!DeleteFile(filename.c_str())) {  
                     throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file).");  
                 }  
                 #else // POSIX ...  
                 if (unlink(filename.c_str())) {  
                     throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file): " + gig::String(strerror(errno)));  
                 }  
                 #endif  
                 if (rename(tmpname.c_str(), filename.c_str())) {  
                     #if defined(WIN32)  
                     throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file).");  
                     #else  
                     throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file): " + gig::String(strerror(errno)));  
                     #endif  
                 }  
             }  
         } else {  
             gig->Save(filename, &progress);  
         }  
2006    
2007          printf("End\n");      gig->GetInstrument(0, &progress);
         finished_dispatcher.emit();  
     } catch (RIFF::Exception e) {  
         error_message = e.Message;  
         error_dispatcher.emit();  
     } catch (...) {  
         error_message = _("Unknown exception occurred");  
         error_dispatcher.emit();  
     }  
2008  }  }
2009    
2010  Saver::Saver(gig::File* file, Glib::ustring filename)  
2011      : gig(file), filename(filename), thread(0), progress(0.f)  Saver::Saver(gig::File* file, Glib::ustring filename) :
2012        LoaderSaverBase(filename, file)
2013  {  {
2014  }  }
2015    
2016  void Saver::launch()  void Saver::thread_function_sub(gig::progress_t& progress)
2017  {  {
2018  #ifdef OLD_THREADS      // if no filename was provided, that means "save", if filename was provided means "save as"
2019      thread = Glib::Thread::create(sigc::mem_fun(*this, &Saver::thread_function), true);      if (filename.empty()) {
2020            if (!Settings::singleton()->saveWithTemporaryFile) {
2021                // save directly over the existing .gig file
2022                // (requires less disk space than solution below
2023                // but may be slower)
2024                gig->Save(&progress);
2025            } else {
2026                // save the file as separate temporary file first,
2027                // then move the saved file over the old file
2028                // (may result in performance speedup during save)
2029                gig::String tmpname = filename + ".TMP";
2030                gig->Save(tmpname, &progress);
2031    #if defined(WIN32)
2032                if (!DeleteFile(filename.c_str())) {
2033                    throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file).");
2034                }
2035    #else // POSIX ...
2036                if (unlink(filename.c_str())) {
2037                    throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file): " + gig::String(strerror(errno)));
2038                }
2039    #endif
2040                if (rename(tmpname.c_str(), filename.c_str())) {
2041    #if defined(WIN32)
2042                    throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file).");
2043  #else  #else
2044      thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Saver::thread_function));                  throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file): " + gig::String(strerror(errno)));
2045  #endif  #endif
2046      printf("launch thread=%p\n", static_cast<void*>(thread));              }
2047  }          }
2048        } else {
2049  float Saver::get_progress()          gig->Save(filename, &progress);
 {  
     float res;  
     {  
         Glib::Threads::Mutex::Lock lock(progressMutex);  
         res = progress;  
2050      }      }
     return res;  
2051  }  }
2052    
 Glib::Dispatcher& Saver::signal_progress()  
 {  
     return progress_dispatcher;  
 }  
   
 Glib::Dispatcher& Saver::signal_finished()  
 {  
     return finished_dispatcher;  
 }  
   
 Glib::Dispatcher& Saver::signal_error()  
 {  
     return error_dispatcher;  
 }  
2053    
2054  ProgressDialog::ProgressDialog(const Glib::ustring& title, Gtk::Window& parent)  ProgressDialog::ProgressDialog(const Glib::ustring& title, Gtk::Window& parent)
2055      : Gtk::Dialog(title, parent, true)      : Gtk::Dialog(title, parent, true)
# Line 2198  void MainWindow::on_action_file_open() Line 2205  void MainWindow::on_action_file_open()
2205          dialog.set_current_folder(current_gig_dir);          dialog.set_current_folder(current_gig_dir);
2206      }      }
2207      if (dialog.run() == Gtk::RESPONSE_OK) {      if (dialog.run() == Gtk::RESPONSE_OK) {
2208            dialog.hide();
2209          std::string filename = dialog.get_filename();          std::string filename = dialog.get_filename();
2210          printf("filename=%s\n", filename.c_str());          printf("filename=%s\n", filename.c_str());
2211    #ifdef GLIB_THREADS
2212          printf("on_action_file_open self=%p\n",          printf("on_action_file_open self=%p\n",
2213                 static_cast<void*>(Glib::Threads::Thread::self()));                 static_cast<void*>(Glib::Threads::Thread::self()));
2214    #else
2215            std::cout << "on_action_file_open self=" <<
2216                std::this_thread::get_id() << "\n";
2217    #endif
2218          load_file(filename.c_str());          load_file(filename.c_str());
2219          current_gig_dir = Glib::path_get_dirname(filename);          current_gig_dir = Glib::path_get_dirname(filename);
2220      }      }
# Line 2274  void MainWindow::on_loader_progress() Line 2287  void MainWindow::on_loader_progress()
2287    
2288  void MainWindow::on_loader_finished()  void MainWindow::on_loader_finished()
2289  {  {
2290        loader->join();
2291      printf("Loader finished!\n");      printf("Loader finished!\n");
2292    #ifdef GLIB_THREADS
2293      printf("on_loader_finished self=%p\n",      printf("on_loader_finished self=%p\n",
2294             static_cast<void*>(Glib::Threads::Thread::self()));             static_cast<void*>(Glib::Threads::Thread::self()));
2295    #else
2296        std::cout << "on_loader_finished self=" <<
2297            std::this_thread::get_id() << "\n";
2298    #endif
2299      load_gig(loader->gig, loader->filename.c_str());      load_gig(loader->gig, loader->filename.c_str());
2300      progress_dialog->hide();      progress_dialog->hide();
2301  }  }
2302    
2303  void MainWindow::on_loader_error()  void MainWindow::on_loader_error()
2304  {  {
2305        loader->join();
2306      Glib::ustring txt = _("Could not load file: ") + loader->error_message;      Glib::ustring txt = _("Could not load file: ") + loader->error_message;
2307      Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);      Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);
2308      msg.run();      msg.run();
# Line 2353  void MainWindow::on_saver_progress() Line 2373  void MainWindow::on_saver_progress()
2373    
2374  void MainWindow::on_saver_error()  void MainWindow::on_saver_error()
2375  {  {
2376        saver->join();
2377      file_structure_changed_signal.emit(this->file);      file_structure_changed_signal.emit(this->file);
2378      Glib::ustring txt = _("Could not save file: ") + saver->error_message;      Glib::ustring txt = _("Could not save file: ") + saver->error_message;
2379      Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);      Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR);
# Line 2361  void MainWindow::on_saver_error() Line 2382  void MainWindow::on_saver_error()
2382    
2383  void MainWindow::on_saver_finished()  void MainWindow::on_saver_finished()
2384  {  {
2385        saver->join();
2386      this->file = saver->gig;      this->file = saver->gig;
2387      this->filename = saver->filename;      this->filename = saver->filename;
2388      current_gig_dir = Glib::path_get_dirname(filename);      current_gig_dir = Glib::path_get_dirname(filename);
# Line 2452  bool MainWindow::file_save_as() Line 2474  bool MainWindow::file_save_as()
2474  #endif  #endif
2475    
2476      if (dialog.run() == Gtk::RESPONSE_OK) {      if (dialog.run() == Gtk::RESPONSE_OK) {
2477            dialog.hide();
2478          std::string filename = dialog.get_filename();          std::string filename = dialog.get_filename();
2479          if (!Glib::str_has_suffix(filename, ".gig")) {          if (!Glib::str_has_suffix(filename, ".gig")) {
2480              filename += ".gig";              filename += ".gig";
# Line 2589  void MainWindow::on_action_warn_user_on_ Line 2612  void MainWindow::on_action_warn_user_on_
2612          !Settings::singleton()->warnUserOnExtensions;          !Settings::singleton()->warnUserOnExtensions;
2613  }  }
2614    
2615    void MainWindow::on_action_show_tooltips() {
2616        Settings::singleton()->showTooltips =
2617            !Settings::singleton()->showTooltips;
2618    
2619        on_show_tooltips_changed();
2620    }
2621    
2622    void MainWindow::on_show_tooltips_changed() {
2623        const bool b = Settings::singleton()->showTooltips;
2624    
2625        dimreg_label.set_has_tooltip(b);
2626        dimreg_all_regions.set_has_tooltip(b);
2627        dimreg_all_dimregs.set_has_tooltip(b);
2628        dimreg_stereo.set_has_tooltip(b);
2629    
2630        // Not doing this here, we let onQueryTreeViewTooltip() handle this per cell
2631        //m_TreeView.set_has_tooltip(b);
2632    
2633        m_TreeViewSamples.set_has_tooltip(b);
2634        m_TreeViewScripts.set_has_tooltip(b);
2635    
2636        set_has_tooltip(b);
2637    }
2638    
2639  void MainWindow::on_action_sync_sampler_instrument_selection() {  void MainWindow::on_action_sync_sampler_instrument_selection() {
2640      Settings::singleton()->syncSamplerInstrumentSelection =      Settings::singleton()->syncSamplerInstrumentSelection =
2641          !Settings::singleton()->syncSamplerInstrumentSelection;          !Settings::singleton()->syncSamplerInstrumentSelection;
# Line 2608  void MainWindow::on_action_help_about() Line 2655  void MainWindow::on_action_help_about()
2655      dialog.set_name("Gigedit");      dialog.set_name("Gigedit");
2656  #endif  #endif
2657      dialog.set_version(VERSION);      dialog.set_version(VERSION);
2658      dialog.set_copyright("Copyright (C) 2006-2017 Andreas Persson");      dialog.set_copyright("Copyright (C) 2006-2019 Andreas Persson");
2659      const std::string sComment =      const std::string sComment =
2660          _("Built " __DATE__ "\nUsing ") +          _("Built " __DATE__ "\nUsing ") +
2661          ::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" +          ::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" +
# Line 2619  void MainWindow::on_action_help_about() Line 2666  void MainWindow::on_action_help_about()
2666              "backup your Gigasampler/GigaStudio files before editing them with "              "backup your Gigasampler/GigaStudio files before editing them with "
2667              "this application.\n"              "this application.\n"
2668              "\n"              "\n"
2669              "Please report bugs to: http://bugs.linuxsampler.org"              "Please report bugs to: https://bugs.linuxsampler.org"
2670          );          );
2671      dialog.set_comments(sComment.c_str());      dialog.set_comments(sComment.c_str());
2672      dialog.set_website("http://www.linuxsampler.org");      dialog.set_website("https://www.linuxsampler.org");
2673      dialog.set_website_label("http://www.linuxsampler.org");      dialog.set_website_label("https://www.linuxsampler.org");
2674      dialog.set_position(Gtk::WIN_POS_CENTER);      dialog.set_position(Gtk::WIN_POS_CENTER);
2675      dialog.run();      dialog.run();
2676  }  }
# Line 2662  PropDialog::PropDialog() Line 2709  PropDialog::PropDialog()
2709      set_title(_("File Properties"));      set_title(_("File Properties"));
2710      eName.set_width_chars(50);      eName.set_width_chars(50);
2711    
2712        connect(eFileFormat, &PropDialog::set_FileFormat);
2713      connect(eName, &DLS::Info::Name);      connect(eName, &DLS::Info::Name);
2714      connect(eCreationDate, &DLS::Info::CreationDate);      connect(eCreationDate, &DLS::Info::CreationDate);
2715      connect(eComments, &DLS::Info::Comments);      connect(eComments, &DLS::Info::Comments);
# Line 2704  PropDialog::PropDialog() Line 2752  PropDialog::PropDialog()
2752  #endif  #endif
2753    
2754      add(vbox);      add(vbox);
2755  #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22)  #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24)
2756      table.set_margin(5);      table.set_margin(5);
2757  #else  #else
2758      table.set_border_width(5);      table.set_border_width(5);
# Line 2712  PropDialog::PropDialog() Line 2760  PropDialog::PropDialog()
2760      vbox.add(table);      vbox.add(table);
2761      vbox.pack_start(buttonBox, Gtk::PACK_SHRINK);      vbox.pack_start(buttonBox, Gtk::PACK_SHRINK);
2762      buttonBox.set_layout(Gtk::BUTTONBOX_END);      buttonBox.set_layout(Gtk::BUTTONBOX_END);
2763  #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22)  #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24)
2764      buttonBox.set_margin(5);      buttonBox.set_margin(5);
2765  #else  #else
2766      buttonBox.set_border_width(5);      buttonBox.set_border_width(5);
# Line 2723  PropDialog::PropDialog() Line 2771  PropDialog::PropDialog()
2771      quitButton.grab_focus();      quitButton.grab_focus();
2772      quitButton.signal_clicked().connect(      quitButton.signal_clicked().connect(
2773          sigc::mem_fun(*this, &PropDialog::hide));          sigc::mem_fun(*this, &PropDialog::hide));
     eFileFormat.signal_value_changed().connect(  
         sigc::mem_fun(*this, &PropDialog::onFileFormatChanged));  
2774    
2775      quitButton.show();      quitButton.show();
2776      vbox.show();      vbox.show();
# Line 2736  PropDialog::PropDialog() Line 2782  PropDialog::PropDialog()
2782  void PropDialog::set_file(gig::File* file)  void PropDialog::set_file(gig::File* file)
2783  {  {
2784      m_file = file;      m_file = file;
2785        update(file->pInfo);
2786    
2787      // update file format version combo box      // update file format version combo box
2788      const std::string sGiga = "Gigasampler/GigaStudio v";      const std::string sGiga = "Gigasampler/GigaStudio v";
# Line 2743  void PropDialog::set_file(gig::File* fil Line 2790  void PropDialog::set_file(gig::File* fil
2790      std::vector<std::string> txts;      std::vector<std::string> txts;
2791      std::vector<int> values;      std::vector<int> values;
2792      txts.push_back(sGiga + "2"); values.push_back(2);      txts.push_back(sGiga + "2"); values.push_back(2);
2793      txts.push_back(sGiga + "3/v4"); values.push_back(3);      txts.push_back(sGiga + "3"); values.push_back(3);
2794      if (major != 2 && major != 3) {      txts.push_back(sGiga + "4"); values.push_back(4);
2795        if (major < 2 || major > 4) {
2796          txts.push_back(sGiga + ToString(major)); values.push_back(major);          txts.push_back(sGiga + ToString(major)); values.push_back(major);
2797      }      }
2798      std::vector<const char*> texts;      std::vector<const char*> texts;
2799      for (int i = 0; i < txts.size(); ++i) texts.push_back(txts[i].c_str());      for (int i = 0; i < txts.size(); ++i) texts.push_back(txts[i].c_str());
2800      texts.push_back(NULL); values.push_back(0);      texts.push_back(NULL); values.push_back(0);
2801    
2802        update_model++;
2803      eFileFormat.set_choices(&texts[0], &values[0]);      eFileFormat.set_choices(&texts[0], &values[0]);
2804      eFileFormat.set_value(major);      eFileFormat.set_value(major);
2805        update_model--;
2806  }  }
2807    
2808  void PropDialog::onFileFormatChanged() {  void PropDialog::set_FileFormat(int value)
     const int major = eFileFormat.get_value();  
     if (m_file) m_file->pVersion->major = major;  
 }  
   
 void PropDialog::set_info(DLS::Info* info)  
2809  {  {
2810      update(info);      m_file->pVersion->major = value;
2811  }  }
2812    
2813    
# Line 2863  InstrumentProps::InstrumentProps() : Line 2909  InstrumentProps::InstrumentProps() :
2909      table.add(eDimensionKeyRangeHigh);      table.add(eDimensionKeyRangeHigh);
2910    
2911      add(vbox);      add(vbox);
2912  #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22)  #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24)
2913      table.set_margin(5);      table.set_margin(5);
2914  #else  #else
2915      table.set_border_width(5);      table.set_border_width(5);
# Line 2872  InstrumentProps::InstrumentProps() : Line 2918  InstrumentProps::InstrumentProps() :
2918      table.show();      table.show();
2919      vbox.pack_start(buttonBox, Gtk::PACK_SHRINK);      vbox.pack_start(buttonBox, Gtk::PACK_SHRINK);
2920      buttonBox.set_layout(Gtk::BUTTONBOX_END);      buttonBox.set_layout(Gtk::BUTTONBOX_END);
2921  #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22)  #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24)
2922      buttonBox.set_margin(5);      buttonBox.set_margin(5);
2923  #else  #else
2924      buttonBox.set_border_width(5);      buttonBox.set_border_width(5);
# Line 2934  void MainWindow::updateSampleRefCountMap Line 2980  void MainWindow::updateSampleRefCountMap
2980      }      }
2981  }  }
2982    
2983    bool MainWindow::onQueryTreeViewTooltip(int x, int y, bool keyboardTip, const Glib::RefPtr<Gtk::Tooltip>& tooltip) {
2984        Gtk::TreeModel::iterator iter;
2985        if (!m_TreeView.get_tooltip_context_iter(x, y, keyboardTip, iter)) {
2986            return false;
2987        }
2988        Gtk::TreeModel::Path path(iter);
2989        Gtk::TreeModel::Row row = *iter;
2990        Gtk::TreeViewColumn* pointedColumn = NULL;
2991        // resolve the precise table column the mouse points to
2992        {
2993            Gtk::TreeModel::Path path; // unused
2994            int cellX, cellY; // unused
2995            m_TreeView.get_path_at_pos(x, y, path, pointedColumn, cellX, cellY);
2996        }
2997        Gtk::TreeViewColumn* scriptsColumn = m_TreeView.get_column(2);
2998        if (pointedColumn == scriptsColumn) { // mouse hovers scripts column ...
2999            // show the script(s) assigned to the hovered instrument as tooltip
3000            tooltip->set_markup( row[m_Columns.m_col_tooltip] );
3001            m_TreeView.set_tooltip_cell(tooltip, &path, scriptsColumn, NULL);
3002        } else {
3003            // if beginners' tooltips is disabled then don't show the following one
3004            if (!Settings::singleton()->showTooltips)
3005                return false;
3006            // yeah, a beginners tooltip
3007            tooltip->set_text(_(
3008                "Right click here for actions on instruments & MIDI Rules. "
3009                "Drag & drop to change the order of instruments."
3010            ));
3011            m_TreeView.set_tooltip_cell(tooltip, &path, pointedColumn, NULL);
3012        }
3013        return true;
3014    }
3015    
3016    static Glib::ustring scriptTooltipFor(gig::Instrument* instrument, int index) {
3017        Glib::ustring name(gig_to_utf8(instrument->pInfo->Name));
3018        const int iScriptSlots = instrument->ScriptSlotCount();
3019        Glib::ustring tooltip = "<u>(" + ToString(index) + ") “"  + name + "”</u>\n\n";
3020        if (!iScriptSlots)
3021            tooltip += "<span foreground='red'><i>No script assigned</i></span>";
3022        else {
3023            for (int i = 0; i < iScriptSlots; ++i) {
3024                tooltip += "• " + ToString(i+1) + ". Script: “<span foreground='#46DEFF'><b>" +
3025                           instrument->GetScriptOfSlot(i)->Name + "</b></span>”";
3026                if (i + 1 < iScriptSlots) tooltip += "\n\n";
3027            }
3028        }
3029        return tooltip;
3030    }
3031    
3032  void MainWindow::load_gig(gig::File* gig, const char* filename, bool isSharedInstrument)  void MainWindow::load_gig(gig::File* gig, const char* filename, bool isSharedInstrument)
3033  {  {
3034      file = 0;      file = 0;
# Line 2948  void MainWindow::load_gig(gig::File* gig Line 3043  void MainWindow::load_gig(gig::File* gig
3043      file_is_changed = false;      file_is_changed = false;
3044    
3045      propDialog.set_file(gig);      propDialog.set_file(gig);
     propDialog.set_info(gig->pInfo);  
3046    
3047      instrument_name_connection.block();      instrument_name_connection.block();
3048      int index = 0;      int index = 0;
# Line 2963  void MainWindow::load_gig(gig::File* gig Line 3057  void MainWindow::load_gig(gig::File* gig
3057          row[m_Columns.m_col_name] = name;          row[m_Columns.m_col_name] = name;
3058          row[m_Columns.m_col_instr] = instrument;          row[m_Columns.m_col_instr] = instrument;
3059          row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : "";          row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : "";
3060            row[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index);
3061    
3062  #if !USE_GTKMM_BUILDER  #if !USE_GTKMM_BUILDER
3063          add_instrument_to_menu(name);          add_instrument_to_menu(name);
# Line 3080  void MainWindow::instr_name_changed_by_i Line 3175  void MainWindow::instr_name_changed_by_i
3175      gig::Instrument* instrument = row[m_Columns.m_col_instr];      gig::Instrument* instrument = row[m_Columns.m_col_instr];
3176      Glib::ustring gigname(gig_to_utf8(instrument->pInfo->Name));      Glib::ustring gigname(gig_to_utf8(instrument->pInfo->Name));
3177      if (gigname != name) {      if (gigname != name) {
3178            Gtk::TreeModel::Path path(*it);
3179            const int index = path[0];
3180          row[m_Columns.m_col_name] = gigname;          row[m_Columns.m_col_name] = gigname;
3181            row[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index);
3182      }      }
3183  }  }
3184    
# Line 3126  void MainWindow::onScriptSlotsModified(g Line 3224  void MainWindow::onScriptSlotsModified(g
3224          Gtk::TreeModel::Row row = model->children()[i];          Gtk::TreeModel::Row row = model->children()[i];
3225          if (row[m_Columns.m_col_instr] != pInstrument) continue;          if (row[m_Columns.m_col_instr] != pInstrument) continue;
3226          row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : "";          row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : "";
3227            row[m_Columns.m_col_tooltip] = scriptTooltipFor(pInstrument, i);
3228          break;          break;
3229      }      }
3230    
# Line 3151  void MainWindow::assignScript(gig::Scrip Line 3250  void MainWindow::assignScript(gig::Scrip
3250      onScriptSlotsModified(pInstrument);      onScriptSlotsModified(pInstrument);
3251  }  }
3252    
3253    void MainWindow::dropAllScriptSlots() {
3254        gig::Instrument* pInstrument = get_instrument();
3255        if (!pInstrument) {
3256            printf("!instrument\n");
3257            return;
3258        }
3259    
3260        const int iScriptSlots = pInstrument->ScriptSlotCount();
3261        for (int i = iScriptSlots - 1; i >= 0; --i)
3262            pInstrument->RemoveScriptSlot(i);
3263    
3264        onScriptSlotsModified(pInstrument);
3265    }
3266    
3267  void MainWindow::on_action_refresh_all() {  void MainWindow::on_action_refresh_all() {
3268      __refreshEntireGUI();      __refreshEntireGUI();
3269  }  }
# Line 3325  void MainWindow::select_instrument(gig:: Line 3438  void MainWindow::select_instrument(gig::
3438              show_intruments_tab();              show_intruments_tab();
3439              m_TreeView.get_selection()->unselect_all();              m_TreeView.get_selection()->unselect_all();
3440                            
3441  #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22)  #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24)
3442              auto iterSel = model->children()[i].get_iter();              auto iterSel = model->children()[i].get_iter();
3443              m_TreeView.get_selection()->select(iterSel);              m_TreeView.get_selection()->select(iterSel);
3444  #else  #else
# Line 3355  bool MainWindow::select_dimension_region Line 3468  bool MainWindow::select_dimension_region
3468              // select and show the respective instrument in the list view              // select and show the respective instrument in the list view
3469              show_intruments_tab();              show_intruments_tab();
3470              m_TreeView.get_selection()->unselect_all();              m_TreeView.get_selection()->unselect_all();
3471  #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22)  #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24)
3472              auto iterSel = model->children()[i].get_iter();              auto iterSel = model->children()[i].get_iter();
3473              m_TreeView.get_selection()->select(iterSel);              m_TreeView.get_selection()->select(iterSel);
3474  #else  #else
# Line 3391  void MainWindow::select_sample(gig::Samp Line 3504  void MainWindow::select_sample(gig::Samp
3504              if (rowSample[m_SamplesModel.m_col_sample] == sample) {              if (rowSample[m_SamplesModel.m_col_sample] == sample) {
3505                  show_samples_tab();                  show_samples_tab();
3506                  m_TreeViewSamples.get_selection()->unselect_all();                  m_TreeViewSamples.get_selection()->unselect_all();
3507  #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22)  #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24)
3508                  auto iterSel = rowGroup.children()[s].get_iter();                  auto iterSel = rowGroup.children()[s].get_iter();
3509                  m_TreeViewSamples.get_selection()->select(iterSel);                  m_TreeViewSamples.get_selection()->select(iterSel);
3510  #else  #else
# Line 3591  void MainWindow::updateScriptListOfMenu( Line 3704  void MainWindow::updateScriptListOfMenu(
3704          assign_scripts_menu->append(*item);          assign_scripts_menu->append(*item);
3705      }      }
3706    
3707        // add separator line to menu
3708        assign_scripts_menu->append(*new Gtk::SeparatorMenuItem);
3709    
3710        {
3711            Gtk::MenuItem* item = new Gtk::MenuItem(_("Unassign All Scripts"));
3712            item->signal_activate().connect(
3713                sigc::mem_fun(*this, &MainWindow::dropAllScriptSlots)
3714            );
3715            assign_scripts_menu->append(*item);
3716            item->set_accel_path("<Scripts>/DropAllScriptSlots");
3717        }
3718    
3719  #if HAS_GTKMM_SHOW_ALL_CHILDREN  #if HAS_GTKMM_SHOW_ALL_CHILDREN
3720      assign_scripts_menu->show_all_children();      assign_scripts_menu->show_all_children();
3721  #endif  #endif
# Line 3639  void MainWindow::add_instrument(gig::Ins Line 3764  void MainWindow::add_instrument(gig::Ins
3764      instrument_name_connection.block();      instrument_name_connection.block();
3765      Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append();      Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append();
3766      Gtk::TreeModel::Row rowInstr = *iterInstr;      Gtk::TreeModel::Row rowInstr = *iterInstr;
3767      rowInstr[m_Columns.m_col_nr] = m_refTreeModel->children().size() - 1;      const int index = m_refTreeModel->children().size() - 1;
3768        rowInstr[m_Columns.m_col_nr] = index;
3769      rowInstr[m_Columns.m_col_name] = name;      rowInstr[m_Columns.m_col_name] = name;
3770      rowInstr[m_Columns.m_col_instr] = instrument;      rowInstr[m_Columns.m_col_instr] = instrument;
3771      rowInstr[m_Columns.m_col_scripts] = "";      rowInstr[m_Columns.m_col_scripts] = "";
3772        rowInstr[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index);
3773      instrument_name_connection.unblock();      instrument_name_connection.unblock();
3774    
3775  #if !USE_GTKMM_BUILDER  #if !USE_GTKMM_BUILDER
# Line 3729  void MainWindow::on_action_remove_instru Line 3856  void MainWindow::on_action_remove_instru
3856                       it != m_refTreeModel->children().end(); ++it, ++index)                       it != m_refTreeModel->children().end(); ++it, ++index)
3857                  {                  {
3858                      Gtk::TreeModel::Row row = *it;                      Gtk::TreeModel::Row row = *it;
3859                        gig::Instrument* instrument = row[m_Columns.m_col_instr];
3860                      row[m_Columns.m_col_nr] = index;                      row[m_Columns.m_col_nr] = index;
3861                        row[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index);
3862                  }                  }
3863              }              }
3864    
# Line 3982  void MainWindow::add_or_replace_sample(b Line 4111  void MainWindow::add_or_replace_sample(b
4111          dialog.set_current_folder(current_sample_dir);          dialog.set_current_folder(current_sample_dir);
4112      }      }
4113      if (dialog.run() == Gtk::RESPONSE_OK) {      if (dialog.run() == Gtk::RESPONSE_OK) {
4114            dialog.hide();
4115          current_sample_dir = dialog.get_current_folder();          current_sample_dir = dialog.get_current_folder();
4116          Glib::ustring error_files;          Glib::ustring error_files;
4117          std::vector<std::string> filenames = dialog.get_filenames();          std::vector<std::string> filenames = dialog.get_filenames();
# Line 4162  void MainWindow::on_action_replace_all_s Line 4292  void MainWindow::on_action_replace_all_s
4292      }      }
4293      if (dialog.run() == Gtk::RESPONSE_OK)      if (dialog.run() == Gtk::RESPONSE_OK)
4294      {      {
4295            dialog.hide();
4296          current_sample_dir = dialog.get_current_folder();          current_sample_dir = dialog.get_current_folder();
4297          Glib::ustring error_files;          Glib::ustring error_files;
4298          std::string folder = dialog.get_filename();          std::string folder = dialog.get_filename();
# Line 4650  bool MainWindow::instrument_row_visible( Line 4781  bool MainWindow::instrument_row_visible(
4781      trim(pattern);      trim(pattern);
4782      if (pattern.empty()) return true;      if (pattern.empty()) return true;
4783    
4784  #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22)  #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24)
4785      //HACK: on GTKMM4 development branch const_iterator cannot be easily converted to iterator, probably going to be fixed before final GTKMM4 release though.      //HACK: on GTKMM4 development branch const_iterator cannot be easily converted to iterator, probably going to be fixed before final GTKMM4 release though.
4786      Gtk::TreeModel::Row row = **(Gtk::TreeModel::iterator*)(&iter);      Gtk::TreeModel::Row row = **(Gtk::TreeModel::iterator*)(&iter);
4787  #else  #else
# Line 4890  void MainWindow::on_action_merge_files() Line 5021  void MainWindow::on_action_merge_files()
5021  #endif  #endif
5022    
5023      if (dialog.run() == Gtk::RESPONSE_OK) {      if (dialog.run() == Gtk::RESPONSE_OK) {
5024            dialog.hide();
5025    #ifdef GLIB_THREADS
5026          printf("on_action_merge_files self=%p\n",          printf("on_action_merge_files self=%p\n",
5027                 static_cast<void*>(Glib::Threads::Thread::self()));                 static_cast<void*>(Glib::Threads::Thread::self()));
5028    #else
5029            std::cout << "on_action_merge_files self=" <<
5030                std::this_thread::get_id() << "\n";
5031    #endif
5032          std::vector<std::string> filenames = dialog.get_filenames();          std::vector<std::string> filenames = dialog.get_filenames();
5033    
5034          // merge the selected files to the currently open .gig file          // merge the selected files to the currently open .gig file

Legend:
Removed from v.3408  
changed lines
  Added in v.3619

  ViewVC Help
Powered by ViewVC