/[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 3409 by schoenebeck, Tue Jan 23 16:30:56 2018 UTC revision 3636 by schoenebeck, Thu Oct 24 12:06:18 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 1356  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 1487  MainWindow::MainWindow() : Line 1484  MainWindow::MainWindow() :
1484          sigc::mem_fun(*this, &MainWindow::file_changed));          sigc::mem_fun(*this, &MainWindow::file_changed));
1485      instrumentProps.signal_changed().connect(      instrumentProps.signal_changed().connect(
1486          sigc::mem_fun(*this, &MainWindow::file_changed));          sigc::mem_fun(*this, &MainWindow::file_changed));
1487      propDialog.signal_changed().connect(      fileProps.signal_changed().connect(
1488          sigc::mem_fun(*this, &MainWindow::file_changed));          sigc::mem_fun(*this, &MainWindow::file_changed));
1489      midiRules.signal_changed().connect(      midiRules.signal_changed().connect(
1490          sigc::mem_fun(*this, &MainWindow::file_changed));          sigc::mem_fun(*this, &MainWindow::file_changed));
# Line 1513  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 1521  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 1543  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 1597  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 1619  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);
# Line 1866  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 1885  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 1909  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;  
 }  
   
 Glib::Dispatcher& Saver::signal_progress()  
 {  
     return progress_dispatcher;  
 }  
   
 Glib::Dispatcher& Saver::signal_finished()  
 {  
     return finished_dispatcher;  
2051  }  }
2052    
 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 2217  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 2293  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 2372  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 2380  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 2471  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 2599  void MainWindow::__import_queued_samples Line 2603  void MainWindow::__import_queued_samples
2603    
2604  void MainWindow::on_action_file_properties()  void MainWindow::on_action_file_properties()
2605  {  {
2606      propDialog.show();      fileProps.show();
2607      propDialog.deiconify();      fileProps.deiconify();
2608  }  }
2609    
2610  void MainWindow::on_action_warn_user_on_extensions() {  void MainWindow::on_action_warn_user_on_extensions() {
# Line 2622  void MainWindow::on_show_tooltips_change Line 2626  void MainWindow::on_show_tooltips_change
2626      dimreg_all_regions.set_has_tooltip(b);      dimreg_all_regions.set_has_tooltip(b);
2627      dimreg_all_dimregs.set_has_tooltip(b);      dimreg_all_dimregs.set_has_tooltip(b);
2628      dimreg_stereo.set_has_tooltip(b);      dimreg_stereo.set_has_tooltip(b);
2629      m_TreeView.set_has_tooltip(b);  
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);      m_TreeViewSamples.set_has_tooltip(b);
2634      m_TreeViewScripts.set_has_tooltip(b);      m_TreeViewScripts.set_has_tooltip(b);
2635    
# Line 2648  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 2659  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  }  }
2677    
2678  PropDialog::PropDialog()  FilePropDialog::FilePropDialog()
2679      : eFileFormat(_("File Format")),      : eFileFormat(_("File Format")),
2680        eName(_("Name")),        eName(_("Name")),
2681        eCreationDate(_("Creation date")),        eCreationDate(_("Creation date")),
# Line 2702  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, &FilePropDialog::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 2744  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 2752  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 2762  PropDialog::PropDialog() Line 2770  PropDialog::PropDialog()
2770      quitButton.set_can_default();      quitButton.set_can_default();
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, &FilePropDialog::hide));
     eFileFormat.signal_value_changed().connect(  
         sigc::mem_fun(*this, &PropDialog::onFileFormatChanged));  
