32 |
#include <glibmm/dispatcher.h> |
#include <glibmm/dispatcher.h> |
33 |
#include <glibmm/miscutils.h> |
#include <glibmm/miscutils.h> |
34 |
#include <glibmm/stringutils.h> |
#include <glibmm/stringutils.h> |
35 |
|
#include <glibmm/regex.h> |
36 |
#include <gtkmm/aboutdialog.h> |
#include <gtkmm/aboutdialog.h> |
37 |
#include <gtkmm/filechooserdialog.h> |
#include <gtkmm/filechooserdialog.h> |
38 |
#include <gtkmm/messagedialog.h> |
#include <gtkmm/messagedialog.h> |
122 |
|
|
123 |
m_TreeViewNotebook.set_size_request(300); |
m_TreeViewNotebook.set_size_request(300); |
124 |
|
|
125 |
m_HPaned.add1(m_TreeViewNotebook); |
m_searchLabel.set_text(Glib::ustring(" ") + _("Filter:")); |
126 |
|
m_searchField.pack_start(m_searchLabel, Gtk::PACK_SHRINK); |
127 |
|
m_searchField.pack_start(m_searchText); |
128 |
|
m_searchField.set_spacing(5); |
129 |
|
|
130 |
|
m_left_vbox.pack_start(m_TreeViewNotebook); |
131 |
|
m_left_vbox.pack_start(m_searchField, Gtk::PACK_SHRINK); |
132 |
|
|
133 |
|
m_HPaned.add1(m_left_vbox); |
134 |
|
|
135 |
dimreg_hbox.add(dimreg_label); |
dimreg_hbox.add(dimreg_label); |
136 |
dimreg_hbox.add(dimreg_all_regions); |
dimreg_hbox.add(dimreg_all_regions); |
137 |
dimreg_hbox.add(dimreg_all_dimregs); |
dimreg_hbox.add(dimreg_all_dimregs); |
695 |
|
|
696 |
// Create the Tree model: |
// Create the Tree model: |
697 |
m_refTreeModel = Gtk::ListStore::create(m_Columns); |
m_refTreeModel = Gtk::ListStore::create(m_Columns); |
698 |
m_TreeView.set_model(m_refTreeModel); |
m_refTreeModelFilter = Gtk::TreeModelFilter::create(m_refTreeModel); |
699 |
|
m_refTreeModelFilter->set_visible_func( |
700 |
|
sigc::mem_fun(*this, &MainWindow::instrument_row_visible) |
701 |
|
); |
702 |
|
m_TreeView.set_model(m_refTreeModelFilter); |
703 |
|
|
704 |
m_TreeView.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE); |
m_TreeView.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE); |
705 |
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_tooltip_text(_("Right click here for actions on instruments & MIDI Rules. Drag & drop to change the order of instruments.")); |
706 |
instrument_name_connection = m_refTreeModel->signal_row_changed().connect( |
instrument_name_connection = m_refTreeModel->signal_row_changed().connect( |
876 |
dimreg_stereo.signal_toggled().connect( |
dimreg_stereo.signal_toggled().connect( |
877 |
sigc::mem_fun(*this, &MainWindow::update_dimregs)); |
sigc::mem_fun(*this, &MainWindow::update_dimregs)); |
878 |
|
|
879 |
|
m_searchText.signal_changed().connect( |
880 |
|
sigc::mem_fun(m_refTreeModelFilter.operator->(), &Gtk::TreeModelFilter::refilter) |
881 |
|
); |
882 |
|
|
883 |
file = 0; |
file = 0; |
884 |
file_is_changed = false; |
file_is_changed = false; |
885 |
|
|
888 |
// start with a new gig file by default |
// start with a new gig file by default |
889 |
on_action_file_new(); |
on_action_file_new(); |
890 |
|
|
891 |
|
m_TreeViewNotebook.signal_switch_page().connect( |
892 |
|
sigc::mem_fun(*this, &MainWindow::on_notebook_tab_switched) |
893 |
|
); |
894 |
|
|
895 |
// select 'Instruments' tab by default |
// select 'Instruments' tab by default |
896 |
// (gtk allows this only if the tab childs are visible, thats why it's here) |
// (gtk allows this only if the tab childs are visible, thats why it's here) |
897 |
m_TreeViewNotebook.set_current_page(1); |
m_TreeViewNotebook.set_current_page(1); |
1064 |
updateMacroMenu(); |
updateMacroMenu(); |
1065 |
} |
} |
1066 |
|
|
1067 |
|
//NOTE: the actual signal's first argument for argument 'page' is on some gtkmm version GtkNotebookPage* and on some Gtk::Widget*. Since we don't need that argument, it is simply void* here for now. |
1068 |
|
void MainWindow::on_notebook_tab_switched(void* page, guint page_num) { |
1069 |
|
bool isInstrumentsPage = (page_num == 1); |
1070 |
|
// so far we only support filtering for the instruments list, so hide the |
1071 |
|
// filter text entry field if another tab is selected |
1072 |
|
m_searchField.set_visible(isInstrumentsPage); |
1073 |
|
} |
1074 |
|
|
1075 |
bool MainWindow::on_delete_event(GdkEventAny* event) |
bool MainWindow::on_delete_event(GdkEventAny* event) |
1076 |
{ |
{ |
1077 |
return !file_is_shared && file_is_changed && !close_confirmation_dialog(); |
return !file_is_shared && file_is_changed && !close_confirmation_dialog(); |
2366 |
if (!pInstrument) return; |
if (!pInstrument) return; |
2367 |
const int iScriptSlots = pInstrument->ScriptSlotCount(); |
const int iScriptSlots = pInstrument->ScriptSlotCount(); |
2368 |
|
|
2369 |
Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
//NOTE: This is a big mess! Sometimes GTK requires m_TreeView.get_model(), here we need m_refTreeModelFilter->get_model(), otherwise accessing children below causes an error! |
2370 |
|
//Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
2371 |
|
Glib::RefPtr<Gtk::TreeModel> model = m_refTreeModelFilter->get_model(); |
2372 |
|
|
2373 |
for (int i = 0; i < model->children().size(); ++i) { |
for (int i = 0; i < model->children().size(); ++i) { |
2374 |
Gtk::TreeModel::Row row = model->children()[i]; |
Gtk::TreeModel::Row row = model->children()[i]; |
2375 |
if (row[m_Columns.m_col_instr] != pInstrument) continue; |
if (row[m_Columns.m_col_instr] != pInstrument) continue; |
2501 |
void MainWindow::select_instrument(gig::Instrument* instrument) { |
void MainWindow::select_instrument(gig::Instrument* instrument) { |
2502 |
if (!instrument) return; |
if (!instrument) return; |
2503 |
|
|
2504 |
|
//NOTE: This is a big mess! Sometimes GTK requires m_refTreeModelFilter->get_model(), here we need m_TreeView.get_model(), otherwise treeview selection below causes an error! |
2505 |
Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
2506 |
|
//Glib::RefPtr<Gtk::TreeModel> model = m_refTreeModelFilter->get_model(); |
2507 |
|
|
2508 |
for (int i = 0; i < model->children().size(); ++i) { |
for (int i = 0; i < model->children().size(); ++i) { |
2509 |
Gtk::TreeModel::Row row = model->children()[i]; |
Gtk::TreeModel::Row row = model->children()[i]; |
2510 |
if (row[m_Columns.m_col_instr] == instrument) { |
if (row[m_Columns.m_col_instr] == instrument) { |
2526 |
gig::Region* pRegion = (gig::Region*) dimRgn->GetParent(); |
gig::Region* pRegion = (gig::Region*) dimRgn->GetParent(); |
2527 |
gig::Instrument* pInstrument = (gig::Instrument*) pRegion->GetParent(); |
gig::Instrument* pInstrument = (gig::Instrument*) pRegion->GetParent(); |
2528 |
|
|
2529 |
|
//NOTE: This is a big mess! Sometimes GTK requires m_refTreeModelFilter->get_model(), here we need m_TreeView.get_model(), otherwise treeview selection below causes an error! |
2530 |
Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
2531 |
|
//Glib::RefPtr<Gtk::TreeModel> model = m_refTreeModelFilter->get_model(); |
2532 |
|
|
2533 |
for (int i = 0; i < model->children().size(); ++i) { |
for (int i = 0; i < model->children().size(); ++i) { |
2534 |
Gtk::TreeModel::Row row = model->children()[i]; |
Gtk::TreeModel::Row row = model->children()[i]; |
2535 |
if (row[m_Columns.m_col_instr] == pInstrument) { |
if (row[m_Columns.m_col_instr] == pInstrument) { |
3739 |
} |
} |
3740 |
} |
} |
3741 |
|
|
3742 |
|
bool MainWindow::instrument_row_visible(const Gtk::TreeModel::const_iterator& iter) { |
3743 |
|
if (!iter) |
3744 |
|
return true; |
3745 |
|
|
3746 |
|
Glib::ustring pattern = m_searchText.get_text().lowercase(); |
3747 |
|
trim(pattern); |
3748 |
|
if (pattern.empty()) return true; |
3749 |
|
|
3750 |
|
Gtk::TreeModel::Row row = *iter; |
3751 |
|
Glib::ustring name = row[m_Columns.m_col_name]; |
3752 |
|
name = name.lowercase(); |
3753 |
|
|
3754 |
|
std::vector<Glib::ustring> tokens = Glib::Regex::split_simple(" ", pattern); |
3755 |
|
for (int t = 0; t < tokens.size(); ++t) |
3756 |
|
if (name.find(tokens[t]) == Glib::ustring::npos) |
3757 |
|
return false; |
3758 |
|
|
3759 |
|
return true; |
3760 |
|
} |
3761 |
|
|
3762 |
void MainWindow::on_action_combine_instruments() { |
void MainWindow::on_action_combine_instruments() { |
3763 |
CombineInstrumentsDialog* d = new CombineInstrumentsDialog(*this, file); |
CombineInstrumentsDialog* d = new CombineInstrumentsDialog(*this, file); |
3764 |
|
|