/[svn]/gigedit/trunk/src/gigedit/mainwindow.cpp
ViewVC logotype

Diff of /gigedit/trunk/src/gigedit/mainwindow.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2604 by schoenebeck, Sat Jun 7 22:34:31 2014 UTC revision 2615 by schoenebeck, Tue Jun 10 19:14:01 2014 UTC
# Line 46  Line 46 
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    
# Line 134  MainWindow::MainWindow() : Line 135  MainWindow::MainWindow() :
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));
# Line 296  MainWindow::MainWindow() : Line 301  MainWindow::MainWindow() :
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/>"
# Line 424  MainWindow::MainWindow() : Line 430  MainWindow::MainWindow() :
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"));
# Line 680  void MainWindow::__clear() { Line 697  void MainWindow::__clear() {
697      // clear the samples and instruments tree views      // clear the samples and instruments tree views
698      m_refTreeModel->clear();      m_refTreeModel->clear();
699      m_refSamplesTreeModel->clear();      m_refSamplesTreeModel->clear();
700        m_refScriptsTreeModel->clear();
701      // remove all entries from "Instrument" menu      // remove all entries from "Instrument" menu
702      while (!instrument_menu->get_children().empty()) {      while (!instrument_menu->get_children().empty()) {
703          remove_instrument_from_menu(0);          remove_instrument_from_menu(0);
# Line 694  void MainWindow::__refreshEntireGUI() { Line 712  void MainWindow::__refreshEntireGUI() {
712      // clear the samples and instruments tree views      // clear the samples and instruments tree views
713      m_refTreeModel->clear();      m_refTreeModel->clear();
714      m_refSamplesTreeModel->clear();      m_refSamplesTreeModel->clear();
715        m_refScriptsTreeModel->clear();
716      // remove all entries from "Instrument" menu      // remove all entries from "Instrument" menu
717      while (!instrument_menu->get_children().empty()) {      while (!instrument_menu->get_children().empty()) {
718          remove_instrument_from_menu(0);          remove_instrument_from_menu(0);
# Line 1478  void MainWindow::show_midi_rules() Line 1497  void MainWindow::show_midi_rules()
1497      }      }
1498  }  }
1499    
1500    void MainWindow::show_script_slots() {
1501        if (!file) return;
1502        // get selected instrument
1503        Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection();
1504        Gtk::TreeModel::iterator it = sel->get_selected();
1505        if (!it) return;
1506        Gtk::TreeModel::Row row = *it;
1507        gig::Instrument* instrument = row[m_Columns.m_col_instr];
1508        if (!instrument) return;
1509    
1510        ScriptSlots* window = new ScriptSlots;
1511        window->setInstrument(instrument);
1512        //window->reparent(*this);
1513        window->show();
1514    }
1515    
1516  void MainWindow::on_action_view_status_bar() {  void MainWindow::on_action_view_status_bar() {
1517      Gtk::CheckMenuItem* item =      Gtk::CheckMenuItem* item =
1518          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar"));          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar"));
# Line 2228  void MainWindow::on_action_remove_sample Line 2263  void MainWindow::on_action_remove_sample
2263      }      }
2264  }  }
2265    
2266    // see comment on on_sample_treeview_drag_begin()
2267    void MainWindow::on_scripts_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context)
2268    {
2269        first_call_to_drag_data_get = true;
2270    }
2271    
2272    void MainWindow::on_scripts_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,
2273                                                       Gtk::SelectionData& selection_data, guint, guint)
2274    {
2275        if (!first_call_to_drag_data_get) return;
2276        first_call_to_drag_data_get = false;
2277    
2278        // get selected script
2279        gig::Script* script = NULL;
2280        Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewScripts.get_selection();
2281        Gtk::TreeModel::iterator it = sel->get_selected();
2282        if (it) {
2283            Gtk::TreeModel::Row row = *it;
2284            script = row[m_ScriptsModel.m_col_script];
2285        }
2286        // pass the gig::Script as pointer
2287        selection_data.set(selection_data.get_target(), 0/*unused*/,
2288                           (const guchar*)&script,
2289                           sizeof(script)/*length of data in bytes*/);
2290    }
2291    
2292  // For some reason drag_data_get gets called two times for each  // For some reason drag_data_get gets called two times for each
2293  // 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
2294  // 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

Legend:
Removed from v.2604  
changed lines
  Added in v.2615

  ViewVC Help
Powered by ViewVC