Commit Graph

13992 Commits

Author SHA1 Message Date
Benjamin Otte
cec2875d36 cssprovider: Add support for strings 2011-05-18 21:58:46 +02:00
Benjamin Otte
2a0ac6d102 cssprovider: Parse strings as identifiers when parsing property values 2011-05-18 21:58:46 +02:00
Benjamin Otte
6b66efe873 cssprovider: Add recursion checks for @import
This is pretty important, because otherwise recursions cause crashes.
And if you accidentally change your theme to one that crashes on load,
all your gonna SEGV and then on reboot, gdm tries to load the theme...
2011-05-18 21:58:46 +02:00
Benjamin Otte
22492a37c1 cssprovider: Allow storing the parent stylesheet 2011-05-18 21:58:46 +02:00
Benjamin Otte
286b5b9b72 cssprovider: Don't fail if an import doesn't work 2011-05-18 21:58:46 +02:00
Benjamin Otte
d6c6a0bcc0 cssprovider: Reimplement gtk_css_provider_load_from_path()
Call gtk_css_provider_load_from_file() instead of the internal function.
This has two advantages:
1) It simplifies the code a lot
2) It gets rid of GMappedFile usage. GMappedFile does not work
   everywhere, so this is finally portable.
2011-05-18 21:58:46 +02:00
Benjamin Otte
b0d3078aa7 cssprovider: Make @import use the new load_internal() func 2011-05-18 21:58:46 +02:00
Benjamin Otte
a183375b94 cssprovider: Make load_internal() load the contents
This way, we achieve two things:
1) We can unify file loading to one location
2) We can emit the error from file loading using the parsing-error
   signal. This is very useful for @import handling in particular.
2011-05-18 21:58:46 +02:00
Benjamin Otte
5bedc822ec cssprovider: Introduce gtk_css_provider_take_error_full()
Emits the error without the need for a scanner. Also simplifies
gtk_css_provider_take_error() because we now can assert an available
scanner at all times.
2011-05-18 21:58:46 +02:00
Benjamin Otte
f937d0275a cssprovider: More error handling into load_internal()
Now the parsing functions starting at parse_stylesheet() don't have to
care about errors anymore.
2011-05-18 21:58:46 +02:00
Benjamin Otte
da52175013 cssprovider: Add a load_internal function that all loads chain to 2011-05-18 21:58:46 +02:00
Benjamin Otte
5cf6a8a23f cssprovider: Keep base url in the scanner
And provide a nice function to query it. Simplifies a bunch of code.
2011-05-18 21:58:46 +02:00
Benjamin Otte
84ba8255fc cssprovider: Move properties to scanner constructor
So we can set them in one place.
2011-05-18 21:58:46 +02:00
Benjamin Otte
2de4f71586 cssprovider: Don't store scanner in the struct
Instead, create scanners whenever we actually parse stuff.
2011-05-18 21:58:46 +02:00
Benjamin Otte
5c940f2bd4 cssprovider: Get rid of gtk_css_provider_reset_parser()
Instead call gtk_css_scanner_reset(). There is nothing else we could
need to do.
2011-05-18 21:58:45 +02:00
Benjamin Otte
607846879e cssprovider: Keep track of passed in error differently
Instead of having an error member in the CSS provider's private struct,
connect a signal handler when an error is passed in. This has two
advantages:
1) It makes the code clearer as we don't have to keep track of an error
   member anywhere.
2) It causes a non-emission of the g_warning() when an error was passed
   in, because it only triggers when no signal handlers are connected.
   So we get identical behavior to GTK 3.0 where warnings where only
   emitted when no error was passed in.
