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.BuilderListItemFactory;
26 
27 private import glib.Bytes;
28 private import glib.ConstructionException;
29 private import glib.Str;
30 private import glib.c.functions;
31 private import gobject.ObjectG;
32 private import gtk.BuilderScopeIF;
33 private import gtk.ListItemFactory;
34 private import gtk.c.functions;
35 public  import gtk.c.types;
36 
37 
38 /**
39  * `GtkBuilderListItemFactory` is a `GtkListItemFactory` that creates
40  * widgets by instantiating `GtkBuilder` UI templates.
41  * 
42  * The templates must be extending `GtkListItem`, and typically use
43  * `GtkExpression`s to obtain data from the items in the model.
44  * 
45  * Example:
46  * ```xml
47  * <interface>
48  * <template class="GtkListItem">
49  * <property name="child">
50  * <object class="GtkLabel">
51  * <property name="xalign">0</property>
52  * <binding name="label">
53  * <lookup name="name" type="SettingsKey">
54  * <lookup name="item">GtkListItem</lookup>
55  * </lookup>
56  * </binding>
57  * </object>
58  * </property>
59  * </template>
60  * </interface>
61  * ```
62  */
63 public class BuilderListItemFactory : ListItemFactory
64 {
65 	/** the main Gtk struct */
66 	protected GtkBuilderListItemFactory* gtkBuilderListItemFactory;
67 
68 	/** Get the main Gtk struct */
69 	public GtkBuilderListItemFactory* getBuilderListItemFactoryStruct(bool transferOwnership = false)
70 	{
71 		if (transferOwnership)
72 			ownedRef = false;
73 		return gtkBuilderListItemFactory;
74 	}
75 
76 	/** the main Gtk struct as a void* */
77 	protected override void* getStruct()
78 	{
79 		return cast(void*)gtkBuilderListItemFactory;
80 	}
81 
82 	/**
83 	 * Sets our main struct and passes it to the parent class.
84 	 */
85 	public this (GtkBuilderListItemFactory* gtkBuilderListItemFactory, bool ownedRef = false)
86 	{
87 		this.gtkBuilderListItemFactory = gtkBuilderListItemFactory;
88 		super(cast(GtkListItemFactory*)gtkBuilderListItemFactory, ownedRef);
89 	}
90 
91 
92 	/** */
93 	public static GType getType()
94 	{
95 		return gtk_builder_list_item_factory_get_type();
96 	}
97 
98 	/**
99 	 * Creates a new `GtkBuilderListItemFactory` that instantiates widgets
100 	 * using @bytes as the data to pass to `GtkBuilder`.
101 	 *
102 	 * Params:
103 	 *     scope_ = A scope to use when instantiating
104 	 *     bytes = the `GBytes` containing the ui file to instantiate
105 	 *
106 	 * Returns: a new `GtkBuilderListItemFactory`
107 	 *
108 	 * Throws: ConstructionException GTK+ fails to create the object.
109 	 */
110 	public this(BuilderScopeIF scope_, Bytes bytes)
111 	{
112 		auto __p = gtk_builder_list_item_factory_new_from_bytes((scope_ is null) ? null : scope_.getBuilderScopeStruct(), (bytes is null) ? null : bytes.getBytesStruct());
113 
114 		if(__p is null)
115 		{
116 			throw new ConstructionException("null returned by new_from_bytes");
117 		}
118 
119 		this(cast(GtkBuilderListItemFactory*) __p, true);
120 	}
121 
122 	/**
123 	 * Creates a new `GtkBuilderListItemFactory` that instantiates widgets
124 	 * using data read from the given @resource_path to pass to `GtkBuilder`.
125 	 *
126 	 * Params:
127 	 *     scope_ = A scope to use when instantiating
128 	 *     resourcePath = valid path to a resource that contains the data
129 	 *
130 	 * Returns: a new `GtkBuilderListItemFactory`
131 	 *
132 	 * Throws: ConstructionException GTK+ fails to create the object.
133 	 */
134 	public this(BuilderScopeIF scope_, string resourcePath)
135 	{
136 		auto __p = gtk_builder_list_item_factory_new_from_resource((scope_ is null) ? null : scope_.getBuilderScopeStruct(), Str.toStringz(resourcePath));
137 
138 		if(__p is null)
139 		{
140 			throw new ConstructionException("null returned by new_from_resource");
141 		}
142 
143 		this(cast(GtkBuilderListItemFactory*) __p, true);
144 	}
145 
146 	/**
147 	 * Gets the data used as the `GtkBuilder` UI template for constructing
148 	 * listitems.
149 	 *
150 	 * Returns: The `GtkBuilder` data
151 	 */
152 	public Bytes getBytes()
153 	{
154 		auto __p = gtk_builder_list_item_factory_get_bytes(gtkBuilderListItemFactory);
155 
156 		if(__p is null)
157 		{
158 			return null;
159 		}
160 
161 		return new Bytes(cast(GBytes*) __p);
162 	}
163 
164 	/**
165 	 * If the data references a resource, gets the path of that resource.
166 	 *
167 	 * Returns: The path to the resource or %NULL
168 	 *     if none
169 	 */
170 	public string getResource()
171 	{
172 		return Str.toString(gtk_builder_list_item_factory_get_resource(gtkBuilderListItemFactory));
173 	}
174 
175 	/**
176 	 * Gets the scope used when constructing listitems.
177 	 *
178 	 * Returns: The scope used when constructing listitems
179 	 */
180 	public BuilderScopeIF getScope()
181 	{
182 		auto __p = gtk_builder_list_item_factory_get_scope(gtkBuilderListItemFactory);
183 
184 		if(__p is null)
185 		{
186 			return null;
187 		}
188 
189 		return ObjectG.getDObject!(BuilderScopeIF)(cast(GtkBuilderScope*) __p);
190 	}
191 }