Commit Graph

479 Commits

Author SHA1 Message Date
Carlos Garnacho
2c8e01dc80 gtkcssprovider: plug several leaks
In finalize(), clear all rulesets.
In parse_declaration(), Free the GValue under unhandled error situations.
In gtk_css_provider_load_internal(), Do not leak the file contents.
2011-05-30 19:26:28 +02:00
Carlos Garnacho
747dc65c2c gtkcssprovider: Use g_slice_dup() to copy GValues around
GValues stored in GtkCssRulesets are gslice managed, so don't
g_memdup() GValues from shorthand properties. This fixes
memory corruptions when reloading contents in a GtkCssProvider.
2011-05-30 19:13:36 +02:00
Benjamin Otte
7de5a4e08d cssprovider: Don't convert widget style properties to CSS
They are still CSS, so converting them is wrong.
2011-05-23 15:56:09 +02:00
Benjamin Otte
7836df29cb cssprovider: Use right hash table when printing
If the CSS provider had widget style properties, printing them would
crash since 82b340f6f0
2011-05-23 15:56:09 +02:00
Benjamin Otte
21236cf270 style: Make margin a shorthand
... and add the real properties:
- margin-top
- margin-left
- margin-bottom
- margin-right
2011-05-22 05:56:12 +02:00
Benjamin Otte
a35aa96149 style: Make padding a shorthand
... and add the real properties:
- padding-top
- padding-left
- padding-bottom
- padding-right
2011-05-22 05:56:12 +02:00
Benjamin Otte
f5c7cefcca style: Convert border-width to a shorthand
Add the corresponding properties it refers to, too:
- border-top-width
- border-left-width
- border-bottom-width
- border-right-width
2011-05-22 05:56:11 +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
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
5eca8f8275 css: Rename gtkcssstrfuncs file to gtkstyleproperty
The idea is to handle the style property registering etc in this file
instead of the styleproperties file. The next commits will move those
files.
2011-05-21 22:49:43 +02:00
Benjamin Otte
548a1302ee cssprovider: Use _gtk_style_property_lookup()
This way we get the actual data node and can use it.
2011-05-21 22:49:43 +02:00
Benjamin Otte
d333911d30 docs: Add missing <row> 2011-05-21 03:41:52 +02: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
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
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
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
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
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
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
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
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
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
Benjamin Otte
a5e1337ad7 cssprovider: Move private struct definition to header
consistency, improved debugging, etc
2011-04-16 22:31:25 +02:00
Benjamin Otte
0a23796f5d cssprovider: Use g_type_depth() instead of computing the depth manually 2011-04-14 14:59:24 +02:00
Carlos Garnacho
e8c78edeb2 theme: Fix prelight on selected rows' expanders
There was no prelight effect on selected rows' expanders with the
builtin theme, noticed by Kris Rietveld.
2011-04-03 12:32:20 +02:00
Carlos Garcia Campos
ef061c4e96 gtkentry: Add hinting to GtkEntry
gtk_entry_set_placeholder_text() makes the entry display the given text
when it is empty and unfocused. Based on previous patch by Alberto
Garcia.

https://bugzilla.gnome.org/show_bug.cgi?id=440963
2011-03-21 09:37:37 +01:00
Carlos Garnacho
fe12c46531 cssprovider: Reset the scope before skipping to the next rule after an error happens.
This is so the selector token gets parsed with the correct GScanner scope/config
on all situations.
2011-03-07 23:06:54 +01:00
Carlos Garnacho
aa6eee73e5 cssprovider: plug two more leak fixes 2011-03-07 23:06:54 +01:00
Carlos Garnacho
794593a4f8 cssprovider: return immediately if there's remaining data behind a parsed value
parse_value() could fill in a GError, but yet (incorrectly) return G_TOKEN_NONE,
having the GError leaked as a result.

