2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD 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 Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = gtk-GtkTreeView-drag-and-drop.html
27 * outFile = TreeDragSource
28 * strct = GtkTreeDragSource
31 * clss = TreeDragSource
48 * - GtkTreeModel* -> TreeModel
49 * - GtkTreePath* -> TreePath
54 module gtk
.TreeDragSource
;
60 import tango
.io
.Stdout
; // use the tango loging?
64 private import gtkc
.gtktypes
;
66 private import gtkc
.gtk
;
69 private import gtk
.TreePath
;
70 private import gtk
.TreeModel
;
77 * GTK+ supports Drag-and-Drop in tree views with a high-level and a low-level
79 * The low-level API consists of the GTK+ DND API, augmented by some treeview
80 * utility functions: gtk_tree_view_set_drag_dest_row(),
81 * gtk_tree_view_get_drag_dest_row(), gtk_tree_view_get_dest_row_at_pos(),
82 * gtk_tree_view_create_row_drag_icon(), gtk_tree_set_row_drag_data() and
83 * gtk_tree_get_row_drag_data(). This API leaves a lot of flexibility, but
84 * nothing is done automatically, and implementing advanced features like
85 * hover-to-open-rows or autoscrolling on top of this API is a lot of work.
86 * On the other hand, if you write to the high-level API, then all the
87 * bookkeeping of rows is done for you, as well as things like hover-to-open
88 * and auto-scroll, but your models have to implement the
89 * GtkTreeDragSource and GtkTreeDragDest interfaces.
91 public class TreeDragSource
94 /** the main Gtk struct */
95 protected GtkTreeDragSource
* gtkTreeDragSource
;
98 public GtkTreeDragSource
* getTreeDragSourceStruct()
100 return gtkTreeDragSource
;
104 /** the main Gtk struct as a void* */
105 protected void* getStruct()
107 return cast(void*)gtkTreeDragSource
;
111 * Sets our main struct and passes it to the parent class
113 public this (GtkTreeDragSource
* gtkTreeDragSource
)
117 if ( gtkTreeDragSource
is null )
122 Stdout("struct gtkTreeDragSource is null on constructor").newline
;
126 printf("struct gtkTreeDragSource is null on constructor");
133 assert(gtkTreeDragSource
!is null, "struct gtkTreeDragSource is null on constructor");
135 this.gtkTreeDragSource
= gtkTreeDragSource
;
144 * Asks the GtkTreeDragSource to delete the row at path, because
145 * it was moved somewhere else via drag-and-drop. Returns FALSE
146 * if the deletion fails because path no longer exists, or for
147 * some model-specific reason. Should robustly handle a path no
148 * longer found in the model!
150 * a GtkTreeDragSource
152 * row that was being dragged
154 * TRUE if the row was successfully deleted
156 public int sourceDragDataDelete(TreePath path
)
158 // gboolean gtk_tree_drag_source_drag_data_delete (GtkTreeDragSource *drag_source, GtkTreePath *path);
159 return gtk_tree_drag_source_drag_data_delete(gtkTreeDragSource
, (path
is null) ?
null : path
.getTreePathStruct());
163 * Asks the GtkTreeDragSource to fill in selection_data with a
164 * representation of the row at path. selection_data->target gives
165 * the required type of the data. Should robustly handle a path no
166 * longer found in the model!
168 * a GtkTreeDragSource
170 * row that was dragged
172 * a GtkSelectionData to fill with data from the dragged row
174 * TRUE if data of the required type was provided
176 public int sourceDragDataGet(TreePath path
, GtkSelectionData
* selectionData
)
178 // gboolean gtk_tree_drag_source_drag_data_get (GtkTreeDragSource *drag_source, GtkTreePath *path, GtkSelectionData *selection_data);
179 return gtk_tree_drag_source_drag_data_get(gtkTreeDragSource
, (path
is null) ?
null : path
.getTreePathStruct(), selectionData
);
183 * Asks the GtkTreeDragSource whether a particular row can be used as
184 * the source of a DND operation. If the source doesn't implement
185 * this interface, the row is assumed draggable.
187 * a GtkTreeDragSource
189 * row on which user is initiating a drag
191 * TRUE if the row can be dragged
193 public int sourceRowDraggable(TreePath path
)
195 // gboolean gtk_tree_drag_source_row_draggable (GtkTreeDragSource *drag_source, GtkTreePath *path);
196 return gtk_tree_drag_source_row_draggable(gtkTreeDragSource
, (path
is null) ?
null : path
.getTreePathStruct());
202 * Asks the GtkTreeDragDest to insert a row before the path dest,
203 * deriving the contents of the row from selection_data. If dest is
204 * outside the tree so that inserting before it is impossible, FALSE
205 * will be returned. Also, FALSE may be returned if the new row is
206 * not created for some model-specific reason. Should robustly handle
207 * a dest no longer found in the model!
211 * row to drop in front of
215 * whether a new row was created before position dest
217 public static int destDragDataReceived(GtkTreeDragDest
* dragDest
, TreePath dest
, GtkSelectionData
* selectionData
)
219 // gboolean gtk_tree_drag_dest_drag_data_received (GtkTreeDragDest *drag_dest, GtkTreePath *dest, GtkSelectionData *selection_data);
220 return gtk_tree_drag_dest_drag_data_received(dragDest
, (dest
is null) ?
null : dest
.getTreePathStruct(), selectionData
);
224 * Determines whether a drop is possible before the given dest_path,
225 * at the same depth as dest_path. i.e., can we drop the data in
226 * selection_data at that location. dest_path does not have to
227 * exist; the return value will almost certainly be FALSE if the
228 * parent of dest_path doesn't exist, though.
234 * the data being dragged
236 * TRUE if a drop is possible before dest_path
238 public static int destRowDropPossible(GtkTreeDragDest
* dragDest
, TreePath destPath
, GtkSelectionData
* selectionData
)
240 // gboolean gtk_tree_drag_dest_row_drop_possible (GtkTreeDragDest *drag_dest, GtkTreePath *dest_path, GtkSelectionData *selection_data);
241 return gtk_tree_drag_dest_row_drop_possible(dragDest
, (destPath
is null) ?
null : destPath
.getTreePathStruct(), selectionData
);
245 * Sets selection data of target type GTK_TREE_MODEL_ROW. Normally used
246 * in a drag_data_get handler.
248 * some GtkSelectionData
252 * a row in tree_model
254 * TRUE if the GtkSelectionData had the proper target type to allow us to set a tree row
256 public static int treeSetRowDragData(GtkSelectionData
* selectionData
, TreeModel treeModel
, TreePath path
)
258 // gboolean gtk_tree_set_row_drag_data (GtkSelectionData *selection_data, GtkTreeModel *tree_model, GtkTreePath *path);
259 return gtk_tree_set_row_drag_data(selectionData
, (treeModel
is null) ?
null : treeModel
.getTreeModelStruct(), (path
is null) ?
null : path
.getTreePathStruct());
263 * Obtains a tree_model and path from selection data of target type
264 * GTK_TREE_MODEL_ROW. Normally called from a drag_data_received handler.
265 * This function can only be used if selection_data originates from the same
266 * process that's calling this function, because a pointer to the tree model
267 * is being passed around. If you aren't in the same process, then you'll
268 * get memory corruption. In the GtkTreeDragDest drag_data_received handler,
269 * you can assume that selection data of type GTK_TREE_MODEL_ROW is
270 * in from the current process. The returned path must be freed with
271 * gtk_tree_path_free().
279 * TRUE if selection_data had target type GTK_TREE_MODEL_ROW and
282 public static int treeGetRowDragData(GtkSelectionData
* selectionData
, GtkTreeModel
** treeModel
, GtkTreePath
** path
)
284 // gboolean gtk_tree_get_row_drag_data (GtkSelectionData *selection_data, GtkTreeModel **tree_model, GtkTreePath **path);
285 return gtk_tree_get_row_drag_data(selectionData
, treeModel
, path
);