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.SignalListItemFactory;
26 
27 private import glib.ConstructionException;
28 private import gobject.ObjectG;
29 private import gobject.Signals;
30 private import gtk.ListItem;
31 private import gtk.ListItemFactory;
32 private import gtk.c.functions;
33 public  import gtk.c.types;
34 private import std.algorithm;
35 
36 
37 /**
38  * `GtkSignalListItemFactory` is a `GtkListItemFactory` that emits signals
39  * to to manage listitems.
40  * 
41  * Signals are emitted for every listitem in the same order:
42  * 
43  * 1. [signal@Gtk.SignalListItemFactory::setup] is emitted to set up permanent
44  * things on the listitem. This usually means constructing the widgets used in
45  * the row and adding them to the listitem.
46  * 
47  * 2. [signal@Gtk.SignalListItemFactory::bind] is emitted to bind the item passed
48  * via [property@Gtk.ListItem:item] to the widgets that have been created in
49  * step 1 or to add item-specific widgets. Signals are connected to listen to
50  * changes - both to changes in the item to update the widgets or to changes
51  * in the widgets to update the item. After this signal has been called, the
52  * listitem may be shown in a list widget.
53  * 
54  * 3. [signal@Gtk.SignalListItemFactory::unbind] is emitted to undo everything
55  * done in step 2. Usually this means disconnecting signal handlers. Once this
56  * signal has been called, the listitem will no longer be used in a list
57  * widget.
58  * 
59  * 4. [signal@Gtk.SignalListItemFactory::bind] and
60  * [signal@Gtk.SignalListItemFactory::unbind] may be emitted multiple times
61  * again to bind the listitem for use with new items. By reusing listitems,
62  * potentially costly setup can be avoided. However, it means code needs to
63  * make sure to properly clean up the listitem in step 3 so that no information
64  * from the previous use leaks into the next use.
65  * 
66  * 5. [signal@Gtk.SignalListItemFactory::teardown] is emitted to allow undoing
67  * the effects of [signal@Gtk.SignalListItemFactory::setup]. After this signal
68  * was emitted on a listitem, the listitem will be destroyed and not be used again.
69  * 
70  * Note that during the signal emissions, changing properties on the
71  * #GtkListItems passed will not trigger notify signals as the listitem's
72  * notifications are frozen. See g_object_freeze_notify() for details.
73  * 
74  * For tracking changes in other properties in the `GtkListItem`, the
75  * ::notify signal is recommended. The signal can be connected in the
76  * [signal@Gtk.SignalListItemFactory::setup] signal and removed again during
77  * [signal@Gtk.SignalListItemFactory::teardown].
78  */
79 public class SignalListItemFactory : ListItemFactory
80 {
81 	/** the main Gtk struct */
82 	protected GtkSignalListItemFactory* gtkSignalListItemFactory;
83 
84 	/** Get the main Gtk struct */
85 	public GtkSignalListItemFactory* getSignalListItemFactoryStruct(bool transferOwnership = false)
86 	{
87 		if (transferOwnership)
88 			ownedRef = false;
89 		return gtkSignalListItemFactory;
90 	}
91 
92 	/** the main Gtk struct as a void* */
93 	protected override void* getStruct()
94 	{
95 		return cast(void*)gtkSignalListItemFactory;
96 	}
97 
98 	/**
99 	 * Sets our main struct and passes it to the parent class.
100 	 */
101 	public this (GtkSignalListItemFactory* gtkSignalListItemFactory, bool ownedRef = false)
102 	{
103 		this.gtkSignalListItemFactory = gtkSignalListItemFactory;
104 		super(cast(GtkListItemFactory*)gtkSignalListItemFactory, ownedRef);
105 	}
106 
107 
108 	/** */
109 	public static GType getType()
110 	{
111 		return gtk_signal_list_item_factory_get_type();
112 	}
113 
114 	/**
115 	 * Creates a new `GtkSignalListItemFactory`.
116 	 *
117 	 * You need to connect signal handlers before you use it.
118 	 *
119 	 * Returns: a new `GtkSignalListItemFactory`
120 	 *
121 	 * Throws: ConstructionException GTK+ fails to create the object.
122 	 */
123 	public this()
124 	{
125 		auto __p = gtk_signal_list_item_factory_new();
126 
127 		if(__p is null)
128 		{
129 			throw new ConstructionException("null returned by new");
130 		}
131 
132 		this(cast(GtkSignalListItemFactory*) __p, true);
133 	}
134 
135 	/**
136 	 * Emitted when a new [property@Gtk.ListItem:item] has been set
137 	 * on the @listitem and should be bound for use.
138 	 *
139 	 * After this signal was emitted, the listitem might be shown in
140 	 * a [class@Gtk.ListView] or other list widget.
141 	 *
142 	 * The [signal@Gtk.SignalListItemFactory::unbind] signal is the
143 	 * opposite of this signal and can be used to undo everything done
144 	 * in this signal.
145 	 *
146 	 * Params:
147 	 *     listitem = The #GtkListItem to bind
148 	 */
149 	gulong addOnBind(void delegate(ListItem, SignalListItemFactory) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
150 	{
151 		return Signals.connect(this, "bind", dlg, connectFlags ^ ConnectFlags.SWAPPED);
152 	}
153 
154 	/**
155 	 * Emitted when a new listitem has been created and needs to be setup for use.
156 	 *
157 	 * It is the first signal emitted for every listitem.
158 	 *
159 	 * The [signal@Gtk.SignalListItemFactory::teardown] signal is the opposite
160 	 * of this signal and can be used to undo everything done in this signal.
161 	 *
162 	 * Params:
163 	 *     listitem = The #GtkListItem to set up
164 	 */
165 	gulong addOnSetup(void delegate(ListItem, SignalListItemFactory) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
166 	{
167 		return Signals.connect(this, "setup", dlg, connectFlags ^ ConnectFlags.SWAPPED);
168 	}
169 
170 	/**
171 	 * Emitted when a listitem is about to be destroyed.
172 	 *
173 	 * It is the last signal ever emitted for this @listitem.
174 	 *
175 	 * This signal is the opposite of the [signal@Gtk.SignalListItemFactory::setup]
176 	 * signal and should be used to undo everything done in that signal.
177 	 *
178 	 * Params:
179 	 *     listitem = The #GtkListItem to teardown
180 	 */
181 	gulong addOnTeardown(void delegate(ListItem, SignalListItemFactory) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
182 	{
183 		return Signals.connect(this, "teardown", dlg, connectFlags ^ ConnectFlags.SWAPPED);
184 	}
185 
186 	/**
187 	 * Emitted when a listitem has been removed from use in a list widget
188 	 * and its new [property@Gtk.ListItem:item] is about to be unset.
189 	 *
190 	 * This signal is the opposite of the [signal@Gtk.SignalListItemFactory::bind]
191 	 * signal and should be used to undo everything done in that signal.
192 	 *
193 	 * Params:
194 	 *     listitem = The #GtkListItem to unbind
195 	 */
196 	gulong addOnUnbind(void delegate(ListItem, SignalListItemFactory) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
197 	{
198 		return Signals.connect(this, "unbind", dlg, connectFlags ^ ConnectFlags.SWAPPED);
199 	}
200 }