https://bugzilla.gnome.org/show_bug.cgi?id=642604 , Reported by Felix Riemann.
2011-03-07 23:06:54 +01:00
Carlos Garnacho
3100b76ba9 Fix parsing of color names containing numbers
They were being defined correctly through @define-color
in CSS, but parsing failed at the moment of creating
GtkSymbolicColors depending on these.
2011-02-17 20:10:49 +01:00
Michael Natterer
330158977d gtk: make the .trough background-color darker() as it was in GTK+ 2.x 2011-02-06 13:48:42 +01:00
Michael Natterer
c990699922 gtk: don't style GtkLabel:selected's color separately
or labels in selected state will not have a different color. Reviewed
by Carlos.
2011-02-05 14:10:18 +01:00
Matthias Clasen
3c1ff82b21 Fix a memory leak in GtkCSSProvider
Found by Felix Riemann
https://bugzilla.gnome.org/show_bug.cgi?id=641558
2011-02-04 21:13:56 -05:00
Emmanuele Bassi
d51c617e13 css-provider: Fix up the Switch style
As it was with the old style, when the Switch is in the "on" state the
trough should be using the selected background color.
2011-01-31 16:21:36 +00:00
Matthias Clasen
cb498c2101 Speed up expander animation
Go back to 200ms, which is what we had in GTK+ 2.x.
Themes can change this, of course.
2011-01-31 10:51:09 -05:00
Matthias Clasen
09a52de478 Add a missing id to the docs 2011-01-31 07:39:06 -05:00
Matthias Clasen
f67ab808fd doc fixes 2011-01-30 23:35:25 -05:00
Matthias Clasen
8bb0d552f1 Improve binding-set parser
Make gtk_binding_entry_add_signal_from_string() return the expected
token in case of parsing error, so that we can return a GError
instead of spewing. Also, add a separate scope for binding-set,
since allowing {} in identifiers in SCOPE_VALUE breaks the fact
that the ; after the last assignment in a rule is optional.
2011-01-30 21:27:56 -05:00
Matthias Clasen
bf9e59e392 Make documentation match behaviour 2011-01-30 21:27:55 -05:00
Carlos Garnacho
c70b65f0eb Document @binding-set and the gtk-key-bindings css parser property 2011-01-30 21:24:52 -05: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
Carlos Garnacho
dbff92fd9f Add @binding-set rules to the CSS parser
these custom rules can be used to define key themes
as in the RC files, a series of bind/unbind rules
may be added then:

@binding foo-bar {
  bind "<alt>1" { "move-cursor" (visual-positions, 1, 0) };
  unbind "<ctl>d"
}
2011-01-30 21:24:51 -05:00
Bastien Nocera
b98caf9385 GtkCssProvider: Take into account variant
When loading a theme, make sure we take into account the variant
so we don't use the plain version when the theme changes.

Also make sure to fallback to the plain theme when loading a variant
fails.

https://bugzilla.gnome.org/show_bug.cgi?id=640983
2011-01-30 21:22:12 -05:00
Carlos Garnacho
08af1783c5 Make GtkTreeView use GtkStyleContext
Expander animation has been replaced by implicit animations
from the style context.

Column headers are also properly themed, GtkContainer::get_path_for_child()
is implemented and the treeview resets column buttons style on columns
being reordered.

The default CSS has changed to theme treeviews sensibly.
2011-01-27 20:57:11 +01:00
Matthias Clasen
ea24fa62c8 Privately export css_provider_get_theme_dir 2011-01-27 00:32:07 -05:00
Carlos Garnacho
e3be6fc24f Unset border-width for treeview rows in default CSS
Fixes bug #640391 - Display lines between rows when window is focused.
Reported by Guillaume Desmottes.
2011-01-24 18:14:05 +01:00
Matthias Clasen
d9fcc4c630 Silence new gcc warnings
gcc 4.6.0 has started to warn about set-but-unused variables.
So don't do that, then.
2011-01-23 21:51:38 -05:00
Matthias Clasen
a12dad75a2 Split out private style context api into a private header 2011-01-23 18:29:28 -05:00
Carlos Garnacho
e3774b6ff2 Render check/radio buttons with border-color: @fg_color 2011-01-23 20:01:22 +01:00
Matthias Clasen
0a5e8ce685 Mention type vs region ambiguity in the docs 2011-01-19 12:55:48 -05:00
Carlos Garnacho
0b7496558d Make GtkCssProvider deal with widget types not being in plain CamelCase
Fixes bug #Bug 639754, reported by Kjell Ahlstedt. gtkmm doesn't
use plain CamelCase for its widget type names, so in order to
distinguish widget type names from regions in the CSS parser,
the following checks are now done:

* if it contains an uppercase letter -> widget class (that should
  also work for gtkmm)

