Commit Graph

22981 Commits

Author SHA1 Message Date
Benjamin Otte
df51bc836b cssnode: Always return correct style values
If CSS values are queried from a widget, recompute them if necessary. Do
not emit style-updated until the validation phase however.

This way, we don't run into performance traps when style-update causes
invalidations that cause new style-updated to be emitted.
2015-03-18 15:23:32 +01:00
Benjamin Otte
3d1e2a0558 cssstyle: Add optimization
There is no difference between a style and itself.
2015-03-18 15:23:32 +01:00
Benjamin Otte
399df06d19 stylecontext: Refactor gtk_style_context_invalidate()
There's no need anymore to recreate styles, nodes do that automagically
now.

This allows making gtk_css_node_set_style() private.
2015-03-18 15:23:32 +01:00
Benjamin Otte
6dd19306eb cssnode: Create animated styles by default
... and hardcode transient and path nodes to never create animated
styles.
2015-03-18 15:23:32 +01:00
Benjamin Otte
f43543165b cssnode: Add optimization
Don't even try to propagate changes when we know there are none.
2015-03-18 15:23:32 +01:00
Benjamin Otte
2954417335 cssnode: Change the way we start animations
We now have a flag for "invalidate animations", use that to restart
animations and decide if we want to start transitions.
2015-03-18 15:23:32 +01:00
Benjamin Otte
172f345d01 cssnode: Return NULL as frame clock when animations are disabled
This is a crude hack, but it works.

FIXME: Hook it up to the GtkSettings so that we properly update when the
setting changes.
2015-03-18 15:23:32 +01:00
Benjamin Otte
fbe796f293 cssstyle: Handle 0 timestamp to mean "don't animate" 2015-03-18 15:23:32 +01:00
Benjamin Otte
2ec26cd9b5 cssnode: Move style context function to only user 2015-03-18 15:23:32 +01:00
Benjamin Otte
4b2cdb37fb cssnode: Remove timestamp from gtk_css_node_validate()
GtkCssNode knows its own timestamp.
2015-03-18 15:23:32 +01:00
Benjamin Otte
dbe5058b86 cssnode: Add API to query the timestamp
... and pass it to the API that computes new styles.

A special timestamp of 0 means "please don't animate" and is used when
no frame clock is available for a node.
2015-03-18 15:23:32 +01:00
Benjamin Otte
5833858abf cssnode: Make parent style change part of GtkCssNode 2015-03-18 15:23:32 +01:00
Benjamin Otte
ceaa594fa4 cssnode: Propagate pending changes after recomputing new style
This way we can propagate if the new style actually changed anything.
2015-03-18 15:23:32 +01:00
Benjamin Otte
cadf6a9d3c cssnode: Add gtk_css_node_invalidate_style_provider()
This function not just invalidates the current node, but also all
children.
2015-03-18 15:23:32 +01:00
Benjamin Otte
16b8972bee cssnode: Change get_style_provider() vfunc
Instead of always returning a provider, allow the vfunc to return NULL
to mane "use same provider as parent". This allows a bunch of
optimizations.
2015-03-18 15:23:32 +01:00
Benjamin Otte
c0f6e746a0 cssnode: Implement a way to properly track invalidations
See the comment in gtkcssnodeprivate.h for how this works.
2015-03-18 15:23:32 +01:00
Benjamin Otte
13fd368781 cssnode: Change vfunc
This is mainly an attempt to merge the update_style() and validte()
vfuncs. Code is not there yet, but that's the idea.

