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 |
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> |
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 |
} |
} |
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( |
sampleProps.signal_changed().connect( |
1488 |
|
sigc::mem_fun(*this, &MainWindow::file_changed)); |
1489 |
|
fileProps.signal_changed().connect( |
1490 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
1491 |
midiRules.signal_changed().connect( |
midiRules.signal_changed().connect( |
1492 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
1512 |
sigc::hide( |
sigc::hide( |
1513 |
sigc::bind( |
sigc::bind( |
1514 |
file_structure_to_be_changed_signal.make_slot(), |
file_structure_to_be_changed_signal.make_slot(), |
1515 |
|
#if SIGCXX_MAJOR_VERSION > 2 || (SIGCXX_MAJOR_VERSION == 2 && SIGCXX_MINOR_VERSION >= 8) |
1516 |
|
std::ref(this->file) |
1517 |
|
#else |
1518 |
sigc::ref(this->file) |
sigc::ref(this->file) |
1519 |
|
#endif |
1520 |
) |
) |
1521 |
) |
) |
1522 |
); |
); |
1524 |
sigc::hide( |
sigc::hide( |
1525 |
sigc::bind( |
sigc::bind( |
1526 |
file_structure_changed_signal.make_slot(), |
file_structure_changed_signal.make_slot(), |
1527 |
|
#if SIGCXX_MAJOR_VERSION > 2 || (SIGCXX_MAJOR_VERSION == 2 && SIGCXX_MINOR_VERSION >= 8) |
1528 |
|
std::ref(this->file) |
1529 |
|
#else |
1530 |
sigc::ref(this->file) |
sigc::ref(this->file) |
1531 |
|
#endif |
1532 |
) |
) |
1533 |
) |
) |
1534 |
); |
); |
1550 |
sigc::mem_fun(*this, &MainWindow::update_dimregs)); |
sigc::mem_fun(*this, &MainWindow::update_dimregs)); |
1551 |
|
|
1552 |
m_searchText.signal_changed().connect( |
m_searchText.signal_changed().connect( |
1553 |
sigc::mem_fun(m_refTreeModelFilter.operator->(), &Gtk::TreeModelFilter::refilter) |
sigc::mem_fun(*m_refTreeModelFilter.operator->(), &Gtk::TreeModelFilter::refilter) |
1554 |
); |
); |
1555 |
|
|
1556 |
file = 0; |
file = 0; |
1640 |
Gtk::AccelMap::add_entry("<Scripts>/script_16", GDK_KEY_F17, Gdk::SHIFT_MASK); |
Gtk::AccelMap::add_entry("<Scripts>/script_16", GDK_KEY_F17, Gdk::SHIFT_MASK); |
1641 |
Gtk::AccelMap::add_entry("<Scripts>/script_17", GDK_KEY_F18, Gdk::SHIFT_MASK); |
Gtk::AccelMap::add_entry("<Scripts>/script_17", GDK_KEY_F18, Gdk::SHIFT_MASK); |
1642 |
Gtk::AccelMap::add_entry("<Scripts>/script_18", GDK_KEY_F19, Gdk::SHIFT_MASK); |
Gtk::AccelMap::add_entry("<Scripts>/script_18", GDK_KEY_F19, Gdk::SHIFT_MASK); |
1643 |
|
Gtk::AccelMap::add_entry("<Scripts>/DropAllScriptSlots", GDK_KEY_BackSpace, Gdk::SHIFT_MASK); |
1644 |
|
|
1645 |
Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group(); |
Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group(); |
1646 |
assign_scripts_menu->set_accel_group(accelGroup); |
assign_scripts_menu->set_accel_group(accelGroup); |
1888 |
} |
} |
1889 |
} |
} |
1890 |
|
|
1891 |
|
|
1892 |
|
LoaderSaverBase::LoaderSaverBase(const Glib::ustring filename, gig::File* gig) : |
1893 |
|
filename(filename), gig(gig), |
1894 |
|
#ifdef GLIB_THREADS |
1895 |
|
thread(0), |
1896 |
|
#endif |
1897 |
|
progress(0.f) |
1898 |
|
{ |
1899 |
|
} |
1900 |
|
|
1901 |
void loader_progress_callback(gig::progress_t* progress) |
void loader_progress_callback(gig::progress_t* progress) |
1902 |
{ |
{ |
1903 |
Loader* loader = static_cast<Loader*>(progress->custom); |
LoaderSaverBase* loader = static_cast<LoaderSaverBase*>(progress->custom); |
1904 |
loader->progress_callback(progress->factor); |
loader->progress_callback(progress->factor); |
1905 |
} |
} |
1906 |
|
|
1907 |
void Loader::progress_callback(float fraction) |
void LoaderSaverBase::progress_callback(float fraction) |
1908 |
{ |
{ |
1909 |
{ |
{ |
1910 |
|
#ifdef GLIB_THREADS |
1911 |
Glib::Threads::Mutex::Lock lock(progressMutex); |
Glib::Threads::Mutex::Lock lock(progressMutex); |
1912 |
|
#else |
1913 |
|
std::lock_guard<std::mutex> lock(progressMutex); |
1914 |
|
#endif |
1915 |
progress = fraction; |
progress = fraction; |
1916 |
} |
} |
1917 |
progress_dispatcher(); |
progress_dispatcher(); |
1921 |
// make sure stack is 16-byte aligned for SSE instructions |
// make sure stack is 16-byte aligned for SSE instructions |
1922 |
__attribute__((force_align_arg_pointer)) |
__attribute__((force_align_arg_pointer)) |
1923 |
#endif |
#endif |
1924 |
void Loader::thread_function() |
void LoaderSaverBase::thread_function() |
1925 |
{ |
{ |
1926 |
|
#ifdef GLIB_THREADS |
1927 |
printf("thread_function self=%p\n", |
printf("thread_function self=%p\n", |
1928 |
static_cast<void*>(Glib::Threads::Thread::self())); |
static_cast<void*>(Glib::Threads::Thread::self())); |
1929 |
|
#else |
1930 |
|
std::cout << "thread_function self=" << std::this_thread::get_id() << "\n"; |
1931 |
|
#endif |
1932 |
printf("Start %s\n", filename.c_str()); |
printf("Start %s\n", filename.c_str()); |
1933 |
try { |
try { |
|
RIFF::File* riff = new RIFF::File(filename); |
|
|
gig = new gig::File(riff); |
|
1934 |
gig::progress_t progress; |
gig::progress_t progress; |
1935 |
progress.callback = loader_progress_callback; |
progress.callback = loader_progress_callback; |
1936 |
progress.custom = this; |
progress.custom = this; |
1937 |
|
|
1938 |
gig->GetInstrument(0, &progress); |
thread_function_sub(progress); |
1939 |
printf("End\n"); |
printf("End\n"); |
1940 |
finished_dispatcher(); |
finished_dispatcher(); |
1941 |
} catch (RIFF::Exception e) { |
} catch (RIFF::Exception e) { |
1947 |
} |
} |
1948 |
} |
} |
1949 |
|
|
1950 |
Loader::Loader(const char* filename) |
void LoaderSaverBase::launch() |
|
: filename(filename), gig(0), thread(0), progress(0.f) |
|
|
{ |
|
|
} |
|
|
|
|
|
void Loader::launch() |
|
1951 |
{ |
{ |
1952 |
|
#ifdef GLIB_THREADS |
1953 |
#ifdef OLD_THREADS |
#ifdef OLD_THREADS |
1954 |
thread = Glib::Thread::create(sigc::mem_fun(*this, &Loader::thread_function), true); |
thread = Glib::Thread::create(sigc::mem_fun(*this, &LoaderSaverBase::thread_function), true); |
1955 |
#else |
#else |
1956 |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Loader::thread_function)); |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &LoaderSaverBase::thread_function)); |
1957 |
#endif |
#endif |
1958 |
printf("launch thread=%p\n", static_cast<void*>(thread)); |
printf("launch thread=%p\n", static_cast<void*>(thread)); |
1959 |
|
#else |
1960 |
|
thread = std::thread([this](){ thread_function(); }); |
1961 |
|
std::cout << "launch thread=" << thread.get_id() << "\n"; |
1962 |
|
#endif |
1963 |
} |
} |
1964 |
|
|
1965 |
float Loader::get_progress() |
float LoaderSaverBase::get_progress() |
1966 |
{ |
{ |
1967 |
float res; |
#ifdef GLIB_THREADS |
1968 |
{ |
Glib::Threads::Mutex::Lock lock(progressMutex); |
1969 |
Glib::Threads::Mutex::Lock lock(progressMutex); |
#else |
1970 |
res = progress; |
std::lock_guard<std::mutex> lock(progressMutex); |
1971 |
} |
#endif |
1972 |
return res; |
return progress; |
1973 |
} |
} |
1974 |
|
|
1975 |
Glib::Dispatcher& Loader::signal_progress() |
Glib::Dispatcher& LoaderSaverBase::signal_progress() |
1976 |
{ |
{ |
1977 |
return progress_dispatcher; |
return progress_dispatcher; |
1978 |
} |
} |
1979 |
|
|
1980 |
Glib::Dispatcher& Loader::signal_finished() |
Glib::Dispatcher& LoaderSaverBase::signal_finished() |
1981 |
{ |
{ |
1982 |
return finished_dispatcher; |
return finished_dispatcher; |
1983 |
} |
} |
1984 |
|
|
1985 |
Glib::Dispatcher& Loader::signal_error() |
Glib::Dispatcher& LoaderSaverBase::signal_error() |
1986 |
{ |
{ |
1987 |
return error_dispatcher; |
return error_dispatcher; |
1988 |
} |
} |
1989 |
|
|
1990 |
void saver_progress_callback(gig::progress_t* progress) |
void LoaderSaverBase::join() { |
1991 |
{ |
#ifdef GLIB_THREADS |
1992 |
Saver* saver = static_cast<Saver*>(progress->custom); |
thread->join(); |
1993 |
saver->progress_callback(progress->factor); |
#else |
1994 |
|
thread.join(); |
1995 |
|
#endif |
1996 |
} |
} |
1997 |
|
|
1998 |
void Saver::progress_callback(float fraction) |
|
1999 |
|
Loader::Loader(const char* filename) : |
2000 |
|
LoaderSaverBase(filename, 0) |
2001 |
{ |
{ |
|
{ |
|
|
Glib::Threads::Mutex::Lock lock(progressMutex); |
|
|
progress = fraction; |
|
|
} |
|
|
progress_dispatcher.emit(); |
|
2002 |
} |
} |
2003 |
|
|
2004 |
#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() |
|
2005 |
{ |
{ |
2006 |
printf("thread_function self=%p\n", |
RIFF::File* riff = new RIFF::File(filename); |
2007 |
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); |
|
|
} |
|
2008 |
|
|
2009 |
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(); |
|
|
} |
|
2010 |
} |
} |
2011 |
|
|
2012 |
Saver::Saver(gig::File* file, Glib::ustring filename) |
|
2013 |
: gig(file), filename(filename), thread(0), progress(0.f) |
Saver::Saver(gig::File* file, Glib::ustring filename) : |
2014 |
|
LoaderSaverBase(filename, file) |
2015 |
{ |
{ |
2016 |
} |
} |
2017 |
|
|
2018 |
void Saver::launch() |
void Saver::thread_function_sub(gig::progress_t& progress) |
2019 |
{ |
{ |
2020 |
#ifdef OLD_THREADS |
// if no filename was provided, that means "save", if filename was provided means "save as" |
2021 |
thread = Glib::Thread::create(sigc::mem_fun(*this, &Saver::thread_function), true); |
if (filename.empty()) { |
2022 |
|
if (!Settings::singleton()->saveWithTemporaryFile) { |
2023 |
|
// save directly over the existing .gig file |
2024 |
|
// (requires less disk space than solution below |
2025 |
|
// but may be slower) |
2026 |
|
gig->Save(&progress); |
2027 |
|
} else { |
2028 |
|
// save the file as separate temporary file first, |
2029 |
|
// then move the saved file over the old file |
2030 |
|
// (may result in performance speedup during save) |
2031 |
|
gig::String tmpname = filename + ".TMP"; |
2032 |
|
gig->Save(tmpname, &progress); |
2033 |
|
#if defined(WIN32) |
2034 |
|
if (!DeleteFile(filename.c_str())) { |
2035 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file)."); |
2036 |
|
} |
2037 |
|
#else // POSIX ... |
2038 |
|
if (unlink(filename.c_str())) { |
2039 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file): " + gig::String(strerror(errno))); |
2040 |
|
} |
2041 |
|
#endif |
2042 |
|
if (rename(tmpname.c_str(), filename.c_str())) { |
2043 |
|
#if defined(WIN32) |
2044 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file)."); |
2045 |
#else |
#else |
2046 |
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))); |
2047 |
#endif |
#endif |
2048 |
printf("launch thread=%p\n", static_cast<void*>(thread)); |
} |
2049 |
} |
} |
2050 |
|
} else { |
2051 |
float Saver::get_progress() |
gig->Save(filename, &progress); |
|
{ |
|
|
float res; |
|
|
{ |
|
|
Glib::Threads::Mutex::Lock lock(progressMutex); |
|
|
res = progress; |
|
2052 |
} |
} |
|
return res; |
|
|
} |
|
|
|
|
|
Glib::Dispatcher& Saver::signal_progress() |
|
|
{ |
|
|
return progress_dispatcher; |
|
|
} |
|
|
|
|
|
Glib::Dispatcher& Saver::signal_finished() |
|
|
{ |
|
|
return finished_dispatcher; |
|
2053 |
} |
} |
2054 |
|
|
|
Glib::Dispatcher& Saver::signal_error() |
|
|
{ |
|
|
return error_dispatcher; |
|
|
} |
|
2055 |
|
|
2056 |
ProgressDialog::ProgressDialog(const Glib::ustring& title, Gtk::Window& parent) |
ProgressDialog::ProgressDialog(const Glib::ustring& title, Gtk::Window& parent) |
2057 |
: Gtk::Dialog(title, parent, true) |
: Gtk::Dialog(title, parent, true) |
2207 |
dialog.set_current_folder(current_gig_dir); |
dialog.set_current_folder(current_gig_dir); |
2208 |
} |
} |
2209 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
2210 |
|
dialog.hide(); |
2211 |
std::string filename = dialog.get_filename(); |
std::string filename = dialog.get_filename(); |
2212 |
printf("filename=%s\n", filename.c_str()); |
printf("filename=%s\n", filename.c_str()); |
2213 |
|
#ifdef GLIB_THREADS |
2214 |
printf("on_action_file_open self=%p\n", |
printf("on_action_file_open self=%p\n", |
2215 |
static_cast<void*>(Glib::Threads::Thread::self())); |
static_cast<void*>(Glib::Threads::Thread::self())); |
2216 |
|
#else |
2217 |
|
std::cout << "on_action_file_open self=" << |
2218 |
|
std::this_thread::get_id() << "\n"; |
2219 |
|
#endif |
2220 |
load_file(filename.c_str()); |
load_file(filename.c_str()); |
2221 |
current_gig_dir = Glib::path_get_dirname(filename); |
current_gig_dir = Glib::path_get_dirname(filename); |
2222 |
} |
} |
2289 |
|
|
2290 |
void MainWindow::on_loader_finished() |
void MainWindow::on_loader_finished() |
2291 |
{ |
{ |
2292 |
|
loader->join(); |
2293 |
printf("Loader finished!\n"); |
printf("Loader finished!\n"); |
2294 |
|
#ifdef GLIB_THREADS |
2295 |
printf("on_loader_finished self=%p\n", |
printf("on_loader_finished self=%p\n", |
2296 |
static_cast<void*>(Glib::Threads::Thread::self())); |
static_cast<void*>(Glib::Threads::Thread::self())); |
2297 |
|
#else |
2298 |
|
std::cout << "on_loader_finished self=" << |
2299 |
|
std::this_thread::get_id() << "\n"; |
2300 |
|
#endif |
2301 |
load_gig(loader->gig, loader->filename.c_str()); |
load_gig(loader->gig, loader->filename.c_str()); |
2302 |
progress_dialog->hide(); |
progress_dialog->hide(); |
2303 |
} |
} |
2304 |
|
|
2305 |
void MainWindow::on_loader_error() |
void MainWindow::on_loader_error() |
2306 |
{ |
{ |
2307 |
|
loader->join(); |
2308 |
Glib::ustring txt = _("Could not load file: ") + loader->error_message; |
Glib::ustring txt = _("Could not load file: ") + loader->error_message; |
2309 |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
2310 |
msg.run(); |
msg.run(); |
2375 |
|
|
2376 |
void MainWindow::on_saver_error() |
void MainWindow::on_saver_error() |
2377 |
{ |
{ |
2378 |
|
saver->join(); |
2379 |
file_structure_changed_signal.emit(this->file); |
file_structure_changed_signal.emit(this->file); |
2380 |
Glib::ustring txt = _("Could not save file: ") + saver->error_message; |
Glib::ustring txt = _("Could not save file: ") + saver->error_message; |
2381 |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
2384 |
|
|
2385 |
void MainWindow::on_saver_finished() |
void MainWindow::on_saver_finished() |
2386 |
{ |
{ |
2387 |
|
saver->join(); |
2388 |
this->file = saver->gig; |
this->file = saver->gig; |
2389 |
this->filename = saver->filename; |
this->filename = saver->filename; |
2390 |
current_gig_dir = Glib::path_get_dirname(filename); |
current_gig_dir = Glib::path_get_dirname(filename); |
2476 |
#endif |
#endif |
2477 |
|
|
2478 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
2479 |
|
dialog.hide(); |
2480 |
std::string filename = dialog.get_filename(); |
std::string filename = dialog.get_filename(); |
2481 |
if (!Glib::str_has_suffix(filename, ".gig")) { |
if (!Glib::str_has_suffix(filename, ".gig")) { |
2482 |
filename += ".gig"; |
filename += ".gig"; |
2605 |
|
|
2606 |
void MainWindow::on_action_file_properties() |
void MainWindow::on_action_file_properties() |
2607 |
{ |
{ |
2608 |
propDialog.show(); |
fileProps.show(); |
2609 |
propDialog.deiconify(); |
fileProps.deiconify(); |
2610 |
} |
} |
2611 |
|
|
2612 |
void MainWindow::on_action_warn_user_on_extensions() { |
void MainWindow::on_action_warn_user_on_extensions() { |
2657 |
dialog.set_name("Gigedit"); |
dialog.set_name("Gigedit"); |
2658 |
#endif |
#endif |
2659 |
dialog.set_version(VERSION); |
dialog.set_version(VERSION); |
2660 |
dialog.set_copyright("Copyright (C) 2006-2017 Andreas Persson"); |
dialog.set_copyright("Copyright (C) 2006-2019 Andreas Persson"); |
2661 |
const std::string sComment = |
const std::string sComment = |
2662 |
_("Built " __DATE__ "\nUsing ") + |
_("Built " __DATE__ "\nUsing ") + |
2663 |
::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" + |
::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" + |
2668 |
"backup your Gigasampler/GigaStudio files before editing them with " |
"backup your Gigasampler/GigaStudio files before editing them with " |
2669 |
"this application.\n" |
"this application.\n" |
2670 |
"\n" |
"\n" |
2671 |
"Please report bugs to: http://bugs.linuxsampler.org" |
"Please report bugs to: https://bugs.linuxsampler.org" |
2672 |
); |
); |
2673 |
dialog.set_comments(sComment.c_str()); |
dialog.set_comments(sComment.c_str()); |
2674 |
dialog.set_website("http://www.linuxsampler.org"); |
dialog.set_website("https://www.linuxsampler.org"); |
2675 |
dialog.set_website_label("http://www.linuxsampler.org"); |
dialog.set_website_label("https://www.linuxsampler.org"); |
2676 |
dialog.set_position(Gtk::WIN_POS_CENTER); |
dialog.set_position(Gtk::WIN_POS_CENTER); |
2677 |
dialog.run(); |
dialog.run(); |
2678 |
} |
} |
2679 |
|
|
2680 |
PropDialog::PropDialog() |
FilePropDialog::FilePropDialog() |
2681 |
: eFileFormat(_("File Format")), |
: eFileFormat(_("File Format")), |
2682 |
eName(_("Name")), |
eName(_("Name")), |
2683 |
eCreationDate(_("Creation date")), |
eCreationDate(_("Creation date")), |
2711 |
set_title(_("File Properties")); |
set_title(_("File Properties")); |
2712 |
eName.set_width_chars(50); |
eName.set_width_chars(50); |
2713 |
|
|
2714 |
|
connect(eFileFormat, &FilePropDialog::set_FileFormat); |
2715 |
connect(eName, &DLS::Info::Name); |
connect(eName, &DLS::Info::Name); |
2716 |
connect(eCreationDate, &DLS::Info::CreationDate); |
connect(eCreationDate, &DLS::Info::CreationDate); |
2717 |
connect(eComments, &DLS::Info::Comments); |
connect(eComments, &DLS::Info::Comments); |
2754 |
#endif |
#endif |
2755 |
|
|
2756 |
add(vbox); |
add(vbox); |
2757 |
#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) |
2758 |
table.set_margin(5); |
table.set_margin(5); |
2759 |
#else |
#else |
2760 |
table.set_border_width(5); |
table.set_border_width(5); |
2762 |
vbox.add(table); |
vbox.add(table); |
2763 |
vbox.pack_start(buttonBox, Gtk::PACK_SHRINK); |
vbox.pack_start(buttonBox, Gtk::PACK_SHRINK); |
2764 |
buttonBox.set_layout(Gtk::BUTTONBOX_END); |
buttonBox.set_layout(Gtk::BUTTONBOX_END); |
2765 |
#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) |
2766 |
buttonBox.set_margin(5); |
buttonBox.set_margin(5); |
2767 |
#else |
#else |
2768 |
buttonBox.set_border_width(5); |
buttonBox.set_border_width(5); |
2772 |
quitButton.set_can_default(); |
quitButton.set_can_default(); |
2773 |
quitButton.grab_focus(); |
quitButton.grab_focus(); |
2774 |
quitButton.signal_clicked().connect( |
quitButton.signal_clicked().connect( |
2775 |
sigc::mem_fun(*this, &PropDialog::hide)); |
sigc::mem_fun(*this, &FilePropDialog::hide)); |
|
eFileFormat.signal_value_changed().connect( |
|
|
sigc::mem_fun(*this, &PropDialog::onFileFormatChanged)); |
|
2776 |
|
|
2777 |
quitButton.show(); |
quitButton.show(); |
2778 |
vbox.show(); |
vbox.show(); |
2781 |
#endif |
#endif |
2782 |
} |
} |
2783 |
|
|
2784 |
void PropDialog::set_file(gig::File* file) |
void FilePropDialog::set_file(gig::File* file) |
2785 |
{ |
{ |
2786 |
m_file = file; |
m_file = file; |
2787 |
|
update(file->pInfo); |
2788 |
|
|
2789 |
// update file format version combo box |
// update file format version combo box |
2790 |
const std::string sGiga = "Gigasampler/GigaStudio v"; |
const std::string sGiga = "Gigasampler/GigaStudio v"; |
2792 |
std::vector<std::string> txts; |
std::vector<std::string> txts; |
2793 |
std::vector<int> values; |
std::vector<int> values; |
2794 |
txts.push_back(sGiga + "2"); values.push_back(2); |
txts.push_back(sGiga + "2"); values.push_back(2); |
2795 |
txts.push_back(sGiga + "3/v4"); values.push_back(3); |
txts.push_back(sGiga + "3"); values.push_back(3); |
2796 |
if (major != 2 && major != 3) { |
txts.push_back(sGiga + "4"); values.push_back(4); |
2797 |
|
if (major < 2 || major > 4) { |
2798 |
txts.push_back(sGiga + ToString(major)); values.push_back(major); |
txts.push_back(sGiga + ToString(major)); values.push_back(major); |
2799 |
} |
} |
2800 |
std::vector<const char*> texts; |
std::vector<const char*> texts; |
2801 |
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()); |
2802 |
texts.push_back(NULL); values.push_back(0); |
texts.push_back(NULL); values.push_back(0); |
2803 |
|
|
2804 |
|
update_model++; |
2805 |
eFileFormat.set_choices(&texts[0], &values[0]); |
eFileFormat.set_choices(&texts[0], &values[0]); |
2806 |
eFileFormat.set_value(major); |
eFileFormat.set_value(major); |
2807 |
|
update_model--; |
2808 |
} |
} |
2809 |
|
|
2810 |
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) |
|
2811 |
{ |
{ |
2812 |
update(info); |
m_file->pVersion->major = value; |
2813 |
} |
} |
2814 |
|
|
2815 |
|
|
2858 |
ePitchbendRange(_("Pitchbend range"), 0, 48), |
ePitchbendRange(_("Pitchbend range"), 0, 48), |
2859 |
ePianoReleaseMode(_("Piano release mode")), |
ePianoReleaseMode(_("Piano release mode")), |
2860 |
eDimensionKeyRangeLow(_("Keyswitching range low")), |
eDimensionKeyRangeLow(_("Keyswitching range low")), |
2861 |
eDimensionKeyRangeHigh(_("Keyswitching range high")) |
eDimensionKeyRangeHigh(_("Keyswitching range high")), |
2862 |
|
table2(2,1), |
2863 |
|
eName2(_("Name")), |
2864 |
|
eCreationDate(_("Creation date")), |
2865 |
|
eComments(_("Comments")), |
2866 |
|
eProduct(_("Product")), |
2867 |
|
eCopyright(_("Copyright")), |
2868 |
|
eArtists(_("Artists")), |
2869 |
|
eGenre(_("Genre")), |
2870 |
|
eKeywords(_("Keywords")), |
2871 |
|
eEngineer(_("Engineer")), |
2872 |
|
eTechnician(_("Technician")), |
2873 |
|
eSoftware(_("Software")), |
2874 |
|
eMedium(_("Medium")), |
2875 |
|
eSource(_("Source")), |
2876 |
|
eSourceForm(_("Source form")), |
2877 |
|
eCommissioned(_("Commissioned")), |
2878 |
|
eSubject(_("Subject")) |
2879 |
{ |
{ |
2880 |
if (!Settings::singleton()->autoRestoreWindowDimension) { |
if (!Settings::singleton()->autoRestoreWindowDimension) { |
2881 |
//set_default_size(470, 390); |
//set_default_size(470, 390); |
2884 |
|
|
2885 |
set_title(_("Instrument Properties")); |
set_title(_("Instrument Properties")); |
2886 |
|
|
2887 |
|
tabs.append_page(vbox[1], _("Settings")); |
2888 |
|
tabs.append_page(vbox[2], _("Info")); |
2889 |
|
|
2890 |
eDimensionKeyRangeLow.set_tip( |
eDimensionKeyRangeLow.set_tip( |
2891 |
_("start of the keyboard area which should switch the " |
_("start of the keyboard area which should switch the " |
2892 |
"\"keyswitching\" dimension") |
"\"keyswitching\" dimension") |
2911 |
|
|
2912 |
eName.signal_value_changed().connect(sig_name_changed.make_slot()); |
eName.signal_value_changed().connect(sig_name_changed.make_slot()); |
2913 |
|
|
2914 |
|
connect(eName2, &InstrumentProps::set_Name); |
2915 |
|
connectLambda(eCreationDate, [this](gig::String s) { |
2916 |
|
m->pInfo->CreationDate = s; |
2917 |
|
}); |
2918 |
|
connectLambda(eComments, [this](gig::String s) { |
2919 |
|
m->pInfo->Comments = s; |
2920 |
|
}); |
2921 |
|
connectLambda(eProduct, [this](gig::String s) { |
2922 |
|
m->pInfo->Product = s; |
2923 |
|
}); |
2924 |
|
connectLambda(eCopyright, [this](gig::String s) { |
2925 |
|
m->pInfo->Copyright = s; |
2926 |
|
}); |
2927 |
|
connectLambda(eArtists, [this](gig::String s) { |
2928 |
|
m->pInfo->Artists = s; |
2929 |
|
}); |
2930 |
|
connectLambda(eGenre, [this](gig::String s) { |
2931 |
|
m->pInfo->Genre = s; |
2932 |
|
}); |
2933 |
|
connectLambda(eKeywords, [this](gig::String s) { |
2934 |
|
m->pInfo->Keywords = s; |
2935 |
|
}); |
2936 |
|
connectLambda(eEngineer, [this](gig::String s) { |
2937 |
|
m->pInfo->Engineer = s; |
2938 |
|
}); |
2939 |
|
connectLambda(eTechnician, [this](gig::String s) { |
2940 |
|
m->pInfo->Technician = s; |
2941 |
|
}); |
2942 |
|
connectLambda(eSoftware, [this](gig::String s) { |
2943 |
|
m->pInfo->Software = s; |
2944 |
|
}); |
2945 |
|
connectLambda(eMedium, [this](gig::String s) { |
2946 |
|
m->pInfo->Medium = s; |
2947 |
|
}); |
2948 |
|
connectLambda(eSource, [this](gig::String s) { |
2949 |
|
m->pInfo->Source = s; |
2950 |
|
}); |
2951 |
|
connectLambda(eSourceForm, [this](gig::String s) { |
2952 |
|
m->pInfo->SourceForm = s; |
2953 |
|
}); |
2954 |
|
connectLambda(eCommissioned, [this](gig::String s) { |
2955 |
|
m->pInfo->Commissioned = s; |
2956 |
|
}); |
2957 |
|
connectLambda(eSubject, [this](gig::String s) { |
2958 |
|
m->pInfo->Subject = s; |
2959 |
|
}); |
2960 |
|
|
2961 |
|
// tab 1 |
2962 |
#if USE_GTKMM_GRID |
#if USE_GTKMM_GRID |
2963 |
table.set_column_spacing(5); |
table.set_column_spacing(5); |
2964 |
#else |
#else |
2965 |
table.set_col_spacings(5); |
table.set_col_spacings(5); |
2966 |
#endif |
#endif |
|
|
|
2967 |
table.add(eName); |
table.add(eName); |
2968 |
table.add(eIsDrum); |
table.add(eIsDrum); |
2969 |
table.add(eMIDIBank); |
table.add(eMIDIBank); |
2977 |
table.add(eDimensionKeyRangeLow); |
table.add(eDimensionKeyRangeLow); |
2978 |
table.add(eDimensionKeyRangeHigh); |
table.add(eDimensionKeyRangeHigh); |
2979 |
|
|
2980 |
add(vbox); |
// tab 2 |
2981 |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22) |
#if USE_GTKMM_GRID |
2982 |
|
table2.set_column_spacing(5); |
2983 |
|
#else |
2984 |
|
table2.set_col_spacings(5); |
2985 |
|
#endif |
2986 |
|
table2.add(eName2); |
2987 |
|
table2.add(eCreationDate); |
2988 |
|
table2.add(eComments); |
2989 |
|
table2.add(eProduct); |
2990 |
|
table2.add(eCopyright); |
2991 |
|
table2.add(eArtists); |
2992 |
|
table2.add(eGenre); |
2993 |
|
table2.add(eKeywords); |
2994 |
|
table2.add(eEngineer); |
2995 |
|
table2.add(eTechnician); |
2996 |
|
table2.add(eSoftware); |
2997 |
|
table2.add(eMedium); |
2998 |
|
table2.add(eSource); |
2999 |
|
table2.add(eSourceForm); |
3000 |
|
table2.add(eCommissioned); |
3001 |
|
table2.add(eSubject); |
3002 |
|
|
3003 |
|
add(vbox[0]); |
3004 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
3005 |
table.set_margin(5); |
table.set_margin(5); |
3006 |
#else |
#else |
3007 |
table.set_border_width(5); |
table.set_border_width(5); |
3008 |
#endif |
#endif |
3009 |
vbox.pack_start(table); |
vbox[1].pack_start(table); |
3010 |
|
vbox[2].pack_start(table2); |
3011 |
table.show(); |
table.show(); |
3012 |
vbox.pack_start(buttonBox, Gtk::PACK_SHRINK); |
table2.show(); |
3013 |
|
vbox[0].pack_start(tabs); |
3014 |
|
vbox[0].pack_start(buttonBox, Gtk::PACK_SHRINK); |
3015 |
buttonBox.set_layout(Gtk::BUTTONBOX_END); |
buttonBox.set_layout(Gtk::BUTTONBOX_END); |
3016 |
#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) |
3017 |
buttonBox.set_margin(5); |
buttonBox.set_margin(5); |
3018 |
#else |
#else |
3019 |
buttonBox.set_border_width(5); |
buttonBox.set_border_width(5); |
3027 |
sigc::mem_fun(*this, &InstrumentProps::hide)); |
sigc::mem_fun(*this, &InstrumentProps::hide)); |
3028 |
|
|
3029 |
quitButton.show(); |
quitButton.show(); |
3030 |
vbox.show(); |
vbox[0].show(); |
3031 |
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
3032 |
show_all_children(); |
show_all_children(); |
3033 |
#endif |
#endif |
3038 |
update(instrument); |
update(instrument); |
3039 |
|
|
3040 |
update_model++; |
update_model++; |
3041 |
|
|
3042 |
|
// tab 1 |
3043 |
eName.set_value(instrument->pInfo->Name); |
eName.set_value(instrument->pInfo->Name); |
3044 |
eIsDrum.set_value(instrument->IsDrum); |
eIsDrum.set_value(instrument->IsDrum); |
3045 |
eMIDIBank.set_value(instrument->MIDIBank); |
eMIDIBank.set_value(instrument->MIDIBank); |
3046 |
eMIDIProgram.set_value(instrument->MIDIProgram); |
eMIDIProgram.set_value(instrument->MIDIProgram); |
3047 |
|
// tab 2 |
3048 |
|
eName2.set_value(instrument->pInfo->Name); |
3049 |
|
eCreationDate.set_value(instrument->pInfo->CreationDate); |
3050 |
|
eComments.set_value(instrument->pInfo->Comments); |
3051 |
|
eProduct.set_value(instrument->pInfo->Product); |
3052 |
|
eCopyright.set_value(instrument->pInfo->Copyright); |
3053 |
|
eArtists.set_value(instrument->pInfo->Artists); |
3054 |
|
eGenre.set_value(instrument->pInfo->Genre); |
3055 |
|
eKeywords.set_value(instrument->pInfo->Keywords); |
3056 |
|
eEngineer.set_value(instrument->pInfo->Engineer); |
3057 |
|
eTechnician.set_value(instrument->pInfo->Technician); |
3058 |
|
eSoftware.set_value(instrument->pInfo->Software); |
3059 |
|
eMedium.set_value(instrument->pInfo->Medium); |
3060 |
|
eSource.set_value(instrument->pInfo->Source); |
3061 |
|
eSourceForm.set_value(instrument->pInfo->SourceForm); |
3062 |
|
eCommissioned.set_value(instrument->pInfo->Commissioned); |
3063 |
|
eSubject.set_value(instrument->pInfo->Subject); |
3064 |
|
|
3065 |
|
update_model--; |
3066 |
|
} |
3067 |
|
|
3068 |
|
|
3069 |
|
SampleProps::SampleProps() : |
3070 |
|
#if HAS_GTKMM_STOCK |
3071 |
|
quitButton(Gtk::Stock::CLOSE), |
3072 |
|
#else |
3073 |
|
quitButton(_("_Close")), |
3074 |
|
#endif |
3075 |
|
table(2,1), |
3076 |
|
eName(_("Name")), |
3077 |
|
eUnityNote(_("Unity Note")), |
3078 |
|
eSampleGroup(_("Sample Group")), |
3079 |
|
eSampleFormatInfo(_("Sample Format")), |
3080 |
|
eSampleID("Sample ID"), |
3081 |
|
eChecksum("Wave Data CRC-32"), |
3082 |
|
eLoopsCount(_("Loops"), 0, 1), // we might support more than 1 loop in future |
3083 |
|
eLoopStart(_("Loop start position"), 0, 9999999), |
3084 |
|
eLoopLength(_("Loop size"), 0, 9999999), |
3085 |
|
eLoopType(_("Loop type")), |
3086 |
|
eLoopPlayCount(_("Playback count")), |
3087 |
|
table2(2,1), |
3088 |
|
eName2(_("Name")), |
3089 |
|
eCreationDate(_("Creation date")), |
3090 |
|
eComments(_("Comments")), |
3091 |
|
eProduct(_("Product")), |
3092 |
|
eCopyright(_("Copyright")), |
3093 |
|
eArtists(_("Artists")), |
3094 |
|
eGenre(_("Genre")), |
3095 |
|
eKeywords(_("Keywords")), |
3096 |
|
eEngineer(_("Engineer")), |
3097 |
|
eTechnician(_("Technician")), |
3098 |
|
eSoftware(_("Software")), |
3099 |
|
eMedium(_("Medium")), |
3100 |
|
eSource(_("Source")), |
3101 |
|
eSourceForm(_("Source form")), |
3102 |
|
eCommissioned(_("Commissioned")), |
3103 |
|
eSubject(_("Subject")) |
3104 |
|
{ |
3105 |
|
if (!Settings::singleton()->autoRestoreWindowDimension) { |
3106 |
|
//set_default_size(470, 390); |
3107 |
|
set_position(Gtk::WIN_POS_MOUSE); |
3108 |
|
} |
3109 |
|
|
3110 |
|
set_title(_("Sample Properties")); |
3111 |
|
|
3112 |
|
tabs.append_page(vbox[1], _("Settings")); |
3113 |
|
tabs.append_page(vbox[2], _("Info")); |
3114 |
|
|
3115 |
|
connect(eName, &SampleProps::set_Name); |
3116 |
|
connect(eUnityNote, &gig::Sample::MIDIUnityNote); |
3117 |
|
connect(eLoopsCount, &gig::Sample::Loops); |
3118 |
|
connectLambda(eLoopStart, [this](uint32_t start){ |
3119 |
|
m->LoopStart = start; |
3120 |
|
m->LoopEnd = start + m->LoopSize; |
3121 |
|
}); |
3122 |
|
connectLambda(eLoopLength, [this](uint32_t length){ |
3123 |
|
m->LoopSize = length; |
3124 |
|
m->LoopEnd = m->LoopStart + length; |
3125 |
|
}); |
3126 |
|
{ |
3127 |
|
const char* choices[] = { _("normal"), _("bidirectional"), _("backward"), 0 }; |
3128 |
|
static const gig::loop_type_t values[] = { |
3129 |
|
gig::loop_type_normal, |
3130 |
|
gig::loop_type_bidirectional, |
3131 |
|
gig::loop_type_backward |
3132 |
|
}; |
3133 |
|
eLoopType.set_choices(choices, values); |
3134 |
|
} |
3135 |
|
connect(eLoopType, &gig::Sample::LoopType); |
3136 |
|
connect(eLoopPlayCount, &gig::Sample::LoopPlayCount); |
3137 |
|
|
3138 |
|
eName.signal_value_changed().connect(sig_name_changed.make_slot()); |
3139 |
|
|
3140 |
|
connect(eName2, &SampleProps::set_Name); |
3141 |
|
connectLambda(eCreationDate, [this](gig::String s) { |
3142 |
|
m->pInfo->CreationDate = s; |
3143 |
|
}); |
3144 |
|
connectLambda(eComments, [this](gig::String s) { |
3145 |
|
m->pInfo->Comments = s; |
3146 |
|
}); |
3147 |
|
connectLambda(eProduct, [this](gig::String s) { |
3148 |
|
m->pInfo->Product = s; |
3149 |
|
}); |
3150 |
|
connectLambda(eCopyright, [this](gig::String s) { |
3151 |
|
m->pInfo->Copyright = s; |
3152 |
|
}); |
3153 |
|
connectLambda(eArtists, [this](gig::String s) { |
3154 |
|
m->pInfo->Artists = s; |
3155 |
|
}); |
3156 |
|
connectLambda(eGenre, [this](gig::String s) { |
3157 |
|
m->pInfo->Genre = s; |
3158 |
|
}); |
3159 |
|
connectLambda(eKeywords, [this](gig::String s) { |
3160 |
|
m->pInfo->Keywords = s; |
3161 |
|
}); |
3162 |
|
connectLambda(eEngineer, [this](gig::String s) { |
3163 |
|
m->pInfo->Engineer = s; |
3164 |
|
}); |
3165 |
|
connectLambda(eTechnician, [this](gig::String s) { |
3166 |
|
m->pInfo->Technician = s; |
3167 |
|
}); |
3168 |
|
connectLambda(eSoftware, [this](gig::String s) { |
3169 |
|
m->pInfo->Software = s; |
3170 |
|
}); |
3171 |
|
connectLambda(eMedium, [this](gig::String s) { |
3172 |
|
m->pInfo->Medium = s; |
3173 |
|
}); |
3174 |
|
connectLambda(eSource, [this](gig::String s) { |
3175 |
|
m->pInfo->Source = s; |
3176 |
|
}); |
3177 |
|
connectLambda(eSourceForm, [this](gig::String s) { |
3178 |
|
m->pInfo->SourceForm = s; |
3179 |
|
}); |
3180 |
|
connectLambda(eCommissioned, [this](gig::String s) { |
3181 |
|
m->pInfo->Commissioned = s; |
3182 |
|
}); |
3183 |
|
connectLambda(eSubject, [this](gig::String s) { |
3184 |
|
m->pInfo->Subject = s; |
3185 |
|
}); |
3186 |
|
|
3187 |
|
// tab 1 |
3188 |
|
#if USE_GTKMM_GRID |
3189 |
|
table.set_column_spacing(5); |
3190 |
|
#else |
3191 |
|
table.set_col_spacings(5); |
3192 |
|
#endif |
3193 |
|
table.add(eName); |
3194 |
|
table.add(eUnityNote); |
3195 |
|
table.add(eSampleGroup); |
3196 |
|
table.add(eSampleFormatInfo); |
3197 |
|
table.add(eSampleID); |
3198 |
|
table.add(eChecksum); |
3199 |
|
table.add(eLoopsCount); |
3200 |
|
table.add(eLoopStart); |
3201 |
|
table.add(eLoopLength); |
3202 |
|
table.add(eLoopType); |
3203 |
|
table.add(eLoopPlayCount); |
3204 |
|
|
3205 |
|
// tab 2 |
3206 |
|
#if USE_GTKMM_GRID |
3207 |
|
table2.set_column_spacing(5); |
3208 |
|
#else |
3209 |
|
table2.set_col_spacings(5); |
3210 |
|
#endif |
3211 |
|
table2.add(eName2); |
3212 |
|
table2.add(eCreationDate); |
3213 |
|
table2.add(eComments); |
3214 |
|
table2.add(eProduct); |
3215 |
|
table2.add(eCopyright); |
3216 |
|
table2.add(eArtists); |
3217 |
|
table2.add(eGenre); |
3218 |
|
table2.add(eKeywords); |
3219 |
|
table2.add(eEngineer); |
3220 |
|
table2.add(eTechnician); |
3221 |
|
table2.add(eSoftware); |
3222 |
|
table2.add(eMedium); |
3223 |
|
table2.add(eSource); |
3224 |
|
table2.add(eSourceForm); |
3225 |
|
table2.add(eCommissioned); |
3226 |
|
table2.add(eSubject); |
3227 |
|
|
3228 |
|
add(vbox[0]); |
3229 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
3230 |
|
table.set_margin(5); |
3231 |
|
#else |
3232 |
|
table.set_border_width(5); |
3233 |
|
#endif |
3234 |
|
vbox[1].pack_start(table); |
3235 |
|
vbox[2].pack_start(table2); |
3236 |
|
table.show(); |
3237 |
|
table2.show(); |
3238 |
|
vbox[0].pack_start(tabs); |
3239 |
|
vbox[0].pack_start(buttonBox, Gtk::PACK_SHRINK); |
3240 |
|
buttonBox.set_layout(Gtk::BUTTONBOX_END); |
3241 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
3242 |
|
buttonBox.set_margin(5); |
3243 |
|
#else |
3244 |
|
buttonBox.set_border_width(5); |
3245 |
|
#endif |
3246 |
|
buttonBox.show(); |
3247 |
|
buttonBox.pack_start(quitButton); |
3248 |
|
quitButton.set_can_default(); |
3249 |
|
quitButton.grab_focus(); |
3250 |
|
|
3251 |
|
quitButton.signal_clicked().connect( |
3252 |
|
sigc::mem_fun(*this, &SampleProps::hide)); |
3253 |
|
|
3254 |
|
quitButton.show(); |
3255 |
|
vbox[0].show(); |
3256 |
|
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
3257 |
|
show_all_children(); |
3258 |
|
#endif |
3259 |
|
} |
3260 |
|
|
3261 |
|
void SampleProps::set_sample(gig::Sample* sample) |
3262 |
|
{ |
3263 |
|
update(sample); |
3264 |
|
|
3265 |
|
update_model++; |
3266 |
|
|
3267 |
|
// tab 1 |
3268 |
|
eName.set_value(sample->pInfo->Name); |
3269 |
|
eUnityNote.set_value(sample->MIDIUnityNote); |
3270 |
|
// show sample group name |
3271 |
|
{ |
3272 |
|
Glib::ustring s = "---"; |
3273 |
|
if (sample && sample->GetGroup()) |
3274 |
|
s = sample->GetGroup()->Name; |
3275 |
|
eSampleGroup.text.set_text(s); |
3276 |
|
} |
3277 |
|
// assemble sample format info string |
3278 |
|
{ |
3279 |
|
Glib::ustring s; |
3280 |
|
if (sample) { |
3281 |
|
switch (sample->Channels) { |
3282 |
|
case 1: s = _("Mono"); break; |
3283 |
|
case 2: s = _("Stereo"); break; |
3284 |
|
default: |
3285 |
|
s = ToString(sample->Channels) + _(" audio channels"); |
3286 |
|
break; |
3287 |
|
} |
3288 |
|
s += " " + ToString(sample->BitDepth) + " Bits"; |
3289 |
|
s += " " + ToString(sample->SamplesPerSecond/1000) + "." |
3290 |
|
+ ToString((sample->SamplesPerSecond%1000)/100) + " kHz"; |
3291 |
|
} else { |
3292 |
|
s = _("No sample assigned to this dimension region."); |
3293 |
|
} |
3294 |
|
eSampleFormatInfo.text.set_text(s); |
3295 |
|
} |
3296 |
|
// generate sample's memory address pointer string |
3297 |
|
{ |
3298 |
|
Glib::ustring s; |
3299 |
|
if (sample) { |
3300 |
|
char buf[64] = {}; |
3301 |
|
snprintf(buf, sizeof(buf), "%p", sample); |
3302 |
|
s = buf; |
3303 |
|
} else { |
3304 |
|
s = "---"; |
3305 |
|
} |
3306 |
|
eSampleID.text.set_text(s); |
3307 |
|
} |
3308 |
|
// generate raw wave form data CRC-32 checksum string |
3309 |
|
{ |
3310 |
|
Glib::ustring s = "---"; |
3311 |
|
if (sample) { |
3312 |
|
char buf[64] = {}; |
3313 |
|
snprintf(buf, sizeof(buf), "%x", sample->GetWaveDataCRC32Checksum()); |
3314 |
|
s = buf; |
3315 |
|
} |
3316 |
|
eChecksum.text.set_text(s); |
3317 |
|
} |
3318 |
|
eLoopsCount.set_value(sample->Loops); |
3319 |
|
eLoopStart.set_value(sample->LoopStart); |
3320 |
|
eLoopLength.set_value(sample->LoopSize); |
3321 |
|
eLoopType.set_value(sample->LoopType); |
3322 |
|
eLoopPlayCount.set_value(sample->LoopPlayCount); |
3323 |
|
// tab 2 |
3324 |
|
eName2.set_value(sample->pInfo->Name); |
3325 |
|
eCreationDate.set_value(sample->pInfo->CreationDate); |
3326 |
|
eComments.set_value(sample->pInfo->Comments); |
3327 |
|
eProduct.set_value(sample->pInfo->Product); |
3328 |
|
eCopyright.set_value(sample->pInfo->Copyright); |
3329 |
|
eArtists.set_value(sample->pInfo->Artists); |
3330 |
|
eGenre.set_value(sample->pInfo->Genre); |
3331 |
|
eKeywords.set_value(sample->pInfo->Keywords); |
3332 |
|
eEngineer.set_value(sample->pInfo->Engineer); |
3333 |
|
eTechnician.set_value(sample->pInfo->Technician); |
3334 |
|
eSoftware.set_value(sample->pInfo->Software); |
3335 |
|
eMedium.set_value(sample->pInfo->Medium); |
3336 |
|
eSource.set_value(sample->pInfo->Source); |
3337 |
|
eSourceForm.set_value(sample->pInfo->SourceForm); |
3338 |
|
eCommissioned.set_value(sample->pInfo->Commissioned); |
3339 |
|
eSubject.set_value(sample->pInfo->Subject); |
3340 |
|
|
3341 |
|
update_model--; |
3342 |
|
} |
3343 |
|
|
3344 |
|
void SampleProps::set_Name(const gig::String& name) |
3345 |
|
{ |
3346 |
|
m->pInfo->Name = name; |
3347 |
|
} |
3348 |
|
|
3349 |
|
void SampleProps::update_name() |
3350 |
|
{ |
3351 |
|
update_model++; |
3352 |
|
eName.set_value(m->pInfo->Name); |
3353 |
update_model--; |
update_model--; |
3354 |
} |
} |
3355 |
|
|
3385 |
|
|
3386 |
bool MainWindow::onQueryTreeViewTooltip(int x, int y, bool keyboardTip, const Glib::RefPtr<Gtk::Tooltip>& tooltip) { |
bool MainWindow::onQueryTreeViewTooltip(int x, int y, bool keyboardTip, const Glib::RefPtr<Gtk::Tooltip>& tooltip) { |
3387 |
Gtk::TreeModel::iterator iter; |
Gtk::TreeModel::iterator iter; |
3388 |
m_TreeView.get_tooltip_context_iter(x, y, keyboardTip, iter); |
if (!m_TreeView.get_tooltip_context_iter(x, y, keyboardTip, iter)) { |
3389 |
|
return false; |
3390 |
|
} |
3391 |
Gtk::TreeModel::Path path(iter); |
Gtk::TreeModel::Path path(iter); |
3392 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
3393 |
Gtk::TreeViewColumn* pointedColumn = NULL; |
Gtk::TreeViewColumn* pointedColumn = NULL; |
3419 |
static Glib::ustring scriptTooltipFor(gig::Instrument* instrument, int index) { |
static Glib::ustring scriptTooltipFor(gig::Instrument* instrument, int index) { |
3420 |
Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
3421 |
const int iScriptSlots = instrument->ScriptSlotCount(); |
const int iScriptSlots = instrument->ScriptSlotCount(); |
3422 |
Glib::ustring tooltip = "<u>(" + ToString(index) + ") „" + name + "”</u>\n\n"; |
Glib::ustring tooltip = "<u>(" + ToString(index) + ") “" + name + "”</u>\n\n"; |
3423 |
if (!iScriptSlots) |
if (!iScriptSlots) |
3424 |
tooltip += "<span foreground='red'><i>No script assigned</i></span>"; |
tooltip += "<span foreground='red'><i>No script assigned</i></span>"; |
3425 |
else { |
else { |
3426 |
for (int i = 0; i < iScriptSlots; ++i) { |
for (int i = 0; i < iScriptSlots; ++i) { |
3427 |
tooltip += "• " + ToString(i+1) + ". Script: „<span foreground='#46DEFF'><b>" + |
tooltip += "• " + ToString(i+1) + ". Script: “<span foreground='#46DEFF'><b>" + |
3428 |
instrument->GetScriptOfSlot(i)->Name + "</b></span>”"; |
instrument->GetScriptOfSlot(i)->Name + "</b></span>”"; |
3429 |
if (i + 1 < iScriptSlots) tooltip += "\n\n"; |
if (i + 1 < iScriptSlots) tooltip += "\n\n"; |
3430 |
} |
} |
3445 |
file_has_name = filename; |
file_has_name = filename; |
3446 |
file_is_changed = false; |
file_is_changed = false; |
3447 |
|
|
3448 |
propDialog.set_file(gig); |
fileProps.set_file(gig); |
|
propDialog.set_info(gig->pInfo); |
|
3449 |
|
|
3450 |
instrument_name_connection.block(); |
instrument_name_connection.block(); |
3451 |
int index = 0; |
int index = 0; |
3585 |
} |
} |
3586 |
} |
} |
3587 |
|
|
3588 |
|
bool MainWindow::sample_props_set_sample() |
3589 |
|
{ |
3590 |
|
sampleProps.signal_name_changed().clear(); |
3591 |
|
|
3592 |
|
std::vector<Gtk::TreeModel::Path> rows = m_TreeViewSamples.get_selection()->get_selected_rows(); |
3593 |
|
if (rows.empty()) { |
3594 |
|
sampleProps.hide(); |
3595 |
|
return false; |
3596 |
|
} |
3597 |
|
//NOTE: was const_iterator before, which did not compile with GTKMM4 development branch, probably going to be fixed before final GTKMM4 release though. |
3598 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]); |
3599 |
|
if (it) { |
3600 |
|
Gtk::TreeModel::Row row = *it; |
3601 |
|
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
3602 |
|
|
3603 |
|
sampleProps.set_sample(sample); |
3604 |
|
|
3605 |
|
// make sure sample tree is updated when user changes the |
3606 |
|
// sample name in sample properties window |
3607 |
|
sampleProps.signal_name_changed().connect( |
3608 |
|
sigc::bind( |
3609 |
|
sigc::mem_fun(*this, |
3610 |
|
&MainWindow::sample_name_changed_by_sample_props |
3611 |
|
), it |
3612 |
|
) |
3613 |
|
); |
3614 |
|
} else { |
3615 |
|
sampleProps.hide(); |
3616 |
|
} |
3617 |
|
//NOTE: explicit boolean cast required for GTKMM4 development branch here |
3618 |
|
return it ? true : false; |
3619 |
|
} |
3620 |
|
|
3621 |
|
void MainWindow::show_sample_props() |
3622 |
|
{ |
3623 |
|
if (sample_props_set_sample()) { |
3624 |
|
sampleProps.show(); |
3625 |
|
sampleProps.deiconify(); |
3626 |
|
} |
3627 |
|
} |
3628 |
|
|
3629 |
|
void MainWindow::sample_name_changed_by_sample_props(Gtk::TreeModel::iterator& it) |
3630 |
|
{ |
3631 |
|
Gtk::TreeModel::Row row = *it; |
3632 |
|
Glib::ustring name = row[m_SamplesModel.m_col_name]; |
3633 |
|
|
3634 |
|
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
3635 |
|
Glib::ustring gigname(gig_to_utf8(sample->pInfo->Name)); |
3636 |
|
if (gigname != name) { |
3637 |
|
Gtk::TreeModel::Path path(*it); |
3638 |
|
row[m_SamplesModel.m_col_name] = gigname; |
3639 |
|
} |
3640 |
|
} |
3641 |
|
|
3642 |
void MainWindow::show_midi_rules() |
void MainWindow::show_midi_rules() |
3643 |
{ |
{ |
3644 |
if (gig::Instrument* instrument = get_instrument()) |
if (gig::Instrument* instrument = get_instrument()) |
3707 |
onScriptSlotsModified(pInstrument); |
onScriptSlotsModified(pInstrument); |
3708 |
} |
} |
3709 |
|
|
3710 |
|
void MainWindow::dropAllScriptSlots() { |
3711 |
|
gig::Instrument* pInstrument = get_instrument(); |
3712 |
|
if (!pInstrument) { |
3713 |
|
printf("!instrument\n"); |
3714 |
|
return; |
3715 |
|
} |
3716 |
|
|
3717 |
|
const int iScriptSlots = pInstrument->ScriptSlotCount(); |
3718 |
|
for (int i = iScriptSlots - 1; i >= 0; --i) |
3719 |
|
pInstrument->RemoveScriptSlot(i); |
3720 |
|
|
3721 |
|
onScriptSlotsModified(pInstrument); |
3722 |
|
} |
3723 |
|
|
3724 |
void MainWindow::on_action_refresh_all() { |
void MainWindow::on_action_refresh_all() { |
3725 |
__refreshEntireGUI(); |
__refreshEntireGUI(); |
3726 |
} |
} |
3895 |
show_intruments_tab(); |
show_intruments_tab(); |
3896 |
m_TreeView.get_selection()->unselect_all(); |
m_TreeView.get_selection()->unselect_all(); |
3897 |
|
|
3898 |
#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) |
3899 |
auto iterSel = model->children()[i].get_iter(); |
auto iterSel = model->children()[i].get_iter(); |
3900 |
m_TreeView.get_selection()->select(iterSel); |
m_TreeView.get_selection()->select(iterSel); |
3901 |
#else |
#else |
3925 |
// select and show the respective instrument in the list view |
// select and show the respective instrument in the list view |
3926 |
show_intruments_tab(); |
show_intruments_tab(); |
3927 |
m_TreeView.get_selection()->unselect_all(); |
m_TreeView.get_selection()->unselect_all(); |
3928 |
#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) |
3929 |
auto iterSel = model->children()[i].get_iter(); |
auto iterSel = model->children()[i].get_iter(); |
3930 |
m_TreeView.get_selection()->select(iterSel); |
m_TreeView.get_selection()->select(iterSel); |
3931 |
#else |
#else |
3961 |
if (rowSample[m_SamplesModel.m_col_sample] == sample) { |
if (rowSample[m_SamplesModel.m_col_sample] == sample) { |
3962 |
show_samples_tab(); |
show_samples_tab(); |
3963 |
m_TreeViewSamples.get_selection()->unselect_all(); |
m_TreeViewSamples.get_selection()->unselect_all(); |
3964 |
#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) |
3965 |
auto iterSel = rowGroup.children()[s].get_iter(); |
auto iterSel = rowGroup.children()[s].get_iter(); |
3966 |
m_TreeViewSamples.get_selection()->select(iterSel); |
m_TreeViewSamples.get_selection()->select(iterSel); |
3967 |
#else |
#else |
4161 |
assign_scripts_menu->append(*item); |
assign_scripts_menu->append(*item); |
4162 |
} |
} |
4163 |
|
|
4164 |
|
// add separator line to menu |
4165 |
|
assign_scripts_menu->append(*new Gtk::SeparatorMenuItem); |
4166 |
|
|
4167 |
|
{ |
4168 |
|
Gtk::MenuItem* item = new Gtk::MenuItem(_("Unassign All Scripts")); |
4169 |
|
item->signal_activate().connect( |
4170 |
|
sigc::mem_fun(*this, &MainWindow::dropAllScriptSlots) |
4171 |
|
); |
4172 |
|
assign_scripts_menu->append(*item); |
4173 |
|
item->set_accel_path("<Scripts>/DropAllScriptSlots"); |
4174 |
|
} |
4175 |
|
|
4176 |
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
4177 |
assign_scripts_menu->show_all_children(); |
assign_scripts_menu->show_all_children(); |
4178 |
#endif |
#endif |
4345 |
} |
} |
4346 |
|
|
4347 |
void MainWindow::on_action_sample_properties() { |
void MainWindow::on_action_sample_properties() { |
4348 |
//TODO: show a dialog where the selected sample's properties can be edited |
show_sample_props(); |
|
Gtk::MessageDialog msg( |
|
|
*this, _("Sorry, yet to be implemented!"), false, Gtk::MESSAGE_INFO |
|
|
); |
|
|
msg.run(); |
|
4349 |
} |
} |
4350 |
|
|
4351 |
void MainWindow::on_action_add_script_group() { |
void MainWindow::on_action_add_script_group() { |
4564 |
dialog.set_current_folder(current_sample_dir); |
dialog.set_current_folder(current_sample_dir); |
4565 |
} |
} |
4566 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
4567 |
|
dialog.hide(); |
4568 |
current_sample_dir = dialog.get_current_folder(); |
current_sample_dir = dialog.get_current_folder(); |
4569 |
Glib::ustring error_files; |
Glib::ustring error_files; |
4570 |
std::vector<std::string> filenames = dialog.get_filenames(); |
std::vector<std::string> filenames = dialog.get_filenames(); |
4745 |
} |
} |
4746 |
if (dialog.run() == Gtk::RESPONSE_OK) |
if (dialog.run() == Gtk::RESPONSE_OK) |
4747 |
{ |
{ |
4748 |
|
dialog.hide(); |
4749 |
current_sample_dir = dialog.get_current_folder(); |
current_sample_dir = dialog.get_current_folder(); |
4750 |
Glib::ustring error_files; |
Glib::ustring error_files; |
4751 |
std::string folder = dialog.get_filename(); |
std::string folder = dialog.get_filename(); |
5144 |
file_changed(); |
file_changed(); |
5145 |
} |
} |
5146 |
} |
} |
5147 |
|
// change name in the sample properties window |
5148 |
|
if (sampleProps.get_sample() == sample && sample) { |
5149 |
|
sampleProps.set_sample(sample); |
5150 |
|
} |
5151 |
} |
} |
5152 |
|
|
5153 |
void MainWindow::script_name_changed(const Gtk::TreeModel::Path& path, |
void MainWindow::script_name_changed(const Gtk::TreeModel::Path& path, |
5238 |
trim(pattern); |
trim(pattern); |
5239 |
if (pattern.empty()) return true; |
if (pattern.empty()) return true; |
5240 |
|
|
5241 |
#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) |
5242 |
//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. |
5243 |
Gtk::TreeModel::Row row = **(Gtk::TreeModel::iterator*)(&iter); |
Gtk::TreeModel::Row row = **(Gtk::TreeModel::iterator*)(&iter); |
5244 |
#else |
#else |
5478 |
#endif |
#endif |
5479 |
|
|
5480 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
5481 |
|
dialog.hide(); |
5482 |
|
#ifdef GLIB_THREADS |
5483 |
printf("on_action_merge_files self=%p\n", |
printf("on_action_merge_files self=%p\n", |
5484 |
static_cast<void*>(Glib::Threads::Thread::self())); |
static_cast<void*>(Glib::Threads::Thread::self())); |
5485 |
|
#else |
5486 |
|
std::cout << "on_action_merge_files self=" << |
5487 |
|
std::this_thread::get_id() << "\n"; |
5488 |
|
#endif |
5489 |
std::vector<std::string> filenames = dialog.get_filenames(); |
std::vector<std::string> filenames = dialog.get_filenames(); |
5490 |
|
|
5491 |
// merge the selected files to the currently open .gig file |
// merge the selected files to the currently open .gig file |