* if it's a string compound by lowercase letters and '-' -> it's
  a region, checks have been added in gtk_style_context_add_region()
  and gtk_widget_path_iter_add_region() to ensure this.
2011-01-19 04:28:49 +01:00
Carlos Garnacho
f430a306f7 Make GtkCheckButton/GtkRadioButton background white again 2011-01-19 04:28:49 +01:00
Carlos Garnacho
e28a2695ac Improve progressbars theming.
Make progressbar itself have an outset border, and improve spacings.
2011-01-17 04:43:16 +01:00
Tristan Van Berkom
9438107bff Plugged leak in gtkcssprovider.c
SelectorStyleInfo structs were never freed.
2011-01-16 20:52:43 +09:00
Carlos Garnacho
26db0b7276 Make GtkMenu(Shell) use GtkStyleContext
The default CSS has also been modified to theme these sensibly
2011-01-12 20:55:36 +01:00
Carlos Garnacho
162380fca5 Make GtkCalendar use GtkStyleContext 2011-01-10 20:49:34 +01:00
Carlos Garnacho
12944d9c23 Do not set any padding for scrolled window children. 2011-01-10 20:49:27 +01:00
Carlos Garnacho
d9dab98ad6 GtkCssProvider: enable parsing negative GtkBorders
this can be used as in regular CSS under some situations,
so child items overlap the parent element's border.
2011-01-10 20:49:14 +01:00
Paolo Borelli
c5a8584c3e CSS styles for the selection in a TextView.
https://bugzilla.gnome.org/show_bug.cgi?id=639106
2011-01-10 18:52:35 +01:00
Carlos Garnacho
2f6514ce34 Make GtkHSV use GtkStyleContext
two custom classes replace the light/dark focus detail strings,
it doesn't make much sense to have a GTK_STYLE_CLASS_* for that.
2011-01-10 03:49:59 +01:00
Ignacio Casal Quinteiro
8de4661d80 Set the style for .view so i.e the GtkTextView gets the right style. 2011-01-07 11:35:40 +01:00
Matthias Clasen
bf2a6114ab Mention gvfs in the gtk_show_uri() docs
https://bugzilla.gnome.org/show_bug.cgi?id=622125
2011-01-04 11:25:40 -05:00
Carlos Garnacho
554e649a68 Make GtkTooltip use GtkStyleContext 2011-01-04 03:06:17 +01:00
Carlos Garnacho
7981869308 Update GtkAssistant to GtkStyleContext 2011-01-04 03:06:08 +01:00
Hans Breuer
5fe027500e win32: include gtkprivate.h for win32 GTK_DATA_PREFIX 2011-01-02 13:33:11 +01:00
Carlos Garnacho
b2e8992291 Make GtkProgressBar use GtkStyleContext 2010-12-28 19:25:48 +01:00
Carlos Garnacho
e5e95934ba Fix color name (as of rgb.txt) parsing in symbolic colors
The end of the substring wasn't being detected properly.
2010-12-24 19:37:30 +01:00
Matthias Clasen
5b6bdcf016 Fix a tag mismatch in the docs 2010-12-21 18:18:34 -05:00
Matthias Clasen
5b299ce7af Remove reference to GTK2_RC_FILES from the docs
Pointed out in bug 637471.
2010-12-20 10:23:43 -05:00
Cosimo Cecchi
b792a31995 widgetpath: allow GTypes non-derived from GTK_TYPE_WIDGET
This makes things like GtkCellRenderer or GtkNumerableIcon more easily
themeable.

https://bugzilla.gnome.org/show_bug.cgi?id=637169
2010-12-17 18:30:57 +01:00
Benjamin Otte
1b64655eb6 cssprovider: Explode if we fail to parse the default CSS
This can only happen if somebody really messed up with a checkin, and in
that case we want to explode early.
2010-12-15 14:51:26 +01:00
Carlos Garnacho
ee31a016ec Make GtkInfoBar use GtkStyleContext
All colors are defined now in the default css, and classes have
been added so the bars are fully themeable (as opposed to
gtk_widget_override_*, which require changing the color map itself)
2010-12-14 02:29:57 +01:00
Carlos Garnacho
a517cf1bed Make GtkExpander use GtkStyleContext 2010-12-13 22:31:30 +01:00
Carlos Garnacho
618b1a8b33 GtkCssProvider: Make selectors applying from the topmost widget rank higher
For example, for an entry within a notebook, previously these 2 rules would
have the same weight:

