Commit Graph

57 Commits

Author SHA1 Message Date
Benjamin Otte
68ebc77a9a styleproperties: Add an unset vfunc to style properties
This makes unsetting work for shorthands.
2011-07-19 11:58:22 +02:00
Benjamin Otte
ba7d1c2104 styleproperty: Make default_value() take a state
Because of this, resolve() needs to take a state, too. This is so that
we can have default values depend on other values (like border color).
2011-06-13 15:01:52 +02:00
Cosimo Cecchi
e3dd437b67 styleproperty: turn border-image into a shorthand property
It's composed by
- border-image-source: a cairo_pattern_t holding an image from file or a
  gradient
- border-image-slice: a GtkBorder containing the slice offsets to apply
  on the image
- border-image-repeat: a GtkRepeatType for the image

We deviate from pure CSS3 in the following ways:

* border-image-width is assumed to be always 1, i.e. always equal to
  what's specified by border-width. I don't think it's a particularly
  useful property to have, but we could add it later if needed.
* border-image-outset is absent, as we can't render outside of the
  allocation yet.

https://bugzilla.gnome.org/show_bug.cgi?id=651194
2011-06-09 05:51:54 +02:00
Benjamin Otte
1845849596 styleproperty: Move resolving code
Also, resolving now always succeeds - if it doesn't we fall back to the
default value right here, instead of later.
2011-06-02 02:03:52 +02:00
Benjamin Otte
cc3afc7c0f Revert "API: Add API to set style properties to be inherit"
Inheritance is now done using style property flags, so thereis no ned
anymore to clobber the pspec flags namespace.
Also, there is no need to expose this functionality in the public API
without exposing more of the styleproperty API.

This essentially reverts commit 9bfd3d2eec.
2011-06-02 02:03:52 +02:00
Benjamin Otte
4feddc6190 styleproperty: Add flags
This allows to set a bunch of specific features, like inheritance in
here, without having to molest the psec.
2011-06-02 02:03:52 +02:00
Benjamin Otte
d59081310b styleproperties: Rename enum value
I want to use that same enum value elsewhere.
2011-06-02 02:03:52 +02:00
Benjamin Otte
66396d2bab styleproperty: Move default value setting to styleproperty.c 2011-06-02 02:03:52 +02:00
Benjamin Otte
914654901c styleproperties: use property, not pspec as key
This allows calling functions on the style property from more places.
2011-06-02 02:03:52 +02:00
Benjamin Otte
90ff426396 css: Add all border-radius properties
Implement all border-radisu properties as specified by
http://www.w3.org/TR/css3-background/#the-border-radius
The end goal here is to get joined buttons to really look joined.
2011-06-02 02:03:51 +02:00
Benjamin Otte
d14fbf3254 styleproperty: Allow passing in a parse func and a print func
It's not used yet, but it's now possible to specify a custom read or
write func.
2011-06-02 02:03:50 +02:00
Benjamin Otte
35488f5846 css: Rename struct variable
I want to add parse_func as something different soon.
2011-06-02 02:03:50 +02:00
Carlos Garnacho
b68172b2c6 gtkstyleproperties: zero GValue out before using G_VALUE_COLLECT_INIT()
Fixes invalid reads in valgrind
2011-05-30 19:18:41 +02:00
Benjamin Otte
0b653abcd4 styleproperties: Remove unused priv variables 2011-05-27 16:11:10 +02:00
Benjamin Otte
42a4bd1c5b style: Add support for shorthand properties
Shorthand properties are basically the same a in CSS. For storage in
style properties or the CSS provider, they are unpacked into the real
values, so it is possible to partially override them.

No properties are yet converted to the new world yet, this is just the
code for supporting them.
2011-05-22 01:25:17 +02:00
Benjamin Otte
70e654f1a5 stylepropertis: Use set_by_property() in set_valist()
... instead of duplicating code. This causes an extra g_value_copy().
If that turns out to be a performance issue, we can invent something
that handles this (like passing a gboolean take_value).

The reason for this duplication deletion is that we want to complicate
the setting code to handle shorthands by unpacking them and storing the
separate values.
2011-05-22 01:25:16 +02:00
Benjamin Otte
73c39f5b16 styleproperties: Add _gtk_style_properties_set_property_by_property()
... as a replacement for _gtk_style_properties_set_property_by_pspec().
We'll need that to handle shorthands.
2011-05-22 01:25:16 +02:00
Benjamin Otte
b67ae42ecd styleproperties: Use peek_property() in get_valist() 2011-05-22 01:23:43 +02:00
Benjamin Otte
0a368fe622 styleproperties: Validate values when setting them
Note that validation is not necessary when resolving, because all values
are valid for those cases.
2011-05-22 01:23:36 +02:00
Benjamin Otte
e7db090620 styleproperties: Remove needless check 2011-05-21 22:49:43 +02:00
Benjamin Otte
b889f499a7 styleproperties: Use peek_property in get_property
... instead of duplicating the code.
2011-05-21 22:49:43 +02:00
Benjamin Otte
5f5cc79623 styleproperties: Adapt _gtk_style_properties_peek_property()
Optionally return the GtkStyleProperty that was looked up. This feature
isn't used yet, but will soon be.
2011-05-21 22:49:43 +02:00
Benjamin Otte
727a839d71 styleproperties: Move the style property handling code
... from gtkstyleproperties.c to gtkstyleproperty.c
2011-05-21 22:49:43 +02:00
Benjamin Otte
777a6846db styleproperties: Put gtk_style_property_lookup() in private header 2011-05-21 22:49:43 +02:00
Benjamin Otte
0f211f78a5 styleproperties: Class ref no longer necessary
Now that we initialize the pspecs on-demand, we can avoid the class ref.
2011-05-21 22:49:43 +02:00
Benjamin Otte
85e900b522 styleproperties: Init the default properties when they're needed
Instead of initing the default style properties in the class_init
func of the style properties, init them when they are first needed -
when they are queried or when new ones are registered.

