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