.entry {}
.notebook {}

Now ".entry" will rank higher than ".notebook" for the GtkEntry, further
specific selectors such as:

.notebook .entry {}

still get a higher score than the previous ones.
2010-12-13 22:31:28 +01:00
Guillaume Desmottes
107cebe546 gtk_css_provider_get_named: don't leak subpath (#636777) 2010-12-08 21:13:03 -05:00
Matthias Clasen
ad80cb6279 Allow + in identifiers
This is necessary since we treat paths as identifiers in
@import rules, and it is common to have a + in there (at least
when distchecking gtk+ ...)
2010-12-06 14:13:07 -05:00
Matthias Clasen
f1fafca6ca Make invalid stylesheets fail to parse again
The recent improvements to error reporting caused gtk_css_provider_load...
to always return TRUE and leave the error unset. Error messages were instead
dumped out with g_message, which is not helpful.

This commit changes things back to the way they were before:
If a GError is passed in, parsing will fail at the first error, reporting
it in the given GError. If no GError is passed in, we keep going and
just issue the warning messages. This fixes the parser tests.
2010-12-06 00:47:13 -05:00
Matthias Clasen
d5df33c75f Fix abi check after recent merges 2010-12-05 12:18:30 -05:00
Carlos Garnacho
0cba2dc726 GtkCssProvider: Improve error handling and reporting.
Nicer error reports are provided, and a GError can be spread from
anywhere in parsing, so over time more precise and meaningful
messages can be produced.
2010-12-04 15:39:57 +01:00
Carlos Garnacho
066f35bf28 Parse user CSS from $XDG_CONFIG_HOME/gtk-3.0/gtk.css 2010-12-04 15:39:53 +01:00
Carlos Garnacho
901af8fec8 Fix compiler warnings. 2010-12-04 15:39:52 +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
Carlos Garnacho
daab45565a GtkCssProvider: Fix up state matching when looking up style properties. 2010-12-04 15:39:51 +01:00
Carlos Garnacho
297fa7a3dd GtkStyleProvider: Add GtkStateFlags parameter to get_style_property().
Widget style properties can now have different values depending on the
current state.
2010-12-04 15:39:51 +01:00
Matthias Clasen
f86e8f7512 Allow images for background-image
In addition to -gtk-gradient(...), allow url(path), and create
a pattern from the image. Still to do: allow stretch/repeat options.
2010-12-04 15:39:48 +01:00
Matthias Clasen
ca143b1303 Add list of classes and regions to the docs 2010-12-04 15:39:48 +01:00
Matthias Clasen
897c370f5f Avoid compiler warnings 2010-12-04 15:39:47 +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
Carlos Garnacho
e9ef162d4c GtkSpinner: Use style context for rendering.
Animation is now handled by the theming layer, a looping animation
has been defined in the default CSS to handle active spinners.
2010-12-04 15:39:45 +01:00
Carlos Garnacho
ebd8463007 GtkCssProvider: Handle unfocused label selections in default CSS. 2010-12-04 15:39:40 +01:00
Carlos Garnacho
6bf04fbd94 GtkCssProvider: Add a default border color for insensitive elements. 2010-12-04 15:39:39 +01:00
Matthias Clasen
391e445d11 Allow digits in selectors and values, where appropriate 2010-12-04 15:39:37 +01:00
Matthias Clasen
d4c70f214d Declare transition and border-image properties to be writeonly
We don't make the types of their values public, so getting their
values is useless and will leak.
2010-12-04 15:39:37 +01:00
Matthias Clasen
a5e10e9b26 Improve some gtk_render_ docs
With pictures !!
2010-12-04 15:39:36 +01:00
Matthias Clasen
fc10599ac8 Make unfocused selections visible in entries 2010-12-04 15:39:33 +01:00
Matthias Clasen
21a193ad02 Make expanders prelight 2010-12-04 15:39:33 +01:00
Carlos Garnacho
d63615d9cc GtkCssProvider: Render inconsistent toggle buttons differently. 2010-12-04 15:39:32 +01:00
Carlos Garnacho
9b2f878b06 GtkCssProvider: do not use selected fg/bg in sliders or spinbutton buttons. 2010-12-04 15:39:32 +01:00
Carlos Garnacho
bcf1ee4825 GtkCssProvider: Use 1px border width for spinbutton buttons. 2010-12-04 15:39:32 +01:00
Carlos Garnacho
74b032b816 GtkCssProvider: Render radio and check boxes framess in menus. 2010-12-04 15:39:32 +01:00
Carlos Garnacho
b33d48a802 GtkCssProvider: use selected fg/bg for selected menu items in CSS. 2010-12-04 15:39:31 +01:00
Carlos Garnacho
85aa672ff7 GtkCssProvider: Draw frame around menubars and toolbars in default CSS. 2010-12-04 15:39:31 +01:00
Matthias Clasen
fea567bb9f More documentation reshuffling 2010-12-04 15:39:31 +01:00
Matthias Clasen
ace967a042 Tweak wording 2010-12-04 15:39:30 +01:00
Matthias Clasen
3a7f79e814 Document border images better 2010-12-04 15:39:30 +01:00
Matthias Clasen
953ac51fb8 Make url parsing work for slices
The border-image parsing code relies on parse_path_str to return
a meaningful end_ptr in case of success, too.
2010-12-04 15:39:29 +01:00
Matthias Clasen
69254c552a Allow / in values
Otherwise, using url(path) on the right-hand side of properties
is not going to work.
2010-12-04 15:39:28 +01:00
Matthias Clasen
7d6fb7b7e7 Add some images to the docs
Add graphs for the transition functions and gradient examples.
2010-12-04 15:39:28 +01:00
Carlos Garnacho
71f187a84f GtkCssProvider: Handle progressbars. 2010-12-04 15:39:24 +01:00
Carlos Garnacho
f3445a2430 GtkCssProvider: Do not have border-color the same than active bg-color. 2010-12-04 15:39:24 +01:00
Carlos Garnacho
ee37847952 GtkCssProvider: Use default value when handling "none".
This way the default value has a way to override other values in previous
GtkStyleProviders when merged.
2010-12-04 15:39:22 +01:00
Matthias Clasen
e2f91f7201 Documentation improvements
This patch adds more detail to the explanation of CSS, and also
adds documentation about which files are read.

