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

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

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

revision 1095 by schoenebeck, Sun Mar 11 17:47:21 2007 UTC revision 1096 by schoenebeck, Tue Mar 13 17:14:38 2007 UTC
# Line 28  Line 28 
28  #define ABOUT_DIALOG  #define ABOUT_DIALOG
29  #include <gtkmm/aboutdialog.h>  #include <gtkmm/aboutdialog.h>
30  #include <gtkmm/messagedialog.h>  #include <gtkmm/messagedialog.h>
31    #include <gtkmm/targetentry.h>
32  #endif  #endif
33    
34  #include <stdio.h>  #include <stdio.h>
# Line 550  MainWindow::MainWindow() : Line 551  MainWindow::MainWindow() :
551      firstRowInBlock = 0;      firstRowInBlock = 0;
552    
553      addString("Sample", lSample, wSample);      addString("Sample", lSample, wSample);
554        //TODO: the following would break drag&drop:   wSample->property_editable().set_value(false);  or this:    wSample->set_editable(false);
555      addHeader("EG1");      addHeader("EG1");
556      addProp(eEG1PreAttack);      addProp(eEG1PreAttack);
557      addProp(eEG1Attack);      addProp(eEG1Attack);
# Line 928  MainWindow::MainWindow() : Line 930  MainWindow::MainWindow() :
930      m_TreeView.set_headers_visible(false);      m_TreeView.set_headers_visible(false);
931    
932      // create samples treeview (including its data model)      // create samples treeview (including its data model)
933      m_refSamplesTreeModel = Gtk::TreeStore::create(m_SamplesModel);      m_refSamplesTreeModel = SamplesTreeStore::create(m_SamplesModel);
934      m_TreeViewSamples.set_model(m_refSamplesTreeModel);      m_TreeViewSamples.set_model(m_refSamplesTreeModel);
935      m_TreeViewSamples.append_column("Samples", m_SamplesModel.m_col_name);      m_TreeViewSamples.append_column("Samples", m_SamplesModel.m_col_name);
936      m_TreeViewSamples.set_headers_visible(false);      m_TreeViewSamples.set_headers_visible(false);
# Line 936  MainWindow::MainWindow() : Line 938  MainWindow::MainWindow() :
938          sigc::mem_fun(*this, &MainWindow::on_sample_treeview_button_release)          sigc::mem_fun(*this, &MainWindow::on_sample_treeview_button_release)
939      );      );
940    
941        // establish drag&drop between samples tree view and dimension region 'Sample' text entry
942        std::list<Gtk::TargetEntry> drag_target_gig_sample;
943        drag_target_gig_sample.push_back( Gtk::TargetEntry("gig::Sample") );
944    //drag_target_gig_sample.push_back( Gtk::TargetEntry("STRING") );
945    //drag_target_gig_sample.push_back( Gtk::TargetEntry("text/plain") );
946        m_TreeViewSamples.drag_source_set(drag_target_gig_sample);
947        m_TreeViewSamples.signal_drag_data_get().connect(
948            sigc::mem_fun(*this, &MainWindow::on_sample_treeview_drag_data_get)
949        );
950        wSample->drag_dest_set(drag_target_gig_sample);
951        wSample->signal_drag_data_received().connect(
952            sigc::mem_fun(*this, &MainWindow::on_sample_label_drop_drag_data_received)
953        );
954    
955      file = 0;      file = 0;
956    
957      show_all_children();      show_all_children();
# Line 1907  void MainWindow::on_action_remove_sample Line 1923  void MainWindow::on_action_remove_sample
1923          }          }
1924      }      }
1925  }  }
1926    
1927    void MainWindow::on_sample_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&, Gtk::SelectionData& selection_data, guint, guint)
1928    {
1929        // get selected sample
1930        gig::Sample* sample = NULL;
1931        Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection();
1932        Gtk::TreeModel::iterator it = sel->get_selected();
1933        if (it) {
1934            Gtk::TreeModel::Row row = *it;
1935            sample = row[m_SamplesModel.m_col_sample];
1936        }
1937        // pass the gig::Sample as pointer
1938        selection_data.set(selection_data.get_target(), 0/*unused*/, (const guchar*)&sample, sizeof(sample)/*length of data in bytes*/);
1939    }
1940    
1941    void MainWindow::on_sample_label_drop_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const Gtk::SelectionData& selection_data, guint, guint time)
1942    {
1943        gig::DimensionRegion* dimregion = m_DimRegionChooser.get_dimregion();
1944        gig::Sample* sample = *((gig::Sample**) selection_data.get_data());
1945    
1946        if (sample && dimregion && selection_data.get_length() == sizeof(gig::Sample*)) {
1947            if (sample != dimregion->pSample) {
1948                dimregion->pSample = sample;
1949                wSample->set_text(dimregion->pSample->pInfo->Name.c_str());
1950                std::cout << "Drop received sample \"" << dimregion->pSample->pInfo->Name.c_str() << "\"" << std::endl;
1951                // drop success
1952                context->drop_reply(true, time);
1953                return;
1954            }
1955        }
1956        // drop failed
1957        context->drop_reply(false, time);
1958    }

Legend:
Removed from v.1095  
changed lines
  Added in v.1096

  ViewVC Help
Powered by ViewVC