Also, gtk_css_node_set_style() should not be public. And this gets
closer to that goal, too.
2015-03-18 15:23:31 +01:00
Benjamin Otte
75b633ae08 cssnode: Only pass a boolean for parent changes
Nobody cares what changed in the parent, so don't track it.
2015-03-18 15:23:31 +01:00
Benjamin Otte
da25771e58 cssvalue: Remove GtkCssDependencies
They are not used anymore.
2015-03-18 15:23:31 +01:00
Benjamin Otte
e95985da26 cssstyle: Remove unused optimization
After measuring it, I realized the optimization never triggers for
Adwaita and rarely ever triggers for simple themes. So it is not
useful to keep it around.
2015-03-18 15:23:31 +01:00
Benjamin Otte
6f9969f4fe csswidgetnode: Always return a valid style 2015-03-18 15:23:31 +01:00
Benjamin Otte
b827725ace csspathnode: Call gtk_style_context_validate()
Don't call gtk_style_context_invalidate(), that function does too much
work.
2015-03-18 15:23:31 +01:00
Benjamin Otte
d3471508a0 cssnode: Use the frame clock's time
... nstead of the monotonic time when validating a cssnode.
2015-03-18 15:23:31 +01:00
Benjamin Otte
9b73b39f9a cssnode: Treat transient nodes as invisible nodes
Making transient nodes invisible allows us to remove special cases
without any bad side effects and they continue working just like they
did before.
2015-03-18 15:23:31 +01:00
Benjamin Otte
2694545468 cssnode: Add visibility concept
This allows hiding nodes of invisible widgets.
And that in turn makes sure :nth-child() works as expected.
2015-03-18 15:23:31 +01:00
Benjamin Otte
ee91fb71ca box: Use CSS nodes instead of widget paths
This is a very simple patch that causes a bunch of overhead. But it
works.
2015-03-18 15:23:31 +01:00
Benjamin Otte
b92fe2fa85 widget: Add gtk_widget_get_css_node()
and replace gtk_style_context_get_root() with it.
2015-03-18 15:23:31 +01:00
Benjamin Otte
507016cafc cssnode: Refactor node tree modification code
This allows adding more API for it.

It also includes code that tracks modifications and invalidates siblings
and their positions whenever nodes get added or removed.
2015-03-18 15:23:31 +01:00
Benjamin Otte
310f9f40da cssnode: Add hackery to allow bypassing widget paths
If we know the parent's get_path_for_child() implementation is safe to
be used with GtkCssNode because it doesn't do anything special, we do
that. Unfortunately that requires whitelisting vfuncs because the vfunc
is public API so anyone can override it.
2015-03-18 15:23:31 +01:00
Benjamin Otte
ee6d081ed9 cssnode: Remove now unused arg from vfunc 2015-03-18 15:23:31 +01:00
Benjamin Otte
89115be3cb cssnode: Add a matcher for nodes
... and use that matcher by default - ie for transient nodes.
2015-03-18 15:23:31 +01:00
Benjamin Otte
2a5194b635 cssnode: Make widget node not copy the path
Instead, use gtk_widget_get_path() which makes GtkWidget cache the path.
This is a temporary solution until we can get rid of widget paths.

