1. ------------------------------------------------------------------------------ 
  2. --                                                                          -- 
  3. --      Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet       -- 
  4. --                     Copyright (C) 2000-2014, AdaCore                     -- 
  5. --                                                                          -- 
  6. -- This library is free software;  you can redistribute it and/or modify it -- 
  7. -- under terms of the  GNU General Public License  as published by the Free -- 
  8. -- Software  Foundation;  either version 3,  or (at your  option) any later -- 
  9. -- version. This library is distributed in the hope that it will be useful, -- 
  10. -- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- -- 
  11. -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.                            -- 
  12. --                                                                          -- 
  13. -- As a special exception under Section 7 of GPL version 3, you are granted -- 
  14. -- additional permissions described in the GCC Runtime Library Exception,   -- 
  15. -- version 3.1, as published by the Free Software Foundation.               -- 
  16. --                                                                          -- 
  17. -- You should have received a copy of the GNU General Public License and    -- 
  18. -- a copy of the GCC Runtime Library Exception along with this program;     -- 
  19. -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    -- 
  20. -- <http://www.gnu.org/licenses/>.                                          -- 
  21. --                                                                          -- 
  22. ------------------------------------------------------------------------------ 
  23.  
  24. --  <description> 
  25. --  GtkCssProvider is an object implementing the 
  26. --  Gtk.Style_Provider.Gtk_Style_Provider interface. It is able to parse <ulink 
  27. --  url="http://www.w3.org/TR/CSS2">CSS</ulink>-like input in order to style 
  28. --  widgets. 
  29. -- 
  30. --  == Default files == 
  31. -- 
  32. --  An application can cause GTK+ to parse a specific CSS style sheet by 
  33. --  calling gtk_css_provider_load_from_file and adding the provider with 
  34. --  Gtk.Style_Context.Add_Provider or 
  35. --  Gtk.Style_Context.Add_Provider_For_Screen. In addition, certain files will 
  36. --  be read when GTK+ is initialized. First, the file 
  37. --  '<envar>$XDG_CONFIG_HOME</envar>/gtk-3.0/gtk.css' is loaded if it exists. 
  38. --  Then, GTK+ tries to load 
  39. --  '<envar>$HOME</envar>/.themes/<replaceable>theme-name</replaceable>/gtk-3.0/gtk.css', 
  40. --  falling back to 
  41. --  '<replaceable>datadir</replaceable>/share/themes/<replaceable>theme-name</replaceable>/gtk-3.0/gtk.css', 
  42. --  where <replaceable>theme-name</replaceable> is the name of the current 
  43. --  theme (see the Gtk.Settings.Gtk_Settings:gtk-theme-name setting) and 
  44. --  <replaceable>datadir</replaceable> is the prefix configured when GTK+ was 
  45. --  compiled, unless overridden by the <envar>GTK_DATA_PREFIX</envar> 
  46. --  environment variable. 
  47. -- 
  48. --  == Style sheets == 
  49. -- 
  50. --  The basic structure of the style sheets understood by this provider is a 
  51. --  series of statements, which are either rule sets or '@-rules', separated by 
  52. --  whitespace. 
  53. -- 
  54. --  A rule set consists of a selector and a declaration block, which is a 
  55. --  series of declarations enclosed in curly braces ({ and }). The declarations 
  56. --  are separated by semicolons (;). Multiple selectors can share the same 
  57. --  declaration block, by putting all the separators in front of the block, 
  58. --  separated by commas. 
  59. -- 
  60. --  == A rule set with two selectors == 
  61. -- 
  62. --  <programlisting language="text"> GtkButton, GtkEntry { color: &num;ff00ea; 
  63. --  font: Comic Sans 12 } </programlisting> 
  64. --  == Selectors == 
  65. -- 
  66. --  Selectors work very similar to the way they do in CSS, with widget class 
  67. --  names taking the role of element names, and widget names taking the role of 
  68. --  IDs. When used in a selector, widget names must be prefixed with a '&num;' 
  69. --  character. The '*' character represents the so-called universal selector, 
  70. --  which matches any widget. 
  71. -- 
  72. --  To express more complicated situations, selectors can be combined in 
  73. --  various ways: 
  74. -- 
  75. --     * To require that a widget satisfies several conditions, combine 
  76. --  several selectors into one by concatenating them. E.g. 
  77. --  'GtkButton&num;button1' matches a GtkButton widget with the name button1. 
  78. -- 
  79. --     * To only match a widget when it occurs inside some other widget, write 
  80. --  the two selectors after each other, separated by whitespace. E.g. 
  81. --  'GtkToolBar GtkButton' matches GtkButton widgets that occur inside a 
  82. --  GtkToolBar. 
  83. -- 
  84. --     * In the previous example, the GtkButton is matched even if it occurs 
  85. --  deeply nested inside the toolbar. To restrict the match to direct children 
  86. --  of the parent widget, insert a '>' character between the two selectors. 
  87. --  E.g. 'GtkNotebook > GtkLabel' matches GtkLabel widgets that are direct 
  88. --  children of a GtkNotebook. 
  89. -- 
  90. --  == Widget classes and names in selectors == 
  91. -- 
  92. --  <programlisting language="text"> /* Theme labels that are descendants of a 
  93. --  window */ GtkWindow GtkLabel { background-color: &num;898989 } 
  94. --  /* Theme notebooks, and anything that's within these */ GtkNotebook { 
  95. --  background-color: &num;a939f0 } 
  96. -- 
  97. --  /* Theme combo boxes, and entries that are direct children of a notebook 
  98. --  */ GtkComboBox, GtkNotebook > GtkEntry { color: Fg_Color; background-color: 
  99. --  &num;1209a2 } 
  100. -- 
  101. --  /* Theme any widget within a GtkBin */ GtkBin * { font: Sans 20 } 
  102. -- 
  103. --  /* Theme a label named title-label */ GtkLabel&num;title-label { font: 
  104. --  Sans 15 } 
  105. -- 
  106. --  /* Theme any widget named main-entry */ &num;main-entry { 
  107. --  background-color: &num;f0a810 } </programlisting> 
  108. -- 
  109. --  Widgets may also define style classes, which can be used for matching. 
  110. --  When used in a selector, style classes must be prefixed with a '.' 
  111. --  character. 
  112. -- 
  113. --  Refer to the documentation of individual widgets to learn which style 
  114. --  classes they define and see <xref linkend="gtkstylecontext-classes"/> for a 
  115. --  list of all style classes used by GTK+ widgets. 
  116. -- 
  117. --  Note that there is some ambiguity in the selector syntax when it comes to 
  118. --  differentiation widget class names from regions. GTK+ currently treats a 
  119. --  string as a widget class name if it contains any uppercase characters 
  120. --  (which should work for more widgets with names like GtkLabel). 
  121. -- 
  122. --  == Style classes in selectors == 
  123. -- 
  124. --  <programlisting language="text"> /* Theme all widgets defining the class 
  125. --  entry */ .entry { color: &num;39f1f9; } 
  126. --  /* Theme spinbuttons' entry */ GtkSpinButton.entry { color: &num;900185 } 
  127. --  </programlisting> 
  128. -- 
  129. --  In complicated widgets like e.g. a GtkNotebook, it may be desirable to 
  130. --  style different parts of the widget differently. To make this possible, 
  131. --  container widgets may define regions, whose names may be used for matching 
  132. --  in selectors. 
  133. -- 
  134. --  Some containers allow to further differentiate between regions by applying 
  135. --  so-called pseudo-classes to the region. For example, the tab region in 
  136. --  GtkNotebook allows to single out the first or last tab by using the 
  137. --  :first-child or :last-child pseudo-class. When used in selectors, 
  138. --  pseudo-classes must be prefixed with a ':' character. 
  139. -- 
  140. --  Refer to the documentation of individual widgets to learn which regions 
  141. --  and pseudo-classes they define and see <xref 
  142. --  linkend="gtkstylecontext-classes"/> for a list of all regions used by GTK+ 
  143. --  widgets. 
  144. -- 
  145. --  == Regions in selectors == 
  146. -- 
  147. --  <programlisting language="text"> /* Theme any label within a notebook */ 
  148. --  GtkNotebook GtkLabel { color: &num;f90192; } 
  149. --  /* Theme labels within notebook tabs */ GtkNotebook tab GtkLabel { color: 
  150. --  &num;703910; } 
  151. -- 
  152. --  /* Theme labels in the any first notebook tab, both selectors are 
  153. --  equivalent */ GtkNotebook tab:nth-child(first) GtkLabel, GtkNotebook 
  154. --  tab:first-child GtkLabel { color: &num;89d012; } </programlisting> 
  155. -- 
  156. --  Another use of pseudo-classes is to match widgets depending on their 
  157. --  state. This is conceptually similar to the :hover, :active or :focus 
  158. --  pseudo-classes in CSS. The available pseudo-classes for widget states are 
  159. --  :active, :prelight (or :hover), :insensitive, :selected, :focused and 
  160. --  :inconsistent. 
  161. -- 
  162. --  == Styling specific widget states == 
  163. -- 
  164. --  <programlisting language="text"> /* Theme active (pressed) buttons */ 
  165. --  GtkButton:active { background-color: &num;0274d9; } 
  166. --  /* Theme buttons with the mouse pointer on it, both are equivalent */ 
  167. --  GtkButton:hover, GtkButton:prelight { background-color: &num;3085a9; } 
  168. -- 
  169. --  /* Theme insensitive widgets, both are equivalent */ :insensitive, 
  170. --  *:insensitive { background-color: &num;320a91; } 
  171. -- 
  172. --  /* Theme selection colors in entries */ GtkEntry:selected { 
  173. --  background-color: &num;56f9a0; } 
  174. -- 
  175. --  /* Theme focused labels */ GtkLabel:focused { background-color: 
  176. --  &num;b4940f; } 
  177. -- 
  178. --  /* Theme inconsistent checkbuttons */ GtkCheckButton:inconsistent { 
  179. --  background-color: &num;20395a; } </programlisting> 
  180. -- 
  181. --  Widget state pseudoclasses may only apply to the last element in a 
  182. --  selector. 
  183. -- 
  184. --  To determine the effective style for a widget, all the matching rule sets 
  185. --  are merged. As in CSS, rules apply by specificity, so the rules whose 
  186. --  selectors more closely match a widget path will take precedence over the 
  187. --  others. 
  188. -- 
  189. --  == &commat; Rules == 
  190. -- 
  191. --  GTK+'s CSS supports the &commat;import rule, in order to load another CSS 
  192. --  style sheet in addition to the currently parsed one. 
  193. -- 
  194. --  == Using the &commat;import rule == 
  195. -- 
  196. --  <programlisting language="text"> &commat;import url 
  197. --  ("path/to/common.css"); </programlisting> 
  198. --  <para id="css-binding-set"> In order to extend key bindings affecting 
  199. --  different widgets, GTK+ supports the &commat;binding-set rule to parse a 
  200. --  set of bind/unbind directives, see Gtk.Binding_Set.Gtk_Binding_Set for the 
  201. --  supported syntax. Note that the binding sets defined in this way must be 
  202. --  associated with rule sets by setting the gtk-key-bindings style property. 
  203. --  Customized key bindings are typically defined in a separate 'gtk-keys.css' 
  204. --  CSS file and GTK+ loads this file according to the current key theme, which 
  205. --  is defined by the Gtk.Settings.Gtk_Settings:gtk-key-theme-name setting. 
  206. -- 
  207. --  == Using the &commat;binding rule == 
  208. -- 
  209. --  <programlisting language="text"> &commat;binding-set binding-set1 { bind 
  210. --  "<alt>Left" { "move-cursor" (visual-positions, -3, 0) }; unbind "End"; }; 
  211. --  &commat;binding-set binding-set2 { bind "<alt>Right" { "move-cursor" 
  212. --  (visual-positions, 3, 0) }; bind "<alt>KP_space" { "delete-from-cursor" 
  213. --  (whitespace, 1) "insert-at-cursor" (" ") }; }; 
  214. -- 
  215. --  GtkEntry { gtk-key-bindings: binding-set1, binding-set2; } 
  216. --  </programlisting> 
  217. -- 
  218. --  GTK+ also supports an additional &commat;define-color rule, in order to 
  219. --  define a color name which may be used instead of color numeric 
  220. --  representations. Also see the Gtk.Settings.Gtk_Settings:gtk-color-scheme 
  221. --  setting for a way to override the values of these named colors. 
  222. -- 
  223. --  == Defining colors == 
  224. -- 
  225. --  <programlisting language="text"> &commat;define-color bg_color 
  226. --  &num;f9a039; 
  227. --  * { background-color: &commat;bg_color; } </programlisting> 
  228. -- 
  229. --  == Symbolic colors == 
  230. -- 
  231. --  Besides being able to define color names, the CSS parser is also able to 
  232. --  read different color expressions, which can also be nested, providing a 
  233. --  rich language to define colors which are derived from a set of base colors. 
  234. -- 
  235. --  == Using symbolic colors == 
  236. -- 
  237. --  <programlisting language="text"> &commat;define-color entry-color shade 
  238. --  (&commat;bg_color, 0.7); 
  239. --  GtkEntry { background-color: Entry-color; } 
  240. -- 
  241. --  GtkEntry:focused { background-color: mix (&commat;entry-color, shade 
  242. --  (&num;fff, 0.5), 0.8); } </programlisting> 
  243. -- 
  244. --  The various ways to express colors in GTK+ CSS are: 
  245. -- 
  246. --  <thead> 
  247. --  Syntax 
  248. -- 
  249. --  Explanation 
  250. -- 
  251. --  Examples </thead> 
  252. -- 
  253. --  rgb(R, G, B) 
  254. -- 
  255. --  An opaque color; R, G, B can be either integers between 0 and 255 or 
  256. --  percentages 
  257. -- 
  258. --  <literallayout>rgb(128, 10, 54) rgb(20%, 30%, 0%)</literallayout> 
  259. --  rgba(R, G, B, A) 
  260. -- 
  261. --  A translucent color; R, G, B are as in the previous row, A is a floating 
  262. --  point number between 0 and 1 
  263. -- 
  264. --  <literallayout>rgba(255, 255, 0, 0.5)</literallayout> 
  265. --  &num;Xxyyzz 
  266. -- 
  267. --  An opaque color; Xx, Yy, Zz are hexadecimal numbers specifying R, G, B 
  268. --  variants with between 1 and 4 hexadecimal digits per component are allowed 
  269. -- 
  270. --  <literallayout>&num;ff12ab &num;f0c</literallayout> 
  271. --  &commat;name 
  272. -- 
  273. --  Reference to a color that has been defined with &commat;define-color 
  274. -- 
  275. --  &commat;bg_color 
  276. -- 
  277. --  mix(Color1, Color2, F) 
  278. -- 
  279. --  A linear combination of Color1 and Color2. F is a floating point number 
  280. --  between 0 and 1. 
  281. -- 
  282. --  <literallayout>mix(&num;ff1e0a, &commat;bg_color, 0.8)</literallayout> 
  283. --  shade(Color, F) 
  284. -- 
  285. --  A lighter or darker variant of Color. F is a floating point number. 
  286. -- 
  287. --  shade(&commat;fg_color, 0.5) 
  288. -- 
  289. --  lighter(Color) 
  290. -- 
  291. --  A lighter variant of Color 
  292. -- 
  293. --  darker(Color) 
  294. -- 
  295. --  A darker variant of Color 
  296. -- 
  297. --  alpha(Color, F) 
  298. -- 
  299. --  Modifies passed color's alpha by a factor F. F is a floating point number. 
  300. --  F < 1.0 results in a more transparent color while F > 1.0 results in a more 
  301. --  opaque color. 
  302. -- 
  303. --  alhpa(blue, 0.5) 
  304. -- 
  305. --  == Gradients == 
  306. -- 
  307. --  Linear or radial Gradients can be used as background images. 
  308. -- 
  309. --  A linear gradient along the line from (Start_X, Start_Y) to (End_X, End_Y) 
  310. --  is specified using the syntax <literallayout>-gtk-gradient (linear, Start_X 
  311. --  Start_Y, End_X End_Y, color-stop (Position, Color), ...)</literallayout> 
  312. --  where Start_X and End_X can be either a floating point number between 0 and 
  313. --  1 or one of the special values 'left', 'right' or 'center', Start_Y and 
  314. --  End_Y can be either a floating point number between 0 and 1 or one of the 
  315. --  special values 'top', 'bottom' or 'center', Position is a floating point 
  316. --  number between 0 and 1 and Color is a color expression (see above). The 
  317. --  color-stop can be repeated multiple times to add more than one color stop. 
  318. --  'from (Color)' and 'to (Color)' can be used as abbreviations for color 
  319. --  stops with position 0 and 1, respectively. 
  320. -- 
  321. --  == A linear gradient == 
  322. -- 
  323. --  <inlinegraphic fileref="gradient1.png" format="PNG"/> 
  324. --  This gradient was specified with <literallayout>-gtk-gradient (linear, 
  325. --  left top, right bottom, from(&commat;yellow), 
  326. --  to(&commat;blue))</literallayout> 
  327. -- 
  328. --  == Another linear gradient == 
  329. -- 
  330. --  <inlinegraphic fileref="gradient2.png" format="PNG"/> 
  331. --  This gradient was specified with <literallayout>-gtk-gradient (linear, 0 
  332. --  0, 0 1, color-stop(0, &commat;yellow), color-stop(0.2, &commat;blue), 
  333. --  color-stop(1, &num;0f0))</literallayout> 
  334. -- 
  335. --  A radial gradient along the two circles defined by (Start_X, Start_Y, 
  336. --  Start_Radius) and (End_X, End_Y, End_Radius) is specified using the syntax 
  337. --  <literallayout>-gtk-gradient (radial, Start_X Start_Y, Start_Radius, End_X 
  338. --  End_Y, End_Radius, color-stop (Position, Color), ...)</literallayout> where 
  339. --  Start_Radius and End_Radius are floating point numbers and the other 
  340. --  parameters are as before. 
  341. -- 
  342. --  == A radial gradient == 
  343. -- 
  344. --  <inlinegraphic fileref="gradient3.png" format="PNG"/> 
  345. --  This gradient was specified with <literallayout>-gtk-gradient (radial, 
  346. --  center center, 0, center center, 1, from(&commat;yellow), 
  347. --  to(&commat;green))</literallayout> 
  348. -- 
  349. --  == Another radial gradient == 
  350. -- 
  351. --  <inlinegraphic fileref="gradient4.png" format="PNG"/> 
  352. --  This gradient was specified with <literallayout>-gtk-gradient (radial, 0.4 
  353. --  0.4, 0.1, 0.6 0.6, 0.7, color-stop (0, &num;f00), color-stop (0.1, 
  354. --  &num;a0f), color-stop (0.2, &commat;yellow), color-stop (1, 
  355. --  &commat;green))</literallayout> 
  356. -- 
  357. --  == Text shadow == 
  358. -- 
  359. --  A shadow list can be applied to text or symbolic icons, using the CSS3 
  360. --  text-shadow syntax, as defined in <ulink 
  361. --  url="http://www.w3.org/TR/css3-text/text-shadow">the CSS3 
  362. --  specification</ulink>. 
  363. -- 
  364. --  A text shadow is specified using the syntax <literallayout>text-shadow: 
  365. --  Horizontal_Offset Vertical_Offset [ Blur_Radius ] Color</literallayout> The 
  366. --  offset of the shadow is specified with the Horizontal_Offset and 
  367. --  Vertical_Offset parameters. The optional blur radius is parsed, but it is 
  368. --  currently not rendered by the GTK+ theming engine. 
  369. -- 
  370. --  To set multiple shadows on an element, you can specify a comma-separated 
  371. --  list of shadow elements in the text-shadow property. Shadows are always 
  372. --  rendered front-back, i.e. the first shadow specified is on top of the 
  373. --  others. Shadows can thus overlay each other, but they can never overlay the 
  374. --  text itself, which is always rendered on top of the shadow layer. 
  375. -- 
  376. --  == Box shadow == 
  377. -- 
  378. --  Themes can apply shadows on framed elements using the CSS3 box-shadow 
  379. --  syntax, as defined in <ulink 
  380. --  url="http://www.w3.org/TR/css3-background/the-box-shadow">the CSS3 
  381. --  specification</ulink>. 
  382. -- 
  383. --  A box shadow is specified using the syntax <literallayout>box-shadow: [ 
  384. --  Inset ] Horizontal_Offset Vertical_Offset [ Blur_Radius ] [ Spread ] 
  385. --  Color</literallayout> A positive offset will draw a shadow that is offset 
  386. --  to the right (down) of the box, a negative offset to the left (top). The 
  387. --  optional spread parameter defines an additional distance to expand the 
  388. --  shadow shape in all directions, by the specified radius. The optional blur 
  389. --  radius parameter is parsed, but it is currently not rendered by the GTK+ 
  390. --  theming engine. The inset parameter defines whether the drop shadow should 
  391. --  be rendered inside or outside the box canvas. Only inset box-shadows are 
  392. --  currently supported by the GTK+ theming engine, non-inset elements are 
  393. --  currently ignored. 
  394. -- 
  395. --  To set multiple box-shadows on an element, you can specify a 
  396. --  comma-separated list of shadow elements in the box-shadow property. Shadows 
  397. --  are always rendered front-back, i.e. the first shadow specified is on top 
  398. --  of the others, so they may overlap other boxes or other shadows. 
  399. -- 
  400. --  == Border images == 
  401. -- 
  402. --  Images and gradients can also be used in slices for the purpose of 
  403. --  creating scalable borders. For more information, see the CSS3 documentation 
  404. --  for the border-image property, which can be found <ulink 
  405. --  url="http://www.w3.org/TR/css3-background/border-images">here</ulink>. 
  406. -- 
  407. --  <inlinegraphic fileref="slices.png" format="PNG"/> 
  408. --  The parameters of the slicing process are controlled by four separate 
  409. --  properties. Note that you can use the 
  410. --  <literallayout>border-image</literallayout> shorthand property to set 
  411. --  values for the three properties at the same time. 
  412. -- 
  413. --  <literallayout>border-image-source: url(Path) (or border-image-source: 
  414. --  -gtk-gradient(...))</literallayout>: Specifies the source of the border 
  415. --  image, and it can either be an URL or a gradient (see above). 
  416. --  <literallayout>border-image-slice: Top Right Bottom Left</literallayout> 
  417. --  The sizes specified by the Top, Right, Bottom and Left parameters are the 
  418. --  offsets, in pixels, from the relevant edge where the image should be "cut 
  419. --  off" to build the slices used for the rendering of the border. 
  420. --  <literallayout>border-image-width: Top Right Bottom Left</literallayout> 
  421. --  The sizes specified by the Top, Right, Bottom and Left parameters are 
  422. --  inward distances from the border box edge, used to specify the rendered 
  423. --  size of each slice determined by border-image-slice. If this property is 
  424. --  not specified, the values of border-width will be used as a fallback. 
  425. --  <literallayout>border-image-repeat: [stretch|repeat|round|space] ? 
  426. --  [stretch|repeat|round|space]</literallayout> Specifies how the image slices 
  427. --  should be rendered in the area outlined by border-width. The default 
  428. --  (stretch) is to resize the slice to fill in the whole allocated area. If 
  429. --  the value of this property is 'repeat', the image slice will be tiled to 
  430. --  fill the area. If the value of this property is 'round', the image slice 
  431. --  will be tiled to fill the area, and scaled to fit it exactly a whole number 
  432. --  of times. If the value of this property is 'space', the image slice will be 
  433. --  tiled to fill the area, and if it doesn't fit it exactly a whole number of 
  434. --  times, the extra space is distributed as padding around the slices. If two 
  435. --  options are specified, the first one affects the horizontal behaviour and 
  436. --  the second one the vertical behaviour. If only one option is specified, it 
  437. --  affects both. 
  438. --  == A border image == 
  439. -- 
  440. --  <inlinegraphic fileref="border1.png" format="PNG"/> 
  441. --  This border image was specified with <literallayout>url("gradient1.png") 
  442. --  10 10 10 10</literallayout> 
  443. -- 
  444. --  == A repeating border image == 
  445. -- 
  446. --  <inlinegraphic fileref="border2.png" format="PNG"/> 
  447. --  This border image was specified with <literallayout>url("gradient1.png") 
  448. --  10 10 10 10 repeat</literallayout> 
  449. -- 
  450. --  == A stretched border image == 
  451. -- 
  452. --  <inlinegraphic fileref="border3.png" format="PNG"/> 
  453. --  This border image was specified with <literallayout>url("gradient1.png") 
  454. --  10 10 10 10 stretch</literallayout> 
  455. -- 
  456. --  Styles can specify transitions that will be used to create a gradual 
  457. --  change in the appearance when a widget state changes. The following syntax 
  458. --  is used to specify transitions: <literallayout>Duration [s|ms] 
  459. --  [linear|ease|ease-in|ease-out|ease-in-out] [loop]?</literallayout> The 
  460. --  Duration is the amount of time that the animation will take for a complete 
  461. --  cycle from start to end. If the loop option is given, the animation will be 
  462. --  repated until the state changes again. The option after the duration 
  463. --  determines the transition function from a small set of predefined 
  464. --  functions. <figure> 
  465. -- 
  466. --  == Linear transition == 
  467. -- 
  468. --  <graphic fileref="linear.png" format="PNG"/> </figure> <figure> 
  469. --  == Ease transition == 
  470. -- 
  471. --  <graphic fileref="ease.png" format="PNG"/> </figure> <figure> 
  472. --  == Ease-in-out transition == 
  473. -- 
  474. --  <graphic fileref="ease-in-out.png" format="PNG"/> </figure> <figure> 
  475. --  == Ease-in transition == 
  476. -- 
  477. --  <graphic fileref="ease-in.png" format="PNG"/> </figure> <figure> 
  478. --  == Ease-out transition == 
  479. -- 
  480. --  <graphic fileref="ease-out.png" format="PNG"/> </figure> 
  481. --  == Supported properties == 
  482. -- 
  483. --  Properties are the part that differ the most to common CSS, not all 
  484. --  properties are supported (some are planned to be supported eventually, some 
  485. --  others are meaningless or don't map intuitively in a widget based 
  486. --  environment). 
  487. -- 
  488. --  The currently supported properties are: 
  489. -- 
  490. --  <thead> 
  491. --  Property name 
  492. -- 
  493. --  Syntax 
  494. -- 
  495. --  Maps to 
  496. -- 
  497. --  Examples </thead> 
  498. -- 
  499. --  engine 
  500. -- 
  501. --  engine-name 
  502. -- 
  503. --  Gtk.Theming_Engine.Gtk_Theming_Engine 
  504. -- 
  505. --  engine: clearlooks; engine: none; /* use the default (i.e. builtin) 
  506. --  engine) */ 
  507. -- 
  508. --  background-color <entry morerows="2">color (see above) <entry 
  509. --  morerows="7">Gdk.RGBA.Gdk_RGBA <entry 
  510. --  morerows="7"><literallayout>background-color: &num;fff; color: &amp;color1; 
  511. --  background-color: shade (&amp;color1, 0.5); color: mix (&amp;color1, 
  512. --  &num;f0f, 0.8);</literallayout> 
  513. -- 
  514. --  color 
  515. -- 
  516. --  border-top-color <entry morerows="4">transparent|color (see above) 
  517. -- 
  518. --  border-right-color 
  519. -- 
  520. --  border-bottom-color 
  521. -- 
  522. --  border-left-color 
  523. -- 
  524. --  border-color 
  525. -- 
  526. --  [transparent|color]{1,4} 
  527. -- 
  528. --  font-family 
  529. -- 
  530. --  Family [, Family]* 
  531. -- 
  532. --  gchararray 
  533. -- 
  534. --  font-family: Sans, Arial; 
  535. -- 
  536. --  font-style 
  537. -- 
  538. --  [normal|oblique|italic] 
  539. -- 
  540. --  PANGO_TYPE_STYLE 
  541. -- 
  542. --  font-style: italic; 
  543. -- 
  544. --  font-variant 
  545. -- 
  546. --  [normal|small-caps] 
  547. -- 
  548. --  PANGO_TYPE_VARIANT 
  549. -- 
  550. --  font-variant: normal; 
  551. -- 
  552. --  font-weight 
  553. -- 
  554. --  [normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900] 
  555. -- 
  556. --  PANGO_TYPE_WEIGHT 
  557. -- 
  558. --  font-weight: bold; 
  559. -- 
  560. --  font-size 
  561. -- 
  562. --  Font size in point 
  563. -- 
  564. --  Gint 
  565. -- 
  566. --  font-size: 13; 
  567. -- 
  568. --  font 
  569. -- 
  570. --  Family [Style] [Size] 
  571. -- 
  572. --  Pango.Font.Pango_Font_Description 
  573. -- 
  574. --  font: Sans 15; 
  575. -- 
  576. --  margin-top 
  577. -- 
  578. --  integer 
  579. -- 
  580. --  Gint 
  581. -- 
  582. --  margin-top: 0; 
  583. -- 
  584. --  margin-left 
  585. -- 
  586. --  integer 
  587. -- 
  588. --  Gint 
  589. -- 
  590. --  margin-left: 1; 
  591. -- 
  592. --  margin-bottom 
  593. -- 
  594. --  integer 
  595. -- 
  596. --  Gint 
  597. -- 
  598. --  margin-bottom: 2; 
  599. -- 
  600. --  margin-right 
  601. -- 
  602. --  integer 
  603. -- 
  604. --  Gint 
  605. -- 
  606. --  margin-right: 4; 
  607. -- 
  608. --  margin <entry morerows="1"><literallayout>Width Vertical_Width 
  609. --  Horizontal_Width Top_Width Horizontal_Width Bottom_Width Top_Width 
  610. --  Right_Width Bottom_Width Left_Width</literallayout> <entry 
  611. --  morerows="1">Gtk.Style.Gtk_Border <entry 
  612. --  morerows="1"><literallayout>margin: 5; margin: 5 10; margin: 5 10 3; 
  613. --  margin: 5 10 3 5;</literallayout> 
  614. -- 
  615. --  padding-top 
  616. -- 
  617. --  integer 
  618. -- 
  619. --  Gint 
  620. -- 
  621. --  padding-top: 5; 
  622. -- 
  623. --  padding-left 
  624. -- 
  625. --  integer 
  626. -- 
  627. --  Gint 
  628. -- 
  629. --  padding-left: 5; 
  630. -- 
  631. --  padding-bottom 
  632. -- 
  633. --  integer 
  634. -- 
  635. --  Gint 
  636. -- 
  637. --  padding-bottom: 5; 
  638. -- 
  639. --  padding-right 
  640. -- 
  641. --  integer 
  642. -- 
  643. --  Gint 
  644. -- 
  645. --  padding-right: 5; 
  646. -- 
  647. --  padding 
  648. -- 
  649. --  background-image 
  650. -- 
  651. --  <literallayout>gradient (see above) or url(Path)</literallayout> 
  652. --  cairo_pattern_t 
  653. -- 
  654. --  <literallayout>-gtk-gradient (linear, left top, right top, from 
  655. --  (&num;fff), to (&num;000)); -gtk-gradient (linear, 0.0 0.5, 0.5 1.0, from 
  656. --  (&num;fff), color-stop (0.5, &num;f00), to (&num;000)); -gtk-gradient 
  657. --  (radial, center center, 0.2, center center, 0.8, color-stop (0.0, 
  658. --  &num;fff), color-stop (1.0, &num;000)); url 
  659. --  ('background.png');</literallayout> 
  660. --  background-repeat 
  661. -- 
  662. --  [repeat|no-repeat] 
  663. -- 
  664. --  internal 
  665. -- 
  666. --  <literallayout>background-repeat: no-repeat;</literallayout> If not 
  667. --  specified, the style doesn't respect the CSS3 specification, since the 
  668. --  background will be stretched to fill the area. 
  669. --  border-top-width 
  670. -- 
  671. --  integer 
  672. -- 
  673. --  Gint 
  674. -- 
  675. --  border-top-width: 5; 
  676. -- 
  677. --  border-left-width 
  678. -- 
  679. --  integer 
  680. -- 
  681. --  Gint 
  682. -- 
  683. --  border-left-width: 5; 
  684. -- 
  685. --  border-bottom-width 
  686. -- 
  687. --  integer 
  688. -- 
  689. --  Gint 
  690. -- 
  691. --  border-bottom-width: 5; 
  692. -- 
  693. --  border-right-width 
  694. -- 
  695. --  integer 
  696. -- 
  697. --  Gint 
  698. -- 
  699. --  border-right-width: 5; 
  700. -- 
  701. --  border-width <entry morerows="1">Gtk.Style.Gtk_Border <entry 
  702. --  morerows="1"><literallayout>border-width: 1; border-width: 1 2; 
  703. --  border-width: 1 2 3; border-width: 1 2 3 5;</literallayout> 
  704. -- 
  705. --  border-radius 
  706. -- 
  707. --  integer 
  708. -- 
  709. --  Gint 
  710. -- 
  711. --  border-radius: 5; 
  712. -- 
  713. --  border-style 
  714. -- 
  715. --  [none|solid|inset|outset] 
  716. -- 
  717. --  Gtk_Border_Style 
  718. -- 
  719. --  border-style: solid; 
  720. -- 
  721. --  border-image 
  722. -- 
  723. --  <literallayout>border image (see above)</literallayout> 
  724. --  internal use only 
  725. -- 
  726. --  <literallayout>border-image: url("/path/to/image.png") 3 4 3 4 stretch; 
  727. --  border-image: url("/path/to/image.png") 3 4 4 3 repeat 
  728. --  stretch;</literallayout> 
  729. --  text-shadow 
  730. -- 
  731. --  shadow list (see above) 
  732. -- 
  733. --  internal use only 
  734. -- 
  735. --  <literallayout>text-shadow: 1 1 0 blue, -4 -4 red;</literallayout> 
  736. --  transition 
  737. -- 
  738. --  transition (see above) 
  739. -- 
  740. --  internal use only 
  741. -- 
  742. --  <literallayout>transition: 150ms ease-in-out; transition: 1s linear 
  743. --  loop;</literallayout> 
  744. --  gtk-key-bindings 
  745. -- 
  746. --  binding set name list 
  747. -- 
  748. --  internal use only 
  749. -- 
  750. --  <literallayout>gtk-bindings: binding1, binding2, ...;</literallayout> 
  751. --  GtkThemingEngines can register their own, engine-specific style properties 
  752. --  with the function gtk_theming_engine_register_property. These properties 
  753. --  can be set in CSS like other properties, using a name of the form 
  754. --  <literallayout>-<replaceable>namespace</replaceable>-<replaceable>name</replaceable></literallayout>, 
  755. --  where <replaceable>namespace</replaceable> is typically the name of the 
  756. --  theming engine, and <replaceable>name</replaceable> is the name of the 
  757. --  property. Style properties that have been registered by widgets using 
  758. --  Gtk.Widget.Install_Style_Property can also be set in this way, using the 
  759. --  widget class name for <replaceable>namespace</replaceable>. 
  760. -- 
  761. --  == Using engine-specific style properties == 
  762. -- 
  763. --    * { 
  764. --       engine: clearlooks; 
  765. --       border-radius: 4; 
  766. --       -GtkPaned-handle-size: 6; 
  767. --       -clearlooks-colorize-scrollbar: false; 
  768. --    } 
  769. -- 
  770. -- 
  771. --  </description> 
  772. pragma Ada_2005; 
  773.  
  774. pragma Warnings (Off, "*is already use-visible*"); 
  775. with Glib;               use Glib; 
  776. with Glib.Error;         use Glib.Error; 
  777. with Glib.Object;        use Glib.Object; 
  778. with Glib.Types;         use Glib.Types; 
  779. with Glib.Values;        use Glib.Values; 
  780. with Gtk.Enums;          use Gtk.Enums; 
  781. with Gtk.Style_Provider; use Gtk.Style_Provider; 
  782. with Gtk.Widget;         use Gtk.Widget; 
  783.  
  784. package Gtk.Css_Provider is 
  785.  
  786.    type Gtk_Css_Provider_Record is new GObject_Record with null record; 
  787.    type Gtk_Css_Provider is access all Gtk_Css_Provider_Record'Class; 
  788.  
  789.    ------------------ 
  790.    -- Constructors -- 
  791.    ------------------ 
  792.  
  793.    procedure Gtk_New (Self : out Gtk_Css_Provider); 
  794.    procedure Initialize 
  795.       (Self : not null access Gtk_Css_Provider_Record'Class); 
  796.    --  Returns a newly created Gtk.Css_Provider.Gtk_Css_Provider. 
  797.  
  798.    function Gtk_Css_Provider_New return Gtk_Css_Provider; 
  799.    --  Returns a newly created Gtk.Css_Provider.Gtk_Css_Provider. 
  800.  
  801.    function Get_Type return Glib.GType; 
  802.    pragma Import (C, Get_Type, "gtk_css_provider_get_type"); 
  803.  
  804.    ------------- 
  805.    -- Methods -- 
  806.    ------------- 
  807.  
  808.    function Load_From_Data 
  809.       (Self  : not null access Gtk_Css_Provider_Record; 
  810.        Data  : UTF8_String; 
  811.        Error : access Glib.Error.GError) return Boolean; 
  812.    --  Loads Data into Css_Provider, making it clear any previously loaded 
  813.    --  information. 
  814.    --  "data": CSS data loaded in memory 
  815.  
  816.    function Load_From_Path 
  817.       (Self  : not null access Gtk_Css_Provider_Record; 
  818.        Path  : UTF8_String; 
  819.        Error : access Glib.Error.GError) return Boolean; 
  820.    --  Loads the data contained in Path into Css_Provider, making it clear any 
  821.    --  previously loaded information. 
  822.    --  "path": the path of a filename to load, in the GLib filename encoding 
  823.  
  824.    function To_String 
  825.       (Self : not null access Gtk_Css_Provider_Record) return UTF8_String; 
  826.    --  Convertes the Provider into a string representation in CSS format. 
  827.    --  Using Gtk.Css_Provider.Load_From_Data with the return value from this 
  828.    --  function on a new provider created with Gtk.Css_Provider.Gtk_New will 
  829.    --  basicallu create a duplicate of this Provider. 
  830.    --  Since: gtk+ 3.2 
  831.  
  832.    --------------------------------------------- 
  833.    -- Inherited subprograms (from interfaces) -- 
  834.    --------------------------------------------- 
  835.  
  836.    procedure Get_Style_Property 
  837.       (Self  : not null access Gtk_Css_Provider_Record; 
  838.        Path  : Gtk.Widget.Gtk_Widget_Path; 
  839.        State : Gtk.Enums.Gtk_State_Flags; 
  840.        Pspec : in out Glib.Param_Spec; 
  841.        Value : out Glib.Values.GValue; 
  842.        Found : out Boolean); 
  843.  
  844.    --------------- 
  845.    -- Functions -- 
  846.    --------------- 
  847.  
  848.    function Get_Default return Gtk_Css_Provider; 
  849.    --  Returns the provider containing the style settings used as a fallback 
  850.    --  for all widgets. 
  851.  
  852.    function Get_Named 
  853.       (Name    : UTF8_String; 
  854.        Variant : UTF8_String := "") return Gtk_Css_Provider; 
  855.    --  Loads a theme from the usual theme paths 
  856.    --  "name": A theme name 
  857.    --  "variant": variant to load, for example, "dark", or null for the 
  858.    --  default 
  859.  
  860.    ------------- 
  861.    -- Signals -- 
  862.    ------------- 
  863.  
  864.    Signal_Parsing_Error : constant Glib.Signal_Name := "parsing-error"; 
  865.    --  Signals that a parsing error occured. the Path, Line and Position 
  866.    --  describe the actual location of the error as accurately as possible. 
  867.    -- 
  868.    --  Parsing errors are never fatal, so the parsing will resume after the 
  869.    --  error. Errors may however cause parts of the given data or even all of 
  870.    --  it to not be parsed at all. So it is a useful idea to check that the 
  871.    --  parsing succeeds by connecting to this signal. 
  872.    -- 
  873.    --  Note that this signal may be emitted at any time as the css provider 
  874.    --  may opt to defer parsing parts or all of the input to a later time than 
  875.    --  when a loading function was called. 
  876.    --    procedure Handler 
  877.    --       (Self    : access Gtk_Css_Provider_Record'Class; 
  878.    --        Section : Gtk.Css_Section.Gtk_Css_Section; 
  879.    --        Error   : GLib.Error) 
  880.    --  
  881.    --  Callback parameters: 
  882.    --    --  "section": section the error happened in 
  883.    --    --  "error": The parsing error 
  884.  
  885.    ---------------- 
  886.    -- Interfaces -- 
  887.    ---------------- 
  888.    --  This class implements several interfaces. See Glib.Types 
  889.    -- 
  890.    --  - "StyleProvider" 
  891.  
  892.    package Implements_Gtk_Style_Provider is new Glib.Types.Implements 
  893.      (Gtk.Style_Provider.Gtk_Style_Provider, Gtk_Css_Provider_Record, Gtk_Css_Provider); 
  894.    function "+" 
  895.      (Widget : access Gtk_Css_Provider_Record'Class) 
  896.    return Gtk.Style_Provider.Gtk_Style_Provider 
  897.    renames Implements_Gtk_Style_Provider.To_Interface; 
  898.    function "-" 
  899.      (Interf : Gtk.Style_Provider.Gtk_Style_Provider) 
  900.    return Gtk_Css_Provider 
  901.    renames Implements_Gtk_Style_Provider.To_Object; 
  902.  
  903. end Gtk.Css_Provider;