Commit Graph

14079 Commits

Author SHA1 Message Date
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
Cosimo Cecchi
5b6253252e css: add a parser for GTK_TYPE_SHADOW properties
https://bugzilla.gnome.org/show_bug.cgi?id=649314
2011-05-20 18:44:12 -04:00
Cosimo Cecchi
fcc78bedc8 shadow: add a GtkShadow private type
This will be used as a base both for parsing text-shadow and box-shadow
properties. The type is private, as there's no real use in exporting
this in a public API.

https://bugzilla.gnome.org/show_bug.cgi?id=649314
2011-05-20 18:44:07 -04:00
Cosimo Cecchi
8301b24ee5 assistant: pack the sidebar in a frame instead of an event box
This has mostly two advantages:
- the most obvious one is the theme can render a border around the
  sidebar if it wants to.
- we also can avoid hardcoding a container border width for the sidebar,
  and just use a padding from the theme. This also allows different
  themes to define a different padding, etc.

The drawback is we must draw the background ourselves, but it's easy
enough.

https://bugzilla.gnome.org/show_bug.cgi?id=650530
2011-05-19 10:54:04 -04:00
Cosimo Cecchi
6bbb9d6f15 assistant: remove an useless gtk_widget_reset_style() call
It's not needed to call _reset_style() here, as we did not add the
widget to the parent container yet.

https://bugzilla.gnome.org/show_bug.cgi?id=650530
2011-05-19 10:54:01 -04:00
Benjamin Otte
3ecb308e56 menu: Only realize menu if it isn't realized yet
Lots of code calls gtk_menu_popup() and we don't want to resize the
window needlessly.
In this particular case, keyboard navigation to submenus caused those
submenus to shrink.

Note: I'm not sure this fix doesn't have nasty side effects, as I'm not
a specialist on menu popup code, so if it does, we'll need to revert it.
Until then, let's keep it, it fixes a bug.
2011-05-19 13:04:19 +02:00
Benjamin Otte
3410b14751 mac keys: Add a missing semicolon 2011-05-18 22:17:59 +02:00
Benjamin Otte
c3701c737c keys.css: Remove semicolons at end of rules
This is not CSS conform (it will break resync code after errors for
generic CSS parsers), so I deprecated the support for that semicolon.
2011-05-18 22:17:59 +02:00
Benjamin Otte
a1858c5454 cssprovider: When loading themes, don't pass in an error
We want to parse existing themes as well as possible instead of failing.
And the g_warning() is preserved.
2011-05-18 22:17:59 +02:00
Benjamin Otte
17e3d6f85e cssprovider: Don't propagate deprecation messages to passed-in error
It's an informative message, don't stop parsing the CSS because of it.
2011-05-18 22:17:59 +02:00
Benjamin Otte
d2ef71627b css: Make property parsing functions take a css parser
Instead of reading a string and then passing that in, let the parse
functions use the full power of the parser.
2011-05-18 22:17:59 +02:00
Benjamin Otte
03e84b7ee3 css: Move binding set parsing to strfuncs 2011-05-18 22:17:59 +02:00
Benjamin Otte
c73d1cf2a6 cssstringfuncs: Read colors as symbolic colors always
... and then try to resolve them, so static colors get resolved in
advance, just like it was before.
2011-05-18 22:17:58 +02:00
Benjamin Otte
9e18d8b448 symboliccolor: Allow props == NULL when resolving
If props == NULL in gtk_symbolic_color_resolve(), fail sanely for named
colors. The docs used to say it was not allowed to pass NULL for named
color, but that had problems:
1) You do not know if a color was created that way. This is especially
   hard for generic users (like language bindings).
2) It wasn't even true. Colors using other symbolic colors would also
   fail when trying to resolve their named colors, but the docs didn't
   say so.
And because I want to use the function to resolve static colors early
where possible, I changed things.
2011-05-18 22:17:58 +02:00
Benjamin Otte
8111d99183 cssprovider: Cache if rulesets have inheritable style properties
This provides a huge speedup as we only need to preprocess style
properties when they are indeed inherited. This roughly doubles the
performance of the CSS matcher and brings the time taken by
gtk_css_provider_get_style() from 19% to 7% in my favorite benchmark.
2011-05-18 22:17:58 +02:00
Benjamin Otte
82b340f6f0 cssprovider: Keep two hash tables per ruleset
One for the style properties, one for the widget style properties.
This way we can make one hash table by pspec which means we don't have
to repeat the pspec lookup.
2011-05-18 22:17:58 +02:00
Benjamin Otte
399a439103 cssprovider: Add a new setter for rulesets
We now have set-by-pspec (which is used for normal style properties) and
set-by-name (which is used by widget properties).
2011-05-18 22:17:58 +02:00
Benjamin Otte
0318ab2ce1 cssprovider: Refactor handling of rulesets
Keep rulesets as an on-stack/heap structure instead of allocating all
instances separately.
Also, pass a ruleset to the ruleset parser, so we can make the ruleset
parser do lots of fancy things that might be useful for performance.
2011-05-18 22:17:58 +02:00
Benjamin Otte
151294576d cssprovider: Refactor code to have a gtk_css_ruleset_matches() 2011-05-18 22:17:58 +02:00
Benjamin Otte
71c748b47e cssprovider: Rename "SelectorStyleInfo" to "Ruleset"
No code changes, just clarification of the name
2011-05-18 22:17:58 +02:00
Benjamin Otte
b37f9fdf81 css: Implement inherit properties
Huge performance hit (slows down things roughly by a factor of 3), but
necessary for CSS conformance and for implementing "inherit" and
percentages.
2011-05-18 22:17:58 +02: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
d6f0042773 css: Make _gtk_css_selector_matches() take a path length
This will be necessary when handling inherit.
2011-05-18 22:17:57 +02:00
Benjamin Otte
08e83ca66b cssprovider: Simplify code
Don't go through an intermediate array when matching styles.
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
Benjamin Otte
8605a2a10a cssprovider: Speed up gtk_widget_style_get() property lookups
Previously we got the list of all matching rules and then iterated it to
find the first one that had the property. Now we look while matching
rules, so we don't lookup rules that we don't need.
2011-05-18 22:17:57 +02:00
Benjamin Otte
d3c60cc89c css: Don't query type for regions
Regions are regions and don't match by type.
2011-05-18 22:17:57 +02:00
Benjamin Otte
619d344d8d css: Raised SYNTAX error when enum value can't be parsed 2011-05-18 22:17:56 +02:00
Benjamin Otte
e875c619ef css: No more special code for regions
Just treat regions the same as elements.
2011-05-18 22:17:55 +02:00
Benjamin Otte
fc88b0f47c css: Rewrite selectors
Selectors now go into their own C file. The new selectors are modeled a
lot closer to the CSS spec. In particular the specificity computation
matches CSS 2.1 exactly.

