ardour
dndtreeview.cc
Go to the documentation of this file.
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::DragData DnDTreeViewBase::drag_data;
33 
34 DnDTreeViewBase::DnDTreeViewBase ()
35  : TreeView ()
36 {
37  draggable.push_back (TargetEntry ("GTK_TREE_MODEL_ROW", TARGET_SAME_WIDGET));
38  data_column = -1;
39 
40  enable_model_drag_source (draggable);
41  enable_model_drag_dest (draggable);
42 
43  suggested_action = Gdk::DragAction (0);
44 }
45 
46 void
47 DnDTreeViewBase::add_drop_targets (list<TargetEntry>& targets)
48 {
49  for (list<TargetEntry>::iterator i = targets.begin(); i != targets.end(); ++i) {
50  draggable.push_back (*i);
51  }
52 
53  enable_model_drag_source (draggable);
54  enable_model_drag_dest (draggable);
55 }
56 
57 void
58 DnDTreeViewBase::add_object_drag (int column, string type_name)
59 {
60  draggable.push_back (TargetEntry (type_name, TargetFlags(0)));
61  data_column = column;
62  object_type = type_name;
63 
64  enable_model_drag_source (draggable);
65  enable_model_drag_dest (draggable);
66 }
67 
68 bool
69 DnDTreeViewBase::on_drag_drop(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint time)
70 {
71  suggested_action = Gdk::DragAction (0);
72  drag_data.source = 0;
73  return TreeView::on_drag_drop (context, x, y, time);
74 }
75 
76 
Definition: ardour_ui.h:130
std::list< Gtk::TargetEntry > draggable
Definition: dndtreeview.h:69
void add_drop_targets(std::list< Gtk::TargetEntry > &)
Definition: dndtreeview.cc:47
Definition: Beats.hpp:239
void add_object_drag(int column, std::string type_name)
Definition: dndtreeview.cc:58
bool on_drag_drop(const Glib::RefPtr< Gdk::DragContext > &context, int x, int y, guint time)
Definition: dndtreeview.cc:69
Gdk::DragAction suggested_action
Definition: dndtreeview.h:70
static DragData drag_data
Definition: dndtreeview.h:82