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.TreeListRow;
26 
27 private import gio.ListModelIF;
28 private import gobject.ObjectG;
29 private import gtk.c.functions;
30 public  import gtk.c.types;
31 
32 
33 /**
34  * `GtkTreeListRow` is used by `GtkTreeListModel` to represent items.
35  * 
36  * It allows navigating the model as a tree and modify the state of rows.
37  * 
38  * `GtkTreeListRow` instances are created by a `GtkTreeListModel` only
39  * when the [property@Gtk.TreeListModel:passthrough] property is not set.
40  * 
41  * There are various support objects that can make use of `GtkTreeListRow`
42  * objects, such as the [class@Gtk.TreeExpander] widget that allows displaying
43  * an icon to expand or collapse a row or [class@Gtk.TreeListRowSorter] that
44  * makes it possible to sort trees properly.
45  */
46 public class TreeListRow : ObjectG
47 {
48 	/** the main Gtk struct */
49 	protected GtkTreeListRow* gtkTreeListRow;
50 
51 	/** Get the main Gtk struct */
52 	public GtkTreeListRow* getTreeListRowStruct(bool transferOwnership = false)
53 	{
54 		if (transferOwnership)
55 			ownedRef = false;
56 		return gtkTreeListRow;
57 	}
58 
59 	/** the main Gtk struct as a void* */
60 	protected override void* getStruct()
61 	{
62 		return cast(void*)gtkTreeListRow;
63 	}
64 
65 	/**
66 	 * Sets our main struct and passes it to the parent class.
67 	 */
68 	public this (GtkTreeListRow* gtkTreeListRow, bool ownedRef = false)
69 	{
70 		this.gtkTreeListRow = gtkTreeListRow;
71 		super(cast(GObject*)gtkTreeListRow, ownedRef);
72 	}
73 
74 
75 	/** */
76 	public static GType getType()
77 	{
78 		return gtk_tree_list_row_get_type();
79 	}
80 
81 	/**
82 	 * If @self is not expanded or @position is greater than the
83 	 * number of children, %NULL is returned.
84 	 *
85 	 * Params:
86 	 *     position = position of the child to get
87 	 *
88 	 * Returns: the child in @position
89 	 */
90 	public TreeListRow getChildRow(uint position)
91 	{
92 		auto __p = gtk_tree_list_row_get_child_row(gtkTreeListRow, position);
93 
94 		if(__p is null)
95 		{
96 			return null;
97 		}
98 
99 		return ObjectG.getDObject!(TreeListRow)(cast(GtkTreeListRow*) __p, true);
100 	}
101 
102 	/**
103 	 * If the row is expanded, gets the model holding the children of @self.
104 	 *
105 	 * This model is the model created by the
106 	 * [callback@Gtk.TreeListModelCreateModelFunc]
107 	 * and contains the original items, no matter what value
108 	 * [property@Gtk.TreeListModel:passthrough] is set to.
109 	 *
110 	 * Returns: The model containing the children
111 	 */
112 	public ListModelIF getChildren()
113 	{
114 		auto __p = gtk_tree_list_row_get_children(gtkTreeListRow);
115 
116 		if(__p is null)
117 		{
118 			return null;
119 		}
120 
121 		return ObjectG.getDObject!(ListModelIF)(cast(GListModel*) __p);
122 	}
123 
124 	/**
125 	 * Gets the depth of this row.
126 	 *
127 	 * Rows that correspond to items in the root model have a depth
128 	 * of zero, rows corresponding to items of models of direct children
129 	 * of the root model have a depth of 1 and so on.
130 	 *
131 	 * The depth of a row never changes until the row is destroyed.
132 	 *
133 	 * Returns: The depth of this row
134 	 */
135 	public uint getDepth()
136 	{
137 		return gtk_tree_list_row_get_depth(gtkTreeListRow);
138 	}
139 
140 	/**
141 	 * Gets if a row is currently expanded.
142 	 *
143 	 * Returns: %TRUE if the row is expanded
144 	 */
145 	public bool getExpanded()
146 	{
147 		return gtk_tree_list_row_get_expanded(gtkTreeListRow) != 0;
148 	}
149 
150 	/**
151 	 * Gets the item corresponding to this row,
152 	 *
153 	 * The value returned by this function never changes until the
154 	 * row is destroyed.
155 	 *
156 	 * Returns: The item
157 	 *     of this row or %NULL when the row was destroyed
158 	 */
159 	public ObjectG getItem()
160 	{
161 		auto __p = gtk_tree_list_row_get_item(gtkTreeListRow);
162 
163 		if(__p is null)
164 		{
165 			return null;
166 		}
167 
168 		return ObjectG.getDObject!(ObjectG)(cast(GObject*) __p, true);
169 	}
170 
171 	/**
172 	 * Gets the row representing the parent for @self.
173 	 *
174 	 * That is the row that would need to be collapsed
175 	 * to make this row disappear.
176 	 *
177 	 * If @self is a row corresponding to the root model,
178 	 * %NULL is returned.
179 	 *
180 	 * The value returned by this function never changes
181 	 * until the row is destroyed.
182 	 *
183 	 * Returns: The parent of @self
184 	 */
185 	public TreeListRow getParent()
186 	{
187 		auto __p = gtk_tree_list_row_get_parent(gtkTreeListRow);
188 
189 		if(__p is null)
190 		{
191 			return null;
192 		}
193 
194 		return ObjectG.getDObject!(TreeListRow)(cast(GtkTreeListRow*) __p, true);
195 	}
196 
197 	/**
198 	 * Returns the position in the `GtkTreeListModel` that @self occupies
199 	 * at the moment.
200 	 *
201 	 * Returns: The position in the model
202 	 */
203 	public uint getPosition()
204 	{
205 		return gtk_tree_list_row_get_position(gtkTreeListRow);
206 	}
207 
208 	/**
209 	 * Checks if a row can be expanded.
210 	 *
211 	 * This does not mean that the row is actually expanded,
212 	 * this can be checked with [method@Gtk.TreeListRow.get_expanded].
213 	 *
214 	 * If a row is expandable never changes until the row is destroyed.
215 	 *
216 	 * Returns: %TRUE if the row is expandable
217 	 */
218 	public bool isExpandable()
219 	{
220 		return gtk_tree_list_row_is_expandable(gtkTreeListRow) != 0;
221 	}
222 
223 	/**
224 	 * Expands or collapses a row.
225 	 *
226 	 * If a row is expanded, the model of calling the
227 	 * [callback@Gtk.TreeListModelCreateModelFunc] for the row's
228 	 * item will be inserted after this row. If a row is collapsed,
229 	 * those items will be removed from the model.
230 	 *
231 	 * If the row is not expandable, this function does nothing.
232 	 *
233 	 * Params:
234 	 *     expanded = %TRUE if the row should be expanded
235 	 */
236 	public void setExpanded(bool expanded)
237 	{
238 		gtk_tree_list_row_set_expanded(gtkTreeListRow, expanded);
239 	}
240 }