That way, they will always be available.
2011-05-21 22:49:42 +02:00
Benjamin Otte
a2200e8971 styleproperties: constify gtk_style_property_lookup() 2011-05-21 22:49:42 +02:00
Benjamin Otte
1bd065fa4d styleproperties: Rename the storage struct for style pspecs
PropertyNode => GtkStyleProperty
2011-05-21 22:49:42 +02:00
Cosimo Cecchi
c3f3e4a670 styleproperties: resolve properties of type GTK_TYPE_SHADOW
https://bugzilla.gnome.org/show_bug.cgi?id=649314
2011-05-20 18:49:50 -04:00
Cosimo Cecchi
016f540931 styleproperties: add a "text-shadow" style property
And document its use in the CSS parser gtk-doc.

https://bugzilla.gnome.org/show_bug.cgi?id=649314
2011-05-20 18:44:15 -04:00
Benjamin Otte
c1dc3e9372 css: Refactor code to do property lookups earlier
We want to ook up the property in the CSS parser, so we can do fancy
things with it. We currently don't but we want to later.
2011-05-18 22:17:57 +02:00
Benjamin Otte
82399bf457 styleproperties: Speed up by not optimizing
g_quark_try_string() takes a lock and then does a hashtable lookup. So
just using a string hash table for properties is faster.
2011-05-18 22:17:57 +02:00
Benjamin Otte
4c92fb2b5d styleproperties: Speed up style_property_lookup()
Use the already existing bsearch version instead of iterating the array
manually.
2011-05-18 22:17:57 +02:00
Benjamin Otte
beba515243 styleproperties: Use the pspec as the hash table key
The code used the quarked name before, but when we already have the
pspec we want to have a lookup that does not involve quarking. And
lookup is equally fast if we only have the name.
2011-05-18 22:17:57 +02:00
Benjamin Otte
f04f943708 styleproperties: Mark "color" and "font" as inherit
Keeping it identical to CSS 2.1 again
2011-05-18 22:17:57 +02:00
Benjamin Otte
9bfd3d2eec API: Add API to set style properties to be inherit
The API is not used anywhere yet.
2011-05-18 22:17:57 +02:00
Cosimo Cecchi
ec2055d1b0 Revert "styleproperties: don't force replacing the font description"
It turns out the bug is more complicated than I originally understood.
Not replacing the font description fields while merging here makes it
impossible for application's CSS to override fonts.

This reverts commit 89c1d93b68.

https://bugzilla.gnome.org/show_bug.cgi?id=645458
2011-03-23 09:59:58 -04:00
Cosimo Cecchi
2ae6becef9 styleproperties: don't force replacing the font description
Otherwise custom fonts will always get overridden by the default stored
in GtkSettings when merging them.

https://bugzilla.gnome.org/show_bug.cgi?id=644975
2011-03-17 14:34:44 -04:00
Javier Jardón
db97f8660a Use faster new G_VALUE_COLLECT_INIT variant instead G_VALUE_COLLECT
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=641621
2011-02-07 13:14:47 +00:00
Carlos Garnacho
d39f0411be Add the gtk-key-bindings CSS parser property.
This property takes a list of binding set names to have these
stored as a GPtrArray containing GtkBindingSets. this property
is handled so merging GtkStyleProperties will merge both
GtkBindingSet lists.
2011-01-30 21:24:51 -05:00
Pavel Holejsovsky
374e76a19d [GI] Mark unintrospectable constructs as (skip)
Also adds 'Rename to:' annotation to some constructs replacing the
skipped ones.
2011-01-20 13:57:21 +01:00
Pavel Holejsovsky
2f0d40335b [GI] Add missing (transfer) annotations 2011-01-20 13:57:18 +01:00
Matthias Clasen
6869ff26f3 Make GtkBorder style properties have a non-NULL default
https://bugzilla.gnome.org/show_bug.cgi?id=639625
2011-01-19 21:24:30 -05:00
Carlos Garnacho
2f207ca749 Make selectors with no explicit state from higher priority GtkStyleProviders override lower ones with a state.
This makes overriding information from the themes more intuitive
2011-01-17 04:44:29 +01:00
Matthias Clasen
4b10167ce6 Set a default value for rgba style properties 2010-12-21 18:18:34 -05:00
Carlos Garnacho
ca7fe1cb73 GtkStyleProperties: Assign default value for the font property
This fixes a failure when running make test, where style queries
happened before there was even an screen.
2010-12-20 13:55:37 +01:00
Carlos Garnacho
bacb7906f2 Add helper API for getting colors/borders in GtkStyleContext/GtkThemingEngine 2010-12-04 15:39:55 +01:00
Carlos Garnacho
3e8d138ed6 GtkStyleProperties: Refactor color/gradient resolution 2010-12-04 15:39:55 +01:00
Carlos Garnacho
cf0bd12e6c GtkStyleProperties: Turn border-width into a GtkBorder property.
All current users of this CSS property have been updated to deal
with a GtkBorder.

Also a 0 border width has been set in the default CSS to ensure
GtkStyleContext and GtkThemingEngine always provide a non-NULL
pointer for this property.
2010-12-04 15:39:52 +01:00
Matthias Clasen
e598f17871 Some header cleanups
Move GtkGradient to their own files, also move GtkBorder out of
gtkstyle.h, so that header can be all deprecated.
2010-12-04 15:39:47 +01:00