This file is indexed.

/usr/include/d/gtkd-3/gtk/TreeSelection.d is in libgtkd-3-dev 3.7.5-2build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
/*
 * This file is part of gtkD.
 *
 * gtkD is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 3
 * of the License, or (at your option) any later version, with
 * some exceptions, please read the COPYING file.
 *
 * gtkD is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with gtkD; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
 */

// generated automatically - do not change
// find conversion definition on APILookup.txt
// implement new conversion functionalities on the wrap.utils pakage


module gtk.TreeSelection;

private import glib.ListG;
private import glib.MemorySlice;
private import gobject.ObjectG;
private import gobject.Signals;
private import gtk.TreeIter;
private import gtk.TreeModelIF;
private import gtk.TreePath;
private import gtk.TreeView;
private import gtk.c.functions;
public  import gtk.c.types;
public  import gtkc.gtktypes;
private import std.algorithm;


/**
 * The #GtkTreeSelection object is a helper object to manage the selection
 * for a #GtkTreeView widget.  The #GtkTreeSelection object is
 * automatically created when a new #GtkTreeView widget is created, and
 * cannot exist independently of this widget.  The primary reason the
 * #GtkTreeSelection objects exists is for cleanliness of code and API.
 * That is, there is no conceptual reason all these functions could not be
 * methods on the #GtkTreeView widget instead of a separate function.
 * 
 * The #GtkTreeSelection object is gotten from a #GtkTreeView by calling
 * gtk_tree_view_get_selection().  It can be manipulated to check the
 * selection status of the tree, as well as select and deselect individual
 * rows.  Selection is done completely view side.  As a result, multiple
 * views of the same model can have completely different selections.
 * Additionally, you cannot change the selection of a row on the model that
 * is not currently displayed by the view without expanding its parents
 * first.
 * 
 * One of the important things to remember when monitoring the selection of
 * a view is that the #GtkTreeSelection::changed signal is mostly a hint.
 * That is, it may only emit one signal when a range of rows is selected.
 * Additionally, it may on occasion emit a #GtkTreeSelection::changed signal
 * when nothing has happened (mostly as a result of programmers calling
 * select_row on an already selected row).
 */
public class TreeSelection : ObjectG
{
	/** the main Gtk struct */
	protected GtkTreeSelection* gtkTreeSelection;

	/** Get the main Gtk struct */
	public GtkTreeSelection* getTreeSelectionStruct(bool transferOwnership = false)
	{
		if (transferOwnership)
			ownedRef = false;
		return gtkTreeSelection;
	}

	/** the main Gtk struct as a void* */
	protected override void* getStruct()
	{
		return cast(void*)gtkTreeSelection;
	}

	protected override void setStruct(GObject* obj)
	{
		gtkTreeSelection = cast(GtkTreeSelection*)obj;
		super.setStruct(obj);
	}

	/**
	 * Sets our main struct and passes it to the parent class.
	 */
	public this (GtkTreeSelection* gtkTreeSelection, bool ownedRef = false)
	{
		this.gtkTreeSelection = gtkTreeSelection;
		super(cast(GObject*)gtkTreeSelection, ownedRef);
	}

	/**
	 * Returns an TreeIter set to the currently selected node if selection
	 * is set to Selection.SINGLE or Selection.BROWSE.
	 * This function will not work if you use selection is Selection.MULTIPLE.
	 * Returns: A TreeIter for the selected node.
	 */
	public TreeIter getSelected()
	{
		TreeModelIF model;
		TreeIter iter = new TreeIter();

		if ( getSelected(model, iter) )
		{
			iter.setModel(model);
			return iter;
		}
		else
		{
			return null;
		}
	}

	/**
	 * Creates a list of path of all selected rows. Additionally, if you are
	 * planning on modifying the model after calling this function, you may
	 * want to convert the returned list into a list of TreeRowReferences.
	 * Since: 2.2
	 * Params:
	 *  model = A pointer to set to the GtkTreeModel, or NULL.
	 * Returns:
	 *  A GList containing a GtkTreePath for each selected row.
	 */
	TreePath[] getSelectedRows(out TreeModelIF model)
	{
		TreePath[] paths;
		GtkTreeModel* outmodel = null;
		GList* gList = gtk_tree_selection_get_selected_rows(gtkTreeSelection, &outmodel);
		if ( gList !is null )
		{
			ListG list = new ListG(gList);
			for ( int i=0 ; i<list.length() ; i++ )
			{
				paths ~= new TreePath(cast(GtkTreePath*)list.nthData(i));
			}
		}
		model = ObjectG.getDObject!(TreeModelIF)(outmodel);

		return paths;
	}

	/**
	 */

	/** */
	public static GType getType()
	{
		return gtk_tree_selection_get_type();
	}

