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  = gtk3-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.SelectionData
50  * 	- gtk.TreeModelIF
51  * 	- gtk.TreeModel
52  * 	- gtk.TreePath
53  * structWrap:
54  * 	- GtkSelectionData* -> SelectionData
55  * 	- GtkTreeModel* -> TreeModelIF
56  * 	- GtkTreePath* -> TreePath
57  * module aliases:
58  * local aliases:
59  * overrides:
60  */
61 
62 module gtk.TreeDragSourceT;
63 
64 public  import gtkc.gtktypes;
65 
66 public import gtkc.gtk;
67 public import glib.ConstructionException;
68 public import gobject.ObjectG;
69 
70 
71 public import gtk.SelectionData;
72 public import gtk.TreeModelIF;
73 public import gtk.TreeModel;
74 public import gtk.TreePath;
75 
76 
77 
78 
79 /**
80  * GTK+ supports Drag-and-Drop in tree views with a high-level and a low-level
81  * API.
82  *
83  * The low-level API consists of the GTK+ DND API, augmented by some treeview
84  * utility functions: gtk_tree_view_set_drag_dest_row(),
85  * gtk_tree_view_get_drag_dest_row(), gtk_tree_view_get_dest_row_at_pos(),
86  * gtk_tree_view_create_row_drag_icon(), gtk_tree_set_row_drag_data() and
87  * gtk_tree_get_row_drag_data(). This API leaves a lot of flexibility, but
88  * nothing is done automatically, and implementing advanced features like
89  * hover-to-open-rows or autoscrolling on top of this API is a lot of work.
90  *
91  * On the other hand, if you write to the high-level API, then all the
92  * bookkeeping of rows is done for you, as well as things like hover-to-open
93  * and auto-scroll, but your models have to implement the
94  * GtkTreeDragSource and GtkTreeDragDest interfaces.
95  */
96 public template TreeDragSourceT(TStruct)
97 {
98 	
99 	/** the main Gtk struct */
100 	protected GtkTreeDragSource* gtkTreeDragSource;
101 	
102 	
103 	public GtkTreeDragSource* getTreeDragSourceTStruct()
104 	{
105 		return cast(GtkTreeDragSource*)getStruct();
106 	}
107 	
108 	
109 	/**
110 	 */
111 	
112 	/**
113 	 * Asks the GtkTreeDragSource to delete the row at path, because
114 	 * it was moved somewhere else via drag-and-drop. Returns FALSE
115 	 * if the deletion fails because path no longer exists, or for
116 	 * some model-specific reason. Should robustly handle a path no
117 	 * longer found in the model!
118 	 * Params:
119 	 * path = row that was being dragged
120 	 * Returns: TRUE if the row was successfully deleted
121 	 */
122 	public int dragDataDelete(TreePath path)
123 	{
124 		// gboolean gtk_tree_drag_source_drag_data_delete  (GtkTreeDragSource *drag_source,  GtkTreePath *path);
125 		return gtk_tree_drag_source_drag_data_delete(getTreeDragSourceTStruct(), (path is null) ? null : path.getTreePathStruct());
126 	}
127 	
128 	/**
129 	 * Asks the GtkTreeDragSource to fill in selection_data with a
130 	 * representation of the row at path. selection_data->target gives
131 	 * the required type of the data. Should robustly handle a path no
132 	 * longer found in the model!
133 	 * Params:
134 	 * path = row that was dragged
135 	 * selectionData = a GtkSelectionData to fill with data
136 	 * from the dragged row
137 	 * Returns: TRUE if data of the required type was provided
138 	 */
139 	public int dragDataGet(TreePath path, SelectionData selectionData)
140 	{
141 		// gboolean gtk_tree_drag_source_drag_data_get (GtkTreeDragSource *drag_source,  GtkTreePath *path,  GtkSelectionData *selection_data);
142 		return gtk_tree_drag_source_drag_data_get(getTreeDragSourceTStruct(), (path is null) ? null : path.getTreePathStruct(), (selectionData is null) ? null : selectionData.getSelectionDataStruct());
143 	}
144 	
145 	/**
146 	 * Asks the GtkTreeDragSource whether a particular row can be used as
147 	 * the source of a DND operation. If the source doesn't implement
148 	 * this interface, the row is assumed draggable.
149 	 * Params:
150 	 * path = row on which user is initiating a drag
151 	 * Returns: TRUE if the row can be dragged
152 	 */
153 	public int rowDraggable(TreePath path)
154 	{
155 		// gboolean gtk_tree_drag_source_row_draggable (GtkTreeDragSource *drag_source,  GtkTreePath *path);
156 		return gtk_tree_drag_source_row_draggable(getTreeDragSourceTStruct(), (path is null) ? null : path.getTreePathStruct());
157 	}
158 	
159 	/**
160 	 * Sets selection data of target type GTK_TREE_MODEL_ROW. Normally used
161 	 * in a drag_data_get handler.
162 	 * Params:
163 	 * selectionData = some GtkSelectionData
164 	 * treeModel = a GtkTreeModel
165 	 * path = a row in tree_model
166 	 * Returns: TRUE if the GtkSelectionData had the proper target type to allow us to set a tree row
167 	 */
168 	public static int setRowDragData(SelectionData selectionData, TreeModelIF treeModel, TreePath path)
169 	{
170 		// gboolean gtk_tree_set_row_drag_data (GtkSelectionData *selection_data,  GtkTreeModel *tree_model,  GtkTreePath *path);
171 		return gtk_tree_set_row_drag_data((selectionData is null) ? null : selectionData.getSelectionDataStruct(), (treeModel is null) ? null : treeModel.getTreeModelTStruct(), (path is null) ? null : path.getTreePathStruct());
172 	}
173 	
174 	/**
175 	 * Obtains a tree_model and path from selection data of target type
176 	 * GTK_TREE_MODEL_ROW. Normally called from a drag_data_received handler.
177 	 * This function can only be used if selection_data originates from the same
178 	 * process that's calling this function, because a pointer to the tree model
179 	 * is being passed around. If you aren't in the same process, then you'll
180 	 * get memory corruption. In the GtkTreeDragDest drag_data_received handler,
181 	 * you can assume that selection data of type GTK_TREE_MODEL_ROW is
182 	 * in from the current process. The returned path must be freed with
183 	 * gtk_tree_path_free().
184 	 * Params:
185 	 * selectionData = a GtkSelectionData
186 	 * treeModel = a GtkTreeModel. [out]
187 	 * path = row in tree_model. [out]
188 	 * Returns: TRUE if selection_data had target type GTK_TREE_MODEL_ROW and is otherwise valid
189 	 */
190 	public static int getRowDragData(SelectionData selectionData, out TreeModelIF treeModel, out TreePath path)
191 	{
192 		// gboolean gtk_tree_get_row_drag_data (GtkSelectionData *selection_data,  GtkTreeModel **tree_model,  GtkTreePath **path);
193 		GtkTreeModel* outtreeModel = null;
194 		GtkTreePath* outpath = null;
195 		
196 		auto p = gtk_tree_get_row_drag_data((selectionData is null) ? null : selectionData.getSelectionDataStruct(), &outtreeModel, &outpath);
197 		
198 		treeModel = ObjectG.getDObject!(TreeModel)(outtreeModel);
199 		path = ObjectG.getDObject!(TreePath)(outpath);
200 		return p;
201 	}
202 }