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 module gtk.TreeDragSourceT;
26 
27 public  import gobject.ObjectG;
28 public  import gtk.SelectionData;
29 public  import gtk.TreeModel;
30 public  import gtk.TreeModelIF;
31 public  import gtk.TreePath;
32 public  import gtkc.gtk;
33 public  import gtkc.gtktypes;
34 
35 
36 public template TreeDragSourceT(TStruct)
37 {
38 	/** Get the main Gtk struct */
39 	public GtkTreeDragSource* getTreeDragSourceStruct()
40 	{
41 		return cast(GtkTreeDragSource*)getStruct();
42 	}
43 
44 	/**
45 	 */
46 
47 	/**
48 	 * Asks the #GtkTreeDragSource to delete the row at @path, because
49 	 * it was moved somewhere else via drag-and-drop. Returns %FALSE
50 	 * if the deletion fails because @path no longer exists, or for
51 	 * some model-specific reason. Should robustly handle a @path no
52 	 * longer found in the model!
53 	 *
54 	 * Params:
55 	 *     path = row that was being dragged
56 	 *
57 	 * Return: %TRUE if the row was successfully deleted
58 	 */
59 	public bool dragDataDelete(TreePath path)
60 	{
61 		return gtk_tree_drag_source_drag_data_delete(getTreeDragSourceStruct(), (path is null) ? null : path.getTreePathStruct()) != 0;
62 	}
63 
64 	/**
65 	 * Asks the #GtkTreeDragSource to fill in @selection_data with a
66 	 * representation of the row at @path. @selection_data->target gives
67 	 * the required type of the data.  Should robustly handle a @path no
68 	 * longer found in the model!
69 	 *
70 	 * Params:
71 	 *     path = row that was dragged
72 	 *     selectionData = a #GtkSelectionData to fill with data
73 	 *         from the dragged row
74 	 *
75 	 * Return: %TRUE if data of the required type was provided
76 	 */
77 	public bool dragDataGet(TreePath path, SelectionData selectionData)
78 	{
79 		return gtk_tree_drag_source_drag_data_get(getTreeDragSourceStruct(), (path is null) ? null : path.getTreePathStruct(), (selectionData is null) ? null : selectionData.getSelectionDataStruct()) != 0;
80 	}
81 
82 	/**
83 	 * Asks the #GtkTreeDragSource whether a particular row can be used as
84 	 * the source of a DND operation. If the source doesn’t implement
85 	 * this interface, the row is assumed draggable.
86 	 *
87 	 * Params:
88 	 *     path = row on which user is initiating a drag
89 	 *
90 	 * Return: %TRUE if the row can be dragged
91 	 */
92 	public bool rowDraggable(TreePath path)
93 	{
94 		return gtk_tree_drag_source_row_draggable(getTreeDragSourceStruct(), (path is null) ? null : path.getTreePathStruct()) != 0;
95 	}
96 
97 	/**
98 	 * Obtains a @tree_model and @path from selection data of target type
99 	 * %GTK_TREE_MODEL_ROW. Normally called from a drag_data_received handler.
100 	 * This function can only be used if @selection_data originates from the same
101 	 * process that’s calling this function, because a pointer to the tree model
102 	 * is being passed around. If you aren’t in the same process, then you'll
103 	 * get memory corruption. In the #GtkTreeDragDest drag_data_received handler,
104 	 * you can assume that selection data of type %GTK_TREE_MODEL_ROW is
105 	 * in from the current process. The returned path must be freed with
106 	 * gtk_tree_path_free().
107 	 *
108 	 * Params:
109 	 *     selectionData = a #GtkSelectionData
110 	 *     treeModel = a #GtkTreeModel
111 	 *     path = row in @tree_model
112 	 *
113 	 * Return: %TRUE if @selection_data had target type %GTK_TREE_MODEL_ROW and
114 	 *     is otherwise valid
115 	 */
116 	public static bool getRowDragData(SelectionData selectionData, out TreeModelIF treeModel, out TreePath path)
117 	{
118 		GtkTreeModel* outtreeModel = null;
119 		GtkTreePath* outpath = null;
120 		
121 		auto p = gtk_tree_get_row_drag_data((selectionData is null) ? null : selectionData.getSelectionDataStruct(), &outtreeModel, &outpath) != 0;
122 		
123 		treeModel = ObjectG.getDObject!(TreeModel, TreeModelIF)(outtreeModel);
124 		path = ObjectG.getDObject!(TreePath)(outpath);
125 		
126 		return p;
127 	}
128 
129 	/**
130 	 * Sets selection data of target type %GTK_TREE_MODEL_ROW. Normally used
131 	 * in a drag_data_get handler.
132 	 *
133 	 * Params:
134 	 *     selectionData = some #GtkSelectionData
135 	 *     treeModel = a #GtkTreeModel
136 	 *     path = a row in @tree_model
137 	 *
138 	 * Return: %TRUE if the #GtkSelectionData had the proper target type to allow us to set a tree row
139 	 */
140 	public static bool setRowDragData(SelectionData selectionData, TreeModelIF treeModel, TreePath path)
141 	{
142 		return gtk_tree_set_row_drag_data((selectionData is null) ? null : selectionData.getSelectionDataStruct(), (treeModel is null) ? null : treeModel.getTreeModelStruct(), (path is null) ? null : path.getTreePathStruct()) != 0;
143 	}
144 }