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.CssProvider; 26 27 private import gio.FileIF; 28 private import glib.ConstructionException; 29 private import glib.ErrorG; 30 private import glib.GException; 31 private import glib.Str; 32 private import gobject.ObjectG; 33 private import gobject.Signals; 34 private import gtk.CssSection; 35 private import gtk.StyleProviderIF; 36 private import gtk.StyleProviderT; 37 public import gtkc.gdktypes; 38 private import gtkc.gtk; 39 public import gtkc.gtktypes; 40 41 42 /** 43 * GtkCssProvider is an object implementing the #GtkStyleProvider interface. 44 * It is able to parse [CSS-like](http://www.w3.org/TR/CSS2) 45 * input in order to style widgets. 46 * 47 * ## Default files 48 * 49 * An application can cause GTK+ to parse a specific CSS style sheet by 50 * calling gtk_css_provider_load_from_file() and adding the provider with 51 * gtk_style_context_add_provider() or gtk_style_context_add_provider_for_screen(). 52 * In addition, certain files will be read when GTK+ is initialized. First, 53 * the file `$XDG_CONFIG_HOME/gtk-3.0/gtk.css` 54 * is loaded if it exists. Then, GTK+ tries to load 55 * `$HOME/.themes/theme-name/gtk-3.0/gtk.css`, 56 * falling back to 57 * `datadir/share/themes/theme-name/gtk-3.0/gtk.css`, 58 * where theme-name is the name of the current theme 59 * (see the #GtkSettings:gtk-theme-name setting) and datadir 60 * is the prefix configured when GTK+ was compiled, unless overridden by the 61 * `GTK_DATA_PREFIX` environment variable. 62 * 63 * # Style sheets 64 * 65 * The basic structure of the style sheets understood by this provider is 66 * a series of statements, which are either rule sets or “@-rules”, separated 67 * by whitespace. 68 * 69 * A rule set consists of a selector and a declaration block, which is 70 * a series of declarations enclosed in curly braces ({ and }). The 71 * declarations are separated by semicolons (;). Multiple selectors can 72 * share the same declaration block, by putting all the separators in 73 * front of the block, separated by commas. 74 * 75 * An example of a rule set with two selectors: 76 * |[ 77 * GtkButton, GtkEntry { 78 * color: #ff00ea; 79 * font: Comic Sans 12 80 * } 81 * ]| 82 * 83 * # Selectors # {#gtkcssprovider-selectors} 84 * 85 * Selectors work very similar to the way they do in CSS, with widget class 86 * names taking the role of element names, and widget names taking the role 87 * of IDs. When used in a selector, widget names must be prefixed with a 88 * '#' character. The “*” character represents the so-called universal 89 * selector, which matches any widget. 90 * 91 * To express more complicated situations, selectors can be combined in 92 * various ways: 93 * - To require that a widget satisfies several conditions, 94 * combine several selectors into one by concatenating them. E.g. 95 * `GtkButton#button1` matches a GtkButton widget 96 * with the name button1. 97 * - To only match a widget when it occurs inside some other 98 * widget, write the two selectors after each other, separated by whitespace. 99 * E.g. `GtkToolBar GtkButton` matches GtkButton widgets 100 * that occur inside a GtkToolBar. 101 * - In the previous example, the GtkButton is matched even 102 * if it occurs deeply nested inside the toolbar. To restrict the match 103 * to direct children of the parent widget, insert a “>” character between 104 * the two selectors. E.g. `GtkNotebook > GtkLabel` matches 105 * GtkLabel widgets that are direct children of a GtkNotebook. 106 * 107 * ## Examples of widget classes and names in selectors 108 * 109 * Theme labels that are descendants of a window: 110 * |[ 111 * GtkWindow GtkLabel { 112 * background-color: #898989 113 * } 114 * ]| 115 * 116 * Theme notebooks, and anything that’s within these: 117 * |[ 118 * GtkNotebook { 119 * background-color: #a939f0 120 * } 121 * ]| 122 * 123 * Theme combo boxes, and entries that are direct children of a notebook: 124 * |[ 125 * GtkComboBox, 126 * GtkNotebook > GtkEntry { 127 * color: @fg_color; 128 * background-color: #1209a2 129 * } 130 * ]| 131 * 132 * Theme any widget within a GtkBin: 133 * |[ 134 * GtkBin * { 135 * font: Sans 20 136 * } 137 * ]| 138 * 139 * Theme a label named title-label: 140 * |[ 141 * GtkLabel#title-label { 142 * font: Sans 15 143 * } 144 * ]| 145 * 146 * Theme any widget named main-entry: 147 * |[ 148 * #main-entry { 149 * background-color: #f0a810 150 * } 151 * ]| 152 * 153 * Widgets may also define style classes, which can be used for matching. 154 * When used in a selector, style classes must be prefixed with a “.” 155 * character. 156 * 157 * Refer to the documentation of individual widgets to learn which 158 * style classes they define and see 159 * [Style Classes and Regions][gtkstylecontext-classes] 160 * for a list of all style classes used by GTK+ widgets. 161 * 162 * Note that there is some ambiguity in the selector syntax when it comes 163 * to differentiation widget class names from regions. GTK+ currently treats 164 * a string as a widget class name if it contains any uppercase characters 165 * (which should work for more widgets with names like GtkLabel). 166 * 167 * ## Examples for style classes in selectors 168 * 169 * Theme all widgets defining the class entry: 170 * |[ 171 * .entry { 172 * color: #39f1f9; 173 * } 174 * ]| 175 * 176 * Theme spinbuttons’ entry: 177 * |[ 178 * GtkSpinButton.entry { 179 * color: #900185 180 * } 181 * ]| 182 * 183 * In complicated widgets like e.g. a GtkNotebook, it may be desirable 184 * to style different parts of the widget differently. To make this 185 * possible, container widgets may define regions, whose names 186 * may be used for matching in selectors. 187 * 188 * Some containers allow to further differentiate between regions by 189 * applying so-called pseudo-classes to the region. For example, the 190 * tab region in GtkNotebook allows to single out the first or last 191 * tab by using the :first-child or :last-child pseudo-class. 192 * When used in selectors, pseudo-classes must be prefixed with a 193 * ':' character. 194 * 195 * Refer to the documentation of individual widgets to learn which 196 * regions and pseudo-classes they define and see 197 * [Style Classes and Regions][gtkstylecontext-classes] 198 * for a list of all regions 199 * used by GTK+ widgets. 200 * 201 * ## Examples for regions in selectors 202 * 203 * Theme any label within a notebook: 204 * |[ 205 * GtkNotebook GtkLabel { 206 * color: #f90192; 207 * } 208 * ]| 209 * 210 * Theme labels within notebook tabs: 211 * |[ 212 * GtkNotebook tab GtkLabel { 213 * color: #703910; 214 * } 215 * ]| 216 * 217 * Theme labels in the any first notebook tab, both selectors are 218 * equivalent: 219 * |[ 220 * GtkNotebook tab:nth-child(first) GtkLabel, 221 * GtkNotebook tab:first-child GtkLabel { 222 * color: #89d012; 223 * } 224 * ]| 225 * 226 * Another use of pseudo-classes is to match widgets depending on their 227 * state. This is conceptually similar to the :hover, :active or :focus 228 * pseudo-classes in CSS. The available pseudo-classes for widget states 229 * are :active, :prelight (or :hover), :insensitive, :selected, :focused 230 * and :inconsistent. 231 * 232 * ## Examples for styling specific widget states 233 * 234 * Theme active (pressed) buttons: 235 * |[ 236 * GtkButton:active { 237 * background-color: #0274d9; 238 * } 239 * ]| 240 * 241 * Theme buttons with the mouse pointer on it, both are equivalent: 242 * |[ 243 * GtkButton:hover, 244 * GtkButton:prelight { 245 * background-color: #3085a9; 246 * } 247 * ]| 248 * 249 * Theme insensitive widgets, both are equivalent: 250 * |[ 251 * :insensitive, 252 * *:insensitive { 253 * background-color: #320a91; 254 * } 255 * ]| 256 * 257 * Theme selection colors in entries: 258 * |[ 259 * GtkEntry:selected { 260 * background-color: #56f9a0; 261 * } 262 * ]| 263 * 264 * Theme focused labels: 265 * |[ 266 * GtkLabel:focused { 267 * background-color: #b4940f; 268 * } 269 * ]| 270 * 271 * Theme inconsistent checkbuttons: 272 * |[ 273 * GtkCheckButton:inconsistent { 274 * background-color: #20395a; 275 * } 276 * ]| 277 * 278 * Widget state pseudoclasses may only apply to the last element 279 * in a selector. 280 * 281 * To determine the effective style for a widget, all the matching rule 282 * sets are merged. As in CSS, rules apply by specificity, so the rules 283 * whose selectors more closely match a widget path will take precedence 284 * over the others. 285 * 286 * # @ Rules 287 * 288 * GTK+’s CSS supports the \@import rule, in order to load another 289 * CSS style sheet in addition to the currently parsed one. 290 * 291 * An example for using the \@import rule: 292 * |[ 293 * @import url ("path/to/common.css"); 294 * ]| 295 * 296 * In order to extend key bindings affecting different widgets, GTK+ 297 * supports the \@binding-set rule to parse a set of bind/unbind 298 * directives, see #GtkBindingSet for the supported syntax. Note that 299 * the binding sets defined in this way must be associated with rule sets 300 * by setting the gtk-key-bindings style property. 301 * 302 * Customized key bindings are typically defined in a separate 303 * `gtk-keys.css` CSS file and GTK+ loads this file 304 * according to the current key theme, which is defined by the 305 * #GtkSettings:gtk-key-theme-name setting. 306 * 307 * An example for using the \@binding rule: 308 * |[ 309 * @binding-set binding-set1 { 310 * bind "<alt>Left" { "move-cursor" (visual-positions, -3, 0) }; 311 * unbind "End"; 312 * }; 313 * 314 * @binding-set binding-set2 { 315 * bind "<alt>Right" { "move-cursor" (visual-positions, 3, 0) }; 316 * bind "<alt>KP_space" { "delete-from-cursor" (whitespace, 1) 317 * "insert-at-cursor" (" ") }; 318 * }; 319 * 320 * GtkEntry { 321 * gtk-key-bindings: binding-set1, binding-set2; 322 * } 323 * ]| 324 * 325 * GTK+ also supports an additional \@define-color rule, in order 326 * to define a color name which may be used instead of color numeric 327 * representations. Also see the #GtkSettings:gtk-color-scheme setting 328 * for a way to override the values of these named colors. 329 * 330 * An example for defining colors: 331 * |[ 332 * @define-color bg_color #f9a039; 333 * 334 * * { 335 * background-color: @bg_color; 336 * } 337 * ]| 338 * 339 * # Symbolic colors 340 * 341 * Besides being able to define color names, the CSS parser is also able 342 * to read different color expressions, which can also be nested, providing 343 * a rich language to define colors which are derived from a set of base 344 * colors. 345 * 346 * An example for using symbolic colors: 347 * |[ 348 * @define-color entry-color shade (@bg_color, 0.7); 349 * 350 * GtkEntry { 351 * background-color: @entry-color; 352 * } 353 * 354 * GtkEntry:focused { 355 * background-color: mix (@entry-color, 356 * shade (#fff, 0.5), 357 * 0.8); 358 * } 359 * ]| 360 * 361 * # Specifying Colors # {#specifying-colors} 362 * There are various ways to express colors in GTK+ CSS. 363 * 364 * ## rgb(r, g, b) 365 * 366 * An opaque color. 367 * 368 * - `r`, `g`, `b` can be either integers between 0 and 255, or percentages. 369 * 370 * |[ 371 * color: rgb(128, 10, 54); 372 * background-color: rgb(20%, 30%, 0%); 373 * ]| 374 * 375 * ## rgba(r, g, b, a) 376 * 377 * A translucent color. 378 * 379 * - `r`, `g`, `b` can be either integers between 0 and 255, or percentages. 380 * - `a` is a floating point number between 0 and 1. 381 * 382 * |[ 383 * color: rgb(128, 10, 54, 0.5); 384 * ]| 385 * 386 * ## \#xxyyzz 387 * 388 * An opaque color. 389 * 390 * - `xx`, `yy`, `zz` are hexadecimal numbers specifying `r`, `g`, `b` 391 * variants with between 1 and 4 hexadecimal digits per component. 392 * 393 * |[ 394 * color: #f0c; 395 * background-color: #ff00cc; 396 * border-color: #ffff0000cccc; 397 * ]| 398 * 399 * ## \@name 400 * 401 * Reference to a color that has been defined with \@define-color 402 * 403 * |[ 404 * color: @bg_color; 405 * ]| 406 * 407 * ## mix(color1, color2, factor) 408 * 409 * A linear combination of `color1` and `color2`. 410 * 411 * - `factor` is a floating point number between 0 and 1. 412 * 413 * |[ 414 * color: mix(#ff1e0a, @bg_color, 0.8); 415 * ]| 416 * 417 * ## shade(color, factor) 418 * 419 * A lighter or darker variant of `color`. 420 * 421 * - `factor` is a floating point number. 422 * 423 * |[ 424 * color: shade(@fg_color, 0.5); 425 * ]| 426 * 427 * ## lighter(color) 428 * 429 * A lighter variant of `color`. 430 * 431 * |[ 432 * color: lighter(@fg_color); 433 * ]| 434 * 435 * ## darker(color) 436 * 437 * A darker variant of `color`. 438 * 439 * |[ 440 * color: darker(@bg_color); 441 * ]| 442 * 443 * ## alpha(color, factor) 444 * 445 * Modifies passed color’s alpha by a factor. 446 * 447 * - `factor` is a floating point number. `factor` < 1.0 results in a more 448 * transparent color while `factor` > 1.0 results in a more opaque color. 449 * 450 * |[ 451 * color: alpha(@fg_color, 0.5); 452 * ]| 453 * 454 * 455 * # Gradients 456 * 457 * Linear or radial gradients can be used as background images. 458 * 459 * ## Linear Gradients 460 * 461 * A linear gradient along the line from (`start_x`, `start_y`) to 462 * (`end_x`, `end_y`) is specified using the following syntax: 463 * 464 * > `-gtk-gradient (linear, start_x start_y, end_x end_y, color-stop (position, color), ...)` 465 * 466 * - `start_x` and `end_x` can be either a floating point number between 467 * 0 and 1, or one of the special values: “left”, “right”, or “center”. 468 * - `start_y` and `end_y` can be either a floating point number between 0 and 1, or one 469 * of the special values: “top”, “bottom” or “center”. 470 * - `position` is a floating point number between 0 and 1. 471 * - `color` is a color expression (see above). 472 * 473 * The color-stop can be repeated multiple times to add more than one color 474 * stop. “from (color)” and “to (color)” can be used as abbreviations for 475 * color stops with position 0 and 1, respectively. 476 * 477 * ## Example: Linear Gradient 478 * ![](gradient1.png) 479 * |[ 480 * -gtk-gradient (linear, 481 * left top, right bottom, 482 * from(@yellow), to(@blue)); 483 * ]| 484 * 485 * ## Example: Linear Gradient 2 486 * ![](gradient2.png) 487 * |[ 488 * -gtk-gradient (linear, 489 * 0 0, 0 1, 490 * color-stop(0, @yellow), 491 * color-stop(0.2, @blue), 492 * color-stop(1, #0f0)) 493 * ]| 494 * 495 * ## Radial Gradients 496 * 497 * A radial gradient along the two circles defined by (`start_x`, 498 * `start_y`, `start_radius`) and (`end_x`, `end_y`, `end_radius`) is 499 * specified using the following syntax: 500 * 501 * > `-gtk-gradient (radial, start_x start_y, start_radius, end_x end_y, end_radius, color-stop (position, color), ...)` 502 * 503 * where `start_radius` and `end_radius` are floating point numbers 504 * and the other parameters are as before. 505 * 506 * ## Example: Radial Gradient 507 * ![](gradient3.png) 508 * |[ 509 * -gtk-gradient (radial, 510 * center center, 0, 511 * center center, 1, 512 * from(@yellow), to(@green)) 513 * ]| 514 * 515 * ## Example: Radial Gradient 2 516 * ![](gradient4.png) 517 * |[ 518 * -gtk-gradient (radial, 519 * 0.4 0.4, 0.1, 520 * 0.6 0.6, 0.7, 521 * color-stop (0, #f00), 522 * color-stop (0.1, #a0f), 523 * color-stop (0.2, @yellow), 524 * color-stop (1, @green)) 525 * ]| 526 * 527 * # Border images # {#border-images} 528 * 529 * Images and gradients can also be used in slices for the purpose of creating 530 * scalable borders. 531 * For more information, see the [CSS3 documentation for the border-image property](http://www.w3.org/TR/css3-background/#border-images). 532 * 533 * ![](slices.png) 534 * 535 * The parameters of the slicing process are controlled by four 536 * separate properties. 537 * 538 * - Image Source 539 * - Image Slice 540 * - Image Width 541 * - Image Repeat 542 * 543 * Note that you can use the `border-image` shorthand property to set 544 * values for the properties at the same time. 545 * 546 * ## Image Source 547 * 548 * The border image source can be specified either as a 549 * URL or a gradient: 550 * |[ 551 * border-image-source: url(path); 552 * ]| 553 * or 554 * |[ 555 * border-image-source: -gtk-gradient(...); 556 * ]| 557 * 558 * ## Image Slice 559 * 560 * |[ 561 * border-image-slice: top right bottom left; 562 * ]| 563 * 564 * The sizes specified by the `top`, `right`, `bottom`, and `left` parameters 565 * are the offsets (in pixels) from the relevant edge where the image 566 * should be “cut off” to build the slices used for the rendering 567 * of the border. 568 * 569 * ## Image Width 570 * 571 * |[ 572 * border-image-width: top right bottom left; 573 * ]| 574 * 575 * The sizes specified by the @top, @right, @bottom and @left parameters 576 * are inward distances from the border box edge, used to specify the 577 * rendered size of each slice determined by border-image-slice. 578 * If this property is not specified, the values of border-width will 579 * be used as a fallback. 580 * 581 * ## Image Repeat 582 * 583 * Specifies how the image slices should be rendered in the area 584 * outlined by border-width. 585 * 586 * |[ 587 * border-image-repeat: [stretch|repeat|round|space]; 588 * ]| 589 * or 590 * |[ 591 * border-image-repeat: [stretch|repeat|round|space] [stretch|repeat|round|space]; 592 * ]| 593 * 594 * - The default (stretch) is to resize the slice to fill in the 595 * whole allocated area. 596 * 597 * - If the value of this property is “repeat”, the image slice will 598 * be tiled to fill the area. 599 * 600 * - If the value of this property is “round”, the image slice will be 601 * tiled to fill the area, and scaled to fit it exactly a whole number 602 * of times. 603 * 604 * - If the value of this property is “space”, the image slice will be 605 * tiled to fill the area, and if it doesn’t fit it exactly a whole 606 * number of times, the extra space is distributed as padding around 607 * the slices. 608 * 609 * - If two options are specified, the first one affects the 610 * horizontal behaviour and the second one the vertical behaviour. If 611 * only one option is specified, it affects both. 612 * 613 * 614 * ## Example: Border Image 615 * ![](border1.png) 616 * |[ 617 * border-image: url("gradient1.png") 10 10 10 10; 618 * ]| 619 * 620 * ## Example: Repeating Border Image 621 * ![](border2.png) 622 * |[ 623 * border-image: url("gradient1.png") 10 10 10 10 repeat; 624 * ]| 625 * 626 * ## Example: Stetched Border Image 627 * ![](border3.png) 628 * |[ 629 * border-image: url("gradient1.png") 10 10 10 10 stretch; 630 * ]| 631 * 632 * 633 * # Supported Properties 634 * 635 * Properties are the part that differ the most to common CSS, not all 636 * properties are supported (some are planned to be supported 637 * eventually, some others are meaningless or don't map intuitively in 638 * a widget based environment). 639 * 640 * The currently supported properties are: 641 * 642 * ## engine: [name|none]; 643 * 644 * - `none` means to use the default (ie. builtin engine) 645 * |[ 646 * engine: clearlooks; 647 * ]| 648 * 649 * ## background-color: [color|transparent]; 650 * 651 * - `color`: See [Specifying Colors][specifying-colors] 652 * |[ 653 * background-color: shade (@color1, 0.5); 654 * ]| 655 * 656 * ## color: [color|transparent]; 657 * 658 * - `color`: See [Specifying Colors][specifying-colors] 659 * |[ 660 * color: #fff; 661 * ]| 662 * 663 * ## border-color: [color|transparent]{1,4}; 664 * 665 * - `color`: See [Specifying Colors][specifying-colors] 666 * - Four values used to specify: top right bottom left 667 * - Three values used to specify: top vertical bottom 668 * - Two values used to specify: horizontal vertical 669 * - One value used to specify: color 670 * |[ 671 * border-color: red green blue; 672 * ]| 673 * 674 * ## border-top-color: [color|transparent]; 675 * 676 * - `color`: See [Specifying Colors][specifying-colors] 677 * |[ 678 * border-top-color: @borders; 679 * ]| 680 * 681 * ## border-right-color: [color|transparent]; 682 * 683 * - `color`: See [Specifying Colors][specifying-colors] 684 * |[ 685 * border-right-color: @borders; 686 * ]| 687 * 688 * ## border-bottom-color: [color|transparent]; 689 * 690 * - `color`: See [Specifying Colors][specifying-colors] 691 * |[ 692 * border-bottom-color: @borders; 693 * ]| 694 * 695 * ## border-left-color: [color|transparent]; 696 * 697 * - `color`: See [Specifying Colors][specifying-colors] 698 * |[ 699 * border-left-color: @borders; 700 * ]| 701 * 702 * ## font-family: name; 703 * 704 * The name of the font family or font name to use. 705 * 706 * - Note: unlike the CSS2 Specification this does not support using a 707 * prioritized list of font family names and/or generic family 708 * names. 709 * 710 * |[ 711 * font-family: Sans, Cantarell; 712 * ]| 713 * 714 * ## font-style: [normal|oblique|italic]; 715 * 716 * Selects between normal, italic and oblique faces within a font family. 717 * 718 * |[ 719 * font-style: italic; 720 * ]| 721 * 722 * ## font-variant: [normal|small-caps]; 723 * 724 * In a small-caps font the lower case letters look similar to the 725 * uppercase ones, but in a smaller size and with slightly different 726 * proportions. 727 * 728 * |[ 729 * font-variant: normal; 730 * ]| 731 * 732 * ## font-weight: [normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900]; 733 * 734 * Selects the weight of the font. The values '100' to '900' form an 735 * ordered sequence, where each number indicates a weight that is at 736 * least as dark as its predecessor. The keyword 'normal' is 737 * synonymous with '400', and 'bold' is synonymous with 738 * '700'. Keywords other than 'normal' and 'bold' have been shown to 739 * be often confused with font names and a numerical scale was 740 * therefore chosen for the 9-value list. 741 * - Maps to #PANGO_TYPE_WEIGHT 742 * |[ 743 * font-weight: bold; 744 * ]| 745 * 746 * ## font-size: [absolute-size|relative-size|percentage]; 747 * 748 * - `absolute-size`: The size in normal size units like `px`, `pt`, 749 * and `em`. Or symbolic sizes like `xx-small`, `x-small`, `small`, 750 * `medium`, `large`, `x-large`, `xx-large`. 751 * - `relative-size`: `larger` or `smaller` relative to the parent. 752 * - `percentage`: A percentage difference from the nominal size. 753 * |[ 754 * font-size: 12px; 755 * ]| 756 * 757 * ## font-stretch: [face] 758 * 759 * Selects a normal, condensed, or expanded face from a font family. 760 * 761 * Absolute keyword values have the following ordering, from narrowest to widest: 762 * 763 * - ultra-condensed 764 * - extra-condensed 765 * - condensed 766 * - semi-condensed 767 * - normal 768 * - semi-expanded 769 * - expanded 770 * - extra-expanded 771 * - ultra-expanded 772 * 773 * ## font: [family] [style] [variant] [stretch] [size]; 774 * 775 * A shorthand for setting a few font properties at once. 776 * - Supports any format accepted by pango_font_description_from_string() 777 * - Note: this is somewhat different from the CSS2 Specification for this property. 778 * |[ 779 * font: Bold 11; 780 * ]| 781 * 782 * ## margin: [length|percentage]{1,4}; 783 * 784 * A shorthand for setting the margin space required on all sides of 785 * an element. 786 * - Four values used to specify: top right bottom left 787 * - Three values used to specify: top horizontal bottom 788 * - Two values used to specify: vertical horizontal 789 * - One value used to specify: margin 790 * |[ 791 * margin: 1em 2em 4em; 792 * ]| 793 * 794 * ## margin-top: [length|percentage]; 795 * 796 * Sets the margin space required on the top of an element. 797 * |[ 798 * margin-top: 10px; 799 * ]| 800 * 801 * ## margin-right: [length|percentage]; 802 * 803 * Sets the margin space required on the right of an element. 804 * |[ 805 * margin-right: 0px; 806 * ]| 807 * 808 * ## margin-bottom: [length|percentage]; 809 * 810 * Sets the margin space required on the bottom of an element. 811 * |[ 812 * margin-bottom: 10px; 813 * ]| 814 * 815 * ## margin-left: [length|percentage]; 816 * 817 * Sets the margin space required on the left of an element. 818 * |[ 819 * margin-left: 1em; 820 * ]| 821 * 822 * ## padding: [length|percentage]{1,4}; 823 * 824 * A shorthand for setting the padding space required on all sides of 825 * an element. The padding area is the space between the content of 826 * the element and its border. 827 * - Four values used to specify: top right bottom left 828 * - Three values used to specify: top horizontal bottom 829 * - Two values used to specify: vertical horizontal 830 * - One value used to specify: padding 831 * |[ 832 * padding: 1em 2em 4em; 833 * ]| 834 * 835 * ## padding-top: [length|percentage]; 836 * 837 * Sets the padding space required on the top of an element. 838 * |[ 839 * padding-top: 10px; 840 * ]| 841 * 842 * ## padding-right: [length|percentage]; 843 * 844 * Sets the padding space required on the right of an element. 845 * |[ 846 * padding-right: 0px; 847 * ]| 848 * 849 * ## padding-bottom: [length|percentage]; 850 * 851 * Sets the padding space required on the bottom of an element. 852 * |[ 853 * padding-bottom: 10px; 854 * ]| 855 * 856 * ## padding-left: [length|percentage]; 857 * 858 * Sets the padding space required on the left of an element. 859 * |[ 860 * padding-left: 1em; 861 * ]| 862 * 863 * ## border-width: [width]{1,4}; 864 * 865 * A shorthand for setting the border width on all sides of 866 * an element. 867 * - Four values used to specify: top right bottom left 868 * - Three values used to specify: top vertical bottom 869 * - Two values used to specify: horizontal vertical 870 * - One value used to specify: width 871 * |[ 872 * border-width: 1px 2px 4px; 873 * ]| 874 * 875 * ## border-top-width: [width]; 876 * 877 * Sets the border width required on the top of an element. 878 * |[ 879 * border-top: 10px; 880 * ]| 881 * 882 * ## border-right-width: [width]; 883 * 884 * Sets the border width required on the right of an element. 885 * |[ 886 * border-right: 0px; 887 * ]| 888 * 889 * ## border-bottom-width: [width]; 890 * 891 * Sets the border width required on the bottom of an element. 892 * |[ 893 * border-bottom: 10px; 894 * ]| 895 * 896 * ## border-left-width: [width]; 897 * 898 * Sets the border width required on the left of an element. 899 * |[ 900 * border-left: 1em; 901 * ]| 902 * 903 * ## border-radius: [length|percentage]{1,4}; 904 * 905 * Allows setting how rounded all border corners are. 906 * - Four values used to specify: top-left top-right bottom-right bottom-left 907 * - Three values used to specify: top-left top-right-and-bottom-left bottom-right 908 * - Two values used to specify: top-left-and-bottom-right top-right-and-bottom-left 909 * - One value used to specify: radius on all sides 910 * |[ 911 * border-radius: 8px 912 * ]| 913 * 914 * ## border-style: [none|solid|inset|outset]{1,4}; 915 * 916 * A shorthand property for setting the line style for all four sides 917 * of the elements border. 918 * - Four values used to specify: top right bottom left; 919 * - Three values used to specify: top horizontal bottom 920 * - Two values used to specify: vertical horizontal 921 * - One value used to specify: style 922 * |[ 923 * border-style: solid; 924 * ]| 925 * 926 * ## border-image: [source] [slice] [ / width ] [repeat]; A shorthand 927 * for setting an image on the borders of elements. See [Border 928 * Images][border-images]. 929 * |[ 930 * border-image: url("/path/to/image.png") 3 4 4 3 repeat stretch; 931 * ]| 932 * 933 * ## border-image-source: [none|url|linear-gradient]{1,4}; 934 * 935 * Defines the image to use instead of the style of the border. If 936 * this property is set to none, the style defined by border-style is 937 * used instead. 938 * |[ 939 * border-image-source: url("/path/to/image.png"); 940 * ]| 941 * 942 * ## border-image-slice: [number|percentage]{1,4}; 943 * 944 * Divides the image specified by border-image-source in nine regions: 945 * the four corners, the four edges and the middle. It does this by 946 * specifying 4 inwards offsets. 947 * - Four values used to specify: top right bottom left; 948 * - Three values used to specify: top vertical bottom 949 * - Two values used to specify: horizontal vertical 950 * - One value used to specify: slice 951 * |[ 952 * border-image-slice: 3 3 4 3; 953 * ]| 954 * 955 * ## border-image-width: [length|percentage]{1,4}; 956 * 957 * Defines the offset to use for dividing the border image in nine 958 * parts, the top-left corner, central top edge, top-right-corner, 959 * central right edge, bottom-right corner, central bottom edge, 960 * bottom-left corner, and central right edge. They represent inward 961 * distance from the top, right, bottom, and left edges. 962 * - Four values used to specify: top right bottom left; 963 * - Three values used to specify: top horizontal bottom 964 * - Two values used to specify: vertical horizontal 965 * - One value used to specify: width 966 * |[ 967 * border-image-width: 4px 0 4px 0; 968 * ]| 969 * 970 * ## border-image-repeat: [none|url|linear-gradient]{1,4}; 971 * 972 * Defines how the middle part of a border image is handled to match 973 * the size of the border. It has a one-value syntax which describes 974 * the behavior for all sides, and a two-value syntax that sets a 975 * different value for the horizontal and vertical behavior. 976 * - Two values used to specify: horizontal vertical 977 * - One value used to specify: repeat 978 * |[ 979 * border-image-repeat: stretch; 980 * ]| 981 * 982 * ## background-image: [none|url|linear-gradient], ... 983 * Sets one or several background images for an element. The images 984 * are drawn on successive stacking context layers, with the first 985 * specified being drawn as if it is the closest to the user. The 986 * borders of the element are then drawn on top of them, and the 987 * background-color is drawn beneath them. 988 * - There can be several sources listed, separated by commas. 989 * |[ 990 * background-image: gtk-gradient (linear, 991 * left top, right top, 992 * from (#fff), to (#000)); 993 * ]| 994 * 995 * ## background-repeat: [repeat|no-repeat|space|round|repeat-x|repeat-y]; 996 * 997 * Defines how background images are repeated. A background image can 998 * be repeated along the horizontal axis, the vertical axis, both, or 999 * not repeated at all. 1000 * - `repeat`: The image is repeated in the given direction as much as 1001 * needed to cover the whole background image painting area. The 1002 * last image may be clipped if the whole thing won't fit in the 1003 * remaining area. 1004 * - `space`: The image is repeated in the given direction as much as 1005 * needed to cover most of the background image painting area, 1006 * without clipping an image. The remaining non-covered space is 1007 * spaced out evenly between the images. The first and last images 1008 * touches the edge of the element. The value of the 1009 * background-position CSS property is ignored for the concerned 1010 * direction, except if one single image is greater than the 1011 * background image painting area, which is the only case where an 1012 * image can be clipped when the space value is used. 1013 * - `round`: The image is repeated in the given direction as much as 1014 * needed to cover most of the background image painting area, 1015 * without clipping an image. If it doesn't cover exactly the area, 1016 * the tiles are resized in that direction in order to match it. 1017 * - `no-repeat`: The image is not repeated (and hence the background 1018 * image painting area will not necessarily been entirely 1019 * covered). The position of the non-repeated background image is 1020 * defined by the background-position CSS property. 1021 * - Note if not specified, the style doesn’t respect the CSS3 1022 * specification, since the background will be stretched to fill 1023 * the area. 1024 * |[ 1025 * background-repeat: no-repeat; 1026 * ]| 1027 * 1028 * ## text-shadow: horizontal_offset vertical_offset [ blur_radius ] color; 1029 * 1030 * A shadow list can be applied to text or symbolic icons, using the CSS3 1031 * text-shadow syntax, as defined in the 1032 * [CSS3 Specification](http://www.w3.org/TR/css3-text/#text-shadow). 1033 * 1034 * - The offset of the shadow is specified with the 1035 * `horizontal_offset` and `vertical_offset` parameters. 1036 * - The optional blur radius is parsed, but it is currently not 1037 * rendered by the GTK+ theming engine. 1038 * 1039 * To set a shadow on an icon, use the `icon-shadow` property instead, 1040 * with the same syntax. 1041 * 1042 * To set multiple shadows on an element, you can specify a comma-separated list 1043 * of shadow elements in the `text-shadow` or `icon-shadow` property. Shadows are 1044 * always rendered front to back (i.e. the first shadow specified is on top of the 1045 * others). Shadows can thus overlay each other, but they can never overlay the 1046 * text or icon itself, which is always rendered on top of the shadow layer. 1047 * 1048 * |[ 1049 * text-shadow: 1 1 0 blue, -4 -4 red; 1050 * ]| 1051 * 1052 * ## box-shadow: [ inset ] horizontal_offset vertical_offset [ blur_radius ] [ spread ] color; 1053 * 1054 * Themes can apply shadows on framed elements using the CSS3 box-shadow syntax, 1055 * as defined in the 1056 * [CSS3 Specification](http://www.w3.org/TR/css3-background/#the-box-shadow). 1057 * 1058 * - A positive offset will draw a shadow that is offset to the right (down) of the box, 1059 * - A negative offset to the left (top). 1060 * - The optional spread parameter defines an additional distance to 1061 * expand the shadow shape in all directions, by the specified radius. 1062 * - The optional blur radius parameter is parsed, but it is currently not rendered by 1063 * the GTK+ theming engine. 1064 * - The inset parameter defines whether the drop shadow should be rendered inside or outside 1065 * the box canvas. 1066 * 1067 * To set multiple box-shadows on an element, you can specify a comma-separated list 1068 * of shadow elements in the `box-shadow` property. Shadows are always rendered 1069 * front to back (i.e. the first shadow specified is on top of the others) so they may 1070 * overlap other boxes or other shadows. 1071 * 1072 * |[ 1073 * box-shadow: inset 0 1px 1px alpha(black, 0.1); 1074 * ]| 1075 * 1076 * ## transition: duration [s|ms] [linear|ease|ease-in|ease-out|ease-in-out] [loop]; 1077 * 1078 * Styles can specify transitions that will be used to create a 1079 * gradual change in the appearance when a widget state changes. 1080 * - The `duration` is the amount of time that the animation will take 1081 * for a complete cycle from start to end. 1082 * - If the loop option is given, the animation will be repated until 1083 * the state changes again. 1084 * - The option after the duration determines the transition function 1085 * from a small set of predefined functions. 1086 * 1087 * - Linear 1088 * 1089 * ![](linear.png) 1090 * 1091 * - Ease transition 1092 * 1093 * ![](ease.png) 1094 * 1095 * - Ease-in-out transition 1096 * 1097 * ![](ease-in-out.png) 1098 * 1099 * - Ease-in transition 1100 * 1101 * ![](ease-in.png) 1102 * 1103 * - Ease-out transition 1104 * 1105 * ![](ease-out.png) 1106 * 1107 * |[ 1108 * transition: 150ms ease-in-out; 1109 * ]| 1110 * 1111 * 1112 * ## gtk-key-bindings: binding1, binding2, ...; 1113 * 1114 * Key binding set name list. 1115 * 1116 * ## Other Properties 1117 * 1118 * GtkThemingEngines can register their own, engine-specific style properties 1119 * with the function gtk_theming_engine_register_property(). These properties 1120 * can be set in CSS like other properties, using a name of the form 1121 * `-namespace-name`, where namespace is typically 1122 * the name of the theming engine, and name is the 1123 * name of the property. Style properties that have been registered by widgets 1124 * using gtk_widget_class_install_style_property() can also be set in this 1125 * way, using the widget class name for namespace. 1126 * 1127 * An example for using engine-specific style properties: 1128 * |[ 1129 * * { 1130 * engine: clearlooks; 1131 * border-radius: 4; 1132 * -GtkPaned-handle-size: 6; 1133 * -clearlooks-colorize-scrollbar: false; 1134 * } 1135 * ]| 1136 */ 1137 public class CssProvider : ObjectG, StyleProviderIF 1138 { 1139 /** the main Gtk struct */ 1140 protected GtkCssProvider* gtkCssProvider; 1141 1142 /** Get the main Gtk struct */ 1143 public GtkCssProvider* getCssProviderStruct() 1144 { 1145 return gtkCssProvider; 1146 } 1147 1148 /** the main Gtk struct as a void* */ 1149 protected override void* getStruct() 1150 { 1151 return cast(void*)gtkCssProvider; 1152 } 1153 1154 protected override void setStruct(GObject* obj) 1155 { 1156 gtkCssProvider = cast(GtkCssProvider*)obj; 1157 super.setStruct(obj); 1158 } 1159 1160 /** 1161 * Sets our main struct and passes it to the parent class. 1162 */ 1163 public this (GtkCssProvider* gtkCssProvider, bool ownedRef = false) 1164 { 1165 this.gtkCssProvider = gtkCssProvider; 1166 super(cast(GObject*)gtkCssProvider, ownedRef); 1167 } 1168 1169 // add the StyleProvider capabilities 1170 mixin StyleProviderT!(GtkCssProvider); 1171 1172 1173 /** */ 1174 public static GType getType() 1175 { 1176 return gtk_css_provider_get_type(); 1177 } 1178 1179 /** 1180 * Returns a newly created #GtkCssProvider. 1181 * 1182 * Return: A new #GtkCssProvider 1183 * 1184 * Throws: ConstructionException GTK+ fails to create the object. 1185 */ 1186 public this() 1187 { 1188 auto p = gtk_css_provider_new(); 1189 1190 if(p is null) 1191 { 1192 throw new ConstructionException("null returned by new"); 1193 } 1194 1195 this(cast(GtkCssProvider*) p, true); 1196 } 1197 1198 /** 1199 * Returns the provider containing the style settings used as a 1200 * fallback for all widgets. 1201 * 1202 * Return: The provider used for fallback styling. 1203 * This memory is owned by GTK+, and you must not free it. 1204 */ 1205 public static CssProvider getDefault() 1206 { 1207 auto p = gtk_css_provider_get_default(); 1208 1209 if(p is null) 1210 { 1211 return null; 1212 } 1213 1214 return ObjectG.getDObject!(CssProvider)(cast(GtkCssProvider*) p); 1215 } 1216 1217 /** 1218 * Loads a theme from the usual theme paths 1219 * 1220 * Params: 1221 * name = A theme name 1222 * variant = variant to load, for example, "dark", or 1223 * %NULL for the default 1224 * 1225 * Return: a #GtkCssProvider with the theme loaded. 1226 * This memory is owned by GTK+, and you must not free it. 1227 */ 1228 public static CssProvider getNamed(string name, string variant) 1229 { 1230 auto p = gtk_css_provider_get_named(Str.toStringz(name), Str.toStringz(variant)); 1231 1232 if(p is null) 1233 { 1234 return null; 1235 } 1236 1237 return ObjectG.getDObject!(CssProvider)(cast(GtkCssProvider*) p); 1238 } 1239 1240 /** 1241 * Loads @data into @css_provider, making it clear any previously loaded 1242 * information. 1243 * 1244 * Params: 1245 * data = CSS data loaded in memory 1246 * length = the length of @data in bytes, or -1 for NUL terminated strings. If 1247 * @length is not -1, the code will assume it is not NUL terminated and will 1248 * potentially do a copy. 1249 * 1250 * Return: %TRUE. The return value is deprecated and %FALSE will only be 1251 * returned for backwards compatibility reasons if an @error is not 1252 * %NULL and a loading error occured. To track errors while loading 1253 * CSS, connect to the #GtkCssProvider::parsing-error signal. 1254 * 1255 * Throws: GException on failure. 1256 */ 1257 public bool loadFromData(string data) 1258 { 1259 GError* err = null; 1260 1261 auto p = gtk_css_provider_load_from_data(gtkCssProvider, Str.toStringz(data), cast(ptrdiff_t)data.length, &err) != 0; 1262 1263 if (err !is null) 1264 { 1265 throw new GException( new ErrorG(err) ); 1266 } 1267 1268 return p; 1269 } 1270 1271 /** 1272 * Loads the data contained in @file into @css_provider, making it 1273 * clear any previously loaded information. 1274 * 1275 * Params: 1276 * file = #GFile pointing to a file to load 1277 * 1278 * Return: %TRUE. The return value is deprecated and %FALSE will only be 1279 * returned for backwards compatibility reasons if an @error is not 1280 * %NULL and a loading error occured. To track errors while loading 1281 * CSS, connect to the #GtkCssProvider::parsing-error signal. 1282 * 1283 * Throws: GException on failure. 1284 */ 1285 public bool loadFromFile(FileIF file) 1286 { 1287 GError* err = null; 1288 1289 auto p = gtk_css_provider_load_from_file(gtkCssProvider, (file is null) ? null : file.getFileStruct(), &err) != 0; 1290 1291 if (err !is null) 1292 { 1293 throw new GException( new ErrorG(err) ); 1294 } 1295 1296 return p; 1297 } 1298 1299 /** 1300 * Loads the data contained in @path into @css_provider, making it clear 1301 * any previously loaded information. 1302 * 1303 * Params: 1304 * path = the path of a filename to load, in the GLib filename encoding 1305 * 1306 * Return: %TRUE. The return value is deprecated and %FALSE will only be 1307 * returned for backwards compatibility reasons if an @error is not 1308 * %NULL and a loading error occured. To track errors while loading 1309 * CSS, connect to the #GtkCssProvider::parsing-error signal. 1310 * 1311 * Throws: GException on failure. 1312 */ 1313 public bool loadFromPath(string path) 1314 { 1315 GError* err = null; 1316 1317 auto p = gtk_css_provider_load_from_path(gtkCssProvider, Str.toStringz(path), &err) != 0; 1318 1319 if (err !is null) 1320 { 1321 throw new GException( new ErrorG(err) ); 1322 } 1323 1324 return p; 1325 } 1326 1327 /** 1328 * Loads the data contained in the resource at @resource_path into 1329 * the #GtkCssProvider, clearing any previously loaded information. 1330 * 1331 * To track errors while loading CSS, connect to the 1332 * #GtkCssProvider::parsing-error signal. 1333 * 1334 * Params: 1335 * resourcePath = a #GResource resource path 1336 * 1337 * Since: 3.16 1338 */ 1339 public void loadFromResource(string resourcePath) 1340 { 1341 gtk_css_provider_load_from_resource(gtkCssProvider, Str.toStringz(resourcePath)); 1342 } 1343 1344 /** 1345 * Converts the @provider into a string representation in CSS 1346 * format. 1347 * 1348 * Using gtk_css_provider_load_from_data() with the return value 1349 * from this function on a new provider created with 1350 * gtk_css_provider_new() will basically create a duplicate of 1351 * this @provider. 1352 * 1353 * Return: a new string representing the @provider. 1354 * 1355 * Since: 3.2 1356 */ 1357 public override string toString() 1358 { 1359 return Str.toString(gtk_css_provider_to_string(gtkCssProvider)); 1360 } 1361 1362 int[string] connectedSignals; 1363 1364 void delegate(CssSection, ErrorG, CssProvider)[] onParsingErrorListeners; 1365 /** 1366 * Signals that a parsing error occured. the @path, @line and @position 1367 * describe the actual location of the error as accurately as possible. 1368 * 1369 * Parsing errors are never fatal, so the parsing will resume after 1370 * the error. Errors may however cause parts of the given 1371 * data or even all of it to not be parsed at all. So it is a useful idea 1372 * to check that the parsing succeeds by connecting to this signal. 1373 * 1374 * Note that this signal may be emitted at any time as the css provider 1375 * may opt to defer parsing parts or all of the input to a later time 1376 * than when a loading function was called. 1377 * 1378 * Params: 1379 * section = section the error happened in 1380 * error = The parsing error 1381 */ 1382 void addOnParsingError(void delegate(CssSection, ErrorG, CssProvider) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1383 { 1384 if ( "parsing-error" !in connectedSignals ) 1385 { 1386 Signals.connectData( 1387 this, 1388 "parsing-error", 1389 cast(GCallback)&callBackParsingError, 1390 cast(void*)this, 1391 null, 1392 connectFlags); 1393 connectedSignals["parsing-error"] = 1; 1394 } 1395 onParsingErrorListeners ~= dlg; 1396 } 1397 extern(C) static void callBackParsingError(GtkCssProvider* cssproviderStruct, GtkCssSection* section, GError* error, CssProvider _cssprovider) 1398 { 1399 foreach ( void delegate(CssSection, ErrorG, CssProvider) dlg; _cssprovider.onParsingErrorListeners ) 1400 { 1401 dlg(ObjectG.getDObject!(CssSection)(section), new ErrorG(error), _cssprovider); 1402 } 1403 } 1404 }