Compare commits

...

122 Commits

Author SHA1 Message Date
Benjamin Otte 1af58dc4ee entry: Use cssnodeutils for the widget node 2015-03-22 02:44:41 +01:00
Benjamin Otte cb1cf06744 cssnodeutils: Implement margins 2015-03-20 18:55:27 +01:00
Benjamin Otte c5d00ae119 css: Add min-width/height CSS properties
Use them for the minimum size during size requests.
2015-03-20 14:59:36 +01:00
Benjamin Otte 15582ef9c1 entry: Make progressbar a CssNode 2015-03-20 14:59:28 +01:00
Benjamin Otte 0e57785af7 entry: Set insensitive state on icon css node
... instead of doing it on-demand.
2015-03-20 14:59:28 +01:00
Benjamin Otte 52f58f1637 entry: Use the :active state for pressed icons 2015-03-20 14:59:28 +01:00
Benjamin Otte cd87252130 entry: Set the prelight flag on the CSS node 2015-03-20 14:59:28 +01:00
Benjamin Otte 85d86d61de cssnode: Add gtk_css_node_add/remove_state() API
This mirrors gtk_css_node_add/remove_class() APIs and allows you to
specify a (set of) state(s) to set or unset.

These functions are purely convenience.
2015-03-20 14:59:28 +01:00
Benjamin Otte 0d01ceb415 entry: Prelight icons when pressed
There's no reason to not keep them in the prelight state, theme authors
can override a prelight effect in :active if they want.
2015-03-20 14:59:28 +01:00
Benjamin Otte aa005486de entry: Ignore the "icon-prelight" style property
Always prelight icons. CSS is powerful enough to let people keep the
appearance the same upon prelight.
2015-03-20 14:59:27 +01:00
Benjamin Otte cdd26d0d01 entry: Set style classes on entry icons upon state change 2015-03-20 14:59:27 +01:00
Benjamin Otte f408c59869 entry: Add a cssnode for icons 2015-03-20 14:59:27 +01:00
Benjamin Otte 4326e38b90 cssnode: Make classes APIs string-based
Using quarks is a bad idea now that we are calling the CssNode API
directly.
2015-03-20 14:59:27 +01:00
Benjamin Otte 0f488064a2 box: Port to cssnodeutils 2015-03-20 14:59:27 +01:00
Benjamin Otte e6c7e038c8 switch: Port to cssnodeutils 2015-03-20 14:59:27 +01:00
Benjamin Otte 18bd973014 cssnodeutils: Add a bunch of utility functions for using nodes
The idea is to wrap size request, size allocation and drawing each into
a function that takes care of the CSS box and then calls a callback to
request/allocate/draw the contents.

The idea is that complex widgets then nest these calls for all the css
nodes they need to handle.
2015-03-20 14:59:27 +01:00
Benjamin Otte dae2d9ec27 switch: Port to GtkCssNode
This is a simple port, no code modifications so far other than replacing
gtk_style_context_save() with gtk_style_context_save_to_node().
2015-03-20 14:59:27 +01:00
Benjamin Otte c0c79eee03 stylecontext: Add gtk_style_context_save_to_node()
To be used instead of gtk_style_context_save() with persistent nodes.
2015-03-20 14:59:27 +01:00
Jakub Steiner 3f13349f27 fix insensitive and backdrop states
- checkboxes, labels and buttons were a mixed bag for
  :insensitive and :backdrop

https://bugzilla.gnome.org/show_bug.cgi?id=746188
2015-03-20 13:25:52 +01:00
Matthias Clasen d6bfc2b9c9 HighContrast: fix insensitive labels
Make insensitive labels differerent from regular labels.

https://bugzilla.gnome.org/show_bug.cgi?id=746493
2015-03-20 06:20:30 -04:00
Matthias Clasen fa1bb8972a gtk-demo: Plug a memory leak 2015-03-19 22:57:10 -04:00
Matthias Clasen 8e82d0fba2 widget-factory: Fix toolbar on page 3
Set toolbar-style to 'icons' to avoid rectangular buttons.
2015-03-19 19:11:39 -04:00
Kjartan Maraas 7b1ff7c215 Updated Norwegian bokmål translation. 2015-03-19 21:13:10 +01:00
Vadim Rutkovsky 3211e82b59 inspector: show accessible name and description 2015-03-19 17:01:23 +01:00
Carlos Garnacho 6c8c37abbb wayland: Silence warnings on clipboard data sending cancellation
During copy/paste, it may be common that we receive several property changes
around the selection atom, this results in warnings when cancelling the previous
write attempt. We already honor the last request properly, so we should just
cancel silently.
2015-03-19 16:05:04 +01:00
Carlos Garnacho d5160bb950 wayland: Ensure we re-request the target if the fd changes
If we receive wl_data_source.target before .send, the target would already
be cached, but we'd take no action on the new fd.
2015-03-19 16:05:04 +01:00
Carlos Garnacho a59fd4a9ad wayland: Don't accept the "TARGETS" target on the wl_data_offer
This is handled separately through the data already cached from the
wl_data_offer.offer handler, we can avoid this request entirely then.
2015-03-19 16:05:04 +01:00
Милош Поповић 4d0e1e0b88 Updated Serbian translation 2015-03-19 13:20:12 +00:00
Benjamin Otte d48ba486ee Adwaita: Fix context menu shadows not showing up 2015-03-19 03:55:06 +01:00
Bastien Nocera 7dac38f841 inspector: Make it easier to cut'n'paste advice message
The message says "Enable statistics with GOBJECT_DEBUG=instance-count"
but the message itself isn't selectable, making it hard to cut'n'paste.

https://bugzilla.gnome.org/show_bug.cgi?id=746391
2015-03-18 22:05:46 -04:00
Benjamin Otte ec57c6c10b csspathnode: Handle context going away
Sometimes path nodes can survive longer than the style context that
created them. Don't crash in those cases.

Fixes startup of mutter.

Testcase included.

https://bugzilla.gnome.org/show_bug.cgi?id=746407
2015-03-18 18:24:45 +01:00
Benjamin Otte d55c261079 inspector: Add a new page that lists the CSS node tree 2015-03-18 15:23:33 +01:00
Benjamin Otte 8640bc47b1 cssnode: Add properties 2015-03-18 15:23:33 +01:00
Benjamin Otte d0d9f5a302 csswidgetnode: Use style_changed signal instead of update_style vfunc 2015-03-18 15:23:33 +01:00
Benjamin Otte 10d39171d9 cssnode: Add a style-changed signal
The signal gets emitted whenever the style needs to be changed.
2015-03-18 15:23:33 +01:00
Benjamin Otte 6988f9b818 cssnode: Add node-added and node-removed signal
This allows monitoring the CSS tree. For now, moving a child to a
different position relative to its siblings while keeping the same
parent will cause a child-added + child-removed emission.
2015-03-18 15:23:33 +01:00
Benjamin Otte c7fba52a36 cssnode: Track invalid children
We need to properly track if a node needs to propagate invalidation
state information to its children. We didn't do this properly before and
that could lead to us forgetting to invalidate nodes in corner cases.
2015-03-18 15:23:33 +01:00
Benjamin Otte 7395dddd47 csswidgetnode: Avoid creating a stylecontext
If the widget doesn't have a style context, don't create one. Instead,
call functions on the widget directly.
2015-03-18 15:23:33 +01:00
Benjamin Otte d785820c53 cssnode: Change the way we invalidate timestamps
Do not propagate the TIMESTAMP change through the node tree, as that
causes lots of uneeded markings of nodes as invalid.

