1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = gtk-GtkTreeView-drag-and-drop.html
27  * outPack = gtk
28  * outFile = TreeDragSourceT
29  * strct   = GtkTreeDragSource
30  * realStrct=
31  * ctorStrct=
32  * clss    = TreeDragSourceT
33  * interf  = TreeDragSourceIF
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * 	- TStruct
38  * extend  = 
39  * implements:
40  * prefixes:
41  * 	- gtk_tree_drag_source_
42  * 	- gtk_tree_
43  * omit structs:
44  * omit prefixes:
45  * 	- gtk_tree_drag_dest_
46  * omit code:
47  * omit signals:
48  * imports:
49  * 	- gtk.TreePath
50  * 	- gtk.TreeModelIF
51  * 	- gtk.TreeModel
52  * structWrap:
53  * 	- GtkTreeModel* -> TreeModelIF
54  * 	- GtkTreePath* -> TreePath
55  * module aliases:
56  * local aliases:
57  * overrides:
58  */
59 
60 module gtk.TreeDragSourceT;
61 
62 public  import gtkc.gtktypes;
63 
64 public import gtkc.gtk;
65 public import glib.ConstructionException;
66 public import gobject.ObjectG;
67 
68 
69 public import gtk.TreePath;
70 public import gtk.TreeModelIF;
71 public import gtk.TreeModel;
72 
73 
74 
75 
76 /**
77  * Description
78  * GTK+ supports Drag-and-Drop in tree views with a high-level and a low-level
79  * API.
80  * The low-level API consists of the GTK+ DND API, augmented by some treeview
81  * utility functions: gtk_tree_view_set_drag_dest_row(),
82  * gtk_tree_view_get_drag_dest_row(), gtk_tree_view_get_dest_row_at_pos(),
83  * gtk_tree_view_create_row_drag_icon(), gtk_tree_set_row_drag_data() and
84  * gtk_tree_get_row_drag_data(). This API leaves a lot of flexibility, but
85  * nothing is done automatically, and implementing advanced features like
86  * hover-to-open-rows or autoscrolling on top of this API is a lot of work.
87  * On the other hand, if you write to the high-level API, then all the
88  * bookkeeping of rows is done for you, as well as things like hover-to-open
89  * and auto-scroll, but your models have to implement the
90  * GtkTreeDragSource and GtkTreeDragDest interfaces.
91  */
92 public template TreeDragSourceT(TStruct)
93 {
94 	
95 	/** the main Gtk struct */
96 	protected GtkTreeDragSource* gtkTreeDragSource;
97 	
98 	
99 	public GtkTreeDragSource* getTreeDragSourceTStruct()
100 	{
101 		return cast(GtkTreeDragSource*)getStruct();
102 	}
103 	
104 	
105 	/**
106 	 */
107 	
108 	/**
109 	 * Asks the GtkTreeDragSource to delete the row at path, because
110 	 * it was moved somewhere else via drag-and-drop. Returns FALSE
111 	 * if the deletion fails because path no longer exists, or for
112 	 * some model-specific reason. Should robustly handle a path no
113 	 * longer found in the model!
114 	 * Params:
115 	 * path = row that was being dragged
116 	 * Returns: TRUE if the row was successfully deleted
117 	 */
118 	public int dragDataDelete(TreePath path)
119 	{
120 		// gboolean gtk_tree_drag_source_drag_data_delete  (GtkTreeDragSource *drag_source,  GtkTreePath *path);
121 		return gtk_tree_drag_source_drag_data_delete(getTreeDragSourceTStruct(), (path is null) ? null : path.getTreePathStruct());
122 	}
123 	
124 	/**
125 	 * Asks the GtkTreeDragSource to fill in selection_data with a
126 	 * representation of the row at path. selection_data->target gives
127 	 * the required type of the data. Should robustly handle a path no
128 	 * longer found in the model!
129 	 * Params:
130 	 * path = row that was dragged
131 	 * selectionData = a GtkSelectionData to fill with data
132 	 * from the dragged row. [out]
133 	 * Returns: TRUE if data of the required type was provided
134 	 */
135 	public int dragDataGet(TreePath path, GtkSelectionData* selectionData)
136 	{
137 		// gboolean gtk_tree_drag_source_drag_data_get (GtkTreeDragSource *drag_source,  GtkTreePath *path,  GtkSelectionData *selection_data);
138 		return gtk_tree_drag_source_drag_data_get(getTreeDragSourceTStruct(), (path is null) ? null : path.getTreePathStruct(), selectionData);
139 	}
140 	
141 	/**
142 	 * Asks the GtkTreeDragSource whether a particular row can be used as
143 	 * the source of a DND operation. If the source doesn't implement
144 	 * this interface, the row is assumed draggable.
145 	 * Params:
146 	 * path = row on which user is initiating a drag
147 	 * Returns: TRUE if the row can be dragged
148 	 */
149 	public int rowDraggable(TreePath path)
150 	{
151 		// gboolean gtk_tree_drag_source_row_draggable (GtkTreeDragSource *drag_source,  GtkTreePath *path);
152 		return gtk_tree_drag_source_row_draggable(getTreeDragSourceTStruct(), (path is null) ? null : path.getTreePathStruct());
153 	}
154 	
155 	/**
156 	 * Sets selection data of target type GTK_TREE_MODEL_ROW. Normally used
157 	 * in a drag_data_get handler.
158 	 * Params:
159 	 * selectionData = some GtkSelectionData
160 	 * treeModel = a GtkTreeModel
161 	 * path = a row in tree_model
162 	 * Returns: TRUE if the GtkSelectionData had the proper target type to allow us to set a tree row
163 	 */
164 	public static int setRowDragData(GtkSelectionData* selectionData, TreeModelIF treeModel, TreePath path)
165 	{
166 		// gboolean gtk_tree_set_row_drag_data (GtkSelectionData *selection_data,  GtkTreeModel *tree_model,  GtkTreePath *path);
167 		return gtk_tree_set_row_drag_data(selectionData, (treeModel is null) ? null : treeModel.getTreeModelTStruct(), (path is null) ? null : path.getTreePathStruct());
168 	}
169 	
170 	/**
171 	 * Obtains a tree_model and path from selection data of target type
172 	 * GTK_TREE_MODEL_ROW. Normally called from a drag_data_received handler.
173 	 * This function can only be used if selection_data originates from the same
174 	 * process that's calling this function, because a pointer to the tree model
175 	 * is being passed around. If you aren't in the same process, then you'll
176 	 * get memory corruption. In the GtkTreeDragDest drag_data_received handler,
177 	 * you can assume that selection data of type GTK_TREE_MODEL_ROW is
178 	 * in from the current process. The returned path must be freed with
179 	 * gtk_tree_path_free().
180 	 * Params:
181 	 * selectionData = a GtkSelectionData
182 	 * treeModel = a GtkTreeModel. [out]
183 	 * path = row in tree_model. [out]
184 	 * Returns: TRUE if selection_data had target type GTK_TREE_MODEL_ROW and is otherwise valid
185 	 */
186 	public static int getRowDragData(GtkSelectionData* selectionData, out TreeModelIF treeModel, out TreePath path)
187 	{
188 		// gboolean gtk_tree_get_row_drag_data (GtkSelectionData *selection_data,  GtkTreeModel **tree_model,  GtkTreePath **path);
189 		GtkTreeModel* outtreeModel = null;
190 		GtkTreePath* outpath = null;
191 		
192 		auto p = gtk_tree_get_row_drag_data(selectionData, &outtreeModel, &outpath);
193 		
194 		treeModel = ObjectG.getDObject!(TreeModel, TreeModelIF)(outtreeModel);
195 		path = ObjectG.getDObject!(TreePath)(outpath);
196 		return p;
197 	}
198 }