--- gigedit/trunk/src/gigedit/mainwindow.cpp 2017/05/09 14:35:23 3162 +++ gigedit/trunk/src/gigedit/mainwindow.cpp 2017/05/30 20:17:12 3258 @@ -62,6 +62,9 @@ #include "gfx/builtinpix.h" #include "MacroEditor.h" #include "MacrosSetup.h" +#if defined(__APPLE__) +# include "MacHelper.h" +#endif MainWindow::MainWindow() : m_DimRegionChooser(*this), @@ -78,7 +81,11 @@ loadBuiltInPix(); // set_border_width(5); -// set_default_size(400, 200); + + if (!Settings::singleton()->autoRestoreWindowDimension) { + set_default_size(800, 600); + set_position(Gtk::WIN_POS_CENTER); + } add(m_VBox); @@ -654,6 +661,7 @@ // Add the TreeView's view columns: m_TreeView.append_column(_("Nr"), m_Columns.m_col_nr); m_TreeView.append_column_editable(_("Instrument"), m_Columns.m_col_name); + m_TreeView.append_column(_("Scripts"), m_Columns.m_col_scripts); m_TreeView.set_headers_visible(true); // establish drag&drop within the instrument tree view, allowing to reorder @@ -870,12 +878,25 @@ updateMacroMenu(); } + + Glib::signal_idle().connect_once( + sigc::mem_fun(*this, &MainWindow::bringToFront), + 200 + ); } MainWindow::~MainWindow() { } +void MainWindow::bringToFront() { + #if defined(__APPLE__) + macRaiseAppWindow(); + #endif + raise(); + present(); +} + void MainWindow::updateMacroMenu() { Gtk::Menu* menuMacro = dynamic_cast( uiManager->get_widget("/MenuBar/MenuMacro") @@ -914,6 +935,9 @@ ); menuMacro->append(*item); item->set_accel_path("/macro_" + ToString(iMacro)); + Glib::ustring comment = macro.comment(); + if (!comment.empty()) + item->set_tooltip_text(comment); } // if there are no macros configured at all, then show a dummy entry instead if (m_macros.empty()) { @@ -1201,7 +1225,7 @@ // save the file as separate temporary file first, // then move the saved file over the old file // (may result in performance speedup during save) - String tmpname = filename + ".TMP"; + gig::String tmpname = filename + ".TMP"; gig->Save(tmpname, &progress); #if defined(WIN32) if (!DeleteFile(filename.c_str())) { @@ -1209,14 +1233,14 @@ } #else // POSIX ... if (unlink(filename.c_str())) { - throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file): " + String(strerror(errno))); + 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): " + String(strerror(errno))); + throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file): " + gig::String(strerror(errno))); #endif } } @@ -1812,6 +1836,7 @@ dialog.set_comments(sComment.c_str()); dialog.set_website("http://www.linuxsampler.org"); dialog.set_website_label("http://www.linuxsampler.org"); + dialog.set_position(Gtk::WIN_POS_CENTER); dialog.run(); } @@ -1837,6 +1862,11 @@ table(2, 1), m_file(NULL) { + if (!Settings::singleton()->autoRestoreWindowDimension) { + set_default_size(470, 390); + set_position(Gtk::WIN_POS_MOUSE); + } + set_title(_("File Properties")); eName.set_width_chars(50); @@ -1971,6 +2001,11 @@ eDimensionKeyRangeLow(_("Keyswitching range low")), eDimensionKeyRangeHigh(_("Keyswitching range high")) { + if (!Settings::singleton()->autoRestoreWindowDimension) { + //set_default_size(470, 390); + set_position(Gtk::WIN_POS_MOUSE); + } + set_title(_("Instrument Properties")); eDimensionKeyRangeLow.set_tip( @@ -2095,12 +2130,14 @@ for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ; instrument = gig->GetNextInstrument(), ++index) { Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); + const int iScriptSlots = instrument->ScriptSlotCount(); Gtk::TreeModel::iterator iter = m_refTreeModel->append(); Gtk::TreeModel::Row row = *iter; row[m_Columns.m_col_nr] = index; row[m_Columns.m_col_name] = name; row[m_Columns.m_col_instr] = instrument; + row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; add_instrument_to_menu(name); } @@ -2239,10 +2276,26 @@ ScriptSlots* window = new ScriptSlots; window->setInstrument(instrument); + window->signal_script_slots_changed().connect( + sigc::mem_fun(*this, &MainWindow::onScriptSlotsModified) + ); //window->reparent(*this); window->show(); } +void MainWindow::onScriptSlotsModified(gig::Instrument* pInstrument) { + if (!pInstrument) return; + const int iScriptSlots = pInstrument->ScriptSlotCount(); + + Glib::RefPtr model = m_TreeView.get_model(); + for (int i = 0; i < model->children().size(); ++i) { + Gtk::TreeModel::Row row = model->children()[i]; + if (row[m_Columns.m_col_instr] != pInstrument) continue; + row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; + break; + } +} + void MainWindow::on_action_refresh_all() { __refreshEntireGUI(); } @@ -2557,6 +2610,7 @@ rowInstr[m_Columns.m_col_nr] = m_refTreeModel->children().size() - 1; rowInstr[m_Columns.m_col_name] = name; rowInstr[m_Columns.m_col_instr] = instrument; + rowInstr[m_Columns.m_col_scripts] = ""; instrument_name_connection.unblock(); add_instrument_to_menu(name); @@ -3535,7 +3589,6 @@ void MainWindow::on_action_combine_instruments() { CombineInstrumentsDialog* d = new CombineInstrumentsDialog(*this, file); d->show_all(); - d->resize(500, 400); d->run(); if (d->fileWasChanged()) { // update GUI with new instrument just created @@ -3920,9 +3973,8 @@ itDimReg != dimreg_edit.dimregs.end(); ++itDimReg) { gig::DimensionRegion* pDimRgn = *itDimReg; - dimreg_to_be_changed_signal.emit(pDimRgn); + DimRegionChangeGuard(this, pDimRgn); macro.deserialize(pDimRgn); - dimreg_changed_signal.emit(pDimRgn); } //region_changed() file_changed();