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 = GtkTreeSelection.html
27 * outFile = TreeSelection
28 * strct = GtkTreeSelection
31 * clss = TreeSelection
39 * - gtk_tree_selection_
44 * - gtk_tree_selection_get_selected
45 * - gtk_tree_selection_get_selected_rows
55 * - GtkTreeIter* -> TreeIter
56 * - GtkTreePath* -> TreePath
57 * - GtkTreeView* -> TreeView
62 module gtk
.TreeSelection
;
68 import tango
.io
.Stdout
; // use the tango loging?
72 private import gtkc
.gtktypes
;
74 private import gtkc
.gtk
;
77 private import gtk
.TreeView
;
78 private import gtk
.TreeIter
;
79 private import glib
.ListG
;
80 private import gtk
.TreePath
;
81 private import gtk
.TreeModel
;
82 private import gtk
.TreeIter
;
89 * The GtkTreeSelection object is a helper object to manage the selection
90 * for a GtkTreeView widget. The GtkTreeSelection object is
91 * automatically created when a new GtkTreeView widget is created, and
92 * cannot exist independentally of this widget. The primary reason the
93 * GtkTreeSelection objects exists is for cleanliness of code and API.
94 * That is, there is no conceptual reason all these functions could not be
95 * methods on the GtkTreeView widget instead of a separate function.
96 * The GtkTreeSelection object is gotten from a GtkTreeView by calling
97 * gtk_tree_view_get_selection(). It can be manipulated to check the
98 * selection status of the tree, as well as select and deselect individual
99 * rows. Selection is done completely view side. As a result, multiple
100 * views of the same model can have completely different selections.
101 * Additionally, you cannot change the selection of a row on the model that
102 * is not currently displayed by the view without expanding its parents
104 * One of the important things to remember when monitoring the selection of
105 * a view is that the "changed" signal is mostly a hint. That is, it may
106 * only emit one signal when a range of rows is selected. Additionally, it
107 * may on occasion emit a "changed" signal when nothing has happened
108 * (mostly as a result of programmers calling select_row on an already
111 private import gobject
.ObjectG
;
112 public class TreeSelection
: ObjectG
115 /** the main Gtk struct */
116 protected GtkTreeSelection
* gtkTreeSelection
;
119 public GtkTreeSelection
* getTreeSelectionStruct()
121 return gtkTreeSelection
;
125 /** the main Gtk struct as a void* */
126 protected void* getStruct()
128 return cast(void*)gtkTreeSelection
;
132 * Sets our main struct and passes it to the parent class
134 public this (GtkTreeSelection
* gtkTreeSelection
)
138 if ( gtkTreeSelection
is null )
143 Stdout("struct gtkTreeSelection is null on constructor").newline
;
147 printf("struct gtkTreeSelection is null on constructor");
154 assert(gtkTreeSelection
!is null, "struct gtkTreeSelection is null on constructor");
156 super(cast(GObject
*)gtkTreeSelection
);
157 this.gtkTreeSelection
= gtkTreeSelection
;
161 * Sets iter to the currently selected node if selection is set to
162 * GTK_SELECTION_SINGLE or GTK_SELECTION_BROWSE. iter may be NULL if you
163 * just want to test if selection has any selected nodes. model is filled
164 * with the current model as a convenience. This function will not work if you
165 * use selection is GTK_SELECTION_MULTIPLE.
167 * A GtkTreeSelection.
169 * A pointer to set to the GtkTreeModel, or NULL.
171 * The GtkTreeIter, or NULL.
173 * TRUE, if there is a selected node.
175 int getSelected(TreeModel model
, TreeIter iter
)
177 GtkTreeModel
* m
= model
.getTreeModelStruct();
178 return gtk_tree_selection_get_selected(gtkTreeSelection
, &m
, iter
.getTreeIterStruct())==0 ?
false : true;
182 * Creates a list of path of all selected rows. Additionally, if you are
183 * planning on modifying the model after calling this function, you may
184 * want to convert the returned list into a list of GtkTreeRowReferences.
185 * To do this, you can use gtk_tree_row_reference_new().
186 * To free the return value, use:
187 * g_list_foreach (list, gtk_tree_path_free, NULL);
188 * g_list_free (list);
190 * A GtkTreeSelection.
192 * A pointer to set to the GtkTreeModel, or NULL.
194 * A GList containing a GtkTreePath for each selected row.
197 TreePath
[] getSelectedRows(TreeModel model
)
200 GtkTreeModel
* m
= model
.getTreeModelStruct();
201 GList
* gList
= gtk_tree_selection_get_selected_rows(gtkTreeSelection
, &m
);
202 if ( gList
!is null )
204 ListG list
= new ListG(gList
);
205 for ( int i
=0 ; i
<list
.length() ; i
++ )
207 paths
~= new TreePath(cast(GtkTreePath
*)list
.nthData(i
));
216 // imports for the signal processing
217 private import gobject
.Signals
;
218 private import gtkc
.gdktypes
;
219 int[char[]] connectedSignals
;
221 void delegate(TreeSelection
)[] onChangedListeners
;
222 void addOnChanged(void delegate(TreeSelection
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
224 if ( !("changed" in connectedSignals
) )
229 cast(GCallback
)&callBackChanged
,
233 connectedSignals
["changed"] = 1;
235 onChangedListeners
~= dlg
;
237 extern(C
) static void callBackChanged(GtkTreeSelection
* treeselectionStruct
, TreeSelection treeSelection
)
239 bool consumed
= false;
241 foreach ( void delegate(TreeSelection
) dlg
; treeSelection
.onChangedListeners
)
254 * Sets the selection mode of the selection. If the previous type was
255 * GTK_SELECTION_MULTIPLE, then the anchor is kept selected, if it was
256 * previously selected.
258 * A GtkTreeSelection.
262 public void setMode(GtkSelectionMode type
)
264 // void gtk_tree_selection_set_mode (GtkTreeSelection *selection, GtkSelectionMode type);
265 gtk_tree_selection_set_mode(gtkTreeSelection
, type
);
269 * Gets the selection mode for selection. See
270 * gtk_tree_selection_set_mode().
274 * the current selection mode
276 public GtkSelectionMode
getMode()
278 // GtkSelectionMode gtk_tree_selection_get_mode (GtkTreeSelection *selection);
279 return gtk_tree_selection_get_mode(gtkTreeSelection
);
283 * Sets the selection function. If set, this function is called before any node
284 * is selected or unselected, giving some control over which nodes are selected.
285 * The select function should return TRUE if the state of the node may be toggled,
286 * and FALSE if the state of the node should be left unchanged.
288 * A GtkTreeSelection.
290 * The selection function.
292 * The selection function's data.
294 * The destroy function for user data. May be NULL.
296 public void setSelectFunction(GtkTreeSelectionFunc func
, void* data
, GtkDestroyNotify destroy
)
298 // void gtk_tree_selection_set_select_function (GtkTreeSelection *selection, GtkTreeSelectionFunc func, gpointer data, GtkDestroyNotify destroy);
299 gtk_tree_selection_set_select_function(gtkTreeSelection
, func
, data
, destroy
);
303 * Returns the user data for the selection function.
305 * A GtkTreeSelection.
309 public void* getUserData()
311 // gpointer gtk_tree_selection_get_user_data (GtkTreeSelection *selection);
312 return gtk_tree_selection_get_user_data(gtkTreeSelection
);
316 * Returns the tree view associated with selection.
322 public TreeView
getTreeView()
324 // GtkTreeView* gtk_tree_selection_get_tree_view (GtkTreeSelection *selection);
325 return new TreeView( gtk_tree_selection_get_tree_view(gtkTreeSelection
) );
330 * Calls a function for each selected node. Note that you cannot modify
331 * the tree or selection from within this function. As a result,
332 * gtk_tree_selection_get_selected_rows() might be more useful.
334 * A GtkTreeSelection.
336 * The function to call for each selected node.
338 * user data to pass to the function.
340 public void selectedForeach(GtkTreeSelectionForeachFunc func
, void* data
)
342 // void gtk_tree_selection_selected_foreach (GtkTreeSelection *selection, GtkTreeSelectionForeachFunc func, gpointer data);
343 gtk_tree_selection_selected_foreach(gtkTreeSelection
, func
, data
);
348 * Returns the number of rows that have been selected in tree.
350 * A GtkTreeSelection.
352 * The number of rows selected.
355 public int countSelectedRows()
357 // gint gtk_tree_selection_count_selected_rows (GtkTreeSelection *selection);
358 return gtk_tree_selection_count_selected_rows(gtkTreeSelection
);
362 * Select the row at path.
364 * A GtkTreeSelection.
366 * The GtkTreePath to be selected.
368 public void selectPath(TreePath path
)
370 // void gtk_tree_selection_select_path (GtkTreeSelection *selection, GtkTreePath *path);
371 gtk_tree_selection_select_path(gtkTreeSelection
, (path
is null) ?
null : path
.getTreePathStruct());
375 * Unselects the row at path.
377 * A GtkTreeSelection.
379 * The GtkTreePath to be unselected.
381 public void unselectPath(TreePath path
)
383 // void gtk_tree_selection_unselect_path (GtkTreeSelection *selection, GtkTreePath *path);
384 gtk_tree_selection_unselect_path(gtkTreeSelection
, (path
is null) ?
null : path
.getTreePathStruct());
388 * Returns TRUE if the row pointed to by path is currently selected. If path
389 * does not point to a valid location, FALSE is returned
391 * A GtkTreeSelection.
393 * A GtkTreePath to check selection on.
395 * TRUE if path is selected.
397 public int pathIsSelected(TreePath path
)
399 // gboolean gtk_tree_selection_path_is_selected (GtkTreeSelection *selection, GtkTreePath *path);
400 return gtk_tree_selection_path_is_selected(gtkTreeSelection
, (path
is null) ?
null : path
.getTreePathStruct());
404 * Selects the specified iterator.
406 * A GtkTreeSelection.
408 * The GtkTreeIter to be selected.
410 public void selectIter(TreeIter iter
)
412 // void gtk_tree_selection_select_iter (GtkTreeSelection *selection, GtkTreeIter *iter);
413 gtk_tree_selection_select_iter(gtkTreeSelection
, (iter
is null) ?
null : iter
.getTreeIterStruct());
417 * Unselects the specified iterator.
419 * A GtkTreeSelection.
421 * The GtkTreeIter to be unselected.
423 public void unselectIter(TreeIter iter
)
425 // void gtk_tree_selection_unselect_iter (GtkTreeSelection *selection, GtkTreeIter *iter);
426 gtk_tree_selection_unselect_iter(gtkTreeSelection
, (iter
is null) ?
null : iter
.getTreeIterStruct());
430 * Returns TRUE if the row at iter is currently selected.
434 * A valid GtkTreeIter
436 * TRUE, if iter is selected
438 public int iterIsSelected(TreeIter iter
)
440 // gboolean gtk_tree_selection_iter_is_selected (GtkTreeSelection *selection, GtkTreeIter *iter);
441 return gtk_tree_selection_iter_is_selected(gtkTreeSelection
, (iter
is null) ?
null : iter
.getTreeIterStruct());
445 * Selects all the nodes. selection must be set to GTK_SELECTION_MULTIPLE
448 * A GtkTreeSelection.
450 public void selectAll()
452 // void gtk_tree_selection_select_all (GtkTreeSelection *selection);
453 gtk_tree_selection_select_all(gtkTreeSelection
);
457 * Unselects all the nodes.
459 * A GtkTreeSelection.
461 public void unselectAll()
463 // void gtk_tree_selection_unselect_all (GtkTreeSelection *selection);
464 gtk_tree_selection_unselect_all(gtkTreeSelection
);
468 * Selects a range of nodes, determined by start_path and end_path inclusive.
469 * selection must be set to GTK_SELECTION_MULTIPLE mode.
471 * A GtkTreeSelection.
473 * The initial node of the range.
475 * The final node of the range.
477 public void selectRange(TreePath startPath
, TreePath endPath
)
479 // void gtk_tree_selection_select_range (GtkTreeSelection *selection, GtkTreePath *start_path, GtkTreePath *end_path);
480 gtk_tree_selection_select_range(gtkTreeSelection
, (startPath
is null) ?
null : startPath
.getTreePathStruct(), (endPath
is null) ?
null : endPath
.getTreePathStruct());
484 * Unselects a range of nodes, determined by start_path and end_path
487 * A GtkTreeSelection.
489 * The initial node of the range.
491 * The initial node of the range.
494 * The "changed" signal
495 * void user_function (GtkTreeSelection *treeselection,
496 * gpointer user_data) : Run First
497 * Emitted whenever the selection has (possibly) changed. Please note that
498 * this signal is mostly a hint. It may only be emitted once when a range
499 * of rows are selected, and it may occasionally be emitted when nothing
502 * the object which received the signal.
504 * user data set when the signal handler was connected.
506 * GtkTreeView, GtkTreeViewColumn, GtkTreeDnd, GtkTreeMode, GtkTreeSortable, GtkTreeModelSort, GtkListStore, GtkTreeStore, GtkCellRenderer, GtkCellEditable, GtkCellRendererPixbuf, GtkCellRendererText, GtkCellRendererToggle
508 public void unselectRange(TreePath startPath
, TreePath endPath
)
510 // void gtk_tree_selection_unselect_range (GtkTreeSelection *selection, GtkTreePath *start_path, GtkTreePath *end_path);
511 gtk_tree_selection_unselect_range(gtkTreeSelection
, (startPath
is null) ?
null : startPath
.getTreePathStruct(), (endPath
is null) ?
null : endPath
.getTreePathStruct());