This increases memory usage quite noticably.
2015-03-18 15:23:30 +01:00
Benjamin Otte
2143abe5ee cssnode: Make widget node use new matcher 2015-03-18 15:23:30 +01:00
Benjamin Otte
76ca9a9181 cssnode: Make path node create matcher without copying
... the WidgetPath. This uses the functionality introduced in the
previous commits.
2015-03-18 15:23:30 +01:00
Benjamin Otte
2bf7bdd651 cssmatcher: Allow widget path matcher to take a node declaration
The node declaration has the same functionality as
gtk_css_node_declaration_add_to_widget_path(). So instead of using that
function on a path, you can use the original path and the declaration in
a matcher.
2015-03-18 15:23:30 +01:00
Benjamin Otte
630f0f199e cssnode: Split out a function
So far the vfunc is kinda quirky (the path argument is an out argument
for something you have to free when you're done with the matcher), but
  I'm about to change that.
2015-03-18 15:23:30 +01:00
Benjamin Otte
5df01f9244 widget: Create widget path classes from proper style
We don't want to add the current classes to the widget path - which
might potentially be different after a gtk_style_context_save() - but
the root node's ones. So what better thing to do than actually using the
root node?
2015-03-18 15:23:30 +01:00
Benjamin Otte
5edc6d94d1 widget: Use correct type for widgetpath creation
This is relevant when the widget path is created while the widget is
still constructing. G_OBJECT_TYPE(widget) might not point to the final
type yet.
2015-03-18 15:23:30 +01:00
Benjamin Otte
ffb410f11e widget: Create the CssNode
... and pass it to the style context instead of having the style context
create it for us.
2015-03-18 15:23:30 +01:00
Benjamin Otte
28043f0a92 cssnode: Refactor invalidation propagation
We want to be sure to gtk_css_node_invalidate() all potential changes.
2015-03-18 15:23:30 +01:00
Benjamin Otte
efda30c495 stylecontext: Don't queue animate tick callbacks anymore
Instead, just mark nodes permanently as invalid.
2015-03-18 15:23:30 +01:00
Benjamin Otte
020f3f11c8 cssnode: Handle invalidate queueing differently
Instead of directly requesting the layout phase, register a tick
callback. This is what the docs suggest for animations and it's what we
need for the next commit.
2015-03-18 15:23:30 +01:00
Benjamin Otte
cdd964a3af cssnode: Change way invalidation is handled
Have a queue_validate() vfunc and a dequeue_validate() vfunc that are
called only on root nodes so they can queue a validation on their frame
clocks.
2015-03-18 15:23:30 +01:00
Benjamin Otte
5f19f09ac3 cssnode: Refactor gtk_css_widget_node_validate()
Makes it clearer what actually happens in that function.
2015-03-18 15:23:30 +01:00
Benjamin Otte
caf2fc9a10 cssnode: Only recreate styles when needed 2015-03-18 15:23:30 +01:00
Benjamin Otte
219e52f7e1 cssnode: Automatically recreate style on get_style() call
When the style is invalid, redo it.

Make this a vfunc, so the widget nodes can opt out.
2015-03-18 15:23:30 +01:00
Benjamin Otte
71813671ef cssnode: Track pending changes here
... instead of GtkCssWidgetNode.
2015-03-18 15:23:30 +01:00
Benjamin Otte
c550cf122a stylecontext: Move gtk_style_context_validate() to GtkCssWidgetNode 2015-03-18 15:23:30 +01:00
Benjamin Otte
649edbe2fc stylecontext: Move style creation functions to CssNode code 2015-03-18 15:23:30 +01:00
Benjamin Otte
c4b88e05fd stylecontext: Redo handling of differing state
Instead of passing an "override_state" flag, create a new CssNode just
for this simple lookup.
2015-03-18 15:23:30 +01:00
Benjamin Otte
637a4bda5c stylecontext: Get rid of stylecontext argument
... to a bunch of functions.

This requires a tiny change to the heuristics for the style cache - we
now cache styles when they have the same style provider as their parent
instead of when they have the default provider - but that change doesn't
have any effect in practice.
2015-03-18 15:23:29 +01:00
Benjamin Otte
03ac5f310b cssnode: Add gtk_style_context_get_style_provider()
... and use it when looking up properties.
2015-03-18 15:23:29 +01:00
Benjamin Otte
6dc6af674c stylecontext: Remove children list
It's not needed.
2015-03-18 15:23:29 +01:00
Benjamin Otte
4cc2af2db1 stylecontext: Move validation into GtkCssNode 2015-03-18 15:23:29 +01:00
Benjamin Otte
8e1017db35 stylecontext: Export gtk_style_context_get_root()
.. in the private header. This avoids tiny wrapper functions.
2015-03-18 15:23:29 +01:00
Benjamin Otte
55e68bc2ea cssnode: Track invalid flag
Remove it from GtkStyleContext.
2015-03-18 15:23:29 +01:00
Benjamin Otte
a589f98821 cssnode: Implement refcounting
The parent refs the child, so gtk_css_node_set_parent() adds/removes a
reference.

We should probably refactor this so that we name the function
parent.add(node) instead of node.set_parent(parent) - makes the
refcounting more clear.
2015-03-18 15:23:29 +01:00
Benjamin Otte
721dce73e0 stylecontext: Handle parent in CssNode code
Make CssNode a real tree with a DOM-like API.
2015-03-18 15:23:29 +01:00
Benjamin Otte
8c73799ca8 stylecontext: Move relevant_changes tracking to GtkCssWidgetNode 2015-03-18 15:23:29 +01:00
Benjamin Otte
7bafb63ec3 cssnode: Handle invalidation
Handle invalidation of node inside the CssNode code, don't do it in the
stylecontext.
2015-03-18 15:23:29 +01:00
Benjamin Otte
d79a44c1af stylecontext: Get rid of create_query_path()
Move that functionality into GtkCssNode.
2015-03-18 15:23:29 +01:00
Benjamin Otte
6f99a3cdb0 stylecontext: Change arguments for build_properties
Instead of passing the style declaration, take the node's style
declaration. Add arguments to allow overriding the state for the one
case where this didn't work.
2015-03-18 15:23:29 +01:00
Benjamin Otte
0e3da2f7cf stylecontext: Compute rootness of CssNode
.. instead of passing it as an argument.
2015-03-18 15:23:29 +01:00
Benjamin Otte
b9f1f8aa38 stylecontext: Pass cssnode to build_properties 2015-03-18 15:23:29 +01:00
Benjamin Otte
21c3b13596 stylecontext: Simplify a function 2015-03-18 15:23:29 +01:00
Benjamin Otte
40d94fcd38 stylecontext: Remove values cache
The code is confusing the stylecontext=>node transition, so I'll remove
it.

WIth the recent introduction of the parent style cachen, I'm not sure
it's worth it at all. Some crude benchmarking suggests a slight speedup
when removing the cache.

So no guarantees about adding it back later.
2015-03-18 15:23:29 +01:00
Benjamin Otte
e2f6d4db43 cssnode: Split into 3 objects
- GtkCssWidgetNode
  for style contexts owned by a widget
- GtkCssPathNode
  for style contexts using a GtkWidgetPath
- GtkCssTransientNode
  for nodes created with gtk_style_context_save()/restore()
2015-03-18 15:23:29 +01:00
Benjamin Otte
726d8abb7d cssnode: Turn into a GObject
This will allow us to use subclasses.
2015-03-18 15:23:28 +01:00
Benjamin Otte
cf6d9edc12 stylecontext: Turn CssNode accesses into getters/setters
That way we can hide the struct in the source file.
2015-03-18 15:23:28 +01:00
Benjamin Otte
be596f3967 stylecontext: Split out GtkCssNode into own file
The functionality of it is supposed to grow, so better put it in a
custom file early.

This is just a naive split so far, the next patches will split things
further.
2015-03-18 15:23:28 +01:00
Benjamin Otte
99c4f2dd39 render: Make image effect not depend on state
Instead rely on -gtk-image-effect only. Adwaita should already work this
way.

Relying on state was a leftover feature from the GTK 2 days.
2015-03-18 15:22:09 +01:00
Benjamin Otte
0529e15d61 notebook: Protect against invalid allocations
A widget can be mapped but not have a size allocated yet. In that case
avoid computing a broken rectangle.

https://bugzilla.gnome.org/show_bug.cgi?id=746301
2015-03-18 15:14:47 +01:00
Christian Hergert
28063ee2e4 textview: add support for underline and strikethrough colors
This commit adds the GtkTextTag:underline-rgba and :strikethrough-rgba
properties and the necessary plumbing to apply these colors in GtkTextLayout.
With this change, you can alter the color of underlines including those
of type PANGO_UNDERLINE_ERROR.

You might want to alter the underline color to differentiate between
spelling and grammer mistakes. In code editors, it is convenient to
differentiate between errors and warnings.

Note that the GtkTextAppearance struct is public ABI and has no spare
room for new fields, so we are resorting to some tricky packing to store
the colors in the unused pixel field of the fg_color and bg_color structs.
This packing is accomplished by the macros in gtktextattributesprivate.h.

Signed-off-by: Christian Hergert <christian@hergert.me>

https://bugzilla.gnome.org/show_bug.cgi?id=402168
2015-03-17 23:24:13 -04:00
Matthias Clasen
416c370da1 GtkRange: Fix scroll wheel direction for horizontal ranges
The expected behavior here is that scrolling up goes towards
larger values, ie to the right. This matches e.g. volume
sliders in gnome-shell.

https://bugzilla.gnome.org/show_bug.cgi?id=737175
2015-03-17 22:02:35 -04:00
Matthias Clasen
d823c39caf scrolled window: Use shift to modify scroll direction
It has been a long-standing request to interpret scroll events
with Shift held down as horizontal instead of vertical, and
some applications are already doing this on their own.

https://bugzilla.gnome.org/show_bug.cgi?id=132197
2015-03-17 20:50:24 -04:00
Matthias Clasen
00544e9090 HighContrast: Fix calendar selection
The selected day was not differentiated from other
days at all. Render it white on black instead.

https://bugzilla.gnome.org/show_bug.cgi?id=746369
2015-03-17 19:38:18 -04:00
Matthias Clasen
3d3591e873 HighContrast: Fix color chooser marks
The checkmark for the selected color was always black,
making it more or less invisible on dark colors.

https://bugzilla.gnome.org/show_bug.cgi?id=746368
2015-03-17 19:34:15 -04:00
Jakub Steiner
49b6be4e06 HighContrast: catch backdrop:insensitive:active of GtkSwitch
https://bugzilla.gnome.org/show_bug.cgi?id=746358
2015-03-17 23:55:10 +01:00
Jakub Steiner
557f5d5c7c HighContrast: unbreak GtkExpander
- the open state is checked, not active now

https://bugzilla.gnome.org/show_bug.cgi?id=746370
2015-03-17 23:43:20 +01:00
Jakub Steiner
f671cd6296 HightContrast: make tab buttons not shift size
- only 1px stroke for close buttons in notebook tabs

https://bugzilla.gnome.org/show_bug.cgi?id=746149
2015-03-17 18:18:18 +01:00
Jakub Steiner
9b5fa0860f HighContrast: OSD fixes
- buttons
- labels
- scale trough/slider

https://bugzilla.gnome.org/show_bug.cgi?id=746148
2015-03-17 18:09:28 +01:00
Jakub Steiner
6f478db2fa Adwaita: desaturate selected color for backdrop
https://bugzilla.gnome.org/show_bug.cgi?id=746202
2015-03-16 19:41:19 +01:00
Matthias Clasen
c7672699e9 Don't pass invalid rectangles to cairo
This causes pixman warnings, or worse.
Clearly, something is not quite right here, if we end up
redrawing tabs at a time when the allocation is set to (1, 1).
For now, avoid straining the error handling in the lower layers.

https://bugzilla.gnome.org/show_bug.cgi?id=746301
2015-03-16 12:51:56 -04:00
Matthias Clasen
855c4dc0ce unrealize: Don't ref twice
After the recent change to add an outermost ref/unref pair,
we can do away with the inner one.
2015-03-16 11:54:38 -04:00
Carlos Garnacho
70e7b4c848 inspector: Remove flash timeout from widgets being unmapped
Otherwise the timeout can keep running, even if the widget is being
destroyed.
2015-03-16 16:29:37 +01:00
Carlos Garnacho
b4b23580a6 window: Protect against popover destruction on ::unmap
On popover_unmap(), perform the gtk_widget_unmap() call last, so the
GtkWindowPopover data is ensured to be alive throughout the function
if the popover widget is destroyed right on ::unmap.

https://bugzilla.gnome.org/show_bug.cgi?id=745829
2015-03-16 16:27:06 +01:00
Carlos Garnacho
b4e61b759b widget: Take a ref during ::unrealize emission
In order to prevent invalid memory access/crashes if the widget is
destroyed in a callback of that signal.

https://bugzilla.gnome.org/show_bug.cgi?id=745829
2015-03-16 16:27:06 +01:00
Carlos Garnacho
f5f6ad9981 widget: Take a ref during ::unmap emission
This ensures the widget data stays live long enough to perform invariants
check after emission if the widget happens to be destroyed on a callback.

https://bugzilla.gnome.org/show_bug.cgi?id=745829
2015-03-16 16:22:25 +01:00
Benjamin Otte
a24aee6bb2 spinbutton: Fix get_text_area_size for vertical spinbuttons
Commit c5905b13b9 changed the semantics of
this vfunc and get_entry_size but I only fixed one of them in the
spinbutton subclass.

https://bugzilla.gnome.org/show_bug.cgi?id=746282
2015-03-16 15:24:16 +01:00
Jakub Steiner
6675b9639c HC: no border for insensitive backdrop buttons
https://bugzilla.gnome.org/show_bug.cgi?id=746192
2015-03-16 12:37:54 +01:00
Matthias Clasen
e98b096ca8 print dialog: Stop using follow-state
It is no longer needed.
2015-03-15 22:44:33 -04:00
Matthias Clasen
399d2c1389 app chooser widget: Stop using follow-state
It is no longer needed.
2015-03-15 22:44:33 -04:00
Matthias Clasen
59a901e285 places sidebar: Stop using follow-state
It is no longer needed.
2015-03-15 22:44:33 -04:00
Nelson Benítez León
11096885ae gemfile: needs add source rubygems.org
`bundle install` command on fedora 21 was failing
with following message:

Your Gemfile has no gem server sources. If you need
gems that are not already on your machine, add a line
like this to your Gemfile:
source 'https://rubygems.org'

After adding that line it worked again.

https://bugzilla.gnome.org/show_bug.cgi?id=746205
2015-03-14 23:48:21 +01:00
Benjamin Otte
c5905b13b9 entry: Make code do what it's meant to do
With the 3.0 transition, this code went from just querying the entry's
height request to doing a full size request.
Then it got code to revert the features that a full size request does.
And then it grew code that manually computed the baseline.

Avoid this and just do what happened back in the days: Do a regular
height request.

This changes the semantics of the get_frame_size() vfunc wrt its
behavior towards subclasses overwriting the get_height() vfuncs, but I'm
happy to live with that.
2015-03-14 15:46:13 +01:00
Benjamin Otte
d2881d901b cellrendererpixbuf: Always follow state
Applications forget to set the follow-state property and then some
themes used a style where normal symbolic icons have the same color as
prelit or selected backgrounds and that suddenly made icons invisible
and who wants that?

https://bugzilla.gnome.org/show_bug.cgi?id=746201
2015-03-14 15:46:13 +01:00
Carlos Soriano
7ef7873b23 gtkstacksidebar: fix missing macro
commit e41cadd835 forgot to change some macros.
2015-03-14 13:41:57 +01:00
Matthias Clasen
e41cadd835 GtkStackSidebar: Fix incomplete renaming
Some of the boilerplate macros were missing. Oops
2015-03-13 23:24:53 -04:00
Matthias Clasen
0ddb5d729c More documentation fixes 2015-03-13 23:24:53 -04:00
Matthias Clasen
c93d66c8a7 Fix a typo in the docs
gtk-doc complains about parameter name mismatches.
2015-03-13 23:24:53 -04:00