2011-05-18 21:58:45 +02:00
Benjamin Otte
8fb6fdd3e7 cssprovider: Do error handling differently
Instead of aborting a parse whenever we encounter an error, parse to the
end. But if a GError was passed in, reset the provider completely as if
nothing had been parsed.
2011-05-18 21:58:45 +02:00
Benjamin Otte
992ee6a203 cssprovider: Emit a g_warning() when a css file is erroneous
... and no other error handler is active. See the source code comment
for the reasoning.
2011-05-18 21:58:45 +02:00
Benjamin Otte
2d75dd2fdf cssprovider: No need to restore after @import parsing
With the recent changes, this just resets the error, and we don't the
error reset from subfile parsing.
2011-05-18 21:58:45 +02:00
Benjamin Otte
3e146b468b cssprovider: Store current properties and selectors in scanner
They don't belong in the css provider
2011-05-18 21:58:45 +02:00
Benjamin Otte
f3bb815517 cssprovider: Use scanner variable instead of priv->scanner 2011-05-18 21:58:45 +02:00
Benjamin Otte
d85cbfe157 cssprovider: Pass scanner argument explicitly to error functions 2011-05-18 21:58:45 +02:00
Benjamin Otte
5bc2ae1a91 cssprovider: Update the scope modifying functions
Make them take the scanner as an argument, as that's what gets changed,
not the CssProvider.
2011-05-18 21:58:45 +02:00
Benjamin Otte
83ebc91dce cssprovider: track state in the scanner
This way, we don't have to do magic copies when we create a new scanner
for a subfile.
2011-05-18 21:58:45 +02:00
Benjamin Otte
740f2458bf cssprovider: Add a private structure to the scanner
So far, it's unused
2011-05-18 21:58:45 +02:00
Benjamin Otte
073d75a880 cssprovider: Add a custom gtk_css_scanner_destroy() function
So far, it does nothing
2011-05-18 21:58:45 +02:00
Benjamin Otte
5ca9f25523 cssprovider: Pass the scanner explicitly to parse_stylesheet()
This is the first step in decoupling the scanner from the provider.
2011-05-18 21:58:45 +02:00
Benjamin Otte
318a3af96e cssprovider: No need to set user data anymore 2011-05-18 21:58:45 +02:00
Benjamin Otte
cb8a595a65 cssprovider: Clean up declaration parser to conform to more tests
The tests will follow with the next commits
2011-05-18 21:58:44 +02:00
Benjamin Otte
22bda2b92f cssprovider: Rework declaration parsing loop
The new loop can cope better with invalid identifiers and manages to
resume parsing properly.
2011-05-18 21:58:44 +02:00
Benjamin Otte
5e054b37a2 cssprovider: Don't fail with invalid syntax when parsing a value
Instead, raise a PROPERTY_VALUE error, find the next semicolon or
closing bracket and resume parsing.
2011-05-18 21:58:44 +02:00
Benjamin Otte
a94ea9a4e3 css: Overhaul value parsing
Value parsing only sometimes emitted errors. Sometimes it didn't emit
errors but ignored the value, sometimes it took a default, sometimes it
converted it to something it deemed suitable.

While refactoring, I moved the whole GValue <=> char * conversion
routines to a separate file, to make navigating the core css provider
easier.
2011-05-18 21:58:44 +02:00
Benjamin Otte
a50a06b583 cssprovider: Remove now useless variables 2011-05-18 21:58:44 +02:00
Benjamin Otte
469ed3e8ed cssprovider: Remove scanner_report_warning() function
That function does superbad stuff just to print out something on stderr.
Don't do superbad stuff.
2011-05-18 21:58:44 +02:00
Benjamin Otte
4622614784 cssprovider: use INVALID_SYNTAX for unexpected token error 2011-05-18 21:58:44 +02:00
Benjamin Otte
b34f004f43 cssprovider: Change declaration parsing for error reporting
Previously, we only checked for errors after parsing the full
declaration. Now we detect errors with the property before even
attempting to parse its value.
The benefit here is that the error reporting reports the correct line
and position numbers.
2011-05-18 21:58:44 +02:00
Benjamin Otte
ee53156762 API: cssprovider: Add more error codes 2011-05-18 21:58:44 +02:00
Benjamin Otte
78afa9671e API: cssprovider: Make error a signal 2011-05-18 21:58:44 +02:00
Benjamin Otte
06d4dab48c cssprovider: Handle errors completely via new error functions 2011-05-18 21:58:43 +02:00
Benjamin Otte
582aa955c2 cssprovider: Provide better API to set errors 2011-05-18 21:58:43 +02:00
Benjamin Otte
707ba8597f cssprovider: Have a private error variable 2011-05-18 21:58:43 +02:00
Benjamin Otte
38ca304825 cssprovider: Automatically add final closing bracket to last rule 2011-05-18 21:58:43 +02:00
Benjamin Otte
9d9f1e38b2 cssprovider: Ignore empty rules 2011-05-18 21:58:43 +02:00
Benjamin Otte
b1556abe04 API: gtk: Add gtk_css_provider_to_string()
This is intented to convert the contents of a CSS provider back to a
string.
It is not complete yet but good enough for starting a testsuite. :)
2011-05-18 21:58:43 +02:00
Benjamin Otte
8b6f92d087 API: Add gtk_gradient_to_string() 2011-05-18 21:58:43 +02:00
Benjamin Otte
dc43239a61 gtk: Add _gtk_animation_description_to_string()
Reverses _gtk_animation_description_from_string()
2011-05-18 21:58:43 +02:00
Benjamin Otte
6e18b5f3de API: gtk: Add gtk_symbolic_color_to_string()
See future commits for why this is useful. Or try to debug some color
problem.
2011-05-18 21:58:43 +02:00
Benjamin Otte
b566debef9 cssprovider: Add a function for signalling errors 2011-05-18 21:58:43 +02:00
Benjamin Otte
f5bc27f7ef cssprovider: Store cssprovider in scanner's user data 2011-05-18 21:58:43 +02:00
Cosimo Cecchi
f398745a15 treeview: don't arbitrairly add 2 to the expander size
Bump the default expander size by 2 pixels instead.

https://bugzilla.gnome.org/show_bug.cgi?id=650424
2011-05-18 11:12:47 -04:00