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  * Conversion parameters:
26  * inFile  = 
27  * outPack = gtk
28  * outFile = ListBoxRow
29  * strct   = GtkListBoxRow
30  * realStrct=
31  * ctorStrct=
32  * clss    = ListBoxRow
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_list_box_row_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * 	- activate-cursor-row
46  * 	- move-cursor
47  * 	- row-activated
48  * 	- row-selected
49  * 	- toggle-cursor-row
50  * imports:
51  * 	- gtk.Widget
52  * structWrap:
53  * 	- GtkWidget* -> Widget
54  * module aliases:
55  * local aliases:
56  * overrides:
57  */
58 
59 module gtk.ListBoxRow;
60 
61 public  import gtkc.gtktypes;
62 
63 private import gtkc.gtk;
64 private import glib.ConstructionException;
65 private import gobject.ObjectG;
66 
67 private import gobject.Signals;
68 public  import gtkc.gdktypes;
69 
70 private import gtk.Widget;
71 
72 
73 
74 
75 /**
76  * A GtkListBox is a vertical container that contains GtkListBoxRow
77  * children. These rows can by dynamically sorted and filtered, and
78  * headers can be added dynamically depending on the row content.
79  * It also allows keyboard and mouse navigation and selection like
80  * a typical list.
81  *
82  * Using GtkListBox is often an alternative to GtkTreeView, especially
83  * when the list contents has a more complicated layout than what is allowed
84  * by a GtkCellRenderer, or when the contents is interactive (i.e. has a
85  * button in it).
86  *
87  * Although a GtkListBox must have only GtkListBoxRow children you can
88  * add any kind of widget to it via gtk_container_add(), and a GtkListBoxRow
89  * widget will automatically be inserted between the list and the widget.
90  *
91  * The GtkListBox widget was added in GTK+ 3.10.
92  */
93 public class ListBoxRow
94 {
95 	
96 	/** the main Gtk struct */
97 	protected GtkListBoxRow* gtkListBoxRow;
98 	
99 	
100 	public GtkListBoxRow* getListBoxRowStruct()
101 	{
102 		return gtkListBoxRow;
103 	}
104 	
105 	
106 	/** the main Gtk struct as a void* */
107 	protected void* getStruct()
108 	{
109 		return cast(void*)gtkListBoxRow;
110 	}
111 	
112 	/**
113 	 * Sets our main struct and passes it to the parent class
114 	 */
115 	public this (GtkListBoxRow* gtkListBoxRow)
116 	{
117 		this.gtkListBoxRow = gtkListBoxRow;
118 	}
119 	
120 	/**
121 	 */
122 	int[string] connectedSignals;
123 	
124 	void delegate(ListBoxRow)[] onActivateListeners;
125 	/**
126 	 * See Also
127 	 * GtkScrolledWindow
128 	 */
129 	void addOnActivate(void delegate(ListBoxRow) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
130 	{
131 		if ( !("activate" in connectedSignals) )
132 		{
133 			Signals.connectData(
134 			getStruct(),
135 			"activate",
136 			cast(GCallback)&callBackActivate,
137 			cast(void*)this,
138 			null,
139 			connectFlags);
140 			connectedSignals["activate"] = 1;
141 		}
142 		onActivateListeners ~= dlg;
143 	}
144 	extern(C) static void callBackActivate(GtkListBoxRow* listboxrowStruct, ListBoxRow _listBoxRow)
145 	{
146 		foreach ( void delegate(ListBoxRow) dlg ; _listBoxRow.onActivateListeners )
147 		{
148 			dlg(_listBoxRow);
149 		}
150 	}
151 	
152 	
153 	/**
154 	 * Creates a new GtkListBoxRow, to be used as a child of a GtkListBox.
155 	 * Throws: ConstructionException GTK+ fails to create the object.
156 	 */
157 	public this ()
158 	{
159 		// GtkWidget * gtk_list_box_row_new (void);
160 		auto p = gtk_list_box_row_new();
161 		if(p is null)
162 		{
163 			throw new ConstructionException("null returned by gtk_list_box_row_new()");
164 		}
165 		this(cast(GtkListBoxRow*) p);
166 	}
167 	
168 	/**
169 	 * Marks row as changed, causing any state that depends on this
170 	 * to be updated. This affects sorting, filtering and headers.
171 	 * Note that calls to this method must be in sync with the data
172 	 * used for the row functions. For instance, if the list is
173 	 * mirroring some external data set, and *two* rows changed in the
174 	 * external data set then when you call gtk_list_box_row_changed()
175 	 * on the first row the sort function must only read the new data
176 	 * for the first of the two changed rows, otherwise the resorting
177 	 * of the rows will be wrong.
178 	 * This generally means that if you don't fully control the data
179 	 * model you have to duplicate the data that affects the listbox
180 	 * row functions into the row widgets themselves. Another alternative
181 	 * is to call gtk_list_box_invalidate_sort() on any model change,
182 	 * but that is more expensive.
183 	 */
184 	public void changed()
185 	{
186 		// void gtk_list_box_row_changed (GtkListBoxRow *row);
187 		gtk_list_box_row_changed(gtkListBoxRow);
188 	}
189 	
190 	/**
191 	 * Returns the current header of the row. This can be used
192 	 * in a GtkListBoxUpdateHeaderFunc to see if there is a header
193 	 * set already, and if so to update the state of it.
194 	 * Returns: the current header, or NULL if none. [transfer none] Since 3.10
195 	 */
196 	public Widget getHeader()
197 	{
198 		// GtkWidget * gtk_list_box_row_get_header (GtkListBoxRow *row);
199 		auto p = gtk_list_box_row_get_header(gtkListBoxRow);
200 		
201 		if(p is null)
202 		{
203 			return null;
204 		}
205 		
206 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
207 	}
208 	
209 	/**
210 	 */
211 	public static GType getType()
212 	{
213 		// GType gtk_list_box_row_get_type (void);
214 		return gtk_list_box_row_get_type();
215 	}
216 	
217 	/**
218 	 * Sets the current header of the row. This is only allowed to be called
219 	 * from a GtkListBoxUpdateHeaderFunc. It will replace any existing
220 	 * header in the row, and be shown in front of the row in the listbox.
221 	 * Params:
222 	 * header = the header, or NULL. [allow-none]
223 	 * Since 3.10
224 	 */
225 	public void setHeader(Widget header)
226 	{
227 		// void gtk_list_box_row_set_header (GtkListBoxRow *row,  GtkWidget *header);
228 		gtk_list_box_row_set_header(gtkListBoxRow, (header is null) ? null : header.getWidgetStruct());
229 	}
230 	
231 	/**
232 	 * Gets the current index of the row in its GtkListBox container.
233 	 * Returns: the index of the row, or -1 if the row is not in a listbox Since 3.10
234 	 */
235 	public int getIndex()
236 	{
237 		// gint gtk_list_box_row_get_index (GtkListBoxRow *row);
238 		return gtk_list_box_row_get_index(gtkListBoxRow);
239 	}
240 }