added files
[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         void add_object_drag (int column, std::string type_name);
21         sigc::signal<void,std::string,uint32_t,void**> signal_object_drop;
22         
23         void on_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context) {
24                 TreeView::on_drag_begin (context);
25         }
26         void on_drag_end(const Glib::RefPtr<Gdk::DragContext>& context) {
27                 TreeView::on_drag_end (context);
28         }
29         void on_drag_data_delete(const Glib::RefPtr<Gdk::DragContext>& context) {
30                 TreeView::on_drag_data_delete (context);
31         }
32         void on_drag_leave(const Glib::RefPtr<Gdk::DragContext>& context, guint time) {
33             suggested_action = context->get_suggested_action();
34             TreeView::on_drag_leave (context, time);
35         }
36         bool on_drag_motion(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint time) {
37                 suggested_action = context->get_suggested_action();
38                 return TreeView::on_drag_motion (context, x, y, time);
39         }
40         bool on_drag_drop(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint time) {
41                 suggested_action = Gdk::DragAction (0);
42                 return TreeView::on_drag_drop (context, x, y, time);
43         }
44         
45         void on_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, Gtk::SelectionData& selection_data, guint info, guint time);
46         void on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& selection_data, guint info, guint time);
47
48   private:
49         std::list<Gtk::TargetEntry> draggable;
50         Gdk::DragAction             suggested_action;
51         int                         data_column;
52         
53         struct SerializedObjectPointers {
54             uint32_t size;
55             uint32_t cnt;
56             char     type[32];
57             void*    ptr[0];
58         };
59         
60         SerializedObjectPointers* serialize_pointers (Glib::RefPtr<Gtk::TreeModel> m, 
61                                                       Gtk::TreeSelection::ListHandle_Path*,
62                                                       Glib::ustring type);
63 };
64
65 } // namespace
66  
67 #endif /* __gtkmm2ext_dndtreeview_h__ */