We also make :focus an alternative to :focused (since :focus is
a standard CSS pseudo-class).
2010-12-04 15:39:22 +01:00
Carlos Garnacho
9567ed01e8 GtkCssProvider: Base prelight foreground on bg color.
Entries are also handled, so base/text colors are used.
2010-12-04 15:39:21 +01:00
Carlos Garnacho
de94d04fea GtkCssProvider: Make prelight a bit less light in default CSS. 2010-12-04 15:39:21 +01:00
Carlos Garnacho
84d586043e Fix checkbuttons theming in CSS so it's more similar to 2.x 2010-12-04 15:39:19 +01:00
Matthias Clasen
4135fbf4d6 A little closer to css
Declarations are ;-separated, but there is no ; required after
the last declaration. We harmlessly accept either.
2010-12-04 15:39:17 +01:00
Matthias Clasen
0396550ece Work harder at parsing import statements
Also, turn g_warning() into g_message() for now, so that tests
don't abort. Eventually, this needs to all go into GErrors.
2010-12-04 15:39:16 +01:00
Matthias Clasen
11cd19987b Move import syntax closer to css
Css allows @import url ("foo.css") or @import "foo.css" or
@import url ('foo.css') but not @import url(foo.css) or @immport foo.css.
2010-12-04 15:39:16 +01:00
Matthias Clasen
f92c352f96 Some error reporting
When we take a GError argument, better use it.
2010-12-04 15:39:16 +01:00
Matthias Clasen
5f13b65065 Fix prototype of gtk_css_style_provider_load_from_data
GError arguments must be **.
2010-12-04 15:39:16 +01:00
Matthias Clasen
72f9a7940f Add an outline around menu popups 2010-12-04 15:39:15 +01:00
Matthias Clasen
627b33265b Handle float and uint style properties
These were giving errors in testgtk.
2010-12-04 15:39:15 +01:00
Matthias Clasen
512bc44dbc Make frames visible by default 2010-12-04 15:39:14 +01:00
Carlos Garnacho
c9dc09e980 GtkStyleProvider: Pass a GParamSpec in get_style_property().
This is so we can know the owner type of the property, and matching
with the stored strings in GtkCssProvider is direct.
2010-12-04 15:39:13 +01:00
Carlos Garnacho
43cff6f6f7 GtkCssProvider: theme notebooks. 2010-12-04 15:39:11 +01:00
Carlos Garnacho
d4aade109f Fix gtk_css_provider_get_named() docs. 2010-12-04 15:39:09 +01:00
Carlos Garnacho
8243c3c025 GtkCssProvider: Fix typo in gtk_css_provider_get_named()
provider was being redefined in the inner block, so the loaded
provider didn't get to be returned.
2010-12-04 15:39:08 +01:00
Carlos Garnacho
a185954d7c Hardcode 3.0 version for style files and paths.
It's about time to start using the right paths.
2010-12-04 15:39:07 +01:00
Carlos Garnacho
9ffaf1122d GtkCssProvider: Accept '%' in value strings. 2010-12-04 15:39:06 +01:00
Carlos Garnacho
62ee0956e3 GtkStyleProperties: Use GParamSpec for properties registration. 2010-12-04 15:39:06 +01:00
Carlos Garnacho
1c847d9c21 GtkCssProvider: Docs fix for -gtk-gradient() syntax. 2010-12-04 15:39:06 +01:00
Carlos Garnacho
bcf81a0e23 Handle looping transition animations. 2010-12-04 15:39:05 +01:00
Carlos Garnacho
1123159dc9 GtkCssProvider: Handle better wrong enum/flag values. 2010-12-04 15:39:05 +01:00
Carlos Garnacho
9bb96e271d GtkCssProviders: Parse GTypeFlags based values. 2010-12-04 15:39:05 +01:00
Carlos Garnacho
5cb6fed0bd GtkCssProvider: Add initial unit parsing logic
At the moment only "px" are supported, and such is the default
value when no unit is specified.
2010-12-04 15:39:05 +01:00
Carlos Garnacho
65abcb722e GtkCssProvider: Handle the "none" keyword to unset properties. 2010-12-04 15:39:05 +01:00
Carlos Garnacho
8b9b9c22e7 GtkCssProvider: Also parse GdkColor values
This is necessary for widget style properties to work.
2010-12-04 15:39:04 +01:00
Carlos Garnacho
815e3499ae GtkCssProvider: Add lighter/darker color functions.
These behave the same than in GtkStyle.
2010-12-04 15:39:04 +01:00
Carlos Garnacho
cb2f9a86e5 GtkCssProvider: allow color names from rgb.txt when parsing colors. 2010-12-04 15:39:03 +01:00
Carlos Garnacho
1487b34679 Remove GTK_STATE_LAST.
It didn't turn out to be that useful, nor widely used.
2010-12-04 15:38:56 +01:00
Carlos Garnacho
1fb6cc8d77 Use the correct cairo-gobject.h include path. 2010-12-04 15:38:56 +01:00
Carlos Garnacho
3848a58b17 GtkCssProvider: theme progressbars in default CSS. 2010-12-04 15:38:48 +01:00
Carlos Garnacho
8b267a58da GtkCssProvider: Do not miss the last class name in concatenated classes.
Selectors like .menu.check or .entry.progressbar were being misparsed
and attributed to .menu and .entry.
2010-12-04 15:38:45 +01:00
Carlos Garnacho
912ad78cc5 Remove GTK_REGION_DEFAULT
GTK_STYLE_CLASS_DEFAULT is preferred to match a default area, as
it doesn't make sense to have a per-region default.
2010-12-04 15:38:41 +01:00
Carlos Garnacho
4acc20abc1 s/GtkStyleSet/GtkStyleProperties/
The former name had oddities such as gtk_style_set_set() and such,
so the new name is nicer in that regard and not much longer.
2010-12-04 15:38:29 +01:00
Carlos Garnacho
8ea649e0a0 Rely only on fg/bg colors.
"foreground-color" has been renamed to just "color" as in regular CSS,
and the "text-color" and "base-color" properties have been removed. The
default CSS has been changed to have widgets cope with this change.
2010-12-04 15:38:29 +01:00
Carlos Garnacho
7de2cf3286 GtkCssProvider: Fix parsing of concatenated classes.
Now selectors such as:

 GtkWidget#name.class1.class2
 #name.class1.class2
 .class1.class2

