globally remove all trailing whitespace from ardour code base.
[ardour.git] / libs / gtkmm2ext / gtkmm2ext / dndtreeview.h
index 085e500f219f8600d2cb45e4d1315dc52ce4c676..dd58f77a4c6760a5e9e26c33d37cff111ae0fe62 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2000-2007 Paul Davis 
+    Copyright (C) 2000-2007 Paul Davis
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
 #include <gtkmm/treeselection.h>
 #include <gtkmm/selectiondata.h>
 
+#include "gtkmm2ext/visibility.h"
+
 namespace Gtkmm2ext {
 
 template<class DataType>
-struct SerializedObjectPointers {
+struct /*LIBGTKMM2EXT_API*/ SerializedObjectPointers {
     uint32_t size;
     uint32_t cnt;
     char     type[32];
     DataType data[0];
 };
 
-class DnDTreeViewBase : public Gtk::TreeView 
+class LIBGTKMM2EXT_API DnDTreeViewBase : public Gtk::TreeView
 {
   private:
   public:
@@ -45,6 +47,11 @@ class DnDTreeViewBase : public Gtk::TreeView
 
        void add_drop_targets (std::list<Gtk::TargetEntry>&);
        void add_object_drag (int column, std::string type_name);
+
+       void on_drag_begin (Glib::RefPtr<Gdk::DragContext> const & context) {
+               Gtk::TreeView::on_drag_begin (context);
+               start_object_drag ();
+       }
        
        void on_drag_leave(const Glib::RefPtr<Gdk::DragContext>& context, guint time) {
                suggested_action = context->get_suggested_action();
@@ -65,6 +72,8 @@ class DnDTreeViewBase : public Gtk::TreeView
        std::string                 object_type;
 
        struct DragData {
+           DragData () : source (0) {}
+               
            Gtk::TreeView* source;
            int            data_column;
            std::string    object_type;
@@ -80,13 +89,13 @@ class DnDTreeViewBase : public Gtk::TreeView
 };
 
 template<class DataType>
-class DnDTreeView : public DnDTreeViewBase
+class /*LIBGTKMM2EXT_API*/ DnDTreeView : public DnDTreeViewBase
 {
   public:
-       DnDTreeView() {} 
+       DnDTreeView() {}
        ~DnDTreeView() {}
 
-       sigc::signal<void,const std::list<DataType>& > signal_drop;
+       sigc::signal<void,const std::list<DataType>&,Gtk::TreeView*,int,int,Glib::RefPtr<Gdk::DragContext>&> signal_drop;
 
        void on_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, Gtk::SelectionData& selection_data, guint info, guint time) {
                if (selection_data.get_target() == "GTK_TREE_MODEL_ROW") {
@@ -95,8 +104,6 @@ class DnDTreeView : public DnDTreeViewBase
 
                } else if (selection_data.get_target() == object_type) {
 
-                       start_object_drag ();
-
                        /* we don't care about the data passed around by DnD, but
                           we have to provide something otherwise it will stop.
                         */
@@ -123,7 +130,7 @@ class DnDTreeView : public DnDTreeViewBase
 
                } else if (selection_data.get_target() == object_type) {
                        
-                       end_object_drag ();
+                       end_object_drag (const_cast<Glib::RefPtr<Gdk::DragContext>& > (context), x, y);
 
                } else {
                        /* some kind of target type added by the app, which will be handled by a signal handler */
@@ -131,11 +138,16 @@ class DnDTreeView : public DnDTreeViewBase
        }
 
        /**
-        * this can be called by the Treeview itself or by some other
+        * This can be called by the Treeview itself or by some other
         * object that wants to get the list of dragged items.
         */
 
-       void get_object_drag_data (std::list<DataType>& l) {
+       void get_object_drag_data (std::list<DataType>& l, Gtk::TreeView** source) {
+
+               if (drag_data.source == 0) {
+                       return;
+               }
+                       
                Glib::RefPtr<Gtk::TreeModel> model = drag_data.source->get_model();
                DataType v;
                Gtk::TreeSelection::ListHandle_Path selection = drag_data.source->get_selection()->get_selected_rows ();
@@ -144,17 +156,20 @@ class DnDTreeView : public DnDTreeViewBase
                        model->get_iter (*x)->get_value (drag_data.data_column, v);
                        l.push_back (v);
                }
+               
+               *source = drag_data.source;
        }
 
   private:
-       void end_object_drag () {
+       void end_object_drag (Glib::RefPtr<Gdk::DragContext>& context, int x, int y) {
                std::list<DataType> l;
-               get_object_drag_data (l);
-               signal_drop (l);
+               Gtk::TreeView* source;
+               get_object_drag_data (l, &source);
+               signal_drop (l, source, x, y, context);
        }
 
 };
 
 } // namespace
+
 #endif /* __gtkmm2ext_dndtreeview_h__ */