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.Bin;
31 private import gtk.Widget;
32 public  import gtkc.gdktypes;
33 private import gtkc.gtk;
34 public  import gtkc.gtktypes;
35 
36 
37 public class ListBoxRow : Bin
38 {
39 	/** the main Gtk struct */
40 	protected GtkListBoxRow* gtkListBoxRow;
41 
42 	/** Get the main Gtk struct */
43 	public GtkListBoxRow* getListBoxRowStruct()
44 	{
45 		return gtkListBoxRow;
46 	}
47 
48 	/** the main Gtk struct as a void* */
49 	protected override void* getStruct()
50 	{
51 		return cast(void*)gtkListBoxRow;
52 	}
53 
54 	protected override void setStruct(GObject* obj)
55 	{
56 		gtkListBoxRow = cast(GtkListBoxRow*)obj;
57 		super.setStruct(obj);
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 	/**
70 	 */
71 
72 	public static GType getType()
73 	{
74 		return gtk_list_box_row_get_type();
75 	}
76 
77 	/**
78 	 * Creates a new #GtkListBoxRow, to be used as a child of a #GtkListBox.
79 	 *
80 	 * Return: a new #GtkListBoxRow
81 	 *
82 	 * Since: 3.10
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. This affects sorting, filtering and headers.
101 	 *
102 	 * Note that calls to this method must be in sync with the data
103 	 * used for the row functions. For instance, if the list is
104 	 * mirroring some external data set, and *two* rows changed in the
105 	 * external data set then when you call gtk_list_box_row_changed()
106 	 * on the first row the sort function must only read the new data
107 	 * for the first of the two changed rows, otherwise the resorting
108 	 * of the rows will be wrong.
109 	 *
110 	 * This generally means that if you don’t fully control the data
111 	 * model you have to duplicate the data that affects the listbox
112 	 * row functions into the row widgets themselves. Another alternative
113 	 * is to call gtk_list_box_invalidate_sort() on any model change,
114 	 * but that is more expensive.
115 	 *
116 	 * Since: 3.10
117 	 */
118 	public void changed()
119 	{
120 		gtk_list_box_row_changed(gtkListBoxRow);
121 	}
122 
123 	/**
124 	 * Gets the value of the #GtkListBoxRow:activatable property
125 	 * for this row.
126 	 *
127 	 * Return: %TRUE if the row is activatable
128 	 *
129 	 * Since: 3.14
130 	 */
131 	public bool getActivatable()
132 	{
133 		return gtk_list_box_row_get_activatable(gtkListBoxRow) != 0;
134 	}
135 
136 	/**
137 	 * Returns the current header of the @row. This can be used
138 	 * in a #GtkListBoxUpdateHeaderFunc to see if there is a header
139 	 * set already, and if so to update the state of it.
140 	 *
141 	 * Return: the current header, or %NULL if none
142 	 *
143 	 * Since: 3.10
144 	 */
145 	public Widget getHeader()
146 	{
147 		auto p = gtk_list_box_row_get_header(gtkListBoxRow);
148 		
149 		if(p is null)
150 		{
151 			return null;
152 		}
153 		
154 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
155 	}
156 
157 	/**
158 	 * Gets the current index of the @row in its #GtkListBox container.
159 	 *
160 	 * Return: the index of the @row, or -1 if the @row is not in a listbox
161 	 *
162 	 * Since: 3.10
163 	 */
164 	public int getIndex()
165 	{
166 		return gtk_list_box_row_get_index(gtkListBoxRow);
167 	}
168 
169 	/**
170 	 * Gets the value of the #GtkListBoxRow:selectable property
171 	 * for this row.
172 	 *
173 	 * Return: %TRUE if the row is selectable
174 	 *
175 	 * Since: 3.14
176 	 */
177 	public bool getSelectable()
178 	{
179 		return gtk_list_box_row_get_selectable(gtkListBoxRow) != 0;
180 	}
181 
182 	/**
183 	 * Returns whether the child is currently selected in its
184 	 * #GtkListBox container.
185 	 *
186 	 * Return: %TRUE if @row is selected
187 	 *
188 	 * Since: 3.14
189 	 */
190 	public bool isSelected()
191 	{
192 		return gtk_list_box_row_is_selected(gtkListBoxRow) != 0;
193 	}
194 
195 	/**
196 	 * Set the #GtkListBoxRow:activatable property for this row.
197 	 *
198 	 * Params:
199 	 *     activatable = %TRUE to mark the row as activatable
200 	 *
201 	 * Since: 3.14
202 	 */
203 	public void setActivatable(bool activatable)
204 	{
205 		gtk_list_box_row_set_activatable(gtkListBoxRow, activatable);
206 	}
207 
208 	/**
209 	 * Sets the current header of the @row. This is only allowed to be called
210 	 * from a #GtkListBoxUpdateHeaderFunc. It will replace any existing
211 	 * header in the row, and be shown in front of the row in the listbox.
212 	 *
213 	 * Params:
214 	 *     header = the header, or %NULL
215 	 *
216 	 * Since: 3.10
217 	 */
218 	public void setHeader(Widget header)
219 	{
220 		gtk_list_box_row_set_header(gtkListBoxRow, (header is null) ? null : header.getWidgetStruct());
221 	}
222 
223 	/**
224 	 * Set the #GtkListBoxRow:selectable property for this row.
225 	 *
226 	 * Params:
227 	 *     selectable = %TRUE to mark the row as selectable
228 	 *
229 	 * Since: 3.14
230 	 */
231 	public void setSelectable(bool selectable)
232 	{
233 		gtk_list_box_row_set_selectable(gtkListBoxRow, selectable);
234 	}
235 
236 	int[string] connectedSignals;
237 
238 	void delegate(ListBoxRow)[] onActivateListeners;
239 	void addOnActivate(void delegate(ListBoxRow) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
240 	{
241 		if ( "activate" !in connectedSignals )
242 		{
243 			Signals.connectData(
244 				this,
245 				"activate",
246 				cast(GCallback)&callBackActivate,
247 				cast(void*)this,
248 				null,
249 				connectFlags);
250 			connectedSignals["activate"] = 1;
251 		}
252 		onActivateListeners ~= dlg;
253 	}
254 	extern(C) static void callBackActivate(GtkListBoxRow* listboxrowStruct, ListBoxRow _listboxrow)
255 	{
256 		foreach ( void delegate(ListBoxRow) dlg; _listboxrow.onActivateListeners )
257 		{
258 			dlg(_listboxrow);
259 		}
260 	}
261 }