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 * Conversion parameters: 26 * inFile = gtk3-GtkWidgetPath.html 27 * outPack = gtk 28 * outFile = WidgetPath 29 * strct = GtkWidgetPath 30 * realStrct= 31 * ctorStrct= 32 * clss = WidgetPath 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_widget_path_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * - glib.ListSG 48 * - gtk.Widget 49 * - gtkc.Loader 50 * - gtkc.paths 51 * structWrap: 52 * - GSList* -> ListSG 53 * - GtkWidget* -> Widget 54 * - GtkWidgetPath* -> WidgetPath 55 * module aliases: 56 * local aliases: 57 * overrides: 58 * - toString 59 */ 60 61 module gtk.WidgetPath; 62 63 public import gtkc.gtktypes; 64 65 private import gtkc.gtk; 66 private import glib.ConstructionException; 67 private import gobject.ObjectG; 68 69 private import glib.Str; 70 private import glib.ListSG; 71 private import gtk.Widget; 72 private import gtkc.Loader; 73 private import gtkc.paths; 74 75 76 77 /** 78 * GtkWidgetPath is a boxed type that represents a widget hierarchy from 79 * the topmost widget, typically a toplevel, to any child. This widget 80 * path abstraction is used in GtkStyleContext on behalf of the real 81 * widget in order to query style information. 82 * 83 * If you are using GTK+ widgets, you probably will not need to use 84 * this API directly, as there is gtk_widget_get_path(), and the style 85 * context returned by gtk_widget_get_style_context() will be automatically 86 * updated on widget hierarchy changes. 87 * 88 * The widget path generation is generally simple: 89 * 90 * $(DDOC_COMMENT example) 91 * 92 * Although more complex information, such as widget names, or 93 * different classes (property that may be used by other widget 94 * types) and intermediate regions may be included: 95 * 96 * $(DDOC_COMMENT example) 97 * 98 * All this information will be used to match the style information 99 * that applies to the described widget. 100 */ 101 public class WidgetPath 102 { 103 104 /** the main Gtk struct */ 105 protected GtkWidgetPath* gtkWidgetPath; 106 107 108 /** Get the main Gtk struct */ 109 public GtkWidgetPath* getWidgetPathStruct() 110 { 111 return gtkWidgetPath; 112 } 113 114 115 /** the main Gtk struct as a void* */ 116 protected void* getStruct() 117 { 118 return cast(void*)gtkWidgetPath; 119 } 120 121 /** 122 * Sets our main struct and passes it to the parent class 123 */ 124 public this (GtkWidgetPath* gtkWidgetPath) 125 { 126 this.gtkWidgetPath = gtkWidgetPath; 127 } 128 129 ~this () 130 { 131 if ( Linker.isLoaded(LIBRARY.GTK) && gtkWidgetPath !is null ) 132 { 133 gtk_widget_path_free(gtkWidgetPath); 134 } 135 } 136 137 /** 138 */ 139 140 /** 141 * Appends a widget type to the widget hierarchy represented by path. 142 * Params: 143 * type = widget type to append 144 * Returns: the position where the element was inserted Since 3.0 145 */ 146 public int appendType(GType type) 147 { 148 // gint gtk_widget_path_append_type (GtkWidgetPath *path, GType type); 149 return gtk_widget_path_append_type(gtkWidgetPath, type); 150 } 151 152 /** 153 * Appends a widget type with all its siblings to the widget hierarchy 154 * represented by path. Using this function instead of 155 * gtk_widget_path_append_type() will allow the CSS theming to use 156 * sibling matches in selectors and apply :nth-child() pseudo classes. 157 * In turn, it requires a lot more care in widget implementations as 158 * widgets need to make sure to call gtk_widget_reset_style() on all 159 * involved widgets when the siblings path changes. 160 * Params: 161 * siblings = a widget path describing a list of siblings. This path 162 * may not contain any siblings itself and it must not be modified 163 * afterwards. 164 * siblingIndex = index into siblings for where the added element is 165 * positioned. 166 * Returns: the position where the element was inserted. Since 3.2 167 */ 168 public int appendWithSiblings(WidgetPath siblings, uint siblingIndex) 169 { 170 // gint gtk_widget_path_append_with_siblings (GtkWidgetPath *path, GtkWidgetPath *siblings, guint sibling_index); 171 return gtk_widget_path_append_with_siblings(gtkWidgetPath, (siblings is null) ? null : siblings.getWidgetPathStruct(), siblingIndex); 172 } 173 174 /** 175 * Appends the data from widget to the widget hierarchy represented 176 * by path. This function is a shortcut for adding information from 177 * widget to the given path. This includes setting the name or 178 * adding the style classes from widget. 179 * Params: 180 * widget = the widget to append to the widget path 181 * Returns: the position where the data was inserted Since 3.2 182 */ 183 public int appendForWidget(Widget widget) 184 { 185 // gint gtk_widget_path_append_for_widget (GtkWidgetPath *path, GtkWidget *widget); 186 return gtk_widget_path_append_for_widget(gtkWidgetPath, (widget is null) ? null : widget.getWidgetStruct()); 187 } 188 189 /** 190 * Returns a copy of path 191 * Returns: a copy of path. [transfer full] Since 3.0 192 */ 193 public WidgetPath copy() 194 { 195 // GtkWidgetPath * gtk_widget_path_copy (const GtkWidgetPath *path); 196 auto p = gtk_widget_path_copy(gtkWidgetPath); 197 198 if(p is null) 199 { 200 return null; 201 } 202 203 return ObjectG.getDObject!(WidgetPath)(cast(GtkWidgetPath*) p); 204 } 205 206 /** 207 * Increments the reference count on path. 208 * Returns: path itself. Since 3.2 209 */ 210 public WidgetPath doref() 211 { 212 // GtkWidgetPath * gtk_widget_path_ref (GtkWidgetPath *path); 213 auto p = gtk_widget_path_ref(gtkWidgetPath); 214 215 if(p is null) 216 { 217 return null; 218 } 219 220 return ObjectG.getDObject!(WidgetPath)(cast(GtkWidgetPath*) p); 221 } 222 223 /** 224 * Decrements the reference count on path, freeing the structure 225 * if the reference count reaches 0. 226 */ 227 public void unref() 228 { 229 // void gtk_widget_path_unref (GtkWidgetPath *path); 230 gtk_widget_path_unref(gtkWidgetPath); 231 } 232 233 /** 234 * Decrements the reference count on path, freeing the structure 235 * if the reference count reaches 0. 236 */ 237 public void free() 238 { 239 // void gtk_widget_path_free (GtkWidgetPath *path); 240 gtk_widget_path_free(gtkWidgetPath); 241 } 242 243 /** 244 * Returns the topmost object type, that is, the object type this path 245 * is representing. 246 * Returns: The object type Since 3.0 247 */ 248 public GType getObjectType() 249 { 250 // GType gtk_widget_path_get_object_type (const GtkWidgetPath *path); 251 return gtk_widget_path_get_object_type(gtkWidgetPath); 252 } 253 254 /** 255 * Returns TRUE if any of the parents of the widget represented 256 * in path is of type type, or any subtype of it. 257 * Params: 258 * type = widget type to check in parents 259 * Returns: TRUE if any parent is of type type Since 3.0 260 */ 261 public int hasParent(GType type) 262 { 263 // gboolean gtk_widget_path_has_parent (const GtkWidgetPath *path, GType type); 264 return gtk_widget_path_has_parent(gtkWidgetPath, type); 265 } 266 267 /** 268 * Returns TRUE if the widget type represented by this path 269 * is type, or a subtype of it. 270 * Params: 271 * type = widget type to match 272 * Returns: TRUE if the widget represented by path is of type type Since 3.0 273 */ 274 public int isType(GType type) 275 { 276 // gboolean gtk_widget_path_is_type (const GtkWidgetPath *path, GType type); 277 return gtk_widget_path_is_type(gtkWidgetPath, type); 278 } 279 280 /** 281 * Adds the class name to the widget at position pos in 282 * the hierarchy defined in path. See 283 * gtk_style_context_add_class(). 284 * Params: 285 * pos = position to modify, -1 for the path head 286 * name = a class name 287 * Since 3.0 288 */ 289 public void iterAddClass(int pos, string name) 290 { 291 // void gtk_widget_path_iter_add_class (GtkWidgetPath *path, gint pos, const gchar *name); 292 gtk_widget_path_iter_add_class(gtkWidgetPath, pos, Str.toStringz(name)); 293 } 294 295 /** 296 * Adds the region name to the widget at position pos in 297 * the hierarchy defined in path. See 298 * gtk_style_context_add_region(). 299 * Note 300 * Region names must only contain lowercase letters 301 * and '-', starting always with a lowercase letter. 302 * Params: 303 * pos = position to modify, -1 for the path head 304 * name = region name 305 * flags = flags affecting the region 306 * Since 3.0 307 */ 308 public void iterAddRegion(int pos, string name, GtkRegionFlags flags) 309 { 310 // void gtk_widget_path_iter_add_region (GtkWidgetPath *path, gint pos, const gchar *name, GtkRegionFlags flags); 311 gtk_widget_path_iter_add_region(gtkWidgetPath, pos, Str.toStringz(name), flags); 312 } 313 314 /** 315 * Removes all classes from the widget at position pos in the 316 * hierarchy defined in path. 317 * Params: 318 * pos = position to modify, -1 for the path head 319 * Since 3.0 320 */ 321 public void iterClearClasses(int pos) 322 { 323 // void gtk_widget_path_iter_clear_classes (GtkWidgetPath *path, gint pos); 324 gtk_widget_path_iter_clear_classes(gtkWidgetPath, pos); 325 } 326 327 /** 328 * Removes all regions from the widget at position pos in the 329 * hierarchy defined in path. 330 * Params: 331 * pos = position to modify, -1 for the path head 332 * Since 3.0 333 */ 334 public void iterClearRegions(int pos) 335 { 336 // void gtk_widget_path_iter_clear_regions (GtkWidgetPath *path, gint pos); 337 gtk_widget_path_iter_clear_regions(gtkWidgetPath, pos); 338 } 339 340 /** 341 * Returns the name corresponding to the widget found at 342 * the position pos in the widget hierarchy defined by 343 * path 344 * Params: 345 * pos = position to get the widget name for, -1 for the path head 346 * Returns: The widget name, or NULL if none was set. 347 */ 348 public string iterGetName(int pos) 349 { 350 // const gchar * gtk_widget_path_iter_get_name (const GtkWidgetPath *path, gint pos); 351 return Str.toString(gtk_widget_path_iter_get_name(gtkWidgetPath, pos)); 352 } 353 354 /** 355 * Returns the object GType that is at position pos in the widget 356 * hierarchy defined in path. 357 * Params: 358 * pos = position to get the object type for, -1 for the path head 359 * Returns: a widget type Since 3.0 360 */ 361 public GType iterGetObjectType(int pos) 362 { 363 // GType gtk_widget_path_iter_get_object_type (const GtkWidgetPath *path, gint pos); 364 return gtk_widget_path_iter_get_object_type(gtkWidgetPath, pos); 365 } 366 367 /** 368 * Returns the list of siblings for the element at pos. If the element 369 * was not added with siblings, NULL is returned. 370 * Params: 371 * pos = position to get the siblings for, -1 for the path head 372 * Returns: NULL or the list of siblings for the element at pos. 373 */ 374 public WidgetPath iterGetSiblings(int pos) 375 { 376 // const GtkWidgetPath * gtk_widget_path_iter_get_siblings (const GtkWidgetPath *path, gint pos); 377 auto p = gtk_widget_path_iter_get_siblings(gtkWidgetPath, pos); 378 379 if(p is null) 380 { 381 return null; 382 } 383 384 return ObjectG.getDObject!(WidgetPath)(cast(GtkWidgetPath*) p); 385 } 386 387 /** 388 * Returns the index into the list of siblings for the element at pos as 389 * returned by gtk_widget_path_iter_get_siblings(). If that function would 390 * return NULL because the element at pos has no siblings, this function 391 * will return 0. 392 * Params: 393 * pos = position to get the sibling index for, -1 for the path head 394 * Returns: 0 or the index into the list of siblings for the element at pos. 395 */ 396 public uint iterGetSiblingIndex(int pos) 397 { 398 // guint gtk_widget_path_iter_get_sibling_index (const GtkWidgetPath *path, gint pos); 399 return gtk_widget_path_iter_get_sibling_index(gtkWidgetPath, pos); 400 } 401 402 /** 403 * Returns TRUE if the widget at position pos has the class name 404 * defined, FALSE otherwise. 405 * Params: 406 * pos = position to query, -1 for the path head 407 * name = class name 408 * Returns: TRUE if the class name is defined for the widget at pos Since 3.0 409 */ 410 public int iterHasClass(int pos, string name) 411 { 412 // gboolean gtk_widget_path_iter_has_class (const GtkWidgetPath *path, gint pos, const gchar *name); 413 return gtk_widget_path_iter_has_class(gtkWidgetPath, pos, Str.toStringz(name)); 414 } 415 416 /** 417 * Returns TRUE if the widget at position pos has the name name, 418 * FALSE otherwise. 419 * Params: 420 * pos = position to query, -1 for the path head 421 * name = a widget name 422 * Returns: TRUE if the widget at pos has this name Since 3.0 423 */ 424 public int iterHasName(int pos, string name) 425 { 426 // gboolean gtk_widget_path_iter_has_name (const GtkWidgetPath *path, gint pos, const gchar *name); 427 return gtk_widget_path_iter_has_name(gtkWidgetPath, pos, Str.toStringz(name)); 428 } 429 430 /** 431 * See gtk_widget_path_iter_has_class(). This is a version that operates 432 * with GQuarks. 433 * Params: 434 * pos = position to query, -1 for the path head 435 * qname = class name as a GQuark 436 * Returns: TRUE if the widget at pos has the class defined. Since 3.0 437 */ 438 public int iterHasQclass(int pos, GQuark qname) 439 { 440 // gboolean gtk_widget_path_iter_has_qclass (const GtkWidgetPath *path, gint pos, GQuark qname); 441 return gtk_widget_path_iter_has_qclass(gtkWidgetPath, pos, qname); 442 } 443 444 /** 445 * See gtk_widget_path_iter_has_name(). This is a version 446 * that operates on GQuarks. 447 * Params: 448 * pos = position to query, -1 for the path head 449 * qname = widget name as a GQuark 450 * Returns: TRUE if the widget at pos has this name Since 3.0 451 */ 452 public int iterHasQname(int pos, GQuark qname) 453 { 454 // gboolean gtk_widget_path_iter_has_qname (const GtkWidgetPath *path, gint pos, GQuark qname); 455 return gtk_widget_path_iter_has_qname(gtkWidgetPath, pos, qname); 456 } 457 458 /** 459 * See gtk_widget_path_iter_has_region(). This is a version that operates 460 * with GQuarks. 461 * Params: 462 * pos = position to query, -1 for the path head 463 * qname = region name as a GQuark 464 * flags = return location for the region flags. [out] 465 * Returns: TRUE if the widget at pos has the region defined. Since 3.0 466 */ 467 public int iterHasQregion(int pos, GQuark qname, out GtkRegionFlags flags) 468 { 469 // gboolean gtk_widget_path_iter_has_qregion (const GtkWidgetPath *path, gint pos, GQuark qname, GtkRegionFlags *flags); 470 return gtk_widget_path_iter_has_qregion(gtkWidgetPath, pos, qname, &flags); 471 } 472 473 /** 474 * Returns TRUE if the widget at position pos has the class name 475 * defined, FALSE otherwise. 476 * Params: 477 * pos = position to query, -1 for the path head 478 * name = region name 479 * flags = return location for the region flags. [out] 480 * Returns: TRUE if the class name is defined for the widget at pos Since 3.0 481 */ 482 public int iterHasRegion(int pos, string name, out GtkRegionFlags flags) 483 { 484 // gboolean gtk_widget_path_iter_has_region (const GtkWidgetPath *path, gint pos, const gchar *name, GtkRegionFlags *flags); 485 return gtk_widget_path_iter_has_region(gtkWidgetPath, pos, Str.toStringz(name), &flags); 486 } 487 488 /** 489 * Returns a list with all the class names defined for the widget 490 * at position pos in the hierarchy defined in path. 491 * Params: 492 * pos = position to query, -1 for the path head 493 * Returns: The list of classes, This is a list of strings, the GSList contents are owned by GTK+, but you should use g_slist_free() to free the list itself. [transfer container][element-type utf8] Since 3.0 494 */ 495 public ListSG iterListClasses(int pos) 496 { 497 // GSList * gtk_widget_path_iter_list_classes (const GtkWidgetPath *path, gint pos); 498 auto p = gtk_widget_path_iter_list_classes(gtkWidgetPath, pos); 499 500 if(p is null) 501 { 502 return null; 503 } 504 505 return ObjectG.getDObject!(ListSG)(cast(GSList*) p); 506 } 507 508 /** 509 * Returns a list with all the region names defined for the widget 510 * at position pos in the hierarchy defined in path. 511 * Params: 512 * pos = position to query, -1 for the path head 513 * Returns: The list of regions, This is a list of strings, the GSList contents are owned by GTK+, but you should use g_slist_free() to free the list itself. [transfer container][element-type utf8] Since 3.0 514 */ 515 public ListSG iterListRegions(int pos) 516 { 517 // GSList * gtk_widget_path_iter_list_regions (const GtkWidgetPath *path, gint pos); 518 auto p = gtk_widget_path_iter_list_regions(gtkWidgetPath, pos); 519 520 if(p is null) 521 { 522 return null; 523 } 524 525 return ObjectG.getDObject!(ListSG)(cast(GSList*) p); 526 } 527 528 /** 529 * Removes the class name from the widget at position pos in 530 * the hierarchy defined in path. 531 * Params: 532 * pos = position to modify, -1 for the path head 533 * name = class name 534 * Since 3.0 535 */ 536 public void iterRemoveClass(int pos, string name) 537 { 538 // void gtk_widget_path_iter_remove_class (GtkWidgetPath *path, gint pos, const gchar *name); 539 gtk_widget_path_iter_remove_class(gtkWidgetPath, pos, Str.toStringz(name)); 540 } 541 542 /** 543 * Removes the region name from the widget at position pos in 544 * the hierarchy defined in path. 545 * Params: 546 * pos = position to modify, -1 for the path head 547 * name = region name 548 * Since 3.0 549 */ 550 public void iterRemoveRegion(int pos, string name) 551 { 552 // void gtk_widget_path_iter_remove_region (GtkWidgetPath *path, gint pos, const gchar *name); 553 gtk_widget_path_iter_remove_region(gtkWidgetPath, pos, Str.toStringz(name)); 554 } 555 556 /** 557 * Sets the widget name for the widget found at position pos 558 * in the widget hierarchy defined by path. 559 * Params: 560 * pos = position to modify, -1 for the path head 561 * name = widget name 562 * Since 3.0 563 */ 564 public void iterSetName(int pos, string name) 565 { 566 // void gtk_widget_path_iter_set_name (GtkWidgetPath *path, gint pos, const gchar *name); 567 gtk_widget_path_iter_set_name(gtkWidgetPath, pos, Str.toStringz(name)); 568 } 569 570 /** 571 * Sets the object type for a given position in the widget hierarchy 572 * defined by path. 573 * Params: 574 * pos = position to modify, -1 for the path head 575 * type = object type to set 576 * Since 3.0 577 */ 578 public void iterSetObjectType(int pos, GType type) 579 { 580 // void gtk_widget_path_iter_set_object_type (GtkWidgetPath *path, gint pos, GType type); 581 gtk_widget_path_iter_set_object_type(gtkWidgetPath, pos, type); 582 } 583 584 /** 585 * Returns the number of GtkWidget GTypes between the represented 586 * widget and its topmost container. 587 * Returns: the number of elements in the path Since 3.0 588 */ 589 public int length() 590 { 591 // gint gtk_widget_path_length (const GtkWidgetPath *path); 592 return gtk_widget_path_length(gtkWidgetPath); 593 } 594 595 /** 596 * Returns an empty widget path. 597 * Throws: ConstructionException GTK+ fails to create the object. 598 */ 599 public this () 600 { 601 // GtkWidgetPath * gtk_widget_path_new (void); 602 auto p = gtk_widget_path_new(); 603 if(p is null) 604 { 605 throw new ConstructionException("null returned by gtk_widget_path_new()"); 606 } 607 this(cast(GtkWidgetPath*) p); 608 } 609 610 /** 611 * Prepends a widget type to the widget hierachy represented by path. 612 * Params: 613 * type = widget type to prepend 614 * Since 3.0 615 */ 616 public void prependType(GType type) 617 { 618 // void gtk_widget_path_prepend_type (GtkWidgetPath *path, GType type); 619 gtk_widget_path_prepend_type(gtkWidgetPath, type); 620 } 621 622 /** 623 * Dumps the widget path into a string representation. It tries to match 624 * the CSS style as closely as possible (Note that there might be paths 625 * that cannot be represented in CSS). 626 * The main use of this code is for debugging purposes, so that you can 627 * g_print() the path or dump it in a gdb session. 628 * Returns: A new string describing path. Since 3.2 629 */ 630 public override string toString() 631 { 632 // char * gtk_widget_path_to_string (const GtkWidgetPath *path); 633 return Str.toString(gtk_widget_path_to_string(gtkWidgetPath)); 634 } 635 }