Instead, walk the node tree and find the nodes that have a non-static
style and only invalidate timestamps on those.
2015-03-18 15:23:33 +01:00
Benjamin Otte 759d8dafd9 cssstyle: Add gtk_css_style_is_static()
Gets rid of the need to do

  if (ANIMATED_STYLE() &&
      animated_style_is_static(ANIMATED_STYLE(style))
2015-03-18 15:23:33 +01:00
Benjamin Otte d9727290cf cssnode: Special-case TIMESTAMP invalidations
Only invalidate timestamps if the node is marked as invalid. We overload
the meaning of "invalid" as "tracks timestamps".

While I don't like the way this is written, it is an important
optimization because 95+% of nodes don't animate so timestamps don't
matter to them. But timestamps are invalidated 60x per second.
2015-03-18 15:23:33 +01:00
Benjamin Otte 68b8f792d6 cssnode: Redo style changed tracking
We don't return a NULL style to mean "no changes" anymore, instead
we check new_style == old_style to mean that.

Make sure the code reflects this, otherwise we'll send
GTK_CSS_CHANGE_PARENT_STYLE invalidations everywhere and screw up
performance.
2015-03-18 15:23:32 +01:00
Benjamin Otte 776d99ac51 stylecontext: Call get_style(), not create_style()
We want to ensure that the style is created properly.

This also allows making the create_Style() function private.
2015-03-18 15:23:32 +01:00
Benjamin Otte 092ff983f7 cssnode: Merge the 2 places that compute styles
Now that the widget node recomputes styles on update_style() we can just
call it during validate(). That way, we don't need the widget node to
manually compute its style.
2015-03-18 15:23:32 +01:00
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 6c00eba7fb testsuite: Add another random stylecontext test 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 2670ae4436 reftests: Add a reftest for box sibling ordering 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
Carlos Garnacho dcfa55ac7e wayland: Fix thinko in wl_data_source.cancelled handler
The wl_data_source may be the clipboard's. Looking up the drag context in
order to get the display isn't going to fare well there. So, just use the
default display, and only look up the drag context when we know we need it.

https://bugzilla.gnome.org/show_bug.cgi?id=746386
2015-03-18 11:21:40 +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
115 changed files with 10023 additions and 5032 deletions
+1 -1
View File
@@ -543,7 +543,7 @@ add_data_tab (const gchar *demoname)
* not an image. Let's try something else then.
*/
g_object_ref_sink (widget);
gtk_widget_destroy (widget);
g_object_unref (widget);
bytes = g_resources_lookup_data (resource_name, 0, NULL);
g_assert (bytes);
+1
View File
@@ -3627,6 +3627,7 @@ microphone-sensitivity-medium-symbolic</property>
<object class="GtkToolbar">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="toolbar-style">icons</property>
<property name="icon-size">1</property>
<child>
<object class="GtkToolButton" id="toolbutton1">
+21 -15
View File
@@ -416,9 +416,11 @@ async_write_data_cb (GObject *object,
res, &error);
if (error)
{
g_warning ("Error writing selection data: %s", error->message);
g_error_free (error);
if (error->domain != G_IO_ERROR ||
error->code != G_IO_ERROR_CANCELLED)
g_warning ("Error writing selection data: %s", error->message);
g_error_free (error);
async_write_data_free (write_data);
return;
}
@@ -558,12 +560,12 @@ gdk_wayland_selection_request_target (GdkWaylandSelection *wayland_selection,
else
return FALSE;
if (fd >= 0)
wayland_selection->stored_selection.fd = fd;
if (wayland_selection->source_requested_target == target)
if (wayland_selection->stored_selection.fd == fd &&
wayland_selection->source_requested_target == target)
return FALSE;
wayland_selection->stored_selection.fd = fd;
wayland_selection->source_requested_target = target;
if (window && target != GDK_NONE)
@@ -668,16 +670,19 @@ data_source_cancelled (void *data,
g_debug (G_STRLOC ": %s source = %p",
G_STRFUNC, source);
context = gdk_wayland_drag_context_lookup_by_data_source (source);
display = gdk_window_get_display (context->source_window);
display = gdk_display_get_default ();
if (source == wayland_selection->dnd_source)
gdk_wayland_selection_unset_data_source (display, atoms[ATOM_DND]);
{
gdk_wayland_selection_unset_data_source (display, atoms[ATOM_DND]);
context = gdk_wayland_drag_context_lookup_by_data_source (source);
if (context)
gdk_wayland_drag_context_undo_grab (context);
}
else if (source == wayland_selection->clipboard_source)
gdk_wayland_selection_unset_data_source (display, atoms[ATOM_CLIPBOARD]);
if (context)
gdk_wayland_drag_context_undo_grab (context);
}
static const struct wl_data_source_listener data_source_listener = {
@@ -893,9 +898,10 @@ _gdk_wayland_display_convert_selection (GdkDisplay *display,
return;
}
wl_data_offer_accept (wayland_selection->offer,
_gdk_wayland_display_get_serial (GDK_WAYLAND_DISPLAY (display)),
gdk_atom_name (target));
if (target != gdk_atom_intern_static_string ("TARGETS"))
wl_data_offer_accept (wayland_selection->offer,
_gdk_wayland_display_get_serial (GDK_WAYLAND_DISPLAY (display)),
gdk_atom_name (target));
buffer_data = g_hash_table_lookup (wayland_selection->selection_buffers,
target);
+13 -2
View File
@@ -397,9 +397,12 @@ gtk_private_h_sources = \
gtkcsskeyframesprivate.h \
gtkcsslookupprivate.h \
gtkcssmatcherprivate.h \
gtkcssnodeprivate.h \
gtkcssnodedeclarationprivate.h \
gtkcssnodeutilsprivate.h \
gtkcssnumbervalueprivate.h \
gtkcssparserprivate.h \
gtkcsspathnodeprivate.h \
gtkcsspositionvalueprivate.h \
gtkcssproviderprivate.h \
gtkcssrepeatvalueprivate.h \
@@ -415,10 +418,12 @@ gtk_private_h_sources = \
gtkcssstyleprivate.h \
gtkcssstylepropertyprivate.h \
gtkcsstransformvalueprivate.h \
gtkcsstransientnodeprivate.h \
gtkcsstransitionprivate.h \
gtkcsstypedvalueprivate.h \
gtkcssunsetvalueprivate.h \
gtkcssvalueprivate.h \
gtkcsswidgetnodeprivate.h \
gtkcustompaperunixdialog.h \
gtkdialogprivate.h \
gtkentryprivate.h \
@@ -500,6 +505,7 @@ gtk_private_h_sources = \
gtkstylecontextprivate.h \
gtkstylepropertyprivate.h \
gtkstyleproviderprivate.h \
gtktextattributesprivate.h \
gtktextbtree.h \
gtktextbufferserialize.h \
gtktextchildprivate.h \
@@ -626,9 +632,12 @@ gtk_base_c_sources = \
gtkcsskeyframes.c \
gtkcsslookup.c \
gtkcssmatcher.c \
gtkcssnode.c \
gtkcssnodedeclaration.c \
gtkcssnodeutils.c \
gtkcssnumbervalue.c \
gtkcssparser.c \
gtkcsspathnode.c \
gtkcsspositionvalue.c \
gtkcssprovider.c \
gtkcssrepeatvalue.c \
@@ -646,11 +655,13 @@ gtk_base_c_sources = \
gtkcssstyleproperty.c \
gtkcssstylepropertyimpl.c \
gtkcsstransformvalue.c \
gtkcsstransientnode.c \
gtkcsstransition.c \
gtkcsstypedvalue.c \
gtkcssunsetvalue.c \
gtkcssvalue.c \
gtkcsstypes.c \
gtkcssvalue.c \
gtkcsswidgetnode.c \
gtkdialog.c \
gtkdrawingarea.c \
gtkeditable.c \
@@ -1121,7 +1132,7 @@ gtktypebuiltins.c: $(gtk_public_h_sources) $(a11y_h_sources) $(deprecated_h_sour
&& cp xgen-gtbc gtktypebuiltins.c \
&& rm -f xgen-gtbc
gtk.gresource.xml: Makefile.am
gtk.gresource.xml: Makefile.am inspector/Makefile.inc
$(AM_V_GEN) echo "<?xml version='1.0' encoding='UTF-8'?>" > $@; \
echo "<gresources>" >> $@; \
echo " <gresource prefix='/org/gtk/libgtk'>" >> $@; \
+5 -11
View File
@@ -305,18 +305,16 @@ gtk_gradient_resolve (GtkGradient *gradient,
cairo_pattern_t *
_gtk_gradient_resolve_full (GtkGradient *gradient,
GtkStyleProviderPrivate *provider,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies)
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
cairo_pattern_t *pattern;
guint i;
g_return_val_if_fail (gradient != NULL, NULL);
g_return_val_if_fail (GTK_IS_STYLE_PROVIDER (provider), NULL);
g_return_val_if_fail (GTK_IS_CSS_STYLE (values), NULL);
g_return_val_if_fail (parent_values == NULL || GTK_IS_CSS_STYLE (parent_values), NULL);
g_return_val_if_fail (*dependencies == 0, NULL);
g_return_val_if_fail (GTK_IS_CSS_STYLE (style), NULL);
g_return_val_if_fail (parent_style == NULL || GTK_IS_CSS_STYLE (parent_style), NULL);
if (gradient->radius0 == 0 && gradient->radius1 == 0)
pattern = cairo_pattern_create_linear (gradient->x0, gradient->y0,
@@ -332,21 +330,17 @@ _gtk_gradient_resolve_full (GtkGradient *gradient,
ColorStop *stop;
GtkCssValue *val;
GdkRGBA rgba;
GtkCssDependencies stop_deps;
stop = &g_array_index (gradient->stops, ColorStop, i);
/* if color resolving fails, assume transparency */
val = _gtk_css_color_value_resolve (_gtk_symbolic_color_get_css_value (stop->color),
provider,
gtk_css_style_get_value (values, GTK_CSS_PROPERTY_COLOR),
GTK_CSS_DEPENDS_ON_COLOR,
&stop_deps,
gtk_css_style_get_value (style, GTK_CSS_PROPERTY_COLOR),
NULL);
if (val)
{
rgba = *_gtk_css_rgba_value_get_rgba (val);
*dependencies = _gtk_css_dependencies_union (*dependencies, stop_deps);
_gtk_css_value_unref (val);
}
else
+2 -3
View File
@@ -25,9 +25,8 @@ G_BEGIN_DECLS
cairo_pattern_t * _gtk_gradient_resolve_full (GtkGradient *gradient,
GtkStyleProviderPrivate *provider,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssDependencies *dependencies);
GtkCssStyle *style,
GtkCssStyle *parent_style);
GtkGradient * _gtk_gradient_transition (GtkGradient *start,
GtkGradient *end,
-2
View File
@@ -306,8 +306,6 @@ gtk_symbolic_color_resolve (GtkSymbolicColor *color,
v = _gtk_css_color_value_resolve (color->value,
GTK_STYLE_PROVIDER_PRIVATE (props),
current,
0,
NULL,
NULL);
_gtk_css_value_unref (current);
if (v == NULL)
+127 -77
View File
@@ -77,6 +77,8 @@
#include "gtkbox.h"
#include "gtkboxprivate.h"
#include "gtkcssnodeprivate.h"
#include "gtkcssnodeutilsprivate.h"
#include "gtkintl.h"
#include "gtkorientable.h"
#include "gtkorientableprivate.h"
@@ -435,14 +437,12 @@ static gboolean
gtk_box_draw (GtkWidget *widget,
cairo_t *cr)
{
GtkStyleContext *context;
GtkAllocation alloc;
context = gtk_widget_get_style_context (widget);
gtk_widget_get_allocation (widget, &alloc);
gtk_render_background (context, cr, 0, 0, alloc.width, alloc.height);
gtk_render_frame (context, cr, 0, 0, alloc.width, alloc.height);
gtk_css_node_draw (gtk_widget_get_css_node (widget),
cr,
gtk_widget_get_allocated_width (widget),
gtk_widget_get_allocated_height (widget),
NULL,
widget);
return GTK_WIDGET_CLASS (gtk_box_parent_class)->draw (widget, cr);
}
@@ -472,9 +472,13 @@ count_expand_children (GtkBox *box,
}
static void
gtk_box_size_allocate_no_center (GtkWidget *widget,
GtkAllocation *allocation)
gtk_box_size_allocate_no_center (GtkCssNode *cssnode,
const GtkAllocation *allocation,
int baseline,
GtkAllocation *out_clip,
gpointer data)
{
GtkWidget *widget = GTK_WIDGET (data);
GtkBox *box = GTK_BOX (widget);
GtkBoxPrivate *private = box->priv;
GtkBoxChild *child;
@@ -484,12 +488,12 @@ gtk_box_size_allocate_no_center (GtkWidget *widget,
GtkTextDirection direction;
GtkAllocation child_allocation;
GtkAllocation child_clip;
GtkRequestedSize *sizes;
gint child_minimum_baseline, child_natural_baseline;
gint minimum_above, natural_above;
gint minimum_below, natural_below;
gboolean have_baseline;
gint baseline;
GtkPackType packing;
@@ -499,8 +503,7 @@ gtk_box_size_allocate_no_center (GtkWidget *widget,
gint x = 0, y = 0, i;
gint child_size;
gtk_widget_set_allocation (widget, allocation);
*out_clip = *allocation;
count_expand_children (box, &nvis_children, &nexpand_children);
@@ -679,7 +682,6 @@ gtk_box_size_allocate_no_center (GtkWidget *widget,
}
}
baseline = gtk_widget_get_allocated_baseline (widget);
if (baseline == -1 && have_baseline)
{
gint height = MAX (1, allocation->height);
@@ -798,18 +800,21 @@ gtk_box_size_allocate_no_center (GtkWidget *widget,
}
}
gtk_widget_size_allocate_with_baseline (child->widget, &child_allocation, baseline);
gtk_widget_get_clip (child->widget, &child_clip);
gdk_rectangle_union (out_clip, out_clip, &child_clip);
i++;
}
}
_gtk_widget_set_simple_clip (widget, NULL);
}
static void
gtk_box_size_allocate_with_center (GtkWidget *widget,
GtkAllocation *allocation)
gtk_box_size_allocate_with_center (GtkCssNode *cssnode,
const GtkAllocation *allocation,
int baseline,
GtkAllocation *out_clip,
gpointer data)
{
GtkWidget *widget = GTK_WIDGET (data);
GtkBox *box = GTK_BOX (widget);
GtkBoxPrivate *priv = box->priv;
GtkBoxChild *child;
@@ -817,14 +822,13 @@ gtk_box_size_allocate_with_center (GtkWidget *widget,
gint nvis[2];
gint nexp[2];
GtkTextDirection direction;
GtkAllocation child_allocation;
GtkAllocation child_allocation, child_clip;
GtkRequestedSize *sizes[2];
GtkRequestedSize center_req;
gint child_minimum_baseline, child_natural_baseline;
gint minimum_above, natural_above;
gint minimum_below, natural_below;
gboolean have_baseline;
gint baseline;
gint idx[2];
gint center_pos;
gint center_size;
@@ -838,8 +842,6 @@ gtk_box_size_allocate_with_center (GtkWidget *widget,
gint x = 0, y = 0, i;
gint child_size;
gtk_widget_set_allocation (widget, allocation);
nvis[0] = nvis[1] = 0;
nexp[0] = nexp[1] = 0;
for (children = priv->children; children; children = children->next)
@@ -871,6 +873,8 @@ gtk_box_size_allocate_with_center (GtkWidget *widget,
min_size[0] = nat_size[0] = nvis[0] * priv->spacing;
min_size[1] = nat_size[1] = nvis[1] * priv->spacing;
*out_clip = *allocation;
/* Retrieve desired size for visible children. */
idx[0] = idx[1] = 0;
for (children = priv->children; children; children = children->next)
@@ -1025,7 +1029,6 @@ gtk_box_size_allocate_with_center (GtkWidget *widget,
}
}
baseline = gtk_widget_get_allocated_baseline (widget);
if (baseline == -1 && have_baseline)
{
gint height = MAX (1, allocation->height);
@@ -1139,6 +1142,8 @@ gtk_box_size_allocate_with_center (GtkWidget *widget,
}
}
gtk_widget_size_allocate_with_baseline (child->widget, &child_allocation, baseline);
gtk_widget_get_clip (child->widget, &child_clip);
gdk_rectangle_union (out_clip, out_clip, &child_clip);
i++;
}
@@ -1170,9 +1175,10 @@ gtk_box_size_allocate_with_center (GtkWidget *widget,
child_allocation.y = center_pos;
child_allocation.height = center_size;
}
gtk_widget_size_allocate_with_baseline (priv->center->widget, &child_allocation, baseline);
_gtk_widget_set_simple_clip (widget, NULL);
gtk_widget_size_allocate_with_baseline (priv->center->widget, &child_allocation, baseline);
gtk_widget_get_clip (priv->center->widget, &child_clip);
gdk_rectangle_union (out_clip, out_clip, &child_clip);
}
static void
@@ -1180,12 +1186,20 @@ gtk_box_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkBox *box = GTK_BOX (widget);
GtkAllocation clip;
if (box->priv->center &&
gtk_widget_get_visible (box->priv->center->widget))
gtk_box_size_allocate_with_center (widget, allocation);
else
gtk_box_size_allocate_no_center (widget, allocation);
gtk_widget_set_allocation (widget, allocation);
gtk_css_node_allocate (gtk_widget_get_css_node (widget),
allocation,
gtk_widget_get_allocated_baseline (widget),
&clip,
box->priv->center && gtk_widget_get_visible (box->priv->center->widget)
? gtk_box_size_allocate_with_center
: gtk_box_size_allocate_no_center,
box);
gtk_widget_set_clip (widget, &clip);
}
static GType
@@ -1434,17 +1448,25 @@ gtk_box_buildable_init (GtkBuildableIface *iface)
}
static void
gtk_box_invalidate_order_foreach (GtkWidget *widget)
gtk_box_invalidate_order_foreach (GtkWidget *widget,
gpointer prev)
{
_gtk_widget_invalidate_style_context (widget, GTK_CSS_CHANGE_POSITION | GTK_CSS_CHANGE_SIBLING_POSITION);
GtkCssNode **previous = prev;
GtkCssNode *cur = gtk_widget_get_css_node (widget);
if (*previous)
gtk_css_node_set_after (cur, *previous);
*previous = cur;
}
static void
gtk_box_invalidate_order (GtkBox *box)
{
GtkCssNode *previous = NULL;
gtk_container_foreach (GTK_CONTAINER (box),
(GtkCallback) gtk_box_invalidate_order_foreach,
NULL);
gtk_box_invalidate_order_foreach,
&previous);
}
static void
@@ -1490,8 +1512,8 @@ gtk_box_pack (GtkBox *box,
gtk_widget_freeze_child_notify (child);
gtk_box_invalidate_order (box);
gtk_widget_set_parent (child, GTK_WIDGET (box));
gtk_box_invalidate_order (box);
g_signal_connect (child, "notify::visible",
G_CALLBACK (box_child_visibility_notify_cb), box);
@@ -1657,22 +1679,6 @@ gtk_box_get_size (GtkWidget *widget,
*natural_baseline = nat_baseline;
}
static void
gtk_box_get_preferred_width (GtkWidget *widget,
gint *minimum_size,
gint *natural_size)
{
gtk_box_get_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size, NULL, NULL);
}
static void
gtk_box_get_preferred_height (GtkWidget *widget,
gint *minimum_size,
gint *natural_size)
{
gtk_box_get_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size, NULL, NULL);
}
static void
gtk_box_compute_size_for_opposing_orientation (GtkBox *box,
gint avail_size,
@@ -1956,19 +1962,74 @@ gtk_box_compute_size_for_orientation (GtkBox *box,
*natural_size = required_natural;
}
static void
gtk_box_get_preferred_size (GtkCssNode *cssnode,
GtkOrientation orientation,
gint for_size,
gint *minimum,
gint *natural,
gint *minimum_baseline,
gint *natural_baseline,
gpointer data)
{
GtkWidget *widget = data;
GtkBox *box = GTK_BOX (widget);
GtkBoxPrivate *priv = box->priv;
if (for_size < 0)
{
gtk_box_get_size (widget, orientation, minimum, natural, minimum_baseline, natural_baseline);
}
else
{
if (priv->orientation == orientation)
gtk_box_compute_size_for_orientation (box, for_size, minimum, natural);
else
gtk_box_compute_size_for_opposing_orientation (box, for_size, minimum, natural, minimum_baseline, natural_baseline);
}
}
static void
gtk_box_get_preferred_width (GtkWidget *widget,
gint *minimum_size,
gint *natural_size)
{
gtk_css_node_get_preferred_size (gtk_widget_get_css_node (widget),
GTK_ORIENTATION_HORIZONTAL,
-1,
minimum_size, natural_size,
NULL, NULL,
gtk_box_get_preferred_size,
widget);
}
static void
gtk_box_get_preferred_height (GtkWidget *widget,
gint *minimum_size,
gint *natural_size)
{
gtk_css_node_get_preferred_size (gtk_widget_get_css_node (widget),
GTK_ORIENTATION_VERTICAL,
-1,
minimum_size, natural_size,
NULL, NULL,
gtk_box_get_preferred_size,
widget);
}
static void
gtk_box_get_preferred_width_for_height (GtkWidget *widget,
gint height,
gint *minimum_width,
gint *natural_width)
{
GtkBox *box = GTK_BOX (widget);
GtkBoxPrivate *private = box->priv;
if (private->orientation == GTK_ORIENTATION_VERTICAL)
gtk_box_compute_size_for_opposing_orientation (box, height, minimum_width, natural_width, NULL, NULL);
else
gtk_box_compute_size_for_orientation (box, height, minimum_width, natural_width);
gtk_css_node_get_preferred_size (gtk_widget_get_css_node (widget),
GTK_ORIENTATION_HORIZONTAL,
height,
minimum_width, natural_width,
NULL, NULL,
gtk_box_get_preferred_size,
widget);
}
static void
@@ -1979,24 +2040,13 @@ gtk_box_get_preferred_height_and_baseline_for_width (GtkWidget *widget,
gint *minimum_baseline,
gint *natural_baseline)
{
GtkBox *box = GTK_BOX (widget);
GtkBoxPrivate *private = box->priv;
if (width < 0)
gtk_box_get_size (widget, GTK_ORIENTATION_VERTICAL, minimum_height, natural_height, minimum_baseline, natural_baseline);
else
{
if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
gtk_box_compute_size_for_opposing_orientation (box, width, minimum_height, natural_height, minimum_baseline, natural_baseline);
else
{
if (minimum_baseline)
*minimum_baseline = -1;
if (natural_baseline)
*natural_baseline = -1;
gtk_box_compute_size_for_orientation (box, width, minimum_height, natural_height);
}
}
gtk_css_node_get_preferred_size (gtk_widget_get_css_node (widget),
GTK_ORIENTATION_VERTICAL,
width,
minimum_height, natural_height,
minimum_baseline, natural_baseline,
gtk_box_get_preferred_size,
widget);
}
static void
+1 -12
View File
@@ -1846,19 +1846,8 @@ gtk_container_idle_sizer (GdkFrameClock *clock,
*/
if (container->priv->restyle_pending)
{
GtkBitmask *empty;
gint64 current_time;
empty = _gtk_bitmask_new ();
current_time = g_get_monotonic_time ();
container->priv->restyle_pending = FALSE;
_gtk_style_context_validate (gtk_widget_get_style_context (GTK_WIDGET (container)),
current_time,
0,
empty);
_gtk_bitmask_free (empty);
gtk_css_node_validate (gtk_widget_get_css_node (GTK_WIDGET (container)));
}
/* we may be invoked with a container_resize_queue of NULL, because
+22 -16
View File
@@ -63,6 +63,21 @@ gtk_css_animated_style_get_section (GtkCssStyle *style,
return gtk_css_style_get_section (animated->style, id);
}
static gboolean
gtk_css_animated_style_is_static (GtkCssStyle *style)
{
GtkCssAnimatedStyle *animated = GTK_CSS_ANIMATED_STYLE (style);
GSList *list;
for (list = animated->animations; list; list = list->next)
{
if (!_gtk_style_animation_is_static (list->data, animated->current_time))
return FALSE;
}
return TRUE;
}
static void
gtk_css_animated_style_dispose (GObject *object)
{
@@ -101,6 +116,7 @@ gtk_css_animated_style_class_init (GtkCssAnimatedStyleClass *klass)
style_class->get_value = gtk_css_animated_style_get_value;
style_class->get_section = gtk_css_animated_style_get_section;
style_class->is_static = gtk_css_animated_style_is_static;
}
static void
@@ -410,6 +426,9 @@ gtk_css_animated_style_new (GtkCssStyle *base_style,
gtk_internal_return_val_if_fail (GTK_IS_STYLE_PROVIDER (provider), NULL);
gtk_internal_return_val_if_fail (previous_style == NULL || GTK_IS_CSS_STYLE (previous_style), NULL);
if (timestamp == 0)
return g_object_ref (base_style);
animations = NULL;
if (previous_style != NULL)
@@ -441,6 +460,9 @@ gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
gtk_internal_return_val_if_fail (GTK_IS_CSS_ANIMATED_STYLE (source), NULL);
gtk_internal_return_val_if_fail (GTK_IS_CSS_STYLE (base), NULL);
if (timestamp == 0)
return g_object_ref (source->style);
animations = NULL;
for (l = source->animations; l; l = l->next)
{
@@ -466,19 +488,3 @@ gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
return GTK_CSS_STYLE (result);
}
gboolean
gtk_css_animated_style_is_static (GtkCssAnimatedStyle *style)
{
GSList *list;
gtk_internal_return_val_if_fail (GTK_IS_CSS_ANIMATED_STYLE (style), TRUE);
for (list = style->animations; list; list = list->next)
{
if (!_gtk_style_animation_is_static (list->data, style->current_time))
return FALSE;
}
return TRUE;
}
-2
View File
@@ -68,8 +68,6 @@ void gtk_css_animated_style_set_animated_value(GtkCssAnimated
GtkCssValue * gtk_css_animated_style_get_intrinsic_value (GtkCssAnimatedStyle *style,
guint id);
gboolean gtk_css_animated_style_is_static (GtkCssAnimatedStyle *style);
G_END_DECLS
#endif /* __GTK_CSS_ANIMATED_STYLE_PRIVATE_H__ */
+2 -6
View File
@@ -47,20 +47,16 @@ gtk_css_value_array_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
GtkCssValue *result;
GtkCssValue *i_value;
guint i, j;
GtkCssDependencies child_deps;
result = NULL;
for (i = 0; i < value->n_values; i++)
{
i_value = _gtk_css_value_compute (value->values[i], property_id, provider, style, parent_style, &child_deps);
*dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
i_value = _gtk_css_value_compute (value->values[i], property_id, provider, style, parent_style);
if (result == NULL &&
i_value != value->values[i])
+3 -8
View File
@@ -45,25 +45,20 @@ gtk_css_value_bg_size_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
GtkCssValue *x, *y;
GtkCssDependencies x_deps, y_deps;
if (value->x == NULL && value->y == NULL)
return _gtk_css_value_ref (value);
x_deps = y_deps = 0;
x = y = NULL;
if (value->x)
x = _gtk_css_value_compute (value->x, property_id, provider, style, parent_style, &x_deps);
x = _gtk_css_value_compute (value->x, property_id, provider, style, parent_style);
if (value->y)
y = _gtk_css_value_compute (value->y, property_id, provider, style, parent_style, &y_deps);
*dependencies = _gtk_css_dependencies_union (x_deps, y_deps);
y = _gtk_css_value_compute (value->y, property_id, provider, style, parent_style);
return _gtk_css_bg_size_value_new (value->x ? x : NULL,
value->y ? y : NULL);
+2 -5
View File
@@ -46,11 +46,9 @@ gtk_css_value_border_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
GtkCssValue *computed;
GtkCssDependencies child_deps;
gboolean changed = FALSE;
guint i;
@@ -61,8 +59,7 @@ gtk_css_value_border_compute (GtkCssValue *value,
{
if (value->values[i])
{
computed->values[i] = _gtk_css_value_compute (value->values[i], property_id, provider, style, parent_style, &child_deps);
*dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
computed->values[i] = _gtk_css_value_compute (value->values[i], property_id, provider, style, parent_style);
changed |= (computed->values[i] != value->values[i]);
}
}
+9 -36
View File
@@ -124,8 +124,7 @@ gtk_css_value_color_get_fallback (guint property_id,
property_id,
provider,
style,
parent_style,
NULL);
parent_style);
default:
if (property_id < GTK_CSS_PROPERTY_N_PROPERTIES)
g_warning ("No fallback color defined for property '%s'",
@@ -138,20 +137,13 @@ GtkCssValue *
_gtk_css_color_value_resolve (GtkCssValue *color,
GtkStyleProviderPrivate *provider,
GtkCssValue *current,
GtkCssDependencies current_deps,
GtkCssDependencies *dependencies,
GSList *cycle_list)
{
GtkCssDependencies unused;
GtkCssValue *value;
g_return_val_if_fail (color != NULL, NULL);
g_return_val_if_fail (provider == NULL || GTK_IS_STYLE_PROVIDER_PRIVATE (provider), NULL);
if (dependencies == NULL)
dependencies = &unused;
*dependencies = 0;
switch (color->type)
{
case COLOR_TYPE_LITERAL:
@@ -170,7 +162,7 @@ _gtk_css_color_value_resolve (GtkCssValue *color,
if (named == NULL)
return NULL;
value = _gtk_css_color_value_resolve (named, provider, current, current_deps, dependencies, &cycle);
value = _gtk_css_color_value_resolve (named, provider, current, &cycle);
if (value == NULL)
return NULL;
}
@@ -182,12 +174,10 @@ _gtk_css_color_value_resolve (GtkCssValue *color,
GtkHSLA hsla;
GdkRGBA shade;
val = _gtk_css_color_value_resolve (color->sym_col.shade.color, provider, current, current_deps, dependencies, cycle_list);
val = _gtk_css_color_value_resolve (color->sym_col.shade.color, provider, current, cycle_list);
if (val == NULL)
return NULL;
*dependencies = _gtk_css_dependencies_union (*dependencies, 0);
_gtk_hsla_init_from_rgba (&hsla, _gtk_css_rgba_value_get_rgba (val));
_gtk_hsla_shade (&hsla, &hsla, color->sym_col.shade.factor);
@@ -204,11 +194,10 @@ _gtk_css_color_value_resolve (GtkCssValue *color,
GtkCssValue *val;
GdkRGBA alpha;
val = _gtk_css_color_value_resolve (color->sym_col.alpha.color, provider, current, current_deps, dependencies, cycle_list);
val = _gtk_css_color_value_resolve (color->sym_col.alpha.color, provider, current, cycle_list);
if (val == NULL)
return NULL;
*dependencies = _gtk_css_dependencies_union (*dependencies, 0);
alpha = *_gtk_css_rgba_value_get_rgba (val);
alpha.alpha = CLAMP (alpha.alpha * color->sym_col.alpha.factor, 0, 1);
@@ -222,21 +211,19 @@ _gtk_css_color_value_resolve (GtkCssValue *color,
{
GtkCssValue *val;
GdkRGBA color1, color2, res;
GtkCssDependencies dep1, dep2;
val = _gtk_css_color_value_resolve (color->sym_col.mix.color1, provider, current, current_deps, &dep1, cycle_list);
val = _gtk_css_color_value_resolve (color->sym_col.mix.color1, provider, current, cycle_list);
if (val == NULL)
return NULL;
color1 = *_gtk_css_rgba_value_get_rgba (val);
_gtk_css_value_unref (val);
val = _gtk_css_color_value_resolve (color->sym_col.mix.color2, provider, current, current_deps, &dep2, cycle_list);
val = _gtk_css_color_value_resolve (color->sym_col.mix.color2, provider, current, cycle_list);
if (val == NULL)
return NULL;
color2 = *_gtk_css_rgba_value_get_rgba (val);
_gtk_css_value_unref (val);
*dependencies = _gtk_css_dependencies_union (dep1, dep2);
res.red = CLAMP (color1.red + ((color2.red - color1.red) * color->sym_col.mix.factor), 0, 1);
res.green = CLAMP (color1.green + ((color2.green - color1.green) * color->sym_col.mix.factor), 0, 1);
res.blue = CLAMP (color1.blue + ((color2.blue - color1.blue) * color->sym_col.mix.factor), 0, 1);
@@ -262,7 +249,6 @@ _gtk_css_color_value_resolve (GtkCssValue *color,
case COLOR_TYPE_CURRENT_COLOR:
if (current)
{
*dependencies = current_deps;
return _gtk_css_value_ref (current);
}
else
@@ -270,8 +256,6 @@ _gtk_css_color_value_resolve (GtkCssValue *color,
return _gtk_css_color_value_resolve (_gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (GTK_CSS_PROPERTY_COLOR)),
provider,
NULL,
0,
dependencies,
cycle_list);
}
break;
@@ -301,11 +285,9 @@ gtk_css_value_color_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
GtkCssValue *resolved, *current;
GtkCssDependencies current_deps;
/* The computed value of the currentColor keyword is the computed
* value of the color property. If the currentColor keyword is
@@ -314,27 +296,18 @@ gtk_css_value_color_compute (GtkCssValue *value,
if (property_id == GTK_CSS_PROPERTY_COLOR)
{
if (parent_style)
{
current = gtk_css_style_get_value (parent_style, GTK_CSS_PROPERTY_COLOR);
current_deps = GTK_CSS_EQUALS_PARENT;
}
current = gtk_css_style_get_value (parent_style, GTK_CSS_PROPERTY_COLOR);
else
{
current = NULL;
current_deps = 0;
}
current = NULL;
}
else
{
current = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_COLOR);
current_deps = GTK_CSS_DEPENDS_ON_COLOR;
}
resolved = _gtk_css_color_value_resolve (value,
provider,
current,
current_deps,
dependencies,
NULL);
if (resolved == NULL)
-2
View File
@@ -46,8 +46,6 @@ GtkCssValue * _gtk_css_color_value_parse (GtkCssParser *parser)
GtkCssValue * _gtk_css_color_value_resolve (GtkCssValue *color,
GtkStyleProviderPrivate *provider,
GtkCssValue *current,
GtkCssDependencies current_deps,
GtkCssDependencies *dependencies,
GSList *cycle_list);
+3 -6
View File
@@ -41,15 +41,12 @@ gtk_css_value_corner_compute (GtkCssValue *corner,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
GtkCssValue *x, *y;
GtkCssDependencies x_deps, y_deps;
x = _gtk_css_value_compute (corner->x, property_id, provider, style, parent_style, &x_deps);
y = _gtk_css_value_compute (corner->y, property_id, provider, style, parent_style, &y_deps);
*dependencies = _gtk_css_dependencies_union (x_deps, y_deps);
x = _gtk_css_value_compute (corner->x, property_id, provider, style, parent_style);
y = _gtk_css_value_compute (corner->y, property_id, provider, style, parent_style);
if (x == corner->x && y == corner->y)
{
_gtk_css_value_unref (x);
+1 -2
View File
@@ -54,8 +54,7 @@ gtk_css_value_ease_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
return _gtk_css_value_ref (value);
}
+1 -2
View File
@@ -40,8 +40,7 @@ gtk_css_value_engine_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
return _gtk_css_value_ref (value);
}
+3 -10
View File
@@ -42,8 +42,7 @@ gtk_css_value_enum_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
return _gtk_css_value_ref (value);
}
@@ -165,8 +164,7 @@ gtk_css_value_font_size_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
double font_size;
@@ -197,7 +195,6 @@ gtk_css_value_font_size_compute (GtkCssValue *value,
font_size = _gtk_css_font_size_get_default (provider) * 2;
break;
case GTK_CSS_FONT_SIZE_SMALLER:
*dependencies = GTK_CSS_DEPENDS_ON_PARENT;
if (parent_style)
font_size = _gtk_css_number_value_get (gtk_css_style_get_value (parent_style, GTK_CSS_PROPERTY_FONT_SIZE), 100);
else
@@ -206,7 +203,6 @@ gtk_css_value_font_size_compute (GtkCssValue *value,
font_size /= 1.2;
break;
case GTK_CSS_FONT_SIZE_LARGER:
*dependencies = GTK_CSS_DEPENDS_ON_PARENT;
if (parent_style)
font_size = _gtk_css_number_value_get (gtk_css_style_get_value (parent_style, GTK_CSS_PROPERTY_FONT_SIZE), 100);
else
@@ -376,8 +372,7 @@ gtk_css_value_font_weight_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
PangoWeight new_weight;
int parent_value;
@@ -385,8 +380,6 @@ gtk_css_value_font_weight_compute (GtkCssValue *value,
if (value->value >= 0)
return _gtk_css_value_ref (value);
*dependencies = GTK_CSS_DEPENDS_ON_PARENT;
if (parent_style)
parent_value = gtk_css_style_get_value (parent_style, property_id)->value;
else
+1 -2
View File
@@ -74,8 +74,7 @@ gtk_css_value_icon_theme_compute (GtkCssValue *icon_theme,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
GtkCssValue *result;
GtkIconTheme *icontheme;
+3 -10
View File
@@ -65,8 +65,7 @@ gtk_css_image_real_compute (GtkCssImage *image,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
return g_object_ref (image);
}
@@ -149,23 +148,17 @@ _gtk_css_image_compute (GtkCssImage *image,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
GtkCssDependencies unused;
GtkCssImageClass *klass;
g_return_val_if_fail (GTK_IS_CSS_IMAGE (image), NULL);
g_return_val_if_fail (GTK_IS_CSS_STYLE (style), NULL);
g_return_val_if_fail (parent_style == NULL || GTK_IS_CSS_STYLE (parent_style), NULL);
if (dependencies == NULL)
dependencies = &unused;
*dependencies = 0;
klass = GTK_CSS_IMAGE_GET_CLASS (image);
return klass->compute (image, property_id, provider, style, parent_style, dependencies);
return klass->compute (image, property_id, provider, style, parent_style);
}
GtkCssImage *
+1 -5
View File
@@ -806,8 +806,7 @@ gtk_css_image_builtin_compute (GtkCssImage *image,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
GtkCssImageBuiltin *result;
GtkBorderStyle border_style;
@@ -832,9 +831,6 @@ gtk_css_image_builtin_compute (GtkCssImage *image,
result->bg_color = *_gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BACKGROUND_COLOR));
result->border_color = *_gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_TOP_COLOR));
/* XXX: We also depend on other values, but I guess we cannot express that */
*dependencies = GTK_CSS_DEPENDS_ON_COLOR;
return GTK_CSS_IMAGE (result);
}
+2 -3
View File
@@ -35,8 +35,7 @@ gtk_css_image_gradient_compute (GtkCssImage *image,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
GtkCssImageGradient *gradient = GTK_CSS_IMAGE_GRADIENT (image);
GtkCssImageGradient *copy;
@@ -46,7 +45,7 @@ gtk_css_image_gradient_compute (GtkCssImage *image,
copy = g_object_new (GTK_TYPE_CSS_IMAGE_GRADIENT, NULL);
copy->gradient = gtk_gradient_ref (gradient->gradient);
copy->pattern = _gtk_gradient_resolve_full (copy->gradient, provider, style, parent_style, dependencies);
copy->pattern = _gtk_gradient_resolve_full (copy->gradient, provider, style, parent_style);
return GTK_CSS_IMAGE (copy);
}
+1 -4
View File
@@ -129,8 +129,7 @@ gtk_css_image_icon_theme_compute (GtkCssImage *image,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
GtkCssImageIconTheme *icon_theme = GTK_CSS_IMAGE_ICON_THEME (image);
GtkCssImageIconTheme *copy;
@@ -149,8 +148,6 @@ gtk_css_image_icon_theme_compute (GtkCssImage *image,
copy->scale = _gtk_style_provider_private_get_scale (provider);
copy->color = *_gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_COLOR));
*dependencies = GTK_CSS_DEPENDS_ON_COLOR;
return GTK_CSS_IMAGE (copy);
}
+4 -8
View File
@@ -432,8 +432,7 @@ gtk_css_image_linear_compute (GtkCssImage *image,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
GtkCssImageLinear *linear = GTK_CSS_IMAGE_LINEAR (image);
GtkCssImageLinear *copy;
@@ -442,24 +441,21 @@ gtk_css_image_linear_compute (GtkCssImage *image,
copy = g_object_new (GTK_TYPE_CSS_IMAGE_LINEAR, NULL);
copy->repeating = linear->repeating;
copy->angle = _gtk_css_value_compute (linear->angle, property_id, provider, style, parent_style, dependencies);
copy->angle = _gtk_css_value_compute (linear->angle, property_id, provider, style, parent_style);
g_array_set_size (copy->stops, linear->stops->len);
for (i = 0; i < linear->stops->len; i++)
{
GtkCssImageLinearColorStop *stop, *scopy;
GtkCssDependencies child_deps;
stop = &g_array_index (linear->stops, GtkCssImageLinearColorStop, i);
scopy = &g_array_index (copy->stops, GtkCssImageLinearColorStop, i);
scopy->color = _gtk_css_value_compute (stop->color, property_id, provider, style, parent_style, &child_deps);
*dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
scopy->color = _gtk_css_value_compute (stop->color, property_id, provider, style, parent_style);
if (stop->offset)
{
scopy->offset = _gtk_css_value_compute (stop->offset, property_id, provider, style, parent_style, &child_deps);
*dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
scopy->offset = _gtk_css_value_compute (stop->offset, property_id, provider, style, parent_style);
}
else
{
+2 -4
View File
@@ -59,8 +59,7 @@ struct _GtkCssImageClass
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies);
GtkCssStyle *parent_style);
/* compare two images for equality */
gboolean (* equal) (GtkCssImage *image1,
GtkCssImage *image2);
@@ -96,8 +95,7 @@ GtkCssImage * _gtk_css_image_compute (GtkCssImage *
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies);
GtkCssStyle *parent_style);
gboolean _gtk_css_image_equal (GtkCssImage *image1,
GtkCssImage *image2);
GtkCssImage * _gtk_css_image_transition (GtkCssImage *start,
+2 -4
View File
@@ -97,8 +97,7 @@ gtk_css_image_scaled_compute (GtkCssImage *image,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
GtkCssImageScaled *scaled = GTK_CSS_IMAGE_SCALED (image);
GtkCssImageScaled *copy;
@@ -122,8 +121,7 @@ gtk_css_image_scaled_compute (GtkCssImage *image,
property_id,
provider,
style,
parent_style,
dependencies);
parent_style);
else
copy->images[i] = g_object_ref (scaled->images[i]);
}
+1 -2
View File
@@ -124,8 +124,7 @@ gtk_css_image_url_compute (GtkCssImage *image,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
GtkCssImageUrl *url = GTK_CSS_IMAGE_URL (image);
+2 -3
View File
@@ -38,8 +38,7 @@ gtk_css_value_image_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
GtkCssImage *image, *computed;
@@ -48,7 +47,7 @@ gtk_css_value_image_compute (GtkCssValue *value,
if (image == NULL)
return _gtk_css_value_ref (value);
computed = _gtk_css_image_compute (image, property_id, provider, style, parent_style, dependencies);
computed = _gtk_css_image_compute (image, property_id, provider, style, parent_style);
if (computed == image)
{
+2 -5
View File
@@ -38,12 +38,10 @@ gtk_css_value_inherit_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
if (parent_style)
{
*dependencies = GTK_CSS_EQUALS_PARENT;
return _gtk_css_value_ref (gtk_css_style_get_value (parent_style, property_id));
}
else
@@ -52,8 +50,7 @@ gtk_css_value_inherit_compute (GtkCssValue *value,
property_id,
provider,
style,
parent_style,
dependencies);
parent_style);
}
}
+2 -4
View File
@@ -42,8 +42,7 @@ gtk_css_value_initial_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
GtkSettings *settings;
@@ -94,8 +93,7 @@ gtk_css_value_initial_compute (GtkCssValue *value,
property_id,
provider,
style,
parent_style,
dependencies);
parent_style);
}
static gboolean
+1 -2
View File
@@ -466,8 +466,7 @@ _gtk_css_keyframes_compute (GtkCssKeyframes *keyframes,
resolved->property_ids[p],
provider,
style,
parent_style,
NULL);
parent_style);
}
}
+233 -3
View File
@@ -19,6 +19,8 @@
#include "gtkcssmatcherprivate.h"
#include "gtkcssnodedeclarationprivate.h"
#include "gtkcssnodeprivate.h"
#include "gtkwidgetpath.h"
/* GTK_CSS_MATCHER_WIDGET_PATH */
@@ -31,6 +33,7 @@ gtk_css_matcher_widget_path_get_parent (GtkCssMatcher *matcher,
return FALSE;
matcher->path.klass = child->path.klass;
matcher->path.decl = NULL;
matcher->path.path = child->path.path;
matcher->path.index = child->path.index - 1;
matcher->path.sibling_index = gtk_widget_path_iter_get_sibling_index (matcher->path.path, matcher->path.index);
@@ -46,6 +49,7 @@ gtk_css_matcher_widget_path_get_previous (GtkCssMatcher *matcher,
return FALSE;
matcher->path.klass = next->path.klass;
matcher->path.decl = NULL;
matcher->path.path = next->path.path;
matcher->path.index = next->path.index;
matcher->path.sibling_index = next->path.sibling_index - 1;
@@ -58,6 +62,9 @@ gtk_css_matcher_widget_path_get_state (const GtkCssMatcher *matcher)
{
const GtkWidgetPath *siblings;
if (matcher->path.decl)
return gtk_css_node_declaration_get_state (matcher->path.decl);
siblings = gtk_widget_path_iter_get_siblings (matcher->path.path, matcher->path.index);
if (siblings && matcher->path.sibling_index != gtk_widget_path_iter_get_sibling_index (matcher->path.path, matcher->path.index))
return gtk_widget_path_iter_get_state (siblings, matcher->path.sibling_index);
@@ -84,6 +91,10 @@ gtk_css_matcher_widget_path_has_class (const GtkCssMatcher *matcher,
{
const GtkWidgetPath *siblings;
if (matcher->path.decl &&
gtk_css_node_declaration_has_class (matcher->path.decl, class_name))
return TRUE;
siblings = gtk_widget_path_iter_get_siblings (matcher->path.path, matcher->path.index);
if (siblings && matcher->path.sibling_index != gtk_widget_path_iter_get_sibling_index (matcher->path.path, matcher->path.index))
return gtk_widget_path_iter_has_qclass (siblings, matcher->path.sibling_index, class_name);
@@ -111,6 +122,16 @@ gtk_css_matcher_widget_path_has_regions (const GtkCssMatcher *matcher)
GSList *regions;
gboolean result;
if (matcher->path.decl)
{
GList *list = gtk_css_node_declaration_list_regions (matcher->path.decl);
if (list)
{
g_list_free (list);
return TRUE;
}
}
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
siblings = gtk_widget_path_iter_get_siblings (matcher->path.path, matcher->path.index);
if (siblings && matcher->path.sibling_index != gtk_widget_path_iter_get_sibling_index (matcher->path.path, matcher->path.index))
@@ -132,6 +153,14 @@ gtk_css_matcher_widget_path_has_region (const GtkCssMatcher *matcher,
const GtkWidgetPath *siblings;
GtkRegionFlags region_flags;
if (matcher->path.decl)
{
GQuark q = g_quark_try_string (region);
if (q && gtk_css_node_declaration_has_region (matcher->path.decl, q, &region_flags))
goto found;
}
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
siblings = gtk_widget_path_iter_get_siblings (matcher->path.path, matcher->path.index);
if (siblings && matcher->path.sibling_index != gtk_widget_path_iter_get_sibling_index (matcher->path.path, matcher->path.index))
@@ -144,12 +173,13 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
if (!gtk_widget_path_iter_has_region (matcher->path.path, matcher->path.index, region, &region_flags))
return FALSE;
}
G_GNUC_END_IGNORE_DEPRECATIONS
found:
if ((flags & region_flags) != flags)
return FALSE;
return TRUE;
G_GNUC_END_IGNORE_DEPRECATIONS
}
static gboolean
@@ -195,13 +225,15 @@ static const GtkCssMatcherClass GTK_CSS_MATCHER_WIDGET_PATH = {
};
gboolean
_gtk_css_matcher_init (GtkCssMatcher *matcher,
const GtkWidgetPath *path)
_gtk_css_matcher_init (GtkCssMatcher *matcher,
const GtkWidgetPath *path,
const GtkCssNodeDeclaration *decl)
{
if (gtk_widget_path_length (path) == 0)
return FALSE;
matcher->path.klass = &GTK_CSS_MATCHER_WIDGET_PATH;
matcher->path.decl = decl;
matcher->path.path = path;
matcher->path.index = gtk_widget_path_length (path) - 1;
matcher->path.sibling_index = gtk_widget_path_iter_get_sibling_index (path, matcher->path.index);
@@ -209,6 +241,204 @@ _gtk_css_matcher_init (GtkCssMatcher *matcher,
return TRUE;
}
/* GTK_CSS_MATCHER_NODE */
static gboolean
gtk_css_matcher_node_get_parent (GtkCssMatcher *matcher,
const GtkCssMatcher *child)
{
GtkCssNode *node;
node = gtk_css_node_get_parent (child->node.node);
if (node == NULL)
return FALSE;
return gtk_css_node_init_matcher (node, matcher);
}
static GtkCssNode *
get_previous_visible_sibling (GtkCssNode *node)
{
do {
node = gtk_css_node_get_previous_sibling (node);
} while (node && !gtk_css_node_get_visible (node));
return node;
}
static GtkCssNode *
get_next_visible_sibling (GtkCssNode *node)
{
do {
node = gtk_css_node_get_next_sibling (node);
} while (node && !gtk_css_node_get_visible (node));
return node;
}
static gboolean
gtk_css_matcher_node_get_previous (GtkCssMatcher *matcher,
const GtkCssMatcher *next)
{
GtkCssNode *node;
node = get_previous_visible_sibling (next->node.node);
if (node == NULL)
return FALSE;
return gtk_css_node_init_matcher (node, matcher);
}
static GtkStateFlags
gtk_css_matcher_node_get_state (const GtkCssMatcher *matcher)
{
return gtk_css_node_get_state (matcher->node.node);
}
static gboolean
gtk_css_matcher_node_has_type (const GtkCssMatcher *matcher,
GType type)
{
return g_type_is_a (gtk_css_node_get_widget_type (matcher->node.node), type);
}
static gboolean
gtk_css_matcher_node_has_class (const GtkCssMatcher *matcher,
GQuark class_name)
{
return gtk_css_node_has_qclass (matcher->node.node, class_name);
}
static gboolean
gtk_css_matcher_node_has_id (const GtkCssMatcher *matcher,
const char *id)
{
return gtk_css_node_get_id (matcher->node.node) == g_intern_string (id);
}
static gboolean
gtk_css_matcher_node_has_regions (const GtkCssMatcher *matcher)
{
GList *regions;
gboolean result;
regions = gtk_css_node_list_regions (matcher->node.node);
result = regions != NULL;
g_list_free (regions);
return result;
}
static gboolean
gtk_css_matcher_node_has_region (const GtkCssMatcher *matcher,
const char *region,
GtkRegionFlags flags)
{
GtkRegionFlags region_flags;
GQuark region_quark;
region_quark = g_quark_try_string (region);
if (!region_quark)
return FALSE;
if (!gtk_css_node_has_region (matcher->node.node, region_quark, &region_flags))
return FALSE;
if ((flags & region_flags) != flags)
return FALSE;
return TRUE;
}
static gboolean
gtk_css_matcher_node_nth_child (GtkCssNode *node,
int a,
int b)
{
while (b-- > 0)
{
if (node == NULL)
return FALSE;
node = get_previous_visible_sibling (node);
}
if (a == 0)
return node == NULL;
else if (a == 1)
return TRUE;
b = 0;
while (node)
{
b++;
node = get_previous_visible_sibling (node);
}
return b % a == 0;
}
static gboolean
gtk_css_matcher_node_nth_last_child (GtkCssNode *node,
int a,
int b)
{
while (b-- > 0)
{
if (node == NULL)
return FALSE;
node = get_next_visible_sibling (node);
}
if (a == 0)
return node == NULL;
else if (a == 1)
return TRUE;
b = 0;
while (node)
{
b++;
node = get_next_visible_sibling (node);
}
return b % a == 0;
}
static gboolean
gtk_css_matcher_node_has_position (const GtkCssMatcher *matcher,
gboolean forward,
int a,
int b)
{
if (forward)
return gtk_css_matcher_node_nth_child (matcher->node.node, a, b);
else
return gtk_css_matcher_node_nth_last_child (matcher->node.node, a, b);
}
static const GtkCssMatcherClass GTK_CSS_MATCHER_NODE = {
gtk_css_matcher_node_get_parent,
gtk_css_matcher_node_get_previous,
gtk_css_matcher_node_get_state,
gtk_css_matcher_node_has_type,
gtk_css_matcher_node_has_class,
gtk_css_matcher_node_has_id,
gtk_css_matcher_node_has_regions,
gtk_css_matcher_node_has_region,
gtk_css_matcher_node_has_position,
FALSE
};
void
_gtk_css_matcher_node_init (GtkCssMatcher *matcher,
GtkCssNode *node)
{
matcher->node.klass = &GTK_CSS_MATCHER_NODE;
matcher->node.node = node;
}
/* GTK_CSS_MATCHER_WIDGET_ANY */
static gboolean
+12 -2
View File
@@ -24,7 +24,7 @@
G_BEGIN_DECLS
typedef union _GtkCssMatcher GtkCssMatcher;
typedef struct _GtkCssMatcherNode GtkCssMatcherNode;
typedef struct _GtkCssMatcherSuperset GtkCssMatcherSuperset;
typedef struct _GtkCssMatcherWidgetPath GtkCssMatcherWidgetPath;
typedef struct _GtkCssMatcherClass GtkCssMatcherClass;
@@ -55,11 +55,17 @@ struct _GtkCssMatcherClass {
struct _GtkCssMatcherWidgetPath {
const GtkCssMatcherClass *klass;
const GtkCssNodeDeclaration *decl;
const GtkWidgetPath *path;
guint index;
guint sibling_index;
};
struct _GtkCssMatcherNode {
const GtkCssMatcherClass *klass;
GtkCssNode *node;
};
struct _GtkCssMatcherSuperset {
const GtkCssMatcherClass *klass;
const GtkCssMatcher *subset;
@@ -69,11 +75,15 @@ struct _GtkCssMatcherSuperset {
union _GtkCssMatcher {
const GtkCssMatcherClass *klass;
GtkCssMatcherWidgetPath path;
GtkCssMatcherNode node;
GtkCssMatcherSuperset superset;
};
gboolean _gtk_css_matcher_init (GtkCssMatcher *matcher,
const GtkWidgetPath *path) G_GNUC_WARN_UNUSED_RESULT;
const GtkWidgetPath *path,
const GtkCssNodeDeclaration *decl) G_GNUC_WARN_UNUSED_RESULT;
void _gtk_css_matcher_node_init (GtkCssMatcher *matcher,
GtkCssNode *node);
void _gtk_css_matcher_any_init (GtkCssMatcher *matcher);
void _gtk_css_matcher_superset_init (GtkCssMatcher *matcher,
const GtkCssMatcher *subset,
+1300
View File
File diff suppressed because it is too large Load Diff
+1 -3
View File
@@ -18,14 +18,12 @@
#ifndef __GTK_CSS_NODE_DECLARATION_PRIVATE_H__
#define __GTK_CSS_NODE_DECLARATION_PRIVATE_H__
#include "gtkcsstypesprivate.h"
#include "gtkenums.h"
#include "gtkwidgetpath.h"
G_BEGIN_DECLS
typedef struct _GtkCssNodeDeclaration GtkCssNodeDeclaration;
GtkCssNodeDeclaration * gtk_css_node_declaration_new (void);
GtkCssNodeDeclaration * gtk_css_node_declaration_ref (GtkCssNodeDeclaration *decl);
void gtk_css_node_declaration_unref (GtkCssNodeDeclaration *decl);
+176
View File
@@ -0,0 +1,176 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2014 Benjamin Otte <otte@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_CSS_NODE_PRIVATE_H__
#define __GTK_CSS_NODE_PRIVATE_H__
#include "gtkcssnodedeclarationprivate.h"
#include "gtkbitmaskprivate.h"
#include "gtkcsstypesprivate.h"
G_BEGIN_DECLS
#define GTK_TYPE_CSS_NODE (gtk_css_node_get_type ())
#define GTK_CSS_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GTK_TYPE_CSS_NODE, GtkCssNode))
#define GTK_CSS_NODE_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST (cls, GTK_TYPE_CSS_NODE, GtkCssNodeClass))
#define GTK_IS_CSS_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GTK_TYPE_CSS_NODE))
#define GTK_IS_CSS_NODE_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE (obj, GTK_TYPE_CSS_NODE))
#define GTK_CSS_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CSS_NODE, GtkCssNodeClass))
typedef struct _GtkCssNode GtkCssNode;
typedef struct _GtkCssNodeClass GtkCssNodeClass;
struct _GtkCssNode
{
GObject object;
GtkCssNode *parent;
GtkCssNode *previous_sibling;
GtkCssNode *next_sibling;
GtkCssNode *first_child;
GtkCssNode *last_child;
GtkCssNodeDeclaration *decl;
GtkCssStyle *style;
GtkCssChange pending_changes; /* changes that accumulated since the style was last computed */
guint visible :1; /* node will be skipped when validating or computing styles */
guint invalid :1; /* node or a child needs to be validated (even if just for animation) */
guint children_changed :1; /* the children changed since last validation */
guint needs_propagation :1; /* children have state changes that need to be propagated to their siblings */
/* Two invariants hold for this variable:
* style_is_invalid == TRUE => next_sibling->style_is_invalid == TRUE
* style_is_invalid == FALSE => first_child->style_is_invalid == TRUE
* So if a valid style is computed, one has to previously ensure that the parent's and the previous sibling's style
* are valid. This allows both validation and invalidation to run in O(nodes-in-tree) */
guint style_is_invalid :1; /* the style needs to be recomputed */
};
struct _GtkCssNodeClass
{
GObjectClass object_class;
void (* node_added) (GtkCssNode *cssnode,
GtkCssNode *child,
GtkCssNode *previous);
void (* node_removed) (GtkCssNode *cssnode,
GtkCssNode *child,
GtkCssNode *previous);
void (* style_changed) (GtkCssNode *cssnode,
GtkCssStyle *old_style,
GtkCssStyle *new_style);
gboolean (* init_matcher) (GtkCssNode *cssnode,
GtkCssMatcher *matcher);
GtkWidgetPath * (* create_widget_path) (GtkCssNode *cssnode);
const GtkWidgetPath * (* get_widget_path) (GtkCssNode *cssnode);
/* get style provider to use or NULL to use parent's */
GtkStyleProviderPrivate *(* get_style_provider) (GtkCssNode *cssnode);
/* get frame clock or NULL (only relevant for root node) */
GdkFrameClock * (* get_frame_clock) (GtkCssNode *cssnode);
GtkCssStyle * (* update_style) (GtkCssNode *cssnode,
GtkCssChange pending_changes,
gint64 timestamp,
GtkCssStyle *old_style);
void (* invalidate) (GtkCssNode *node);
void (* queue_validate) (GtkCssNode *node);
void (* dequeue_validate) (GtkCssNode *node);
void (* validate) (GtkCssNode *node);
};
GType gtk_css_node_get_type (void) G_GNUC_CONST;
GtkCssNode * gtk_css_node_new (void);
void gtk_css_node_set_parent (GtkCssNode *cssnode,
GtkCssNode *parent);
void gtk_css_node_set_after (GtkCssNode *cssnode,
GtkCssNode *previous_sibling);
void gtk_css_node_set_before (GtkCssNode *cssnode,
GtkCssNode *next_sibling);
GtkCssNode * gtk_css_node_get_parent (GtkCssNode *cssnode);
GtkCssNode * gtk_css_node_get_first_child (GtkCssNode *cssnode);
GtkCssNode * gtk_css_node_get_last_child (GtkCssNode *cssnode);
GtkCssNode * gtk_css_node_get_previous_sibling(GtkCssNode *cssnode);
GtkCssNode * gtk_css_node_get_next_sibling (GtkCssNode *cssnode);
void gtk_css_node_set_visible (GtkCssNode *cssnode,
gboolean visible);
gboolean gtk_css_node_get_visible (GtkCssNode *cssnode);
void gtk_css_node_set_widget_type (GtkCssNode *cssnode,
GType widget_type);
GType gtk_css_node_get_widget_type (GtkCssNode *cssnode);
void gtk_css_node_set_id (GtkCssNode *cssnode,
const char *id);
const char * gtk_css_node_get_id (GtkCssNode *cssnode);
void gtk_css_node_set_state (GtkCssNode *cssnode,
GtkStateFlags state_flags);
GtkStateFlags gtk_css_node_get_state (GtkCssNode *cssnode);
void gtk_css_node_add_state (GtkCssNode *cssnode,
GtkStateFlags state_flags);
void gtk_css_node_remove_state (GtkCssNode *cssnode,
GtkStateFlags state_flags);
void gtk_css_node_set_junction_sides (GtkCssNode *cssnode,
GtkJunctionSides junction_sides);
GtkJunctionSides gtk_css_node_get_junction_sides (GtkCssNode *cssnode);
void gtk_css_node_set_classes (GtkCssNode *cssnode,
const char **classes);
char ** gtk_css_node_get_classes (GtkCssNode *cssnode);
void gtk_css_node_add_class (GtkCssNode *cssnode,
const char *style_class);
void gtk_css_node_remove_class (GtkCssNode *cssnode,
const char *style_class);
gboolean gtk_css_node_has_class (GtkCssNode *cssnode,
const char *style_class);
gboolean gtk_css_node_has_qclass (GtkCssNode *cssnode,
GQuark style_class);
GList * gtk_css_node_list_classes (GtkCssNode *cssnode);
void gtk_css_node_add_region (GtkCssNode *cssnode,
GQuark region,
GtkRegionFlags flags);
void gtk_css_node_remove_region (GtkCssNode *cssnode,
GQuark region);
gboolean gtk_css_node_has_region (GtkCssNode *cssnode,
GQuark region,
GtkRegionFlags *out_flags);
GList * gtk_css_node_list_regions (GtkCssNode *cssnode);
const GtkCssNodeDeclaration *
gtk_css_node_get_declaration (GtkCssNode *cssnode);
GtkCssStyle * gtk_css_node_get_style (GtkCssNode *cssnode);
void gtk_css_node_invalidate_style_provider
(GtkCssNode *cssnode);
void gtk_css_node_invalidate_frame_clock
(GtkCssNode *cssnode,
gboolean just_timestamp);
void gtk_css_node_invalidate (GtkCssNode *cssnode,
GtkCssChange change);
void gtk_css_node_validate (GtkCssNode *cssnode);
gboolean gtk_css_node_init_matcher (GtkCssNode *cssnode,
GtkCssMatcher *matcher);
GtkWidgetPath * gtk_css_node_create_widget_path (GtkCssNode *cssnode);
const GtkWidgetPath * gtk_css_node_get_widget_path (GtkCssNode *cssnode);
GtkStyleProviderPrivate *gtk_css_node_get_style_provider(GtkCssNode *cssnode);
G_END_DECLS
#endif /* __GTK_CSS_NODE_PRIVATE_H__ */
+300
View File
@@ -0,0 +1,300 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2014 Benjamin Otte <otte@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtkcssnodeutilsprivate.h"
#include <math.h>
#include "gtkcssnumbervalueprivate.h"
#include "gtkcssshadowsvalueprivate.h"
#include "gtkcssstyleprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkrenderbackgroundprivate.h"
#include "gtkrenderborderprivate.h"
void
gtk_css_node_style_changed_for_widget (GtkCssNode *node,
GtkCssStyle *old_style,
GtkCssStyle *new_style,
GtkWidget *widget)
{
static GtkBitmask *affects_size = NULL;
GtkBitmask *changes;
changes = gtk_css_style_get_difference (old_style, new_style);
if (G_UNLIKELY (affects_size == NULL))
affects_size = _gtk_css_style_property_get_mask_affecting (GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP);
if (_gtk_bitmask_intersects (changes, affects_size))
gtk_widget_queue_resize (widget);
else
gtk_widget_queue_draw (widget);
_gtk_bitmask_free (changes);
}
static gint
get_number (GtkCssStyle *style,
guint property)
{
double d = _gtk_css_number_value_get (gtk_css_style_get_value (style, property), 100);
if (d < 1)
return ceil (d);
else
return floor (d);
}
static void
get_box_margin (GtkCssStyle *style,
GtkBorder *margin)
{
margin->top = get_number (style, GTK_CSS_PROPERTY_MARGIN_TOP);
margin->left = get_number (style, GTK_CSS_PROPERTY_MARGIN_LEFT);
margin->bottom = get_number (style, GTK_CSS_PROPERTY_MARGIN_BOTTOM);
margin->right = get_number (style, GTK_CSS_PROPERTY_MARGIN_RIGHT);
}
static void
get_box_border (GtkCssStyle *style,
GtkBorder *border)
{
border->top = get_number (style, GTK_CSS_PROPERTY_BORDER_TOP_WIDTH);
border->left = get_number (style, GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH);
border->bottom = get_number (style, GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH);
border->right = get_number (style, GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH);
}
static void
get_box_padding (GtkCssStyle *style,
GtkBorder *border)
{
border->top = get_number (style, GTK_CSS_PROPERTY_PADDING_TOP);
border->left = get_number (style, GTK_CSS_PROPERTY_PADDING_LEFT);
border->bottom = get_number (style, GTK_CSS_PROPERTY_PADDING_BOTTOM);
border->right = get_number (style, GTK_CSS_PROPERTY_PADDING_RIGHT);
}
static void
get_content_size_func_default (GtkCssNode *cssnode,
GtkOrientation orientation,
gint for_size,
gint *minimum,
gint *natural,
gint *minimum_baseline,
gint *natural_baseline,
gpointer unused)
{
*minimum = 0;
*natural = 0;
if (minimum_baseline)
*minimum_baseline = 0;
if (natural_baseline)
*natural_baseline = 0;
}
void
gtk_css_node_get_preferred_size (GtkCssNode *cssnode,
GtkOrientation orientation,
gint for_size,
gint *minimum,
gint *natural,
gint *minimum_baseline,
gint *natural_baseline,
GtkCssNodeSizeFunc get_content_size_func,
gpointer get_content_size_data)
{
GtkCssStyle *style;
GtkBorder margin, border, padding;
int min_size, extra_size, extra_opposite, extra_baseline;
if (!get_content_size_func)
get_content_size_func = get_content_size_func_default;
style = gtk_css_node_get_style (cssnode);
get_box_margin (style, &margin);
get_box_border (style, &border);
get_box_padding (style, &padding);
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
extra_size = margin.left + margin.right + border.left + border.right + padding.left + padding.right;
extra_opposite = margin.top + margin.bottom + border.top + border.bottom + padding.top + padding.bottom;
extra_baseline = margin.left + border.left + padding.left;
min_size = get_number (style, GTK_CSS_PROPERTY_MIN_WIDTH);
}
else
{
extra_size = margin.top + margin.bottom + border.top + border.bottom + padding.top + padding.bottom;
extra_opposite = margin.left + margin.right + border.left + border.right + padding.left + padding.right;
extra_baseline = margin.top + border.top + padding.top;
min_size = get_number (style, GTK_CSS_PROPERTY_MIN_HEIGHT);
}
if (for_size > -1)
for_size -= extra_opposite;
if (minimum_baseline)
*minimum_baseline = -1;
if (natural_baseline)
*natural_baseline = -1;
get_content_size_func (cssnode,
orientation,
for_size,
minimum, natural,
minimum_baseline, natural_baseline,
get_content_size_data);
g_warn_if_fail (*minimum <= *natural);
*minimum = MAX (min_size, *minimum);
*natural = MAX (min_size, *natural);
*minimum += extra_size;
*natural += extra_size;
if (minimum_baseline && *minimum_baseline > -1)
*minimum_baseline += extra_baseline;
if (natural_baseline && *natural_baseline > -1)
*natural_baseline += extra_baseline;
}
static void
allocate_func_default (GtkCssNode *cssnode,
const GtkAllocation *allocation,
int baseline,
GtkAllocation *out_clip,
gpointer unused)
{
*out_clip = *allocation;
}
void
gtk_css_node_allocate (GtkCssNode *cssnode,
const GtkAllocation *allocation,
int baseline,
GtkAllocation *out_clip,
GtkCssNodeAllocateFunc allocate_func,
gpointer allocate_data)
{
GtkAllocation content_allocation, clip;
GtkBorder margin, border, padding, shadow, extents;
GtkCssStyle *style;
if (out_clip == NULL)
out_clip = &clip;
if (!allocate_func)
allocate_func = allocate_func_default;
style = gtk_css_node_get_style (cssnode);
get_box_margin (style, &margin);
get_box_border (style, &border);
get_box_padding (style, &padding);
extents.top = margin.top + border.top + padding.top;
extents.right = margin.right + border.right + padding.right;
extents.bottom = margin.bottom + border.bottom + padding.bottom;
extents.left = margin.left + border.left + padding.left;
content_allocation.x = allocation->x + extents.left;
content_allocation.y = allocation->y + extents.top;
content_allocation.width = allocation->width - extents.left - extents.right;
content_allocation.height = allocation->height - extents.top - extents.bottom;
if (baseline >= 0)
baseline += extents.top;
g_assert (content_allocation.width >= 0);
g_assert (content_allocation.height >= 0);
allocate_func (cssnode, &content_allocation, baseline, out_clip, allocate_data);
_gtk_css_shadows_value_get_extents (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BOX_SHADOW), &shadow);
out_clip->x -= extents.left + shadow.left - margin.left;
out_clip->y -= extents.top + shadow.top - margin.top;
out_clip->width += extents.left + extents.right + shadow.left + shadow.right - margin.left - margin.right;
out_clip->height += extents.top + extents.bottom + shadow.top + shadow.bottom - margin.top - margin.bottom;
}
static gboolean
draw_contents_func_default (GtkCssNode *cssnode,
cairo_t *cr,
int width,
int height,
gpointer unused)
{
return FALSE;
}
void
gtk_css_node_draw (GtkCssNode *cssnode,
cairo_t *cr,
int width,
int height,
GtkCssNodeDrawFunc draw_contents_func,
gpointer draw_contents_data)
{
GtkBorder margin, border, padding;
gboolean draw_focus;
GtkCssStyle *style;
int contents_width, contents_height;
if (draw_contents_func == NULL)
draw_contents_func = draw_contents_func_default;
style = gtk_css_node_get_style (cssnode);
get_box_margin (style, &margin);
get_box_border (style, &border);
get_box_padding (style, &padding);
gtk_css_style_render_background (style,
cr,
margin.left,
margin.top,
width - margin.left - margin.right,
height - margin.top - margin.bottom,
gtk_css_node_get_junction_sides (cssnode));
gtk_css_style_render_border (style,
cr,
margin.left,
margin.top,
width - margin.left - margin.right,
height - margin.top - margin.bottom,
0,
gtk_css_node_get_junction_sides (cssnode));
cairo_translate (cr,
margin.left + border.left + padding.left,
margin.top + border.top + padding.top);
contents_width = width - margin.left - margin.right - border.left - border.right - padding.left - padding.right;
contents_height = height - margin.top - margin.bottom - border.top - border.bottom - padding.top - padding.bottom;
draw_focus = draw_contents_func (cssnode, cr, contents_width, contents_height, draw_contents_data);
cairo_translate (cr,
- (margin.left + border.left + padding.left),
- (margin.top + border.top + padding.top));
if (draw_focus)
gtk_css_style_render_outline (style,
cr,
margin.left,
margin.top,
width - margin.left - margin.right,
height - margin.top - margin.bottom);
}
+75
View File
@@ -0,0 +1,75 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2014 Benjamin Otte <otte@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_CSS_NODE_UTILS_PRIVATE_H__
#define __GTK_CSS_NODE_UTILS_PRIVATE_H__
#include <gtk/gtkwidget.h>
#include "gtk/gtkcssnodeprivate.h"
G_BEGIN_DECLS
void gtk_css_node_style_changed_for_widget (GtkCssNode *node,
GtkCssStyle *old_style,
GtkCssStyle *new_style,
GtkWidget *widget);
typedef void (* GtkCssNodeSizeFunc) (GtkCssNode *cssnode,
GtkOrientation orientation,
gint for_size,
gint *minimum,
gint *natural,
gint *minimum_baseline,
gint *natural_baseline,
gpointer get_content_size_data);
void gtk_css_node_get_preferred_size (GtkCssNode *cssnode,
GtkOrientation orientation,
gint for_size,
gint *minimum,
gint *natural,
gint *minimum_baseline,
gint *natural_baseline,
GtkCssNodeSizeFunc get_content_size_func,
gpointer get_content_size_data);
typedef void (* GtkCssNodeAllocateFunc) (GtkCssNode *cssnode,
const GtkAllocation *allocation,
int baseline,
GtkAllocation *out_clip,
gpointer allocate_data);
void gtk_css_node_allocate (GtkCssNode *cssnode,
const GtkAllocation *allocation,
int baseline,
GtkAllocation *out_clip,
GtkCssNodeAllocateFunc allocate_func,
gpointer allocate_data);
typedef gboolean (* GtkCssNodeDrawFunc) (GtkCssNode *cssnode,
cairo_t *cr,
int width,
int height,
gpointer data);
void gtk_css_node_draw (GtkCssNode *cssnode,
cairo_t *cr,
int width,
int height,
GtkCssNodeDrawFunc draw_contents_func,
gpointer draw_contents_data);
G_END_DECLS
#endif /* __GTK_CSS_NODE_UTILS_PRIVATE_H__ */
+5 -9
View File
@@ -39,19 +39,16 @@ static double
get_base_font_size (guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
if (property_id == GTK_CSS_PROPERTY_FONT_SIZE)
{
*dependencies = GTK_CSS_DEPENDS_ON_PARENT;
if (parent_style)
return _gtk_css_number_value_get (gtk_css_style_get_value (parent_style, GTK_CSS_PROPERTY_FONT_SIZE), 100);
else
return _gtk_css_font_size_get_default (provider);
}
*dependencies = GTK_CSS_DEPENDS_ON_FONT_SIZE;
return _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_FONT_SIZE), 100);
}
@@ -60,8 +57,7 @@ gtk_css_value_number_compute (GtkCssValue *number,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
GtkBorderStyle border_style;
@@ -106,7 +102,7 @@ gtk_css_value_number_compute (GtkCssValue *number,
/* percentages for font sizes are computed, other percentages aren't */
if (property_id == GTK_CSS_PROPERTY_FONT_SIZE)
return _gtk_css_number_value_new (number->value / 100.0 *
get_base_font_size (property_id, provider, style, parent_style, dependencies),
get_base_font_size (property_id, provider, style, parent_style),
GTK_CSS_PX);
case GTK_CSS_NUMBER:
case GTK_CSS_PX:
@@ -134,13 +130,13 @@ gtk_css_value_number_compute (GtkCssValue *number,
break;
case GTK_CSS_EM:
return _gtk_css_number_value_new (number->value *
get_base_font_size (property_id, provider, style, parent_style, dependencies),
get_base_font_size (property_id, provider, style, parent_style),
GTK_CSS_PX);
break;
case GTK_CSS_EX:
/* for now we pretend ex is half of em */
return _gtk_css_number_value_new (number->value * 0.5 *
get_base_font_size (property_id, provider, style, parent_style, dependencies),
get_base_font_size (property_id, provider, style, parent_style),
GTK_CSS_PX);
case GTK_CSS_RAD:
return _gtk_css_number_value_new (number->value * 360.0 / (2 * G_PI),
+197
View File
@@ -0,0 +1,197 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2014 Benjamin Otte <otte@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtkcsspathnodeprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkprivate.h"
#include "gtkstylecontextprivate.h"
G_DEFINE_TYPE (GtkCssPathNode, gtk_css_path_node, GTK_TYPE_CSS_NODE)
static void
gtk_css_path_node_finalize (GObject *object)
{
GtkCssPathNode *node = GTK_CSS_PATH_NODE (object);
if (node->path)
gtk_widget_path_unref (node->path);
G_OBJECT_CLASS (gtk_css_path_node_parent_class)->finalize (object);
}
static void
gtk_css_path_node_invalidate (GtkCssNode *node)
{
GtkCssPathNode *path_node = GTK_CSS_PATH_NODE (node);
if (path_node->context)
{
GtkBitmask *changes;
changes = _gtk_bitmask_new ();
changes = _gtk_bitmask_invert_range (changes,
0,
_gtk_css_style_property_get_n_properties ());
gtk_style_context_validate (path_node->context, changes);
_gtk_bitmask_free (changes);
}
}
gboolean
gtk_css_path_node_real_init_matcher (GtkCssNode *node,
GtkCssMatcher *matcher)
{
GtkCssPathNode *path_node = GTK_CSS_PATH_NODE (node);
if (path_node->path == NULL ||
gtk_widget_path_length (path_node->path) == 0)
return FALSE;
return _gtk_css_matcher_init (matcher,
path_node->path,
gtk_css_node_get_declaration (node));
}
static GtkWidgetPath *
gtk_css_path_node_real_create_widget_path (GtkCssNode *node)
{
GtkCssPathNode *path_node = GTK_CSS_PATH_NODE (node);
GtkWidgetPath *path;
guint length;
if (path_node->path == NULL)
path = gtk_widget_path_new ();
else
path = gtk_widget_path_copy (path_node->path);
length = gtk_widget_path_length (path);
if (length > 0)
{
gtk_css_node_declaration_add_to_widget_path (gtk_css_node_get_declaration (node),
path,
length - 1);
}
return path;
}
static const GtkWidgetPath *
gtk_css_path_node_real_get_widget_path (GtkCssNode *node)
{
GtkCssPathNode *path_node = GTK_CSS_PATH_NODE (node);
return path_node->path;
}
static GtkCssStyle *
gtk_css_path_node_update_style (GtkCssNode *cssnode,
GtkCssChange change,
gint64 timestamp,
GtkCssStyle *style)
{
/* This should get rid of animations */
return GTK_CSS_NODE_CLASS (gtk_css_path_node_parent_class)->update_style (cssnode, change, 0, style);
}
static GtkStyleProviderPrivate *
gtk_css_path_node_get_style_provider (GtkCssNode *node)
{
GtkCssPathNode *path_node = GTK_CSS_PATH_NODE (node);
if (path_node->context == NULL)
return NULL;
return gtk_style_context_get_style_provider (path_node->context);
}
static void
gtk_css_path_node_class_init (GtkCssPathNodeClass *klass)
{
GtkCssNodeClass *node_class = GTK_CSS_NODE_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gtk_css_path_node_finalize;
node_class->invalidate = gtk_css_path_node_invalidate;
node_class->update_style = gtk_css_path_node_update_style;
node_class->init_matcher = gtk_css_path_node_real_init_matcher;
node_class->create_widget_path = gtk_css_path_node_real_create_widget_path;
node_class->get_widget_path = gtk_css_path_node_real_get_widget_path;
node_class->get_style_provider = gtk_css_path_node_get_style_provider;
}
static void
gtk_css_path_node_init (GtkCssPathNode *cssnode)
{
}
GtkCssNode *
gtk_css_path_node_new (GtkStyleContext *context)
{
GtkCssPathNode *node;
g_return_val_if_fail (context == NULL || GTK_IS_STYLE_CONTEXT (context), NULL);
node = g_object_new (GTK_TYPE_CSS_PATH_NODE, NULL);
node->context = context;
return GTK_CSS_NODE (node);
}
void
gtk_css_path_node_unset_context (GtkCssPathNode *node)
{
gtk_internal_return_if_fail (GTK_IS_CSS_PATH_NODE (node));
gtk_internal_return_if_fail (node->context != NULL);
node->context = NULL;
gtk_css_node_invalidate_style_provider (GTK_CSS_NODE (node));
}
void
gtk_css_path_node_set_widget_path (GtkCssPathNode *node,
GtkWidgetPath *path)
{
gtk_internal_return_if_fail (GTK_IS_CSS_PATH_NODE (node));
if (node->path == path)
return;
if (node->path)
gtk_widget_path_unref (node->path);
if (path)
gtk_widget_path_ref (path);
node->path = path;
gtk_css_node_invalidate (GTK_CSS_NODE (node), GTK_CSS_CHANGE_ANY);
}
GtkWidgetPath *
gtk_css_path_node_get_widget_path (GtkCssPathNode *node)
{
gtk_internal_return_val_if_fail (GTK_IS_CSS_PATH_NODE (node), NULL);
return node->path;
}
+61
View File
@@ -0,0 +1,61 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2014 Benjamin Otte <otte@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_CSS_PATH_NODE_PRIVATE_H__
#define __GTK_CSS_PATH_NODE_PRIVATE_H__
#include "gtkcssnodeprivate.h"
#include "gtkwidgetpath.h"
G_BEGIN_DECLS
#define GTK_TYPE_CSS_PATH_NODE (gtk_css_path_node_get_type ())
#define GTK_CSS_PATH_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GTK_TYPE_CSS_PATH_NODE, GtkCssPathNode))
#define GTK_CSS_PATH_NODE_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST (cls, GTK_TYPE_CSS_PATH_NODE, GtkCssPathNodeClass))
#define GTK_IS_CSS_PATH_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GTK_TYPE_CSS_PATH_NODE))
#define GTK_IS_CSS_PATH_NODE_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE (obj, GTK_TYPE_CSS_PATH_NODE))
#define GTK_CSS_PATH_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CSS_PATH_NODE, GtkCssPathNodeClass))
typedef struct _GtkCssPathNode GtkCssPathNode;
typedef struct _GtkCssPathNodeClass GtkCssPathNodeClass;
struct _GtkCssPathNode
{
GtkCssNode node;
GtkStyleContext *context;
GtkWidgetPath *path;
};
struct _GtkCssPathNodeClass
{
GtkCssNodeClass node_class;
};
GType gtk_css_path_node_get_type (void) G_GNUC_CONST;
GtkCssNode * gtk_css_path_node_new (GtkStyleContext *context);
void gtk_css_path_node_unset_context (GtkCssPathNode *node);
void gtk_css_path_node_set_widget_path (GtkCssPathNode *node,
GtkWidgetPath *path);
GtkWidgetPath * gtk_css_path_node_get_widget_path (GtkCssPathNode *node);
G_END_DECLS
#endif /* __GTK_CSS_PATH_NODE_PRIVATE_H__ */
+3 -6
View File
@@ -41,15 +41,12 @@ gtk_css_value_position_compute (GtkCssValue *position,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
GtkCssValue *x, *y;
GtkCssDependencies x_deps, y_deps;
x = _gtk_css_value_compute (position->x, property_id, provider, style, parent_style, &x_deps);
y = _gtk_css_value_compute (position->y, property_id, provider, style, parent_style, &y_deps);
*dependencies = _gtk_css_dependencies_union (x_deps, y_deps);
x = _gtk_css_value_compute (position->x, property_id, provider, style, parent_style);
y = _gtk_css_value_compute (position->y, property_id, provider, style, parent_style);
if (x == position->x && y == position->y)
{
_gtk_css_value_unref (x);
+1 -1
View File
@@ -1695,7 +1695,7 @@ gtk_css_provider_get_style_property (GtkStyleProvider *provider,
gtk_widget_path_iter_set_state (path, -1, state);
}
if (!_gtk_css_matcher_init (&matcher, path))
if (!_gtk_css_matcher_init (&matcher, path, NULL))
{
gtk_widget_path_unref (path);
return FALSE;
+1 -2
View File
@@ -38,8 +38,7 @@ gtk_css_value_repeat_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
return _gtk_css_value_ref (value);
}
+1 -2
View File
@@ -38,8 +38,7 @@ gtk_css_value_rgba_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
return _gtk_css_value_ref (value);
}
+2 -5
View File
@@ -55,11 +55,9 @@ gtk_css_value_shadows_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
GtkCssValue *result;
GtkCssDependencies child_deps;
guint i;
if (value->len == 0)
@@ -68,8 +66,7 @@ gtk_css_value_shadows_compute (GtkCssValue *value,
result = gtk_css_shadows_value_new (value->values, value->len);
for (i = 0; i < value->len; i++)
{
result->values[i] = _gtk_css_value_compute (value->values[i], property_id, provider, style, parent_style, &child_deps);
*dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
result->values[i] = _gtk_css_value_compute (value->values[i], property_id, provider, style, parent_style);
}
return result;
+6 -22
View File
@@ -67,31 +67,15 @@ gtk_css_value_shadow_compute (GtkCssValue *shadow,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
GtkCssValue *hoffset, *voffset, *radius, *spread, *color;
GtkCssDependencies child_deps;
child_deps = 0;
hoffset = _gtk_css_value_compute (shadow->hoffset, property_id, provider, style, parent_style, &child_deps);
*dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
child_deps = 0;
voffset = _gtk_css_value_compute (shadow->voffset, property_id, provider, style, parent_style, &child_deps);
*dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
child_deps = 0;
radius = _gtk_css_value_compute (shadow->radius, property_id, provider, style, parent_style, &child_deps);
*dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
child_deps = 0;
spread = _gtk_css_value_compute (shadow->spread, property_id, provider, style, parent_style, &child_deps),
*dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
child_deps = 0;
color = _gtk_css_value_compute (shadow->color, property_id, provider, style, parent_style, &child_deps);
*dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
hoffset = _gtk_css_value_compute (shadow->hoffset, property_id, provider, style, parent_style);
voffset = _gtk_css_value_compute (shadow->voffset, property_id, provider, style, parent_style);
radius = _gtk_css_value_compute (shadow->radius, property_id, provider, style, parent_style);
spread = _gtk_css_value_compute (shadow->spread, property_id, provider, style, parent_style),
color = _gtk_css_value_compute (shadow->color, property_id, provider, style, parent_style);
return gtk_css_shadow_value_new (hoffset, voffset, radius, spread, shadow->inset, color);
}
+1 -116
View File
@@ -66,28 +66,6 @@ gtk_css_static_style_get_section (GtkCssStyle *style,
return g_ptr_array_index (sstyle->sections, id);
}
/* Compute the bitmask of potentially changed properties if the parent has changed
* the passed in ones.
* This is for example needed when changes in the "color" property will affect
* all properties using "currentColor" as a color.
*/
static GtkBitmask *
gtk_css_static_style_compute_dependencies (GtkCssStaticStyle *style,
const GtkBitmask *parent_changes)
{
GtkCssStaticStyle *sstyle = GTK_CSS_STATIC_STYLE (style);
GtkBitmask *changes;
changes = _gtk_bitmask_copy (parent_changes);
changes = _gtk_bitmask_intersect (changes, sstyle->depends_on_parent);
if (_gtk_bitmask_get (changes, GTK_CSS_PROPERTY_COLOR))
changes = _gtk_bitmask_union (changes, sstyle->depends_on_color);
if (_gtk_bitmask_get (changes, GTK_CSS_PROPERTY_FONT_SIZE))
changes = _gtk_bitmask_union (changes, sstyle->depends_on_font_size);
return changes;
}
static void
gtk_css_static_style_dispose (GObject *object)
{
@@ -107,19 +85,6 @@ gtk_css_static_style_dispose (GObject *object)
G_OBJECT_CLASS (gtk_css_static_style_parent_class)->dispose (object);
}
static void
gtk_css_static_style_finalize (GObject *object)
{
GtkCssStaticStyle *style = GTK_CSS_STATIC_STYLE (object);
_gtk_bitmask_free (style->depends_on_parent);
_gtk_bitmask_free (style->equals_parent);
_gtk_bitmask_free (style->depends_on_color);
_gtk_bitmask_free (style->depends_on_font_size);
G_OBJECT_CLASS (gtk_css_static_style_parent_class)->finalize (object);
}
static void
gtk_css_static_style_class_init (GtkCssStaticStyleClass *klass)
{
@@ -127,7 +92,6 @@ gtk_css_static_style_class_init (GtkCssStaticStyleClass *klass)
GtkCssStyleClass *style_class = GTK_CSS_STYLE_CLASS (klass);
object_class->dispose = gtk_css_static_style_dispose;
object_class->finalize = gtk_css_static_style_finalize;
style_class->get_value = gtk_css_static_style_get_value;
style_class->get_section = gtk_css_static_style_get_section;
@@ -136,10 +100,6 @@ gtk_css_static_style_class_init (GtkCssStaticStyleClass *klass)
static void
gtk_css_static_style_init (GtkCssStaticStyle *style)
{
style->depends_on_parent = _gtk_bitmask_new ();
style->equals_parent = _gtk_bitmask_new ();
style->depends_on_color = _gtk_bitmask_new ();
style->depends_on_font_size = _gtk_bitmask_new ();
}
static void
@@ -235,71 +195,6 @@ gtk_css_static_style_new_compute (GtkStyleProviderPrivate *provider,
return GTK_CSS_STYLE (result);
}
GtkCssStyle *
gtk_css_static_style_new_update (GtkCssStaticStyle *style,
const GtkBitmask *parent_changes,
GtkStyleProviderPrivate *provider,
const GtkCssMatcher *matcher,
GtkCssStyle *parent)
{
GtkCssStaticStyle *result;
GtkCssLookup *lookup;
GtkBitmask *changes;
guint i;
gtk_internal_return_val_if_fail (GTK_IS_CSS_STATIC_STYLE (style), NULL);
gtk_internal_return_val_if_fail (parent_changes != NULL, NULL);
gtk_internal_return_val_if_fail (GTK_IS_STYLE_PROVIDER_PRIVATE (provider), NULL);
gtk_internal_return_val_if_fail (matcher != NULL, NULL);
changes = gtk_css_static_style_compute_dependencies (style, parent_changes);
if (_gtk_bitmask_is_empty (changes))
{
_gtk_bitmask_free (changes);
return g_object_ref (style);
}
result = g_object_new (GTK_TYPE_CSS_STATIC_STYLE, NULL);
result->change = style->change;
result->depends_on_parent = _gtk_bitmask_subtract (_gtk_bitmask_union (result->depends_on_parent, style->depends_on_parent),
changes);
result->equals_parent = _gtk_bitmask_subtract (_gtk_bitmask_union (result->equals_parent, style->equals_parent),
changes);
result->depends_on_color = _gtk_bitmask_subtract (_gtk_bitmask_union (result->depends_on_color, style->depends_on_color),
changes);
result->depends_on_font_size = _gtk_bitmask_subtract (_gtk_bitmask_union (result->depends_on_font_size, style->depends_on_font_size),
changes);
for (i = 0; i < style->values->len; i++)
{
if (_gtk_bitmask_get (changes, i))
continue;
gtk_css_static_style_set_value (result,
i,
gtk_css_static_style_get_value (GTK_CSS_STYLE (style), i),
gtk_css_static_style_get_section (GTK_CSS_STYLE (style), i));
}
lookup = _gtk_css_lookup_new (changes);
_gtk_style_provider_private_lookup (provider,
matcher,
lookup,
NULL);
_gtk_css_lookup_resolve (lookup,
provider,
result,
parent);
_gtk_css_lookup_free (lookup);
_gtk_bitmask_free (changes);
return GTK_CSS_STYLE (result);
}
void
gtk_css_static_style_compute_value (GtkCssStaticStyle *style,
GtkStyleProviderPrivate *provider,
@@ -308,7 +203,6 @@ gtk_css_static_style_compute_value (GtkCssStaticStyle *style,
GtkCssValue *specified,
GtkCssSection *section)
{
GtkCssDependencies dependencies;
GtkCssValue *value;
gtk_internal_return_if_fail (GTK_IS_CSS_STATIC_STYLE (style));
@@ -332,19 +226,10 @@ gtk_css_static_style_compute_value (GtkCssStaticStyle *style,
else
_gtk_css_value_ref (specified);
value = _gtk_css_value_compute (specified, id, provider, GTK_CSS_STYLE (style), parent_style, &dependencies);
value = _gtk_css_value_compute (specified, id, provider, GTK_CSS_STYLE (style), parent_style);
gtk_css_static_style_set_value (style, id, value, section);
if (dependencies & (GTK_CSS_DEPENDS_ON_PARENT | GTK_CSS_EQUALS_PARENT))
style->depends_on_parent = _gtk_bitmask_set (style->depends_on_parent, id, TRUE);
if (dependencies & (GTK_CSS_EQUALS_PARENT))
style->equals_parent = _gtk_bitmask_set (style->equals_parent, id, TRUE);
if (dependencies & (GTK_CSS_DEPENDS_ON_COLOR))
style->depends_on_color = _gtk_bitmask_set (style->depends_on_color, id, TRUE);
if (dependencies & (GTK_CSS_DEPENDS_ON_FONT_SIZE))
style->depends_on_font_size = _gtk_bitmask_set (style->depends_on_font_size, id, TRUE);
_gtk_css_value_unref (value);
_gtk_css_value_unref (specified);
}
-10
View File
@@ -42,11 +42,6 @@ struct _GtkCssStaticStyle
GPtrArray *values; /* the values */
GPtrArray *sections; /* sections the values are defined in */
GtkBitmask *depends_on_parent; /* values that depend on parent values */
GtkBitmask *equals_parent; /* values that equal their parent values */
GtkBitmask *depends_on_color; /* values that depend on the color property */
GtkBitmask *depends_on_font_size; /* values that depend on the font-size property */
GtkCssChange change; /* change as returned by value lookup */
};
@@ -61,11 +56,6 @@ GtkCssStyle * gtk_css_static_style_get_default (void);
GtkCssStyle * gtk_css_static_style_new_compute (GtkStyleProviderPrivate *provider,
const GtkCssMatcher *matcher,
GtkCssStyle *parent);
GtkCssStyle * gtk_css_static_style_new_update (GtkCssStaticStyle *style,
const GtkBitmask *parent_changes,
GtkStyleProviderPrivate *provider,
const GtkCssMatcher *matcher,
GtkCssStyle *parent);
void gtk_css_static_style_compute_value (GtkCssStaticStyle *style,
GtkStyleProviderPrivate*provider,
+1 -2
View File
@@ -38,8 +38,7 @@ gtk_css_value_string_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
return _gtk_css_value_ref (value);
}
+19
View File
@@ -46,10 +46,17 @@ gtk_css_style_real_get_section (GtkCssStyle *style,
return NULL;
}
static gboolean
gtk_css_style_real_is_static (GtkCssStyle *style)
{
return TRUE;
}
static void
gtk_css_style_class_init (GtkCssStyleClass *klass)
{
klass->get_section = gtk_css_style_real_get_section;
klass->is_static = gtk_css_style_real_is_static;
}
static void
@@ -82,6 +89,9 @@ gtk_css_style_get_difference (GtkCssStyle *style,
GtkBitmask *result;
guint i, len;
if (style == other)
return _gtk_bitmask_new ();
result = _gtk_bitmask_new ();
len = _gtk_css_style_property_get_n_properties ();
for (i = 0; i < len; i++)
@@ -94,6 +104,15 @@ gtk_css_style_get_difference (GtkCssStyle *style,
return result;
}
gboolean
gtk_css_style_is_static (GtkCssStyle *style)
{
gtk_internal_return_val_if_fail (GTK_IS_CSS_STYLE (style), TRUE);
return GTK_CSS_STYLE_GET_CLASS (style)->is_static (style);
}
void
gtk_css_style_print (GtkCssStyle *style,
GString *string)
+7 -19
View File
@@ -58,8 +58,7 @@ typedef void (* GtkStylePrintFunc) (const GValue
typedef GtkCssValue * (* GtkStyleComputeFunc) (GtkStyleProviderPrivate *provider,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssValue *specified,
GtkCssDependencies *dependencies);
GtkCssValue *specified);
static void
register_conversion_function (GType type,
@@ -185,8 +184,7 @@ static GtkCssValue *
rgba_value_compute (GtkStyleProviderPrivate *provider,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssValue *specified,
GtkCssDependencies *dependencies)
GtkCssValue *specified)
{
GdkRGBA white = { 1, 1, 1, 1 };
const GValue *value;
@@ -205,8 +203,6 @@ rgba_value_compute (GtkStyleProviderPrivate *provider,
val = _gtk_css_color_value_resolve (_gtk_symbolic_color_get_css_value (symbolic),
provider,
gtk_css_style_get_value (values, GTK_CSS_PROPERTY_COLOR),
GTK_CSS_DEPENDS_ON_COLOR,
dependencies,
NULL);
if (val != NULL)
{
@@ -284,8 +280,7 @@ static GtkCssValue *
color_value_compute (GtkStyleProviderPrivate *provider,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssValue *specified,
GtkCssDependencies *dependencies)
GtkCssValue *specified)
{
GdkColor color = { 0, 65535, 65535, 65535 };
const GValue *value;
@@ -302,8 +297,6 @@ color_value_compute (GtkStyleProviderPrivate *provider,
val = _gtk_css_color_value_resolve (_gtk_symbolic_color_get_css_value (g_value_get_boxed (value)),
provider,
gtk_css_style_get_value (values, GTK_CSS_PROPERTY_COLOR),
GTK_CSS_DEPENDS_ON_COLOR,
dependencies,
NULL);
if (val != NULL)
{
@@ -849,8 +842,7 @@ static GtkCssValue *
pattern_value_compute (GtkStyleProviderPrivate *provider,
GtkCssStyle *values,
GtkCssStyle *parent_values,
GtkCssValue *specified,
GtkCssDependencies *dependencies)
GtkCssValue *specified)
{
const GValue *value = _gtk_css_typed_value_get (specified);
@@ -861,7 +853,7 @@ pattern_value_compute (GtkStyleProviderPrivate *provider,
GValue new_value = G_VALUE_INIT;
cairo_pattern_t *gradient;
gradient = _gtk_gradient_resolve_full (g_value_get_boxed (value), provider, values, parent_values, dependencies);
gradient = _gtk_gradient_resolve_full (g_value_get_boxed (value), provider, values, parent_values);
g_value_init (&new_value, CAIRO_GOBJECT_TYPE_PATTERN);
g_value_take_boxed (&new_value, gradient);
@@ -1142,8 +1134,6 @@ _gtk_css_style_funcs_print_value (const GValue *value,
* @parent_values: Values to look up inherited values from
* @target_type: Type the resulting value should have
* @specified: the value to use for the computation
* @dependencies: (out): Value initialized with 0 to take the dependencies
* of the returned value
*
* Converts the @specified value into the @computed value using the
* information in @context. The values must have matching types, ie
@@ -1157,15 +1147,13 @@ _gtk_css_style_funcs_compute_value (GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GType target_type,
GtkCssValue *specified,
GtkCssDependencies *dependencies)
GtkCssValue *specified)
{
GtkStyleComputeFunc func;
g_return_val_if_fail (GTK_IS_STYLE_PROVIDER (provider), NULL);
g_return_val_if_fail (GTK_IS_CSS_STYLE (style), NULL);
g_return_val_if_fail (parent_style == NULL || GTK_IS_CSS_STYLE (parent_style), NULL);
g_return_val_if_fail (*dependencies == 0, NULL);
gtk_css_style_funcs_init ();
@@ -1176,7 +1164,7 @@ _gtk_css_style_funcs_compute_value (GtkStyleProviderPrivate *provider,
GSIZE_TO_POINTER (g_type_fundamental (target_type)));
if (func)
return func (provider, style, parent_style, specified, dependencies);
return func (provider, style, parent_style, specified);
else
return _gtk_css_value_ref (specified);
}
+1 -2
View File
@@ -32,8 +32,7 @@ GtkCssValue * _gtk_css_style_funcs_compute_value (GtkStyleProviderPriv
GtkCssStyle *style,
GtkCssStyle *parent_style,
GType target_type,
GtkCssValue *specified,
GtkCssDependencies *dependencies);
GtkCssValue *specified);
G_END_DECLS
+3
View File
@@ -54,6 +54,8 @@ struct _GtkCssStyleClass
* Optional: default impl will just return NULL */
GtkCssSection * (* get_section) (GtkCssStyle *style,
guint id);
/* TRUE if this style will require changes based on timestamp */
gboolean (* is_static) (GtkCssStyle *style);
};
GType gtk_css_style_get_type (void) G_GNUC_CONST;
@@ -64,6 +66,7 @@ GtkCssSection * gtk_css_style_get_section (GtkCssStyle
guint id);
GtkBitmask * gtk_css_style_get_difference (GtkCssStyle *style,
GtkCssStyle *other);
gboolean gtk_css_style_is_static (GtkCssStyle *style);
char * gtk_css_style_to_string (GtkCssStyle *style);
void gtk_css_style_print (GtkCssStyle *style,
+28
View File
@@ -804,6 +804,15 @@ border_image_width_parse (GtkCssStyleProperty *property,
FALSE);
}
static GtkCssValue *
minmax_parse (GtkCssStyleProperty *property,
GtkCssParser *parser)
{
return _gtk_css_number_value_parse (parser,
GTK_CSS_PARSE_LENGTH
| GTK_CSS_POSITIVE_ONLY);
}
static GtkCssValue *
transition_property_parse_one (GtkCssParser *parser)
{
@@ -1529,6 +1538,25 @@ _gtk_css_style_property_init_properties (void)
NULL,
_gtk_css_transform_value_new_none ());
gtk_css_style_property_register ("min-width",
GTK_CSS_PROPERTY_MIN_WIDTH,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_SIZE,
minmax_parse,
NULL,
NULL,
_gtk_css_number_value_new (0, GTK_CSS_PX));
gtk_css_style_property_register ("min-height",
GTK_CSS_PROPERTY_MIN_HEIGHT,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_SIZE,
minmax_parse,
NULL,
NULL,
_gtk_css_number_value_new (0, GTK_CSS_PX));
gtk_css_style_property_register ("transition-property",
GTK_CSS_PROPERTY_TRANSITION_PROPERTY,
G_TYPE_NONE,
+13 -26
View File
@@ -231,12 +231,9 @@ gtk_css_transform_compute (GtkCssTransform *dest,
GtkCssTransform *src,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
GtkCssDependencies x_deps, y_deps;
dest->type = src->type;
switch (src->type)
@@ -244,34 +241,28 @@ gtk_css_transform_compute (GtkCssTransform *dest,
case GTK_CSS_TRANSFORM_MATRIX:
return TRUE;
case GTK_CSS_TRANSFORM_TRANSLATE:
x_deps = y_deps = 0;
dest->translate.x = _gtk_css_value_compute (src->translate.x, property_id, provider, style, parent_style, &x_deps);
dest->translate.y = _gtk_css_value_compute (src->translate.y, property_id, provider, style, parent_style, &y_deps);
*dependencies = _gtk_css_dependencies_union (x_deps, y_deps);
dest->translate.x = _gtk_css_value_compute (src->translate.x, property_id, provider, style, parent_style);
dest->translate.y = _gtk_css_value_compute (src->translate.y, property_id, provider, style, parent_style);
return dest->translate.x == src->translate.x
&& dest->translate.y == src->translate.y;
case GTK_CSS_TRANSFORM_ROTATE:
dest->rotate.rotate = _gtk_css_value_compute (src->rotate.rotate, property_id, provider, style, parent_style, dependencies);
dest->rotate.rotate = _gtk_css_value_compute (src->rotate.rotate, property_id, provider, style, parent_style);
return dest->rotate.rotate == src->rotate.rotate;
case GTK_CSS_TRANSFORM_SCALE:
x_deps = y_deps = 0;
dest->scale.x = _gtk_css_value_compute (src->scale.x, property_id, provider, style, parent_style, &x_deps);
dest->scale.y = _gtk_css_value_compute (src->scale.y, property_id, provider, style, parent_style, &y_deps);
*dependencies = _gtk_css_dependencies_union (x_deps, y_deps);
dest->scale.x = _gtk_css_value_compute (src->scale.x, property_id, provider, style, parent_style);
dest->scale.y = _gtk_css_value_compute (src->scale.y, property_id, provider, style, parent_style);
return dest->scale.x == src->scale.x
&& dest->scale.y == src->scale.y;
case GTK_CSS_TRANSFORM_SKEW:
x_deps = y_deps = 0;
dest->skew.x = _gtk_css_value_compute (src->skew.x, property_id, provider, style, parent_style, &x_deps);
dest->skew.y = _gtk_css_value_compute (src->skew.y, property_id, provider, style, parent_style, &y_deps);
*dependencies = _gtk_css_dependencies_union (x_deps, y_deps);
dest->skew.x = _gtk_css_value_compute (src->skew.x, property_id, provider, style, parent_style);
dest->skew.y = _gtk_css_value_compute (src->skew.y, property_id, provider, style, parent_style);
return dest->skew.x == src->skew.x
&& dest->skew.y == src->skew.y;
case GTK_CSS_TRANSFORM_SKEW_X:
dest->skew_x.skew = _gtk_css_value_compute (src->skew_x.skew, property_id, provider, style, parent_style, dependencies);
dest->skew_x.skew = _gtk_css_value_compute (src->skew_x.skew, property_id, provider, style, parent_style);
return dest->skew_x.skew == src->skew_x.skew;
case GTK_CSS_TRANSFORM_SKEW_Y:
dest->skew_y.skew = _gtk_css_value_compute (src->skew_y.skew, property_id, provider, style, parent_style, dependencies);
dest->skew_y.skew = _gtk_css_value_compute (src->skew_y.skew, property_id, provider, style, parent_style);
return dest->skew_y.skew == src->skew_y.skew;
case GTK_CSS_TRANSFORM_NONE:
default:
@@ -285,10 +276,8 @@ gtk_css_value_transform_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
GtkCssDependencies transform_deps;
GtkCssValue *result;
gboolean changes;
guint i;
@@ -307,9 +296,7 @@ gtk_css_value_transform_compute (GtkCssValue *value,
property_id,
provider,
style,
parent_style,
&transform_deps);
*dependencies = _gtk_css_dependencies_union (*dependencies, transform_deps);
parent_style);
}
if (!changes)
+94
View File
@@ -0,0 +1,94 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2014 Benjamin Otte <otte@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtkcsstransientnodeprivate.h"
#include "gtkprivate.h"
G_DEFINE_TYPE (GtkCssTransientNode, gtk_css_transient_node, GTK_TYPE_CSS_NODE)
static GtkWidgetPath *
gtk_css_transient_node_create_widget_path (GtkCssNode *node)
{
GtkWidgetPath *result;
GtkCssNode *parent;
parent = gtk_css_node_get_parent (node);
if (parent == NULL)
result = gtk_widget_path_new ();
else
result = gtk_css_node_create_widget_path (parent);
gtk_widget_path_append_type (result, gtk_css_node_get_widget_type (node));
gtk_css_node_declaration_add_to_widget_path (gtk_css_node_get_declaration (node), result, -1);
return result;
}
static const GtkWidgetPath *
gtk_css_transient_node_get_widget_path (GtkCssNode *node)
{
GtkCssNode *parent;
parent = gtk_css_node_get_parent (node);
if (parent == NULL)
return NULL;
return gtk_css_node_get_widget_path (parent);
}
static GtkCssStyle *
gtk_css_transient_node_update_style (GtkCssNode *cssnode,
GtkCssChange change,
gint64 timestamp,
GtkCssStyle *style)
{
/* This should get rid of animations */
return GTK_CSS_NODE_CLASS (gtk_css_transient_node_parent_class)->update_style (cssnode, change, 0, style);
}
static void
gtk_css_transient_node_class_init (GtkCssTransientNodeClass *klass)
{
GtkCssNodeClass *node_class = GTK_CSS_NODE_CLASS (klass);
node_class->create_widget_path = gtk_css_transient_node_create_widget_path;
node_class->get_widget_path = gtk_css_transient_node_get_widget_path;
node_class->update_style = gtk_css_transient_node_update_style;
}
static void
gtk_css_transient_node_init (GtkCssTransientNode *cssnode)
{
gtk_css_node_set_visible (GTK_CSS_NODE (cssnode), FALSE);
}
GtkCssNode *
gtk_css_transient_node_new (GtkCssNode *parent)
{
GtkCssNode *result;
gtk_internal_return_val_if_fail (GTK_IS_CSS_NODE (parent), NULL);
result = g_object_new (GTK_TYPE_CSS_TRANSIENT_NODE, NULL);
gtk_css_node_declaration_unref (result->decl);
result->decl = gtk_css_node_declaration_ref (parent->decl);
return result;
}
+51
View File
@@ -0,0 +1,51 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2014 Benjamin Otte <otte@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_CSS_TRANSIENT_NODE_PRIVATE_H__
#define __GTK_CSS_TRANSIENT_NODE_PRIVATE_H__
#include "gtkcssnodeprivate.h"
G_BEGIN_DECLS
#define GTK_TYPE_CSS_TRANSIENT_NODE (gtk_css_transient_node_get_type ())
#define GTK_CSS_TRANSIENT_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GTK_TYPE_CSS_TRANSIENT_NODE, GtkCssTransientNode))
#define GTK_CSS_TRANSIENT_NODE_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST (cls, GTK_TYPE_CSS_TRANSIENT_NODE, GtkCssTransientNodeClass))
#define GTK_IS_CSS_TRANSIENT_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GTK_TYPE_CSS_TRANSIENT_NODE))
#define GTK_IS_CSS_TRANSIENT_NODE_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE (obj, GTK_TYPE_CSS_TRANSIENT_NODE))
#define GTK_CSS_TRANSIENT_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CSS_TRANSIENT_NODE, GtkCssTransientNodeClass))
typedef struct _GtkCssTransientNode GtkCssTransientNode;
typedef struct _GtkCssTransientNodeClass GtkCssTransientNodeClass;
struct _GtkCssTransientNode
{
GtkCssNode node;
};
struct _GtkCssTransientNodeClass
{
GtkCssNodeClass node_class;
};
GType gtk_css_transient_node_get_type (void) G_GNUC_CONST;
GtkCssNode * gtk_css_transient_node_new (GtkCssNode *parent);
G_END_DECLS
#endif /* __GTK_CSS_TRANSIENT_NODE_PRIVATE_H__ */
+2 -3
View File
@@ -39,12 +39,11 @@ gtk_css_value_typed_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
GtkCssCustomProperty *custom = GTK_CSS_CUSTOM_PROPERTY (_gtk_css_style_property_lookup_by_id (property_id));
return _gtk_css_style_funcs_compute_value (provider, style, parent_style, custom->pspec->value_type, value, dependencies);
return _gtk_css_style_funcs_compute_value (provider, style, parent_style, custom->pspec->value_type, value);
}
static gboolean
+2 -10
View File
@@ -57,7 +57,7 @@ _gtk_css_change_for_sibling (GtkCssChange match)
{ GTK_CSS_CHANGE_POSITION, GTK_CSS_CHANGE_SIBLING_POSITION },
{ GTK_CSS_CHANGE_STATE, GTK_CSS_CHANGE_SIBLING_STATE },
{ GTK_CSS_CHANGE_SOURCE, 0 },
{ GTK_CSS_CHANGE_ANIMATE, 0 }
{ GTK_CSS_CHANGE_PARENT_STYLE, 0 }
};
return gtk_css_change_translate (match, table, G_N_ELEMENTS (table));
@@ -76,17 +76,9 @@ _gtk_css_change_for_child (GtkCssChange match)
{ GTK_CSS_CHANGE_SIBLING_POSITION, GTK_CSS_CHANGE_PARENT_SIBLING_POSITION },
{ GTK_CSS_CHANGE_SIBLING_STATE, GTK_CSS_CHANGE_PARENT_SIBLING_STATE },
{ GTK_CSS_CHANGE_SOURCE, 0 },
{ GTK_CSS_CHANGE_ANIMATE, 0 }
{ GTK_CSS_CHANGE_PARENT_STYLE, 0 }
};
return gtk_css_change_translate (match, table, G_N_ELEMENTS (table));
}
GtkCssDependencies
_gtk_css_dependencies_union (GtkCssDependencies first,
GtkCssDependencies second)
{
return (first & ~GTK_CSS_EQUALS_PARENT) | ((first & GTK_CSS_EQUALS_PARENT) ? GTK_CSS_DEPENDS_ON_PARENT : 0)
| (second & ~GTK_CSS_EQUALS_PARENT) | ((second & GTK_CSS_EQUALS_PARENT) ? GTK_CSS_DEPENDS_ON_PARENT : 0);
}
+8 -11
View File
@@ -23,7 +23,9 @@
G_BEGIN_DECLS
/* forward declaration for GtkCssValue */
typedef union _GtkCssMatcher GtkCssMatcher;
typedef struct _GtkCssNode GtkCssNode;
typedef struct _GtkCssNodeDeclaration GtkCssNodeDeclaration;
typedef struct _GtkCssStyle GtkCssStyle;
typedef struct _GtkStyleProviderPrivate GtkStyleProviderPrivate; /* dummy typedef */
@@ -49,7 +51,9 @@ typedef enum { /*< skip >*/
GTK_CSS_CHANGE_PARENT_SIBLING_STATE = (1 << 15),
/* add more */
GTK_CSS_CHANGE_SOURCE = (1 << 16),
GTK_CSS_CHANGE_ANIMATE = (1 << 17),
GTK_CSS_CHANGE_PARENT_STYLE = (1 << 17),
GTK_CSS_CHANGE_TIMESTAMP = (1 << 18),
GTK_CSS_CHANGE_ANIMATIONS = (1 << 19),
GTK_CSS_CHANGE_RESERVED_BIT = (1 << 31) /* Used internally in gtkcssselector.c */
} GtkCssChange;
@@ -63,13 +67,6 @@ typedef enum { /*< skip >*/
GTK_CSS_CHANGE_PARENT_POSITION | GTK_CSS_CHANGE_PARENT_SIBLING_POSITION | \
GTK_CSS_CHANGE_PARENT_STATE | GTK_CSS_CHANGE_PARENT_SIBLING_STATE)
typedef enum /*< skip >*/ {
GTK_CSS_DEPENDS_ON_PARENT = (1 << 0),
GTK_CSS_EQUALS_PARENT = (1 << 1),
GTK_CSS_DEPENDS_ON_COLOR = (1 << 2),
GTK_CSS_DEPENDS_ON_FONT_SIZE = (1 << 3)
} GtkCssDependencies;
/*
* GtkCssAffects:
* @GTK_CSS_AFFECTS_FOREGROUND: The foreground rendering is affected.
@@ -167,6 +164,8 @@ enum { /*< skip >*/
GTK_CSS_PROPERTY_ICON_SHADOW,
GTK_CSS_PROPERTY_ICON_STYLE,
GTK_CSS_PROPERTY_ICON_TRANSFORM,
GTK_CSS_PROPERTY_MIN_WIDTH,
GTK_CSS_PROPERTY_MIN_HEIGHT,
GTK_CSS_PROPERTY_TRANSITION_PROPERTY,
GTK_CSS_PROPERTY_TRANSITION_DURATION,
GTK_CSS_PROPERTY_TRANSITION_TIMING_FUNCTION,
@@ -279,8 +278,6 @@ typedef enum /*< skip >*/ {
GtkCssChange _gtk_css_change_for_sibling (GtkCssChange match);
GtkCssChange _gtk_css_change_for_child (GtkCssChange match);
GtkCssDependencies _gtk_css_dependencies_union (GtkCssDependencies first,
GtkCssDependencies second);
/* for lack of better place to put it */
/* mirror what cairo does */
+2 -4
View File
@@ -39,8 +39,7 @@ gtk_css_value_unset_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
GtkCssStyleProperty *property;
GtkCssValue *unset_value;
@@ -56,8 +55,7 @@ gtk_css_value_unset_compute (GtkCssValue *value,
property_id,
provider,
style,
parent_style,
dependencies);
parent_style);
}
static gboolean
+2 -11
View File
@@ -72,9 +72,6 @@ _gtk_css_value_unref (GtkCssValue *value)
* @provider: Style provider for looking up extra information
* @values: values to compute for
* @parent_values: parent values to use for inherited values
* @dependencies: (out) (allow-none): Set to the dependencies of the
* computed values that indicate when this value needs to be
* recomputed and how.
*
* Converts the specified @value into the computed value for the CSS
* property given by @property_id using the information in @context.
@@ -88,21 +85,15 @@ _gtk_css_value_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies)
GtkCssStyle *parent_style)
{
GtkCssDependencies fallback;
gtk_internal_return_val_if_fail (value != NULL, NULL);
gtk_internal_return_val_if_fail (GTK_IS_STYLE_PROVIDER_PRIVATE (provider), NULL);
gtk_internal_return_val_if_fail (GTK_IS_CSS_STYLE (style), NULL);
gtk_internal_return_val_if_fail (parent_style == NULL || GTK_IS_CSS_STYLE (parent_style), NULL);
if (dependencies == NULL)
dependencies = &fallback;
*dependencies = 0;
return value->class->compute (value, property_id, provider, style, parent_style, dependencies);
return value->class->compute (value, property_id, provider, style, parent_style);
}
gboolean
+2 -4
View File
@@ -44,8 +44,7 @@ struct _GtkCssValueClass {
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies);
GtkCssStyle *parent_style);
gboolean (* equal) (const GtkCssValue *value1,
const GtkCssValue *value2);
GtkCssValue * (* transition) (GtkCssValue *start,
@@ -69,8 +68,7 @@ GtkCssValue *_gtk_css_value_compute (GtkCssValue
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssDependencies *dependencies);
GtkCssStyle *parent_style);
gboolean _gtk_css_value_equal (const GtkCssValue *value1,
const GtkCssValue *value2);
gboolean _gtk_css_value_equal0 (const GtkCssValue *value1,
+300
View File
@@ -0,0 +1,300 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2014 Benjamin Otte <otte@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtkcsswidgetnodeprivate.h"
#include "gtkcontainerprivate.h"
#include "gtkcssanimatedstyleprivate.h"
#include "gtkprivate.h"
#include "gtksettingsprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtkwidgetprivate.h"
/* widgets for special casing go here */
#include "gtkbox.h"
/* When these change we do a full restyling. Otherwise we try to figure out
* if we need to change things. */
#define GTK_CSS_RADICAL_CHANGE (GTK_CSS_CHANGE_NAME | GTK_CSS_CHANGE_CLASS | GTK_CSS_CHANGE_SOURCE | GTK_CSS_CHANGE_PARENT_STYLE)
G_DEFINE_TYPE (GtkCssWidgetNode, gtk_css_widget_node, GTK_TYPE_CSS_NODE)
static void
gtk_css_widget_node_finalize (GObject *object)
{
GtkCssWidgetNode *node = GTK_CSS_WIDGET_NODE (object);
_gtk_bitmask_free (node->accumulated_changes);
G_OBJECT_CLASS (gtk_css_widget_node_parent_class)->finalize (object);
}
static void
gtk_css_widget_node_style_changed (GtkCssNode *cssnode,
GtkCssStyle *old_style,
GtkCssStyle *new_style)
{
GtkCssWidgetNode *node;
GtkBitmask *diff;
node = GTK_CSS_WIDGET_NODE (cssnode);
GTK_CSS_NODE_CLASS (gtk_css_widget_node_parent_class)->style_changed (cssnode, old_style, new_style);
diff = gtk_css_style_get_difference (new_style, old_style);
node->accumulated_changes = _gtk_bitmask_union (node->accumulated_changes, diff);
_gtk_bitmask_free (diff);
}
static gboolean
gtk_css_widget_node_queue_callback (GtkWidget *widget,
GdkFrameClock *frame_clock,
gpointer user_data)
{
GtkCssNode *node = user_data;
gtk_css_node_invalidate_frame_clock (node, TRUE);
_gtk_container_queue_restyle (GTK_CONTAINER (widget));
return G_SOURCE_CONTINUE;
}
static void
gtk_css_widget_node_queue_validate (GtkCssNode *node)
{
GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
if (GTK_IS_RESIZE_CONTAINER (widget_node->widget))
widget_node->validate_cb_id = gtk_widget_add_tick_callback (widget_node->widget,
gtk_css_widget_node_queue_callback,
node,
NULL);
G_GNUC_END_IGNORE_DEPRECATIONS
}
static void
gtk_css_widget_node_dequeue_validate (GtkCssNode *node)
{
GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
if (GTK_IS_RESIZE_CONTAINER (widget_node->widget))
gtk_widget_remove_tick_callback (widget_node->widget,
widget_node->validate_cb_id);
G_GNUC_END_IGNORE_DEPRECATIONS
}
static void
gtk_css_widget_node_validate (GtkCssNode *node)
{
GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
GtkStyleContext *context;
if (widget_node->widget == NULL)
return;
context = _gtk_widget_peek_style_context (widget_node->widget);
if (context)
gtk_style_context_validate (context, widget_node->accumulated_changes);
else
_gtk_widget_style_context_invalidated (widget_node->widget);
_gtk_bitmask_free (widget_node->accumulated_changes);
widget_node->accumulated_changes = _gtk_bitmask_new ();
}
typedef GtkWidgetPath * (* GetPathForChildFunc) (GtkContainer *, GtkWidget *);
static gboolean
widget_needs_widget_path (GtkWidget *widget)
{
static GetPathForChildFunc funcs[2];
GtkWidget *parent;
GetPathForChildFunc parent_func;
guint i;
if (G_UNLIKELY (funcs[0] == NULL))
{
i = 0;
funcs[i++] = GTK_CONTAINER_CLASS (g_type_class_ref (GTK_TYPE_CONTAINER))->get_path_for_child;
funcs[i++] = GTK_CONTAINER_CLASS (g_type_class_ref (GTK_TYPE_BOX))->get_path_for_child;
g_assert (i == G_N_ELEMENTS (funcs));
}
parent = gtk_widget_get_parent (widget);
if (parent == NULL)
return FALSE;
parent_func = GTK_CONTAINER_GET_CLASS (GTK_CONTAINER (parent))->get_path_for_child;
for (i = 0; i < G_N_ELEMENTS (funcs); i++)
{
if (funcs[i] == parent_func)
return FALSE;
}
return TRUE;
}
gboolean
gtk_css_widget_node_init_matcher (GtkCssNode *node,
GtkCssMatcher *matcher)
{
GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
if (widget_node->widget == NULL)
return FALSE;
if (!widget_needs_widget_path (widget_node->widget))
return GTK_CSS_NODE_CLASS (gtk_css_widget_node_parent_class)->init_matcher (node, matcher);
return _gtk_css_matcher_init (matcher,
gtk_widget_get_path (widget_node->widget),
gtk_css_node_get_declaration (node));
}
static GtkWidgetPath *
gtk_css_widget_node_create_widget_path (GtkCssNode *node)
{
GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
GtkWidgetPath *path;
guint length;
if (widget_node->widget == NULL)
path = gtk_widget_path_new ();
else
path = _gtk_widget_create_path (widget_node->widget);
length = gtk_widget_path_length (path);
if (length > 0)
{
gtk_css_node_declaration_add_to_widget_path (gtk_css_node_get_declaration (node),
path,
length - 1);
}
return path;
}
static const GtkWidgetPath *
gtk_css_widget_node_get_widget_path (GtkCssNode *node)
{
GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
if (widget_node->widget == NULL)
return NULL;
return gtk_widget_get_path (widget_node->widget);
}
static GtkStyleProviderPrivate *
gtk_css_widget_node_get_style_provider (GtkCssNode *node)
{
GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
GtkStyleContext *context;
GtkStyleCascade *cascade;
if (widget_node->widget == NULL)
return NULL;
context = _gtk_widget_peek_style_context (widget_node->widget);
if (context)
return gtk_style_context_get_style_provider (context);
cascade = _gtk_settings_get_style_cascade (gtk_widget_get_settings (widget_node->widget),
gtk_widget_get_scale_factor (widget_node->widget));
return GTK_STYLE_PROVIDER_PRIVATE (cascade);
}
static GdkFrameClock *
gtk_css_widget_node_get_frame_clock (GtkCssNode *node)
{
GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
gboolean animate;
if (widget_node->widget == NULL)
return NULL;
g_object_get (gtk_widget_get_settings (widget_node->widget),
"gtk-enable-animations", &animate,
NULL);
if (animate == FALSE)
return NULL;
return gtk_widget_get_frame_clock (widget_node->widget);
}
static void
gtk_css_widget_node_class_init (GtkCssWidgetNodeClass *klass)
{
GtkCssNodeClass *node_class = GTK_CSS_NODE_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gtk_css_widget_node_finalize;
node_class->validate = gtk_css_widget_node_validate;
node_class->queue_validate = gtk_css_widget_node_queue_validate;
node_class->dequeue_validate = gtk_css_widget_node_dequeue_validate;
node_class->init_matcher = gtk_css_widget_node_init_matcher;
node_class->create_widget_path = gtk_css_widget_node_create_widget_path;
node_class->get_widget_path = gtk_css_widget_node_get_widget_path;
node_class->get_style_provider = gtk_css_widget_node_get_style_provider;
node_class->get_frame_clock = gtk_css_widget_node_get_frame_clock;
node_class->style_changed = gtk_css_widget_node_style_changed;
}
static void
gtk_css_widget_node_init (GtkCssWidgetNode *node)
{
node->accumulated_changes = _gtk_bitmask_new ();
}
GtkCssNode *
gtk_css_widget_node_new (GtkWidget *widget)
{
GtkCssWidgetNode *result;
gtk_internal_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
result = g_object_new (GTK_TYPE_CSS_WIDGET_NODE, NULL);
result->widget = widget;
gtk_css_node_set_visible (GTK_CSS_NODE (result),
gtk_widget_get_visible (widget));
return GTK_CSS_NODE (result);
}
void
gtk_css_widget_node_widget_destroyed (GtkCssWidgetNode *node)
{
gtk_internal_return_if_fail (GTK_IS_CSS_WIDGET_NODE (node));
gtk_internal_return_if_fail (node->widget != NULL);
node->widget = NULL;
/* Contents of this node are now undefined.
* So we don't clear the style or anything.
*/
}
GtkWidget *
gtk_css_widget_node_get_widget (GtkCssWidgetNode *node)
{
gtk_internal_return_val_if_fail (GTK_IS_CSS_WIDGET_NODE (node), NULL);
return node->widget;
}
+60
View File
@@ -0,0 +1,60 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2014 Benjamin Otte <otte@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_CSS_WIDGET_NODE_PRIVATE_H__
#define __GTK_CSS_WIDGET_NODE_PRIVATE_H__
#include "gtkcssnodeprivate.h"
#include "gtkwidget.h"
G_BEGIN_DECLS
#define GTK_TYPE_CSS_WIDGET_NODE (gtk_css_widget_node_get_type ())
#define GTK_CSS_WIDGET_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GTK_TYPE_CSS_WIDGET_NODE, GtkCssWidgetNode))
#define GTK_CSS_WIDGET_NODE_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST (cls, GTK_TYPE_CSS_WIDGET_NODE, GtkCssWidgetNodeClass))
#define GTK_IS_CSS_WIDGET_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GTK_TYPE_CSS_WIDGET_NODE))
#define GTK_IS_CSS_WIDGET_NODE_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE (obj, GTK_TYPE_CSS_WIDGET_NODE))
#define GTK_CSS_WIDGET_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CSS_WIDGET_NODE, GtkCssWidgetNodeClass))
typedef struct _GtkCssWidgetNode GtkCssWidgetNode;
typedef struct _GtkCssWidgetNodeClass GtkCssWidgetNodeClass;
struct _GtkCssWidgetNode
{
GtkCssNode node;
GtkWidget *widget;
guint validate_cb_id;
GtkBitmask *accumulated_changes;
};
struct _GtkCssWidgetNodeClass
{
GtkCssNodeClass node_class;
};
GType gtk_css_widget_node_get_type (void) G_GNUC_CONST;
GtkCssNode * gtk_css_widget_node_new (GtkWidget *widget);
void gtk_css_widget_node_widget_destroyed (GtkCssWidgetNode *node);
GtkWidget * gtk_css_widget_node_get_widget (GtkCssWidgetNode *node);
G_END_DECLS
#endif /* __GTK_CSS_WIDGET_NODE_PRIVATE_H__ */
+195 -126
View File
@@ -34,6 +34,7 @@
#include "gtkbindings.h"
#include "gtkcelleditable.h"
#include "gtkclipboard.h"
#include "gtkcssnodeutilsprivate.h"
#include "gtkdebug.h"
#include "gtkdnd.h"
#include "gtkentry.h"
@@ -174,6 +175,8 @@ struct _GtkEntryPrivate
GtkGesture *drag_gesture;
GtkGesture *multipress_gesture;
GtkCssNode *progress_node;
gfloat xalign;
gint ascent; /* font ascent in pango units */
@@ -235,12 +238,12 @@ struct _GtkEntryPrivate
struct _EntryIconInfo
{
GdkWindow *window;
GtkCssNode *css_node;
gchar *tooltip;
guint insensitive : 1;
guint nonactivatable : 1;
guint prelight : 1;
guint in_drag : 1;
guint pressed : 1;
GdkDragAction actions;
GtkTargetList *target_list;
@@ -1509,13 +1512,17 @@ gtk_entry_class_init (GtkEntryClass *class)
* icons prelight on mouseover.
*
* Since: 2.16
*
* Deprecated: 3.18: Activatable icons are always prelit on hover.
* Just don't style the :hover style if you don't want them to
* look different.
*/
gtk_widget_class_install_style_property (widget_class,
g_param_spec_boolean ("icon-prelight",
P_("Icon Prelight"),
P_("Whether activatable icons should prelight when hovered"),
TRUE,
GTK_PARAM_READABLE|G_PARAM_EXPLICIT_NOTIFY));
GTK_PARAM_READABLE|G_PARAM_EXPLICIT_NOTIFY|G_PARAM_DEPRECATED));
/**
* GtkEntry:progress-border:
@@ -2691,7 +2698,7 @@ find_invisible_char (GtkWidget *widget)
static void
gtk_entry_init (GtkEntry *entry)
{
GtkStyleContext *context;
GtkCssNode *widget_node;
GtkEntryPrivate *priv;
entry->priv = gtk_entry_get_instance_private (entry);
@@ -2735,8 +2742,8 @@ gtk_entry_init (GtkEntry *entry)
g_signal_connect (priv->im_context, "delete-surrounding",
G_CALLBACK (gtk_entry_delete_surrounding_cb), entry);
context = gtk_widget_get_style_context (GTK_WIDGET (entry));
gtk_style_context_add_class (context, GTK_STYLE_CLASS_ENTRY);
widget_node = gtk_widget_get_css_node (GTK_WIDGET (entry));
gtk_css_node_add_class (widget_node, GTK_STYLE_CLASS_ENTRY);
gtk_entry_update_cached_style_values (entry);
@@ -2753,6 +2760,16 @@ gtk_entry_init (GtkEntry *entry)
G_CALLBACK (gtk_entry_multipress_gesture_pressed), entry);
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (priv->multipress_gesture), 0);
gtk_gesture_single_set_exclusive (GTK_GESTURE_SINGLE (priv->multipress_gesture), TRUE);
priv->progress_node = gtk_css_node_new ();
gtk_css_node_set_widget_type (priv->progress_node, GTK_TYPE_ENTRY);
gtk_css_node_add_class (priv->progress_node, GTK_STYLE_CLASS_ENTRY);
gtk_css_node_add_class (priv->progress_node, GTK_STYLE_CLASS_PROGRESSBAR);
gtk_css_node_set_parent (priv->progress_node, widget_node);
gtk_css_node_set_state (priv->progress_node, gtk_css_node_get_state (widget_node));
g_signal_connect_object (priv->progress_node, "style-changed", G_CALLBACK (gtk_css_node_style_changed_for_widget), entry, 0);
g_object_unref (priv->progress_node);
}
static void
@@ -2791,47 +2808,6 @@ gtk_entry_ensure_text_handles (GtkEntry *entry)
G_CALLBACK (gtk_entry_handle_drag_finished), entry);
}
static void
gtk_entry_prepare_context_for_icon (GtkEntry *entry,
GtkStyleContext *context,
GtkEntryIconPosition icon_pos)
{
GtkEntryPrivate *priv = entry->priv;
EntryIconInfo *icon_info = priv->icons[icon_pos];
GtkWidget *widget;
GtkStateFlags state;
widget = GTK_WIDGET (entry);
state = gtk_widget_get_state_flags (widget);
state &= ~(GTK_STATE_FLAG_PRELIGHT);
if ((state & GTK_STATE_FLAG_INSENSITIVE) || icon_info->insensitive)
state |= GTK_STATE_FLAG_INSENSITIVE;
else if (icon_info->prelight)
state |= GTK_STATE_FLAG_PRELIGHT;
gtk_style_context_save (context);
gtk_style_context_set_state (context, state);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_IMAGE);
if (gtk_widget_get_direction (GTK_WIDGET (entry)) == GTK_TEXT_DIR_RTL)
{
if (icon_pos == GTK_ENTRY_ICON_PRIMARY)
gtk_style_context_add_class (context, GTK_STYLE_CLASS_RIGHT);
else
gtk_style_context_add_class (context, GTK_STYLE_CLASS_LEFT);
}
else
{
if (icon_pos == GTK_ENTRY_ICON_PRIMARY)
gtk_style_context_add_class (context, GTK_STYLE_CLASS_LEFT);
else
gtk_style_context_add_class (context, GTK_STYLE_CLASS_RIGHT);
}
}
static gint
get_icon_width (GtkEntry *entry,
GtkEntryIconPosition icon_pos)
@@ -2847,7 +2823,7 @@ get_icon_width (GtkEntry *entry,
return 0;
context = gtk_widget_get_style_context (GTK_WIDGET (entry));
gtk_entry_prepare_context_for_icon (entry, context, icon_pos);
gtk_style_context_save_to_node (context, priv->icons[icon_pos]->css_node);
state = gtk_style_context_get_state (context);
gtk_style_context_get_padding (context, state, &padding);
@@ -3002,6 +2978,8 @@ gtk_entry_finalize (GObject *object)
{
if ((icon_info = priv->icons[i]) != NULL)
{
g_object_unref (icon_info->css_node);
if (icon_info->target_list != NULL)
{
gtk_target_list_unref (icon_info->target_list);
@@ -3213,12 +3191,85 @@ realize_icon_info (GtkWidget *widget,
}
static void
update_state_for_icon_infos (GtkWidget *widget)
{
GtkCssNode *cssnode, *first_node, *last_node;
GtkEntry *entry = GTK_ENTRY (widget);
GtkEntryPrivate *priv = entry->priv;
GtkStateFlags state;
#define NOT_INHERITED (GTK_STATE_FLAG_PRELIGHT | GTK_STATE_FLAG_ACTIVE)
cssnode = gtk_widget_get_css_node (widget);
state = gtk_widget_get_state_flags (widget);
if (priv->icons[GTK_ENTRY_ICON_PRIMARY])
gtk_css_node_set_state (priv->icons[GTK_ENTRY_ICON_PRIMARY]->css_node,
(state & ~NOT_INHERITED)
| (gtk_css_node_get_state (priv->icons[GTK_ENTRY_ICON_PRIMARY]->css_node) & NOT_INHERITED)
| (priv->icons[GTK_ENTRY_ICON_PRIMARY]->insensitive ? GTK_STATE_FLAG_INSENSITIVE : 0));
if (priv->icons[GTK_ENTRY_ICON_SECONDARY])
gtk_css_node_set_state (priv->icons[GTK_ENTRY_ICON_SECONDARY]->css_node,
(state & ~NOT_INHERITED)
| (gtk_css_node_get_state (priv->icons[GTK_ENTRY_ICON_SECONDARY]->css_node) & NOT_INHERITED)
| (priv->icons[GTK_ENTRY_ICON_SECONDARY]->insensitive ? GTK_STATE_FLAG_INSENSITIVE : 0));
if (state & GTK_STATE_FLAG_DIR_RTL)
{
first_node = priv->icons[GTK_ENTRY_ICON_SECONDARY] ? priv->icons[GTK_ENTRY_ICON_SECONDARY]->css_node : NULL;
last_node = priv->icons[GTK_ENTRY_ICON_PRIMARY] ? priv->icons[GTK_ENTRY_ICON_PRIMARY]->css_node : NULL;
}
else
{
first_node = priv->icons[GTK_ENTRY_ICON_PRIMARY] ? priv->icons[GTK_ENTRY_ICON_PRIMARY]->css_node : NULL;
last_node = priv->icons[GTK_ENTRY_ICON_SECONDARY] ? priv->icons[GTK_ENTRY_ICON_SECONDARY]->css_node : NULL;
}
if (first_node)
{
if (first_node != gtk_css_node_get_first_child (cssnode))
gtk_css_node_set_before (first_node, gtk_css_node_get_first_child (cssnode));
gtk_css_node_remove_class (first_node, GTK_STYLE_CLASS_RIGHT);
gtk_css_node_add_class (first_node, GTK_STYLE_CLASS_LEFT);
}
if (last_node)
{
if (last_node != gtk_css_node_get_last_child (cssnode))
gtk_css_node_set_after (last_node, gtk_css_node_get_last_child (cssnode));
gtk_css_node_remove_class (last_node, GTK_STYLE_CLASS_LEFT);
gtk_css_node_add_class (last_node, GTK_STYLE_CLASS_RIGHT);
}
#undef NOT_INHERITED
}
static void
icon_node_style_changed_cb (GtkCssNode *node,
GtkCssStyle *old_style,
GtkCssStyle *new_style,
GtkWidget *widget)
{
GtkEntry *entry = GTK_ENTRY (widget);
GtkEntryPrivate *priv = entry->priv;
GtkIconHelper *icon_helper;
gtk_css_node_style_changed_for_widget (node, old_style, new_style, widget);
if (priv->icons[GTK_ENTRY_ICON_PRIMARY] && priv->icons[GTK_ENTRY_ICON_PRIMARY]->css_node == node)
icon_helper = priv->icons[GTK_ENTRY_ICON_PRIMARY]->icon_helper;
else
icon_helper = priv->icons[GTK_ENTRY_ICON_SECONDARY]->icon_helper;
_gtk_icon_helper_invalidate (icon_helper);
}
static EntryIconInfo*
construct_icon_info (GtkWidget *widget,
GtkEntryIconPosition icon_pos)
{
GtkEntry *entry = GTK_ENTRY (widget);
GtkEntryPrivate *priv = entry->priv;
GtkCssNode *widget_node;
EntryIconInfo *icon_info;
g_return_val_if_fail (priv->icons[icon_pos] == NULL, NULL);
@@ -3229,6 +3280,14 @@ construct_icon_info (GtkWidget *widget,
icon_info->icon_helper = _gtk_icon_helper_new ();
_gtk_icon_helper_set_force_scale_pixbuf (icon_info->icon_helper, TRUE);
icon_info->css_node = gtk_css_node_new ();
widget_node = gtk_widget_get_css_node (widget);
gtk_css_node_add_class (icon_info->css_node, GTK_STYLE_CLASS_ENTRY);
gtk_css_node_add_class (icon_info->css_node, GTK_STYLE_CLASS_IMAGE);
gtk_css_node_set_parent (icon_info->css_node, widget_node);
g_signal_connect_object (icon_info->css_node, "style-changed", G_CALLBACK (icon_node_style_changed_cb), widget, 0);
update_state_for_icon_infos (widget);
if (gtk_widget_get_realized (widget))
realize_icon_info (widget, icon_pos);
@@ -3429,14 +3488,19 @@ _gtk_entry_get_borders (GtkEntry *entry,
}
static void
gtk_entry_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural)
gtk_entry_get_content_width (GtkCssNode *cssnode,
GtkOrientation orientation,
gint for_size,
gint *minimum,
gint *natural,
gint *minimum_baseline,
gint *natural_baseline,
gpointer data)
{
GtkEntry *entry = GTK_ENTRY (widget);
GtkWidget *widget = GTK_WIDGET(data);
GtkEntry *entry = GTK_ENTRY (data);
GtkEntryPrivate *priv = entry->priv;
PangoFontMetrics *metrics;
GtkBorder borders;
PangoContext *context;
gint icon_width, i;
gint min, nat;
@@ -3444,8 +3508,6 @@ gtk_entry_get_preferred_width (GtkWidget *widget,
gint digit_width;
gint char_pixels;
_gtk_entry_get_borders (entry, &borders);
context = gtk_widget_get_pango_context (widget);
metrics = pango_context_get_metrics (context,
pango_context_get_font_description (context),
@@ -3458,14 +3520,14 @@ gtk_entry_get_preferred_width (GtkWidget *widget,
pango_font_metrics_unref (metrics);
if (priv->width_chars < 0)
min = MIN_ENTRY_WIDTH + borders.left + borders.right;
min = MIN_ENTRY_WIDTH;
else
min = char_pixels * priv->width_chars + borders.left + borders.right;
min = char_pixels * priv->width_chars;
if (priv->max_width_chars < 0)
nat = MIN_ENTRY_WIDTH + borders.left + borders.right;
nat = MIN_ENTRY_WIDTH;
else
nat = char_pixels * priv->max_width_chars + borders.left + borders.right;
nat = char_pixels * priv->max_width_chars;
icon_width = 0;
for (i = 0; i < MAX_ICONS; i++)
@@ -3479,17 +3541,33 @@ gtk_entry_get_preferred_width (GtkWidget *widget,
}
static void
gtk_entry_get_preferred_height_and_baseline_for_width (GtkWidget *widget,
gint width,
gint *minimum,
gint *natural,
gint *minimum_baseline,
gint *natural_baseline)
gtk_entry_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkEntry *entry = GTK_ENTRY (widget);
gtk_css_node_get_preferred_size (gtk_widget_get_css_node (widget),
GTK_ORIENTATION_HORIZONTAL,
-1,
minimum, natural,
NULL, NULL,
gtk_entry_get_content_width,
widget);
}
static void
gtk_entry_get_content_height (GtkCssNode *cssnode,
GtkOrientation orientation,
gint for_size,
gint *minimum,
gint *natural,
gint *minimum_baseline,
gint *natural_baseline,
gpointer data)
{
GtkWidget *widget = GTK_WIDGET(data);
GtkEntry *entry = GTK_ENTRY (data);
GtkEntryPrivate *priv = entry->priv;
PangoFontMetrics *metrics;
GtkBorder borders;
PangoContext *context;
gint height, baseline;
PangoLayout *layout;
@@ -3505,14 +3583,11 @@ gtk_entry_get_preferred_height_and_baseline_for_width (GtkWidget *widget,
priv->descent = pango_font_metrics_get_descent (metrics);
pango_font_metrics_unref (metrics);
_gtk_entry_get_borders (entry, &borders);
pango_layout_get_pixel_size (layout, NULL, &height);
height = MAX (height, PANGO_PIXELS (priv->ascent + priv->descent));
height += borders.top + borders.bottom;
baseline = pango_layout_get_baseline (layout) / PANGO_SCALE;
baseline += borders.top;
*minimum = height;
*natural = height;
@@ -3522,6 +3597,23 @@ gtk_entry_get_preferred_height_and_baseline_for_width (GtkWidget *widget,
*natural_baseline = baseline;
}
static void
gtk_entry_get_preferred_height_and_baseline_for_width (GtkWidget *widget,
gint width,
gint *minimum,
gint *natural,
gint *minimum_baseline,
gint *natural_baseline)
{
gtk_css_node_get_preferred_size (gtk_widget_get_css_node (widget),
GTK_ORIENTATION_VERTICAL,
width,
minimum, natural,
minimum_baseline, natural_baseline,
gtk_entry_get_content_height,
widget);
}
static void
gtk_entry_get_preferred_height (GtkWidget *widget,
gint *minimum,
@@ -3736,7 +3828,6 @@ should_prelight (GtkEntry *entry,
{
GtkEntryPrivate *priv = entry->priv;
EntryIconInfo *icon_info = priv->icons[icon_pos];
gboolean prelight;
if (!icon_info)
return FALSE;
@@ -3744,14 +3835,7 @@ should_prelight (GtkEntry *entry,
if (icon_info->nonactivatable && icon_info->target_list == NULL)
return FALSE;
if (icon_info->pressed)
return FALSE;
gtk_widget_style_get (GTK_WIDGET (entry),
"icon-prelight", &prelight,
NULL);
return prelight;
return TRUE;
}
static void
@@ -3782,7 +3866,7 @@ draw_icon (GtkWidget *widget,
gtk_cairo_transform_to_window (cr, widget, icon_info->window);
context = gtk_widget_get_style_context (widget);
gtk_entry_prepare_context_for_icon (entry, context, icon_pos);
gtk_style_context_save_to_node (context, priv->icons[icon_pos]->css_node);
_gtk_icon_helper_get_size (icon_info->icon_helper, context,
&pix_width, &pix_height);
state = gtk_style_context_get_state (context);
@@ -3839,18 +3923,6 @@ gtk_entry_draw_frame (GtkWidget *widget,
cairo_restore (cr);
}
static void
gtk_entry_prepare_context_for_progress (GtkEntry *entry,
GtkStyleContext *context)
{
GtkEntryPrivate *private = entry->priv;
gtk_style_context_save (context);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_PROGRESSBAR);
if (private->progress_pulse_mode)
gtk_style_context_add_class (context, GTK_STYLE_CLASS_PULSE);
}
static void
get_progress_area (GtkWidget *widget,
gint *x,
@@ -3899,7 +3971,7 @@ get_progress_area (GtkWidget *widget,
}
}
gtk_entry_prepare_context_for_progress (entry, context);
gtk_style_context_save_to_node (context, private->progress_node);
gtk_style_context_get_margin (context, state, &margin);
gtk_style_context_restore (context);
@@ -3953,7 +4025,7 @@ gtk_entry_draw_progress (GtkWidget *widget,
if ((width <= 0) || (height <= 0))
return;
gtk_entry_prepare_context_for_progress (entry, context);
gtk_style_context_save_to_node (context, entry->priv->progress_node);
gtk_render_background (context, cr, x, y, width, height);
gtk_render_frame (context, cr, x, y, width, height);
@@ -4023,10 +4095,7 @@ gtk_entry_enter_notify (GtkWidget *widget,
if (icon_info != NULL && event->window == icon_info->window)
{
if (should_prelight (entry, i))
{
icon_info->prelight = TRUE;
gtk_widget_queue_draw (widget);
}
gtk_css_node_add_state (icon_info->css_node, GTK_STATE_FLAG_PRELIGHT);
break;
}
@@ -4051,13 +4120,10 @@ gtk_entry_leave_notify (GtkWidget *widget,
{
/* a grab means that we may never see the button release */
if (event->mode == GDK_CROSSING_GRAB || event->mode == GDK_CROSSING_GTK_GRAB)
icon_info->pressed = FALSE;
gtk_css_node_remove_state (icon_info->css_node, GTK_STATE_FLAG_ACTIVE);
if (should_prelight (entry, i))
{
icon_info->prelight = FALSE;
gtk_widget_queue_draw (widget);
}
gtk_css_node_remove_state (icon_info->css_node, GTK_STATE_FLAG_PRELIGHT);
break;
}
@@ -4297,15 +4363,10 @@ gtk_entry_event (GtkWidget *widget,
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
if (should_prelight (GTK_ENTRY (widget), i))
{
icon_info->prelight = FALSE;
gtk_widget_queue_draw (widget);
}
priv->start_x = x;
priv->start_y = y;
icon_info->pressed = TRUE;
gtk_css_node_add_state (icon_info->css_node, GTK_STATE_FLAG_ACTIVE);
icon_info->device = device;
if (!icon_info->nonactivatable)
@@ -4318,7 +4379,7 @@ gtk_entry_event (GtkWidget *widget,
break;
/* Fall through */
case GDK_MOTION_NOTIFY:
if (icon_info->pressed &&
if ((gtk_css_node_get_state (icon_info->css_node) & GTK_STATE_FLAG_ACTIVE) &&
icon_info->target_list != NULL &&
gtk_drag_check_threshold (widget,
priv->start_x,
@@ -4344,18 +4405,9 @@ gtk_entry_event (GtkWidget *widget,
icon_info->current_sequence = NULL;
/* Fall through */
case GDK_BUTTON_RELEASE:
icon_info->pressed = FALSE;
gtk_css_node_remove_state (icon_info->css_node, GTK_STATE_FLAG_ACTIVE);
icon_info->device = NULL;
if (should_prelight (GTK_ENTRY (widget), i) &&
x >= 0 && y >= 0 &&
x < gdk_window_get_width (icon_info->window) &&
y < gdk_window_get_height (icon_info->window))
{
icon_info->prelight = TRUE;
gtk_widget_queue_draw (widget);
}
if (!icon_info->nonactivatable)
g_signal_emit (widget, signals[ICON_RELEASE], 0, i, event);
@@ -5075,6 +5127,8 @@ gtk_entry_state_flags_changed (GtkWidget *widget,
gtk_editable_select_region (GTK_EDITABLE (entry), priv->current_pos, priv->current_pos);
}
update_state_for_icon_infos (widget);
gtk_entry_update_cached_style_values (entry);
}
@@ -6499,7 +6553,7 @@ gtk_entry_draw_text (GtkEntry *entry,
gtk_style_context_get_color (context, state, &text_color);
/* Get foreground color for progressbars */
gtk_entry_prepare_context_for_progress (entry, context);
gtk_style_context_save_to_node (context, priv->progress_node);
gtk_style_context_get_color (context, state, &bar_text_color);
gtk_style_context_restore (context);
@@ -7439,6 +7493,8 @@ gtk_entry_clear (GtkEntry *entry,
if (GDK_IS_WINDOW (icon_info->window))
gdk_window_hide (icon_info->window);
gtk_css_node_set_visible (icon_info->css_node, FALSE);
storage_type = _gtk_icon_helper_get_storage_type (icon_info->icon_helper);
switch (storage_type)
@@ -7486,7 +7542,7 @@ gtk_entry_ensure_pixbuf (GtkEntry *entry,
GdkPixbuf *pix;
context = gtk_widget_get_style_context (GTK_WIDGET (entry));
gtk_entry_prepare_context_for_icon (entry, context, icon_pos);
gtk_style_context_save_to_node (context, priv->icons[icon_pos]->css_node);
pix = _gtk_icon_helper_ensure_pixbuf (icon_info->icon_helper,
context);
@@ -8496,6 +8552,8 @@ gtk_entry_set_icon_from_pixbuf (GtkEntry *entry,
_gtk_icon_helper_set_icon_size (icon_info->icon_helper,
GTK_ICON_SIZE_MENU);
gtk_css_node_set_visible (icon_info->css_node, TRUE);
if (icon_pos == GTK_ENTRY_ICON_PRIMARY)
{
g_object_notify (G_OBJECT (entry), "primary-icon-pixbuf");
@@ -8562,6 +8620,8 @@ gtk_entry_set_icon_from_stock (GtkEntry *entry,
{
_gtk_icon_helper_set_stock_id (icon_info->icon_helper, new_id, GTK_ICON_SIZE_MENU);
gtk_css_node_set_visible (icon_info->css_node, TRUE);
if (icon_pos == GTK_ENTRY_ICON_PRIMARY)
{
g_object_notify (G_OBJECT (entry), "primary-icon-stock");
@@ -8629,6 +8689,8 @@ gtk_entry_set_icon_from_icon_name (GtkEntry *entry,
{
_gtk_icon_helper_set_icon_name (icon_info->icon_helper, new_name, GTK_ICON_SIZE_MENU);
gtk_css_node_set_visible (icon_info->css_node, TRUE);
if (icon_pos == GTK_ENTRY_ICON_PRIMARY)
{
g_object_notify (G_OBJECT (entry), "primary-icon-name");
@@ -8695,6 +8757,8 @@ gtk_entry_set_icon_from_gicon (GtkEntry *entry,
{
_gtk_icon_helper_set_gicon (icon_info->icon_helper, icon, GTK_ICON_SIZE_MENU);
gtk_css_node_set_visible (icon_info->css_node, TRUE);
if (icon_pos == GTK_ENTRY_ICON_PRIMARY)
{
g_object_notify (G_OBJECT (entry), "primary-icon-gicon");
@@ -8961,14 +9025,15 @@ gtk_entry_set_icon_sensitive (GtkEntry *entry,
{
icon_info->insensitive = !sensitive;
icon_info->pressed = FALSE;
icon_info->prelight = FALSE;
gtk_css_node_remove_state (icon_info->css_node, GTK_STATE_FLAG_PRELIGHT | GTK_STATE_FLAG_ACTIVE);
if (!gtk_widget_is_sensitive (GTK_WIDGET (entry)) || icon_info->insensitive)
gtk_css_node_add_state (icon_info->css_node, GTK_STATE_FLAG_INSENSITIVE);
else
gtk_css_node_remove_state (icon_info->css_node, GTK_STATE_FLAG_INSENSITIVE);
if (gtk_widget_get_realized (GTK_WIDGET (entry)))
update_cursors (GTK_WIDGET (entry));
gtk_widget_queue_draw (GTK_WIDGET (entry));
g_object_notify (G_OBJECT (entry),
icon_pos == GTK_ENTRY_ICON_PRIMARY ? "primary-icon-sensitive" : "secondary-icon-sensitive");
}
@@ -9480,7 +9545,7 @@ check_undo_icon_grab (GtkEntry *entry,
!gtk_widget_device_is_shadowed (GTK_WIDGET (entry), info->device))
return;
info->pressed = FALSE;
gtk_css_node_remove_state (info->css_node, GTK_STATE_FLAG_ACTIVE);
info->current_sequence = NULL;
info->device = NULL;
}
@@ -10554,6 +10619,8 @@ gtk_entry_start_pulse_mode (GtkEntry *entry)
priv->progress_pulse_mode = TRUE;
priv->tick_id = gtk_widget_add_tick_callback (GTK_WIDGET (entry), tick_cb, NULL, NULL);
gtk_css_node_add_class (priv->progress_node, GTK_STYLE_CLASS_PULSE);
priv->progress_fraction = 0.0;
priv->progress_pulse_way_back = FALSE;
priv->progress_pulse_current = 0.0;
@@ -10574,6 +10641,8 @@ gtk_entry_stop_pulse_mode (GtkEntry *entry)
priv->progress_pulse_mode = FALSE;
gtk_widget_remove_tick_callback (GTK_WIDGET (entry), priv->tick_id);
priv->tick_id = 0;
gtk_css_node_remove_class (priv->progress_node, GTK_STYLE_CLASS_PULSE);
}
}
+2
View File
@@ -4822,6 +4822,8 @@ gtk_notebook_redraw_tabs (GtkNotebook *notebook)
redraw_rect.y = border;
gtk_widget_get_allocation (widget, &allocation);
if (allocation.width <= 1)
return;
get_padding_and_border (notebook, &padding);
+7 -7
View File
@@ -2823,10 +2823,11 @@ _gtk_range_get_wheel_delta (GtkRange *range,
GtkRangePrivate *priv = range->priv;
GtkAdjustment *adjustment = priv->adjustment;
gdouble dx, dy;
gdouble delta;
gdouble delta = 0;
gdouble page_size;
gdouble page_increment;
gdouble scroll_unit;
GdkScrollDirection direction;
page_size = gtk_adjustment_get_page_size (adjustment);
page_increment = gtk_adjustment_get_page_increment (adjustment);
@@ -2842,16 +2843,15 @@ _gtk_range_get_wheel_delta (GtkRange *range,
scroll_unit = 1;
#endif
if (dx != 0 &&
gtk_orientable_get_orientation (GTK_ORIENTABLE (range)) == GTK_ORIENTATION_HORIZONTAL)
delta = dx * scroll_unit;
if (gtk_orientable_get_orientation (GTK_ORIENTABLE (range)) == GTK_ORIENTATION_HORIZONTAL)
delta = - (dx ? dx : dy) * scroll_unit;
else
delta = dy * scroll_unit;
}
else
else if (gdk_event_get_scroll_direction ((GdkEvent *) event, &direction))
{
if (event->direction == GDK_SCROLL_UP ||
event->direction == GDK_SCROLL_LEFT)
if (direction == GDK_SCROLL_UP ||
direction == GDK_SCROLL_RIGHT)
delta = - scroll_unit;
else
delta = scroll_unit;
+13 -11
View File
@@ -1077,7 +1077,6 @@ gtk_do_render_icon_pixbuf (GtkStyleContext *context,
GdkPixbuf *scaled;
GdkPixbuf *stated;
GdkPixbuf *base_pixbuf;
GtkStateFlags state;
gint width = 1;
gint height = 1;
cairo_t *cr;
@@ -1089,8 +1088,6 @@ gtk_do_render_icon_pixbuf (GtkStyleContext *context,
base_pixbuf = gtk_icon_source_get_pixbuf (source);
G_GNUC_END_IGNORE_DEPRECATIONS;
state = gtk_style_context_get_state (context);
g_return_val_if_fail (base_pixbuf != NULL, NULL);
if (size != (GtkIconSize) -1 &&
@@ -1122,9 +1119,9 @@ gtk_do_render_icon_pixbuf (GtkStyleContext *context,
image_effect = _gtk_css_image_effect_value_get
(_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_GTK_IMAGE_EFFECT));
if (image_effect == GTK_CSS_IMAGE_EFFECT_DIM ||
state & GTK_STATE_FLAG_INSENSITIVE)
switch (image_effect)
{
case GTK_CSS_IMAGE_EFFECT_DIM:
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
gdk_pixbuf_get_width (scaled),
gdk_pixbuf_get_height (scaled));
@@ -1139,10 +1136,9 @@ gtk_do_render_icon_pixbuf (GtkStyleContext *context,
cairo_image_surface_get_width (surface),
cairo_image_surface_get_height (surface));
cairo_surface_destroy (surface);
}
else if (image_effect == GTK_CSS_IMAGE_EFFECT_HIGHLIGHT ||
state & GTK_STATE_FLAG_PRELIGHT)
{
break;
case GTK_CSS_IMAGE_EFFECT_HIGHLIGHT:
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
gdk_pixbuf_get_width (scaled),
gdk_pixbuf_get_height (scaled));
@@ -1158,9 +1154,15 @@ gtk_do_render_icon_pixbuf (GtkStyleContext *context,
cairo_image_surface_get_width (surface),
cairo_image_surface_get_height (surface));
cairo_surface_destroy (surface);
break;
default:
g_warn_if_reached ();
/* fall through */
case GTK_CSS_IMAGE_EFFECT_NONE:
stated = scaled;
break;
}
else
stated = scaled;
return stated;
}
+17 -3
View File
@@ -2908,7 +2908,10 @@ gtk_scrolled_window_scroll_event (GtkWidget *widget,
gboolean handled = FALSE;
gdouble delta_x;
gdouble delta_y;
gdouble delta;
GdkScrollDirection direction;
gboolean shifted;
shifted = (event->state & GDK_SHIFT_MASK) != 0;
scrolled_window = GTK_SCROLLED_WINDOW (widget);
priv = scrolled_window->priv;
@@ -2917,6 +2920,15 @@ gtk_scrolled_window_scroll_event (GtkWidget *widget,
if (gdk_event_get_scroll_deltas ((GdkEvent *) event, &delta_x, &delta_y))
{
if (shifted)
{
gdouble delta;
delta = delta_x;
delta_x = delta_y;
delta_y = delta;
}
if (delta_x != 0.0 &&
may_hscroll (scrolled_window))
{
@@ -2963,12 +2975,13 @@ gtk_scrolled_window_scroll_event (GtkWidget *widget,
handled = TRUE;
}
}
else
else if (gdk_event_get_scroll_direction ((GdkEvent *)event, &direction))
{
GtkWidget *range;
gboolean may_scroll;
if (event->direction == GDK_SCROLL_UP || event->direction == GDK_SCROLL_DOWN)
if ((!shifted && (direction == GDK_SCROLL_UP || direction == GDK_SCROLL_DOWN)) ||
(shifted && (direction == GDK_SCROLL_LEFT || direction == GDK_SCROLL_RIGHT)))
{
range = priv->vscrollbar;
may_scroll = may_vscroll (scrolled_window);
@@ -2983,6 +2996,7 @@ gtk_scrolled_window_scroll_event (GtkWidget *widget,
{
GtkAdjustment *adj = gtk_range_get_adjustment (GTK_RANGE (range));
gdouble new_value;
gdouble delta;
delta = _gtk_range_get_wheel_delta (GTK_RANGE (range), event);
+194 -890
View File
File diff suppressed because it is too large Load Diff
+11 -12
View File
@@ -20,6 +20,7 @@
#include "gtkstylecontext.h"
#include "gtkcssnodeprivate.h"
#include "gtkicontheme.h"
#include "gtkstyleproviderprivate.h"
#include "gtkbitmaskprivate.h"
@@ -27,11 +28,16 @@
G_BEGIN_DECLS
void _gtk_style_context_set_widget (GtkStyleContext *context,
GtkWidget *widget);
GtkStyleContext *gtk_style_context_new_for_node (GtkCssNode *node);
void gtk_style_context_set_id (GtkStyleContext *context,
const char *id);
const char * gtk_style_context_get_id (GtkStyleContext *context);
GtkStyleProviderPrivate *
gtk_style_context_get_style_provider (GtkStyleContext *context);
void gtk_style_context_save_to_node (GtkStyleContext *context,
GtkCssNode *node);
const GtkBitmask *
_gtk_style_context_get_changes (GtkStyleContext *context);
@@ -42,24 +48,17 @@ GtkCssValue * _gtk_style_context_peek_property (GtkStyleContext *c
const GValue * _gtk_style_context_peek_style_property (GtkStyleContext *context,
GType widget_type,
GParamSpec *pspec);
void _gtk_style_context_validate (GtkStyleContext *context,
gint64 timestamp,
GtkCssChange change,
const GtkBitmask*parent_changes);
void _gtk_style_context_queue_invalidate (GtkStyleContext *context,
GtkCssChange change);
void gtk_style_context_validate (GtkStyleContext *context,
const GtkBitmask*changes);
gboolean _gtk_style_context_check_region_name (const gchar *str);
gboolean _gtk_style_context_resolve_color (GtkStyleContext *context,
GtkCssValue *color,
GdkRGBA *result,
GtkCssDependencies *dependencies);
GdkRGBA *result);
void _gtk_style_context_get_cursor_color (GtkStyleContext *context,
GdkRGBA *primary_color,
GdkRGBA *secondary_color);
void _gtk_style_context_update_animating (GtkStyleContext *context);
void _gtk_style_context_get_icon_extents (GtkStyleContext *context,
GdkRectangle *extents,
gint x,
+176 -130
View File
@@ -42,15 +42,18 @@
#include "gtkswitch.h"
#include "deprecated/gtkactivatable.h"
#include "deprecated/gtktoggleaction.h"
#include "gtkintl.h"
#include "gtkprivate.h"
#include "deprecated/gtktoggleaction.h"
#include "gtkwidget.h"
#include "gtkmarshalers.h"
#include "gtkapplicationprivate.h"
#include "gtkactionable.h"
#include "a11y/gtkswitchaccessible.h"
#include "gtkactionhelper.h"
#include "gtkcssnodeprivate.h"
#include "gtkcssnodeutilsprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtkwidgetprivate.h"
#include "fallback-c89.c"
@@ -66,6 +69,8 @@ struct _GtkSwitchPrivate
GtkGesture *pan_gesture;
GtkGesture *multipress_gesture;
GtkCssNode *slider_node;
double handle_pos;
gint64 start_time;
gint64 end_time;
@@ -254,9 +259,7 @@ gtk_switch_pan_gesture_pan (GtkGesturePan *gesture,
context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
gtk_style_context_save (context);
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_TROUGH);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_SLIDER);
gtk_style_context_save_to_node (context, priv->slider_node);
gtk_style_context_get_padding (context, state, &padding);
gtk_style_context_restore (context);
@@ -344,55 +347,99 @@ gtk_switch_activate (GtkSwitch *sw)
}
static void
gtk_switch_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural)
gtk_switch_get_slider_size (GtkCssNode *cssnode,
GtkOrientation orientation,
gint for_size,
gint *minimum,
gint *natural,
gint *minimum_baseline,
gint *natural_baseline,
gpointer data)
{
GtkStyleContext *context;
GtkStateFlags state;
GtkBorder padding;
gint width, slider_width;
PangoLayout *layout;
PangoRectangle logical_rect;
context = gtk_widget_get_style_context (widget);
state = gtk_style_context_get_state (context);
gtk_style_context_save (context);
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_TROUGH);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_SLIDER);
gtk_style_context_get_padding (context, state, &padding);
width = padding.left + padding.right;
gtk_style_context_restore (context);
GtkWidget *widget = GTK_WIDGET (data);
gint slider_width;
gtk_widget_style_get (widget,
"slider-width", &slider_width,
NULL);
if (orientation == GTK_ORIENTATION_VERTICAL)
slider_width *= 0.6;
*minimum = slider_width;
*natural = slider_width;
}
static void
gtk_switch_get_content_size (GtkCssNode *cssnode,
GtkOrientation orientation,
gint for_size,
gint *minimum,
gint *natural,
gint *minimum_baseline,
gint *natural_baseline,
gpointer data)
{
GtkWidget *widget;
GtkSwitch *self;
GtkSwitchPrivate *priv;
gint slider_minimum, slider_natural;
PangoLayout *layout;
PangoRectangle on_rect, off_rect;
widget = GTK_WIDGET (data);
self = GTK_SWITCH (data);
priv = self->priv;
gtk_css_node_get_preferred_size (priv->slider_node,
orientation,
-1,
&slider_minimum, &slider_natural,
NULL, NULL,
gtk_switch_get_slider_size,
self);
/* Translators: if the "on" state label requires more than three
* glyphs then use MEDIUM VERTICAL BAR (U+2759) as the text for
* the state
*/
layout = gtk_widget_create_pango_layout (widget, C_("switch", "ON"));
pango_layout_get_extents (layout, NULL, &logical_rect);
pango_extents_to_pixels (&logical_rect, NULL);
width += MAX (logical_rect.width, slider_width);
pango_layout_get_pixel_extents (layout, NULL, &on_rect);
/* Translators: if the "off" state label requires more than three
* glyphs then use WHITE CIRCLE (U+25CB) as the text for the state
*/
pango_layout_set_text (layout, C_("switch", "OFF"), -1);
pango_layout_get_extents (layout, NULL, &logical_rect);
pango_extents_to_pixels (&logical_rect, NULL);
width += MAX (logical_rect.width, slider_width);
pango_layout_get_pixel_extents (layout, NULL, &off_rect);
g_object_unref (layout);
*minimum = width;
*natural = width;
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
int text_width = MAX (on_rect.width, off_rect.width);
*minimum = 2 * MAX (slider_minimum, text_width);
*natural = 2 * MAX (slider_natural, text_width);
}
else
{
int text_height = MAX (on_rect.height, off_rect.height);
*minimum = MAX (slider_minimum, text_height);
*natural = MAX (slider_natural, text_height);
}
}
static void
gtk_switch_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural)
{
gtk_css_node_get_preferred_size (gtk_widget_get_css_node (widget),
GTK_ORIENTATION_HORIZONTAL,
-1,
minimum, natural,
NULL, NULL,
gtk_switch_get_content_size,
widget);
}
static void
@@ -400,47 +447,34 @@ gtk_switch_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkStyleContext *context;
GtkStateFlags state;
GtkBorder padding;
gint height, slider_width, min_height;
PangoLayout *layout;
PangoRectangle logical_rect;
gchar *str;
gtk_css_node_get_preferred_size (gtk_widget_get_css_node (widget),
GTK_ORIENTATION_VERTICAL,
-1,
minimum, natural,
NULL, NULL,
gtk_switch_get_content_size,
widget);
}
context = gtk_widget_get_style_context (widget);
state = gtk_style_context_get_state (context);
static void
gtk_switch_allocate_contents (GtkCssNode *cssnode,
const GtkAllocation *allocation,
int baseline,
GtkAllocation *out_clip,
gpointer data)
{
GtkSwitch *self = data;
GtkSwitchPrivate *priv = self->priv;
gtk_style_context_save (context);
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_TROUGH);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_SLIDER);
gtk_style_context_get_padding (context, state, &padding);
height = padding.top + padding.bottom;
gtk_style_context_restore (context);
gtk_widget_style_get (widget,
"slider-width", &slider_width,
NULL);
min_height = slider_width * 0.6;
str = g_strdup_printf ("%s%s",
C_("switch", "ON"),
C_("switch", "OFF"));
layout = gtk_widget_create_pango_layout (widget, str);
pango_layout_get_extents (layout, NULL, &logical_rect);
pango_extents_to_pixels (&logical_rect, NULL);
height += MAX (min_height, logical_rect.height);
g_object_unref (layout);
g_free (str);
*minimum = height;
*natural = height;
/* We pretend to allocate the full area to the slider. That way both
* potential left and right clip overlap gets correctly computed.
*/
gtk_css_node_allocate (priv->slider_node,
allocation,
baseline,
out_clip,
NULL,
NULL);
}
static void
@@ -448,6 +482,7 @@ gtk_switch_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkSwitchPrivate *priv = GTK_SWITCH (widget)->priv;
GtkAllocation clip;
gtk_widget_set_allocation (widget, allocation);
@@ -458,7 +493,14 @@ gtk_switch_size_allocate (GtkWidget *widget,
allocation->width,
allocation->height);
_gtk_widget_set_simple_clip (widget, NULL);
gtk_css_node_allocate (gtk_widget_get_css_node (widget),
allocation,
gtk_widget_get_allocated_baseline (widget),
&clip,
gtk_switch_allocate_contents,
widget);
gtk_widget_set_clip (widget, &clip);
}
static void
@@ -543,9 +585,7 @@ gtk_switch_paint_handle (GtkWidget *widget,
{
GtkStyleContext *context = gtk_widget_get_style_context (widget);
gtk_style_context_save (context);
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_TROUGH);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_SLIDER);
gtk_style_context_save_to_node (context, GTK_SWITCH (widget)->priv->slider_node);
gtk_render_slider (context, cr,
box->x, box->y,
@@ -556,48 +596,31 @@ gtk_switch_paint_handle (GtkWidget *widget,
}
static gboolean
gtk_switch_draw (GtkWidget *widget,
cairo_t *cr)
gtk_switch_render_slider (GtkCssNode *cssnode,
cairo_t *cr,
int width,
int height,
gpointer data)
{
GtkWidget *widget = GTK_WIDGET (data);
return gtk_widget_has_visible_focus (widget);
}
static gboolean
gtk_switch_render_trough (GtkCssNode *cssnode,
cairo_t *cr,
int width,
int height,
gpointer data)
{
GtkWidget *widget = GTK_WIDGET (data);
GtkSwitchPrivate *priv = GTK_SWITCH (widget)->priv;
GtkStyleContext *context;
GdkRectangle handle;
GtkStyleContext *context = gtk_widget_get_style_context (widget);
PangoLayout *layout;
PangoRectangle rect;
gint label_x, label_y;
GtkBorder padding;
GtkStateFlags state;
gint x, y, width, height;
context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
gtk_style_context_save (context);
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_TROUGH);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_SLIDER);
gtk_style_context_get_padding (context, state, &padding);
gtk_style_context_restore (context);
x = 0;
y = 0;
width = gtk_widget_get_allocated_width (widget);
height = gtk_widget_get_allocated_height (widget);
gtk_render_background (context, cr, x, y, width, height);
gtk_render_frame (context, cr, x, y, width, height);
width -= padding.left + padding.right;
height -= padding.top + padding.bottom;
x += padding.left;
y += padding.top;
handle.y = y;
handle.width = width / 2;
handle.height = height;
gint slider_offset;
/* Translators: if the "on" state label requires more than three
* glyphs then use MEDIUM VERTICAL BAR (U+2759) as the text for
@@ -605,11 +628,10 @@ gtk_switch_draw (GtkWidget *widget,
*/
layout = gtk_widget_create_pango_layout (widget, C_("switch", "ON"));
pango_layout_get_extents (layout, NULL, &rect);
pango_extents_to_pixels (&rect, NULL);
pango_layout_get_pixel_extents (layout, NULL, &rect);
label_x = x + ((width / 2) - rect.width) / 2;
label_y = y + (height - rect.height) / 2;
label_x = ((width / 2) - rect.width) / 2;
label_y = (height - rect.height) / 2;
gtk_render_layout (context, cr, label_x, label_y, layout);
@@ -620,26 +642,40 @@ gtk_switch_draw (GtkWidget *widget,
*/
layout = gtk_widget_create_pango_layout (widget, C_("switch", "OFF"));
pango_layout_get_extents (layout, NULL, &rect);
pango_extents_to_pixels (&rect, NULL);
pango_layout_get_pixel_extents (layout, NULL, &rect);
label_x = x + (width / 2) + ((width / 2) - rect.width) / 2;
label_y = y + (height - rect.height) / 2;
label_x = (width / 2) + ((width / 2) - rect.width) / 2;
label_y = (height - rect.height) / 2;
gtk_render_layout (context, cr, label_x, label_y, layout);
g_object_unref (layout);
handle.x = x + round (priv->handle_pos * width / 2);
slider_offset = round (priv->handle_pos * (width - width / 2));
cairo_translate (cr, slider_offset, 0);
gtk_switch_paint_handle (widget, cr, &handle);
gtk_css_node_draw (priv->slider_node,
cr,
width / 2,
height,
gtk_switch_render_slider,
widget);
if (gtk_widget_has_visible_focus (widget))
{
gtk_render_focus (context, cr,
handle.x, handle.y,
handle.width, handle.height);
}
cairo_translate (cr, -slider_offset, 0);
return FALSE;
}
static gboolean
gtk_switch_draw (GtkWidget *widget,
cairo_t *cr)
{
gtk_css_node_draw (gtk_widget_get_css_node (widget),
cr,
gtk_widget_get_allocated_width (widget),
gtk_widget_get_allocated_height (widget),
gtk_switch_render_trough,
widget);
return FALSE;
}
@@ -995,6 +1031,7 @@ gtk_switch_init (GtkSwitch *self)
GtkSwitchPrivate *priv;
GtkStyleContext *context;
GtkGesture *gesture;
GtkCssNode *widget_node;
priv = self->priv = gtk_switch_get_instance_private (self);
@@ -1002,6 +1039,15 @@ gtk_switch_init (GtkSwitch *self)
gtk_widget_set_has_window (GTK_WIDGET (self), FALSE);
gtk_widget_set_can_focus (GTK_WIDGET (self), TRUE);
widget_node = gtk_widget_get_css_node (GTK_WIDGET (self));
priv->slider_node = gtk_css_node_new ();
gtk_css_node_set_widget_type (priv->slider_node, GTK_TYPE_SWITCH);
gtk_css_node_add_class (priv->slider_node, GTK_STYLE_CLASS_SLIDER);
gtk_css_node_set_parent (priv->slider_node, widget_node);
gtk_css_node_set_state (priv->slider_node, gtk_css_node_get_state (widget_node));
g_signal_connect_object (priv->slider_node, "style-changed", G_CALLBACK (gtk_css_node_style_changed_for_widget), self, 0);
g_object_unref (priv->slider_node);
gesture = gtk_gesture_multi_press_new (GTK_WIDGET (self));
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (gesture), FALSE);
gtk_gesture_single_set_exclusive (GTK_GESTURE_SINGLE (gesture), TRUE);
+22 -1
View File
@@ -50,6 +50,7 @@
#include "config.h"
#include "gtktextattributes.h"
#include "gtktextattributesprivate.h"
#include "gtktexttagprivate.h"
/**
@@ -363,9 +364,27 @@ G_GNUC_END_IGNORE_DEPRECATIONS
if (tag->priv->underline_set)
dest->appearance.underline = vals->appearance.underline;
if (GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA_SET (&vals->appearance))
{
GdkRGBA rgba;
GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA (&vals->appearance, &rgba);
GTK_TEXT_APPEARANCE_SET_UNDERLINE_RGBA (&dest->appearance, &rgba);
GTK_TEXT_APPEARANCE_SET_UNDERLINE_RGBA_SET (&dest->appearance, TRUE);
}
if (tag->priv->strikethrough_set)
dest->appearance.strikethrough = vals->appearance.strikethrough;
if (GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA_SET (&vals->appearance))
{
GdkRGBA rgba;
GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA (&vals->appearance, &rgba);
GTK_TEXT_APPEARANCE_SET_STRIKETHROUGH_RGBA (&dest->appearance, &rgba);
GTK_TEXT_APPEARANCE_SET_STRIKETHROUGH_RGBA_SET (&dest->appearance, TRUE);
}
if (tag->priv->invisible_set)
dest->invisible = vals->invisible;
@@ -425,5 +444,7 @@ _gtk_text_tag_affects_nonsize_appearance (GtkTextTag *tag)
priv->strikethrough_set ||
priv->bg_full_height_set ||
priv->pg_bg_color_set ||
priv->fallback_set;
priv->fallback_set ||
GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA_SET (&priv->values->appearance) ||
GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA_SET (&priv->values->appearance);
}
+2 -2
View File
@@ -89,8 +89,8 @@ typedef struct _GtkTextAppearance GtkTextAppearance;
struct _GtkTextAppearance
{
/*< public >*/
GdkColor bg_color;
GdkColor fg_color;
GdkColor bg_color; /* pixel is taken for underline color */
GdkColor fg_color; /* pixel is taken for strikethrough color */
/* super/subscript rise, can be negative */
gint rise;
+75
View File
@@ -0,0 +1,75 @@
/*
* Copyright (c) 2015 Christian Hergert <chergert@gnome.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Author: Christian Hergert <chergert@gnome.org>
*
*/
#ifndef __GTK_TEXT_ATTRIBUTE_PRIVATE_H__
#define __GTK_TEXT_ATTRIBUTE_PRIVATE_H__
/*
* The following macros are used to store and extract information about the
* Pango underline and strikethrough colors in the unused pixel member of
* the GdkColor members of GtkTextAppearance.
*
* In 4.0, we should revisit this.
*/
#define GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA_SET(appr) \
(((guint8*)&(appr)->bg_color)[3] != 0)
#define GTK_TEXT_APPEARANCE_SET_UNDERLINE_RGBA_SET(appr,val) \
G_STMT_START { \
((guint8*)&(appr)->bg_color)[3] = !!val; \
} G_STMT_END
#define GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA(appr,rgba) \
G_STMT_START { \
(rgba)->red = ((guint8*)&(appr)->bg_color)[0] / 255.; \
(rgba)->green = ((guint8*)&(appr)->bg_color)[1] / 255.; \
(rgba)->blue = ((guint8*)&(appr)->bg_color)[2] / 255.; \
(rgba)->alpha = 1.0; \
} G_STMT_END
#define GTK_TEXT_APPEARANCE_SET_UNDERLINE_RGBA(appr,rgba) \
G_STMT_START { \
((guint8*)&(appr)->bg_color)[0] = (rgba)->red * 255; \
((guint8*)&(appr)->bg_color)[1] = (rgba)->green * 255; \
((guint8*)&(appr)->bg_color)[2] = (rgba)->blue * 255; \
} G_STMT_END
#define GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA_SET(appr) \
(((guint8*)&(appr)->fg_color)[3] != 0)
#define GTK_TEXT_APPEARANCE_SET_STRIKETHROUGH_RGBA_SET(appr,val) \
G_STMT_START { \
((guint8*)&(appr)->fg_color)[3] = !!val; \
} G_STMT_END
#define GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA(appr,rgba) \
G_STMT_START { \
(rgba)->red = ((guint8*)&(appr)->fg_color)[0] / 255.; \
(rgba)->green = ((guint8*)&(appr)->fg_color)[1] / 255.; \
(rgba)->blue = ((guint8*)&(appr)->fg_color)[2] / 255.; \
(rgba)->alpha = 1.0; \
} G_STMT_END
#define GTK_TEXT_APPEARANCE_SET_STRIKETHROUGH_RGBA(appr,rgba) \
G_STMT_START { \
((guint8*)&(appr)->fg_color)[0] = (rgba)->red * 255; \
((guint8*)&(appr)->fg_color)[1] = (rgba)->green * 255; \
((guint8*)&(appr)->fg_color)[2] = (rgba)->blue * 255; \
} G_STMT_END
#endif /* __GTK_TEXT_ATTRIBUTE_PRIVATE_H__ */
+28
View File
@@ -4793,10 +4793,38 @@ get_tag_for_attributes (PangoAttrIterator *iter)
if (attr)
g_object_set (tag, "underline", ((PangoAttrInt*)attr)->value, NULL);
attr = pango_attr_iterator_get (iter, PANGO_ATTR_UNDERLINE_COLOR);
if (attr)
{
PangoColor *color;
GdkRGBA rgba;
color = &((PangoAttrColor*)attr)->color;
rgba.red = color->red / 65535.;
rgba.green = color->green / 65535.;
rgba.blue = color->blue / 65535.;
rgba.alpha = 1.;
g_object_set (tag, "underline-rgba", &rgba, NULL);
}
attr = pango_attr_iterator_get (iter, PANGO_ATTR_STRIKETHROUGH);
if (attr)
g_object_set (tag, "strikethrough", (gboolean) (((PangoAttrInt*)attr)->value != 0), NULL);
attr = pango_attr_iterator_get (iter, PANGO_ATTR_STRIKETHROUGH_COLOR);
if (attr)
{
PangoColor *color;
GdkRGBA rgba;
color = &((PangoAttrColor*)attr)->color;
rgba.red = color->red / 65535.;
rgba.green = color->green / 65535.;
rgba.blue = color->blue / 65535.;
rgba.alpha = 1.;
g_object_set (tag, "strikethrough-rgba", &rgba, NULL);
}
attr = pango_attr_iterator_get (iter, PANGO_ATTR_RISE);
if (attr)
g_object_set (tag, "rise", ((PangoAttrInt*)attr)->value, NULL);
+19 -2
View File
@@ -75,6 +75,7 @@
#define GTK_TEXT_USE_INTERNAL_UNSUPPORTED_API
#include "config.h"
#include "gtktextattributesprivate.h"
#include "gtktextdisplay.h"
#include "gtkwidgetprivate.h"
#include "gtkstylecontextprivate.h"
@@ -204,9 +205,25 @@ gtk_text_renderer_prepare_run (PangoRenderer *renderer,
fg_rgba = appearance->rgba[1];
text_renderer_set_rgba (text_renderer, PANGO_RENDER_PART_FOREGROUND, fg_rgba);
text_renderer_set_rgba (text_renderer, PANGO_RENDER_PART_STRIKETHROUGH, fg_rgba);
if (appearance->underline == PANGO_UNDERLINE_ERROR)
if (GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA_SET (appearance))
{
GdkRGBA rgba;
GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA (appearance, &rgba);
text_renderer_set_rgba (text_renderer, PANGO_RENDER_PART_STRIKETHROUGH, &rgba);
}
else
text_renderer_set_rgba (text_renderer, PANGO_RENDER_PART_STRIKETHROUGH, fg_rgba);
if (GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA_SET (appearance))
{
GdkRGBA rgba;
GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA (appearance, &rgba);
text_renderer_set_rgba (text_renderer, PANGO_RENDER_PART_UNDERLINE, &rgba);
}
else if (appearance->underline == PANGO_UNDERLINE_ERROR)
{
if (!text_renderer->error_color)
{
+77 -3
View File
@@ -81,6 +81,7 @@
#include "gtktextlayout.h"
#include "gtktextbtree.h"
#include "gtktextiterprivate.h"
#include "gtktextattributesprivate.h"
#include "gtktextutil.h"
#include "gtkintl.h"
@@ -1447,6 +1448,38 @@ rgba_equal (const GdkRGBA *rgba1, const GdkRGBA *rgba2)
return TRUE;
}
static gboolean
underline_equal (const GtkTextAppearance *appearance1,
const GtkTextAppearance *appearance2)
{
GdkRGBA c1;
GdkRGBA c2;
GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA (appearance1, &c1);
GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA (appearance2, &c2);
return ((appearance1->underline == appearance2->underline) &&
(GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA_SET (appearance1) ==
GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA_SET (appearance2)) &&
gdk_rgba_equal (&c1, &c2));
}
static gboolean
strikethrough_equal (const GtkTextAppearance *appearance1,
const GtkTextAppearance *appearance2)
{
GdkRGBA c1;
GdkRGBA c2;
GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA (appearance1, &c1);
GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA (appearance2, &c2);
return ((appearance1->strikethrough == appearance2->strikethrough) &&
(GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA_SET (appearance1) ==
GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA_SET (appearance2)) &&
gdk_rgba_equal (&c1, &c2));
}
static gboolean
gtk_text_attr_appearance_compare (const PangoAttribute *attr1,
const PangoAttribute *attr2)
@@ -1456,9 +1489,9 @@ gtk_text_attr_appearance_compare (const PangoAttribute *attr1,
return (rgba_equal (appearance1->rgba[0], appearance2->rgba[0]) &&
rgba_equal (appearance1->rgba[1], appearance2->rgba[1]) &&
appearance1->underline == appearance2->underline &&
appearance1->strikethrough == appearance2->strikethrough &&
appearance1->draw_bg == appearance2->draw_bg);
appearance1->draw_bg == appearance2->draw_bg &&
strikethrough_equal (appearance1, appearance2) &&
underline_equal (appearance1, appearance2));
}
/*
@@ -1522,6 +1555,22 @@ add_generic_attrs (GtkTextLayout *layout,
pango_attr_list_insert (attrs, attr);
}
if (GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA_SET (appearance))
{
GdkRGBA rgba;
GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA (appearance, &rgba);
attr = pango_attr_underline_color_new (rgba.red * 65535,
rgba.green * 65535,
rgba.blue * 65535);
attr->start_index = start;
attr->end_index = start + byte_count;
pango_attr_list_insert (attrs, attr);
}
if (appearance->strikethrough)
{
attr = pango_attr_strikethrough_new (appearance->strikethrough);
@@ -1532,6 +1581,22 @@ add_generic_attrs (GtkTextLayout *layout,
pango_attr_list_insert (attrs, attr);
}
if (GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA_SET (appearance))
{
GdkRGBA rgba;
GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA (appearance, &rgba);
attr = pango_attr_strikethrough_color_new (rgba.red * 65535,
rgba.green * 65535,
rgba.blue * 65535);
attr->start_index = start;
attr->end_index = start + byte_count;
pango_attr_list_insert (attrs, attr);
}
if (appearance->rise != 0)
{
attr = pango_attr_rise_new (appearance->rise);
@@ -1935,9 +2000,18 @@ add_preedit_attrs (GtkTextLayout *layout,
case PANGO_ATTR_UNDERLINE:
appearance.underline = ((PangoAttrInt *)attr)->value;
break;
case PANGO_ATTR_UNDERLINE_COLOR:
convert_color (&rgba, (PangoAttrColor*)attr);
GTK_TEXT_APPEARANCE_SET_UNDERLINE_RGBA_SET (&appearance, TRUE);
GTK_TEXT_APPEARANCE_SET_UNDERLINE_RGBA (&appearance, &rgba);
break;
case PANGO_ATTR_STRIKETHROUGH:
appearance.strikethrough = ((PangoAttrInt *)attr)->value;
break;
case PANGO_ATTR_STRIKETHROUGH_COLOR:
convert_color (&rgba, (PangoAttrColor*)attr);
GTK_TEXT_APPEARANCE_SET_STRIKETHROUGH_RGBA_SET (&appearance, TRUE);
GTK_TEXT_APPEARANCE_SET_STRIKETHROUGH_RGBA (&appearance, &rgba);
case PANGO_ATTR_RISE:
appearance.rise = ((PangoAttrInt *)attr)->value;
break;
+178 -1
View File
@@ -74,6 +74,7 @@
#include <stdlib.h>
#include <string.h>
#include "gtktextattributesprivate.h"
#include "gtktexttag.h"
#include "gtktexttypes.h"
#include "gtktexttagtable.h"
@@ -119,8 +120,10 @@ enum {
PROP_LEFT_MARGIN,
PROP_INDENT,
PROP_STRIKETHROUGH,
PROP_STRIKETHROUGH_RGBA,
PROP_RIGHT_MARGIN,
PROP_UNDERLINE,
PROP_UNDERLINE_RGBA,
PROP_RISE,
PROP_BACKGROUND_FULL_HEIGHT,
PROP_LANGUAGE,
@@ -154,8 +157,10 @@ enum {
PROP_LEFT_MARGIN_SET,
PROP_INDENT_SET,
PROP_STRIKETHROUGH_SET,
PROP_STRIKETHROUGH_RGBA_SET,
PROP_RIGHT_MARGIN_SET,
PROP_UNDERLINE_SET,
PROP_UNDERLINE_RGBA_SET,
PROP_RISE_SET,
PROP_BACKGROUND_FULL_HEIGHT_SET,
PROP_LANGUAGE_SET,
@@ -518,7 +523,43 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
PANGO_TYPE_UNDERLINE,
PANGO_UNDERLINE_NONE,
GTK_PARAM_READWRITE));
/**
* GtkTextTag:underline-rgba:
*
* This property modifies the color of underlines. If not set, underlines
* will use the forground color.
*
* If #GtkTextTag:underline is set to %PANGO_UNDERLINE_ERROR, an alternate
* color may be applied instead of the foreground. Setting this property
* will always override those defaults.
*
* Since: 3.18
*/
g_object_class_install_property (object_class,
PROP_UNDERLINE_RGBA,
g_param_spec_boxed ("underline-rgba",
P_("Underline RGBA"),
P_("Color of underline for this text"),
GDK_TYPE_RGBA,
GTK_PARAM_READWRITE));
/**
* GtkTextTag:strikethrough-rgba:
*
* This property modifies the color of strikeouts. If not set, strikeouts
* will use the forground color.
*
* Since: 3.18
*/
g_object_class_install_property (object_class,
PROP_STRIKETHROUGH_RGBA,
g_param_spec_boxed ("strikethrough-rgba",
P_("Strike-through RGBA"),
P_("Color of strike-through for this text"),
GDK_TYPE_RGBA,
GTK_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_WRAP_MODE,
g_param_spec_enum ("wrap-mode",
@@ -746,6 +787,28 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
P_("Underline set"),
P_("Whether this tag affects underlining"));
/**
* GtkTextTag:underline-rgba-set:
*
* If the #GtkTextTag:underline-rgba property has been set.
*
* Since: 3.18
*/
ADD_SET_PROP ("underline-rgba-set", PROP_UNDERLINE_RGBA_SET,
P_("Underline RGBA set"),
P_("Whether this tag affects underlining color"));
/**
* GtkTextTag:strikethrough-rgba-set:
*
* If the #GtkTextTag:strikethrough-rgba property has been set.
*
* Since: 3.18
*/
ADD_SET_PROP ("strikethrough-rgba-set", PROP_STRIKETHROUGH_RGBA_SET,
P_("Strikethrough RGBA set"),
P_("Whether this tag affects strikethrough color"));
ADD_SET_PROP ("wrap-mode-set", PROP_WRAP_MODE_SET,
P_("Wrap mode set"),
P_("Whether this tag affects line wrap mode"));
@@ -862,6 +925,66 @@ copy_gdk_color_to_rgba (GdkColor *src,
dest->alpha = 1;
}
static void
set_underline_rgba (GtkTextTag *tag,
const GdkRGBA *rgba)
{
GtkTextTagPrivate *priv = tag->priv;
if (rgba)
{
GTK_TEXT_APPEARANCE_SET_UNDERLINE_RGBA (&priv->values->appearance, rgba);
if (!GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA_SET (&priv->values->appearance))
{
GTK_TEXT_APPEARANCE_SET_UNDERLINE_RGBA_SET (&priv->values->appearance, TRUE);
g_object_notify (G_OBJECT (tag), "underline-rgba-set");
}
}
else
{
GdkRGBA black = { 0 };
GTK_TEXT_APPEARANCE_SET_UNDERLINE_RGBA (&priv->values->appearance, &black);
if (GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA_SET (&priv->values->appearance))
{
GTK_TEXT_APPEARANCE_SET_UNDERLINE_RGBA_SET (&priv->values->appearance, FALSE);
g_object_notify (G_OBJECT (tag), "underline-rgba-set");
}
}
}
static void
set_strikethrough_rgba (GtkTextTag *tag,
const GdkRGBA *rgba)
{
GtkTextTagPrivate *priv = tag->priv;
if (rgba)
{
GTK_TEXT_APPEARANCE_SET_STRIKETHROUGH_RGBA (&priv->values->appearance, rgba);
if (!GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA_SET (&priv->values->appearance))
{
GTK_TEXT_APPEARANCE_SET_STRIKETHROUGH_RGBA_SET (&priv->values->appearance, TRUE);
g_object_notify (G_OBJECT (tag), "strikethrough-rgba-set");
}
}
else
{
GdkRGBA black = { 0 };
GTK_TEXT_APPEARANCE_SET_STRIKETHROUGH_RGBA (&priv->values->appearance, &black);
if (GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA_SET (&priv->values->appearance))
{
GTK_TEXT_APPEARANCE_SET_STRIKETHROUGH_RGBA_SET (&priv->values->appearance, FALSE);
g_object_notify (G_OBJECT (tag), "strikethrough-rgba-set");
}
}
}
static void
set_bg_rgba (GtkTextTag *tag, GdkRGBA *rgba)
{
@@ -1409,6 +1532,13 @@ gtk_text_tag_set_property (GObject *object,
g_object_notify (object, "strikethrough-set");
break;
case PROP_STRIKETHROUGH_RGBA:
{
GdkRGBA *color = g_value_get_boxed (value);
set_strikethrough_rgba (text_tag, color);
}
break;
case PROP_RIGHT_MARGIN:
priv->right_margin_set = TRUE;
priv->values->right_margin = g_value_get_int (value);
@@ -1422,6 +1552,13 @@ gtk_text_tag_set_property (GObject *object,
g_object_notify (object, "underline-set");
break;
case PROP_UNDERLINE_RGBA:
{
GdkRGBA *color = g_value_get_boxed (value);
set_underline_rgba (text_tag, color);
}
break;
case PROP_RISE:
priv->rise_set = TRUE;
priv->values->appearance.rise = g_value_get_int (value);
@@ -1593,6 +1730,11 @@ gtk_text_tag_set_property (GObject *object,
priv->strikethrough_set = g_value_get_boolean (value);
break;
case PROP_STRIKETHROUGH_RGBA_SET:
GTK_TEXT_APPEARANCE_SET_STRIKETHROUGH_RGBA_SET (&priv->values->appearance,
g_value_get_boolean (value));
break;
case PROP_RIGHT_MARGIN_SET:
priv->right_margin_set = g_value_get_boolean (value);
size_changed = TRUE;
@@ -1602,6 +1744,11 @@ gtk_text_tag_set_property (GObject *object,
priv->underline_set = g_value_get_boolean (value);
break;
case PROP_UNDERLINE_RGBA_SET:
GTK_TEXT_APPEARANCE_SET_UNDERLINE_RGBA_SET (&priv->values->appearance,
g_value_get_boolean (value));
break;
case PROP_RISE_SET:
priv->rise_set = g_value_get_boolean (value);
size_changed = TRUE;
@@ -1790,6 +1937,16 @@ gtk_text_tag_get_property (GObject *object,
g_value_set_boolean (value, priv->values->appearance.strikethrough);
break;
case PROP_STRIKETHROUGH_RGBA:
if (GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA_SET (&priv->values->appearance))
{
GdkRGBA rgba;
GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA (&priv->values->appearance, &rgba);
g_value_set_boxed (value, &rgba);
}
break;
case PROP_RIGHT_MARGIN:
g_value_set_int (value, priv->values->right_margin);
break;
@@ -1798,6 +1955,16 @@ gtk_text_tag_get_property (GObject *object,
g_value_set_enum (value, priv->values->appearance.underline);
break;
case PROP_UNDERLINE_RGBA:
if (GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA_SET (&priv->values->appearance))
{
GdkRGBA rgba;
GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA (&priv->values->appearance, &rgba);
g_value_set_boxed (value, &rgba);
}
break;
case PROP_RISE:
g_value_set_int (value, priv->values->appearance.rise);
break;
@@ -1901,6 +2068,11 @@ gtk_text_tag_get_property (GObject *object,
g_value_set_boolean (value, priv->strikethrough_set);
break;
case PROP_STRIKETHROUGH_RGBA_SET:
g_value_set_boolean (value,
GTK_TEXT_APPEARANCE_GET_STRIKETHROUGH_RGBA_SET (&priv->values->appearance));
break;
case PROP_RIGHT_MARGIN_SET:
g_value_set_boolean (value, priv->right_margin_set);
break;
@@ -1909,6 +2081,11 @@ gtk_text_tag_get_property (GObject *object,
g_value_set_boolean (value, priv->underline_set);
break;
case PROP_UNDERLINE_RGBA_SET:
g_value_set_boolean (value,
GTK_TEXT_APPEARANCE_GET_UNDERLINE_RGBA_SET (&priv->values->appearance));
break;
case PROP_RISE_SET:
g_value_set_boolean (value, priv->rise_set);
break;
+44 -22
View File
@@ -60,6 +60,7 @@
#include "gtksizerequest.h"
#include "gtkstylecontextprivate.h"
#include "gtkcssprovider.h"
#include "gtkcsswidgetnodeprivate.h"
#include "gtkmodifierstyle.h"
#include "gtkversion.h"
#include "gtkdebug.h"
@@ -557,6 +558,7 @@ struct _GtkWidgetPrivate
* the font to use for text.
*/
GtkStyle *style;
GtkCssNode *cssnode;
GtkStyleContext *context;
/* Widget's path for styling */
@@ -733,7 +735,8 @@ struct _GtkStateData
static void gtk_widget_base_class_init (gpointer g_class);
static void gtk_widget_class_init (GtkWidgetClass *klass);
static void gtk_widget_base_class_finalize (GtkWidgetClass *klass);
static void gtk_widget_init (GtkWidget *widget);
static void gtk_widget_init (GTypeInstance *instance,
gpointer g_class);
static void gtk_widget_set_property (GObject *object,
guint prop_id,
const GValue *value,
@@ -992,7 +995,7 @@ gtk_widget_get_type (void)
NULL, /* class_init */
sizeof (GtkWidget),
0, /* n_preallocs */
(GInstanceInitFunc) gtk_widget_init,
gtk_widget_init,
NULL, /* value_table */
};
@@ -4454,8 +4457,9 @@ _gtk_widget_cancel_sequence (GtkWidget *widget,
}
static void
gtk_widget_init (GtkWidget *widget)
gtk_widget_init (GTypeInstance *instance, gpointer g_class)
{
GtkWidget *widget = GTK_WIDGET (instance);
GtkWidgetPrivate *priv;
widget->priv = gtk_widget_get_instance_private (widget);
@@ -4506,6 +4510,11 @@ gtk_widget_init (GtkWidget *widget)
_gtk_size_request_cache_init (&priv->requests);
priv->cssnode = gtk_css_widget_node_new (widget);
gtk_css_node_set_state (priv->cssnode, GTK_STATE_FLAG_DIR_LTR);
/* need to set correct type here, and only class has the correct type here */
gtk_css_node_set_widget_type (priv->cssnode, G_TYPE_FROM_CLASS (g_class));
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
priv->style = gtk_widget_get_default_style ();
G_GNUC_END_IGNORE_DEPRECATIONS;
@@ -4738,6 +4747,7 @@ gtk_widget_unparent (GtkWidget *widget)
gtk_widget_unset_state_flags (widget, GTK_STATE_FLAG_BACKDROP);
if (priv->context)
gtk_style_context_set_parent (priv->context, NULL);
gtk_css_node_set_parent (widget->priv->cssnode, NULL);
_gtk_widget_update_parent_muxer (widget);
@@ -4859,6 +4869,8 @@ gtk_widget_show (GtkWidget *widget)
gtk_widget_queue_compute_expand (widget->priv->parent);
}
gtk_css_node_set_visible (widget->priv->cssnode, TRUE);
g_signal_emit (widget, widget_signals[SHOW], 0);
g_object_notify (G_OBJECT (widget), "visible");
@@ -4957,6 +4969,8 @@ gtk_widget_hide (GtkWidget *widget)
gtk_widget_queue_compute_expand (widget);
}
gtk_css_node_set_visible (widget->priv->cssnode, FALSE);
g_signal_emit (widget, widget_signals[HIDE], 0);
if (!gtk_widget_is_toplevel (widget))
gtk_widget_queue_resize (widget);
@@ -5056,9 +5070,6 @@ gtk_widget_map (GtkWidget *widget)
if (!gtk_widget_get_has_window (widget))
gdk_window_invalidate_rect (priv->window, &priv->clip, FALSE);
if (widget->priv->context)
_gtk_style_context_update_animating (widget->priv->context);
gtk_widget_pop_verify_invariants (widget);
}
}
@@ -5088,9 +5099,6 @@ gtk_widget_unmap (GtkWidget *widget)
gdk_window_invalidate_rect (priv->window, &priv->clip, FALSE);
_gtk_tooltip_hide (widget);
if (widget->priv->context)
_gtk_style_context_update_animating (widget->priv->context);
g_signal_emit (widget, widget_signals[UNMAP], 0);
gtk_widget_pop_verify_invariants (widget);
@@ -5438,6 +5446,8 @@ gtk_widget_connect_frame_clock (GtkWidget *widget,
gdk_frame_clock_begin_updating (frame_clock);
}
gtk_css_node_invalidate_frame_clock (priv->cssnode, FALSE);
if (priv->context)
gtk_style_context_set_frame_clock (priv->context, frame_clock);
}
@@ -5451,6 +5461,8 @@ gtk_widget_disconnect_frame_clock (GtkWidget *widget,
if (GTK_IS_CONTAINER (widget))
_gtk_container_stop_idle_sizer (GTK_CONTAINER (widget));
gtk_css_node_invalidate_frame_clock (priv->cssnode, FALSE);
if (priv->clock_tick_id)
{
g_signal_handler_disconnect (frame_clock, priv->clock_tick_id);
@@ -9530,6 +9542,8 @@ gtk_widget_set_parent (GtkWidget *widget,
data.flags_to_unset = 0;
gtk_widget_propagate_state (widget, &data);
if (gtk_css_node_get_parent (widget->priv->cssnode) == NULL)
gtk_css_node_set_parent (widget->priv->cssnode, parent->priv->cssnode);
if (priv->context)
gtk_style_context_set_parent (priv->context,
gtk_widget_get_style_context (parent));
@@ -12181,11 +12195,11 @@ gtk_widget_finalize (GObject *object)
if (priv->path)
gtk_widget_path_free (priv->path);
gtk_css_widget_node_widget_destroyed (GTK_CSS_WIDGET_NODE (priv->cssnode));
g_object_unref (priv->cssnode);
if (priv->context)
{
_gtk_style_context_set_widget (priv->context, NULL);
g_object_unref (priv->context);
}
g_object_unref (priv->context);
_gtk_size_request_cache_free (&priv->requests);
@@ -16308,7 +16322,7 @@ gtk_widget_path_append_for_widget (GtkWidgetPath *path,
g_return_val_if_fail (path != NULL, 0);
g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
pos = gtk_widget_path_append_type (path, G_OBJECT_TYPE (widget));
pos = gtk_widget_path_append_type (path, gtk_css_node_get_widget_type (widget->priv->cssnode));
if (widget->priv->name)
gtk_widget_path_iter_set_name (path, pos, widget->priv->name);
@@ -16322,7 +16336,7 @@ gtk_widget_path_append_for_widget (GtkWidgetPath *path,
/* Also add any persistent classes in
* the style context the widget path
*/
classes = gtk_style_context_list_classes (widget->priv->context);
classes = gtk_css_node_list_classes (widget->priv->cssnode);
for (l = classes; l; l = l->next)
gtk_widget_path_iter_add_class (path, pos, l->data);
@@ -16407,6 +16421,19 @@ _gtk_widget_style_context_invalidated (GtkWidget *widget)
}
}
GtkCssNode *
gtk_widget_get_css_node (GtkWidget *widget)
{
return widget->priv->cssnode;
}
GtkStyleContext *
_gtk_widget_peek_style_context (GtkWidget *widget)
{
return widget->priv->context;
}
/**
* gtk_widget_get_style_context:
* @widget: a #GtkWidget
@@ -16430,7 +16457,7 @@ gtk_widget_get_style_context (GtkWidget *widget)
GdkScreen *screen;
GdkFrameClock *frame_clock;
priv->context = gtk_style_context_new ();
priv->context = gtk_style_context_new_for_node (priv->cssnode);
gtk_style_context_set_id (priv->context, priv->name);
gtk_style_context_set_state (priv->context, priv->state_flags);
@@ -16447,8 +16474,6 @@ gtk_widget_get_style_context (GtkWidget *widget)
if (priv->parent)
gtk_style_context_set_parent (priv->context,
gtk_widget_get_style_context (priv->parent));
_gtk_style_context_set_widget (priv->context, widget);
}
return widget->priv->context;
@@ -16462,10 +16487,7 @@ _gtk_widget_invalidate_style_context (GtkWidget *widget,
priv = widget->priv;
if (priv->context == NULL)
return;
_gtk_style_context_queue_invalidate (priv->context, change);
gtk_css_node_invalidate (priv->cssnode, change);
}
/**
+2
View File
@@ -32,6 +32,7 @@
G_BEGIN_DECLS
GtkCssNode * gtk_widget_get_css_node (GtkWidget *widget);
void _gtk_widget_set_visible_flag (GtkWidget *widget,
gboolean visible);
gboolean _gtk_widget_get_in_reparent (GtkWidget *widget);
@@ -130,6 +131,7 @@ gpointer _gtk_widget_peek_request_cache (GtkWidget *widget);
void _gtk_widget_buildable_finish_accelerator (GtkWidget *widget,
GtkWidget *toplevel,
gpointer user_data);
GtkStyleContext * _gtk_widget_peek_style_context (GtkWidget *widget);
GtkStyle * _gtk_widget_get_style (GtkWidget *widget);
void _gtk_widget_set_style (GtkWidget *widget,
GtkStyle *style);
+1 -7
View File
@@ -5834,7 +5834,6 @@ gtk_window_show (GtkWidget *widget)
GtkWindow *window = GTK_WINDOW (widget);
GtkWindowPrivate *priv = window->priv;
GtkContainer *container = GTK_CONTAINER (window);
GtkBitmask *empty;
gboolean need_resize;
gboolean is_plug;
@@ -5848,12 +5847,7 @@ gtk_window_show (GtkWidget *widget)
need_resize = _gtk_widget_get_alloc_needed (widget) || !gtk_widget_get_realized (widget);
empty = _gtk_bitmask_new ();
_gtk_style_context_validate (gtk_widget_get_style_context (widget),
g_get_monotonic_time (),
0,
empty);
_gtk_bitmask_free (empty);
gtk_css_node_validate (gtk_widget_get_css_node (widget));
if (need_resize)
{
+5
View File
@@ -4,10 +4,12 @@ inspector_c_sources = \
inspector/cellrenderergraph.c \
inspector/classes-list.c \
inspector/css-editor.c \
inspector/css-node-tree.c \
inspector/data-list.c \
inspector/general.c \
inspector/gestures.c \
inspector/graphdata.c \
inspector/gtktreemodelcssnode.c \
inspector/init.c \
inspector/inspect-button.c \
inspector/magnifier.c \
@@ -33,10 +35,12 @@ inspector_h_sources = \
inspector/cellrenderergraph.h \
inspector/classes-list.h \
inspector/css-editor.h \
inspector/css-node-tree.h \
inspector/data-list.h \
inspector/general.h \
inspector/gestures.h \
inspector/graphdata.h \
inspector/gtktreemodelcssnode.h \
inspector/init.h \
inspector/magnifier.h \
inspector/menu.h \
@@ -59,6 +63,7 @@ inspector_templates = \
inspector/actions.ui \
inspector/classes-list.ui \
inspector/css-editor.ui \
inspector/css-node-tree.ui \
inspector/data-list.ui \
inspector/general.ui \
inspector/magnifier.ui \
+168
View File
@@ -0,0 +1,168 @@
/*
* Copyright (c) 2014 Benjamin Otte <otte@gnome.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicntnse,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright noticnt and this permission noticnt shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "config.h"
#include <glib/gi18n-lib.h>
#include "css-node-tree.h"
#include <strings.h>
#include "gtktreemodelcssnode.h"
#include <gtk/gtktreeview.h>
#include "gtk/gtkwidgetprivate.h"
enum {
COLUMN_NAME,
COLUMN_VISIBLE,
COLUMN_CLASSES,
COLUMN_ID,
/* add more */
N_COLUMNS
};
struct _GtkInspectorCssNodeTreePrivate
{
GtkWidget *tree_view;
GtkTreeModel *model;
};
G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorCssNodeTree, gtk_inspector_css_node_tree, GTK_TYPE_BOX)
static void
gtk_inspector_css_node_tree_finalize (GObject *object)
{
//GtkInspectorCssNodeTree *cnt = GTK_INSPECTOR_CSS_NODE_TREE (object);
G_OBJECT_CLASS (gtk_inspector_css_node_tree_parent_class)->finalize (object);
}
static void
gtk_inspector_css_node_tree_class_init (GtkInspectorCssNodeTreeClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->finalize = gtk_inspector_css_node_tree_finalize;
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/inspector/css-node-tree.ui");
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorCssNodeTree, tree_view);
}
static int
sort_strv (gconstpointer a,
gconstpointer b,
gpointer data)
{
char **ap = (char **) a;
char **bp = (char **) b;
return strcasecmp (*ap, *bp);
}
static void
strv_sort (char **strv)
{
g_qsort_with_data (strv,
g_strv_length (strv),
sizeof (char *),
sort_strv,
NULL);
}
static void
gtk_inspector_css_node_tree_get_node_value (GtkTreeModelCssNode *model,
GtkCssNode *node,
int column,
GValue *value)
{
char **strv;
char *s;
switch (column)
{
case COLUMN_NAME:
g_value_set_string (value, g_type_name (gtk_css_node_get_widget_type (node)));
break;
case COLUMN_VISIBLE:
g_value_set_boolean (value, gtk_css_node_get_visible (node));
break;
case COLUMN_CLASSES:
strv = gtk_css_node_get_classes (node);
strv_sort (strv);
s = g_strjoinv (" ", strv);
g_value_take_string (value, s);
g_strfreev (strv);
break;
case COLUMN_ID:
g_value_set_string (value, gtk_css_node_get_id (node));
break;
default:
g_assert_not_reached ();
break;
}
}
static void
gtk_inspector_css_node_tree_init (GtkInspectorCssNodeTree *cnt)
{
GtkInspectorCssNodeTreePrivate *priv;
cnt->priv = gtk_inspector_css_node_tree_get_instance_private (cnt);
gtk_widget_init_template (GTK_WIDGET (cnt));
priv = cnt->priv;
priv->model = gtk_tree_model_css_node_new (gtk_inspector_css_node_tree_get_node_value,
N_COLUMNS,
G_TYPE_STRING,
G_TYPE_BOOLEAN,
G_TYPE_STRING,
G_TYPE_STRING);
gtk_tree_view_set_model (GTK_TREE_VIEW (priv->tree_view), priv->model);
g_object_unref (priv->model);
}
void
gtk_inspector_css_node_tree_set_object (GtkInspectorCssNodeTree *cnt,
GObject *object)
{
GtkInspectorCssNodeTreePrivate *priv;
g_return_if_fail (GTK_INSPECTOR_IS_CSS_NODE_TREE (cnt));
priv = cnt->priv;
if (!GTK_IS_WIDGET (object))
{
gtk_tree_model_css_node_set_root_node (GTK_TREE_MODEL_CSS_NODE (priv->model), NULL);
return;
}
gtk_tree_model_css_node_set_root_node (GTK_TREE_MODEL_CSS_NODE (priv->model),
gtk_widget_get_css_node (GTK_WIDGET (object)));
}
// vim: set et sw=2 ts=2:
+61
View File
@@ -0,0 +1,61 @@
/*
* Copyright (c) 2014 Benjamin Otte <otte@gnome.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef _GTK_INSPECTOR_CSS_NODE_TREE_H_
#define _GTK_INSPECTOR_CSS_NODE_TREE_H_
#include <gtk/gtkbox.h>
#include "gtk/gtkcssnodeprivate.h"
#define GTK_TYPE_INSPECTOR_CSS_NODE_TREE (gtk_inspector_css_node_tree_get_type())
#define GTK_INSPECTOR_CSS_NODE_TREE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_INSPECTOR_CSS_NODE_TREE, GtkInspectorCssNodeTree))
#define GTK_INSPECTOR_CSS_NODE_TREE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_INSPECTOR_CSS_NODE_TREE, GtkInspectorCssNodeTreeClass))
#define GTK_INSPECTOR_IS_CSS_NODE_TREE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_INSPECTOR_CSS_NODE_TREE))
#define GTK_INSPECTOR_IS_CSS_NODE_TREE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_INSPECTOR_CSS_NODE_TREE))
#define GTK_INSPECTOR_CSS_NODE_TREE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_INSPECTOR_CSS_NODE_TREE, GtkInspectorCssNodeTreeClass))
typedef struct _GtkInspectorCssNodeTreePrivate GtkInspectorCssNodeTreePrivate;
typedef struct _GtkInspectorCssNodeTree
{
GtkBox parent;
GtkInspectorCssNodeTreePrivate *priv;
} GtkInspectorCssNodeTree;
typedef struct _GtkInspectorCssNodeTreeClass
{
GtkBoxClass parent;
} GtkInspectorCssNodeTreeClass;
G_BEGIN_DECLS
GType gtk_inspector_css_node_tree_get_type (void);
void gtk_inspector_css_node_tree_set_object (GtkInspectorCssNodeTree *cnt,
GObject *object);
G_END_DECLS
#endif // _GTK_INSPECTOR_CSS_NODE_TREE_H_
// vim: set et sw=2 ts=2:
+58
View File
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface domain="gtk30">
<template class="GtkInspectorCssNodeTree" parent="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="hscrollbar-policy">never</property>
<property name="vscrollbar-policy">automatic</property>
<property name="expand">True</property>
<child>
<object class="GtkTreeView" id="tree_view">
<property name="visible">True</property>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
<property name="resizable">True</property>
<property name="title" translatable="yes">Name</property>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="text">0</attribute>
<attribute name="sensitive">1</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn2">
<property name="resizable">True</property>
<property name="title" translatable="yes">ID</property>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="text">3</attribute>
<attribute name="sensitive">1</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn3">
<property name="resizable">True</property>
<property name="title" translatable="yes">Classes</property>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="text">2</attribute>
<attribute name="sensitive">1</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</template>
</interface>
+626
View File
@@ -0,0 +1,626 @@
/* gtktreestore.c
* Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford <jrb@redhat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtktreemodelcssnode.h"
struct _GtkTreeModelCssNodePrivate
{
GtkTreeModelCssNodeGetFunc get_func;
gint n_columns;
GType *column_types;
GtkCssNode *root;
};
static void gtk_tree_model_css_node_connect_node (GtkTreeModelCssNode *model,
GtkCssNode *node,
gboolean emit_signal);
static void gtk_tree_model_css_node_disconnect_node (GtkTreeModelCssNode *model,
GtkCssNode *node,
gboolean emit_signal,
GtkCssNode *parent,
GtkCssNode *previous);
static void gtk_tree_model_css_node_tree_model_init (GtkTreeModelIface *iface);
G_DEFINE_TYPE_WITH_CODE (GtkTreeModelCssNode, gtk_tree_model_css_node, G_TYPE_OBJECT,
G_ADD_PRIVATE (GtkTreeModelCssNode)
G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL,
gtk_tree_model_css_node_tree_model_init))
static GtkCssNode *
get_nth_child (GtkCssNode *node,
gint i)
{
for (node = gtk_css_node_get_first_child (node);
node != NULL && i > 0;
node = gtk_css_node_get_next_sibling (node))
i--;
return node;
}
static int
get_node_index (GtkCssNode *node)
{
int result = 0;
while ((node = gtk_css_node_get_previous_sibling (node)))
result++;
return result;
}
static GtkTreeModelFlags
gtk_tree_model_css_node_get_flags (GtkTreeModel *tree_model)
{
return GTK_TREE_MODEL_ITERS_PERSIST;
}
static gint
gtk_tree_model_css_node_get_n_columns (GtkTreeModel *tree_model)
{
GtkTreeModelCssNode *nodemodel = GTK_TREE_MODEL_CSS_NODE (tree_model);
GtkTreeModelCssNodePrivate *priv = nodemodel->priv;
return priv->n_columns;
}
static GType
gtk_tree_model_css_node_get_column_type (GtkTreeModel *tree_model,
gint column)
{
GtkTreeModelCssNode *nodemodel = GTK_TREE_MODEL_CSS_NODE (tree_model);
GtkTreeModelCssNodePrivate *priv = nodemodel->priv;
g_return_val_if_fail (column < priv->n_columns, G_TYPE_INVALID);
return priv->column_types[column];
}
static gboolean
gtk_tree_model_css_node_get_iter (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreePath *path)
{
GtkTreeModelCssNode *nodemodel = GTK_TREE_MODEL_CSS_NODE (tree_model);
GtkTreeModelCssNodePrivate *priv = nodemodel->priv;
GtkCssNode *node;
int *indices;
int depth, i;
if (priv->root == NULL)
return FALSE;
indices = gtk_tree_path_get_indices (path);
depth = gtk_tree_path_get_depth (path);
if (depth < 1 || indices[0] != 0)
return FALSE;
node = priv->root;
for (i = 1; i < depth; i++)
{
node = get_nth_child (node, indices[i]);
if (node == NULL)
return FALSE;
}
gtk_tree_model_css_node_get_iter_from_node (nodemodel, iter, node);
return TRUE;
}
static GtkTreePath *
gtk_tree_model_css_node_get_path (GtkTreeModel *tree_model,
GtkTreeIter *iter)
{
GtkTreeModelCssNode *nodemodel = GTK_TREE_MODEL_CSS_NODE (tree_model);
GtkTreeModelCssNodePrivate *priv = nodemodel->priv;
GtkCssNode *node;
GtkTreePath *path;
g_return_val_if_fail (priv->root != NULL, NULL);
path = gtk_tree_path_new ();
node = gtk_tree_model_css_node_get_node_from_iter (nodemodel, iter);
while (node != priv->root)
{
gtk_tree_path_prepend_index (path, get_node_index (node));
node = gtk_css_node_get_parent (node);
}
gtk_tree_path_prepend_index (path, 0);
return path;
}
static void
gtk_tree_model_css_node_get_value (GtkTreeModel *tree_model,
GtkTreeIter *iter,
gint column,
GValue *value)
{
GtkTreeModelCssNode *nodemodel = GTK_TREE_MODEL_CSS_NODE (tree_model);
GtkTreeModelCssNodePrivate *priv = nodemodel->priv;
g_value_init (value, priv->column_types[column]);
priv->get_func (nodemodel,
gtk_tree_model_css_node_get_node_from_iter (nodemodel, iter),
column,
value);
}
static gboolean
gtk_tree_model_css_node_iter_next (GtkTreeModel *tree_model,
GtkTreeIter *iter)
{
GtkTreeModelCssNode *nodemodel = GTK_TREE_MODEL_CSS_NODE (tree_model);
GtkTreeModelCssNodePrivate *priv = nodemodel->priv;
GtkCssNode *node;
node = gtk_tree_model_css_node_get_node_from_iter (nodemodel, iter);
if (node == priv->root)
return FALSE;
node = gtk_css_node_get_next_sibling (node);
if (node == NULL)
return FALSE;
gtk_tree_model_css_node_get_iter_from_node (nodemodel, iter, node);
return TRUE;
}
static gboolean
gtk_tree_model_css_node_iter_previous (GtkTreeModel *tree_model,
GtkTreeIter *iter)
{
GtkTreeModelCssNode *nodemodel = GTK_TREE_MODEL_CSS_NODE (tree_model);
GtkTreeModelCssNodePrivate *priv = nodemodel->priv;
GtkCssNode *node;
node = gtk_tree_model_css_node_get_node_from_iter (nodemodel, iter);
if (node == priv->root)
return FALSE;
node = gtk_css_node_get_previous_sibling (node);
if (node == NULL)
return FALSE;
gtk_tree_model_css_node_get_iter_from_node (nodemodel, iter, node);
return TRUE;
}
static gboolean
gtk_tree_model_css_node_iter_children (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreeIter *parent)
{
GtkTreeModelCssNode *nodemodel = GTK_TREE_MODEL_CSS_NODE (tree_model);
GtkTreeModelCssNodePrivate *priv = nodemodel->priv;
GtkCssNode *node;
if (parent == NULL)
{
node = priv->root;
}
else
{
node = gtk_tree_model_css_node_get_node_from_iter (nodemodel, parent);
node = gtk_css_node_get_first_child (node);
}
if (node == NULL)
return FALSE;
gtk_tree_model_css_node_get_iter_from_node (nodemodel, iter, node);
return TRUE;
}
static gboolean
gtk_tree_model_css_node_iter_has_child (GtkTreeModel *tree_model,
GtkTreeIter *iter)
{
GtkTreeModelCssNode *nodemodel = GTK_TREE_MODEL_CSS_NODE (tree_model);
GtkCssNode *node;
node = gtk_tree_model_css_node_get_node_from_iter (nodemodel, iter);
return gtk_css_node_get_first_child (node) != NULL;
}
static gint
gtk_tree_model_css_node_iter_n_children (GtkTreeModel *tree_model,
GtkTreeIter *iter)
{
GtkTreeModelCssNode *nodemodel = GTK_TREE_MODEL_CSS_NODE (tree_model);
GtkTreeModelCssNodePrivate *priv = nodemodel->priv;
GtkCssNode *node;
if (iter == NULL)
return priv->root ? 1 : 0;
node = gtk_tree_model_css_node_get_node_from_iter (nodemodel, iter);
node = gtk_css_node_get_last_child (node);
if (node == NULL)
return 0;
return get_node_index (node) + 1;
}
static gboolean
gtk_tree_model_css_node_iter_nth_child (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreeIter *parent,
gint n)
{
GtkTreeModelCssNode *nodemodel = GTK_TREE_MODEL_CSS_NODE (tree_model);
GtkTreeModelCssNodePrivate *priv = nodemodel->priv;
GtkCssNode *node;
if (parent == NULL)
{
if (n > 0)
return FALSE;
node = priv->root;
}
else
{
node = gtk_tree_model_css_node_get_node_from_iter (nodemodel, parent);
node = get_nth_child (node, n);
}
if (node == NULL)
return FALSE;
gtk_tree_model_css_node_get_iter_from_node (nodemodel, iter, node);
return TRUE;
}
static gboolean
gtk_tree_model_css_node_iter_parent (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreeIter *child)
{
GtkTreeModelCssNode *nodemodel = GTK_TREE_MODEL_CSS_NODE (tree_model);
GtkTreeModelCssNodePrivate *priv = nodemodel->priv;
GtkCssNode *node;
node = gtk_tree_model_css_node_get_node_from_iter (nodemodel, child);
if (node == priv->root)
return FALSE;
node = gtk_css_node_get_parent (node);
gtk_tree_model_css_node_get_iter_from_node (nodemodel, iter, node);
return TRUE;
}
static void
gtk_tree_model_css_node_tree_model_init (GtkTreeModelIface *iface)
{
iface->get_flags = gtk_tree_model_css_node_get_flags;
iface->get_n_columns = gtk_tree_model_css_node_get_n_columns;
iface->get_column_type = gtk_tree_model_css_node_get_column_type;
iface->get_iter = gtk_tree_model_css_node_get_iter;
iface->get_path = gtk_tree_model_css_node_get_path;
iface->get_value = gtk_tree_model_css_node_get_value;
iface->iter_next = gtk_tree_model_css_node_iter_next;
iface->iter_previous = gtk_tree_model_css_node_iter_previous;
iface->iter_children = gtk_tree_model_css_node_iter_children;
iface->iter_has_child = gtk_tree_model_css_node_iter_has_child;
iface->iter_n_children = gtk_tree_model_css_node_iter_n_children;
iface->iter_nth_child = gtk_tree_model_css_node_iter_nth_child;
iface->iter_parent = gtk_tree_model_css_node_iter_parent;
}
static void
gtk_tree_model_css_node_finalize (GObject *object)
{
GtkTreeModelCssNode *model = GTK_TREE_MODEL_CSS_NODE (object);
GtkTreeModelCssNodePrivate *priv = model->priv;
if (priv->root)
{
gtk_tree_model_css_node_disconnect_node (model, priv->root, FALSE, NULL, NULL);
priv->root = NULL;
}
G_OBJECT_CLASS (gtk_tree_model_css_node_parent_class)->finalize (object);
}
static void
gtk_tree_model_css_node_class_init (GtkTreeModelCssNodeClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->finalize = gtk_tree_model_css_node_finalize;
}
static void
gtk_tree_model_css_node_init (GtkTreeModelCssNode *nodemodel)
{
nodemodel->priv = gtk_tree_model_css_node_get_instance_private (nodemodel);
}
GtkTreeModel *
gtk_tree_model_css_node_new (GtkTreeModelCssNodeGetFunc get_func,
gint n_columns,
...)
{
GtkTreeModel *result;
va_list args;
GType *types;
gint i;
g_return_val_if_fail (get_func != NULL, NULL);
g_return_val_if_fail (n_columns > 0, NULL);
types = g_new (GType, n_columns);
va_start (args, n_columns);
for (i = 0; i < n_columns; i++)
{
types[i] = va_arg (args, GType);
}
va_end (args);
result = gtk_tree_model_css_node_newv (get_func, n_columns, types);
g_free (types);
return result;
}
GtkTreeModel *
gtk_tree_model_css_node_newv (GtkTreeModelCssNodeGetFunc get_func,
gint n_columns,
GType *types)
{
GtkTreeModelCssNode *result;
GtkTreeModelCssNodePrivate *priv;
g_return_val_if_fail (get_func != NULL, NULL);
g_return_val_if_fail (n_columns > 0, NULL);
g_return_val_if_fail (types != NULL, NULL);
result = g_object_new (GTK_TYPE_TREE_MODEL_CSS_NODE, NULL);
priv = result->priv;
priv->get_func = get_func;
priv->n_columns = n_columns;
priv->column_types = g_memdup (types, sizeof (GType) * n_columns);
return GTK_TREE_MODEL (result);
}
static void
child_added_cb (GtkCssNode *node,
GtkCssNode *child,
GtkCssNode *previous,
GtkTreeModelCssNode *model)
{
gtk_tree_model_css_node_connect_node (model, child, TRUE);
}
static void
child_removed_cb (GtkCssNode *node,
GtkCssNode *child,
GtkCssNode *previous,
GtkTreeModelCssNode *model)
{
gtk_tree_model_css_node_disconnect_node (model, child, TRUE, node, previous);
}
static void
notify_cb (GtkCssNode *node,
GParamSpec *pspec,
GtkTreeModelCssNode *model)
{
GtkTreeIter iter;
GtkTreePath *path;
gtk_tree_model_css_node_get_iter_from_node (model, &iter, node);
path = gtk_tree_model_css_node_get_path (GTK_TREE_MODEL (model), &iter);
gtk_tree_model_row_changed (GTK_TREE_MODEL (model), path, &iter);
gtk_tree_path_free (path);
}
static void
style_changed_cb (GtkCssNode *node,
GtkCssStyle *old_style,
GtkCssStyle *new_style,
GtkTreeModelCssNode *model)
{
GtkTreeIter iter;
GtkTreePath *path;
gtk_tree_model_css_node_get_iter_from_node (model, &iter, node);
path = gtk_tree_model_css_node_get_path (GTK_TREE_MODEL (model), &iter);
gtk_tree_model_row_changed (GTK_TREE_MODEL (model), path, &iter);
gtk_tree_path_free (path);
}
static void
gtk_tree_model_css_node_connect_node (GtkTreeModelCssNode *model,
GtkCssNode *node,
gboolean emit_signal)
{
GtkCssNode *child;
g_object_ref (node);
g_signal_connect_after (node, "node-added", G_CALLBACK (child_added_cb), model);
g_signal_connect_after (node, "node-removed", G_CALLBACK (child_removed_cb), model);
g_signal_connect_after (node, "notify", G_CALLBACK (notify_cb), model);
g_signal_connect_after (node, "style-changed", G_CALLBACK (style_changed_cb), model);
for (child = gtk_css_node_get_first_child (node);
child;
child = gtk_css_node_get_next_sibling (child))
{
gtk_tree_model_css_node_connect_node (model, child, FALSE);
}
if (emit_signal)
{
GtkTreeIter iter;
GtkTreePath *path;
if (node != model->priv->root &&
gtk_css_node_get_previous_sibling (node) == NULL &&
gtk_css_node_get_next_sibling (node) == NULL)
{
/* We're the first child of the parent */
gtk_tree_model_css_node_get_iter_from_node (model, &iter, gtk_css_node_get_parent (node));
path = gtk_tree_model_css_node_get_path (GTK_TREE_MODEL (model), &iter);
gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (model), path, &iter);
gtk_tree_path_free (path);
}
gtk_tree_model_css_node_get_iter_from_node (model, &iter, node);
path = gtk_tree_model_css_node_get_path (GTK_TREE_MODEL (model), &iter);
gtk_tree_model_row_inserted (GTK_TREE_MODEL (model), path, &iter);
if (gtk_css_node_get_first_child (node))
gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (model), path, &iter);
gtk_tree_path_free (path);
}
}
static void
gtk_tree_model_css_node_disconnect_node (GtkTreeModelCssNode *model,
GtkCssNode *node,
gboolean emit_signal,
GtkCssNode *parent,
GtkCssNode *previous)
{
GtkCssNode *child;
g_signal_handlers_disconnect_by_func (node, G_CALLBACK (child_added_cb), model);
g_signal_handlers_disconnect_by_func (node, G_CALLBACK (child_removed_cb), model);
g_signal_handlers_disconnect_by_func (node, G_CALLBACK (notify_cb), model);
g_signal_handlers_disconnect_by_func (node, G_CALLBACK (style_changed_cb), model);
for (child = gtk_css_node_get_first_child (node);
child;
child = gtk_css_node_get_next_sibling (child))
{
gtk_tree_model_css_node_disconnect_node (model, child, FALSE, NULL, NULL);
}
if (emit_signal)
{
GtkTreeIter iter;
GtkTreePath *path;
if (parent)
{
gtk_tree_model_css_node_get_iter_from_node (model, &iter, parent);
path = gtk_tree_model_css_node_get_path (GTK_TREE_MODEL (model), &iter);
}
else
{
path = gtk_tree_path_new ();
}
if (previous)
gtk_tree_path_append_index (path, get_node_index (previous) + 1);
else
gtk_tree_path_append_index (path, 0);
gtk_tree_model_row_deleted (GTK_TREE_MODEL (model), path);
if (parent && gtk_css_node_get_first_child (parent) == NULL)
{
gtk_tree_path_up (path);
gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (model), path, &iter);
}
gtk_tree_path_free (path);
}
g_object_unref (node);
}
void
gtk_tree_model_css_node_set_root_node (GtkTreeModelCssNode *model,
GtkCssNode *node)
{
GtkTreeModelCssNodePrivate *priv;
g_return_if_fail (GTK_IS_TREE_MODEL_CSS_NODE (model));
g_return_if_fail (node == NULL || GTK_IS_CSS_NODE (node));
priv = model->priv;
if (priv->root == node)
return;
if (priv->root)
{
gtk_tree_model_css_node_disconnect_node (model, priv->root, TRUE, NULL, NULL);
priv->root = NULL;
}
if (node)
{
priv->root = node;
gtk_tree_model_css_node_connect_node (model, node, TRUE);
}
}
GtkCssNode *
gtk_tree_model_css_node_get_root_node (GtkTreeModelCssNode *model)
{
g_return_val_if_fail (GTK_IS_TREE_MODEL_CSS_NODE (model), NULL);
return model->priv->root;
}
GtkCssNode *
gtk_tree_model_css_node_get_node_from_iter (GtkTreeModelCssNode *model,
GtkTreeIter *iter)
{
g_return_val_if_fail (GTK_IS_TREE_MODEL_CSS_NODE (model), NULL);
g_return_val_if_fail (iter != NULL, NULL);
g_return_val_if_fail (iter->user_data == model, NULL);
g_return_val_if_fail (GTK_IS_CSS_NODE (iter->user_data2), NULL);
return iter->user_data2;
}
void
gtk_tree_model_css_node_get_iter_from_node (GtkTreeModelCssNode *model,
GtkTreeIter *iter,
GtkCssNode *node)
{
g_return_if_fail (GTK_IS_TREE_MODEL_CSS_NODE (model));
g_return_if_fail (iter != NULL);
g_return_if_fail (GTK_IS_CSS_NODE (node));
iter->user_data = model;
iter->user_data2 = node;
}
+80
View File
@@ -0,0 +1,80 @@
/* gtktreestore.h
* Copyright (C) 2014 Benjamin Otte <otte@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_TREE_MODEL_CSS_NODE_H__
#define __GTK_TREE_MODEL_CSS_NODE_H__
#include <gtk/gtktreemodel.h>
#include "gtk/gtkcssnodeprivate.h"
G_BEGIN_DECLS
#define GTK_TYPE_TREE_MODEL_CSS_NODE (gtk_tree_model_css_node_get_type ())
#define GTK_TREE_MODEL_CSS_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TREE_MODEL_CSS_NODE, GtkTreeModelCssNode))
#define GTK_TREE_MODEL_CSS_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TREE_MODEL_CSS_NODE, GtkTreeModelCssNodeClass))
#define GTK_IS_TREE_MODEL_CSS_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TREE_MODEL_CSS_NODE))
#define GTK_IS_TREE_MODEL_CSS_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TREE_MODEL_CSS_NODE))
#define GTK_TREE_MODEL_CSS_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TREE_MODEL_CSS_NODE, GtkTreeModelCssNodeClass))
typedef struct _GtkTreeModelCssNode GtkTreeModelCssNode;
typedef struct _GtkTreeModelCssNodeClass GtkTreeModelCssNodeClass;
typedef struct _GtkTreeModelCssNodePrivate GtkTreeModelCssNodePrivate;
typedef void (* GtkTreeModelCssNodeGetFunc) (GtkTreeModelCssNode *model,
GtkCssNode *node,
int column,
GValue *value);
struct _GtkTreeModelCssNode
{
GObject parent;
GtkTreeModelCssNodePrivate *priv;
};
struct _GtkTreeModelCssNodeClass
{
GObjectClass parent_class;
};
GType gtk_tree_model_css_node_get_type (void) G_GNUC_CONST;
GtkTreeModel *gtk_tree_model_css_node_new (GtkTreeModelCssNodeGetFunc get_func,
gint n_columns,
...);
GtkTreeModel *gtk_tree_model_css_node_newv (GtkTreeModelCssNodeGetFunc get_func,
gint n_columns,
GType *types);
void gtk_tree_model_css_node_set_root_node (GtkTreeModelCssNode *model,
GtkCssNode *node);
GtkCssNode *gtk_tree_model_css_node_get_root_node (GtkTreeModelCssNode *model);
GtkCssNode *gtk_tree_model_css_node_get_node_from_iter(GtkTreeModelCssNode *model,
GtkTreeIter *iter);
void gtk_tree_model_css_node_get_iter_from_node(GtkTreeModelCssNode *model,
GtkTreeIter *iter,
GtkCssNode *node);
G_END_DECLS
#endif /* __GTK_TREE_MODEL_CSS_NODE_H__ */
+2
View File
@@ -28,6 +28,7 @@
#include "cellrenderergraph.h"
#include "classes-list.h"
#include "css-editor.h"
#include "css-node-tree.h"
#include "data-list.h"
#include "general.h"
#include "gestures.h"
@@ -61,6 +62,7 @@ gtk_inspector_init (void)
g_type_ensure (GTK_TYPE_INSPECTOR_ACTIONS);
g_type_ensure (GTK_TYPE_INSPECTOR_CLASSES_LIST);
g_type_ensure (GTK_TYPE_INSPECTOR_CSS_EDITOR);
g_type_ensure (GTK_TYPE_INSPECTOR_CSS_NODE_TREE);
g_type_ensure (GTK_TYPE_INSPECTOR_DATA_LIST);
g_type_ensure (GTK_TYPE_INSPECTOR_GENERAL);
g_type_ensure (GTK_TYPE_INSPECTOR_GESTURES);
+14
View File
@@ -63,6 +63,10 @@ struct _GtkInspectorMiscInfoPrivate {
GtkWidget *framecount;
GtkWidget *accessible_role_row;
GtkWidget *accessible_role;
GtkWidget *accessible_name_row;
GtkWidget *accessible_name;
GtkWidget *accessible_description_row;
GtkWidget *accessible_description;
GtkWidget *mapped_row;
GtkWidget *mapped;
GtkWidget *realized_row;
@@ -316,6 +320,8 @@ update_info (gpointer data)
accessible = ATK_OBJECT (gtk_widget_get_accessible (GTK_WIDGET (sl->priv->object)));
role = atk_object_get_role (accessible);
gtk_label_set_text (GTK_LABEL (sl->priv->accessible_role), atk_role_get_name (role));
gtk_label_set_text (GTK_LABEL (sl->priv->accessible_name), atk_object_get_name (accessible));
gtk_label_set_text (GTK_LABEL (sl->priv->accessible_description), atk_object_get_description (accessible));
gtk_widget_set_visible (sl->priv->mapped, gtk_widget_get_mapped (GTK_WIDGET (sl->priv->object)));
gtk_widget_set_visible (sl->priv->realized, gtk_widget_get_realized (GTK_WIDGET (sl->priv->object)));
gtk_widget_set_visible (sl->priv->is_toplevel, gtk_widget_is_toplevel (GTK_WIDGET (sl->priv->object)));
@@ -407,6 +413,8 @@ gtk_inspector_misc_info_set_object (GtkInspectorMiscInfo *sl,
gtk_widget_show (sl->priv->mnemonic_label_row);
gtk_widget_show (sl->priv->tick_callback_row);
gtk_widget_show (sl->priv->accessible_role_row);
gtk_widget_show (sl->priv->accessible_name_row);
gtk_widget_show (sl->priv->accessible_description_row);
gtk_widget_show (sl->priv->mapped_row);
gtk_widget_show (sl->priv->realized_row);
gtk_widget_show (sl->priv->is_toplevel_row);
@@ -426,6 +434,8 @@ gtk_inspector_misc_info_set_object (GtkInspectorMiscInfo *sl,
gtk_widget_hide (sl->priv->clip_area_row);
gtk_widget_hide (sl->priv->tick_callback_row);
gtk_widget_hide (sl->priv->accessible_role_row);
gtk_widget_hide (sl->priv->accessible_name_row);
gtk_widget_hide (sl->priv->accessible_description_row);
gtk_widget_hide (sl->priv->mapped_row);
gtk_widget_hide (sl->priv->realized_row);
gtk_widget_hide (sl->priv->is_toplevel_row);
@@ -581,6 +591,10 @@ gtk_inspector_misc_info_class_init (GtkInspectorMiscInfoClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, framerate);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, accessible_role_row);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, accessible_role);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, accessible_name_row);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, accessible_name);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, accessible_description_row);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, accessible_description);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, mapped_row);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, mapped);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, realized_row);
+68
View File
@@ -491,6 +491,74 @@
</object>
</child>
<child>
<object class="GtkListBoxRow" id="accessible_name_row">
<property name="visible">true</property>
<property name="activatable">false</property>
<child>
<object class="GtkBox">
<property name="visible">true</property>
<property name="orientation">horizontal</property>
<property name="margin">10</property>
<property name="spacing">40</property>
<child>
<object class="GtkLabel">
<property name="visible">true</property>
<property name="label" translatable="yes">Accessible name</property>
<property name="halign">start</property>
<property name="valign">baseline</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">true</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="accessible_name">
<property name="visible">true</property>
<property name="halign">end</property>
<property name="valign">baseline</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow" id="accessible_description_row">
<property name="visible">true</property>
<property name="activatable">false</property>
<child>
<object class="GtkBox">
<property name="visible">true</property>
<property name="orientation">horizontal</property>
<property name="margin">10</property>
<property name="spacing">40</property>
<child>
<object class="GtkLabel">
<property name="visible">true</property>
<property name="label" translatable="yes">Accessible description</property>
<property name="halign">start</property>
<property name="valign">baseline</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">true</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="accessible_description">
<property name="visible">true</property>
<property name="halign">end</property>
<property name="valign">baseline</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow" id="mapped_row">
<property name="visible">true</property>
+2
View File
@@ -13,6 +13,8 @@ N_("Tick callback");
N_("Frame count");
N_("Frame rate");
N_("Accessible role");
N_("Accessible name");
N_("Accessible description");
N_("Mapped");
N_("Realized");
N_("Is Toplevel");
+1
View File
@@ -161,6 +161,7 @@
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="selectable">True</property>
<property name="label" translatable="yes">Enable statistics with GOBJECT_DEBUG=instance-count</property>
</object>
</child>
+3
View File
@@ -31,6 +31,7 @@
#include "prop-list.h"
#include "classes-list.h"
#include "css-editor.h"
#include "css-node-tree.h"
#include "object-hierarchy.h"
#include "object-tree.h"
#include "selector.h"
@@ -71,6 +72,7 @@ set_selected_object (GtkInspectorWindow *iw,
gtk_inspector_misc_info_set_object (GTK_INSPECTOR_MISC_INFO (iw->misc_info), selected);
gtk_inspector_classes_list_set_object (GTK_INSPECTOR_CLASSES_LIST (iw->classes_list), selected);
gtk_inspector_css_editor_set_object (GTK_INSPECTOR_CSS_EDITOR (iw->widget_css_editor), selected);
gtk_inspector_css_node_tree_set_object (GTK_INSPECTOR_CSS_NODE_TREE (iw->widget_css_node_tree), selected);
gtk_inspector_size_groups_set_object (GTK_INSPECTOR_SIZE_GROUPS (iw->size_groups), selected);
gtk_inspector_data_list_set_object (GTK_INSPECTOR_DATA_LIST (iw->data_list), selected);
gtk_inspector_actions_set_object (GTK_INSPECTOR_ACTIONS (iw->actions), selected);
@@ -228,6 +230,7 @@ gtk_inspector_window_class_init (GtkInspectorWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, classes_list);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, style_prop_list);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, widget_css_editor);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, widget_css_node_tree);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_hierarchy);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, selector);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, size_groups);
+1
View File
@@ -57,6 +57,7 @@ typedef struct
GtkWidget *style_prop_list;
GtkWidget *classes_list;
GtkWidget *widget_css_editor;
GtkWidget *widget_css_node_tree;
GtkWidget *object_hierarchy;
GtkWidget *size_groups;
GtkWidget *data_list;
+9
View File
@@ -319,6 +319,15 @@
<property name="title" translatable="yes">Style Properties</property>
</packing>
</child>
<child>
<object class="GtkInspectorCssNodeTree" id="widget_css_node_tree">
<property name="visible">True</property>
</object>
<packing>
<property name="name">css-nodes</property>
<property name="title" translatable="yes">CSS nodes</property>
</packing>
</child>
<child>
<object class="GtkInspectorCssEditor" id="widget_css_editor">
<property name="global">False</property>

Some files were not shown because too many files have changed in this diff Show More