2774    
2775      quitButton.show();      quitButton.show();
2776      vbox.show();      vbox.show();
# Line 2773  PropDialog::PropDialog() Line 2779  PropDialog::PropDialog()
2779  #endif  #endif
2780  }  }
2781    
2782  void PropDialog::set_file(gig::File* file)  void FilePropDialog::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 2783  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 FilePropDialog::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 2850  InstrumentProps::InstrumentProps() : Line 2856  InstrumentProps::InstrumentProps() :
2856      ePitchbendRange(_("Pitchbend range"), 0, 48),      ePitchbendRange(_("Pitchbend range"), 0, 48),
2857      ePianoReleaseMode(_("Piano release mode")),      ePianoReleaseMode(_("Piano release mode")),
2858      eDimensionKeyRangeLow(_("Keyswitching range low")),      eDimensionKeyRangeLow(_("Keyswitching range low")),
2859      eDimensionKeyRangeHigh(_("Keyswitching range high"))      eDimensionKeyRangeHigh(_("Keyswitching range high")),
2860        table2(2,1),
2861        eName2(_("Name")),
2862        eCreationDate(_("Creation date")),
2863        eComments(_("Comments")),
2864        eProduct(_("Product")),
2865        eCopyright(_("Copyright")),
2866        eArtists(_("Artists")),
2867        eGenre(_("Genre")),
2868        eKeywords(_("Keywords")),
2869        eEngineer(_("Engineer")),
2870        eTechnician(_("Technician")),
2871        eSoftware(_("Software")),
2872        eMedium(_("Medium")),
2873        eSource(_("Source")),
2874        eSourceForm(_("Source form")),
2875        eCommissioned(_("Commissioned")),
2876        eSubject(_("Subject"))
2877  {  {
2878      if (!Settings::singleton()->autoRestoreWindowDimension) {      if (!Settings::singleton()->autoRestoreWindowDimension) {
2879          //set_default_size(470, 390);          //set_default_size(470, 390);
# Line 2859  InstrumentProps::InstrumentProps() : Line 2882  InstrumentProps::InstrumentProps() :
2882    
2883      set_title(_("Instrument Properties"));      set_title(_("Instrument Properties"));
2884    
2885        tabs.append_page(vbox[1], _("Settings"));
2886        tabs.append_page(vbox[2], _("Info"));
2887    
2888      eDimensionKeyRangeLow.set_tip(      eDimensionKeyRangeLow.set_tip(
2889          _("start of the keyboard area which should switch the "          _("start of the keyboard area which should switch the "
2890            "\"keyswitching\" dimension")            "\"keyswitching\" dimension")
# Line 2883  InstrumentProps::InstrumentProps() : Line 2909  InstrumentProps::InstrumentProps() :
2909    
2910      eName.signal_value_changed().connect(sig_name_changed.make_slot());      eName.signal_value_changed().connect(sig_name_changed.make_slot());
2911    
2912        connect(eName2, &InstrumentProps::set_Name);
2913        connectLambda(eCreationDate, [this](gig::String s) {
2914            m->pInfo->CreationDate = s;
2915        });
2916        connectLambda(eComments, [this](gig::String s) {
2917            m->pInfo->Comments = s;
2918        });
2919        connectLambda(eProduct, [this](gig::String s) {
2920            m->pInfo->Product = s;
2921        });
2922        connectLambda(eCopyright, [this](gig::String s) {
2923            m->pInfo->Copyright = s;
2924        });
2925        connectLambda(eArtists, [this](gig::String s) {
2926            m->pInfo->Artists = s;
2927        });
2928        connectLambda(eGenre, [this](gig::String s) {
2929            m->pInfo->Genre = s;
2930        });
2931        connectLambda(eKeywords, [this](gig::String s) {
2932            m->pInfo->Keywords = s;
2933        });
2934        connectLambda(eEngineer, [this](gig::String s) {
2935            m->pInfo->Engineer = s;
2936        });
2937        connectLambda(eTechnician, [this](gig::String s) {
2938            m->pInfo->Technician = s;
2939        });
2940        connectLambda(eSoftware, [this](gig::String s) {
2941            m->pInfo->Software = s;
2942        });
2943        connectLambda(eMedium, [this](gig::String s) {
2944            m->pInfo->Medium = s;
2945        });
2946        connectLambda(eSource, [this](gig::String s) {
2947            m->pInfo->Source = s;
2948        });
2949        connectLambda(eSourceForm, [this](gig::String s) {
2950            m->pInfo->SourceForm = s;
2951        });
2952        connectLambda(eCommissioned, [this](gig::String s) {
2953            m->pInfo->Commissioned = s;
2954        });
2955        connectLambda(eSubject, [this](gig::String s) {
2956            m->pInfo->Subject = s;
2957        });
2958    
2959        // tab 1
2960  #if USE_GTKMM_GRID  #if USE_GTKMM_GRID
2961      table.set_column_spacing(5);      table.set_column_spacing(5);
2962  #else  #else
2963      table.set_col_spacings(5);      table.set_col_spacings(5);
2964  #endif  #endif
   
2965      table.add(eName);      table.add(eName);
2966      table.add(eIsDrum);      table.add(eIsDrum);
2967      table.add(eMIDIBank);      table.add(eMIDIBank);
# Line 2902  InstrumentProps::InstrumentProps() : Line 2975  InstrumentProps::InstrumentProps() :
2975      table.add(eDimensionKeyRangeLow);      table.add(eDimensionKeyRangeLow);
2976      table.add(eDimensionKeyRangeHigh);      table.add(eDimensionKeyRangeHigh);
2977    
2978      add(vbox);      // tab 2
2979  #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22)  #if USE_GTKMM_GRID
2980        table2.set_column_spacing(5);
2981    #else
2982        table2.set_col_spacings(5);
2983    #endif
2984        table2.add(eName2);
2985        table2.add(eCreationDate);
2986        table2.add(eComments);
2987        table2.add(eProduct);
2988        table2.add(eCopyright);
2989        table2.add(eArtists);
2990        table2.add(eGenre);
2991        table2.add(eKeywords);
2992        table2.add(eEngineer);
2993        table2.add(eTechnician);
2994        table2.add(eSoftware);
2995        table2.add(eMedium);
2996        table2.add(eSource);
2997        table2.add(eSourceForm);
2998        table2.add(eCommissioned);
2999        table2.add(eSubject);
3000    
3001        add(vbox[0]);
3002    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24)
3003      table.set_margin(5);      table.set_margin(5);
3004  #else  #else
3005      table.set_border_width(5);      table.set_border_width(5);
3006  #endif  #endif
3007      vbox.pack_start(table);      vbox[1].pack_start(table);
3008        vbox[2].pack_start(table2);
3009      table.show();      table.show();
3010      vbox.pack_start(buttonBox, Gtk::PACK_SHRINK);      table2.show();
3011        vbox[0].pack_start(tabs);
3012        vbox[0].pack_start(buttonBox, Gtk::PACK_SHRINK);
3013      buttonBox.set_layout(Gtk::BUTTONBOX_END);      buttonBox.set_layout(Gtk::BUTTONBOX_END);
3014  #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)
3015      buttonBox.set_margin(5);      buttonBox.set_margin(5);
3016  #else  #else
3017      buttonBox.set_border_width(5);      buttonBox.set_border_width(5);
# Line 2926  InstrumentProps::InstrumentProps() : Line 3025  InstrumentProps::InstrumentProps() :
3025          sigc::mem_fun(*this, &InstrumentProps::hide));          sigc::mem_fun(*this, &InstrumentProps::hide));
3026    
3027      quitButton.show();      quitButton.show();
3028      vbox.show();      vbox[0].show();
3029  #if HAS_GTKMM_SHOW_ALL_CHILDREN  #if HAS_GTKMM_SHOW_ALL_CHILDREN
3030      show_all_children();      show_all_children();
3031  #endif  #endif
# Line 2937  void InstrumentProps::set_instrument(gig Line 3036  void InstrumentProps::set_instrument(gig
3036      update(instrument);      update(instrument);
3037    
3038      update_model++;      update_model++;
3039    
3040        // tab 1
3041      eName.set_value(instrument->pInfo->Name);      eName.set_value(instrument->pInfo->Name);
3042      eIsDrum.set_value(instrument->IsDrum);      eIsDrum.set_value(instrument->IsDrum);
3043      eMIDIBank.set_value(instrument->MIDIBank);      eMIDIBank.set_value(instrument->MIDIBank);
3044      eMIDIProgram.set_value(instrument->MIDIProgram);      eMIDIProgram.set_value(instrument->MIDIProgram);
3045        // tab 2
3046        eName2.set_value(instrument->pInfo->Name);
3047        eCreationDate.set_value(instrument->pInfo->CreationDate);
3048        eComments.set_value(instrument->pInfo->Comments);
3049        eProduct.set_value(instrument->pInfo->Product);
3050        eCopyright.set_value(instrument->pInfo->Copyright);
3051        eArtists.set_value(instrument->pInfo->Artists);
3052        eGenre.set_value(instrument->pInfo->Genre);
3053        eKeywords.set_value(instrument->pInfo->Keywords);
3054        eEngineer.set_value(instrument->pInfo->Engineer);
3055        eTechnician.set_value(instrument->pInfo->Technician);
3056        eSoftware.set_value(instrument->pInfo->Software);
3057        eMedium.set_value(instrument->pInfo->Medium);
3058        eSource.set_value(instrument->pInfo->Source);
3059        eSourceForm.set_value(instrument->pInfo->SourceForm);
3060        eCommissioned.set_value(instrument->pInfo->Commissioned);
3061        eSubject.set_value(instrument->pInfo->Subject);
3062    
3063      update_model--;      update_model--;
3064  }  }
3065    
# Line 2974  void MainWindow::updateSampleRefCountMap Line 3093  void MainWindow::updateSampleRefCountMap
3093      }      }
3094  }  }
3095    
3096    bool MainWindow::onQueryTreeViewTooltip(int x, int y, bool keyboardTip, const Glib::RefPtr<Gtk::Tooltip>& tooltip) {
3097        Gtk::TreeModel::iterator iter;
3098        if (!m_TreeView.get_tooltip_context_iter(x, y, keyboardTip, iter)) {
3099            return false;
3100        }
3101        Gtk::TreeModel::Path path(iter);
3102        Gtk::TreeModel::Row row = *iter;
3103        Gtk::TreeViewColumn* pointedColumn = NULL;
3104        // resolve the precise table column the mouse points to
3105        {
3106            Gtk::TreeModel::Path path; // unused
3107            int cellX, cellY; // unused
3108            m_TreeView.get_path_at_pos(x, y, path, pointedColumn, cellX, cellY);
3109        }
3110        Gtk::TreeViewColumn* scriptsColumn = m_TreeView.get_column(2);
3111        if (pointedColumn == scriptsColumn) { // mouse hovers scripts column ...
3112            // show the script(s) assigned to the hovered instrument as tooltip
3113            tooltip->set_markup( row[m_Columns.m_col_tooltip] );
3114            m_TreeView.set_tooltip_cell(tooltip, &path, scriptsColumn, NULL);
3115        } else {
3116            // if beginners' tooltips is disabled then don't show the following one
3117            if (!Settings::singleton()->showTooltips)
3118                return false;
3119            // yeah, a beginners tooltip
3120            tooltip->set_text(_(
3121                "Right click here for actions on instruments & MIDI Rules. "
3122                "Drag & drop to change the order of instruments."
3123            ));
3124            m_TreeView.set_tooltip_cell(tooltip, &path, pointedColumn, NULL);
3125        }
3126        return true;
3127    }
3128    
3129    static Glib::ustring scriptTooltipFor(gig::Instrument* instrument, int index) {
3130        Glib::ustring name(gig_to_utf8(instrument->pInfo->Name));
3131        const int iScriptSlots = instrument->ScriptSlotCount();
3132        Glib::ustring tooltip = "<u>(" + ToString(index) + ") “"  + name + "”</u>\n\n";
3133        if (!iScriptSlots)
3134            tooltip += "<span foreground='red'><i>No script assigned</i></span>";
3135        else {
3136            for (int i = 0; i < iScriptSlots; ++i) {
3137                tooltip += "• " + ToString(i+1) + ". Script: “<span foreground='#46DEFF'><b>" +
3138                           instrument->GetScriptOfSlot(i)->Name + "</b></span>”";
3139                if (i + 1 < iScriptSlots) tooltip += "\n\n";
3140            }
3141        }
3142        return tooltip;
3143    }
3144    
3145  void MainWindow::load_gig(gig::File* gig, const char* filename, bool isSharedInstrument)  void MainWindow::load_gig(gig::File* gig, const char* filename, bool isSharedInstrument)
3146  {  {
3147      file = 0;      file = 0;
# Line 2987  void MainWindow::load_gig(gig::File* gig Line 3155  void MainWindow::load_gig(gig::File* gig
3155      file_has_name = filename;      file_has_name = filename;
3156      file_is_changed = false;      file_is_changed = false;
3157    
3158      propDialog.set_file(gig);      fileProps.set_file(gig);
     propDialog.set_info(gig->pInfo);  
3159    
3160      instrument_name_connection.block();      instrument_name_connection.block();
3161      int index = 0;      int index = 0;
# Line 3003  void MainWindow::load_gig(gig::File* gig Line 3170  void MainWindow::load_gig(gig::File* gig
3170          row[m_Columns.m_col_name] = name;          row[m_Columns.m_col_name] = name;
3171          row[m_Columns.m_col_instr] = instrument;          row[m_Columns.m_col_instr] = instrument;
3172          row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : "";          row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : "";
3173            row[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index);
3174    
3175  #if !USE_GTKMM_BUILDER  #if !USE_GTKMM_BUILDER
3176          add_instrument_to_menu(name);          add_instrument_to_menu(name);
# Line 3120  void MainWindow::instr_name_changed_by_i Line 3288  void MainWindow::instr_name_changed_by_i
3288      gig::Instrument* instrument = row[m_Columns.m_col_instr];      gig::Instrument* instrument = row[m_Columns.m_col_instr];
3289      Glib::ustring gigname(gig_to_utf8(instrument->pInfo->Name));      Glib::ustring gigname(gig_to_utf8(instrument->pInfo->Name));
3290      if (gigname != name) {      if (gigname != name) {
3291            Gtk::TreeModel::Path path(*it);
3292            const int index = path[0];
3293          row[m_Columns.m_col_name] = gigname;          row[m_Columns.m_col_name] = gigname;
3294            row[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index);
3295      }      }
3296  }  }
3297    
# Line 3166  void MainWindow::onScriptSlotsModified(g Line 3337  void MainWindow::onScriptSlotsModified(g
3337          Gtk::TreeModel::Row row = model->children()[i];          Gtk::TreeModel::Row row = model->children()[i];
3338          if (row[m_Columns.m_col_instr] != pInstrument) continue;          if (row[m_Columns.m_col_instr] != pInstrument) continue;
3339          row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : "";          row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : "";
3340            row[m_Columns.m_col_tooltip] = scriptTooltipFor(pInstrument, i);
3341          break;          break;
3342      }      }
3343    
# Line 3191  void MainWindow::assignScript(gig::Scrip Line 3363  void MainWindow::assignScript(gig::Scrip
3363      onScriptSlotsModified(pInstrument);      onScriptSlotsModified(pInstrument);
3364  }  }
3365    
3366    void MainWindow::dropAllScriptSlots() {
3367        gig::Instrument* pInstrument = get_instrument();
3368        if (!pInstrument) {
3369            printf("!instrument\n");
3370            return;
3371        }
3372    
3373        const int iScriptSlots = pInstrument->ScriptSlotCount();
3374        for (int i = iScriptSlots - 1; i >= 0; --i)
3375            pInstrument->RemoveScriptSlot(i);
3376    
3377        onScriptSlotsModified(pInstrument);
3378    }
3379    
3380  void MainWindow::on_action_refresh_all() {  void MainWindow::on_action_refresh_all() {
3381      __refreshEntireGUI();      __refreshEntireGUI();
3382  }  }
# Line 3365  void MainWindow::select_instrument(gig:: Line 3551  void MainWindow::select_instrument(gig::
3551              show_intruments_tab();              show_intruments_tab();
3552              m_TreeView.get_selection()->unselect_all();              m_TreeView.get_selection()->unselect_all();
3553                            
3554  #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)
3555              auto iterSel = model->children()[i].get_iter();              auto iterSel = model->children()[i].get_iter();
3556              m_TreeView.get_selection()->select(iterSel);              m_TreeView.get_selection()->select(iterSel);
3557  #else  #else
# Line 3395  bool MainWindow::select_dimension_region Line 3581  bool MainWindow::select_dimension_region
3581              // select and show the respective instrument in the list view              // select and show the respective instrument in the list view
3582              show_intruments_tab();              show_intruments_tab();
3583              m_TreeView.get_selection()->unselect_all();              m_TreeView.get_selection()->unselect_all();
3584  #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)
3585              auto iterSel = model->children()[i].get_iter();              auto iterSel = model->children()[i].get_iter();
3586              m_TreeView.get_selection()->select(iterSel);              m_TreeView.get_selection()->select(iterSel);
3587  #else  #else
# Line 3431  void MainWindow::select_sample(gig::Samp Line 3617  void MainWindow::select_sample(gig::Samp
3617              if (rowSample[m_SamplesModel.m_col_sample] == sample) {              if (rowSample[m_SamplesModel.m_col_sample] == sample) {
3618                  show_samples_tab();                  show_samples_tab();
3619                  m_TreeViewSamples.get_selection()->unselect_all();                  m_TreeViewSamples.get_selection()->unselect_all();
3620  #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)
3621                  auto iterSel = rowGroup.children()[s].get_iter();                  auto iterSel = rowGroup.children()[s].get_iter();
3622                  m_TreeViewSamples.get_selection()->select(iterSel);                  m_TreeViewSamples.get_selection()->select(iterSel);
3623  #else  #else
# Line 3631  void MainWindow::updateScriptListOfMenu( Line 3817  void MainWindow::updateScriptListOfMenu(
3817          assign_scripts_menu->append(*item);          assign_scripts_menu->append(*item);
3818      }      }
3819    
3820        // add separator line to menu
3821        assign_scripts_menu->append(*new Gtk::SeparatorMenuItem);
3822    
3823        {
3824            Gtk::MenuItem* item = new Gtk::MenuItem(_("Unassign All Scripts"));
3825            item->signal_activate().connect(
3826                sigc::mem_fun(*this, &MainWindow::dropAllScriptSlots)
3827            );
3828            assign_scripts_menu->append(*item);
3829            item->set_accel_path("<Scripts>/DropAllScriptSlots");
3830        }
3831    
3832  #if HAS_GTKMM_SHOW_ALL_CHILDREN  #if HAS_GTKMM_SHOW_ALL_CHILDREN
3833      assign_scripts_menu->show_all_children();      assign_scripts_menu->show_all_children();
3834  #endif  #endif
# Line 3679  void MainWindow::add_instrument(gig::Ins Line 3877  void MainWindow::add_instrument(gig::Ins
3877      instrument_name_connection.block();      instrument_name_connection.block();
3878      Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append();      Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append();
3879      Gtk::TreeModel::Row rowInstr = *iterInstr;      Gtk::TreeModel::Row rowInstr = *iterInstr;
3880      rowInstr[m_Columns.m_col_nr] = m_refTreeModel->children().size() - 1;      const int index = m_refTreeModel->children().size() - 1;
3881        rowInstr[m_Columns.m_col_nr] = index;
3882      rowInstr[m_Columns.m_col_name] = name;      rowInstr[m_Columns.m_col_name] = name;
3883      rowInstr[m_Columns.m_col_instr] = instrument;      rowInstr[m_Columns.m_col_instr] = instrument;
3884      rowInstr[m_Columns.m_col_scripts] = "";      rowInstr[m_Columns.m_col_scripts] = "";
3885        rowInstr[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index);
3886      instrument_name_connection.unblock();      instrument_name_connection.unblock();
3887    
3888  #if !USE_GTKMM_BUILDER  #if !USE_GTKMM_BUILDER
# Line 3769  void MainWindow::on_action_remove_instru Line 3969  void MainWindow::on_action_remove_instru
3969                       it != m_refTreeModel->children().end(); ++it, ++index)                       it != m_refTreeModel->children().end(); ++it, ++index)
3970                  {                  {
3971                      Gtk::TreeModel::Row row = *it;                      Gtk::TreeModel::Row row = *it;
3972                        gig::Instrument* instrument = row[m_Columns.m_col_instr];
3973                      row[m_Columns.m_col_nr] = index;                      row[m_Columns.m_col_nr] = index;
3974                        row[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index);
3975                  }                  }
3976              }              }
3977    
# Line 4022  void MainWindow::add_or_replace_sample(b Line 4224  void MainWindow::add_or_replace_sample(b
4224          dialog.set_current_folder(current_sample_dir);          dialog.set_current_folder(current_sample_dir);
4225      }      }
4226      if (dialog.run() == Gtk::RESPONSE_OK) {      if (dialog.run() == Gtk::RESPONSE_OK) {
4227            dialog.hide();
4228          current_sample_dir = dialog.get_current_folder();          current_sample_dir = dialog.get_current_folder();
4229          Glib::ustring error_files;          Glib::ustring error_files;
4230          std::vector<std::string> filenames = dialog.get_filenames();          std::vector<std::string> filenames = dialog.get_filenames();
# Line 4202  void MainWindow::on_action_replace_all_s Line 4405  void MainWindow::on_action_replace_all_s
4405      }      }
4406      if (dialog.run() == Gtk::RESPONSE_OK)      if (dialog.run() == Gtk::RESPONSE_OK)
4407      {      {
4408            dialog.hide();
4409          current_sample_dir = dialog.get_current_folder();          current_sample_dir = dialog.get_current_folder();
4410          Glib::ustring error_files;          Glib::ustring error_files;
4411          std::string folder = dialog.get_filename();          std::string folder = dialog.get_filename();
# Line 4690  bool MainWindow::instrument_row_visible( Line 4894  bool MainWindow::instrument_row_visible(
4894      trim(pattern);      trim(pattern);
4895      if (pattern.empty()) return true;      if (pattern.empty()) return true;
4896    
4897  #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)
4898      //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.
4899      Gtk::TreeModel::Row row = **(Gtk::TreeModel::iterator*)(&iter);      Gtk::TreeModel::Row row = **(Gtk::TreeModel::iterator*)(&iter);
4900  #else  #else
# Line 4930  void MainWindow::on_action_merge_files() Line 5134  void MainWindow::on_action_merge_files()
5134  #endif  #endif
5135    
5136      if (dialog.run() == Gtk::RESPONSE_OK) {      if (dialog.run() == Gtk::RESPONSE_OK) {
5137            dialog.hide();
5138    #ifdef GLIB_THREADS
5139          printf("on_action_merge_files self=%p\n",          printf("on_action_merge_files self=%p\n",
5140                 static_cast<void*>(Glib::Threads::Thread::self()));                 static_cast<void*>(Glib::Threads::Thread::self()));
5141    #else
5142            std::cout << "on_action_merge_files self=" <<
5143                std::this_thread::get_id() << "\n";
5144    #endif
5145          std::vector<std::string> filenames = dialog.get_filenames();          std::vector<std::string> filenames = dialog.get_filenames();
5146    
5147          // merge the selected files to the currently open .gig file          // merge the selected files to the currently open .gig file

Legend:
Removed from v.3409  
changed lines
  Added in v.3636

  ViewVC Help
Powered by ViewVC