82bb7651b9de3122fda2bb958ff0871c86d26d9a
[ardour.git] / libs / gtkmm2ext / gtkmm2ext / dndtreeview.h
1 #ifndef __gtkmm2ext_dndtreeview_h__
2 #define __gtkmm2ext_dndtreeview_h__
3
4 #include <stdint.h>
5 #include <string>
6 #include <gtkmm/treeview.h>
7 #include <gtkmm/treeselection.h>
8 #include <gtkmm/selectiondata.h>
9
10 namespace Gtkmm2ext {
11
12 class DnDTreeView : public Gtk::TreeView 
13 {
14
15   private:
16   public:
17         DnDTreeView ();
18         ~DnDTreeView() {}
19
20         /* this is the structure pointed to if add_object_drag() is called
21            and a drop happens on a destination which has declared itself
22            willing to accept a target of the type named in the call
23            to add_object_drag().
24         */
25         
26         struct SerializedObjectPointers {
27             uint32_t size;
28             uint32_t cnt;
29             char     type[32];
30             void*    ptr[0];
31         };
32         
33         void add_drop_targets (std::list<Gtk::TargetEntry>&);
34         void add_object_drag (int column, std::string type_name);
35         sigc::signal<void,std::string,uint32_t,void**> signal_object_drop;
36         
37         void on_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context) {
38                 TreeView::on_drag_begin (context);
39         }
40         void on_drag_end(const Glib::RefPtr<Gdk::DragContext>& context) {
41                 TreeView::on_drag_end (context);
42         }
43         void on_drag_data_delete(const Glib::RefPtr<Gdk::DragContext>& context) {
44                 TreeView::on_drag_data_delete (context);
45         }
46         void on_drag_leave(const Glib::RefPtr<Gdk::DragContext>& context, guint time) {
47             suggested_action = context->get_suggested_action();
48             TreeView::on_drag_leave (context, time);
49         }
50         bool on_drag_motion(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint time) {
51                 suggested_action = context->get_suggested_action();
52                 return TreeView::on_drag_motion (context, x, y, time);
53         }
54         bool on_drag_drop(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint time);
55         void on_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, Gtk::SelectionData& selection_data, guint info, guint time);
56         void on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& selection_data, guint info, guint time);
57
58   private:
59         std::list<Gtk::TargetEntry> draggable;
60         Gdk::DragAction             suggested_action;
61         int                         data_column;
62         
63         SerializedObjectPointers* serialize_pointers (Glib::RefPtr<Gtk::TreeModel> m, 
64                                                       Gtk::TreeSelection::ListHandle_Path*,
65                                                       Glib::ustring type);
66 };
67
68 } // namespace
69  
70 #endif /* __gtkmm2ext_dndtreeview_h__ */