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