Merged changes from trunk 1699:1751 into 2.1-staging
[ardour.git] / libs / gtkmm2ext / dndtreeview.cc
1 /*
2     Copyright (C) 2000-2007 Paul Davis 
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include <cstdio>
21 #include <iostream>
22
23 #include <gtkmm2ext/dndtreeview.h>
24
25 using namespace std;
26 using namespace sigc;
27 using namespace Gdk;
28 using namespace Gtk;
29 using namespace Glib;
30 using namespace Gtkmm2ext;
31
32 DnDTreeViewBase::DnDTreeViewBase ()
33         : TreeView ()
34 {
35         draggable.push_back (TargetEntry ("GTK_TREE_MODEL_ROW", TARGET_SAME_WIDGET));
36         data_column = -1;
37
38         enable_model_drag_source (draggable);
39         enable_model_drag_dest (draggable);
40
41         suggested_action = Gdk::DragAction (0);
42 }
43
44 void
45 DnDTreeViewBase::add_drop_targets (list<TargetEntry>& targets)
46 {
47         for (list<TargetEntry>::iterator i = targets.begin(); i != targets.end(); ++i) {
48                 draggable.push_back (*i);
49         }
50         enable_model_drag_source (draggable);
51         enable_model_drag_dest (draggable);
52 }       
53
54 void
55 DnDTreeViewBase::add_object_drag (int column, string type_name)
56 {
57         draggable.push_back (TargetEntry (type_name, TargetFlags(0)));
58         data_column = column;
59
60         enable_model_drag_source (draggable);
61         enable_model_drag_dest (draggable);
62 }
63
64 bool 
65 DnDTreeViewBase::on_drag_drop(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint time)
66 {
67         suggested_action = Gdk::DragAction (0);
68         return TreeView::on_drag_drop (context, x, y, time);
69 }
70
71