	/**
	 * Returns the number of rows that have been selected in @tree.
	 *
	 * Returns: The number of rows selected.
	 *
	 * Since: 2.2
	 */
	public int countSelectedRows()
	{
		return gtk_tree_selection_count_selected_rows(gtkTreeSelection);
	}

	/**
	 * Gets the selection mode for @selection. See
	 * gtk_tree_selection_set_mode().
	 *
	 * Returns: the current selection mode
	 */
	public GtkSelectionMode getMode()
	{
		return gtk_tree_selection_get_mode(gtkTreeSelection);
	}

	/**
	 * Returns the current selection function.
	 *
	 * Returns: The function.
	 *
	 * Since: 2.14
	 */
	public GtkTreeSelectionFunc getSelectFunction()
	{
		return gtk_tree_selection_get_select_function(gtkTreeSelection);
	}

	/**
	 * Sets @iter to the currently selected node if @selection is set to
	 * #GTK_SELECTION_SINGLE or #GTK_SELECTION_BROWSE.  @iter may be NULL if you
	 * just want to test if @selection has any selected nodes.  @model is filled
	 * with the current model as a convenience.  This function will not work if you
	 * use @selection is #GTK_SELECTION_MULTIPLE.
	 *
	 * Params:
	 *     model = A pointer to set to the #GtkTreeModel, or NULL.
	 *     iter = The #GtkTreeIter, or NULL.
	 *
	 * Returns: TRUE, if there is a selected node.
	 */
	public bool getSelected(out TreeModelIF model, out TreeIter iter)
	{
		GtkTreeModel* outmodel = null;
		GtkTreeIter* outiter = sliceNew!GtkTreeIter();

		auto p = gtk_tree_selection_get_selected(gtkTreeSelection, &outmodel, outiter) != 0;

		model = ObjectG.getDObject!(TreeModelIF)(outmodel);
		iter = ObjectG.getDObject!(TreeIter)(outiter, true);

		return p;
	}

	/**
	 * Returns the tree view associated with @selection.
	 *
	 * Returns: A #GtkTreeView
	 */
	public TreeView getTreeView()
	{
		auto p = gtk_tree_selection_get_tree_view(gtkTreeSelection);

		if(p is null)
		{
			return null;
		}

		return ObjectG.getDObject!(TreeView)(cast(GtkTreeView*) p);
	}

	/**
	 * Returns the user data for the selection function.
	 *
	 * Returns: The user data.
	 */
	public void* getUserData()
	{
		return gtk_tree_selection_get_user_data(gtkTreeSelection);
	}

	/**
	 * Returns %TRUE if the row at @iter is currently selected.
	 *
	 * Params:
	 *     iter = A valid #GtkTreeIter
	 *
	 * Returns: %TRUE, if @iter is selected
	 */
	public bool iterIsSelected(TreeIter iter)
	{
		return gtk_tree_selection_iter_is_selected(gtkTreeSelection, (iter is null) ? null : iter.getTreeIterStruct()) != 0;
	}

	/**
	 * Returns %TRUE if the row pointed to by @path is currently selected.  If @path
	 * does not point to a valid location, %FALSE is returned
	 *
	 * Params:
	 *     path = A #GtkTreePath to check selection on.
	 *
	 * Returns: %TRUE if @path is selected.
	 */
	public bool pathIsSelected(TreePath path)
	{
		return gtk_tree_selection_path_is_selected(gtkTreeSelection, (path is null) ? null : path.getTreePathStruct()) != 0;
	}

	/**
	 * Selects all the nodes. @selection must be set to #GTK_SELECTION_MULTIPLE
	 * mode.
	 */
	public void selectAll()
	{
		gtk_tree_selection_select_all(gtkTreeSelection);
	}

	/**
	 * Selects the specified iterator.
	 *
	 * Params:
	 *     iter = The #GtkTreeIter to be selected.
	 */
	public void selectIter(TreeIter iter)
	{
		gtk_tree_selection_select_iter(gtkTreeSelection, (iter is null) ? null : iter.getTreeIterStruct());
	}

	/**
	 * Select the row at @path.
	 *
	 * Params:
	 *     path = The #GtkTreePath to be selected.
	 */
	public void selectPath(TreePath path)
	{
		gtk_tree_selection_select_path(gtkTreeSelection, (path is null) ? null : path.getTreePathStruct());
	}

	/**
	 * Selects a range of nodes, determined by @start_path and @end_path inclusive.
	 * @selection must be set to #GTK_SELECTION_MULTIPLE mode.
	 *
	 * Params:
	 *     startPath = The initial node of the range.
	 *     endPath = The final node of the range.
	 */
	public void selectRange(TreePath startPath, TreePath endPath)
	{
		gtk_tree_selection_select_range(gtkTreeSelection, (startPath is null) ? null : startPath.getTreePathStruct(), (endPath is null) ? null : endPath.getTreePathStruct());
	}

