Commit Graph

449 Commits

Author SHA1 Message Date
Benjamin Otte
932794e105 styleprovider: Remove (broken) implementations of get_style
The implementations were broken and get_style() is deprecated and
documented to return NULL now.
2012-11-24 21:12:00 +01:00
Benjamin Otte
4bc264a514 cssprovider: Handle non-existing section
Otherwise we'll get warnings on errors when CSS debug is disabled.
2012-11-15 19:25:14 +01:00
Alexander Larsson
1c4158a649 gtk_css_style_provider_lookup: minor loop optimiziation
This is a minor performance improvement but this loop
is run a lot so it actually matters in large state
changes.
2012-11-09 10:16:18 +01:00
Alexander Larsson
55d65571f3 Exit early in gtk_style_context_update_cache codepaths
If lookup->missing is empty we don't need to continue looking.
We short circuit in several places as this can happen
after iteratively makeign lookup->missing smaller.
2012-11-09 10:15:23 +01:00
Benjamin Otte
b41215bdea cssprovider: Move fallback code into _gtk_css_provider_load_named()
This makes sure the full theme loading logic resides in one function and
isn't scattered around.

As a side-effect, the hash table kept by gtk_css_provider_get_named()
will now be populated with fallback themes. This will not be a problem
after the next commit though.
2012-10-31 11:09:09 +01:00
Benjamin Otte
738b453c66 cssprovider: Export gtk_css_provider_load_named) function
... and document it.
For now, the function is only exported internally.
2012-10-31 11:09:09 +01:00
Benjamin Otte
9c9d82f1a9 cssprovider: Split out theme loading function
Split maintaining the global themes hash table and the theme loading
code into two functions.
This also fixes leaking the provider when loading a theme from a builtin
resource.
2012-10-31 11:09:09 +01:00
Benjamin Otte
5e1ae36b2f section: Add _gtk_css_section_to_string()
Mostly for debugging pruposes, but use it for printing CSS errors in
GtkCssProvider, too.
2012-09-28 18:27:49 +02:00
Benjamin Otte
6696aa2128 cssprovider: Remove another path that can't be reached
... because the return value of a function is always TRUE.
2012-09-19 15:32:38 +02:00
Benjamin Otte
697ed544dd docs: Clarify GtkCssProvider loading return values 2012-09-19 15:30:21 +02:00
Benjamin Otte
ee91f22086 cssprovider: Get rid of return value
... that is always TRUE.
2012-09-19 15:18:51 +02:00
Matthias Clasen
ab3d6a0b0a Revert "Bind the themes to the livecycle of the screen"
This reverts commit 1f5dea9eba,
since it was causeing noticable behaviour changes.

Previously, GTK_DATA_PREFIX=/ ./gtk3-demo would start
gtk3-demo with the Raleigh theme. With that change, it
was starting with no theme at all (i.e. all black).
2012-09-17 22:31:25 -04:00
Benjamin Otte
e6c951a303 styleprovider: Add query function for keyframes 2012-09-17 20:39:11 +02:00
Benjamin Otte
c4cdb33b32 cssprovider: Add parsing support for @keyframes 2012-09-17 20:39:10 +02:00
William Jon McCann
b05224b059 Add back gtk_css_provider_get_named
Was in the original patch but was not in 1f5dea9 probably due to
a bad rebase.