are parsed correctly, being meaningful for a widget defining several
classes.
2010-12-04 15:38:29 +01:00
Carlos Garnacho
51b742044a GtkCssProvider: Parse alpha() symbolic colors.
The "alpha" symbolic color modifies a passed color's alpha by a factor,
the syntax would accept things like:

background-color: alpha (@bg_color, 0.8);
foreground-color: alpha (shade (@fg_color, 0.8), 0.5);
2010-12-04 15:38:28 +01:00
Carlos Garnacho
0bd81ef710 GtkCssProvider: Make default style depend more on custom colors. 2010-12-04 15:38:28 +01:00
Carlos Garnacho
087249db07 GtkCssProvider: Update end string when misparsing symbolic colors. 2010-12-04 15:38:26 +01:00
Carlos Garnacho
7d441000f7 GtkCssProvider: Allow '\t' when parsing values. 2010-12-04 15:38:26 +01:00
Carlos Garnacho
39ce35dd75 GtkCssProvider: Improve default CSS. 2010-12-04 15:38:26 +01:00
Carlos Garnacho
4e02218f52 Use GdkRGBA all around in GtkStyleContext. 2010-12-04 15:38:25 +01:00
Carlos Garnacho
0a0a1a20a7 GtkCssProvider: Make it able to parse enums. 2010-12-04 15:38:23 +01:00
Carlos Garnacho
d03caa4683 GtkCssProvider: Run through the widget path in the correct order.
Comparing a selector with a widget path was being done backwards since
the change to use GtkContainer::get_path_for_child().
2010-12-04 15:38:23 +01:00
Carlos Garnacho
c2f47063c3 GtkCssProvider: Parse default/sorted region flags. 2010-12-04 15:38:22 +01:00
Carlos Garnacho
4a9890e3ab GtkCssProvider: Parse missing widget states. 2010-12-04 15:38:22 +01:00
Carlos Garnacho
a79626b7fb Add theming docs
Both API and file format is documented, there's still missing
a migration doc though.
2010-12-04 15:38:21 +01:00
Benjamin Berg
e8c103f652 Use cairo gobject support instead of a new boxed type. 2010-12-04 15:38:20 +01:00
Carlos Garnacho
88a3c2daae GtkGradient: Handle symbolic gradients.
The css parser has been modified to parse correctly radial gradients:

