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