	/**
	 * Calls a function for each selected node. Note that you cannot modify
	 * the tree or selection from within this function. As a result,
	 * gtk_tree_selection_get_selected_rows() might be more useful.
	 *
	 * Params:
	 *     func = The function to call for each selected node.
	 *     data = user data to pass to the function.
	 */
	public void selectedForeach(GtkTreeSelectionForeachFunc func, void* data)
	{
		gtk_tree_selection_selected_foreach(gtkTreeSelection, func, data);
	}

	/**
	 * Sets the selection mode of the @selection.  If the previous type was
	 * #GTK_SELECTION_MULTIPLE, then the anchor is kept selected, if it was
	 * previously selected.
	 *
	 * Params:
	 *     type = The selection mode
	 */
	public void setMode(GtkSelectionMode type)
	{
		gtk_tree_selection_set_mode(gtkTreeSelection, type);
	}

	/**
	 * Sets the selection function.
	 *
	 * If set, this function is called before any node is selected or unselected,
	 * giving some control over which nodes are selected. The select function
	 * should return %TRUE if the state of the node may be toggled, and %FALSE
	 * if the state of the node should be left unchanged.
	 *
	 * Params:
	 *     func = The selection function. May be %NULL
	 *     data = The selection function’s data. May be %NULL
	 *     destroy = The destroy function for user data.  May be %NULL
	 */
	public void setSelectFunction(GtkTreeSelectionFunc func, void* data, GDestroyNotify destroy)
	{
		gtk_tree_selection_set_select_function(gtkTreeSelection, func, data, destroy);
	}

	/**
	 * Unselects all the nodes.
	 */
	public void unselectAll()
	{
		gtk_tree_selection_unselect_all(gtkTreeSelection);
	}

	/**
	 * Unselects the specified iterator.
	 *
	 * Params:
	 *     iter = The #GtkTreeIter to be unselected.
	 */
	public void unselectIter(TreeIter iter)
	{
		gtk_tree_selection_unselect_iter(gtkTreeSelection, (iter is null) ? null : iter.getTreeIterStruct());
	}

	/**
	 * Unselects the row at @path.
	 *
	 * Params:
	 *     path = The #GtkTreePath to be unselected.
	 */
	public void unselectPath(TreePath path)
	{
		gtk_tree_selection_unselect_path(gtkTreeSelection, (path is null) ? null : path.getTreePathStruct());
	}

	/**
	 * Unselects a range of nodes, determined by @start_path and @end_path
	 * inclusive.
	 *
	 * Params:
	 *     startPath = The initial node of the range.
	 *     endPath = The initial node of the range.
	 *
	 * Since: 2.2
	 */
	public void unselectRange(TreePath startPath, TreePath endPath)
	{
		gtk_tree_selection_unselect_range(gtkTreeSelection, (startPath is null) ? null : startPath.getTreePathStruct(), (endPath is null) ? null : endPath.getTreePathStruct());
	}

	protected class OnChangedDelegateWrapper
	{
		void delegate(TreeSelection) dlg;
		gulong handlerId;

		this(void delegate(TreeSelection) dlg)
		{
			this.dlg = dlg;
			onChangedListeners ~= this;
		}

		void remove(OnChangedDelegateWrapper source)
		{
			foreach(index, wrapper; onChangedListeners)
			{
				if (wrapper.handlerId == source.handlerId)
				{
					onChangedListeners[index] = null;
					onChangedListeners = std.algorithm.remove(onChangedListeners, index);
					break;
				}
			}
		}
	}
	OnChangedDelegateWrapper[] onChangedListeners;

	/**
	 * Emitted whenever the selection has (possibly) changed. Please note that
	 * this signal is mostly a hint.  It may only be emitted once when a range
	 * of rows are selected, and it may occasionally be emitted when nothing
	 * has happened.
	 */
	gulong addOnChanged(void delegate(TreeSelection) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
	{
		auto wrapper = new OnChangedDelegateWrapper(dlg);
		wrapper.handlerId = Signals.connectData(
			this,
			"changed",
			cast(GCallback)&callBackChanged,
			cast(void*)wrapper,
			cast(GClosureNotify)&callBackChangedDestroy,
			connectFlags);
		return wrapper.handlerId;
	}

	extern(C) static void callBackChanged(GtkTreeSelection* treeselectionStruct, OnChangedDelegateWrapper wrapper)
	{
		wrapper.dlg(wrapper.outer);
	}

	extern(C) static void callBackChangedDestroy(OnChangedDelegateWrapper wrapper, GClosure* closure)
	{
		wrapper.remove(wrapper);
	}
}