GtkStyle from CSS (and gtkrc using CSS syntax)



GtkStyle is a member of GtkWidget, determine how the widget have
appearance. GtkRcStyle create a GtkStyle object from a set of GtkStyle statements, AFAIS.

To make GtkStyle by GtkRcStyle, from CSS, a CSS parser make GtkStyle
statements from corresponding CSS statements.

and gtk_widget_set_style(widget, style) will do the rest of procedure
to apply CSS statements to GtkWidget, which suggest richer visual model
than GtkStyle does.

For instance, background statements will translate to GtkStyle::bg
or ~::base from background-color. and ~::bg_pixmap from background-image.
(base[] is replacement of bg[] for text widgets, AFAIK.
 so the same background-color statement for both of them.
 suggest another approach if this is wrong.)

and font statements are totally equivalent to PangoFontDescription.
Owen said: Pango's font handling is closely based on CSS font properties.
(some other statements like letter-spacing and word-spacing are matter)
'PangoFontDescription from CSS' is subset of 'GtkStyle from CSS'.

and filter extensions, like alpha, possibly supported by GTK+ in the
future.

Furthuremore, lexical units like EM or INCH proposed to gtk-devel-list
by jrb[1]. This is good news for implementing GtkStyle from CSS.


On the other hand, GtkStyle from CSS include another issue of
'gtkrc using CSS syntax'. For example:

style "default"{

#fonts
  fg[NORMAL] = "#000000"
  fg[PRELIGHT]  = "#000000"
  fg[SELECTED] = "#000000"

#selected areas
  base[SELECTED] = "#8a8aa0"
  base[ACTIVE]     = "#e3e3e3"
  base[PRELIGHT]   = "#E5E5F7"
  base[INSENSITIVE]= "#ced0d7"
  bg[SELECTED]= "#828aa4"

#app backgrouds
  bg_pixmap[NORMAL]     = "lines_background.png"
  bg_pixmap[PRELIGHT]   = "lines_background_blue.png"
}class "GtkWidget" style "default"
-- from Smokey-Blue/gtk-2.0/gtkrc

are mostly equivalent to

GtkWidget {
  color: black; /* fg[NORMAL] */
  background-image: url(lines_background.png);
}
GtkWidget:hover {
  color: black; /* fg[PRELIGHT] */
  background-color: #E5E5F7; /* base[PRELIGHT] */
  background-image: url(lines_background_blue.png);
}
GtkWidget:selected {
  color: black; /* fg[SELECTED] */
  bakcground-color: #8a8aa0; /* base[SELECTED] */
}
GtkWidget:active {
  background-color: #e3e3e3; /* base[ACTIVE] */
}
GtkWidget:disabled {
  background-color: #ced0d7; /* base[INSENSITIVE] */
}
(well, some of pseudo-classes are really pseudo. :P)

and other complex gtkrc possibly translated into CSS statements,
I believe.

'gtkrc using CSS syntax' is a stage to GtkStyle from CSS,
of gtkrc file itself using CSS syntax,
as well as in-memory gtkrc statements from CSS.


Request For Comments.

regard,
kz.

--
[1]
http://mail.gnome.org/archives/gtk-devel-list/2003-February/msg00009.html



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]