For details about the why, see also:
http://mail.gnome.org/archives/gtk-devel-list/2011-May/msg00061.html
https://bugzilla.gnome.org/show_bug.cgi?id=649798
2011-05-18 22:17:55 +02:00
Benjamin Otte
4e2d3f5d18 cssprovider: Remove a bunch of commented-out code
The code was only kept for reference while writing the new parser, it's
not necessary anhymore.
2011-05-18 22:17:55 +02:00
Benjamin Otte
7ccb9db79e css: Rewrite the parser
Instead of relying on GScanner and its idea of syntax, code up a parser
that obeys the CSS spec.
This also has the great side effect of reporting correct line numbers
and positions.

Also included is a reorganization of the returned error values. Instead
of error values describing what type of syntax error was returned, the
code just returns SYNTAX_ERROR. Other messages exist for when actual
values don't work or when errors shouldn't be fatal due to backwards
compatibility.
2011-05-18 22:17:55 +02:00
Benjamin Otte
e1dda3d03f cssprovider: Don't hardcode strings anymore 2011-05-18 21:58:46 +02:00
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
Cosimo Cecchi
42f5856e77 treeview: render a frame around the rows, after drawing their background
https://bugzilla.gnome.org/show_bug.cgi?id=650424
2011-05-18 11:12:31 -04:00
Cosimo Cecchi
1a7239481c raleigh: clear up menu handling in the fallback CSS
Now that menus properly respect padding/border, this is not needed
anymore.
2011-05-18 10:45:51 -04:00
Cosimo Cecchi
091a4d7f22 menu: don't use the border as a padding value
Borders should be rendered inside the allocation, not act as a second
padding.

https://bugzilla.gnome.org/show_bug.cgi?id=650418
2011-05-18 10:45:50 -04:00
Cosimo Cecchi
c8a59a6f92 all: avoid boxed structs copying where possible
Use the GtkStyleContext accessors for boxed properties where possible,
to reduce allocations.

https://bugzilla.gnome.org/show_bug.cgi?id=650420
2011-05-18 10:27:21 -04:00
Carlos Garnacho
52452236bc button: Fix typo in keyboard grab's evmask
https://bugzilla.gnome.org/show_bug.cgi?id=650382, spotted
by Alexander Larsson.
2011-05-17 13:17:25 +02:00
Matthias Clasen
b219b3b0ec Add shortcuts for the !children case
Not that we are doing too much work in that case, but we are
segfaulting, which is bad.
https://bugzilla.gnome.org/show_bug.cgi?id=649972
2011-05-12 20:12:51 -04:00
Benjamin Otte
5084739756 themingengine: Set current point to 0,0 when rendering rotated layout
Otherwise the layout may move to who-knows-where
2011-05-12 23:40:26 +02:00
Micah Carrick
86f5849158 Fix annotation for Gtk.TreeView.enable_model_drag_source
https://bugzilla.gnome.org/show_bug.cgi?id=649979
2011-05-11 16:15:23 -04:00
Benjamin Otte
f96777ea02 paned: Be careful about showing windows
The previous code failed to account for all child visibility and paned
mapedness invariants which could cause stray GDK windows to appear.
Not good.

Credit goes to Xan for triggering it.
2011-05-11 00:47:23 +02:00
Matthias Clasen
1ab425b132 GtkAssistant: make the content expand
Its all about the content, so make sure the content fills
the available space.
2011-05-10 17:57:21 -04:00
Benjamin Otte
6bda6f0c58 paned: Ensure children aren't underallocated
Instead, allocate them a proper size and just clip them using the window
we added for them in the last commit.
2011-05-09 18:55:13 +02:00
Benjamin Otte
206b9f940d paned: Create a GDK window for every child
We need the window to clip drawing. Otherwise we cannot allow
undersizing without doing underallocations.
2011-05-09 18:37:08 +02:00
John Stowers
21761ce5fc Add missing gtk_widget_override_* annotations
https://bugzilla.gnome.org/show_bug.cgi?id=649779
2011-05-09 23:09:26 +12:00