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.ContainerClass;
26 
27 private import glib.Str;
28 private import gobject.ObjectG;
29 private import gobject.ParamSpec;
30 private import gtk.c.functions;
31 public  import gtk.c.types;
32 public  import gtkc.gtktypes;
33 
34 
35 /**
36  * Base class for containers.
37  */
38 public class ContainerClass
39 {
40 	/** the main Gtk struct */
41 	protected GtkContainerClass* gtkContainerClass;
42 	protected bool ownedRef;
43 
44 	/** Get the main Gtk struct */
45 	public GtkContainerClass* getContainerClassStruct(bool transferOwnership = false)
46 	{
47 		if (transferOwnership)
48 			ownedRef = false;
49 		return gtkContainerClass;
50 	}
51 
52 	/** the main Gtk struct as a void* */
53 	protected void* getStruct()
54 	{
55 		return cast(void*)gtkContainerClass;
56 	}
57 
58 	/**
59 	 * Sets our main struct and passes it to the parent class.
60 	 */
61 	public this (GtkContainerClass* gtkContainerClass, bool ownedRef = false)
62 	{
63 		this.gtkContainerClass = gtkContainerClass;
64 		this.ownedRef = ownedRef;
65 	}
66 
67 
68 	/**
69 	 * Finds a child property of a container class by name.
70 	 *
71 	 * Params:
72 	 *     propertyName = the name of the child property to find
73 	 *
74 	 * Returns: the #GParamSpec of the child
75 	 *     property or %NULL if @class has no child property with that
76 	 *     name.
77 	 */
78 	public ParamSpec findChildProperty(string propertyName)
79 	{
80 		auto p = gtk_container_class_find_child_property(cast(GObjectClass*)gtkContainerClass, Str.toStringz(propertyName));
81 
82 		if(p is null)
83 		{
84 			return null;
85 		}
86 
87 		return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p);
88 	}
89 
90 	/**
91 	 * Modifies a subclass of #GtkContainerClass to automatically add and
92 	 * remove the border-width setting on GtkContainer.  This allows the
93 	 * subclass to ignore the border width in its size request and
94 	 * allocate methods. The intent is for a subclass to invoke this
95 	 * in its class_init function.
96 	 *
97 	 * gtk_container_class_handle_border_width() is necessary because it
98 	 * would break API too badly to make this behavior the default. So
99 	 * subclasses must “opt in” to the parent class handling border_width
100 	 * for them.
101 	 */
102 	public void handleBorderWidth()
103 	{
104 		gtk_container_class_handle_border_width(gtkContainerClass);
105 	}
106 
107 	/**
108 	 * Installs child properties on a container class.
109 	 *
110 	 * Params:
111 	 *     pspecs = the #GParamSpec array defining the new
112 	 *         child properties
113 	 *
114 	 * Since: 3.18
115 	 */
116 	public void installChildProperties(ParamSpec[] pspecs)
117 	{
118 		GParamSpec*[] pspecsArray = new GParamSpec*[pspecs.length];
119 		for ( int i = 0; i < pspecs.length; i++ )
120 		{
121 			pspecsArray[i] = pspecs[i].getParamSpecStruct();
122 		}
123 
124 		gtk_container_class_install_child_properties(gtkContainerClass, cast(uint)pspecs.length, pspecsArray.ptr);
125 	}
126 
127 	/**
128 	 * Installs a child property on a container class.
129 	 *
130 	 * Params:
131 	 *     propertyId = the id for the property
132 	 *     pspec = the #GParamSpec for the property
133 	 */
134 	public void installChildProperty(uint propertyId, ParamSpec pspec)
135 	{
136 		gtk_container_class_install_child_property(gtkContainerClass, propertyId, (pspec is null) ? null : pspec.getParamSpecStruct());
137 	}
138 
139 	/**
140 	 * Returns all child properties of a container class.
141 	 *
142 	 * Returns: a newly allocated %NULL-terminated array of #GParamSpec*.
143 	 *     The array must be freed with g_free().
144 	 */
145 	public ParamSpec[] listChildProperties()
146 	{
147 		uint nProperties;
148 
149 		auto p = gtk_container_class_list_child_properties(cast(GObjectClass*)gtkContainerClass, &nProperties);
150 
151 		if(p is null)
152 		{
153 			return null;
154 		}
155 
156 		ParamSpec[] arr = new ParamSpec[nProperties];
157 		for(int i = 0; i < nProperties; i++)
158 		{
159 			arr[i] = ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p[i]);
160 		}
161 
162 		return arr;
163 	}
164 }