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.ListBoxRow;
26 
27 private import glib.ConstructionException;
28 private import gobject.ObjectG;
29 private import gobject.Signals;
30 private import gtk.ActionableIF;
31 private import gtk.ActionableT;
32 private import gtk.Bin;
33 private import gtk.Widget;
34 private import gtk.c.functions;
35 public  import gtk.c.types;
36 public  import gtkc.gtktypes;
37 private import std.algorithm;
38 
39 
40 /** */
41 public class ListBoxRow : Bin, ActionableIF
42 {
43 	/** the main Gtk struct */
44 	protected GtkListBoxRow* gtkListBoxRow;
45 
46 	/** Get the main Gtk struct */
47 	public GtkListBoxRow* getListBoxRowStruct(bool transferOwnership = false)
48 	{
49 		if (transferOwnership)
50 			ownedRef = false;
51 		return gtkListBoxRow;
52 	}
53 
54 	/** the main Gtk struct as a void* */
55 	protected override void* getStruct()
56 	{
57 		return cast(void*)gtkListBoxRow;
58 	}
59 
60 	/**
61 	 * Sets our main struct and passes it to the parent class.
62 	 */
63 	public this (GtkListBoxRow* gtkListBoxRow, bool ownedRef = false)
64 	{
65 		this.gtkListBoxRow = gtkListBoxRow;
66 		super(cast(GtkBin*)gtkListBoxRow, ownedRef);
67 	}
68 
69 	// add the Actionable capabilities
70 	mixin ActionableT!(GtkListBoxRow);
71 
72 
73 	/** */
74 	public static GType getType()
75 	{
76 		return gtk_list_box_row_get_type();
77 	}
78 
79 	/**
80 	 * Creates a new #GtkListBoxRow, to be used as a child of a #GtkListBox.
81 	 *
82 	 * Returns: a new #GtkListBoxRow
83 	 *
84 	 * Since: 3.10
85 	 *
86 	 * Throws: ConstructionException GTK+ fails to create the object.
87 	 */
88 	public this()
89 	{
90 		auto p = gtk_list_box_row_new();
91 
92 		if(p is null)
93 		{
94 			throw new ConstructionException("null returned by new");
95 		}
96 
97 		this(cast(GtkListBoxRow*) p);
98 	}
99 
100 	/**
101 	 * Marks @row as changed, causing any state that depends on this
102 	 * to be updated. This affects sorting, filtering and headers.
103 	 *
104 	 * Note that calls to this method must be in sync with the data
105 	 * used for the row functions. For instance, if the list is
106 	 * mirroring some external data set, and *two* rows changed in the
107 	 * external data set then when you call gtk_list_box_row_changed()
108 	 * on the first row the sort function must only read the new data
109 	 * for the first of the two changed rows, otherwise the resorting
110 	 * of the rows will be wrong.
111 	 *
112 	 * This generally means that if you don’t fully control the data
113 	 * model you have to duplicate the data that affects the listbox
114 	 * row functions into the row widgets themselves. Another alternative
115 	 * is to call gtk_list_box_invalidate_sort() on any model change,
116 	 * but that is more expensive.
117 	 *
118 	 * Since: 3.10
119 	 */
120 	public void changed()
121 	{
122 		gtk_list_box_row_changed(gtkListBoxRow);
123 	}
124 
125 	/**
126 	 * Gets the value of the #GtkListBoxRow:activatable property
127 	 * for this row.
128 	 *
129 	 * Returns: %TRUE if the row is activatable
130 	 *
131 	 * Since: 3.14
132 	 */
133 	public bool getActivatable()
134 	{
135 		return gtk_list_box_row_get_activatable(gtkListBoxRow) != 0;
136 	}
137 
138 	/**
139 	 * Returns the current header of the @row. This can be used
140 	 * in a #GtkListBoxUpdateHeaderFunc to see if there is a header
141 	 * set already, and if so to update the state of it.
142 	 *
143 	 * Returns: the current header, or %NULL if none
144 	 *
145 	 * Since: 3.10
146 	 */
147 	public Widget getHeader()
148 	{
149 		auto p = gtk_list_box_row_get_header(gtkListBoxRow);
150 
151 		if(p is null)
152 		{
153 			return null;
154 		}
155 
156 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
157 	}
158 
159 	/**
160 	 * Gets the current index of the @row in its #GtkListBox container.
161 	 *
162 	 * Returns: the index of the @row, or -1 if the @row is not in a listbox
163 	 *
164 	 * Since: 3.10
165 	 */
166 	public int getIndex()
167 	{
168 		return gtk_list_box_row_get_index(gtkListBoxRow);
169 	}
170 
171 	/**
172 	 * Gets the value of the #GtkListBoxRow:selectable property
173 	 * for this row.
174 	 *
175 	 * Returns: %TRUE if the row is selectable
176 	 *
177 	 * Since: 3.14
178 	 */
179 	public bool getSelectable()
180 	{
181 		return gtk_list_box_row_get_selectable(gtkListBoxRow) != 0;
182 	}
183 
184 	/**
185 	 * Returns whether the child is currently selected in its
186 	 * #GtkListBox container.
187 	 *
188 	 * Returns: %TRUE if @row is selected
189 	 *
190 	 * Since: 3.14
191 	 */
192 	public bool isSelected()
193 	{
194 		return gtk_list_box_row_is_selected(gtkListBoxRow) != 0;
195 	}
196 
197 	/**
198 	 * Set the #GtkListBoxRow:activatable property for this row.
199 	 *
200 	 * Params:
201 	 *     activatable = %TRUE to mark the row as activatable
202 	 *
203 	 * Since: 3.14
204 	 */
205 	public void setActivatable(bool activatable)
206 	{
207 		gtk_list_box_row_set_activatable(gtkListBoxRow, activatable);
208 	}
209 
210 	/**
211 	 * Sets the current header of the @row. This is only allowed to be called
212 	 * from a #GtkListBoxUpdateHeaderFunc. It will replace any existing
213 	 * header in the row, and be shown in front of the row in the listbox.
214 	 *
215 	 * Params:
216 	 *     header = the header, or %NULL
217 	 *
218 	 * Since: 3.10
219 	 */
220 	public void setHeader(Widget header)
221 	{
222 		gtk_list_box_row_set_header(gtkListBoxRow, (header is null) ? null : header.getWidgetStruct());
223 	}
224 
225 	/**
226 	 * Set the #GtkListBoxRow:selectable property for this row.
227 	 *
228 	 * Params:
229 	 *     selectable = %TRUE to mark the row as selectable
230 	 *
231 	 * Since: 3.14
232 	 */
233 	public void setSelectable(bool selectable)
234 	{
235 		gtk_list_box_row_set_selectable(gtkListBoxRow, selectable);
236 	}
237 
238 	/**
239 	 * This is a keybinding signal, which will cause this row to be activated.
240 	 *
241 	 * If you want to be notified when the user activates a row (by key or not),
242 	 * use the #GtkListBox::row-activated signal on the row’s parent #GtkListBox.
243 	 *
244 	 * Since: 3.10
245 	 */
246 	gulong addOnActivate(void delegate(ListBoxRow) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
247 	{
248 		return Signals.connect(this, "activate", dlg, connectFlags ^ ConnectFlags.SWAPPED);
249 	}
250 }