https://bugzilla.gnome.org/show_bug.cgi?id=683896
2012-09-17 09:54:26 -04:00
William Jon McCann
1f5dea9eba Bind the themes to the lifecycle of the screen
https://bugzilla.gnome.org/show_bug.cgi?id=683896
2012-09-16 20:20:44 -04:00
Benjamin Otte
6dc3113edc cssstyleproperty: Get rid of unused API
Both _gtk_css_style_property_print_value() and
_gtk_css_style_property_compute_value() aren't necessary anymore and are
replaced by _gtk_css_value_print() and _gtk_css_value_comptue()
respectively.
2012-08-28 15:40:57 +02:00
Cosimo Cecchi
f70fc49ebc docs: fix a number of typos and obsolete references 2012-07-02 10:41:11 -04:00
Benjamin Otte
25695684ad cssprovider: Remove unused members from scanner
Now that the parser takes care of the file, we don't need to keep track
of it ourselves anymore.
2012-05-11 16:42:12 +02:00
Benjamin Otte
0e4670150a csssection: Remove file argument from constructor
The parser has the file available.
2012-05-11 16:42:12 +02:00
Benjamin Otte
a7f238138e styleproperty: Remove base argument
from _gtk_style_property_parse_value(). The GtkCssParser takes care of
that now.
2012-05-11 16:42:12 +02:00
Benjamin Otte
1367ef7e54 cssstylefuncs: Remove base argument
The GtkCssParser keeps track of the base file now.
2012-05-11 16:42:12 +02:00
Benjamin Otte
e1317268a3 cssparser: Change APIs that work with files
Now that we keep track of the parser's file, we don't require it to be
passed anymore.
2012-05-11 16:42:12 +02:00
Benjamin Otte
a65780902a cssparser: Keep track of the file 2012-05-11 16:42:11 +02:00
Benjamin Otte
a8d8c02ab7 Revert "cssprovider: Remove unused members from scanner"
This reverts commit b501e64a8a.
2012-05-11 16:41:25 +02:00
Benjamin Otte
b501e64a8a cssprovider: Remove unused members from scanner
Now that the parser takes care of the file, we don't need to keep track
of it ourselves anymore.
2012-05-11 16:35:30 +02:00
Benjamin Otte
b4195cb408 cssmatcher: Handle case of empty widget path
This is tested by the stylecontext test, but doesn't appear in practice.
2012-05-01 03:13:02 +02:00
Benjamin Otte
6c63842e68 cssprovider: Actually match the state for style properties
Copy/paste error when refactoring.

Caught by stylecontext test.
2012-05-01 03:13:02 +02:00
William Jon McCann
9f5e580821 Try to load css themes from the XDG config directory first
Will fall back to previous locations.

https://bugzilla.gnome.org/show_bug.cgi?id=646631
2012-04-30 06:42:33 -04:00
Benjamin Otte
6443baadb9 styleprovider: Make all implementors emit the new signal
... and listen to it in the cases where they use other style providers.
2012-04-17 08:59:21 +02:00
Benjamin Otte
0111b9d507 symboliccolor: Treat it as a CssValue
.. now that it is one.
2012-04-17 08:59:20 +02:00
Benjamin Otte
505fefbec7 cssprovider: Add an empty line when printing
... between the @define-color statements and the rules.
2012-04-17 08:59:20 +02:00
Benjamin Otte
0cce3520d3 cssprovider: Store widget style value as string
There's no need to turn it into a GtkCssValue, it's always a string.
2012-04-17 08:59:15 +02:00
Benjamin Otte
9b7640b898 styleproperty: Make _gtk_style_property_parse_value() return a CssValue
Also split out initial/inherit handling into a custom GtkCssValue class.
2012-04-17 08:59:11 +02:00
Benjamin Otte
718ceaec45 css: Remove _gtk_css_style_property_is_specified_type()
That check is going to be refactored away.
2012-04-17 08:59:11 +02:00
Benjamin Otte
8dbe8c8349 syleprovider: Add a vfunc to get the changes
This way we can check what changes are even interesting for our matcher.
2012-04-17 08:59:08 +02:00
Benjamin Otte
a94b85d375 css: Make the style provider take a matcher as an input argument 2012-04-17 08:59:07 +02:00
Alexander Larsson
0b26605ab0 css: Only keep around GtkCssSections if GTK_CSS_DEBUG env var set
These are used purely for CSS debugging, and was using over 100k just
starting up gtk3-demo.
2012-03-29 13:57:22 +02:00
Alexander Larsson
a20b4423f4 Remove broken approach to get stable sort of CSS rules
The pointer comparisons in the sort compare function just doesn't
work.

