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 = GtkCssProvider.html 27 * outPack = gtk 28 * outFile = CssProvider 29 * strct = GtkCssProvider 30 * realStrct= 31 * ctorStrct= 32 * clss = CssProvider 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * - StyleProviderIF 40 * prefixes: 41 * - gtk_css_provider_ 42 * omit structs: 43 * omit prefixes: 44 * - gtk_css_section_ 45 * omit code: 46 * omit signals: 47 * imports: 48 * - glib.Str 49 * - glib.ErrorG 50 * - glib.GException 51 * - gio.File 52 * - gtk.CssSection 53 * - gtk.StyleProviderT 54 * - gtk.StyleProviderIF 55 * structWrap: 56 * - GError* -> ErrorG 57 * - GFile* -> File 58 * - GtkCssProvider* -> CssProvider 59 * - GtkCssSection* -> CssSection 60 * module aliases: 61 * local aliases: 62 * overrides: 63 * - toString 64 */ 65 66 module gtk.CssProvider; 67 68 public import gtkc.gtktypes; 69 70 private import gtkc.gtk; 71 private import glib.ConstructionException; 72 private import gobject.ObjectG; 73 74 private import gobject.Signals; 75 public import gtkc.gdktypes; 76 private import glib.Str; 77 private import glib.ErrorG; 78 private import glib.GException; 79 private import gio.File; 80 private import gtk.CssSection; 81 private import gtk.StyleProviderT; 82 private import gtk.StyleProviderIF; 83 84 85 private import gobject.ObjectG; 86 87 /** 88 * GtkCssProvider is an object implementing the GtkStyleProvider interface. 89 * It is able to parse CSS-like 90 * input in order to style widgets. 91 * 92 * Default files 93 * 94 * An application can cause GTK+ to parse a specific CSS style sheet by 95 * calling gtk_css_provider_load_from_file() and adding the provider with 96 * gtk_style_context_add_provider() or gtk_style_context_add_provider_for_screen(). 97 * In addition, certain files will be read when GTK+ is initialized. First, 98 * the file $XDG_CONFIG_HOME/gtk-3.0/gtk.css 99 * is loaded if it exists. Then, GTK+ tries to load 100 * $HOME/.themes/theme-name/gtk-3.0/gtk.css, 101 * falling back to 102 * datadir/share/themes/theme-name/gtk-3.0/gtk.css, 103 * where theme-name is the name of the current theme 104 * (see the "gtk-theme-name" setting) and datadir 105 * is the prefix configured when GTK+ was compiled, unless overridden by the 106 * GTK_DATA_PREFIX environment variable. 107 * 108 * <hr> 109 * 110 * Style sheets 111 * 112 * The basic structure of the style sheets understood by this provider is 113 * a series of statements, which are either rule sets or '@-rules', separated 114 * by whitespace. 115 * 116 * A rule set consists of a selector and a declaration block, which is 117 * a series of declarations enclosed in curly braces ({ and }). The 118 * declarations are separated by semicolons (;). Multiple selectors can 119 * share the same declaration block, by putting all the separators in 120 * front of the block, separated by commas. 121 * 122 * $(DDOC_COMMENT example) 123 * 124 * <hr> 125 * 126 * Selectors 127 * 128 * Selectors work very similar to the way they do in CSS, with widget class 129 * names taking the role of element names, and widget names taking the role 130 * of IDs. When used in a selector, widget names must be prefixed with a 131 * '#' character. The '*' character represents the so-called universal 132 * selector, which matches any widget. 133 * 134 * To express more complicated situations, selectors can be combined in 135 * various ways: 136 * 137 * To require that a widget satisfies several conditions, 138 * combine several selectors into one by concatenating them. E.g. 139 * GtkButton#button1 matches a GtkButton widget 140 * with the name button1. 141 * 142 * To only match a widget when it occurs inside some other 143 * widget, write the two selectors after each other, separated by whitespace. 144 * E.g. GtkToolBar GtkButton matches GtkButton widgets 145 * that occur inside a GtkToolBar. 146 * 147 * In the previous example, the GtkButton is matched even 148 * if it occurs deeply nested inside the toolbar. To restrict the match 149 * to direct children of the parent widget, insert a '>' character between 150 * the two selectors. E.g. GtkNotebook > GtkLabel matches 151 * GtkLabel widgets that are direct children of a GtkNotebook. 152 * 153 * $(DDOC_COMMENT example) 154 * 155 * Widgets may also define style classes, which can be used for matching. 156 * When used in a selector, style classes must be prefixed with a '.' 157 * character. 158 * 159 * Refer to the documentation of individual widgets to learn which 160 * style classes they define and see the section called “Style classes and regions” 161 * for a list of all style classes used by GTK+ widgets. 162 * 163 * Note that there is some ambiguity in the selector syntax when it comes 164 * to differentiation widget class names from regions. GTK+ currently treats 165 * a string as a widget class name if it contains any uppercase characters 166 * (which should work for more widgets with names like GtkLabel). 167 * 168 * $(DDOC_COMMENT example) 169 * 170 * In complicated widgets like e.g. a GtkNotebook, it may be desirable 171 * to style different parts of the widget differently. To make this 172 * possible, container widgets may define regions, whose names 173 * may be used for matching in selectors. 174 * 175 * Some containers allow to further differentiate between regions by 176 * applying so-called pseudo-classes to the region. For example, the 177 * tab region in GtkNotebook allows to single out the first or last 178 * tab by using the :first-child or :last-child pseudo-class. 179 * When used in selectors, pseudo-classes must be prefixed with a 180 * ':' character. 181 * 182 * Refer to the documentation of individual widgets to learn which 183 * regions and pseudo-classes they define and see 184 * the section called “Style classes and regions” for a list of all regions 185 * used by GTK+ widgets. 186 * 187 * $(DDOC_COMMENT example) 188 * 189 * Another use of pseudo-classes is to match widgets depending on their 190 * state. This is conceptually similar to the :hover, :active or :focus 191 * pseudo-classes in CSS. The available pseudo-classes for widget states 192 * are :active, :prelight (or :hover), :insensitive, :selected, :focused 193 * and :inconsistent. 194 * 195 * $(DDOC_COMMENT example) 196 * 197 * Widget state pseudoclasses may only apply to the last element 198 * in a selector. 199 * 200 * To determine the effective style for a widget, all the matching rule 201 * sets are merged. As in CSS, rules apply by specificity, so the rules 202 * whose selectors more closely match a widget path will take precedence 203 * over the others. 204 * 205 * <hr> 206 * 207 * @ Rules 208 * 209 * GTK+'s CSS supports the @import rule, in order to load another 210 * CSS style sheet in addition to the currently parsed one. 211 * 212 * $(DDOC_COMMENT example) 213 * 214 * In order to extend key bindings affecting different widgets, GTK+ 215 * supports the @binding-set rule to parse a set of bind/unbind 216 * directives, see GtkBindingSet for the supported syntax. Note that 217 * the binding sets defined in this way must be associated with rule sets 218 * by setting the gtk-key-bindings style property. 219 * 220 * Customized key bindings are typically defined in a separate 221 * gtk-keys.css CSS file and GTK+ loads this file 222 * according to the current key theme, which is defined by the 223 * "gtk-key-theme-name" setting. 224 * 225 * $(DDOC_COMMENT example) 226 * 227 * GTK+ also supports an additional @define-color rule, in order 228 * to define a color name which may be used instead of color numeric 229 * representations. Also see the "gtk-color-scheme" setting 230 * for a way to override the values of these named colors. 231 * 232 * $(DDOC_COMMENT example) 233 * 234 * <hr> 235 * 236 * Symbolic colors 237 * 238 * Besides being able to define color names, the CSS parser is also able 239 * to read different color expressions, which can also be nested, providing 240 * a rich language to define colors which are derived from a set of base 241 * colors. 242 * 243 * $(DDOC_COMMENT example) 244 * 245 * The various ways to express colors in GTK+ CSS are: 246 * 247 * Syntax 248 * Explanation 249 * Examples 250 * 251 * rgb(r, g, b) 252 * An opaque color; r, g, b can be either integers between 253 * 0 and 255 or percentages 254 * 255 * rgb(128, 10, 54) 256 * rgb(20%, 30%, 0%) 257 * 258 * rgba(r, g, b, a) 259 * A translucent color; r, g, b are as in the previous row, 260 * a is a floating point number between 0 and 1 261 * 262 * rgba(255, 255, 0, 0.5) 263 * 264 * #xxyyzz 265 * 266 * An opaque color; xx, yy, zz are hexadecimal numbers 267 * specifying r, g, b variants with between 1 and 4 268 * hexadecimal digits per component are allowed 269 * 270 * #ff12ab 271 * #f0c 272 * 273 * @name 274 * Reference to a color that has been defined with 275 * @define-color 276 * 277 * @bg_color 278 * 279 * mix(color1, color2, f) 280 * A linear combination of color1 and color2. f is a 281 * floating point number between 0 and 1. 282 * 283 * mix(#ff1e0a, @bg_color, 0.8) 284 * 285 * shade(color, f) 286 * A lighter or darker variant of color. f is a 287 * floating point number. 288 * 289 * shade(@fg_color, 0.5) 290 * 291 * lighter(color) 292 * A lighter variant of color 293 * 294 * darker(color) 295 * A darker variant of color 296 * 297 * alpha(color, f) 298 * Modifies passed color's alpha by a factor f. f is a 299 * floating point number. f < 1.0 results in a more transparent 300 * color while f > 1.0 results in a more opaque color. 301 * 302 * alhpa(blue, 0.5) 303 * 304 * <hr> 305 * 306 * Gradients 307 * 308 * Linear or radial Gradients can be used as background images. 309 * 310 * A linear gradient along the line from (start_x, start_y) to 311 * (end_x, end_y) is specified using the syntax 312 * 313 * -gtk-gradient (linear, 314 * start_x start_y, end_x end_y, 315 * color-stop (position, color), 316 * ...) 317 * 318 * where start_x and end_x can be either a floating point number between 319 * 0 and 1 or one of the special values 'left', 'right' or 'center', start_y 320 * and end_y can be either a floating point number between 0 and 1 or one 321 * of the special values 'top', 'bottom' or 'center', position is a floating 322 * point number between 0 and 1 and color is a color expression (see above). 323 * The color-stop can be repeated multiple times to add more than one color 324 * stop. 'from (color)' and 'to (color)' can be used as abbreviations for 325 * color stops with position 0 and 1, respectively. 326 * 327 * $(DDOC_COMMENT example) 328 * 329 * $(DDOC_COMMENT example) 330 * 331 * A radial gradient along the two circles defined by (start_x, start_y, 332 * start_radius) and (end_x, end_y, end_radius) is specified using the 333 * syntax 334 * 335 * -gtk-gradient (radial, 336 * start_x start_y, start_radius, 337 * end_x end_y, end_radius, 338 * color-stop (position, color), 339 * ...) 340 * 341 * where start_radius and end_radius are floating point numbers and 342 * the other parameters are as before. 343 * 344 * $(DDOC_COMMENT example) 345 * 346 * $(DDOC_COMMENT example) 347 * 348 * <hr> 349 * 350 * Text shadow 351 * 352 * A shadow list can be applied to text or symbolic icons, using the CSS3 353 * text-shadow syntax, as defined in 354 * the CSS3 specification. 355 * 356 * A text shadow is specified using the syntax 357 * 358 * text-shadow: horizontal_offset vertical_offset [ blur_radius ] color 359 * 360 * The offset of the shadow is specified with the horizontal_offset and vertical_offset 361 * parameters. The optional blur radius is parsed, but it is currently not rendered by 362 * the GTK+ theming engine. 363 * 364 * To set a shadow on an icon, use the icon-shadow property instead, 365 * with the same syntax. 366 * 367 * To set multiple shadows on an element, you can specify a comma-separated list 368 * of shadow elements in the text-shadow or icon-shadow property. Shadows are 369 * always rendered front-back, i.e. the first shadow specified is on top of the 370 * others. Shadows can thus overlay each other, but they can never overlay the 371 * text or icon itself, which is always rendered on top of the shadow layer. 372 * 373 * <hr> 374 * 375 * Box shadow 376 * 377 * Themes can apply shadows on framed elements using the CSS3 box-shadow syntax, 378 * as defined in 379 * the CSS3 specification. 380 * 381 * A box shadow is specified using the syntax 382 * 383 * box-shadow: [ inset ] horizontal_offset vertical_offset [ blur_radius ] [ spread ] color 384 * 385 * A positive offset will draw a shadow that is offset to the right (down) of the box, 386 * a negative offset to the left (top). The optional spread parameter defines an additional 387 * distance to expand the shadow shape in all directions, by the specified radius. 388 * The optional blur radius parameter is parsed, but it is currently not rendered by 389 * the GTK+ theming engine. 390 * The inset parameter defines whether the drop shadow should be rendered inside or outside 391 * the box canvas. 392 * 393 * To set multiple box-shadows on an element, you can specify a comma-separated list 394 * of shadow elements in the box-shadow property. Shadows are always rendered 395 * front-back, i.e. the first shadow specified is on top of the others, so they may 396 * overlap other boxes or other shadows. 397 * 398 * <hr> 399 * 400 * Border images 401 * 402 * Images and gradients can also be used in slices for the purpose of creating 403 * scalable borders. 404 * For more information, see the CSS3 documentation for the border-image property, 405 * which can be found here. 406 * 407 * The parameters of the slicing process are controlled by 408 * four separate properties. Note that you can use the 409 * 410 * border-image 411 * 412 * shorthand property 413 * to set values for the three properties at the same time. 414 * 415 * border-image-source: url(path) 416 * (or border-image-source: -gtk-gradient(...)) 417 * 418 * : 419 * Specifies the source of the border image, and it can either 420 * be an URL or a gradient (see above). 421 * 422 * border-image-slice: top right bottom left 423 * 424 * The sizes specified by the top, right, bottom and left parameters 425 * are the offsets, in pixels, from the relevant edge where the image 426 * should be "cut off" to build the slices used for the rendering 427 * of the border. 428 * 429 * border-image-width: top right bottom left 430 * 431 * The sizes specified by the top, right, bottom and left parameters 432 * are inward distances from the border box edge, used to specify the 433 * rendered size of each slice determined by border-image-slice. 434 * If this property is not specified, the values of border-width will 435 * be used as a fallback. 436 * 437 * border-image-repeat: [stretch|repeat|round|space] ? 438 * [stretch|repeat|round|space] 439 * 440 * Specifies how the image slices should be rendered in the area 441 * outlined by border-width. 442 * The default (stretch) is to resize the slice to fill in the whole 443 * allocated area. 444 * If the value of this property is 'repeat', the image slice 445 * will be tiled to fill the area. 446 * If the value of this property is 'round', the image slice will 447 * be tiled to fill the area, and scaled to fit it exactly 448 * a whole number of times. 449 * If the value of this property is 'space', the image slice will 450 * be tiled to fill the area, and if it doesn't fit it exactly a whole 451 * number of times, the extra space is distributed as padding around 452 * the slices. 453 * If two options are specified, the first one affects 454 * the horizontal behaviour and the second one the vertical behaviour. 455 * If only one option is specified, it affects both. 456 * 457 * $(DDOC_COMMENT example) 458 * 459 * $(DDOC_COMMENT example) 460 * 461 * $(DDOC_COMMENT example) 462 * 463 * <hr> 464 * 465 * Styles can specify transitions that will be used to create a gradual 466 * change in the appearance when a widget state changes. The following 467 * syntax is used to specify transitions: 468 * 469 * duration [s|ms] [linear|ease|ease-in|ease-out|ease-in-out] [loop]? 470 * 471 * The duration is the amount of time that the animation will take for 472 * a complete cycle from start to end. If the loop option is given, the 473 * animation will be repated until the state changes again. 474 * The option after the duration determines the transition function from a 475 * small set of predefined functions. 476 * 477 * Figure 6. Linear transition 478 * 479 * Figure 7. Ease transition 480 * 481 * Figure 8. Ease-in-out transition 482 * 483 * Figure 9. Ease-in transition 484 * 485 * Figure 10. Ease-out transition 486 * 487 * <hr> 488 * 489 * Supported properties 490 * 491 * Properties are the part that differ the most to common CSS, 492 * not all properties are supported (some are planned to be 493 * supported eventually, some others are meaningless or don't 494 * map intuitively in a widget based environment). 495 * 496 * The currently supported properties are: 497 * 498 * Property name 499 * Syntax 500 * Maps to 501 * Examples 502 * 503 * engine 504 * engine-name 505 * GtkThemingEngine 506 * engine: clearlooks; 507 * engine: none; /+* use the default (i.e. builtin) engine) +/ 508 * 509 * background-color 510 * color (see above) 511 * GdkRGBA 512 * 513 * background-color: #fff; 514 * color: color1; 515 * background-color: shade (color1, 0.5); 516 * color: mix (color1, #f0f, 0.8); 517 * 518 * color 519 * 520 * border-top-color 521 * transparent|color (see above) 522 * 523 * border-right-color 524 * 525 * border-bottom-color 526 * 527 * border-left-color 528 * 529 * border-color 530 * [transparent|color]{1,4} 531 * 532 * font-family 533 * 534 * family [, family]* 535 * gchararray 536 * font-family: Sans, Arial; 537 * 538 * font-style 539 * [normal|oblique|italic] 540 * PANGO_TYPE_STYLE 541 * font-style: italic; 542 * 543 * font-variant 544 * [normal|small-caps] 545 * PANGO_TYPE_VARIANT 546 * font-variant: normal; 547 * 548 * font-weight 549 * [normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900] 550 * PANGO_TYPE_WEIGHT 551 * font-weight: bold; 552 * 553 * font-size 554 * Font size in point 555 * gint 556 * font-size: 13; 557 * 558 * font 559 * 560 * family [style] [size] 561 * PangoFontDescription 562 * font: Sans 15; 563 * 564 * margin-top 565 * integer 566 * gint 567 * margin-top: 0; 568 * 569 * margin-left 570 * integer 571 * gint 572 * margin-left: 1; 573 * 574 * margin-bottom 575 * integer 576 * gint 577 * margin-bottom: 2; 578 * 579 * margin-right 580 * integer 581 * gint 582 * margin-right: 4; 583 * 584 * margin 585 * 586 * width 587 * vertical_width horizontal_width 588 * top_width horizontal_width bottom_width 589 * top_width right_width bottom_width left_width 590 * 591 * GtkBorder 592 * 593 * margin: 5; 594 * margin: 5 10; 595 * margin: 5 10 3; 596 * margin: 5 10 3 5; 597 * 598 * padding-top 599 * integer 600 * gint 601 * padding-top: 5; 602 * 603 * padding-left 604 * integer 605 * gint 606 * padding-left: 5; 607 * 608 * padding-bottom 609 * integer 610 * gint 611 * padding-bottom: 5; 612 * 613 * padding-right 614 * integer 615 * gint 616 * padding-right: 5; 617 * 618 * padding 619 * 620 * background-image 621 * 622 * gradient (see above) or 623 * url(path) 624 * cairo_pattern_t 625 * 626 * -gtk-gradient (linear, 627 * left top, right top, 628 * from (#fff), to (#000)); 629 * -gtk-gradient (linear, 0.0 0.5, 0.5 1.0, 630 * from (#fff), 631 * color-stop (0.5, #f00), 632 * to (#000)); 633 * -gtk-gradient (radial, 634 * center center, 0.2, 635 * center center, 0.8, 636 * color-stop (0.0, #fff), 637 * color-stop (1.0, #000)); 638 * url ('background.png'); 639 * 640 * background-repeat 641 * [repeat|no-repeat] 642 * internal 643 * 644 * background-repeat: no-repeat; 645 * If not specified, the style doesn't respect the CSS3 646 * specification, since the background will be 647 * stretched to fill the area. 648 * 649 * border-top-width 650 * integer 651 * gint 652 * border-top-width: 5; 653 * 654 * border-left-width 655 * integer 656 * gint 657 * border-left-width: 5; 658 * 659 * border-bottom-width 660 * integer 661 * gint 662 * border-bottom-width: 5; 663 * 664 * border-right-width 665 * integer 666 * gint 667 * border-right-width: 5; 668 * 669 * border-width 670 * GtkBorder 671 * 672 * border-width: 1; 673 * border-width: 1 2; 674 * border-width: 1 2 3; 675 * border-width: 1 2 3 5; 676 * 677 * border-radius 678 * integer 679 * gint 680 * border-radius: 5; 681 * 682 * border-style 683 * [none|solid|inset|outset] 684 * GtkBorderStyle 685 * border-style: solid; 686 * 687 * border-image 688 * 689 * border image (see above) 690 * internal use only 691 * 692 * border-image: url("/path/to/image.png") 3 4 3 4 stretch; 693 * border-image: url("/path/to/image.png") 3 4 4 3 repeat stretch; 694 * 695 * text-shadow 696 * shadow list (see above) 697 * internal use only 698 * 699 * text-shadow: 1 1 0 blue, -4 -4 red; 700 * 701 * transition 702 * transition (see above) 703 * internal use only 704 * 705 * transition: 150ms ease-in-out; 706 * transition: 1s linear loop; 707 * 708 * gtk-key-bindings 709 * binding set name list 710 * internal use only 711 * 712 * gtk-bindings: binding1, binding2, ...; 713 * 714 * GtkThemingEngines can register their own, engine-specific style properties 715 * with the function gtk_theming_engine_register_property(). These properties 716 * can be set in CSS like other properties, using a name of the form 717 * 718 * -namespace-name 719 * 720 * , where namespace is typically 721 * the name of the theming engine, and name is the 722 * name of the property. Style properties that have been registered by widgets 723 * using gtk_widget_class_install_style_property() can also be set in this 724 * way, using the widget class name for namespace. 725 * 726 * $(DDOC_COMMENT example) 727 */ 728 public class CssProvider : ObjectG, StyleProviderIF 729 { 730 731 /** the main Gtk struct */ 732 protected GtkCssProvider* gtkCssProvider; 733 734 735 /** Get the main Gtk struct */ 736 public GtkCssProvider* getCssProviderStruct() 737 { 738 return gtkCssProvider; 739 } 740 741 742 /** the main Gtk struct as a void* */ 743 protected override void* getStruct() 744 { 745 return cast(void*)gtkCssProvider; 746 } 747 748 /** 749 * Sets our main struct and passes it to the parent class 750 */ 751 public this (GtkCssProvider* gtkCssProvider) 752 { 753 super(cast(GObject*)gtkCssProvider); 754 this.gtkCssProvider = gtkCssProvider; 755 } 756 757 protected override void setStruct(GObject* obj) 758 { 759 super.setStruct(obj); 760 gtkCssProvider = cast(GtkCssProvider*)obj; 761 } 762 763 // add the StyleProvider capabilities 764 mixin StyleProviderT!(GtkCssProvider); 765 766 /** 767 */ 768 int[string] connectedSignals; 769 770 void delegate(CssSection, ErrorG, CssProvider)[] onParsingErrorListeners; 771 /** 772 * Signals that a parsing error occured. the path, line and position 773 * describe the actual location of the error as accurately as possible. 774 * Parsing errors are never fatal, so the parsing will resume after 775 * the error. Errors may however cause parts of the given 776 * data or even all of it to not be parsed at all. So it is a useful idea 777 * to check that the parsing succeeds by connecting to this signal. 778 * Note that this signal may be emitted at any time as the css provider 779 * may opt to defer parsing parts or all of the input to a later time 780 * than when a loading function was called. 781 * See Also 782 * GtkStyleContext, GtkStyleProvider 783 */ 784 void addOnParsingError(void delegate(CssSection, ErrorG, CssProvider) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 785 { 786 if ( !("parsing-error" in connectedSignals) ) 787 { 788 Signals.connectData( 789 getStruct(), 790 "parsing-error", 791 cast(GCallback)&callBackParsingError, 792 cast(void*)this, 793 null, 794 connectFlags); 795 connectedSignals["parsing-error"] = 1; 796 } 797 onParsingErrorListeners ~= dlg; 798 } 799 extern(C) static void callBackParsingError(GtkCssProvider* providerStruct, GtkCssSection* section, GError* error, CssProvider _cssProvider) 800 { 801 foreach ( void delegate(CssSection, ErrorG, CssProvider) dlg ; _cssProvider.onParsingErrorListeners ) 802 { 803 dlg(ObjectG.getDObject!(CssSection)(section), ObjectG.getDObject!(ErrorG)(error), _cssProvider); 804 } 805 } 806 807 808 /** 809 * Returns the provider containing the style settings used as a 810 * fallback for all widgets. 811 * Returns: The provider used for fallback styling. This memory is owned by GTK+, and you must not free it. [transfer none] 812 */ 813 public static CssProvider getDefault() 814 { 815 // GtkCssProvider * gtk_css_provider_get_default (void); 816 auto p = gtk_css_provider_get_default(); 817 818 if(p is null) 819 { 820 return null; 821 } 822 823 return ObjectG.getDObject!(CssProvider)(cast(GtkCssProvider*) p); 824 } 825 826 /** 827 * Loads a theme from the usual theme paths 828 * Params: 829 * name = A theme name 830 * variant = variant to load, for example, "dark", or 831 * NULL for the default. [allow-none] 832 * Returns: a GtkCssProvider with the theme loaded. This memory is owned by GTK+, and you must not free it. [transfer none] 833 */ 834 public static CssProvider getNamed(string name, string variant) 835 { 836 // GtkCssProvider * gtk_css_provider_get_named (const gchar *name, const gchar *variant); 837 auto p = gtk_css_provider_get_named(Str.toStringz(name), Str.toStringz(variant)); 838 839 if(p is null) 840 { 841 return null; 842 } 843 844 return ObjectG.getDObject!(CssProvider)(cast(GtkCssProvider*) p); 845 } 846 847 /** 848 * Loads data into css_provider, making it clear any previously loaded 849 * information. 850 * Params: 851 * data = CSS data loaded in memory. [array length=length][element-type guint8] 852 * Returns: TRUE. The return value is deprecated and FALSE will only be returned for backwards compatibility reasons if an error is not NULL and a loading error occured. To track errors while loading CSS, connect to the GtkCssProvider::parsing-error signal. 853 * Throws: GException on failure. 854 */ 855 public int loadFromData(string data) 856 { 857 // gboolean gtk_css_provider_load_from_data (GtkCssProvider *css_provider, const gchar *data, gssize length, GError **error); 858 GError* err = null; 859 860 auto p = gtk_css_provider_load_from_data(gtkCssProvider, cast(char*)data.ptr, cast(int) data.length, &err); 861 862 if (err !is null) 863 { 864 throw new GException( new ErrorG(err) ); 865 } 866 867 return p; 868 } 869 870 /** 871 * Loads the data contained in file into css_provider, making it 872 * clear any previously loaded information. 873 * Params: 874 * file = GFile pointing to a file to load 875 * Returns: TRUE. The return value is deprecated and FALSE will only be returned for backwards compatibility reasons if an error is not NULL and a loading error occured. To track errors while loading CSS, connect to the GtkCssProvider::parsing-error signal. 876 * Throws: GException on failure. 877 */ 878 public int loadFromFile(File file) 879 { 880 // gboolean gtk_css_provider_load_from_file (GtkCssProvider *css_provider, GFile *file, GError **error); 881 GError* err = null; 882 883 auto p = gtk_css_provider_load_from_file(gtkCssProvider, (file is null) ? null : file.getFileStruct(), &err); 884 885 if (err !is null) 886 { 887 throw new GException( new ErrorG(err) ); 888 } 889 890 return p; 891 } 892 893 /** 894 * Loads the data contained in path into css_provider, making it clear 895 * any previously loaded information. 896 * Params: 897 * path = the path of a filename to load, in the GLib filename encoding 898 * Returns: TRUE. The return value is deprecated and FALSE will only be returned for backwards compatibility reasons if an error is not NULL and a loading error occured. To track errors while loading CSS, connect to the GtkCssProvider::parsing-error signal. 899 * Throws: GException on failure. 900 */ 901 public int loadFromPath(string path) 902 { 903 // gboolean gtk_css_provider_load_from_path (GtkCssProvider *css_provider, const gchar *path, GError **error); 904 GError* err = null; 905 906 auto p = gtk_css_provider_load_from_path(gtkCssProvider, Str.toStringz(path), &err); 907 908 if (err !is null) 909 { 910 throw new GException( new ErrorG(err) ); 911 } 912 913 return p; 914 } 915 916 /** 917 * Returns a newly created GtkCssProvider. 918 * Throws: ConstructionException GTK+ fails to create the object. 919 */ 920 public this () 921 { 922 // GtkCssProvider * gtk_css_provider_new (void); 923 auto p = gtk_css_provider_new(); 924 if(p is null) 925 { 926 throw new ConstructionException("null returned by gtk_css_provider_new()"); 927 } 928 this(cast(GtkCssProvider*) p); 929 } 930 931 /** 932 * Convertes the provider into a string representation in CSS 933 * format. 934 * Using gtk_css_provider_load_from_data() with the return value 935 * from this function on a new provider created with 936 * gtk_css_provider_new() will basicallu create a duplicate of 937 * this provider. 938 * Returns: a new string representing the provider. Since 3.2 939 */ 940 public override string toString() 941 { 942 // char * gtk_css_provider_to_string (GtkCssProvider *provider); 943 return Str.toString(gtk_css_provider_to_string(gtkCssProvider)); 944 } 945 }