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