We still need a stable sort, but the plan is to add a real
one in glib.
2012-03-15 21:12:32 +01:00
Alexander Larsson
7603e6e473 css: Use GtkCssValues instead of GValue in the css machinery
Also, in places where we're computing a new CssValue based on an
old one, make sure that if nothing changes we're returning a reference
to the old one, rather than creating a new identical instance.
2012-03-08 11:03:57 +01:00
Paolo Borelli
8adf311acd Free the resource file string. 2012-03-04 18:02:06 +01:00
Benjamin Otte
67d0b8195d css: Move selector parsing code into a custom function 2012-03-02 02:17:09 +01:00
Benjamin Otte
64425a28de bitmask: Make setters return a new value
(Actually, it's not a real 'new' value yet, but will be soon.

This is the first step to make bitmasks immutable.
2012-03-01 15:10:36 +01:00
Benjamin Otte
49571ccc30 css: Fix variable
And you'd think I'd test my code...
2012-03-01 13:46:11 +01:00
Benjamin Otte
4608278328 cssprovider: Redo styles as an array
Saves even more memory and avoids an extra copy during assigning.
2012-03-01 06:40:15 +01:00
Benjamin Otte
98f557b859 css: Fix fallout
.. from carelessly merging 85b1b9b778
2012-03-01 05:32:34 +01:00
Alexander Larsson
85b1b9b778 Don't use hashtables for storing css rule properties
This saves a lot of memory
2012-03-01 03:00:29 +01:00
Javier Jardón
9d0febc9a6 Change FSF Address 2012-02-27 17:06:11 +00:00
Matthias Clasen
a96c122fa4 Plug a small memory leak 2012-02-11 13:06:12 -05:00
Sebastian Keller
f33fe5b677 docs: Add documentation for alpha() in CSS 2012-02-11 01:48:03 +01:00
Alexander Larsson
cdc6e82720 Remove all default css and make Raleigh a pure fallback theme
It was problematic to maintain Raleigh going forward, as any
changes in it affected all themes. Also, its more robust if
each theme is a full standalone css rather than relying on
an inherited css base.

So, this changes Raleigh to a standalone theme that we can tweak
without accidentally breaking other themes, and makes the
default theme empty. In fact, we don't even add the default
provider anymore as its always empty.
2012-02-09 23:19:17 +01:00
Alexander Larsson
fb0c53a0ed Fix crash with theme resource file
The freeing the GResource in gtk_css_provider_reset caused problems
because it was called from gtk_css_provider_load_from_path() inside
gtk_css_provider_get_named(). We fix this by delaying the
setting of priv->resource until we successfully loaded the file.
2012-02-03 16:37:54 +01:00
Alexander Larsson
b5b9965283 css: Remove any loaded resource in gtk_css_provider_reset 2012-02-03 16:01:51 +01:00
Alexander Larsson
57386285fa Support a gtk.gresource file in themes
This lets themes install a .gresource for efficient loading
of resources. This resource file will (if it exists) be automatically
loaded (mmaped) when the theme is used and unloaded when not used.
2012-02-03 15:50:49 +01:00
Benjamin Otte
762ea4793f css: Make border-width a length property 2012-02-02 03:14:00 +01:00
Benjamin Otte
a81ac3d5cd css: Add a check function for specified types
... and use it.

It seems kinda necessary for the refactoring I'm about to do...
2012-02-02 03:14:00 +01:00
Benjamin Otte
8da4c2affa css: Return GArrays from shorthand parsing
GValueArray is deprecated now.
2012-01-25 19:05:33 +01:00
Benjamin Otte
6f9cc94fae cssprovider: Improve error handling for import errors
We don't want to include the whitespace after an import statement.
Because people tend to add newlines after @import, we report the wrong
lines for failed imports. And that's bad.
2012-01-16 18:44:43 +01:00
Benjamin Otte
1b0231b743 css: Don't import CSS too early
First, finish parsing the import rule including the semicolon. Then try
to actually import.

test: css/parser/at-invalid-01.css
2012-01-16 18:34:41 +01:00
Alexander Larsson
1a36414da7 Access win32 css as resource, not custom generated C code 2012-01-16 14:19:18 +01:00
Alexander Larsson
4f0cc6572b Add Gtk resource file with the default CSS file 2012-01-16 14:19:16 +01:00
Cosimo Cecchi
ddd164c230 provider: use _gtk_css_parse_read_url() in parse_import()
Instead of _gtk_css_parser_read_uri(), which is going away.
2012-01-13 18:08:12 -05:00
Rui Matos
e9adaabc5e Rename 'window-unfocused' to 'backdrop'
'window-unfocused' is too long and mentions "focus" which is historically
loaded with the meaning "input focus".

'backdrop' isn't generally used in GUI speak and still conveys the state the
widgets in an unfocused or background toplevel window are in.
2012-01-09 18:38:00 +01:00
Benjamin Otte
2d46618e08 styleproperty: Let parse_value() initialize the value
... and document that behavior.
2012-01-09 18:37:54 +01:00
Benjamin Otte
01548bfcbe shorthand: Redo shorthand value parsing
The new approach does not need unpack functions anymore.
2012-01-09 18:37:53 +01:00
Benjamin Otte
5ae00c3755 css: Use _gtk_style_property_get_value_type() where appropriate 2012-01-09 18:37:53 +01:00
Benjamin Otte
389531d15d styleproperty: require property in _gtk_style_property_parse_value()
Other code uses _gtk_css_style_parse_value() instead now.
2012-01-09 18:37:53 +01:00
Benjamin Otte
30eb26087c css: Feed sections to CSS lookup code 2012-01-09 18:37:53 +01:00
Benjamin Otte
b904679a11 styleproperty: Move value printing to real properties
We can't print shorthands, so don't try.
In particular, I want to get away from shorthands being representable
using GValue, and this function kinda requires that.
2012-01-09 18:37:53 +01:00
Benjamin Otte
544d210a61 css: Move a bunch of functions
... from GtkStyleProperty to GtkCssStyleProperty.
2012-01-09 18:37:52 +01:00
Benjamin Otte
7a76694780 styleproperty: Use _gtk_style_property_get_name() 2012-01-09 18:37:52 +01:00
Benjamin Otte
4383701e25 styleproperty: unconstify
GtkStyleProperty is a real GObject now, so treat it like one and don't
use const.
2012-01-09 18:37:52 +01:00
Benjamin Otte
81b2bb0ade styleproperty: Get rid of _gtk_style_property_is_shorthand()
Use GTK_IS_CSS_SHORTHAND_PROPERTY() instead now that we have it.
2012-01-09 18:37:51 +01:00
Benjamin Otte
57379adb3c css: Add generic support for 'inherit' and 'initial'
CSS3 says they work for every property, so here we go.
2012-01-09 18:37:51 +01:00
Benjamin Otte
a6ac53e2a9 css: Change prototype of _gtk_css_selector_matches()
Passing the length of the widget path that is relevant is not necessary
anymore, it was only useful for inheritance. Instead, we now pass the
state flags and let the selector do the state matching for us.
2012-01-09 18:37:50 +01:00
Benjamin Otte
a3225fdd42 cssprovider: Remove has_inherit flag from rulesets
It's not used anymore
2012-01-09 18:37:50 +01:00
Benjamin Otte
40a7618d2a cssprovider: Don't do inheritance anymore
Its' done in GtkCssLookup with the help of GtkStyleContext::parent now.
2012-01-09 18:37:50 +01:00
Benjamin Otte
ba5e7012b1 css: Redo StyleProvider interface
We now use the GtkStleProviderPrivate interface, which hopefully is
faster and more conformant to CSS. Long term, it definitely should be
both.

I would have liked to split this up into multiple commits, but couldn't
find a way.
2012-01-09 18:37:50 +01:00
Benjamin Otte
54d2b9dbc2 cssprovider: Keep a bitmask for the properties
That way we can easily tell wich properties are in use.
2012-01-09 18:37:49 +01:00
Matthias Clasen
d7e8388e9d Add a Since tag
gtk_css_provider_to_string is a post-3.0 addition.
Fixes bug 659516
2011-12-30 00:38:06 -05:00
Benjamin Otte
58d553c604 cssprovider: Fix leak
Thanks to the heroic valgrinding efforts of Olivier Sessnik, another
leak could be plugged.
2011-12-23 22:30:45 +01:00
Stef Walter
d462f86aad GtkCssProvider: don't segfault when CSS file is not found
* Fix null dereference in gtk_css_provider_take_error()
 * And another in gtk_css_provider_emit_error()

https://bugzilla.gnome.org/show_bug.cgi?id=664537
2011-11-30 00:23:07 -05:00
Alexander Larsson
f59836a4d0 Build in default win32 css as gtk-win32 2011-11-18 16:54:04 +01:00
Rui Matos
70f87b8bd5 gtk: Add a GTK_STATE_FLAG_WINDOW_UNFOCUSED widget state flag
This allows themes to style widgets differently according to whether the
toplevel window they are in is presented as focused.

https://bugzilla.gnome.org/show_bug.cgi?id=661428
2011-11-08 19:33:22 +00:00
Marc-André Lureau
3b436eec6d css: start background-repeat
By default, a background image is stretched. Instead, it is worth to
have a tiled background.

This patch allows background surfaces to be repeated or not, and should
be compatible with future extensions and CSS.

https://bugzilla.gnome.org/show_bug.cgi?id=663522
2011-11-08 11:10:44 -05:00
Michael Natterer
2688ccdbc4 gtk: clean up the private horror
- add gtkmodulesprivate.h and move stuff there from gtkprivate.h
- add gtkprivate.c and move stuff there from gtkmain.c
- add gtkwin32.c and move stuff there from gtkmain.c
- don't redefine GTK_DATADIR and friends in gtkprivate.h
- have _gtk_get_datadir() and friends on all platforms
- remove the horrid hacks where gtkprivate.h can't be included,
  or must be included later due to redefinition of the compile-time
  directories
2011-10-22 23:53:55 +02:00
Cosimo Cecchi
1f2cfb5619 all: add an 'only-child' pseudo-class selector
Add an :only-child pseudo-class selector, which selects single children
of a parent container.

https://bugzilla.gnome.org/show_bug.cgi?id=660833
2011-10-04 11:47:47 -04:00
Benjamin Otte
b01e20f1d1 cssprovider: Remove unused enums 2011-09-26 16:00:26 +02:00
Morten Welinder
9d96830571 cssprovider: Remove outdated docs 2011-09-22 21:44:05 +02:00
Dan Winship
e028a5c090 gtkcssprovider: fix a crash in gtk_css_provider_parsing_error
"info" was being declared in two different scopes, and the one that
was freed wasn't the one that was set.
2011-09-09 09:37:44 -04:00
Eitan Isaacson
6eb777a8af Change gtk_css_provider_propagate_error's signature.
Update to new parsing-error signal.

https://bugzilla.gnome.org/show_bug.cgi?id=657882
2011-09-02 09:19:18 -07:00
Benjamin Otte
26e9d07718 API: cssprovider: Change parsing-error signal
Instead of path, line and position, emit the section the error happened
in. This has a lot more information to consume.
2011-08-26 16:26:28 +02:00
Benjamin Otte
0d1b73f857 cssprovider: Store sections with parsed values
Also create a separate section for values to associate the values with.
Finally, use this section information when delayed-parsing a widget
style property.
2011-08-26 16:26:27 +02:00
Benjamin Otte
ebf0b6ee4d cssprovider: Handle non-NULL-terminated data
Do a dumb copy if that happens.
2011-08-26 16:26:27 +02:00
Benjamin Otte
d985b95ef9 cssprovider: Keep only the curent section while parsing
We don't need a list of sections, the section can give us the parent
when we need it (d'oh).
2011-08-26 16:26:27 +02:00
Benjamin Otte
19c44967cb cssprovider: Remove dead code
The code isn't used anymore since the introduction of rulesets.
2011-08-26 16:26:27 +02:00
Benjamin Otte
00d14e3515 API: css: Add GtkCssSection
This struct keeps track of an area of text in a CSS file and uses it
when specifying information. Also, the cssprovider keeps track of
sections when parsing a file.
2011-08-26 16:26:27 +02:00
Benjamin Otte
5a1f371e12 cssprovider: Fix names for first and last child pseudo class
The correct name is :first-child, not :first
2011-07-21 02:43:53 +02:00
Benjamin Otte
1a763044fe cssprovider: Emit an error when parsing a binding fails 2011-07-20 02:36:44 +02:00
Benjamin Otte
b8465d289b cssprovider: Get the location right for semicolon warnings 2011-07-20 02:36:44 +02:00