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