Compare commits

...

118 Commits

Author SHA1 Message Date
Matthias Clasen 8dda7ca6b5 Build fix for GtkCssValues 2020-01-31 11:01:21 +01:00
Daniel Mustieles 9f55377b69 Updated Spanish translation 2020-01-31 09:09:43 +01:00
Matthias Clasen f140b151e1 Merge branch 'meson-sassc-subproject' into 'master'
build: require sassc and drop generated .css files

See merge request GNOME/gtk!814
2020-01-31 07:26:48 +00:00
Matthias Clasen c91c4b60e7 Merge branch 'kill-primary-monitor-2' into 'master'
Remove primary monitor api

See merge request GNOME/gtk!1371
2020-01-30 20:51:07 +00:00
Matthias Clasen a46f9af1c0 Remove primary monitor api
We only have implementations of this on X11 and Win32,
so make it available as backend api there.

Update all callers to use either the backend api, or
just monitor 0.
2020-01-30 21:33:37 +01:00
Christoph Reiter 4071e1e734 build: require sassc and drop generated .css files
Instead of requiring sassc to be installed add meson subprojects
which build libsass and sassc (currently both forks of mine, tested
under linux/mingw/msvc) when needed.

This allows us to drop the generated .css files and build scripts from git.

See #1502
2020-01-30 20:45:38 +01:00
Alexander Larsson 99c89d61e1 Merge branch 'icon-theme-rework' into 'master'
Rework icon themes

See merge request GNOME/gtk!1368
2020-01-30 17:30:10 +00:00
Alexander Larsson 09ef67afbc icon-theme: Add icon theme name in profiler mark 2020-01-30 18:22:11 +01:00
Alexander Larsson d478ae1ef5 icon-theme: Avoid reentrancy issues while loading icon theme
In gtk_icon_theme_get_for_display() we were calling
gtk_icon_theme_set_display() which eventually (via the css machinery)
called back into gtk_icon_theme_get_for_display() which created a
second icon theme. We avoid this by setting the user-data earlier so
that the css machinery gets back the currently initializing theme
instead.
2020-01-30 18:19:56 +01:00
Alexander Larsson b67d582230 GtkIconHelper: Preload icons for mapped widgets with higher priority
We look at whether a widget will be mapped (the actual state is not
yet set, so we can't rely on that at css validation time) and use
that to set the i/o priority of the async task.

This means that its likely that widgets that will be displayed soon
are loaded before those that are not yet going to be needed.
2020-01-30 15:41:24 +01:00
Alexander Larsson 498ab6ac6c IconHelper: Only preload icons once
This limits the amount of preloading we to, which can for instance
avoid trashing if the icon cache is full, and in general do less work
when its likely to be wasted such as when e.g. background-color for an
icon helper changes.
2020-01-30 15:17:59 +01:00
Alexander Larsson c69327caa8 icon-theme: Show which icon loads are threaded in profile mark 2020-01-30 15:16:40 +01:00
Alexander Larsson d1cd578d59 icon-theme: Add i/o priority to choose_icon_async()
This is set on the GTask and lower priority will be loaded before,
this can be used to prioritize some icons for preloading.
2020-01-30 15:15:08 +01:00
Alexander Larsson 5f8c2b52c6 indentation: fix various alignment issues
Most of these stem from the GtkIconInfo -> GtkIcon rename
2020-01-30 12:27:15 +01:00
Alexander Larsson 27799ba4f5 Remove final references to "icon info" with just "icon" 2020-01-30 10:53:43 +01:00
Alexander Larsson 2ec51b7010 icon-theme: Update the docs 2020-01-30 10:53:43 +01:00
Alexander Larsson f7cd2a782b Fix warnings in gdk gir build
We now have graphene arguments in a gdk function, so add that to the
dependencies.
2020-01-30 10:53:43 +01:00
Alexander Larsson ff0642bba6 icon-theme: Remove trailing whitespaces
Since everything is changing anyway lets just clean up all the
trailing whitespace issues in the whole file.
2020-01-30 10:53:43 +01:00
Alexander Larsson b227a2f190 icon-theme: Use GtkSnapshot, not GdkSnapshot 2020-01-30 10:53:43 +01:00
Alexander Larsson 2b202129bb icon-theme: Fix indentation of matrix values 2020-01-30 10:53:43 +01:00
Alexander Larsson d1c6d78ebb GtkImage: Preload icons during css validation
At the end of GtkImage css validation (during style-updated) when the
css properties (like the icon size) are valid we call _gtk_icon_helper_preload
which does an async icon theme lookup and load. This will happen on a thread
in parallel with the rest of the css machinery, and hopefully by the
time we need the icon it will be ready. If not we will block when we need
it, but during that blocking all the other icons will be loaded.

Testing widget-factory this changes the time of snapshot() from 31 to
25 msec, but on the other hand we also load a few more icons that we
didn't before causing the css validation phase to be about 8 msec slower.
This is because we're preloading all the images in the window, not only
the ones that are visible.

Unfortunately we still load a bunch of icons in snapshot(), from
GtkCssImageIconTheme, and ideally we should try to preload those also.
2020-01-30 10:53:43 +01:00
Alexander Larsson 6a8001fe7d icon-theme: Preload default icon themes in thread
This happens when we first get the theme for a display, or then the
icon theme setting changes.

This means we don't have to do this scan in the first snapshot
and can do the i/o it in parallel with other stuff. This moves
a 10msec block from the first snapshot cycle to early setup.
2020-01-30 10:53:43 +01:00
Alexander Larsson ff3e022182 icon helper: Remove profiler mark
This was hitting every time we looked up an icon, and we already
log the actual load of the icon in the icon theme.
2020-01-30 10:53:43 +01:00
Alexander Larsson d2f26b2f27 icon-theme: Improve profiler mark for icon loads
This adds the actual time it took to them as well as the icon size
and scale.
2020-01-30 10:53:43 +01:00
Alexander Larsson 55db9d07c5 icon-theme: Only add theme load profiler mark if we actually load theme 2020-01-30 10:53:43 +01:00
Alexander Larsson 1be932279c icon theme: Actually use scale in choose_icon_async() 2020-01-30 10:53:43 +01:00
Alexander Larsson 56ec748824 icon theme: Actually don't block in gtk_icon_theme_choose_icon_async()
If some other thread is lock the icon or icon theme locks they are likely
to do so for a long time, doing i/o. So, switch to trylock() for the
nonblocking part of _async(). This way we can return directly if the
result is available, but do a thread otherwise, never blocking the
calling (main) thread.
2020-01-30 10:53:43 +01:00
Alexander Larsson 1e6a82513b icon-theme: Clean up locking
Move the lru cache under the global cache lock to avoid some ABBA
style deadlocks when going from icon_theme->icon lock an icon->icon_theme.
We also move all the icon lock uses to a small part of code and make
sure that code never calls out or blocks with any locks held.

Rename the GtkIcon->cache_lock to texture_lock to avoid confusion withe
the global cache_lock.

Removed any mentions of threadsafety from the API docs, we don't
want apps to rely on this, but rather use it outselves internally.
2020-01-30 10:53:43 +01:00
Alexander Larsson b087f9ca51 icon-theme: Drop the _for_scale() versions and always take scale 2020-01-30 10:53:43 +01:00
Alexander Larsson e2f778602b icon-theme: Rename GtkIconInfo to GtkIcon 2020-01-30 10:53:43 +01:00
Alexander Larsson 6a15e9169d Rename GtkIcon widget to GtkBuiltinIcon
This is an internal widget whose name is not very important, and we
want to rename GtkIconInfo to GtkIcon, so lets rename this.
2020-01-30 10:53:33 +01:00
Matthias Clasen 929d325560 profiler: Exit gracefully on SIGTERM
This is nice, since it lets me quickly launch a test app
and terminate it with Ctrl-C and still produce a usable
sysprof trace.
2020-01-30 10:04:38 +01:00
Matthias Clasen cb60c1b83d builder: Add profiler marks for parsing
This is useful to understand what ui files take
long to load.
2020-01-30 10:04:38 +01:00
Matthias Clasen ab69d43089 builder: Use a better name for templates
This name can show up in error messages or profiler
traces, so it is nice to provide some hint what
file we are dealing with.
<GtkFileChoser template> is a lot more helpful
than <input>.
2020-01-30 10:04:38 +01:00
Alexander Larsson 6af4b6a644 icon-theme: Drop all load() calls from GtkIconInfo
All users now either use it directly as a paintable or download
the texture to use the pixels.
2020-01-29 19:12:15 +01:00
Alexander Larsson 0d666f0cec icon-theme: Use gtk_icon_theme_choose_icon_async in tests 2020-01-29 19:06:16 +01:00
Alexander Larsson 317b395f0f icon-theme: Drop loading_themes recursion check
This was added in 0b1c9b7cc2 to protect
against reentrancy from the theme-changed signal, but we only emit this
from an idle these days, so thats not necessary anymore, and the recursion
check was causing issues with the async operations where a different
thread loading the theme caused the calling thread to thing the
theme is valid.
2020-01-29 19:06:16 +01:00
Alexander Larsson 71b3b54215 icon-theme: Add async icon loader 2020-01-29 19:06:16 +01:00
Alexander Larsson 97b24b0732 tests: Use gtk_icon_info_download_colored_texture instead of load_symbolic 2020-01-29 19:06:16 +01:00
Alexander Larsson 6ffb54f47f icon-theme: Add gtk_icon_info_download_colored_texture()
This is a way to get at recolored pixels and will replace all existing users
of _load_symbolic*()
2020-01-29 19:06:16 +01:00
Alexander Larsson afa6cc2369 Break out cairo color matrix recoloring to gdk_cairo_image_surface_recolor()
This is useful in some parts of the icon theme APIs.
2020-01-29 19:06:16 +01:00
Alexander Larsson dbe021239f icons: Convert use of load() to download_texture() 2020-01-29 19:06:16 +01:00
Alexander Larsson 884e06ad37 icon theme: Add gtk_icon_info_download_texture() function
This returns a reference to the texture (if possible) and can be
used to get access to the pixels of the icon.
2020-01-29 19:06:16 +01:00
Alexander Larsson 53c542765f Add gtk_icon_info_snapshot_with_colors() and use instead of custom code 2020-01-29 19:06:16 +01:00
Alexander Larsson c42977af04 Convert trivial users of icon theme loading to use info as paintable 2020-01-29 19:06:16 +01:00
Alexander Larsson aefd8443de GtkIconHelper use GtkIconInfo as paintable 2020-01-29 19:06:16 +01:00
Alexander Larsson b96ab7453b GtkIconInfo: Implement paintable
This makes GtkIconInfo directly implement paintable by loading
the icon as needed. This is done in a blocking fashion for now, but
could be made more async in the future.

It also means we can't return errors to the called, but I doubt
anyone actually does anything useful with them other than showing
nothing (which we already do).

This also changes a fringe behaviour for unthemed icons. They used to
be never scaled down, but that means we can't tell without i/o the
size of the paintable. Since this is the only case we can't know the
size i took an executive decision and removed that behaviour. I don't
think picking some arbitrary much larger than requested size is ever
right, nor do i think using GtkIconTheme with unthemed icons is overly
useful. If you want to display some random non-iconish image, use
GtkImage instead.
2020-01-29 19:06:16 +01:00
Alexander Larsson 3ac7e30455 icon theme: Make GtkIconInfo cached data threadsafe
Whenever this is accessed or updated we just grab a lock, thus
blocking on whoever is currenly updating it.
2020-01-29 19:06:16 +01:00
Alexander Larsson aef67bd53a GtkIconTheme: Make the base GtkIconTheme threadsafe
This makes the core icon theme object threadsafe, however its
not yet very useful because the IconInfo objects are not threadsafe.
2020-01-29 19:06:16 +01:00
Piotr Drąg bba5de7c6d Update POTFILES.skip 2020-01-29 17:20:23 +01:00
Emmanuele Bassi 556a8a8351 Merge branch 'wip/muktupavels/work-areas' into 'master'
per-monitor work areas

Closes #1086 and #980

See merge request GNOME/gtk!1300
2020-01-29 13:38:31 +00:00
Matthias Clasen 5e95e15a03 animatedstyle: Fix the debug build
This wasn't caught by our ci.
2020-01-29 14:10:24 +01:00
Alberts Muktupāvels 248883089c x11: add support for _GTK_WORKAREAS_Dn
If window manager supports _GTK_WORKAREAS use per-monitor work areas.

https://mail.gnome.org/archives/wm-spec-list/2018-December/msg00000.html
https://gitlab.freedesktop.org/xdg/xdg-specs/merge_requests/22

https://gitlab.gnome.org/GNOME/gtk/merge_requests/1300
2020-01-29 14:38:08 +02:00
Carlos Garnacho aabb250741 Merge branch 'gtk-4-im-wayland-controller-focus-in' into 'master'
imwayland: Connect gtk_im_context_focus_in/out to GtkEventControllerKey

See merge request GNOME/gtk!1349
2020-01-29 11:22:11 +00:00
Matthias Clasen 83cccfc984 Merge branch 'gdk-device-leak-fix' into 'master'
GdkDevice leak fix

See merge request GNOME/gtk!1358
2020-01-29 10:44:42 +00:00
Matthias Clasen b97054fc38 Merge branch 'css-style-split-2' into 'master'
css: Split styles into groups

See merge request GNOME/gtk!1362
2020-01-29 10:39:43 +00:00
Matthias Clasen b859407620 Merge branch 'reset-with-click' into 'master'
Always emit reset for IM preedit with mouse click

Closes #1534

See merge request GNOME/gtk!460
2020-01-29 10:39:22 +00:00
Matthias Clasen 75c73ac3cd Merge branch 'robertroth/shortcuts-overlay-accel' into 'master'
Application: Do not reuse Ctrl+F1 for help-overlay

See merge request GNOME/gtk!307
2020-01-29 10:25:40 +00:00
Matthias Clasen 10e4c04e61 Use style values directly
Replace uses of gtk_css_style_get_value with direct access,
throughout the tree. We don't replace all uses, just those
where we are dealing with a fixed property. Be careful to
handle the currentColor special case for color properties.
2020-01-29 11:07:32 +01:00
Matthias Clasen b378f566d7 Compute style change based on values structs
We can save some time here by comparing struct by
struct and avoiding individual values comparisons
as much as possible.
2020-01-29 11:07:32 +01:00
Matthias Clasen 5776d0dd99 css: Split styles into groups
Introduce refcounted structs for groups of related css properties,
and use them to store the style values. Both GtkCssStaticStyle and
GtkCssAnimatedStyle fill in the structs in GtkCssStyle, and we
can avoid vfuncs for value access, which should be much faster.
We can even start accessing style->core->color directly.
2020-01-29 11:07:32 +01:00
Matthias Clasen 59994bdd22 performance test: Produce better numbers
Try to isolate the test runs from each other in the
eyes of the kernel scheduler, by sleeping a bit. And
ignore the first run, to avoid cache effects.
2020-01-29 11:06:32 +01:00
Matthias Clasen db8276f470 Merge branch 'wip/baedert/widget-add-style-class' into 'master'
widget: Add style class API

See merge request GNOME/gtk!1366
2020-01-29 09:46:36 +00:00
Matthias Clasen c3421cea25 Silence a compiler warning 2020-01-29 10:44:25 +01:00
Emmanuele Bassi 6830845fda Merge branch 'gtk-doc-ci' into 'master'
Publish the API reference

See merge request GNOME/gtk!1367
2020-01-29 09:11:15 +00:00
Emmanuele Bassi db5d9ccdfb Remove reftests from expected-fail list
With an updated version of the base CI image it seems some tests that
were failing have started to pass again.
2020-01-29 10:02:02 +01:00
Emmanuele Bassi 51e155bffa ci: Deploy the API reference on our GitLab pages
Now that we can build gtk-doc as a sub-project, we can go back to
publishing the API reference for the master branch every time we
build it.
2020-01-29 09:46:13 +01:00
Emmanuele Bassi 98e6e0cf77 ci: Update the version of Meson in the CI image
We need at least 0.52.1 to be able to use gtk-doc as a sub-project.
2020-01-29 09:39:21 +01:00
Emmanuele Bassi 058f82d03d Add gtk-doc as a subproject
We rely on a specific minimum version of gtk-doc to be able to build the
GTK API reference for the new API. In order to be able to use gtk-doc as
a subproject, though, we need to use a recent version of Meson.
2020-01-29 09:39:21 +01:00
Timm Bäder a7b34df6af widget: Add style class API
Add GtkWidget API for adding and removing style classes, as well as
checking whether a widget has a style class applied.

Everyone has to go through GtkStyleContext for this these days but with
GtkStyleContext eventually going away, it makse sense for GtkWidget to
have API for this.
2020-01-29 09:36:48 +01:00
Timm Bäder b3f454ed98 Merge branch 'fix-doc-typo' into 'master'
Fix a doc typo

See merge request GNOME/gtk!1364
2020-01-29 07:49:13 +00:00
Benjamin Otte fd021e794c Merge branch 'wip/otte/for-master' into 'master'
Wip/otte/for master

See merge request GNOME/gtk!1365
2020-01-29 04:35:56 +00:00
Benjamin Otte 5e3cbff8d2 cssselector: Rework how we handle the bloom filter
Instead of foreaching through all the previous selectors every time we
bloom-filter, just bloom-filter the current element and return a special
value if that filter fails (FALSE). If that happens, don't try
filter-matching more nodes in the caller as we know it's an abort.
2020-01-29 04:20:47 +01:00
Luca Bacci f0fe2e0743 Fix a doc typo 2020-01-28 20:42:03 +00:00
Benjamin Otte c6158f1684 cssselector: Reorder functions
This just changes the order of functions in the source code in
preparation for the next commit.
2020-01-28 18:28:32 +01:00
Benjamin Otte 65050a1c81 css: Don't do the "all set" test
We have so many properties that it is basically impossible that all of
them are set and the time spent checking is higher than the time saved
if it does indeed happen.
2020-01-28 17:57:59 +01:00
Benjamin Otte 12ec090a7b Merge branch 'wip/otte/for-master' into 'master'
popover: Do not validate the css node on show()

See merge request GNOME/gtk!1363
2020-01-28 16:43:33 +00:00
Benjamin Otte 17ca95a161 popover: Do not validate the css node on show()
This was a good idea back in GTK3 when popovers were toplevels, but now
they're regular child widgets, so they should behave that way.

Also, with the introduction of the bloom filter, gtk_css_node_validate()
now assumes it's only called on root nodes, so assert that that is the
case.
2020-01-28 17:19:28 +01:00
Takao Fujiwara 5be14577d6 imwayland: Connect gtk_im_context_focus_in/out to GtkEventControllerKey
GtkEventControllerKey can handle GDK_FOCUS_CHANGE and call
gtk_im_context_focus_in/out directly.

https://gitlab.gnome.org/GNOME/gtk/issues/2390
2020-01-28 23:47:16 +09:00
Benjamin Otte 1a9ab1a32f Merge branch 'wip/otte/css' into 'master'
selector: Rework iterating over subnodes

See merge request GNOME/gtk!1361
2020-01-28 03:56:49 +00:00
Benjamin Otte c7dca199ae selector: Rework iterating over subnodes
Instead of a foreach() function, introduce an iterator, so that the
caller can drive the iteration.

This allows doing stuff inbetween callbacks and avoids closures when
more than one data object should be passed.

As a side effect I even get a small, but noticeable performance
improvement in the 2-10% range depending on benchmark, I guess that's
because there's no function pointer passing going on anymore.
2020-01-28 04:32:15 +01:00
Benjamin Otte 50a3d9be6a Merge branch 'wip/otte/css' into 'master'
CSS improvements

See merge request GNOME/gtk!1360
2020-01-28 02:47:25 +00:00
Benjamin Otte 5e4b102273 styleproperty: Remove ability to query properties
With gtk_style_context_get() gone, this is no longer used.
2020-01-28 02:58:02 +01:00
Benjamin Otte 632fab0ca7 stylecontext: Get rid of gtk_style_context_get()
... and replace all the calls to it with
gtk_style_context_peek_property().

All the calls are hacks that need to go away btw.
2020-01-28 02:58:02 +01:00
Benjamin Otte 43339f1c1c testcalendar: Don't do dumb stuff with font sizes.
If you want to test font stuff, it's 2020 and we have an inspector.
2020-01-28 02:17:32 +01:00
Benjamin Otte afbff574f5 filechooser: Remove default size machinery
The FileChooser ToolKit (fctk) had its own machinery to handle default
sizes which was completely busted and trying to marshal random numbers
through the widget hierarchy that maybe made sense in 2012 but don't do
now.

Get rid of it, just keep the dialog's GSetting - which funnily enough
used to be written by the dialog but written by the widget.
But that's fctk for you.
2020-01-28 02:17:31 +01:00
Benjamin Otte aff25212df cellrenderertoggle: size based on -gtk-icon-size
Instead of hardcoding 16px.
2020-01-28 02:17:03 +01:00
Benjamin Otte 18cb15a05a stylecontext: Remove gtk_style_context_get_section()
The inspectors gets values differently these days.
2020-01-28 02:17:03 +01:00
Benjamin Otte 6c8b65baf9 stylecontext: Remove GTK_STYLE_PROPERTY_* defines
They shouldn't be (and aren't) used anymore.
2020-01-28 02:17:03 +01:00
Benjamin Otte 495eaf31d4 css: Use the bloom filter for change matching
Instead of just doing radical change matching on the node itself, also
consider the parent nodes via the bloom filter.

This means a radical change is now also one where the parent
name/id/classes change, but since that's considered a radical change on
the parent already, those things are slow anyway.

Improves the benchmark times for CSS validation during backdrop
transitions in widget-factory from 45ms to 35ms on my machine.
2020-01-28 02:17:03 +01:00
Benjamin Otte ccdc3ee406 selector: Make :not() selectors not radical
:not() selectors cannot be radical because the bloomfilter only knows if
a value is set in any of the nodes, but cannot determine the opposite
(if a value is not set in at least one node), but that would be required
for:not() selectors.
However, this is very unlikely to happen in the real world, so it's not
worth optimizing.

Unfortunately, change tracking could know this, so by excluding the
:not() selectors from radical changes, the change tracking will now pick
them up. If that turns out to be a performance problem, we need to add a
special category for radical not filters, so change tracking and bloom
filters can deal with them.

The testcase demonstrating the problem in widget-factory has been
extrated and added.
2020-01-28 02:17:03 +01:00
Benjamin Otte 93cf76b068 testsuite: Improve diff_with_file() function
Properly handle diff(1) failing.

In this particular case, the test passed a NULL input file to the diff
(that was fixed, too) and then diff only found one input file and
aborted.

But without this fix, we'd also not catch other abortion reasons for
diff() - as long as it exited in any way, we were happy.
2020-01-28 02:17:03 +01:00
Benjamin Otte 170130f1d9 css: Add fast-path for parent selector matching
Add a fast path for parent selector matching that uses a bloom filter to
quickly discard selectors that can't possibly match.

Keep in mind that we match using a bloom filter, so we might
accidentally include too many selectors when hash/bucket collisions
occur.
That's not a correctness problem though, because we'll do a real check
afterwards.

The idea for this change is taken from browsers, in particular WebKit.
2020-01-28 02:17:03 +01:00
Benjamin Otte 6aac56e144 cssnodedeclaration: C99-ify the code
zero-sized arrays are allowed now.
2020-01-28 02:17:03 +01:00
Benjamin Otte 2d5a8974b3 selector: Hash differently
This will be relevant for a bloom filter. And bloom filters want 12bit
hashes, so we try to produce hash values < 4096.
2020-01-28 02:17:03 +01:00
Benjamin Otte 146b921246 cssnode: Convert name + id from interned string to GQuark
The reason for this is simply that I want to get hash functions that
have their values close together, so they can fit in a smaller range
(the goal here is 12 bits). By using GQuark, we get consecutive numbers
starting with 1 (and applications have <1000 quarks usually), whereas
interned strings can be all over the place.

As a side effect we also save 64 bytes per declaration.
2020-01-28 02:17:03 +01:00
Benjamin Otte 8b93ea9238 css: Get rid of GtkCssMatcher 2020-01-28 02:17:02 +01:00
Benjamin Otte aa7c5e96a6 css: Pass node through the lookup code
... instead of passing a matcher.

The matcher code is now local to the CssProvider/CssSelector machinery.
2020-01-28 02:17:02 +01:00
Benjamin Otte 1953bc92bc cssnode: Remove init_matcher() vfunc
It's unused.
2020-01-28 02:17:02 +01:00
Benjamin Otte 98eeee5bce cssnode: Remove ability to set GType as fallback name 2020-01-28 02:17:02 +01:00
Benjamin Otte 49b47c9133 Remove GtkWidgetPath
... and all associated demos and tests.
2020-01-28 02:17:02 +01:00
Benjamin Otte af6128b3ab Remove gtkwidgetpath.h include where no longer needed 2020-01-28 02:17:02 +01:00
Benjamin Otte 496f3c17bd Revert "cssmatcher: Inline node values into matcher"
This reverts commit a75529f3c0.

It just complicates code and there are no performance numbers that would
warrant such a commit.
2020-01-28 02:17:02 +01:00
Benjamin Otte c2d69643a8 css: Move utility function
The function was not selector-specific, so putting it with all the other
utility functions makes more sense.

Also use the utility function in the node declaration printing.
2020-01-28 02:17:02 +01:00
Sebastian Keller 9c6669be48 gdk/x11: Properly unref removed device in XI2 device manager
When a device is added, there are two references to it by the device
manager, the initial one and the one used for the id_table. Removing a
device only removed the reference added by the id_table resulting in the
GdkDevice being leaked.

https://gitlab.gnome.org/GNOME/gtk/merge_requests/1358
2020-01-27 21:42:34 +01:00
Matthias Clasen d0aa79b5a1 textutil: Stop using GtkStyleContext
We can just use the css style directly.
2020-01-27 13:35:04 -05:00
Matthias Clasen 4b63523b1f gskpango: Don't free rgba's we don't own
We don't copy them anymore, so don't free them.
2020-01-27 13:35:04 -05:00
Matthias Clasen 997186f640 filechooser: Stop using gtk_style_context_get
Just go to the css style directly.
2020-01-27 12:52:24 -05:00
Rafael Fontenelle 3940482820 Update Brazilian Portuguese translation 2020-01-27 17:09:32 +00:00
Timm Bäder 616a83fb53 popover: Fix an oversight in gap coord computation
This caused a border to show up between the popover arrow and the
contents.
2020-01-27 13:37:50 +01:00
Timm Bäder baeadea342 calendar: Use widgets for the header
This is not meant to be a full GtkCalendar conversion to use widgets
instead of custom drawing, but we lost the arrows in the calendar header
when builtin icons were removed. Using proper button for the year/month
buttons brings them back.
2020-01-27 13:37:50 +01:00
Umarzuki Bin Mochlis Moktar 04beedfef0 Update Malay translation 2020-01-27 12:25:12 +00:00
Umarzuki Bin Mochlis Moktar da73394abd Update Malay translation 2020-01-27 12:22:47 +00:00
Fabio Tomat d0f69794a5 Update Friulian translation 2020-01-27 08:56:42 +00:00
Dušan Kazik 185ef214fa Update Slovak translation 2020-01-27 07:01:51 +00:00
Sebastian Keller 5040d81e03 gdkseatdefault: Unref removed slave devices
Adding a slave device adds a ref, but removing it does not unref it.

https://gitlab.gnome.org/GNOME/gtk/merge_requests/1358
2020-01-27 01:37:14 +01:00
Takao Fujiwara 4b2e4f6628 Always emit reset for IM preedit with mouse click
Hangul inputs treat pre-edit text as output text and the pre-edit
text won't be moved with mouse click.
Now the reset signal is always emitted simply with mouse click and
each IM engine could handle the signal whether the preedit is committed,
cleared or kept.

Closes #1534
2019-02-20 18:58:51 +09:00
Daniel Boles 4b96e7fc78 Application: Do not reuse Ctrl+F1 for help-overlay
It just gets overridden to do something else, as the 1st GtkWidget’s
class_init() adds it as a binding to toggle tooltips with the keyboard.
The last entity to hook it (& return TRUE) is the only one who gets it.

So, worse: If users needed to manually set accels for a ShortcutsWindow,
coincidentally waited until after the 1st GtkWidget init() to do it, &
copied what GtkApplication said in an attempt to be good & consistent —
they inadvertently broke the keyboard tooltips (except for users with a
GDK_KEY_KP_F1 – whatever that is) as their handler blocked GtkWidget’s.

So, one side has to drop this accelerator, and it seems clear that being
able to open tooltips with the keyboard is more important than having a
second accel for the help-overlay. We can make up a replacement later.

https://gitlab.gnome.org/GNOME/gtk/issues/626
2018-08-24 14:51:21 +03:00
199 changed files with 24477 additions and 28324 deletions
+18 -18
View File
@@ -1,7 +1,7 @@
stages:
- build
- flatpak
# - deploy
- deploy
.cache-paths: &cache-paths
paths:
@@ -13,7 +13,7 @@ stages:
- subprojects/pango/
fedora-x86_64: &fedora-x86_64-defaults
image: registry.gitlab.gnome.org/gnome/gtk/master:v9
image: registry.gitlab.gnome.org/gnome/gtk/master:v10
stage: build
script:
- bash -x ./.gitlab-ci/test-docker.sh
@@ -107,19 +107,19 @@ flatpak-master:icon-browser:
APPID: org.gtk.IconBrowser4
<<: *flatpak-master
#pages:
# image: registry.gitlab.gnome.org/gnome/gtk/master:v6
# stage: deploy
# script:
# - meson -Dgtk_doc=true _build .
# - ninja -C _build
# - ninja -C _build gdk4-doc gsk4-doc gtk4-doc
# - mkdir -p public/
# - mv _build/docs/reference/gtk/html/ public/gtk/
# - mv _build/docs/reference/gdk/html/ public/gdk/
# - mv _build/docs/reference/gsk/html/ public/gsk/
# artifacts:
# paths:
# - public
# only:
# - master
pages:
image: registry.gitlab.gnome.org/gnome/gtk/master:v10
stage: deploy
script:
- meson -Dgtk_doc=true _build .
- ninja -C _build
- ninja -C _build gdk4-doc gsk4-doc gtk4-doc
- mkdir -p public/
- mv _build/docs/reference/gtk/html/ public/gtk/
- mv _build/docs/reference/gdk/html/ public/gdk/
- mv _build/docs/reference/gsk/html/ public/gsk/
artifacts:
paths:
- public
only:
- master
+1 -1
View File
@@ -76,7 +76,7 @@ RUN dnf -y install \
xorg-x11-server-Xvfb \
&& dnf clean all
RUN pip3 install meson==0.50.1
RUN pip3 install meson==0.52.1
ARG HOST_USER_ID=5555
ENV HOST_USER_ID ${HOST_USER_ID}
+1 -1
View File
@@ -2,7 +2,7 @@
set -e
TAG="registry.gitlab.gnome.org/gnome/gtk/master:v7"
TAG="registry.gitlab.gnome.org/gnome/gtk/master:v10"
sudo docker build --build-arg HOST_USER_ID="$UID" --tag "${TAG}" \
--file "Dockerfile" .
+4 -4
View File
@@ -98,7 +98,7 @@ get_image_paintable (GtkImage *image)
{
const gchar *icon_name;
GtkIconTheme *icon_theme;
GtkIconInfo *icon_info;
GtkIcon *icon;
switch (gtk_image_get_storage_type (image))
{
@@ -107,10 +107,10 @@ get_image_paintable (GtkImage *image)
case GTK_IMAGE_ICON_NAME:
icon_name = gtk_image_get_icon_name (image);
icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (image)));
icon_info = gtk_icon_theme_lookup_icon (icon_theme, icon_name, 48, GTK_ICON_LOOKUP_GENERIC_FALLBACK);
if (icon_info == NULL)
icon = gtk_icon_theme_lookup_icon (icon_theme, icon_name, 48, 1, GTK_ICON_LOOKUP_GENERIC_FALLBACK);
if (icon == NULL)
return NULL;
return gtk_icon_info_load_icon (icon_info, NULL);
return GDK_PAINTABLE (icon);
default:
g_warning ("Image storage type %d not handled",
gtk_image_get_storage_type (image));
-1
View File
@@ -173,7 +173,6 @@
<file>fishbowl.c</file>
<file>fixed.c</file>
<file>flowbox.c</file>
<file>foreigndrawing.c</file>
<file>font_features.c</file>
<file>fontplane.c</file>
<file>fontrendering.c</file>
-984
View File
@@ -1,984 +0,0 @@
/* Foreign drawing
*
* Many applications can't use GTK widgets, for a variety of reasons,
* but still want their user interface to appear integrated with the
* rest of the desktop, and follow GTK themes. This demo shows how to
* use GtkStyleContext and the gtk_render_ APIs to achieve this.
*
* Note that this is a very simple, non-interactive example.
*/
#include <gtk/gtk.h>
#include <string.h>
static void
append_element (GtkWidgetPath *path,
const char *selector)
{
static const struct {
const char *name;
GtkStateFlags state_flag;
} pseudo_classes[] = {
{ "active", GTK_STATE_FLAG_ACTIVE },
{ "hover", GTK_STATE_FLAG_PRELIGHT },
{ "selected", GTK_STATE_FLAG_SELECTED },
{ "disabled", GTK_STATE_FLAG_INSENSITIVE },
{ "indeterminate", GTK_STATE_FLAG_INCONSISTENT },
{ "focus", GTK_STATE_FLAG_FOCUSED },
{ "backdrop", GTK_STATE_FLAG_BACKDROP },
{ "dir(ltr)", GTK_STATE_FLAG_DIR_LTR },
{ "dir(rtl)", GTK_STATE_FLAG_DIR_RTL },
{ "link", GTK_STATE_FLAG_LINK },
{ "visited", GTK_STATE_FLAG_VISITED },
{ "checked", GTK_STATE_FLAG_CHECKED },
{ "drop(active)", GTK_STATE_FLAG_DROP_ACTIVE }
};
const char *next;
char *name;
char type;
guint i;
next = strpbrk (selector, "#.:");
if (next == NULL)
next = selector + strlen (selector);
name = g_strndup (selector, next - selector);
if (g_ascii_isupper (selector[0]))
{
GType gtype;
gtype = g_type_from_name (name);
if (gtype == G_TYPE_INVALID)
{
g_critical ("Unknown type name `%s'", name);
g_free (name);
return;
}
gtk_widget_path_append_type (path, gtype);
}
else
{
/* Omit type, we're using name */
gtk_widget_path_append_type (path, G_TYPE_NONE);
gtk_widget_path_iter_set_object_name (path, -1, name);
}
g_free (name);
while (*next != '\0')
{
type = *next;
selector = next + 1;
next = strpbrk (selector, "#.:");
if (next == NULL)
next = selector + strlen (selector);
name = g_strndup (selector, next - selector);
switch (type)
{
case '#':
gtk_widget_path_iter_set_name (path, -1, name);
break;
case '.':
gtk_widget_path_iter_add_class (path, -1, name);
break;
case ':':
for (i = 0; i < G_N_ELEMENTS (pseudo_classes); i++)
{
if (g_str_equal (pseudo_classes[i].name, name))
{
gtk_widget_path_iter_set_state (path,
-1,
gtk_widget_path_iter_get_state (path, -1)
| pseudo_classes[i].state_flag);
break;
}
}
if (i == G_N_ELEMENTS (pseudo_classes))
g_critical ("Unknown pseudo-class :%s", name);
break;
default:
g_assert_not_reached ();
break;
}
g_free (name);
}
}
static GtkStyleContext *
create_context_for_path (GtkWidgetPath *path,
GtkStyleContext *parent)
{
GtkStyleContext *context;
context = gtk_style_context_new ();
gtk_style_context_set_path (context, path);
gtk_style_context_set_parent (context, parent);
/* Unfortunately, we have to explicitly set the state again here
* for it to take effect
*/
gtk_style_context_set_state (context, gtk_widget_path_iter_get_state (path, -1));
gtk_widget_path_unref (path);
return context;
}
static GtkStyleContext *
get_style (GtkStyleContext *parent,
const char *selector)
{
GtkWidgetPath *path;
if (parent)
path = gtk_widget_path_copy (gtk_style_context_get_path (parent));
else
path = gtk_widget_path_new ();
append_element (path, selector);
return create_context_for_path (path, parent);
}
static GtkStyleContext *
get_style_with_siblings (GtkStyleContext *parent,
const char *selector,
const char **siblings,
gint position)
{
GtkWidgetPath *path, *siblings_path;
guint i;
if (parent)
path = gtk_widget_path_copy (gtk_style_context_get_path (parent));
else
path = gtk_widget_path_new ();
siblings_path = gtk_widget_path_new ();
for (i = 0; siblings[i]; i++)
append_element (siblings_path, siblings[i]);
gtk_widget_path_append_with_siblings (path, siblings_path, position);
gtk_widget_path_unref (siblings_path);
return create_context_for_path (path, parent);
}
static void
draw_style_common (GtkStyleContext *context,
cairo_t *cr,
gint x,
gint y,
gint width,
gint height,
gint *contents_x,
gint *contents_y,
gint *contents_width,
gint *contents_height)
{
GtkBorder margin, border, padding;
int min_width, min_height;
gtk_style_context_get_margin (context, &margin);
gtk_style_context_get_border (context, &border);
gtk_style_context_get_padding (context, &padding);
gtk_style_context_get (context,
"min-width", &min_width,
"min-height", &min_height,
NULL);
x += margin.left;
y += margin.top;
width -= margin.left + margin.right;
height -= margin.top + margin.bottom;
width = MAX (width, min_width);
height = MAX (height, min_height);
gtk_render_background (context, cr, x, y, width, height);
gtk_render_frame (context, cr, x, y, width, height);
if (contents_x)
*contents_x = x + border.left + padding.left;
if (contents_y)
*contents_y = y + border.top + padding.top;
if (contents_width)
*contents_width = width - border.left - border.right - padding.left - padding.right;
if (contents_height)
*contents_height = height - border.top - border.bottom - padding.top - padding.bottom;
}
static void
query_size (GtkStyleContext *context,
gint *width,
gint *height)
{
GtkBorder margin, border, padding;
int min_width, min_height;
gtk_style_context_get_margin (context, &margin);
gtk_style_context_get_border (context, &border);
gtk_style_context_get_padding (context, &padding);
gtk_style_context_get (context,
"min-width", &min_width,
"min-height", &min_height,
NULL);
min_width += margin.left + margin.right + border.left + border.right + padding.left + padding.right;
min_height += margin.top + margin.bottom + border.top + border.bottom + padding.top + padding.bottom;
if (width)
*width = MAX (*width, min_width);
if (height)
*height = MAX (*height, min_height);
}
static void
draw_menu (GtkWidget *widget,
cairo_t *cr,
gint x,
gint y,
gint width,
gint *height)
{
GtkStyleContext *menu_context;
GtkStyleContext *menuitem_context;
GtkStyleContext *hovermenuitem_context;
GtkStyleContext *hoveredarrowmenuitem_context;
GtkStyleContext *arrowmenuitem_context;
GtkStyleContext *checkmenuitem_context;
GtkStyleContext *disabledarrowmenuitem_context;
GtkStyleContext *disabledcheckmenuitem_context;
GtkStyleContext *radiomenuitem_context;
GtkStyleContext *disablemenuitem_context;
GtkStyleContext *disabledradiomenuitem_context;
GtkStyleContext *separatormenuitem_context;
gint menuitem1_height, menuitem2_height, menuitem3_height, menuitem4_height, menuitem5_height;
gint contents_x, contents_y, contents_width, contents_height;
gint menu_x, menu_y, menu_width, menu_height;
gint arrow_width, arrow_height, arrow_size;
gint toggle_x, toggle_y, toggle_width, toggle_height;
/* This information is taken from the GtkMenu docs, see "CSS nodes" */
menu_context = get_style (NULL, "menu");
hovermenuitem_context = get_style (menu_context, "menuitem:hover");
hoveredarrowmenuitem_context = get_style (hovermenuitem_context, "arrow.right:dir(ltr)");
menuitem_context = get_style (menu_context, "menuitem");
arrowmenuitem_context = get_style (menuitem_context, "arrow:dir(rtl)");
disablemenuitem_context = get_style (menu_context, "menuitem:disabled");
disabledarrowmenuitem_context = get_style (disablemenuitem_context, "arrow:dir(rtl)");
checkmenuitem_context = get_style (menuitem_context, "check:checked");
disabledcheckmenuitem_context = get_style (disablemenuitem_context, "check");
separatormenuitem_context = get_style (menu_context, "separator:disabled");
radiomenuitem_context = get_style (menuitem_context, "radio:checked");
disabledradiomenuitem_context = get_style (disablemenuitem_context, "radio");
*height = 0;
query_size (menu_context, NULL, height);
menuitem1_height = 0;
query_size (hovermenuitem_context, NULL, &menuitem1_height);
query_size (hoveredarrowmenuitem_context, NULL, &menuitem1_height);
*height += menuitem1_height;
menuitem2_height = 0;
query_size (menu_context, NULL, &menuitem5_height);
query_size (menuitem_context, NULL, &menuitem2_height);
query_size (arrowmenuitem_context, NULL, &menuitem2_height);
query_size (disabledarrowmenuitem_context, NULL, &menuitem2_height);
*height += menuitem2_height;
menuitem3_height = 0;
query_size (menu_context, NULL, &menuitem5_height);
query_size (menuitem_context, NULL, &menuitem3_height);
query_size (checkmenuitem_context, NULL, &menuitem3_height);
query_size (disabledcheckmenuitem_context, NULL, &menuitem3_height);
*height += menuitem3_height;
menuitem4_height = 0;
query_size (menu_context, NULL, &menuitem5_height);
query_size (separatormenuitem_context, NULL, &menuitem4_height);
*height += menuitem4_height;
menuitem5_height = 0;
query_size (menu_context, NULL, &menuitem5_height);
query_size (menuitem_context, NULL, &menuitem5_height);
query_size (radiomenuitem_context, NULL, &menuitem5_height);
query_size (disabledradiomenuitem_context, NULL, &menuitem5_height);
*height += menuitem5_height;
draw_style_common (menu_context, cr, x, y, width, *height,
&menu_x, &menu_y, &menu_width, &menu_height);
/* Hovered with right arrow */
gtk_style_context_get (hoveredarrowmenuitem_context,
"min-width", &arrow_width, "min-height", &arrow_height, NULL);
arrow_size = MIN (arrow_width, arrow_height);
draw_style_common (hovermenuitem_context, cr, menu_x, menu_y, menu_width, menuitem1_height,
&contents_x, &contents_y, &contents_width, &contents_height);
gtk_render_arrow (hoveredarrowmenuitem_context, cr, G_PI / 2,
contents_x + contents_width - arrow_size,
contents_y + (contents_height - arrow_size) / 2, arrow_size);
/* Left arrow sensitive, and right arrow insensitive */
draw_style_common (menuitem_context, cr, menu_x, menu_y + menuitem1_height, menu_width, menuitem2_height,
&contents_x, &contents_y, &contents_width, &contents_height);
gtk_style_context_get (arrowmenuitem_context,
"min-width", &arrow_width, "min-height", &arrow_height, NULL);
arrow_size = MIN (arrow_width, arrow_height);
gtk_render_arrow (arrowmenuitem_context, cr, G_PI / 2,
contents_x,
contents_y + (contents_height - arrow_size) / 2, arrow_size);
gtk_style_context_get (disabledarrowmenuitem_context,
"min-width", &arrow_width, "min-height", &arrow_height, NULL);
arrow_size = MIN (arrow_width, arrow_height);
gtk_render_arrow (disabledarrowmenuitem_context, cr, G_PI / 2,
contents_x + contents_width - arrow_size,
contents_y + (contents_height - arrow_size) / 2, arrow_size);
/* Left check enabled, sensitive, and right check unchecked, insensitive */
draw_style_common (menuitem_context, cr, menu_x, menu_y + menuitem1_height + menuitem2_height, menu_width, menuitem3_height,
&contents_x, &contents_y, &contents_width, &contents_height);
gtk_style_context_get (checkmenuitem_context,
"min-width", &toggle_width, "min-height", &toggle_height, NULL);
draw_style_common (checkmenuitem_context, cr,
contents_x,
contents_y,
toggle_width, toggle_height,
&toggle_x, &toggle_y, &toggle_width, &toggle_height);
gtk_render_check (checkmenuitem_context, cr, toggle_x, toggle_y, toggle_width, toggle_height);
gtk_style_context_get (disabledcheckmenuitem_context,
"min-width", &toggle_width, "min-height", &toggle_height, NULL);
draw_style_common (disabledcheckmenuitem_context, cr,
contents_x + contents_width - toggle_width,
contents_y,
toggle_width, toggle_height,
&toggle_x, &toggle_y, &toggle_width, &toggle_height);
gtk_render_check (disabledcheckmenuitem_context, cr, toggle_x, toggle_y, toggle_width, toggle_height);
/* Separator */
draw_style_common (separatormenuitem_context, cr, menu_x, menu_y + menuitem1_height + menuitem2_height + menuitem3_height,
menu_width, menuitem4_height,
NULL, NULL, NULL, NULL);
/* Left check enabled, sensitive, and right check unchecked, insensitive */
draw_style_common (menuitem_context, cr, menu_x, menu_y + menuitem1_height + menuitem2_height + menuitem3_height + menuitem4_height,
menu_width, menuitem5_height,
&contents_x, &contents_y, &contents_width, &contents_height);
gtk_style_context_get (radiomenuitem_context,
"min-width", &toggle_width, "min-height", &toggle_height, NULL);
draw_style_common (radiomenuitem_context, cr,
contents_x,
contents_y,
toggle_width, toggle_height,
&toggle_x, &toggle_y, &toggle_width, &toggle_height);
gtk_render_check (radiomenuitem_context, cr, toggle_x, toggle_y, toggle_width, toggle_height);
gtk_style_context_get (disabledradiomenuitem_context,
"min-width", &toggle_width, "min-height", &toggle_height, NULL);
draw_style_common (disabledradiomenuitem_context, cr,
contents_x + contents_width - toggle_width,
contents_y,
toggle_width, toggle_height,
&toggle_x, &toggle_y, &toggle_width, &toggle_height);
gtk_render_check (disabledradiomenuitem_context, cr, toggle_x, toggle_y, toggle_width, toggle_height);
g_object_unref (menu_context);
g_object_unref (menuitem_context);
g_object_unref (hovermenuitem_context);
g_object_unref (hoveredarrowmenuitem_context);
g_object_unref (arrowmenuitem_context);
g_object_unref (checkmenuitem_context);
g_object_unref (disabledarrowmenuitem_context);
g_object_unref (disabledcheckmenuitem_context);
g_object_unref (radiomenuitem_context);
g_object_unref (disablemenuitem_context);
g_object_unref (disabledradiomenuitem_context);
g_object_unref (separatormenuitem_context);
}
static void
draw_menubar (GtkWidget *widget,
cairo_t *cr,
gint x,
gint y,
gint width,
gint *height)
{
GtkStyleContext *frame_context;
GtkStyleContext *border_context;
GtkStyleContext *menubar_context;
GtkStyleContext *hovered_menuitem_context;
GtkStyleContext *menuitem_context;
gint contents_x, contents_y, contents_width, contents_height;
gint item_width;
/* Menubar background is the same color as our base background, so use a frame */
frame_context = get_style (NULL, "frame");
border_context = get_style (frame_context, "border");
/* This information is taken from the GtkPopoverMenuBar docs, see "CSS nodes" */
menubar_context = get_style (NULL, "menubar");
hovered_menuitem_context = get_style (menubar_context, "menuitem:hover");
menuitem_context = get_style (menubar_context, "menuitem");
*height = 0;
query_size (frame_context, NULL, height);
query_size (border_context, NULL, height);
query_size (menubar_context, NULL, height);
query_size (hovered_menuitem_context, NULL, height);
query_size (menuitem_context, NULL, height);
draw_style_common (frame_context, cr, x, y, width, *height,
NULL, NULL, NULL, NULL);
draw_style_common (border_context, cr, x, y, width, *height,
&contents_x, &contents_y, &contents_width, &contents_height);
draw_style_common (menubar_context, cr, contents_x, contents_y, contents_width, contents_height,
NULL, NULL, NULL, NULL);
item_width = contents_width / 3;
draw_style_common (hovered_menuitem_context, cr, contents_x, contents_y, item_width, contents_height,
NULL, NULL, NULL, NULL);
draw_style_common (menuitem_context, cr, contents_x + item_width * 2, contents_y, item_width, contents_height,
NULL, NULL, NULL, NULL);
g_object_unref (menuitem_context);
g_object_unref (hovered_menuitem_context);
g_object_unref (menubar_context);
g_object_unref (border_context);
g_object_unref (frame_context);
}
static void
draw_notebook (GtkWidget *widget,
cairo_t *cr,
gint x,
gint y,
gint width,
gint height)
{
GtkStyleContext *notebook_context;
GtkStyleContext *header_context;
GtkStyleContext *tabs_context;
GtkStyleContext *tab1_context, *tab2_context;
GtkStyleContext *stack_context;
gint header_height;
gint contents_x, contents_y, contents_width, contents_height;
/* This information is taken from the GtkNotebook docs, see "CSS nodes" */
notebook_context = get_style (NULL, "notebook.frame");
header_context = get_style (notebook_context, "header.top");
tabs_context = get_style (header_context, "tabs");
tab1_context = get_style (tabs_context, "tab:checked");
tab2_context = get_style (tabs_context, "tab:hover");
stack_context = get_style (notebook_context, "stack");
header_height = 0;
query_size (notebook_context, NULL, &header_height);
query_size (header_context, NULL, &header_height);
query_size (tabs_context, NULL, &header_height);
query_size (tab1_context, NULL, &header_height);
query_size (tab2_context, NULL, &header_height);
draw_style_common (notebook_context, cr, x, y, width, height, NULL, NULL, NULL, NULL);
draw_style_common (header_context, cr, x, y, width, header_height, NULL, NULL, NULL, NULL);
draw_style_common (tabs_context, cr, x, y, width, header_height, NULL, NULL, NULL, NULL);
draw_style_common (tab1_context, cr, x, y, width / 2, header_height,
&contents_x, &contents_y, &contents_width, &contents_height);
draw_style_common (tab2_context, cr, x + width / 2, y, width / 2, header_height,
NULL, NULL, NULL, NULL);
draw_style_common (stack_context, cr, x, y + header_height, width,height - header_height,
NULL, NULL, NULL, NULL);
g_object_unref (stack_context);
g_object_unref (tabs_context);
g_object_unref (tab1_context);
g_object_unref (tab2_context);
g_object_unref (header_context);
g_object_unref (notebook_context);
}
static void
draw_horizontal_scrollbar (GtkWidget *widget,
cairo_t *cr,
gint x,
gint y,
gint width,
gint position,
GtkStateFlags state,
gint *height)
{
GtkStyleContext *scrollbar_context;
GtkStyleContext *contents_context;
GtkStyleContext *trough_context;
GtkStyleContext *slider_context;
gint slider_width;
/* This information is taken from the GtkScrollbar docs, see "CSS nodes" */
scrollbar_context = get_style (NULL, "scrollbar.horizontal.bottom");
contents_context = get_style (scrollbar_context, "contents");
trough_context = get_style (contents_context, "trough");
slider_context = get_style (trough_context, "slider");
gtk_style_context_set_state (scrollbar_context, state);
gtk_style_context_set_state (contents_context, state);
gtk_style_context_set_state (trough_context, state);
gtk_style_context_set_state (slider_context, state);
*height = 0;
query_size (scrollbar_context, NULL, height);
query_size (contents_context, NULL, height);
query_size (trough_context, NULL, height);
query_size (slider_context, NULL, height);
gtk_style_context_get (slider_context,
"min-width", &slider_width, NULL);
draw_style_common (scrollbar_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
draw_style_common (contents_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
draw_style_common (trough_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
draw_style_common (slider_context, cr, x + position, y, slider_width, *height, NULL, NULL, NULL, NULL);
g_object_unref (slider_context);
g_object_unref (trough_context);
g_object_unref (contents_context);
g_object_unref (scrollbar_context);
}
static void
draw_text (GtkWidget *widget,
cairo_t *cr,
gint x,
gint y,
gint width,
gint height,
const gchar *text,
GtkStateFlags state)
{
GtkStyleContext *label_context;
GtkStyleContext *selection_context;
GtkStyleContext *context;
PangoLayout *layout;
/* This information is taken from the GtkLabel docs, see "CSS nodes" */
label_context = get_style (NULL, "label.view");
selection_context = get_style (label_context, "selection");
gtk_style_context_set_state (label_context, state);
if (state & GTK_STATE_FLAG_SELECTED)
context = selection_context;
else
context = label_context;
layout = gtk_widget_create_pango_layout (widget, text);
gtk_render_background (context, cr, x, y, width, height);
gtk_render_frame (context, cr, x, y, width, height);
gtk_render_layout (context, cr, x, y, layout);
g_object_unref (layout);
g_object_unref (selection_context);
g_object_unref (label_context);
}
static void
draw_check (GtkWidget *widget,
cairo_t *cr,
gint x,
gint y,
GtkStateFlags state,
gint *width,
gint *height)
{
GtkStyleContext *button_context;
GtkStyleContext *check_context;
gint contents_x, contents_y, contents_width, contents_height;
/* This information is taken from the GtkCheckButton docs, see "CSS nodes" */
button_context = get_style (NULL, "checkbutton");
check_context = get_style (button_context, "check");
gtk_style_context_set_state (check_context, state);
*width = *height = 0;
query_size (button_context, width, height);
query_size (check_context, width, height);
draw_style_common (button_context, cr, x, y, *width, *height, NULL, NULL, NULL, NULL);
draw_style_common (check_context, cr, x, y, *width, *height,
&contents_x, &contents_y, &contents_width, &contents_height);
gtk_render_check (check_context, cr, contents_x, contents_y, contents_width, contents_height);
g_object_unref (check_context);
g_object_unref (button_context);
}
static void
draw_radio (GtkWidget *widget,
cairo_t *cr,
gint x,
gint y,
GtkStateFlags state,
gint *width,
gint *height)
{
GtkStyleContext *button_context;
GtkStyleContext *check_context;
gint contents_x, contents_y, contents_width, contents_height;
/* This information is taken from the GtkRadioButton docs, see "CSS nodes" */
button_context = get_style (NULL, "radiobutton");
check_context = get_style (button_context, "radio");
gtk_style_context_set_state (check_context, state);
*width = *height = 0;
query_size (button_context, width, height);
query_size (check_context, width, height);
draw_style_common (button_context, cr, x, y, *width, *height, NULL, NULL, NULL, NULL);
draw_style_common (check_context, cr, x, y, *width, *height,
&contents_x, &contents_y, &contents_width, &contents_height);
gtk_render_check (check_context, cr, contents_x, contents_y, contents_width, contents_height);
g_object_unref (check_context);
g_object_unref (button_context);
}
static void
draw_progress (GtkWidget *widget,
cairo_t *cr,
gint x,
gint y,
gint width,
gint position,
gint *height)
{
GtkStyleContext *bar_context;
GtkStyleContext *trough_context;
GtkStyleContext *progress_context;
/* This information is taken from the GtkProgressBar docs, see "CSS nodes" */
bar_context = get_style (NULL, "progressbar.horizontal");
trough_context = get_style (bar_context, "trough");
progress_context = get_style (trough_context, "progress.left");
*height = 0;
query_size (bar_context, NULL, height);
query_size (trough_context, NULL, height);
query_size (progress_context, NULL, height);
draw_style_common (bar_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
draw_style_common (trough_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
draw_style_common (progress_context, cr, x, y, position, *height, NULL, NULL, NULL, NULL);
g_object_unref (progress_context);
g_object_unref (trough_context);
g_object_unref (bar_context);
}
static void
draw_scale (GtkWidget *widget,
cairo_t *cr,
gint x,
gint y,
gint width,
gint position,
gint *height)
{
GtkStyleContext *scale_context;
GtkStyleContext *contents_context;
GtkStyleContext *trough_context;
GtkStyleContext *slider_context;
GtkStyleContext *highlight_context;
gint contents_x, contents_y, contents_width, contents_height;
gint trough_height, slider_height;
scale_context = get_style (NULL, "scale.horizontal");
contents_context = get_style (scale_context, "contents");
trough_context = get_style (contents_context, "trough");
slider_context = get_style (trough_context, "slider");
highlight_context = get_style (trough_context, "highlight.top");
*height = 0;
query_size (scale_context, NULL, height);
query_size (contents_context, NULL, height);
query_size (trough_context, NULL, height);
query_size (slider_context, NULL, height);
query_size (highlight_context, NULL, height);
draw_style_common (scale_context, cr, x, y, width, *height,
&contents_x, &contents_y, &contents_width, &contents_height);
draw_style_common (contents_context, cr, contents_x, contents_y, contents_width, contents_height,
&contents_x, &contents_y, &contents_width, &contents_height);
/* Scale trough defines its size querying slider and highlight */
trough_height = 0;
query_size (trough_context, NULL, &trough_height);
slider_height = 0;
query_size (slider_context, NULL, &slider_height);
query_size (highlight_context, NULL, &slider_height);
trough_height += slider_height;
draw_style_common (trough_context, cr, contents_x, contents_y, contents_width, trough_height,
&contents_x, &contents_y, &contents_width, &contents_height);
draw_style_common (highlight_context, cr, contents_x, contents_y,
contents_width / 2, contents_height,
NULL, NULL, NULL, NULL);
draw_style_common (slider_context, cr, contents_x + position, contents_y, contents_height, contents_height,
NULL, NULL, NULL, NULL);
g_object_unref (scale_context);
g_object_unref (contents_context);
g_object_unref (trough_context);
g_object_unref (slider_context);
g_object_unref (highlight_context);
}
static void
draw_combobox (GtkWidget *widget,
cairo_t *cr,
gint x,
gint y,
gint width,
gboolean has_entry,
gint *height)
{
GtkStyleContext *combo_context;
GtkStyleContext *box_context;
GtkStyleContext *button_context;
GtkStyleContext *button_box_context;
GtkStyleContext *entry_context;
GtkStyleContext *arrow_context;
gint contents_x, contents_y, contents_width, contents_height;
gint button_width;
gint arrow_width, arrow_height, arrow_size;
/* This information is taken from the GtkComboBox docs, see "CSS nodes" */
combo_context = get_style (NULL, "combobox:focus");
box_context = get_style (combo_context, "box.horizontal.linked");
if (has_entry)
{
const char *siblings[3] = { "entry.combo:focus", "button.combo" , NULL };
entry_context = get_style_with_siblings (box_context, "entry.combo:focus", siblings, 0);
button_context = get_style_with_siblings (box_context, "button.combo", siblings, 1);
}
else
{
const char *siblings[2] = { "button.combo" , NULL };
button_context = get_style_with_siblings (box_context, "button.combo", siblings, 0);
}
button_box_context = get_style (button_context, "box.horizontal");
arrow_context = get_style (button_box_context, "arrow");
*height = 0;
query_size (combo_context, NULL, height);
query_size (box_context, NULL, height);
if (has_entry)
query_size (entry_context, NULL, height);
query_size (button_context, NULL, height);
query_size (button_box_context, NULL, height);
query_size (arrow_context, NULL, height);
gtk_style_context_get (arrow_context,
"min-width", &arrow_width, "min-height", &arrow_height, NULL);
arrow_size = MIN (arrow_width, arrow_height);
draw_style_common (combo_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
draw_style_common (box_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
if (has_entry)
{
button_width = *height;
draw_style_common (entry_context, cr, x, y, width - button_width, *height, NULL, NULL, NULL, NULL);
draw_style_common (button_context, cr, x + width - button_width, y, button_width, *height,
&contents_x, &contents_y, &contents_width, &contents_height);
}
else
{
button_width = width;
draw_style_common (button_context, cr, x, y, width, *height,
&contents_x, &contents_y, &contents_width, &contents_height);
}
draw_style_common (button_box_context, cr, contents_x, contents_y, contents_width, contents_height,
NULL, NULL, NULL, NULL);
draw_style_common (arrow_context, cr, contents_x, contents_y, contents_width, contents_height,
NULL, NULL, NULL, NULL);
gtk_render_arrow (arrow_context, cr, G_PI / 2,
contents_x + contents_width - arrow_size,
contents_y + (contents_height - arrow_size) / 2, arrow_size);
g_object_unref (arrow_context);
if (has_entry)
g_object_unref (entry_context);
g_object_unref (button_context);
g_object_unref (combo_context);
}
static void
draw_spinbutton (GtkWidget *widget,
cairo_t *cr,
gint x,
gint y,
gint width,
gint *height)
{
GtkStyleContext *spin_context;
GtkStyleContext *entry_context;
GtkStyleContext *up_context;
GtkStyleContext *down_context;
GtkIconTheme *icon_theme;
GtkIconInfo *icon_info;
GdkTexture *texture;
gint icon_width, icon_height, icon_size;
gint button_width;
gint contents_x, contents_y, contents_width, contents_height;
/* This information is taken from the GtkSpinButton docs, see "CSS nodes" */
spin_context = get_style (NULL, "spinbutton.horizontal:focus");
entry_context = get_style (spin_context, "entry:focus");
up_context = get_style (spin_context, "button.up:focus:active");
down_context = get_style (spin_context, "button.down:focus");
*height = 0;
query_size (spin_context, NULL, height);
query_size (entry_context, NULL, height);
query_size (up_context, NULL, height);
query_size (down_context, NULL, height);
button_width = *height;
draw_style_common (spin_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
draw_style_common (entry_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (widget));
gtk_style_context_get (up_context,
"min-width", &icon_width, "min-height", &icon_height, NULL);
icon_size = MIN (icon_width, icon_height);
icon_info = gtk_icon_theme_lookup_icon (icon_theme, "list-add-symbolic", icon_size, 0);
texture = GDK_TEXTURE (gtk_icon_info_load_symbolic_for_context (icon_info, up_context, NULL, NULL));
g_object_unref (icon_info);
draw_style_common (up_context, cr, x + width - button_width, y, button_width, *height,
&contents_x, &contents_y, &contents_width, &contents_height);
gtk_render_icon (up_context, cr, texture, contents_x, contents_y + (contents_height - icon_size) / 2);
g_object_unref (texture);
gtk_style_context_get (down_context,
"min-width", &icon_width, "min-height", &icon_height, NULL);
icon_size = MIN (icon_width, icon_height);
icon_info = gtk_icon_theme_lookup_icon (icon_theme, "list-remove-symbolic", icon_size, 0);
texture = GDK_TEXTURE (gtk_icon_info_load_symbolic_for_context (icon_info, down_context, NULL, NULL));
g_object_unref (icon_info);
draw_style_common (down_context, cr, x + width - 2 * button_width, y, button_width, *height,
&contents_x, &contents_y, &contents_width, &contents_height);
gtk_render_icon (down_context, cr, texture, contents_x, contents_y + (contents_height - icon_size) / 2);
g_object_unref (texture);
g_object_unref (down_context);
g_object_unref (up_context);
g_object_unref (entry_context);
g_object_unref (spin_context);
}
static void
draw_func (GtkDrawingArea *da,
cairo_t *cr,
int width,
int height,
gpointer data)
{
GtkWidget *widget = GTK_WIDGET (da);
gint panewidth;
gint x, y;
panewidth = width / 2;
cairo_rectangle (cr, 0, 0, width, height);
cairo_set_source_rgb (cr, 0.9, 0.9, 0.9);
cairo_fill (cr);
x = y = 10;
draw_horizontal_scrollbar (widget, cr, x, y, panewidth - 20, 30, GTK_STATE_FLAG_NORMAL, &height);
y += height + 8;
draw_horizontal_scrollbar (widget, cr, x, y, panewidth - 20, 40, GTK_STATE_FLAG_PRELIGHT, &height);
y += height + 8;
draw_horizontal_scrollbar (widget, cr, x, y, panewidth - 20, 50, GTK_STATE_FLAG_ACTIVE|GTK_STATE_FLAG_PRELIGHT, &height);
y += height + 8;
draw_text (widget, cr, x, y, panewidth - 20, 20, "Not selected", GTK_STATE_FLAG_NORMAL);
y += 20 + 10;
draw_text (widget, cr, x, y, panewidth - 20, 20, "Selected", GTK_STATE_FLAG_SELECTED);
x = 10;
y += 20 + 10;
draw_check (widget, cr, x, y, GTK_STATE_FLAG_NORMAL, &width, &height);
x += width + 10;
draw_check (widget, cr, x, y, GTK_STATE_FLAG_CHECKED, &width, &height);
x += width + 10;
draw_radio (widget, cr, x, y, GTK_STATE_FLAG_NORMAL, &width, &height);
x += width + 10;
draw_radio (widget, cr, x, y, GTK_STATE_FLAG_CHECKED, &width, &height);
x = 10;
y += height + 10;
draw_progress (widget, cr, x, y, panewidth - 20, 50, &height);
y += height + 10;
draw_scale (widget, cr, x, y, panewidth - 20, 75, &height);
y += height + 20;
draw_notebook (widget, cr, x, y, panewidth - 20, 160);
/* Second column */
x += panewidth;
y = 10;
draw_menu (widget, cr, x, y, panewidth - 20, &height);
y += height + 10;
draw_menubar (widget, cr, x, y, panewidth - 20, &height);
y += height + 20;
draw_spinbutton (widget, cr, x, y, panewidth - 20, &height);
y += height + 30;
draw_combobox (widget, cr, x, y, panewidth - 20, FALSE, &height);
y += height + 10;
draw_combobox (widget, cr, 10 + panewidth, y, panewidth - 20, TRUE, &height);
}
GtkWidget *
do_foreigndrawing (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;
if (!window)
{
GtkWidget *box;
GtkWidget *da;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "Foreign drawing");
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed), &window);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
gtk_container_add (GTK_CONTAINER (window), box);
da = gtk_drawing_area_new ();
gtk_drawing_area_set_content_width (GTK_DRAWING_AREA (da), 400);
gtk_drawing_area_set_content_height (GTK_DRAWING_AREA (da), 400);
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (da), draw_func, NULL, NULL);
gtk_widget_set_hexpand (da, TRUE);
gtk_widget_set_vexpand (da, TRUE);
gtk_container_add (GTK_CONTAINER (box), da);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
gtk_widget_destroy (window);
return window;
}
-1
View File
@@ -28,7 +28,6 @@ demos = files([
'fishbowl.c',
'fixed.c',
'fontrendering.c',
'foreigndrawing.c',
'gestures.c',
'glarea.c',
'headerbar.c',
+7 -5
View File
@@ -130,13 +130,15 @@ insert_text (GtkTextBuffer *buffer)
GtkTextIter start, end;
GdkTexture *texture;
GtkIconTheme *icon_theme;
GtkIcon *icon;
icon_theme = gtk_icon_theme_get_default ();
texture = GDK_TEXTURE (gtk_icon_theme_load_icon (icon_theme,
"gtk3-demo",
32,
GTK_ICON_LOOKUP_GENERIC_FALLBACK,
NULL));
icon = gtk_icon_theme_lookup_icon (icon_theme,
"gtk3-demo",
32, 1,
GTK_ICON_LOOKUP_GENERIC_FALLBACK);
texture = gtk_icon_download_texture (icon, NULL);
g_object_unref (icon);
g_assert (texture);
/* get start of buffer; each insertion will revalidate the
+8 -8
View File
@@ -348,7 +348,7 @@ get_image_paintable (GtkImage *image)
{
const gchar *icon_name;
GtkIconTheme *icon_theme;
GtkIconInfo *icon_info;
GtkIcon *icon;
int size;
switch (gtk_image_get_storage_type (image))
@@ -359,11 +359,11 @@ get_image_paintable (GtkImage *image)
icon_name = gtk_image_get_icon_name (image);
size = gtk_image_get_pixel_size (image);
icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (image)));
icon_info = gtk_icon_theme_lookup_icon (icon_theme, icon_name, size,
GTK_ICON_LOOKUP_FORCE_SIZE | GTK_ICON_LOOKUP_GENERIC_FALLBACK);
if (icon_info == NULL)
icon = gtk_icon_theme_lookup_icon (icon_theme, icon_name, size, 1,
GTK_ICON_LOOKUP_FORCE_SIZE | GTK_ICON_LOOKUP_GENERIC_FALLBACK);
if (icon == NULL)
return NULL;
return gtk_icon_info_load_icon (icon_info, NULL);
return GDK_PAINTABLE (icon);
default:
g_warning ("Image storage type %d not handled",
gtk_image_get_storage_type (image));
@@ -405,13 +405,13 @@ get_file (GValue *value,
gpointer data)
{
const char *name;
GtkIconInfo *info;
GtkIcon *info;
GFile *file;
name = gtk_image_get_icon_name (GTK_IMAGE (data));
info = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_default (), name, -1, 0);
file = g_file_new_for_path (gtk_icon_info_get_filename (info));
info = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_default (), name, 32, 1, 0);
file = g_file_new_for_path (gtk_icon_get_filename (info));
g_value_set_object (value, file);
g_object_unref (file);
g_object_unref (info);
+1
View File
@@ -376,6 +376,7 @@ gdk_cairo_region
gdk_cairo_region_create_from_surface
gdk_cairo_draw_from_gl
gdk_cairo_surface_upload_to_gl
gdk_cairo_image_surface_recolor
</SECTION>
<SECTION>
-1
View File
@@ -374,7 +374,6 @@
<xi:include href="xml/gtkstylecontext.xml" />
<xi:include href="xml/gtkcssprovider.xml" />
<xi:include href="xml/gtkstyleprovider.xml" />
<xi:include href="xml/gtkwidgetpath.xml" />
<xi:include href="xml/gtkicontheme.xml" />
</part>
+23 -87
View File
@@ -4409,6 +4409,9 @@ gtk_widget_insert_after
gtk_widget_set_layout_manager
gtk_widget_get_layout_manager
gtk_widget_should_layout
gtk_widget_add_style_class
gtk_widget_remove_style_class
gtk_widget_has_style_class
<SUBSECTION>
gtk_widget_get_style_context
@@ -4689,50 +4692,6 @@ GTK_INTERFACE_AGE
GTK_CHECK_VERSION
</SECTION>
<SECTION>
<FILE>gtkwidgetpath</FILE>
<TITLE>GtkWidgetPath</TITLE>
GtkWidgetPath
gtk_widget_path_append_type
gtk_widget_path_append_with_siblings
gtk_widget_path_append_for_widget
gtk_widget_path_copy
gtk_widget_path_ref
gtk_widget_path_unref
gtk_widget_path_free
gtk_widget_path_get_object_type
gtk_widget_path_has_parent
gtk_widget_path_is_type
gtk_widget_path_iter_add_class
gtk_widget_path_iter_clear_classes
gtk_widget_path_iter_get_name
gtk_widget_path_iter_get_object_name
gtk_widget_path_iter_get_object_type
gtk_widget_path_iter_get_siblings
gtk_widget_path_iter_get_sibling_index
gtk_widget_path_iter_get_state
gtk_widget_path_iter_has_class
gtk_widget_path_iter_has_name
gtk_widget_path_iter_has_qclass
gtk_widget_path_iter_has_qname
gtk_widget_path_iter_list_classes
gtk_widget_path_iter_remove_class
gtk_widget_path_iter_set_name
gtk_widget_path_iter_set_object_name
gtk_widget_path_iter_set_object_type
gtk_widget_path_iter_set_state
gtk_widget_path_length
gtk_widget_path_new
gtk_widget_path_prepend_type
gtk_widget_path_to_string
<SUBSECTION Standard>
GTK_TYPE_WIDGET_PATH
<SUBSECTION Private>
gtk_widget_path_get_type
</SECTION>
<SECTION>
<FILE>gtkstyleprovider</FILE>
<TITLE>GtkStyleProvider</TITLE>
@@ -4755,16 +4714,6 @@ gtk_style_provider_get_type
<FILE>gtkstylecontext</FILE>
<TITLE>GtkStyleContext</TITLE>
<SUBSECTION>
GTK_STYLE_PROPERTY_BACKGROUND_COLOR
GTK_STYLE_PROPERTY_COLOR
GTK_STYLE_PROPERTY_FONT
GTK_STYLE_PROPERTY_MARGIN
GTK_STYLE_PROPERTY_PADDING
GTK_STYLE_PROPERTY_BORDER_WIDTH
GTK_STYLE_PROPERTY_BORDER_RADIUS
GTK_STYLE_PROPERTY_BORDER_STYLE
GTK_STYLE_PROPERTY_BORDER_COLOR
GTK_STYLE_PROPERTY_BACKGROUND_IMAGE
GtkBorderStyle
<SUBSECTION>
GTK_STYLE_CLASS_ACCELERATOR
@@ -4855,14 +4804,9 @@ GtkStyleContext
gtk_style_context_new
gtk_style_context_add_provider
gtk_style_context_add_provider_for_display
gtk_style_context_get
gtk_style_context_get_parent
gtk_style_context_get_path
gtk_style_context_get_property
gtk_style_context_get_display
gtk_style_context_get_state
gtk_style_context_get_valist
gtk_style_context_get_section
gtk_style_context_get_color
gtk_style_context_get_border
gtk_style_context_get_padding
@@ -4874,7 +4818,6 @@ gtk_style_context_reset_widgets
gtk_style_context_restore
gtk_style_context_save
gtk_style_context_set_parent
gtk_style_context_set_path
gtk_style_context_add_class
gtk_style_context_remove_class
gtk_style_context_has_class
@@ -5044,10 +4987,12 @@ GtkIconSize
<SECTION>
<FILE>gtkicontheme</FILE>
<TITLE>GtkIconTheme</TITLE>
GtkIconInfo
GtkIcon
GtkIconTheme
GtkIconLookupFlags
GTK_ICON_THEME_ERROR
GTK_TYPE_ICON_THEME_ERROR
GTK_TYPE_ICON_LOOKUP_FLAGS
GtkIconThemeError
gtk_icon_theme_new
gtk_icon_theme_get_default
@@ -5061,31 +5006,22 @@ gtk_icon_theme_add_resource_path
gtk_icon_theme_set_custom_theme
gtk_icon_theme_has_icon
gtk_icon_theme_lookup_icon
gtk_icon_theme_lookup_icon_for_scale
gtk_icon_theme_choose_icon
gtk_icon_theme_choose_icon_for_scale
gtk_icon_theme_choose_icon_async
gtk_icon_theme_choose_icon_finish
gtk_icon_theme_lookup_by_gicon
gtk_icon_theme_lookup_by_gicon_for_scale
gtk_icon_theme_load_icon
gtk_icon_theme_load_icon_for_scale
gtk_icon_theme_list_icons
gtk_icon_theme_get_icon_sizes
gtk_icon_theme_rescan_if_needed
gtk_icon_info_get_base_size
gtk_icon_info_get_base_scale
gtk_icon_info_get_filename
gtk_icon_info_load_icon
gtk_icon_info_load_icon_async
gtk_icon_info_load_icon_finish
gtk_icon_info_load_symbolic
gtk_icon_info_load_symbolic_async
gtk_icon_info_load_symbolic_finish
gtk_icon_info_load_symbolic_for_context
gtk_icon_info_load_symbolic_for_context_async
gtk_icon_info_load_symbolic_for_context_finish
gtk_icon_info_is_symbolic
gtk_icon_get_base_size
gtk_icon_get_base_scale
gtk_icon_get_filename
gtk_icon_is_symbolic
gtk_icon_snapshot_with_colors
gtk_icon_download_colored_texture
gtk_icon_download_texture
<SUBSECTION Standard>
GtkIconInfoClass
GtkIconClass
GTK_ICON_THEME
GTK_IS_ICON_THEME
GTK_TYPE_ICON_THEME
@@ -5093,13 +5029,13 @@ gtk_icon_theme_get_type
GTK_ICON_THEME_CLASS
GTK_IS_ICON_THEME_CLASS
GTK_ICON_THEME_GET_CLASS
gtk_icon_info_get_type
GTK_TYPE_ICON_INFO
GTK_ICON_INFO
GTK_ICON_INFO_CLASS
GTK_ICON_INFO_GET_CLASS
GTK_IS_ICON_INFO
GTK_IS_ICON_INFO_CLASS
gtk_icon_get_type
GTK_ICON
GTK_IS_ICON
GTK_TYPE_ICON
GTK_ICON_CLASS
GTK_ICON_GET_CLASS
GTK_IS_ICON_CLASS
<SUBSECTION Private>
GtkIconThemePrivate
gtk_icon_theme_error_quark
+9
View File
@@ -1,4 +1,13 @@
if get_option('gtk_doc')
if not meson.version().version_compare('>=0.52.0')
error('Building the GTK documentation requires Meson 0.52.0')
endif
# Use gtk-doc as a sub-project if the version isn't new enough
dependency('gtk-doc', version: '>=1.32',
fallback: ['gtk-doc', 'dummy_dep'],
default_options: ['tests=false'])
glib_prefix = dependency('glib-2.0').get_pkgconfig_variable('prefix')
glib_docpath = join_paths(glib_prefix, 'share', 'gtk-doc', 'html')
-9
View File
@@ -329,14 +329,6 @@ gdk_broadway_display_get_monitor (GdkDisplay *display,
return NULL;
}
static GdkMonitor *
gdk_broadway_display_get_primary_monitor (GdkDisplay *display)
{
GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (display);
return broadway_display->monitor;
}
static gboolean
gdk_broadway_display_get_setting (GdkDisplay *display,
const char *name,
@@ -443,7 +435,6 @@ gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class)
display_class->get_n_monitors = gdk_broadway_display_get_n_monitors;
display_class->get_monitor = gdk_broadway_display_get_monitor;
display_class->get_primary_monitor = gdk_broadway_display_get_primary_monitor;
display_class->get_setting = gdk_broadway_display_get_setting;
display_class->get_last_seen_time = gdk_broadway_display_get_last_seen_time;
}
+1 -1
View File
@@ -770,7 +770,7 @@ gdk_broadway_surface_maximize (GdkSurface *surface)
impl->pre_maximize_height = surface->height;
display = gdk_surface_get_display (surface);
monitor = gdk_display_get_primary_monitor (display);
monitor = gdk_display_get_monitor (display, 0);
gdk_monitor_get_geometry (monitor, &geom);
gdk_broadway_surface_move_resize (surface,
+71
View File
@@ -456,3 +456,74 @@ gdk_cairo_region_from_clip (cairo_t *cr)
return region;
}
/**
* gdk_cairo_image_surface_recolor:
* @image_surface: a cairo image surface
* @color_matrix: the color matrix to use
* @color_offset: the color offset to use
*
* Modifies the colors of an surfaceimage by applying an affine transformation
* in RGB space.
*
* This is the same operation as in gtk_snapshot_push_color_matrix() but
* always done on the cpu.
*/
void
gdk_cairo_image_surface_recolor (cairo_surface_t *image_surface,
const graphene_matrix_t *color_matrix,
const graphene_vec4_t *color_offset)
{
graphene_vec4_t pixel;
guint32* pixel_data;
guchar *data;
gsize x, y, width, height, stride;
float alpha;
data = cairo_image_surface_get_data (image_surface);
width = cairo_image_surface_get_width (image_surface);
height = cairo_image_surface_get_height (image_surface);
stride = cairo_image_surface_get_stride (image_surface);
for (y = 0; y < height; y++)
{
pixel_data = (guint32 *) data;
for (x = 0; x < width; x++)
{
alpha = ((pixel_data[x] >> 24) & 0xFF) / 255.0;
if (alpha == 0)
{
graphene_vec4_init (&pixel, 0.0, 0.0, 0.0, 0.0);
}
else
{
graphene_vec4_init (&pixel,
((pixel_data[x] >> 16) & 0xFF) / (255.0 * alpha),
((pixel_data[x] >> 8) & 0xFF) / (255.0 * alpha),
( pixel_data[x] & 0xFF) / (255.0 * alpha),
alpha);
graphene_matrix_transform_vec4 (color_matrix, &pixel, &pixel);
}
graphene_vec4_add (&pixel, color_offset, &pixel);
alpha = graphene_vec4_get_w (&pixel);
if (alpha > 0.0)
{
alpha = MIN (alpha, 1.0);
pixel_data[x] = (((guint32) roundf (alpha * 255)) << 24) |
(((guint32) roundf (CLAMP (graphene_vec4_get_x (&pixel), 0, 1) * alpha * 255)) << 16) |
(((guint32) roundf (CLAMP (graphene_vec4_get_y (&pixel), 0, 1) * alpha * 255)) << 8) |
((guint32) roundf (CLAMP (graphene_vec4_get_z (&pixel), 0, 1) * alpha * 255));
}
else
{
pixel_data[x] = 0;
}
}
data += stride;
}
cairo_surface_mark_dirty (image_surface);
}
+6
View File
@@ -26,6 +26,7 @@
#include <gdk/gdkrgba.h>
#include <gdk/gdkpixbuf.h>
#include <pango/pangocairo.h>
#include <graphene.h>
G_BEGIN_DECLS
@@ -72,6 +73,11 @@ void gdk_cairo_surface_upload_to_gl (cairo_surface_t *surface,
int height,
GdkGLContext *context);
GDK_AVAILABLE_IN_ALL
void gdk_cairo_image_surface_recolor (cairo_surface_t *image_surface,
const graphene_matrix_t *color_matrix,
const graphene_vec4_t *color_offset);
G_END_DECLS
#endif /* __GDK_CAIRO_H__ */
+1 -1
View File
@@ -738,7 +738,7 @@ gdk_device_get_source (GdkDevice *device)
*
* Determines the mode of the device.
*
* Returns: a #GdkInputSource
* Returns: a #GdkInputMode
**/
GdkInputMode
gdk_device_get_mode (GdkDevice *device)
-34
View File
@@ -155,12 +155,6 @@ gdk_display_real_get_default_seat (GdkDisplay *display)
return display->seats->data;
}
static GdkMonitor *
gdk_display_real_get_primary_monitor (GdkDisplay *display)
{
return gdk_display_get_monitor (display, 0);
}
static void
gdk_display_class_init (GdkDisplayClass *class)
{
@@ -177,8 +171,6 @@ gdk_display_class_init (GdkDisplayClass *class)
class->event_data_free = gdk_display_real_event_data_free;
class->get_default_seat = gdk_display_real_get_default_seat;
class->get_primary_monitor = gdk_display_real_get_primary_monitor;
/**
* GdkDisplay:composited:
*
@@ -1588,32 +1580,6 @@ gdk_display_get_monitor (GdkDisplay *display,
return GDK_DISPLAY_GET_CLASS (display)->get_monitor (display, monitor_num);
}
/**
* gdk_display_get_primary_monitor:
* @display: a #GdkDisplay
*
* Gets the primary monitor for the display.
*
* The primary monitor is considered the monitor where the “main desktop”
* lives. While normal application surfaces typically allow the window
* manager to place the surfaces, specialized desktop applications
* such as panels should place themselves on the primary monitor.
*
* If no monitor is the designated primary monitor, any monitor
* (usually the first) may be returned. To make sure there is a dedicated
* primary monitor, use gdk_monitor_is_primary() on the returned monitor.
*
* Returns: (transfer none): the primary monitor, or any monitor if no
* primary monitor is configured by the user
*/
GdkMonitor *
gdk_display_get_primary_monitor (GdkDisplay *display)
{
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
return GDK_DISPLAY_GET_CLASS (display)->get_primary_monitor (display);
}
/**
* gdk_display_get_monitor_at_surface:
* @display: a #GdkDisplay
-2
View File
@@ -112,8 +112,6 @@ GDK_AVAILABLE_IN_ALL
GdkMonitor * gdk_display_get_monitor (GdkDisplay *display,
int monitor_num);
GDK_AVAILABLE_IN_ALL
GdkMonitor * gdk_display_get_primary_monitor (GdkDisplay *display);
GDK_AVAILABLE_IN_ALL
GdkMonitor * gdk_display_get_monitor_at_surface (GdkDisplay *display,
GdkSurface *surface);
-17
View File
@@ -492,23 +492,6 @@ gdk_monitor_get_subpixel_layout (GdkMonitor *monitor)
return monitor->subpixel_layout;
}
/**
* gdk_monitor_is_primary:
* @monitor: a #GdkMonitor
*
* Gets whether this monitor should be considered primary
* (see gdk_display_get_primary_monitor()).
*
* Returns: %TRUE if @monitor is primary
*/
gboolean
gdk_monitor_is_primary (GdkMonitor *monitor)
{
g_return_val_if_fail (GDK_IS_MONITOR (monitor), FALSE);
return monitor == gdk_display_get_primary_monitor (monitor->display);
}
GdkMonitor *
gdk_monitor_new (GdkDisplay *display)
{
-2
View File
@@ -88,8 +88,6 @@ int gdk_monitor_get_refresh_rate (GdkMonitor *monitor);
GDK_AVAILABLE_IN_ALL
GdkSubpixelLayout gdk_monitor_get_subpixel_layout (GdkMonitor *monitor);
GDK_AVAILABLE_IN_ALL
gboolean gdk_monitor_is_primary (GdkMonitor *monitor);
GDK_AVAILABLE_IN_ALL
gboolean gdk_monitor_is_valid (GdkMonitor *monitor);
G_END_DECLS
+4 -2
View File
@@ -21,6 +21,7 @@
#include "config.h"
#include <sys/types.h>
#include <signal.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
@@ -38,7 +39,7 @@ static SysprofCaptureWriter *writer = NULL;
static gboolean running = FALSE;
static void
profiler_stop (void)
profiler_stop (int s)
{
if (writer)
sysprof_capture_writer_unref (writer);
@@ -67,7 +68,8 @@ gdk_profiler_start (int fd)
if (writer)
running = TRUE;
atexit (profiler_stop);
atexit (G_CALLBACK (profiler_stop));
signal (SIGTERM, profiler_stop);
}
void
+2
View File
@@ -417,6 +417,7 @@ gdk_seat_default_remove_slave (GdkSeatDefault *seat,
priv->capabilities |= device_get_capability (GDK_DEVICE (l->data));
gdk_seat_device_removed (GDK_SEAT (seat), device);
g_object_unref (device);
}
else if (g_list_find (priv->slave_keyboards, device))
{
@@ -427,6 +428,7 @@ gdk_seat_default_remove_slave (GdkSeatDefault *seat,
priv->capabilities |= device_get_capability (GDK_DEVICE (l->data));
gdk_seat_device_removed (GDK_SEAT (seat), device);
g_object_unref (device);
}
}
-9
View File
@@ -159,14 +159,6 @@ gdk_quartz_display_get_monitor (GdkDisplay *display,
return NULL;
}
static GdkMonitor *
gdk_quartz_display_get_primary_monitor (GdkDisplay *display)
{
GdkQuartzDisplay *quartz_display = GDK_QUARTZ_DISPLAY (display);
return quartz_display->monitors->pdata[0];
}
static gboolean
gdk_quartz_display_get_setting (GdkDisplay *display,
const gchar *name,
@@ -242,7 +234,6 @@ gdk_quartz_display_class_init (GdkQuartzDisplayClass *class)
display_class->utf8_to_string_target = _gdk_quartz_display_utf8_to_string_target;
display_class->get_n_monitors = gdk_quartz_display_get_n_monitors;
display_class->get_monitor = gdk_quartz_display_get_monitor;
display_class->get_primary_monitor = gdk_quartz_display_get_primary_monitor;
display_class->get_setting = gdk_quartz_display_get_setting;
ProcessSerialNumber psn = { 0, kCurrentProcess };
+1 -2
View File
@@ -980,7 +980,7 @@ gdk_win32_display_get_monitor (GdkDisplay *display,
return (GdkMonitor *) g_ptr_array_index (win32_display->monitors, monitor_num);
}
static GdkMonitor *
GdkMonitor *
gdk_win32_display_get_primary_monitor (GdkDisplay *display)
{
GdkWin32Display *win32_display = GDK_WIN32_DISPLAY (display);
@@ -1124,7 +1124,6 @@ gdk_win32_display_class_init (GdkWin32DisplayClass *klass)
display_class->get_n_monitors = gdk_win32_display_get_n_monitors;
display_class->get_monitor = gdk_win32_display_get_monitor;
display_class->get_primary_monitor = gdk_win32_display_get_primary_monitor;
#ifdef GDK_RENDERING_VULKAN
display_class->vk_context_type = GDK_TYPE_WIN32_VULKAN_CONTEXT;
+1 -1
View File
@@ -2822,7 +2822,7 @@ _gdk_win32_surface_handle_aerosnap (GdkSurface *window,
unsnap (window, monitor);
snap_right (window,
monitor,
gdk_monitor_is_primary (monitor) ? monitor : gdk_display_get_monitor (display, n_monitors - 1));
(gdk_win32_display_get_primary_monitor (monitor->display) == monitor) ? monitor : gdk_display_get_monitor (display, n_monitors - 1));
}
else if (impl->snap_state == GDK_WIN32_AEROSNAP_STATE_HALFRIGHT)
{
+4
View File
@@ -101,6 +101,10 @@ void gdk_win32_display_remove_filter (GdkWin32Display
GdkWin32MessageFilterFunc function,
gpointer data);
GDK_AVAILABLE_IN_ALL
GdkMonitor * gdk_win32_display_get_primary_monitor (GdkDisplay *display);
G_END_DECLS
#endif /* __GDK_WIN32_DISPLAY_H__ */
+1 -1
View File
@@ -176,7 +176,7 @@ gdk_x11_cursor_create_for_texture (GdkDisplay *display,
int target_scale;
target_scale =
gdk_monitor_get_scale_factor (gdk_display_get_primary_monitor (display));
gdk_monitor_get_scale_factor (gdk_x11_display_get_primary_monitor (display));
xcimage = create_cursor_image (texture, x, y, target_scale);
xcursor = XcursorImageLoadCursor (GDK_DISPLAY_XDISPLAY (display), xcimage);
XcursorImageDestroy (xcimage);
+4 -3
View File
@@ -685,12 +685,13 @@ remove_device (GdkX11DeviceManagerXI2 *device_manager,
if (device)
{
detach_from_seat (device);
device_manager->devices = g_list_remove (device_manager->devices, device);
g_object_run_dispose (G_OBJECT (device));
g_hash_table_remove (device_manager->id_table,
GINT_TO_POINTER (device_id));
device_manager->devices = g_list_remove (device_manager->devices, device);
g_object_run_dispose (G_OBJECT (device));
g_object_unref (device);
}
}
+19 -2
View File
@@ -2956,7 +2956,25 @@ gdk_x11_display_get_monitor (GdkDisplay *display,
return NULL;
}
static GdkMonitor *
/**
* gdk_x11_display_get_primary_monitor:
* @display: a #GdkDisplay
*
* Gets the primary monitor for the display.
*
* The primary monitor is considered the monitor where the main desktop
* lives. While normal application surfaces typically allow the window
* manager to place the surfaces, specialized desktop applications
* such as panels should place themselves on the primary monitor.
*
* If no monitor is the designated primary monitor, any monitor
* (usually the first) may be returned. To make sure there is a dedicated
* primary monitor, use gdk_monitor_is_primary() on the returned monitor.
*
* Returns: (transfer none): the primary monitor, or any monitor if no
* primary monitor is configured by the user
*/
GdkMonitor *
gdk_x11_display_get_primary_monitor (GdkDisplay *display)
{
GdkX11Display *x11_display = GDK_X11_DISPLAY (display);
@@ -3062,7 +3080,6 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class)
display_class->get_n_monitors = gdk_x11_display_get_n_monitors;
display_class->get_monitor = gdk_x11_display_get_monitor;
display_class->get_primary_monitor = gdk_x11_display_get_primary_monitor;
display_class->get_setting = gdk_x11_display_get_setting;
display_class->get_last_seen_time = gdk_x11_display_get_last_seen_time;
display_class->set_cursor_theme = gdk_x11_display_set_cursor_theme;
+18 -10
View File
@@ -67,19 +67,27 @@ gdk_x11_monitor_get_workarea (GdkMonitor *monitor,
gdk_monitor_get_geometry (monitor, dest);
/* The EWMH constrains workarea to be a rectangle, so it
* can't adequately deal with L-shaped monitor arrangements.
* As a workaround, we ignore the workarea for anything
* but the primary monitor. Since that is where the 'desktop
* chrome' usually lives, this works ok in practice.
*/
if (gdk_monitor_is_primary (monitor) &&
!gdk_monitor_has_fullscreen_window (monitor))
if (_gdk_x11_screen_get_monitor_work_area (screen, monitor, &workarea))
{
gdk_x11_screen_get_work_area (screen, &workarea);
if (gdk_rectangle_intersect (dest, &workarea, &workarea))
if (!gdk_monitor_has_fullscreen_window (monitor))
*dest = workarea;
}
else
{
/* The EWMH constrains workarea to be a rectangle, so it
* can't adequately deal with L-shaped monitor arrangements.
* As a workaround, we ignore the workarea for anything
* but the primary monitor. Since that is where the 'desktop
* chrome' usually lives, this works ok in practice.
*/
if (monitor == gdk_x11_display_get_primary_monitor (monitor->display) &&
!gdk_monitor_has_fullscreen_window (monitor))
{
gdk_x11_screen_get_work_area (screen, &workarea);
if (gdk_rectangle_intersect (dest, &workarea, &workarea))
*dest = workarea;
}
}
}
static void
+99
View File
@@ -179,6 +179,105 @@ get_current_desktop (GdkX11Screen *screen)
return workspace;
}
gboolean
_gdk_x11_screen_get_monitor_work_area (GdkX11Screen *x11_screen,
GdkMonitor *monitor,
GdkRectangle *area)
{
Display *xdisplay;
Atom net_workareas;
int current_desktop;
char *workareas_dn_name;
Atom workareas_dn;
int screen_number;
Window xroot;
int result;
Atom type;
int format;
gulong num;
gulong leftovers;
guchar *ret_workarea;
long *workareas;
GdkRectangle geometry;
int i;
if (!gdk_x11_screen_supports_net_wm_hint (x11_screen,
g_intern_static_string ("_GTK_WORKAREAS")))
return FALSE;
xdisplay = gdk_x11_display_get_xdisplay (x11_screen->display);
net_workareas = XInternAtom (xdisplay, "_GTK_WORKAREAS", False);
if (net_workareas == None)
return FALSE;
current_desktop = get_current_desktop (x11_screen);
workareas_dn_name = g_strdup_printf ("_GTK_WORKAREAS_D%d", current_desktop);
workareas_dn = XInternAtom (xdisplay, workareas_dn_name, True);
g_free (workareas_dn_name);
if (workareas_dn == None)
return FALSE;
screen_number = gdk_x11_screen_get_screen_number (x11_screen);
xroot = XRootWindow (xdisplay, screen_number);
gdk_x11_display_error_trap_push (x11_screen->display);
ret_workarea = NULL;
result = XGetWindowProperty (xdisplay,
xroot,
workareas_dn,
0,
G_MAXLONG,
False,
AnyPropertyType,
&type,
&format,
&num,
&leftovers,
&ret_workarea);
gdk_x11_display_error_trap_pop_ignored (x11_screen->display);
if (result != Success ||
type == None ||
format == 0 ||
leftovers ||
num % 4 != 0)
{
XFree (ret_workarea);
return FALSE;
}
workareas = (long *) ret_workarea;
gdk_monitor_get_geometry (monitor, &geometry);
*area = geometry;
for (i = 0; i < num / 4; i++)
{
GdkRectangle work_area;
work_area = (GdkRectangle) {
.x = workareas[0] / x11_screen->surface_scale,
.y = workareas[1] / x11_screen->surface_scale,
.width = workareas[2] / x11_screen->surface_scale,
.height = workareas[3] / x11_screen->surface_scale,
};
if (gdk_rectangle_intersect (area, &work_area, &work_area))
*area = work_area;
workareas += 4;
}
XFree (ret_workarea);
return TRUE;
}
void
gdk_x11_screen_get_work_area (GdkX11Screen *x11_screen,
GdkRectangle *area)
+3
View File
@@ -108,6 +108,9 @@ void _gdk_x11_screen_get_edge_monitors (GdkX11Screen *screen,
gint *right);
void _gdk_x11_screen_set_surface_scale (GdkX11Screen *x11_screen,
int scale);
gboolean _gdk_x11_screen_get_monitor_work_area (GdkX11Screen *screen,
GdkMonitor *monitor,
GdkRectangle *area);
void gdk_x11_screen_get_work_area (GdkX11Screen *screen,
GdkRectangle *area);
gboolean gdk_x11_screen_get_setting (GdkX11Screen *screen,
+3 -1
View File
@@ -105,6 +105,9 @@ GdkDisplay *gdk_x11_lookup_xdisplay (Display *xdisplay);
GDK_AVAILABLE_IN_ALL
GdkX11Screen *gdk_x11_display_get_screen (GdkDisplay *display);
GDK_AVAILABLE_IN_ALL
GdkMonitor * gdk_x11_display_get_primary_monitor (GdkDisplay *display);
GDK_AVAILABLE_IN_ALL
void gdk_x11_display_grab (GdkDisplay *display);
GDK_AVAILABLE_IN_ALL
@@ -130,7 +133,6 @@ void gdk_x11_register_standard_event_type (GdkDisplay *display,
GDK_AVAILABLE_IN_ALL
void gdk_x11_set_sm_client_id (const gchar *sm_client_id);
G_END_DECLS
#endif /* __GDK_X11_DISPLAY_H__ */
+3 -50
View File
@@ -2339,11 +2339,6 @@ gsk_color_matrix_node_draw (GskRenderNode *node,
GskColorMatrixNode *self = (GskColorMatrixNode *) node;
cairo_pattern_t *pattern;
cairo_surface_t *surface, *image_surface;
graphene_vec4_t pixel;
guint32* pixel_data;
guchar *data;
gsize x, y, width, height, stride;
float alpha;
cairo_save (cr);
@@ -2360,52 +2355,10 @@ gsk_color_matrix_node_draw (GskRenderNode *node,
cairo_pattern_get_surface (pattern, &surface);
image_surface = cairo_surface_map_to_image (surface, NULL);
data = cairo_image_surface_get_data (image_surface);
width = cairo_image_surface_get_width (image_surface);
height = cairo_image_surface_get_height (image_surface);
stride = cairo_image_surface_get_stride (image_surface);
gdk_cairo_image_surface_recolor (image_surface,
&self->color_matrix,
&self->color_offset);
for (y = 0; y < height; y++)
{
pixel_data = (guint32 *) data;
for (x = 0; x < width; x++)
{
alpha = ((pixel_data[x] >> 24) & 0xFF) / 255.0;
if (alpha == 0)
{
graphene_vec4_init (&pixel, 0.0, 0.0, 0.0, 0.0);
}
else
{
graphene_vec4_init (&pixel,
((pixel_data[x] >> 16) & 0xFF) / (255.0 * alpha),
((pixel_data[x] >> 8) & 0xFF) / (255.0 * alpha),
( pixel_data[x] & 0xFF) / (255.0 * alpha),
alpha);
graphene_matrix_transform_vec4 (&self->color_matrix, &pixel, &pixel);
}
graphene_vec4_add (&pixel, &self->color_offset, &pixel);
alpha = graphene_vec4_get_w (&pixel);
if (alpha > 0.0)
{
alpha = MIN (alpha, 1.0);
pixel_data[x] = (((guint32) roundf (alpha * 255)) << 24) |
(((guint32) roundf (CLAMP (graphene_vec4_get_x (&pixel), 0, 1) * alpha * 255)) << 16) |
(((guint32) roundf (CLAMP (graphene_vec4_get_y (&pixel), 0, 1) * alpha * 255)) << 8) |
((guint32) roundf (CLAMP (graphene_vec4_get_z (&pixel), 0, 1) * alpha * 255));
}
else
{
pixel_data[x] = 0;
}
}
data += stride;
}
cairo_surface_mark_dirty (image_surface);
cairo_surface_unmap_image (surface, image_surface);
cairo_set_source (cr, pattern);
+6 -9
View File
@@ -310,8 +310,8 @@ gsk_pango_renderer_prepare_run (PangoRenderer *renderer,
PangoLayoutRun *run)
{
GskPangoRenderer *crenderer = GSK_PANGO_RENDERER (renderer);
GdkRGBA *bg_rgba = NULL;
GdkRGBA *fg_rgba = NULL;
const GdkRGBA *bg_rgba = NULL;
const GdkRGBA *fg_rgba = NULL;
GtkTextAppearance *appearance;
PANGO_RENDERER_CLASS (gsk_pango_renderer_parent_class)->prepare_run (renderer, run);
@@ -335,8 +335,8 @@ gsk_pango_renderer_prepare_run (PangoRenderer *renderer,
GtkCssValue *value;
node = gtk_text_view_get_selection_node ((GtkTextView *)crenderer->widget);
value = gtk_css_style_get_value (gtk_css_node_get_style (node), GTK_CSS_PROPERTY_COLOR);
fg_rgba = (GdkRGBA *)gtk_css_color_value_get_rgba (value);
value = gtk_css_node_get_style (node)->core->color;
fg_rgba = gtk_css_color_value_get_rgba (value);
}
else if (crenderer->state == GSK_PANGO_RENDERER_CURSOR && gtk_widget_has_focus (crenderer->widget))
{
@@ -344,8 +344,8 @@ gsk_pango_renderer_prepare_run (PangoRenderer *renderer,
GtkCssValue *value;
node = gtk_widget_get_css_node (crenderer->widget);
value = gtk_css_style_get_value (gtk_css_node_get_style (node), GTK_CSS_PROPERTY_BACKGROUND_COLOR);
fg_rgba = (GdkRGBA *)gtk_css_color_value_get_rgba (value);
value = gtk_css_node_get_style (node)->background->background_color;
fg_rgba = gtk_css_color_value_get_rgba (value);
}
else
fg_rgba = appearance->fg_rgba;
@@ -371,9 +371,6 @@ gsk_pango_renderer_prepare_run (PangoRenderer *renderer,
}
else
text_renderer_set_rgba (crenderer, PANGO_RENDER_PART_UNDERLINE, fg_rgba);
if (fg_rgba != appearance->fg_rgba)
gdk_rgba_free (fg_rgba);
}
static void
+1 -2
View File
@@ -95,7 +95,7 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkHeaderBar, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkIMContext, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkIMContextSimple, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkIMMulticontext, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkIconInfo, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkIcon, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkIconTheme, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkIconView, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkImage, g_object_unref)
@@ -178,6 +178,5 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkTextIter, gtk_text_iter_free)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkTreeIter, gtk_tree_iter_free)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkTreePath, gtk_tree_path_free)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkTreeRowReference, gtk_tree_row_reference_free)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkWidgetPath, gtk_widget_path_unref)
#endif
-1
View File
@@ -253,7 +253,6 @@
#include <gtk/gtkvolumebutton.h>
#include <gtk/gtkwidget.h>
#include <gtk/gtkwidgetpaintable.h>
#include <gtk/gtkwidgetpath.h>
#include <gtk/gtkwindow.h>
#include <gtk/gtkwindowgroup.h>
+8 -8
View File
@@ -103,7 +103,7 @@ icon_loaded (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
GtkIconInfo *info = GTK_ICON_INFO (object);
GtkIcon *icon = GTK_ICON (object);
GNSMenuItem *item = user_data;
GError *error = NULL;
GdkPixbuf *pixbuf;
@@ -117,7 +117,7 @@ icon_loaded (GObject *object,
scale = roundf ([[NSScreen mainScreen] backingScaleFactor]);
#endif
pixbuf = gtk_icon_info_load_symbolic_finish (info, result, NULL, &error);
pixbuf = gtk_icon_load_symbolic_finish (icon, result, NULL, &error);
if (pixbuf != NULL)
{
@@ -278,7 +278,7 @@ icon_loaded (GObject *object,
static GdkRGBA error;
GtkIconTheme *theme;
GtkIconInfo *info;
GtkIcon *icon;
gint scale = 1;
if (!parsed)
@@ -300,14 +300,14 @@ icon_loaded (GObject *object,
if ([[NSScreen mainScreen] respondsToSelector:@selector(backingScaleFactor)])
scale = roundf ([[NSScreen mainScreen] backingScaleFactor]);
#endif
info = gtk_icon_theme_lookup_by_gicon_for_scale (theme, icon, ICON_SIZE, scale, GTK_ICON_LOOKUP_USE_BUILTIN);
icon = gtk_icon_theme_lookup_by_gicon (theme, icon, ICON_SIZE, scale, GTK_ICON_LOOKUP_USE_BUILTIN);
if (info != NULL)
if (icon != NULL)
{
cancellable = g_cancellable_new ();
gtk_icon_info_load_symbolic_async (info, &foreground, &success, &warning, &error,
cancellable, icon_loaded, self);
g_object_unref (info);
gtk_icon_load_symbolic_async (icon, &foreground, &success, &warning, &error,
cancellable, icon_loaded, self);
g_object_unref (icon);
return;
}
}
+3 -3
View File
@@ -105,8 +105,8 @@
* If there is a resource located at "gtk/help-overlay.ui" which
* defines a #GtkShortcutsWindow with ID "help_overlay" then GtkApplication
* associates an instance of this shortcuts window with each
* #GtkApplicationWindow and sets up keyboard accelerators (Control-F1
* and Control-?) to open it. To create a menu item that displays the
* #GtkApplicationWindow and sets up the keyboard accelerator Control-?
* to open it. To create a menu item that displays the
* shortcuts window, associate the item with the action win.show-help-overlay.
*
* ## A simple application ## {#gtkapplication}
@@ -279,7 +279,7 @@ gtk_application_load_resources (GtkApplication *application)
path = g_strconcat (base_path, "/gtk/help-overlay.ui", NULL);
if (g_resources_get_info (path, G_RESOURCE_LOOKUP_FLAGS_NONE, NULL, NULL, NULL))
{
const gchar * const accels[] = { "<Primary>F1", "<Primary>question", NULL };
const gchar * const accels[] = { "<Primary>question", NULL };
priv->help_overlay_path = path;
gtk_application_set_accels_for_action (application, "win.show-help-overlay", accels);
-1
View File
@@ -66,7 +66,6 @@
#include "gtktypebuiltins.h"
#include "gtksizerequest.h"
#include "gtkstylecontextprivate.h"
#include "gtkwidgetpath.h"
#include "gtkwidgetprivate.h"
#include "a11y/gtkcontaineraccessible.h"
+12 -8
View File
@@ -1219,6 +1219,7 @@ gtk_builder_extend_with_template (GtkBuilder *builder,
{
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
GError *tmp_error;
char *filename;
g_return_val_if_fail (GTK_IS_BUILDER (builder), 0);
g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
@@ -1234,11 +1235,13 @@ gtk_builder_extend_with_template (GtkBuilder *builder,
priv->resource_prefix = NULL;
priv->template_type = template_type;
filename = g_strconcat ("<", g_type_name (template_type), " template>", NULL);
gtk_builder_expose_object (builder, g_type_name (template_type), G_OBJECT (widget));
_gtk_builder_parser_parse_buffer (builder, "<input>",
_gtk_builder_parser_parse_buffer (builder, filename,
buffer, length,
NULL,
&tmp_error);
g_free (filename);
if (tmp_error != NULL)
{
@@ -2157,7 +2160,8 @@ gtk_builder_value_from_string_type (GtkBuilder *builder,
if (pixbuf == NULL)
{
GtkIconTheme *theme;
GdkPaintable *texture;
GtkIcon *icon;
GdkTexture *texture;
g_warning ("Could not load image '%s': %s",
string, tmp_error->message);
@@ -2165,12 +2169,12 @@ gtk_builder_value_from_string_type (GtkBuilder *builder,
/* fall back to a missing image */
theme = gtk_icon_theme_get_default ();
texture = gtk_icon_theme_load_icon (theme,
"image-missing",
16,
GTK_ICON_LOOKUP_USE_BUILTIN,
NULL);
pixbuf = gdk_pixbuf_get_from_texture (GDK_TEXTURE (texture));
icon = gtk_icon_theme_lookup_icon (theme, "image-missing", 16, 1,
GTK_ICON_LOOKUP_USE_BUILTIN);
texture = gtk_icon_download_texture (icon, NULL);
pixbuf = gdk_pixbuf_get_from_texture (texture);
g_object_unref (icon);
g_object_unref (texture);
}
+4
View File
@@ -26,6 +26,7 @@
#include "gtkintl.h"
#include "gtktypebuiltins.h"
#include "gtkversion.h"
#include "gdkprofilerprivate.h"
#include <gio/gio.h>
#include <string.h>
@@ -1548,6 +1549,7 @@ _gtk_builder_parser_parse_buffer (GtkBuilder *builder,
const gchar* domain;
ParserData data;
GSList *l;
gint64 before = g_get_monotonic_time ();
/* Store the original domain so that interface domain attribute can be
* applied for the builder and the original domain can be restored after
@@ -1622,4 +1624,6 @@ _gtk_builder_parser_parse_buffer (GtkBuilder *builder,
/* restore the original domain */
gtk_builder_set_translation_domain (builder, domain);
gdk_profiler_add_mark (before * 1000, (g_get_monotonic_time () - before) * 1000, "builder load", filename);
}
+25 -25
View File
@@ -23,26 +23,26 @@
#include "gtkcssnodeprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkiconprivate.h"
#include "gtkbuiltiniconprivate.h"
#include "gtkwidgetprivate.h"
#include "gtkrendericonprivate.h"
#include "gtksnapshot.h"
/* GtkIcon was a minimal widget wrapped around a GtkBuiltinIcon gadget,
/* GtkBuiltinIcon was a minimal widget wrapped around a GtkBuiltinIcon gadget,
* It should be used whenever builtin-icon functionality is desired
* but a widget is needed for other reasons.
*/
struct _GtkIcon
struct _GtkBuiltinIcon
{
GtkWidget parent;
};
G_DEFINE_TYPE (GtkIcon, gtk_icon, GTK_TYPE_WIDGET)
G_DEFINE_TYPE (GtkBuiltinIcon, gtk_builtin_icon, GTK_TYPE_WIDGET)
static void
gtk_icon_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot)
gtk_builtin_icon_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot)
{
GtkCssStyle *style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
int width, height;
@@ -55,7 +55,7 @@ gtk_icon_snapshot (GtkWidget *widget,
}
static void
gtk_icon_style_updated (GtkWidget *widget)
gtk_builtin_icon_style_updated (GtkWidget *widget)
{
GtkStyleContext *context;
GtkCssStyleChange *change = NULL;
@@ -63,7 +63,7 @@ gtk_icon_style_updated (GtkWidget *widget)
context = gtk_widget_get_style_context (widget);
change = gtk_style_context_get_change (context);
GTK_WIDGET_CLASS (gtk_icon_parent_class)->style_updated (widget);
GTK_WIDGET_CLASS (gtk_builtin_icon_parent_class)->style_updated (widget);
if (change == NULL ||
gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_ICON_SIZE))
@@ -78,13 +78,13 @@ gtk_icon_style_updated (GtkWidget *widget)
}
static void
gtk_icon_measure (GtkWidget *widget,
GtkOrientation orientation,
int for_size,
int *minimum,
int *natural,
int *minimum_baseline,
int *natural_baseline)
gtk_builtin_icon_measure (GtkWidget *widget,
GtkOrientation orientation,
int for_size,
int *minimum,
int *natural,
int *minimum_baseline,
int *natural_baseline)
{
GtkCssValue *icon_size;
@@ -93,32 +93,32 @@ gtk_icon_measure (GtkWidget *widget,
}
static void
gtk_icon_class_init (GtkIconClass *klass)
gtk_builtin_icon_class_init (GtkBuiltinIconClass *klass)
{
GtkWidgetClass *wclass = GTK_WIDGET_CLASS (klass);
wclass->snapshot = gtk_icon_snapshot;
wclass->measure = gtk_icon_measure;
wclass->style_updated = gtk_icon_style_updated;
wclass->snapshot = gtk_builtin_icon_snapshot;
wclass->measure = gtk_builtin_icon_measure;
wclass->style_updated = gtk_builtin_icon_style_updated;
}
static void
gtk_icon_init (GtkIcon *self)
gtk_builtin_icon_init (GtkBuiltinIcon *self)
{
}
GtkWidget *
gtk_icon_new (const char *css_name)
gtk_builtin_icon_new (const char *css_name)
{
return g_object_new (GTK_TYPE_ICON,
return g_object_new (GTK_TYPE_BUILTIN_ICON,
"css-name", css_name,
NULL);
}
void
gtk_icon_set_css_name (GtkIcon *self,
const char *css_name)
gtk_builtin_icon_set_css_name (GtkBuiltinIcon *self,
const char *css_name)
{
gtk_css_node_set_name (gtk_widget_get_css_node (GTK_WIDGET (self)),
g_intern_string (css_name));
g_quark_from_string (css_name));
}
@@ -17,23 +17,22 @@
* Authors: Cosimo Cecchi <cosimoc@gnome.org>
*/
#ifndef __GTK_ICON_PRIVATE_H__
#define __GTK_ICON_PRIVATE_H__
#ifndef __GTK_BUILTIN_ICON_PRIVATE_H__
#define __GTK_BUILTIN_ICON_PRIVATE_H__
#include "gtkwidget.h"
#include "gtkcsstypesprivate.h"
G_BEGIN_DECLS
#define GTK_TYPE_ICON (gtk_icon_get_type ())
#define GTK_TYPE_BUILTIN_ICON (gtk_builtin_icon_get_type ())
G_DECLARE_FINAL_TYPE (GtkIcon, gtk_icon, GTK, ICON, GtkWidget)
G_DECLARE_FINAL_TYPE (GtkBuiltinIcon, gtk_builtin_icon, GTK, BUILTIN_ICON, GtkWidget)
GtkWidget * gtk_icon_new (const char *css_name);
void gtk_icon_set_css_name (GtkIcon *self,
const char *css_name);
GtkWidget * gtk_builtin_icon_new (const char *css_name);
void gtk_builtin_icon_set_css_name (GtkBuiltinIcon *self,
const char *css_name);
G_END_DECLS
#endif /* __GTK_ICON_PRIVATE_H__ */
#endif /* __GTK_BUILTIN_ICON_PRIVATE_H__ */
+144 -251
View File
@@ -90,6 +90,10 @@
#include "gtknative.h"
#include "gtkicontheme.h"
#include "gtkdragicon.h"
#include "gtkbutton.h"
#include "gtkbox.h"
#include "gtklabel.h"
#include "gtkstack.h"
#define TIMEOUT_INITIAL 500
#define TIMEOUT_REPEAT 50
@@ -212,6 +216,11 @@ struct _GtkCalendarPrivate
{
GtkCalendarDisplayOptions display_flags;
GtkWidget *header_box;
GtkWidget *year_label;
GtkWidget *month_name_stack;
GtkWidget *arrow_widgets[4];
gint month;
gint year;
gint selected_day;
@@ -364,11 +373,27 @@ static gboolean gtk_calendar_scroll_controller_scroll (GtkEventControllerScroll
gdouble dy,
GtkWidget *widget);
static void calendar_set_month_prev (GtkCalendar *calendar);
static void calendar_set_month_next (GtkCalendar *calendar);
static void calendar_set_year_prev (GtkCalendar *calendar);
static void calendar_set_year_next (GtkCalendar *calendar);
static char *default_abbreviated_dayname[7];
static char *default_monthname[12];
G_DEFINE_TYPE_WITH_PRIVATE (GtkCalendar, gtk_calendar, GTK_TYPE_WIDGET)
static void
gtk_calendar_dispose (GObject *object)
{
GtkCalendarPrivate *priv = gtk_calendar_get_instance_private (GTK_CALENDAR (object));
g_clear_pointer (&priv->header_box, gtk_widget_unparent);
G_OBJECT_CLASS (gtk_calendar_parent_class)->dispose (object);
}
static void
gtk_calendar_class_init (GtkCalendarClass *class)
{
@@ -378,6 +403,7 @@ gtk_calendar_class_init (GtkCalendarClass *class)
gobject_class = (GObjectClass*) class;
widget_class = (GtkWidgetClass*) class;
gobject_class->dispose = gtk_calendar_dispose;
gobject_class->set_property = gtk_calendar_set_property;
gobject_class->get_property = gtk_calendar_get_property;
@@ -637,12 +663,59 @@ gtk_calendar_class_init (GtkCalendarClass *class)
gtk_widget_class_set_css_name (widget_class, I_("calendar"));
}
static void
set_year (GtkCalendar *calendar,
int new_year)
{
GtkCalendarPrivate *priv = gtk_calendar_get_instance_private (calendar);
char buffer[255];
char *str;
time_t tmp_time;
struct tm *tm;
priv->year = new_year;
tmp_time = 1; /* Jan 1 1970, 00:00:01 UTC */
tm = gmtime (&tmp_time);
tm->tm_year = priv->year - 1900;
/* Translators: This dictates how the year is displayed in
* gtkcalendar widget. See strftime() manual for the format.
* Use only ASCII in the translation.
*
* Also look for the msgid "2000".
* Translate that entry to a year with the widest output of this
* msgid.
*
* "%Y" is appropriate for most locales.
*/
strftime (buffer, sizeof (buffer), C_("calendar year format", "%Y"), tm);
str = g_locale_to_utf8 (buffer, -1, NULL, NULL, NULL);
gtk_label_set_label (GTK_LABEL (priv->year_label), str);
g_free (str);
}
static void
set_month (GtkCalendar *calendar,
int new_month)
{
GtkCalendarPrivate *priv = gtk_calendar_get_instance_private (calendar);
g_return_if_fail (new_month >= 0);
g_return_if_fail (new_month < 12);
priv->month = new_month;
gtk_stack_set_visible_child_name (GTK_STACK (priv->month_name_stack),
default_monthname[priv->month]);
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
static void
gtk_calendar_init (GtkCalendar *calendar)
{
GtkCalendarPrivate *priv = gtk_calendar_get_instance_private (calendar);
GtkWidget *widget = GTK_WIDGET (calendar);
GtkEventController *controller;
GtkGesture *gesture;
@@ -656,7 +729,6 @@ gtk_calendar_init (GtkCalendar *calendar)
char buffer[255];
time_t tmp_time;
#endif
GtkCalendarPrivate *priv = gtk_calendar_get_instance_private (calendar);
gchar *year_before;
#ifdef HAVE__NL_TIME_FIRST_WEEKDAY
union { unsigned int word; char *string; } langinfo;
@@ -674,6 +746,33 @@ gtk_calendar_init (GtkCalendar *calendar)
gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (calendar)),
GTK_STYLE_CLASS_VIEW);
priv->header_box = g_object_new (GTK_TYPE_BOX,
"css-name", "header",
NULL);
priv->year_label = gtk_label_new ("");
gtk_style_context_add_class (gtk_widget_get_style_context (priv->year_label), "year");
priv->month_name_stack = gtk_stack_new ();
gtk_style_context_add_class (gtk_widget_get_style_context (priv->month_name_stack), "month");
priv->arrow_widgets[0] = gtk_button_new_from_icon_name ("pan-start-symbolic");
g_signal_connect_swapped (priv->arrow_widgets[0], "clicked", G_CALLBACK (calendar_set_month_prev), calendar);
priv->arrow_widgets[1] = gtk_button_new_from_icon_name ("pan-end-symbolic");
g_signal_connect_swapped (priv->arrow_widgets[1], "clicked", G_CALLBACK (calendar_set_month_next), calendar);
gtk_widget_set_hexpand (priv->arrow_widgets[1], TRUE);
gtk_widget_set_halign (priv->arrow_widgets[1], GTK_ALIGN_START);
priv->arrow_widgets[2] = gtk_button_new_from_icon_name ("pan-start-symbolic");
g_signal_connect_swapped (priv->arrow_widgets[2], "clicked", G_CALLBACK (calendar_set_year_prev), calendar);
priv->arrow_widgets[3] = gtk_button_new_from_icon_name ("pan-end-symbolic");
g_signal_connect_swapped (priv->arrow_widgets[3], "clicked", G_CALLBACK (calendar_set_year_next), calendar);
gtk_container_add (GTK_CONTAINER (priv->header_box), priv->arrow_widgets[0]);
gtk_container_add (GTK_CONTAINER (priv->header_box), priv->month_name_stack);
gtk_container_add (GTK_CONTAINER (priv->header_box), priv->arrow_widgets[1]);
gtk_container_add (GTK_CONTAINER (priv->header_box), priv->arrow_widgets[2]);
gtk_container_add (GTK_CONTAINER (priv->header_box), priv->year_label);
gtk_container_add (GTK_CONTAINER (priv->header_box), priv->arrow_widgets[3]);
gtk_widget_set_parent (priv->header_box, GTK_WIDGET (calendar));
gesture = gtk_gesture_click_new ();
g_signal_connect (gesture, "pressed", G_CALLBACK (gtk_calendar_button_press), calendar);
g_signal_connect (gesture, "released", G_CALLBACK (gtk_calendar_button_release), calendar);
@@ -750,11 +849,19 @@ gtk_calendar_init (GtkCalendar *calendar)
#endif
}
for (i = 0; i < 12; i ++)
{
GtkWidget *month_label = gtk_label_new (default_monthname[i]);
gtk_stack_add_named (GTK_STACK (priv->month_name_stack), month_label, default_monthname[i]);
}
/* Set defaults */
secs = time (NULL);
tm = localtime (&secs);
priv->month = tm->tm_mon;
priv->year = 1900 + tm->tm_year;
set_month (calendar, tm->tm_mon);
set_year (calendar, 1900 + tm->tm_year);
for (i=0;i<31;i++)
priv->marked_date[i] = FALSE;
@@ -894,11 +1001,11 @@ calendar_set_month_next (GtkCalendar *calendar)
if (priv->month == 11)
{
priv->month = 0;
priv->year++;
set_month (calendar, 0);
set_year (calendar, priv->year + 1);
}
else
priv->month++;
set_month (calendar, priv->month + 1);
calendar_compute_days (calendar);
g_signal_emit (calendar,
@@ -927,7 +1034,8 @@ calendar_set_year_prev (GtkCalendar *calendar)
GtkCalendarPrivate *priv = gtk_calendar_get_instance_private (calendar);
gint month_len;
priv->year--;
set_year (calendar, priv->year - 1);
calendar_compute_days (calendar);
g_signal_emit (calendar,
gtk_calendar_signals[PREV_YEAR_SIGNAL],
@@ -955,7 +1063,8 @@ calendar_set_year_next (GtkCalendar *calendar)
GtkCalendarPrivate *priv = gtk_calendar_get_instance_private (calendar);
gint month_len;
priv->year++;
set_year (calendar, priv->year + 1);
calendar_compute_days (calendar);
g_signal_emit (calendar,
gtk_calendar_signals[NEXT_YEAR_SIGNAL],
@@ -1229,51 +1338,9 @@ calendar_arrow_rectangle (GtkCalendar *calendar,
GdkRectangle *rect)
{
GtkCalendarPrivate *priv = gtk_calendar_get_instance_private (calendar);
GtkWidget *widget = GTK_WIDGET (calendar);
int width;
gboolean year_left;
width = gtk_widget_get_width (widget);
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
year_left = priv->year_before;
else
year_left = !priv->year_before;
rect->y = 3;
rect->width = priv->arrow_width;
rect->height = priv->header_h - 7;
switch (arrow)
{
case ARROW_MONTH_LEFT:
if (year_left)
rect->x = (width - (3 + 2 * priv->arrow_width + priv->max_month_width));
else
rect->x = 3;
break;
case ARROW_MONTH_RIGHT:
if (year_left)
rect->x = width - 3 - priv->arrow_width;
else
rect->x = priv->arrow_width + priv->max_month_width;
break;
case ARROW_YEAR_LEFT:
if (year_left)
rect->x = 3;
else
rect->x = width - (3 + 2 * priv->arrow_width + priv->max_year_width);
break;
case ARROW_YEAR_RIGHT:
if (year_left)
rect->x = (priv->arrow_width + priv->max_year_width);
else
rect->x = width - 3 - priv->arrow_width;
break;
default:
g_assert_not_reached();
}
gtk_widget_get_allocation (priv->arrow_widgets[arrow],
rect);
}
static void
@@ -1301,11 +1368,11 @@ calendar_set_month_prev (GtkCalendar *calendar)
if (priv->month == 0)
{
priv->month = 11;
priv->year--;
set_month (calendar, 11);
set_year (calendar, priv->year - 1);
}
else
priv->month--;
set_month (calendar, priv->month - 1);
month_len = month_length[leap (priv->year)][priv->month + 1];
@@ -1628,35 +1695,14 @@ gtk_calendar_size_request (GtkWidget *widget,
layout = gtk_widget_create_pango_layout (widget, NULL);
/*
* Calculate the requisition width for the widget.
*/
/* Header width */
if (priv->display_flags & GTK_CALENDAR_SHOW_HEADING)
{
priv->max_month_width = 0;
for (i = 0; i < 12; i++)
{
pango_layout_set_text (layout, default_monthname[i], -1);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
priv->max_month_width = MAX (priv->max_month_width,
logical_rect.width + 8);
max_header_height = MAX (max_header_height, logical_rect.height);
}
priv->max_year_width = 0;
/* Translators: This is a text measurement template.
* Translate it to the widest year text
*
* If you don't understand this, leave it as "2000"
*/
pango_layout_set_text (layout, C_("year measurement template", "2000"), -1);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
priv->max_year_width = MAX (priv->max_year_width,
logical_rect.width + 8);
max_header_height = MAX (max_header_height, logical_rect.height);
gtk_widget_measure (priv->header_box, GTK_ORIENTATION_HORIZONTAL, -1,
&header_width, NULL, NULL, NULL);
gtk_widget_measure (priv->header_box, GTK_ORIENTATION_VERTICAL, -1,
&max_header_height, NULL, NULL, NULL);
}
else
{
@@ -1664,15 +1710,6 @@ gtk_calendar_size_request (GtkWidget *widget,
priv->max_year_width = 0;
}
if (priv->display_flags & GTK_CALENDAR_NO_MONTH_CHANGE)
header_width = (priv->max_month_width
+ priv->max_year_width
+ 3 * 3);
else
header_width = (priv->max_month_width
+ priv->max_year_width
+ 4 * priv->arrow_width + 3 * 3);
/* Mainwindow labels width */
priv->max_day_char_width = 0;
@@ -1875,6 +1912,7 @@ gtk_calendar_size_allocate (GtkWidget *widget,
GtkCalendarPrivate *priv = gtk_calendar_get_instance_private (calendar);
gint inner_border = calendar_get_inner_border (calendar);
gint calendar_xsep = calendar_get_xsep (calendar);
int header_height;
if (priv->display_flags & GTK_CALENDAR_SHOW_WEEK_NUMBERS)
{
@@ -1894,6 +1932,11 @@ gtk_calendar_size_allocate (GtkWidget *widget,
- (DAY_XSEP * 6))/7;
priv->week_width = 0;
}
gtk_widget_measure (priv->header_box, GTK_ORIENTATION_VERTICAL, width,
&header_height, NULL, NULL, NULL);
gtk_widget_size_allocate (priv->header_box,
&(GtkAllocation){ 0, 0, width, header_height }, -1);
}
@@ -1901,114 +1944,6 @@ gtk_calendar_size_allocate (GtkWidget *widget,
* Repainting *
****************************************/
static void
calendar_snapshot_header (GtkCalendar *calendar,
GtkSnapshot *snapshot)
{
GtkWidget *widget = GTK_WIDGET (calendar);
GtkCalendarPrivate *priv = gtk_calendar_get_instance_private (calendar);
GtkStyleContext *context;
GtkStateFlags state;
char buffer[255];
gint x, y;
gint header_width;
gint max_month_width;
gint max_year_width;
PangoLayout *layout;
PangoRectangle logical_rect;
gboolean year_left;
time_t tmp_time;
struct tm *tm;
gchar *str;
context = gtk_widget_get_style_context (widget);
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
year_left = priv->year_before;
else
year_left = !priv->year_before;
header_width = gtk_widget_get_width (widget);
max_month_width = priv->max_month_width;
max_year_width = priv->max_year_width;
state = gtk_style_context_get_state (context);
state &= ~GTK_STATE_FLAG_DROP_ACTIVE;
gtk_style_context_save (context);
gtk_style_context_set_state (context, state);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_HEADER);
gtk_snapshot_render_background (snapshot, context, 0, 0, header_width, priv->header_h);
gtk_snapshot_render_frame (snapshot, context, 0, 0, header_width, priv->header_h);
tmp_time = 1; /* Jan 1 1970, 00:00:01 UTC */
tm = gmtime (&tmp_time);
tm->tm_year = priv->year - 1900;
/* Translators: This dictates how the year is displayed in
* gtkcalendar widget. See strftime() manual for the format.
* Use only ASCII in the translation.
*
* Also look for the msgid "2000".
* Translate that entry to a year with the widest output of this
* msgid.
*
* "%Y" is appropriate for most locales.
*/
strftime (buffer, sizeof (buffer), C_("calendar year format", "%Y"), tm);
str = g_locale_to_utf8 (buffer, -1, NULL, NULL, NULL);
layout = gtk_widget_create_pango_layout (widget, str);
g_free (str);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
/* Draw title */
y = (priv->header_h - logical_rect.height) / 2;
/* Draw year and its arrows */
if (priv->display_flags & GTK_CALENDAR_NO_MONTH_CHANGE)
if (year_left)
x = 3 + (max_year_width - logical_rect.width)/2;
else
x = header_width - (3 + max_year_width
- (max_year_width - logical_rect.width)/2);
else
if (year_left)
x = 3 + priv->arrow_width + (max_year_width - logical_rect.width)/2;
else
x = header_width - (3 + priv->arrow_width + max_year_width
- (max_year_width - logical_rect.width)/2);
gtk_snapshot_render_layout (snapshot, context, x, y, layout);
/* Draw month */
g_snprintf (buffer, sizeof (buffer), "%s", default_monthname[priv->month]);
pango_layout_set_text (layout, buffer, -1);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
if (priv->display_flags & GTK_CALENDAR_NO_MONTH_CHANGE)
if (year_left)
x = header_width - (3 + max_month_width
- (max_month_width - logical_rect.width)/2);
else
x = 3 + (max_month_width - logical_rect.width) / 2;
else
if (year_left)
x = header_width - (3 + priv->arrow_width + max_month_width
- (max_month_width - logical_rect.width)/2);
else
x = 3 + priv->arrow_width + (max_month_width - logical_rect.width)/2;
gtk_snapshot_render_layout (snapshot, context, x, y, layout);
g_object_unref (layout);
gtk_style_context_restore (context);
}
static void
calendar_snapshot_day_names (GtkCalendar *calendar,
GtkSnapshot *snapshot)
@@ -2387,61 +2322,16 @@ calendar_snapshot_main (GtkCalendar *calendar,
calendar_snapshot_day (calendar, snapshot, row, col);
}
static void
calendar_snapshot_arrow (GtkCalendar *calendar,
GtkSnapshot *snapshot,
guint arrow)
{
GtkWidget *widget = GTK_WIDGET (calendar);
GtkCalendarPrivate *priv = gtk_calendar_get_instance_private (calendar);
GtkStyleContext *context;
GtkStateFlags state;
GdkRectangle rect;
calendar_arrow_rectangle (calendar, arrow, &rect);
context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
if (priv->arrow_prelight & (1 << arrow))
state |= GTK_STATE_FLAG_PRELIGHT;
else
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_BUTTON);
gtk_snapshot_render_background (snapshot, context,
rect.x, rect.y,
rect.width, rect.height);
gtk_snapshot_save (snapshot);
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT(
rect.x + (rect.width - 8) / 2,
rect.y + (rect.height - 8) / 2));
gtk_css_style_snapshot_icon (gtk_style_context_lookup_style (context), snapshot, 8, 8);
gtk_snapshot_restore (snapshot);
gtk_style_context_restore (context);
}
static void
gtk_calendar_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot)
{
GtkCalendar *calendar = GTK_CALENDAR (widget);
GtkCalendarPrivate *priv = gtk_calendar_get_instance_private (calendar);
int i;
calendar_snapshot_main (calendar, snapshot);
if (priv->display_flags & GTK_CALENDAR_SHOW_HEADING)
{
calendar_snapshot_header (calendar, snapshot);
for (i = 0; i < 4; i++)
calendar_snapshot_arrow (calendar, snapshot, i);
}
gtk_widget_snapshot_child (widget, priv->header_box, snapshot);
if (priv->display_flags & GTK_CALENDAR_SHOW_DAY_NAMES)
calendar_snapshot_day_names (calendar, snapshot);
@@ -2695,7 +2585,7 @@ gtk_calendar_drag_update (GtkGestureDrag *gesture,
GdkDevice *device;
GdkDrag *drag;
GtkIconTheme *theme;
GdkPaintable *paintable;
GtkIcon *icon;
GdkSurface *surface;
if (!priv->in_drag)
@@ -2714,9 +2604,9 @@ gtk_calendar_drag_update (GtkGestureDrag *gesture,
drag = gdk_drag_begin (surface, device, content, GDK_ACTION_COPY, start_x, start_y);
theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (widget));
paintable = gtk_icon_theme_load_icon (theme, "text-x-generic", 32, 0, NULL);
gtk_drag_icon_set_from_paintable (drag, paintable, 0, 0);
g_clear_object (&paintable);
icon = gtk_icon_theme_lookup_icon (theme, "text-x-generic", 32, 1, 0);
gtk_drag_icon_set_from_paintable (drag, GDK_PAINTABLE (icon), 0, 0);
g_clear_object (&icon);
g_object_unref (content);
g_object_unref (drag);
@@ -3149,11 +3039,14 @@ gtk_calendar_set_display_options (GtkCalendar *calendar,
if ((flags ^ priv->display_flags) & GTK_CALENDAR_SHOW_HEADING)
{
resize++;
if (flags & GTK_CALENDAR_SHOW_HEADING)
{
priv->display_flags |= GTK_CALENDAR_SHOW_HEADING;
gtk_widget_show (priv->header_box);
}
else
{
gtk_widget_hide (priv->header_box);
}
}
@@ -3217,12 +3110,12 @@ gtk_calendar_select_month (GtkCalendar *calendar,
if (priv->month != month)
{
priv->month = month;
set_month (calendar, month);
g_object_notify (G_OBJECT (calendar), "month");
}
if (priv->year != year)
{
priv->year = year;
set_year (calendar, year);
g_object_notify (G_OBJECT (calendar), "year");
}
+1 -1
View File
@@ -210,7 +210,7 @@ gtk_cell_renderer_spinner_update_size (GtkCellRendererSpinner *cell,
node = gtk_style_context_get_node (context);
gtk_icon_size_set_style_classes (node, priv->icon_size);
style = gtk_css_node_get_style (node);
priv->size = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_ICON_SIZE), 100);
priv->size = _gtk_css_number_value_get (style->icon->icon_size, 100);
gtk_style_context_restore (context);
}
+3 -2
View File
@@ -19,6 +19,7 @@
#include "gtkcellrenderertext.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkeditable.h"
#include "gtkentry.h"
#include "gtkentryprivate.h"
@@ -27,7 +28,7 @@
#include "gtkprivate.h"
#include "gtksizerequest.h"
#include "gtksnapshot.h"
#include "gtkstylecontext.h"
#include "gtkstylecontextprivate.h"
#include "gtktreeprivate.h"
#include "a11y/gtktextcellaccessible.h"
@@ -1631,7 +1632,7 @@ get_size (GtkCellRenderer *cell,
style_context = gtk_widget_get_style_context (widget);
gtk_style_context_get (style_context, "font", &font_desc, NULL);
font_desc = gtk_css_style_get_pango_font (gtk_style_context_lookup_style (style_context));
pango_font_description_merge_static (font_desc, priv->font, TRUE);
if (priv->scale_set)
+6 -16
View File
@@ -19,6 +19,7 @@
#include "gtkcellrenderertoggle.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkintl.h"
#include "gtkmarshalers.h"
#include "gtkprivate.h"
@@ -86,8 +87,6 @@ enum {
PROP_INCONSISTENT
};
#define TOGGLE_WIDTH 16
static guint toggle_cell_signals[LAST_SIGNAL] = { 0 };
typedef struct _GtkCellRendererTogglePrivate GtkCellRendererTogglePrivate;
@@ -316,20 +315,11 @@ gtk_cell_renderer_toggle_save_context (GtkCellRenderer *cell,
return context;
}
static void
calc_indicator_size (GtkStyleContext *context,
gint *width,
gint *height)
static int
calc_indicator_size (GtkStyleContext *context)
{
gtk_style_context_get (context,
"min-width", width,
"min-height", height,
NULL);
if (*width == 0)
*width = TOGGLE_WIDTH;
if (*height == 0)
*height = TOGGLE_WIDTH;
GtkCssStyle *style = gtk_style_context_lookup_style (context);
return _gtk_css_number_value_get (style->icon->icon_size, 100);
}
static void
@@ -353,7 +343,7 @@ gtk_cell_renderer_toggle_get_size (GtkCellRenderer *cell,
gtk_style_context_get_padding (context, &padding);
gtk_style_context_get_border (context, &border);
calc_indicator_size (context, &calc_width, &calc_height);
calc_width = calc_height = calc_indicator_size (context);
calc_width += xpad * 2 + padding.left + padding.right + border.left + border.right;
calc_height += ypad * 2 + padding.top + padding.bottom + border.top + border.bottom;
+6 -6
View File
@@ -37,7 +37,7 @@
#include "gtkstylecontextprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkradiobutton.h"
#include "gtkiconprivate.h"
#include "gtkbuiltiniconprivate.h"
/**
@@ -356,19 +356,19 @@ draw_indicator_changed (GtkCheckButton *check_button)
if (priv->draw_indicator)
{
priv->indicator_widget = gtk_icon_new ("check");
priv->indicator_widget = gtk_builtin_icon_new ("check");
gtk_widget_set_halign (priv->indicator_widget, GTK_ALIGN_CENTER);
gtk_widget_set_valign (priv->indicator_widget, GTK_ALIGN_CENTER);
gtk_widget_set_parent (priv->indicator_widget, GTK_WIDGET (check_button));
if (GTK_IS_RADIO_BUTTON (check_button))
{
gtk_css_node_remove_class (widget_node, g_quark_from_static_string ("radio"));
gtk_css_node_set_name (widget_node, I_("radiobutton"));
gtk_css_node_set_name (widget_node, g_quark_from_static_string ("radiobutton"));
}
else if (GTK_IS_CHECK_BUTTON (check_button))
{
gtk_css_node_remove_class (widget_node, g_quark_from_static_string ("check"));
gtk_css_node_set_name (widget_node, I_("checkbutton"));
gtk_css_node_set_name (widget_node, g_quark_from_static_string ("checkbutton"));
}
}
else
@@ -378,12 +378,12 @@ draw_indicator_changed (GtkCheckButton *check_button)
if (GTK_IS_RADIO_BUTTON (check_button))
{
gtk_css_node_add_class (widget_node, g_quark_from_static_string ("radio"));
gtk_css_node_set_name (widget_node, I_("button"));
gtk_css_node_set_name (widget_node, g_quark_from_static_string ("button"));
}
else if (GTK_IS_CHECK_BUTTON (check_button))
{
gtk_css_node_add_class (widget_node, g_quark_from_static_string ("check"));
gtk_css_node_set_name (widget_node, I_("button"));
gtk_css_node_set_name (widget_node, g_quark_from_static_string ("button"));
}
}
}
+2 -2
View File
@@ -27,7 +27,7 @@
#include "gtkcellview.h"
#include "gtkeventcontrollerscroll.h"
#include "gtkframe.h"
#include "gtkiconprivate.h"
#include "gtkbuiltiniconprivate.h"
#include "gtkintl.h"
#include "gtkliststore.h"
#include "gtkmain.h"
@@ -844,7 +844,7 @@ gtk_combo_box_init (GtkComboBox *combo_box)
priv->text_renderer = NULL;
priv->id_column = -1;
g_type_ensure (GTK_TYPE_ICON);
g_type_ensure (GTK_TYPE_BUILTIN_ICON);
g_type_ensure (GTK_TYPE_TREE_POPOVER);
gtk_widget_init_template (GTK_WIDGET (combo_box));
+158
View File
@@ -0,0 +1,158 @@
/*
* Copyright © 2020 Benjamin Otte
*
* 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.1 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/>.
*
* Authors: Benjamin Otte <otte@gnome.org>
*/
#ifndef __GTK_COUNTING_BLOOM_FILTER_PRIVATE_H__
#define __GTK_COUNTING_BLOOM_FILTER_PRIVATE_H__
#include <glib.h>
G_BEGIN_DECLS
/*
* SECTION:gtkcountingbloomfilter
* @Short_description: A counting bloom filter
* @Title: GtkCountingBloomFilter
* @See_also: https://en.wikipedia.org/wiki/Bloom_filter,
* https://en.wikipedia.org/wiki/Counting_Bloom_filter
*
* This implements a counting bloom filter. A bloom filter is a space-efficient
* probabilistic data structure that is used to test whether an element may be
* a member of a set.
* The Wikipedia links provide a lot more details into how and why this data
* structure works and when to use it.
*
* This implementation is based on similar implementations in web browsers, because it's
* original use case is the same: Making CSS lookups fast.
*
* As such, the number of bits is hardcoded to 12 and the elements in the set
* are 16bit hash values.
* It is possible to use 32bit hash values or a different number of bits, should this
* be considered useful.
*/
/* The number of bits from the hash we care about */
#define GTK_COUNTING_BLOOM_FILTER_BITS (12)
/* The necessary size of the filter */
#define GTK_COUNTING_BLOOM_FILTER_SIZE (1 << GTK_COUNTING_BLOOM_FILTER_BITS)
typedef struct _GtkCountingBloomFilter GtkCountingBloomFilter;
struct _GtkCountingBloomFilter
{
guint8 buckets[GTK_COUNTING_BLOOM_FILTER_SIZE];
};
static inline void gtk_counting_bloom_filter_add (GtkCountingBloomFilter *self,
guint16 hash);
static inline void gtk_counting_bloom_filter_remove (GtkCountingBloomFilter *self,
guint16 hash);
static inline gboolean gtk_counting_bloom_filter_may_contain (const GtkCountingBloomFilter *self,
guint16 hash);
/*
* GTK_COUNTING_BLOOM_FILTER_INIT:
*
* Initialize the bloom filter. As bloom filters are always stack-allocated,
* initialization should happen when defining them, like:
* ```c
* GtkCountingBloomFilter filter = GTK_COUNTING_BLOOM_FILTER_INIT;
* ```
*
* The filter does not need to be freed.
*/
#define GTK_COUNTING_BLOOM_FILTER_INIT { 0, }
/*
* gtk_counting_bloom_filter_add:
* @self: a #GtkCountingBloomFilter
* @hash: a hash value to add to the filter
*
* Adds the hash value to the filter.
*
* If the same hash value gets added multiple times, it will
* be considered as contained in the hash until it has been
* removed as many times.
**/
static inline void
gtk_counting_bloom_filter_add (GtkCountingBloomFilter *self,
guint16 hash)
{
guint16 bucket = hash % GTK_COUNTING_BLOOM_FILTER_SIZE;
if (self->buckets[bucket] == 255)
return;
self->buckets[bucket]++;
}
/*
* gtk_counting_bloom_filter_remove:
* @self: a #GtkCountingBloomFilter
* @hash: a hash value to remove from the filter
*
* Removes a hash value from the filter that has previously
* been added via gtk_counting_bloom_filter_add().
**/
static inline void
gtk_counting_bloom_filter_remove (GtkCountingBloomFilter *self,
guint16 hash)
{
guint16 bucket = hash % GTK_COUNTING_BLOOM_FILTER_SIZE;
if (self->buckets[bucket] == 255)
return;
g_assert (self->buckets[bucket] > 0);
self->buckets[bucket]--;
}
/*
* gtk_counting_bloom_filter_may_contain:
* @self: a #GtkCountingBloomFilter
* @hash: the hash value to check
*
* Checks if @hash may be contained in @self.
*
* A return value of %FALSE means that @hash is definitely not part
* of @self.
*
* A return value of %TRUE means that @hash may or may not have been
* added to @self. In that case a different method must be used to
* confirm that @hash is indeed part of the set.
*
* Returns: %FALSE if @hash is not part of @self.
**/
static inline gboolean
gtk_counting_bloom_filter_may_contain (const GtkCountingBloomFilter *self,
guint16 hash)
{
guint16 bucket = hash % GTK_COUNTING_BLOOM_FILTER_SIZE;
return self->buckets[bucket] != 0;
}
G_END_DECLS
#endif /* __GTK_COUNTING_BLOOM_FILTER_PRIVATE_H_ */
+461 -46
View File
@@ -40,20 +40,6 @@
G_DEFINE_TYPE (GtkCssAnimatedStyle, gtk_css_animated_style, GTK_TYPE_CSS_STYLE)
static GtkCssValue *
gtk_css_animated_style_get_value (GtkCssStyle *style,
guint id)
{
/* This is called a lot, so we avoid a dynamic type check here */
GtkCssAnimatedStyle *animated = (GtkCssAnimatedStyle *) style;
if (animated->animated_values &&
id < animated->animated_values->len &&
g_ptr_array_index (animated->animated_values, id))
return g_ptr_array_index (animated->animated_values, id);
return gtk_css_animated_style_get_intrinsic_value (animated, id);
}
static GtkCssSection *
gtk_css_animated_style_get_section (GtkCssStyle *style,
@@ -94,12 +80,6 @@ gtk_css_animated_style_dispose (GObject *object)
GtkCssAnimatedStyle *style = GTK_CSS_ANIMATED_STYLE (object);
guint i;
if (style->animated_values)
{
g_ptr_array_unref (style->animated_values);
style->animated_values = NULL;
}
for (i = 0; i < style->n_animations; i ++)
g_object_unref (style->animations[i]);
@@ -129,7 +109,6 @@ gtk_css_animated_style_class_init (GtkCssAnimatedStyleClass *klass)
object_class->dispose = gtk_css_animated_style_dispose;
object_class->finalize = gtk_css_animated_style_finalize;
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;
style_class->get_static_style = gtk_css_animated_style_get_static_style;
@@ -140,24 +119,432 @@ gtk_css_animated_style_init (GtkCssAnimatedStyle *style)
{
}
#define DEFINE_UNSHARE(TYPE, NAME) \
static inline void \
unshare_ ## NAME (GtkCssAnimatedStyle *animated) \
{ \
GtkCssStyle *style = (GtkCssStyle *)animated; \
if (style->NAME == animated->style->NAME) \
{ \
gtk_css_values_unref ((GtkCssValues *)style->NAME); \
style->NAME = (TYPE *)gtk_css_values_copy ((GtkCssValues *)animated->style->NAME); \
} \
}
DEFINE_UNSHARE (GtkCssCoreValues, core)
DEFINE_UNSHARE (GtkCssBackgroundValues, background)
DEFINE_UNSHARE (GtkCssBorderValues, border)
DEFINE_UNSHARE (GtkCssIconValues, icon)
DEFINE_UNSHARE (GtkCssOutlineValues, outline)
DEFINE_UNSHARE (GtkCssFontValues, font)
DEFINE_UNSHARE (GtkCssFontVariantValues, font_variant)
DEFINE_UNSHARE (GtkCssAnimationValues, animation)
DEFINE_UNSHARE (GtkCssTransitionValues, transition)
DEFINE_UNSHARE (GtkCssSizeValues, size)
DEFINE_UNSHARE (GtkCssOtherValues, other)
static inline void
gtk_css_take_value (GtkCssValue **variable,
GtkCssValue *value)
{
if (*variable)
gtk_css_value_unref (*variable);
*variable = value;
}
void
gtk_css_animated_style_set_animated_value (GtkCssAnimatedStyle *style,
gtk_css_animated_style_set_animated_value (GtkCssAnimatedStyle *animated,
guint id,
GtkCssValue *value)
{
GtkCssStyle *style = (GtkCssStyle *)animated;
gtk_internal_return_if_fail (GTK_IS_CSS_ANIMATED_STYLE (style));
gtk_internal_return_if_fail (value != NULL);
if (style->animated_values == NULL)
style->animated_values = g_ptr_array_new_with_free_func ((GDestroyNotify)_gtk_css_value_unref);
if (id >= style->animated_values->len)
g_ptr_array_set_size (style->animated_values, id + 1);
if (g_ptr_array_index (style->animated_values, id))
_gtk_css_value_unref (g_ptr_array_index (style->animated_values, id));
g_ptr_array_index (style->animated_values, id) = value;
switch (id)
{
case GTK_CSS_PROPERTY_COLOR:
unshare_core (animated);
gtk_css_take_value (&style->core->color, value);
break;
case GTK_CSS_PROPERTY_DPI:
unshare_core (animated);
gtk_css_take_value (&style->core->dpi, value);
break;
case GTK_CSS_PROPERTY_FONT_SIZE:
unshare_core (animated);
gtk_css_take_value (&style->core->font_size, value);
break;
case GTK_CSS_PROPERTY_ICON_THEME:
unshare_core (animated);
gtk_css_take_value (&style->core->icon_theme, value);
break;
case GTK_CSS_PROPERTY_ICON_PALETTE:
unshare_core (animated);
gtk_css_take_value (&style->core->icon_palette, value);
break;
case GTK_CSS_PROPERTY_BACKGROUND_COLOR:
unshare_background (animated);
gtk_css_take_value (&style->background->background_color, value);
break;
case GTK_CSS_PROPERTY_FONT_FAMILY:
unshare_font (animated);
gtk_css_take_value (&style->font->font_family, value);
break;
case GTK_CSS_PROPERTY_FONT_STYLE:
unshare_font (animated);
gtk_css_take_value (&style->font->font_style, value);
break;
case GTK_CSS_PROPERTY_FONT_WEIGHT:
unshare_font (animated);
gtk_css_take_value (&style->font->font_weight, value);
break;
case GTK_CSS_PROPERTY_FONT_STRETCH:
unshare_font (animated);
gtk_css_take_value (&style->font->font_stretch, value);
break;
case GTK_CSS_PROPERTY_LETTER_SPACING:
unshare_font (animated);
gtk_css_take_value (&style->font->letter_spacing, value);
break;
case GTK_CSS_PROPERTY_TEXT_DECORATION_LINE:
unshare_font_variant (animated);
gtk_css_take_value (&style->font_variant->text_decoration_line, value);
break;
case GTK_CSS_PROPERTY_TEXT_DECORATION_COLOR:
unshare_font_variant (animated);
gtk_css_take_value (&style->font_variant->text_decoration_color, value);
break;
case GTK_CSS_PROPERTY_TEXT_DECORATION_STYLE:
unshare_font_variant (animated);
gtk_css_take_value (&style->font_variant->text_decoration_style, value);
break;
case GTK_CSS_PROPERTY_FONT_KERNING:
unshare_font_variant (animated);
gtk_css_take_value (&style->font_variant->font_kerning, value);
break;
case GTK_CSS_PROPERTY_FONT_VARIANT_LIGATURES:
unshare_font_variant (animated);
gtk_css_take_value (&style->font_variant->font_variant_ligatures, value);
break;
case GTK_CSS_PROPERTY_FONT_VARIANT_POSITION:
unshare_font_variant (animated);
gtk_css_take_value (&style->font_variant->font_variant_position, value);
break;
case GTK_CSS_PROPERTY_FONT_VARIANT_CAPS:
unshare_font_variant (animated);
gtk_css_take_value (&style->font_variant->font_variant_caps, value);
break;
case GTK_CSS_PROPERTY_FONT_VARIANT_NUMERIC:
unshare_font_variant (animated);
gtk_css_take_value (&style->font_variant->font_variant_numeric, value);
break;
case GTK_CSS_PROPERTY_FONT_VARIANT_ALTERNATES:
unshare_font_variant (animated);
gtk_css_take_value (&style->font_variant->font_variant_alternates, value);
break;
case GTK_CSS_PROPERTY_FONT_VARIANT_EAST_ASIAN:
unshare_font_variant (animated);
gtk_css_take_value (&style->font_variant->font_variant_east_asian, value);
break;
case GTK_CSS_PROPERTY_TEXT_SHADOW:
unshare_font (animated);
gtk_css_take_value (&style->font->text_shadow, value);
break;
case GTK_CSS_PROPERTY_BOX_SHADOW:
unshare_background (animated);
gtk_css_take_value (&style->background->box_shadow, value);
break;
case GTK_CSS_PROPERTY_MARGIN_TOP:
unshare_size (animated);
gtk_css_take_value (&style->size->margin_top, value);
break;
case GTK_CSS_PROPERTY_MARGIN_LEFT:
unshare_size (animated);
gtk_css_take_value (&style->size->margin_left, value);
break;
case GTK_CSS_PROPERTY_MARGIN_BOTTOM:
unshare_size (animated);
gtk_css_take_value (&style->size->margin_bottom, value);
break;
case GTK_CSS_PROPERTY_MARGIN_RIGHT:
unshare_size (animated);
gtk_css_take_value (&style->size->margin_right, value);
break;
case GTK_CSS_PROPERTY_PADDING_TOP:
unshare_size (animated);
gtk_css_take_value (&style->size->padding_top, value);
break;
case GTK_CSS_PROPERTY_PADDING_LEFT:
unshare_size (animated);
gtk_css_take_value (&style->size->padding_left, value);
break;
case GTK_CSS_PROPERTY_PADDING_BOTTOM:
unshare_size (animated);
gtk_css_take_value (&style->size->padding_bottom, value);
break;
case GTK_CSS_PROPERTY_PADDING_RIGHT:
unshare_size (animated);
gtk_css_take_value (&style->size->padding_right, value);
break;
case GTK_CSS_PROPERTY_BORDER_TOP_STYLE:
unshare_border (animated);
gtk_css_take_value (&style->border->border_top_style, value);
break;
case GTK_CSS_PROPERTY_BORDER_TOP_WIDTH:
unshare_border (animated);
gtk_css_take_value (&style->border->border_top_width, value);
break;
case GTK_CSS_PROPERTY_BORDER_LEFT_STYLE:
unshare_border (animated);
gtk_css_take_value (&style->border->border_left_style, value);
break;
case GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH:
unshare_border (animated);
gtk_css_take_value (&style->border->border_left_width, value);
break;
case GTK_CSS_PROPERTY_BORDER_BOTTOM_STYLE:
unshare_border (animated);
gtk_css_take_value (&style->border->border_bottom_style, value);
break;
case GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH:
unshare_border (animated);
gtk_css_take_value (&style->border->border_bottom_width, value);
break;
case GTK_CSS_PROPERTY_BORDER_RIGHT_STYLE:
unshare_border (animated);
gtk_css_take_value (&style->border->border_right_style, value);
break;
case GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH:
unshare_border (animated);
gtk_css_take_value (&style->border->border_right_width, value);
break;
case GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS:
unshare_border (animated);
gtk_css_take_value (&style->border->border_top_left_radius, value);
break;
case GTK_CSS_PROPERTY_BORDER_TOP_RIGHT_RADIUS:
unshare_border (animated);
gtk_css_take_value (&style->border->border_top_right_radius, value);
break;
case GTK_CSS_PROPERTY_BORDER_BOTTOM_RIGHT_RADIUS:
unshare_border (animated);
gtk_css_take_value (&style->border->border_bottom_right_radius, value);
break;
case GTK_CSS_PROPERTY_BORDER_BOTTOM_LEFT_RADIUS:
unshare_border (animated);
gtk_css_take_value (&style->border->border_bottom_left_radius, value);
break;
case GTK_CSS_PROPERTY_OUTLINE_STYLE:
unshare_outline (animated);
gtk_css_take_value (&style->outline->outline_style, value);
break;
case GTK_CSS_PROPERTY_OUTLINE_WIDTH:
unshare_outline (animated);
gtk_css_take_value (&style->outline->outline_width, value);
break;
case GTK_CSS_PROPERTY_OUTLINE_OFFSET:
unshare_outline (animated);
gtk_css_take_value (&style->outline->outline_offset, value);
break;
case GTK_CSS_PROPERTY_OUTLINE_TOP_LEFT_RADIUS:
unshare_outline (animated);
gtk_css_take_value (&style->outline->outline_top_left_radius, value);
break;
case GTK_CSS_PROPERTY_OUTLINE_TOP_RIGHT_RADIUS:
unshare_outline (animated);
gtk_css_take_value (&style->outline->outline_top_right_radius, value);
break;
case GTK_CSS_PROPERTY_OUTLINE_BOTTOM_RIGHT_RADIUS:
unshare_outline (animated);
gtk_css_take_value (&style->outline->outline_bottom_right_radius, value);
break;
case GTK_CSS_PROPERTY_OUTLINE_BOTTOM_LEFT_RADIUS:
unshare_outline (animated);
gtk_css_take_value (&style->outline->outline_bottom_left_radius, value);
break;
case GTK_CSS_PROPERTY_BACKGROUND_CLIP:
unshare_background (animated);
gtk_css_take_value (&style->background->background_clip, value);
break;
case GTK_CSS_PROPERTY_BACKGROUND_ORIGIN:
unshare_background (animated);
gtk_css_take_value (&style->background->background_origin, value);
break;
case GTK_CSS_PROPERTY_BACKGROUND_SIZE:
unshare_background (animated);
gtk_css_take_value (&style->background->background_size, value);
break;
case GTK_CSS_PROPERTY_BACKGROUND_POSITION:
unshare_background (animated);
gtk_css_take_value (&style->background->background_position, value);
break;
case GTK_CSS_PROPERTY_BORDER_TOP_COLOR:
unshare_border (animated);
gtk_css_take_value (&style->border->border_top_color, value);
break;
case GTK_CSS_PROPERTY_BORDER_RIGHT_COLOR:
unshare_border (animated);
gtk_css_take_value (&style->border->border_right_color, value);
break;
case GTK_CSS_PROPERTY_BORDER_BOTTOM_COLOR:
unshare_border (animated);
gtk_css_take_value (&style->border->border_bottom_color, value);
break;
case GTK_CSS_PROPERTY_BORDER_LEFT_COLOR:
unshare_border (animated);
gtk_css_take_value (&style->border->border_left_color, value);
break;
case GTK_CSS_PROPERTY_OUTLINE_COLOR:
unshare_outline (animated);
gtk_css_take_value (&style->outline->outline_color, value);
break;
case GTK_CSS_PROPERTY_BACKGROUND_REPEAT:
unshare_background (animated);
gtk_css_take_value (&style->background->background_repeat, value);
break;
case GTK_CSS_PROPERTY_BACKGROUND_IMAGE:
unshare_background (animated);
gtk_css_take_value (&style->background->background_image, value);
break;
case GTK_CSS_PROPERTY_BACKGROUND_BLEND_MODE:
unshare_background (animated);
gtk_css_take_value (&style->background->background_blend_mode, value);
break;
case GTK_CSS_PROPERTY_BORDER_IMAGE_SOURCE:
unshare_border (animated);
gtk_css_take_value (&style->border->border_image_source, value);
break;
case GTK_CSS_PROPERTY_BORDER_IMAGE_REPEAT:
unshare_border (animated);
gtk_css_take_value (&style->border->border_image_repeat, value);
break;
case GTK_CSS_PROPERTY_BORDER_IMAGE_SLICE:
unshare_border (animated);
gtk_css_take_value (&style->border->border_image_slice, value);
break;
case GTK_CSS_PROPERTY_BORDER_IMAGE_WIDTH:
unshare_border (animated);
gtk_css_take_value (&style->border->border_image_width, value);
break;
case GTK_CSS_PROPERTY_ICON_SOURCE:
unshare_other (animated);
gtk_css_take_value (&style->other->icon_source, value);
break;
case GTK_CSS_PROPERTY_ICON_SIZE:
unshare_icon (animated);
gtk_css_take_value (&style->icon->icon_size, value);
break;
case GTK_CSS_PROPERTY_ICON_SHADOW:
unshare_icon (animated);
gtk_css_take_value (&style->icon->icon_shadow, value);
break;
case GTK_CSS_PROPERTY_ICON_STYLE:
unshare_icon (animated);
gtk_css_take_value (&style->icon->icon_style, value);
break;
case GTK_CSS_PROPERTY_ICON_TRANSFORM:
unshare_other (animated);
gtk_css_take_value (&style->other->icon_transform, value);
break;
case GTK_CSS_PROPERTY_ICON_FILTER:
unshare_other (animated);
gtk_css_take_value (&style->other->icon_filter, value);
break;
case GTK_CSS_PROPERTY_BORDER_SPACING:
unshare_size (animated);
gtk_css_take_value (&style->size->border_spacing, value);
break;
case GTK_CSS_PROPERTY_TRANSFORM:
unshare_other (animated);
gtk_css_take_value (&style->other->transform, value);
break;
case GTK_CSS_PROPERTY_MIN_WIDTH:
unshare_size (animated);
gtk_css_take_value (&style->size->min_width, value);
break;
case GTK_CSS_PROPERTY_MIN_HEIGHT:
unshare_size (animated);
gtk_css_take_value (&style->size->min_height, value);
break;
case GTK_CSS_PROPERTY_TRANSITION_PROPERTY:
unshare_transition (animated);
gtk_css_take_value (&style->transition->transition_property, value);
break;
case GTK_CSS_PROPERTY_TRANSITION_DURATION:
unshare_transition (animated);
gtk_css_take_value (&style->transition->transition_duration, value);
break;
case GTK_CSS_PROPERTY_TRANSITION_TIMING_FUNCTION:
unshare_transition (animated);
gtk_css_take_value (&style->transition->transition_timing_function, value);
break;
case GTK_CSS_PROPERTY_TRANSITION_DELAY:
unshare_transition (animated);
gtk_css_take_value (&style->transition->transition_delay, value);
break;
case GTK_CSS_PROPERTY_ANIMATION_NAME:
unshare_animation (animated);
gtk_css_take_value (&style->animation->animation_name, value);
break;
case GTK_CSS_PROPERTY_ANIMATION_DURATION:
unshare_animation (animated);
gtk_css_take_value (&style->animation->animation_duration, value);
break;
case GTK_CSS_PROPERTY_ANIMATION_TIMING_FUNCTION:
unshare_animation (animated);
gtk_css_take_value (&style->animation->animation_timing_function, value);
break;
case GTK_CSS_PROPERTY_ANIMATION_ITERATION_COUNT:
unshare_animation (animated);
gtk_css_take_value (&style->animation->animation_iteration_count, value);
break;
case GTK_CSS_PROPERTY_ANIMATION_DIRECTION:
unshare_animation (animated);
gtk_css_take_value (&style->animation->animation_direction, value);
break;
case GTK_CSS_PROPERTY_ANIMATION_PLAY_STATE:
unshare_animation (animated);
gtk_css_take_value (&style->animation->animation_play_state, value);
break;
case GTK_CSS_PROPERTY_ANIMATION_DELAY:
unshare_animation (animated);
gtk_css_take_value (&style->animation->animation_delay, value);
break;
case GTK_CSS_PROPERTY_ANIMATION_FILL_MODE:
unshare_animation (animated);
gtk_css_take_value (&style->animation->animation_fill_mode, value);
break;
case GTK_CSS_PROPERTY_OPACITY:
unshare_other (animated);
gtk_css_take_value (&style->other->opacity, value);
break;
case GTK_CSS_PROPERTY_FILTER:
unshare_other (animated);
gtk_css_take_value (&style->other->filter, value);
break;
case GTK_CSS_PROPERTY_CARET_COLOR:
unshare_font (animated);
gtk_css_take_value (&style->font->caret_color, value);
break;
case GTK_CSS_PROPERTY_SECONDARY_CARET_COLOR:
unshare_font (animated);
gtk_css_take_value (&style->font->secondary_caret_color, value);
break;
case GTK_CSS_PROPERTY_FONT_FEATURE_SETTINGS:
unshare_font (animated);
gtk_css_take_value (&style->font->font_feature_settings, value);
break;
case GTK_CSS_PROPERTY_FONT_VARIATION_SETTINGS:
unshare_font (animated);
gtk_css_take_value (&style->font->font_variation_settings, value);
break;
default:
g_assert_not_reached ();
break;
}
}
GtkCssValue *
@@ -300,9 +687,9 @@ gtk_css_animated_style_create_css_transitions (GPtrArray *animations,
gboolean source_is_animated;
guint i;
durations = gtk_css_style_get_value (base_style, GTK_CSS_PROPERTY_TRANSITION_DURATION);
delays = gtk_css_style_get_value (base_style, GTK_CSS_PROPERTY_TRANSITION_DELAY);
timing_functions = gtk_css_style_get_value (base_style, GTK_CSS_PROPERTY_TRANSITION_TIMING_FUNCTION);
durations = base_style->transition->transition_duration;
delays = base_style->transition->transition_delay;
timing_functions = base_style->transition->transition_timing_function;
if (_gtk_css_array_value_get_n_values (durations) == 1 &&
_gtk_css_array_value_get_n_values (delays) == 1 &&
@@ -310,7 +697,7 @@ gtk_css_animated_style_create_css_transitions (GPtrArray *animations,
_gtk_css_number_value_get (_gtk_css_array_value_get_nth (delays, 0), 100) == 0)
return animations;
transition_infos_set (transitions, gtk_css_style_get_value (base_style, GTK_CSS_PROPERTY_TRANSITION_PROPERTY));
transition_infos_set (transitions, base_style->transition->transition_property);
source_is_animated = GTK_IS_CSS_ANIMATED_STYLE (source);
for (i = 0; i < GTK_CSS_PROPERTY_N_PROPERTIES; i++)
@@ -400,14 +787,14 @@ gtk_css_animated_style_create_css_animations (GPtrArray *animations,
GtkCssValue *iteration_counts, *directions, *play_states, *fill_modes;
guint i;
animation_names = gtk_css_style_get_value (base_style, GTK_CSS_PROPERTY_ANIMATION_NAME);
durations = gtk_css_style_get_value (base_style, GTK_CSS_PROPERTY_ANIMATION_DURATION);
delays = gtk_css_style_get_value (base_style, GTK_CSS_PROPERTY_ANIMATION_DELAY);
timing_functions = gtk_css_style_get_value (base_style, GTK_CSS_PROPERTY_ANIMATION_TIMING_FUNCTION);
iteration_counts = gtk_css_style_get_value (base_style, GTK_CSS_PROPERTY_ANIMATION_ITERATION_COUNT);
directions = gtk_css_style_get_value (base_style, GTK_CSS_PROPERTY_ANIMATION_DIRECTION);
play_states = gtk_css_style_get_value (base_style, GTK_CSS_PROPERTY_ANIMATION_PLAY_STATE);
fill_modes = gtk_css_style_get_value (base_style, GTK_CSS_PROPERTY_ANIMATION_FILL_MODE);
animation_names = base_style->animation->animation_name;
durations = base_style->animation->animation_duration;
delays = base_style->animation->animation_delay;
timing_functions = base_style->animation->animation_timing_function;
iteration_counts = base_style->animation->animation_iteration_count;
directions = base_style->animation->animation_direction;
play_states = base_style->animation->animation_play_state;
fill_modes = base_style->animation->animation_fill_mode;
for (i = 0; i < _gtk_css_array_value_get_n_values (animation_names); i++)
{
@@ -489,6 +876,7 @@ gtk_css_animated_style_new (GtkCssStyle *base_style,
GtkCssStyle *previous_style)
{
GtkCssAnimatedStyle *result;
GtkCssStyle *style;
GPtrArray *animations = NULL;
gtk_internal_return_val_if_fail (GTK_IS_CSS_STYLE (base_style), NULL);
@@ -515,6 +903,19 @@ gtk_css_animated_style_new (GtkCssStyle *base_style,
result->n_animations = animations->len;
result->animations = g_ptr_array_free (animations, FALSE);
style = (GtkCssStyle *)result;
style->core = (GtkCssCoreValues *)gtk_css_values_ref ((GtkCssValues *)base_style->core);
style->background = (GtkCssBackgroundValues *)gtk_css_values_ref ((GtkCssValues *)base_style->background);
style->border = (GtkCssBorderValues *)gtk_css_values_ref ((GtkCssValues *)base_style->border);
style->icon = (GtkCssIconValues *)gtk_css_values_ref ((GtkCssValues *)base_style->icon);
style->outline = (GtkCssOutlineValues *)gtk_css_values_ref ((GtkCssValues *)base_style->outline);
style->font = (GtkCssFontValues *)gtk_css_values_ref ((GtkCssValues *)base_style->font);
style->font_variant = (GtkCssFontVariantValues *)gtk_css_values_ref ((GtkCssValues *)base_style->font_variant);
style->animation = (GtkCssAnimationValues *)gtk_css_values_ref ((GtkCssValues *)base_style->animation);
style->transition = (GtkCssTransitionValues *)gtk_css_values_ref ((GtkCssValues *)base_style->transition);
style->size = (GtkCssSizeValues *)gtk_css_values_ref ((GtkCssValues *)base_style->size);
style->other = (GtkCssOtherValues *)gtk_css_values_ref ((GtkCssValues *)base_style->other);
gtk_css_animated_style_apply_animations (result);
return GTK_CSS_STYLE (result);
@@ -522,15 +923,16 @@ gtk_css_animated_style_new (GtkCssStyle *base_style,
GtkCssStyle *
gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
GtkCssStyle *base,
GtkCssStyle *base_style,
gint64 timestamp)
{
GtkCssAnimatedStyle *result;
GtkCssStyle *style;
GPtrArray *animations;
guint i;
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);
gtk_internal_return_val_if_fail (GTK_IS_CSS_STYLE (base_style), NULL);
if (timestamp == 0 || timestamp == source->current_time)
return g_object_ref (source->style);
@@ -557,11 +959,24 @@ gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
result = g_object_new (GTK_TYPE_CSS_ANIMATED_STYLE, NULL);
result->style = g_object_ref (base);
result->style = g_object_ref (base_style);
result->current_time = timestamp;
result->n_animations = animations->len;
result->animations = g_ptr_array_free (animations, FALSE);
style = (GtkCssStyle *)result;
style->core = (GtkCssCoreValues *)gtk_css_values_ref ((GtkCssValues *)base_style->core);
style->background = (GtkCssBackgroundValues *)gtk_css_values_ref ((GtkCssValues *)base_style->background);
style->border = (GtkCssBorderValues *)gtk_css_values_ref ((GtkCssValues *)base_style->border);
style->icon = (GtkCssIconValues *)gtk_css_values_ref ((GtkCssValues *)base_style->icon);
style->outline = (GtkCssOutlineValues *)gtk_css_values_ref ((GtkCssValues *)base_style->outline);
style->font = (GtkCssFontValues *)gtk_css_values_ref ((GtkCssValues *)base_style->font);
style->font_variant = (GtkCssFontVariantValues *)gtk_css_values_ref ((GtkCssValues *)base_style->font_variant);
style->animation = (GtkCssAnimationValues *)gtk_css_values_ref ((GtkCssValues *)base_style->animation);
style->transition = (GtkCssTransitionValues *)gtk_css_values_ref ((GtkCssValues *)base_style->transition);
style->size = (GtkCssSizeValues *)gtk_css_values_ref ((GtkCssValues *)base_style->size);
style->other = (GtkCssOtherValues *)gtk_css_values_ref ((GtkCssValues *)base_style->other);
gtk_css_animated_style_apply_animations (result);
return GTK_CSS_STYLE (result);
-1
View File
@@ -40,7 +40,6 @@ struct _GtkCssAnimatedStyle
GtkCssStyle *style; /* the style if we weren't animating */
GPtrArray *animated_values; /* NULL or array of animated values/NULL if not animated */
gint64 current_time; /* the current time in our world */
gpointer *animations; /* GtkStyleAnimation**, least important one first */
guint n_animations;
+42 -54
View File
@@ -74,17 +74,11 @@ gtk_css_boxes_init_border_box (GtkCssBoxes *boxes,
static inline void
gtk_css_boxes_rect_grow (GskRoundedRect *dest,
GskRoundedRect *src,
GtkCssStyle *style,
int top_property,
int right_property,
int bottom_property,
int left_property)
GtkCssValue *top,
GtkCssValue *right,
GtkCssValue *bottom,
GtkCssValue *left)
{
GtkCssValue *top = gtk_css_style_get_value (style, top_property);
GtkCssValue *right = gtk_css_style_get_value (style, right_property);
GtkCssValue *bottom = gtk_css_style_get_value (style, bottom_property);
GtkCssValue *left = gtk_css_style_get_value (style, left_property);
if (gtk_css_dimension_value_is_zero (left))
{
dest->bounds.origin.x = src->bounds.origin.x;
@@ -129,16 +123,15 @@ gtk_css_boxes_rect_grow (GskRoundedRect *dest,
static inline void
gtk_css_boxes_rect_shrink (GskRoundedRect *dest,
GskRoundedRect *src,
GtkCssStyle *style,
int top_property,
int right_property,
int bottom_property,
int left_property)
GtkCssValue *top_value,
GtkCssValue *right_value,
GtkCssValue *bottom_value,
GtkCssValue *left_value)
{
double top = _gtk_css_number_value_get (gtk_css_style_get_value (style, top_property), 100);
double right = _gtk_css_number_value_get (gtk_css_style_get_value (style, right_property), 100);
double bottom = _gtk_css_number_value_get (gtk_css_style_get_value (style, bottom_property), 100);
double left = _gtk_css_number_value_get (gtk_css_style_get_value (style, left_property), 100);
double top = _gtk_css_number_value_get (top_value, 100);
double right = _gtk_css_number_value_get (right_value, 100);
double bottom = _gtk_css_number_value_get (bottom_value, 100);
double left = _gtk_css_number_value_get (left_value, 100);
/* FIXME: Do we need underflow checks here? */
dest->bounds.origin.x = src->bounds.origin.x + left;
@@ -177,11 +170,10 @@ gtk_css_boxes_compute_border_rect (GtkCssBoxes *boxes)
gtk_css_boxes_rect_grow (&boxes->box[GTK_CSS_AREA_BORDER_BOX],
&boxes->box[GTK_CSS_AREA_PADDING_BOX],
boxes->style,
GTK_CSS_PROPERTY_BORDER_TOP_WIDTH,
GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH,
GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH,
GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH);
boxes->style->border->border_top_width,
boxes->style->border->border_right_width,
boxes->style->border->border_bottom_width,
boxes->style->border->border_left_width);
boxes->has_rect[GTK_CSS_AREA_BORDER_BOX] = TRUE;
}
@@ -196,21 +188,19 @@ gtk_css_boxes_compute_padding_rect (GtkCssBoxes *boxes)
{
gtk_css_boxes_rect_shrink (&boxes->box[GTK_CSS_AREA_PADDING_BOX],
&boxes->box[GTK_CSS_AREA_BORDER_BOX],
boxes->style,
GTK_CSS_PROPERTY_BORDER_TOP_WIDTH,
GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH,
GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH,
GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH);
boxes->style->border->border_top_width,
boxes->style->border->border_right_width,
boxes->style->border->border_bottom_width,
boxes->style->border->border_left_width);
}
else
{
gtk_css_boxes_rect_grow (&boxes->box[GTK_CSS_AREA_PADDING_BOX],
&boxes->box[GTK_CSS_AREA_CONTENT_BOX],
boxes->style,
GTK_CSS_PROPERTY_PADDING_TOP,
GTK_CSS_PROPERTY_PADDING_RIGHT,
GTK_CSS_PROPERTY_PADDING_BOTTOM,
GTK_CSS_PROPERTY_PADDING_LEFT);
boxes->style->size->padding_top,
boxes->style->size->padding_right,
boxes->style->size->padding_bottom,
boxes->style->size->padding_left);
}
boxes->has_rect[GTK_CSS_AREA_PADDING_BOX] = TRUE;
@@ -226,11 +216,10 @@ gtk_css_boxes_compute_content_rect (GtkCssBoxes *boxes)
gtk_css_boxes_rect_shrink (&boxes->box[GTK_CSS_AREA_CONTENT_BOX],
&boxes->box[GTK_CSS_AREA_PADDING_BOX],
boxes->style,
GTK_CSS_PROPERTY_PADDING_TOP,
GTK_CSS_PROPERTY_PADDING_RIGHT,
GTK_CSS_PROPERTY_PADDING_BOTTOM,
GTK_CSS_PROPERTY_PADDING_LEFT);
boxes->style->size->padding_top,
boxes->style->size->padding_right,
boxes->style->size->padding_bottom,
boxes->style->size->padding_left);
boxes->has_rect[GTK_CSS_AREA_CONTENT_BOX] = TRUE;
}
@@ -245,11 +234,10 @@ gtk_css_boxes_compute_margin_rect (GtkCssBoxes *boxes)
gtk_css_boxes_rect_grow (&boxes->box[GTK_CSS_AREA_MARGIN_BOX],
&boxes->box[GTK_CSS_AREA_BORDER_BOX],
boxes->style,
GTK_CSS_PROPERTY_MARGIN_TOP,
GTK_CSS_PROPERTY_MARGIN_RIGHT,
GTK_CSS_PROPERTY_MARGIN_BOTTOM,
GTK_CSS_PROPERTY_MARGIN_LEFT);
boxes->style->size->margin_top,
boxes->style->size->margin_right,
boxes->style->size->margin_bottom,
boxes->style->size->margin_left);
boxes->has_rect[GTK_CSS_AREA_MARGIN_BOX] = TRUE;
}
@@ -268,8 +256,8 @@ gtk_css_boxes_compute_outline_rect (GtkCssBoxes *boxes)
dest = &boxes->box[GTK_CSS_AREA_OUTLINE_BOX].bounds;
src = &boxes->box[GTK_CSS_AREA_BORDER_BOX].bounds;
d = _gtk_css_number_value_get (gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_OUTLINE_OFFSET), 100) +
_gtk_css_number_value_get (gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_OUTLINE_WIDTH), 100);
d = _gtk_css_number_value_get (boxes->style->outline->outline_offset, 100) +
_gtk_css_number_value_get (boxes->style->outline->outline_width, 100);
dest->origin.x = src->origin.x - d;
dest->origin.y = src->origin.y - d;
@@ -442,10 +430,10 @@ gtk_css_boxes_compute_border_box (GtkCssBoxes *boxes)
gtk_css_boxes_compute_border_rect (boxes);
gtk_css_boxes_apply_border_radius (&boxes->box[GTK_CSS_AREA_BORDER_BOX],
gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS),
gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BORDER_TOP_RIGHT_RADIUS),
gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BORDER_BOTTOM_RIGHT_RADIUS),
gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BORDER_BOTTOM_LEFT_RADIUS));
boxes->style->border->border_top_left_radius,
boxes->style->border->border_top_right_radius,
boxes->style->border->border_bottom_right_radius,
boxes->style->border->border_bottom_left_radius);
boxes->has_box[GTK_CSS_AREA_BORDER_BOX] = TRUE;
}
@@ -489,10 +477,10 @@ gtk_css_boxes_compute_outline_box (GtkCssBoxes *boxes)
gtk_css_boxes_compute_outline_rect (boxes);
gtk_css_boxes_apply_border_radius (&boxes->box[GTK_CSS_AREA_OUTLINE_BOX],
gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_OUTLINE_TOP_LEFT_RADIUS),
gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_OUTLINE_TOP_RIGHT_RADIUS),
gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_OUTLINE_BOTTOM_RIGHT_RADIUS),
gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_OUTLINE_BOTTOM_LEFT_RADIUS));
boxes->style->outline->outline_top_left_radius,
boxes->style->outline->outline_top_right_radius,
boxes->style->outline->outline_bottom_right_radius,
boxes->style->outline->outline_bottom_left_radius);
boxes->has_box[GTK_CSS_AREA_OUTLINE_BOX] = TRUE;
}
+3 -3
View File
@@ -120,7 +120,7 @@ gtk_css_value_color_get_fallback (guint property_id,
style,
parent_style);
case GTK_CSS_PROPERTY_ICON_PALETTE:
return _gtk_css_value_ref (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_COLOR));
return _gtk_css_value_ref (style->core->color);
default:
if (property_id < GTK_CSS_PROPERTY_N_PROPERTIES)
g_warning ("No fallback color defined for property '%s'",
@@ -147,7 +147,7 @@ gtk_css_value_color_compute (GtkCssValue *value,
GtkCssValue *current;
if (parent_style)
current = gtk_css_style_get_value (parent_style, GTK_CSS_PROPERTY_COLOR);
current = parent_style->core->color;
else
current = NULL;
@@ -162,7 +162,7 @@ gtk_css_value_color_compute (GtkCssValue *value,
}
else
{
GtkCssValue *current = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_COLOR);
GtkCssValue *current = style->core->color;
resolved = _gtk_css_color_value_resolve (value,
provider,
+3 -3
View File
@@ -45,18 +45,18 @@ get_base_font_size_px (guint property_id,
if (property_id == GTK_CSS_PROPERTY_FONT_SIZE)
{
if (parent_style)
return _gtk_css_number_value_get (gtk_css_style_get_value (parent_style, GTK_CSS_PROPERTY_FONT_SIZE), 100);
return _gtk_css_number_value_get (parent_style->core->font_size, 100);
else
return gtk_css_font_size_get_default_px (provider, style);
}
return _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_FONT_SIZE), 100);
return _gtk_css_number_value_get (style->core->font_size, 100);
}
static double
get_dpi (GtkCssStyle *style)
{
return _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_DPI), 96);
return _gtk_css_number_value_get (style->core->dpi, 96);
}
static GtkCssValue *
+4 -4
View File
@@ -202,7 +202,7 @@ _gtk_css_blend_mode_value_get (const GtkCssValue *value)
static double
get_dpi (GtkCssStyle *style)
{
return _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_DPI), 96);
return _gtk_css_number_value_get (style->core->dpi, 96);
}
/* XXX: Kinda bad to have that machinery here, nobody expects vital font
@@ -267,7 +267,7 @@ gtk_css_value_font_size_compute (GtkCssValue *value,
break;
case GTK_CSS_FONT_SIZE_SMALLER:
if (parent_style)
font_size = _gtk_css_number_value_get (gtk_css_style_get_value (parent_style, GTK_CSS_PROPERTY_FONT_SIZE), 100);
font_size = _gtk_css_number_value_get (parent_style->core->font_size, 100);
else
font_size = gtk_css_font_size_get_default_px (provider, style);
/* XXX: This is what WebKit does... */
@@ -275,7 +275,7 @@ gtk_css_value_font_size_compute (GtkCssValue *value,
break;
case GTK_CSS_FONT_SIZE_LARGER:
if (parent_style)
font_size = _gtk_css_number_value_get (gtk_css_style_get_value (parent_style, GTK_CSS_PROPERTY_FONT_SIZE), 100);
font_size = _gtk_css_number_value_get (parent_style->core->font_size, 100);
else
font_size = gtk_css_font_size_get_default_px (provider, style);
/* XXX: This is what WebKit does... */
@@ -411,7 +411,7 @@ gtk_css_value_font_weight_compute (GtkCssValue *value,
return _gtk_css_value_ref (value);
if (parent_style)
parent_value = _gtk_css_number_value_get (gtk_css_style_get_value (parent_style, property_id), 100);
parent_value = _gtk_css_number_value_get (parent_style->font->font_weight, 100);
else
parent_value = 400;
+38 -62
View File
@@ -45,85 +45,61 @@ gtk_css_image_icon_theme_snapshot (GtkCssImage *image,
double height)
{
GtkCssImageIconTheme *icon_theme = GTK_CSS_IMAGE_ICON_THEME (image);
GdkTexture *texture;
double texture_width, texture_height;
GtkIcon *icon;
double icon_width, icon_height;
gint size;
gboolean symbolic;
double x, y;
size = floor (MIN (width, height));
if (size <= 0)
return;
if (size == icon_theme->cached_size &&
icon_theme->cached_texture != NULL)
icon_theme->cached_icon != NULL)
{
texture = icon_theme->cached_texture;
symbolic = icon_theme->cached_symbolic;
icon = icon_theme->cached_icon;
}
else
{
GtkIconInfo *icon_info;
icon = gtk_icon_theme_lookup_icon (icon_theme->icon_theme,
icon_theme->name,
size,
icon_theme->scale,
GTK_ICON_LOOKUP_USE_BUILTIN);
if (icon == NULL)
icon = gtk_icon_theme_lookup_icon (icon_theme->icon_theme,
"image-missing",
size, icon_theme->scale,
GTK_ICON_LOOKUP_USE_BUILTIN | GTK_ICON_LOOKUP_GENERIC_FALLBACK);
icon_info = gtk_icon_theme_lookup_icon_for_scale (icon_theme->icon_theme,
icon_theme->name,
size,
icon_theme->scale,
GTK_ICON_LOOKUP_USE_BUILTIN);
if (icon_info == NULL)
icon_info = gtk_icon_theme_lookup_icon (icon_theme->icon_theme,
"image-missing",
size,
GTK_ICON_LOOKUP_USE_BUILTIN | GTK_ICON_LOOKUP_GENERIC_FALLBACK);
g_assert (icon != NULL);
g_assert (icon_info != NULL);
symbolic = gtk_icon_info_is_symbolic (icon_info);
texture = GDK_TEXTURE (gtk_icon_info_load_icon (icon_info, NULL));
g_clear_object (&icon_theme->cached_texture);
g_clear_object (&icon_theme->cached_icon);
icon_theme->cached_size = size;
icon_theme->cached_texture = texture;
icon_theme->cached_symbolic = symbolic;
g_object_unref (icon_info);
icon_theme->cached_icon = icon;
}
texture_width = (double) gdk_texture_get_width (texture) / icon_theme->scale;
texture_height = (double) gdk_texture_get_height (texture) / icon_theme->scale;
icon_width = (double) MIN (gdk_paintable_get_intrinsic_width (GDK_PAINTABLE (icon)), width);
icon_height = (double) MIN (gdk_paintable_get_intrinsic_height (GDK_PAINTABLE (icon)), height);
if (symbolic)
x = (width - icon_width) / 2;
y = (height - icon_height) / 2;
if (x != 0 || y != 0)
{
const GdkRGBA *fg = &icon_theme->color;
const GdkRGBA *sc = &icon_theme->success;
const GdkRGBA *wc = &icon_theme->warning;
const GdkRGBA *ec = &icon_theme->error;
graphene_matrix_t matrix;
graphene_vec4_t offset;
graphene_matrix_init_from_float (&matrix,
(float[16]) {
sc->red - fg->red, sc->green - fg->green, sc->blue - fg->blue, 0,
wc->red - fg->red, wc->green - fg->green, wc->blue - fg->blue, 0,
ec->red - fg->red, ec->green - fg->green, ec->blue - fg->blue, 0,
0, 0, 0, fg->alpha
});
graphene_vec4_init (&offset, fg->red, fg->green, fg->blue, 0);
gtk_snapshot_push_color_matrix (snapshot, &matrix, &offset);
gtk_snapshot_save (snapshot);
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (x, y));
}
gtk_snapshot_append_texture (snapshot,
texture,
&GRAPHENE_RECT_INIT(
(width - texture_width) / 2.0,
(height - texture_height) / 2.0,
texture_width,
texture_height
));
if (symbolic)
gtk_snapshot_pop (snapshot);
gtk_icon_snapshot_with_colors (icon, snapshot,
icon_width,
icon_height,
&icon_theme->color,
&icon_theme->success,
&icon_theme->warning,
&icon_theme->error);
if (x != 0 || y != 0)
gtk_snapshot_restore (snapshot);
}
static guint
@@ -176,7 +152,7 @@ gtk_css_image_icon_theme_compute (GtkCssImage *image,
copy = g_object_new (GTK_TYPE_CSS_IMAGE_ICON_THEME, NULL);
copy->name = g_strdup (icon_theme->name);
copy->icon_theme = gtk_css_icon_theme_value_get_icon_theme (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_ICON_THEME));
copy->icon_theme = gtk_css_icon_theme_value_get_icon_theme (style->core->icon_theme);
copy->scale = gtk_style_provider_get_scale (provider);
gtk_icon_theme_lookup_symbolic_colors (style, &copy->color, &copy->success, &copy->warning, &copy->error);
@@ -201,7 +177,7 @@ gtk_css_image_icon_theme_dispose (GObject *object)
g_free (icon_theme->name);
icon_theme->name = NULL;
g_clear_object (&icon_theme->cached_texture);
g_clear_object (&icon_theme->cached_icon);
G_OBJECT_CLASS (_gtk_css_image_icon_theme_parent_class)->dispose (object);
}
@@ -228,6 +204,6 @@ _gtk_css_image_icon_theme_init (GtkCssImageIconTheme *icon_theme)
icon_theme->icon_theme = gtk_icon_theme_get_default ();
icon_theme->scale = 1;
icon_theme->cached_size = -1;
icon_theme->cached_texture = NULL;
icon_theme->cached_icon = NULL;
}
+1 -1
View File
@@ -49,7 +49,7 @@ struct _GtkCssImageIconTheme
int cached_size;
gboolean cached_symbolic;
GdkTexture *cached_texture;
GtkIcon *cached_icon;
};
struct _GtkCssImageIconThemeClass
+2 -4
View File
@@ -70,11 +70,9 @@ lookup_symbolic_colors (GtkCssStyle *style,
GdkRGBA *warning_out,
GdkRGBA *error_out)
{
GtkCssValue *color;
const GdkRGBA *lookup;
color = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_COLOR);
*color_out = *gtk_css_color_value_get_rgba (color);
*color_out = *gtk_css_color_value_get_rgba (style->core->color);
lookup = gtk_css_palette_value_get_color (palette, "success");
if (lookup)
@@ -220,7 +218,7 @@ gtk_css_image_recolor_compute (GtkCssImage *image,
if (recolor->palette)
palette = _gtk_css_value_compute (recolor->palette, property_id, provider, style, parent_style);
else
palette = _gtk_css_value_ref (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_ICON_PALETTE));
palette = _gtk_css_value_ref (style->core->icon_palette);
img = gtk_css_image_recolor_load (recolor, style, palette, scale, &error);
+5 -44
View File
@@ -28,11 +28,14 @@ void
_gtk_css_lookup_init (GtkCssLookup *lookup)
{
memset (lookup, 0, sizeof (*lookup));
lookup->set_values = _gtk_bitmask_new ();
}
void
_gtk_css_lookup_destroy (GtkCssLookup *lookup)
{
_gtk_bitmask_free (lookup->set_values);
}
gboolean
@@ -41,13 +44,7 @@ _gtk_css_lookup_is_missing (const GtkCssLookup *lookup,
{
gtk_internal_return_val_if_fail (lookup != NULL, FALSE);
return lookup->values[id].value == NULL;
}
gboolean
_gtk_css_lookup_all_set (const GtkCssLookup *lookup)
{
return lookup->n_set_values == GTK_CSS_PROPERTY_N_PROPERTIES;
return !_gtk_bitmask_get (lookup->set_values, id);
}
/**
@@ -75,41 +72,5 @@ _gtk_css_lookup_set (GtkCssLookup *lookup,
lookup->values[id].value = value;
lookup->values[id].section = section;
lookup->n_set_values ++;
}
/**
* _gtk_css_lookup_resolve:
* @lookup: the lookup
* @context: the context the values are resolved for
* @values: a new #GtkCssStyle to be filled with the new properties
*
* Resolves the current lookup into a styleproperties object. This is done
* by converting from the winning declaration to the computed value.
*
* XXX: This bypasses the notion of specified value. If this ever becomes
* an issue, go fix it.
**/
void
_gtk_css_lookup_resolve (GtkCssLookup *lookup,
GtkStyleProvider *provider,
GtkCssStaticStyle *style,
GtkCssStyle *parent_style)
{
guint i;
gtk_internal_return_if_fail (lookup != NULL);
gtk_internal_return_if_fail (GTK_IS_STYLE_PROVIDER (provider));
gtk_internal_return_if_fail (GTK_IS_CSS_STATIC_STYLE (style));
gtk_internal_return_if_fail (parent_style == NULL || GTK_IS_CSS_STYLE (parent_style));
for (i = 0; i < GTK_CSS_PROPERTY_N_PROPERTIES; i++)
{
gtk_css_static_style_compute_value (style,
provider,
parent_style,
i,
lookup->values[i].value,
lookup->values[i].section);
}
lookup->set_values = _gtk_bitmask_set (lookup->set_values, id, TRUE);
}
+7 -6
View File
@@ -36,7 +36,7 @@ typedef struct {
} GtkCssLookupValue;
struct _GtkCssLookup {
guint n_set_values;
GtkBitmask *set_values;
GtkCssLookupValue values[GTK_CSS_PROPERTY_N_PROPERTIES];
};
@@ -44,15 +44,16 @@ void _gtk_css_lookup_init (GtkCssLookup
void _gtk_css_lookup_destroy (GtkCssLookup *lookup);
gboolean _gtk_css_lookup_is_missing (const GtkCssLookup *lookup,
guint id);
gboolean _gtk_css_lookup_all_set (const GtkCssLookup *lookup);
void _gtk_css_lookup_set (GtkCssLookup *lookup,
guint id,
GtkCssSection *section,
GtkCssValue *value);
void _gtk_css_lookup_resolve (GtkCssLookup *lookup,
GtkStyleProvider *provider,
GtkCssStaticStyle *style,
GtkCssStyle *parent_style);
static inline const GtkBitmask *
_gtk_css_lookup_get_set_values (const GtkCssLookup *lookup)
{
return lookup->set_values;
}
G_END_DECLS
-400
View File
@@ -1,400 +0,0 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2012 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 "gtkcssmatcherprivate.h"
#include "gtkcssnodedeclarationprivate.h"
#include "gtkcssnodeprivate.h"
#include "gtkwidgetpath.h"
void
gtk_css_matcher_print (const GtkCssMatcher *matcher,
GString *string)
{
matcher->klass->print (matcher, string);
}
char *
gtk_css_matcher_to_string (const GtkCssMatcher *matcher)
{
GString *string = g_string_new ("");
gtk_css_matcher_print (matcher, string);
return g_string_free (string, FALSE);
}
/* GTK_CSS_MATCHER_WIDGET_PATH */
static gboolean
gtk_css_matcher_widget_path_get_parent (GtkCssMatcher *matcher,
const GtkCssMatcher *child)
{
if (child->path.index == 0)
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);
return TRUE;
}
static gboolean
gtk_css_matcher_widget_path_get_previous (GtkCssMatcher *matcher,
const GtkCssMatcher *next)
{
if (next->path.sibling_index == 0)
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;
return TRUE;
}
static gboolean
gtk_css_matcher_widget_path_has_state (const GtkCssMatcher *matcher,
GtkStateFlags state)
{
GtkStateFlags path_state;
if (matcher->path.decl)
path_state = gtk_css_node_declaration_get_state (matcher->path.decl);
else
{
const GtkWidgetPath *siblings;
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))
path_state = gtk_widget_path_iter_get_state (siblings, matcher->path.sibling_index);
else
path_state = gtk_widget_path_iter_get_state (matcher->path.path, matcher->path.index);
}
return (path_state & state) == state;
}
static gboolean
gtk_css_matcher_widget_path_has_name (const GtkCssMatcher *matcher,
/*interned*/ const char *name)
{
const GtkWidgetPath *siblings;
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))
{
const char *path_name = gtk_widget_path_iter_get_object_name (siblings, matcher->path.sibling_index);
if (path_name == NULL)
path_name = g_type_name (gtk_widget_path_iter_get_object_type (siblings, matcher->path.sibling_index));
return path_name == name;
}
else
{
const char *path_name = gtk_widget_path_iter_get_object_name (matcher->path.path, matcher->path.index);
if (path_name == NULL)
path_name = g_type_name (gtk_widget_path_iter_get_object_type (matcher->path.path, matcher->path.index));
return path_name == name;
}
}
static gboolean
gtk_css_matcher_widget_path_has_class (const GtkCssMatcher *matcher,
GQuark class_name)
{
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);
else
return gtk_widget_path_iter_has_qclass (matcher->path.path, matcher->path.index, class_name);
}
static gboolean
gtk_css_matcher_widget_path_has_id (const GtkCssMatcher *matcher,
const char *id)
{
const GtkWidgetPath *siblings;
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_name (siblings, matcher->path.sibling_index, id);
else
return gtk_widget_path_iter_has_name (matcher->path.path, matcher->path.index, id);
}
static gboolean
gtk_css_matcher_widget_path_has_position (const GtkCssMatcher *matcher,
gboolean forward,
int a,
int b)
{
const GtkWidgetPath *siblings;
int x;
siblings = gtk_widget_path_iter_get_siblings (matcher->path.path, matcher->path.index);
if (!siblings)
return FALSE;
if (forward)
x = matcher->path.sibling_index + 1;
else
x = gtk_widget_path_length (siblings) - matcher->path.sibling_index;
x -= b;
if (a == 0)
return x == 0;
if (x % a)
return FALSE;
return x / a >= 0;
}
static void
gtk_css_matcher_widget_path_print (const GtkCssMatcher *matcher,
GString *string)
{
char *s = gtk_widget_path_to_string (matcher->path.path);
g_string_append (string, s);
g_free (s);
}
static const GtkCssMatcherClass GTK_CSS_MATCHER_WIDGET_PATH = {
GTK_CSS_MATCHER_TYPE_WIDGET_PATH,
gtk_css_matcher_widget_path_get_parent,
gtk_css_matcher_widget_path_get_previous,
gtk_css_matcher_widget_path_has_state,
gtk_css_matcher_widget_path_has_name,
gtk_css_matcher_widget_path_has_class,
gtk_css_matcher_widget_path_has_id,
gtk_css_matcher_widget_path_has_position,
gtk_css_matcher_widget_path_print
};
gboolean
_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);
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 gboolean
gtk_css_matcher_node_has_state (const GtkCssMatcher *matcher,
GtkStateFlags state)
{
return (matcher->node.node_state & state) == state;
}
static gboolean
gtk_css_matcher_node_has_name (const GtkCssMatcher *matcher,
/*interned*/ const char *name)
{
return matcher->node.node_name == name;
}
static gboolean
gtk_css_matcher_node_has_class (const GtkCssMatcher *matcher,
GQuark class_name)
{
const GQuark *classes = matcher->node.classes;
switch (matcher->node.n_classes)
{
case 3:
if (classes[2] == class_name)
return TRUE;
G_GNUC_FALLTHROUGH;
case 2:
if (classes[1] == class_name)
return TRUE;
G_GNUC_FALLTHROUGH;
case 1:
if (classes[0] == class_name)
return TRUE;
G_GNUC_FALLTHROUGH;
case 0:
return FALSE;
default:
return gtk_css_node_has_class (matcher->node.node, class_name);
}
return FALSE;
}
static gboolean
gtk_css_matcher_node_has_id (const GtkCssMatcher *matcher,
const char *id)
{
/* assume all callers pass an interned string */
return matcher->node.node_id == id;
}
static gboolean
gtk_css_matcher_node_nth_child (GtkCssNode *node,
GtkCssNode *(* prev_node_func) (GtkCssNode *),
int a,
int b)
{
int pos, x;
/* special-case the common "first-child" and "last-child" */
if (a == 0)
{
while (b > 0 && node != NULL)
{
b--;
node = prev_node_func (node);
}
return b == 0 && node == NULL;
}
/* count nodes */
for (pos = 0; node != NULL; pos++)
node = prev_node_func (node);
/* solve pos = a * X + b
* and return TRUE if X is integer >= 0 */
x = pos - b;
if (x % a)
return FALSE;
return x / a >= 0;
}
static gboolean
gtk_css_matcher_node_has_position (const GtkCssMatcher *matcher,
gboolean forward,
int a,
int b)
{
return gtk_css_matcher_node_nth_child (matcher->node.node,
forward ? get_previous_visible_sibling
: get_next_visible_sibling,
a, b);
}
static void
gtk_css_matcher_node_print (const GtkCssMatcher *matcher,
GString *string)
{
gtk_css_node_print (matcher->node.node, 0, string, 0);
}
static const GtkCssMatcherClass GTK_CSS_MATCHER_NODE = {
GTK_CSS_MATCHER_TYPE_NODE,
gtk_css_matcher_node_get_parent,
gtk_css_matcher_node_get_previous,
gtk_css_matcher_node_has_state,
gtk_css_matcher_node_has_name,
gtk_css_matcher_node_has_class,
gtk_css_matcher_node_has_id,
gtk_css_matcher_node_has_position,
gtk_css_matcher_node_print
};
void
_gtk_css_matcher_node_init (GtkCssMatcher *matcher,
GtkCssNode *node)
{
matcher->node.klass = &GTK_CSS_MATCHER_NODE;
matcher->node.node = node;
matcher->node.node_state = gtk_css_node_get_state (node);
matcher->node.node_name = gtk_css_node_get_name (node);
matcher->node.node_id = gtk_css_node_get_id (node);
matcher->node.classes = gtk_css_node_declaration_get_classes (gtk_css_node_get_declaration (node),
&matcher->node.n_classes);
}
-148
View File
@@ -1,148 +0,0 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2012 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_MATCHER_PRIVATE_H__
#define __GTK_CSS_MATCHER_PRIVATE_H__
#include <gtk/gtkenums.h>
#include <gtk/gtktypes.h>
#include "gtk/gtkcsstypesprivate.h"
G_BEGIN_DECLS
typedef struct _GtkCssMatcherNode GtkCssMatcherNode;
typedef struct _GtkCssMatcherSuperset GtkCssMatcherSuperset;
typedef struct _GtkCssMatcherWidgetPath GtkCssMatcherWidgetPath;
typedef struct _GtkCssMatcherClass GtkCssMatcherClass;
typedef enum {
GTK_CSS_MATCHER_TYPE_NODE,
GTK_CSS_MATCHER_TYPE_WIDGET_PATH
} GtkCssMatcherType;
struct _GtkCssMatcherClass {
GtkCssMatcherType type;
gboolean (* get_parent) (GtkCssMatcher *matcher,
const GtkCssMatcher *child);
gboolean (* get_previous) (GtkCssMatcher *matcher,
const GtkCssMatcher *next);
gboolean (* has_state) (const GtkCssMatcher *matcher,
GtkStateFlags state);
gboolean (* has_name) (const GtkCssMatcher *matcher,
/*interned*/const char*name);
gboolean (* has_class) (const GtkCssMatcher *matcher,
GQuark class_name);
gboolean (* has_id) (const GtkCssMatcher *matcher,
const char *id);
gboolean (* has_position) (const GtkCssMatcher *matcher,
gboolean forward,
int a,
int b);
void (* print) (const GtkCssMatcher *matcher,
GString *string);
};
struct _GtkCssMatcherWidgetPath {
const GtkCssMatcherClass *klass;
const GtkCssNodeDeclaration *decl;
const GtkWidgetPath *path;
guint index;
guint sibling_index;
};
struct _GtkCssMatcherNode {
const GtkCssMatcherClass *klass;
GtkCssNode *node;
GtkStateFlags node_state;
const char *node_name;
const char *node_id;
const GQuark *classes;
guint n_classes;
};
union _GtkCssMatcher {
const GtkCssMatcherClass *klass;
GtkCssMatcherWidgetPath path;
GtkCssMatcherNode node;
};
gboolean _gtk_css_matcher_init (GtkCssMatcher *matcher,
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_print (const GtkCssMatcher *matcher,
GString *string);
char * gtk_css_matcher_to_string (const GtkCssMatcher *matcher);
static inline gboolean
_gtk_css_matcher_get_parent (GtkCssMatcher *matcher,
const GtkCssMatcher *child)
{
return child->klass->get_parent (matcher, child);
}
static inline gboolean
_gtk_css_matcher_get_previous (GtkCssMatcher *matcher,
const GtkCssMatcher *next)
{
return next->klass->get_previous (matcher, next);
}
static inline gboolean
_gtk_css_matcher_has_state (const GtkCssMatcher *matcher,
GtkStateFlags state)
{
return matcher->klass->has_state (matcher, state);
}
static inline gboolean
_gtk_css_matcher_has_name (const GtkCssMatcher *matcher,
/*interned*/ const char *name)
{
return matcher->klass->has_name (matcher, name);
}
static inline gboolean
_gtk_css_matcher_has_class (const GtkCssMatcher *matcher,
GQuark class_name)
{
return matcher->klass->has_class (matcher, class_name);
}
static inline gboolean
_gtk_css_matcher_has_id (const GtkCssMatcher *matcher,
const char *id)
{
return matcher->klass->has_id (matcher, id);
}
static inline guint
_gtk_css_matcher_has_position (const GtkCssMatcher *matcher,
gboolean forward,
int a,
int b)
{
return matcher->klass->has_position (matcher, forward, a, b);
}
G_END_DECLS
#endif /* __GTK_CSS_MATCHER_PRIVATE_H__ */
+55 -91
View File
@@ -87,7 +87,9 @@
/* 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_ID | GTK_CSS_CHANGE_NAME | GTK_CSS_CHANGE_CLASS | GTK_CSS_CHANGE_SOURCE | GTK_CSS_CHANGE_PARENT_STYLE)
#define GTK_CSS_RADICAL_CHANGE (GTK_CSS_CHANGE_ID | GTK_CSS_CHANGE_NAME | GTK_CSS_CHANGE_CLASS | \
GTK_CSS_CHANGE_PARENT_ID | GTK_CSS_CHANGE_PARENT_NAME | GTK_CSS_CHANGE_PARENT_CLASS | \
GTK_CSS_CHANGE_SOURCE | GTK_CSS_CHANGE_PARENT_STYLE)
/* When these change, we need to recompute the change flags for the new style
* since they may have changed.
@@ -110,7 +112,6 @@ enum {
PROP_NAME,
PROP_STATE,
PROP_VISIBLE,
PROP_WIDGET_TYPE,
NUM_PROPERTIES
};
@@ -172,11 +173,11 @@ gtk_css_node_get_property (GObject *object,
break;
case PROP_ID:
g_value_set_string (value, gtk_css_node_get_id (cssnode));
g_value_set_string (value, g_quark_to_string (gtk_css_node_get_id (cssnode)));
break;
case PROP_NAME:
g_value_set_string (value, gtk_css_node_get_name (cssnode));
g_value_set_string (value, g_quark_to_string (gtk_css_node_get_name (cssnode)));
break;
case PROP_STATE:
@@ -187,10 +188,6 @@ gtk_css_node_get_property (GObject *object,
g_value_set_boolean (value, gtk_css_node_get_visible (cssnode));
break;
case PROP_WIDGET_TYPE:
g_value_set_gtype (value, gtk_css_node_get_widget_type (cssnode));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
@@ -211,11 +208,11 @@ gtk_css_node_set_property (GObject *object,
break;
case PROP_ID:
gtk_css_node_set_id (cssnode, g_value_get_string (value));
gtk_css_node_set_id (cssnode, g_quark_from_string (g_value_get_string (value)));
break;
case PROP_NAME:
gtk_css_node_set_name (cssnode, g_value_get_string (value));
gtk_css_node_set_name (cssnode, g_quark_from_string (g_value_get_string (value)));
break;
case PROP_STATE:
@@ -226,10 +223,6 @@ gtk_css_node_set_property (GObject *object,
gtk_css_node_set_visible (cssnode, g_value_get_boolean (value));
break;
case PROP_WIDGET_TYPE:
gtk_css_node_set_widget_type (cssnode, g_value_get_gtype (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
@@ -363,12 +356,11 @@ store_in_global_parent_cache (GtkCssNode *node,
}
static GtkCssStyle *
gtk_css_node_create_style (GtkCssNode *cssnode,
GtkCssChange change)
gtk_css_node_create_style (GtkCssNode *cssnode,
const GtkCountingBloomFilter *filter,
GtkCssChange change)
{
const GtkCssNodeDeclaration *decl;
GtkCssMatcher matcher;
GtkCssStyle *parent;
GtkCssStyle *style;
GtkCssChange style_change;
@@ -380,8 +372,6 @@ gtk_css_node_create_style (GtkCssNode *cssnode,
created_styles++;
parent = cssnode->parent ? cssnode->parent->style : NULL;
if (change & GTK_CSS_CHANGE_NEEDS_RECOMPUTE)
{
/* Need to recompute the change flags */
@@ -392,16 +382,10 @@ gtk_css_node_create_style (GtkCssNode *cssnode,
style_change = gtk_css_static_style_get_change (gtk_css_style_get_static_style (cssnode->style));
}
if (gtk_css_node_init_matcher (cssnode, &matcher))
style = gtk_css_static_style_new_compute (gtk_css_node_get_style_provider (cssnode),
&matcher,
parent,
style_change);
else
style = gtk_css_static_style_new_compute (gtk_css_node_get_style_provider (cssnode),
NULL,
parent,
style_change);
style = gtk_css_static_style_new_compute (gtk_css_node_get_style_provider (cssnode),
filter,
cssnode,
style_change);
store_in_global_parent_cache (cssnode, decl, style);
@@ -431,17 +415,18 @@ gtk_css_style_needs_recreation (GtkCssStyle *style,
}
static GtkCssStyle *
gtk_css_node_real_update_style (GtkCssNode *cssnode,
GtkCssChange change,
gint64 timestamp,
GtkCssStyle *style)
gtk_css_node_real_update_style (GtkCssNode *cssnode,
const GtkCountingBloomFilter *filter,
GtkCssChange change,
gint64 timestamp,
GtkCssStyle *style)
{
GtkCssStyle *static_style, *new_static_style, *new_style;
static_style = GTK_CSS_STYLE (gtk_css_style_get_static_style (style));
if (gtk_css_style_needs_recreation (static_style, change))
new_static_style = gtk_css_node_create_style (cssnode, change);
new_static_style = gtk_css_node_create_style (cssnode, filter, change);
else
new_static_style = g_object_ref (static_style);
@@ -497,15 +482,6 @@ gtk_css_node_real_validate (GtkCssNode *node)
{
}
static gboolean
gtk_css_node_real_init_matcher (GtkCssNode *cssnode,
GtkCssMatcher *matcher)
{
_gtk_css_matcher_node_init (matcher, cssnode);
return TRUE;
}
static GtkStyleProvider *
gtk_css_node_real_get_style_provider (GtkCssNode *cssnode)
{
@@ -585,7 +561,6 @@ gtk_css_node_class_init (GtkCssNodeClass *klass)
klass->validate = gtk_css_node_real_validate;
klass->queue_validate = gtk_css_node_real_queue_validate;
klass->dequeue_validate = gtk_css_node_real_dequeue_validate;
klass->init_matcher = gtk_css_node_real_init_matcher;
klass->get_style_provider = gtk_css_node_real_get_style_provider;
klass->get_frame_clock = gtk_css_node_real_get_frame_clock;
@@ -655,11 +630,6 @@ gtk_css_node_class_init (GtkCssNodeClass *klass)
TRUE,
G_PARAM_READWRITE
| G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
cssnode_properties[PROP_WIDGET_TYPE] =
g_param_spec_gtype ("widget-type", P_("Widget type"), P_("GType of the widget"),
G_TYPE_NONE,
G_PARAM_READWRITE
| G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, NUM_PROPERTIES, cssnode_properties);
@@ -985,8 +955,9 @@ gtk_css_node_needs_new_style (GtkCssNode *cssnode)
}
static void
gtk_css_node_ensure_style (GtkCssNode *cssnode,
gint64 current_time)
gtk_css_node_ensure_style (GtkCssNode *cssnode,
const GtkCountingBloomFilter *filter,
gint64 current_time)
{
gboolean style_changed;
@@ -994,18 +965,19 @@ gtk_css_node_ensure_style (GtkCssNode *cssnode,
return;
if (cssnode->parent)
gtk_css_node_ensure_style (cssnode->parent, current_time);
gtk_css_node_ensure_style (cssnode->parent, filter, current_time);
if (cssnode->style_is_invalid)
{
GtkCssStyle *new_style;
if (cssnode->previous_sibling)
gtk_css_node_ensure_style (cssnode->previous_sibling, current_time);
gtk_css_node_ensure_style (cssnode->previous_sibling, filter, current_time);
g_clear_pointer (&cssnode->cache, gtk_css_node_style_cache_unref);
new_style = GTK_CSS_NODE_GET_CLASS (cssnode)->update_style (cssnode,
filter,
cssnode->pending_changes,
current_time,
cssnode->style);
@@ -1031,7 +1003,7 @@ gtk_css_node_get_style (GtkCssNode *cssnode)
{
gint64 timestamp = gtk_css_node_get_timestamp (cssnode);
gtk_css_node_ensure_style (cssnode, timestamp);
gtk_css_node_ensure_style (cssnode, NULL, timestamp);
}
return cssnode->style;
@@ -1105,8 +1077,8 @@ gtk_css_node_get_visible (GtkCssNode *cssnode)
}
void
gtk_css_node_set_name (GtkCssNode *cssnode,
/*interned*/ const char *name)
gtk_css_node_set_name (GtkCssNode *cssnode,
GQuark name)
{
if (gtk_css_node_declaration_set_name (&cssnode->decl, name))
{
@@ -1115,32 +1087,15 @@ gtk_css_node_set_name (GtkCssNode *cssnode,
}
}
/* interned */ const char *
GQuark
gtk_css_node_get_name (GtkCssNode *cssnode)
{
return gtk_css_node_declaration_get_name (cssnode->decl);
}
void
gtk_css_node_set_widget_type (GtkCssNode *cssnode,
GType widget_type)
{
if (gtk_css_node_declaration_set_type (&cssnode->decl, widget_type))
{
gtk_css_node_invalidate (cssnode, GTK_CSS_CHANGE_NAME);
g_object_notify_by_pspec (G_OBJECT (cssnode), cssnode_properties[PROP_WIDGET_TYPE]);
}
}
GType
gtk_css_node_get_widget_type (GtkCssNode *cssnode)
{
return gtk_css_node_declaration_get_type (cssnode->decl);
}
void
gtk_css_node_set_id (GtkCssNode *cssnode,
/* interned */ const char *id)
gtk_css_node_set_id (GtkCssNode *cssnode,
GQuark id)
{
if (gtk_css_node_declaration_set_id (&cssnode->decl, id))
{
@@ -1149,7 +1104,7 @@ gtk_css_node_set_id (GtkCssNode *cssnode,
}
}
/* interned */ const char *
GQuark
gtk_css_node_get_id (GtkCssNode *cssnode)
{
return gtk_css_node_declaration_get_id (cssnode->decl);
@@ -1352,15 +1307,17 @@ gtk_css_node_invalidate (GtkCssNode *cssnode,
}
static void
gtk_css_node_validate_internal (GtkCssNode *cssnode,
gint64 timestamp)
gtk_css_node_validate_internal (GtkCssNode *cssnode,
GtkCountingBloomFilter *filter,
gint64 timestamp)
{
GtkCssNode *child;
gboolean bloomed = FALSE;
if (!cssnode->invalid)
return;
gtk_css_node_ensure_style (cssnode, timestamp);
gtk_css_node_ensure_style (cssnode, filter, timestamp);
/* need to set to FALSE then to TRUE here to make it chain up */
gtk_css_node_set_invalid (cssnode, FALSE);
@@ -1373,20 +1330,34 @@ gtk_css_node_validate_internal (GtkCssNode *cssnode,
child;
child = gtk_css_node_get_next_sibling (child))
{
if (child->visible)
gtk_css_node_validate_internal (child, timestamp);
if (!child->visible)
continue;
if (!bloomed)
{
gtk_css_node_declaration_add_bloom_hashes (cssnode->decl, filter);
bloomed = TRUE;
}
gtk_css_node_validate_internal (child, filter, timestamp);
}
if (bloomed)
gtk_css_node_declaration_remove_bloom_hashes (cssnode->decl, filter);
}
void
gtk_css_node_validate (GtkCssNode *cssnode)
{
GtkCountingBloomFilter filter = GTK_COUNTING_BLOOM_FILTER_INIT;
gint64 timestamp;
gint64 before = g_get_monotonic_time ();
g_assert (cssnode->parent == NULL);
timestamp = gtk_css_node_get_timestamp (cssnode);
gtk_css_node_validate_internal (cssnode, timestamp);
gtk_css_node_validate_internal (cssnode, &filter, timestamp);
if (cssnode->parent == NULL)
{
@@ -1402,13 +1373,6 @@ gtk_css_node_validate (GtkCssNode *cssnode)
}
}
gboolean
gtk_css_node_init_matcher (GtkCssNode *cssnode,
GtkCssMatcher *matcher)
{
return GTK_CSS_NODE_GET_CLASS (cssnode)->init_matcher (cssnode, matcher);
}
GtkStyleProvider *
gtk_css_node_get_style_provider (GtkCssNode *cssnode)
{
+63 -111
View File
@@ -18,26 +18,18 @@
#include "config.h"
#include "gtkcssnodedeclarationprivate.h"
#include "gtkwidgetpathprivate.h"
#include <string.h>
struct _GtkCssNodeDeclaration {
guint refcount;
GType type;
const /* interned */ char *name;
const /* interned */ char *id;
GQuark name;
GQuark id;
GtkStateFlags state;
guint n_classes;
/* GQuark classes[n_classes]; */
GQuark classes[0];
};
static inline GQuark *
get_classes (const GtkCssNodeDeclaration *decl)
{
return (GQuark *) (decl + 1);
}
static inline gsize
sizeof_node (guint n_classes)
{
@@ -100,8 +92,7 @@ gtk_css_node_declaration_new (void)
static GtkCssNodeDeclaration empty = {
1, /* need to own a ref ourselves so the copy-on-write path kicks in when people change things */
0,
NULL,
NULL,
0,
0,
0
};
@@ -128,27 +119,8 @@ gtk_css_node_declaration_unref (GtkCssNodeDeclaration *decl)
}
gboolean
gtk_css_node_declaration_set_type (GtkCssNodeDeclaration **decl,
GType type)
{
if ((*decl)->type == type)
return FALSE;
gtk_css_node_declaration_make_writable (decl);
(*decl)->type = type;
return TRUE;
}
GType
gtk_css_node_declaration_get_type (const GtkCssNodeDeclaration *decl)
{
return decl->type;
}
gboolean
gtk_css_node_declaration_set_name (GtkCssNodeDeclaration **decl,
/*interned*/ const char *name)
gtk_css_node_declaration_set_name (GtkCssNodeDeclaration **decl,
GQuark name)
{
if ((*decl)->name == name)
return FALSE;
@@ -159,7 +131,7 @@ gtk_css_node_declaration_set_name (GtkCssNodeDeclaration **decl,
return TRUE;
}
/*interned*/ const char *
GQuark
gtk_css_node_declaration_get_name (const GtkCssNodeDeclaration *decl)
{
return decl->name;
@@ -167,10 +139,8 @@ gtk_css_node_declaration_get_name (const GtkCssNodeDeclaration *decl)
gboolean
gtk_css_node_declaration_set_id (GtkCssNodeDeclaration **decl,
const char *id)
GQuark id)
{
id = g_intern_string (id);
if ((*decl)->id == id)
return FALSE;
@@ -180,7 +150,7 @@ gtk_css_node_declaration_set_id (GtkCssNodeDeclaration **decl,
return TRUE;
}
const char *
GQuark
gtk_css_node_declaration_get_id (const GtkCssNodeDeclaration *decl)
{
return decl->id;
@@ -212,7 +182,6 @@ find_class (const GtkCssNodeDeclaration *decl,
{
gint min, max, mid;
gboolean found = FALSE;
GQuark *classes;
guint pos;
*position = 0;
@@ -222,14 +191,13 @@ find_class (const GtkCssNodeDeclaration *decl,
min = 0;
max = decl->n_classes - 1;
classes = get_classes (decl);
do
{
GQuark item;
mid = (min + max) / 2;
item = classes[mid];
item = decl->classes[mid];
if (class_quark == item)
{
@@ -262,11 +230,11 @@ gtk_css_node_declaration_add_class (GtkCssNodeDeclaration **decl,
return FALSE;
gtk_css_node_declaration_make_writable_resize (decl,
(char *) &get_classes (*decl)[pos] - (char *) *decl,
(char *) &(*decl)->classes[pos] - (char *) *decl,
sizeof (GQuark),
0);
(*decl)->n_classes++;
get_classes(*decl)[pos] = class_quark;
(*decl)->classes[pos] = class_quark;
return TRUE;
}
@@ -281,7 +249,7 @@ gtk_css_node_declaration_remove_class (GtkCssNodeDeclaration **decl,
return FALSE;
gtk_css_node_declaration_make_writable_resize (decl,
(char *) &get_classes (*decl)[pos] - (char *) *decl,
(char *) &(*decl)->classes[pos] - (char *) *decl,
0,
sizeof (GQuark));
(*decl)->n_classes--;
@@ -296,7 +264,7 @@ gtk_css_node_declaration_clear_classes (GtkCssNodeDeclaration **decl)
return FALSE;
gtk_css_node_declaration_make_writable_resize (decl,
(char *) get_classes (*decl) - (char *) *decl,
(char *) (*decl)->classes - (char *) *decl,
0,
sizeof (GQuark) * (*decl)->n_classes);
(*decl)->n_classes = 0;
@@ -309,22 +277,21 @@ gtk_css_node_declaration_has_class (const GtkCssNodeDeclaration *decl,
GQuark class_quark)
{
guint pos;
GQuark *classes = get_classes (decl);
switch (decl->n_classes)
{
case 3:
if (classes[2] == class_quark)
if (decl->classes[2] == class_quark)
return TRUE;
G_GNUC_FALLTHROUGH;
case 2:
if (classes[1] == class_quark)
if (decl->classes[1] == class_quark)
return TRUE;
G_GNUC_FALLTHROUGH;
case 1:
if (classes[0] == class_quark)
if (decl->classes[0] == class_quark)
return TRUE;
G_GNUC_FALLTHROUGH;
@@ -342,26 +309,57 @@ gtk_css_node_declaration_get_classes (const GtkCssNodeDeclaration *decl,
{
*n_classes = decl->n_classes;
return get_classes (decl);
return decl->classes;
}
void
gtk_css_node_declaration_add_bloom_hashes (const GtkCssNodeDeclaration *decl,
GtkCountingBloomFilter *filter)
{
guint i;
if (decl->name)
gtk_counting_bloom_filter_add (filter, gtk_css_hash_name (decl->name));
if (decl->id)
gtk_counting_bloom_filter_add (filter, gtk_css_hash_id (decl->id));
for (i = 0; i < decl->n_classes; i++)
{
gtk_counting_bloom_filter_add (filter, gtk_css_hash_class (decl->classes[i]));
}
}
void
gtk_css_node_declaration_remove_bloom_hashes (const GtkCssNodeDeclaration *decl,
GtkCountingBloomFilter *filter)
{
guint i;
if (decl->name)
gtk_counting_bloom_filter_remove (filter, gtk_css_hash_name (decl->name));
if (decl->id)
gtk_counting_bloom_filter_remove (filter, gtk_css_hash_id (decl->id));
for (i = 0; i < decl->n_classes; i++)
{
gtk_counting_bloom_filter_remove (filter, gtk_css_hash_class (decl->classes[i]));
}
}
guint
gtk_css_node_declaration_hash (gconstpointer elem)
{
const GtkCssNodeDeclaration *decl = elem;
GQuark *classes;
guint hash, i;
hash = (guint) decl->type;
hash ^= GPOINTER_TO_UINT (decl->name);
hash = GPOINTER_TO_UINT (decl->name);
hash <<= 5;
hash ^= GPOINTER_TO_UINT (decl->id);
classes = get_classes (decl);
for (i = 0; i < decl->n_classes; i++)
{
hash <<= 5;
hash += classes[i];
hash += decl->classes[i];
}
hash ^= decl->state;
@@ -375,15 +373,11 @@ gtk_css_node_declaration_equal (gconstpointer elem1,
{
const GtkCssNodeDeclaration *decl1 = elem1;
const GtkCssNodeDeclaration *decl2 = elem2;
GQuark *classes1, *classes2;
guint i;
if (decl1 == decl2)
return TRUE;
if (decl1->type != decl2->type)
return FALSE;
if (decl1->name != decl2->name)
return FALSE;
@@ -396,41 +390,15 @@ gtk_css_node_declaration_equal (gconstpointer elem1,
if (decl1->n_classes != decl2->n_classes)
return FALSE;
classes1 = get_classes (decl1);
classes2 = get_classes (decl2);
for (i = 0; i < decl1->n_classes; i++)
{
if (classes1[i] != classes2[i])
if (decl1->classes[i] != decl2->classes[i])
return FALSE;
}
return TRUE;
}
void
gtk_css_node_declaration_add_to_widget_path (const GtkCssNodeDeclaration *decl,
GtkWidgetPath *path,
guint pos)
{
GQuark *classes;
guint i;
/* Set name and id */
gtk_widget_path_iter_set_object_name (path, pos, decl->name);
if (decl->id)
gtk_widget_path_iter_set_name (path, pos, decl->id);
/* Set widget classes */
classes = get_classes (decl);
for (i = 0; i < decl->n_classes; i++)
{
gtk_widget_path_iter_add_qclass (path, pos, classes[i]);
}
/* Set widget state */
gtk_widget_path_iter_set_state (path, pos, decl->state);
}
static int
cmpstr (gconstpointer a,
gconstpointer b,
@@ -447,41 +415,23 @@ void
gtk_css_node_declaration_print (const GtkCssNodeDeclaration *decl,
GString *string)
{
static const char *state_names[] = {
"active",
"hover",
"selected",
"disabled",
"indeterminate",
"focus",
"backdrop",
"dir(ltr)",
"dir(rtl)",
"link",
"visited",
"checked",
"drop(active)"
};
const GQuark *classes;
guint i;
char **classnames;
if (decl->name)
g_string_append (string, decl->name);
g_string_append (string, g_quark_to_string (decl->name));
else
g_string_append (string, g_type_name (decl->type));
g_string_append (string, "*");
if (decl->id)
{
g_string_append_c (string, '#');
g_string_append (string, decl->id);
g_string_append (string, g_quark_to_string (decl->id));
}
classes = get_classes (decl);
classnames = g_new (char *, decl->n_classes);
for (i = 0; i < decl->n_classes; i++)
classnames[i] = (char *)g_quark_to_string (classes[i]);
classnames[i] = (char *)g_quark_to_string (decl->classes[i]);
g_qsort_with_data (classnames, decl->n_classes, sizeof (char *), cmpstr, NULL);
@@ -492,12 +442,14 @@ gtk_css_node_declaration_print (const GtkCssNodeDeclaration *decl,
}
g_free (classnames);
for (i = 0; i < G_N_ELEMENTS (state_names); i++)
for (i = 0; i < sizeof (GtkStateFlags) * 8; i++)
{
if (decl->state & (1 << i))
{
const char *name = gtk_css_pseudoclass_name (1 << i);
g_assert (name);
g_string_append_c (string, ':');
g_string_append (string, state_names[i]);
g_string_append (string, name);
}
}
}
+10 -12
View File
@@ -18,9 +18,9 @@
#ifndef __GTK_CSS_NODE_DECLARATION_PRIVATE_H__
#define __GTK_CSS_NODE_DECLARATION_PRIVATE_H__
#include "gtkcountingbloomfilterprivate.h"
#include "gtkcsstypesprivate.h"
#include "gtkenums.h"
#include "gtkwidgetpath.h"
G_BEGIN_DECLS
@@ -28,15 +28,12 @@ GtkCssNodeDeclaration * gtk_css_node_declaration_new (void);
GtkCssNodeDeclaration * gtk_css_node_declaration_ref (GtkCssNodeDeclaration *decl);
void gtk_css_node_declaration_unref (GtkCssNodeDeclaration *decl);
gboolean gtk_css_node_declaration_set_type (GtkCssNodeDeclaration **decl,
GType type);
GType gtk_css_node_declaration_get_type (const GtkCssNodeDeclaration *decl);
gboolean gtk_css_node_declaration_set_name (GtkCssNodeDeclaration **decl,
/*interned*/ const char *name);
/*interned*/ const char*gtk_css_node_declaration_get_name (const GtkCssNodeDeclaration *decl);
GQuark name);
GQuark gtk_css_node_declaration_get_name (const GtkCssNodeDeclaration *decl);
gboolean gtk_css_node_declaration_set_id (GtkCssNodeDeclaration **decl,
const char *id);
const char * gtk_css_node_declaration_get_id (const GtkCssNodeDeclaration *decl);
GQuark id);
GQuark gtk_css_node_declaration_get_id (const GtkCssNodeDeclaration *decl);
gboolean gtk_css_node_declaration_set_state (GtkCssNodeDeclaration **decl,
GtkStateFlags flags);
GtkStateFlags gtk_css_node_declaration_get_state (const GtkCssNodeDeclaration *decl);
@@ -51,14 +48,15 @@ gboolean gtk_css_node_declaration_has_class (const G
const GQuark * gtk_css_node_declaration_get_classes (const GtkCssNodeDeclaration *decl,
guint *n_classes);
void gtk_css_node_declaration_add_bloom_hashes (const GtkCssNodeDeclaration *decl,
GtkCountingBloomFilter *filter);
void gtk_css_node_declaration_remove_bloom_hashes (const GtkCssNodeDeclaration *decl,
GtkCountingBloomFilter *filter);
guint gtk_css_node_declaration_hash (gconstpointer elem);
gboolean gtk_css_node_declaration_equal (gconstpointer elem1,
gconstpointer elem2);
void gtk_css_node_declaration_add_to_widget_path (const GtkCssNodeDeclaration *decl,
GtkWidgetPath *path,
guint pos);
void gtk_css_node_declaration_print (const GtkCssNodeDeclaration *decl,
GString *string);
+6 -11
View File
@@ -18,6 +18,7 @@
#ifndef __GTK_CSS_NODE_PRIVATE_H__
#define __GTK_CSS_NODE_PRIVATE_H__
#include "gtkcountingbloomfilterprivate.h"
#include "gtkcssnodedeclarationprivate.h"
#include "gtkcssnodestylecacheprivate.h"
#include "gtkcssstylechangeprivate.h"
@@ -76,13 +77,12 @@ struct _GtkCssNodeClass
void (* style_changed) (GtkCssNode *cssnode,
GtkCssStyleChange *style_change);
gboolean (* init_matcher) (GtkCssNode *cssnode,
GtkCssMatcher *matcher);
/* get style provider to use or NULL to use parent's */
GtkStyleProvider * (* 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,
const GtkCountingBloomFilter *filter,
GtkCssChange pending_changes,
gint64 timestamp,
GtkCssStyle *old_style);
@@ -116,14 +116,11 @@ void gtk_css_node_set_visible (GtkCssNode *
gboolean gtk_css_node_get_visible (GtkCssNode *cssnode) G_GNUC_PURE;
void gtk_css_node_set_name (GtkCssNode *cssnode,
/*interned*/const char*name);
/*interned*/const char *gtk_css_node_get_name (GtkCssNode *cssnode) G_GNUC_PURE;
void gtk_css_node_set_widget_type (GtkCssNode *cssnode,
GType widget_type);
GType gtk_css_node_get_widget_type (GtkCssNode *cssnode) G_GNUC_PURE;
GQuark name);
GQuark gtk_css_node_get_name (GtkCssNode *cssnode) G_GNUC_PURE;
void gtk_css_node_set_id (GtkCssNode *cssnode,
/*interned*/const char*id);
/*interned*/const char *gtk_css_node_get_id (GtkCssNode *cssnode) G_GNUC_PURE;
GQuark id);
GQuark gtk_css_node_get_id (GtkCssNode *cssnode) G_GNUC_PURE;
void gtk_css_node_set_state (GtkCssNode *cssnode,
GtkStateFlags state_flags);
GtkStateFlags gtk_css_node_get_state (GtkCssNode *cssnode) G_GNUC_PURE;
@@ -153,8 +150,6 @@ void gtk_css_node_invalidate (GtkCssNode *
GtkCssChange change);
void gtk_css_node_validate (GtkCssNode *cssnode);
gboolean gtk_css_node_init_matcher (GtkCssNode *cssnode,
GtkCssMatcher *matcher);
GtkStyleProvider * gtk_css_node_get_style_provider (GtkCssNode *cssnode) G_GNUC_PURE;
void gtk_css_node_print (GtkCssNode *cssnode,
-153
View File
@@ -1,153 +0,0 @@
/* 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)
gtk_style_context_validate (path_node->context, NULL);
}
static 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 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 GtkStyleProvider *
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->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
@@ -1,61 +0,0 @@
/* 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__ */
+11 -14
View File
@@ -31,7 +31,6 @@
#include "gtkstylecontextprivate.h"
#include "gtkstylepropertyprivate.h"
#include "gtkstyleproviderprivate.h"
#include "gtkwidgetpath.h"
#include "gtkbindings.h"
#include "gtkmarshalers.h"
#include "gtkprivate.h"
@@ -393,8 +392,8 @@ gtk_css_provider_init (GtkCssProvider *css_provider)
static void
verify_tree_match_results (GtkCssProvider *provider,
const GtkCssMatcher *matcher,
GPtrArray *tree_rules)
GtkCssNode *node,
GPtrArray *tree_rules)
{
#ifdef VERIFY_TREE
GtkCssProviderPrivate *priv = gtk_css_provider_get_instance_private (provider);
@@ -416,7 +415,7 @@ verify_tree_match_results (GtkCssProvider *provider,
break;
}
}
should_match = _gtk_css_selector_matches (ruleset->selector, matcher);
should_match = gtk_css_selector_matches (ruleset->selector, node);
if (found != !!should_match)
{
g_error ("expected rule '%s' to %s, but it %s",
@@ -449,10 +448,11 @@ gtk_css_style_provider_get_keyframes (GtkStyleProvider *provider,
}
static void
gtk_css_style_provider_lookup (GtkStyleProvider *provider,
const GtkCssMatcher *matcher,
GtkCssLookup *lookup,
GtkCssChange *change)
gtk_css_style_provider_lookup (GtkStyleProvider *provider,
const GtkCountingBloomFilter *filter,
GtkCssNode *node,
GtkCssLookup *lookup,
GtkCssChange *change)
{
GtkCssProvider *css_provider = GTK_CSS_PROVIDER (provider);
GtkCssProviderPrivate *priv = gtk_css_provider_get_instance_private (css_provider);
@@ -464,10 +464,10 @@ gtk_css_style_provider_lookup (GtkStyleProvider *provider,
if (_gtk_css_selector_tree_is_empty (priv->tree))
return;
tree_rules = _gtk_css_selector_tree_match_all (priv->tree, matcher);
tree_rules = _gtk_css_selector_tree_match_all (priv->tree, filter, node);
if (tree_rules)
{
verify_tree_match_results (css_provider, matcher, tree_rules);
verify_tree_match_results (css_provider, node, tree_rules);
for (i = tree_rules->len - 1; i >= 0; i--)
{
@@ -489,16 +489,13 @@ gtk_css_style_provider_lookup (GtkStyleProvider *provider,
ruleset->styles[j].section,
ruleset->styles[j].value);
}
if (_gtk_css_lookup_all_set (lookup))
break;
}
g_ptr_array_free (tree_rules, TRUE);
}
if (change)
*change = _gtk_css_selector_tree_get_change_all (priv->tree, matcher);
*change = gtk_css_selector_tree_get_change_all (priv->tree, filter, node);
}
static void
+300 -294
View File
@@ -48,37 +48,37 @@ typedef enum {
} GtkCssSelectorCategory;
typedef struct _GtkCssSelectorClass GtkCssSelectorClass;
typedef gboolean (* GtkCssSelectorForeachFunc) (const GtkCssSelector *selector,
const GtkCssMatcher *matcher,
gpointer data);
struct _GtkCssSelectorClass {
const char *name;
GtkCssSelectorCategory category;
void (* print) (const GtkCssSelector *selector,
GString *string);
/* NULL or an iterator that calls func with each submatcher of @matcher.
* Potentially no submatcher exists.
* If any @invocation of @func returns %TRUE, the function will immediately
* return %TRUE itself. If @func never returns %TRUE (or isn't called at all),
* %FALSE will be returned.
void (* print) (const GtkCssSelector *selector,
GString *string);
/* NULL or an iterator that returns the next node or %NULL if there are no
* more nodes.
* Call it like:
* for (iter = gtk_css_selector_iterator (node, NULL);
* iter;
* iter = gtk_css_selector_iterator (node, iter))
* {
* do_stuff();
* }
*/
gboolean (* foreach_matcher) (const GtkCssSelector *selector,
const GtkCssMatcher *matcher,
GtkCssSelectorForeachFunc func,
gpointer data);
gboolean (* match_one) (const GtkCssSelector *selector,
const GtkCssMatcher *matcher);
GtkCssChange (* get_change) (const GtkCssSelector *selector,
GtkCssChange previous_change);
void (* add_specificity) (const GtkCssSelector *selector,
guint *ids,
guint *classes,
guint *elements);
guint (* hash_one) (const GtkCssSelector *selector);
int (* compare_one) (const GtkCssSelector *a,
const GtkCssSelector *b);
GtkCssNode * (* iterator) (const GtkCssSelector *selector,
GtkCssNode *node,
GtkCssNode *current);
gboolean (* match_one) (const GtkCssSelector *selector,
GtkCssNode *node);
GtkCssChange (* get_change) (const GtkCssSelector *selector,
GtkCssChange previous_change);
void (* add_specificity) (const GtkCssSelector *selector,
guint *ids,
guint *classes,
guint *elements);
guint (* hash_one) (const GtkCssSelector *selector);
int (* compare_one) (const GtkCssSelector *a,
const GtkCssSelector *b);
};
typedef enum {
@@ -94,7 +94,7 @@ union _GtkCssSelector
const GtkCssSelectorClass *class; /* type of check this selector does */
struct {
const GtkCssSelectorClass *class;
const char *name; /* interned */
GQuark name;
} id;
struct {
const GtkCssSelectorClass *class;
@@ -102,7 +102,7 @@ union _GtkCssSelector
} style_class;
struct {
const GtkCssSelectorClass *class;
const char *name; /* interned */
GQuark name;
} name;
struct {
const GtkCssSelectorClass *class;
@@ -138,7 +138,7 @@ gtk_css_selector_equal (const GtkCssSelector *a,
static guint
gtk_css_selector_hash_one (const GtkCssSelector *selector)
{
return GPOINTER_TO_UINT (selector->class) ^ selector->class->hash_one (selector);
return selector->class->hash_one (selector);
}
static inline gpointer *
@@ -168,38 +168,19 @@ g_ptr_array_insert_sorted (GPtrArray *array,
g_ptr_array_insert (array, i, data);
}
static void
gtk_css_selector_tree_found_match (const GtkCssSelectorTree *tree,
GPtrArray **array)
static inline gboolean
gtk_css_selector_match_one (const GtkCssSelector *selector,
GtkCssNode *node)
{
int i;
gpointer *matches;
matches = gtk_css_selector_tree_get_matches (tree);
if (matches)
{
if (!*array)
*array = g_ptr_array_sized_new (16);
for (i = 0; matches[i] != NULL; i++)
g_ptr_array_insert_sorted (*array, matches[i]);
}
return selector->class->match_one (selector, node);
}
static inline gboolean
gtk_css_selector_match (const GtkCssSelector *selector,
const GtkCssMatcher *matcher)
static inline GtkCssNode *
gtk_css_selector_iterator (const GtkCssSelector *selector,
GtkCssNode *node,
GtkCssNode *current)
{
return selector->class->match_one (selector, matcher);
}
static inline gboolean
gtk_css_selector_foreach (const GtkCssSelector *selector,
const GtkCssMatcher *matcher,
GtkCssSelectorForeachFunc func,
gpointer data)
{
return selector->class->foreach_matcher (selector, matcher, func, data);
return selector->class->iterator (selector, node, current);
}
static int
@@ -258,18 +239,20 @@ gtk_css_selector_default_add_specificity (const GtkCssSelector *selector,
/* no specificity changes */
}
static gboolean
gtk_css_selector_default_foreach_matcher (const GtkCssSelector *selector,
const GtkCssMatcher *matcher,
GtkCssSelectorForeachFunc func,
gpointer data)
static GtkCssNode *
gtk_css_selector_default_iterator (const GtkCssSelector *selector,
GtkCssNode *node,
GtkCssNode *current)
{
return func (selector, matcher, data);
if (current)
return NULL;
else
return node;
}
static gboolean
gtk_css_selector_default_match_one (const GtkCssSelector *selector,
const GtkCssMatcher *matcher)
GtkCssNode *node)
{
return TRUE;
}
@@ -277,7 +260,7 @@ gtk_css_selector_default_match_one (const GtkCssSelector *selector,
static guint
gtk_css_selector_default_hash_one (const GtkCssSelector *selector)
{
return 0;
return GPOINTER_TO_UINT (selector->class);
}
static int
@@ -296,23 +279,12 @@ gtk_css_selector_descendant_print (const GtkCssSelector *selector,
g_string_append_c (string, ' ');
}
static gboolean
gtk_css_selector_descendant_foreach_matcher (const GtkCssSelector *selector,
const GtkCssMatcher *matcher,
GtkCssSelectorForeachFunc func,
gpointer data)
static GtkCssNode *
gtk_css_selector_descendant_iterator (const GtkCssSelector *selector,
GtkCssNode *node,
GtkCssNode *current)
{
GtkCssMatcher ancestor;
while (_gtk_css_matcher_get_parent (&ancestor, matcher))
{
matcher = &ancestor;
if (func (selector, &ancestor, data))
return TRUE;
}
return FALSE;
return gtk_css_node_get_parent (current ? current : node);
}
static GtkCssChange
@@ -325,7 +297,7 @@ static const GtkCssSelectorClass GTK_CSS_SELECTOR_DESCENDANT = {
"descendant",
GTK_CSS_SELECTOR_CATEGORY_PARENT,
gtk_css_selector_descendant_print,
gtk_css_selector_descendant_foreach_matcher,
gtk_css_selector_descendant_iterator,
gtk_css_selector_default_match_one,
gtk_css_selector_descendant_get_change,
gtk_css_selector_default_add_specificity,
@@ -342,18 +314,15 @@ gtk_css_selector_child_print (const GtkCssSelector *selector,
g_string_append (string, " > ");
}
static gboolean
gtk_css_selector_child_foreach_matcher (const GtkCssSelector *selector,
const GtkCssMatcher *matcher,
GtkCssSelectorForeachFunc func,
gpointer data)
static GtkCssNode *
gtk_css_selector_child_iterator (const GtkCssSelector *selector,
GtkCssNode *node,
GtkCssNode *current)
{
GtkCssMatcher parent;
if (current == NULL)
return gtk_css_node_get_parent (node);
if (!_gtk_css_matcher_get_parent (&parent, matcher))
return FALSE;
return func (selector, &parent, data);
return NULL;
}
static GtkCssChange
@@ -366,7 +335,7 @@ static const GtkCssSelectorClass GTK_CSS_SELECTOR_CHILD = {
"child",
GTK_CSS_SELECTOR_CATEGORY_PARENT,
gtk_css_selector_child_print,
gtk_css_selector_child_foreach_matcher,
gtk_css_selector_child_iterator,
gtk_css_selector_default_match_one,
gtk_css_selector_child_get_change,
gtk_css_selector_default_add_specificity,
@@ -383,23 +352,32 @@ gtk_css_selector_sibling_print (const GtkCssSelector *selector,
g_string_append (string, " ~ ");
}
static gboolean
gtk_css_selector_sibling_foreach_matcher (const GtkCssSelector *selector,
const GtkCssMatcher *matcher,
GtkCssSelectorForeachFunc func,
gpointer data)
static GtkCssNode *
get_previous_visible_sibling (GtkCssNode *node)
{
GtkCssMatcher previous;
do {
node = gtk_css_node_get_previous_sibling (node);
} while (node && !gtk_css_node_get_visible (node));
while (_gtk_css_matcher_get_previous (&previous, matcher))
{
matcher = &previous;
return node;
}
if (func (selector, matcher, data))
return TRUE;
}
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 FALSE;
return node;
}
static GtkCssNode *
gtk_css_selector_sibling_iterator (const GtkCssSelector *selector,
GtkCssNode *node,
GtkCssNode *current)
{
return get_previous_visible_sibling (current ? current : node);
}
static GtkCssChange
@@ -412,7 +390,7 @@ static const GtkCssSelectorClass GTK_CSS_SELECTOR_SIBLING = {
"sibling",
GTK_CSS_SELECTOR_CATEGORY_SIBLING,
gtk_css_selector_sibling_print,
gtk_css_selector_sibling_foreach_matcher,
gtk_css_selector_sibling_iterator,
gtk_css_selector_default_match_one,
gtk_css_selector_sibling_get_change,
gtk_css_selector_default_add_specificity,
@@ -429,18 +407,15 @@ gtk_css_selector_adjacent_print (const GtkCssSelector *selector,
g_string_append (string, " + ");
}
static gboolean
gtk_css_selector_adjacent_foreach_matcher (const GtkCssSelector *selector,
const GtkCssMatcher *matcher,
GtkCssSelectorForeachFunc func,
gpointer data)
static GtkCssNode *
gtk_css_selector_adjacent_iterator (const GtkCssSelector *selector,
GtkCssNode *node,
GtkCssNode *current)
{
GtkCssMatcher previous;
if (current == NULL)
return get_previous_visible_sibling (node);
if (!_gtk_css_matcher_get_previous (&previous, matcher))
return FALSE;
return func (selector, &previous, data);
return NULL;
}
static GtkCssChange
@@ -453,7 +428,7 @@ static const GtkCssSelectorClass GTK_CSS_SELECTOR_ADJACENT = {
"adjacent",
GTK_CSS_SELECTOR_CATEGORY_SIBLING,
gtk_css_selector_adjacent_print,
gtk_css_selector_adjacent_foreach_matcher,
gtk_css_selector_adjacent_iterator,
gtk_css_selector_default_match_one,
gtk_css_selector_adjacent_get_change,
gtk_css_selector_default_add_specificity,
@@ -491,9 +466,9 @@ gtk_css_selector_not_ ## n ## _print (const GtkCssSelector *selector, \
\
static gboolean \
gtk_css_selector_not_ ## n ## _match_one (const GtkCssSelector *selector, \
const GtkCssMatcher *matcher) \
GtkCssNode *node) \
{ \
return !match_func (selector, matcher); \
return !match_func (selector, node); \
} \
\
static GtkCssChange \
@@ -526,7 +501,7 @@ static const GtkCssSelectorClass GTK_CSS_SELECTOR_ ## c = { \
G_STRINGIFY(n), \
ignore_for_change ? GTK_CSS_SELECTOR_CATEGORY_SIMPLE : GTK_CSS_SELECTOR_CATEGORY_SIMPLE_RADICAL, \
gtk_css_selector_ ## n ## _print, \
gtk_css_selector_default_foreach_matcher, \
gtk_css_selector_default_iterator, \
match_func, \
gtk_css_selector_ ## n ## _get_change, \
gtk_css_selector_ ## n ## _add_specificity, \
@@ -536,9 +511,9 @@ static const GtkCssSelectorClass GTK_CSS_SELECTOR_ ## c = { \
\
static const GtkCssSelectorClass GTK_CSS_SELECTOR_NOT_ ## c = { \
"not_" G_STRINGIFY(n), \
ignore_for_change ? GTK_CSS_SELECTOR_CATEGORY_SIMPLE : GTK_CSS_SELECTOR_CATEGORY_SIMPLE_RADICAL, \
GTK_CSS_SELECTOR_CATEGORY_SIMPLE, \
gtk_css_selector_not_ ## n ## _print, \
gtk_css_selector_default_foreach_matcher, \
gtk_css_selector_default_iterator, \
gtk_css_selector_not_ ## n ## _match_one, \
gtk_css_selector_ ## n ## _get_change, \
gtk_css_selector_ ## n ## _add_specificity, \
@@ -557,7 +532,7 @@ print_any (const GtkCssSelector *selector,
static gboolean
match_any (const GtkCssSelector *selector,
const GtkCssMatcher *matcher)
GtkCssNode *node)
{
return TRUE;
}
@@ -575,28 +550,27 @@ static void
print_name (const GtkCssSelector *selector,
GString *string)
{
g_string_append (string, selector->name.name);
g_string_append (string, g_quark_to_string (selector->name.name));
}
static gboolean
match_name (const GtkCssSelector *selector,
const GtkCssMatcher *matcher)
GtkCssNode *node)
{
return _gtk_css_matcher_has_name (matcher, selector->name.name);
return gtk_css_node_get_name (node) == selector->name.name;
}
static guint
hash_name (const GtkCssSelector *a)
{
return g_str_hash (a->name.name);
return gtk_css_hash_name (a->name.name);
}
static int
comp_name (const GtkCssSelector *a,
const GtkCssSelector *b)
{
return strcmp (a->name.name,
b->name.name);
return a->name.name - b->name.name;
}
DEFINE_SIMPLE_SELECTOR(name, NAME, print_name, match_name, hash_name, comp_name, FALSE, FALSE, TRUE, FALSE)
@@ -613,15 +587,15 @@ print_class (const GtkCssSelector *selector,
static gboolean
match_class (const GtkCssSelector *selector,
const GtkCssMatcher *matcher)
GtkCssNode *node)
{
return _gtk_css_matcher_has_class (matcher, selector->style_class.style_class);
return gtk_css_node_has_class (node, selector->style_class.style_class);
}
static guint
hash_class (const GtkCssSelector *a)
{
return a->style_class.style_class;
return gtk_css_hash_class (a->style_class.style_class);
}
static int
@@ -645,66 +619,31 @@ print_id (const GtkCssSelector *selector,
GString *string)
{
g_string_append_c (string, '#');
g_string_append (string, selector->id.name);
g_string_append (string, g_quark_to_string (selector->id.name));
}
static gboolean
match_id (const GtkCssSelector *selector,
const GtkCssMatcher *matcher)
GtkCssNode *node)
{
return _gtk_css_matcher_has_id (matcher, selector->id.name);
return gtk_css_node_get_id (node) == selector->id.name;
}
static guint
hash_id (const GtkCssSelector *a)
{
return GPOINTER_TO_UINT (a->id.name);
return gtk_css_hash_id (a->id.name);
}
static int
comp_id (const GtkCssSelector *a,
const GtkCssSelector *b)
{
if (a->id.name < b->id.name)
return -1;
else if (a->id.name > b->id.name)
return 1;
else
return 0;
return a->id.name - b->id.name;
}
DEFINE_SIMPLE_SELECTOR(id, ID, print_id, match_id, hash_id, comp_id, TRUE, FALSE, FALSE, FALSE)
const gchar *
gtk_css_pseudoclass_name (GtkStateFlags state)
{
static const char * state_names[] = {
"active",
"hover",
"selected",
"disabled",
"indeterminate",
"focus",
"backdrop",
"dir(ltr)",
"dir(rtl)",
"link",
"visited",
"checked",
"drop(active)",
"focus(visible)"
};
guint i;
for (i = 0; i < G_N_ELEMENTS (state_names); i++)
{
if (state == (1 << i))
return state_names[i];
}
return NULL;
}
/* PSEUDOCLASS FOR STATE */
static void
print_pseudoclass_state (const GtkCssSelector *selector,
@@ -716,9 +655,9 @@ print_pseudoclass_state (const GtkCssSelector *selector,
static gboolean
match_pseudoclass_state (const GtkCssSelector *selector,
const GtkCssMatcher *matcher)
GtkCssNode *node)
{
return _gtk_css_matcher_has_state (matcher, selector->state.state);
return (gtk_css_node_get_state (node) & selector->state.state) == selector->state.state;
}
static guint
@@ -839,23 +778,57 @@ print_pseudoclass_position (const GtkCssSelector *selector,
}
}
static gboolean
match_position (GtkCssNode *node,
GtkCssNode *(* prev_node_func) (GtkCssNode *),
int a,
int b)
{
int pos, x;
/* special-case the common "first-child" and "last-child" */
if (a == 0)
{
while (b > 0 && node != NULL)
{
b--;
node = prev_node_func (node);
}
return b == 0 && node == NULL;
}
/* count nodes */
for (pos = 0; node != NULL; pos++)
node = prev_node_func (node);
/* solve pos = a * X + b
* and return TRUE if X is integer >= 0 */
x = pos - b;
if (x % a)
return FALSE;
return x / a >= 0;
}
static gboolean
match_pseudoclass_position (const GtkCssSelector *selector,
const GtkCssMatcher *matcher)
GtkCssNode *node)
{
switch (selector->position.type)
{
case POSITION_FORWARD:
if (!_gtk_css_matcher_has_position (matcher, TRUE, selector->position.a, selector->position.b))
if (!match_position (node, get_previous_visible_sibling, selector->position.a, selector->position.b))
return FALSE;
break;
case POSITION_BACKWARD:
if (!_gtk_css_matcher_has_position (matcher, FALSE, selector->position.a, selector->position.b))
if (!match_position (node, get_next_visible_sibling, selector->position.a, selector->position.b))
return FALSE;
break;
case POSITION_ONLY:
if (!_gtk_css_matcher_has_position (matcher, TRUE, 0, 1) ||
!_gtk_css_matcher_has_position (matcher, FALSE, 0, 1))
if (get_previous_visible_sibling (node) ||
get_next_visible_sibling (node))
return FALSE;
break;
default:
@@ -1406,13 +1379,13 @@ gtk_css_selector_parse_selector_pseudo_class (GtkCssParser *parser,
else if (gtk_css_token_is (token, GTK_CSS_TOKEN_IDENT))
{
selector = gtk_css_selector_new (&GTK_CSS_SELECTOR_NOT_NAME, selector);
selector->name.name = g_intern_string (token->string.string);
selector->name.name = g_quark_from_string (token->string.string);
gtk_css_parser_consume_token (parser);
}
else if (gtk_css_token_is (token, GTK_CSS_TOKEN_HASH_ID))
{
selector = gtk_css_selector_new (&GTK_CSS_SELECTOR_NOT_ID, selector);
selector->id.name = g_intern_string (token->string.string);
selector->id.name = g_quark_from_string (token->string.string);
gtk_css_parser_consume_token (parser);
}
else if (gtk_css_token_is_delim (token, '.'))
@@ -1538,13 +1511,13 @@ gtk_css_selector_parse_simple_selector (GtkCssParser *parser,
else if (!parsed_something && gtk_css_token_is (token, GTK_CSS_TOKEN_IDENT))
{
selector = gtk_css_selector_new (&GTK_CSS_SELECTOR_NAME, selector);
selector->name.name = g_intern_string (token->string.string);
selector->name.name = g_quark_from_string (token->string.string);
gtk_css_parser_consume_token (parser);
}
else if (gtk_css_token_is (token, GTK_CSS_TOKEN_HASH_ID))
{
selector = gtk_css_selector_new (&GTK_CSS_SELECTOR_ID, selector);
selector->id.name = g_intern_string (token->string.string);
selector->id.name = g_quark_from_string (token->string.string);
gtk_css_parser_consume_token (parser);
}
else if (gtk_css_token_is_delim (token, '.'))
@@ -1673,48 +1646,41 @@ _gtk_css_selector_to_string (const GtkCssSelector *selector)
return g_string_free (string, FALSE);
}
static gboolean
gtk_css_selector_foreach_match (const GtkCssSelector *selector,
const GtkCssMatcher *matcher,
gpointer unused)
{
selector = gtk_css_selector_previous (selector);
if (selector == NULL)
return TRUE;
if (!gtk_css_selector_match (selector, matcher))
return FALSE;
return gtk_css_selector_foreach (selector, matcher, gtk_css_selector_foreach_match, NULL);
}
/**
* _gtk_css_selector_matches:
* gtk_css_selector_matches:
* @selector: the selector
* @path: the path to check
* @state: The state to match
* @node: The node to match
*
* Checks if the @selector matches the given @path. If @length is
* smaller than the number of elements in @path, it is assumed that
* only the first @length element of @path are valid and the rest
* does not exist. This is useful for doing parent matches for the
* 'inherit' keyword.
* Checks if the @selector matches the given @node.
*
* Returns: %TRUE if the selector matches @path
* Returns: %TRUE if the selector matches @node
**/
gboolean
_gtk_css_selector_matches (const GtkCssSelector *selector,
const GtkCssMatcher *matcher)
gtk_css_selector_matches (const GtkCssSelector *selector,
GtkCssNode *node)
{
GtkCssNode *child;
const GtkCssSelector *prev;
g_return_val_if_fail (selector != NULL, FALSE);
g_return_val_if_fail (matcher != NULL, FALSE);
g_return_val_if_fail (node != NULL, FALSE);
if (!gtk_css_selector_match (selector, matcher))
if (!gtk_css_selector_match_one (selector, node))
return FALSE;
return gtk_css_selector_foreach (selector, matcher, gtk_css_selector_foreach_match, NULL);
prev = gtk_css_selector_previous (selector);
if (prev == NULL)
return TRUE;
for (child = gtk_css_selector_iterator (selector, node, NULL);
child;
child = gtk_css_selector_iterator (selector, node, child))
{
if (gtk_css_selector_matches (prev, child))
return TRUE;
}
return FALSE;
}
/* Computes specificity according to CSS 2.1.
@@ -1849,55 +1815,6 @@ gtk_css_selectors_skip_initial_selector (GtkCssSelector *selector, const GtkCssS
return (GtkCssSelector *)gtk_css_selector_previous (selector);
}
static gboolean
gtk_css_selector_tree_match_foreach (const GtkCssSelector *selector,
const GtkCssMatcher *matcher,
gpointer res)
{
const GtkCssSelectorTree *tree = (const GtkCssSelectorTree *) selector;
const GtkCssSelectorTree *prev;
if (!gtk_css_selector_match (selector, matcher))
return FALSE;
gtk_css_selector_tree_found_match (tree, res);
for (prev = gtk_css_selector_tree_get_previous (tree);
prev != NULL;
prev = gtk_css_selector_tree_get_sibling (prev))
gtk_css_selector_foreach (&prev->selector, matcher, gtk_css_selector_tree_match_foreach, res);
return FALSE;
}
GPtrArray *
_gtk_css_selector_tree_match_all (const GtkCssSelectorTree *tree,
const GtkCssMatcher *matcher)
{
GPtrArray *array = NULL;
for (; tree != NULL;
tree = gtk_css_selector_tree_get_sibling (tree))
gtk_css_selector_foreach (&tree->selector, matcher, gtk_css_selector_tree_match_foreach, &array);
return array;
}
/* The code for collecting matches assumes that the name, id and classes
* of a node remain unchanged, and anything else can change. This needs to
* be kept in sync with the definition of 'radical change' in gtkcssnode.c.
*/
static gboolean
gtk_css_selector_match_for_change (const GtkCssSelector *selector,
const GtkCssMatcher *matcher)
{
if (selector->class->category != GTK_CSS_SELECTOR_CATEGORY_SIMPLE_RADICAL)
return TRUE;
return selector->class->match_one (selector, matcher);
}
/* When checking for changes via the tree we need to know if a rule further
down the tree matched, because if so we need to add "our bit" to the
Change. For instance in a match like *.class:active we'll
@@ -1909,39 +1826,56 @@ gtk_css_selector_match_for_change (const GtkCssSelector *selector,
that change != 0 on any match. */
#define GTK_CSS_CHANGE_GOT_MATCH GTK_CSS_CHANGE_RESERVED_BIT
/* The code for collecting matches assumes that the name, id and classes
* of a node remain unchanged, and anything else can change. This needs to
* be kept in sync with the definition of 'radical change' in gtkcssnode.c.
*/
static GtkCssChange
gtk_css_selector_tree_collect_change (const GtkCssSelectorTree *tree)
gtk_css_selector_tree_get_change (const GtkCssSelectorTree *tree,
const GtkCountingBloomFilter *filter,
GtkCssNode *node,
gboolean skipping)
{
GtkCssChange change = 0;
const GtkCssSelectorTree *prev;
for (prev = gtk_css_selector_tree_get_previous (tree);
prev != NULL;
prev = gtk_css_selector_tree_get_sibling (prev))
change |= gtk_css_selector_tree_collect_change (prev);
change = tree->selector.class->get_change (&tree->selector, change);
return change;
}
static GtkCssChange
gtk_css_selector_tree_get_change (const GtkCssSelectorTree *tree,
const GtkCssMatcher *matcher)
{
GtkCssChange change = 0;
const GtkCssSelectorTree *prev;
if (!gtk_css_selector_match_for_change (&tree->selector, matcher))
return 0;
if (!gtk_css_selector_is_simple (&tree->selector))
return gtk_css_selector_tree_collect_change (tree) | GTK_CSS_CHANGE_GOT_MATCH;
switch (tree->selector.class->category)
{
case GTK_CSS_SELECTOR_CATEGORY_SIMPLE:
break;
case GTK_CSS_SELECTOR_CATEGORY_SIMPLE_RADICAL:
if (skipping)
break;
if (node)
{
if (!tree->selector.class->match_one (&tree->selector, node))
return 0;
}
else if (filter)
{
if (!gtk_counting_bloom_filter_may_contain (filter,
gtk_css_selector_hash_one (&tree->selector)))
return 0;
}
break;
case GTK_CSS_SELECTOR_CATEGORY_PARENT:
skipping = FALSE;
node = NULL;
break;
case GTK_CSS_SELECTOR_CATEGORY_SIBLING:
skipping = TRUE;
node = NULL;
break;
default:
g_assert_not_reached ();
return 0;
}
for (prev = gtk_css_selector_tree_get_previous (tree);
prev != NULL;
prev = gtk_css_selector_tree_get_sibling (prev))
change |= gtk_css_selector_tree_get_change (prev, matcher);
change |= gtk_css_selector_tree_get_change (prev, filter, node, skipping);
if (change || gtk_css_selector_tree_get_matches (tree))
change = tree->selector.class->get_change (&tree->selector, change & ~GTK_CSS_CHANGE_GOT_MATCH) | GTK_CSS_CHANGE_GOT_MATCH;
@@ -1949,6 +1883,80 @@ gtk_css_selector_tree_get_change (const GtkCssSelectorTree *tree,
return change;
}
static void
gtk_css_selector_tree_found_match (const GtkCssSelectorTree *tree,
GPtrArray **results)
{
int i;
gpointer *matches;
matches = gtk_css_selector_tree_get_matches (tree);
if (!matches)
return;
if (*results == NULL)
*results = g_ptr_array_sized_new (16);
for (i = 0; matches[i] != NULL; i++)
g_ptr_array_insert_sorted (*results, matches[i]);
}
static gboolean
gtk_css_selector_tree_match (const GtkCssSelectorTree *tree,
const GtkCountingBloomFilter *filter,
gboolean match_filter,
GtkCssNode *node,
GPtrArray **results)
{
const GtkCssSelectorTree *prev;
GtkCssNode *child;
if (match_filter && tree->selector.class->category == GTK_CSS_SELECTOR_CATEGORY_SIMPLE_RADICAL &&
!gtk_counting_bloom_filter_may_contain (filter, gtk_css_selector_hash_one (&tree->selector)))
return FALSE;
if (!gtk_css_selector_match_one (&tree->selector, node))
return TRUE;
gtk_css_selector_tree_found_match (tree, results);
if (filter && !gtk_css_selector_is_simple (&tree->selector))
match_filter = tree->selector.class->category == GTK_CSS_SELECTOR_CATEGORY_PARENT;
for (prev = gtk_css_selector_tree_get_previous (tree);
prev != NULL;
prev = gtk_css_selector_tree_get_sibling (prev))
{
for (child = gtk_css_selector_iterator (&tree->selector, node, NULL);
child;
child = gtk_css_selector_iterator (&tree->selector, node, child))
{
if (!gtk_css_selector_tree_match (prev, filter, match_filter, child, results))
break;
}
}
return TRUE;
}
GPtrArray *
_gtk_css_selector_tree_match_all (const GtkCssSelectorTree *tree,
const GtkCountingBloomFilter *filter,
GtkCssNode *node)
{
const GtkCssSelectorTree *iter;
GPtrArray *results = NULL;
for (iter = tree;
iter != NULL;
iter = gtk_css_selector_tree_get_sibling (iter))
{
gtk_css_selector_tree_match (iter, filter, FALSE, node, &results);
}
return results;
}
gboolean
_gtk_css_selector_tree_is_empty (const GtkCssSelectorTree *tree)
{
@@ -1956,17 +1964,15 @@ _gtk_css_selector_tree_is_empty (const GtkCssSelectorTree *tree)
}
GtkCssChange
_gtk_css_selector_tree_get_change_all (const GtkCssSelectorTree *tree,
const GtkCssMatcher *matcher)
gtk_css_selector_tree_get_change_all (const GtkCssSelectorTree *tree,
const GtkCountingBloomFilter *filter,
GtkCssNode *node)
{
GtkCssChange change;
GtkCssChange change = 0;
change = 0;
/* no need to foreach here because we abort for non-simple selectors */
for (; tree != NULL;
tree = gtk_css_selector_tree_get_sibling (tree))
change |= gtk_css_selector_tree_get_change (tree, matcher);
change |= gtk_css_selector_tree_get_change (tree, filter, node, FALSE);
/* Never return reserved bit set */
return change & ~GTK_CSS_CHANGE_RESERVED_BIT;
@@ -1974,7 +1980,7 @@ _gtk_css_selector_tree_get_change_all (const GtkCssSelectorTree *tree,
#ifdef PRINT_TREE
static void
_gtk_css_selector_tree_print (const GtkCssSelectorTree *tree, GString *str, char *prefix)
_gtk_css_selector_tree_print (const GtkCssSelectorTree *tree, GString *str, const char *prefix)
{
gboolean first = TRUE;
int len, i;
+9 -8
View File
@@ -18,7 +18,8 @@
#ifndef __GTK_CSS_SELECTOR_PRIVATE_H__
#define __GTK_CSS_SELECTOR_PRIVATE_H__
#include "gtk/gtkcssmatcherprivate.h"
#include "gtk/gtkcountingbloomfilterprivate.h"
#include "gtk/gtkcsstypesprivate.h"
#include "gtk/gtkcssparserprivate.h"
G_BEGIN_DECLS
@@ -34,17 +35,19 @@ char * _gtk_css_selector_to_string (const GtkCssSelector *sel
void _gtk_css_selector_print (const GtkCssSelector *selector,
GString *str);
gboolean _gtk_css_selector_matches (const GtkCssSelector *selector,
const GtkCssMatcher *matcher);
gboolean gtk_css_selector_matches (const GtkCssSelector *selector,
GtkCssNode *node);
GtkCssChange _gtk_css_selector_get_change (const GtkCssSelector *selector);
int _gtk_css_selector_compare (const GtkCssSelector *a,
const GtkCssSelector *b);
void _gtk_css_selector_tree_free (GtkCssSelectorTree *tree);
GPtrArray * _gtk_css_selector_tree_match_all (const GtkCssSelectorTree *tree,
const GtkCssMatcher *matcher);
GtkCssChange _gtk_css_selector_tree_get_change_all (const GtkCssSelectorTree *tree,
const GtkCssMatcher *matcher);
const GtkCountingBloomFilter *filter,
GtkCssNode *node);
GtkCssChange gtk_css_selector_tree_get_change_all (const GtkCssSelectorTree *tree,
const GtkCountingBloomFilter *filter,
GtkCssNode *node);
void _gtk_css_selector_tree_match_print (const GtkCssSelectorTree *tree,
GString *str);
gboolean _gtk_css_selector_tree_is_empty (const GtkCssSelectorTree *tree) G_GNUC_CONST;
@@ -59,8 +62,6 @@ void _gtk_css_selector_tree_builder_add (GtkCssSelectorT
GtkCssSelectorTree * _gtk_css_selector_tree_builder_build (GtkCssSelectorTreeBuilder *builder);
void _gtk_css_selector_tree_builder_free (GtkCssSelectorTreeBuilder *builder);
const char *gtk_css_pseudoclass_name (GtkStateFlags flags);
G_END_DECLS
#endif /* __GTK_CSS_SELECTOR_PRIVATE_H__ */
-12
View File
@@ -62,17 +62,6 @@ gtk_css_shorthand_property_set_property (GObject *object,
}
}
static void
_gtk_css_shorthand_property_query (GtkStyleProperty *property,
GValue *value,
GtkStyleQueryFunc query_func,
gpointer query_data)
{
GtkCssShorthandProperty *shorthand = GTK_CSS_SHORTHAND_PROPERTY (property);
shorthand->query (shorthand, value, query_func, query_data);
}
static GtkCssValue *
gtk_css_shorthand_property_parse_value (GtkStyleProperty *property,
GtkCssParser *parser)
@@ -160,7 +149,6 @@ _gtk_css_shorthand_property_class_init (GtkCssShorthandPropertyClass *klass)
G_TYPE_STRV,
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
property_class->query = _gtk_css_shorthand_property_query;
property_class->parse_value = gtk_css_shorthand_property_parse_value;
}
+66 -241
View File
@@ -1076,152 +1076,19 @@ parse_all (GtkCssShorthandProperty *shorthand,
return FALSE;
}
/*** PACKING ***/
static void
pack_border (GtkCssShorthandProperty *shorthand,
GValue *value,
GtkStyleQueryFunc query_func,
gpointer query_data)
{
GtkCssStyleProperty *prop;
GtkBorder border;
GValue v;
prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 0);
_gtk_style_property_query (GTK_STYLE_PROPERTY (prop), &v, query_func, query_data);
border.top = g_value_get_int (&v);
g_value_unset (&v);
prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 1);
_gtk_style_property_query (GTK_STYLE_PROPERTY (prop), &v, query_func, query_data);
border.right = g_value_get_int (&v);
g_value_unset (&v);
prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 2);
_gtk_style_property_query (GTK_STYLE_PROPERTY (prop), &v, query_func, query_data);
border.bottom = g_value_get_int (&v);
g_value_unset (&v);
prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 3);
_gtk_style_property_query (GTK_STYLE_PROPERTY (prop), &v, query_func, query_data);
border.left = g_value_get_int (&v);
g_value_unset (&v);
g_value_init (value, GTK_TYPE_BORDER);
g_value_set_boxed (value, &border);
}
static void
pack_border_radius (GtkCssShorthandProperty *shorthand,
GValue *value,
GtkStyleQueryFunc query_func,
gpointer query_data)
{
GtkCssValue *v;
int i = 0;
v = (* query_func) (GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS, query_data);
if (v)
i = _gtk_css_corner_value_get_x (v, 100);
g_value_init (value, G_TYPE_INT);
g_value_set_int (value, i);
}
static void
pack_font_description (GtkCssShorthandProperty *shorthand,
GValue *value,
GtkStyleQueryFunc query_func,
gpointer query_data)
{
PangoFontDescription *description;
GtkCssValue *v;
description = pango_font_description_new ();
v = (* query_func) (GTK_CSS_PROPERTY_FONT_FAMILY, query_data);
if (v)
{
if (_gtk_css_array_value_get_n_values (v) > 1)
{
int i;
GString *s = g_string_new ("");
for (i = 0; i < _gtk_css_array_value_get_n_values (v); i++)
{
if (i > 0)
g_string_append (s, ",");
g_string_append (s, _gtk_css_string_value_get (_gtk_css_array_value_get_nth (v, i)));
}
pango_font_description_set_family (description, s->str);
g_string_free (s, TRUE);
}
else
{
pango_font_description_set_family (description,
_gtk_css_string_value_get (_gtk_css_array_value_get_nth (v, 0)));
}
}
v = (* query_func) (GTK_CSS_PROPERTY_FONT_SIZE, query_data);
if (v)
pango_font_description_set_absolute_size (description, round (_gtk_css_number_value_get (v, 100) * PANGO_SCALE));
v = (* query_func) (GTK_CSS_PROPERTY_FONT_STYLE, query_data);
if (v)
pango_font_description_set_style (description, _gtk_css_font_style_value_get (v));
v = (* query_func) (GTK_CSS_PROPERTY_FONT_WEIGHT, query_data);
if (v)
pango_font_description_set_weight (description, _gtk_css_number_value_get (v, 100));
v = (* query_func) (GTK_CSS_PROPERTY_FONT_STRETCH, query_data);
if (v)
pango_font_description_set_stretch (description, _gtk_css_font_stretch_value_get (v));
g_value_init (value, PANGO_TYPE_FONT_DESCRIPTION);
g_value_take_boxed (value, description);
}
static void
pack_first_element (GtkCssShorthandProperty *shorthand,
GValue *value,
GtkStyleQueryFunc query_func,
gpointer query_data)
{
GtkCssStyleProperty *prop;
/* NB: This is a fallback for properties that originally were
* not used as shorthand. We just pick the first subproperty
* as a representative.
* Lesson learned: Don't query the shorthand, query the
* real properties instead. */
prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 0);
_gtk_style_property_query (GTK_STYLE_PROPERTY (prop),
value,
query_func,
query_data);
}
static void
_gtk_css_shorthand_property_register (const char *name,
GType value_type,
const char **subproperties,
GtkCssShorthandPropertyParseFunc parse_func,
GtkCssShorthandPropertyQueryFunc query_func)
gtk_css_shorthand_property_register (const char *name,
const char **subproperties,
GtkCssShorthandPropertyParseFunc parse_func)
{
GtkCssShorthandProperty *node;
node = g_object_new (GTK_TYPE_CSS_SHORTHAND_PROPERTY,
"name", name,
"value-type", value_type,
"subproperties", subproperties,
NULL);
node->parse = parse_func;
node->query = query_func;
}
/* NB: return value is transfer: container */
@@ -1277,112 +1144,70 @@ _gtk_css_shorthand_property_init_properties (void)
const char **all_subproperties;
_gtk_css_shorthand_property_register ("font",
PANGO_TYPE_FONT_DESCRIPTION,
font_subproperties,
parse_font,
pack_font_description);
_gtk_css_shorthand_property_register ("margin",
GTK_TYPE_BORDER,
margin_subproperties,
parse_margin,
pack_border);
_gtk_css_shorthand_property_register ("padding",
GTK_TYPE_BORDER,
padding_subproperties,
parse_padding,
pack_border);
_gtk_css_shorthand_property_register ("border-width",
GTK_TYPE_BORDER,
border_width_subproperties,
parse_border_width,
pack_border);
_gtk_css_shorthand_property_register ("border-radius",
G_TYPE_INT,
border_radius_subproperties,
parse_border_radius,
pack_border_radius);
_gtk_css_shorthand_property_register ("border-color",
GDK_TYPE_RGBA,
border_color_subproperties,
parse_border_color,
pack_first_element);
_gtk_css_shorthand_property_register ("border-style",
GTK_TYPE_BORDER_STYLE,
border_style_subproperties,
parse_border_style,
pack_first_element);
_gtk_css_shorthand_property_register ("border-image",
G_TYPE_NONE,
border_image_subproperties,
parse_border_image,
NULL);
_gtk_css_shorthand_property_register ("border-top",
G_TYPE_NONE,
border_top_subproperties,
parse_border_side,
NULL);
_gtk_css_shorthand_property_register ("border-right",
G_TYPE_NONE,
border_right_subproperties,
parse_border_side,
NULL);
_gtk_css_shorthand_property_register ("border-bottom",
G_TYPE_NONE,
border_bottom_subproperties,
parse_border_side,
NULL);
_gtk_css_shorthand_property_register ("border-left",
G_TYPE_NONE,
border_left_subproperties,
parse_border_side,
NULL);
_gtk_css_shorthand_property_register ("border",
G_TYPE_NONE,
border_subproperties,
parse_border,
NULL);
_gtk_css_shorthand_property_register ("-gtk-outline-radius",
G_TYPE_INT,
outline_radius_subproperties,
parse_border_radius,
pack_border_radius);
_gtk_css_shorthand_property_register ("outline",
G_TYPE_NONE,
outline_subproperties,
parse_border_side,
NULL);
_gtk_css_shorthand_property_register ("background",
G_TYPE_NONE,
background_subproperties,
parse_background,
NULL);
_gtk_css_shorthand_property_register ("transition",
G_TYPE_NONE,
transition_subproperties,
parse_transition,
NULL);
_gtk_css_shorthand_property_register ("animation",
G_TYPE_NONE,
animation_subproperties,
parse_animation,
NULL);
_gtk_css_shorthand_property_register ("text-decoration",
G_TYPE_NONE,
text_decoration_subproperties,
parse_text_decoration,
NULL);
_gtk_css_shorthand_property_register ("font-variant",
G_TYPE_NONE,
font_variant_subproperties,
parse_font_variant,
NULL);
gtk_css_shorthand_property_register ("font",
font_subproperties,
parse_font);
gtk_css_shorthand_property_register ("margin",
margin_subproperties,
parse_margin);
gtk_css_shorthand_property_register ("padding",
padding_subproperties,
parse_padding);
gtk_css_shorthand_property_register ("border-width",
border_width_subproperties,
parse_border_width);
gtk_css_shorthand_property_register ("border-radius",
border_radius_subproperties,
parse_border_radius);
gtk_css_shorthand_property_register ("border-color",
border_color_subproperties,
parse_border_color);
gtk_css_shorthand_property_register ("border-style",
border_style_subproperties,
parse_border_style);
gtk_css_shorthand_property_register ("border-image",
border_image_subproperties,
parse_border_image);
gtk_css_shorthand_property_register ("border-top",
border_top_subproperties,
parse_border_side);
gtk_css_shorthand_property_register ("border-right",
border_right_subproperties,
parse_border_side);
gtk_css_shorthand_property_register ("border-bottom",
border_bottom_subproperties,
parse_border_side);
gtk_css_shorthand_property_register ("border-left",
border_left_subproperties,
parse_border_side);
gtk_css_shorthand_property_register ("border",
border_subproperties,
parse_border);
gtk_css_shorthand_property_register ("-gtk-outline-radius",
outline_radius_subproperties,
parse_border_radius);
gtk_css_shorthand_property_register ("outline",
outline_subproperties,
parse_border_side);
gtk_css_shorthand_property_register ("background",
background_subproperties,
parse_background);
gtk_css_shorthand_property_register ("transition",
transition_subproperties,
parse_transition);
gtk_css_shorthand_property_register ("animation",
animation_subproperties,
parse_animation);
gtk_css_shorthand_property_register ("text-decoration",
text_decoration_subproperties,
parse_text_decoration);
gtk_css_shorthand_property_register ("font-variant",
font_variant_subproperties,
parse_font_variant);
all_subproperties = get_all_subproperties ();
_gtk_css_shorthand_property_register ("all",
G_TYPE_NONE,
all_subproperties,
parse_all,
NULL);
gtk_css_shorthand_property_register ("all",
all_subproperties,
parse_all);
g_free (all_subproperties);
}
-5
View File
@@ -41,10 +41,6 @@ typedef struct _GtkCssShorthandPropertyClass GtkCssShorthandPropertyClass;
typedef gboolean (* GtkCssShorthandPropertyParseFunc) (GtkCssShorthandProperty *shorthand,
GtkCssValue **values,
GtkCssParser *parser);
typedef void (* GtkCssShorthandPropertyQueryFunc) (GtkCssShorthandProperty *shorthand,
GValue *value,
GtkStyleQueryFunc query_func,
gpointer query_data);
struct _GtkCssShorthandProperty
{
@@ -53,7 +49,6 @@ struct _GtkCssShorthandProperty
GPtrArray *subproperties;
GtkCssShorthandPropertyParseFunc parse;
GtkCssShorthandPropertyQueryFunc query;
};
struct _GtkCssShorthandPropertyClass
+880 -43
View File
File diff suppressed because it is too large Load Diff
+8 -15
View File
@@ -20,9 +20,10 @@
#ifndef __GTK_CSS_STATIC_STYLE_PRIVATE_H__
#define __GTK_CSS_STATIC_STYLE_PRIVATE_H__
#include "gtk/gtkcssmatcherprivate.h"
#include "gtk/gtkcssstyleprivate.h"
#include "gtk/gtkcountingbloomfilterprivate.h"
G_BEGIN_DECLS
#define GTK_TYPE_CSS_STATIC_STYLE (gtk_css_static_style_get_type ())
@@ -34,11 +35,11 @@ G_BEGIN_DECLS
typedef struct _GtkCssStaticStyleClass GtkCssStaticStyleClass;
struct _GtkCssStaticStyle
{
GtkCssStyle parent;
GtkCssValue *values[GTK_CSS_PROPERTY_N_PROPERTIES]; /* the values */
GPtrArray *sections; /* sections the values are defined in */
GtkCssChange change; /* change as returned by value lookup */
@@ -52,19 +53,11 @@ struct _GtkCssStaticStyleClass
GType gtk_css_static_style_get_type (void) G_GNUC_CONST;
GtkCssStyle * gtk_css_static_style_get_default (void);
GtkCssStyle * gtk_css_static_style_new_compute (GtkStyleProvider *provider,
const GtkCssMatcher *matcher,
GtkCssStyle *parent,
GtkCssChange change);
void gtk_css_static_style_compute_value (GtkCssStaticStyle *style,
GtkStyleProvider *provider,
GtkCssStyle *parent_style,
guint id,
GtkCssValue *specified,
GtkCssSection *section);
GtkCssChange gtk_css_static_style_get_change (GtkCssStaticStyle *style);
GtkCssStyle * gtk_css_static_style_new_compute (GtkStyleProvider *provider,
const GtkCountingBloomFilter *filter,
GtkCssNode *node,
GtkCssChange change);
GtkCssChange gtk_css_static_style_get_change (GtkCssStaticStyle *style);
G_END_DECLS
+327 -30
View File
@@ -54,9 +54,34 @@ gtk_css_style_real_is_static (GtkCssStyle *style)
return TRUE;
}
static void
gtk_css_style_finalize (GObject *object)
{
GtkCssStyle *style = GTK_CSS_STYLE (object);
gtk_css_values_unref ((GtkCssValues *)style->core);
gtk_css_values_unref ((GtkCssValues *)style->background);
gtk_css_values_unref ((GtkCssValues *)style->border);
gtk_css_values_unref ((GtkCssValues *)style->icon);
gtk_css_values_unref ((GtkCssValues *)style->outline);
gtk_css_values_unref ((GtkCssValues *)style->font);
gtk_css_values_unref ((GtkCssValues *)style->font_variant);
gtk_css_values_unref ((GtkCssValues *)style->animation);
gtk_css_values_unref ((GtkCssValues *)style->transition);
gtk_css_values_unref ((GtkCssValues *)style->size);
gtk_css_values_unref ((GtkCssValues *)style->other);
G_OBJECT_CLASS (gtk_css_style_parent_class)->finalize (object);
}
static void
gtk_css_style_class_init (GtkCssStyleClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gtk_css_style_finalize;
klass->get_section = gtk_css_style_real_get_section;
klass->is_static = gtk_css_style_real_is_static;
}
@@ -68,9 +93,202 @@ gtk_css_style_init (GtkCssStyle *style)
GtkCssValue *
gtk_css_style_get_value (GtkCssStyle *style,
guint id)
guint id)
{
return GTK_CSS_STYLE_GET_CLASS (style)->get_value (style, id);
switch (id)
{
case GTK_CSS_PROPERTY_COLOR:
return style->core->color;
case GTK_CSS_PROPERTY_DPI:
return style->core->dpi;
case GTK_CSS_PROPERTY_FONT_SIZE:
return style->core->font_size;
case GTK_CSS_PROPERTY_ICON_THEME:
return style->core->icon_theme;
case GTK_CSS_PROPERTY_ICON_PALETTE:
return style->core->icon_palette;
case GTK_CSS_PROPERTY_BACKGROUND_COLOR:
return style->background->background_color;
case GTK_CSS_PROPERTY_FONT_FAMILY:
return style->font->font_family;
case GTK_CSS_PROPERTY_FONT_STYLE:
return style->font->font_style;
case GTK_CSS_PROPERTY_FONT_WEIGHT:
return style->font->font_weight;
case GTK_CSS_PROPERTY_FONT_STRETCH:
return style->font->font_stretch;
case GTK_CSS_PROPERTY_LETTER_SPACING:
return style->font->letter_spacing;
case GTK_CSS_PROPERTY_TEXT_DECORATION_LINE:
return style->font_variant->text_decoration_line;
case GTK_CSS_PROPERTY_TEXT_DECORATION_COLOR:
return style->font_variant->text_decoration_color ? style->font_variant->text_decoration_color : style->core->color;
case GTK_CSS_PROPERTY_TEXT_DECORATION_STYLE:
return style->font_variant->text_decoration_style;
case GTK_CSS_PROPERTY_FONT_KERNING:
return style->font_variant->font_kerning;
case GTK_CSS_PROPERTY_FONT_VARIANT_LIGATURES:
return style->font_variant->font_variant_ligatures;
case GTK_CSS_PROPERTY_FONT_VARIANT_POSITION:
return style->font_variant->font_variant_position;
case GTK_CSS_PROPERTY_FONT_VARIANT_CAPS:
return style->font_variant->font_variant_caps;
case GTK_CSS_PROPERTY_FONT_VARIANT_NUMERIC:
return style->font_variant->font_variant_numeric;
case GTK_CSS_PROPERTY_FONT_VARIANT_ALTERNATES:
return style->font_variant->font_variant_alternates;
case GTK_CSS_PROPERTY_FONT_VARIANT_EAST_ASIAN:
return style->font_variant->font_variant_east_asian;
case GTK_CSS_PROPERTY_TEXT_SHADOW:
return style->font->text_shadow;
case GTK_CSS_PROPERTY_BOX_SHADOW:
return style->background->box_shadow;
case GTK_CSS_PROPERTY_MARGIN_TOP:
return style->size->margin_top;
case GTK_CSS_PROPERTY_MARGIN_LEFT:
return style->size->margin_left;
case GTK_CSS_PROPERTY_MARGIN_BOTTOM:
return style->size->margin_bottom;
case GTK_CSS_PROPERTY_MARGIN_RIGHT:
return style->size->margin_right;
case GTK_CSS_PROPERTY_PADDING_TOP:
return style->size->padding_top;
case GTK_CSS_PROPERTY_PADDING_LEFT:
return style->size->padding_left;
case GTK_CSS_PROPERTY_PADDING_BOTTOM:
return style->size->padding_bottom;
case GTK_CSS_PROPERTY_PADDING_RIGHT:
return style->size->padding_right;
case GTK_CSS_PROPERTY_BORDER_TOP_STYLE:
return style->border->border_top_style;
case GTK_CSS_PROPERTY_BORDER_TOP_WIDTH:
return style->border->border_top_width;
case GTK_CSS_PROPERTY_BORDER_LEFT_STYLE:
return style->border->border_left_style;
case GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH:
return style->border->border_left_width;
case GTK_CSS_PROPERTY_BORDER_BOTTOM_STYLE:
return style->border->border_bottom_style;
case GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH:
return style->border->border_bottom_width;
case GTK_CSS_PROPERTY_BORDER_RIGHT_STYLE:
return style->border->border_right_style;
case GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH:
return style->border->border_right_width;
case GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS:
return style->border->border_top_left_radius;
case GTK_CSS_PROPERTY_BORDER_TOP_RIGHT_RADIUS:
return style->border->border_top_right_radius;
case GTK_CSS_PROPERTY_BORDER_BOTTOM_RIGHT_RADIUS:
return style->border->border_bottom_right_radius;
case GTK_CSS_PROPERTY_BORDER_BOTTOM_LEFT_RADIUS:
return style->border->border_bottom_left_radius;
case GTK_CSS_PROPERTY_OUTLINE_STYLE:
return style->outline->outline_style;
case GTK_CSS_PROPERTY_OUTLINE_WIDTH:
return style->outline->outline_width;
case GTK_CSS_PROPERTY_OUTLINE_OFFSET:
return style->outline->outline_offset;
case GTK_CSS_PROPERTY_OUTLINE_TOP_LEFT_RADIUS:
return style->outline->outline_top_left_radius;
case GTK_CSS_PROPERTY_OUTLINE_TOP_RIGHT_RADIUS:
return style->outline->outline_top_right_radius;
case GTK_CSS_PROPERTY_OUTLINE_BOTTOM_RIGHT_RADIUS:
return style->outline->outline_bottom_right_radius;
case GTK_CSS_PROPERTY_OUTLINE_BOTTOM_LEFT_RADIUS:
return style->outline->outline_bottom_left_radius;
case GTK_CSS_PROPERTY_BACKGROUND_CLIP:
return style->background->background_clip;
case GTK_CSS_PROPERTY_BACKGROUND_ORIGIN:
return style->background->background_origin;
case GTK_CSS_PROPERTY_BACKGROUND_SIZE:
return style->background->background_size;
case GTK_CSS_PROPERTY_BACKGROUND_POSITION:
return style->background->background_position;
case GTK_CSS_PROPERTY_BORDER_TOP_COLOR:
return style->border->border_top_color ? style->border->border_top_color : style->core->color;
case GTK_CSS_PROPERTY_BORDER_RIGHT_COLOR:
return style->border->border_right_color ? style->border->border_right_color : style->core->color;
case GTK_CSS_PROPERTY_BORDER_BOTTOM_COLOR:
return style->border->border_bottom_color ? style->border->border_bottom_color : style->core->color;
case GTK_CSS_PROPERTY_BORDER_LEFT_COLOR:
return style->border->border_left_color ? style->border->border_left_color: style->core->color;
case GTK_CSS_PROPERTY_OUTLINE_COLOR:
return style->outline->outline_color ? style->outline->outline_color : style->core->color;
case GTK_CSS_PROPERTY_BACKGROUND_REPEAT:
return style->background->background_repeat;
case GTK_CSS_PROPERTY_BACKGROUND_IMAGE:
return style->background->background_image;
case GTK_CSS_PROPERTY_BACKGROUND_BLEND_MODE:
return style->background->background_blend_mode;
case GTK_CSS_PROPERTY_BORDER_IMAGE_SOURCE:
return style->border->border_image_source;
case GTK_CSS_PROPERTY_BORDER_IMAGE_REPEAT:
return style->border->border_image_repeat;
case GTK_CSS_PROPERTY_BORDER_IMAGE_SLICE:
return style->border->border_image_slice;
case GTK_CSS_PROPERTY_BORDER_IMAGE_WIDTH:
return style->border->border_image_width;
case GTK_CSS_PROPERTY_ICON_SOURCE:
return style->other->icon_source;
case GTK_CSS_PROPERTY_ICON_SIZE:
return style->icon->icon_size;
case GTK_CSS_PROPERTY_ICON_SHADOW:
return style->icon->icon_shadow;
case GTK_CSS_PROPERTY_ICON_STYLE:
return style->icon->icon_style;
case GTK_CSS_PROPERTY_ICON_TRANSFORM:
return style->other->icon_transform;
case GTK_CSS_PROPERTY_ICON_FILTER:
return style->other->icon_filter;
case GTK_CSS_PROPERTY_BORDER_SPACING:
return style->size->border_spacing;
case GTK_CSS_PROPERTY_TRANSFORM:
return style->other->transform;
case GTK_CSS_PROPERTY_MIN_WIDTH:
return style->size->min_width;
case GTK_CSS_PROPERTY_MIN_HEIGHT:
return style->size->min_height;
case GTK_CSS_PROPERTY_TRANSITION_PROPERTY:
return style->transition->transition_property;
case GTK_CSS_PROPERTY_TRANSITION_DURATION:
return style->transition->transition_duration;
case GTK_CSS_PROPERTY_TRANSITION_TIMING_FUNCTION:
return style->transition->transition_timing_function;
case GTK_CSS_PROPERTY_TRANSITION_DELAY:
return style->transition->transition_delay;
case GTK_CSS_PROPERTY_ANIMATION_NAME:
return style->animation->animation_name;
case GTK_CSS_PROPERTY_ANIMATION_DURATION:
return style->animation->animation_duration;
case GTK_CSS_PROPERTY_ANIMATION_TIMING_FUNCTION:
return style->animation->animation_timing_function;
case GTK_CSS_PROPERTY_ANIMATION_ITERATION_COUNT:
return style->animation->animation_iteration_count;
case GTK_CSS_PROPERTY_ANIMATION_DIRECTION:
return style->animation->animation_direction;
case GTK_CSS_PROPERTY_ANIMATION_PLAY_STATE:
return style->animation->animation_play_state;
case GTK_CSS_PROPERTY_ANIMATION_DELAY:
return style->animation->animation_delay;
case GTK_CSS_PROPERTY_ANIMATION_FILL_MODE:
return style->animation->animation_fill_mode;
case GTK_CSS_PROPERTY_OPACITY:
return style->other->opacity;
case GTK_CSS_PROPERTY_FILTER:
return style->other->filter;
case GTK_CSS_PROPERTY_CARET_COLOR:
return style->font->caret_color ? style->font->caret_color : style->core->color;
case GTK_CSS_PROPERTY_SECONDARY_CARET_COLOR:
return style->font->secondary_caret_color ? style->font->secondary_caret_color : style->core->color;
case GTK_CSS_PROPERTY_FONT_FEATURE_SETTINGS:
return style->font->font_feature_settings;
case GTK_CSS_PROPERTY_FONT_VARIATION_SETTINGS:
return style->font->font_variation_settings;
default:
g_assert_not_reached ();
}
}
GtkCssSection *
@@ -218,7 +436,6 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
const GdkRGBA *color;
const GdkRGBA *decoration_color;
gint letter_spacing;
GtkCssValue *value;
GtkCssFontVariantLigature ligatures;
GtkCssFontVariantNumeric numeric;
GtkCssFontVariantEastAsian east_asian;
@@ -226,10 +443,12 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
char *settings;
/* text-decoration */
decoration_line = _gtk_css_text_decoration_line_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_TEXT_DECORATION_LINE));
decoration_style = _gtk_css_text_decoration_style_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_TEXT_DECORATION_STYLE));
color = gtk_css_color_value_get_rgba (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_COLOR));
decoration_color = gtk_css_color_value_get_rgba (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_TEXT_DECORATION_COLOR));
decoration_line = _gtk_css_text_decoration_line_value_get (style->font_variant->text_decoration_line);
decoration_style = _gtk_css_text_decoration_style_value_get (style->font_variant->text_decoration_style);
color = gtk_css_color_value_get_rgba (style->core->color);
decoration_color = gtk_css_color_value_get_rgba (style->font_variant->text_decoration_color
? style->font_variant->text_decoration_color
: style->core->color);
switch (decoration_line)
{
@@ -253,7 +472,7 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
}
/* letter-spacing */
letter_spacing = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_LETTER_SPACING), 100);
letter_spacing = _gtk_css_number_value_get (style->font->letter_spacing, 100);
if (letter_spacing != 0)
{
attrs = add_pango_attr (attrs, pango_attr_letter_spacing_new (letter_spacing * PANGO_SCALE));
@@ -263,8 +482,7 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
s = g_string_new ("");
value = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_FONT_KERNING);
switch (_gtk_css_font_kerning_value_get (value))
switch (_gtk_css_font_kerning_value_get (style->font_variant->font_kerning))
{
case GTK_CSS_FONT_KERNING_NORMAL:
append_separated (s, "kern 1");
@@ -277,8 +495,7 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
break;
}
value = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_FONT_VARIANT_LIGATURES);
ligatures = _gtk_css_font_variant_ligature_value_get (value);
ligatures = _gtk_css_font_variant_ligature_value_get (style->font_variant->font_variant_ligatures);
if (ligatures == GTK_CSS_FONT_VARIANT_LIGATURE_NORMAL)
{
/* all defaults */
@@ -305,8 +522,7 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
append_separated (s, "calt 0");
}
value = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_FONT_VARIANT_POSITION);
switch (_gtk_css_font_variant_position_value_get (value))
switch (_gtk_css_font_variant_position_value_get (style->font_variant->font_variant_position))
{
case GTK_CSS_FONT_VARIANT_POSITION_SUB:
append_separated (s, "subs 1");
@@ -319,8 +535,7 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
break;
}
value = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_FONT_VARIANT_CAPS);
switch (_gtk_css_font_variant_caps_value_get (value))
switch (_gtk_css_font_variant_caps_value_get (style->font_variant->font_variant_caps))
{
case GTK_CSS_FONT_VARIANT_CAPS_SMALL_CAPS:
append_separated (s, "smcp 1");
@@ -345,8 +560,7 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
break;
}
value = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_FONT_VARIANT_NUMERIC);
numeric = _gtk_css_font_variant_numeric_value_get (value);
numeric = _gtk_css_font_variant_numeric_value_get (style->font_variant->font_variant_numeric);
if (numeric == GTK_CSS_FONT_VARIANT_NUMERIC_NORMAL)
{
/* all defaults */
@@ -371,8 +585,7 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
append_separated (s, "zero 1");
}
value = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_FONT_VARIANT_ALTERNATES);
switch (_gtk_css_font_variant_alternate_value_get (value))
switch (_gtk_css_font_variant_alternate_value_get (style->font_variant->font_variant_alternates))
{
case GTK_CSS_FONT_VARIANT_ALTERNATE_HISTORICAL_FORMS:
append_separated (s, "hist 1");
@@ -382,8 +595,7 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
break;
}
value = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_FONT_VARIANT_EAST_ASIAN);
east_asian = _gtk_css_font_variant_east_asian_value_get (value);
east_asian = _gtk_css_font_variant_east_asian_value_get (style->font_variant->font_variant_east_asian);
if (east_asian == GTK_CSS_FONT_VARIANT_EAST_ASIAN_NORMAL)
{
/* all defaults */
@@ -410,8 +622,7 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
append_separated (s, "ruby 1");
}
value = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_FONT_FEATURE_SETTINGS);
settings = gtk_css_font_features_value_get_features (value);
settings = gtk_css_font_features_value_get_features (style->font->font_feature_settings);
if (settings)
{
append_separated (s, settings);
@@ -433,7 +644,7 @@ gtk_css_style_get_pango_font (GtkCssStyle *style)
description = pango_font_description_new ();
v = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_FONT_FAMILY);
v = style->font->font_family;
if (_gtk_css_array_value_get_n_values (v) > 1)
{
int i;
@@ -455,22 +666,108 @@ gtk_css_style_get_pango_font (GtkCssStyle *style)
_gtk_css_string_value_get (_gtk_css_array_value_get_nth (v, 0)));
}
v = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_FONT_SIZE);
v = style->core->font_size;
pango_font_description_set_absolute_size (description, round (_gtk_css_number_value_get (v, 100) * PANGO_SCALE));
v = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_FONT_STYLE);
v = style->font->font_style;
pango_font_description_set_style (description, _gtk_css_font_style_value_get (v));
v = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_FONT_WEIGHT);
v = style->font->font_weight;
pango_font_description_set_weight (description, _gtk_css_number_value_get (v, 100));
v = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_FONT_STRETCH);
v = style->font->font_stretch;
pango_font_description_set_stretch (description, _gtk_css_font_stretch_value_get (v));
v = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_FONT_VARIATION_SETTINGS);
v = style->font->font_variation_settings;
str = gtk_css_font_variations_value_get_variations (v);
pango_font_description_set_variations (description, str);
g_free (str);
return description;
}
/* Refcounted value structs */
static int values_size[] = {
sizeof (GtkCssCoreValues),
sizeof (GtkCssBackgroundValues),
sizeof (GtkCssBorderValues),
sizeof (GtkCssIconValues),
sizeof (GtkCssOutlineValues),
sizeof (GtkCssFontValues),
sizeof (GtkCssFontVariantValues),
sizeof (GtkCssAnimationValues),
sizeof (GtkCssTransitionValues),
sizeof (GtkCssSizeValues),
sizeof (GtkCssOtherValues)
};
#define N_VALUES(type) ((values_size[type] - sizeof (GtkCssValues)) / sizeof (GtkCssValue *))
#define GET_VALUES(v) (GtkCssValue **)((guint8 *)(v) + sizeof (GtkCssValues))
GtkCssValues *gtk_css_values_ref (GtkCssValues *values)
{
values->ref_count++;
return values;
}
static void
gtk_css_values_free (GtkCssValues *values)
{
int i;
GtkCssValue **v = GET_VALUES (values);
for (i = 0; i < N_VALUES (values->type); i++)
{
if (v[i])
gtk_css_value_unref (v[i]);
}
g_free (values);
}
void gtk_css_values_unref (GtkCssValues *values)
{
if (!values)
return;
values->ref_count--;
if (values->ref_count == 0)
gtk_css_values_free (values);
}
GtkCssValues *
gtk_css_values_copy (GtkCssValues *values)
{
GtkCssValues *copy;
GtkCssValue **v, **v2;
int i;
copy = gtk_css_values_new (values->type);
v = GET_VALUES (values);
v2 = GET_VALUES (copy);
for (i = 0; i < N_VALUES (values->type); i++)
{
if (v[i])
v2[i] = gtk_css_value_ref (v[i]);
}
return copy;
}
GtkCssValues *
gtk_css_values_new (GtkCssValuesType type)
{
GtkCssValues *values;
values = (GtkCssValues *)g_malloc0 (values_size[type]);
values->ref_count = 1;
values->type = type;
return values;
}
+64 -42
View File
@@ -21,6 +21,66 @@
#include "gtkcssstylepropertyprivate.h"
static void
compute_change (GtkCssStyleChange *change)
{
if (change->old_style->core != change->new_style->core)
gtk_css_core_values_compute_changes_and_affects (change->old_style,
change->new_style,
&change->changes,
&change->affects);
if (change->old_style->background != change->new_style->background)
gtk_css_background_values_compute_changes_and_affects (change->old_style,
change->new_style,
&change->changes,
&change->affects);
if (change->old_style->border != change->new_style->border)
gtk_css_border_values_compute_changes_and_affects (change->old_style,
change->new_style,
&change->changes,
&change->affects);
if (change->old_style->icon != change->new_style->icon)
gtk_css_icon_values_compute_changes_and_affects (change->old_style,
change->new_style,
&change->changes,
&change->affects);
if (change->old_style->outline != change->new_style->outline)
gtk_css_outline_values_compute_changes_and_affects (change->old_style,
change->new_style,
&change->changes,
&change->affects);
if (change->old_style->font != change->new_style->font)
gtk_css_font_values_compute_changes_and_affects (change->old_style,
change->new_style,
&change->changes,
&change->affects);
if (change->old_style->font_variant != change->new_style->font_variant)
gtk_css_font_variant_values_compute_changes_and_affects (change->old_style,
change->new_style,
&change->changes,
&change->affects);
if (change->old_style->animation != change->new_style->animation)
gtk_css_animation_values_compute_changes_and_affects (change->old_style,
change->new_style,
&change->changes,
&change->affects);
if (change->old_style->transition != change->new_style->transition)
gtk_css_transition_values_compute_changes_and_affects (change->old_style,
change->new_style,
&change->changes,
&change->affects);
if (change->old_style->size != change->new_style->size)
gtk_css_size_values_compute_changes_and_affects (change->old_style,
change->new_style,
&change->changes,
&change->affects);
if (change->old_style->other != change->new_style->other)
gtk_css_other_values_compute_changes_and_affects (change->old_style,
change->new_style,
&change->changes,
&change->affects);
}
void
gtk_css_style_change_init (GtkCssStyleChange *change,
GtkCssStyle *old_style,
@@ -29,14 +89,11 @@ gtk_css_style_change_init (GtkCssStyleChange *change,
change->old_style = g_object_ref (old_style);
change->new_style = g_object_ref (new_style);
change->n_compared = 0;
change->affects = 0;
change->changes = _gtk_bitmask_new ();
/* Make sure we don't do extra work if old and new are equal. */
if (old_style == new_style)
change->n_compared = GTK_CSS_PROPERTY_N_PROPERTIES;
if (old_style != new_style)
compute_change (change);
}
void
@@ -59,54 +116,23 @@ gtk_css_style_change_get_new_style (GtkCssStyleChange *change)
return change->new_style;
}
static gboolean
gtk_css_style_compare_next_value (GtkCssStyleChange *change)
{
if (change->n_compared == GTK_CSS_PROPERTY_N_PROPERTIES)
return FALSE;
if (!_gtk_css_value_equal (gtk_css_style_get_value (change->old_style, change->n_compared),
gtk_css_style_get_value (change->new_style, change->n_compared)))
{
change->affects |= _gtk_css_style_property_get_affects (_gtk_css_style_property_lookup_by_id (change->n_compared));
change->changes = _gtk_bitmask_set (change->changes, change->n_compared, TRUE);
}
change->n_compared++;
return TRUE;
}
gboolean
gtk_css_style_change_has_change (GtkCssStyleChange *change)
{
do {
if (!_gtk_bitmask_is_empty (change->changes))
return TRUE;
} while (gtk_css_style_compare_next_value (change));
return FALSE;
return !_gtk_bitmask_is_empty (change->changes);
}
gboolean
gtk_css_style_change_affects (GtkCssStyleChange *change,
GtkCssAffects affects)
{
do {
if (change->affects & affects)
return TRUE;
} while (gtk_css_style_compare_next_value (change));
return FALSE;
return (change->affects & affects) != 0;
}
gboolean
gtk_css_style_change_changes_property (GtkCssStyleChange *change,
guint id)
{
while (change->n_compared <= id)
gtk_css_style_compare_next_value (change);
return _gtk_bitmask_get (change->changes, id);
}
@@ -126,10 +152,6 @@ gtk_css_style_change_print (GtkCssStyleChange *change,
GtkCssValue *value;
const char *name;
if (_gtk_css_value_equal (gtk_css_style_get_value (change->old_style, i),
gtk_css_style_get_value (change->new_style, i)))
continue;
prop = _gtk_css_style_property_lookup_by_id (i);
name = _gtk_style_property_get_name (GTK_STYLE_PROPERTY (prop));
-2
View File
@@ -28,8 +28,6 @@ struct _GtkCssStyleChange {
GtkCssStyle *old_style;
GtkCssStyle *new_style;
guint n_compared;
GtkCssAffects affects;
GtkBitmask *changes;
};
+234 -3
View File
@@ -35,21 +35,201 @@ G_BEGIN_DECLS
#define GTK_IS_CSS_STYLE_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE (obj, GTK_TYPE_CSS_STYLE))
#define GTK_CSS_STYLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CSS_STYLE, GtkCssStyleClass))
typedef enum {
GTK_CSS_CORE_VALUES,
GTK_CSS_BACKGROUND_VALUES,
GTK_CSS_BORDER_VALUES,
GTK_CSS_ICON_VALUES,
GTK_CSS_OUTLINE_VALUES,
GTK_CSS_FONT_VALUES,
GTK_CSS_FONT_VARIANT_VALUES,
GTK_CSS_ANIMATION_VALUES,
GTK_CSS_TRANSITION_VALUES,
GTK_CSS_SIZE_VALUES,
GTK_CSS_OTHER_VALUES
} GtkCssValuesType;
typedef struct _GtkCssValues GtkCssValues;
typedef struct _GtkCssCoreValues GtkCssCoreValues;
typedef struct _GtkCssBackgroundValues GtkCssBackgroundValues;
typedef struct _GtkCssBorderValues GtkCssBorderValues;
typedef struct _GtkCssIconValues GtkCssIconValues;
typedef struct _GtkCssOutlineValues GtkCssOutlineValues;
typedef struct _GtkCssFontValues GtkCssFontValues;
typedef struct _GtkCssFontVariantValues GtkCssFontVariantValues;
typedef struct _GtkCssAnimationValues GtkCssAnimationValues;
typedef struct _GtkCssTransitionValues GtkCssTransitionValues;
typedef struct _GtkCssSizeValues GtkCssSizeValues;
typedef struct _GtkCssOtherValues GtkCssOtherValues;
struct _GtkCssValues {
int ref_count;
GtkCssValuesType type;
};
struct _GtkCssCoreValues {
GtkCssValues base;
GtkCssValue *color;
GtkCssValue *dpi;
GtkCssValue *font_size;
GtkCssValue *icon_theme;
GtkCssValue *icon_palette;
};
struct _GtkCssBackgroundValues {
GtkCssValues base;
GtkCssValue *background_color;
GtkCssValue *box_shadow;
GtkCssValue *background_clip;
GtkCssValue *background_origin;
GtkCssValue *background_size;
GtkCssValue *background_position;
GtkCssValue *background_repeat;
GtkCssValue *background_image;
GtkCssValue *background_blend_mode;
};
struct _GtkCssBorderValues {
GtkCssValues base;
GtkCssValue *border_top_style;
GtkCssValue *border_top_width;
GtkCssValue *border_left_style;
GtkCssValue *border_left_width;
GtkCssValue *border_bottom_style;
GtkCssValue *border_bottom_width;
GtkCssValue *border_right_style;
GtkCssValue *border_right_width;
GtkCssValue *border_top_left_radius;
GtkCssValue *border_top_right_radius;
GtkCssValue *border_bottom_right_radius;
GtkCssValue *border_bottom_left_radius;
GtkCssValue *border_top_color; // NULL if currentColor
GtkCssValue *border_right_color; // NULL if currentColor
GtkCssValue *border_bottom_color; // NULL if currentColor
GtkCssValue *border_left_color; // NULL if currentColor
GtkCssValue *border_image_source;
GtkCssValue *border_image_repeat;
GtkCssValue *border_image_slice;
GtkCssValue *border_image_width;
};
struct _GtkCssIconValues {
GtkCssValues base;
GtkCssValue *icon_size;
GtkCssValue *icon_shadow;
GtkCssValue *icon_style;
};
struct _GtkCssOutlineValues {
GtkCssValues base;
GtkCssValue *outline_style;
GtkCssValue *outline_width;
GtkCssValue *outline_offset;
GtkCssValue *outline_top_left_radius;
GtkCssValue *outline_top_right_radius;
GtkCssValue *outline_bottom_right_radius;
GtkCssValue *outline_bottom_left_radius;
GtkCssValue *outline_color;
};
struct _GtkCssFontValues {
GtkCssValues base;
GtkCssValue *font_family;
GtkCssValue *font_style;
GtkCssValue *font_weight;
GtkCssValue *font_stretch;
GtkCssValue *letter_spacing;
GtkCssValue *text_shadow;
GtkCssValue *caret_color; // NULL if currentColor
GtkCssValue *secondary_caret_color; // NULL if currentColor
GtkCssValue *font_feature_settings;
GtkCssValue *font_variation_settings;
};
struct _GtkCssFontVariantValues {
GtkCssValues base;
GtkCssValue *text_decoration_line;
GtkCssValue *text_decoration_color; // NULL if currentColor
GtkCssValue *text_decoration_style;
GtkCssValue *font_kerning;
GtkCssValue *font_variant_ligatures;
GtkCssValue *font_variant_position;
GtkCssValue *font_variant_caps;
GtkCssValue *font_variant_numeric;
GtkCssValue *font_variant_alternates;
GtkCssValue *font_variant_east_asian;
};
struct _GtkCssAnimationValues {
GtkCssValues base;
GtkCssValue *animation_name;
GtkCssValue *animation_duration;
GtkCssValue *animation_timing_function;
GtkCssValue *animation_iteration_count;
GtkCssValue *animation_direction;
GtkCssValue *animation_play_state;
GtkCssValue *animation_delay;
GtkCssValue *animation_fill_mode;
};
struct _GtkCssTransitionValues {
GtkCssValues base;
GtkCssValue *transition_property;
GtkCssValue *transition_duration;
GtkCssValue *transition_timing_function;
GtkCssValue *transition_delay;
};
struct _GtkCssSizeValues {
GtkCssValues base;
GtkCssValue *margin_top;
GtkCssValue *margin_left;
GtkCssValue *margin_bottom;
GtkCssValue *margin_right;
GtkCssValue *padding_top;
GtkCssValue *padding_left;
GtkCssValue *padding_bottom;
GtkCssValue *padding_right;
GtkCssValue *border_spacing;
GtkCssValue *min_width;
GtkCssValue *min_height;
};
struct _GtkCssOtherValues {
GtkCssValues base;
GtkCssValue *icon_source;
GtkCssValue *icon_transform;
GtkCssValue *icon_filter;
GtkCssValue *transform;
GtkCssValue *opacity;
GtkCssValue *filter;
};
/* typedef struct _GtkCssStyle GtkCssStyle; */
typedef struct _GtkCssStyleClass GtkCssStyleClass;
struct _GtkCssStyle
{
GObject parent;
GtkCssCoreValues *core;
GtkCssBackgroundValues *background;
GtkCssBorderValues *border;
GtkCssIconValues *icon;
GtkCssOutlineValues *outline;
GtkCssFontValues *font;
GtkCssFontVariantValues *font_variant;
GtkCssAnimationValues *animation;
GtkCssTransitionValues *transition;
GtkCssSizeValues *size;
GtkCssOtherValues *other;
};
struct _GtkCssStyleClass
{
GObjectClass parent_class;
/* Get the value for the given property id. This needs to be FAST. */
GtkCssValue * (* get_value) (GtkCssStyle *style,
guint id);
/* Get the section the value at the given id was declared at or NULL if unavailable.
* Optional: default impl will just return NULL */
GtkCssSection * (* get_section) (GtkCssStyle *style,
@@ -78,6 +258,57 @@ PangoAttrList * gtk_css_style_get_pango_attributes (GtkCssStyle
PangoFontDescription * gtk_css_style_get_pango_font (GtkCssStyle *style);
GtkCssStaticStyle * gtk_css_style_get_static_style (GtkCssStyle *style);
GtkCssValues *gtk_css_values_new (GtkCssValuesType type);
GtkCssValues *gtk_css_values_ref (GtkCssValues *values);
void gtk_css_values_unref (GtkCssValues *values);
GtkCssValues *gtk_css_values_copy (GtkCssValues *values);
void gtk_css_core_values_compute_changes_and_affects (GtkCssStyle *style1,
GtkCssStyle *style2,
GtkBitmask **changes,
GtkCssAffects *affects);
void gtk_css_background_values_compute_changes_and_affects (GtkCssStyle *style1,
GtkCssStyle *style2,
GtkBitmask **changes,
GtkCssAffects *affects);
void gtk_css_border_values_compute_changes_and_affects (GtkCssStyle *style1,
GtkCssStyle *style2,
GtkBitmask **changes,
GtkCssAffects *affects);
void gtk_css_icon_values_compute_changes_and_affects (GtkCssStyle *style1,
GtkCssStyle *style2,
GtkBitmask **changes,
GtkCssAffects *affects);
void gtk_css_outline_values_compute_changes_and_affects (GtkCssStyle *style1,
GtkCssStyle *style2,
GtkBitmask **changes,
GtkCssAffects *affects);
void gtk_css_font_values_compute_changes_and_affects (GtkCssStyle *style1,
GtkCssStyle *style2,
GtkBitmask **changes,
GtkCssAffects *affects);
void gtk_css_font_variant_values_compute_changes_and_affects (GtkCssStyle *style1,
GtkCssStyle *style2,
GtkBitmask **changes,
GtkCssAffects *affects);
void gtk_css_animation_values_compute_changes_and_affects (GtkCssStyle *style1,
GtkCssStyle *style2,
GtkBitmask **changes,
GtkCssAffects *affects);
void gtk_css_transition_values_compute_changes_and_affects (GtkCssStyle *style1,
GtkCssStyle *style2,
GtkBitmask **changes,
GtkCssAffects *affects);
void gtk_css_size_values_compute_changes_and_affects (GtkCssStyle *style1,
GtkCssStyle *style2,
GtkBitmask **changes,
GtkCssAffects *affects);
void gtk_css_other_values_compute_changes_and_affects (GtkCssStyle *style1,
GtkCssStyle *style2,
GtkBitmask **changes,
GtkCssAffects *affects);
G_END_DECLS
#endif /* __GTK_CSS_STYLE_PRIVATE_H__ */
-17
View File
@@ -120,22 +120,6 @@ gtk_css_style_property_get_property (GObject *object,
}
}
static void
_gtk_css_style_property_query (GtkStyleProperty *property,
GValue *value,
GtkStyleQueryFunc query_func,
gpointer query_data)
{
GtkCssStyleProperty *style_property = GTK_CSS_STYLE_PROPERTY (property);
GtkCssValue *css_value;
css_value = (* query_func) (GTK_CSS_STYLE_PROPERTY (property)->id, query_data);
if (css_value == NULL)
css_value =_gtk_css_style_property_get_initial_value (style_property);
style_property->query_value (style_property, css_value, value);
}
static GtkCssValue *
gtk_css_style_property_parse_value (GtkStyleProperty *property,
GtkCssParser *parser)
@@ -218,7 +202,6 @@ _gtk_css_style_property_class_init (GtkCssStylePropertyClass *klass)
GTK_TYPE_CSS_VALUE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
property_class->query = _gtk_css_style_property_query;
property_class->parse_value = gtk_css_style_property_parse_value;
klass->style_properties = g_ptr_array_new ();
-305
View File
@@ -69,21 +69,17 @@ typedef enum {
static void
gtk_css_style_property_register (const char * name,
guint expected_id,
GType value_type,
GtkStylePropertyFlags flags,
GtkCssAffects affects,
GtkCssStylePropertyParseFunc parse_value,
GtkCssStylePropertyQueryFunc query_value,
GtkCssValue * initial_value)
{
GtkCssStyleProperty *node;
g_assert (initial_value != NULL);
g_assert (parse_value != NULL);
g_assert (value_type == G_TYPE_NONE || query_value != NULL);
node = g_object_new (GTK_TYPE_CSS_STYLE_PROPERTY,
"value-type", value_type,
"affects", affects,
"animated", (flags & GTK_STYLE_PROPERTY_ANIMATED) ? TRUE : FALSE,
"inherit", (flags & GTK_STYLE_PROPERTY_INHERIT) ? TRUE : FALSE,
@@ -92,7 +88,6 @@ gtk_css_style_property_register (const char * name,
NULL);
node->parse_value = parse_value;
node->query_value = query_value;
_gtk_css_value_unref (initial_value);
@@ -101,41 +96,6 @@ gtk_css_style_property_register (const char * name,
/*** IMPLEMENTATIONS ***/
static void
query_length_as_int (GtkCssStyleProperty *property,
GtkCssValue *css_value,
GValue *value)
{
g_value_init (value, G_TYPE_INT);
g_value_set_int (value, round (_gtk_css_number_value_get (css_value, 100)));
}
static void
query_font_size (GtkCssStyleProperty *property,
GtkCssValue *css_value,
GValue *value)
{
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, _gtk_css_number_value_get (css_value, 100));
}
static void
query_border (GtkCssStyleProperty *property,
GtkCssValue *css_value,
GValue *value)
{
GtkBorder border;
g_value_init (value, GTK_TYPE_BORDER);
border.top = round (_gtk_css_number_value_get (_gtk_css_border_value_get_top (css_value), 100));
border.right = round (_gtk_css_number_value_get (_gtk_css_border_value_get_right (css_value), 100));
border.bottom = round (_gtk_css_number_value_get (_gtk_css_border_value_get_bottom (css_value), 100));
border.left = round (_gtk_css_number_value_get (_gtk_css_border_value_get_left (css_value), 100));
g_value_set_boxed (value, &border);
}
static GtkCssValue *
color_parse (GtkCssStyleProperty *property,
GtkCssParser *parser)
@@ -143,15 +103,6 @@ color_parse (GtkCssStyleProperty *property,
return _gtk_css_color_value_parse (parser);
}
static void
color_query (GtkCssStyleProperty *property,
GtkCssValue *css_value,
GValue *value)
{
g_value_init (value, GDK_TYPE_RGBA);
g_value_set_boxed (value, gtk_css_color_value_get_rgba (css_value));
}
static GtkCssValue *
font_family_parse_one (GtkCssParser *parser)
{
@@ -196,28 +147,6 @@ font_family_parse (GtkCssStyleProperty *property,
return gtk_css_font_family_value_parse (parser);
}
static void
font_family_query (GtkCssStyleProperty *property,
GtkCssValue *css_value,
GValue *value)
{
GPtrArray *array;
guint i;
array = g_ptr_array_new ();
for (i = 0; i < _gtk_css_array_value_get_n_values (css_value); i++)
{
g_ptr_array_add (array, g_strdup (_gtk_css_string_value_get (_gtk_css_array_value_get_nth (css_value, i))));
}
/* NULL-terminate */
g_ptr_array_add (array, NULL);
g_value_init (value, G_TYPE_STRV);
g_value_set_boxed (value, g_ptr_array_free (array, FALSE));
}
static GtkCssValue *
font_style_parse (GtkCssStyleProperty *property,
GtkCssParser *parser)
@@ -230,15 +159,6 @@ font_style_parse (GtkCssStyleProperty *property,
return value;
}
static void
font_style_query (GtkCssStyleProperty *property,
GtkCssValue *css_value,
GValue *value)
{
g_value_init (value, PANGO_TYPE_STYLE);
g_value_set_enum (value, _gtk_css_font_style_value_get (css_value));
}
static GtkCssValue *
font_weight_parse (GtkCssStyleProperty *property,
GtkCssParser *parser)
@@ -263,15 +183,6 @@ font_weight_parse (GtkCssStyleProperty *property,
return value;
}
static void
font_weight_query (GtkCssStyleProperty *property,
GtkCssValue *css_value,
GValue *value)
{
g_value_init (value, PANGO_TYPE_WEIGHT);
g_value_set_enum (value, _gtk_css_number_value_get (css_value, 100));
}
static GtkCssValue *
font_stretch_parse (GtkCssStyleProperty *property,
GtkCssParser *parser)
@@ -284,15 +195,6 @@ font_stretch_parse (GtkCssStyleProperty *property,
return value;
}
static void
font_stretch_query (GtkCssStyleProperty *property,
GtkCssValue *css_value,
GValue *value)
{
g_value_init (value, PANGO_TYPE_STRETCH);
g_value_set_enum (value, _gtk_css_font_stretch_value_get (css_value));
}
static GtkCssValue *
parse_border_style (GtkCssStyleProperty *property,
GtkCssParser *parser)
@@ -305,15 +207,6 @@ parse_border_style (GtkCssStyleProperty *property,
return value;
}
static void
query_border_style (GtkCssStyleProperty *property,
GtkCssValue *css_value,
GValue *value)
{
g_value_init (value, GTK_TYPE_BORDER_STYLE);
g_value_set_enum (value, _gtk_css_border_style_value_get (css_value));
}
static GtkCssValue *
parse_css_area_one (GtkCssParser *parser)
{
@@ -357,16 +250,6 @@ opacity_parse (GtkCssStyleProperty *property,
return _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_NUMBER);
}
static void
opacity_query (GtkCssStyleProperty *property,
GtkCssValue *css_value,
GValue *value)
{
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, _gtk_css_number_value_get (css_value, 100));
}
static GtkCssValue *
parse_one_css_play_state (GtkCssParser *parser)
{
@@ -933,43 +816,33 @@ _gtk_css_style_property_init_properties (void)
* sizes in em can be looked up properly */
gtk_css_style_property_register ("color",
GTK_CSS_PROPERTY_COLOR,
GDK_TYPE_RGBA,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_CONTENT | GTK_CSS_AFFECTS_ICON_REDRAW_SYMBOLIC,
color_parse,
color_query,
gtk_css_color_value_new_white ());
gtk_css_style_property_register ("-gtk-dpi",
GTK_CSS_PROPERTY_DPI,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_TEXT_SIZE,
dpi_parse,
NULL,
_gtk_css_number_value_new (96.0, GTK_CSS_NUMBER));
gtk_css_style_property_register ("font-size",
GTK_CSS_PROPERTY_FONT_SIZE,
G_TYPE_DOUBLE,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_TEXT_SIZE,
font_size_parse,
query_font_size,
_gtk_css_font_size_value_new (GTK_CSS_FONT_SIZE_MEDIUM));
gtk_css_style_property_register ("-gtk-icon-theme",
GTK_CSS_PROPERTY_ICON_THEME,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_INHERIT,
GTK_CSS_AFFECTS_ICON_TEXTURE,
icon_theme_value_parse,
NULL,
gtk_css_icon_theme_value_new (NULL));
gtk_css_style_property_register ("-gtk-icon-palette",
GTK_CSS_PROPERTY_ICON_PALETTE,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_INHERIT,
GTK_CSS_AFFECTS_ICON_REDRAW_SYMBOLIC,
icon_palette_parse,
NULL,
gtk_css_palette_value_new_default ());
@@ -977,514 +850,392 @@ _gtk_css_style_property_init_properties (void)
* start here */
gtk_css_style_property_register ("background-color",
GTK_CSS_PROPERTY_BACKGROUND_COLOR,
GDK_TYPE_RGBA,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_BACKGROUND,
color_parse,
color_query,
gtk_css_color_value_new_transparent ());
gtk_css_style_property_register ("font-family",
GTK_CSS_PROPERTY_FONT_FAMILY,
G_TYPE_STRV,
GTK_STYLE_PROPERTY_INHERIT,
GTK_CSS_AFFECTS_TEXT_SIZE,
font_family_parse,
font_family_query,
_gtk_css_string_value_new ("Sans"));
gtk_css_style_property_register ("font-style",
GTK_CSS_PROPERTY_FONT_STYLE,
PANGO_TYPE_STYLE,
GTK_STYLE_PROPERTY_INHERIT,
GTK_CSS_AFFECTS_TEXT_SIZE,
font_style_parse,
font_style_query,
_gtk_css_font_style_value_new (PANGO_STYLE_NORMAL));
gtk_css_style_property_register ("font-weight",
GTK_CSS_PROPERTY_FONT_WEIGHT,
PANGO_TYPE_WEIGHT,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_TEXT_SIZE,
font_weight_parse,
font_weight_query,
_gtk_css_number_value_new (PANGO_WEIGHT_NORMAL, GTK_CSS_NUMBER));
gtk_css_style_property_register ("font-stretch",
GTK_CSS_PROPERTY_FONT_STRETCH,
PANGO_TYPE_STRETCH,
GTK_STYLE_PROPERTY_INHERIT,
GTK_CSS_AFFECTS_TEXT_SIZE,
font_stretch_parse,
font_stretch_query,
_gtk_css_font_stretch_value_new (PANGO_STRETCH_NORMAL));
gtk_css_style_property_register ("letter-spacing",
GTK_CSS_PROPERTY_LETTER_SPACING,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_TEXT_ATTRS | GTK_CSS_AFFECTS_TEXT_SIZE,
parse_letter_spacing,
NULL,
_gtk_css_number_value_new (0.0, GTK_CSS_PX));
gtk_css_style_property_register ("text-decoration-line",
GTK_CSS_PROPERTY_TEXT_DECORATION_LINE,
G_TYPE_NONE,
0,
GTK_CSS_AFFECTS_TEXT_ATTRS,
parse_text_decoration_line,
NULL,
_gtk_css_text_decoration_line_value_new (GTK_CSS_TEXT_DECORATION_LINE_NONE));
gtk_css_style_property_register ("text-decoration-color",
GTK_CSS_PROPERTY_TEXT_DECORATION_COLOR,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_TEXT_ATTRS,
color_parse,
NULL,
_gtk_css_color_value_new_current_color ());
gtk_css_style_property_register ("text-decoration-style",
GTK_CSS_PROPERTY_TEXT_DECORATION_STYLE,
G_TYPE_NONE,
0,
GTK_CSS_AFFECTS_TEXT_ATTRS,
parse_text_decoration_style,
NULL,
_gtk_css_text_decoration_style_value_new (GTK_CSS_TEXT_DECORATION_STYLE_SOLID));
gtk_css_style_property_register ("font-kerning",
GTK_CSS_PROPERTY_FONT_KERNING,
G_TYPE_NONE,
0,
GTK_CSS_AFFECTS_TEXT_ATTRS | GTK_CSS_AFFECTS_TEXT_SIZE,
parse_font_kerning,
NULL,
_gtk_css_font_kerning_value_new (GTK_CSS_FONT_KERNING_AUTO));
gtk_css_style_property_register ("font-variant-ligatures",
GTK_CSS_PROPERTY_FONT_VARIANT_LIGATURES,
G_TYPE_NONE,
0,
GTK_CSS_AFFECTS_TEXT_ATTRS,
parse_font_variant_ligatures,
NULL,
_gtk_css_font_variant_ligature_value_new (GTK_CSS_FONT_VARIANT_LIGATURE_NORMAL));
gtk_css_style_property_register ("font-variant-position",
GTK_CSS_PROPERTY_FONT_VARIANT_POSITION,
G_TYPE_NONE,
0,
GTK_CSS_AFFECTS_TEXT_ATTRS,
parse_font_variant_position,
NULL,
_gtk_css_font_variant_position_value_new (GTK_CSS_FONT_VARIANT_POSITION_NORMAL));
gtk_css_style_property_register ("font-variant-caps",
GTK_CSS_PROPERTY_FONT_VARIANT_CAPS,
G_TYPE_NONE,
0,
GTK_CSS_AFFECTS_TEXT_ATTRS,
parse_font_variant_caps,
NULL,
_gtk_css_font_variant_caps_value_new (GTK_CSS_FONT_VARIANT_CAPS_NORMAL));
gtk_css_style_property_register ("font-variant-numeric",
GTK_CSS_PROPERTY_FONT_VARIANT_NUMERIC,
G_TYPE_NONE,
0,
GTK_CSS_AFFECTS_TEXT_ATTRS,
parse_font_variant_numeric,
NULL,
_gtk_css_font_variant_numeric_value_new (GTK_CSS_FONT_VARIANT_NUMERIC_NORMAL));
gtk_css_style_property_register ("font-variant-alternates",
GTK_CSS_PROPERTY_FONT_VARIANT_ALTERNATES,
G_TYPE_NONE,
0,
GTK_CSS_AFFECTS_TEXT_ATTRS,
parse_font_variant_alternates,
NULL,
_gtk_css_font_variant_alternate_value_new (GTK_CSS_FONT_VARIANT_ALTERNATE_NORMAL));
gtk_css_style_property_register ("font-variant-east-asian",
GTK_CSS_PROPERTY_FONT_VARIANT_EAST_ASIAN,
G_TYPE_NONE,
0,
GTK_CSS_AFFECTS_TEXT_ATTRS,
parse_font_variant_east_asian,
NULL,
_gtk_css_font_variant_east_asian_value_new (GTK_CSS_FONT_VARIANT_EAST_ASIAN_NORMAL));
gtk_css_style_property_register ("text-shadow",
GTK_CSS_PROPERTY_TEXT_SHADOW,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_TEXT_CONTENT,
shadow_value_parse,
NULL,
gtk_css_shadow_value_new_none ());
gtk_css_style_property_register ("box-shadow",
GTK_CSS_PROPERTY_BOX_SHADOW,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_BACKGROUND,
box_shadow_value_parse,
NULL,
gtk_css_shadow_value_new_none ());
gtk_css_style_property_register ("margin-top",
GTK_CSS_PROPERTY_MARGIN_TOP,
G_TYPE_INT,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_SIZE,
parse_margin,
query_length_as_int,
_gtk_css_number_value_new (0.0, GTK_CSS_PX));
gtk_css_style_property_register ("margin-left",
GTK_CSS_PROPERTY_MARGIN_LEFT,
G_TYPE_INT,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_SIZE,
parse_margin,
query_length_as_int,
_gtk_css_number_value_new (0.0, GTK_CSS_PX));
gtk_css_style_property_register ("margin-bottom",
GTK_CSS_PROPERTY_MARGIN_BOTTOM,
G_TYPE_INT,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_SIZE,
parse_margin,
query_length_as_int,
_gtk_css_number_value_new (0.0, GTK_CSS_PX));
gtk_css_style_property_register ("margin-right",
GTK_CSS_PROPERTY_MARGIN_RIGHT,
G_TYPE_INT,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_SIZE,
parse_margin,
query_length_as_int,
_gtk_css_number_value_new (0.0, GTK_CSS_PX));
gtk_css_style_property_register ("padding-top",
GTK_CSS_PROPERTY_PADDING_TOP,
G_TYPE_INT,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_SIZE,
parse_padding,
query_length_as_int,
_gtk_css_number_value_new (0.0, GTK_CSS_PX));
gtk_css_style_property_register ("padding-left",
GTK_CSS_PROPERTY_PADDING_LEFT,
G_TYPE_INT,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_SIZE,
parse_padding,
query_length_as_int,
_gtk_css_number_value_new (0.0, GTK_CSS_PX));
gtk_css_style_property_register ("padding-bottom",
GTK_CSS_PROPERTY_PADDING_BOTTOM,
G_TYPE_INT,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_SIZE,
parse_padding,
query_length_as_int,
_gtk_css_number_value_new (0.0, GTK_CSS_PX));
gtk_css_style_property_register ("padding-right",
GTK_CSS_PROPERTY_PADDING_RIGHT,
G_TYPE_INT,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_SIZE,
parse_padding,
query_length_as_int,
_gtk_css_number_value_new (0.0, GTK_CSS_PX));
/* IMPORTANT: the border-width properties must come after border-style properties,
* they depend on them for their value computation.
*/
gtk_css_style_property_register ("border-top-style",
GTK_CSS_PROPERTY_BORDER_TOP_STYLE,
GTK_TYPE_BORDER_STYLE,
0,
GTK_CSS_AFFECTS_BORDER,
parse_border_style,
query_border_style,
_gtk_css_border_style_value_new (GTK_BORDER_STYLE_NONE));
gtk_css_style_property_register ("border-top-width",
GTK_CSS_PROPERTY_BORDER_TOP_WIDTH,
G_TYPE_INT,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_BORDER | GTK_CSS_AFFECTS_SIZE,
parse_border_width,
query_length_as_int,
_gtk_css_number_value_new (0.0, GTK_CSS_PX));
gtk_css_style_property_register ("border-left-style",
GTK_CSS_PROPERTY_BORDER_LEFT_STYLE,
GTK_TYPE_BORDER_STYLE,
0,
GTK_CSS_AFFECTS_BORDER,
parse_border_style,
query_border_style,
_gtk_css_border_style_value_new (GTK_BORDER_STYLE_NONE));
gtk_css_style_property_register ("border-left-width",
GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH,
G_TYPE_INT,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_BORDER | GTK_CSS_AFFECTS_SIZE,
parse_border_width,
query_length_as_int,
_gtk_css_number_value_new (0.0, GTK_CSS_PX));
gtk_css_style_property_register ("border-bottom-style",
GTK_CSS_PROPERTY_BORDER_BOTTOM_STYLE,
GTK_TYPE_BORDER_STYLE,
0,
GTK_CSS_AFFECTS_BORDER,
parse_border_style,
query_border_style,
_gtk_css_border_style_value_new (GTK_BORDER_STYLE_NONE));
gtk_css_style_property_register ("border-bottom-width",
GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH,
G_TYPE_INT,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_BORDER | GTK_CSS_AFFECTS_SIZE,
parse_border_width,
query_length_as_int,
_gtk_css_number_value_new (0.0, GTK_CSS_PX));
gtk_css_style_property_register ("border-right-style",
GTK_CSS_PROPERTY_BORDER_RIGHT_STYLE,
GTK_TYPE_BORDER_STYLE,
0,
GTK_CSS_AFFECTS_BORDER,
parse_border_style,
query_border_style,
_gtk_css_border_style_value_new (GTK_BORDER_STYLE_NONE));
gtk_css_style_property_register ("border-right-width",
GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH,
G_TYPE_INT,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_BORDER | GTK_CSS_AFFECTS_SIZE,
parse_border_width,
query_length_as_int,
_gtk_css_number_value_new (0.0, GTK_CSS_PX));
gtk_css_style_property_register ("border-top-left-radius",
GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_BACKGROUND | GTK_CSS_AFFECTS_BORDER,
border_corner_radius_value_parse,
NULL,
_gtk_css_number_value_new (0, GTK_CSS_PX));
gtk_css_style_property_register ("border-top-right-radius",
GTK_CSS_PROPERTY_BORDER_TOP_RIGHT_RADIUS,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_BACKGROUND | GTK_CSS_AFFECTS_BORDER,
border_corner_radius_value_parse,
NULL,
_gtk_css_number_value_new (0, GTK_CSS_PX));
gtk_css_style_property_register ("border-bottom-right-radius",
GTK_CSS_PROPERTY_BORDER_BOTTOM_RIGHT_RADIUS,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_BACKGROUND | GTK_CSS_AFFECTS_BORDER,
border_corner_radius_value_parse,
NULL,
_gtk_css_number_value_new (0, GTK_CSS_PX));
gtk_css_style_property_register ("border-bottom-left-radius",
GTK_CSS_PROPERTY_BORDER_BOTTOM_LEFT_RADIUS,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_BACKGROUND | GTK_CSS_AFFECTS_BORDER,
border_corner_radius_value_parse,
NULL,
_gtk_css_number_value_new (0, GTK_CSS_PX));
gtk_css_style_property_register ("outline-style",
GTK_CSS_PROPERTY_OUTLINE_STYLE,
GTK_TYPE_BORDER_STYLE,
0,
GTK_CSS_AFFECTS_OUTLINE,
parse_border_style,
query_border_style,
_gtk_css_border_style_value_new (GTK_BORDER_STYLE_NONE));
gtk_css_style_property_register ("outline-width",
GTK_CSS_PROPERTY_OUTLINE_WIDTH,
G_TYPE_INT,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_OUTLINE,
parse_border_width,
query_length_as_int,
_gtk_css_number_value_new (0.0, GTK_CSS_PX));
gtk_css_style_property_register ("outline-offset",
GTK_CSS_PROPERTY_OUTLINE_OFFSET,
G_TYPE_INT,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_OUTLINE,
outline_parse,
query_length_as_int,
_gtk_css_number_value_new (0.0, GTK_CSS_PX));
gtk_css_style_property_register ("-gtk-outline-top-left-radius",
GTK_CSS_PROPERTY_OUTLINE_TOP_LEFT_RADIUS,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_OUTLINE,
border_corner_radius_value_parse,
NULL,
_gtk_css_number_value_new (0, GTK_CSS_PX));
gtk_css_style_property_register ("-gtk-outline-top-right-radius",
GTK_CSS_PROPERTY_OUTLINE_TOP_RIGHT_RADIUS,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_OUTLINE,
border_corner_radius_value_parse,
NULL,
_gtk_css_number_value_new (0, GTK_CSS_PX));
gtk_css_style_property_register ("-gtk-outline-bottom-right-radius",
GTK_CSS_PROPERTY_OUTLINE_BOTTOM_RIGHT_RADIUS,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_OUTLINE,
border_corner_radius_value_parse,
NULL,
_gtk_css_number_value_new (0, GTK_CSS_PX));
gtk_css_style_property_register ("-gtk-outline-bottom-left-radius",
GTK_CSS_PROPERTY_OUTLINE_BOTTOM_LEFT_RADIUS,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_OUTLINE,
border_corner_radius_value_parse,
NULL,
_gtk_css_number_value_new (0, GTK_CSS_PX));
gtk_css_style_property_register ("background-clip",
GTK_CSS_PROPERTY_BACKGROUND_CLIP,
G_TYPE_NONE,
0,
GTK_CSS_AFFECTS_BACKGROUND,
parse_css_area,
NULL,
_gtk_css_area_value_new (GTK_CSS_AREA_BORDER_BOX));
gtk_css_style_property_register ("background-origin",
GTK_CSS_PROPERTY_BACKGROUND_ORIGIN,
G_TYPE_NONE,
0,
GTK_CSS_AFFECTS_BACKGROUND,
parse_css_area,
NULL,
_gtk_css_area_value_new (GTK_CSS_AREA_PADDING_BOX));
gtk_css_style_property_register ("background-size",
GTK_CSS_PROPERTY_BACKGROUND_SIZE,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_BACKGROUND,
background_size_parse,
NULL,
_gtk_css_bg_size_value_new (NULL, NULL));
gtk_css_style_property_register ("background-position",
GTK_CSS_PROPERTY_BACKGROUND_POSITION,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_BACKGROUND,
background_position_parse,
NULL,
_gtk_css_position_value_new (_gtk_css_number_value_new (0, GTK_CSS_PERCENT),
_gtk_css_number_value_new (0, GTK_CSS_PERCENT)));
gtk_css_style_property_register ("border-top-color",
GTK_CSS_PROPERTY_BORDER_TOP_COLOR,
GDK_TYPE_RGBA,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_BORDER,
color_parse,
color_query,
_gtk_css_color_value_new_current_color ());
gtk_css_style_property_register ("border-right-color",
GTK_CSS_PROPERTY_BORDER_RIGHT_COLOR,
GDK_TYPE_RGBA,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_BORDER,
color_parse,
color_query,
_gtk_css_color_value_new_current_color ());
gtk_css_style_property_register ("border-bottom-color",
GTK_CSS_PROPERTY_BORDER_BOTTOM_COLOR,
GDK_TYPE_RGBA,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_BORDER,
color_parse,
color_query,
_gtk_css_color_value_new_current_color ());
gtk_css_style_property_register ("border-left-color",
GTK_CSS_PROPERTY_BORDER_LEFT_COLOR,
GDK_TYPE_RGBA,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_BORDER,
color_parse,
color_query,
_gtk_css_color_value_new_current_color ());
gtk_css_style_property_register ("outline-color",
GTK_CSS_PROPERTY_OUTLINE_COLOR,
GDK_TYPE_RGBA,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_OUTLINE,
color_parse,
color_query,
_gtk_css_color_value_new_current_color ());
gtk_css_style_property_register ("background-repeat",
GTK_CSS_PROPERTY_BACKGROUND_REPEAT,
G_TYPE_NONE,
0,
GTK_CSS_AFFECTS_BACKGROUND,
background_repeat_value_parse,
NULL,
_gtk_css_background_repeat_value_new (GTK_CSS_REPEAT_STYLE_REPEAT,
GTK_CSS_REPEAT_STYLE_REPEAT));
gtk_css_style_property_register ("background-image",
GTK_CSS_PROPERTY_BACKGROUND_IMAGE,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_BACKGROUND,
background_image_value_parse,
NULL,
_gtk_css_image_value_new (NULL));
gtk_css_style_property_register ("background-blend-mode",
GTK_CSS_PROPERTY_BACKGROUND_BLEND_MODE,
G_TYPE_NONE,
0,
GTK_CSS_AFFECTS_BACKGROUND,
blend_mode_value_parse,
NULL,
_gtk_css_blend_mode_value_new (GSK_BLEND_MODE_DEFAULT));
gtk_css_style_property_register ("border-image-source",
GTK_CSS_PROPERTY_BORDER_IMAGE_SOURCE,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_BORDER,
css_image_value_parse,
NULL,
_gtk_css_image_value_new (NULL));
gtk_css_style_property_register ("border-image-repeat",
GTK_CSS_PROPERTY_BORDER_IMAGE_REPEAT,
G_TYPE_NONE,
0,
GTK_CSS_AFFECTS_BORDER,
border_image_repeat_parse,
NULL,
_gtk_css_border_repeat_value_new (GTK_CSS_REPEAT_STYLE_STRETCH,
GTK_CSS_REPEAT_STYLE_STRETCH));
gtk_css_style_property_register ("border-image-slice",
GTK_CSS_PROPERTY_BORDER_IMAGE_SLICE,
GTK_TYPE_BORDER,
0,
GTK_CSS_AFFECTS_BORDER,
border_image_slice_parse,
query_border,
_gtk_css_border_value_new (_gtk_css_number_value_new (100, GTK_CSS_PERCENT),
_gtk_css_number_value_new (100, GTK_CSS_PERCENT),
_gtk_css_number_value_new (100, GTK_CSS_PERCENT),
_gtk_css_number_value_new (100, GTK_CSS_PERCENT)));
gtk_css_style_property_register ("border-image-width",
GTK_CSS_PROPERTY_BORDER_IMAGE_WIDTH,
GTK_TYPE_BORDER,
0,
GTK_CSS_AFFECTS_BORDER,
border_image_width_parse,
query_border,
_gtk_css_border_value_new (_gtk_css_number_value_new (1, GTK_CSS_NUMBER),
_gtk_css_number_value_new (1, GTK_CSS_NUMBER),
_gtk_css_number_value_new (1, GTK_CSS_NUMBER),
@@ -1492,232 +1243,176 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("-gtk-icon-source",
GTK_CSS_PROPERTY_ICON_SOURCE,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_ICON_TEXTURE,
css_image_value_parse,
NULL,
_gtk_css_image_value_new (NULL));
gtk_css_style_property_register ("-gtk-icon-size",
GTK_CSS_PROPERTY_ICON_SIZE,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_ICON_SIZE,
icon_size_parse,
NULL,
_gtk_css_number_value_new (16, GTK_CSS_PX));
gtk_css_style_property_register ("-gtk-icon-shadow",
GTK_CSS_PROPERTY_ICON_SHADOW,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_ICON_REDRAW,
shadow_value_parse,
NULL,
gtk_css_shadow_value_new_none ());
gtk_css_style_property_register ("-gtk-icon-style",
GTK_CSS_PROPERTY_ICON_STYLE,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_INHERIT,
GTK_CSS_AFFECTS_ICON_TEXTURE,
icon_style_parse,
NULL,
_gtk_css_icon_style_value_new (GTK_CSS_ICON_STYLE_REQUESTED));
gtk_css_style_property_register ("-gtk-icon-transform",
GTK_CSS_PROPERTY_ICON_TRANSFORM,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_CONTENT,
transform_value_parse,
NULL,
_gtk_css_transform_value_new_none ());
gtk_css_style_property_register ("-gtk-icon-filter",
GTK_CSS_PROPERTY_ICON_FILTER,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_CONTENT,
filter_value_parse,
NULL,
gtk_css_filter_value_new_none ());
gtk_css_style_property_register ("border-spacing",
GTK_CSS_PROPERTY_BORDER_SPACING,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_SIZE,
border_spacing_value_parse,
NULL,
_gtk_css_position_value_new (_gtk_css_number_value_new (0, GTK_CSS_PX),
_gtk_css_number_value_new (0, GTK_CSS_PX)));
gtk_css_style_property_register ("transform",
GTK_CSS_PROPERTY_TRANSFORM,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_TRANSFORM,
transform_value_parse,
NULL,
_gtk_css_transform_value_new_none ());
gtk_css_style_property_register ("min-width",
GTK_CSS_PROPERTY_MIN_WIDTH,
G_TYPE_INT,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_SIZE,
minmax_parse,
query_length_as_int,
_gtk_css_number_value_new (0, GTK_CSS_PX));
gtk_css_style_property_register ("min-height",
GTK_CSS_PROPERTY_MIN_HEIGHT,
G_TYPE_INT,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_SIZE,
minmax_parse,
query_length_as_int,
_gtk_css_number_value_new (0, GTK_CSS_PX));
gtk_css_style_property_register ("transition-property",
GTK_CSS_PROPERTY_TRANSITION_PROPERTY,
G_TYPE_NONE,
0,
0,
transition_property_parse,
NULL,
_gtk_css_ident_value_new ("all"));
gtk_css_style_property_register ("transition-duration",
GTK_CSS_PROPERTY_TRANSITION_DURATION,
G_TYPE_NONE,
0,
0,
transition_time_parse,
NULL,
_gtk_css_number_value_new (0, GTK_CSS_S));
gtk_css_style_property_register ("transition-timing-function",
GTK_CSS_PROPERTY_TRANSITION_TIMING_FUNCTION,
G_TYPE_NONE,
0,
0,
transition_timing_function_parse,
NULL,
_gtk_css_ease_value_new_cubic_bezier (0.25, 0.1, 0.25, 1.0));
gtk_css_style_property_register ("transition-delay",
GTK_CSS_PROPERTY_TRANSITION_DELAY,
G_TYPE_NONE,
0,
0,
transition_time_parse,
NULL,
_gtk_css_number_value_new (0, GTK_CSS_S));
gtk_css_style_property_register ("animation-name",
GTK_CSS_PROPERTY_ANIMATION_NAME,
G_TYPE_NONE,
0,
0,
transition_property_parse,
NULL,
_gtk_css_ident_value_new ("none"));
gtk_css_style_property_register ("animation-duration",
GTK_CSS_PROPERTY_ANIMATION_DURATION,
G_TYPE_NONE,
0,
0,
transition_time_parse,
NULL,
_gtk_css_number_value_new (0, GTK_CSS_S));
gtk_css_style_property_register ("animation-timing-function",
GTK_CSS_PROPERTY_ANIMATION_TIMING_FUNCTION,
G_TYPE_NONE,
0,
0,
transition_timing_function_parse,
NULL,
_gtk_css_ease_value_new_cubic_bezier (0.25, 0.1, 0.25, 1.0));
gtk_css_style_property_register ("animation-iteration-count",
GTK_CSS_PROPERTY_ANIMATION_ITERATION_COUNT,
G_TYPE_NONE,
0,
0,
iteration_count_parse,
NULL,
_gtk_css_number_value_new (1, GTK_CSS_NUMBER));
gtk_css_style_property_register ("animation-direction",
GTK_CSS_PROPERTY_ANIMATION_DIRECTION,
G_TYPE_NONE,
0,
0,
parse_css_direction,
NULL,
_gtk_css_direction_value_new (GTK_CSS_DIRECTION_NORMAL));
gtk_css_style_property_register ("animation-play-state",
GTK_CSS_PROPERTY_ANIMATION_PLAY_STATE,
G_TYPE_NONE,
0,
0,
parse_css_play_state,
NULL,
_gtk_css_play_state_value_new (GTK_CSS_PLAY_STATE_RUNNING));
gtk_css_style_property_register ("animation-delay",
GTK_CSS_PROPERTY_ANIMATION_DELAY,
G_TYPE_NONE,
0,
0,
transition_time_parse,
NULL,
_gtk_css_number_value_new (0, GTK_CSS_S));
gtk_css_style_property_register ("animation-fill-mode",
GTK_CSS_PROPERTY_ANIMATION_FILL_MODE,
G_TYPE_NONE,
0,
0,
parse_css_fill_mode,
NULL,
_gtk_css_fill_mode_value_new (GTK_CSS_FILL_NONE));
gtk_css_style_property_register ("opacity",
GTK_CSS_PROPERTY_OPACITY,
G_TYPE_DOUBLE,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_POSTEFFECT,
opacity_parse,
opacity_query,
_gtk_css_number_value_new (1, GTK_CSS_NUMBER));
gtk_css_style_property_register ("filter",
GTK_CSS_PROPERTY_FILTER,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_POSTEFFECT,
filter_value_parse,
NULL,
gtk_css_filter_value_new_none ());
gtk_css_style_property_register ("caret-color",
GTK_CSS_PROPERTY_CARET_COLOR,
GDK_TYPE_RGBA,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_CONTENT,
color_parse,
color_query,
_gtk_css_color_value_new_current_color ());
gtk_css_style_property_register ("-gtk-secondary-caret-color",
GTK_CSS_PROPERTY_SECONDARY_CARET_COLOR,
GDK_TYPE_RGBA,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_CONTENT,
color_parse,
color_query,
_gtk_css_color_value_new_current_color ());
gtk_css_style_property_register ("font-feature-settings",
GTK_CSS_PROPERTY_FONT_FEATURE_SETTINGS,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_TEXT_ATTRS | GTK_CSS_AFFECTS_TEXT_SIZE,
parse_font_feature_settings,
NULL,
gtk_css_font_features_value_new_default ());
gtk_css_style_property_register ("font-variation-settings",
GTK_CSS_PROPERTY_FONT_VARIATION_SETTINGS,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_TEXT_ATTRS | GTK_CSS_AFFECTS_TEXT_SIZE,
parse_font_variation_settings,
NULL,
gtk_css_font_variations_value_new_default ());
}
+6 -5
View File
@@ -23,13 +23,14 @@
G_DEFINE_TYPE (GtkCssTransientNode, gtk_css_transient_node, GTK_TYPE_CSS_NODE)
static GtkCssStyle *
gtk_css_transient_node_update_style (GtkCssNode *cssnode,
GtkCssChange change,
gint64 timestamp,
GtkCssStyle *style)
gtk_css_transient_node_update_style (GtkCssNode *cssnode,
const GtkCountingBloomFilter *filter,
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);
return GTK_CSS_NODE_CLASS (gtk_css_transient_node_parent_class)->update_style (cssnode, filter, change, 0, style);
}
static void
+30
View File
@@ -257,3 +257,33 @@ gtk_css_change_to_string (GtkCssChange change)
return g_string_free (string, FALSE);
}
const gchar *
gtk_css_pseudoclass_name (GtkStateFlags state)
{
static const char * state_names[] = {
"active",
"hover",
"selected",
"disabled",
"indeterminate",
"focus",
"backdrop",
"dir(ltr)",
"dir(rtl)",
"link",
"visited",
"checked",
"drop(active)",
"focus(visible)"
};
guint i;
for (i = 0; i < G_N_ELEMENTS (state_names); i++)
{
if (state == (1 << i))
return state_names[i];
}
return NULL;
}
+30 -1
View File
@@ -21,9 +21,10 @@
#include <glib-object.h>
#include <gsk/gsk.h>
#include <gtk/gtkenums.h>
G_BEGIN_DECLS
typedef union _GtkCssMatcher GtkCssMatcher;
typedef struct _GtkCssNode GtkCssNode;
typedef struct _GtkCssNodeDeclaration GtkCssNodeDeclaration;
typedef struct _GtkCssStyle GtkCssStyle;
@@ -456,6 +457,34 @@ char * gtk_css_change_to_string (GtkCssChange
void gtk_css_change_print (GtkCssChange change,
GString *string);
const char * gtk_css_pseudoclass_name (GtkStateFlags flags);
/* These hash functions are selected so they achieve 2 things:
* 1. collision free among each other
* Hashing the CSS selectors "button", ".button" and "#button" should give different results.
* So we multiply the hash values with distinct prime numbers.
* 2. generate small numbers
* It's why the code uses quarks instead of interned strings. Interned strings are random
* pointers, quarks are numbers increasing from 0.
* Both of these goals should achieve a bloom filter for selector matching that is as free
* of collisions as possible.
*/
static inline guint
gtk_css_hash_class (GQuark klass)
{
return klass * 5;
}
static inline guint
gtk_css_hash_name (GQuark name)
{
return name * 7;
}
static inline guint
gtk_css_hash_id (GQuark id)
{
return id * 11;
}
G_END_DECLS
#endif /* __GTK_CSS_TYPES_PRIVATE_H__ */
-13
View File
@@ -107,18 +107,6 @@ gtk_css_widget_node_validate (GtkCssNode *node)
gtk_css_style_change_finish (&change);
}
static 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;
return GTK_CSS_NODE_CLASS (gtk_css_widget_node_parent_class)->init_matcher (node, matcher);
}
static GtkStyleProvider *
gtk_css_widget_node_get_style_provider (GtkCssNode *node)
{
@@ -162,7 +150,6 @@ gtk_css_widget_node_class_init (GtkCssWidgetNodeClass *klass)
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->get_style_provider = gtk_css_widget_node_get_style_provider;
node_class->get_frame_clock = gtk_css_widget_node_get_frame_clock;
}
+6 -6
View File
@@ -113,12 +113,12 @@ gtk_drag_icon_native_get_surface_transform (GtkNative *native,
GtkCssStyle *style;
style = gtk_css_node_get_style (gtk_widget_get_css_node (GTK_WIDGET (native)));
*x = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_MARGIN_LEFT), 100) +
_gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH), 100) +
_gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_PADDING_LEFT), 100);
*y = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_MARGIN_TOP), 100) +
_gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_TOP_WIDTH), 100) +
_gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_PADDING_TOP), 100);
*x = _gtk_css_number_value_get (style->size->margin_left, 100) +
_gtk_css_number_value_get (style->border->border_left_width, 100) +
_gtk_css_number_value_get (style->size->padding_left, 100);
*y = _gtk_css_number_value_get (style->size->margin_top, 100) +
_gtk_css_number_value_get (style->border->border_top_width, 100) +
_gtk_css_number_value_get (style->size->padding_top, 100);
}
static void
+2 -2
View File
@@ -484,9 +484,9 @@ gtk_drag_source_drag_begin (GtkDragSource *source)
if (!source->paintable)
{
GtkIconTheme *theme;
theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (widget));
source->paintable = gtk_icon_theme_load_icon (theme, "text-x-generic", 32, 0, NULL);
source->paintable = GDK_PAINTABLE(gtk_icon_theme_lookup_icon (theme, "text-x-generic", 32, 1, 0));
source->hot_x = 0;
source->hot_y = 0;
}
+7
View File
@@ -129,6 +129,13 @@ update_focus (GtkEventControllerKey *key,
{
key->is_focus = is_focus;
g_object_notify (G_OBJECT (key), "is-focus");
if (key->im_context)
{
if (focus_in)
gtk_im_context_focus_in (key->im_context);
else
gtk_im_context_focus_out (key->im_context);
}
}
if (key->contains_focus != contains_focus)
{
+2 -2
View File
@@ -116,7 +116,7 @@
#include "gtkbuildable.h"
#include "gtkcontainerprivate.h"
#include "gtkdragdest.h"
#include "gtkiconprivate.h"
#include "gtkbuiltiniconprivate.h"
#include "gtkgestureclick.h"
#include "gtkgesturesingle.h"
#include "gtkintl.h"
@@ -369,7 +369,7 @@ gtk_expander_init (GtkExpander *expander)
NULL);
gtk_container_add (GTK_CONTAINER (priv->box), priv->title_widget);
priv->arrow_widget = gtk_icon_new ("expander");
priv->arrow_widget = gtk_builtin_icon_new ("expander");
gtk_style_context_add_class (gtk_widget_get_style_context (priv->arrow_widget),
GTK_STYLE_CLASS_HORIZONTAL);
gtk_container_add (GTK_CONTAINER (priv->title_widget), priv->arrow_widget);
+19 -29
View File
@@ -240,6 +240,7 @@ static void gtk_file_chooser_dialog_get_property (GObject *obj
static void gtk_file_chooser_dialog_notify (GObject *object,
GParamSpec *pspec);
static void gtk_file_chooser_dialog_realize (GtkWidget *widget);
static void gtk_file_chooser_dialog_map (GtkWidget *widget);
static void gtk_file_chooser_dialog_unmap (GtkWidget *widget);
static void gtk_file_chooser_dialog_size_allocate (GtkWidget *widget,
@@ -248,8 +249,6 @@ static void gtk_file_chooser_dialog_size_allocate (GtkWidget *wid
int baseline);
static void file_chooser_widget_file_activated (GtkFileChooser *chooser,
GtkFileChooserDialog *dialog);
static void file_chooser_widget_default_size_changed (GtkWidget *widget,
GtkFileChooserDialog *dialog);
static void file_chooser_widget_response_requested (GtkWidget *widget,
GtkFileChooserDialog *dialog);
static void file_chooser_widget_selection_changed (GtkWidget *widget,
@@ -275,6 +274,7 @@ gtk_file_chooser_dialog_class_init (GtkFileChooserDialogClass *class)
gobject_class->get_property = gtk_file_chooser_dialog_get_property;
gobject_class->notify = gtk_file_chooser_dialog_notify;
widget_class->realize = gtk_file_chooser_dialog_realize;
widget_class->map = gtk_file_chooser_dialog_map;
widget_class->unmap = gtk_file_chooser_dialog_unmap;
widget_class->size_allocate = gtk_file_chooser_dialog_size_allocate;
@@ -292,7 +292,6 @@ gtk_file_chooser_dialog_class_init (GtkFileChooserDialogClass *class)
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserDialog, buttons);
gtk_widget_class_bind_template_callback (widget_class, response_cb);
gtk_widget_class_bind_template_callback (widget_class, file_chooser_widget_file_activated);
gtk_widget_class_bind_template_callback (widget_class, file_chooser_widget_default_size_changed);
gtk_widget_class_bind_template_callback (widget_class, file_chooser_widget_response_requested);
gtk_widget_class_bind_template_callback (widget_class, file_chooser_widget_selection_changed);
}
@@ -357,32 +356,6 @@ file_chooser_widget_file_activated (GtkFileChooser *chooser,
gtk_widget_activate_default (GTK_WIDGET (chooser));
}
static void
file_chooser_widget_default_size_changed (GtkWidget *widget,
GtkFileChooserDialog *dialog)
{
GtkFileChooserDialogPrivate *priv = gtk_file_chooser_dialog_get_instance_private (dialog);
gint default_width, default_height;
GtkRequisition req, widget_req;
/* Unset any previously set size */
gtk_widget_set_size_request (GTK_WIDGET (dialog), -1, -1);
if (gtk_widget_is_drawable (widget))
{
/* Force a size request of everything before we start. This will make sure
* that widget->requisition is meaningful.
*/
gtk_widget_get_preferred_size (GTK_WIDGET (dialog), &req, NULL);
gtk_widget_get_preferred_size (widget, &widget_req, NULL);
}
_gtk_file_chooser_embed_get_default_size (GTK_FILE_CHOOSER_EMBED (priv->widget),
&default_width, &default_height);
gtk_window_resize (GTK_WINDOW (dialog), default_width, default_height);
}
static void
file_chooser_widget_selection_changed (GtkWidget *widget,
GtkFileChooserDialog *dialog)
@@ -562,6 +535,23 @@ ensure_default_response (GtkFileChooserDialog *dialog)
gtk_window_set_default_widget (GTK_WINDOW (dialog), widget);
}
static void
gtk_file_chooser_dialog_realize (GtkWidget *widget)
{
GtkFileChooserDialog *dialog = GTK_FILE_CHOOSER_DIALOG (widget);
GSettings *settings;
gint width, height;
settings = _gtk_file_chooser_get_settings_for_widget (widget);
g_settings_get (settings, SETTINGS_KEY_WINDOW_SIZE, "(ii)", &width, &height);
if (width != 0 && height != 0)
gtk_window_set_default_size (GTK_WINDOW (dialog), width, height);
g_print ("%d %d\n", width, height);
GTK_WIDGET_CLASS (gtk_file_chooser_dialog_parent_class)->realize (widget);
}
static void
gtk_file_chooser_dialog_map (GtkWidget *widget)
{
-42
View File
@@ -22,13 +22,8 @@
#include "gtkintl.h"
static void gtk_file_chooser_embed_class_init (gpointer g_iface);
static void delegate_get_default_size (GtkFileChooserEmbed *chooser_embed,
gint *default_width,
gint *default_height);
static gboolean delegate_should_respond (GtkFileChooserEmbed *chooser_embed);
static void delegate_initial_focus (GtkFileChooserEmbed *chooser_embed);
static void delegate_default_size_changed (GtkFileChooserEmbed *chooser_embed,
gpointer data);
static void delegate_response_requested (GtkFileChooserEmbed *chooser_embed,
gpointer data);
@@ -50,7 +45,6 @@ get_delegate (GtkFileChooserEmbed *receiver)
void
_gtk_file_chooser_embed_delegate_iface_init (GtkFileChooserEmbedIface *iface)
{
iface->get_default_size = delegate_get_default_size;
iface->should_respond = delegate_should_respond;
iface->initial_focus = delegate_initial_focus;
}
@@ -74,22 +68,12 @@ _gtk_file_chooser_embed_set_delegate (GtkFileChooserEmbed *receiver,
g_object_set_data (G_OBJECT (receiver), I_("gtk-file-chooser-embed-delegate"), delegate);
g_signal_connect (delegate, "default-size-changed",
G_CALLBACK (delegate_default_size_changed), receiver);
g_signal_connect (delegate, "response-requested",
G_CALLBACK (delegate_response_requested), receiver);
}
static void
delegate_get_default_size (GtkFileChooserEmbed *chooser_embed,
gint *default_width,
gint *default_height)
{
_gtk_file_chooser_embed_get_default_size (get_delegate (chooser_embed), default_width, default_height);
}
static gboolean
delegate_should_respond (GtkFileChooserEmbed *chooser_embed)
{
@@ -102,13 +86,6 @@ delegate_initial_focus (GtkFileChooserEmbed *chooser_embed)
_gtk_file_chooser_embed_initial_focus (get_delegate (chooser_embed));
}
static void
delegate_default_size_changed (GtkFileChooserEmbed *chooser_embed,
gpointer data)
{
g_signal_emit_by_name (data, "default-size-changed");
}
static void
delegate_response_requested (GtkFileChooserEmbed *chooser_embed,
gpointer data)
@@ -149,13 +126,6 @@ gtk_file_chooser_embed_class_init (gpointer g_iface)
{
GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
g_signal_new (I_("default-size-changed"),
iface_type,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkFileChooserEmbedIface, default_size_changed),
NULL, NULL,
NULL,
G_TYPE_NONE, 0);
g_signal_new (I_("response-requested"),
iface_type,
G_SIGNAL_RUN_LAST,
@@ -165,18 +135,6 @@ gtk_file_chooser_embed_class_init (gpointer g_iface)
G_TYPE_NONE, 0);
}
void
_gtk_file_chooser_embed_get_default_size (GtkFileChooserEmbed *chooser_embed,
gint *default_width,
gint *default_height)
{
g_return_if_fail (GTK_IS_FILE_CHOOSER_EMBED (chooser_embed));
g_return_if_fail (default_width != NULL);
g_return_if_fail (default_height != NULL);
GTK_FILE_CHOOSER_EMBED_GET_IFACE (chooser_embed)->get_default_size (chooser_embed, default_width, default_height);
}
gboolean
_gtk_file_chooser_embed_should_respond (GtkFileChooserEmbed *chooser_embed)
{
-8
View File
@@ -38,24 +38,16 @@ struct _GtkFileChooserEmbedIface
/* Methods
*/
void (*get_default_size) (GtkFileChooserEmbed *chooser_embed,
gint *default_width,
gint *default_height);
gboolean (*should_respond) (GtkFileChooserEmbed *chooser_embed);
void (*initial_focus) (GtkFileChooserEmbed *chooser_embed);
/* Signals
*/
void (*default_size_changed) (GtkFileChooserEmbed *chooser_embed);
void (*response_requested) (GtkFileChooserEmbed *chooser_embed);
};
GType _gtk_file_chooser_embed_get_type (void) G_GNUC_CONST;
void _gtk_file_chooser_embed_get_default_size (GtkFileChooserEmbed *chooser_embed,
gint *default_width,
gint *default_height);
gboolean _gtk_file_chooser_embed_should_respond (GtkFileChooserEmbed *chooser_embed);
void _gtk_file_chooser_embed_initial_focus (GtkFileChooserEmbed *chooser_embed);
+1 -101
View File
@@ -83,6 +83,7 @@
#include "gtkentryprivate.h"
#include "gtkroot.h"
#include "gtkbinlayout.h"
#include "gtkwidgetprivate.h"
#include <cairo-gobject.h>
@@ -475,7 +476,6 @@ static void gtk_file_chooser_widget_get_property (GObject *obj
GValue *value,
GParamSpec *pspec);
static void gtk_file_chooser_widget_dispose (GObject *object);
static void gtk_file_chooser_widget_realize (GtkWidget *widget);
static void gtk_file_chooser_widget_map (GtkWidget *widget);
static void gtk_file_chooser_widget_unmap (GtkWidget *widget);
static void gtk_file_chooser_widget_root (GtkWidget *widget);
@@ -517,9 +517,6 @@ static gboolean gtk_file_chooser_widget_remove_shortcut_folder (GtkFileCho
GError **error);
static GSList * gtk_file_chooser_widget_list_shortcut_folders (GtkFileChooser *chooser);
static void gtk_file_chooser_widget_get_default_size (GtkFileChooserEmbed *chooser_embed,
gint *default_width,
gint *default_height);
static gboolean gtk_file_chooser_widget_should_respond (GtkFileChooserEmbed *chooser_embed);
static void gtk_file_chooser_widget_initial_focus (GtkFileChooserEmbed *chooser_embed);
@@ -659,7 +656,6 @@ gtk_file_chooser_widget_iface_init (GtkFileChooserIface *iface)
static void
gtk_file_chooser_embed_default_iface_init (GtkFileChooserEmbedIface *iface)
{
iface->get_default_size = gtk_file_chooser_widget_get_default_size;
iface->should_respond = gtk_file_chooser_widget_should_respond;
iface->initial_focus = gtk_file_chooser_widget_initial_focus;
}
@@ -944,14 +940,6 @@ change_folder_and_display_error (GtkFileChooserWidget *impl,
return result;
}
static void
emit_default_size_changed (GtkFileChooserWidget *impl)
{
profile_msg (" emit default-size-changed start", NULL);
g_signal_emit_by_name (impl, "default-size-changed");
profile_msg (" emit default-size-changed end", NULL);
}
static void
update_preview_widget_visibility (GtkFileChooserWidget *impl)
{
@@ -979,9 +967,6 @@ update_preview_widget_visibility (GtkFileChooserWidget *impl)
gtk_widget_show (priv->preview_box);
else
gtk_widget_hide (priv->preview_box);
if (!gtk_widget_get_mapped (GTK_WIDGET (impl)))
emit_default_size_changed (impl);
}
static void
@@ -3225,8 +3210,6 @@ update_appearance (GtkFileChooserWidget *impl)
* of files may change depending whether we are in a file or folder-only mode.
*/
gtk_widget_queue_draw (priv->browse_files_tree_view);
emit_default_size_changed (impl);
}
static gchar *
@@ -3678,8 +3661,6 @@ gtk_file_chooser_widget_style_updated (GtkWidget *widget)
change_icon_theme (impl);
emit_default_size_changed (impl);
profile_end ("end", NULL);
}
@@ -3788,19 +3769,6 @@ settings_save (GtkFileChooserWidget *impl)
g_settings_apply (settings);
}
/* GtkWidget::realize method */
static void
gtk_file_chooser_widget_realize (GtkWidget *widget)
{
GtkFileChooserWidget *impl;
impl = GTK_FILE_CHOOSER_WIDGET (widget);
GTK_WIDGET_CLASS (gtk_file_chooser_widget_parent_class)->realize (widget);
emit_default_size_changed (impl);
}
/* Changes the current folder to $CWD */
static void
switch_to_cwd (GtkFileChooserWidget *impl)
@@ -6172,73 +6140,6 @@ gtk_file_chooser_widget_list_shortcut_folders (GtkFileChooser *chooser)
return gtk_places_sidebar_list_shortcuts (GTK_PLACES_SIDEBAR (priv->places_sidebar));
}
/* Guesses a size based upon font sizes */
static void
find_good_size_from_style (GtkWidget *widget,
gint *width,
gint *height)
{
GtkStyleContext *context;
double font_size;
double resolution;
context = gtk_widget_get_style_context (widget);
resolution = _gtk_css_number_value_get (_gtk_style_context_peek_property (context,
GTK_CSS_PROPERTY_DPI),
100);
gtk_style_context_get (context,
"font-size", &font_size,
NULL);
font_size = font_size * resolution / 72.0 + 0.5;
*width = font_size * NUM_CHARS;
*height = font_size * NUM_LINES;
}
static void
gtk_file_chooser_widget_get_default_size (GtkFileChooserEmbed *chooser_embed,
gint *default_width,
gint *default_height)
{
GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (chooser_embed);
GtkFileChooserWidgetPrivate *priv = gtk_file_chooser_widget_get_instance_private (impl);
GtkRequisition req;
int width, height;
GSettings *settings;
settings = _gtk_file_chooser_get_settings_for_widget (GTK_WIDGET (impl));
g_settings_get (settings, SETTINGS_KEY_WINDOW_SIZE, "(ii)", &width, &height);
if (width > 0 && height > 0)
{
*default_width = width;
*default_height = height;
return;
}
find_good_size_from_style (GTK_WIDGET (chooser_embed), default_width, default_height);
if (priv->preview_widget_active &&
priv->preview_widget &&
gtk_widget_get_visible (priv->preview_widget))
{
gtk_widget_get_preferred_size (priv->preview_box,
&req, NULL);
*default_width += PREVIEW_HBOX_SPACING + req.width;
}
if (priv->extra_widget &&
gtk_widget_get_visible (priv->extra_widget))
{
gtk_widget_get_preferred_size (priv->extra_align,
&req, NULL);
*default_height += gtk_box_get_spacing (GTK_BOX (priv->box)) + req.height;
}
}
struct switch_folder_closure {
GtkFileChooserWidget *impl;
GFile *file;
@@ -8040,7 +7941,6 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class)
gobject_class->get_property = gtk_file_chooser_widget_get_property;
gobject_class->dispose = gtk_file_chooser_widget_dispose;
widget_class->realize = gtk_file_chooser_widget_realize;
widget_class->map = gtk_file_chooser_widget_map;
widget_class->unmap = gtk_file_chooser_widget_unmap;
widget_class->root = gtk_file_chooser_widget_root;
+4 -4
View File
@@ -80,6 +80,7 @@
#include "gtkadjustment.h"
#include "gtkbindings.h"
#include "gtkcontainerprivate.h"
#include "gtkcsscolorvalueprivate.h"
#include "gtkcssnodeprivate.h"
#include "gtkgesturedrag.h"
#include "gtkgestureclick.h"
@@ -2385,7 +2386,7 @@ gtk_flow_box_snapshot (GtkWidget *widget,
{
cairo_path_t *path;
GtkBorder border;
GdkRGBA *border_color;
const GdkRGBA *border_color;
if (vertical)
path_from_vertical_line_rects (cr, (GdkRectangle *)lines->data, lines->len);
@@ -2405,13 +2406,12 @@ gtk_flow_box_snapshot (GtkWidget *widget,
cairo_append_path (cr, path);
cairo_path_destroy (path);
gtk_style_context_get (context, "border-color", &border_color, NULL);
border_color = gtk_css_color_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_COLOR));
gtk_style_context_get_border (context, &border);
cairo_set_line_width (cr, border.left);
gdk_cairo_set_source_rgba (cr, border_color);
cairo_stroke (cr);
gdk_rgba_free (border_color);
}
g_array_free (lines, TRUE);
@@ -2607,7 +2607,7 @@ gtk_flow_box_drag_gesture_update (GtkGestureDrag *gesture,
widget_node = gtk_widget_get_css_node (GTK_WIDGET (box));
priv->rubberband_node = gtk_css_node_new ();
gtk_css_node_set_name (priv->rubberband_node, I_("rubberband"));
gtk_css_node_set_name (priv->rubberband_node, g_quark_from_static_string ("rubberband"));
gtk_css_node_set_parent (priv->rubberband_node, widget_node);
gtk_css_node_set_state (priv->rubberband_node, gtk_css_node_get_state (widget_node));
g_object_unref (priv->rubberband_node);
+5 -8
View File
@@ -1111,17 +1111,14 @@ gtk_font_chooser_widget_get_preview_text_height (GtkFontChooserWidget *fontchoos
GtkFontChooserWidgetPrivate *priv = gtk_font_chooser_widget_get_instance_private (fontchooser);
GtkWidget *treeview = priv->family_face_list;
GtkStyleContext *context;
double dpi, font_size;
double font_size;
context = gtk_widget_get_style_context (treeview);
dpi = _gtk_css_number_value_get (_gtk_style_context_peek_property (context,
GTK_CSS_PROPERTY_DPI),
100);
gtk_style_context_get (context,
"font-size", &font_size,
NULL);
font_size = _gtk_css_number_value_get (_gtk_style_context_peek_property (context,
GTK_CSS_PROPERTY_FONT_SIZE),
100);
return (dpi < 0.0 ? 96.0 : dpi) / 72.0 * PANGO_SCALE_X_LARGE * font_size * PANGO_SCALE;
return PANGO_SCALE_X_LARGE * font_size * PANGO_SCALE;
}
static PangoAttrList *

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