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.Widget;
33 private import gtk.c.functions;
34 public  import gtk.c.types;
35 private import std.algorithm;
36 
37 
38 /**
39  * `GtkListBoxRow` is the kind of widget that can be added to a `GtkListBox`.
40  */
41 public class ListBoxRow : Widget, 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(GtkWidget*)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`.
81 	 *
82 	 * Returns: a new `GtkListBoxRow`
83 	 *
84 	 * Throws: ConstructionException GTK+ fails to create the object.
85 	 */
86 	public this()
87 	{
88 		auto __p = gtk_list_box_row_new();
89 
90 		if(__p is null)
91 		{
92 			throw new ConstructionException("null returned by new");
93 		}
94 
95 		this(cast(GtkListBoxRow*) __p);
96 	}
97 
98 	/**
99 	 * Marks @row as changed, causing any state that depends on this
100 	 * to be updated.
101 	 *
102 	 * 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 [method@Gtk.ListBox.invalidate_sort] on any model change,
116 	 * but that is more expensive.
117 	 */
118 	public void changed()
119 	{
120 		gtk_list_box_row_changed(gtkListBoxRow);
121 	}
122 
123 	/**
124 	 * Gets whether the row is activatable.
125 	 *
126 	 * Returns: %TRUE if the row is activatable
127 	 */
128 	public bool getActivatable()
129 	{
130 		return gtk_list_box_row_get_activatable(gtkListBoxRow) != 0;
131 	}
132 
133 	/**
134 	 * Gets the child widget of @row.
135 	 *
136 	 * Returns: the child widget of @row
137 	 */
138 	public Widget getChild()
139 	{
140 		auto __p = gtk_list_box_row_get_child(gtkListBoxRow);
141 
142 		if(__p is null)
143 		{
144 			return null;
145 		}
146 
147 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p);
148 	}
149 
150 	/**
151 	 * Returns the current header of the @row.
152 	 *
153 	 * This can be used
154 	 * in a [callback@Gtk.ListBoxUpdateHeaderFunc] to see if
155 	 * there is a header set already, and if so to update
156 	 * the state of it.
157 	 *
158 	 * Returns: the current header, or %NULL if none
159 	 */
160 	public Widget getHeader()
161 	{
162 		auto __p = gtk_list_box_row_get_header(gtkListBoxRow);
163 
164 		if(__p is null)
165 		{
166 			return null;
167 		}
168 
169 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p);
170 	}
171 
172 	/**
173 	 * Gets the current index of the @row in its `GtkListBox` container.
174 	 *
175 	 * Returns: the index of the @row, or -1 if the @row is not in a listbox
176 	 */
177 	public int getIndex()
178 	{
179 		return gtk_list_box_row_get_index(gtkListBoxRow);
180 	}
181 
182 	/**
183 	 * Gets whether the row can be selected.
184 	 *
185 	 * Returns: %TRUE if the row is selectable
186 	 */
187 	public bool getSelectable()
188 	{
189 		return gtk_list_box_row_get_selectable(gtkListBoxRow) != 0;
190 	}
191 
192 	/**
193 	 * Returns whether the child is currently selected in its
194 	 * `GtkListBox` container.
195 	 *
196 	 * Returns: %TRUE if @row is selected
197 	 */
198 	public bool isSelected()
199 	{
200 		return gtk_list_box_row_is_selected(gtkListBoxRow) != 0;
201 	}
202 
203 	/**
204 	 * Set whether the row is activatable.
205 	 *
206 	 * Params:
207 	 *     activatable = %TRUE to mark the row as activatable
208 	 */
209 	public void setActivatable(bool activatable)
210 	{
211 		gtk_list_box_row_set_activatable(gtkListBoxRow, activatable);
212 	}
213 
214 	/**
215 	 * Sets the child widget of @self.
216 	 *
217 	 * Params:
218 	 *     child = the child widget
219 	 */
220 	public void setChild(Widget child)
221 	{
222 		gtk_list_box_row_set_child(gtkListBoxRow, (child is null) ? null : child.getWidgetStruct());
223 	}
224 
225 	/**
226 	 * Sets the current header of the @row.
227 	 *
228 	 * This is only allowed to be called
229 	 * from a [callback@Gtk.ListBoxUpdateHeaderFunc].
230 	 * It will replace any existing header in the row,
231 	 * and be shown in front of the row in the listbox.
232 	 *
233 	 * Params:
234 	 *     header = the header, or %NULL
235 	 */
236 	public void setHeader(Widget header)
237 	{
238 		gtk_list_box_row_set_header(gtkListBoxRow, (header is null) ? null : header.getWidgetStruct());
239 	}
240 
241 	/**
242 	 * Set whether the row can be selected.
243 	 *
244 	 * Params:
245 	 *     selectable = %TRUE to mark the row as selectable
246 	 */
247 	public void setSelectable(bool selectable)
248 	{
249 		gtk_list_box_row_set_selectable(gtkListBoxRow, selectable);
250 	}
251 
252 	/**
253 	 * This is a keybinding signal, which will cause this row to be activated.
254 	 *
255 	 * If you want to be notified when the user activates a row (by key or not),
256 	 * use the [signal@Gtk.ListBox::row-activated] signal on the row’s parent
257 	 * `GtkListBox`.
258 	 */
259 	gulong addOnActivate(void delegate(ListBoxRow) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
260 	{
261 		return Signals.connect(this, "activate", dlg, connectFlags ^ ConnectFlags.SWAPPED);
262 	}
263 }