--- gigedit/trunk/src/gigedit/mainwindow.cpp 2014/06/07 22:34:31 2604 +++ gigedit/trunk/src/gigedit/mainwindow.cpp 2014/06/08 19:09:26 2610 @@ -46,6 +46,7 @@ #include "Settings.h" #include "CombineInstrumentsDialog.h" #include "scripteditor.h" +#include "scriptslots.h" #include "../../gfx/status_attached.xpm" #include "../../gfx/status_detached.xpm" @@ -134,9 +135,13 @@ sigc::mem_fun( *this, &MainWindow::show_instr_props)); actionGroup->add(Gtk::Action::create("MidiRules", - _("_Midi Rules")), + _("_Midi Rules...")), sigc::mem_fun( *this, &MainWindow::show_midi_rules)); + actionGroup->add(Gtk::Action::create("ScriptSlots", + _("_Script Slots...")), + sigc::mem_fun( + *this, &MainWindow::show_script_slots)); actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT), sigc::mem_fun( *this, &MainWindow::on_action_quit)); @@ -296,6 +301,7 @@ " " " " " " + " " " " " " " " @@ -424,6 +430,17 @@ sigc::mem_fun(*this, &MainWindow::script_name_changed) ); + // establish drag&drop between scripts tree view and ScriptSlots window + std::vector drag_target_gig_script; + drag_target_gig_script.push_back(Gtk::TargetEntry("gig::Script")); + m_TreeViewScripts.drag_source_set(drag_target_gig_script); + m_TreeViewScripts.signal_drag_begin().connect( + sigc::mem_fun(*this, &MainWindow::on_scripts_treeview_drag_begin) + ); + m_TreeViewScripts.signal_drag_data_get().connect( + sigc::mem_fun(*this, &MainWindow::on_scripts_treeview_drag_data_get) + ); + // establish drag&drop between samples tree view and dimension region 'Sample' text entry std::vector drag_target_gig_sample; drag_target_gig_sample.push_back(Gtk::TargetEntry("gig::Sample")); @@ -1478,6 +1495,22 @@ } } +void MainWindow::show_script_slots() { + if (!file) return; + // get selected instrument + Glib::RefPtr sel = m_TreeView.get_selection(); + Gtk::TreeModel::iterator it = sel->get_selected(); + if (!it) return; + Gtk::TreeModel::Row row = *it; + gig::Instrument* instrument = row[m_Columns.m_col_instr]; + if (!instrument) return; + + ScriptSlots* window = new ScriptSlots; + window->setInstrument(instrument); + //window->reparent(*this); + window->show(); +} + void MainWindow::on_action_view_status_bar() { Gtk::CheckMenuItem* item = dynamic_cast(uiManager->get_widget("/MenuBar/MenuView/Statusbar")); @@ -2228,6 +2261,32 @@ } } +// see comment on on_sample_treeview_drag_begin() +void MainWindow::on_scripts_treeview_drag_begin(const Glib::RefPtr& context) +{ + first_call_to_drag_data_get = true; +} + +void MainWindow::on_scripts_treeview_drag_data_get(const Glib::RefPtr&, + Gtk::SelectionData& selection_data, guint, guint) +{ + if (!first_call_to_drag_data_get) return; + first_call_to_drag_data_get = false; + + // get selected script + gig::Script* script = NULL; + Glib::RefPtr sel = m_TreeViewScripts.get_selection(); + Gtk::TreeModel::iterator it = sel->get_selected(); + if (it) { + Gtk::TreeModel::Row row = *it; + script = row[m_ScriptsModel.m_col_script]; + } + // pass the gig::Script as pointer + selection_data.set(selection_data.get_target(), 0/*unused*/, + (const guchar*)&script, + sizeof(script)/*length of data in bytes*/); +} + // For some reason drag_data_get gets called two times for each // drag'n'drop (at least when target is an Entry). This work-around // makes sure the code in drag_data_get and drop_drag_data_received is