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.WidgetClass; 26 27 private import glib.Bytes; 28 private import glib.Str; 29 private import gobject.ObjectG; 30 private import gobject.ParamSpec; 31 private import gtkc.gtk; 32 public import gtkc.gtktypes; 33 34 35 /** */ 36 public class WidgetClass 37 { 38 /** the main Gtk struct */ 39 protected GtkWidgetClass* gtkWidgetClass; 40 41 /** Get the main Gtk struct */ 42 public GtkWidgetClass* getWidgetClassStruct() 43 { 44 return gtkWidgetClass; 45 } 46 47 /** the main Gtk struct as a void* */ 48 protected void* getStruct() 49 { 50 return cast(void*)gtkWidgetClass; 51 } 52 53 /** 54 * Sets our main struct and passes it to the parent class. 55 */ 56 public this (GtkWidgetClass* gtkWidgetClass) 57 { 58 this.gtkWidgetClass = gtkWidgetClass; 59 } 60 61 62 /** 63 * Declares a @callback_symbol to handle @callback_name from the template XML 64 * defined for @widget_type. See gtk_builder_add_callback_symbol(). 65 * 66 * Note that this must be called from a composite widget classes class 67 * initializer after calling gtk_widget_class_set_template(). 68 * 69 * Params: 70 * callbackName = The name of the callback as expected in the template XML 71 * callbackSymbol = The callback symbol 72 * 73 * Since: 3.10 74 */ 75 public void bindTemplateCallbackFull(string callbackName, GCallback callbackSymbol) 76 { 77 gtk_widget_class_bind_template_callback_full(gtkWidgetClass, Str.toStringz(callbackName), callbackSymbol); 78 } 79 80 /** 81 * Automatically assign an object declared in the class template XML to be set to a location 82 * on a freshly built instance’s private data, or alternatively accessible via gtk_widget_get_template_child(). 83 * 84 * The struct can point either into the public instance, then you should use G_STRUCT_OFFSET(WidgetType, member) 85 * for @struct_offset, or in the private struct, then you should use G_PRIVATE_OFFSET(WidgetType, member). 86 * 87 * An explicit strong reference will be held automatically for the duration of your 88 * instance’s life cycle, it will be released automatically when #GObjectClass.dispose() runs 89 * on your instance and if a @struct_offset that is != 0 is specified, then the automatic location 90 * in your instance public or private data will be set to %NULL. You can however access an automated child 91 * pointer the first time your classes #GObjectClass.dispose() runs, or alternatively in 92 * #GtkWidgetClass.destroy(). 93 * 94 * If @internal_child is specified, #GtkBuildableIface.get_internal_child() will be automatically 95 * implemented by the #GtkWidget class so there is no need to implement it manually. 96 * 97 * The wrapper macros gtk_widget_class_bind_template_child(), gtk_widget_class_bind_template_child_internal(), 98 * gtk_widget_class_bind_template_child_private() and gtk_widget_class_bind_template_child_internal_private() 99 * might be more convenient to use. 100 * 101 * Note that this must be called from a composite widget classes class 102 * initializer after calling gtk_widget_class_set_template(). 103 * 104 * Params: 105 * name = The “id” of the child defined in the template XML 106 * internalChild = Whether the child should be accessible as an “internal-child” 107 * when this class is used in GtkBuilder XML 108 * structOffset = The structure offset into the composite widget’s instance public or private structure 109 * where the automated child pointer should be set, or 0 to not assign the pointer. 110 * 111 * Since: 3.10 112 */ 113 public void bindTemplateChildFull(string name, bool internalChild, ptrdiff_t structOffset) 114 { 115 gtk_widget_class_bind_template_child_full(gtkWidgetClass, Str.toStringz(name), internalChild, structOffset); 116 } 117 118 /** 119 * Finds a style property of a widget class by name. 120 * 121 * Params: 122 * propertyName = the name of the style property to find 123 * 124 * Return: the #GParamSpec of the style property or 125 * %NULL if @class has no style property with that name. 126 * 127 * Since: 2.2 128 */ 129 public ParamSpec findStyleProperty(string propertyName) 130 { 131 auto p = gtk_widget_class_find_style_property(gtkWidgetClass, Str.toStringz(propertyName)); 132 133 if(p is null) 134 { 135 return null; 136 } 137 138 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p); 139 } 140 141 /** 142 * Installs a style property on a widget class. The parser for the 143 * style property is determined by the value type of @pspec. 144 * 145 * Params: 146 * pspec = the #GParamSpec for the property 147 */ 148 public void installStyleProperty(ParamSpec pspec) 149 { 150 gtk_widget_class_install_style_property(gtkWidgetClass, (pspec is null) ? null : pspec.getParamSpecStruct()); 151 } 152 153 /** 154 * Installs a style property on a widget class. 155 * 156 * Params: 157 * pspec = the #GParamSpec for the style property 158 * parser = the parser for the style property 159 */ 160 public void installStylePropertyParser(ParamSpec pspec, GtkRcPropertyParser parser) 161 { 162 gtk_widget_class_install_style_property_parser(gtkWidgetClass, (pspec is null) ? null : pspec.getParamSpecStruct(), parser); 163 } 164 165 /** 166 * Returns all style properties of a widget class. 167 * 168 * Return: a 169 * newly allocated array of #GParamSpec*. The array must be 170 * freed with g_free(). 171 * 172 * Since: 2.2 173 */ 174 public ParamSpec[] listStyleProperties() 175 { 176 uint nProperties; 177 178 auto p = gtk_widget_class_list_style_properties(gtkWidgetClass, &nProperties); 179 180 if(p is null) 181 { 182 return null; 183 } 184 185 ParamSpec[] arr = new ParamSpec[nProperties]; 186 for(int i = 0; i < nProperties; i++) 187 { 188 arr[i] = ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p[i]); 189 } 190 191 return arr; 192 } 193 194 /** 195 * Sets the default #AtkRole to be set on accessibles created for 196 * widgets of @widget_class. Accessibles may decide to not honor this 197 * setting if their role reporting is more refined. Calls to 198 * gtk_widget_class_set_accessible_type() will reset this value. 199 * 200 * In cases where you want more fine-grained control over the role of 201 * accessibles created for @widget_class, you should provide your own 202 * accessible type and use gtk_widget_class_set_accessible_type() 203 * instead. 204 * 205 * If @role is #ATK_ROLE_INVALID, the default role will not be changed 206 * and the accessible’s default role will be used instead. 207 * 208 * This function should only be called from class init functions of widgets. 209 * 210 * Params: 211 * role = The role to use for accessibles created for @widget_class 212 * 213 * Since: 3.2 214 */ 215 public void setAccessibleRole(AtkRole role) 216 { 217 gtk_widget_class_set_accessible_role(gtkWidgetClass, role); 218 } 219 220 /** 221 * Sets the type to be used for creating accessibles for widgets of 222 * @widget_class. The given @type must be a subtype of the type used for 223 * accessibles of the parent class. 224 * 225 * This function should only be called from class init functions of widgets. 226 * 227 * Params: 228 * type = The object type that implements the accessible for @widget_class 229 * 230 * Since: 3.2 231 */ 232 public void setAccessibleType(GType type) 233 { 234 gtk_widget_class_set_accessible_type(gtkWidgetClass, type); 235 } 236 237 /** 238 * For use in language bindings, this will override the default #GtkBuilderConnectFunc to be 239 * used when parsing GtkBuilder XML from this class’s template data. 240 * 241 * Note that this must be called from a composite widget classes class 242 * initializer after calling gtk_widget_class_set_template(). 243 * 244 * Params: 245 * connectFunc = The #GtkBuilderConnectFunc to use when connecting signals in the class template 246 * connectData = The data to pass to @connect_func 247 * connectDataDestroy = The #GDestroyNotify to free @connect_data, this will only be used at 248 * class finalization time, when no classes of type @widget_type are in use anymore. 249 * 250 * Since: 3.10 251 */ 252 public void setConnectFunc(GtkBuilderConnectFunc connectFunc, void* connectData, GDestroyNotify connectDataDestroy) 253 { 254 gtk_widget_class_set_connect_func(gtkWidgetClass, connectFunc, connectData, connectDataDestroy); 255 } 256 257 /** 258 * This should be called at class initialization time to specify 259 * the GtkBuilder XML to be used to extend a widget. 260 * 261 * For convenience, gtk_widget_class_set_template_from_resource() is also provided. 262 * 263 * Note that any class that installs templates must call gtk_widget_init_template() 264 * in the widget’s instance initializer. 265 * 266 * Params: 267 * templateBytes = A #GBytes holding the #GtkBuilder XML 268 * 269 * Since: 3.10 270 */ 271 public void setTemplate(Bytes templateBytes) 272 { 273 gtk_widget_class_set_template(gtkWidgetClass, (templateBytes is null) ? null : templateBytes.getBytesStruct()); 274 } 275 276 /** 277 * A convenience function to call gtk_widget_class_set_template(). 278 * 279 * Note that any class that installs templates must call gtk_widget_init_template() 280 * in the widget’s instance initializer. 281 * 282 * Params: 283 * resourceName = The name of the resource to load the template from 284 * 285 * Since: 3.10 286 */ 287 public void setTemplateFromResource(string resourceName) 288 { 289 gtk_widget_class_set_template_from_resource(gtkWidgetClass, Str.toStringz(resourceName)); 290 } 291 }