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