46 |
#include "Settings.h" |
#include "Settings.h" |
47 |
#include "CombineInstrumentsDialog.h" |
#include "CombineInstrumentsDialog.h" |
48 |
#include "scripteditor.h" |
#include "scripteditor.h" |
49 |
|
#include "scriptslots.h" |
50 |
#include "../../gfx/status_attached.xpm" |
#include "../../gfx/status_attached.xpm" |
51 |
#include "../../gfx/status_detached.xpm" |
#include "../../gfx/status_detached.xpm" |
52 |
|
|
135 |
sigc::mem_fun( |
sigc::mem_fun( |
136 |
*this, &MainWindow::show_instr_props)); |
*this, &MainWindow::show_instr_props)); |
137 |
actionGroup->add(Gtk::Action::create("MidiRules", |
actionGroup->add(Gtk::Action::create("MidiRules", |
138 |
_("_Midi Rules")), |
_("_Midi Rules...")), |
139 |
sigc::mem_fun( |
sigc::mem_fun( |
140 |
*this, &MainWindow::show_midi_rules)); |
*this, &MainWindow::show_midi_rules)); |
141 |
|
actionGroup->add(Gtk::Action::create("ScriptSlots", |
142 |
|
_("_Script Slots...")), |
143 |
|
sigc::mem_fun( |
144 |
|
*this, &MainWindow::show_script_slots)); |
145 |
actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT), |
actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT), |
146 |
sigc::mem_fun( |
sigc::mem_fun( |
147 |
*this, &MainWindow::on_action_quit)); |
*this, &MainWindow::on_action_quit)); |
301 |
" <popup name='PopupMenu'>" |
" <popup name='PopupMenu'>" |
302 |
" <menuitem action='InstrProperties'/>" |
" <menuitem action='InstrProperties'/>" |
303 |
" <menuitem action='MidiRules'/>" |
" <menuitem action='MidiRules'/>" |
304 |
|
" <menuitem action='ScriptSlots'/>" |
305 |
" <menuitem action='AddInstrument'/>" |
" <menuitem action='AddInstrument'/>" |
306 |
" <menuitem action='DupInstrument'/>" |
" <menuitem action='DupInstrument'/>" |
307 |
" <separator/>" |
" <separator/>" |
430 |
sigc::mem_fun(*this, &MainWindow::script_name_changed) |
sigc::mem_fun(*this, &MainWindow::script_name_changed) |
431 |
); |
); |
432 |
|
|
433 |
|
// establish drag&drop between scripts tree view and ScriptSlots window |
434 |
|
std::vector<Gtk::TargetEntry> drag_target_gig_script; |
435 |
|
drag_target_gig_script.push_back(Gtk::TargetEntry("gig::Script")); |
436 |
|
m_TreeViewScripts.drag_source_set(drag_target_gig_script); |
437 |
|
m_TreeViewScripts.signal_drag_begin().connect( |
438 |
|
sigc::mem_fun(*this, &MainWindow::on_scripts_treeview_drag_begin) |
439 |
|
); |
440 |
|
m_TreeViewScripts.signal_drag_data_get().connect( |
441 |
|
sigc::mem_fun(*this, &MainWindow::on_scripts_treeview_drag_data_get) |
442 |
|
); |
443 |
|
|
444 |
// establish drag&drop between samples tree view and dimension region 'Sample' text entry |
// establish drag&drop between samples tree view and dimension region 'Sample' text entry |
445 |
std::vector<Gtk::TargetEntry> drag_target_gig_sample; |
std::vector<Gtk::TargetEntry> drag_target_gig_sample; |
446 |
drag_target_gig_sample.push_back(Gtk::TargetEntry("gig::Sample")); |
drag_target_gig_sample.push_back(Gtk::TargetEntry("gig::Sample")); |
1495 |
} |
} |
1496 |
} |
} |
1497 |
|
|
1498 |
|
void MainWindow::show_script_slots() { |
1499 |
|
if (!file) return; |
1500 |
|
// get selected instrument |
1501 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
1502 |
|
Gtk::TreeModel::iterator it = sel->get_selected(); |
1503 |
|
if (!it) return; |
1504 |
|
Gtk::TreeModel::Row row = *it; |
1505 |
|
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
1506 |
|
if (!instrument) return; |
1507 |
|
|
1508 |
|
ScriptSlots* window = new ScriptSlots; |
1509 |
|
window->setInstrument(instrument); |
1510 |
|
//window->reparent(*this); |
1511 |
|
window->show(); |
1512 |
|
} |
1513 |
|
|
1514 |
void MainWindow::on_action_view_status_bar() { |
void MainWindow::on_action_view_status_bar() { |
1515 |
Gtk::CheckMenuItem* item = |
Gtk::CheckMenuItem* item = |
1516 |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar")); |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar")); |
2261 |
} |
} |
2262 |
} |
} |
2263 |
|
|
2264 |
|
// see comment on on_sample_treeview_drag_begin() |
2265 |
|
void MainWindow::on_scripts_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context) |
2266 |
|
{ |
2267 |
|
first_call_to_drag_data_get = true; |
2268 |
|
} |
2269 |
|
|
2270 |
|
void MainWindow::on_scripts_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&, |
2271 |
|
Gtk::SelectionData& selection_data, guint, guint) |
2272 |
|
{ |
2273 |
|
if (!first_call_to_drag_data_get) return; |
2274 |
|
first_call_to_drag_data_get = false; |
2275 |
|
|
2276 |
|
// get selected script |
2277 |
|
gig::Script* script = NULL; |
2278 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewScripts.get_selection(); |
2279 |
|
Gtk::TreeModel::iterator it = sel->get_selected(); |
2280 |
|
if (it) { |
2281 |
|
Gtk::TreeModel::Row row = *it; |
2282 |
|
script = row[m_ScriptsModel.m_col_script]; |
2283 |
|
} |
2284 |
|
// pass the gig::Script as pointer |
2285 |
|
selection_data.set(selection_data.get_target(), 0/*unused*/, |
2286 |
|
(const guchar*)&script, |
2287 |
|
sizeof(script)/*length of data in bytes*/); |
2288 |
|
} |
2289 |
|
|
2290 |
// For some reason drag_data_get gets called two times for each |
// For some reason drag_data_get gets called two times for each |
2291 |
// drag'n'drop (at least when target is an Entry). This work-around |
// drag'n'drop (at least when target is an Entry). This work-around |
2292 |
// makes sure the code in drag_data_get and drop_drag_data_received is |
// makes sure the code in drag_data_get and drop_drag_data_received is |