background-image: -gtk-gradient (radial,
                                 center center, 0,
                                 center center, 0.8,
                                 from (#000), to (#fff));

The theming engine has been modified to correctly animate these,
as well as transitions between different pattern types.
2010-12-04 15:38:20 +01:00
Carlos Garnacho
f9788eb173 GtkCssProvider: Add support for @import rules
Now other CSS files can be referenced from the currently parsed file:

@import url (other-file.css);
@import url (/some/file.css);
2010-12-04 15:38:18 +01:00
Carlos Garnacho
0ef48c0bde GtkCssProvider: no need for resetting the parser prior to parsing data
This is done anyway on each iteration to parse_rule() in parse_stylesheet()
2010-12-04 15:38:18 +01:00
Carlos Garnacho
8e96e4e41f GtkCssProvider: improve file paths parser.
It will now return a full path, and check about the file being sane.
2010-12-04 15:38:18 +01:00
Carlos Garnacho
1772b00e85 GtkCssProvider: Transform custom colors to a @define-color rule.
Given there are other rules such as @import (which will be supported),
keep a sane namespace here, so for (re)defining a color name, in the CSS
file it will look like:

@define-color color-name #fff;
@define-color other-color mix (@color-name, #f00, 0.4);
2010-12-04 15:38:18 +01:00
Carlos Garnacho
5c2cf1e934 Plug some leaks. 2010-12-04 15:38:18 +01:00
Carlos Garnacho
5c8a818671 Fix typo in the Gtk9Slice parser. 2010-12-04 15:38:17 +01:00
Carlos Garnacho
20051e02eb GtkCssProvider: use mapped file to read CSS files. 2010-12-04 15:38:16 +01:00
Carlos Garnacho
80cf01c271 GtkCssProvider: unset filename on load_from_data() 2010-12-04 15:38:16 +01:00
Carlos Garnacho
7ee564c7cd GtkCssProvider: Add a parser for 9slice typed properties.
The value it parses is similar to the border-image CSS3 property,
so strings like this will be accepted:

  border-image: url (foo.png) 4 3 4 3 repeat repeat;

the image path is relative to the parsed CSS file dirname if no
absolute path is provided.
2010-12-04 15:38:16 +01:00
Carlos Garnacho
679ff63d5c GtkCssProvider: Add gtk_css_provider_get_named()
This functions loads a CSS file from a installed theme.
2010-12-04 15:38:15 +01:00
Carlos Garnacho
3fc5c87bcb GtkCssProvider: Add a parser for gradients. 2010-12-04 15:38:12 +01:00
Carlos Garnacho
c908e263ac GtkCssProvider: strip whitespaces in symbolic color values. 2010-12-04 15:38:11 +01:00
Carlos Garnacho
f12d7409cc Allow linefeeds in property values. 2010-12-04 15:38:11 +01:00
Carlos Garnacho
58a51bca97 GtkStyle: Fill in x/ythickness and font_desc from the style context. 2010-12-04 15:38:11 +01:00
Carlos Garnacho
585afafa39 Add basic parser for GtkBorder properties.
Different units aren't supported, it takes 1 to 4 integers representing
pixel distances.
2010-12-04 15:38:10 +01:00
Carlos Garnacho
c9d626523d Remove gtkalias from style context code. 2010-12-04 15:38:09 +01:00
Carlos Garnacho
9dfba95f09 GtkCssProvider: Add gtk_css_provider_load_from_path() 2010-12-04 15:38:09 +01:00
Carlos Garnacho
52baa7d51e GtkCssProvider: Parse properties of type GtkAnimationDescription. 2010-12-04 15:37:38 +01:00
Carlos Garnacho
4781f94de2 Move all theming stack to use GtkStateFlags.
This support goes from the theming engines, which are able to retrieve
style for different combined states to the CSS provider, where several
state pseudo-classes may be specified, such as:

GtkButton:active:prelight {}
2010-12-04 15:37:37 +01:00
Carlos Garnacho
bccec3ef0c GtkCssProvider: Use class for tooltips. 2010-12-04 15:37:36 +01:00
Carlos Garnacho
74697d91fe GtkCssProvider: Parse and match class info. 2010-12-04 15:37:36 +01:00
Carlos Garnacho
a3637ec60d s/child class/region/ everywhere.
"Child class" is an invented term anyway, and it conceptually defines
identifiable regions in widgets.
2010-12-04 15:37:35 +01:00
Carlos Garnacho
e04dfd4d6d GtkThemingEngine: Add gtk_theming_engine_register_property().
This function may be used for custom property registration from
theming engines. The property names will have the
-${engine-type-name}-${prop-name} format, the parser has been
modified to allow properties with '-' as the first char.
2010-12-04 15:37:35 +01:00
Carlos Garnacho
355f0d69ab GtkStyleSet: Allow custom parsers on registered properties. 2010-12-04 15:37:35 +01:00
Carlos Garnacho
99224c9eec GtkCssProvider: Parse correctly widget types with a name.
There's now a distinction between:

GtkLabel#label-name: Label with name "label-name"
GtkWindow #label-name: Window containing a widget named "label-name"
2010-12-04 15:37:34 +01:00
Carlos Garnacho
56e4ffabea Compare widget names as GQuarks in style matching. 2010-12-04 15:37:34 +01:00
Carlos Garnacho
09d8592b5b GtkWidgetPath: Make API more consistent. 2010-12-04 15:37:34 +01:00
Carlos Garnacho
ad08330fae Compare region names as quarks in style matching. 2010-12-04 15:37:34 +01:00
Carlos Garnacho
d47d3d0200 GtkCssProvider: Set child combinators in default CSS. 2010-12-04 15:37:34 +01:00
Carlos Garnacho
5f77ead9c6 GtkCssProvider: Parse and compare widget names. 2010-12-04 15:37:33 +01:00
Carlos Garnacho
52878c45b5 GtkCssProvider: Don't jump too eagerly to the next element when comparing selectors. 2010-12-04 15:37:33 +01:00
Carlos Garnacho
85dbc71921 GtkCssProvider: Immediately bail out if GType couldn't be resolved. 2010-12-04 15:37:33 +01:00
Carlos Garnacho
9ebbc7b5c5 GtkCssProvider: Small optimization. 2010-12-04 15:37:33 +01:00
Sven Herzberg
c001833ed1 GtkCssProvider: don't ignore custom attributes
* gtk/gtkcssprovider.c: don't ignore custom attribites (which can be
  added by theme engines)
2010-12-04 15:37:33 +01:00