Compare commits

...

70 Commits

Author SHA1 Message Date
Matthias Clasen
f7a5cada1f css: Give each style its own variable set
gtk_css_style_print relies on this to limit printing of custom
variables to each styles' own variables. Without this, :root
variables get printed for every single style that doesn't define
its own.
2024-05-19 23:12:53 -04:00
Matthias Clasen
858a3cbde5 css: Don't leak variable sets
It is not clear that style->variables must be NULL at this point,
so clear it before overwriting it.
2024-05-19 23:12:53 -04:00
Balázs Úr
89b64cbf47 Update Hungarian translation 2024-05-19 23:47:50 +00:00
Matthias Clasen
d20e0b0370 Merge branch 'gtk-4-macos-dock-quit' into 'main'
[GTK 4] macOS: Dock "Quit" invokes "app.quit" action

See merge request GNOME/gtk!7265
2024-05-19 21:06:11 +00:00
Thomas Holder
f191fc0047 macOS: Dock "Quit" invokes "app.quit" action
Allows the application to handle "Dock icon > Quit" the same as
"Application menu > Quit".

Requires GtkApplication's `register-session` property.

Suitable replacement for gtk-mac-integration's
`NSApplicationBlockTermination` signal.
2024-05-19 23:10:31 +03:00
Matthias Clasen
af0c277bba Merge branch 'matthiasc/for-main' into 'main'
css: Lose more underscores

See merge request GNOME/gtk!7261
2024-05-19 05:14:05 +00:00
Matthias Clasen
970c9eef63 css: Use an anonymous union for color values
We already do this for number values, and it looks less messy.
2024-05-18 09:23:40 -04:00
Matthias Clasen
2439876bd3 css: Simplify color resolving a bit
We know the initial value of the color property, no need to
resolve it again.
2024-05-18 09:09:21 -04:00
Matthias Clasen
97582ae9ad css: Simplify color resolving
The cycle argument is purely a detail of the internal implementation,
no need to have it in the api.
2024-05-18 09:03:57 -04:00
Matthias Clasen
a5b85f0dc5 css: Lose more underscores
Drop the _ from the color value apis. Update all callers.
2024-05-18 08:59:24 -04:00
Matthias Clasen
aefb16510b Merge branch 'css-fiddling' into 'main'
css: Lose some underscores

See merge request GNOME/gtk!7255
2024-05-16 01:49:52 +00:00
Benjamin Otte
4360d433b5 Merge branch 'wip/otte/for-main' into 'main'
columnview: Actually check the listview in return_if_fail()

See merge request GNOME/gtk!7254
2024-05-16 01:30:20 +00:00
Matthias Clasen
5927319589 css: Inline a few functions
These are just operating on the value base and can easily be inlined.
2024-05-15 20:54:45 -04:00
Matthias Clasen
25db645f65 css: Lose some underscores
Drop the _ from all the gtk_css_value apis.
2024-05-15 20:54:43 -04:00
Benjamin Otte
b3c6a98132 vulkan: Add a missing extension
We need to enable this one, too.

Thanks validation layers!
2024-05-16 02:24:17 +02:00
Benjamin Otte
031109aec3 columnview: Actually check the listview in return_if_fail()
This was missed when adding return_if_fail()s in
172cdf8e21.

Related: !7240
2024-05-16 02:24:17 +02:00
Jordi Mas i Hernandez
18d2f9c8a4 Update Catalan translation
(cherry picked from commit 27d75be15e)
2024-05-15 19:53:58 +00:00
Jordi Mas i Hernandez
0ae721f144 Update Catalan translation
(cherry picked from commit 8ccc36c389)
2024-05-15 18:02:53 +00:00
Matthias Clasen
7898d1b46d Merge branch 'wip/sophie-h/print' into 'main'
printdialog: Fix some annotiations

Closes #6709

See merge request GNOME/gtk!7251
2024-05-14 20:51:54 +00:00
Sophie Herold
3648398f6d printsetup: Remove nullable from settings getters
GtkPrintSetup is initialized with the values returned from the portal.
Therefore the page setup and the print settings can never be NULL.
2024-05-14 22:21:19 +02:00
Sophie Herold
019916c5b9 printdialog: Remove nullable for GError functions
Functions that set a GError should not be marked as nullable if they
only return NULL on error.
2024-05-14 22:12:04 +02:00
Sophie Herold
ebb31590ae printdialog: Add missing nullable to getters
The initial values are NULL.
2024-05-14 22:10:29 +02:00
Benjamin Otte
32ea1cf32d Merge branch 'wip/kabus/scroll_to_null_tile' into 'main'
listbase: Fix a null dereference

See merge request GNOME/gtk!7240
2024-05-14 19:48:42 +00:00
Khalid Abu Shawarib
172cdf8e21 listbase: Return early on non-existent scroll position 2024-05-14 15:27:38 +03:00
Matthias Clasen
dc07bcf3a3 Merge branch 'michaelweghorn/a11y_atspi_map_level_property' into 'main'
a11y atspi: Map GTK_ACCESSIBLE_PROPERTY_LEVEL to AT-SPI attr

See merge request GNOME/gtk!6549
2024-05-13 16:02:53 +00:00
Matthias Clasen
bd96c10563 Merge branch 'matthiasc/for-main' into 'main'
testsuite: Improve test-css-parser

See merge request GNOME/gtk!7248
2024-05-13 14:57:15 +00:00
Matthias Clasen
76299396cf testsuite: Improve test-css-parser
Make it so that --generate parse produces output that can be
directly pasted into the ref.css file.
2024-05-13 10:04:28 -04:00
Ekaterine Papava
a96dd2ad0a Update Georgian translation 2024-05-13 00:45:14 +00:00
Matthias Clasen
1e210e83bb Merge branch 'structcleanup' into 'main'
gdk: Remove unused struct 'XPointerUngrabInfo'

See merge request GNOME/gtk!7245
2024-05-12 04:52:19 +00:00
Dr. David Alan Gilbert
14f1a91bff gdk: Remove unused struct 'XPointerUngrabInfo'
'XPointerUngrabInfo' appears unused since
commit 26cbf87d7d ("New approach for grab tracking code")
Remove it.

Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
2024-05-12 01:06:31 +01:00
Matthias Clasen
3f2bcdf82e Merge branch 'matthiasc/for-main' into 'main'
wayland: Tweak cursor sizing code

See merge request GNOME/gtk!7244
2024-05-11 03:40:53 +00:00
Matthias Clasen
c61d8bc188 wayland: Tweak cursor sizing code
We want to take advantage of a viewporter also for named cursors.
2024-05-10 23:10:50 -04:00
Matthias Clasen
4e5976427b NEWS: Updates 2024-05-10 21:47:44 -04:00
Matthias Clasen
7fcdb0205f Merge branch 'wip/alice/css-variables' into 'main'
CSS custom properties/variables

See merge request GNOME/gtk!6540
2024-05-11 01:38:10 +00:00
Benjamin Otte
4814c5f653 array: Don't overflow array size
Copy what gcc's libstdc++ does for vectors to avoid overflows:

1. Define a max size macro and assert against it
   Note that we don't assert but actually check, because this needs
   to abort even if assertions are disabled.
2. Don't do fancy math to compute new capacity.
   Just size *= 2 instead and be careful about overflow.
2024-05-10 21:22:03 -04:00
Alice Mikhaylenko
eb24e3548f inspector: Sort GTK CSS properties between standard and custom ones 2024-05-10 18:29:48 +04:00
Alice Mikhaylenko
87f0f374a9 inspector: Show custom properties for css nodes 2024-05-10 18:29:48 +04:00
Alice Mikhaylenko
0cd95951e6 testsuite: Add css variables tests 2024-05-10 18:29:48 +04:00
Matthias Clasen
c45815c217 css: Improve error reporting for variables
Emit errors for all the variables that were being expanded
if an error occurs while parsing a property value at compute time.

Include the variables that are being expanded in the error message.
2024-05-10 18:29:48 +04:00
Matthias Clasen
b914869715 css parser: Keep variables for tokenizers
Add a function that gets the names of the variables that the
parser is currently in the process of expanding. This will
be used for error reporting.
2024-05-10 18:29:48 +04:00
Matthias Clasen
ff5699e097 css parser: Inline the tokenizer array
This is in preparation of associating more data with the token streams.
2024-05-10 18:29:47 +04:00
Matthias Clasen
8846f85874 css provider: Set bytes on sections
Pass the bytes we're parsing to the sections, and keep a pointer
to them around, so we can compare them in the has_section
implementation.

This commit also corrects some of the location information that
we add into the section for variables to be more accurate.
2024-05-10 18:29:47 +04:00
Matthias Clasen
fc1c6cfb1a css parser: Add gtk_css_parser_get_bytes
Gets the bytes that the parser is operating on.
2024-05-10 18:29:47 +04:00
Matthias Clasen
77028362ab css provider: Set sections on all variable values
We were doing it in one case, but forgetting it in another.
These sections are necessary to report meaningful error locations
when parsing property values at compute time.
2024-05-10 18:29:47 +04:00
Matthias Clasen
496aee5b02 style cascade: Propagate errors
When we compute values, the provider we use ends up being the
style cascade. If we hit a parser error when parsing variable-bearing
property values at compute time, we emit the error on that provider.

By making the cascade propagate the error back to the proper css
provider that contains the section in question, we get it reported
back to the css editor in the inspector.
2024-05-10 18:29:47 +04:00
Matthias Clasen
b2fb624496 style provider: Add a has_section api
Add gtk_style_provider_has_section and implement it for
GtkCssProvider. This will be used later to direct error
emissions to the right provider.
2024-05-10 18:29:47 +04:00
Matthias Clasen
f2ef5d85ea css parser: Add bytes to sections
We will use this later to link sections back to the providers
they come from.
2024-05-10 18:29:47 +04:00
Matthias Clasen
7eca32edf0 css parser: Add gtk_css_parser_skip_whitespace
Does what it says.
2024-05-10 18:29:47 +04:00
Matthias Clasen
7775bcf2fb css: Don't accept junk
Check that there is no junk at the end of the property value
when parsing variable-bearing properties at compute time.
2024-05-10 18:29:47 +04:00
Alice Mikhaylenko
ed35f6f8b8 css: Condense compute parameters into GtkCssComputeContext
That list is getting out of hand, let's make it a struct.
2024-05-10 18:29:47 +04:00
Matthias Clasen
307942e1f7 css: Only compute shorthand values once
When computing a style, only compute the shorthand value once.
2024-05-10 18:29:47 +04:00
Alice Mikhaylenko
92b7231168 csskeyframes: Support variables 2024-05-10 18:29:47 +04:00
Alice Mikhaylenko
14d7eb97d2 cssanimation: Recompute values while playing
This will be necessary for supporting variables in animations.

For this we need to pass all the gtk_css_value_compute() parameters into
GtkCssAnimatedStyle: parent style and provider.
2024-05-10 18:29:47 +04:00
Alice Mikhaylenko
fed1c3d3fc cssstaticstyle: Split property lists into a separate header
We'll need to use them in GtkCssAnimatedStyle too.
2024-05-10 18:29:47 +04:00
Alice Mikhaylenko
e1ac97a185 cssvalue: Pass an extra GtkCssVariableSet to compute()
We'll need this to support variables in @keyframes, since styles will
need to combine their own variables and the ones from the keyframes.

See the next commit, this one is split out to avoid a huge diff.
2024-05-10 18:29:47 +04:00
Alice Mikhaylenko
08a48dd97e Implement basic support for CSS variables 2024-05-10 18:29:47 +04:00
Matthias Clasen
50df3ebb46 css: Give shorthand properties an ID
This will be used in future commits.
2024-05-10 18:29:47 +04:00
Alice Mikhaylenko
df77f22740 cssvalue: Add contains_variables()
We'll need this to know which values to recompute for animations.

It will be used in the next commit, it's separate to avoid the diff
being too large.
2024-05-10 18:29:47 +04:00
Alice Mikhaylenko
2437a551ec csstokenizer: Add save() and restore()
We'll need that to check if property values contain variables.
2024-05-10 18:29:47 +04:00
Alice Mikhaylenko
46ab71fc8a cssprovider: Copy bytes when loading
We'll need to keep accessing them later to compute values with variables,
so we can't avoid this anymore.
2024-05-10 18:29:47 +04:00
Matthias Clasen
f922ff8597 Merge branch 'speed-up-cairo-icons' into 'main'
gsk: Speed up mask nodes with cairo

Closes #6700

See merge request GNOME/gtk!7243
2024-05-10 14:10:18 +00:00
Matthias Clasen
690c06109e gsk: Speed up mask nodes with cairo
Switch symbolc icon drawing from color-matrix to mask nodes
make the performance of the iconscroll demo crater (from 60fps
to 10fps).

Apply the same optimization we already have for color-matrix
nodes when drawing mask nodes. This gets us back to 60fps.

Fixes: #6700
2024-05-10 07:24:25 -04:00
Matthias Clasen
94505987fe Merge branch 'matthiasc/for-main' into 'main'
css parser: Fix a typo

See merge request GNOME/gtk!7241
2024-05-10 04:11:08 +00:00
Matthias Clasen
c6d7b704cb css parser: Fix a typo
Due to an ARAY vs ARRAY mishap, we weren't actually preallocating
any blocks. Fix that, and reduce the number of preallocated blocks
to 12. That seems sufficient, since parsing the Default theme never
needs more than 5 blocks.
2024-05-09 23:26:55 -04:00
Hugo Carvalho
349509c332 Update Portuguese translation
(cherry picked from commit 40e99590e7)
2024-05-09 16:01:52 +00:00
Matthias Clasen
84fd420271 Merge branch '6674_fix_flickering_tooltip' into 'main'
tooltip: query tooltip on widget under pointer only

Closes #6674

See merge request GNOME/gtk!7237
2024-05-08 00:43:05 +00:00
Matthias Clasen
0c40defaf1 Merge branch 'realize_accessible_before_add_event_emission' into 'main'
a11y: Realize the AT context before firing a children added event for it

See merge request GNOME/gtk!7229
2024-05-08 00:42:33 +00:00
g.willems
d665274eb1 tooltip: query tooltip on widget under pointer only
When changing the tooltip text or markup of widget A, we simulate a
motion event on that widget to update the display.
But if there is an active tooltip on widget B, then the current code
belives we moved the pointer from B to A thus hides/shows the tooltip
of B alternatively.

Instead, simulate the motion event on the widget currently under the pointer.
This will avoid flickering if we keep the pointer over widget B.

Fixes #6674
Closes #6674
2024-05-07 19:32:15 +02:00
Lukáš Tyrychtr
81b6251073 a11y: Realize the AT context before firing a children added event for it
This allows, with some other changes, AdwToasts to be read on appearance by Orca.
2024-05-07 15:49:59 +02:00
Michael Weghorn
bcf78aeb39 a11y atspi: Map GTK_ACCESSIBLE_PROPERTY_LEVEL to AT-SPI attr
Map GTK_ACCESSIBLE_PROPERTY_LEVEL to the corresponding
AT-SPI object attribute "level", as it is specified
e.g. in the Core Accessibility Mappings 1.2 for the
"aria-level" attribute, for both, headings [1] and
non-headings [2].

This e.g. makes reporting the header level via
AT-SPI work for the gtk4-based LibreOffice variant
when combined with the corresponding LibreOffice
change [3] to set the GTK_ACCESSIBLE_PROPERTY_LEVEL
property.

For a related discussion, see issue #6196.

[1] https://www.w3.org/TR/core-aam-1.2/#ariaLevelHeading
[2] https://www.w3.org/TR/core-aam-1.2/#ariaLevel
[3] https://gerrit.libreoffice.org/c/core/+/159216
2023-11-09 17:21:00 +01:00
126 changed files with 6308 additions and 3256 deletions

7
NEWS
View File

@@ -6,6 +6,7 @@ Overview of Changes in 4.15.1, xx-xx-xxxx
* CSS:
- Support the :root selector
- Support variables and custom properties
* Icontheme:
- Make symbolic svg loading more efficient
@@ -14,19 +15,22 @@ Overview of Changes in 4.15.1, xx-xx-xxxx
* Accessibility:
- Make the gtk-demo sidebar search more accessible
- Stop emitting focus events
- Realize child contexts when necessary
* GDK:
- Support XDG_ACTIVATION_TOKEN
- dmabuf: Be more defensive when importing unknown formats to GL
- dmabuf: Use narrow range for YUV
- vulkan: Recreate swapchains when necessary or beneficial
* GSK:
- Improve logging for GDK_DEBUG=offload
- Improve logging for GSK_DEBUG=renderer
- gpu: Warn about inefficient texture import
- gpu: Handle tiny offscreens correctly
- gpu: Handle tiny offscreens correctly
- vulkan: Add profiler marks in various places
- vulkan: Fix a problem with imported dmabufs showing up black
- cairo: Speed up mask nodes, since we use them for symbolic icons
* Wayland:
- Use wl_compositor version 6
@@ -46,6 +50,7 @@ Overview of Changes in 4.15.1, xx-xx-xxxx
* Translation updates:
Korean
Portuguese
Turkish

View File

@@ -56,6 +56,30 @@ follows:
1 value:
: all
## Custom Properties
GTK supports custom properties as defined in the
[CSS Custom Properties for Cascading Variables](https://www.w3.org/TR/css-variables-1)
spec.
Custom properties are defined as follows:
```css
--prop: red;
```
and used via the `var` keyword:
```css
color: var(--prop);
```
Custom properties can have a fallback for when the referred property is invalid:
```css
color: var(--prop, green);
```
## Colors
GTK extends the CSS syntax with several additional ways to specify colors.

View File

@@ -41,8 +41,10 @@ G_BEGIN_DECLS
#ifdef GDK_ARRAY_NULL_TERMINATED
#define GDK_ARRAY_REAL_SIZE(_size) ((_size) + 1)
#define GDK_ARRAY_MAX_SIZE (G_MAXSIZE / sizeof (_T_) - 1)
#else
#define GDK_ARRAY_REAL_SIZE(_size) (_size)
#define GDK_ARRAY_MAX_SIZE (G_MAXSIZE / sizeof (_T_))
#endif
/* make this readable */
@@ -177,18 +179,23 @@ G_GNUC_UNUSED static inline void
gdk_array(reserve) (GdkArray *self,
gsize n)
{
gsize new_size, size;
gsize new_capacity, size, capacity;
if (n <= gdk_array(get_capacity) (self))
return;
if (G_UNLIKELY (n > GDK_ARRAY_MAX_SIZE))
g_error ("requesting array size of %zu, but maximum size is %zu", n, GDK_ARRAY_MAX_SIZE);
capacity = gdk_array(get_capacity) (self);
if (n <= capacity)
return;
size = gdk_array(get_size) (self);
new_size = ((gsize) 1) << g_bit_storage (MAX (GDK_ARRAY_REAL_SIZE (n), 16) - 1);
/* capacity * 2 can overflow, that's why we MAX() */
new_capacity = MAX (GDK_ARRAY_REAL_SIZE (n), capacity * 2);
#ifdef GDK_ARRAY_PREALLOC
if (self->start == self->preallocated)
{
self->start = g_new (_T_, new_size);
self->start = g_new (_T_, new_capacity);
memcpy (self->start, self->preallocated, sizeof (_T_) * GDK_ARRAY_REAL_SIZE (size));
}
else
@@ -196,15 +203,15 @@ gdk_array(reserve) (GdkArray *self,
#ifdef GDK_ARRAY_NULL_TERMINATED
if (self->start == NULL)
{
self->start = g_new (_T_, new_size);
self->start = g_new (_T_, new_capacity);
*self->start = *(_T_[1]) { 0 };
}
else
#endif
self->start = g_renew (_T_, self->start, new_size);
self->start = g_renew (_T_, self->start, new_capacity);
self->end = self->start + size;
self->end_allocation = self->start + new_size;
self->end_allocation = self->start + new_capacity;
#ifdef GDK_ARRAY_NULL_TERMINATED
self->end_allocation--;
#endif
@@ -312,6 +319,7 @@ gdk_array(get) (const GdkArray *self,
#undef gdk_array_paste
#undef gdk_array
#undef GDK_ARRAY_REAL_SIZE
#undef GDK_ARRAY_MAX_SIZE
#undef GDK_ARRAY_BY_VALUE
#undef GDK_ARRAY_ELEMENT_TYPE

View File

@@ -607,7 +607,8 @@ physical_device_check_features (VkPhysicalDevice device)
features |= GDK_VULKAN_FEATURE_YCBCR;
if (physical_device_supports_extension (device, VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME) &&
physical_device_supports_extension (device, VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME))
physical_device_supports_extension (device, VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME) &&
physical_device_supports_extension (device, VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME))
features |= GDK_VULKAN_FEATURE_DMABUF;
if (physical_device_supports_extension (device, VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME))
@@ -1517,6 +1518,7 @@ gdk_display_create_vulkan_device (GdkDisplay *display,
g_ptr_array_add (device_extensions, (gpointer) VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME);
g_ptr_array_add (device_extensions, (gpointer) VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME);
g_ptr_array_add (device_extensions, (gpointer) VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME);
g_ptr_array_add (device_extensions, (gpointer) VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME);
g_ptr_array_add (device_extensions, (gpointer) VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME);

View File

@@ -165,25 +165,29 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
double *scale)
{
GdkTexture *texture;
int desired_scale_factor;
desired_scale_factor = (int) ceil (desired_scale);
if (gdk_cursor_get_name (cursor))
{
struct wl_cursor *c;
int scale_factor;
if (g_str_equal (gdk_cursor_get_name (cursor), "none"))
goto none;
{
*hotspot_x = *hotspot_y = 0;
*width = *height = 0;
*scale = 1;
return NULL;
}
scale_factor = (int) ceil (desired_scale);
c = gdk_wayland_cursor_load_for_name (display,
_gdk_wayland_display_get_cursor_theme (display),
desired_scale_factor,
display->cursor_theme,
scale_factor,
gdk_cursor_get_name (cursor));
if (c && c->image_count > 0)
{
struct wl_cursor_image *image;
int cursor_scale;
if (image_index >= c->image_count)
{
@@ -195,23 +199,23 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
image = c->images[image_index];
cursor_scale = desired_scale_factor;
if ((image->width % cursor_scale != 0) ||
(image->height % cursor_scale != 0))
*width = display->cursor_theme_size;
*height = display->cursor_theme_size;
*scale = image->width / (double) *width;
*hotspot_x = image->hotspot_x / scale_factor;
*hotspot_y = image->hotspot_y / scale_factor;
if (*scale != scale_factor && !use_viewporter)
{
g_warning (G_STRLOC " cursor image size (%dx%d) not an integer "
"multiple of scale (%d)", image->width, image->height,
cursor_scale);
cursor_scale = 1;
g_warning (G_STRLOC " cursor image size (%d) not an integer "
"multiple of theme size (%d)", image->width, *width);
*width = image->width;
*height = image->height;
*hotspot_x = image->hotspot_x;
*hotspot_y = image->hotspot_y;
*scale = 1;
}
*hotspot_x = image->hotspot_x / cursor_scale;
*hotspot_y = image->hotspot_y / cursor_scale;
*width = image->width / cursor_scale;
*height = image->height / cursor_scale;
*scale = cursor_scale;
return wl_cursor_image_get_buffer (image);
}
}
@@ -257,7 +261,7 @@ from_texture:
else
{
if (!use_viewporter)
*scale = desired_scale_factor;
*scale = ceil (desired_scale);
else
*scale = desired_scale;
@@ -294,28 +298,23 @@ from_texture:
}
if (gdk_cursor_get_fallback (cursor))
return _gdk_wayland_cursor_get_buffer (display,
gdk_cursor_get_fallback (cursor),
desired_scale,
use_viewporter,
image_index,
hotspot_x, hotspot_y,
width, height,
scale);
{
return _gdk_wayland_cursor_get_buffer (display,
gdk_cursor_get_fallback (cursor),
desired_scale,
use_viewporter,
image_index,
hotspot_x, hotspot_y,
width, height,
scale);
}
else
{
texture = gdk_texture_new_from_resource ("/org/gtk/libgdk/cursor/default");
goto from_texture;
}
none:
*hotspot_x = 0;
*hotspot_y = 0;
*width = 0;
*height = 0;
*scale = 1;
return NULL;
g_assert_not_reached ();
}
guint

View File

@@ -1776,11 +1776,6 @@ _gdk_x11_display_is_root_window (GdkDisplay *display,
return GDK_SCREEN_XROOTWIN (display_x11->screen) == xroot_window;
}
struct XPointerUngrabInfo {
GdkDisplay *display;
guint32 time;
};
static void
device_grab_update_callback (GdkDisplay *display,
gpointer data,

View File

@@ -6397,6 +6397,10 @@ gsk_mask_node_draw (GskRenderNode *node,
graphene_matrix_t color_matrix;
graphene_vec4_t color_offset;
/* clip so the push_group() creates a smaller surface */
gsk_cairo_rectangle (cr, &node->bounds);
cairo_clip (cr);
if (has_empty_clip (cr))
return;

View File

@@ -530,6 +530,15 @@ handle_accessible_method (GDBusConnection *connection,
g_variant_builder_open (&builder, G_VARIANT_TYPE ("a{ss}"));
g_variant_builder_add (&builder, "{ss}", "toolkit", "GTK");
if (gtk_at_context_has_accessible_property (GTK_AT_CONTEXT (self), GTK_ACCESSIBLE_PROPERTY_LEVEL))
{
GtkAccessibleValue *value = gtk_at_context_get_accessible_property (GTK_AT_CONTEXT (self),
GTK_ACCESSIBLE_PROPERTY_LEVEL);
char *level = g_strdup_printf ("%d", gtk_int_accessible_value_get (value));
g_variant_builder_add (&builder, "{ss}", "level", level);
g_free (level);
}
if (gtk_at_context_has_accessible_property (GTK_AT_CONTEXT (self), GTK_ACCESSIBLE_PROPERTY_PLACEHOLDER))
{
GtkAccessibleValue *value;
@@ -1257,10 +1266,13 @@ gtk_at_spi_context_child_change (GtkATContext *ctx,
}
if (change & GTK_ACCESSIBLE_CHILD_CHANGE_ADDED)
{
gtk_at_context_realize (child_context);
emit_children_changed (self,
GTK_AT_SPI_CONTEXT (child_context),
idx,
GTK_ACCESSIBLE_CHILD_STATE_ADDED);
}
else if (change & GTK_ACCESSIBLE_CHILD_CHANGE_REMOVED)
emit_children_changed (self,
GTK_AT_SPI_CONTEXT (child_context),

View File

@@ -26,6 +26,16 @@
#include "gtkcsserror.h"
#include "gtkcsslocationprivate.h"
static void clear_ref (GtkCssVariableValueReference *ref);
#define GDK_ARRAY_NAME gtk_css_parser_references
#define GDK_ARRAY_TYPE_NAME GtkCssParserReferences
#define GDK_ARRAY_ELEMENT_TYPE GtkCssVariableValueReference
#define GDK_ARRAY_BY_VALUE 1
#define GDK_ARRAY_NO_MEMSET 1
#define GDK_ARRAY_FREE_FUNC clear_ref
#include "gdk/gdkarrayimpl.c"
typedef struct _GtkCssParserBlock GtkCssParserBlock;
struct _GtkCssParserBlock
@@ -39,7 +49,7 @@ struct _GtkCssParserBlock
#define GDK_ARRAY_NAME gtk_css_parser_blocks
#define GDK_ARRAY_TYPE_NAME GtkCssParserBlocks
#define GDK_ARRAY_ELEMENT_TYPE GtkCssParserBlock
#define GDK_ARAY_PREALLOC 32
#define GDK_ARRAY_PREALLOC 12
#define GDK_ARRAY_NO_MEMSET 1
#include "gdk/gdkarrayimpl.c"
@@ -55,11 +65,53 @@ gtk_css_parser_blocks_drop_last (GtkCssParserBlocks *blocks)
gtk_css_parser_blocks_set_size (blocks, gtk_css_parser_blocks_get_size (blocks) - 1);
}
typedef struct _GtkCssTokenizerData GtkCssTokenizerData;
struct _GtkCssTokenizerData
{
GtkCssTokenizer *tokenizer;
char *var_name;
GtkCssVariableValue *variable;
};
static void
gtk_css_tokenizer_data_clear (gpointer data)
{
GtkCssTokenizerData *td = data;
gtk_css_tokenizer_unref (td->tokenizer);
if (td->var_name)
g_free (td->var_name);
if (td->variable)
gtk_css_variable_value_unref (td->variable);
}
#define GDK_ARRAY_NAME gtk_css_tokenizers
#define GDK_ARRAY_TYPE_NAME GtkCssTokenizers
#define GDK_ARRAY_ELEMENT_TYPE GtkCssTokenizerData
#define GDK_ARRAY_FREE_FUNC gtk_css_tokenizer_data_clear
#define GDK_ARRAY_BY_VALUE 1
#define GDK_ARRAY_PREALLOC 16
#define GDK_ARRAY_NO_MEMSET 1
#include "gdk/gdkarrayimpl.c"
static inline GtkCssTokenizerData *
gtk_css_tokenizers_get_last (GtkCssTokenizers *tokenizers)
{
return gtk_css_tokenizers_index (tokenizers, gtk_css_tokenizers_get_size (tokenizers) - 1);
}
static inline void
gtk_css_tokenizers_drop_last (GtkCssTokenizers *tokenizers)
{
gtk_css_tokenizers_set_size (tokenizers, gtk_css_tokenizers_get_size (tokenizers) - 1);
}
struct _GtkCssParser
{
volatile int ref_count;
GtkCssTokenizer *tokenizer;
GtkCssTokenizers tokenizers;
GFile *file;
GFile *directory;
GtkCssParserErrorFunc error_func;
@@ -69,10 +121,22 @@ struct _GtkCssParser
GtkCssParserBlocks blocks;
GtkCssLocation location;
GtkCssToken token;
GtkCssVariableValue **refs;
gsize n_refs;
gsize next_ref;
gboolean var_fallback;
};
static inline GtkCssTokenizer *
get_tokenizer (GtkCssParser *self)
{
return gtk_css_tokenizers_get_last (&self->tokenizers)->tokenizer;
}
static GtkCssParser *
gtk_css_parser_new (GtkCssTokenizer *tokenizer,
GtkCssVariableValue *value,
GFile *file,
GtkCssParserErrorFunc error_func,
gpointer user_data,
@@ -83,7 +147,14 @@ gtk_css_parser_new (GtkCssTokenizer *tokenizer,
self = g_new0 (GtkCssParser, 1);
self->ref_count = 1;
self->tokenizer = gtk_css_tokenizer_ref (tokenizer);
gtk_css_tokenizers_init (&self->tokenizers);
gtk_css_tokenizers_append (&self->tokenizers,
&(GtkCssTokenizerData) {
gtk_css_tokenizer_ref (tokenizer),
NULL,
value ? gtk_css_variable_value_ref (value) : NULL });
if (file)
self->file = g_object_ref (file);
@@ -125,21 +196,45 @@ gtk_css_parser_new_for_bytes (GBytes *bytes,
{
GtkCssTokenizer *tokenizer;
GtkCssParser *result;
tokenizer = gtk_css_tokenizer_new (bytes);
result = gtk_css_parser_new (tokenizer, file, error_func, user_data, user_destroy);
result = gtk_css_parser_new (tokenizer, NULL, file, error_func, user_data, user_destroy);
gtk_css_tokenizer_unref (tokenizer);
return result;
}
GtkCssParser *
gtk_css_parser_new_for_token_stream (GtkCssVariableValue *value,
GFile *file,
GtkCssVariableValue **refs,
gsize n_refs,
GtkCssParserErrorFunc error_func,
gpointer user_data,
GDestroyNotify user_destroy)
{
GtkCssTokenizer *tokenizer;
GtkCssParser *result;
tokenizer = gtk_css_tokenizer_new_for_range (value->bytes, value->offset,
value->end_offset - value->offset);
result = gtk_css_parser_new (tokenizer, value, file, error_func, user_data, user_destroy);
gtk_css_tokenizer_unref (tokenizer);
result->refs = refs;
result->n_refs = n_refs;
result->next_ref = 0;
return result;
}
static void
gtk_css_parser_finalize (GtkCssParser *self)
{
if (self->user_destroy)
self->user_destroy (self->user_data);
g_clear_pointer (&self->tokenizer, gtk_css_tokenizer_unref);
gtk_css_tokenizers_clear (&self->tokenizers);
g_clear_object (&self->file);
g_clear_object (&self->directory);
if (gtk_css_parser_blocks_get_size (&self->blocks) > 0)
@@ -179,6 +274,12 @@ gtk_css_parser_get_file (GtkCssParser *self)
return self->file;
}
GBytes *
gtk_css_parser_get_bytes (GtkCssParser *self)
{
return gtk_css_tokenizer_get_bytes (gtk_css_tokenizers_get (&self->tokenizers, 0)->tokenizer);
}
/**
* gtk_css_parser_resolve_url:
* @self: a `GtkCssParser`
@@ -260,7 +361,7 @@ gtk_css_parser_get_start_location (GtkCssParser *self)
const GtkCssLocation *
gtk_css_parser_get_end_location (GtkCssParser *self)
{
return gtk_css_tokenizer_get_location (self->tokenizer);
return gtk_css_tokenizer_get_location (get_tokenizer (self));
}
/**
@@ -294,12 +395,14 @@ static void
gtk_css_parser_ensure_token (GtkCssParser *self)
{
GError *error = NULL;
GtkCssTokenizer *tokenizer;
if (!gtk_css_token_is (&self->token, GTK_CSS_TOKEN_EOF))
return;
self->location = *gtk_css_tokenizer_get_location (self->tokenizer);
if (!gtk_css_tokenizer_read_token (self->tokenizer, &self->token, &error))
tokenizer = get_tokenizer (self);
self->location = *gtk_css_tokenizer_get_location (tokenizer);
if (!gtk_css_tokenizer_read_token (tokenizer, &self->token, &error))
{
/* We ignore the error here, because the resulting token will
* likely already trigger an error in the parsing code and
@@ -307,6 +410,49 @@ gtk_css_parser_ensure_token (GtkCssParser *self)
*/
g_clear_error (&error);
}
if (gtk_css_tokenizers_get_size (&self->tokenizers) > 1 && gtk_css_token_is (&self->token, GTK_CSS_TOKEN_EOF))
{
gtk_css_tokenizers_drop_last (&self->tokenizers);
gtk_css_parser_ensure_token (self);
return;
}
/* Resolve var(--name): skip it and insert the resolved reference instead */
if (self->n_refs > 0 && gtk_css_token_is_function (&self->token, "var") && self->var_fallback == 0)
{
GtkCssVariableValue *ref;
GtkCssTokenizer *ref_tokenizer;
gtk_css_parser_start_block (self);
g_assert (gtk_css_parser_has_token (self, GTK_CSS_TOKEN_IDENT));
char *var_name = gtk_css_parser_consume_ident (self);
g_assert (var_name[0] == '-' && var_name[1] == '-');
/* If we encounter var() in a fallback when we can already resolve the
* actual variable, skip it */
self->var_fallback++;
gtk_css_parser_skip (self);
gtk_css_parser_end_block (self);
self->var_fallback--;
g_assert (self->next_ref < self->n_refs);
ref = self->refs[self->next_ref++];
ref_tokenizer = gtk_css_tokenizer_new_for_range (ref->bytes, ref->offset,
ref->end_offset - ref->offset);
gtk_css_tokenizers_append (&self->tokenizers,
&(GtkCssTokenizerData) {
ref_tokenizer,
g_strdup (var_name),
gtk_css_variable_value_ref (ref)
});
gtk_css_parser_ensure_token (self);
g_free (var_name);
}
}
const GtkCssToken *
@@ -523,6 +669,19 @@ gtk_css_parser_skip_until (GtkCssParser *self,
}
}
void
gtk_css_parser_skip_whitespace (GtkCssParser *self)
{
const GtkCssToken *token;
for (token = gtk_css_parser_peek_token (self);
gtk_css_token_is (token, GTK_CSS_TOKEN_WHITESPACE);
token = gtk_css_parser_peek_token (self))
{
gtk_css_parser_consume_token (self);
}
}
void
gtk_css_parser_emit_error (GtkCssParser *self,
const GtkCssLocation *start,
@@ -1133,3 +1292,319 @@ gtk_css_parser_consume_any (GtkCssParser *parser,
return result;
}
gboolean
gtk_css_parser_has_references (GtkCssParser *self)
{
GtkCssTokenizer *tokenizer = get_tokenizer (self);
gboolean ret = FALSE;
int inner_blocks = 0, i;
gtk_css_tokenizer_save (tokenizer);
do {
const GtkCssToken *token;
token = gtk_css_parser_get_token (self);
if (inner_blocks == 0)
{
if (gtk_css_token_is (token, GTK_CSS_TOKEN_EOF))
break;
if (gtk_css_token_is (token, GTK_CSS_TOKEN_CLOSE_PARENS) ||
gtk_css_token_is (token, GTK_CSS_TOKEN_CLOSE_SQUARE))
{
goto error;
}
}
if (gtk_css_token_is_preserved (token, NULL))
{
if (inner_blocks > 0 && gtk_css_token_is (token, GTK_CSS_TOKEN_EOF))
{
gtk_css_parser_end_block (self);
inner_blocks--;
}
else
{
gtk_css_parser_consume_token (self);
}
}
else
{
gboolean is_var = gtk_css_token_is_function (token, "var");
inner_blocks++;
gtk_css_parser_start_block (self);
if (!ret && is_var)
{
token = gtk_css_parser_get_token (self);
if (gtk_css_token_is (token, GTK_CSS_TOKEN_IDENT))
{
const char *var_name = gtk_css_token_get_string (token);
if (var_name[0] != '-' || var_name[1] != '-')
goto error;
gtk_css_parser_consume_token (self);
if (!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_EOF) &&
!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_COMMA))
{
goto error;
}
ret = TRUE;
}
}
}
}
while (!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_SEMICOLON) &&
!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_CLOSE_CURLY));
if (inner_blocks > 0)
goto error;
g_assert (tokenizer == get_tokenizer (self));
gtk_css_tokenizer_restore (tokenizer);
self->location = *gtk_css_tokenizer_get_location (tokenizer);
gtk_css_tokenizer_read_token (tokenizer, &self->token, NULL);
return ret;
error:
for (i = 0; i < inner_blocks; i++)
gtk_css_parser_end_block (self);
g_assert (tokenizer == get_tokenizer (self));
gtk_css_tokenizer_restore (tokenizer);
self->location = *gtk_css_tokenizer_get_location (tokenizer);
gtk_css_tokenizer_read_token (tokenizer, &self->token, NULL);
return FALSE;
}
static void
clear_ref (GtkCssVariableValueReference *ref)
{
g_free (ref->name);
if (ref->fallback)
gtk_css_variable_value_unref (ref->fallback);
}
#define GDK_ARRAY_NAME gtk_css_parser_references
#define GDK_ARRAY_TYPE_NAME GtkCssParserReferences
#define GDK_ARRAY_ELEMENT_TYPE GtkCssVariableValueReference
GtkCssVariableValue *
gtk_css_parser_parse_value_into_token_stream (GtkCssParser *self)
{
GBytes *bytes = gtk_css_tokenizer_get_bytes (get_tokenizer (self));
const GtkCssToken *token;
gsize offset;
gsize length = 0;
GtkCssParserReferences refs;
int inner_blocks = 0, i;
gboolean is_initial = FALSE;
for (token = gtk_css_parser_peek_token (self);
gtk_css_token_is (token, GTK_CSS_TOKEN_WHITESPACE);
token = gtk_css_parser_peek_token (self))
{
gtk_css_parser_consume_token (self);
}
gtk_css_parser_references_init (&refs);
offset = self->location.bytes;
do {
token = gtk_css_parser_get_token (self);
if (length == 0 && gtk_css_token_is_ident (token, "initial"))
is_initial = TRUE;
if (gtk_css_token_is (token, GTK_CSS_TOKEN_BAD_STRING) ||
gtk_css_token_is (token, GTK_CSS_TOKEN_BAD_URL))
{
gtk_css_parser_error_syntax (self, "Invalid property value");
goto error;
}
if (inner_blocks == 0)
{
if (gtk_css_token_is (token, GTK_CSS_TOKEN_EOF))
break;
if (gtk_css_token_is (token, GTK_CSS_TOKEN_CLOSE_PARENS) ||
gtk_css_token_is (token, GTK_CSS_TOKEN_CLOSE_SQUARE))
{
gtk_css_parser_error_syntax (self, "Invalid property value");
goto error;
}
}
if (gtk_css_token_is_preserved (token, NULL))
{
if (inner_blocks > 0 && gtk_css_token_is (token, GTK_CSS_TOKEN_EOF))
{
length++;
gtk_css_parser_end_block (self);
inner_blocks--;
}
else
{
length++;
gtk_css_parser_consume_token (self);
}
}
else
{
gboolean is_var = gtk_css_token_is_function (token, "var");
length++;
inner_blocks++;
gtk_css_parser_start_block (self);
if (is_var)
{
token = gtk_css_parser_get_token (self);
if (gtk_css_token_is (token, GTK_CSS_TOKEN_IDENT))
{
GtkCssVariableValueReference ref;
char *var_name = g_strdup (gtk_css_token_get_string (token));
if (var_name[0] != '-' || var_name[1] != '-')
{
gtk_css_parser_error_value (self, "Invalid variable name: %s", var_name);
g_free (var_name);
goto error;
}
length++;
gtk_css_parser_consume_token (self);
if (!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_EOF) &&
!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_COMMA))
{
gtk_css_parser_error_syntax (self, "Invalid property value");
g_free (var_name);
goto error;
}
ref.name = var_name;
if (gtk_css_parser_has_token (self, GTK_CSS_TOKEN_EOF))
{
ref.length = 3;
ref.fallback = NULL;
}
else
{
length++;
gtk_css_parser_consume_token (self);
ref.fallback = gtk_css_parser_parse_value_into_token_stream (self);
if (ref.fallback == NULL)
{
gtk_css_parser_error_value (self, "Invalid fallback for: %s", var_name);
g_free (var_name);
goto error;
}
ref.length = 4 + ref.fallback->length;
length += ref.fallback->length;
}
gtk_css_parser_references_append (&refs, &ref);
}
}
}
}
while (!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_SEMICOLON) &&
!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_CLOSE_CURLY));
if (inner_blocks > 0)
{
gtk_css_parser_error_syntax (self, "Invalid property value");
goto error;
}
if (is_initial && length == 1)
{
gtk_css_parser_references_clear (&refs);
return gtk_css_variable_value_new_initial (bytes,
offset,
self->location.bytes);
}
else
{
GtkCssVariableValueReference *out_refs;
gsize n_refs;
n_refs = gtk_css_parser_references_get_size (&refs);
out_refs = gtk_css_parser_references_steal (&refs);
return gtk_css_variable_value_new (bytes,
offset,
self->location.bytes,
length,
out_refs,
n_refs);
}
error:
for (i = 0; i < inner_blocks; i++)
gtk_css_parser_end_block (self);
gtk_css_parser_references_clear (&refs);
return NULL;
}
void
gtk_css_parser_get_expanding_variables (GtkCssParser *self,
GtkCssVariableValue ***variables,
char ***variable_names,
gsize *n_variables)
{
gsize len = gtk_css_tokenizers_get_size (&self->tokenizers);
GtkCssVariableValue **vars = NULL;
char **names = NULL;
gsize n;
if (variables)
vars = g_new0 (GtkCssVariableValue *, len + 1);
if (variable_names)
names = g_new0 (char *, len + 1);
n = 0;
for (gsize i = 0; i < gtk_css_tokenizers_get_size (&self->tokenizers); i++)
{
GtkCssTokenizerData *data = gtk_css_tokenizers_index (&self->tokenizers, i);
if (variables && data->variable)
vars[n] = gtk_css_variable_value_ref (data->variable);
if (variable_names)
names[n] = g_strdup (data->var_name);
n++;
}
if (variables)
*variables = vars;
if (variable_names)
*variable_names = names;
if (n_variables)
*n_variables = n;
}

View File

@@ -22,6 +22,7 @@
#include "gtkcssenums.h"
#include "gtkcsstokenizerprivate.h"
#include "gtkcssvariablevalueprivate.h"
#include <gio/gio.h>
@@ -58,10 +59,18 @@ GtkCssParser * gtk_css_parser_new_for_bytes (GBytes
GtkCssParserErrorFunc error_func,
gpointer user_data,
GDestroyNotify user_destroy);
GtkCssParser * gtk_css_parser_new_for_token_stream (GtkCssVariableValue *value,
GFile *file,
GtkCssVariableValue **refs,
gsize n_refs,
GtkCssParserErrorFunc error_func,
gpointer user_data,
GDestroyNotify user_destroy);
GtkCssParser * gtk_css_parser_ref (GtkCssParser *self);
void gtk_css_parser_unref (GtkCssParser *self);
GFile * gtk_css_parser_get_file (GtkCssParser *self) G_GNUC_PURE;
GBytes * gtk_css_parser_get_bytes (GtkCssParser *self) G_GNUC_PURE;
GFile * gtk_css_parser_resolve_url (GtkCssParser *self,
const char *url);
@@ -81,6 +90,7 @@ void gtk_css_parser_end_block (GtkCssParser
void gtk_css_parser_skip (GtkCssParser *self);
void gtk_css_parser_skip_until (GtkCssParser *self,
GtkCssTokenType token_type);
void gtk_css_parser_skip_whitespace (GtkCssParser *self);
void gtk_css_parser_emit_error (GtkCssParser *self,
const GtkCssLocation *start,
@@ -150,5 +160,14 @@ gsize gtk_css_parser_consume_any (GtkCssParser
gsize n_options,
gpointer user_data);
gboolean gtk_css_parser_has_references (GtkCssParser *parser);
GtkCssVariableValue * gtk_css_parser_parse_value_into_token_stream (GtkCssParser *parser);
void gtk_css_parser_get_expanding_variables (GtkCssParser *parser,
GtkCssVariableValue ***variables,
char ***names,
gsize *n_variables);
G_END_DECLS

View File

@@ -26,6 +26,7 @@ struct _GtkCssSection
int ref_count;
GtkCssSection *parent;
GFile *file;
GBytes *bytes;
GtkCssLocation start_location;
GtkCssLocation end_location; /* end location if parser is %NULL */
};
@@ -48,6 +49,15 @@ GtkCssSection *
gtk_css_section_new (GFile *file,
const GtkCssLocation *start,
const GtkCssLocation *end)
{
return gtk_css_section_new_with_bytes (file, NULL,start, end);
}
GtkCssSection *
gtk_css_section_new_with_bytes (GFile *file,
GBytes *bytes,
const GtkCssLocation *start,
const GtkCssLocation *end)
{
GtkCssSection *result;
@@ -60,6 +70,8 @@ gtk_css_section_new (GFile *file,
result->ref_count = 1;
if (file)
result->file = g_object_ref (file);
if (bytes)
result->bytes = g_bytes_ref (bytes);
result->start_location = *start;
result->end_location = *end;
@@ -104,6 +116,8 @@ gtk_css_section_unref (GtkCssSection *section)
gtk_css_section_unref (section->parent);
if (section->file)
g_object_unref (section->file);
if (section->bytes)
g_bytes_unref (section->bytes);
g_free (section);
}
@@ -151,6 +165,14 @@ gtk_css_section_get_file (const GtkCssSection *section)
return section->file;
}
GBytes *
gtk_css_section_get_bytes (const GtkCssSection *section)
{
g_return_val_if_fail (section != NULL, NULL);
return section->bytes;
}
/**
* gtk_css_section_get_start_location:
* @section: the section

View File

@@ -46,6 +46,11 @@ GDK_AVAILABLE_IN_ALL
GtkCssSection * gtk_css_section_new (GFile *file,
const GtkCssLocation *start,
const GtkCssLocation *end);
GDK_AVAILABLE_IN_4_16
GtkCssSection * gtk_css_section_new_with_bytes (GFile *file,
GBytes *bytes,
const GtkCssLocation *start,
const GtkCssLocation *end);
GDK_AVAILABLE_IN_ALL
GtkCssSection * gtk_css_section_ref (GtkCssSection *section);
GDK_AVAILABLE_IN_ALL
@@ -61,6 +66,8 @@ GDK_AVAILABLE_IN_ALL
GtkCssSection * gtk_css_section_get_parent (const GtkCssSection *section);
GDK_AVAILABLE_IN_ALL
GFile * gtk_css_section_get_file (const GtkCssSection *section);
GDK_AVAILABLE_IN_4_16
GBytes * gtk_css_section_get_bytes (const GtkCssSection *section);
GDK_AVAILABLE_IN_ALL
const GtkCssLocation *
gtk_css_section_get_start_location (const GtkCssSection *section);

View File

@@ -36,6 +36,9 @@ struct _GtkCssTokenizer
const char *end;
GtkCssLocation position;
GtkCssLocation saved_position;
const char *saved_data;
};
void
@@ -568,6 +571,14 @@ gtk_css_token_init_dimension (GtkCssToken *token,
GtkCssTokenizer *
gtk_css_tokenizer_new (GBytes *bytes)
{
return gtk_css_tokenizer_new_for_range (bytes, 0, g_bytes_get_size (bytes));
}
GtkCssTokenizer *
gtk_css_tokenizer_new_for_range (GBytes *bytes,
gsize offset,
gsize length)
{
GtkCssTokenizer *tokenizer;
@@ -576,8 +587,8 @@ gtk_css_tokenizer_new (GBytes *bytes)
tokenizer->bytes = g_bytes_ref (bytes);
tokenizer->name_buffer = g_string_new (NULL);
tokenizer->data = g_bytes_get_data (bytes, NULL);
tokenizer->end = tokenizer->data + g_bytes_get_size (bytes);
tokenizer->data = g_bytes_get_region (bytes, 1, offset, length);
tokenizer->end = tokenizer->data + length;
gtk_css_location_init (&tokenizer->position);
@@ -604,6 +615,12 @@ gtk_css_tokenizer_unref (GtkCssTokenizer *tokenizer)
g_free (tokenizer);
}
GBytes *
gtk_css_tokenizer_get_bytes (GtkCssTokenizer *tokenizer)
{
return tokenizer->bytes;
}
const GtkCssLocation *
gtk_css_tokenizer_get_location (GtkCssTokenizer *tokenizer)
{
@@ -1484,3 +1501,23 @@ gtk_css_tokenizer_read_token (GtkCssTokenizer *tokenizer,
}
}
void
gtk_css_tokenizer_save (GtkCssTokenizer *tokenizer)
{
g_assert (!tokenizer->saved_data);
tokenizer->saved_position = tokenizer->position;
tokenizer->saved_data = tokenizer->data;
}
void
gtk_css_tokenizer_restore (GtkCssTokenizer *tokenizer)
{
g_assert (tokenizer->saved_data);
tokenizer->position = tokenizer->saved_position;
tokenizer->data = tokenizer->saved_data;
gtk_css_location_init (&tokenizer->saved_position);
tokenizer->saved_data = NULL;
}

View File

@@ -138,15 +138,22 @@ void gtk_css_token_print (const GtkCssTok
char * gtk_css_token_to_string (const GtkCssToken *token);
GtkCssTokenizer * gtk_css_tokenizer_new (GBytes *bytes);
GtkCssTokenizer * gtk_css_tokenizer_new_for_range (GBytes *bytes,
gsize offset,
gsize length);
GtkCssTokenizer * gtk_css_tokenizer_ref (GtkCssTokenizer *tokenizer);
void gtk_css_tokenizer_unref (GtkCssTokenizer *tokenizer);
GBytes * gtk_css_tokenizer_get_bytes (GtkCssTokenizer *tokenizer);
const GtkCssLocation * gtk_css_tokenizer_get_location (GtkCssTokenizer *tokenizer) G_GNUC_CONST;
gboolean gtk_css_tokenizer_read_token (GtkCssTokenizer *tokenizer,
GtkCssToken *token,
GError **error);
void gtk_css_tokenizer_save (GtkCssTokenizer *tokenizer);
void gtk_css_tokenizer_restore (GtkCssTokenizer *tokenizer);
G_END_DECLS

View File

@@ -0,0 +1,158 @@
/*
* Copyright (C) 2023 GNOME Foundation Inc.
*
* 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: Alice Mikhaylenko <alicem@gnome.org>
*/
#include "gtkcssvariablevalueprivate.h"
GtkCssVariableValue *
gtk_css_variable_value_new (GBytes *bytes,
gsize offset,
gsize end_offset,
gsize length,
GtkCssVariableValueReference *references,
gsize n_references)
{
GtkCssVariableValue *self = g_new0 (GtkCssVariableValue, 1);
self->ref_count = 1;
self->bytes = g_bytes_ref (bytes);
self->offset = offset;
self->end_offset = end_offset;
self->length = length;
self->references = references;
self->n_references = n_references;
return self;
}
GtkCssVariableValue *
gtk_css_variable_value_new_initial (GBytes *bytes,
gsize offset,
gsize end_offset)
{
GtkCssVariableValue *self = gtk_css_variable_value_new (bytes, offset, end_offset, 1, NULL, 0);
self->is_invalid = TRUE;
return self;
}
GtkCssVariableValue *
gtk_css_variable_value_ref (GtkCssVariableValue *self)
{
self->ref_count++;
return self;
}
void
gtk_css_variable_value_unref (GtkCssVariableValue *self)
{
gsize i;
self->ref_count--;
if (self->ref_count > 0)
return;
g_bytes_unref (self->bytes);
for (i = 0; i < self->n_references; i++)
{
GtkCssVariableValueReference *ref = &self->references[i];
g_free (ref->name);
if (ref->fallback)
gtk_css_variable_value_unref (ref->fallback);
}
if (self->section)
gtk_css_section_unref (self->section);
g_free (self->references);
g_free (self);
}
void
gtk_css_variable_value_print (GtkCssVariableValue *self,
GString *string)
{
gsize len = self->end_offset - self->offset;
gconstpointer data = g_bytes_get_region (self->bytes, 1, self->offset, len);
g_assert (data != NULL);
g_string_append_len (string, (const char *) data, len);
}
char *
gtk_css_variable_value_to_string (GtkCssVariableValue *self)
{
GString *string = g_string_new (NULL);
gtk_css_variable_value_print (self, string);
return g_string_free (string, FALSE);
}
gboolean
gtk_css_variable_value_equal (const GtkCssVariableValue *value1,
const GtkCssVariableValue *value2)
{
if (value1 == value2)
return TRUE;
if (value1 == NULL || value2 == NULL)
return FALSE;
if (value1->bytes != value2->bytes)
return FALSE;
if (value1->offset != value2->offset)
return FALSE;
if (value1->end_offset != value2->end_offset)
return FALSE;
return TRUE;
}
GtkCssVariableValue *
gtk_css_variable_value_transition (GtkCssVariableValue *start,
GtkCssVariableValue *end,
double progress)
{
GtkCssVariableValue *ret = progress < 0.5 ? start : end;
if (ret == NULL)
return NULL;
return gtk_css_variable_value_ref (ret);
}
void
gtk_css_variable_value_set_section (GtkCssVariableValue *self,
GtkCssSection *section)
{
self->section = gtk_css_section_ref (section);
}
void
gtk_css_variable_value_taint (GtkCssVariableValue *self)
{
self->is_animation_tainted = TRUE;
}

View File

@@ -0,0 +1,77 @@
/*
* Copyright (C) 2023 GNOME Foundation Inc.
*
* 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: Alice Mikhaylenko <alicem@gnome.org>
*/
#pragma once
#include "gtkcss.h"
#include "gtkcsstokenizerprivate.h"
G_BEGIN_DECLS
typedef struct _GtkCssVariableValueReference GtkCssVariableValueReference;
typedef struct _GtkCssVariableValue GtkCssVariableValue;
struct _GtkCssVariableValueReference
{
char *name;
gsize length;
GtkCssVariableValue *fallback;
};
struct _GtkCssVariableValue
{
int ref_count;
GBytes *bytes;
gsize offset;
gsize end_offset;
gsize length;
GtkCssVariableValueReference *references;
gsize n_references;
GtkCssSection *section;
gboolean is_invalid;
gboolean is_animation_tainted;
};
GtkCssVariableValue *gtk_css_variable_value_new (GBytes *bytes,
gsize offset,
gsize end_offset,
gsize length,
GtkCssVariableValueReference *references,
gsize n_references);
GtkCssVariableValue *gtk_css_variable_value_new_initial (GBytes *bytes,
gsize offset,
gsize end_offset);
GtkCssVariableValue *gtk_css_variable_value_ref (GtkCssVariableValue *self);
void gtk_css_variable_value_unref (GtkCssVariableValue *self);
void gtk_css_variable_value_print (GtkCssVariableValue *self,
GString *string);
char * gtk_css_variable_value_to_string (GtkCssVariableValue *self);
gboolean gtk_css_variable_value_equal (const GtkCssVariableValue *value1,
const GtkCssVariableValue *value2) G_GNUC_PURE;
GtkCssVariableValue *gtk_css_variable_value_transition (GtkCssVariableValue *start,
GtkCssVariableValue *end,
double progress);
void gtk_css_variable_value_set_section (GtkCssVariableValue *self,
GtkCssSection *section);
void gtk_css_variable_value_taint (GtkCssVariableValue *self);
G_END_DECLS

View File

@@ -6,8 +6,9 @@ gtk_css_public_sources = files([
gtk_css_private_sources = files([
'gtkcssdataurl.c',
'gtkcssparser.c',
'gtkcsstokenizer.c',
'gtkcssserializer.c',
'gtkcsstokenizer.c',
'gtkcssvariablevalue.c',
])
gtk_css_public_headers = files([

View File

@@ -778,15 +778,15 @@ gtk_style_context_resolve_color (GtkStyleContext *context,
g_return_val_if_fail (color != NULL, FALSE);
g_return_val_if_fail (result != NULL, FALSE);
val = _gtk_css_color_value_resolve (color,
GTK_STYLE_PROVIDER (priv->cascade),
_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR),
NULL);
val = gtk_css_color_value_resolve (color,
GTK_STYLE_PROVIDER (priv->cascade),
_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR));
if (val == NULL)
return FALSE;
*result = *gtk_css_color_value_get_rgba (val);
_gtk_css_value_unref (val);
gtk_css_value_unref (val);
return TRUE;
}

View File

@@ -76,13 +76,19 @@ G_DEFINE_TYPE (GtkApplicationImplQuartz, gtk_application_impl_quartz, GTK_TYPE_A
-(NSApplicationTerminateReply) applicationShouldTerminate:(NSApplication *)sender
{
/* We have no way to give our message other than to pop up a dialog
* ourselves, which we should not do since the OS will already show
* one when we return NSTerminateNow.
*
* Just let the OS show the generic message...
*/
return quartz->quit_inhibit == 0 ? NSTerminateNow : NSTerminateCancel;
const gchar *quit_action_name = "quit";
GActionGroup *action_group = G_ACTION_GROUP (quartz->impl.application);
if (quartz->quit_inhibit != 0)
return NSTerminateCancel;
if (g_action_group_has_action (action_group, quit_action_name))
{
g_action_group_activate_action (action_group, quit_action_name, NULL);
return NSTerminateCancel;
}
return NSTerminateNow;
}
-(void)application:(NSApplication *)theApplication openFiles:(NSArray *)filenames

View File

@@ -2188,7 +2188,8 @@ gtk_column_view_set_header_factory (GtkColumnView *self,
/**
* gtk_column_view_scroll_to:
* @self: The columnview to scroll in
* @pos: position of the item
* @pos: position of the item. Must be less than the number of
* items in the view.
* @column: (nullable) (transfer none): The column to scroll to
* or %NULL to not scroll columns.
* @flags: actions to perform
@@ -2211,6 +2212,7 @@ gtk_column_view_scroll_to (GtkColumnView *self,
GtkScrollInfo *scroll)
{
g_return_if_fail (GTK_IS_COLUMN_VIEW (self));
g_return_if_fail (pos < gtk_list_base_get_n_items (GTK_LIST_BASE (self->listview)));
g_return_if_fail (column == NULL || GTK_IS_COLUMN_VIEW_COLUMN (column));
if (column)
{

View File

@@ -33,13 +33,57 @@
#include "gtkcssstringvalueprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkcsstransitionprivate.h"
#include "gtkcssvaluesprivate.h"
#include "gtkprivate.h"
#include "gtkstyleanimationprivate.h"
#include "gtkstylepropertyprivate.h"
#include "gtkstyleproviderprivate.h"
#include "gtkcsscustompropertypoolprivate.h"
G_DEFINE_TYPE (GtkCssAnimatedStyle, gtk_css_animated_style, GTK_TYPE_CSS_STYLE)
#define DEFINE_VALUES(ENUM, TYPE, NAME) \
static inline void \
gtk_css_ ## NAME ## _values_recompute (GtkCssAnimatedStyle *animated, \
GtkCssComputeContext *context) \
{ \
GtkCssStyle *style = (GtkCssStyle *)animated; \
GtkCssValue **values = (GtkCssValue **)((guint8*)(animated->style->NAME) + sizeof (GtkCssValues)); \
int i; \
\
for (i = 0; i < G_N_ELEMENTS (NAME ## _props); i++) \
{ \
guint id = NAME ## _props[i]; \
GtkCssValue *original, *computed; \
\
if (values[i] == NULL) \
continue; \
\
original = gtk_css_style_get_original_value (style, id); \
if (original == NULL) \
continue; \
\
computed = gtk_css_value_compute (original, \
id, \
context); \
if (computed == NULL) \
continue; \
\
gtk_css_animated_style_set_animated_value (animated, id, computed); \
} \
}
DEFINE_VALUES (CORE, Core, core)
DEFINE_VALUES (BACKGROUND, Background, background)
DEFINE_VALUES (BORDER, Border, border)
DEFINE_VALUES (ICON, Icon, icon)
DEFINE_VALUES (OUTLINE, Outline, outline)
DEFINE_VALUES (FONT, Font, font)
DEFINE_VALUES (FONT_VARIANT, FontVariant, font_variant)
DEFINE_VALUES (ANIMATION, Animation, animation)
DEFINE_VALUES (TRANSITION, Transition, transition)
DEFINE_VALUES (SIZE, Size, size)
DEFINE_VALUES (OTHER, Other, other)
static GtkCssSection *
gtk_css_animated_style_get_section (GtkCssStyle *style,
@@ -74,6 +118,15 @@ gtk_css_animated_style_get_static_style (GtkCssStyle *style)
return (GtkCssStaticStyle *)animated->style;
}
static GtkCssValue *
gtk_css_animated_style_get_original_value (GtkCssStyle *style,
guint id)
{
GtkCssAnimatedStyle *animated = GTK_CSS_ANIMATED_STYLE (style);
return gtk_css_style_get_original_value (animated->style, id);
}
static void
gtk_css_animated_style_dispose (GObject *object)
{
@@ -96,6 +149,9 @@ gtk_css_animated_style_finalize (GObject *object)
GtkCssAnimatedStyle *style = GTK_CSS_ANIMATED_STYLE (object);
g_object_unref (style->style);
if (style->parent_style)
g_object_unref (style->parent_style);
g_object_unref (style->provider);
G_OBJECT_CLASS (gtk_css_animated_style_parent_class)->finalize (object);
}
@@ -112,6 +168,7 @@ gtk_css_animated_style_class_init (GtkCssAnimatedStyleClass *klass)
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;
style_class->get_original_value = gtk_css_animated_style_get_original_value;
}
static void
@@ -546,6 +603,57 @@ gtk_css_animated_style_get_intrinsic_value (GtkCssAnimatedStyle *style,
return gtk_css_style_get_value (style->style, id);
}
void
gtk_css_animated_style_set_animated_custom_value (GtkCssAnimatedStyle *animated,
int id,
GtkCssVariableValue *value)
{
GtkCssStyle *style = (GtkCssStyle *)animated;
GtkCssComputeContext context = { NULL, };
gtk_internal_return_if_fail (GTK_IS_CSS_ANIMATED_STYLE (style));
gtk_internal_return_if_fail (value != NULL);
if (style->variables == NULL)
{
style->variables = gtk_css_variable_set_new ();
if (animated->parent_style)
gtk_css_variable_set_set_parent (style->variables,
animated->parent_style->variables);
}
else if (style->variables == animated->style->variables)
{
gtk_css_variable_set_unref (style->variables);
style->variables = gtk_css_variable_set_copy (animated->style->variables);
}
gtk_css_variable_set_add (style->variables, id, value);
context.provider = animated->provider;
context.style = animated->style;
context.parent_style = animated->parent_style;
context.provider = animated->provider;
gtk_css_core_values_recompute (animated, &context);
gtk_css_background_values_recompute (animated, &context);
gtk_css_border_values_recompute (animated, &context);
gtk_css_icon_values_recompute (animated, &context);
gtk_css_outline_values_recompute (animated, &context);
gtk_css_font_values_recompute (animated, &context);
gtk_css_font_variant_values_recompute (animated, &context);
gtk_css_animation_values_recompute (animated, &context);
gtk_css_transition_values_recompute (animated, &context);
gtk_css_size_values_recompute (animated, &context);
gtk_css_other_values_recompute (animated, &context);
}
GtkCssVariableValue *
gtk_css_animated_style_get_intrinsic_custom_value (GtkCssAnimatedStyle *style,
int id)
{
return gtk_css_style_get_custom_property (style->style, id);
}
static GPtrArray *
gtk_css_animated_style_create_dynamic (GPtrArray *animations,
GtkCssStyle *style,
@@ -711,7 +819,7 @@ gtk_css_animated_style_create_css_transitions (GPtrArray *animations,
start = gtk_css_animated_style_get_intrinsic_value ((GtkCssAnimatedStyle *)source, i);
end = gtk_css_style_get_value (base_style, i);
if (_gtk_css_value_equal (start, end))
if (gtk_css_value_equal (start, end))
{
animation = gtk_css_animated_style_find_transition ((GtkCssAnimatedStyle *)source, i);
if (animation)
@@ -727,8 +835,8 @@ gtk_css_animated_style_create_css_transitions (GPtrArray *animations,
}
}
if (_gtk_css_value_equal (gtk_css_style_get_value (source, i),
gtk_css_style_get_value (base_style, i)))
if (gtk_css_value_equal (gtk_css_style_get_value (source, i),
gtk_css_style_get_value (base_style, i)))
continue;
animation = _gtk_css_transition_new (i,
@@ -770,7 +878,6 @@ gtk_css_animated_style_find_animation (GtkStyleAnimation **animations,
static GPtrArray *
gtk_css_animated_style_create_css_animations (GPtrArray *animations,
GtkCssStyle *base_style,
GtkCssStyle *parent_style,
gint64 timestamp,
GtkStyleProvider *provider,
GtkCssStyle *source)
@@ -832,8 +939,6 @@ gtk_css_animated_style_create_css_animations (GPtrArray *animations,
if (keyframes == NULL)
continue;
keyframes = _gtk_css_keyframes_compute (keyframes, provider, base_style, parent_style);
animation = _gtk_css_animation_new (name,
keyframes,
timestamp,
@@ -844,7 +949,6 @@ gtk_css_animated_style_create_css_animations (GPtrArray *animations,
_gtk_css_play_state_value_get (_gtk_css_array_value_get_nth (play_states, i)),
_gtk_css_fill_mode_value_get (_gtk_css_array_value_get_nth (fill_modes, i)),
_gtk_css_number_value_get (_gtk_css_array_value_get_nth (iteration_counts, i), 100));
_gtk_css_keyframes_unref (keyframes);
}
if (!animations)
@@ -893,7 +997,7 @@ gtk_css_animated_style_new (GtkCssStyle *base_style,
if (previous_style != NULL)
animations = gtk_css_animated_style_create_css_transitions (animations, base_style, timestamp, previous_style);
animations = gtk_css_animated_style_create_css_animations (animations, base_style, parent_style, timestamp, provider, previous_style);
animations = gtk_css_animated_style_create_css_animations (animations, base_style, timestamp, provider, previous_style);
animations = gtk_css_animated_style_create_dynamic (animations, base_style, timestamp);
if (animations == NULL)
@@ -902,6 +1006,9 @@ gtk_css_animated_style_new (GtkCssStyle *base_style,
result = g_object_new (GTK_TYPE_CSS_ANIMATED_STYLE, NULL);
result->style = g_object_ref (base_style);
if (parent_style)
result->parent_style = g_object_ref (parent_style);
result->provider = g_object_ref (provider);
result->current_time = timestamp;
result->n_animations = animations->len;
result->animations = g_ptr_array_free (animations, FALSE);
@@ -918,6 +1025,8 @@ gtk_css_animated_style_new (GtkCssStyle *base_style,
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);
if (base_style->variables)
style->variables = gtk_css_variable_set_ref (base_style->variables);
gtk_css_animated_style_apply_animations (result);
@@ -927,7 +1036,9 @@ gtk_css_animated_style_new (GtkCssStyle *base_style,
GtkCssStyle *
gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
GtkCssStyle *base_style,
gint64 timestamp)
GtkCssStyle *parent_style,
gint64 timestamp,
GtkStyleProvider *provider)
{
GtkCssAnimatedStyle *result;
GtkCssStyle *style;
@@ -936,6 +1047,8 @@ gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
gtk_internal_return_val_if_fail (GTK_IS_CSS_ANIMATED_STYLE (source), NULL);
gtk_internal_return_val_if_fail (GTK_IS_CSS_STYLE (base_style), NULL);
gtk_internal_return_val_if_fail (parent_style == NULL || GTK_IS_CSS_STYLE (parent_style), NULL);
gtk_internal_return_val_if_fail (GTK_IS_STYLE_PROVIDER (provider), NULL);
if (timestamp == 0)
return g_object_ref (source->style);
@@ -966,6 +1079,9 @@ gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
result = g_object_new (GTK_TYPE_CSS_ANIMATED_STYLE, NULL);
result->style = g_object_ref (base_style);
if (parent_style)
result->parent_style = g_object_ref (parent_style);
result->provider = g_object_ref (provider);
result->current_time = timestamp;
result->n_animations = animations->len;
result->animations = g_ptr_array_free (animations, FALSE);
@@ -982,8 +1098,34 @@ gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
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);
if (base_style->variables)
style->variables = gtk_css_variable_set_ref (base_style->variables);
gtk_css_animated_style_apply_animations (result);
return GTK_CSS_STYLE (result);
}
GtkCssStyle *
gtk_css_animated_style_get_base_style (GtkCssAnimatedStyle *style)
{
gtk_internal_return_val_if_fail (GTK_IS_CSS_ANIMATED_STYLE (style), NULL);
return style->style;
}
GtkCssStyle *
gtk_css_animated_style_get_parent_style (GtkCssAnimatedStyle *style)
{
gtk_internal_return_val_if_fail (GTK_IS_CSS_ANIMATED_STYLE (style), NULL);
return style->parent_style;
}
GtkStyleProvider *
gtk_css_animated_style_get_provider (GtkCssAnimatedStyle *style)
{
gtk_internal_return_val_if_fail (GTK_IS_CSS_ANIMATED_STYLE (style), NULL);
return style->provider;
}

View File

@@ -38,6 +38,8 @@ struct _GtkCssAnimatedStyle
GtkCssStyle parent;
GtkCssStyle *style; /* the style if we weren't animating */
GtkCssStyle *parent_style;
GtkStyleProvider *provider;
gint64 current_time; /* the current time in our world */
gpointer *animations; /* GtkStyleAnimation**, least important one first */
@@ -57,15 +59,26 @@ GtkCssStyle * gtk_css_animated_style_new (GtkCssStyle
GtkStyleProvider *provider,
GtkCssStyle *previous_style);
GtkCssStyle * gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
GtkCssStyle *base,
gint64 timestamp);
GtkCssStyle *base_style,
GtkCssStyle *parent_style,
gint64 timestamp,
GtkStyleProvider *provider);
void gtk_css_animated_style_set_animated_value(GtkCssAnimatedStyle *style,
guint id,
GtkCssValue *value);
GtkCssValue * gtk_css_animated_style_get_intrinsic_value (GtkCssAnimatedStyle *style,
guint id);
void gtk_css_animated_style_set_animated_custom_value (GtkCssAnimatedStyle *animated,
int id,
GtkCssVariableValue *value);
GtkCssVariableValue * gtk_css_animated_style_get_intrinsic_custom_value (GtkCssAnimatedStyle *style,
int id);
GtkCssStyle * gtk_css_animated_style_get_base_style (GtkCssAnimatedStyle *style);
GtkCssStyle * gtk_css_animated_style_get_parent_style (GtkCssAnimatedStyle *style);
GtkStyleProvider * gtk_css_animated_style_get_provider (GtkCssAnimatedStyle *style);
G_END_DECLS

View File

@@ -90,6 +90,9 @@ gtk_css_animation_apply_values (GtkStyleAnimation *style_animation,
GtkCssAnimatedStyle *style)
{
GtkCssAnimation *animation = (GtkCssAnimation *)style_animation;
GtkCssStyle *base_style, *parent_style;
GtkStyleProvider *provider;
GtkCssKeyframes *resolved_keyframes;
double progress;
guint i;
@@ -99,19 +102,49 @@ gtk_css_animation_apply_values (GtkStyleAnimation *style_animation,
progress = gtk_css_animation_get_progress (animation);
progress = _gtk_css_ease_value_transform (animation->ease, progress);
for (i = 0; i < _gtk_css_keyframes_get_n_properties (animation->keyframes); i++)
base_style = gtk_css_animated_style_get_base_style (style);
parent_style = gtk_css_animated_style_get_parent_style (style);
provider = gtk_css_animated_style_get_provider (style);
resolved_keyframes = _gtk_css_keyframes_compute (animation->keyframes,
provider,
base_style,
parent_style);
for (i = 0; i < _gtk_css_keyframes_get_n_variables (resolved_keyframes); i++)
{
GtkCssVariableValue *value;
int variable_id;
variable_id = _gtk_css_keyframes_get_variable_id (resolved_keyframes, i);
value = _gtk_css_keyframes_get_variable (resolved_keyframes,
i,
progress,
gtk_css_animated_style_get_intrinsic_custom_value (style, variable_id));
if (!value)
continue;
gtk_css_animated_style_set_animated_custom_value (style, variable_id, value);
gtk_css_variable_value_unref (value);
}
for (i = 0; i < _gtk_css_keyframes_get_n_properties (resolved_keyframes); i++)
{
GtkCssValue *value;
guint property_id;
property_id = _gtk_css_keyframes_get_property_id (animation->keyframes, i);
property_id = _gtk_css_keyframes_get_property_id (resolved_keyframes, i);
value = _gtk_css_keyframes_get_value (animation->keyframes,
value = _gtk_css_keyframes_get_value (resolved_keyframes,
i,
progress,
gtk_css_animated_style_get_intrinsic_value (style, property_id));
gtk_css_animated_style_set_animated_value (style, property_id, value);
}
_gtk_css_keyframes_unref (resolved_keyframes);
}
static gboolean
@@ -138,7 +171,7 @@ gtk_css_animation_free (GtkStyleAnimation *animation)
g_free (self->name);
_gtk_css_keyframes_unref (self->keyframes);
_gtk_css_value_unref (self->ease);
gtk_css_value_unref (self->ease);
g_free (self);
}
@@ -178,7 +211,7 @@ _gtk_css_animation_new (const char *name,
animation->name = g_strdup (name);
animation->keyframes = _gtk_css_keyframes_ref (keyframes);
animation->ease = _gtk_css_value_ref (ease);
animation->ease = gtk_css_value_ref (ease);
animation->direction = direction;
animation->play_state = play_state;
animation->fill_mode = fill_mode;
@@ -209,7 +242,7 @@ _gtk_css_animation_advance_with_play_state (GtkCssAnimation *source,
animation->name = g_strdup (source->name);
animation->keyframes = _gtk_css_keyframes_ref (source->keyframes);
animation->ease = _gtk_css_value_ref (source->ease);
animation->ease = gtk_css_value_ref (source->ease);
animation->direction = source->direction;
animation->play_state = play_state;
animation->fill_mode = source->fill_mode;

View File

@@ -35,17 +35,15 @@ gtk_css_value_array_free (GtkCssValue *value)
guint i;
for (i = 0; i < value->n_values; i++)
_gtk_css_value_unref (value->values[i]);
gtk_css_value_unref (value->values[i]);
g_free (value);
}
static GtkCssValue *
gtk_css_value_array_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_value_array_compute (GtkCssValue *value,
guint property_id,
GtkCssComputeContext *context)
{
GtkCssValue *result;
GtkCssValue *i_value;
@@ -54,24 +52,24 @@ gtk_css_value_array_compute (GtkCssValue *value,
result = NULL;
for (i = 0; i < value->n_values; i++)
{
i_value = _gtk_css_value_compute (value->values[i], property_id, provider, style, parent_style);
i_value = gtk_css_value_compute (value->values[i], property_id, context);
if (result == NULL &&
i_value != value->values[i])
{
result = _gtk_css_array_value_new_from_array (value->values, value->n_values);
for (j = 0; j < i; j++)
_gtk_css_value_ref (result->values[j]);
gtk_css_value_ref (result->values[j]);
}
if (result != NULL)
result->values[i] = i_value;
else
_gtk_css_value_unref (i_value);
gtk_css_value_unref (i_value);
}
if (result == NULL)
return _gtk_css_value_ref (value);
return gtk_css_value_ref (value);
return result;
}
@@ -87,8 +85,8 @@ gtk_css_value_array_equal (const GtkCssValue *value1,
for (i = 0; i < value1->n_values; i++)
{
if (!_gtk_css_value_equal (value1->values[i],
value2->values[i]))
if (!gtk_css_value_equal (value1->values[i],
value2->values[i]))
return FALSE;
}
@@ -127,14 +125,14 @@ gtk_css_value_array_transition_repeat (GtkCssValue *start,
for (i = 0; i < n; i++)
{
transitions[i] = _gtk_css_value_transition (start->values[i % start->n_values],
end->values[i % end->n_values],
property_id,
progress);
transitions[i] = gtk_css_value_transition (start->values[i % start->n_values],
end->values[i % end->n_values],
property_id,
progress);
if (transitions[i] == NULL)
{
while (i--)
_gtk_css_value_unref (transitions[i]);
gtk_css_value_unref (transitions[i]);
return NULL;
}
}
@@ -168,14 +166,14 @@ gtk_css_value_array_transition_extend (GtkCssValue *start,
for (i = 0; i < MIN (start->n_values, end->n_values); i++)
{
transitions[i] = _gtk_css_value_transition (start->values[i],
end->values[i],
property_id,
progress);
transitions[i] = gtk_css_value_transition (start->values[i],
end->values[i],
property_id,
progress);
if (transitions[i] == NULL)
{
while (i--)
_gtk_css_value_unref (transitions[i]);
gtk_css_value_unref (transitions[i]);
return NULL;
}
}
@@ -188,28 +186,28 @@ gtk_css_value_array_transition_extend (GtkCssValue *start,
for (; i < start->n_values; i++)
{
transitions[i] = _gtk_css_value_transition (start->values[i],
default_value,
property_id,
progress);
transitions[i] = gtk_css_value_transition (start->values[i],
default_value,
property_id,
progress);
if (transitions[i] == NULL)
{
while (i--)
_gtk_css_value_unref (transitions[i]);
gtk_css_value_unref (transitions[i]);
return NULL;
}
}
for (; i < end->n_values; i++)
{
transitions[i] = _gtk_css_value_transition (default_value,
end->values[i],
property_id,
progress);
transitions[i] = gtk_css_value_transition (default_value,
end->values[i],
property_id,
progress);
if (transitions[i] == NULL)
{
while (i--)
_gtk_css_value_unref (transitions[i]);
gtk_css_value_unref (transitions[i]);
return NULL;
}
}
@@ -327,17 +325,17 @@ gtk_css_value_array_get_dynamic_value (GtkCssValue *value,
{
result = _gtk_css_array_value_new_from_array (value->values, value->n_values);
for (j = 0; j < i; j++)
_gtk_css_value_ref (result->values[j]);
gtk_css_value_ref (result->values[j]);
}
if (result != NULL)
result->values[i] = i_value;
else
_gtk_css_value_unref (i_value);
gtk_css_value_unref (i_value);
}
if (result == NULL)
return _gtk_css_value_ref (value);
return gtk_css_value_ref (value);
return result;
}
@@ -358,7 +356,7 @@ gtk_css_value_array_print (const GtkCssValue *value,
{
if (i > 0)
g_string_append (string, ", ");
_gtk_css_value_print (value->values[i], string);
gtk_css_value_print (value->values[i], string);
}
}
@@ -394,18 +392,22 @@ _gtk_css_array_value_new_from_array (GtkCssValue **values,
if (n_values == 1)
return values[0];
result = _gtk_css_value_alloc (&GTK_CSS_VALUE_ARRAY, sizeof (GtkCssValue) + sizeof (GtkCssValue *) * (n_values - 1));
result = gtk_css_value_alloc (&GTK_CSS_VALUE_ARRAY, sizeof (GtkCssValue) + sizeof (GtkCssValue *) * (n_values - 1));
result->n_values = n_values;
memcpy (&result->values[0], values, sizeof (GtkCssValue *) * n_values);
result->is_computed = TRUE;
result->contains_variables = FALSE;
for (i = 0; i < n_values; i ++)
{
if (!gtk_css_value_is_computed (values[i]))
{
result->is_computed = FALSE;
break;
}
result->is_computed = FALSE;
if (gtk_css_value_contains_variables (values[i]))
result->contains_variables = TRUE;
if (!result->is_computed && result->contains_variables)
break;
}
return result;
@@ -426,7 +428,7 @@ _gtk_css_array_value_parse (GtkCssParser *parser,
if (value == NULL)
{
for (i = 0; i < n_values; i ++)
_gtk_css_value_unref (values[i]);
gtk_css_value_unref (values[i]);
return NULL;
}
@@ -467,3 +469,4 @@ _gtk_css_array_value_get_n_values (const GtkCssValue *value)
return value->n_values;
}

View File

@@ -33,41 +33,39 @@ static void
gtk_css_value_bg_size_free (GtkCssValue *value)
{
if (value->x)
_gtk_css_value_unref (value->x);
gtk_css_value_unref (value->x);
if (value->y)
_gtk_css_value_unref (value->y);
gtk_css_value_unref (value->y);
g_free (value);
}
static GtkCssValue *
gtk_css_value_bg_size_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_value_bg_size_compute (GtkCssValue *value,
guint property_id,
GtkCssComputeContext *context)
{
GtkCssValue *x, *y;
if (value->x == NULL && value->y == NULL)
return _gtk_css_value_ref (value);
return gtk_css_value_ref (value);
x = y = NULL;
if (value->x)
x = _gtk_css_value_compute (value->x, property_id, provider, style, parent_style);
x = gtk_css_value_compute (value->x, property_id, context);
if (value->y)
y = _gtk_css_value_compute (value->y, property_id, provider, style, parent_style);
y = gtk_css_value_compute (value->y, property_id, context);
if (x == value->x && y == value->y)
{
if (x)
_gtk_css_value_unref (x);
gtk_css_value_unref (x);
if (y)
_gtk_css_value_unref (y);
gtk_css_value_unref (y);
return _gtk_css_value_ref (value);
return gtk_css_value_ref (value);
}
return _gtk_css_bg_size_value_new (value->x ? x : NULL,
@@ -82,10 +80,10 @@ gtk_css_value_bg_size_equal (const GtkCssValue *value1,
value1->contain == value2->contain &&
(value1->x == value2->x ||
(value1->x != NULL && value2->x != NULL &&
_gtk_css_value_equal (value1->x, value2->x))) &&
gtk_css_value_equal (value1->x, value2->x))) &&
(value1->y == value2->y ||
(value1->y != NULL && value2->y != NULL &&
_gtk_css_value_equal (value1->y, value2->y)));
gtk_css_value_equal (value1->y, value2->y)));
}
static GtkCssValue *
@@ -97,9 +95,9 @@ gtk_css_value_bg_size_transition (GtkCssValue *start,
GtkCssValue *x, *y;
if (start->cover)
return end->cover ? _gtk_css_value_ref (end) : NULL;
return end->cover ? gtk_css_value_ref (end) : NULL;
if (start->contain)
return end->contain ? _gtk_css_value_ref (end) : NULL;
return end->contain ? gtk_css_value_ref (end) : NULL;
if ((start->x != NULL) ^ (end->x != NULL) ||
(start->y != NULL) ^ (end->y != NULL))
@@ -107,7 +105,7 @@ gtk_css_value_bg_size_transition (GtkCssValue *start,
if (start->x)
{
x = _gtk_css_value_transition (start->x, end->x, property_id, progress);
x = gtk_css_value_transition (start->x, end->x, property_id, progress);
if (x == NULL)
return NULL;
}
@@ -116,10 +114,10 @@ gtk_css_value_bg_size_transition (GtkCssValue *start,
if (start->y)
{
y = _gtk_css_value_transition (start->y, end->y, property_id, progress);
y = gtk_css_value_transition (start->y, end->y, property_id, progress);
if (y == NULL)
{
_gtk_css_value_unref (x);
gtk_css_value_unref (x);
return NULL;
}
}
@@ -142,12 +140,12 @@ gtk_css_value_bg_size_print (const GtkCssValue *value,
if (value->x == NULL)
g_string_append (string, "auto");
else
_gtk_css_value_print (value->x, string);
gtk_css_value_print (value->x, string);
if (value->y)
{
g_string_append_c (string, ' ');
_gtk_css_value_print (value->y, string);
gtk_css_value_print (value->y, string);
}
}
}
@@ -163,9 +161,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_BG_SIZE = {
gtk_css_value_bg_size_print
};
static GtkCssValue auto_singleton = { &GTK_CSS_VALUE_BG_SIZE, 1, TRUE, FALSE, FALSE, NULL, NULL };
static GtkCssValue cover_singleton = { &GTK_CSS_VALUE_BG_SIZE, 1, TRUE, TRUE, FALSE, NULL, NULL };
static GtkCssValue contain_singleton = { &GTK_CSS_VALUE_BG_SIZE, 1, TRUE, FALSE, TRUE, NULL, NULL };
static GtkCssValue auto_singleton = { &GTK_CSS_VALUE_BG_SIZE, 1, TRUE, FALSE, FALSE, FALSE, NULL, NULL };
static GtkCssValue cover_singleton = { &GTK_CSS_VALUE_BG_SIZE, 1, TRUE, FALSE, TRUE, FALSE, NULL, NULL };
static GtkCssValue contain_singleton = { &GTK_CSS_VALUE_BG_SIZE, 1, TRUE, FALSE, FALSE, TRUE, NULL, NULL };
GtkCssValue *
_gtk_css_bg_size_value_new (GtkCssValue *x,
@@ -174,9 +172,9 @@ _gtk_css_bg_size_value_new (GtkCssValue *x,
GtkCssValue *result;
if (x == NULL && y == NULL)
return _gtk_css_value_ref (&auto_singleton);
return gtk_css_value_ref (&auto_singleton);
result = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_BG_SIZE);
result = gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_BG_SIZE);
result->x = x;
result->y = y;
result->is_computed = (!x || gtk_css_value_is_computed (x)) &&
@@ -191,9 +189,9 @@ _gtk_css_bg_size_value_parse (GtkCssParser *parser)
GtkCssValue *x, *y;
if (gtk_css_parser_try_ident (parser, "cover"))
return _gtk_css_value_ref (&cover_singleton);
return gtk_css_value_ref (&cover_singleton);
else if (gtk_css_parser_try_ident (parser, "contain"))
return _gtk_css_value_ref (&contain_singleton);
return gtk_css_value_ref (&contain_singleton);
if (gtk_css_parser_try_ident (parser, "auto"))
x = NULL;
@@ -219,7 +217,7 @@ _gtk_css_bg_size_value_parse (GtkCssParser *parser)
| GTK_CSS_PARSE_LENGTH);
if (y == NULL)
{
_gtk_css_value_unref (x);
gtk_css_value_unref (x);
return NULL;
}
}

View File

@@ -35,18 +35,16 @@ gtk_css_value_border_free (GtkCssValue *value)
for (i = 0; i < 4; i++)
{
if (value->values[i])
_gtk_css_value_unref (value->values[i]);
gtk_css_value_unref (value->values[i]);
}
g_free (value);
}
static GtkCssValue *
gtk_css_value_border_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_value_border_compute (GtkCssValue *value,
guint property_id,
GtkCssComputeContext *context)
{
GtkCssValue *values[4];
GtkCssValue *computed;
@@ -57,7 +55,7 @@ gtk_css_value_border_compute (GtkCssValue *value,
{
if (value->values[i])
{
values[i] = _gtk_css_value_compute (value->values[i], property_id, provider, style, parent_style);
values[i] = gtk_css_value_compute (value->values[i], property_id, context);
changed |= (values[i] != value->values[i]);
}
else
@@ -71,9 +69,9 @@ gtk_css_value_border_compute (GtkCssValue *value,
for (i = 0; i < 4; i++)
{
if (values[i] != NULL)
_gtk_css_value_unref (values[i]);
gtk_css_value_unref (values[i]);
}
return _gtk_css_value_ref (value);
return gtk_css_value_ref (value);
}
computed = _gtk_css_border_value_new (values[0], values[1], values[2], values[3]);
@@ -93,7 +91,7 @@ gtk_css_value_border_equal (const GtkCssValue *value1,
for (i = 0; i < 4; i++)
{
if (!_gtk_css_value_equal0 (value1->values[i], value2->values[i]))
if (!gtk_css_value_equal0 (value1->values[i], value2->values[i]))
return FALSE;
}
@@ -115,11 +113,11 @@ gtk_css_value_border_print (const GtkCssValue *value,
{
guint i, n;
if (!_gtk_css_value_equal0 (value->values[GTK_CSS_RIGHT], value->values[GTK_CSS_LEFT]))
if (!gtk_css_value_equal0 (value->values[GTK_CSS_RIGHT], value->values[GTK_CSS_LEFT]))
n = 4;
else if (!_gtk_css_value_equal0 (value->values[GTK_CSS_TOP], value->values[GTK_CSS_BOTTOM]))
else if (!gtk_css_value_equal0 (value->values[GTK_CSS_TOP], value->values[GTK_CSS_BOTTOM]))
n = 3;
else if (!_gtk_css_value_equal0 (value->values[GTK_CSS_TOP], value->values[GTK_CSS_RIGHT]))
else if (!gtk_css_value_equal0 (value->values[GTK_CSS_TOP], value->values[GTK_CSS_RIGHT]))
n = 2;
else
n = 1;
@@ -132,7 +130,7 @@ gtk_css_value_border_print (const GtkCssValue *value,
if (value->values[i] == NULL)
g_string_append (string, "auto");
else
_gtk_css_value_print (value->values[i], string);
gtk_css_value_print (value->values[i], string);
}
if (value->fill)
@@ -158,7 +156,7 @@ _gtk_css_border_value_new (GtkCssValue *top,
{
GtkCssValue *result;
result = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_BORDER);
result = gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_BORDER);
result->values[GTK_CSS_TOP] = top;
result->values[GTK_CSS_RIGHT] = right;
result->values[GTK_CSS_BOTTOM] = bottom;
@@ -196,7 +194,7 @@ _gtk_css_border_value_parse (GtkCssParser *parser,
result->values[i] = _gtk_css_number_value_parse (parser, flags);
if (result->values[i] == NULL)
{
_gtk_css_value_unref (result);
gtk_css_value_unref (result);
return NULL;
}
}
@@ -204,7 +202,7 @@ _gtk_css_border_value_parse (GtkCssParser *parser,
if (i == 0)
{
gtk_css_parser_error_syntax (parser, "Expected a number");
_gtk_css_value_unref (result);
gtk_css_value_unref (result);
return NULL;
}
@@ -214,7 +212,7 @@ _gtk_css_border_value_parse (GtkCssParser *parser,
for (; i < 4; i++)
{
if (result->values[(i - 1) >> 1])
result->values[i] = _gtk_css_value_ref (result->values[(i - 1) >> 1]);
result->values[i] = gtk_css_value_ref (result->values[(i - 1) >> 1]);
}
result->is_computed = TRUE;
@@ -260,3 +258,4 @@ _gtk_css_border_value_get_left (const GtkCssValue *value)
return value->values[GTK_CSS_LEFT];
}

View File

@@ -99,8 +99,8 @@ gtk_css_calc_value_parse_product (GtkCssParser *parser,
temp = gtk_css_number_value_multiply (result, _gtk_css_number_value_get (value, 100));
else
temp = gtk_css_number_value_multiply (value, _gtk_css_number_value_get (result, 100));
_gtk_css_value_unref (value);
_gtk_css_value_unref (result);
gtk_css_value_unref (value);
gtk_css_value_unref (result);
result = temp;
}
else if (gtk_css_parser_try_delim (parser, '/'))
@@ -109,8 +109,8 @@ gtk_css_calc_value_parse_product (GtkCssParser *parser,
if (value == NULL)
goto fail;
temp = gtk_css_number_value_multiply (result, 1.0 / _gtk_css_number_value_get (value, 100));
_gtk_css_value_unref (value);
_gtk_css_value_unref (result);
gtk_css_value_unref (value);
gtk_css_value_unref (result);
result = temp;
}
else
@@ -132,7 +132,7 @@ gtk_css_calc_value_parse_product (GtkCssParser *parser,
return result;
fail:
_gtk_css_value_unref (result);
gtk_css_value_unref (result);
return NULL;
}
@@ -162,7 +162,7 @@ gtk_css_calc_value_parse_sum (GtkCssParser *parser,
if (temp == NULL)
goto fail;
next = gtk_css_number_value_multiply (temp, -1);
_gtk_css_value_unref (temp);
gtk_css_value_unref (temp);
}
else
{
@@ -178,15 +178,15 @@ gtk_css_calc_value_parse_sum (GtkCssParser *parser,
}
temp = gtk_css_number_value_add (result, next);
_gtk_css_value_unref (result);
_gtk_css_value_unref (next);
gtk_css_value_unref (result);
gtk_css_value_unref (next);
result = temp;
}
return result;
fail:
_gtk_css_value_unref (result);
gtk_css_value_unref (result);
return NULL;
}

View File

@@ -60,29 +60,29 @@ struct _GtkCssValue
GtkCssValue *color2;
double factor;
} mix;
} sym_col;
};
};
static void
gtk_css_value_color_free (GtkCssValue *color)
{
if (color->last_value)
_gtk_css_value_unref (color->last_value);
gtk_css_value_unref (color->last_value);
switch (color->type)
{
case COLOR_TYPE_NAME:
g_free (color->sym_col.name);
g_free (color->name);
break;
case COLOR_TYPE_SHADE:
_gtk_css_value_unref (color->sym_col.shade.color);
gtk_css_value_unref (color->shade.color);
break;
case COLOR_TYPE_ALPHA:
_gtk_css_value_unref (color->sym_col.alpha.color);
gtk_css_value_unref (color->alpha.color);
break;
case COLOR_TYPE_MIX:
_gtk_css_value_unref (color->sym_col.mix.color1);
_gtk_css_value_unref (color->sym_col.mix.color2);
gtk_css_value_unref (color->mix.color1);
gtk_css_value_unref (color->mix.color2);
break;
case COLOR_TYPE_LITERAL:
case COLOR_TYPE_CURRENT_COLOR:
@@ -94,10 +94,8 @@ gtk_css_value_color_free (GtkCssValue *color)
}
static GtkCssValue *
gtk_css_value_color_get_fallback (guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_value_color_get_fallback (guint property_id,
GtkCssComputeContext *context)
{
switch (property_id)
{
@@ -116,64 +114,58 @@ gtk_css_value_color_get_fallback (guint property_id,
case GTK_CSS_PROPERTY_OUTLINE_COLOR:
case GTK_CSS_PROPERTY_CARET_COLOR:
case GTK_CSS_PROPERTY_SECONDARY_CARET_COLOR:
return _gtk_css_value_compute (_gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (property_id)),
return gtk_css_value_compute (_gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (property_id)),
property_id,
provider,
style,
parent_style);
context);
case GTK_CSS_PROPERTY_ICON_PALETTE:
return _gtk_css_value_ref (style->core->color);
return gtk_css_value_ref (context->style->core->color);
default:
if (property_id < GTK_CSS_PROPERTY_N_PROPERTIES)
g_warning ("No fallback color defined for property '%s'",
g_warning ("No fallback color defined for property '%s'",
_gtk_style_property_get_name (GTK_STYLE_PROPERTY (_gtk_css_style_property_lookup_by_id (property_id))));
return gtk_css_color_value_new_transparent ();
}
}
static GtkCssValue *
gtk_css_value_color_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_value_color_compute (GtkCssValue *value,
guint property_id,
GtkCssComputeContext *context)
{
GtkCssValue *resolved;
/* The computed value of the currentColor keyword is the computed
* value of the color property. If the currentColor keyword is
* set on the color property itself, it is treated as color: inherit.
* set on the color property itself, it is treated as color: inherit.
*/
if (property_id == GTK_CSS_PROPERTY_COLOR)
{
GtkCssValue *current;
if (parent_style)
current = parent_style->core->color;
if (context->parent_style)
current = context->parent_style->core->color;
else
current = NULL;
resolved = _gtk_css_color_value_resolve (value,
provider,
current,
NULL);
resolved = gtk_css_color_value_resolve (value,
context->provider,
current);
}
else if (value->type == COLOR_TYPE_LITERAL)
{
resolved = _gtk_css_value_ref (value);
resolved = gtk_css_value_ref (value);
}
else
{
GtkCssValue *current = style->core->color;
GtkCssValue *current = context->style->core->color;
resolved = _gtk_css_color_value_resolve (value,
provider,
current,
NULL);
resolved = gtk_css_color_value_resolve (value,
context->provider,
current);
}
if (resolved == NULL)
return gtk_css_value_color_get_fallback (property_id, provider, style, parent_style);
return gtk_css_value_color_get_fallback (property_id, context);
return resolved;
}
@@ -188,23 +180,23 @@ gtk_css_value_color_equal (const GtkCssValue *value1,
switch (value1->type)
{
case COLOR_TYPE_LITERAL:
return gdk_rgba_equal (&value1->sym_col.rgba, &value2->sym_col.rgba);
return gdk_rgba_equal (&value1->rgba, &value2->rgba);
case COLOR_TYPE_NAME:
return g_str_equal (value1->sym_col.name, value2->sym_col.name);
return g_str_equal (value1->name, value2->name);
case COLOR_TYPE_SHADE:
return value1->sym_col.shade.factor == value2->sym_col.shade.factor &&
_gtk_css_value_equal (value1->sym_col.shade.color,
value2->sym_col.shade.color);
return value1->shade.factor == value2->shade.factor &&
gtk_css_value_equal (value1->shade.color,
value2->shade.color);
case COLOR_TYPE_ALPHA:
return value1->sym_col.alpha.factor == value2->sym_col.alpha.factor &&
_gtk_css_value_equal (value1->sym_col.alpha.color,
value2->sym_col.alpha.color);
return value1->alpha.factor == value2->alpha.factor &&
gtk_css_value_equal (value1->alpha.color,
value2->alpha.color);
case COLOR_TYPE_MIX:
return value1->sym_col.mix.factor == value2->sym_col.mix.factor &&
_gtk_css_value_equal (value1->sym_col.mix.color1,
value2->sym_col.mix.color1) &&
_gtk_css_value_equal (value1->sym_col.mix.color2,
value2->sym_col.mix.color2);
return value1->mix.factor == value2->mix.factor &&
gtk_css_value_equal (value1->mix.color1,
value2->mix.color1) &&
gtk_css_value_equal (value1->mix.color2,
value2->mix.color2);
case COLOR_TYPE_CURRENT_COLOR:
return TRUE;
default:
@@ -219,7 +211,7 @@ gtk_css_value_color_transition (GtkCssValue *start,
guint property_id,
double progress)
{
return _gtk_css_color_value_new_mix (start, end, progress);
return gtk_css_color_value_new_mix (start, end, progress);
}
static void
@@ -230,23 +222,23 @@ gtk_css_value_color_print (const GtkCssValue *value,
{
case COLOR_TYPE_LITERAL:
{
char *s = gdk_rgba_to_string (&value->sym_col.rgba);
char *s = gdk_rgba_to_string (&value->rgba);
g_string_append (string, s);
g_free (s);
}
break;
case COLOR_TYPE_NAME:
g_string_append (string, "@");
g_string_append (string, value->sym_col.name);
g_string_append (string, value->name);
break;
case COLOR_TYPE_SHADE:
{
char factor[G_ASCII_DTOSTR_BUF_SIZE];
g_string_append (string, "shade(");
_gtk_css_value_print (value->sym_col.shade.color, string);
gtk_css_value_print (value->shade.color, string);
g_string_append (string, ", ");
g_ascii_dtostr (factor, sizeof (factor), value->sym_col.shade.factor);
g_ascii_dtostr (factor, sizeof (factor), value->shade.factor);
g_string_append (string, factor);
g_string_append (string, ")");
}
@@ -256,9 +248,9 @@ gtk_css_value_color_print (const GtkCssValue *value,
char factor[G_ASCII_DTOSTR_BUF_SIZE];
g_string_append (string, "alpha(");
_gtk_css_value_print (value->sym_col.alpha.color, string);
gtk_css_value_print (value->alpha.color, string);
g_string_append (string, ", ");
g_ascii_dtostr (factor, sizeof (factor), value->sym_col.alpha.factor);
g_ascii_dtostr (factor, sizeof (factor), value->alpha.factor);
g_string_append (string, factor);
g_string_append (string, ")");
}
@@ -268,11 +260,11 @@ gtk_css_value_color_print (const GtkCssValue *value,
char factor[G_ASCII_DTOSTR_BUF_SIZE];
g_string_append (string, "mix(");
_gtk_css_value_print (value->sym_col.mix.color1, string);
gtk_css_value_print (value->mix.color1, string);
g_string_append (string, ", ");
_gtk_css_value_print (value->sym_col.mix.color2, string);
gtk_css_value_print (value->mix.color2, string);
g_string_append (string, ", ");
g_ascii_dtostr (factor, sizeof (factor), value->sym_col.mix.factor);
g_ascii_dtostr (factor, sizeof (factor), value->mix.factor);
g_string_append (string, factor);
g_string_append (string, ")");
}
@@ -347,11 +339,11 @@ apply_mix (const GdkRGBA *in1,
}
}
GtkCssValue *
_gtk_css_color_value_resolve (GtkCssValue *color,
GtkStyleProvider *provider,
GtkCssValue *current,
GSList *cycle_list)
static GtkCssValue *
gtk_css_color_value_do_resolve (GtkCssValue *color,
GtkStyleProvider *provider,
GtkCssValue *current,
GSList *cycle_list)
{
GtkCssValue *value;
@@ -360,10 +352,10 @@ _gtk_css_color_value_resolve (GtkCssValue *color,
switch (color->type)
{
case COLOR_TYPE_LITERAL:
return _gtk_css_value_ref (color);
return gtk_css_value_ref (color);
case COLOR_TYPE_NAME:
{
GtkCssValue *named;
GtkCssValue *named;
GSList cycle = { color, cycle_list };
/* If color exists in cycle_list, we're currently resolving it.
@@ -371,13 +363,13 @@ _gtk_css_color_value_resolve (GtkCssValue *color,
if (g_slist_find (cycle_list, color))
return NULL;
named = gtk_style_provider_get_color (provider, color->sym_col.name);
if (named == NULL)
return NULL;
named = gtk_style_provider_get_color (provider, color->name);
if (named == NULL)
return NULL;
value = _gtk_css_color_value_resolve (named, provider, current, &cycle);
if (value == NULL)
return NULL;
value = gtk_css_color_value_do_resolve (named, provider, current, &cycle);
if (value == NULL)
return NULL;
}
break;
@@ -387,15 +379,15 @@ _gtk_css_color_value_resolve (GtkCssValue *color,
GtkCssValue *val;
GdkRGBA shade;
val = _gtk_css_color_value_resolve (color->sym_col.shade.color, provider, current, cycle_list);
val = gtk_css_color_value_do_resolve (color->shade.color, provider, current, cycle_list);
if (val == NULL)
return NULL;
c = gtk_css_color_value_get_rgba (val);
apply_shade (c, &shade, color->sym_col.shade.factor);
apply_shade (c, &shade, color->shade.factor);
value = _gtk_css_color_value_new_literal (&shade);
_gtk_css_value_unref (val);
value = gtk_css_color_value_new_literal (&shade);
gtk_css_value_unref (val);
}
break;
@@ -405,15 +397,15 @@ _gtk_css_color_value_resolve (GtkCssValue *color,
GtkCssValue *val;
GdkRGBA alpha;
val = _gtk_css_color_value_resolve (color->sym_col.alpha.color, provider, current, cycle_list);
val = gtk_css_color_value_do_resolve (color->alpha.color, provider, current, cycle_list);
if (val == NULL)
return NULL;
c = gtk_css_color_value_get_rgba (val);
apply_alpha (c, &alpha, color->sym_col.alpha.factor);
apply_alpha (c, &alpha, color->alpha.factor);
value = _gtk_css_color_value_new_literal (&alpha);
_gtk_css_value_unref (val);
value = gtk_css_color_value_new_literal (&alpha);
gtk_css_value_unref (val);
}
break;
@@ -423,45 +415,34 @@ _gtk_css_color_value_resolve (GtkCssValue *color,
GtkCssValue *val1, *val2;
GdkRGBA res;
val1 = _gtk_css_color_value_resolve (color->sym_col.mix.color1, provider, current, cycle_list);
val1 = gtk_css_color_value_do_resolve (color->mix.color1, provider, current, cycle_list);
if (val1 == NULL)
return NULL;
color1 = gtk_css_color_value_get_rgba (val1);
val2 = _gtk_css_color_value_resolve (color->sym_col.mix.color2, provider, current, cycle_list);
val2 = gtk_css_color_value_do_resolve (color->mix.color2, provider, current, cycle_list);
if (val2 == NULL)
return NULL;
color2 = gtk_css_color_value_get_rgba (val2);
apply_mix (color1, color2, &res, color->sym_col.mix.factor);
apply_mix (color1, color2, &res, color->mix.factor);
value = _gtk_css_color_value_new_literal (&res);
_gtk_css_value_unref (val1);
_gtk_css_value_unref (val2);
value = gtk_css_color_value_new_literal (&res);
gtk_css_value_unref (val1);
gtk_css_value_unref (val2);
}
break;
case COLOR_TYPE_CURRENT_COLOR:
if (current)
if (current == NULL)
{
return _gtk_css_value_ref (current);
}
else
{
GtkCssValue *initial = _gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (GTK_CSS_PROPERTY_COLOR));
current = _gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (GTK_CSS_PROPERTY_COLOR));
if (initial->class == &GTK_CSS_VALUE_COLOR)
{
return _gtk_css_color_value_resolve (initial,
provider,
NULL,
cycle_list);
}
else
{
return _gtk_css_value_ref (initial);
}
g_assert (current->class == &GTK_CSS_VALUE_COLOR);
g_assert (current->type == COLOR_TYPE_LITERAL);
}
value = gtk_css_value_ref (current);
break;
default:
value = NULL;
@@ -469,77 +450,85 @@ _gtk_css_color_value_resolve (GtkCssValue *color,
}
if (color->last_value != NULL &&
_gtk_css_value_equal (color->last_value, value))
gtk_css_value_equal (color->last_value, value))
{
_gtk_css_value_unref (value);
value = _gtk_css_value_ref (color->last_value);
gtk_css_value_unref (value);
value = gtk_css_value_ref (color->last_value);
}
else
{
if (color->last_value != NULL)
_gtk_css_value_unref (color->last_value);
color->last_value = _gtk_css_value_ref (value);
gtk_css_value_unref (color->last_value);
color->last_value = gtk_css_value_ref (value);
}
return value;
}
static GtkCssValue transparent_black_singleton = { &GTK_CSS_VALUE_COLOR, 1, TRUE, COLOR_TYPE_LITERAL, NULL,
.sym_col.rgba = {0, 0, 0, 0} };
static GtkCssValue white_singleton = { &GTK_CSS_VALUE_COLOR, 1, TRUE, COLOR_TYPE_LITERAL, NULL,
.sym_col.rgba = {1, 1, 1, 1} };
GtkCssValue *
gtk_css_color_value_resolve (GtkCssValue *color,
GtkStyleProvider *provider,
GtkCssValue *current)
{
return gtk_css_color_value_do_resolve (color, provider, current, NULL);
}
static GtkCssValue transparent_black_singleton = { &GTK_CSS_VALUE_COLOR, 1, TRUE, FALSE, COLOR_TYPE_LITERAL, NULL,
.rgba = {0, 0, 0, 0} };
static GtkCssValue white_singleton = { &GTK_CSS_VALUE_COLOR, 1, TRUE, FALSE, COLOR_TYPE_LITERAL, NULL,
.rgba = {1, 1, 1, 1} };
GtkCssValue *
gtk_css_color_value_new_transparent (void)
{
return _gtk_css_value_ref (&transparent_black_singleton);
return gtk_css_value_ref (&transparent_black_singleton);
}
GtkCssValue *
gtk_css_color_value_new_white (void)
{
return _gtk_css_value_ref (&white_singleton);
return gtk_css_value_ref (&white_singleton);
}
GtkCssValue *
_gtk_css_color_value_new_literal (const GdkRGBA *color)
gtk_css_color_value_new_literal (const GdkRGBA *color)
{
GtkCssValue *value;
g_return_val_if_fail (color != NULL, NULL);
if (gdk_rgba_equal (color, &white_singleton.sym_col.rgba))
return _gtk_css_value_ref (&white_singleton);
if (gdk_rgba_equal (color, &white_singleton.rgba))
return gtk_css_value_ref (&white_singleton);
if (gdk_rgba_equal (color, &transparent_black_singleton.sym_col.rgba))
return _gtk_css_value_ref (&transparent_black_singleton);
if (gdk_rgba_equal (color, &transparent_black_singleton.rgba))
return gtk_css_value_ref (&transparent_black_singleton);
value = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_COLOR);
value = gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_COLOR);
value->type = COLOR_TYPE_LITERAL;
value->is_computed = TRUE;
value->sym_col.rgba = *color;
value->rgba = *color;
return value;
}
GtkCssValue *
_gtk_css_color_value_new_name (const char *name)
gtk_css_color_value_new_name (const char *name)
{
GtkCssValue *value;
gtk_internal_return_val_if_fail (name != NULL, NULL);
value = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_COLOR);
value = gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_COLOR);
value->type = COLOR_TYPE_NAME;
value->sym_col.name = g_strdup (name);
value->name = g_strdup (name);
return value;
}
GtkCssValue *
_gtk_css_color_value_new_shade (GtkCssValue *color,
double factor)
gtk_css_color_value_new_shade (GtkCssValue *color,
double factor)
{
GtkCssValue *value;
@@ -549,22 +538,22 @@ _gtk_css_color_value_new_shade (GtkCssValue *color,
{
GdkRGBA c;
apply_shade (&color->sym_col.rgba, &c, factor);
apply_shade (&color->rgba, &c, factor);
return _gtk_css_color_value_new_literal (&c);
return gtk_css_color_value_new_literal (&c);
}
value = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_COLOR);
value = gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_COLOR);
value->type = COLOR_TYPE_SHADE;
value->sym_col.shade.color = _gtk_css_value_ref (color);
value->sym_col.shade.factor = factor;
value->shade.color = gtk_css_value_ref (color);
value->shade.factor = factor;
return value;
}
GtkCssValue *
_gtk_css_color_value_new_alpha (GtkCssValue *color,
double factor)
gtk_css_color_value_new_alpha (GtkCssValue *color,
double factor)
{
GtkCssValue *value;
@@ -574,23 +563,23 @@ _gtk_css_color_value_new_alpha (GtkCssValue *color,
{
GdkRGBA c;
apply_alpha (&color->sym_col.rgba, &c, factor);
apply_alpha (&color->rgba, &c, factor);
return _gtk_css_color_value_new_literal (&c);
return gtk_css_color_value_new_literal (&c);
}
value = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_COLOR);
value = gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_COLOR);
value->type = COLOR_TYPE_ALPHA;
value->sym_col.alpha.color = _gtk_css_value_ref (color);
value->sym_col.alpha.factor = factor;
value->alpha.color = gtk_css_value_ref (color);
value->alpha.factor = factor;
return value;
}
GtkCssValue *
_gtk_css_color_value_new_mix (GtkCssValue *color1,
GtkCssValue *color2,
double factor)
gtk_css_color_value_new_mix (GtkCssValue *color1,
GtkCssValue *color2,
double factor)
{
GtkCssValue *value;
@@ -602,30 +591,30 @@ _gtk_css_color_value_new_mix (GtkCssValue *color1,
{
GdkRGBA result;
apply_mix (&color1->sym_col.rgba, &color2->sym_col.rgba, &result, factor);
apply_mix (&color1->rgba, &color2->rgba, &result, factor);
return _gtk_css_color_value_new_literal (&result);
return gtk_css_color_value_new_literal (&result);
}
value = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_COLOR);
value = gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_COLOR);
value->type = COLOR_TYPE_MIX;
value->sym_col.mix.color1 = _gtk_css_value_ref (color1);
value->sym_col.mix.color2 = _gtk_css_value_ref (color2);
value->sym_col.mix.factor = factor;
value->mix.color1 = gtk_css_value_ref (color1);
value->mix.color2 = gtk_css_value_ref (color2);
value->mix.factor = factor;
return value;
}
GtkCssValue *
_gtk_css_color_value_new_current_color (void)
gtk_css_color_value_new_current_color (void)
{
static GtkCssValue current_color = { &GTK_CSS_VALUE_COLOR, 1, FALSE, COLOR_TYPE_CURRENT_COLOR, NULL, };
static GtkCssValue current_color = { &GTK_CSS_VALUE_COLOR, 1, FALSE, FALSE, COLOR_TYPE_CURRENT_COLOR, NULL, };
return _gtk_css_value_ref (&current_color);
return gtk_css_value_ref (&current_color);
}
typedef struct
typedef struct
{
GtkCssValue *color;
GtkCssValue *color2;
@@ -642,13 +631,13 @@ parse_color_mix (GtkCssParser *parser,
switch (arg)
{
case 0:
data->color = _gtk_css_color_value_parse (parser);
data->color = gtk_css_color_value_parse (parser);
if (data->color == NULL)
return 0;
return 1;
case 1:
data->color2 = _gtk_css_color_value_parse (parser);
data->color2 = gtk_css_color_value_parse (parser);
if (data->color2 == NULL)
return 0;
return 1;
@@ -673,7 +662,7 @@ parse_color_number (GtkCssParser *parser,
switch (arg)
{
case 0:
data->color = _gtk_css_color_value_parse (parser);
data->color = gtk_css_color_value_parse (parser);
if (data->color == NULL)
return 0;
return 1;
@@ -708,7 +697,7 @@ gtk_css_color_value_can_parse (GtkCssParser *parser)
}
GtkCssValue *
_gtk_css_color_value_parse (GtkCssParser *parser)
gtk_css_color_value_parse (GtkCssParser *parser)
{
ColorFunctionData data = { NULL, };
GtkCssValue *value;
@@ -716,13 +705,13 @@ _gtk_css_color_value_parse (GtkCssParser *parser)
if (gtk_css_parser_try_ident (parser, "currentColor"))
{
return _gtk_css_color_value_new_current_color ();
return gtk_css_color_value_new_current_color ();
}
else if (gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_AT_KEYWORD))
{
const GtkCssToken *token = gtk_css_parser_get_token (parser);
value = _gtk_css_color_value_new_name (gtk_css_token_get_string (token));
value = gtk_css_color_value_new_name (gtk_css_token_get_string (token));
gtk_css_parser_consume_token (parser);
return value;
@@ -730,7 +719,7 @@ _gtk_css_color_value_parse (GtkCssParser *parser)
else if (gtk_css_parser_has_function (parser, "lighter"))
{
if (gtk_css_parser_consume_function (parser, 1, 1, parse_color_number, &data))
value = _gtk_css_color_value_new_shade (data.color, 1.3);
value = gtk_css_color_value_new_shade (data.color, 1.3);
else
value = NULL;
@@ -740,7 +729,7 @@ _gtk_css_color_value_parse (GtkCssParser *parser)
else if (gtk_css_parser_has_function (parser, "darker"))
{
if (gtk_css_parser_consume_function (parser, 1, 1, parse_color_number, &data))
value = _gtk_css_color_value_new_shade (data.color, 0.7);
value = gtk_css_color_value_new_shade (data.color, 0.7);
else
value = NULL;
@@ -750,7 +739,7 @@ _gtk_css_color_value_parse (GtkCssParser *parser)
else if (gtk_css_parser_has_function (parser, "shade"))
{
if (gtk_css_parser_consume_function (parser, 2, 2, parse_color_number, &data))
value = _gtk_css_color_value_new_shade (data.color, data.value);
value = gtk_css_color_value_new_shade (data.color, data.value);
else
value = NULL;
@@ -760,7 +749,7 @@ _gtk_css_color_value_parse (GtkCssParser *parser)
else if (gtk_css_parser_has_function (parser, "alpha"))
{
if (gtk_css_parser_consume_function (parser, 2, 2, parse_color_number, &data))
value = _gtk_css_color_value_new_alpha (data.color, data.value);
value = gtk_css_color_value_new_alpha (data.color, data.value);
else
value = NULL;
@@ -770,7 +759,7 @@ _gtk_css_color_value_parse (GtkCssParser *parser)
else if (gtk_css_parser_has_function (parser, "mix"))
{
if (gtk_css_parser_consume_function (parser, 3, 3, parse_color_mix, &data))
value = _gtk_css_color_value_new_mix (data.color, data.color2, data.value);
value = gtk_css_color_value_new_mix (data.color, data.color2, data.value);
else
value = NULL;
@@ -780,7 +769,7 @@ _gtk_css_color_value_parse (GtkCssParser *parser)
}
if (gdk_rgba_parser_parse (parser, &rgba))
return _gtk_css_color_value_new_literal (&rgba);
return gtk_css_color_value_new_literal (&rgba);
else
return NULL;
}
@@ -791,5 +780,5 @@ gtk_css_color_value_get_rgba (const GtkCssValue *color)
g_assert (color->class == &GTK_CSS_VALUE_COLOR);
g_assert (color->type == COLOR_TYPE_LITERAL);
return &color->sym_col.rgba;
return &color->rgba;
}

View File

@@ -27,24 +27,23 @@ G_BEGIN_DECLS
GtkCssValue * gtk_css_color_value_new_transparent (void) G_GNUC_PURE;
GtkCssValue * gtk_css_color_value_new_white (void) G_GNUC_PURE;
GtkCssValue * _gtk_css_color_value_new_literal (const GdkRGBA *color) G_GNUC_PURE;
GtkCssValue * _gtk_css_color_value_new_name (const char *name) G_GNUC_PURE;
GtkCssValue * _gtk_css_color_value_new_shade (GtkCssValue *color,
GtkCssValue * gtk_css_color_value_new_literal (const GdkRGBA *color) G_GNUC_PURE;
GtkCssValue * gtk_css_color_value_new_name (const char *name) G_GNUC_PURE;
GtkCssValue * gtk_css_color_value_new_shade (GtkCssValue *color,
double factor) G_GNUC_PURE;
GtkCssValue * _gtk_css_color_value_new_alpha (GtkCssValue *color,
GtkCssValue * gtk_css_color_value_new_alpha (GtkCssValue *color,
double factor) G_GNUC_PURE;
GtkCssValue * _gtk_css_color_value_new_mix (GtkCssValue *color1,
GtkCssValue * gtk_css_color_value_new_mix (GtkCssValue *color1,
GtkCssValue *color2,
double factor) G_GNUC_PURE;
GtkCssValue * _gtk_css_color_value_new_current_color (void) G_GNUC_PURE;
GtkCssValue * gtk_css_color_value_new_current_color (void) G_GNUC_PURE;
gboolean gtk_css_color_value_can_parse (GtkCssParser *parser);
GtkCssValue * _gtk_css_color_value_parse (GtkCssParser *parser);
GtkCssValue * gtk_css_color_value_parse (GtkCssParser *parser);
GtkCssValue * _gtk_css_color_value_resolve (GtkCssValue *color,
GtkCssValue * gtk_css_color_value_resolve (GtkCssValue *color,
GtkStyleProvider *provider,
GtkCssValue *current,
GSList *cycle_list);
GtkCssValue *current);
const GdkRGBA * gtk_css_color_value_get_rgba (const GtkCssValue *color) G_GNUC_CONST;

View File

@@ -30,28 +30,26 @@ struct _GtkCssValue {
static void
gtk_css_value_corner_free (GtkCssValue *value)
{
_gtk_css_value_unref (value->x);
_gtk_css_value_unref (value->y);
gtk_css_value_unref (value->x);
gtk_css_value_unref (value->y);
g_free (value);
}
static GtkCssValue *
gtk_css_value_corner_compute (GtkCssValue *corner,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_value_corner_compute (GtkCssValue *corner,
guint property_id,
GtkCssComputeContext *context)
{
GtkCssValue *x, *y;
x = _gtk_css_value_compute (corner->x, property_id, provider, style, parent_style);
y = _gtk_css_value_compute (corner->y, property_id, provider, style, parent_style);
x = gtk_css_value_compute (corner->x, property_id, context);
y = gtk_css_value_compute (corner->y, property_id, context);
if (x == corner->x && y == corner->y)
{
_gtk_css_value_unref (x);
_gtk_css_value_unref (y);
return _gtk_css_value_ref (corner);
gtk_css_value_unref (x);
gtk_css_value_unref (y);
return gtk_css_value_ref (corner);
}
return _gtk_css_corner_value_new (x, y);
@@ -61,8 +59,8 @@ static gboolean
gtk_css_value_corner_equal (const GtkCssValue *corner1,
const GtkCssValue *corner2)
{
return _gtk_css_value_equal (corner1->x, corner2->x)
&& _gtk_css_value_equal (corner1->y, corner2->y);
return gtk_css_value_equal (corner1->x, corner2->x)
&& gtk_css_value_equal (corner1->y, corner2->y);
}
static GtkCssValue *
@@ -73,13 +71,13 @@ gtk_css_value_corner_transition (GtkCssValue *start,
{
GtkCssValue *x, *y;
x = _gtk_css_value_transition (start->x, end->x, property_id, progress);
x = gtk_css_value_transition (start->x, end->x, property_id, progress);
if (x == NULL)
return NULL;
y = _gtk_css_value_transition (start->y, end->y, property_id, progress);
y = gtk_css_value_transition (start->y, end->y, property_id, progress);
if (y == NULL)
{
_gtk_css_value_unref (x);
gtk_css_value_unref (x);
return NULL;
}
@@ -90,11 +88,11 @@ static void
gtk_css_value_corner_print (const GtkCssValue *corner,
GString *string)
{
_gtk_css_value_print (corner->x, string);
if (!_gtk_css_value_equal (corner->x, corner->y))
gtk_css_value_print (corner->x, string);
if (!gtk_css_value_equal (corner->x, corner->y))
{
g_string_append_c (string, ' ');
_gtk_css_value_print (corner->y, string);
gtk_css_value_print (corner->y, string);
}
}
@@ -110,14 +108,14 @@ static const GtkCssValueClass GTK_CSS_VALUE_CORNER = {
};
static GtkCssValue corner_singletons[] = {
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, FALSE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, FALSE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, FALSE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, FALSE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, FALSE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, FALSE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, FALSE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, FALSE, NULL, NULL },
};
static inline void
@@ -160,7 +158,7 @@ _gtk_css_corner_value_new (GtkCssValue *x,
}
}
result = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_CORNER);
result = gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_CORNER);
result->x = x;
result->y = y;
@@ -180,7 +178,7 @@ _gtk_css_corner_value_parse (GtkCssParser *parser)
return NULL;
if (!gtk_css_number_value_can_parse (parser))
y = _gtk_css_value_ref (x);
y = gtk_css_value_ref (x);
else
{
y = _gtk_css_number_value_parse (parser,
@@ -189,7 +187,7 @@ _gtk_css_corner_value_parse (GtkCssParser *parser)
| GTK_CSS_PARSE_LENGTH);
if (y == NULL)
{
_gtk_css_value_unref (x);
gtk_css_value_unref (x);
return NULL;
}
}
@@ -226,3 +224,4 @@ gtk_css_corner_value_is_zero (const GtkCssValue *corner)
return gtk_css_dimension_value_is_zero (corner->x) &&
gtk_css_dimension_value_is_zero (corner->y);
}

View File

@@ -0,0 +1,161 @@
/*
* Copyright (C) 2023 GNOME Foundation Inc.
*
* 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: Alice Mikhaylenko <alicem@gnome.org>
*/
#include "gtkcsscustompropertypoolprivate.h"
struct _GtkCssCustomPropertyPool
{
GObject parent_instance;
GArray *names;
GHashTable *name_mappings;
};
struct _GtkCssCustomPropertyName
{
int ref_count;
char *name;
};
typedef struct _GtkCssCustomPropertyName GtkCssCustomPropertyName;
static GtkCssCustomPropertyPool *instance = NULL;
G_DEFINE_FINAL_TYPE (GtkCssCustomPropertyPool, gtk_css_custom_property_pool, G_TYPE_OBJECT)
static void
clear_custom_property_name (GtkCssCustomPropertyName *name)
{
g_clear_pointer (&name->name, g_free);
}
static void
gtk_css_custom_property_pool_finalize (GObject *object)
{
GtkCssCustomPropertyPool *self = (GtkCssCustomPropertyPool *)object;
g_hash_table_unref (self->name_mappings);
g_array_unref (self->names);
G_OBJECT_CLASS (gtk_css_custom_property_pool_parent_class)->finalize (object);
}
static void
gtk_css_custom_property_pool_class_init (GtkCssCustomPropertyPoolClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gtk_css_custom_property_pool_finalize;
}
static void
gtk_css_custom_property_pool_init (GtkCssCustomPropertyPool *self)
{
self->name_mappings = g_hash_table_new (g_str_hash, g_str_equal);
self->names = g_array_new (FALSE, FALSE, sizeof (GtkCssCustomPropertyName));
g_array_set_clear_func (self->names, (GDestroyNotify) clear_custom_property_name);
}
GtkCssCustomPropertyPool *
gtk_css_custom_property_pool_get (void)
{
if (instance == NULL)
instance = g_object_new (GTK_TYPE_CSS_CUSTOM_PROPERTY_POOL, NULL);
return instance;
}
int
gtk_css_custom_property_pool_add (GtkCssCustomPropertyPool *self,
const char *str)
{
GtkCssCustomPropertyName name;
int id;
id = gtk_css_custom_property_pool_lookup (self, str);
if (id > 0)
return gtk_css_custom_property_pool_ref (self, id);
name.ref_count = 1;
name.name = g_strdup (str);
// TODO reuse slots after they're gone
g_array_append_val (self->names, name);
id = self->names->len;
g_hash_table_insert (self->name_mappings, (char *) name.name, GINT_TO_POINTER (id));
return id;
}
int
gtk_css_custom_property_pool_lookup (GtkCssCustomPropertyPool *self,
const char *str)
{
gpointer id;
id = g_hash_table_lookup (self->name_mappings, str);
return GPOINTER_TO_INT (id);
}
int
gtk_css_custom_property_pool_ref (GtkCssCustomPropertyPool *self,
int id)
{
GtkCssCustomPropertyName *name;
name = &g_array_index (self->names, GtkCssCustomPropertyName, id - 1);
name->ref_count++;
return id;
}
void
gtk_css_custom_property_pool_unref (GtkCssCustomPropertyPool *self,
int id)
{
GtkCssCustomPropertyName *name;
name = &g_array_index (self->names, GtkCssCustomPropertyName, id - 1);
g_assert (name->ref_count > 0);
name->ref_count--;
if (name->ref_count == 0)
{
g_hash_table_remove (self->name_mappings, name->name);
clear_custom_property_name (name);
}
}
const char *
gtk_css_custom_property_pool_get_name (GtkCssCustomPropertyPool *self,
int id)
{
GtkCssCustomPropertyName *name;
name = &g_array_index (self->names, GtkCssCustomPropertyName, id - 1);
return name->name;
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright (C) 2023 GNOME Foundation Inc.
*
* 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: Alice Mikhaylenko <alicem@gnome.org>
*/
#pragma once
#include <glib-object.h>
G_BEGIN_DECLS
#define GTK_TYPE_CSS_CUSTOM_PROPERTY_POOL (gtk_css_custom_property_pool_get_type())
G_DECLARE_FINAL_TYPE (GtkCssCustomPropertyPool, gtk_css_custom_property_pool, GTK, CSS_CUSTOM_PROPERTY_POOL, GObject)
GtkCssCustomPropertyPool *gtk_css_custom_property_pool_get (void);
int gtk_css_custom_property_pool_add (GtkCssCustomPropertyPool *self,
const char *str);
int gtk_css_custom_property_pool_lookup (GtkCssCustomPropertyPool *self,
const char *str);
const char * gtk_css_custom_property_pool_get_name (GtkCssCustomPropertyPool *self,
int id);
int gtk_css_custom_property_pool_ref (GtkCssCustomPropertyPool *self,
int id);
void gtk_css_custom_property_pool_unref (GtkCssCustomPropertyPool *self,
int id);
G_END_DECLS

View File

@@ -50,13 +50,11 @@ gtk_css_value_ease_free (GtkCssValue *value)
}
static GtkCssValue *
gtk_css_value_ease_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_value_ease_compute (GtkCssValue *value,
guint property_id,
GtkCssComputeContext *context)
{
return _gtk_css_value_ref (value);
return gtk_css_value_ref (value);
}
static gboolean
@@ -158,7 +156,7 @@ _gtk_css_ease_value_new_cubic_bezier (double x1,
g_return_val_if_fail (x2 >= 0.0, NULL);
g_return_val_if_fail (x2 <= 1.0, NULL);
value = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_EASE);
value = gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_EASE);
value->type = GTK_CSS_EASE_CUBIC_BEZIER;
value->u.cubic.x1 = x1;
@@ -178,7 +176,7 @@ _gtk_css_ease_value_new_steps (guint n_steps,
g_return_val_if_fail (n_steps > 0, NULL);
value = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_EASE);
value = gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_EASE);
value->type = GTK_CSS_EASE_STEPS;
value->u.steps.steps = n_steps;
@@ -407,3 +405,4 @@ _gtk_css_ease_value_transform (const GtkCssValue *ease,
}

View File

@@ -41,13 +41,11 @@ gtk_css_value_enum_free (GtkCssValue *value)
}
static GtkCssValue *
gtk_css_value_enum_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_value_enum_compute (GtkCssValue *value,
guint property_id,
GtkCssComputeContext *context)
{
return _gtk_css_value_ref (value);
return gtk_css_value_ref (value);
}
static gboolean
@@ -87,16 +85,16 @@ static const GtkCssValueClass GTK_CSS_VALUE_BORDER_STYLE = {
};
static GtkCssValue border_style_values[] = {
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, GTK_BORDER_STYLE_NONE, "none" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, GTK_BORDER_STYLE_SOLID, "solid" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, GTK_BORDER_STYLE_INSET, "inset" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, GTK_BORDER_STYLE_OUTSET, "outset" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, GTK_BORDER_STYLE_HIDDEN, "hidden" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, GTK_BORDER_STYLE_DOTTED, "dotted" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, GTK_BORDER_STYLE_DASHED, "dashed" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, GTK_BORDER_STYLE_DOUBLE, "double" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, GTK_BORDER_STYLE_GROOVE, "groove" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, GTK_BORDER_STYLE_RIDGE, "ridge" }
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_NONE, "none" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_SOLID, "solid" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_INSET, "inset" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_OUTSET, "outset" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_HIDDEN, "hidden" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_DOTTED, "dotted" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_DASHED, "dashed" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_DOUBLE, "double" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_GROOVE, "groove" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_RIDGE, "ridge" }
};
GtkCssValue *
@@ -104,7 +102,7 @@ _gtk_css_border_style_value_new (GtkBorderStyle border_style)
{
g_return_val_if_fail (border_style < G_N_ELEMENTS (border_style_values), NULL);
return _gtk_css_value_ref (&border_style_values[border_style]);
return gtk_css_value_ref (&border_style_values[border_style]);
}
GtkCssValue *
@@ -117,7 +115,7 @@ _gtk_css_border_style_value_try_parse (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (border_style_values); i++)
{
if (gtk_css_parser_try_ident (parser, border_style_values[i].name))
return _gtk_css_value_ref (&border_style_values[i]);
return gtk_css_value_ref (&border_style_values[i]);
}
return NULL;
@@ -145,22 +143,22 @@ static const GtkCssValueClass GTK_CSS_VALUE_BLEND_MODE = {
};
static GtkCssValue blend_mode_values[] = {
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_DEFAULT, "normal" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_MULTIPLY, "multiply" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_SCREEN, "screen" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_OVERLAY, "overlay" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_DARKEN, "darken" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_LIGHTEN, "lighten" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_COLOR_DODGE, "color-dodge" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_COLOR_BURN, "color-burn" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_HARD_LIGHT, "hard-light" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_SOFT_LIGHT, "soft-light" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_DIFFERENCE, "difference" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_EXCLUSION, "exclusion" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_COLOR, "color" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_HUE, "hue" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_SATURATION, "saturation" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_LUMINOSITY, "luminosity" }
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_DEFAULT, "normal" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_MULTIPLY, "multiply" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_SCREEN, "screen" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_OVERLAY, "overlay" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_DARKEN, "darken" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_LIGHTEN, "lighten" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_COLOR_DODGE, "color-dodge" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_COLOR_BURN, "color-burn" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_HARD_LIGHT, "hard-light" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_SOFT_LIGHT, "soft-light" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_DIFFERENCE, "difference" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_EXCLUSION, "exclusion" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_COLOR, "color" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_HUE, "hue" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_SATURATION, "saturation" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_LUMINOSITY, "luminosity" }
};
GtkCssValue *
@@ -168,7 +166,7 @@ _gtk_css_blend_mode_value_new (GskBlendMode blend_mode)
{
g_return_val_if_fail (blend_mode < G_N_ELEMENTS (blend_mode_values), NULL);
return _gtk_css_value_ref (&blend_mode_values[blend_mode]);
return gtk_css_value_ref (&blend_mode_values[blend_mode]);
}
GtkCssValue *
@@ -181,7 +179,7 @@ _gtk_css_blend_mode_value_try_parse (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (blend_mode_values); i++)
{
if (gtk_css_parser_try_ident (parser, blend_mode_values[i].name))
return _gtk_css_value_ref (&blend_mode_values[i]);
return gtk_css_value_ref (&blend_mode_values[i]);
}
return NULL;
@@ -229,12 +227,14 @@ gtk_css_font_size_get_default_px (GtkStyleProvider *provider,
}
static GtkCssValue *
gtk_css_value_font_size_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_value_font_size_compute (GtkCssValue *value,
guint property_id,
GtkCssComputeContext *context)
{
GtkStyleProvider *provider = context->provider;
GtkCssStyle *style = context->style;
GtkCssStyle *parent_style = context->parent_style;
double font_size;
switch (value->value)
@@ -296,15 +296,15 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_SIZE = {
};
static GtkCssValue font_size_values[] = {
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_SMALLER, "smaller" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_LARGER, "larger" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_XX_SMALL, "xx-small" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_X_SMALL, "x-small" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_SMALL, "small" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_MEDIUM, "medium" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_LARGE, "large" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_X_LARGE, "x-large" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_XX_LARGE, "xx-large" }
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_SMALLER, "smaller" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_LARGER, "larger" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_XX_SMALL, "xx-small" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_X_SMALL, "x-small" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_SMALL, "small" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_MEDIUM, "medium" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_LARGE, "large" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_X_LARGE, "x-large" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_XX_LARGE, "xx-large" }
};
GtkCssValue *
@@ -312,7 +312,7 @@ _gtk_css_font_size_value_new (GtkCssFontSize font_size)
{
g_return_val_if_fail (font_size < G_N_ELEMENTS (font_size_values), NULL);
return _gtk_css_value_ref (&font_size_values[font_size]);
return gtk_css_value_ref (&font_size_values[font_size]);
}
GtkCssValue *
@@ -325,7 +325,7 @@ _gtk_css_font_size_value_try_parse (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (font_size_values); i++)
{
if (gtk_css_parser_try_ident (parser, font_size_values[i].name))
return _gtk_css_value_ref (&font_size_values[i]);
return gtk_css_value_ref (&font_size_values[i]);
}
return NULL;
@@ -353,9 +353,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_STYLE = {
};
static GtkCssValue font_style_values[] = {
{ &GTK_CSS_VALUE_FONT_STYLE, 1, TRUE, PANGO_STYLE_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_STYLE, 1, TRUE, PANGO_STYLE_OBLIQUE, "oblique" },
{ &GTK_CSS_VALUE_FONT_STYLE, 1, TRUE, PANGO_STYLE_ITALIC, "italic" }
{ &GTK_CSS_VALUE_FONT_STYLE, 1, TRUE, FALSE, PANGO_STYLE_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_STYLE, 1, TRUE, FALSE, PANGO_STYLE_OBLIQUE, "oblique" },
{ &GTK_CSS_VALUE_FONT_STYLE, 1, TRUE, FALSE, PANGO_STYLE_ITALIC, "italic" }
};
GtkCssValue *
@@ -363,7 +363,7 @@ _gtk_css_font_style_value_new (PangoStyle font_style)
{
g_return_val_if_fail (font_style < G_N_ELEMENTS (font_style_values), NULL);
return _gtk_css_value_ref (&font_style_values[font_style]);
return gtk_css_value_ref (&font_style_values[font_style]);
}
GtkCssValue *
@@ -376,7 +376,7 @@ _gtk_css_font_style_value_try_parse (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (font_style_values); i++)
{
if (gtk_css_parser_try_ident (parser, font_style_values[i].name))
return _gtk_css_value_ref (&font_style_values[i]);
return gtk_css_value_ref (&font_style_values[i]);
}
return NULL;
@@ -396,20 +396,18 @@ _gtk_css_font_style_value_get (const GtkCssValue *value)
#define LIGHTER -2
static GtkCssValue *
gtk_css_value_font_weight_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_value_font_weight_compute (GtkCssValue *value,
guint property_id,
GtkCssComputeContext *context)
{
PangoWeight new_weight;
int parent_value;
if (value->value >= 0)
return _gtk_css_value_ref (value);
return gtk_css_value_ref (value);
if (parent_style)
parent_value = _gtk_css_number_value_get (parent_style->font->font_weight, 100);
if (context->parent_style)
parent_value = _gtk_css_number_value_get (context->parent_style->font->font_weight, 100);
else
parent_value = 400;
@@ -452,8 +450,8 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_WEIGHT = {
};
static GtkCssValue font_weight_values[] = {
{ &GTK_CSS_VALUE_FONT_WEIGHT, 1, FALSE, BOLDER, "bolder" },
{ &GTK_CSS_VALUE_FONT_WEIGHT, 1, FALSE, LIGHTER, "lighter" },
{ &GTK_CSS_VALUE_FONT_WEIGHT, 1, FALSE, FALSE, BOLDER, "bolder" },
{ &GTK_CSS_VALUE_FONT_WEIGHT, 1, FALSE, FALSE, LIGHTER, "lighter" },
};
GtkCssValue *
@@ -466,7 +464,7 @@ gtk_css_font_weight_value_try_parse (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (font_weight_values); i++)
{
if (gtk_css_parser_try_ident (parser, font_weight_values[i].name))
return _gtk_css_value_ref (&font_weight_values[i]);
return gtk_css_value_ref (&font_weight_values[i]);
}
if (gtk_css_parser_try_ident (parser, "normal"))
@@ -502,15 +500,15 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_STRETCH = {
};
static GtkCssValue font_stretch_values[] = {
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_ULTRA_CONDENSED, "ultra-condensed" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_EXTRA_CONDENSED, "extra-condensed" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_CONDENSED, "condensed" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_SEMI_CONDENSED, "semi-condensed" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_SEMI_EXPANDED, "semi-expanded" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_EXPANDED, "expanded" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_EXTRA_EXPANDED, "extra-expanded" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_ULTRA_EXPANDED, "ultra-expanded" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_ULTRA_CONDENSED, "ultra-condensed" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_EXTRA_CONDENSED, "extra-condensed" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_CONDENSED, "condensed" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_SEMI_CONDENSED, "semi-condensed" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_SEMI_EXPANDED, "semi-expanded" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_EXPANDED, "expanded" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_EXTRA_EXPANDED, "extra-expanded" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_ULTRA_EXPANDED, "ultra-expanded" },
};
GtkCssValue *
@@ -518,7 +516,7 @@ _gtk_css_font_stretch_value_new (PangoStretch font_stretch)
{
g_return_val_if_fail (font_stretch < G_N_ELEMENTS (font_stretch_values), NULL);
return _gtk_css_value_ref (&font_stretch_values[font_stretch]);
return gtk_css_value_ref (&font_stretch_values[font_stretch]);
}
GtkCssValue *
@@ -531,7 +529,7 @@ _gtk_css_font_stretch_value_try_parse (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (font_stretch_values); i++)
{
if (gtk_css_parser_try_ident (parser, font_stretch_values[i].name))
return _gtk_css_value_ref (&font_stretch_values[i]);
return gtk_css_value_ref (&font_stretch_values[i]);
}
return NULL;
@@ -559,9 +557,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_TEXT_DECORATION_STYLE = {
};
static GtkCssValue text_decoration_style_values[] = {
{ &GTK_CSS_VALUE_TEXT_DECORATION_STYLE, 1, TRUE, GTK_CSS_TEXT_DECORATION_STYLE_SOLID, "solid" },
{ &GTK_CSS_VALUE_TEXT_DECORATION_STYLE, 1, TRUE, GTK_CSS_TEXT_DECORATION_STYLE_DOUBLE, "double" },
{ &GTK_CSS_VALUE_TEXT_DECORATION_STYLE, 1, TRUE, GTK_CSS_TEXT_DECORATION_STYLE_WAVY, "wavy" },
{ &GTK_CSS_VALUE_TEXT_DECORATION_STYLE, 1, TRUE, FALSE, GTK_CSS_TEXT_DECORATION_STYLE_SOLID, "solid" },
{ &GTK_CSS_VALUE_TEXT_DECORATION_STYLE, 1, TRUE, FALSE, GTK_CSS_TEXT_DECORATION_STYLE_DOUBLE, "double" },
{ &GTK_CSS_VALUE_TEXT_DECORATION_STYLE, 1, TRUE, FALSE, GTK_CSS_TEXT_DECORATION_STYLE_WAVY, "wavy" },
};
GtkCssValue *
@@ -569,7 +567,7 @@ _gtk_css_text_decoration_style_value_new (GtkTextDecorationStyle style)
{
g_return_val_if_fail (style < G_N_ELEMENTS (text_decoration_style_values), NULL);
return _gtk_css_value_ref (&text_decoration_style_values[style]);
return gtk_css_value_ref (&text_decoration_style_values[style]);
}
GtkCssValue *
@@ -582,7 +580,7 @@ _gtk_css_text_decoration_style_value_try_parse (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (text_decoration_style_values); i++)
{
if (gtk_css_parser_try_ident (parser, text_decoration_style_values[i].name))
return _gtk_css_value_ref (&text_decoration_style_values[i]);
return gtk_css_value_ref (&text_decoration_style_values[i]);
}
return NULL;
@@ -610,9 +608,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_AREA = {
};
static GtkCssValue area_values[] = {
{ &GTK_CSS_VALUE_AREA, 1, TRUE, GTK_CSS_AREA_BORDER_BOX, "border-box" },
{ &GTK_CSS_VALUE_AREA, 1, TRUE, GTK_CSS_AREA_PADDING_BOX, "padding-box" },
{ &GTK_CSS_VALUE_AREA, 1, TRUE, GTK_CSS_AREA_CONTENT_BOX, "content-box" }
{ &GTK_CSS_VALUE_AREA, 1, TRUE, FALSE, GTK_CSS_AREA_BORDER_BOX, "border-box" },
{ &GTK_CSS_VALUE_AREA, 1, TRUE, FALSE, GTK_CSS_AREA_PADDING_BOX, "padding-box" },
{ &GTK_CSS_VALUE_AREA, 1, TRUE, FALSE, GTK_CSS_AREA_CONTENT_BOX, "content-box" }
};
GtkCssValue *
@@ -623,7 +621,7 @@ _gtk_css_area_value_new (GtkCssArea area)
for (i = 0; i < G_N_ELEMENTS (area_values); i++)
{
if (area_values[i].value == area)
return _gtk_css_value_ref (&area_values[i]);
return gtk_css_value_ref (&area_values[i]);
}
g_return_val_if_reached (NULL);
@@ -639,7 +637,7 @@ _gtk_css_area_value_try_parse (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (area_values); i++)
{
if (gtk_css_parser_try_ident (parser, area_values[i].name))
return _gtk_css_value_ref (&area_values[i]);
return gtk_css_value_ref (&area_values[i]);
}
return NULL;
@@ -667,10 +665,10 @@ static const GtkCssValueClass GTK_CSS_VALUE_DIRECTION = {
};
static GtkCssValue direction_values[] = {
{ &GTK_CSS_VALUE_DIRECTION, 1, TRUE, GTK_CSS_DIRECTION_NORMAL, "normal" },
{ &GTK_CSS_VALUE_DIRECTION, 1, TRUE, GTK_CSS_DIRECTION_REVERSE, "reverse" },
{ &GTK_CSS_VALUE_DIRECTION, 1, TRUE, GTK_CSS_DIRECTION_ALTERNATE, "alternate" },
{ &GTK_CSS_VALUE_DIRECTION, 1, TRUE, GTK_CSS_DIRECTION_ALTERNATE_REVERSE, "alternate-reverse" }
{ &GTK_CSS_VALUE_DIRECTION, 1, TRUE, FALSE, GTK_CSS_DIRECTION_NORMAL, "normal" },
{ &GTK_CSS_VALUE_DIRECTION, 1, TRUE, FALSE, GTK_CSS_DIRECTION_REVERSE, "reverse" },
{ &GTK_CSS_VALUE_DIRECTION, 1, TRUE, FALSE, GTK_CSS_DIRECTION_ALTERNATE, "alternate" },
{ &GTK_CSS_VALUE_DIRECTION, 1, TRUE, FALSE, GTK_CSS_DIRECTION_ALTERNATE_REVERSE, "alternate-reverse" }
};
GtkCssValue *
@@ -681,7 +679,7 @@ _gtk_css_direction_value_new (GtkCssDirection direction)
for (i = 0; i < G_N_ELEMENTS (direction_values); i++)
{
if (direction_values[i].value == direction)
return _gtk_css_value_ref (&direction_values[i]);
return gtk_css_value_ref (&direction_values[i]);
}
g_return_val_if_reached (NULL);
@@ -700,7 +698,7 @@ _gtk_css_direction_value_try_parse (GtkCssParser *parser)
for (i = G_N_ELEMENTS (direction_values) - 1; i >= 0; i--)
{
if (gtk_css_parser_try_ident (parser, direction_values[i].name))
return _gtk_css_value_ref (&direction_values[i]);
return gtk_css_value_ref (&direction_values[i]);
}
return NULL;
@@ -728,8 +726,8 @@ static const GtkCssValueClass GTK_CSS_VALUE_PLAY_STATE = {
};
static GtkCssValue play_state_values[] = {
{ &GTK_CSS_VALUE_PLAY_STATE, 1, TRUE, GTK_CSS_PLAY_STATE_RUNNING, "running" },
{ &GTK_CSS_VALUE_PLAY_STATE, 1, TRUE, GTK_CSS_PLAY_STATE_PAUSED, "paused" }
{ &GTK_CSS_VALUE_PLAY_STATE, 1, TRUE, FALSE, GTK_CSS_PLAY_STATE_RUNNING, "running" },
{ &GTK_CSS_VALUE_PLAY_STATE, 1, TRUE, FALSE, GTK_CSS_PLAY_STATE_PAUSED, "paused" }
};
GtkCssValue *
@@ -740,7 +738,7 @@ _gtk_css_play_state_value_new (GtkCssPlayState play_state)
for (i = 0; i < G_N_ELEMENTS (play_state_values); i++)
{
if (play_state_values[i].value == play_state)
return _gtk_css_value_ref (&play_state_values[i]);
return gtk_css_value_ref (&play_state_values[i]);
}
g_return_val_if_reached (NULL);
@@ -756,7 +754,7 @@ _gtk_css_play_state_value_try_parse (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (play_state_values); i++)
{
if (gtk_css_parser_try_ident (parser, play_state_values[i].name))
return _gtk_css_value_ref (&play_state_values[i]);
return gtk_css_value_ref (&play_state_values[i]);
}
return NULL;
@@ -784,10 +782,10 @@ static const GtkCssValueClass GTK_CSS_VALUE_FILL_MODE = {
};
static GtkCssValue fill_mode_values[] = {
{ &GTK_CSS_VALUE_FILL_MODE, 1, TRUE, GTK_CSS_FILL_NONE, "none" },
{ &GTK_CSS_VALUE_FILL_MODE, 1, TRUE, GTK_CSS_FILL_FORWARDS, "forwards" },
{ &GTK_CSS_VALUE_FILL_MODE, 1, TRUE, GTK_CSS_FILL_BACKWARDS, "backwards" },
{ &GTK_CSS_VALUE_FILL_MODE, 1, TRUE, GTK_CSS_FILL_BOTH, "both" }
{ &GTK_CSS_VALUE_FILL_MODE, 1, TRUE, FALSE, GTK_CSS_FILL_NONE, "none" },
{ &GTK_CSS_VALUE_FILL_MODE, 1, TRUE, FALSE, GTK_CSS_FILL_FORWARDS, "forwards" },
{ &GTK_CSS_VALUE_FILL_MODE, 1, TRUE, FALSE, GTK_CSS_FILL_BACKWARDS, "backwards" },
{ &GTK_CSS_VALUE_FILL_MODE, 1, TRUE, FALSE, GTK_CSS_FILL_BOTH, "both" }
};
GtkCssValue *
@@ -798,7 +796,7 @@ _gtk_css_fill_mode_value_new (GtkCssFillMode fill_mode)
for (i = 0; i < G_N_ELEMENTS (fill_mode_values); i++)
{
if (fill_mode_values[i].value == fill_mode)
return _gtk_css_value_ref (&fill_mode_values[i]);
return gtk_css_value_ref (&fill_mode_values[i]);
}
g_return_val_if_reached (NULL);
@@ -814,7 +812,7 @@ _gtk_css_fill_mode_value_try_parse (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (fill_mode_values); i++)
{
if (gtk_css_parser_try_ident (parser, fill_mode_values[i].name))
return _gtk_css_value_ref (&fill_mode_values[i]);
return gtk_css_value_ref (&fill_mode_values[i]);
}
return NULL;
@@ -842,9 +840,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_ICON_STYLE = {
};
static GtkCssValue icon_style_values[] = {
{ &GTK_CSS_VALUE_ICON_STYLE, 1, TRUE, GTK_CSS_ICON_STYLE_REQUESTED, "requested" },
{ &GTK_CSS_VALUE_ICON_STYLE, 1, TRUE, GTK_CSS_ICON_STYLE_REGULAR, "regular" },
{ &GTK_CSS_VALUE_ICON_STYLE, 1, TRUE, GTK_CSS_ICON_STYLE_SYMBOLIC, "symbolic" }
{ &GTK_CSS_VALUE_ICON_STYLE, 1, TRUE, FALSE, GTK_CSS_ICON_STYLE_REQUESTED, "requested" },
{ &GTK_CSS_VALUE_ICON_STYLE, 1, TRUE, FALSE, GTK_CSS_ICON_STYLE_REGULAR, "regular" },
{ &GTK_CSS_VALUE_ICON_STYLE, 1, TRUE, FALSE, GTK_CSS_ICON_STYLE_SYMBOLIC, "symbolic" }
};
GtkCssValue *
@@ -855,7 +853,7 @@ _gtk_css_icon_style_value_new (GtkCssIconStyle icon_style)
for (i = 0; i < G_N_ELEMENTS (icon_style_values); i++)
{
if (icon_style_values[i].value == icon_style)
return _gtk_css_value_ref (&icon_style_values[i]);
return gtk_css_value_ref (&icon_style_values[i]);
}
g_return_val_if_reached (NULL);
@@ -871,7 +869,7 @@ _gtk_css_icon_style_value_try_parse (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (icon_style_values); i++)
{
if (gtk_css_parser_try_ident (parser, icon_style_values[i].name))
return _gtk_css_value_ref (&icon_style_values[i]);
return gtk_css_value_ref (&icon_style_values[i]);
}
return NULL;
@@ -899,9 +897,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_KERNING = {
};
static GtkCssValue font_kerning_values[] = {
{ &GTK_CSS_VALUE_FONT_KERNING, 1, TRUE, GTK_CSS_FONT_KERNING_AUTO, "auto" },
{ &GTK_CSS_VALUE_FONT_KERNING, 1, TRUE, GTK_CSS_FONT_KERNING_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_KERNING, 1, TRUE, GTK_CSS_FONT_KERNING_NONE, "none" }
{ &GTK_CSS_VALUE_FONT_KERNING, 1, TRUE, FALSE, GTK_CSS_FONT_KERNING_AUTO, "auto" },
{ &GTK_CSS_VALUE_FONT_KERNING, 1, TRUE, FALSE, GTK_CSS_FONT_KERNING_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_KERNING, 1, TRUE, FALSE, GTK_CSS_FONT_KERNING_NONE, "none" }
};
GtkCssValue *
@@ -912,7 +910,7 @@ _gtk_css_font_kerning_value_new (GtkCssFontKerning kerning)
for (i = 0; i < G_N_ELEMENTS (font_kerning_values); i++)
{
if (font_kerning_values[i].value == kerning)
return _gtk_css_value_ref (&font_kerning_values[i]);
return gtk_css_value_ref (&font_kerning_values[i]);
}
g_return_val_if_reached (NULL);
@@ -928,7 +926,7 @@ _gtk_css_font_kerning_value_try_parse (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (font_kerning_values); i++)
{
if (gtk_css_parser_try_ident (parser, font_kerning_values[i].name))
return _gtk_css_value_ref (&font_kerning_values[i]);
return gtk_css_value_ref (&font_kerning_values[i]);
}
return NULL;
@@ -956,9 +954,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_VARIANT_POSITION = {
};
static GtkCssValue font_variant_position_values[] = {
{ &GTK_CSS_VALUE_FONT_VARIANT_POSITION, 1, TRUE, GTK_CSS_FONT_VARIANT_POSITION_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_VARIANT_POSITION, 1, TRUE, GTK_CSS_FONT_VARIANT_POSITION_SUB, "sub" },
{ &GTK_CSS_VALUE_FONT_VARIANT_POSITION, 1, TRUE, GTK_CSS_FONT_VARIANT_POSITION_SUPER, "super" }
{ &GTK_CSS_VALUE_FONT_VARIANT_POSITION, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_POSITION_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_VARIANT_POSITION, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_POSITION_SUB, "sub" },
{ &GTK_CSS_VALUE_FONT_VARIANT_POSITION, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_POSITION_SUPER, "super" }
};
GtkCssValue *
@@ -969,7 +967,7 @@ _gtk_css_font_variant_position_value_new (GtkCssFontVariantPosition position)
for (i = 0; i < G_N_ELEMENTS (font_variant_position_values); i++)
{
if (font_variant_position_values[i].value == position)
return _gtk_css_value_ref (&font_variant_position_values[i]);
return gtk_css_value_ref (&font_variant_position_values[i]);
}
g_return_val_if_reached (NULL);
@@ -985,7 +983,7 @@ _gtk_css_font_variant_position_value_try_parse (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (font_variant_position_values); i++)
{
if (gtk_css_parser_try_ident (parser, font_variant_position_values[i].name))
return _gtk_css_value_ref (&font_variant_position_values[i]);
return gtk_css_value_ref (&font_variant_position_values[i]);
}
return NULL;
@@ -1013,13 +1011,13 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_VARIANT_CAPS = {
};
static GtkCssValue font_variant_caps_values[] = {
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, GTK_CSS_FONT_VARIANT_CAPS_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, GTK_CSS_FONT_VARIANT_CAPS_SMALL_CAPS, "small-caps" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, GTK_CSS_FONT_VARIANT_CAPS_ALL_SMALL_CAPS, "all-small-caps" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, GTK_CSS_FONT_VARIANT_CAPS_PETITE_CAPS, "petite-caps" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, GTK_CSS_FONT_VARIANT_CAPS_ALL_PETITE_CAPS, "all-petite-caps" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, GTK_CSS_FONT_VARIANT_CAPS_UNICASE, "unicase" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, GTK_CSS_FONT_VARIANT_CAPS_TITLING_CAPS, "titling-caps" }
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_CAPS_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_CAPS_SMALL_CAPS, "small-caps" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_CAPS_ALL_SMALL_CAPS, "all-small-caps" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_CAPS_PETITE_CAPS, "petite-caps" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_CAPS_ALL_PETITE_CAPS, "all-petite-caps" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_CAPS_UNICASE, "unicase" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_CAPS_TITLING_CAPS, "titling-caps" }
};
GtkCssValue *
@@ -1030,7 +1028,7 @@ _gtk_css_font_variant_caps_value_new (GtkCssFontVariantCaps caps)
for (i = 0; i < G_N_ELEMENTS (font_variant_caps_values); i++)
{
if (font_variant_caps_values[i].value == caps)
return _gtk_css_value_ref (&font_variant_caps_values[i]);
return gtk_css_value_ref (&font_variant_caps_values[i]);
}
g_return_val_if_reached (NULL);
@@ -1046,7 +1044,7 @@ _gtk_css_font_variant_caps_value_try_parse (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (font_variant_caps_values); i++)
{
if (gtk_css_parser_try_ident (parser, font_variant_caps_values[i].name))
return _gtk_css_value_ref (&font_variant_caps_values[i]);
return gtk_css_value_ref (&font_variant_caps_values[i]);
}
return NULL;
@@ -1074,8 +1072,8 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_VARIANT_ALTERNATE = {
};
static GtkCssValue font_variant_alternate_values[] = {
{ &GTK_CSS_VALUE_FONT_VARIANT_ALTERNATE, 1, TRUE, GTK_CSS_FONT_VARIANT_ALTERNATE_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_VARIANT_ALTERNATE, 1, TRUE, GTK_CSS_FONT_VARIANT_ALTERNATE_HISTORICAL_FORMS, "historical-forms" }
{ &GTK_CSS_VALUE_FONT_VARIANT_ALTERNATE, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_ALTERNATE_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_VARIANT_ALTERNATE, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_ALTERNATE_HISTORICAL_FORMS, "historical-forms" }
};
GtkCssValue *
@@ -1086,7 +1084,7 @@ _gtk_css_font_variant_alternate_value_new (GtkCssFontVariantAlternate alternate)
for (i = 0; i < G_N_ELEMENTS (font_variant_alternate_values); i++)
{
if (font_variant_alternate_values[i].value == alternate)
return _gtk_css_value_ref (&font_variant_alternate_values[i]);
return gtk_css_value_ref (&font_variant_alternate_values[i]);
}
g_return_val_if_reached (NULL);
@@ -1102,7 +1100,7 @@ _gtk_css_font_variant_alternate_value_try_parse (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (font_variant_alternate_values); i++)
{
if (gtk_css_parser_try_ident (parser, font_variant_alternate_values[i].name))
return _gtk_css_value_ref (&font_variant_alternate_values[i]);
return gtk_css_value_ref (&font_variant_alternate_values[i]);
}
return NULL;
@@ -1199,7 +1197,7 @@ _gtk_css_text_decoration_line_value_new (GtkTextDecorationLine line)
if (!text_decoration_line_is_valid (line))
return NULL;
value = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_TEXT_DECORATION_LINE);
value = gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_TEXT_DECORATION_LINE);
value->value = line;
value->name = NULL;
value->is_computed = TRUE;
@@ -1308,7 +1306,7 @@ _gtk_css_font_variant_ligature_value_new (GtkCssFontVariantLigature ligatures)
if (!ligature_value_is_valid (ligatures))
return NULL;
value = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_FONT_VARIANT_LIGATURE);
value = gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_FONT_VARIANT_LIGATURE);
value->value = ligatures;
value->name = NULL;
value->is_computed = TRUE;
@@ -1412,7 +1410,7 @@ _gtk_css_font_variant_numeric_value_new (GtkCssFontVariantNumeric numeric)
if (!numeric_value_is_valid (numeric))
return NULL;
value = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_FONT_VARIANT_NUMERIC);
value = gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_FONT_VARIANT_NUMERIC);
value->value = numeric;
value->name = NULL;
value->is_computed = TRUE;
@@ -1523,7 +1521,7 @@ _gtk_css_font_variant_east_asian_value_new (GtkCssFontVariantEastAsian east_asia
if (!east_asian_value_is_valid (east_asian))
return NULL;
value = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_FONT_VARIANT_EAST_ASIAN);
value = gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_FONT_VARIANT_EAST_ASIAN);
value->value = east_asian;
value->name = NULL;
value->is_computed = TRUE;
@@ -1583,10 +1581,10 @@ static const GtkCssValueClass GTK_CSS_VALUE_TEXT_TRANSFORM = {
};
static GtkCssValue text_transform_values[] = {
{ &GTK_CSS_VALUE_TEXT_TRANSFORM, 1, TRUE, GTK_CSS_TEXT_TRANSFORM_NONE, "none" },
{ &GTK_CSS_VALUE_TEXT_TRANSFORM, 1, TRUE, GTK_CSS_TEXT_TRANSFORM_LOWERCASE, "lowercase" },
{ &GTK_CSS_VALUE_TEXT_TRANSFORM, 1, TRUE, GTK_CSS_TEXT_TRANSFORM_UPPERCASE, "uppercase" },
{ &GTK_CSS_VALUE_TEXT_TRANSFORM, 1, TRUE, GTK_CSS_TEXT_TRANSFORM_CAPITALIZE, "capitalize" },
{ &GTK_CSS_VALUE_TEXT_TRANSFORM, 1, TRUE, FALSE, GTK_CSS_TEXT_TRANSFORM_NONE, "none" },
{ &GTK_CSS_VALUE_TEXT_TRANSFORM, 1, TRUE, FALSE, GTK_CSS_TEXT_TRANSFORM_LOWERCASE, "lowercase" },
{ &GTK_CSS_VALUE_TEXT_TRANSFORM, 1, TRUE, FALSE, GTK_CSS_TEXT_TRANSFORM_UPPERCASE, "uppercase" },
{ &GTK_CSS_VALUE_TEXT_TRANSFORM, 1, TRUE, FALSE, GTK_CSS_TEXT_TRANSFORM_CAPITALIZE, "capitalize" },
};
GtkCssValue *
@@ -1594,7 +1592,7 @@ _gtk_css_text_transform_value_new (GtkTextTransform transform)
{
g_return_val_if_fail (transform < G_N_ELEMENTS (text_transform_values), NULL);
return _gtk_css_value_ref (&text_transform_values[transform]);
return gtk_css_value_ref (&text_transform_values[transform]);
}
GtkCssValue *
@@ -1607,7 +1605,7 @@ _gtk_css_text_transform_value_try_parse (GtkCssParser *parser)
for (i = 0; i < G_N_ELEMENTS (text_transform_values); i++)
{
if (gtk_css_parser_try_ident (parser, text_transform_values[i].name))
return _gtk_css_value_ref (&text_transform_values[i]);
return gtk_css_value_ref (&text_transform_values[i]);
}
return NULL;

View File

@@ -65,34 +65,34 @@ gtk_css_filter_clear (GtkCssFilter *filter)
switch (filter->type)
{
case GTK_CSS_FILTER_BRIGHTNESS:
_gtk_css_value_unref (filter->brightness.value);
gtk_css_value_unref (filter->brightness.value);
break;
case GTK_CSS_FILTER_CONTRAST:
_gtk_css_value_unref (filter->contrast.value);
gtk_css_value_unref (filter->contrast.value);
break;
case GTK_CSS_FILTER_GRAYSCALE:
_gtk_css_value_unref (filter->grayscale.value);
gtk_css_value_unref (filter->grayscale.value);
break;
case GTK_CSS_FILTER_HUE_ROTATE:
_gtk_css_value_unref (filter->hue_rotate.value);
gtk_css_value_unref (filter->hue_rotate.value);
break;
case GTK_CSS_FILTER_INVERT:
_gtk_css_value_unref (filter->invert.value);
gtk_css_value_unref (filter->invert.value);
break;
case GTK_CSS_FILTER_OPACITY:
_gtk_css_value_unref (filter->opacity.value);
gtk_css_value_unref (filter->opacity.value);
break;
case GTK_CSS_FILTER_SATURATE:
_gtk_css_value_unref (filter->saturate.value);
gtk_css_value_unref (filter->saturate.value);
break;
case GTK_CSS_FILTER_SEPIA:
_gtk_css_value_unref (filter->sepia.value);
gtk_css_value_unref (filter->sepia.value);
break;
case GTK_CSS_FILTER_BLUR:
_gtk_css_value_unref (filter->blur.value);
gtk_css_value_unref (filter->blur.value);
break;
case GTK_CSS_FILTER_DROP_SHADOW:
_gtk_css_value_unref (filter->drop_shadow.value);
gtk_css_value_unref (filter->drop_shadow.value);
break;
case GTK_CSS_FILTER_NONE:
default:
@@ -307,55 +307,53 @@ gtk_css_value_filter_free (GtkCssValue *value)
/* returns TRUE if dest == src */
static gboolean
gtk_css_filter_compute (GtkCssFilter *dest,
GtkCssFilter *src,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_filter_compute (GtkCssFilter *dest,
GtkCssFilter *src,
guint property_id,
GtkCssComputeContext *context)
{
dest->type = src->type;
switch (src->type)
{
case GTK_CSS_FILTER_BRIGHTNESS:
dest->brightness.value = _gtk_css_value_compute (src->brightness.value, property_id, provider, style, parent_style);
dest->brightness.value = gtk_css_value_compute (src->brightness.value, property_id, context);
return dest->brightness.value == src->brightness.value;
case GTK_CSS_FILTER_CONTRAST:
dest->contrast.value = _gtk_css_value_compute (src->contrast.value, property_id, provider, style, parent_style);
dest->contrast.value = gtk_css_value_compute (src->contrast.value, property_id, context);
return dest->contrast.value == src->contrast.value;
case GTK_CSS_FILTER_GRAYSCALE:
dest->grayscale.value = _gtk_css_value_compute (src->grayscale.value, property_id, provider, style, parent_style);
dest->grayscale.value = gtk_css_value_compute (src->grayscale.value, property_id, context);
return dest->grayscale.value == src->grayscale.value;
case GTK_CSS_FILTER_HUE_ROTATE:
dest->hue_rotate.value = _gtk_css_value_compute (src->hue_rotate.value, property_id, provider, style, parent_style);
dest->hue_rotate.value = gtk_css_value_compute (src->hue_rotate.value, property_id, context);
return dest->hue_rotate.value == src->hue_rotate.value;
case GTK_CSS_FILTER_INVERT:
dest->invert.value = _gtk_css_value_compute (src->invert.value, property_id, provider, style, parent_style);
dest->invert.value = gtk_css_value_compute (src->invert.value, property_id, context);
return dest->invert.value == src->invert.value;
case GTK_CSS_FILTER_OPACITY:
dest->opacity.value = _gtk_css_value_compute (src->opacity.value, property_id, provider, style, parent_style);
dest->opacity.value = gtk_css_value_compute (src->opacity.value, property_id, context);
return dest->opacity.value == src->opacity.value;
case GTK_CSS_FILTER_SATURATE:
dest->saturate.value = _gtk_css_value_compute (src->saturate.value, property_id, provider, style, parent_style);
dest->saturate.value = gtk_css_value_compute (src->saturate.value, property_id, context);
return dest->saturate.value == src->saturate.value;
case GTK_CSS_FILTER_SEPIA:
dest->sepia.value = _gtk_css_value_compute (src->sepia.value, property_id, provider, style, parent_style);
dest->sepia.value = gtk_css_value_compute (src->sepia.value, property_id, context);
return dest->sepia.value == src->sepia.value;
case GTK_CSS_FILTER_BLUR:
dest->blur.value = _gtk_css_value_compute (src->blur.value, property_id, provider, style, parent_style);
dest->blur.value = gtk_css_value_compute (src->blur.value, property_id, context);
return dest->blur.value == src->blur.value;
case GTK_CSS_FILTER_DROP_SHADOW:
dest->drop_shadow.value = _gtk_css_value_compute (src->drop_shadow.value, property_id, provider, style, parent_style);
dest->drop_shadow.value = gtk_css_value_compute (src->drop_shadow.value, property_id, context);
return dest->drop_shadow.value == src->drop_shadow.value;
case GTK_CSS_FILTER_NONE:
@@ -366,11 +364,9 @@ gtk_css_filter_compute (GtkCssFilter *dest,
}
static GtkCssValue *
gtk_css_value_filter_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_value_filter_compute (GtkCssValue *value,
guint property_id,
GtkCssComputeContext *context)
{
GtkCssValue *result;
gboolean changes;
@@ -378,7 +374,7 @@ gtk_css_value_filter_compute (GtkCssValue *value,
/* Special case the 99% case of "none" */
if (gtk_css_filter_value_is_none (value))
return _gtk_css_value_ref (value);
return gtk_css_value_ref (value);
changes = FALSE;
result = gtk_css_filter_value_alloc (value->n_filters);
@@ -388,15 +384,13 @@ gtk_css_value_filter_compute (GtkCssValue *value,
changes |= !gtk_css_filter_compute (&result->filters[i],
&value->filters[i],
property_id,
provider,
style,
parent_style);
context);
}
if (!changes)
{
_gtk_css_value_unref (result);
result = _gtk_css_value_ref (value);
gtk_css_value_unref (result);
result = gtk_css_value_ref (value);
}
return result;
@@ -412,34 +406,34 @@ gtk_css_filter_equal (const GtkCssFilter *filter1,
switch (filter1->type)
{
case GTK_CSS_FILTER_BRIGHTNESS:
return _gtk_css_value_equal (filter1->brightness.value, filter2->brightness.value);
return gtk_css_value_equal (filter1->brightness.value, filter2->brightness.value);
case GTK_CSS_FILTER_CONTRAST:
return _gtk_css_value_equal (filter1->contrast.value, filter2->contrast.value);
return gtk_css_value_equal (filter1->contrast.value, filter2->contrast.value);
case GTK_CSS_FILTER_GRAYSCALE:
return _gtk_css_value_equal (filter1->grayscale.value, filter2->grayscale.value);
return gtk_css_value_equal (filter1->grayscale.value, filter2->grayscale.value);
case GTK_CSS_FILTER_HUE_ROTATE:
return _gtk_css_value_equal (filter1->hue_rotate.value, filter2->hue_rotate.value);
return gtk_css_value_equal (filter1->hue_rotate.value, filter2->hue_rotate.value);
case GTK_CSS_FILTER_INVERT:
return _gtk_css_value_equal (filter1->invert.value, filter2->invert.value);
return gtk_css_value_equal (filter1->invert.value, filter2->invert.value);
case GTK_CSS_FILTER_OPACITY:
return _gtk_css_value_equal (filter1->opacity.value, filter2->opacity.value);
return gtk_css_value_equal (filter1->opacity.value, filter2->opacity.value);
case GTK_CSS_FILTER_SATURATE:
return _gtk_css_value_equal (filter1->saturate.value, filter2->saturate.value);
return gtk_css_value_equal (filter1->saturate.value, filter2->saturate.value);
case GTK_CSS_FILTER_SEPIA:
return _gtk_css_value_equal (filter1->sepia.value, filter2->sepia.value);
return gtk_css_value_equal (filter1->sepia.value, filter2->sepia.value);
case GTK_CSS_FILTER_BLUR:
return _gtk_css_value_equal (filter1->blur.value, filter2->blur.value);
return gtk_css_value_equal (filter1->blur.value, filter2->blur.value);
case GTK_CSS_FILTER_DROP_SHADOW:
return _gtk_css_value_equal (filter1->drop_shadow.value, filter2->drop_shadow.value);
return gtk_css_value_equal (filter1->drop_shadow.value, filter2->drop_shadow.value);
case GTK_CSS_FILTER_NONE:
default:
@@ -494,43 +488,43 @@ gtk_css_filter_transition (GtkCssFilter *result,
switch (start->type)
{
case GTK_CSS_FILTER_BRIGHTNESS:
result->brightness.value = _gtk_css_value_transition (start->brightness.value, end->brightness.value, property_id, progress);
result->brightness.value = gtk_css_value_transition (start->brightness.value, end->brightness.value, property_id, progress);
break;
case GTK_CSS_FILTER_CONTRAST:
result->contrast.value = _gtk_css_value_transition (start->contrast.value, end->contrast.value, property_id, progress);
result->contrast.value = gtk_css_value_transition (start->contrast.value, end->contrast.value, property_id, progress);
break;
case GTK_CSS_FILTER_GRAYSCALE:
result->grayscale.value = _gtk_css_value_transition (start->grayscale.value, end->grayscale.value, property_id, progress);
result->grayscale.value = gtk_css_value_transition (start->grayscale.value, end->grayscale.value, property_id, progress);
break;
case GTK_CSS_FILTER_HUE_ROTATE:
result->hue_rotate.value = _gtk_css_value_transition (start->hue_rotate.value, end->hue_rotate.value, property_id, progress);
result->hue_rotate.value = gtk_css_value_transition (start->hue_rotate.value, end->hue_rotate.value, property_id, progress);
break;
case GTK_CSS_FILTER_INVERT:
result->invert.value = _gtk_css_value_transition (start->invert.value, end->invert.value, property_id, progress);
result->invert.value = gtk_css_value_transition (start->invert.value, end->invert.value, property_id, progress);
break;
case GTK_CSS_FILTER_OPACITY:
result->opacity.value = _gtk_css_value_transition (start->opacity.value, end->opacity.value, property_id, progress);
result->opacity.value = gtk_css_value_transition (start->opacity.value, end->opacity.value, property_id, progress);
break;
case GTK_CSS_FILTER_SATURATE:
result->saturate.value = _gtk_css_value_transition (start->saturate.value, end->saturate.value, property_id, progress);
result->saturate.value = gtk_css_value_transition (start->saturate.value, end->saturate.value, property_id, progress);
break;
case GTK_CSS_FILTER_SEPIA:
result->sepia.value = _gtk_css_value_transition (start->sepia.value, end->sepia.value, property_id, progress);
result->sepia.value = gtk_css_value_transition (start->sepia.value, end->sepia.value, property_id, progress);
break;
case GTK_CSS_FILTER_BLUR:
result->blur.value = _gtk_css_value_transition (start->blur.value, end->blur.value, property_id, progress);
result->blur.value = gtk_css_value_transition (start->blur.value, end->blur.value, property_id, progress);
break;
case GTK_CSS_FILTER_DROP_SHADOW:
result->drop_shadow.value = _gtk_css_value_transition (start->drop_shadow.value, end->drop_shadow.value, property_id, progress);
result->drop_shadow.value = gtk_css_value_transition (start->drop_shadow.value, end->drop_shadow.value, property_id, progress);
break;
case GTK_CSS_FILTER_NONE:
@@ -552,7 +546,7 @@ gtk_css_value_filter_transition (GtkCssValue *start,
if (gtk_css_filter_value_is_none (start))
{
if (gtk_css_filter_value_is_none (end))
return _gtk_css_value_ref (start);
return gtk_css_value_ref (start);
n = 0;
}
@@ -626,61 +620,61 @@ gtk_css_filter_print (const GtkCssFilter *filter,
{
case GTK_CSS_FILTER_BRIGHTNESS:
g_string_append (string, "brightness(");
_gtk_css_value_print (filter->brightness.value, string);
gtk_css_value_print (filter->brightness.value, string);
g_string_append (string, ")");
break;
case GTK_CSS_FILTER_CONTRAST:
g_string_append (string, "contrast(");
_gtk_css_value_print (filter->contrast.value, string);
gtk_css_value_print (filter->contrast.value, string);
g_string_append (string, ")");
break;
case GTK_CSS_FILTER_GRAYSCALE:
g_string_append (string, "grayscale(");
_gtk_css_value_print (filter->grayscale.value, string);
gtk_css_value_print (filter->grayscale.value, string);
g_string_append (string, ")");
break;
case GTK_CSS_FILTER_HUE_ROTATE:
g_string_append (string, "hue-rotate(");
_gtk_css_value_print (filter->hue_rotate.value, string);
gtk_css_value_print (filter->hue_rotate.value, string);
g_string_append (string, ")");
break;
case GTK_CSS_FILTER_INVERT:
g_string_append (string, "invert(");
_gtk_css_value_print (filter->invert.value, string);
gtk_css_value_print (filter->invert.value, string);
g_string_append (string, ")");
break;
case GTK_CSS_FILTER_OPACITY:
g_string_append (string, "opacity(");
_gtk_css_value_print (filter->opacity.value, string);
gtk_css_value_print (filter->opacity.value, string);
g_string_append (string, ")");
break;
case GTK_CSS_FILTER_SATURATE:
g_string_append (string, "saturate(");
_gtk_css_value_print (filter->saturate.value, string);
gtk_css_value_print (filter->saturate.value, string);
g_string_append (string, ")");
break;
case GTK_CSS_FILTER_SEPIA:
g_string_append (string, "sepia(");
_gtk_css_value_print (filter->sepia.value, string);
gtk_css_value_print (filter->sepia.value, string);
g_string_append (string, ")");
break;
case GTK_CSS_FILTER_BLUR:
g_string_append (string, "blur(");
_gtk_css_value_print (filter->blur.value, string);
gtk_css_value_print (filter->blur.value, string);
g_string_append (string, ")");
break;
case GTK_CSS_FILTER_DROP_SHADOW:
g_string_append (string, "drop-shadow(");
_gtk_css_value_print (filter->drop_shadow.value, string);
gtk_css_value_print (filter->drop_shadow.value, string);
g_string_append (string, ")");
break;
@@ -723,7 +717,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_FILTER = {
gtk_css_value_filter_print
};
static GtkCssValue filter_none_singleton = { &GTK_CSS_VALUE_FILTER, 1, TRUE, 0, { { GTK_CSS_FILTER_NONE } } };
static GtkCssValue filter_none_singleton = { &GTK_CSS_VALUE_FILTER, 1, TRUE, FALSE, 0, { { GTK_CSS_FILTER_NONE } } };
static GtkCssValue *
gtk_css_filter_value_alloc (guint n_filters)
@@ -732,7 +726,7 @@ gtk_css_filter_value_alloc (guint n_filters)
g_return_val_if_fail (n_filters > 0, NULL);
result = _gtk_css_value_alloc (&GTK_CSS_VALUE_FILTER, sizeof (GtkCssValue) + sizeof (GtkCssFilter) * (n_filters - 1));
result = gtk_css_value_alloc (&GTK_CSS_VALUE_FILTER, sizeof (GtkCssValue) + sizeof (GtkCssFilter) * (n_filters - 1));
result->n_filters = n_filters;
return result;
@@ -741,7 +735,7 @@ gtk_css_filter_value_alloc (guint n_filters)
GtkCssValue *
gtk_css_filter_value_new_none (void)
{
return _gtk_css_value_ref (&filter_none_singleton);
return gtk_css_value_ref (&filter_none_singleton);
}
static gboolean

View File

@@ -53,13 +53,11 @@ gtk_css_value_font_features_free (GtkCssValue *value)
}
static GtkCssValue *
gtk_css_value_font_features_compute (GtkCssValue *specified,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_value_font_features_compute (GtkCssValue *specified,
guint property_id,
GtkCssComputeContext *context)
{
return _gtk_css_value_ref (specified);
return gtk_css_value_ref (specified);
}
static gboolean
@@ -170,7 +168,7 @@ gtk_css_font_features_value_new_empty (void)
{
GtkCssValue *result;
result = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_FONT_FEATURES);
result = gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_FONT_FEATURES);
result->features = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
result->is_computed = TRUE;
@@ -183,7 +181,7 @@ gtk_css_font_features_value_new_default (void)
if (default_font_features == NULL)
default_font_features = gtk_css_font_features_value_new_empty ();
return _gtk_css_value_ref (default_font_features);
return gtk_css_value_ref (default_font_features);
}
static gboolean
@@ -217,7 +215,7 @@ gtk_css_font_features_value_parse (GtkCssParser *parser)
name = gtk_css_parser_consume_string (parser);
if (name == NULL)
{
_gtk_css_value_unref (result);
gtk_css_value_unref (result);
return NULL;
}
@@ -225,7 +223,7 @@ gtk_css_font_features_value_parse (GtkCssParser *parser)
{
gtk_css_parser_error_value (parser, "Not a valid OpenType tag.");
g_free (name);
_gtk_css_value_unref (result);
gtk_css_value_unref (result);
return NULL;
}
@@ -238,7 +236,7 @@ gtk_css_font_features_value_parse (GtkCssParser *parser)
if (!gtk_css_parser_consume_integer (parser, &num))
{
g_free (name);
_gtk_css_value_unref (result);
gtk_css_value_unref (result);
return NULL;
}
}

View File

@@ -52,13 +52,11 @@ gtk_css_value_font_variations_free (GtkCssValue *value)
}
static GtkCssValue *
gtk_css_value_font_variations_compute (GtkCssValue *specified,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_value_font_variations_compute (GtkCssValue *specified,
guint property_id,
GtkCssComputeContext *context)
{
return _gtk_css_value_ref (specified);
return gtk_css_value_ref (specified);
}
static gboolean
@@ -78,7 +76,7 @@ gtk_css_value_font_variations_equal (const GtkCssValue *value1,
if (coord2 == NULL)
return FALSE;
if (!_gtk_css_value_equal (coord1, coord2))
if (!gtk_css_value_equal (coord1, coord2))
return FALSE;
}
@@ -108,9 +106,9 @@ gtk_css_value_font_variations_transition (GtkCssValue *start,
{
end_coord = g_hash_table_lookup (end->axes, name);
if (end_coord == NULL)
transition = _gtk_css_value_ref (start_coord);
transition = gtk_css_value_ref (start_coord);
else
transition = _gtk_css_value_transition (start_coord, end_coord, property_id, progress);
transition = gtk_css_value_transition (start_coord, end_coord, property_id, progress);
gtk_css_font_variations_value_add_axis (result, name, transition);
}
@@ -122,7 +120,7 @@ gtk_css_value_font_variations_transition (GtkCssValue *start,
if (start_coord != NULL)
continue;
gtk_css_font_variations_value_add_axis (result, name, _gtk_css_value_ref (end_coord));
gtk_css_font_variations_value_add_axis (result, name, gtk_css_value_ref (end_coord));
}
return result;
@@ -151,7 +149,7 @@ gtk_css_value_font_variations_print (const GtkCssValue *value,
else
g_string_append (string, ", ");
g_string_append_printf (string, "\"%s\" ", name);
_gtk_css_value_print (coord, string);
gtk_css_value_print (coord, string);
}
}
@@ -171,10 +169,10 @@ gtk_css_font_variations_value_new_empty (void)
{
GtkCssValue *result;
result = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_FONT_VARIATIONS);
result = gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_FONT_VARIATIONS);
result->axes = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free,
(GDestroyNotify) _gtk_css_value_unref);
(GDestroyNotify) gtk_css_value_unref);
result->is_computed = TRUE;
return result;
@@ -186,7 +184,7 @@ gtk_css_font_variations_value_new_default (void)
if (default_font_variations == NULL)
default_font_variations = gtk_css_font_variations_value_new_empty ();
return _gtk_css_value_ref (default_font_variations);
return gtk_css_value_ref (default_font_variations);
}
static gboolean
@@ -219,7 +217,7 @@ gtk_css_font_variations_value_parse (GtkCssParser *parser)
name = gtk_css_parser_consume_string (parser);
if (name == NULL)
{
_gtk_css_value_unref (result);
gtk_css_value_unref (result);
return NULL;
}
@@ -227,7 +225,7 @@ gtk_css_font_variations_value_parse (GtkCssParser *parser)
{
gtk_css_parser_error_value (parser, "Not a valid OpenType tag.");
g_free (name);
_gtk_css_value_unref (result);
gtk_css_value_unref (result);
return NULL;
}
@@ -235,7 +233,7 @@ gtk_css_font_variations_value_parse (GtkCssParser *parser)
if (coord == NULL)
{
g_free (name);
_gtk_css_value_unref (result);
gtk_css_value_unref (result);
return NULL;
}

View File

@@ -65,11 +65,9 @@ gtk_css_image_real_get_aspect_ratio (GtkCssImage *image)
}
static GtkCssImage *
gtk_css_image_real_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_image_real_compute (GtkCssImage *image,
guint property_id,
GtkCssComputeContext *context)
{
return g_object_ref (image);
}
@@ -173,21 +171,19 @@ _gtk_css_image_get_aspect_ratio (GtkCssImage *image)
}
GtkCssImage *
_gtk_css_image_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
_gtk_css_image_compute (GtkCssImage *image,
guint property_id,
GtkCssComputeContext *context)
{
GtkCssImageClass *klass;
gtk_internal_return_val_if_fail (GTK_IS_CSS_IMAGE (image), NULL);
gtk_internal_return_val_if_fail (GTK_IS_CSS_STYLE (style), NULL);
gtk_internal_return_val_if_fail (parent_style == NULL || GTK_IS_CSS_STYLE (parent_style), NULL);
gtk_internal_return_val_if_fail (GTK_IS_CSS_STYLE (context->style), NULL);
gtk_internal_return_val_if_fail (context->parent_style == NULL || GTK_IS_CSS_STYLE (context->parent_style), NULL);
klass = GTK_CSS_IMAGE_GET_CLASS (image);
return klass->compute (image, property_id, provider, style, parent_style);
return klass->compute (image, property_id, context);
}
GtkCssImage *

View File

@@ -119,7 +119,7 @@ parse_color (GtkCssParser *parser,
{
GtkCssValue **color = option_data;
*color = _gtk_css_color_value_parse (parser);
*color = gtk_css_color_value_parse (parser);
if (*color == NULL)
return FALSE;
@@ -272,10 +272,10 @@ gtk_css_image_conic_print (GtkCssImage *image,
GtkCssValue *compare = _gtk_css_position_value_new (_gtk_css_number_value_new (50, GTK_CSS_PERCENT),
_gtk_css_number_value_new (50, GTK_CSS_PERCENT));
if (!_gtk_css_value_equal (self->center, compare))
if (!gtk_css_value_equal (self->center, compare))
{
g_string_append (string, "from ");
_gtk_css_value_print (self->center, string);
gtk_css_value_print (self->center, string);
written = TRUE;
}
@@ -287,7 +287,7 @@ gtk_css_image_conic_print (GtkCssImage *image,
if (written)
g_string_append_c (string, ' ');
g_string_append (string, "at ");
_gtk_css_value_print (self->rotation, string);
gtk_css_value_print (self->rotation, string);
}
if (written)
@@ -300,12 +300,12 @@ gtk_css_image_conic_print (GtkCssImage *image,
if (i > 0)
g_string_append (string, ", ");
_gtk_css_value_print (stop->color, string);
gtk_css_value_print (stop->color, string);
if (stop->offset)
{
g_string_append (string, " ");
_gtk_css_value_print (stop->offset, string);
gtk_css_value_print (stop->offset, string);
}
}
@@ -313,11 +313,9 @@ gtk_css_image_conic_print (GtkCssImage *image,
}
static GtkCssImage *
gtk_css_image_conic_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_image_conic_compute (GtkCssImage *image,
guint property_id,
GtkCssComputeContext *context)
{
GtkCssImageConic *self = GTK_CSS_IMAGE_CONIC (image);
GtkCssImageConic *copy;
@@ -325,8 +323,8 @@ gtk_css_image_conic_compute (GtkCssImage *image,
copy = g_object_new (GTK_TYPE_CSS_IMAGE_CONIC, NULL);
copy->center = _gtk_css_value_compute (self->center, property_id, provider, style, parent_style);
copy->rotation = _gtk_css_value_compute (self->rotation, property_id, provider, style, parent_style);
copy->center = gtk_css_value_compute (self->center, property_id, context);
copy->rotation = gtk_css_value_compute (self->rotation, property_id, context);
copy->n_stops = self->n_stops;
copy->color_stops = g_malloc (sizeof (GtkCssImageConicColorStop) * copy->n_stops);
@@ -335,11 +333,11 @@ gtk_css_image_conic_compute (GtkCssImage *image,
const GtkCssImageConicColorStop *stop = &self->color_stops[i];
GtkCssImageConicColorStop *scopy = &copy->color_stops[i];
scopy->color = _gtk_css_value_compute (stop->color, property_id, provider, style, parent_style);
scopy->color = gtk_css_value_compute (stop->color, property_id, context);
if (stop->offset)
{
scopy->offset = _gtk_css_value_compute (stop->offset, property_id, provider, style, parent_style);
scopy->offset = gtk_css_value_compute (stop->offset, property_id, context);
}
else
{
@@ -374,11 +372,11 @@ gtk_css_image_conic_transition (GtkCssImage *start_image,
result = g_object_new (GTK_TYPE_CSS_IMAGE_CONIC, NULL);
result->center = _gtk_css_value_transition (start->center, end->center, property_id, progress);
result->center = gtk_css_value_transition (start->center, end->center, property_id, progress);
if (result->center == NULL)
goto fail;
result->rotation = _gtk_css_value_transition (start->rotation, end->rotation, property_id, progress);
result->rotation = gtk_css_value_transition (start->rotation, end->rotation, property_id, progress);
if (result->rotation == NULL)
goto fail;
@@ -399,22 +397,22 @@ gtk_css_image_conic_transition (GtkCssImage *start_image,
}
else
{
stop->offset = _gtk_css_value_transition (start_stop->offset,
end_stop->offset,
property_id,
progress);
stop->offset = gtk_css_value_transition (start_stop->offset,
end_stop->offset,
property_id,
progress);
if (stop->offset == NULL)
goto fail;
}
stop->color = _gtk_css_value_transition (start_stop->color,
end_stop->color,
property_id,
progress);
stop->color = gtk_css_value_transition (start_stop->color,
end_stop->color,
property_id,
progress);
if (stop->color == NULL)
{
if (stop->offset)
_gtk_css_value_unref (stop->offset);
gtk_css_value_unref (stop->offset);
goto fail;
}
@@ -436,8 +434,8 @@ gtk_css_image_conic_equal (GtkCssImage *image1,
GtkCssImageConic *conic2 = (GtkCssImageConic *) image2;
guint i;
if (!_gtk_css_value_equal (conic1->center, conic2->center) ||
!_gtk_css_value_equal (conic1->rotation, conic2->rotation))
if (!gtk_css_value_equal (conic1->center, conic2->center) ||
!gtk_css_value_equal (conic1->rotation, conic2->rotation))
return FALSE;
for (i = 0; i < conic1->n_stops; i++)
@@ -445,8 +443,8 @@ gtk_css_image_conic_equal (GtkCssImage *image1,
const GtkCssImageConicColorStop *stop1 = &conic1->color_stops[i];
const GtkCssImageConicColorStop *stop2 = &conic2->color_stops[i];
if (!_gtk_css_value_equal0 (stop1->offset, stop2->offset) ||
!_gtk_css_value_equal (stop1->color, stop2->color))
if (!gtk_css_value_equal0 (stop1->offset, stop2->offset) ||
!gtk_css_value_equal (stop1->color, stop2->color))
return FALSE;
}
@@ -463,9 +461,9 @@ gtk_css_image_conic_dispose (GObject *object)
{
GtkCssImageConicColorStop *stop = &self->color_stops[i];
_gtk_css_value_unref (stop->color);
gtk_css_value_unref (stop->color);
if (stop->offset)
_gtk_css_value_unref (stop->offset);
gtk_css_value_unref (stop->offset);
}
g_free (self->color_stops);

View File

@@ -293,7 +293,7 @@ parse_progress (GtkCssParser *parser,
if (number == NULL)
return FALSE;
*progress = _gtk_css_number_value_get (number, 1);
_gtk_css_value_unref (number);
gtk_css_value_unref (number);
if (*progress > 1.0)
{
@@ -323,7 +323,7 @@ parse_image (GtkCssParser *parser,
{
GtkCssValue *color;
color = _gtk_css_color_value_parse (parser);
color = gtk_css_color_value_parse (parser);
if (color == NULL)
return FALSE;
@@ -399,11 +399,9 @@ gtk_css_image_cross_fade_print (GtkCssImage *image,
}
static GtkCssImage *
gtk_css_image_cross_fade_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_image_cross_fade_compute (GtkCssImage *image,
guint property_id,
GtkCssComputeContext *context)
{
GtkCssImageCrossFade *self = GTK_CSS_IMAGE_CROSS_FADE (image);
GtkCssImageCrossFade *result;
@@ -418,7 +416,7 @@ gtk_css_image_cross_fade_compute (GtkCssImage *image,
gtk_css_image_cross_fade_add (result,
entry->has_progress,
entry->progress,
_gtk_css_image_compute (entry->image, property_id, provider, style, parent_style));
_gtk_css_image_compute (entry->image, property_id, context));
}
return GTK_CSS_IMAGE (result);

View File

@@ -105,7 +105,7 @@ gtk_css_image_fallback_print (GtkCssImage *image,
{
if (fallback->n_images > 0)
g_string_append (string, ",");
_gtk_css_value_print (fallback->color, string);
gtk_css_value_print (fallback->color, string);
}
g_string_append (string, ")");
@@ -124,7 +124,7 @@ gtk_css_image_fallback_dispose (GObject *object)
if (fallback->color)
{
_gtk_css_value_unref (fallback->color);
gtk_css_value_unref (fallback->color);
fallback->color = NULL;
}
@@ -133,11 +133,9 @@ gtk_css_image_fallback_dispose (GObject *object)
static GtkCssImage *
gtk_css_image_fallback_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_image_fallback_compute (GtkCssImage *image,
guint property_id,
GtkCssComputeContext *context)
{
GtkCssImageFallback *fallback = GTK_CSS_IMAGE_FALLBACK (image);
GtkCssImageFallback *copy;
@@ -148,11 +146,9 @@ gtk_css_image_fallback_compute (GtkCssImage *image,
GtkCssValue *computed_color = NULL;
if (fallback->color)
computed_color = _gtk_css_value_compute (fallback->color,
property_id,
provider,
style,
parent_style);
computed_color = gtk_css_value_compute (fallback->color,
property_id,
context);
/* image($color) that didn't change */
if (computed_color && !fallback->images &&
@@ -166,9 +162,7 @@ gtk_css_image_fallback_compute (GtkCssImage *image,
{
copy->images[i] = _gtk_css_image_compute (fallback->images[i],
property_id,
provider,
style,
parent_style);
context);
if (gtk_css_image_is_invalid (copy->images[i]))
continue;
@@ -217,7 +211,7 @@ gtk_css_image_fallback_parse_arg (GtkCssParser *parser,
}
else
{
data->color = _gtk_css_color_value_parse (parser);
data->color = gtk_css_color_value_parse (parser);
if (data->color == NULL)
return 0;
@@ -240,7 +234,7 @@ gtk_css_image_fallback_parse (GtkCssImage *image,
if (!gtk_css_parser_consume_function (parser, 1, G_MAXUINT, gtk_css_image_fallback_parse_arg, &data))
{
g_clear_pointer (&data.color, _gtk_css_value_unref);
g_clear_pointer (&data.color, gtk_css_value_unref);
if (data.images)
g_ptr_array_free (data.images, TRUE);
return FALSE;
@@ -273,7 +267,7 @@ gtk_css_image_fallback_equal (GtkCssImage *image1,
if (fallback2->used >= 0)
return FALSE;
return _gtk_css_value_equal (fallback1->color, fallback2->color);
return gtk_css_value_equal (fallback1->color, fallback2->color);
}
if (fallback2->used < 0)

View File

@@ -138,11 +138,9 @@ gtk_css_image_icon_theme_print (GtkCssImage *image,
}
static GtkCssImage *
gtk_css_image_icon_theme_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_image_icon_theme_compute (GtkCssImage *image,
guint property_id,
GtkCssComputeContext *context)
{
GtkCssImageIconTheme *icon_theme = GTK_CSS_IMAGE_ICON_THEME (image);
GtkCssImageIconTheme *copy;
@@ -151,12 +149,12 @@ 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);
settings = gtk_style_provider_get_settings (provider);
settings = gtk_style_provider_get_settings (context->provider);
display = _gtk_settings_get_display (settings);
copy->icon_theme = gtk_icon_theme_get_for_display (display);
copy->serial = gtk_icon_theme_get_serial (copy->icon_theme);
copy->scale = gtk_style_provider_get_scale (provider);
gtk_css_style_lookup_symbolic_colors (style, copy->colors);
copy->scale = gtk_style_provider_get_scale (context->provider);
gtk_css_style_lookup_symbolic_colors (context->style, copy->colors);
return GTK_CSS_IMAGE (copy);
}

View File

@@ -273,7 +273,7 @@ gtk_css_image_linear_parse_color_stop (GtkCssImageLinear *self,
{
GtkCssImageLinearColorStop stop;
stop.color = _gtk_css_color_value_parse (parser);
stop.color = gtk_css_color_value_parse (parser);
if (stop.color == NULL)
return 0;
@@ -284,7 +284,7 @@ gtk_css_image_linear_parse_color_stop (GtkCssImageLinear *self,
| GTK_CSS_PARSE_LENGTH);
if (stop.offset == NULL)
{
_gtk_css_value_unref (stop.color);
gtk_css_value_unref (stop.color);
return 0;
}
}
@@ -464,7 +464,7 @@ gtk_css_image_linear_print (GtkCssImage *image,
}
else
{
_gtk_css_value_print (linear->angle, string);
gtk_css_value_print (linear->angle, string);
g_string_append (string, ", ");
}
@@ -475,12 +475,12 @@ gtk_css_image_linear_print (GtkCssImage *image,
if (i > 0)
g_string_append (string, ", ");
_gtk_css_value_print (stop->color, string);
gtk_css_value_print (stop->color, string);
if (stop->offset)
{
g_string_append (string, " ");
_gtk_css_value_print (stop->offset, string);
gtk_css_value_print (stop->offset, string);
}
}
@@ -488,11 +488,9 @@ gtk_css_image_linear_print (GtkCssImage *image,
}
static GtkCssImage *
gtk_css_image_linear_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_image_linear_compute (GtkCssImage *image,
guint property_id,
GtkCssComputeContext *context)
{
GtkCssImageLinear *linear = GTK_CSS_IMAGE_LINEAR (image);
GtkCssImageLinear *copy;
@@ -503,7 +501,7 @@ gtk_css_image_linear_compute (GtkCssImage *image,
copy->side = linear->side;
if (linear->angle)
copy->angle = _gtk_css_value_compute (linear->angle, property_id, provider, style, parent_style);
copy->angle = gtk_css_value_compute (linear->angle, property_id, context);
copy->n_stops = linear->n_stops;
copy->color_stops = g_malloc (sizeof (GtkCssImageLinearColorStop) * copy->n_stops);
@@ -512,11 +510,11 @@ gtk_css_image_linear_compute (GtkCssImage *image,
const GtkCssImageLinearColorStop *stop = &linear->color_stops[i];
GtkCssImageLinearColorStop *scopy = &copy->color_stops[i];
scopy->color = _gtk_css_value_compute (stop->color, property_id, provider, style, parent_style);
scopy->color = gtk_css_value_compute (stop->color, property_id, context);
if (stop->offset)
{
scopy->offset = _gtk_css_value_compute (stop->offset, property_id, provider, style, parent_style);
scopy->offset = gtk_css_value_compute (stop->offset, property_id, context);
}
else
{
@@ -558,7 +556,7 @@ gtk_css_image_linear_transition (GtkCssImage *start_image,
result->side = start->side;
if (result->side == 0)
result->angle = _gtk_css_value_transition (start->angle, end->angle, property_id, progress);
result->angle = gtk_css_value_transition (start->angle, end->angle, property_id, progress);
if (result->angle == NULL)
goto fail;
@@ -580,22 +578,22 @@ gtk_css_image_linear_transition (GtkCssImage *start_image,
}
else
{
stop->offset = _gtk_css_value_transition (start_stop->offset,
end_stop->offset,
property_id,
progress);
stop->offset = gtk_css_value_transition (start_stop->offset,
end_stop->offset,
property_id,
progress);
if (stop->offset == NULL)
goto fail;
}
stop->color = _gtk_css_value_transition (start_stop->color,
end_stop->color,
property_id,
progress);
stop->color = gtk_css_value_transition (start_stop->color,
end_stop->color,
property_id,
progress);
if (stop->color == NULL)
{
if (stop->offset)
_gtk_css_value_unref (stop->offset);
gtk_css_value_unref (stop->offset);
goto fail;
}
@@ -619,7 +617,7 @@ gtk_css_image_linear_equal (GtkCssImage *image1,
if (linear1->repeating != linear2->repeating ||
linear1->side != linear2->side ||
(linear1->side == 0 && !_gtk_css_value_equal (linear1->angle, linear2->angle)) ||
(linear1->side == 0 && !gtk_css_value_equal (linear1->angle, linear2->angle)) ||
linear1->n_stops != linear2->n_stops)
return FALSE;
@@ -628,8 +626,8 @@ gtk_css_image_linear_equal (GtkCssImage *image1,
const GtkCssImageLinearColorStop *stop1 = &linear1->color_stops[i];
const GtkCssImageLinearColorStop *stop2 = &linear2->color_stops[i];
if (!_gtk_css_value_equal0 (stop1->offset, stop2->offset) ||
!_gtk_css_value_equal (stop1->color, stop2->color))
if (!gtk_css_value_equal0 (stop1->offset, stop2->offset) ||
!gtk_css_value_equal (stop1->color, stop2->color))
return FALSE;
}
@@ -646,16 +644,16 @@ gtk_css_image_linear_dispose (GObject *object)
{
GtkCssImageLinearColorStop *stop = &linear->color_stops[i];
_gtk_css_value_unref (stop->color);
gtk_css_value_unref (stop->color);
if (stop->offset)
_gtk_css_value_unref (stop->offset);
gtk_css_value_unref (stop->offset);
}
g_free (linear->color_stops);
linear->side = 0;
if (linear->angle)
{
_gtk_css_value_unref (linear->angle);
gtk_css_value_unref (linear->angle);
linear->angle = NULL;
}

View File

@@ -20,6 +20,7 @@
#include "config.h"
#include "gtkcssimagepaintableprivate.h"
#include "gtkcssvalueprivate.h"
#include "gtkprivate.h"
@@ -96,11 +97,9 @@ gtk_css_image_paintable_get_static_image (GtkCssImage *image)
}
static GtkCssImage *
gtk_css_image_paintable_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_image_paintable_compute (GtkCssImage *image,
guint property_id,
GtkCssComputeContext *context)
{
return gtk_css_image_paintable_get_static_image (image);
}

View File

@@ -26,6 +26,8 @@
#include "gtk/css/gtkcsstokenizerprivate.h"
#include "gtk/css/gtkcssparserprivate.h"
#include "gtk/gtkcsstypesprivate.h"
#include "gtk/gtkcssvariablesetprivate.h"
#include "gtk/gtkcssvalueprivate.h"
#include "gtk/gtksnapshot.h"
#include "gtk/gtkstyleprovider.h"
@@ -60,9 +62,7 @@ struct _GtkCssImageClass
/* create "computed value" in CSS terms, returns a new reference */
GtkCssImage *(* compute) (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style);
GtkCssComputeContext *context);
/* compare two images for equality */
gboolean (* equal) (GtkCssImage *image1,
GtkCssImage *image2);
@@ -104,9 +104,7 @@ double _gtk_css_image_get_aspect_ratio (GtkCssImage *
GtkCssImage * _gtk_css_image_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style);
GtkCssComputeContext *context);
gboolean _gtk_css_image_equal (GtkCssImage *image1,
GtkCssImage *image2) G_GNUC_PURE;
GtkCssImage * _gtk_css_image_transition (GtkCssImage *start,

View File

@@ -223,7 +223,7 @@ gtk_css_image_radial_parse_color_stop (GtkCssImageRadial *radial,
{
GtkCssImageRadialColorStop stop;
stop.color = _gtk_css_color_value_parse (parser);
stop.color = gtk_css_color_value_parse (parser);
if (stop.color == NULL)
return 0;
@@ -234,7 +234,7 @@ gtk_css_image_radial_parse_color_stop (GtkCssImageRadial *radial,
| GTK_CSS_PARSE_LENGTH);
if (stop.offset == NULL)
{
_gtk_css_value_unref (stop.color);
gtk_css_value_unref (stop.color);
return 0;
}
}
@@ -358,7 +358,7 @@ gtk_css_image_radial_parse_first_arg (GtkCssImageRadial *radial,
if (has_size && !radial->circle)
{
if (radial->sizes[0] && !radial->sizes[1])
radial->sizes[1] = _gtk_css_value_ref (radial->sizes[0]);
radial->sizes[1] = gtk_css_value_ref (radial->sizes[0]);
}
if (found_one)
@@ -456,16 +456,16 @@ gtk_css_image_radial_print (GtkCssImage *image,
else
{
if (radial->sizes[0])
_gtk_css_value_print (radial->sizes[0], string);
gtk_css_value_print (radial->sizes[0], string);
if (radial->sizes[1])
{
g_string_append (string, " ");
_gtk_css_value_print (radial->sizes[1], string);
gtk_css_value_print (radial->sizes[1], string);
}
}
g_string_append (string, " at ");
_gtk_css_value_print (radial->position, string);
gtk_css_value_print (radial->position, string);
g_string_append (string, ", ");
@@ -476,12 +476,12 @@ gtk_css_image_radial_print (GtkCssImage *image,
if (i > 0)
g_string_append (string, ", ");
_gtk_css_value_print (stop->color, string);
gtk_css_value_print (stop->color, string);
if (stop->offset)
{
g_string_append (string, " ");
_gtk_css_value_print (stop->offset, string);
gtk_css_value_print (stop->offset, string);
}
}
@@ -489,11 +489,9 @@ gtk_css_image_radial_print (GtkCssImage *image,
}
static GtkCssImage *
gtk_css_image_radial_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_image_radial_compute (GtkCssImage *image,
guint property_id,
GtkCssComputeContext *context)
{
GtkCssImageRadial *radial = GTK_CSS_IMAGE_RADIAL (image);
GtkCssImageRadial *copy;
@@ -504,13 +502,13 @@ gtk_css_image_radial_compute (GtkCssImage *image,
copy->circle = radial->circle;
copy->size = radial->size;
copy->position = _gtk_css_value_compute (radial->position, property_id, provider, style, parent_style);
copy->position = gtk_css_value_compute (radial->position, property_id, context);
if (radial->sizes[0])
copy->sizes[0] = _gtk_css_value_compute (radial->sizes[0], property_id, provider, style, parent_style);
copy->sizes[0] = gtk_css_value_compute (radial->sizes[0], property_id, context);
if (radial->sizes[1])
copy->sizes[1] = _gtk_css_value_compute (radial->sizes[1], property_id, provider, style, parent_style);
copy->sizes[1] = gtk_css_value_compute (radial->sizes[1], property_id, context);
copy->n_stops = radial->n_stops;
copy->color_stops = g_malloc (sizeof (GtkCssImageRadialColorStop) * copy->n_stops);
@@ -519,11 +517,11 @@ gtk_css_image_radial_compute (GtkCssImage *image,
const GtkCssImageRadialColorStop *stop = &radial->color_stops[i];
GtkCssImageRadialColorStop *scopy = &copy->color_stops[i];
scopy->color = _gtk_css_value_compute (stop->color, property_id, provider, style, parent_style);
scopy->color = gtk_css_value_compute (stop->color, property_id, context);
if (stop->offset)
{
scopy->offset = _gtk_css_value_compute (stop->offset, property_id, provider, style, parent_style);
scopy->offset = gtk_css_value_compute (stop->offset, property_id, context);
}
else
{
@@ -564,13 +562,13 @@ gtk_css_image_radial_transition (GtkCssImage *start_image,
result->circle = start->circle;
result->size = start->size;
result->position = _gtk_css_value_transition (start->position, end->position, property_id, progress);
result->position = gtk_css_value_transition (start->position, end->position, property_id, progress);
if (result->position == NULL)
goto fail;
if (start->sizes[0] && end->sizes[0])
{
result->sizes[0] = _gtk_css_value_transition (start->sizes[0], end->sizes[0], property_id, progress);
result->sizes[0] = gtk_css_value_transition (start->sizes[0], end->sizes[0], property_id, progress);
if (result->sizes[0] == NULL)
goto fail;
}
@@ -579,7 +577,7 @@ gtk_css_image_radial_transition (GtkCssImage *start_image,
if (start->sizes[1] && end->sizes[1])
{
result->sizes[1] = _gtk_css_value_transition (start->sizes[1], end->sizes[1], property_id, progress);
result->sizes[1] = gtk_css_value_transition (start->sizes[1], end->sizes[1], property_id, progress);
if (result->sizes[1] == NULL)
goto fail;
}
@@ -603,22 +601,22 @@ gtk_css_image_radial_transition (GtkCssImage *start_image,
}
else
{
stop->offset = _gtk_css_value_transition (start_stop->offset,
end_stop->offset,
property_id,
progress);
stop->offset = gtk_css_value_transition (start_stop->offset,
end_stop->offset,
property_id,
progress);
if (stop->offset == NULL)
goto fail;
}
stop->color = _gtk_css_value_transition (start_stop->color,
end_stop->color,
property_id,
progress);
stop->color = gtk_css_value_transition (start_stop->color,
end_stop->color,
property_id,
progress);
if (stop->color == NULL)
{
if (stop->offset)
_gtk_css_value_unref (stop->offset);
gtk_css_value_unref (stop->offset);
goto fail;
}
@@ -642,11 +640,11 @@ gtk_css_image_radial_equal (GtkCssImage *image1,
if (radial1->repeating != radial2->repeating ||
radial1->size != radial2->size ||
!_gtk_css_value_equal (radial1->position, radial2->position) ||
!gtk_css_value_equal (radial1->position, radial2->position) ||
((radial1->sizes[0] == NULL) != (radial2->sizes[0] == NULL)) ||
(radial1->sizes[0] && radial2->sizes[0] && !_gtk_css_value_equal (radial1->sizes[0], radial2->sizes[0])) ||
(radial1->sizes[0] && radial2->sizes[0] && !gtk_css_value_equal (radial1->sizes[0], radial2->sizes[0])) ||
((radial1->sizes[1] == NULL) != (radial2->sizes[1] == NULL)) ||
(radial1->sizes[1] && radial2->sizes[1] && !_gtk_css_value_equal (radial1->sizes[1], radial2->sizes[1])) ||
(radial1->sizes[1] && radial2->sizes[1] && !gtk_css_value_equal (radial1->sizes[1], radial2->sizes[1])) ||
radial1->n_stops != radial2->n_stops)
return FALSE;
@@ -655,8 +653,8 @@ gtk_css_image_radial_equal (GtkCssImage *image1,
const GtkCssImageRadialColorStop *stop1 = &radial1->color_stops[i];
const GtkCssImageRadialColorStop *stop2 = &radial2->color_stops[i];
if (!_gtk_css_value_equal0 (stop1->offset, stop2->offset) ||
!_gtk_css_value_equal (stop1->color, stop2->color))
if (!gtk_css_value_equal0 (stop1->offset, stop2->offset) ||
!gtk_css_value_equal (stop1->color, stop2->color))
return FALSE;
}
@@ -673,22 +671,22 @@ gtk_css_image_radial_dispose (GObject *object)
{
GtkCssImageRadialColorStop *stop = &radial->color_stops[i];
_gtk_css_value_unref (stop->color);
gtk_css_value_unref (stop->color);
if (stop->offset)
_gtk_css_value_unref (stop->offset);
gtk_css_value_unref (stop->offset);
}
g_free (radial->color_stops);
if (radial->position)
{
_gtk_css_value_unref (radial->position);
gtk_css_value_unref (radial->position);
radial->position = NULL;
}
for (i = 0; i < 2; i++)
if (radial->sizes[i])
{
_gtk_css_value_unref (radial->sizes[i]);
gtk_css_value_unref (radial->sizes[i]);
radial->sizes[i] = NULL;
}

View File

@@ -44,7 +44,7 @@ gtk_css_image_recolor_print (GtkCssImage *image,
if (recolor->palette)
{
g_string_append (string, ",");
_gtk_css_value_print (recolor->palette, string);
gtk_css_value_print (recolor->palette, string);
}
g_string_append (string, ")");
}
@@ -54,7 +54,7 @@ gtk_css_image_recolor_dispose (GObject *object)
{
GtkCssImageRecolor *recolor = GTK_CSS_IMAGE_RECOLOR (object);
g_clear_pointer (&recolor->palette, _gtk_css_value_unref);
g_clear_pointer (&recolor->palette, gtk_css_value_unref);
g_clear_object (&recolor->file);
g_clear_object (&recolor->texture);
@@ -201,11 +201,9 @@ gtk_css_image_recolor_snapshot (GtkCssImage *image,
}
static GtkCssImage *
gtk_css_image_recolor_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_image_recolor_compute (GtkCssImage *image,
guint property_id,
GtkCssComputeContext *context)
{
GtkCssImageRecolor *recolor = GTK_CSS_IMAGE_RECOLOR (image);
GtkCssValue *palette;
@@ -213,23 +211,23 @@ gtk_css_image_recolor_compute (GtkCssImage *image,
int scale;
GError *error = NULL;
scale = gtk_style_provider_get_scale (provider);
scale = gtk_style_provider_get_scale (context->provider);
if (recolor->palette)
palette = _gtk_css_value_compute (recolor->palette, property_id, provider, style, parent_style);
palette = gtk_css_value_compute (recolor->palette, property_id, context);
else
palette = _gtk_css_value_ref (style->core->icon_palette);
palette = gtk_css_value_ref (context->style->core->icon_palette);
img = gtk_css_image_recolor_load (recolor, style, palette, scale, &error);
img = gtk_css_image_recolor_load (recolor, context->style, palette, scale, &error);
if (error)
{
GtkCssSection *section = gtk_css_style_get_section (style, property_id);
gtk_style_provider_emit_error (provider, section, error);
GtkCssSection *section = gtk_css_style_get_section (context->style, property_id);
gtk_style_provider_emit_error (context->provider, section, error);
g_error_free (error);
}
_gtk_css_value_unref (palette);
gtk_css_value_unref (palette);
return img;
}

View File

@@ -97,11 +97,9 @@ gtk_css_image_scaled_dispose (GObject *object)
static GtkCssImage *
gtk_css_image_scaled_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_image_scaled_compute (GtkCssImage *image,
guint property_id,
GtkCssComputeContext *context)
{
GtkCssImageScaled *scaled = GTK_CSS_IMAGE_SCALED (image);
int scale;
@@ -109,7 +107,7 @@ gtk_css_image_scaled_compute (GtkCssImage *image,
int i;
int best;
scale = gtk_style_provider_get_scale (provider);
scale = gtk_style_provider_get_scale (context->provider);
scale = MAX(scale, 1);
best = 0;
@@ -135,9 +133,7 @@ gtk_css_image_scaled_compute (GtkCssImage *image,
res->images[0] = _gtk_css_image_compute (scaled->images[best],
property_id,
provider,
style,
parent_style);
context);
res->scales[0] = scaled->scales[best];
return GTK_CSS_IMAGE (res);

View File

@@ -112,11 +112,9 @@ gtk_css_image_url_snapshot (GtkCssImage *image,
}
static GtkCssImage *
gtk_css_image_url_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_image_url_compute (GtkCssImage *image,
guint property_id,
GtkCssComputeContext *context)
{
GtkCssImageUrl *url = GTK_CSS_IMAGE_URL (image);
GtkCssImage *copy;
@@ -125,8 +123,8 @@ gtk_css_image_url_compute (GtkCssImage *image,
copy = gtk_css_image_url_load_image (url, &error);
if (error)
{
GtkCssSection *section = gtk_css_style_get_section (style, property_id);
gtk_style_provider_emit_error (provider, section, error);
GtkCssSection *section = gtk_css_style_get_section (context->style, property_id);
gtk_style_provider_emit_error (context->provider, section, error);
g_error_free (error);
}

View File

@@ -34,25 +34,23 @@ gtk_css_value_image_free (GtkCssValue *value)
}
static GtkCssValue *
gtk_css_value_image_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_value_image_compute (GtkCssValue *value,
guint property_id,
GtkCssComputeContext *context)
{
GtkCssImage *image, *computed;
image = _gtk_css_image_value_get_image (value);
if (image == NULL)
return _gtk_css_value_ref (value);
return gtk_css_value_ref (value);
computed = _gtk_css_image_compute (image, property_id, provider, style, parent_style);
computed = _gtk_css_image_compute (image, property_id, context);
if (computed == image)
{
g_object_unref (computed);
return _gtk_css_value_ref (value);
return gtk_css_value_ref (value);
}
return _gtk_css_image_value_new (computed);
@@ -136,13 +134,13 @@ static const GtkCssValueClass GTK_CSS_VALUE_IMAGE = {
GtkCssValue *
_gtk_css_image_value_new (GtkCssImage *image)
{
static GtkCssValue image_none_singleton = { &GTK_CSS_VALUE_IMAGE, 1, TRUE, NULL };
static GtkCssValue image_none_singleton = { &GTK_CSS_VALUE_IMAGE, 1, TRUE, FALSE, NULL };
GtkCssValue *value;
if (image == NULL)
return _gtk_css_value_ref (&image_none_singleton);
return gtk_css_value_ref (&image_none_singleton);
value = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_IMAGE);
value = gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_IMAGE);
value->image = image;
value->is_computed = gtk_css_image_is_computed (image);

View File

@@ -34,23 +34,19 @@ gtk_css_value_inherit_free (GtkCssValue *value)
}
static GtkCssValue *
gtk_css_value_inherit_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_value_inherit_compute (GtkCssValue *value,
guint property_id,
GtkCssComputeContext *context)
{
if (parent_style)
if (context->parent_style)
{
return _gtk_css_value_ref (gtk_css_style_get_value (parent_style, property_id));
return gtk_css_value_ref (gtk_css_style_get_value (context->parent_style, property_id));
}
else
{
return _gtk_css_value_compute (_gtk_css_initial_value_get (),
property_id,
provider,
style,
parent_style);
return gtk_css_value_compute (_gtk_css_initial_value_get (),
property_id,
context);
}
}
@@ -93,7 +89,7 @@ static GtkCssValue inherit = { &GTK_CSS_VALUE_INHERIT, 1 };
GtkCssValue *
_gtk_css_inherit_value_new (void)
{
return _gtk_css_value_ref (&inherit);
return gtk_css_value_ref (&inherit);
}
GtkCssValue *

View File

@@ -38,18 +38,16 @@ gtk_css_value_initial_free (GtkCssValue *value)
}
static GtkCssValue *
gtk_css_value_initial_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_value_initial_compute (GtkCssValue *value,
guint property_id,
GtkCssComputeContext *context)
{
GtkSettings *settings;
switch (property_id)
{
case GTK_CSS_PROPERTY_DPI:
settings = gtk_style_provider_get_settings (provider);
settings = gtk_style_provider_get_settings (context->provider);
if (settings)
{
int dpi_int;
@@ -62,7 +60,7 @@ gtk_css_value_initial_compute (GtkCssValue *value,
break;
case GTK_CSS_PROPERTY_FONT_FAMILY:
settings = gtk_style_provider_get_settings (provider);
settings = gtk_style_provider_get_settings (context->provider);
if (settings && gtk_settings_get_font_family (settings) != NULL)
return _gtk_css_array_value_new (_gtk_css_string_value_new (gtk_settings_get_font_family (settings)));
break;
@@ -71,11 +69,9 @@ gtk_css_value_initial_compute (GtkCssValue *value,
break;
}
return _gtk_css_value_compute (_gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (property_id)),
return gtk_css_value_compute (_gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (property_id)),
property_id,
provider,
style,
parent_style);
context);
}
static gboolean
@@ -117,7 +113,7 @@ static GtkCssValue initial = { &GTK_CSS_VALUE_INITIAL, 1 };
GtkCssValue *
_gtk_css_initial_value_new (void)
{
return _gtk_css_value_ref (&initial);
return gtk_css_value_ref (&initial);
}
GtkCssValue *
@@ -126,14 +122,10 @@ _gtk_css_initial_value_get (void)
return &initial;
}
GtkCssValue *
_gtk_css_initial_value_new_compute (guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
_gtk_css_initial_value_new_compute (guint property_id,
GtkCssComputeContext *context)
{
return gtk_css_value_initial_compute (NULL,
property_id,
provider,
style,
parent_style);
context);
}

View File

@@ -25,10 +25,8 @@ G_BEGIN_DECLS
GtkCssValue * _gtk_css_initial_value_new (void);
GtkCssValue * _gtk_css_initial_value_get (void);
GtkCssValue * _gtk_css_initial_value_new_compute (guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style);
GtkCssValue * _gtk_css_initial_value_new_compute (guint property_id,
GtkCssComputeContext *context);
G_END_DECLS

View File

@@ -21,6 +21,8 @@
#include "gtkcssstyleprivate.h"
#include "gtkcssarrayvalueprivate.h"
#include "gtkcsscustompropertypoolprivate.h"
#include "gtkcssreferencevalueprivate.h"
#include "gtkcssshorthandpropertyprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkstylepropertyprivate.h"
@@ -31,12 +33,15 @@
#include <string.h>
struct _GtkCssKeyframes {
int ref_count; /* ref count */
int n_keyframes; /* number of keyframes (at least 2 for 0% and 100% */
double *keyframe_progress; /* ordered array of n_keyframes of [0..1] */
int n_properties; /* number of properties used by keyframes */
guint *property_ids; /* ordered array of n_properties property ids */
GtkCssValue **values; /* 2D array: n_keyframes * n_properties of (value or NULL) for all the keyframes */
int ref_count; /* ref count */
int n_keyframes; /* number of keyframes (at least 2 for 0% and 100% */
double *keyframe_progress; /* ordered array of n_keyframes of [0..1] */
int n_properties; /* number of properties used by keyframes */
guint *property_ids; /* ordered array of n_properties property ids */
GtkCssValue **values; /* 2D array: n_keyframes * n_properties of (value or NULL) for all the keyframes */
GtkCssVariableSet **variables; /* array of variable sets for each keyframe */
int *variable_ids; /* ordered array of variable ids */
int n_variables; /* number of variable used by keyframes */
};
#define KEYFRAMES_VALUE(keyframes, k, p) ((keyframes)->values[(k) * (keyframes)->n_properties + (p)])
@@ -69,11 +74,16 @@ _gtk_css_keyframes_unref (GtkCssKeyframes *keyframes)
{
for (p = 0; p < keyframes->n_properties; p++)
{
_gtk_css_value_unref (KEYFRAMES_VALUE (keyframes, k, p));
gtk_css_value_unref (KEYFRAMES_VALUE (keyframes, k, p));
KEYFRAMES_VALUE (keyframes, k, p) = NULL;
}
if (keyframes->variables && keyframes->variables[k])
gtk_css_variable_set_unref (keyframes->variables[k]);
}
g_free (keyframes->values);
g_free (keyframes->variables);
g_free (keyframes->variable_ids);
g_free (keyframes);
}
@@ -93,7 +103,7 @@ gtk_css_keyframes_add_keyframe (GtkCssKeyframes *keyframes,
if (KEYFRAMES_VALUE (keyframes, k, p) == NULL)
continue;
_gtk_css_value_unref (KEYFRAMES_VALUE (keyframes, k, p));
gtk_css_value_unref (KEYFRAMES_VALUE (keyframes, k, p));
KEYFRAMES_VALUE (keyframes, k, p) = NULL;
/* XXX: GC properties that are now unset
@@ -120,6 +130,9 @@ gtk_css_keyframes_add_keyframe (GtkCssKeyframes *keyframes,
memset (&KEYFRAMES_VALUE (keyframes, k, 0), 0, size);
}
if (keyframes->variables)
keyframes->variables = g_realloc (keyframes->variables, sizeof (GtkCssVariableSet *) * keyframes->n_keyframes);
return k;
}
@@ -173,6 +186,26 @@ gtk_css_keyframes_lookup_property (GtkCssKeyframes *keyframes,
return p;
}
static void
gtk_css_keyframes_register_variable (GtkCssKeyframes *keyframes,
int variable_id)
{
guint p;
for (p = 0; p < keyframes->n_variables; p++)
{
if (keyframes->variable_ids[p] == variable_id)
return;
else if (keyframes->variable_ids[p] > variable_id)
break;
}
keyframes->n_variables++;
keyframes->variable_ids = g_realloc (keyframes->variable_ids, sizeof (int) * keyframes->n_variables);
memmove (keyframes->variable_ids + p + 1, keyframes->variable_ids + p, sizeof (int) * (keyframes->n_variables - p - 1));
keyframes->variable_ids[p] = variable_id;
}
static GtkCssKeyframes *
gtk_css_keyframes_alloc (void)
{
@@ -211,9 +244,9 @@ keyframes_set_value (GtkCssKeyframes *keyframes,
p = gtk_css_keyframes_lookup_property (keyframes, _gtk_css_style_property_get_id (property));
if (KEYFRAMES_VALUE (keyframes, k, p))
_gtk_css_value_unref (KEYFRAMES_VALUE (keyframes, k, p));
gtk_css_value_unref (KEYFRAMES_VALUE (keyframes, k, p));
KEYFRAMES_VALUE (keyframes, k, p) = _gtk_css_value_ref (value);
KEYFRAMES_VALUE (keyframes, k, p) = gtk_css_value_ref (value);
return TRUE;
}
@@ -235,6 +268,47 @@ gtk_css_keyframes_parse_declaration (GtkCssKeyframes *keyframes,
return FALSE;
}
/* This is a custom property */
if (name[0] == '-' && name[1] == '-')
{
GtkCssVariableValue *var_value;
GtkCssCustomPropertyPool *pool;
int id;
if (!gtk_css_parser_try_token (parser, GTK_CSS_TOKEN_COLON))
{
gtk_css_parser_error_syntax (parser, "Expected a ':'");
g_free (name);
return FALSE;
}
var_value = gtk_css_parser_parse_value_into_token_stream (parser);
if (var_value == NULL)
{
g_free (name);
return FALSE;
}
if (!keyframes->variables)
keyframes->variables = g_new0 (GtkCssVariableSet *, keyframes->n_keyframes);
if (!keyframes->variables[k])
keyframes->variables[k] = gtk_css_variable_set_new ();
pool = gtk_css_custom_property_pool_get ();
id = gtk_css_custom_property_pool_add (pool, name);
gtk_css_keyframes_register_variable (keyframes, id);
gtk_css_variable_value_taint (var_value);
gtk_css_variable_set_add (keyframes->variables[k], id, var_value);
gtk_css_custom_property_pool_unref (pool, id);
g_free (name);
return TRUE;
}
property = _gtk_style_property_lookup (name);
if (property == NULL)
{
@@ -251,14 +325,58 @@ gtk_css_keyframes_parse_declaration (GtkCssKeyframes *keyframes,
return FALSE;
}
value = _gtk_style_property_parse_value (property, parser);
if (value == NULL)
return FALSE;
if (gtk_css_parser_has_references (parser))
{
GtkCssVariableValue *var_value;
var_value = gtk_css_parser_parse_value_into_token_stream (parser);
if (var_value == NULL)
return FALSE;
if (GTK_IS_CSS_SHORTHAND_PROPERTY (property))
{
GtkCssShorthandProperty *shorthand = GTK_CSS_SHORTHAND_PROPERTY (property);
guint i, n;
GtkCssValue **values;
n = _gtk_css_shorthand_property_get_n_subproperties (shorthand);
values = g_new (GtkCssValue *, n);
for (i = 0; i < n; i++)
{
GtkCssValue *child =
_gtk_css_reference_value_new (property,
var_value,
gtk_css_parser_get_file (parser));
_gtk_css_reference_value_set_subproperty (child, i);
values[i] = _gtk_css_array_value_get_nth (child, i);
}
value = _gtk_css_array_value_new_from_array (values, n);
g_free (values);
}
else
{
value = _gtk_css_reference_value_new (property,
var_value,
gtk_css_parser_get_file (parser));
}
gtk_css_variable_value_unref (var_value);
}
else
{
value = _gtk_style_property_parse_value (property, parser);
if (value == NULL)
return FALSE;
}
if (!gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_EOF))
{
gtk_css_parser_error_syntax (parser, "Junk at end of value");
_gtk_css_value_unref (value);
gtk_css_value_unref (value);
return FALSE;
}
@@ -289,7 +407,7 @@ gtk_css_keyframes_parse_declaration (GtkCssKeyframes *keyframes,
g_assert_not_reached ();
}
_gtk_css_value_unref (value);
gtk_css_value_unref (value);
return TRUE;
}
@@ -314,6 +432,9 @@ gtk_css_keyframes_parse_block (GtkCssKeyframes *keyframes,
gtk_css_parser_end_block (parser);
}
if (keyframes->variables && keyframes->variables[k])
gtk_css_variable_set_resolve_cycles (keyframes->variables[k]);
gtk_css_parser_end_block (parser);
return TRUE;
@@ -378,12 +499,27 @@ compare_property_by_name (gconstpointer a,
_gtk_css_style_property_lookup_by_id (keyframes->property_ids[*(const guint *) b]))));
}
static int
compare_custom_property_ids (gconstpointer a, gconstpointer b, gpointer user_data)
{
GtkCssCustomPropertyPool *pool = user_data;
int id1 = GPOINTER_TO_INT (*((const int *) a));
int id2 = GPOINTER_TO_INT (*((const int *) b));
const char *name1, *name2;
name1 = gtk_css_custom_property_pool_get_name (pool, id1);
name2 = gtk_css_custom_property_pool_get_name (pool, id2);
return strcmp (name1, name2);
}
void
_gtk_css_keyframes_print (GtkCssKeyframes *keyframes,
GString *string)
{
GtkCssCustomPropertyPool *pool = gtk_css_custom_property_pool_get ();
guint k, p;
guint *sorted;
guint *sorted, *sorted_variable_ids = NULL;
g_return_if_fail (keyframes != NULL);
g_return_if_fail (string != NULL);
@@ -393,6 +529,18 @@ _gtk_css_keyframes_print (GtkCssKeyframes *keyframes,
sorted[p] = p;
g_qsort_with_data (sorted, keyframes->n_properties, sizeof (guint), compare_property_by_name, keyframes);
if (keyframes->variable_ids)
{
sorted_variable_ids = g_memdup2 (keyframes->variable_ids,
sizeof (int) * keyframes->n_variables);
g_qsort_with_data (sorted_variable_ids,
keyframes->n_variables,
sizeof (int),
compare_custom_property_ids,
pool);
}
for (k = 0; k < keyframes->n_keyframes; k++)
{
/* useful for 0% and 100% which might be empty */
@@ -418,15 +566,47 @@ _gtk_css_keyframes_print (GtkCssKeyframes *keyframes,
GTK_STYLE_PROPERTY (
_gtk_css_style_property_lookup_by_id (
keyframes->property_ids[sorted[p]]))));
_gtk_css_value_print (KEYFRAMES_VALUE (keyframes, k, sorted[p]), string);
gtk_css_value_print (KEYFRAMES_VALUE (keyframes, k, sorted[p]), string);
g_string_append (string, ";\n");
}
if (keyframes->variables && keyframes->variables[k])
{
for (p = 0; p < keyframes->n_variables; p++)
{
int variable_id = sorted_variable_ids[p];
GtkCssVariableValue *value =
gtk_css_variable_set_lookup (keyframes->variables[k], variable_id, NULL);
const char *name;
if (value == NULL)
continue;
if (!opened)
{
if (keyframes->keyframe_progress[k] == 0.0)
g_string_append (string, " from {\n");
else if (keyframes->keyframe_progress[k] == 1.0)
g_string_append (string, " to {\n");
else
g_string_append_printf (string, " %g%% {\n", keyframes->keyframe_progress[k] * 100);
opened = TRUE;
}
name = gtk_css_custom_property_pool_get_name (pool, variable_id);
g_string_append_printf (string, " %s: ", name);
gtk_css_variable_value_print (value, string);
g_string_append (string, ";\n");
}
}
if (opened)
g_string_append (string, " }\n");
}
g_free (sorted);
g_free (sorted_variable_ids);
}
GtkCssKeyframes *
@@ -435,6 +615,7 @@ _gtk_css_keyframes_compute (GtkCssKeyframes *keyframes,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
GtkCssComputeContext context = { NULL, };
GtkCssKeyframes *resolved;
guint k, p;
@@ -450,6 +631,10 @@ _gtk_css_keyframes_compute (GtkCssKeyframes *keyframes,
resolved->property_ids = g_memdup2 (keyframes->property_ids, keyframes->n_properties * sizeof (guint));
resolved->values = g_new0 (GtkCssValue *, resolved->n_keyframes * resolved->n_properties);
context.provider = provider;
context.style = style;
context.parent_style = parent_style;
for (p = 0; p < resolved->n_properties; p++)
{
for (k = 0; k < resolved->n_keyframes; k++)
@@ -457,14 +642,30 @@ _gtk_css_keyframes_compute (GtkCssKeyframes *keyframes,
if (KEYFRAMES_VALUE (keyframes, k, p) == NULL)
continue;
KEYFRAMES_VALUE (resolved, k, p) = _gtk_css_value_compute (KEYFRAMES_VALUE (keyframes, k, p),
resolved->property_ids[p],
provider,
style,
parent_style);
context.variables = keyframes->variables ? keyframes->variables[k] : NULL;
KEYFRAMES_VALUE (resolved, k, p) = gtk_css_value_compute (KEYFRAMES_VALUE (keyframes, k, p),
resolved->property_ids[p],
&context);
}
}
if (keyframes->variables)
{
resolved->variables = g_new0 (GtkCssVariableSet *, resolved->n_keyframes);
for (k = 0; k < resolved->n_keyframes; k++)
{
if (keyframes->variables[k])
resolved->variables[k] = gtk_css_variable_set_ref (keyframes->variables[k]);
}
}
else
resolved->variables = NULL;
resolved->variable_ids = g_memdup2 (keyframes->variable_ids, keyframes->n_variables * sizeof (int));
resolved->n_variables = keyframes->n_variables;
return resolved;
}
@@ -511,7 +712,7 @@ _gtk_css_keyframes_get_value (GtkCssKeyframes *keyframes,
if (keyframes->keyframe_progress[k] == progress)
{
return _gtk_css_value_ref (KEYFRAMES_VALUE (keyframes, k, id));
return gtk_css_value_ref (KEYFRAMES_VALUE (keyframes, k, id));
}
else if (keyframes->keyframe_progress[k] < progress)
{
@@ -528,15 +729,95 @@ _gtk_css_keyframes_get_value (GtkCssKeyframes *keyframes,
progress = (progress - start_progress) / (end_progress - start_progress);
result = _gtk_css_value_transition (start_value,
end_value,
keyframes->property_ids[id],
progress);
result = gtk_css_value_transition (start_value,
end_value,
keyframes->property_ids[id],
progress);
/* XXX: Dear spec, what's the correct thing to do here? */
if (result == NULL)
return _gtk_css_value_ref (start_value);
return gtk_css_value_ref (start_value);
return result;
}
guint
_gtk_css_keyframes_get_n_variables (GtkCssKeyframes *keyframes)
{
g_return_val_if_fail (keyframes != NULL, 0);
return keyframes->n_variables;
}
int
_gtk_css_keyframes_get_variable_id (GtkCssKeyframes *keyframes,
guint id)
{
g_return_val_if_fail (keyframes != NULL, 0);
g_return_val_if_fail (id < keyframes->n_variables, 0);
return keyframes->variable_ids[id];
}
GtkCssVariableValue *
_gtk_css_keyframes_get_variable (GtkCssKeyframes *keyframes,
guint id,
double progress,
GtkCssVariableValue *default_value)
{
GtkCssVariableValue *start_value, *end_value, *result;
double start_progress, end_progress;
int variable_id;
guint k;
g_return_val_if_fail (keyframes != NULL, 0);
g_return_val_if_fail (id < keyframes->n_variables, 0);
start_value = default_value;
start_progress = 0.0;
end_value = default_value;
end_progress = 1.0;
variable_id = keyframes->variable_ids[id];
for (k = 0; k < keyframes->n_keyframes; k++)
{
GtkCssVariableValue *value;
if (keyframes->variables[k] == NULL)
continue;
value = gtk_css_variable_set_lookup (keyframes->variables[k], variable_id, NULL);
if (value == NULL)
continue;
if (keyframes->keyframe_progress[k] == progress)
{
return gtk_css_variable_value_ref (value);
}
else if (keyframes->keyframe_progress[k] < progress)
{
start_value = value;
start_progress = keyframes->keyframe_progress[k];
}
else
{
end_value = value;
end_progress = keyframes->keyframe_progress[k];
break;
}
}
progress = (progress - start_progress) / (end_progress - start_progress);
result = gtk_css_variable_value_transition (start_value,
end_value,
progress);
/* XXX: Dear spec, what's the correct thing to do here? */
if (result == NULL)
return start_value ? gtk_css_variable_value_ref (start_value) : NULL;
return result;
}

View File

@@ -50,5 +50,13 @@ GtkCssValue * _gtk_css_keyframes_get_value (GtkCssKeyframes
double progress,
GtkCssValue *default_value);
guint _gtk_css_keyframes_get_n_variables (GtkCssKeyframes *keyframes);
int _gtk_css_keyframes_get_variable_id (GtkCssKeyframes *keyframes,
guint id);
GtkCssVariableValue *_gtk_css_keyframes_get_variable (GtkCssKeyframes *keyframes,
guint id,
double progress,
GtkCssVariableValue *default_value);
G_END_DECLS

View File

@@ -34,20 +34,18 @@ static GtkCssValue *gtk_css_value_line_height_new (GtkCssValue *height);
static void
gtk_css_value_line_height_free (GtkCssValue *value)
{
_gtk_css_value_unref (value->height);
gtk_css_value_unref (value->height);
g_free (value);
}
static GtkCssValue *
gtk_css_value_line_height_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_value_line_height_compute (GtkCssValue *value,
guint property_id,
GtkCssComputeContext *context)
{
GtkCssValue *height;
height = _gtk_css_value_compute (value->height, property_id, provider, style, parent_style);
height = gtk_css_value_compute (value->height, property_id, context);
if (gtk_css_number_value_get_dimension (height) == GTK_CSS_DIMENSION_PERCENTAGE)
{
@@ -55,9 +53,9 @@ gtk_css_value_line_height_compute (GtkCssValue *value,
GtkCssValue *computed;
factor = _gtk_css_number_value_get (height, 1);
computed = gtk_css_number_value_multiply (style->core->font_size, factor);
computed = gtk_css_number_value_multiply (context->style->core->font_size, factor);
_gtk_css_value_unref (height);
gtk_css_value_unref (height);
return computed;
}
@@ -74,7 +72,7 @@ gtk_css_value_line_height_equal (const GtkCssValue *value1,
if (value1->height == NULL || value2->height == NULL)
return FALSE;
return _gtk_css_value_equal (value1->height, value2->height);
return gtk_css_value_equal (value1->height, value2->height);
}
static GtkCssValue *
@@ -88,7 +86,7 @@ gtk_css_value_line_height_transition (GtkCssValue *start,
if (start->height == NULL || end->height == NULL)
return NULL;
height = _gtk_css_value_transition (start->height, end->height, property_id, progress);
height = gtk_css_value_transition (start->height, end->height, property_id, progress);
if (height == NULL)
return NULL;
@@ -102,7 +100,7 @@ gtk_css_value_line_height_print (const GtkCssValue *value,
if (value->height == NULL)
g_string_append (string, "normal");
else
_gtk_css_value_print (value->height, string);
gtk_css_value_print (value->height, string);
}
static const GtkCssValueClass GTK_CSS_VALUE_LINE_HEIGHT = {
@@ -121,7 +119,7 @@ gtk_css_value_line_height_new_empty (void)
{
GtkCssValue *result;
result = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_LINE_HEIGHT);
result = gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_LINE_HEIGHT);
result->height = NULL;
result->is_computed = TRUE;
@@ -133,7 +131,7 @@ gtk_css_value_line_height_new (GtkCssValue *height)
{
GtkCssValue *result;
result = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_LINE_HEIGHT);
result = gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_LINE_HEIGHT);
result->height = height;
return result;
@@ -154,7 +152,7 @@ gtk_css_line_height_value_parse (GtkCssParser *parser)
GtkCssValue *height;
if (gtk_css_parser_try_ident (parser, "normal"))
return _gtk_css_value_ref (gtk_css_line_height_value_get_default ());
return gtk_css_value_ref (gtk_css_line_height_value_get_default ());
height = _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_NUMBER |
GTK_CSS_PARSE_PERCENT |

View File

@@ -19,6 +19,7 @@
#include "gtkcsslookupprivate.h"
#include "gtkcsscustompropertypoolprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkcsstypesprivate.h"
#include "gtkprivatetypebuiltins.h"
@@ -36,6 +37,9 @@ void
_gtk_css_lookup_destroy (GtkCssLookup *lookup)
{
_gtk_bitmask_free (lookup->set_values);
if (lookup->custom_values)
g_hash_table_unref (lookup->custom_values);
}
gboolean
@@ -74,3 +78,17 @@ _gtk_css_lookup_set (GtkCssLookup *lookup,
lookup->values[id].section = section;
lookup->set_values = _gtk_bitmask_set (lookup->set_values, id, TRUE);
}
void
_gtk_css_lookup_set_custom (GtkCssLookup *lookup,
int id,
GtkCssVariableValue *value)
{
gtk_internal_return_if_fail (lookup != NULL);
if (!lookup->custom_values)
lookup->custom_values = g_hash_table_new (g_direct_hash, g_direct_equal);
if (!g_hash_table_contains (lookup->custom_values, GINT_TO_POINTER (id)))
g_hash_table_replace (lookup->custom_values, GINT_TO_POINTER (id), value);
}

View File

@@ -23,6 +23,8 @@
#include "gtk/gtkcssstaticstyleprivate.h"
#include "gtk/css/gtkcsssection.h"
#include "gtk/css/gtkcsstokenizerprivate.h"
#include "gtk/css/gtkcssvariablevalueprivate.h"
G_BEGIN_DECLS
@@ -37,6 +39,7 @@ typedef struct {
struct _GtkCssLookup {
GtkBitmask *set_values;
GtkCssLookupValue values[GTK_CSS_PROPERTY_N_PROPERTIES];
GHashTable *custom_values;
};
void _gtk_css_lookup_init (GtkCssLookup *lookup);
@@ -47,6 +50,9 @@ void _gtk_css_lookup_set (GtkCssLookup
guint id,
GtkCssSection *section,
GtkCssValue *value);
void _gtk_css_lookup_set_custom (GtkCssLookup *lookup,
int id,
GtkCssVariableValue *value);
static inline const GtkBitmask *
_gtk_css_lookup_get_set_values (const GtkCssLookup *lookup)

View File

@@ -445,9 +445,12 @@ gtk_css_node_real_update_style (GtkCssNode *cssnode,
}
else if (static_style != style && (change & GTK_CSS_CHANGE_TIMESTAMP))
{
GtkCssNode *parent = gtk_css_node_get_parent (cssnode);
new_style = gtk_css_animated_style_new_advance (GTK_CSS_ANIMATED_STYLE (style),
static_style,
timestamp);
parent ? gtk_css_node_get_style (parent) : NULL,
timestamp,
gtk_css_node_get_style_provider (cssnode));
}
else
{

View File

@@ -78,7 +78,7 @@ gtk_css_value_number_free (GtkCssValue *number)
const guint n_terms = number->calc.n_terms;
for (guint i = 0; i < n_terms; i++)
_gtk_css_value_unref (number->calc.terms[i]);
gtk_css_value_unref (number->calc.terms[i]);
}
g_free (number);
@@ -108,12 +108,13 @@ get_base_font_size_px (guint property_id,
}
static GtkCssValue *
gtk_css_value_number_compute (GtkCssValue *number,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_value_number_compute (GtkCssValue *number,
guint property_id,
GtkCssComputeContext *context)
{
GtkStyleProvider *provider = context->provider;
GtkCssStyle *style = context->style;
GtkCssStyle *parent_style = context->parent_style;
double value;
if (G_UNLIKELY (number->type == TYPE_CALC))
@@ -128,9 +129,9 @@ gtk_css_value_number_compute (GtkCssValue *number,
for (i = 0; i < n_terms; i++)
{
GtkCssValue *computed = _gtk_css_value_compute (number->calc.terms[i],
property_id, provider, style,
parent_style);
GtkCssValue *computed = gtk_css_value_compute (number->calc.terms[i],
property_id,
context);
changed |= computed != number->calc.terms[i];
new_values[i] = computed;
}
@@ -144,7 +145,7 @@ gtk_css_value_number_compute (GtkCssValue *number,
for (i = 0; i < n_terms; i++)
gtk_css_value_unref (new_values[i]);
result = _gtk_css_value_ref (number);
result = gtk_css_value_ref (number);
}
return result;
@@ -166,7 +167,7 @@ gtk_css_value_number_compute (GtkCssValue *number,
case GTK_CSS_PX:
case GTK_CSS_DEG:
case GTK_CSS_S:
return _gtk_css_value_ref (number);
return gtk_css_value_ref (number);
case GTK_CSS_PT:
return gtk_css_dimension_value_new (value * get_dpi (style) / 72.0,
GTK_CSS_PX);
@@ -234,7 +235,7 @@ gtk_css_value_number_equal (const GtkCssValue *val1,
for (i = 0; i < val1->calc.n_terms; i++)
{
if (!_gtk_css_value_equal (val1->calc.terms[i], val2->calc.terms[i]))
if (!gtk_css_value_equal (val1->calc.terms[i], val2->calc.terms[i]))
return FALSE;
}
@@ -286,12 +287,12 @@ gtk_css_value_number_print (const GtkCssValue *value,
g_assert (value->type == TYPE_CALC);
g_string_append (string, "calc(");
_gtk_css_value_print (value->calc.terms[0], string);
gtk_css_value_print (value->calc.terms[0], string);
for (i = 1; i < value->calc.n_terms; i++)
{
g_string_append (string, " + ");
_gtk_css_value_print (value->calc.terms[i], string);
gtk_css_value_print (value->calc.terms[i], string);
}
g_string_append (string, ")");
}
@@ -305,7 +306,7 @@ gtk_css_value_number_transition (GtkCssValue *start,
GtkCssValue *result, *mul_start, *mul_end;
if (start == end)
return _gtk_css_value_ref (start);
return gtk_css_value_ref (start);
if (G_LIKELY (start->type == TYPE_DIMENSION && end->type == TYPE_DIMENSION))
{
@@ -323,8 +324,8 @@ gtk_css_value_number_transition (GtkCssValue *start,
result = gtk_css_number_value_add (mul_start, mul_end);
_gtk_css_value_unref (mul_start);
_gtk_css_value_unref (mul_end);
gtk_css_value_unref (mul_start);
gtk_css_value_unref (mul_end);
return result;
}
@@ -353,8 +354,8 @@ gtk_css_calc_value_new (guint n_terms)
{
GtkCssValue *result;
result = _gtk_css_value_alloc (&GTK_CSS_VALUE_NUMBER,
gtk_css_value_calc_get_size (n_terms));
result = gtk_css_value_alloc (&GTK_CSS_VALUE_NUMBER,
gtk_css_value_calc_get_size (n_terms));
result->type = TYPE_CALC;
result->calc.n_terms = n_terms;
@@ -366,38 +367,38 @@ gtk_css_dimension_value_new (double value,
GtkCssUnit unit)
{
static GtkCssValue number_singletons[] = {
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, TYPE_DIMENSION, {{ GTK_CSS_NUMBER, 0 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, TYPE_DIMENSION, {{ GTK_CSS_NUMBER, 1 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, TYPE_DIMENSION, {{ GTK_CSS_NUMBER, 96 }} }, /* DPI default */
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_NUMBER, 0 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_NUMBER, 1 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_NUMBER, 96 }} }, /* DPI default */
};
static GtkCssValue px_singletons[] = {
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, TYPE_DIMENSION, {{ GTK_CSS_PX, 0 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, TYPE_DIMENSION, {{ GTK_CSS_PX, 1 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, TYPE_DIMENSION, {{ GTK_CSS_PX, 2 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, TYPE_DIMENSION, {{ GTK_CSS_PX, 3 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, TYPE_DIMENSION, {{ GTK_CSS_PX, 4 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, TYPE_DIMENSION, {{ GTK_CSS_PX, 5 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, TYPE_DIMENSION, {{ GTK_CSS_PX, 6 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, TYPE_DIMENSION, {{ GTK_CSS_PX, 7 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, TYPE_DIMENSION, {{ GTK_CSS_PX, 8 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, TYPE_DIMENSION, {{ GTK_CSS_PX, 16 }} }, /* Icon size default */
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, TYPE_DIMENSION, {{ GTK_CSS_PX, 32 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, TYPE_DIMENSION, {{ GTK_CSS_PX, 64 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_PX, 0 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_PX, 1 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_PX, 2 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_PX, 3 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_PX, 4 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_PX, 5 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_PX, 6 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_PX, 7 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_PX, 8 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_PX, 16 }} }, /* Icon size default */
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_PX, 32 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_PX, 64 }} },
};
static GtkCssValue percent_singletons[] = {
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, TYPE_DIMENSION, {{ GTK_CSS_PERCENT, 0 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, FALSE, TYPE_DIMENSION, {{ GTK_CSS_PERCENT, 50 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, FALSE, TYPE_DIMENSION, {{ GTK_CSS_PERCENT, 100 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_PERCENT, 0 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, FALSE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_PERCENT, 50 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, FALSE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_PERCENT, 100 }} },
};
static GtkCssValue second_singletons[] = {
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, TYPE_DIMENSION, {{ GTK_CSS_S, 0 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, TYPE_DIMENSION, {{ GTK_CSS_S, 1 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_S, 0 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_S, 1 }} },
};
static GtkCssValue deg_singletons[] = {
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, TYPE_DIMENSION, {{ GTK_CSS_DEG, 0 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, TYPE_DIMENSION, {{ GTK_CSS_DEG, 90 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, TYPE_DIMENSION, {{ GTK_CSS_DEG, 180 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, TYPE_DIMENSION, {{ GTK_CSS_DEG, 270 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_DEG, 0 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_DEG, 90 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_DEG, 180 }} },
{ &GTK_CSS_VALUE_NUMBER, 1, TRUE, FALSE, TYPE_DIMENSION, {{ GTK_CSS_DEG, 270 }} },
};
GtkCssValue *result;
@@ -405,10 +406,10 @@ gtk_css_dimension_value_new (double value,
{
case GTK_CSS_NUMBER:
if (value == 0 || value == 1)
return _gtk_css_value_ref (&number_singletons[(int) value]);
return gtk_css_value_ref (&number_singletons[(int) value]);
if (value == 96)
return _gtk_css_value_ref (&number_singletons[2]);
return gtk_css_value_ref (&number_singletons[2]);
break;
@@ -422,41 +423,41 @@ gtk_css_dimension_value_new (double value,
value == 6 ||
value == 7 ||
value == 8)
return _gtk_css_value_ref (&px_singletons[(int) value]);
return gtk_css_value_ref (&px_singletons[(int) value]);
if (value == 16)
return _gtk_css_value_ref (&px_singletons[9]);
return gtk_css_value_ref (&px_singletons[9]);
if (value == 32)
return _gtk_css_value_ref (&px_singletons[10]);
return gtk_css_value_ref (&px_singletons[10]);
if (value == 64)
return _gtk_css_value_ref (&px_singletons[11]);
return gtk_css_value_ref (&px_singletons[11]);
break;
case GTK_CSS_PERCENT:
if (value == 0)
return _gtk_css_value_ref (&percent_singletons[0]);
return gtk_css_value_ref (&percent_singletons[0]);
if (value == 50)
return _gtk_css_value_ref (&percent_singletons[1]);
return gtk_css_value_ref (&percent_singletons[1]);
if (value == 100)
return _gtk_css_value_ref (&percent_singletons[2]);
return gtk_css_value_ref (&percent_singletons[2]);
break;
case GTK_CSS_S:
if (value == 0 || value == 1)
return _gtk_css_value_ref (&second_singletons[(int)value]);
return gtk_css_value_ref (&second_singletons[(int)value]);
break;
case GTK_CSS_DEG:
if (value == 0)
return _gtk_css_value_ref (&deg_singletons[0]);
return gtk_css_value_ref (&deg_singletons[0]);
if (value == 90)
return _gtk_css_value_ref (&deg_singletons[1]);
return gtk_css_value_ref (&deg_singletons[1]);
if (value == 180)
return _gtk_css_value_ref (&deg_singletons[2]);
return gtk_css_value_ref (&deg_singletons[2]);
if (value == 270)
return _gtk_css_value_ref (&deg_singletons[3]);
return gtk_css_value_ref (&deg_singletons[3]);
break;
@@ -464,7 +465,7 @@ gtk_css_dimension_value_new (double value,
;
}
result = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_NUMBER);
result = gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_NUMBER);
result->type = TYPE_DIMENSION;
result->dimension.unit = unit;
result->dimension.value = value;
@@ -540,7 +541,7 @@ gtk_css_calc_array_add (GPtrArray *array, GtkCssValue *value)
if (sum)
{
g_ptr_array_index (array, i) = sum;
_gtk_css_value_unref (value);
gtk_css_value_unref (value);
return;
}
else if (gtk_css_number_value_get_calc_term_order (g_ptr_array_index (array, i)) > calc_term_order)
@@ -568,12 +569,12 @@ gtk_css_calc_value_new_sum (GtkCssValue *value1,
{
for (i = 0; i < value1->calc.n_terms; i++)
{
gtk_css_calc_array_add (array, _gtk_css_value_ref (value1->calc.terms[i]));
gtk_css_calc_array_add (array, gtk_css_value_ref (value1->calc.terms[i]));
}
}
else
{
gtk_css_calc_array_add (array, _gtk_css_value_ref (value1));
gtk_css_calc_array_add (array, gtk_css_value_ref (value1));
}
if (value2->class == &GTK_CSS_VALUE_NUMBER &&
@@ -581,12 +582,12 @@ gtk_css_calc_value_new_sum (GtkCssValue *value1,
{
for (i = 0; i < value2->calc.n_terms; i++)
{
gtk_css_calc_array_add (array, _gtk_css_value_ref (value2->calc.terms[i]));
gtk_css_calc_array_add (array, gtk_css_value_ref (value2->calc.terms[i]));
}
}
else
{
gtk_css_calc_array_add (array, _gtk_css_value_ref (value2));
gtk_css_calc_array_add (array, gtk_css_value_ref (value2));
}
result = gtk_css_calc_value_new_from_array ((GtkCssValue **)array->pdata, array->len);
@@ -643,7 +644,7 @@ gtk_css_number_value_multiply (GtkCssValue *value,
guint i;
if (factor == 1)
return _gtk_css_value_ref (value);
return gtk_css_value_ref (value);
if (G_LIKELY (value->type == TYPE_DIMENSION))
{
@@ -686,10 +687,10 @@ gtk_css_number_value_try_add (GtkCssValue *value1,
return NULL;
if (value1->dimension.value == 0)
return _gtk_css_value_ref (value2);
return gtk_css_value_ref (value2);
if (value2->dimension.value == 0)
return _gtk_css_value_ref (value1);
return gtk_css_value_ref (value1);
return gtk_css_dimension_value_new (value1->dimension.value + value2->dimension.value,
value1->dimension.unit);

View File

@@ -94,7 +94,7 @@ gtk_css_value_palette_free (GtkCssValue *value)
for (i = 0; i < value->n_colors; i ++)
{
g_free (value->color_names[i]);
_gtk_css_value_unref (value->color_values[i]);
gtk_css_value_unref (value->color_values[i]);
}
g_free (value->color_names);
@@ -103,11 +103,9 @@ gtk_css_value_palette_free (GtkCssValue *value)
}
static GtkCssValue *
gtk_css_value_palette_compute (GtkCssValue *specified,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_value_palette_compute (GtkCssValue *specified,
guint property_id,
GtkCssComputeContext *context)
{
GtkCssValue *computed_color;
GtkCssValue *result;
@@ -120,7 +118,7 @@ gtk_css_value_palette_compute (GtkCssValue *specified,
{
GtkCssValue *value = specified->color_values[i];
computed_color = _gtk_css_value_compute (value, property_id, provider, style, parent_style);
computed_color = gtk_css_value_compute (value, property_id, context);
result->color_names[i] = g_strdup (specified->color_names[i]);
result->color_values[i] = computed_color;
@@ -129,8 +127,8 @@ gtk_css_value_palette_compute (GtkCssValue *specified,
if (!changes)
{
_gtk_css_value_unref (result);
result = _gtk_css_value_ref (specified);
gtk_css_value_unref (result);
result = gtk_css_value_ref (specified);
}
return result;
@@ -150,7 +148,7 @@ gtk_css_value_palette_equal (const GtkCssValue *value1,
if (strcmp (value1->color_names[i], value2->color_names[i]) != 0)
return FALSE;
if (!_gtk_css_value_equal (value1->color_values[i], value2->color_values[i]))
if (!gtk_css_value_equal (value1->color_values[i], value2->color_values[i]))
return FALSE;
}
@@ -186,9 +184,9 @@ gtk_css_value_palette_transition (GtkCssValue *start,
end_color = gtk_css_palette_value_find_color (end, name);
if (end_color == NULL)
transition = _gtk_css_value_ref (start_color);
transition = gtk_css_value_ref (start_color);
else
transition = _gtk_css_value_transition (start_color, end_color, property_id, progress);
transition = gtk_css_value_transition (start_color, end_color, property_id, progress);
g_ptr_array_add (new_names, g_strdup (name));
g_ptr_array_add (new_values, transition);
@@ -204,7 +202,7 @@ gtk_css_value_palette_transition (GtkCssValue *start,
continue;
g_ptr_array_add (new_names, g_strdup (name));
g_ptr_array_add (new_values, _gtk_css_value_ref (end_color));
g_ptr_array_add (new_values, gtk_css_value_ref (end_color));
}
result->n_colors = new_names->len;
@@ -237,7 +235,7 @@ gtk_css_value_palette_print (const GtkCssValue *value,
g_string_append (string, value->color_names[i]);
g_string_append_c (string, ' ');
_gtk_css_value_print (value->color_values[i], string);
gtk_css_value_print (value->color_values[i], string);
}
}
@@ -257,7 +255,7 @@ gtk_css_palette_value_new_empty (void)
{
GtkCssValue *result;
result = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_PALETTE);
result = gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_PALETTE);
return result;
}
@@ -267,7 +265,7 @@ gtk_css_palette_value_new_sized (guint size)
{
GtkCssValue *result;
result = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_PALETTE);
result = gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_PALETTE);
result->n_colors = size;
result->color_names = g_malloc (sizeof (char *) * size);
result->color_values = g_malloc (sizeof (GtkCssValue *) * size);
@@ -282,15 +280,15 @@ gtk_css_palette_value_new_default (void)
{
default_palette = gtk_css_palette_value_new_sized (3);
gtk_css_palette_value_set_color (default_palette, 0, g_strdup ("error"),
_gtk_css_color_value_new_name ("error_color"));
gtk_css_color_value_new_name ("error_color"));
gtk_css_palette_value_set_color (default_palette, 1, g_strdup ("success"),
_gtk_css_color_value_new_name ("success_color"));
gtk_css_color_value_new_name ("success_color"));
gtk_css_palette_value_set_color (default_palette, 2, g_strdup ("warning"),
_gtk_css_color_value_new_name ("warning_color"));
gtk_css_color_value_new_name ("warning_color"));
/* Above is already sorted */
}
return _gtk_css_value_ref (default_palette);
return gtk_css_value_ref (default_palette);
}
GtkCssValue *
@@ -312,15 +310,15 @@ gtk_css_palette_value_parse (GtkCssParser *parser)
ident = gtk_css_parser_consume_ident (parser);
if (ident == NULL)
{
_gtk_css_value_unref (result);
gtk_css_value_unref (result);
return NULL;
}
color = _gtk_css_color_value_parse (parser);
color = gtk_css_color_value_parse (parser);
if (color == NULL)
{
g_free (ident);
_gtk_css_value_unref (result);
gtk_css_value_unref (result);
return NULL;
}

View File

@@ -30,27 +30,25 @@ struct _GtkCssValue {
static void
gtk_css_value_position_free (GtkCssValue *value)
{
_gtk_css_value_unref (value->x);
_gtk_css_value_unref (value->y);
gtk_css_value_unref (value->x);
gtk_css_value_unref (value->y);
g_free (value);
}
static GtkCssValue *
gtk_css_value_position_compute (GtkCssValue *position,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_value_position_compute (GtkCssValue *position,
guint property_id,
GtkCssComputeContext *context)
{
GtkCssValue *x, *y;
x = _gtk_css_value_compute (position->x, property_id, provider, style, parent_style);
y = _gtk_css_value_compute (position->y, property_id, provider, style, parent_style);
x = gtk_css_value_compute (position->x, property_id, context);
y = gtk_css_value_compute (position->y, property_id, context);
if (x == position->x && y == position->y)
{
_gtk_css_value_unref (x);
_gtk_css_value_unref (y);
return _gtk_css_value_ref (position);
gtk_css_value_unref (x);
gtk_css_value_unref (y);
return gtk_css_value_ref (position);
}
return _gtk_css_position_value_new (x, y);
@@ -60,8 +58,8 @@ static gboolean
gtk_css_value_position_equal (const GtkCssValue *position1,
const GtkCssValue *position2)
{
return _gtk_css_value_equal (position1->x, position2->x)
&& _gtk_css_value_equal (position1->y, position2->y);
return gtk_css_value_equal (position1->x, position2->x)
&& gtk_css_value_equal (position1->y, position2->y);
}
static GtkCssValue *
@@ -72,13 +70,13 @@ gtk_css_value_position_transition (GtkCssValue *start,
{
GtkCssValue *x, *y;
x = _gtk_css_value_transition (start->x, end->x, property_id, progress);
x = gtk_css_value_transition (start->x, end->x, property_id, progress);
if (x == NULL)
return NULL;
y = _gtk_css_value_transition (start->y, end->y, property_id, progress);
y = gtk_css_value_transition (start->y, end->y, property_id, progress);
if (y == NULL)
{
_gtk_css_value_unref (x);
gtk_css_value_unref (x);
return NULL;
}
@@ -100,9 +98,9 @@ gtk_css_value_position_print (const GtkCssValue *position,
GtkCssValue *center = _gtk_css_number_value_new (50, GTK_CSS_PERCENT);
guint i;
if (_gtk_css_value_equal (position->x, center))
if (gtk_css_value_equal (position->x, center))
{
if (_gtk_css_value_equal (position->y, center))
if (gtk_css_value_equal (position->y, center))
{
g_string_append (string, "center");
goto done;
@@ -112,16 +110,16 @@ gtk_css_value_position_print (const GtkCssValue *position,
{
for (i = 0; i < G_N_ELEMENTS (values); i++)
{
if (_gtk_css_value_equal (position->x, values[i].number))
if (gtk_css_value_equal (position->x, values[i].number))
{
g_string_append (string, values[i].x_name);
break;
}
}
if (i == G_N_ELEMENTS (values))
_gtk_css_value_print (position->x, string);
gtk_css_value_print (position->x, string);
if (_gtk_css_value_equal (position->y, center))
if (gtk_css_value_equal (position->y, center))
goto done;
g_string_append_c (string, ' ');
@@ -129,7 +127,7 @@ gtk_css_value_position_print (const GtkCssValue *position,
for (i = 0; i < G_N_ELEMENTS (values); i++)
{
if (_gtk_css_value_equal (position->y, values[i].number))
if (gtk_css_value_equal (position->y, values[i].number))
{
g_string_append (string, values[i].y_name);
goto done;
@@ -137,15 +135,15 @@ gtk_css_value_position_print (const GtkCssValue *position,
}
if (i == G_N_ELEMENTS (values))
{
if (_gtk_css_value_equal (position->x, center))
if (gtk_css_value_equal (position->x, center))
g_string_append (string, "center ");
_gtk_css_value_print (position->y, string);
gtk_css_value_print (position->y, string);
}
done:
for (i = 0; i < G_N_ELEMENTS (values); i++)
_gtk_css_value_unref (values[i].number);
_gtk_css_value_unref (center);
gtk_css_value_unref (values[i].number);
gtk_css_value_unref (center);
}
static const GtkCssValueClass GTK_CSS_VALUE_POSITION = {
@@ -165,7 +163,7 @@ _gtk_css_position_value_new (GtkCssValue *x,
{
GtkCssValue *result;
result = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_POSITION);
result = gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_POSITION);
result->x = x;
result->y = y;
result->is_computed = gtk_css_value_is_computed (x) &&
@@ -265,7 +263,7 @@ position_value_parse (GtkCssParser *parser, gboolean try)
{
if (!try)
gtk_css_parser_error_syntax (parser, "Invalid combination of values");
_gtk_css_value_unref (y);
gtk_css_value_unref (y);
return NULL;
}
y = _gtk_css_number_value_parse (parser,
@@ -273,7 +271,7 @@ position_value_parse (GtkCssParser *parser, gboolean try)
| GTK_CSS_PARSE_LENGTH);
if (y == NULL)
{
_gtk_css_value_unref (x);
gtk_css_value_unref (x);
return NULL;
}
}
@@ -315,13 +313,13 @@ gtk_css_position_value_parse_spacing (GtkCssParser *parser)
y = _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_LENGTH | GTK_CSS_POSITIVE_ONLY);
if (y == NULL)
{
_gtk_css_value_unref (x);
gtk_css_value_unref (x);
return NULL;
}
}
else
{
y = _gtk_css_value_ref (x);
y = gtk_css_value_ref (x);
}
return _gtk_css_position_value_new (x, y);

View File

@@ -22,10 +22,13 @@
#include <gtk/css/gtkcss.h>
#include "gtk/css/gtkcsstokenizerprivate.h"
#include "gtk/css/gtkcssparserprivate.h"
#include "gtk/css/gtkcssvariablevalueprivate.h"
#include "gtkbitmaskprivate.h"
#include "gtkcssarrayvalueprivate.h"
#include "gtkcsscolorvalueprivate.h"
#include "gtkcsscustompropertypoolprivate.h"
#include "gtkcsskeyframesprivate.h"
#include "gtkcssreferencevalueprivate.h"
#include "gtkcssselectorprivate.h"
#include "gtkcssshorthandpropertyprivate.h"
#include "gtksettingsprivate.h"
@@ -113,6 +116,7 @@ struct GtkCssRuleset
PropertyValue *styles;
guint n_styles;
guint owns_styles : 1;
GHashTable *custom_properties;
};
struct _GtkCssScanner
@@ -133,6 +137,7 @@ struct _GtkCssProviderPrivate
GtkCssSelectorTree *tree;
GResource *resource;
char *path;
GBytes *bytes; /* *no* reference */
};
enum {
@@ -264,12 +269,14 @@ gtk_css_ruleset_clear (GtkCssRuleset *ruleset)
for (i = 0; i < ruleset->n_styles; i++)
{
_gtk_css_value_unref (ruleset->styles[i].value);
gtk_css_value_unref (ruleset->styles[i].value);
ruleset->styles[i].value = NULL;
if (ruleset->styles[i].section)
gtk_css_section_unref (ruleset->styles[i].section);
}
g_free (ruleset->styles);
if (ruleset->custom_properties)
g_hash_table_unref (ruleset->custom_properties);
}
if (ruleset->selector)
_gtk_css_selector_free (ruleset->selector);
@@ -285,7 +292,7 @@ gtk_css_ruleset_add (GtkCssRuleset *ruleset,
{
guint i;
g_return_if_fail (ruleset->owns_styles || ruleset->n_styles == 0);
g_return_if_fail (ruleset->owns_styles || (ruleset->n_styles == 0 && ruleset->custom_properties == NULL));
ruleset->owns_styles = TRUE;
@@ -293,7 +300,7 @@ gtk_css_ruleset_add (GtkCssRuleset *ruleset,
{
if (ruleset->styles[i].property == property)
{
_gtk_css_value_unref (ruleset->styles[i].value);
gtk_css_value_unref (ruleset->styles[i].value);
ruleset->styles[i].value = NULL;
if (ruleset->styles[i].section)
gtk_css_section_unref (ruleset->styles[i].section);
@@ -315,6 +322,39 @@ gtk_css_ruleset_add (GtkCssRuleset *ruleset,
ruleset->styles[i].section = NULL;
}
static void
unref_custom_property_name (gpointer pointer)
{
GtkCssCustomPropertyPool *pool = gtk_css_custom_property_pool_get ();
gtk_css_custom_property_pool_unref (pool, GPOINTER_TO_INT (pointer));
}
static void
gtk_css_ruleset_add_custom (GtkCssRuleset *ruleset,
const char *name,
GtkCssVariableValue *value)
{
GtkCssCustomPropertyPool *pool;
int id;
g_return_if_fail (ruleset->owns_styles || (ruleset->n_styles == 0 && ruleset->custom_properties == NULL));
ruleset->owns_styles = TRUE;
if (ruleset->custom_properties == NULL)
{
ruleset->custom_properties = g_hash_table_new_full (g_direct_hash, g_direct_equal,
unref_custom_property_name,
(GDestroyNotify) gtk_css_variable_value_unref);
}
pool = gtk_css_custom_property_pool_get ();
id = gtk_css_custom_property_pool_add (pool, name);
g_hash_table_replace (ruleset->custom_properties, GINT_TO_POINTER (id), value);
}
static void
gtk_css_scanner_destroy (GtkCssScanner *scanner)
{
@@ -342,9 +382,10 @@ gtk_css_scanner_parser_error (GtkCssParser *parser,
GtkCssScanner *scanner = user_data;
GtkCssSection *section;
section = gtk_css_section_new (gtk_css_parser_get_file (parser),
start,
end);
section = gtk_css_section_new_with_bytes (gtk_css_parser_get_file (parser),
gtk_css_parser_get_bytes (parser),
start,
end);
gtk_css_style_provider_emit_error (GTK_STYLE_PROVIDER (scanner->provider), section, error);
@@ -399,7 +440,7 @@ gtk_css_provider_init (GtkCssProvider *css_provider)
priv->symbolic_colors = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify) g_free,
(GDestroyNotify) _gtk_css_value_unref);
(GDestroyNotify) gtk_css_value_unref);
priv->keyframes = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify) g_free,
(GDestroyNotify) _gtk_css_keyframes_unref);
@@ -490,7 +531,7 @@ gtk_css_style_provider_lookup (GtkStyleProvider *provider,
{
ruleset = gtk_css_selector_matches_get (&tree_rules, i);
if (ruleset->styles == NULL)
if (ruleset->styles == NULL && ruleset->custom_properties == NULL)
continue;
for (j = 0; j < ruleset->n_styles; j++)
@@ -506,6 +547,18 @@ gtk_css_style_provider_lookup (GtkStyleProvider *provider,
ruleset->styles[j].section,
ruleset->styles[j].value);
}
if (ruleset->custom_properties)
{
GHashTableIter iter;
gpointer id;
GtkCssVariableValue *value;
g_hash_table_iter_init (&iter, ruleset->custom_properties);
while (g_hash_table_iter_next (&iter, &id, (gpointer) &value))
_gtk_css_lookup_set_custom (lookup, GPOINTER_TO_INT (id), value);
}
}
}
gtk_css_selector_matches_clear (&tree_rules);
@@ -514,6 +567,16 @@ gtk_css_style_provider_lookup (GtkStyleProvider *provider,
*change = gtk_css_selector_tree_get_change_all (priv->tree, filter, node);
}
static gboolean
gtk_css_style_provider_has_section (GtkStyleProvider *provider,
GtkCssSection *section)
{
GtkCssProvider *self = GTK_CSS_PROVIDER (provider);
GtkCssProviderPrivate *priv = gtk_css_provider_get_instance_private (self);
return priv->bytes == gtk_css_section_get_bytes (section);
}
static void
gtk_css_style_provider_iface_init (GtkStyleProviderInterface *iface)
{
@@ -521,6 +584,7 @@ gtk_css_style_provider_iface_init (GtkStyleProviderInterface *iface)
iface->get_keyframes = gtk_css_style_provider_get_keyframes;
iface->lookup = gtk_css_style_provider_lookup;
iface->emit_error = gtk_css_style_provider_emit_error;
iface->has_section = gtk_css_style_provider_has_section;
}
static void
@@ -572,7 +636,7 @@ css_provider_commit (GtkCssProvider *css_provider,
GtkCssProviderPrivate *priv = gtk_css_provider_get_instance_private (css_provider);
guint i;
if (ruleset->styles == NULL)
if (ruleset->styles == NULL && ruleset->custom_properties == NULL)
{
for (i = 0; i < gtk_css_selectors_get_size (selectors); i++)
_gtk_css_selector_free (gtk_css_selectors_get (selectors, i));
@@ -704,7 +768,7 @@ parse_color_definition (GtkCssScanner *scanner)
if (name == NULL)
return TRUE;
color = _gtk_css_color_value_parse (scanner->parser);
color = gtk_css_color_value_parse (scanner->parser);
if (color == NULL)
{
g_free (name);
@@ -714,7 +778,7 @@ parse_color_definition (GtkCssScanner *scanner)
if (!gtk_css_parser_has_token (scanner->parser, GTK_CSS_TOKEN_EOF))
{
g_free (name);
_gtk_css_value_unref (color);
gtk_css_value_unref (color);
gtk_css_parser_error_syntax (scanner->parser,
"Missing semicolon at end of color definition");
return TRUE;
@@ -814,6 +878,49 @@ parse_declaration (GtkCssScanner *scanner,
if (name == NULL)
goto out;
/* This is a custom property */
if (name[0] == '-' && name[1] == '-')
{
GtkCssVariableValue *value;
GtkCssLocation start_location;
GtkCssSection *section;
if (!gtk_css_parser_try_token (scanner->parser, GTK_CSS_TOKEN_COLON))
{
gtk_css_parser_error_syntax (scanner->parser, "Expected ':'");
goto out;
}
gtk_css_parser_skip_whitespace (scanner->parser);
if (gtk_keep_css_sections)
start_location = *gtk_css_parser_get_start_location (scanner->parser);
value = gtk_css_parser_parse_value_into_token_stream (scanner->parser);
if (value == NULL)
goto out;
if (gtk_keep_css_sections)
{
section = gtk_css_section_new_with_bytes (gtk_css_parser_get_file (scanner->parser),
gtk_css_parser_get_bytes (scanner->parser),
&start_location,
gtk_css_parser_get_start_location (scanner->parser));
}
else
section = NULL;
if (section != NULL)
{
gtk_css_variable_value_set_section (value, section);
gtk_css_section_unref (section);
}
gtk_css_ruleset_add_custom (ruleset, name, value);
goto out;
}
property = _gtk_style_property_lookup (name);
if (property)
@@ -827,22 +934,88 @@ parse_declaration (GtkCssScanner *scanner,
goto out;
}
value = _gtk_style_property_parse_value (property, scanner->parser);
if (value == NULL)
goto out;
if (!gtk_css_parser_has_token (scanner->parser, GTK_CSS_TOKEN_EOF))
if (gtk_css_parser_has_references (scanner->parser))
{
gtk_css_parser_error_syntax (scanner->parser, "Junk at end of value for %s", property->name);
goto out;
GtkCssLocation start_location;
GtkCssVariableValue *var_value;
gtk_css_parser_skip_whitespace (scanner->parser);
if (gtk_keep_css_sections)
start_location = *gtk_css_parser_get_start_location (scanner->parser);
var_value = gtk_css_parser_parse_value_into_token_stream (scanner->parser);
if (var_value == NULL)
goto out;
if (gtk_keep_css_sections)
section = gtk_css_section_new_with_bytes (gtk_css_parser_get_file (scanner->parser),
gtk_css_parser_get_bytes (scanner->parser),
&start_location,
gtk_css_parser_get_start_location (scanner->parser));
else
section = NULL;
if (section != NULL)
{
gtk_css_variable_value_set_section (var_value, section);
gtk_css_section_unref (section);
}
if (GTK_IS_CSS_SHORTHAND_PROPERTY (property))
{
GtkCssShorthandProperty *shorthand = GTK_CSS_SHORTHAND_PROPERTY (property);
guint i, n;
GtkCssValue **values;
n = _gtk_css_shorthand_property_get_n_subproperties (shorthand);
values = g_new (GtkCssValue *, n);
for (i = 0; i < n; i++)
{
GtkCssValue *child =
_gtk_css_reference_value_new (property,
var_value,
gtk_css_parser_get_file (scanner->parser));
_gtk_css_reference_value_set_subproperty (child, i);
values[i] = _gtk_css_array_value_get_nth (child, i);
}
value = _gtk_css_array_value_new_from_array (values, n);
g_free (values);
}
else
{
value = _gtk_css_reference_value_new (property,
var_value,
gtk_css_parser_get_file (scanner->parser));
}
gtk_css_variable_value_unref (var_value);
}
else
{
value = _gtk_style_property_parse_value (property, scanner->parser);
if (value == NULL)
goto out;
if (!gtk_css_parser_has_token (scanner->parser, GTK_CSS_TOKEN_EOF))
{
gtk_css_parser_error_syntax (scanner->parser, "Junk at end of value for %s", property->name);
gtk_css_value_unref (value);
goto out;
}
}
if (gtk_keep_css_sections)
{
section = gtk_css_section_new (gtk_css_parser_get_file (scanner->parser),
gtk_css_parser_get_block_location (scanner->parser),
gtk_css_parser_get_end_location (scanner->parser));
section = gtk_css_section_new_with_bytes (gtk_css_parser_get_file (scanner->parser),
gtk_css_parser_get_bytes (scanner->parser),
gtk_css_parser_get_block_location (scanner->parser),
gtk_css_parser_get_end_location (scanner->parser));
}
else
section = NULL;
@@ -857,10 +1030,10 @@ parse_declaration (GtkCssScanner *scanner,
GtkCssStyleProperty *child = _gtk_css_shorthand_property_get_subproperty (shorthand, i);
GtkCssValue *sub = _gtk_css_array_value_get_nth (value, i);
gtk_css_ruleset_add (ruleset, child, _gtk_css_value_ref (sub), section);
gtk_css_ruleset_add (ruleset, child, gtk_css_value_ref (sub), section);
}
_gtk_css_value_unref (value);
gtk_css_value_unref (value);
}
else if (GTK_IS_CSS_STYLE_PROPERTY (property))
{
@@ -870,7 +1043,7 @@ parse_declaration (GtkCssScanner *scanner,
else
{
g_assert_not_reached ();
_gtk_css_value_unref (value);
gtk_css_value_unref (value);
}
g_clear_pointer (&section, gtk_css_section_unref);
@@ -1025,6 +1198,7 @@ gtk_css_provider_load_internal (GtkCssProvider *self,
GFile *file,
GBytes *bytes)
{
GtkCssProviderPrivate *priv = gtk_css_provider_get_instance_private (self);
gint64 before G_GNUC_UNUSED;
before = GDK_PROFILER_CURRENT_TIME;
@@ -1059,6 +1233,8 @@ gtk_css_provider_load_internal (GtkCssProvider *self,
}
}
priv->bytes = bytes;
if (bytes)
{
GtkCssScanner *scanner;
@@ -1112,7 +1288,7 @@ gtk_css_provider_load_from_data (GtkCssProvider *css_provider,
if (length < 0)
length = strlen (data);
bytes = g_bytes_new_static (data, length);
bytes = g_bytes_new (data, length);
gtk_css_provider_load_from_bytes (css_provider, bytes);
@@ -1139,7 +1315,7 @@ gtk_css_provider_load_from_string (GtkCssProvider *css_provider,
g_return_if_fail (GTK_IS_CSS_PROVIDER (css_provider));
g_return_if_fail (string != NULL);
bytes = g_bytes_new_static (string, strlen (string));
bytes = g_bytes_new (string, strlen (string));
gtk_css_provider_load_from_bytes (css_provider, bytes);
@@ -1473,6 +1649,20 @@ compare_properties (gconstpointer a, gconstpointer b, gpointer style)
_gtk_style_property_get_name (GTK_STYLE_PROPERTY (styles[*ub].property)));
}
static int
compare_custom_properties (gconstpointer a, gconstpointer b, gpointer user_data)
{
GtkCssCustomPropertyPool *pool = user_data;
int id1 = GPOINTER_TO_INT (*((const int *) a));
int id2 = GPOINTER_TO_INT (*((const int *) b));
const char *name1, *name2;
name1 = gtk_css_custom_property_pool_get_name (pool, id1);
name2 = gtk_css_custom_property_pool_get_name (pool, id2);
return strcmp (name1, name2);
}
static void
gtk_css_ruleset_print (const GtkCssRuleset *ruleset,
GString *str)
@@ -1499,13 +1689,38 @@ gtk_css_ruleset_print (const GtkCssRuleset *ruleset,
g_string_append (str, " ");
g_string_append (str, _gtk_style_property_get_name (GTK_STYLE_PROPERTY (prop->property)));
g_string_append (str, ": ");
_gtk_css_value_print (prop->value, str);
gtk_css_value_print (prop->value, str);
g_string_append (str, ";\n");
}
g_free (sorted);
}
if (ruleset->custom_properties)
{
GtkCssCustomPropertyPool *pool = gtk_css_custom_property_pool_get ();
GPtrArray *keys;
keys = g_hash_table_get_keys_as_ptr_array (ruleset->custom_properties);
g_ptr_array_sort_with_data (keys, compare_custom_properties, pool);
for (i = 0; i < keys->len; i++)
{
int id = GPOINTER_TO_INT (g_ptr_array_index (keys, i));
const char *name = gtk_css_custom_property_pool_get_name (pool, id);
GtkCssVariableValue *value = g_hash_table_lookup (ruleset->custom_properties,
GINT_TO_POINTER (id));
g_string_append (str, " ");
g_string_append (str, name);
g_string_append (str, ": ");
gtk_css_variable_value_print (value, str);
g_string_append (str, ";\n");
}
g_ptr_array_unref (keys);
}
g_string_append (str, "}\n");
}
@@ -1527,7 +1742,7 @@ gtk_css_provider_print_colors (GHashTable *colors,
g_string_append (str, "@define-color ");
g_string_append (str, name);
g_string_append (str, " ");
_gtk_css_value_print (color, str);
gtk_css_value_print (color, str);
g_string_append (str, ";\n");
}
@@ -1598,4 +1813,3 @@ gtk_css_provider_to_string (GtkCssProvider *provider)
return g_string_free (str, FALSE);
}

390
gtk/gtkcssreferencevalue.c Normal file
View File

@@ -0,0 +1,390 @@
/*
* Copyright (C) 2023 GNOME Foundation Inc.
*
* 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: Alice Mikhaylenko <alicem@gnome.org>
*/
#include "config.h"
#include "gtkcssreferencevalueprivate.h"
#include "gtkcssarrayvalueprivate.h"
#include "gtkcsscustompropertypoolprivate.h"
#include "gtkcssshorthandpropertyprivate.h"
#include "gtkcssstyleprivate.h"
#include "gtkcssunsetvalueprivate.h"
#include "gtkcssvalueprivate.h"
#include "gtkstyleproviderprivate.h"
#define GDK_ARRAY_NAME gtk_css_refs
#define GDK_ARRAY_TYPE_NAME GtkCssRefs
#define GDK_ARRAY_ELEMENT_TYPE gpointer
#define GDK_ARAY_PREALLOC 32
#define GDK_ARRAY_NO_MEMSET 1
#include "gdk/gdkarrayimpl.c"
#define MAX_TOKEN_LENGTH 65536
typedef enum {
RESOLVE_SUCCESS,
RESOLVE_INVALID,
RESOLVE_ANIMATION_TAINTED,
} ResolveResult;
struct _GtkCssValue {
GTK_CSS_VALUE_BASE
GtkStyleProperty *property;
GtkCssVariableValue *value;
GFile *file;
guint subproperty;
};
static void
gtk_css_value_reference_free (GtkCssValue *value)
{
gtk_css_variable_value_unref (value->value);
if (value->file)
g_object_unref (value->file);
}
static ResolveResult
resolve_references_do (GtkCssVariableValue *value,
guint property_id,
GtkCssVariableSet *style_variables,
GtkCssVariableSet *keyframes_variables,
gboolean root,
GtkCssRefs *refs,
gsize *out_length,
gsize *out_n_refs)
{
GtkCssCustomPropertyPool *pool = gtk_css_custom_property_pool_get ();
gsize i;
gsize length = value->length;
gsize n_refs = 0;
ResolveResult ret = RESOLVE_SUCCESS;
if (value->is_animation_tainted)
{
GtkCssStyleProperty *prop = _gtk_css_style_property_lookup_by_id (property_id);
if (!_gtk_css_style_property_is_animated (prop))
{
/* Animation-tainted variables make other variables that reference
* them animation-tainted too, so unlike regular invalid variables it
* propagates to the root. For example, if --test is animation-tainted,
* --test2: var(--test, fallback1); prop: var(--test2, fallback2); will\
* resolve to fallback2 and _not_ to fallback1. So we'll propagate it
* up until the root, and treat it same as invalid there instead. */
ret = RESOLVE_ANIMATION_TAINTED;
goto error;
}
}
if (value->is_invalid)
{
ret = RESOLVE_INVALID;
goto error;
}
if (!root)
{
n_refs += 1;
gtk_css_refs_append (refs, value);
}
for (i = 0; i < value->n_references; i++)
{
GtkCssVariableValueReference *ref = &value->references[i];
int id = gtk_css_custom_property_pool_lookup (pool, ref->name);
GtkCssVariableValue *var_value = NULL;
gsize var_length, var_refs;
GtkCssVariableSet *source = style_variables;
ResolveResult result = RESOLVE_INVALID;
if (keyframes_variables)
var_value = gtk_css_variable_set_lookup (keyframes_variables, id, NULL);
if (!var_value && style_variables)
var_value = gtk_css_variable_set_lookup (style_variables, id, &source);
if (var_value)
{
result = resolve_references_do (var_value, property_id, source,
keyframes_variables, FALSE,
refs, &var_length, &var_refs);
if (root && result == RESOLVE_ANIMATION_TAINTED)
result = RESOLVE_INVALID;
}
if (result == RESOLVE_INVALID)
{
if (ref->fallback)
{
result = resolve_references_do (ref->fallback, property_id,
style_variables, keyframes_variables,
FALSE, refs, &var_length, &var_refs);
if (root && result == RESOLVE_ANIMATION_TAINTED)
result = RESOLVE_INVALID;
}
if (result != RESOLVE_SUCCESS)
{
ret = result;
goto error;
}
}
else if (result == RESOLVE_ANIMATION_TAINTED)
{
ret = RESOLVE_ANIMATION_TAINTED;
goto error;
}
length += var_length - ref->length;
n_refs += var_refs;
if (length > MAX_TOKEN_LENGTH)
{
ret = RESOLVE_INVALID;
goto error;
}
}
if (out_length)
*out_length = length;
if (out_n_refs)
*out_n_refs = n_refs;
return ret;
error:
/* Remove the references we added as if nothing happened */
gtk_css_refs_splice (refs, gtk_css_refs_get_size (refs) - n_refs, n_refs, TRUE, NULL, 0);
if (out_length)
*out_length = 0;
if (out_n_refs)
*out_n_refs = 0;
return ret;
}
static void
resolve_references (GtkCssVariableValue *input,
guint property_id,
GtkCssStyle *style,
GtkCssVariableSet *keyframes_variables,
GtkCssRefs *refs)
{
if (resolve_references_do (input, property_id, style->variables,
keyframes_variables, TRUE, refs,
NULL, NULL) != RESOLVE_SUCCESS)
{
gtk_css_refs_clear (refs);
}
}
static void
parser_error (GtkCssParser *parser,
const GtkCssLocation *start,
const GtkCssLocation *end,
const GError *error,
gpointer user_data)
{
GtkStyleProvider *provider = user_data;
GError *new_error = NULL;
GtkCssVariableValue **vars;
char **names;
gsize n_vars;
gtk_css_parser_get_expanding_variables (parser, &vars, &names, &n_vars);
if (n_vars > 0)
{
for (int i = 0; i < n_vars; i++)
{
if (names[i + 1])
g_set_error (&new_error,
GTK_CSS_PARSER_ERROR, GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE,
"While expanding %s: %s", names[i + 1], error->message);
else
g_set_error_literal (&new_error,
GTK_CSS_PARSER_ERROR, GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE,
error->message);
gtk_style_provider_emit_error (provider, vars[i]->section, new_error);
g_clear_error (&new_error);
}
for (int i = 0; i < n_vars; i++)
{
if (vars[i])
gtk_css_variable_value_unref (vars[i]);
g_free (names[i]);
}
g_free (vars);
g_free (names);
}
}
static GtkCssValue *
gtk_css_value_reference_compute (GtkCssValue *value,
guint property_id,
GtkCssComputeContext *context)
{
GtkCssValue *result = NULL, *computed;
GtkCssRefs refs;
guint shorthand_id = G_MAXUINT;
if (GTK_IS_CSS_SHORTHAND_PROPERTY (value->property))
{
shorthand_id = _gtk_css_shorthand_property_get_id (GTK_CSS_SHORTHAND_PROPERTY (value->property));
if (context->shorthands && context->shorthands[shorthand_id])
{
result = gtk_css_value_ref (context->shorthands[shorthand_id]);
goto pick_subproperty;
}
}
gtk_css_refs_init (&refs);
resolve_references (value->value, property_id, context->style, context->variables, &refs);
if (gtk_css_refs_get_size (&refs) > 0)
{
const GtkCssToken *token;
GtkCssParser *value_parser =
gtk_css_parser_new_for_token_stream (value->value,
value->file,
(GtkCssVariableValue **) refs.start,
gtk_css_refs_get_size (&refs),
parser_error, context->provider,
NULL);
result = _gtk_style_property_parse_value (value->property, value_parser);
token = gtk_css_parser_peek_token (value_parser);
if (!gtk_css_token_is (token, GTK_CSS_TOKEN_EOF))
{
char *junk;
junk = gtk_css_token_to_string (token);
gtk_css_parser_error_syntax (value_parser,
"Junk at end of %s value: %s",
value->property->name, junk);
g_free (junk);
g_clear_pointer (&result, gtk_css_value_unref);
}
gtk_css_parser_unref (value_parser);
}
gtk_css_refs_clear (&refs);
if (result == NULL)
result = _gtk_css_unset_value_new ();
if (shorthand_id != G_MAXUINT)
{
GtkCssValue *sub;
if (context->shorthands)
{
g_assert (context->shorthands[shorthand_id] == NULL);
context->shorthands[shorthand_id] = gtk_css_value_ref (result);
}
pick_subproperty:
sub = gtk_css_value_ref (_gtk_css_array_value_get_nth (result, value->subproperty));
gtk_css_value_unref (result);
result = sub;
}
computed = gtk_css_value_compute (result, property_id, context);
computed->is_computed = TRUE;
gtk_css_value_unref (result);
return computed;
}
static gboolean
gtk_css_value_reference_equal (const GtkCssValue *value1,
const GtkCssValue *value2)
{
return FALSE;
}
static GtkCssValue *
gtk_css_value_reference_transition (GtkCssValue *start,
GtkCssValue *end,
guint property_id,
double progress)
{
return NULL;
}
static void
gtk_css_value_reference_print (const GtkCssValue *value,
GString *string)
{
gtk_css_variable_value_print (value->value, string);
}
static const GtkCssValueClass GTK_CSS_VALUE_REFERENCE = {
"GtkCssReferenceValue",
gtk_css_value_reference_free,
gtk_css_value_reference_compute,
gtk_css_value_reference_equal,
gtk_css_value_reference_transition,
NULL,
NULL,
gtk_css_value_reference_print
};
GtkCssValue *
_gtk_css_reference_value_new (GtkStyleProperty *property,
GtkCssVariableValue *value,
GFile *file)
{
GtkCssValue *result;
result = gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_REFERENCE);
result->property = property;
result->value = gtk_css_variable_value_ref (value);
result->contains_variables = TRUE;
if (file)
result->file = g_object_ref (file);
else
result->file = NULL;
return result;
}
void
_gtk_css_reference_value_set_subproperty (GtkCssValue *value,
guint property)
{
g_assert (GTK_IS_CSS_SHORTHAND_PROPERTY (value->property));
value->subproperty = property;
}

View File

@@ -0,0 +1,35 @@
/*
* Copyright (C) 2023 GNOME Foundation Inc.
*
* 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: Alice Mikhaylenko <alicem@gnome.org>
*/
#pragma once
#include <gtk/css/gtkcss.h>
#include "gtkcssvalueprivate.h"
#include "gtkstylepropertyprivate.h"
#include "css/gtkcssvariablevalueprivate.h"
G_BEGIN_DECLS
GtkCssValue *_gtk_css_reference_value_new (GtkStyleProperty *property,
GtkCssVariableValue *value,
GFile *file);
void _gtk_css_reference_value_set_subproperty (GtkCssValue *value,
guint property);
G_END_DECLS

View File

@@ -34,13 +34,11 @@ gtk_css_value_repeat_free (GtkCssValue *value)
}
static GtkCssValue *
gtk_css_value_repeat_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_value_repeat_compute (GtkCssValue *value,
guint property_id,
GtkCssComputeContext *context)
{
return _gtk_css_value_ref (value);
return gtk_css_value_ref (value);
}
static gboolean
@@ -140,28 +138,28 @@ static struct {
GtkCssValue values[4];
} background_repeat_values[4] = {
{ "no-repeat",
{ { &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, GTK_CSS_REPEAT_STYLE_NO_REPEAT, GTK_CSS_REPEAT_STYLE_NO_REPEAT },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, GTK_CSS_REPEAT_STYLE_NO_REPEAT, GTK_CSS_REPEAT_STYLE_REPEAT },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, GTK_CSS_REPEAT_STYLE_NO_REPEAT, GTK_CSS_REPEAT_STYLE_ROUND },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, GTK_CSS_REPEAT_STYLE_NO_REPEAT, GTK_CSS_REPEAT_STYLE_SPACE }
{ { &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_NO_REPEAT, GTK_CSS_REPEAT_STYLE_NO_REPEAT },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_NO_REPEAT, GTK_CSS_REPEAT_STYLE_REPEAT },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_NO_REPEAT, GTK_CSS_REPEAT_STYLE_ROUND },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_NO_REPEAT, GTK_CSS_REPEAT_STYLE_SPACE }
} },
{ "repeat",
{ { &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, GTK_CSS_REPEAT_STYLE_REPEAT, GTK_CSS_REPEAT_STYLE_NO_REPEAT },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, GTK_CSS_REPEAT_STYLE_REPEAT, GTK_CSS_REPEAT_STYLE_REPEAT },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, GTK_CSS_REPEAT_STYLE_REPEAT, GTK_CSS_REPEAT_STYLE_ROUND },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, GTK_CSS_REPEAT_STYLE_REPEAT, GTK_CSS_REPEAT_STYLE_SPACE }
{ { &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_REPEAT, GTK_CSS_REPEAT_STYLE_NO_REPEAT },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_REPEAT, GTK_CSS_REPEAT_STYLE_REPEAT },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_REPEAT, GTK_CSS_REPEAT_STYLE_ROUND },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_REPEAT, GTK_CSS_REPEAT_STYLE_SPACE }
} },
{ "round",
{ { &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, GTK_CSS_REPEAT_STYLE_ROUND, GTK_CSS_REPEAT_STYLE_NO_REPEAT },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, GTK_CSS_REPEAT_STYLE_ROUND, GTK_CSS_REPEAT_STYLE_REPEAT },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, GTK_CSS_REPEAT_STYLE_ROUND, GTK_CSS_REPEAT_STYLE_ROUND },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, GTK_CSS_REPEAT_STYLE_ROUND, GTK_CSS_REPEAT_STYLE_SPACE }
{ { &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_ROUND, GTK_CSS_REPEAT_STYLE_NO_REPEAT },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_ROUND, GTK_CSS_REPEAT_STYLE_REPEAT },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_ROUND, GTK_CSS_REPEAT_STYLE_ROUND },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_ROUND, GTK_CSS_REPEAT_STYLE_SPACE }
} },
{ "space",
{ { &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, GTK_CSS_REPEAT_STYLE_SPACE, GTK_CSS_REPEAT_STYLE_NO_REPEAT },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, GTK_CSS_REPEAT_STYLE_SPACE, GTK_CSS_REPEAT_STYLE_REPEAT },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, GTK_CSS_REPEAT_STYLE_SPACE, GTK_CSS_REPEAT_STYLE_ROUND },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, GTK_CSS_REPEAT_STYLE_SPACE, GTK_CSS_REPEAT_STYLE_SPACE }
{ { &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_SPACE, GTK_CSS_REPEAT_STYLE_NO_REPEAT },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_SPACE, GTK_CSS_REPEAT_STYLE_REPEAT },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_SPACE, GTK_CSS_REPEAT_STYLE_ROUND },
{ &GTK_CSS_VALUE_BACKGROUND_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_SPACE, GTK_CSS_REPEAT_STYLE_SPACE }
} }
};
@@ -169,7 +167,7 @@ GtkCssValue *
_gtk_css_background_repeat_value_new (GtkCssRepeatStyle x,
GtkCssRepeatStyle y)
{
return _gtk_css_value_ref (&background_repeat_values[x].values[y]);
return gtk_css_value_ref (&background_repeat_values[x].values[y]);
}
static gboolean
@@ -234,28 +232,28 @@ static struct {
GtkCssValue values[4];
} border_repeat_values[4] = {
{ "stretch",
{ { &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, GTK_CSS_REPEAT_STYLE_STRETCH, GTK_CSS_REPEAT_STYLE_STRETCH },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, GTK_CSS_REPEAT_STYLE_STRETCH, GTK_CSS_REPEAT_STYLE_REPEAT },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, GTK_CSS_REPEAT_STYLE_STRETCH, GTK_CSS_REPEAT_STYLE_ROUND },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, GTK_CSS_REPEAT_STYLE_STRETCH, GTK_CSS_REPEAT_STYLE_SPACE }
{ { &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_STRETCH, GTK_CSS_REPEAT_STYLE_STRETCH },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_STRETCH, GTK_CSS_REPEAT_STYLE_REPEAT },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_STRETCH, GTK_CSS_REPEAT_STYLE_ROUND },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_STRETCH, GTK_CSS_REPEAT_STYLE_SPACE }
} },
{ "repeat",
{ { &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, GTK_CSS_REPEAT_STYLE_REPEAT, GTK_CSS_REPEAT_STYLE_STRETCH },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, GTK_CSS_REPEAT_STYLE_REPEAT, GTK_CSS_REPEAT_STYLE_REPEAT },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, GTK_CSS_REPEAT_STYLE_REPEAT, GTK_CSS_REPEAT_STYLE_ROUND },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, GTK_CSS_REPEAT_STYLE_REPEAT, GTK_CSS_REPEAT_STYLE_SPACE }
{ { &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_REPEAT, GTK_CSS_REPEAT_STYLE_STRETCH },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_REPEAT, GTK_CSS_REPEAT_STYLE_REPEAT },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_REPEAT, GTK_CSS_REPEAT_STYLE_ROUND },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_REPEAT, GTK_CSS_REPEAT_STYLE_SPACE }
} },
{ "round",
{ { &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, GTK_CSS_REPEAT_STYLE_ROUND, GTK_CSS_REPEAT_STYLE_STRETCH },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, GTK_CSS_REPEAT_STYLE_ROUND, GTK_CSS_REPEAT_STYLE_REPEAT },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, GTK_CSS_REPEAT_STYLE_ROUND, GTK_CSS_REPEAT_STYLE_ROUND },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, GTK_CSS_REPEAT_STYLE_ROUND, GTK_CSS_REPEAT_STYLE_SPACE }
{ { &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_ROUND, GTK_CSS_REPEAT_STYLE_STRETCH },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_ROUND, GTK_CSS_REPEAT_STYLE_REPEAT },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_ROUND, GTK_CSS_REPEAT_STYLE_ROUND },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_ROUND, GTK_CSS_REPEAT_STYLE_SPACE }
} },
{ "space",
{ { &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, GTK_CSS_REPEAT_STYLE_SPACE, GTK_CSS_REPEAT_STYLE_STRETCH },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, GTK_CSS_REPEAT_STYLE_SPACE, GTK_CSS_REPEAT_STYLE_REPEAT },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, GTK_CSS_REPEAT_STYLE_SPACE, GTK_CSS_REPEAT_STYLE_ROUND },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, GTK_CSS_REPEAT_STYLE_SPACE, GTK_CSS_REPEAT_STYLE_SPACE }
{ { &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_SPACE, GTK_CSS_REPEAT_STYLE_STRETCH },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_SPACE, GTK_CSS_REPEAT_STYLE_REPEAT },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_SPACE, GTK_CSS_REPEAT_STYLE_ROUND },
{ &GTK_CSS_VALUE_BORDER_REPEAT, 1, TRUE, FALSE, GTK_CSS_REPEAT_STYLE_SPACE, GTK_CSS_REPEAT_STYLE_SPACE }
} }
};
@@ -263,7 +261,7 @@ GtkCssValue *
_gtk_css_border_repeat_value_new (GtkCssRepeatStyle x,
GtkCssRepeatStyle y)
{
return _gtk_css_value_ref (&border_repeat_values[x].values[y]);
return gtk_css_value_ref (&border_repeat_values[x].values[y]);
}
static gboolean

View File

@@ -69,11 +69,11 @@ shadow_value_for_transition (ShadowValue *result,
static void
shadow_value_unref (const ShadowValue *shadow)
{
_gtk_css_value_unref (shadow->hoffset);
_gtk_css_value_unref (shadow->voffset);
_gtk_css_value_unref (shadow->spread);
_gtk_css_value_unref (shadow->radius);
_gtk_css_value_unref (shadow->color);
gtk_css_value_unref (shadow->hoffset);
gtk_css_value_unref (shadow->voffset);
gtk_css_value_unref (shadow->spread);
gtk_css_value_unref (shadow->radius);
gtk_css_value_unref (shadow->color);
}
static gboolean
@@ -88,11 +88,11 @@ shadow_value_transition (const ShadowValue *start,
return FALSE;
result->inset = start->inset;
result->hoffset = _gtk_css_value_transition (start->hoffset, end->hoffset, property_id, progress);
result->voffset = _gtk_css_value_transition (start->voffset, end->voffset, property_id, progress);
result->radius = _gtk_css_value_transition (start->radius, end->radius, property_id, progress);
result->spread = _gtk_css_value_transition (start->spread, end->spread, property_id, progress);
result->color = _gtk_css_value_transition (start->color, end->color, property_id, progress);
result->hoffset = gtk_css_value_transition (start->hoffset, end->hoffset, property_id, progress);
result->voffset = gtk_css_value_transition (start->voffset, end->voffset, property_id, progress);
result->radius = gtk_css_value_transition (start->radius, end->radius, property_id, progress);
result->spread = gtk_css_value_transition (start->spread, end->spread, property_id, progress);
result->color = gtk_css_value_transition (start->color, end->color, property_id, progress);
return TRUE;
}
@@ -113,11 +113,9 @@ gtk_css_value_shadow_free (GtkCssValue *value)
}
static GtkCssValue *
gtk_css_value_shadow_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_value_shadow_compute (GtkCssValue *value,
guint property_id,
GtkCssComputeContext *context)
{
guint i;
ShadowValue *shadows;
@@ -128,11 +126,11 @@ gtk_css_value_shadow_compute (GtkCssValue *value,
{
const ShadowValue *shadow = &value->shadows[i];
shadows[i].hoffset = _gtk_css_value_compute (shadow->hoffset, property_id, provider, style, parent_style);
shadows[i].voffset = _gtk_css_value_compute (shadow->voffset, property_id, provider, style, parent_style);
shadows[i].radius = _gtk_css_value_compute (shadow->radius, property_id, provider, style, parent_style);
shadows[i].spread = _gtk_css_value_compute (shadow->spread, property_id, provider, style, parent_style),
shadows[i].color = _gtk_css_value_compute (shadow->color, property_id, provider, style, parent_style);
shadows[i].hoffset = gtk_css_value_compute (shadow->hoffset, property_id, context);
shadows[i].voffset = gtk_css_value_compute (shadow->voffset, property_id, context);
shadows[i].radius = gtk_css_value_compute (shadow->radius, property_id, context);
shadows[i].spread = gtk_css_value_compute (shadow->spread, property_id, context),
shadows[i].color = gtk_css_value_compute (shadow->color, property_id, context);
shadows[i].inset = shadow->inset;
}
@@ -154,11 +152,11 @@ gtk_css_value_shadow_equal (const GtkCssValue *value1,
const ShadowValue *shadow2 = &value2->shadows[i];
if (shadow1->inset != shadow2->inset ||
!_gtk_css_value_equal (shadow1->hoffset, shadow2->hoffset) ||
!_gtk_css_value_equal (shadow1->voffset, shadow2->voffset) ||
!_gtk_css_value_equal (shadow1->radius, shadow2->radius) ||
!_gtk_css_value_equal (shadow1->spread, shadow2->spread) ||
!_gtk_css_value_equal (shadow1->color, shadow2->color))
!gtk_css_value_equal (shadow1->hoffset, shadow2->hoffset) ||
!gtk_css_value_equal (shadow1->voffset, shadow2->voffset) ||
!gtk_css_value_equal (shadow1->radius, shadow2->radius) ||
!gtk_css_value_equal (shadow1->spread, shadow2->spread) ||
!gtk_css_value_equal (shadow1->color, shadow2->color))
return FALSE;
}
@@ -252,24 +250,24 @@ gtk_css_value_shadow_print (const GtkCssValue *value,
if (i > 0)
g_string_append (string, ", ");
_gtk_css_value_print (shadow->hoffset, string);
gtk_css_value_print (shadow->hoffset, string);
g_string_append_c (string, ' ');
_gtk_css_value_print (shadow->voffset, string);
gtk_css_value_print (shadow->voffset, string);
g_string_append_c (string, ' ');
if (_gtk_css_number_value_get (shadow->radius, 100) != 0 ||
_gtk_css_number_value_get (shadow->spread, 100) != 0)
{
_gtk_css_value_print (shadow->radius, string);
gtk_css_value_print (shadow->radius, string);
g_string_append_c (string, ' ');
}
if (_gtk_css_number_value_get (shadow->spread, 100) != 0)
{
_gtk_css_value_print (shadow->spread, string);
gtk_css_value_print (shadow->spread, string);
g_string_append_c (string, ' ');
}
_gtk_css_value_print (shadow->color, string);
gtk_css_value_print (shadow->color, string);
if (shadow->inset)
g_string_append (string, " inset");
@@ -292,7 +290,7 @@ static GtkCssValue shadow_none_singleton = { &GTK_CSS_VALUE_SHADOW, 1, TRUE, FAL
GtkCssValue *
gtk_css_shadow_value_new_none (void)
{
return _gtk_css_value_ref (&shadow_none_singleton);
return gtk_css_value_ref (&shadow_none_singleton);
}
static GtkCssValue *
@@ -306,7 +304,7 @@ gtk_css_shadow_value_new (ShadowValue *shadows,
if (n_shadows == 0)
return gtk_css_shadow_value_new_none ();
retval = _gtk_css_value_alloc (&GTK_CSS_VALUE_SHADOW, sizeof (GtkCssValue) + sizeof (ShadowValue) * (n_shadows - 1));
retval = gtk_css_value_alloc (&GTK_CSS_VALUE_SHADOW, sizeof (GtkCssValue) + sizeof (ShadowValue) * (n_shadows - 1));
retval->n_shadows = n_shadows;
retval->is_filter = is_filter;
@@ -428,7 +426,7 @@ parse_color (GtkCssParser *parser,
{
GtkCssValue **color = option_data;
*color = _gtk_css_color_value_parse (parser);
*color = gtk_css_color_value_parse (parser);
if (*color == NULL)
return FALSE;
@@ -461,7 +459,7 @@ gtk_css_shadow_value_parse_one (GtkCssParser *parser,
}
if (color == NULL)
color = _gtk_css_color_value_new_current_color ();
color = gtk_css_color_value_new_current_color ();
result->hoffset = values[HOFFSET];
result->voffset = values[VOFFSET];

View File

@@ -104,7 +104,7 @@ gtk_css_shorthand_property_parse_value (GtkStyleProperty *property,
for (i = 0; i < n_props; i++)
{
if (data[i] != NULL)
_gtk_css_value_unref (data[i]);
gtk_css_value_unref (data[i]);
}
return NULL;
}
@@ -160,7 +160,14 @@ guint
_gtk_css_shorthand_property_get_n_subproperties (GtkCssShorthandProperty *shorthand)
{
g_return_val_if_fail (GTK_IS_CSS_SHORTHAND_PROPERTY (shorthand), 0);
return shorthand->subproperties->len;
}
guint
_gtk_css_shorthand_property_get_id (GtkCssShorthandProperty *shorthand)
{
g_return_val_if_fail (GTK_IS_CSS_SHORTHAND_PROPERTY (shorthand), 0);
return shorthand->id;
}

View File

@@ -77,7 +77,7 @@ parse_four_numbers (GtkCssShorthandProperty *shorthand,
for (; i < 4; i++)
{
values[i] = _gtk_css_value_ref (values[(i - 1) >> 1]);
values[i] = gtk_css_value_ref (values[(i - 1) >> 1]);
}
return TRUE;
@@ -148,7 +148,7 @@ parse_border_radius (GtkCssShorthandProperty *shorthand,
* according to spec. Feel free to check the 4 cases
*/
for (; i < 4; i++)
x[i] = _gtk_css_value_ref (x[(i - 1) >> 1]);
x[i] = gtk_css_value_ref (x[(i - 1) >> 1]);
if (gtk_css_parser_try_delim (parser, '/'))
{
@@ -171,12 +171,12 @@ parse_border_radius (GtkCssShorthandProperty *shorthand,
}
for (; i < 4; i++)
y[i] = _gtk_css_value_ref (y[(i - 1) >> 1]);
y[i] = gtk_css_value_ref (y[(i - 1) >> 1]);
}
else
{
for (i = 0; i < 4; i++)
y[i] = _gtk_css_value_ref (x[i]);
y[i] = gtk_css_value_ref (x[i]);
}
for (i = 0; i < 4; i++)
@@ -190,9 +190,9 @@ fail:
for (i = 0; i < 4; i++)
{
if (x[i])
_gtk_css_value_unref (x[i]);
gtk_css_value_unref (x[i]);
if (y[i])
_gtk_css_value_unref (y[i]);
gtk_css_value_unref (y[i]);
}
return FALSE;
}
@@ -206,7 +206,7 @@ parse_border_color (GtkCssShorthandProperty *shorthand,
for (i = 0; i < 4; i++)
{
values[i] = _gtk_css_color_value_parse (parser);
values[i] = gtk_css_color_value_parse (parser);
if (values[i] == NULL)
return FALSE;
@@ -216,7 +216,7 @@ parse_border_color (GtkCssShorthandProperty *shorthand,
for (i++; i < 4; i++)
{
values[i] = _gtk_css_value_ref (values[(i - 1) >> 1]);
values[i] = gtk_css_value_ref (values[(i - 1) >> 1]);
}
return TRUE;
@@ -243,7 +243,7 @@ parse_border_style (GtkCssShorthandProperty *shorthand,
}
for (; i < 4; i++)
values[i] = _gtk_css_value_ref (values[(i - 1) >> 1]);
values[i] = gtk_css_value_ref (values[(i - 1) >> 1]);
return TRUE;
}
@@ -338,7 +338,7 @@ parse_border_side (GtkCssShorthandProperty *shorthand,
}
else if (values[2] == NULL)
{
values[2] = _gtk_css_color_value_parse (parser);
values[2] = gtk_css_color_value_parse (parser);
if (values[2] == NULL)
return FALSE;
}
@@ -371,26 +371,26 @@ parse_border (GtkCssShorthandProperty *shorthand,
| GTK_CSS_PARSE_LENGTH);
if (values[0] == NULL)
return FALSE;
values[1] = _gtk_css_value_ref (values[0]);
values[2] = _gtk_css_value_ref (values[0]);
values[3] = _gtk_css_value_ref (values[0]);
values[1] = gtk_css_value_ref (values[0]);
values[2] = gtk_css_value_ref (values[0]);
values[3] = gtk_css_value_ref (values[0]);
}
else if (values[4] == NULL &&
(values[4] = _gtk_css_border_style_value_try_parse (parser)))
{
values[5] = _gtk_css_value_ref (values[4]);
values[6] = _gtk_css_value_ref (values[4]);
values[7] = _gtk_css_value_ref (values[4]);
values[5] = gtk_css_value_ref (values[4]);
values[6] = gtk_css_value_ref (values[4]);
values[7] = gtk_css_value_ref (values[4]);
}
else if (values[8] == NULL)
{
values[8] = _gtk_css_color_value_parse (parser);
values[8] = gtk_css_color_value_parse (parser);
if (values[8] == NULL)
return FALSE;
values[9] = _gtk_css_value_ref (values[8]);
values[10] = _gtk_css_value_ref (values[8]);
values[11] = _gtk_css_value_ref (values[8]);
values[9] = gtk_css_value_ref (values[8]);
values[10] = gtk_css_value_ref (values[8]);
values[11] = gtk_css_value_ref (values[8]);
}
else
{
@@ -555,9 +555,9 @@ parse_one_background (GtkCssShorthandProperty *shorthand,
}
else if (values[6] == NULL)
{
value = _gtk_css_color_value_parse (parser);
value = gtk_css_color_value_parse (parser);
if (value == NULL)
values[6] = _gtk_css_value_ref (_gtk_css_style_property_get_initial_value
values[6] = gtk_css_value_ref (_gtk_css_style_property_get_initial_value
(_gtk_css_shorthand_property_get_subproperty (shorthand, 6)));
else
values[6] = value;
@@ -576,7 +576,7 @@ parse_one_background (GtkCssShorthandProperty *shorthand,
while (!value_is_done_parsing (parser));
if (values[5] != NULL && values[4] == NULL)
values[4] = _gtk_css_value_ref (values[5]);
values[4] = gtk_css_value_ref (values[5]);
return TRUE;
}
@@ -603,7 +603,7 @@ parse_background (GtkCssShorthandProperty *shorthand,
{
for (i = 0; i < 6; i++)
{
g_ptr_array_set_free_func (arrays[i], (GDestroyNotify) _gtk_css_value_unref);
g_ptr_array_set_free_func (arrays[i], (GDestroyNotify) gtk_css_value_unref);
g_ptr_array_unref (arrays[i]);
}
return FALSE;
@@ -615,7 +615,7 @@ parse_background (GtkCssShorthandProperty *shorthand,
{
GtkCssValue *initial = _gtk_css_style_property_get_initial_value (
_gtk_css_shorthand_property_get_subproperty (shorthand, i));
step_values[i] = _gtk_css_value_ref (_gtk_css_array_value_get_nth (initial, 0));
step_values[i] = gtk_css_value_ref (_gtk_css_array_value_get_nth (initial, 0));
}
g_ptr_array_add (arrays[i], step_values[i]);
@@ -714,7 +714,7 @@ parse_transition (GtkCssShorthandProperty *shorthand,
{
for (i = 0; i < 4; i++)
{
g_ptr_array_set_free_func (arrays[i], (GDestroyNotify) _gtk_css_value_unref);
g_ptr_array_set_free_func (arrays[i], (GDestroyNotify) gtk_css_value_unref);
g_ptr_array_unref (arrays[i]);
}
return FALSE;
@@ -726,7 +726,7 @@ parse_transition (GtkCssShorthandProperty *shorthand,
{
GtkCssValue *initial = _gtk_css_style_property_get_initial_value (
_gtk_css_shorthand_property_get_subproperty (shorthand, i));
step_values[i] = _gtk_css_value_ref (_gtk_css_array_value_get_nth (initial, 0));
step_values[i] = gtk_css_value_ref (_gtk_css_array_value_get_nth (initial, 0));
}
g_ptr_array_add (arrays[i], step_values[i]);
@@ -831,7 +831,7 @@ parse_animation (GtkCssShorthandProperty *shorthand,
{
for (i = 0; i < 7; i++)
{
g_ptr_array_set_free_func (arrays[i], (GDestroyNotify) _gtk_css_value_unref);
g_ptr_array_set_free_func (arrays[i], (GDestroyNotify) gtk_css_value_unref);
g_ptr_array_unref (arrays[i]);
}
return FALSE;
@@ -843,7 +843,7 @@ parse_animation (GtkCssShorthandProperty *shorthand,
{
GtkCssValue *initial = _gtk_css_style_property_get_initial_value (
_gtk_css_shorthand_property_get_subproperty (shorthand, i));
step_values[i] = _gtk_css_value_ref (_gtk_css_array_value_get_nth (initial, 0));
step_values[i] = gtk_css_value_ref (_gtk_css_array_value_get_nth (initial, 0));
}
g_ptr_array_add (arrays[i], step_values[i]);
@@ -891,7 +891,7 @@ parse_text_decoration (GtkCssShorthandProperty *shorthand,
}
else if (values[2] == NULL)
{
values[2] = _gtk_css_color_value_parse (parser);
values[2] = gtk_css_color_value_parse (parser);
if (values[2] == NULL)
return FALSE;
}
@@ -1093,6 +1093,7 @@ parse_all (GtkCssShorthandProperty *shorthand,
static void
gtk_css_shorthand_property_register (const char *name,
unsigned int id,
const char **subproperties,
GtkCssShorthandPropertyParseFunc parse_func)
{
@@ -1103,6 +1104,8 @@ gtk_css_shorthand_property_register (const char *name,
"subproperties", subproperties,
NULL);
node->id = id;
node->parse = parse_func;
}
@@ -1158,65 +1161,85 @@ _gtk_css_shorthand_property_init_properties (void)
const char **all_subproperties;
gtk_css_shorthand_property_register ("font",
GTK_CSS_SHORTHAND_PROPERTY_FONT,
font_subproperties,
parse_font);
gtk_css_shorthand_property_register ("margin",
GTK_CSS_SHORTHAND_PROPERTY_MARGIN,
margin_subproperties,
parse_margin);
gtk_css_shorthand_property_register ("padding",
GTK_CSS_SHORTHAND_PROPERTY_PADDING,
padding_subproperties,
parse_padding);
gtk_css_shorthand_property_register ("border-width",
GTK_CSS_SHORTHAND_PROPERTY_BORDER_WIDTH,
border_width_subproperties,
parse_border_width);
gtk_css_shorthand_property_register ("border-radius",
GTK_CSS_SHORTHAND_PROPERTY_BORDER_RADIUS,
border_radius_subproperties,
parse_border_radius);
gtk_css_shorthand_property_register ("border-color",
GTK_CSS_SHORTHAND_PROPERTY_BORDER_COLOR,
border_color_subproperties,
parse_border_color);
gtk_css_shorthand_property_register ("border-style",
GTK_CSS_SHORTHAND_PROPERTY_BORDER_STYLE,
border_style_subproperties,
parse_border_style);
gtk_css_shorthand_property_register ("border-image",
GTK_CSS_SHORTHAND_PROPERTY_BORDER_IMAGE,
border_image_subproperties,
parse_border_image);
gtk_css_shorthand_property_register ("border-top",
GTK_CSS_SHORTHAND_PROPERTY_BORDER_TOP,
border_top_subproperties,
parse_border_side);
gtk_css_shorthand_property_register ("border-right",
GTK_CSS_SHORTHAND_PROPERTY_BORDER_RIGHT,
border_right_subproperties,
parse_border_side);
gtk_css_shorthand_property_register ("border-bottom",
GTK_CSS_SHORTHAND_PROPERTY_BORDER_BOTTOM,
border_bottom_subproperties,
parse_border_side);
gtk_css_shorthand_property_register ("border-left",
GTK_CSS_SHORTHAND_PROPERTY_BORDER_LEFT,
border_left_subproperties,
parse_border_side);
gtk_css_shorthand_property_register ("border",
GTK_CSS_SHORTHAND_PROPERTY_BORDER,
border_subproperties,
parse_border);
gtk_css_shorthand_property_register ("outline",
GTK_CSS_SHORTHAND_PROPERTY_OUTLINE,
outline_subproperties,
parse_border_side);
gtk_css_shorthand_property_register ("background",
GTK_CSS_SHORTHAND_PROPERTY_BACKGROUND,
background_subproperties,
parse_background);
gtk_css_shorthand_property_register ("transition",
GTK_CSS_SHORTHAND_PROPERTY_TRANSITION,
transition_subproperties,
parse_transition);
gtk_css_shorthand_property_register ("animation",
GTK_CSS_SHORTHAND_PROPERTY_ANIMATION,
animation_subproperties,
parse_animation);
gtk_css_shorthand_property_register ("text-decoration",
GTK_CSS_SHORTHAND_PROPERTY_TEXT_DECORATION,
text_decoration_subproperties,
parse_text_decoration);
gtk_css_shorthand_property_register ("font-variant",
GTK_CSS_SHORTHAND_PROPERTY_FONT_VARIANT,
font_variant_subproperties,
parse_font_variant);
all_subproperties = get_all_subproperties ();
gtk_css_shorthand_property_register ("all",
GTK_CSS_SHORTHAND_PROPERTY_ALL,
all_subproperties,
parse_all);
g_free (all_subproperties);

View File

@@ -49,6 +49,8 @@ struct _GtkCssShorthandProperty
GPtrArray *subproperties;
guint id;
GtkCssShorthandPropertyParseFunc parse;
};
@@ -65,6 +67,8 @@ GtkCssStyleProperty * _gtk_css_shorthand_property_get_subproperty (GtkCssS
guint property);
guint _gtk_css_shorthand_property_get_n_subproperties (GtkCssShorthandProperty *shorthand) G_GNUC_CONST;
guint _gtk_css_shorthand_property_get_id (GtkCssShorthandProperty *shorthand) G_GNUC_CONST;
G_END_DECLS

View File

@@ -31,6 +31,7 @@
#include "gtkcssstringvalueprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkcsstransitionprivate.h"
#include "gtkcssvaluesprivate.h"
#include "gtkprivate.h"
#include "gtksettings.h"
#include "gtkstyleanimationprivate.h"
@@ -38,136 +39,11 @@
#include "gtkstyleproviderprivate.h"
#include "gtkcssdimensionvalueprivate.h"
static void gtk_css_static_style_compute_value (GtkCssStaticStyle *style,
GtkStyleProvider *provider,
GtkCssStyle *parent_style,
guint id,
GtkCssValue *specified,
GtkCssSection *section);
static const int core_props[] = {
GTK_CSS_PROPERTY_COLOR,
GTK_CSS_PROPERTY_DPI,
GTK_CSS_PROPERTY_FONT_SIZE,
GTK_CSS_PROPERTY_ICON_PALETTE
};
static const int background_props[] = {
GTK_CSS_PROPERTY_BACKGROUND_COLOR,
GTK_CSS_PROPERTY_BOX_SHADOW,
GTK_CSS_PROPERTY_BACKGROUND_CLIP,
GTK_CSS_PROPERTY_BACKGROUND_ORIGIN,
GTK_CSS_PROPERTY_BACKGROUND_SIZE,
GTK_CSS_PROPERTY_BACKGROUND_POSITION,
GTK_CSS_PROPERTY_BACKGROUND_REPEAT,
GTK_CSS_PROPERTY_BACKGROUND_IMAGE,
GTK_CSS_PROPERTY_BACKGROUND_BLEND_MODE
};
static const int border_props[] = {
GTK_CSS_PROPERTY_BORDER_TOP_STYLE,
GTK_CSS_PROPERTY_BORDER_TOP_WIDTH,
GTK_CSS_PROPERTY_BORDER_LEFT_STYLE,
GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH,
GTK_CSS_PROPERTY_BORDER_BOTTOM_STYLE,
GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH,
GTK_CSS_PROPERTY_BORDER_RIGHT_STYLE,
GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH,
GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS,
GTK_CSS_PROPERTY_BORDER_TOP_RIGHT_RADIUS,
GTK_CSS_PROPERTY_BORDER_BOTTOM_RIGHT_RADIUS,
GTK_CSS_PROPERTY_BORDER_BOTTOM_LEFT_RADIUS,
GTK_CSS_PROPERTY_BORDER_TOP_COLOR,
GTK_CSS_PROPERTY_BORDER_RIGHT_COLOR,
GTK_CSS_PROPERTY_BORDER_BOTTOM_COLOR,
GTK_CSS_PROPERTY_BORDER_LEFT_COLOR,
GTK_CSS_PROPERTY_BORDER_IMAGE_SOURCE,
GTK_CSS_PROPERTY_BORDER_IMAGE_REPEAT,
GTK_CSS_PROPERTY_BORDER_IMAGE_SLICE,
GTK_CSS_PROPERTY_BORDER_IMAGE_WIDTH
};
static const int icon_props[] = {
GTK_CSS_PROPERTY_ICON_SIZE,
GTK_CSS_PROPERTY_ICON_SHADOW,
GTK_CSS_PROPERTY_ICON_STYLE,
};
static const int outline_props[] = {
GTK_CSS_PROPERTY_OUTLINE_STYLE,
GTK_CSS_PROPERTY_OUTLINE_WIDTH,
GTK_CSS_PROPERTY_OUTLINE_OFFSET,
GTK_CSS_PROPERTY_OUTLINE_COLOR,
};
static const int font_props[] = {
GTK_CSS_PROPERTY_FONT_FAMILY,
GTK_CSS_PROPERTY_FONT_STYLE,
GTK_CSS_PROPERTY_FONT_WEIGHT,
GTK_CSS_PROPERTY_FONT_STRETCH,
GTK_CSS_PROPERTY_LETTER_SPACING,
GTK_CSS_PROPERTY_TEXT_SHADOW,
GTK_CSS_PROPERTY_CARET_COLOR,
GTK_CSS_PROPERTY_SECONDARY_CARET_COLOR,
GTK_CSS_PROPERTY_FONT_FEATURE_SETTINGS,
GTK_CSS_PROPERTY_FONT_VARIATION_SETTINGS,
GTK_CSS_PROPERTY_LINE_HEIGHT,
};
static const int font_variant_props[] = {
GTK_CSS_PROPERTY_TEXT_DECORATION_LINE,
GTK_CSS_PROPERTY_TEXT_DECORATION_COLOR,
GTK_CSS_PROPERTY_TEXT_DECORATION_STYLE,
GTK_CSS_PROPERTY_TEXT_TRANSFORM,
GTK_CSS_PROPERTY_FONT_KERNING,
GTK_CSS_PROPERTY_FONT_VARIANT_LIGATURES,
GTK_CSS_PROPERTY_FONT_VARIANT_POSITION,
GTK_CSS_PROPERTY_FONT_VARIANT_CAPS,
GTK_CSS_PROPERTY_FONT_VARIANT_NUMERIC,
GTK_CSS_PROPERTY_FONT_VARIANT_ALTERNATES,
GTK_CSS_PROPERTY_FONT_VARIANT_EAST_ASIAN,
};
static const int animation_props[] = {
GTK_CSS_PROPERTY_ANIMATION_NAME,
GTK_CSS_PROPERTY_ANIMATION_DURATION,
GTK_CSS_PROPERTY_ANIMATION_TIMING_FUNCTION,
GTK_CSS_PROPERTY_ANIMATION_ITERATION_COUNT,
GTK_CSS_PROPERTY_ANIMATION_DIRECTION,
GTK_CSS_PROPERTY_ANIMATION_PLAY_STATE,
GTK_CSS_PROPERTY_ANIMATION_DELAY,
GTK_CSS_PROPERTY_ANIMATION_FILL_MODE,
};
static const int transition_props[] = {
GTK_CSS_PROPERTY_TRANSITION_PROPERTY,
GTK_CSS_PROPERTY_TRANSITION_DURATION,
GTK_CSS_PROPERTY_TRANSITION_TIMING_FUNCTION,
GTK_CSS_PROPERTY_TRANSITION_DELAY,
};
static const int size_props[] = {
GTK_CSS_PROPERTY_MARGIN_TOP,
GTK_CSS_PROPERTY_MARGIN_LEFT,
GTK_CSS_PROPERTY_MARGIN_BOTTOM,
GTK_CSS_PROPERTY_MARGIN_RIGHT,
GTK_CSS_PROPERTY_PADDING_TOP,
GTK_CSS_PROPERTY_PADDING_LEFT,
GTK_CSS_PROPERTY_PADDING_BOTTOM,
GTK_CSS_PROPERTY_PADDING_RIGHT,
GTK_CSS_PROPERTY_BORDER_SPACING,
GTK_CSS_PROPERTY_MIN_WIDTH,
GTK_CSS_PROPERTY_MIN_HEIGHT,
};
static const int other_props[] = {
GTK_CSS_PROPERTY_ICON_SOURCE,
GTK_CSS_PROPERTY_ICON_TRANSFORM,
GTK_CSS_PROPERTY_ICON_FILTER,
GTK_CSS_PROPERTY_TRANSFORM,
GTK_CSS_PROPERTY_TRANSFORM_ORIGIN,
GTK_CSS_PROPERTY_OPACITY,
GTK_CSS_PROPERTY_FILTER,
};
static void gtk_css_static_style_compute_value (GtkCssStaticStyle *style,
guint id,
GtkCssValue *specified,
GtkCssSection *section,
GtkCssComputeContext *context);
#define GET_VALUES(v) (GtkCssValue **)((guint8*)(v) + sizeof (GtkCssValues))
@@ -185,7 +61,7 @@ gtk_css_## NAME ## _values_compute_changes_and_affects (GtkCssStyle *style1, \
{ \
GtkCssValue *v1 = g1[i] ? g1[i] : style1->core->color; \
GtkCssValue *v2 = g2[i] ? g2[i] : style2->core->color; \
if (!_gtk_css_value_equal (v1, v2)) \
if (!gtk_css_value_equal (v1, v2)) \
{ \
guint id = NAME ## _props[i]; \
*changes = _gtk_bitmask_set (*changes, id, TRUE); \
@@ -195,10 +71,9 @@ gtk_css_## NAME ## _values_compute_changes_and_affects (GtkCssStyle *style1, \
} \
\
static inline void \
gtk_css_ ## NAME ## _values_new_compute (GtkCssStaticStyle *sstyle, \
GtkStyleProvider *provider, \
GtkCssStyle *parent_style, \
GtkCssLookup *lookup) \
gtk_css_ ## NAME ## _values_new_compute (GtkCssStaticStyle *sstyle, \
GtkCssLookup *lookup, \
GtkCssComputeContext *context) \
{ \
GtkCssStyle *style = (GtkCssStyle *)sstyle; \
int i; \
@@ -209,11 +84,10 @@ gtk_css_ ## NAME ## _values_new_compute (GtkCssStaticStyle *sstyle, \
{ \
guint id = NAME ## _props[i]; \
gtk_css_static_style_compute_value (sstyle, \
provider, \
parent_style, \
id, \
lookup->values[id].value, \
lookup->values[id].section); \
lookup->values[id].section, \
context); \
} \
} \
static GtkBitmask * gtk_css_ ## NAME ## _values_mask; \
@@ -322,6 +196,12 @@ gtk_css_static_style_dispose (GObject *object)
style->sections = NULL;
}
if (style->original_values)
{
g_ptr_array_unref (style->original_values);
style->original_values = NULL;
}
G_OBJECT_CLASS (gtk_css_static_style_parent_class)->dispose (object);
}
@@ -331,6 +211,19 @@ gtk_css_static_style_get_static_style (GtkCssStyle *style)
return (GtkCssStaticStyle *)style;
}
static GtkCssValue *
gtk_css_static_style_get_original_value (GtkCssStyle *style,
guint id)
{
GtkCssStaticStyle *sstyle = GTK_CSS_STATIC_STYLE (style);
if (sstyle->original_values == NULL ||
id >= sstyle->original_values->len)
return NULL;
return g_ptr_array_index (sstyle->original_values, id);
}
static void
gtk_css_static_style_class_init (GtkCssStaticStyleClass *klass)
{
@@ -341,6 +234,7 @@ gtk_css_static_style_class_init (GtkCssStaticStyleClass *klass)
style_class->get_section = gtk_css_static_style_get_section;
style_class->get_static_style = gtk_css_static_style_get_static_style;
style_class->get_original_value = gtk_css_static_style_get_original_value;
gtk_css_core_values_init ();
gtk_css_background_values_init ();
@@ -369,6 +263,13 @@ maybe_unref_section (gpointer section)
gtk_css_section_unref (section);
}
static void
maybe_unref_value (gpointer value)
{
if (value)
gtk_css_value_unref (value);
}
static inline void
gtk_css_take_value (GtkCssValue **variable,
GtkCssValue *value)
@@ -382,6 +283,7 @@ static void
gtk_css_static_style_set_value (GtkCssStaticStyle *sstyle,
guint id,
GtkCssValue *value,
GtkCssValue *original_value,
GtkCssSection *section)
{
GtkCssStyle *style = (GtkCssStyle *)sstyle;
@@ -684,6 +586,22 @@ gtk_css_static_style_set_value (GtkCssStaticStyle *sstyle,
g_ptr_array_set_size (sstyle->sections, id + 1);
g_ptr_array_index (sstyle->sections, id) = gtk_css_section_ref (section);
}
if (sstyle->original_values && sstyle->original_values->len > id &&
g_ptr_array_index (sstyle->original_values, id))
{
gtk_css_value_unref (g_ptr_array_index (sstyle->original_values, id));
g_ptr_array_index (sstyle->original_values, id) = NULL;
}
if (original_value)
{
if (sstyle->original_values == NULL)
sstyle->original_values = g_ptr_array_new_with_free_func (maybe_unref_value);
if (sstyle->original_values->len <= id)
g_ptr_array_set_size (sstyle->original_values, id + 1);
g_ptr_array_index (sstyle->original_values, id) = gtk_css_value_ref (original_value);
}
}
static GtkCssStyle *default_style;
@@ -729,18 +647,19 @@ static GtkCssValues *
gtk_css_background_create_initial_values (void)
{
GtkCssBackgroundValues *values;
GtkCssComputeContext context = { NULL, };
values = (GtkCssBackgroundValues *)gtk_css_values_new (GTK_CSS_BACKGROUND_INITIAL_VALUES);
values->background_color = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BACKGROUND_COLOR, NULL, NULL, NULL);
values->box_shadow = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BOX_SHADOW, NULL, NULL, NULL);
values->background_clip = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BACKGROUND_CLIP, NULL, NULL, NULL);
values->background_origin = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BACKGROUND_ORIGIN, NULL, NULL, NULL);
values->background_size = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BACKGROUND_SIZE, NULL, NULL, NULL);
values->background_position = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BACKGROUND_POSITION, NULL, NULL, NULL);
values->background_repeat = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BACKGROUND_REPEAT, NULL, NULL, NULL);
values->background_image = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BACKGROUND_IMAGE, NULL, NULL, NULL);
values->background_blend_mode = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BACKGROUND_BLEND_MODE, NULL, NULL, NULL);
values->background_color = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BACKGROUND_COLOR, &context);
values->box_shadow = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BOX_SHADOW, &context);
values->background_clip = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BACKGROUND_CLIP, &context);
values->background_origin = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BACKGROUND_ORIGIN, &context);
values->background_size = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BACKGROUND_SIZE, &context);
values->background_position = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BACKGROUND_POSITION, &context);
values->background_repeat = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BACKGROUND_REPEAT, &context);
values->background_image = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BACKGROUND_IMAGE, &context);
values->background_blend_mode = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BACKGROUND_BLEND_MODE, &context);
return (GtkCssValues *)values;
}
@@ -749,29 +668,30 @@ static GtkCssValues *
gtk_css_border_create_initial_values (void)
{
GtkCssBorderValues *values;
GtkCssComputeContext context = { NULL, };
values = (GtkCssBorderValues *)gtk_css_values_new (GTK_CSS_BORDER_INITIAL_VALUES);
values->border_top_style = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_TOP_STYLE, NULL, NULL, NULL);
values->border_top_width = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_TOP_WIDTH, NULL, NULL, NULL);
values->border_left_style = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_LEFT_STYLE, NULL, NULL, NULL);
values->border_left_width = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH, NULL, NULL, NULL);
values->border_bottom_style = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_BOTTOM_STYLE, NULL, NULL, NULL);
values->border_bottom_width = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH, NULL, NULL, NULL);
values->border_right_style = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_RIGHT_STYLE, NULL, NULL, NULL);
values->border_right_width = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH, NULL, NULL, NULL);
values->border_top_left_radius = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS, NULL, NULL, NULL);
values->border_top_right_radius = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_TOP_RIGHT_RADIUS, NULL, NULL, NULL);
values->border_bottom_left_radius = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_BOTTOM_LEFT_RADIUS, NULL, NULL, NULL);
values->border_bottom_right_radius = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_BOTTOM_RIGHT_RADIUS, NULL, NULL, NULL);
values->border_top_style = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_TOP_STYLE, &context);
values->border_top_width = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_TOP_WIDTH, &context);
values->border_left_style = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_LEFT_STYLE, &context);
values->border_left_width = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH, &context);
values->border_bottom_style = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_BOTTOM_STYLE, &context);
values->border_bottom_width = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH, &context);
values->border_right_style = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_RIGHT_STYLE, &context);
values->border_right_width = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH, &context);
values->border_top_left_radius = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS, &context);
values->border_top_right_radius = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_TOP_RIGHT_RADIUS, &context);
values->border_bottom_left_radius = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_BOTTOM_LEFT_RADIUS, &context);
values->border_bottom_right_radius = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_BOTTOM_RIGHT_RADIUS, &context);
values->border_top_color = NULL;
values->border_right_color = NULL;
values->border_bottom_color = NULL;
values->border_left_color = NULL;
values->border_image_source = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_IMAGE_SOURCE, NULL, NULL, NULL);
values->border_image_repeat = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_IMAGE_REPEAT, NULL, NULL, NULL);
values->border_image_slice = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_IMAGE_SLICE, NULL, NULL, NULL);
values->border_image_width = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_IMAGE_WIDTH, NULL, NULL, NULL);
values->border_image_source = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_IMAGE_SOURCE, &context);
values->border_image_repeat = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_IMAGE_REPEAT, &context);
values->border_image_slice = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_IMAGE_SLICE, &context);
values->border_image_width = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_IMAGE_WIDTH, &context);
return (GtkCssValues *)values;
}
@@ -780,12 +700,13 @@ static GtkCssValues *
gtk_css_outline_create_initial_values (void)
{
GtkCssOutlineValues *values;
GtkCssComputeContext context = { NULL, };
values = (GtkCssOutlineValues *)gtk_css_values_new (GTK_CSS_OUTLINE_INITIAL_VALUES);
values->outline_style = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_OUTLINE_STYLE, NULL, NULL, NULL);
values->outline_width = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_OUTLINE_WIDTH, NULL, NULL, NULL);
values->outline_offset = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_OUTLINE_OFFSET, NULL, NULL, NULL);
values->outline_style = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_OUTLINE_STYLE, &context);
values->outline_width = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_OUTLINE_WIDTH, &context);
values->outline_offset = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_OUTLINE_OFFSET, &context);
values->outline_color = NULL;
return (GtkCssValues *)values;
@@ -807,20 +728,21 @@ static GtkCssValues *
gtk_css_font_variant_create_initial_values (void)
{
GtkCssFontVariantValues *values;
GtkCssComputeContext context = { NULL, };
values = (GtkCssFontVariantValues *)gtk_css_values_new (GTK_CSS_FONT_VARIANT_INITIAL_VALUES);
values->text_decoration_line = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TEXT_DECORATION_LINE, NULL, NULL, NULL);
values->text_decoration_line = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TEXT_DECORATION_LINE, &context);
values->text_decoration_color = NULL;
values->text_decoration_style = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TEXT_DECORATION_STYLE, NULL, NULL, NULL);
values->text_transform = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TEXT_TRANSFORM, NULL, NULL, NULL);
values->font_kerning = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_FONT_KERNING, NULL, NULL, NULL);
values->font_variant_ligatures = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_FONT_VARIANT_LIGATURES, NULL, NULL, NULL);
values->font_variant_position = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_FONT_VARIANT_POSITION, NULL, NULL, NULL);
values->font_variant_caps = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_FONT_VARIANT_CAPS, NULL, NULL, NULL);
values->font_variant_numeric = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_FONT_VARIANT_NUMERIC, NULL, NULL, NULL);
values->font_variant_alternates = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_FONT_VARIANT_ALTERNATES, NULL, NULL, NULL);
values->font_variant_east_asian = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_FONT_VARIANT_EAST_ASIAN, NULL, NULL, NULL);
values->text_decoration_style = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TEXT_DECORATION_STYLE, &context);
values->text_transform = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TEXT_TRANSFORM, &context);
values->font_kerning = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_FONT_KERNING, &context);
values->font_variant_ligatures = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_FONT_VARIANT_LIGATURES, &context);
values->font_variant_position = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_FONT_VARIANT_POSITION, &context);
values->font_variant_caps = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_FONT_VARIANT_CAPS, &context);
values->font_variant_numeric = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_FONT_VARIANT_NUMERIC, &context);
values->font_variant_alternates = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_FONT_VARIANT_ALTERNATES, &context);
values->font_variant_east_asian = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_FONT_VARIANT_EAST_ASIAN, &context);
return (GtkCssValues *)values;
}
@@ -829,17 +751,18 @@ static GtkCssValues *
gtk_css_animation_create_initial_values (void)
{
GtkCssAnimationValues *values;
GtkCssComputeContext context = { NULL, };
values = (GtkCssAnimationValues *)gtk_css_values_new (GTK_CSS_ANIMATION_INITIAL_VALUES);
values->animation_name = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_NAME, NULL, NULL, NULL);
values->animation_duration = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_DURATION, NULL, NULL, NULL);
values->animation_timing_function = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_TIMING_FUNCTION, NULL, NULL, NULL);
values->animation_iteration_count = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_ITERATION_COUNT, NULL, NULL, NULL);
values->animation_direction = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_DIRECTION, NULL, NULL, NULL);
values->animation_play_state = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_PLAY_STATE, NULL, NULL, NULL);
values->animation_delay = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_DELAY, NULL, NULL, NULL);
values->animation_fill_mode = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_FILL_MODE, NULL, NULL, NULL);
values->animation_name = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_NAME, &context);
values->animation_duration = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_DURATION, &context);
values->animation_timing_function = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_TIMING_FUNCTION, &context);
values->animation_iteration_count = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_ITERATION_COUNT, &context);
values->animation_direction = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_DIRECTION, &context);
values->animation_play_state = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_PLAY_STATE, &context);
values->animation_delay = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_DELAY, &context);
values->animation_fill_mode = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_FILL_MODE, &context);
return (GtkCssValues *)values;
}
@@ -848,13 +771,14 @@ static GtkCssValues *
gtk_css_transition_create_initial_values (void)
{
GtkCssTransitionValues *values;
GtkCssComputeContext context = { NULL, };
values = (GtkCssTransitionValues *)gtk_css_values_new (GTK_CSS_TRANSITION_INITIAL_VALUES);
values->transition_property = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TRANSITION_PROPERTY, NULL, NULL, NULL);
values->transition_duration = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TRANSITION_DURATION, NULL, NULL, NULL);
values->transition_timing_function = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TRANSITION_TIMING_FUNCTION, NULL, NULL, NULL);
values->transition_delay = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TRANSITION_DELAY, NULL, NULL, NULL);
values->transition_property = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TRANSITION_PROPERTY, &context);
values->transition_duration = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TRANSITION_DURATION, &context);
values->transition_timing_function = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TRANSITION_TIMING_FUNCTION, &context);
values->transition_delay = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TRANSITION_DELAY, &context);
return (GtkCssValues *)values;
}
@@ -863,20 +787,21 @@ static GtkCssValues *
gtk_css_size_create_initial_values (void)
{
GtkCssSizeValues *values;
GtkCssComputeContext context = { NULL, };
values = (GtkCssSizeValues *)gtk_css_values_new (GTK_CSS_SIZE_INITIAL_VALUES);
values->margin_top = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MARGIN_TOP, NULL, NULL, NULL);
values->margin_left = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MARGIN_LEFT, NULL, NULL, NULL);
values->margin_bottom = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MARGIN_BOTTOM, NULL, NULL, NULL);
values->margin_right = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MARGIN_RIGHT, NULL, NULL, NULL);
values->padding_top = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_PADDING_TOP, NULL, NULL, NULL);
values->padding_left = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_PADDING_LEFT, NULL, NULL, NULL);
values->padding_bottom = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_PADDING_BOTTOM, NULL, NULL, NULL);
values->padding_right = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_PADDING_RIGHT, NULL, NULL, NULL);
values->border_spacing = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_SPACING, NULL, NULL, NULL);
values->min_width = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MIN_WIDTH, NULL, NULL, NULL);
values->min_height = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MIN_HEIGHT, NULL, NULL, NULL);
values->margin_top = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MARGIN_TOP, &context);
values->margin_left = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MARGIN_LEFT, &context);
values->margin_bottom = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MARGIN_BOTTOM, &context);
values->margin_right = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MARGIN_RIGHT, &context);
values->padding_top = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_PADDING_TOP, &context);
values->padding_left = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_PADDING_LEFT, &context);
values->padding_bottom = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_PADDING_BOTTOM, &context);
values->padding_right = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_PADDING_RIGHT, &context);
values->border_spacing = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_SPACING, &context);
values->min_width = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MIN_WIDTH, &context);
values->min_height = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MIN_HEIGHT, &context);
return (GtkCssValues *)values;
}
@@ -885,16 +810,17 @@ static GtkCssValues *
gtk_css_other_create_initial_values (void)
{
GtkCssOtherValues *values;
GtkCssComputeContext context = { NULL, };
values = (GtkCssOtherValues *)gtk_css_values_new (GTK_CSS_OTHER_INITIAL_VALUES);
values->icon_source = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ICON_SOURCE, NULL, NULL, NULL);
values->icon_transform = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ICON_TRANSFORM, NULL, NULL, NULL);
values->icon_filter = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ICON_FILTER, NULL, NULL, NULL);
values->transform = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TRANSFORM, NULL, NULL, NULL);
values->transform_origin = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TRANSFORM_ORIGIN, NULL, NULL, NULL);
values->opacity = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_OPACITY, NULL, NULL, NULL);
values->filter = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_FILTER, NULL, NULL, NULL);
values->icon_source = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ICON_SOURCE, &context);
values->icon_transform = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ICON_TRANSFORM, &context);
values->icon_filter = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ICON_FILTER, &context);
values->transform = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TRANSFORM, &context);
values->transform_origin = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TRANSFORM_ORIGIN, &context);
values->opacity = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_OPACITY, &context);
values->filter = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_FILTER, &context);
return (GtkCssValues *)values;
}
@@ -906,12 +832,49 @@ gtk_css_lookup_resolve (GtkCssLookup *lookup,
GtkCssStyle *parent_style)
{
GtkCssStyle *style = (GtkCssStyle *)sstyle;
GtkCssValue *shorthands[GTK_CSS_SHORTHAND_PROPERTY_N_PROPERTIES] = { NULL, };
GtkCssComputeContext context = { NULL, };
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));
if (lookup->custom_values)
{
GHashTableIter iter;
gpointer id;
GtkCssVariableValue *value;
g_clear_pointer (&style->variables, gtk_css_variable_set_unref);
style->variables = gtk_css_variable_set_new ();
g_hash_table_iter_init (&iter, lookup->custom_values);
while (g_hash_table_iter_next (&iter, &id, (gpointer) &value))
gtk_css_variable_set_add (style->variables, GPOINTER_TO_INT (id), value);
gtk_css_variable_set_resolve_cycles (style->variables);
if (parent_style)
{
gtk_css_variable_set_set_parent (style->variables,
parent_style->variables);
}
}
else if (parent_style && parent_style->variables)
{
g_clear_pointer (&style->variables, gtk_css_variable_set_unref);
style->variables = gtk_css_variable_set_new ();
gtk_css_variable_set_set_parent (style->variables,
parent_style->variables);
}
context.provider = provider;
context.style = (GtkCssStyle *) sstyle;
context.parent_style = parent_style;
context.shorthands = shorthands;
if (_gtk_bitmask_is_empty (_gtk_css_lookup_get_set_values (lookup)))
{
style->background = (GtkCssBackgroundValues *)gtk_css_values_ref (gtk_css_background_initial_values);
@@ -931,9 +894,9 @@ gtk_css_lookup_resolve (GtkCssLookup *lookup,
}
else
{
gtk_css_core_values_new_compute (sstyle, provider, parent_style, lookup);
gtk_css_icon_values_new_compute (sstyle, provider, parent_style, lookup);
gtk_css_font_values_new_compute (sstyle, provider, parent_style, lookup);
gtk_css_core_values_new_compute (sstyle, lookup, &context);
gtk_css_icon_values_new_compute (sstyle, lookup, &context);
gtk_css_font_values_new_compute (sstyle, lookup, &context);
}
return;
@@ -942,57 +905,63 @@ gtk_css_lookup_resolve (GtkCssLookup *lookup,
if (parent_style && gtk_css_core_values_unset (lookup))
style->core = (GtkCssCoreValues *)gtk_css_values_ref ((GtkCssValues *)parent_style->core);
else
gtk_css_core_values_new_compute (sstyle, provider, parent_style, lookup);
gtk_css_core_values_new_compute (sstyle, lookup, &context);
if (gtk_css_background_values_unset (lookup))
style->background = (GtkCssBackgroundValues *)gtk_css_values_ref (gtk_css_background_initial_values);
else
gtk_css_background_values_new_compute (sstyle, provider, parent_style, lookup);
gtk_css_background_values_new_compute (sstyle, lookup, &context);
if (gtk_css_border_values_unset (lookup))
style->border = (GtkCssBorderValues *)gtk_css_values_ref (gtk_css_border_initial_values);
else
gtk_css_border_values_new_compute (sstyle, provider, parent_style, lookup);
gtk_css_border_values_new_compute (sstyle, lookup, &context);
if (parent_style && gtk_css_icon_values_unset (lookup))
style->icon = (GtkCssIconValues *)gtk_css_values_ref ((GtkCssValues *)parent_style->icon);
else
gtk_css_icon_values_new_compute (sstyle, provider, parent_style, lookup);
gtk_css_icon_values_new_compute (sstyle, lookup, &context);
if (gtk_css_outline_values_unset (lookup))
style->outline = (GtkCssOutlineValues *)gtk_css_values_ref (gtk_css_outline_initial_values);
else
gtk_css_outline_values_new_compute (sstyle, provider, parent_style, lookup);
gtk_css_outline_values_new_compute (sstyle, lookup, &context);
if (parent_style && gtk_css_font_values_unset (lookup))
style->font = (GtkCssFontValues *)gtk_css_values_ref ((GtkCssValues *)parent_style->font);
else
gtk_css_font_values_new_compute (sstyle, provider, parent_style, lookup);
gtk_css_font_values_new_compute (sstyle, lookup, &context);
if (gtk_css_font_variant_values_unset (lookup))
style->font_variant = (GtkCssFontVariantValues *)gtk_css_values_ref (gtk_css_font_variant_initial_values);
else
gtk_css_font_variant_values_new_compute (sstyle, provider, parent_style, lookup);
gtk_css_font_variant_values_new_compute (sstyle, lookup, &context);
if (gtk_css_animation_values_unset (lookup))
style->animation = (GtkCssAnimationValues *)gtk_css_values_ref (gtk_css_animation_initial_values);
else
gtk_css_animation_values_new_compute (sstyle, provider, parent_style, lookup);
gtk_css_animation_values_new_compute (sstyle, lookup, &context);
if (gtk_css_transition_values_unset (lookup))
style->transition = (GtkCssTransitionValues *)gtk_css_values_ref (gtk_css_transition_initial_values);
else
gtk_css_transition_values_new_compute (sstyle, provider, parent_style, lookup);
gtk_css_transition_values_new_compute (sstyle, lookup, &context);
if (gtk_css_size_values_unset (lookup))
style->size = (GtkCssSizeValues *)gtk_css_values_ref (gtk_css_size_initial_values);
else
gtk_css_size_values_new_compute (sstyle, provider, parent_style, lookup);
gtk_css_size_values_new_compute (sstyle, lookup, &context);
if (gtk_css_other_values_unset (lookup))
style->other = (GtkCssOtherValues *)gtk_css_values_ref (gtk_css_other_initial_values);
else
gtk_css_other_values_new_compute (sstyle, provider, parent_style, lookup);
gtk_css_other_values_new_compute (sstyle, lookup, &context);
for (unsigned int i = 0; i < GTK_CSS_SHORTHAND_PROPERTY_N_PROPERTIES; i++)
{
if (shorthands[i])
gtk_css_value_unref (shorthands[i]);
}
}
GtkCssStyle *
@@ -1040,14 +1009,13 @@ G_STATIC_ASSERT (GTK_CSS_PROPERTY_BORDER_LEFT_STYLE == GTK_CSS_PROPERTY_BORDER_L
G_STATIC_ASSERT (GTK_CSS_PROPERTY_OUTLINE_STYLE == GTK_CSS_PROPERTY_OUTLINE_WIDTH - 1);
static void
gtk_css_static_style_compute_value (GtkCssStaticStyle *style,
GtkStyleProvider *provider,
GtkCssStyle *parent_style,
guint id,
GtkCssValue *specified,
GtkCssSection *section)
gtk_css_static_style_compute_value (GtkCssStaticStyle *style,
guint id,
GtkCssValue *specified,
GtkCssSection *section,
GtkCssComputeContext *context)
{
GtkCssValue *value;
GtkCssValue *value, *original_value;
GtkBorderStyle border_style;
gtk_internal_return_if_fail (id < GTK_CSS_PROPERTY_N_PROPERTIES);
@@ -1068,7 +1036,7 @@ gtk_css_static_style_compute_value (GtkCssStaticStyle *style,
border_style = _gtk_css_border_style_value_get (gtk_css_style_get_value ((GtkCssStyle *)style, id - 1));
if (border_style == GTK_BORDER_STYLE_NONE || border_style == GTK_BORDER_STYLE_HIDDEN)
{
gtk_css_static_style_set_value (style, id, gtk_css_dimension_value_new (0, GTK_CSS_NUMBER), section);
gtk_css_static_style_set_value (style, id, gtk_css_dimension_value_new (0, GTK_CSS_NUMBER), NULL, section);
return;
}
break;
@@ -1085,19 +1053,34 @@ gtk_css_static_style_compute_value (GtkCssStaticStyle *style,
*/
if (specified)
{
value = _gtk_css_value_compute (specified, id, provider, (GtkCssStyle *)style, parent_style);
value = gtk_css_value_compute (specified, id, context);
if (gtk_css_value_contains_variables (specified))
original_value = specified;
else
original_value = NULL;
}
else if (parent_style && _gtk_css_style_property_is_inherit (_gtk_css_style_property_lookup_by_id (id)))
else if (context->parent_style && _gtk_css_style_property_is_inherit (_gtk_css_style_property_lookup_by_id (id)))
{
GtkCssValue *parent_original_value;
/* Just take the style from the parent */
value = _gtk_css_value_ref (gtk_css_style_get_value (parent_style, id));
value = gtk_css_value_ref (gtk_css_style_get_value (context->parent_style, id));
parent_original_value = gtk_css_style_get_original_value (context->parent_style, id);
if (parent_original_value)
original_value = parent_original_value;
else
original_value = NULL;
}
else
{
value = _gtk_css_initial_value_new_compute (id, provider, (GtkCssStyle *)style, parent_style);
value = _gtk_css_initial_value_new_compute (id, context);
original_value = NULL;
}
gtk_css_static_style_set_value (style, id, value, section);
gtk_css_static_style_set_value (style, id, value, original_value, section);
}
GtkCssChange
@@ -1107,3 +1090,15 @@ gtk_css_static_style_get_change (GtkCssStaticStyle *style)
return style->change;
}
void
gtk_css_custom_values_compute_changes_and_affects (GtkCssStyle *style1,
GtkCssStyle *style2,
GtkBitmask **changes,
GtkCssAffects *affects)
{
if (gtk_css_variable_set_equal (style1->variables, style2->variables))
return;
*changes = _gtk_bitmask_set (*changes, GTK_CSS_PROPERTY_CUSTOM, TRUE);
}

View File

@@ -40,6 +40,7 @@ struct _GtkCssStaticStyle
GtkCssStyle parent;
GPtrArray *sections; /* sections the values are defined in */
GPtrArray *original_values;
GtkCssChange change; /* change as returned by value lookup */
};

View File

@@ -35,13 +35,11 @@ gtk_css_value_string_free (GtkCssValue *value)
}
static GtkCssValue *
gtk_css_value_string_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_value_string_compute (GtkCssValue *value,
guint property_id,
GtkCssComputeContext *context)
{
return _gtk_css_value_ref (value);
return gtk_css_value_ref (value);
}
static gboolean
@@ -150,7 +148,7 @@ _gtk_css_string_value_new_take (char *string)
{
GtkCssValue *result;
result = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_STRING);
result = gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_STRING);
result->string = string;
result->is_computed = TRUE;
@@ -191,7 +189,7 @@ _gtk_css_ident_value_new_take (char *ident)
{
GtkCssValue *result;
result = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_IDENT);
result = gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_IDENT);
result->string = ident;
result->is_computed = TRUE;
@@ -226,3 +224,4 @@ _gtk_css_ident_value_get (const GtkCssValue *value)
return value->string;
}

View File

@@ -24,6 +24,7 @@
#include "gtkcssanimationprivate.h"
#include "gtkcssarrayvalueprivate.h"
#include "gtkcsscustompropertypoolprivate.h"
#include "gtkcssenumvalueprivate.h"
#include "gtkcssinheritvalueprivate.h"
#include "gtkcssinitialvalueprivate.h"
@@ -74,6 +75,9 @@ gtk_css_style_finalize (GObject *object)
gtk_css_values_unref ((GtkCssValues *)style->size);
gtk_css_values_unref ((GtkCssValues *)style->other);
if (style->variables)
gtk_css_variable_set_unref (style->variables);
G_OBJECT_CLASS (gtk_css_style_parent_class)->finalize (object);
}
@@ -312,6 +316,15 @@ gtk_css_style_get_static_style (GtkCssStyle *style)
return GTK_CSS_STYLE_GET_CLASS (style)->get_static_style (style);
}
GtkCssValue *
gtk_css_style_get_original_value (GtkCssStyle *style,
guint id)
{
gtk_internal_return_val_if_fail (GTK_IS_CSS_STYLE (style), NULL);
return GTK_CSS_STYLE_GET_CLASS (style)->get_original_value (style, id);
}
/*
* gtk_css_style_print:
* @style: a `GtkCssStyle`
@@ -354,7 +367,7 @@ gtk_css_style_print (GtkCssStyle *style,
value = gtk_css_style_get_value (style, i);
g_string_append_printf (string, "%*s%s: ", indent, "", name);
_gtk_css_value_print (value, string);
gtk_css_value_print (value, string);
g_string_append_c (string, ';');
if (section)
@@ -369,6 +382,43 @@ gtk_css_style_print (GtkCssStyle *style,
retval = TRUE;
}
if (style->variables)
{
GtkCssCustomPropertyPool *pool = gtk_css_custom_property_pool_get ();
GArray *ids = gtk_css_variable_set_list_ids (style->variables);
for (i = 0; i < ids->len; i++)
{
int id = g_array_index (ids, int, i);
const char *name = gtk_css_custom_property_pool_get_name (pool, id);
GtkCssVariableSet *source;
GtkCssVariableValue *value = gtk_css_variable_set_lookup (style->variables, id, &source);
if (!value)
continue;
if (source != style->variables && skip_initial)
continue;
g_string_append_printf (string, "%*s%s: ", indent, "", name);
gtk_css_variable_value_print (value, string);
g_string_append_c (string, ';');
if (value->section)
{
g_string_append (string, " /* ");
gtk_css_section_print (value->section, string);
g_string_append (string, " */");
}
g_string_append_c (string, '\n');
}
retval = TRUE;
g_array_unref (ids);
}
return retval;
}
@@ -865,3 +915,22 @@ gtk_css_values_new (GtkCssValuesType type)
return values;
}
GtkCssVariableValue *
gtk_css_style_get_custom_property (GtkCssStyle *style,
int id)
{
if (style->variables)
return gtk_css_variable_set_lookup (style->variables, id, NULL);
return NULL;
}
GArray *
gtk_css_style_list_custom_properties (GtkCssStyle *style)
{
if (style->variables)
return gtk_css_variable_set_list_ids (style->variables);
return NULL;
}

View File

@@ -102,6 +102,12 @@ compute_change (GtkCssStyleChange *change)
change->new_style,
&change->changes,
&change->affects);
if (change->old_style->variables != change->new_style->variables)
gtk_css_custom_values_compute_changes_and_affects (change->old_style,
change->new_style,
&change->changes,
&change->affects);
}
void
@@ -180,12 +186,12 @@ gtk_css_style_change_print (GtkCssStyleChange *change,
g_string_append_printf (string, "%s: ", name);
value = gtk_css_style_get_value (old, i);
_gtk_css_value_print (value, string);
gtk_css_value_print (value, string);
g_string_append (string, "\n");
g_string_append_printf (string, "%s: ", name);
value = gtk_css_style_get_value (new, i);
_gtk_css_value_print (value, string);
gtk_css_value_print (value, string);
g_string_append (string, "\n");
}
}

View File

@@ -24,6 +24,8 @@
#include "gtk/gtkbitmaskprivate.h"
#include "gtk/gtkcssvalueprivate.h"
#include "gtk/gtkcssvariablesetprivate.h"
#include "gtk/css/gtkcssvariablevalueprivate.h"
G_BEGIN_DECLS
@@ -232,6 +234,10 @@ struct _GtkCssStyle
GtkCssTransitionValues *transition;
GtkCssSizeValues *size;
GtkCssOtherValues *other;
GtkCssVariableSet *variables;
GtkCssValue *variable_values;
int n_variable_values;
};
struct _GtkCssStyleClass
@@ -246,6 +252,9 @@ struct _GtkCssStyleClass
gboolean (* is_static) (GtkCssStyle *style);
GtkCssStaticStyle * (* get_static_style) (GtkCssStyle *style);
GtkCssValue * (* get_original_value) (GtkCssStyle *style,
guint id);
};
GType gtk_css_style_get_type (void) G_GNUC_CONST;
@@ -257,6 +266,9 @@ GtkCssSection * gtk_css_style_get_section (GtkCssStyle
gboolean gtk_css_style_is_static (GtkCssStyle *style) G_GNUC_PURE;
GtkCssStaticStyle * gtk_css_style_get_static_style (GtkCssStyle *style);
GtkCssValue * gtk_css_style_get_original_value (GtkCssStyle *style,
guint id) G_GNUC_PURE;
char * gtk_css_style_to_string (GtkCssStyle *style);
gboolean gtk_css_style_print (GtkCssStyle *style,
GString *string,
@@ -271,6 +283,10 @@ PangoFontDescription * gtk_css_style_get_pango_font (GtkCssStyle
void gtk_css_style_lookup_symbolic_colors (GtkCssStyle *style,
GdkRGBA color_out[4]);
GtkCssVariableValue * gtk_css_style_get_custom_property (GtkCssStyle *style,
int id);
GArray * gtk_css_style_list_custom_properties (GtkCssStyle *style);
GtkCssValues *gtk_css_values_new (GtkCssValuesType type);
GtkCssValues *gtk_css_values_ref (GtkCssValues *values);
void gtk_css_values_unref (GtkCssValues *values);
@@ -320,6 +336,10 @@ void gtk_css_other_values_compute_changes_and_affects (GtkCssStyle *style1,
GtkCssStyle *style2,
GtkBitmask **changes,
GtkCssAffects *affects);
void gtk_css_custom_values_compute_changes_and_affects (GtkCssStyle *style1,
GtkCssStyle *style2,
GtkBitmask **changes,
GtkCssAffects *affects);
G_END_DECLS

View File

@@ -84,7 +84,7 @@ gtk_css_style_property_register (const char * name,
node->parse_value = parse_value;
_gtk_css_value_unref (initial_value);
gtk_css_value_unref (initial_value);
g_assert (_gtk_css_style_property_get_id (node) == expected_id);
}
@@ -95,7 +95,7 @@ static GtkCssValue *
color_parse (GtkCssStyleProperty *property,
GtkCssParser *parser)
{
return _gtk_css_color_value_parse (parser);
return gtk_css_color_value_parse (parser);
}
static GtkCssValue *
@@ -921,7 +921,7 @@ _gtk_css_style_property_init_properties (void)
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_TEXT_ATTRS,
color_parse,
_gtk_css_color_value_new_current_color ());
gtk_css_color_value_new_current_color ());
gtk_css_style_property_register ("text-decoration-style",
GTK_CSS_PROPERTY_TEXT_DECORATION_STYLE,
0,
@@ -1168,31 +1168,31 @@ _gtk_css_style_property_init_properties (void)
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_BORDER,
color_parse,
_gtk_css_color_value_new_current_color ());
gtk_css_color_value_new_current_color ());
gtk_css_style_property_register ("border-right-color",
GTK_CSS_PROPERTY_BORDER_RIGHT_COLOR,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_BORDER,
color_parse,
_gtk_css_color_value_new_current_color ());
gtk_css_color_value_new_current_color ());
gtk_css_style_property_register ("border-bottom-color",
GTK_CSS_PROPERTY_BORDER_BOTTOM_COLOR,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_BORDER,
color_parse,
_gtk_css_color_value_new_current_color ());
gtk_css_color_value_new_current_color ());
gtk_css_style_property_register ("border-left-color",
GTK_CSS_PROPERTY_BORDER_LEFT_COLOR,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_BORDER,
color_parse,
_gtk_css_color_value_new_current_color ());
gtk_css_color_value_new_current_color ());
gtk_css_style_property_register ("outline-color",
GTK_CSS_PROPERTY_OUTLINE_COLOR,
GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_OUTLINE,
color_parse,
_gtk_css_color_value_new_current_color ());
gtk_css_color_value_new_current_color ());
gtk_css_style_property_register ("background-repeat",
GTK_CSS_PROPERTY_BACKGROUND_REPEAT,
@@ -1410,13 +1410,13 @@ _gtk_css_style_property_init_properties (void)
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_CONTENT,
color_parse,
_gtk_css_color_value_new_current_color ());
gtk_css_color_value_new_current_color ());
gtk_css_style_property_register ("-gtk-secondary-caret-color",
GTK_CSS_PROPERTY_SECONDARY_CARET_COLOR,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_CONTENT,
color_parse,
_gtk_css_color_value_new_current_color ());
gtk_css_color_value_new_current_color ());
gtk_css_style_property_register ("font-feature-settings",
GTK_CSS_PROPERTY_FONT_FEATURE_SETTINGS,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
@@ -1434,5 +1434,5 @@ _gtk_css_style_property_init_properties (void)
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
GTK_CSS_AFFECTS_TEXT_ATTRS | GTK_CSS_AFFECTS_TEXT_SIZE,
parse_line_height,
_gtk_css_value_ref (gtk_css_line_height_value_get_default ()));
gtk_css_value_ref (gtk_css_line_height_value_get_default ()));
}

View File

@@ -90,33 +90,33 @@ gtk_css_transform_clear (GtkCssTransform *transform)
case GTK_CSS_TRANSFORM_MATRIX:
break;
case GTK_CSS_TRANSFORM_TRANSLATE:
_gtk_css_value_unref (transform->translate.x);
_gtk_css_value_unref (transform->translate.y);
_gtk_css_value_unref (transform->translate.z);
gtk_css_value_unref (transform->translate.x);
gtk_css_value_unref (transform->translate.y);
gtk_css_value_unref (transform->translate.z);
break;
case GTK_CSS_TRANSFORM_ROTATE:
_gtk_css_value_unref (transform->rotate.x);
_gtk_css_value_unref (transform->rotate.y);
_gtk_css_value_unref (transform->rotate.z);
_gtk_css_value_unref (transform->rotate.angle);
gtk_css_value_unref (transform->rotate.x);
gtk_css_value_unref (transform->rotate.y);
gtk_css_value_unref (transform->rotate.z);
gtk_css_value_unref (transform->rotate.angle);
break;
case GTK_CSS_TRANSFORM_SCALE:
_gtk_css_value_unref (transform->scale.x);
_gtk_css_value_unref (transform->scale.y);
_gtk_css_value_unref (transform->scale.z);
gtk_css_value_unref (transform->scale.x);
gtk_css_value_unref (transform->scale.y);
gtk_css_value_unref (transform->scale.z);
break;
case GTK_CSS_TRANSFORM_SKEW:
_gtk_css_value_unref (transform->skew.x);
_gtk_css_value_unref (transform->skew.y);
gtk_css_value_unref (transform->skew.x);
gtk_css_value_unref (transform->skew.y);
break;
case GTK_CSS_TRANSFORM_SKEW_X:
_gtk_css_value_unref (transform->skew_x.skew);
gtk_css_value_unref (transform->skew_x.skew);
break;
case GTK_CSS_TRANSFORM_SKEW_Y:
_gtk_css_value_unref (transform->skew_y.skew);
gtk_css_value_unref (transform->skew_y.skew);
break;
case GTK_CSS_TRANSFORM_PERSPECTIVE:
_gtk_css_value_unref (transform->perspective.depth);
gtk_css_value_unref (transform->perspective.depth);
break;
case GTK_CSS_TRANSFORM_NONE:
default:
@@ -273,12 +273,10 @@ gtk_css_value_transform_free (GtkCssValue *value)
/* returns TRUE if dest == src */
static gboolean
gtk_css_transform_compute (GtkCssTransform *dest,
GtkCssTransform *src,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_transform_compute (GtkCssTransform *dest,
GtkCssTransform *src,
guint property_id,
GtkCssComputeContext *context)
{
dest->type = src->type;
@@ -288,41 +286,41 @@ gtk_css_transform_compute (GtkCssTransform *dest,
memcpy (dest, src, sizeof (GtkCssTransform));
return TRUE;
case GTK_CSS_TRANSFORM_TRANSLATE:
dest->translate.x = _gtk_css_value_compute (src->translate.x, property_id, provider, style, parent_style);
dest->translate.y = _gtk_css_value_compute (src->translate.y, property_id, provider, style, parent_style);
dest->translate.z = _gtk_css_value_compute (src->translate.z, property_id, provider, style, parent_style);
dest->translate.x = gtk_css_value_compute (src->translate.x, property_id, context);
dest->translate.y = gtk_css_value_compute (src->translate.y, property_id, context);
dest->translate.z = gtk_css_value_compute (src->translate.z, property_id, context);
return dest->translate.x == src->translate.x
&& dest->translate.y == src->translate.y
&& dest->translate.z == src->translate.z;
case GTK_CSS_TRANSFORM_ROTATE:
dest->rotate.x = _gtk_css_value_compute (src->rotate.x, property_id, provider, style, parent_style);
dest->rotate.y = _gtk_css_value_compute (src->rotate.y, property_id, provider, style, parent_style);
dest->rotate.z = _gtk_css_value_compute (src->rotate.z, property_id, provider, style, parent_style);
dest->rotate.angle = _gtk_css_value_compute (src->rotate.angle, property_id, provider, style, parent_style);
dest->rotate.x = gtk_css_value_compute (src->rotate.x, property_id, context);
dest->rotate.y = gtk_css_value_compute (src->rotate.y, property_id, context);
dest->rotate.z = gtk_css_value_compute (src->rotate.z, property_id, context);
dest->rotate.angle = gtk_css_value_compute (src->rotate.angle, property_id, context);
return dest->rotate.x == src->rotate.x
&& dest->rotate.y == src->rotate.y
&& dest->rotate.z == src->rotate.z
&& dest->rotate.angle == src->rotate.angle;
case GTK_CSS_TRANSFORM_SCALE:
dest->scale.x = _gtk_css_value_compute (src->scale.x, property_id, provider, style, parent_style);
dest->scale.y = _gtk_css_value_compute (src->scale.y, property_id, provider, style, parent_style);
dest->scale.z = _gtk_css_value_compute (src->scale.z, property_id, provider, style, parent_style);
dest->scale.x = gtk_css_value_compute (src->scale.x, property_id, context);
dest->scale.y = gtk_css_value_compute (src->scale.y, property_id, context);
dest->scale.z = gtk_css_value_compute (src->scale.z, property_id, context);
return dest->scale.x == src->scale.x
&& dest->scale.y == src->scale.y
&& dest->scale.z == src->scale.z;
case GTK_CSS_TRANSFORM_SKEW:
dest->skew.x = _gtk_css_value_compute (src->skew.x, property_id, provider, style, parent_style);
dest->skew.y = _gtk_css_value_compute (src->skew.y, property_id, provider, style, parent_style);
dest->skew.x = gtk_css_value_compute (src->skew.x, property_id, context);
dest->skew.y = gtk_css_value_compute (src->skew.y, property_id, context);
return dest->skew.x == src->skew.x
&& dest->skew.y == src->skew.y;
case GTK_CSS_TRANSFORM_SKEW_X:
dest->skew_x.skew = _gtk_css_value_compute (src->skew_x.skew, property_id, provider, style, parent_style);
dest->skew_x.skew = gtk_css_value_compute (src->skew_x.skew, property_id, context);
return dest->skew_x.skew == src->skew_x.skew;
case GTK_CSS_TRANSFORM_SKEW_Y:
dest->skew_y.skew = _gtk_css_value_compute (src->skew_y.skew, property_id, provider, style, parent_style);
dest->skew_y.skew = gtk_css_value_compute (src->skew_y.skew, property_id, context);
return dest->skew_y.skew == src->skew_y.skew;
case GTK_CSS_TRANSFORM_PERSPECTIVE:
dest->perspective.depth = _gtk_css_value_compute (src->perspective.depth, property_id, provider, style, parent_style);
dest->perspective.depth = gtk_css_value_compute (src->perspective.depth, property_id, context);
return dest->perspective.depth == src->perspective.depth;
case GTK_CSS_TRANSFORM_NONE:
default:
@@ -332,11 +330,9 @@ gtk_css_transform_compute (GtkCssTransform *dest,
}
static GtkCssValue *
gtk_css_value_transform_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_value_transform_compute (GtkCssValue *value,
guint property_id,
GtkCssComputeContext *context)
{
GtkCssValue *result;
gboolean changes;
@@ -344,7 +340,7 @@ gtk_css_value_transform_compute (GtkCssValue *value,
/* Special case the 99% case of "none" */
if (gtk_css_transform_value_is_none (value))
return _gtk_css_value_ref (value);
return gtk_css_value_ref (value);
changes = FALSE;
result = gtk_css_transform_value_alloc (value->n_transforms);
@@ -354,15 +350,13 @@ gtk_css_value_transform_compute (GtkCssValue *value,
changes |= !gtk_css_transform_compute (&result->transforms[i],
&value->transforms[i],
property_id,
provider,
style,
parent_style);
context);
}
if (!changes)
{
_gtk_css_value_unref (result);
result = _gtk_css_value_ref (value);
gtk_css_value_unref (result);
result = gtk_css_value_ref (value);
}
return result;
@@ -391,27 +385,27 @@ gtk_css_transform_equal (const GtkCssTransform *transform1,
return TRUE;
}
case GTK_CSS_TRANSFORM_TRANSLATE:
return _gtk_css_value_equal (transform1->translate.x, transform2->translate.x)
&& _gtk_css_value_equal (transform1->translate.y, transform2->translate.y)
&& _gtk_css_value_equal (transform1->translate.z, transform2->translate.z);
return gtk_css_value_equal (transform1->translate.x, transform2->translate.x)
&& gtk_css_value_equal (transform1->translate.y, transform2->translate.y)
&& gtk_css_value_equal (transform1->translate.z, transform2->translate.z);
case GTK_CSS_TRANSFORM_ROTATE:
return _gtk_css_value_equal (transform1->rotate.x, transform2->rotate.x)
&& _gtk_css_value_equal (transform1->rotate.y, transform2->rotate.y)
&& _gtk_css_value_equal (transform1->rotate.z, transform2->rotate.z)
&& _gtk_css_value_equal (transform1->rotate.angle, transform2->rotate.angle);
return gtk_css_value_equal (transform1->rotate.x, transform2->rotate.x)
&& gtk_css_value_equal (transform1->rotate.y, transform2->rotate.y)
&& gtk_css_value_equal (transform1->rotate.z, transform2->rotate.z)
&& gtk_css_value_equal (transform1->rotate.angle, transform2->rotate.angle);
case GTK_CSS_TRANSFORM_SCALE:
return _gtk_css_value_equal (transform1->scale.x, transform2->scale.x)
&& _gtk_css_value_equal (transform1->scale.y, transform2->scale.y)
&& _gtk_css_value_equal (transform1->scale.z, transform2->scale.z);
return gtk_css_value_equal (transform1->scale.x, transform2->scale.x)
&& gtk_css_value_equal (transform1->scale.y, transform2->scale.y)
&& gtk_css_value_equal (transform1->scale.z, transform2->scale.z);
case GTK_CSS_TRANSFORM_SKEW:
return _gtk_css_value_equal (transform1->skew.x, transform2->skew.x)
&& _gtk_css_value_equal (transform1->skew.y, transform2->skew.y);
return gtk_css_value_equal (transform1->skew.x, transform2->skew.x)
&& gtk_css_value_equal (transform1->skew.y, transform2->skew.y);
case GTK_CSS_TRANSFORM_SKEW_X:
return _gtk_css_value_equal (transform1->skew_x.skew, transform2->skew_x.skew);
return gtk_css_value_equal (transform1->skew_x.skew, transform2->skew_x.skew);
case GTK_CSS_TRANSFORM_SKEW_Y:
return _gtk_css_value_equal (transform1->skew_y.skew, transform2->skew_y.skew);
return gtk_css_value_equal (transform1->skew_y.skew, transform2->skew_y.skew);
case GTK_CSS_TRANSFORM_PERSPECTIVE:
return _gtk_css_value_equal (transform1->perspective.depth, transform2->perspective.depth);
return gtk_css_value_equal (transform1->perspective.depth, transform2->perspective.depth);
case GTK_CSS_TRANSFORM_NONE:
default:
g_assert_not_reached ();
@@ -504,30 +498,30 @@ gtk_css_transform_transition (GtkCssTransform *result,
&result->matrix.matrix);
break;
case GTK_CSS_TRANSFORM_TRANSLATE:
result->translate.x = _gtk_css_value_transition (start->translate.x, end->translate.x, property_id, progress);
result->translate.y = _gtk_css_value_transition (start->translate.y, end->translate.y, property_id, progress);
result->translate.z = _gtk_css_value_transition (start->translate.z, end->translate.z, property_id, progress);
result->translate.x = gtk_css_value_transition (start->translate.x, end->translate.x, property_id, progress);
result->translate.y = gtk_css_value_transition (start->translate.y, end->translate.y, property_id, progress);
result->translate.z = gtk_css_value_transition (start->translate.z, end->translate.z, property_id, progress);
break;
case GTK_CSS_TRANSFORM_ROTATE:
result->rotate.x = _gtk_css_value_transition (start->rotate.x, end->rotate.x, property_id, progress);
result->rotate.y = _gtk_css_value_transition (start->rotate.y, end->rotate.y, property_id, progress);
result->rotate.z = _gtk_css_value_transition (start->rotate.z, end->rotate.z, property_id, progress);
result->rotate.angle = _gtk_css_value_transition (start->rotate.angle, end->rotate.angle, property_id, progress);
result->rotate.x = gtk_css_value_transition (start->rotate.x, end->rotate.x, property_id, progress);
result->rotate.y = gtk_css_value_transition (start->rotate.y, end->rotate.y, property_id, progress);
result->rotate.z = gtk_css_value_transition (start->rotate.z, end->rotate.z, property_id, progress);
result->rotate.angle = gtk_css_value_transition (start->rotate.angle, end->rotate.angle, property_id, progress);
break;
case GTK_CSS_TRANSFORM_SCALE:
result->scale.x = _gtk_css_value_transition (start->scale.x, end->scale.x, property_id, progress);
result->scale.y = _gtk_css_value_transition (start->scale.y, end->scale.y, property_id, progress);
result->scale.z = _gtk_css_value_transition (start->scale.z, end->scale.z, property_id, progress);
result->scale.x = gtk_css_value_transition (start->scale.x, end->scale.x, property_id, progress);
result->scale.y = gtk_css_value_transition (start->scale.y, end->scale.y, property_id, progress);
result->scale.z = gtk_css_value_transition (start->scale.z, end->scale.z, property_id, progress);
break;
case GTK_CSS_TRANSFORM_SKEW:
result->skew.x = _gtk_css_value_transition (start->skew.x, end->skew.x, property_id, progress);
result->skew.y = _gtk_css_value_transition (start->skew.y, end->skew.y, property_id, progress);
result->skew.x = gtk_css_value_transition (start->skew.x, end->skew.x, property_id, progress);
result->skew.y = gtk_css_value_transition (start->skew.y, end->skew.y, property_id, progress);
break;
case GTK_CSS_TRANSFORM_SKEW_X:
result->skew_x.skew = _gtk_css_value_transition (start->skew_x.skew, end->skew_x.skew, property_id, progress);
result->skew_x.skew = gtk_css_value_transition (start->skew_x.skew, end->skew_x.skew, property_id, progress);
break;
case GTK_CSS_TRANSFORM_SKEW_Y:
result->skew_y.skew = _gtk_css_value_transition (start->skew_y.skew, end->skew_y.skew, property_id, progress);
result->skew_y.skew = gtk_css_value_transition (start->skew_y.skew, end->skew_y.skew, property_id, progress);
break;
case GTK_CSS_TRANSFORM_PERSPECTIVE:
gtk_css_transform_transition_default (result, start, end, property_id, progress);
@@ -551,7 +545,7 @@ gtk_css_value_transform_transition (GtkCssValue *start,
if (gtk_css_transform_value_is_none (start))
{
if (gtk_css_transform_value_is_none (end))
return _gtk_css_value_ref (start);
return gtk_css_value_ref (start);
n = 0;
}
@@ -699,67 +693,67 @@ gtk_css_transform_print (const GtkCssTransform *transform,
break;
case GTK_CSS_TRANSFORM_TRANSLATE:
g_string_append (string, "translate3d(");
_gtk_css_value_print (transform->translate.x, string);
gtk_css_value_print (transform->translate.x, string);
g_string_append (string, ", ");
_gtk_css_value_print (transform->translate.y, string);
gtk_css_value_print (transform->translate.y, string);
g_string_append (string, ", ");
_gtk_css_value_print (transform->translate.z, string);
gtk_css_value_print (transform->translate.z, string);
g_string_append (string, ")");
break;
case GTK_CSS_TRANSFORM_ROTATE:
g_string_append (string, "rotate3d(");
_gtk_css_value_print (transform->rotate.x, string);
gtk_css_value_print (transform->rotate.x, string);
g_string_append (string, ", ");
_gtk_css_value_print (transform->rotate.y, string);
gtk_css_value_print (transform->rotate.y, string);
g_string_append (string, ", ");
_gtk_css_value_print (transform->rotate.z, string);
gtk_css_value_print (transform->rotate.z, string);
g_string_append (string, ", ");
_gtk_css_value_print (transform->rotate.angle, string);
gtk_css_value_print (transform->rotate.angle, string);
g_string_append (string, ")");
break;
case GTK_CSS_TRANSFORM_SCALE:
if (_gtk_css_number_value_get (transform->scale.z, 100) == 1)
{
g_string_append (string, "scale(");
_gtk_css_value_print (transform->scale.x, string);
if (!_gtk_css_value_equal (transform->scale.x, transform->scale.y))
gtk_css_value_print (transform->scale.x, string);
if (!gtk_css_value_equal (transform->scale.x, transform->scale.y))
{
g_string_append (string, ", ");
_gtk_css_value_print (transform->scale.y, string);
gtk_css_value_print (transform->scale.y, string);
}
g_string_append (string, ")");
}
else
{
g_string_append (string, "scale3d(");
_gtk_css_value_print (transform->scale.x, string);
gtk_css_value_print (transform->scale.x, string);
g_string_append (string, ", ");
_gtk_css_value_print (transform->scale.y, string);
gtk_css_value_print (transform->scale.y, string);
g_string_append (string, ", ");
_gtk_css_value_print (transform->scale.z, string);
gtk_css_value_print (transform->scale.z, string);
g_string_append (string, ")");
}
break;
case GTK_CSS_TRANSFORM_SKEW:
g_string_append (string, "skew(");
_gtk_css_value_print (transform->skew.x, string);
gtk_css_value_print (transform->skew.x, string);
g_string_append (string, ", ");
_gtk_css_value_print (transform->skew.y, string);
gtk_css_value_print (transform->skew.y, string);
g_string_append (string, ")");
break;
case GTK_CSS_TRANSFORM_SKEW_X:
g_string_append (string, "skewX(");
_gtk_css_value_print (transform->skew_x.skew, string);
gtk_css_value_print (transform->skew_x.skew, string);
g_string_append (string, ")");
break;
case GTK_CSS_TRANSFORM_SKEW_Y:
g_string_append (string, "skewY(");
_gtk_css_value_print (transform->skew_y.skew, string);
gtk_css_value_print (transform->skew_y.skew, string);
g_string_append (string, ")");
break;
case GTK_CSS_TRANSFORM_PERSPECTIVE:
g_string_append (string, "perspective(");
_gtk_css_value_print (transform->perspective.depth, string);
gtk_css_value_print (transform->perspective.depth, string);
g_string_append (string, ")");
break;
case GTK_CSS_TRANSFORM_NONE:
@@ -801,7 +795,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_TRANSFORM = {
gtk_css_value_transform_print
};
static GtkCssValue transform_none_singleton = { &GTK_CSS_VALUE_TRANSFORM, 1, TRUE, 0, { { GTK_CSS_TRANSFORM_NONE } } };
static GtkCssValue transform_none_singleton = { &GTK_CSS_VALUE_TRANSFORM, 1, TRUE, FALSE, 0, { { GTK_CSS_TRANSFORM_NONE } } };
static GtkCssValue *
gtk_css_transform_value_alloc (guint n_transforms)
@@ -810,7 +804,7 @@ gtk_css_transform_value_alloc (guint n_transforms)
g_return_val_if_fail (n_transforms > 0, NULL);
result = _gtk_css_value_alloc (&GTK_CSS_VALUE_TRANSFORM, sizeof (GtkCssValue) + sizeof (GtkCssTransform) * (n_transforms - 1));
result = gtk_css_value_alloc (&GTK_CSS_VALUE_TRANSFORM, sizeof (GtkCssValue) + sizeof (GtkCssTransform) * (n_transforms - 1));
result->n_transforms = n_transforms;
return result;
@@ -819,7 +813,7 @@ gtk_css_transform_value_alloc (guint n_transforms)
GtkCssValue *
_gtk_css_transform_value_new_none (void)
{
return _gtk_css_value_ref (&transform_none_singleton);
return gtk_css_value_ref (&transform_none_singleton);
}
static gboolean

View File

@@ -57,22 +57,22 @@ gtk_css_transition_apply_values (GtkStyleAnimation *style_animation,
state = gtk_progress_tracker_get_state (&transition->tracker);
if (state == GTK_PROGRESS_STATE_BEFORE)
value = _gtk_css_value_ref (transition->start);
value = gtk_css_value_ref (transition->start);
else if (state == GTK_PROGRESS_STATE_DURING)
{
progress = gtk_progress_tracker_get_progress (&transition->tracker, FALSE);
progress = _gtk_css_ease_value_transform (transition->ease, progress);
value = _gtk_css_value_transition (transition->start,
end,
transition->property,
progress);
value = gtk_css_value_transition (transition->start,
end,
transition->property,
progress);
}
else
return;
if (value == NULL)
value = _gtk_css_value_ref (end);
value = gtk_css_value_ref (end);
gtk_css_animated_style_set_animated_value (style, transition->property, value);
}
@@ -124,8 +124,8 @@ gtk_css_transition_advance (GtkStyleAnimation *style_animation,
transition->parent.ref_count = 1;
transition->property = source->property;
transition->start = _gtk_css_value_ref (source->start);
transition->ease = _gtk_css_value_ref (source->ease);
transition->start = gtk_css_value_ref (source->start);
transition->ease = gtk_css_value_ref (source->ease);
gtk_progress_tracker_init_copy (&source->tracker, &transition->tracker);
gtk_progress_tracker_advance_frame (&transition->tracker, timestamp);
@@ -151,8 +151,8 @@ _gtk_css_transition_new (guint property,
transition->parent.ref_count = 1;
transition->property = property;
transition->start = _gtk_css_value_ref (start);
transition->ease = _gtk_css_value_ref (ease);
transition->start = gtk_css_value_ref (start);
transition->ease = gtk_css_value_ref (ease);
gtk_progress_tracker_start (&transition->tracker, duration_us, delay_us, 1.0);
gtk_progress_tracker_advance_frame (&transition->tracker, timestamp);
transition->finished = gtk_progress_tracker_get_state (&transition->tracker) == GTK_PROGRESS_STATE_AFTER;

View File

@@ -277,7 +277,33 @@ enum { /*< skip >*/
GTK_CSS_PROPERTY_FONT_VARIATION_SETTINGS,
GTK_CSS_PROPERTY_LINE_HEIGHT,
/* add more */
GTK_CSS_PROPERTY_N_PROPERTIES
GTK_CSS_PROPERTY_N_PROPERTIES,
GTK_CSS_PROPERTY_CUSTOM,
};
enum {
GTK_CSS_SHORTHAND_PROPERTY_FONT,
GTK_CSS_SHORTHAND_PROPERTY_MARGIN,
GTK_CSS_SHORTHAND_PROPERTY_PADDING,
GTK_CSS_SHORTHAND_PROPERTY_BORDER_WIDTH,
GTK_CSS_SHORTHAND_PROPERTY_BORDER_RADIUS,
GTK_CSS_SHORTHAND_PROPERTY_BORDER_COLOR,
GTK_CSS_SHORTHAND_PROPERTY_BORDER_STYLE,
GTK_CSS_SHORTHAND_PROPERTY_BORDER_IMAGE,
GTK_CSS_SHORTHAND_PROPERTY_BORDER_TOP,
GTK_CSS_SHORTHAND_PROPERTY_BORDER_RIGHT,
GTK_CSS_SHORTHAND_PROPERTY_BORDER_BOTTOM,
GTK_CSS_SHORTHAND_PROPERTY_BORDER_LEFT,
GTK_CSS_SHORTHAND_PROPERTY_BORDER,
GTK_CSS_SHORTHAND_PROPERTY_OUTLINE,
GTK_CSS_SHORTHAND_PROPERTY_BACKGROUND,
GTK_CSS_SHORTHAND_PROPERTY_TRANSITION,
GTK_CSS_SHORTHAND_PROPERTY_ANIMATION,
GTK_CSS_SHORTHAND_PROPERTY_TEXT_DECORATION,
GTK_CSS_SHORTHAND_PROPERTY_FONT_VARIANT,
GTK_CSS_SHORTHAND_PROPERTY_ALL,
/* add more */
GTK_CSS_SHORTHAND_PROPERTY_N_PROPERTIES,
};
typedef enum /*< skip >*/ {

View File

@@ -35,11 +35,9 @@ gtk_css_value_unset_free (GtkCssValue *value)
}
static GtkCssValue *
gtk_css_value_unset_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_value_unset_compute (GtkCssValue *value,
guint property_id,
GtkCssComputeContext *context)
{
GtkCssStyleProperty *property;
GtkCssValue *unset_value;
@@ -51,11 +49,7 @@ gtk_css_value_unset_compute (GtkCssValue *value,
else
unset_value = _gtk_css_initial_value_get ();
return _gtk_css_value_compute (unset_value,
property_id,
provider,
style,
parent_style);
return gtk_css_value_compute (unset_value, property_id, context);
}
static gboolean
@@ -97,5 +91,5 @@ static GtkCssValue unset = { &GTK_CSS_VALUE_UNSET, 1 };
GtkCssValue *
_gtk_css_unset_value_new (void)
{
return _gtk_css_value_ref (&unset);
return gtk_css_value_ref (&unset);
}

View File

@@ -27,7 +27,7 @@ struct _GtkCssValue {
GTK_CSS_VALUE_BASE
};
G_DEFINE_BOXED_TYPE (GtkCssValue, _gtk_css_value, _gtk_css_value_ref, _gtk_css_value_unref)
G_DEFINE_BOXED_TYPE (GtkCssValue, gtk_css_value, gtk_css_value_ref, gtk_css_value_unref)
#undef CSS_VALUE_ACCOUNTING
@@ -137,8 +137,8 @@ get_accounting_data (const char *class)
#endif
GtkCssValue *
_gtk_css_value_alloc (const GtkCssValueClass *klass,
gsize size)
gtk_css_value_alloc (const GtkCssValueClass *klass,
gsize size)
{
GtkCssValue *value;
@@ -161,7 +161,7 @@ _gtk_css_value_alloc (const GtkCssValueClass *klass,
}
GtkCssValue *
gtk_css_value_ref (GtkCssValue *value)
(gtk_css_value_ref) (GtkCssValue *value)
{
gtk_internal_return_val_if_fail (value != NULL, NULL);
@@ -171,7 +171,7 @@ gtk_css_value_ref (GtkCssValue *value)
}
void
gtk_css_value_unref (GtkCssValue *value)
(gtk_css_value_unref) (GtkCssValue *value)
{
if (value == NULL)
return;
@@ -193,12 +193,14 @@ gtk_css_value_unref (GtkCssValue *value)
}
/**
* _gtk_css_value_compute:
* gtk_css_value_compute:
* @value: the value to compute from
* @property_id: the ID of the property to compute
* @provider: Style provider for looking up extra information
* @style: Style to compute for
* @parent_style: parent style to use for inherited values
* @variables: an additional set of variables to use along with @style
* @shorthands: (nullable): Already computed values for shorthands
*
* Converts the specified @value into the computed value for the CSS
* property given by @property_id using the information in @context.
@@ -208,25 +210,23 @@ gtk_css_value_unref (GtkCssValue *value)
* Returns: the computed value
**/
GtkCssValue *
_gtk_css_value_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_value_compute (GtkCssValue *value,
guint property_id,
GtkCssComputeContext *context)
{
if (gtk_css_value_is_computed (value))
return _gtk_css_value_ref (value);
return gtk_css_value_ref (value);
#ifdef CSS_VALUE_ACCOUNTING
get_accounting_data (value->class->type_name)->computed++;
#endif
return value->class->compute (value, property_id, provider, style, parent_style);
return value->class->compute (value, property_id, context);
}
gboolean
_gtk_css_value_equal (const GtkCssValue *value1,
const GtkCssValue *value2)
gtk_css_value_equal (const GtkCssValue *value1,
const GtkCssValue *value2)
{
gtk_internal_return_val_if_fail (value1 != NULL, FALSE);
gtk_internal_return_val_if_fail (value2 != NULL, FALSE);
@@ -241,8 +241,8 @@ _gtk_css_value_equal (const GtkCssValue *value1,
}
gboolean
_gtk_css_value_equal0 (const GtkCssValue *value1,
const GtkCssValue *value2)
gtk_css_value_equal0 (const GtkCssValue *value1,
const GtkCssValue *value2)
{
/* Includes both values being NULL */
if (value1 == value2)
@@ -251,14 +251,14 @@ _gtk_css_value_equal0 (const GtkCssValue *value1,
if (value1 == NULL || value2 == NULL)
return FALSE;
return _gtk_css_value_equal (value1, value2);
return gtk_css_value_equal (value1, value2);
}
GtkCssValue *
_gtk_css_value_transition (GtkCssValue *start,
GtkCssValue *end,
guint property_id,
double progress)
gtk_css_value_transition (GtkCssValue *start,
GtkCssValue *end,
guint property_id,
double progress)
{
gtk_internal_return_val_if_fail (start != NULL, NULL);
gtk_internal_return_val_if_fail (end != NULL, NULL);
@@ -267,13 +267,13 @@ _gtk_css_value_transition (GtkCssValue *start,
return NULL;
if (progress == 0)
return _gtk_css_value_ref (start);
return gtk_css_value_ref (start);
if (progress == 1)
return _gtk_css_value_ref (end);
return gtk_css_value_ref (end);
if (start == end)
return _gtk_css_value_ref (start);
return gtk_css_value_ref (start);
#ifdef CSS_VALUE_ACCOUNTING
get_accounting_data (start->class->type_name)->transitioned++;
@@ -283,19 +283,19 @@ _gtk_css_value_transition (GtkCssValue *start,
}
char *
_gtk_css_value_to_string (const GtkCssValue *value)
gtk_css_value_to_string (const GtkCssValue *value)
{
GString *string;
gtk_internal_return_val_if_fail (value != NULL, NULL);
string = g_string_new (NULL);
_gtk_css_value_print (value, string);
gtk_css_value_print (value, string);
return g_string_free (string, FALSE);
}
/**
* _gtk_css_value_print:
* gtk_css_value_print:
* @value: the value to print
* @string: the string to print to
*
@@ -304,8 +304,8 @@ _gtk_css_value_to_string (const GtkCssValue *value)
* via _gtk_style_property_assign().
**/
void
_gtk_css_value_print (const GtkCssValue *value,
GString *string)
gtk_css_value_print (const GtkCssValue *value,
GString *string)
{
gtk_internal_return_if_fail (value != NULL);
gtk_internal_return_if_fail (string != NULL);
@@ -361,9 +361,3 @@ gtk_css_value_get_dynamic_value (GtkCssValue *value,
return value->class->get_dynamic_value (value, monotonic_time);
}
gboolean
gtk_css_value_is_computed (const GtkCssValue *value)
{
return value->is_computed;
}

View File

@@ -22,11 +22,12 @@
#include <glib-object.h>
#include "gtkcsstypesprivate.h"
#include "gtkcssvariablesetprivate.h"
#include "gtkstyleprovider.h"
G_BEGIN_DECLS
#define GTK_TYPE_CSS_VALUE (_gtk_css_value_get_type ())
#define GTK_TYPE_CSS_VALUE (gtk_css_value_get_type ())
/* A GtkCssValue is a refcounted immutable value type */
@@ -37,7 +38,16 @@ typedef struct _GtkCssValueClass GtkCssValueClass;
#define GTK_CSS_VALUE_BASE \
const GtkCssValueClass *class; \
int ref_count; \
guint is_computed: 1;
guint is_computed: 1; \
guint contains_variables: 1;
typedef struct {
GtkStyleProvider *provider;
GtkCssStyle *style;
GtkCssStyle *parent_style;
GtkCssVariableSet *variables;
GtkCssValue **shorthands;
} GtkCssComputeContext;
struct _GtkCssValueClass {
const char *type_name;
@@ -45,9 +55,7 @@ struct _GtkCssValueClass {
GtkCssValue * (* compute) (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style);
GtkCssComputeContext *context);
gboolean (* equal) (const GtkCssValue *value1,
const GtkCssValue *value2);
GtkCssValue * (* transition) (GtkCssValue *start,
@@ -61,38 +69,78 @@ struct _GtkCssValueClass {
GString *string);
};
GType _gtk_css_value_get_type (void) G_GNUC_CONST;
GType gtk_css_value_get_type (void) G_GNUC_CONST;
GtkCssValue *_gtk_css_value_alloc (const GtkCssValueClass *klass,
GtkCssValue * gtk_css_value_alloc (const GtkCssValueClass *klass,
gsize size);
#define _gtk_css_value_new(_name, _klass) ((_name *) _gtk_css_value_alloc ((_klass), sizeof (_name)))
#define gtk_css_value_new(name, klass) ((name *) gtk_css_value_alloc ((klass), sizeof (name)))
#define _gtk_css_value_ref gtk_css_value_ref
GtkCssValue * gtk_css_value_ref (GtkCssValue *value);
#define _gtk_css_value_unref gtk_css_value_unref
void gtk_css_value_unref (GtkCssValue *value);
GtkCssValue * (gtk_css_value_ref) (GtkCssValue *value);
void (gtk_css_value_unref) (GtkCssValue *value);
GtkCssValue *_gtk_css_value_compute (GtkCssValue *value,
GtkCssValue * gtk_css_value_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style) G_GNUC_PURE;
gboolean _gtk_css_value_equal (const GtkCssValue *value1,
GtkCssComputeContext *context) G_GNUC_PURE;
gboolean gtk_css_value_equal (const GtkCssValue *value1,
const GtkCssValue *value2) G_GNUC_PURE;
gboolean _gtk_css_value_equal0 (const GtkCssValue *value1,
gboolean gtk_css_value_equal0 (const GtkCssValue *value1,
const GtkCssValue *value2) G_GNUC_PURE;
GtkCssValue *_gtk_css_value_transition (GtkCssValue *start,
GtkCssValue * gtk_css_value_transition (GtkCssValue *start,
GtkCssValue *end,
guint property_id,
double progress);
gboolean gtk_css_value_is_dynamic (const GtkCssValue *value) G_GNUC_PURE;
GtkCssValue * gtk_css_value_get_dynamic_value (GtkCssValue *value,
gboolean gtk_css_value_is_dynamic (const GtkCssValue *value) G_GNUC_PURE;
GtkCssValue * gtk_css_value_get_dynamic_value (GtkCssValue *value,
gint64 monotonic_time);
char * _gtk_css_value_to_string (const GtkCssValue *value);
void _gtk_css_value_print (const GtkCssValue *value,
char * gtk_css_value_to_string (const GtkCssValue *value);
void gtk_css_value_print (const GtkCssValue *value,
GString *string);
gboolean gtk_css_value_is_computed (const GtkCssValue *value) G_GNUC_PURE;
typedef struct { GTK_CSS_VALUE_BASE } GtkCssValueBase;
static inline GtkCssValue *
gtk_css_value_ref_inline (GtkCssValue *value)
{
GtkCssValueBase *value_base = (GtkCssValueBase *) value;
value_base->ref_count += 1;
return value;
}
static inline void
gtk_css_value_unref_inline (GtkCssValue *value)
{
GtkCssValueBase *value_base = (GtkCssValueBase *) value;
if (value_base && value_base->ref_count > 1)
{
value_base->ref_count -= 1;
return;
}
(gtk_css_value_unref) (value);
}
#define gtk_css_value_ref(value) gtk_css_value_ref_inline (value)
#define gtk_css_value_unref(value) gtk_css_value_unref_inline (value)
static inline gboolean
gtk_css_value_is_computed (const GtkCssValue *value)
{
GtkCssValueBase *value_base = (GtkCssValueBase *) value;
return value_base->is_computed;
}
static inline gboolean
gtk_css_value_contains_variables (const GtkCssValue *value)
{
GtkCssValueBase *value_base = (GtkCssValueBase *) value;
return value_base->contains_variables;
}
G_END_DECLS

151
gtk/gtkcssvaluesprivate.h Normal file
View File

@@ -0,0 +1,151 @@
/*
* Copyright © 2012 Red Hat Inc.
*
* 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>
*/
#pragma once
#include <glib-object.h>
G_BEGIN_DECLS
static const int core_props[] = {
GTK_CSS_PROPERTY_COLOR,
GTK_CSS_PROPERTY_DPI,
GTK_CSS_PROPERTY_FONT_SIZE,
GTK_CSS_PROPERTY_ICON_PALETTE
};
static const int background_props[] = {
GTK_CSS_PROPERTY_BACKGROUND_COLOR,
GTK_CSS_PROPERTY_BOX_SHADOW,
GTK_CSS_PROPERTY_BACKGROUND_CLIP,
GTK_CSS_PROPERTY_BACKGROUND_ORIGIN,
GTK_CSS_PROPERTY_BACKGROUND_SIZE,
GTK_CSS_PROPERTY_BACKGROUND_POSITION,
GTK_CSS_PROPERTY_BACKGROUND_REPEAT,
GTK_CSS_PROPERTY_BACKGROUND_IMAGE,
GTK_CSS_PROPERTY_BACKGROUND_BLEND_MODE
};
static const int border_props[] = {
GTK_CSS_PROPERTY_BORDER_TOP_STYLE,
GTK_CSS_PROPERTY_BORDER_TOP_WIDTH,
GTK_CSS_PROPERTY_BORDER_LEFT_STYLE,
GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH,
GTK_CSS_PROPERTY_BORDER_BOTTOM_STYLE,
GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH,
GTK_CSS_PROPERTY_BORDER_RIGHT_STYLE,
GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH,
GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS,
GTK_CSS_PROPERTY_BORDER_TOP_RIGHT_RADIUS,
GTK_CSS_PROPERTY_BORDER_BOTTOM_RIGHT_RADIUS,
GTK_CSS_PROPERTY_BORDER_BOTTOM_LEFT_RADIUS,
GTK_CSS_PROPERTY_BORDER_TOP_COLOR,
GTK_CSS_PROPERTY_BORDER_RIGHT_COLOR,
GTK_CSS_PROPERTY_BORDER_BOTTOM_COLOR,
GTK_CSS_PROPERTY_BORDER_LEFT_COLOR,
GTK_CSS_PROPERTY_BORDER_IMAGE_SOURCE,
GTK_CSS_PROPERTY_BORDER_IMAGE_REPEAT,
GTK_CSS_PROPERTY_BORDER_IMAGE_SLICE,
GTK_CSS_PROPERTY_BORDER_IMAGE_WIDTH
};
static const int icon_props[] = {
GTK_CSS_PROPERTY_ICON_SIZE,
GTK_CSS_PROPERTY_ICON_SHADOW,
GTK_CSS_PROPERTY_ICON_STYLE,
};
static const int outline_props[] = {
GTK_CSS_PROPERTY_OUTLINE_STYLE,
GTK_CSS_PROPERTY_OUTLINE_WIDTH,
GTK_CSS_PROPERTY_OUTLINE_OFFSET,
GTK_CSS_PROPERTY_OUTLINE_COLOR,
};
static const int font_props[] = {
GTK_CSS_PROPERTY_FONT_FAMILY,
GTK_CSS_PROPERTY_FONT_STYLE,
GTK_CSS_PROPERTY_FONT_WEIGHT,
GTK_CSS_PROPERTY_FONT_STRETCH,
GTK_CSS_PROPERTY_LETTER_SPACING,
GTK_CSS_PROPERTY_TEXT_SHADOW,
GTK_CSS_PROPERTY_CARET_COLOR,
GTK_CSS_PROPERTY_SECONDARY_CARET_COLOR,
GTK_CSS_PROPERTY_FONT_FEATURE_SETTINGS,
GTK_CSS_PROPERTY_FONT_VARIATION_SETTINGS,
GTK_CSS_PROPERTY_LINE_HEIGHT,
};
static const int font_variant_props[] = {
GTK_CSS_PROPERTY_TEXT_DECORATION_LINE,
GTK_CSS_PROPERTY_TEXT_DECORATION_COLOR,
GTK_CSS_PROPERTY_TEXT_DECORATION_STYLE,
GTK_CSS_PROPERTY_TEXT_TRANSFORM,
GTK_CSS_PROPERTY_FONT_KERNING,
GTK_CSS_PROPERTY_FONT_VARIANT_LIGATURES,
GTK_CSS_PROPERTY_FONT_VARIANT_POSITION,
GTK_CSS_PROPERTY_FONT_VARIANT_CAPS,
GTK_CSS_PROPERTY_FONT_VARIANT_NUMERIC,
GTK_CSS_PROPERTY_FONT_VARIANT_ALTERNATES,
GTK_CSS_PROPERTY_FONT_VARIANT_EAST_ASIAN,
};
static const int animation_props[] = {
GTK_CSS_PROPERTY_ANIMATION_NAME,
GTK_CSS_PROPERTY_ANIMATION_DURATION,
GTK_CSS_PROPERTY_ANIMATION_TIMING_FUNCTION,
GTK_CSS_PROPERTY_ANIMATION_ITERATION_COUNT,
GTK_CSS_PROPERTY_ANIMATION_DIRECTION,
GTK_CSS_PROPERTY_ANIMATION_PLAY_STATE,
GTK_CSS_PROPERTY_ANIMATION_DELAY,
GTK_CSS_PROPERTY_ANIMATION_FILL_MODE,
};
static const int transition_props[] = {
GTK_CSS_PROPERTY_TRANSITION_PROPERTY,
GTK_CSS_PROPERTY_TRANSITION_DURATION,
GTK_CSS_PROPERTY_TRANSITION_TIMING_FUNCTION,
GTK_CSS_PROPERTY_TRANSITION_DELAY,
};
static const int size_props[] = {
GTK_CSS_PROPERTY_MARGIN_TOP,
GTK_CSS_PROPERTY_MARGIN_LEFT,
GTK_CSS_PROPERTY_MARGIN_BOTTOM,
GTK_CSS_PROPERTY_MARGIN_RIGHT,
GTK_CSS_PROPERTY_PADDING_TOP,
GTK_CSS_PROPERTY_PADDING_LEFT,
GTK_CSS_PROPERTY_PADDING_BOTTOM,
GTK_CSS_PROPERTY_PADDING_RIGHT,
GTK_CSS_PROPERTY_BORDER_SPACING,
GTK_CSS_PROPERTY_MIN_WIDTH,
GTK_CSS_PROPERTY_MIN_HEIGHT,
};
static const int other_props[] = {
GTK_CSS_PROPERTY_ICON_SOURCE,
GTK_CSS_PROPERTY_ICON_TRANSFORM,
GTK_CSS_PROPERTY_ICON_FILTER,
GTK_CSS_PROPERTY_TRANSFORM,
GTK_CSS_PROPERTY_TRANSFORM_ORIGIN,
GTK_CSS_PROPERTY_OPACITY,
GTK_CSS_PROPERTY_FILTER,
};
G_END_DECLS

359
gtk/gtkcssvariableset.c Normal file
View File

@@ -0,0 +1,359 @@
/*
* Copyright (C) 2023 GNOME Foundation Inc.
*
* 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: Alice Mikhaylenko <alicem@gnome.org>
*/
#include "gtkcssvariablesetprivate.h"
#include "gtkcsscustompropertypoolprivate.h"
static void
unref_custom_property_name (gpointer pointer)
{
GtkCssCustomPropertyPool *pool = gtk_css_custom_property_pool_get ();
gtk_css_custom_property_pool_unref (pool, GPOINTER_TO_INT (pointer));
}
static void
maybe_unref_variable (gpointer pointer)
{
if (pointer != NULL)
gtk_css_variable_value_unref (pointer);
}
GtkCssVariableSet *
gtk_css_variable_set_new (void)
{
GtkCssVariableSet *self = g_new0 (GtkCssVariableSet, 1);
self->ref_count = 1;
self->variables = g_hash_table_new_full (g_direct_hash,
g_direct_equal,
unref_custom_property_name,
maybe_unref_variable);
return self;
}
GtkCssVariableSet *
gtk_css_variable_set_ref (GtkCssVariableSet *self)
{
self->ref_count++;
return self;
}
void
gtk_css_variable_set_unref (GtkCssVariableSet *self)
{
self->ref_count--;
if (self->ref_count > 0)
return;
g_hash_table_unref (self->variables);
g_clear_pointer (&self->parent, gtk_css_variable_set_unref);
g_free (self);
}
GtkCssVariableSet *
gtk_css_variable_set_copy (GtkCssVariableSet *self)
{
GtkCssVariableSet *ret = gtk_css_variable_set_new ();
GHashTableIter iter;
gpointer id;
GtkCssVariableValue *value;
g_hash_table_iter_init (&iter, self->variables);
while (g_hash_table_iter_next (&iter, &id, (gpointer) &value))
gtk_css_variable_set_add (ret, GPOINTER_TO_INT (id), value);
gtk_css_variable_set_set_parent (ret, self->parent);
return ret;
}
void
gtk_css_variable_set_set_parent (GtkCssVariableSet *self,
GtkCssVariableSet *parent)
{
if (self->parent)
gtk_css_variable_set_unref (self->parent);
self->parent = parent;
if (self->parent)
gtk_css_variable_set_ref (self->parent);
}
void
gtk_css_variable_set_add (GtkCssVariableSet *self,
int id,
GtkCssVariableValue *value)
{
GtkCssCustomPropertyPool *pool = gtk_css_custom_property_pool_get ();
g_hash_table_insert (self->variables,
GINT_TO_POINTER (gtk_css_custom_property_pool_ref (pool, id)),
value ? gtk_css_variable_value_ref (value) : NULL);
}
static gboolean check_variable (GtkCssVariableSet *self,
GHashTable *unvisited_variables,
GArray *stack,
int id,
GtkCssVariableValue *value);
static gboolean
check_references (GtkCssVariableSet *self,
GHashTable *unvisited_variables,
GArray *stack,
GtkCssVariableValue *value)
{
GtkCssCustomPropertyPool *pool = gtk_css_custom_property_pool_get ();
int i;
for (i = 0; i < value->n_references; i++)
{
GtkCssVariableValueReference *ref = &value->references[i];
int ref_id = gtk_css_custom_property_pool_lookup (pool, ref->name);
if (g_hash_table_contains (unvisited_variables, GINT_TO_POINTER (ref_id)))
{
GtkCssVariableValue *ref_value;
ref_value = g_hash_table_lookup (self->variables, GINT_TO_POINTER (ref_id));
if (check_variable (self, unvisited_variables, stack, ref_id, ref_value))
return TRUE;
}
if (ref->fallback)
{
if (check_references (self, unvisited_variables, stack, ref->fallback))
return TRUE;
}
}
return FALSE;
}
static gboolean
check_variable (GtkCssVariableSet *self,
GHashTable *unvisited_variables,
GArray *stack,
int id,
GtkCssVariableValue *value)
{
int i;
g_array_append_val (stack, id);
for (i = stack->len - 2; i >= 0; i--)
{
/* Found a cycle, stop checking */
if (id == g_array_index (stack, int, i))
return TRUE;
}
if (check_references (self, unvisited_variables, stack, value))
return TRUE;
g_array_remove_index_fast (stack, stack->len - 1);
g_hash_table_remove (unvisited_variables, GINT_TO_POINTER (id));
return FALSE;
}
void
gtk_css_variable_set_resolve_cycles (GtkCssVariableSet *self)
{
GHashTable *variables = g_hash_table_new (g_direct_hash, g_direct_equal);
GHashTable *unvisited_variables = g_hash_table_new (g_direct_hash, g_direct_equal);
GArray *stack;
GHashTableIter iter;
gpointer id;
GtkCssVariableValue *value;
stack = g_array_new (FALSE, FALSE, sizeof (int));
g_hash_table_iter_init (&iter, self->variables);
while (g_hash_table_iter_next (&iter, &id, (gpointer) &value))
{
/* Have 2 copies of self->variables: "variables" can be iterated safely as
* we remove values, and "unvisited_variables" as a visited node marker
* for DFS */
g_hash_table_insert (variables, id, value);
g_hash_table_add (unvisited_variables, id);
}
g_hash_table_iter_init (&iter, variables);
while (g_hash_table_iter_next (&iter, &id, (gpointer) &value))
{
if (!g_hash_table_contains (unvisited_variables, id))
continue;
if (!g_hash_table_contains (self->variables, id))
continue;
if (check_variable (self, unvisited_variables, stack, GPOINTER_TO_INT (id), value))
{
int i;
/* Found a cycle, remove the offending variables */
for (i = stack->len - 2; i >= 0; i--)
{
int id_to_remove = g_array_index (stack, int, i);
g_hash_table_remove (self->variables, GINT_TO_POINTER (id_to_remove));
if (g_array_index (stack, int, i) == g_array_index (stack, int, stack->len - 1))
break;
}
g_array_remove_range (stack, 0, stack->len);
}
}
g_array_unref (stack);
g_hash_table_unref (variables);
g_hash_table_unref (unvisited_variables);
}
GtkCssVariableValue *
gtk_css_variable_set_lookup (GtkCssVariableSet *self,
int id,
GtkCssVariableSet **source)
{
GtkCssVariableValue *ret = g_hash_table_lookup (self->variables, GINT_TO_POINTER (id));
if (ret)
{
if (source)
*source = self;
return ret;
}
if (self->parent)
return gtk_css_variable_set_lookup (self->parent, id, source);
if (source)
*source = NULL;
return NULL;
}
static void
list_ids_recursive (GtkCssVariableSet *self,
GHashTable *table)
{
GHashTableIter iter;
gpointer id;
if (self->parent)
list_ids_recursive (self->parent, table);
g_hash_table_iter_init (&iter, self->variables);
while (g_hash_table_iter_next (&iter, &id, NULL))
g_hash_table_add (table, id);
}
static int
compare_ids (gconstpointer a, gconstpointer b, gpointer user_data)
{
GtkCssCustomPropertyPool *pool = user_data;
int id1 = GPOINTER_TO_INT (*((const int *) a));
int id2 = GPOINTER_TO_INT (*((const int *) b));
const char *name1, *name2;
name1 = gtk_css_custom_property_pool_get_name (pool, id1);
name2 = gtk_css_custom_property_pool_get_name (pool, id2);
return strcmp (name1, name2);
}
GArray *
gtk_css_variable_set_list_ids (GtkCssVariableSet *self)
{
GtkCssCustomPropertyPool *pool = gtk_css_custom_property_pool_get ();
GArray *ret = g_array_new (FALSE, FALSE, sizeof (int));
GHashTable *all_ids;
GHashTableIter iter;
gpointer id;
all_ids = g_hash_table_new (g_direct_hash, g_direct_equal);
list_ids_recursive (self, all_ids);
g_hash_table_iter_init (&iter, all_ids);
while (g_hash_table_iter_next (&iter, &id, NULL))
g_array_append_val (ret, id);
g_hash_table_unref (all_ids);
g_array_sort_with_data (ret, compare_ids, pool);
return ret;
}
gboolean
gtk_css_variable_set_equal (GtkCssVariableSet *set1,
GtkCssVariableSet *set2)
{
GHashTableIter iter;
gpointer id;
GtkCssVariableValue *value1;
if (set1 == set2)
return TRUE;
if (set1 == NULL || set2 == NULL)
return FALSE;
if (g_hash_table_size (set1->variables) != g_hash_table_size (set2->variables))
return FALSE;
if (set1->parent != set2->parent)
return FALSE;
g_hash_table_iter_init (&iter, set2->variables);
while (g_hash_table_iter_next (&iter, &id, NULL))
{
if (!g_hash_table_contains (set1->variables, id))
return FALSE;
}
g_hash_table_iter_init (&iter, set1->variables);
while (g_hash_table_iter_next (&iter, &id, (gpointer) &value1))
{
GtkCssVariableValue *value2 = g_hash_table_lookup (set2->variables, id);
if (value2 == NULL)
return FALSE;
if (!gtk_css_variable_value_equal (value1, value2))
return FALSE;
}
return TRUE;
}

View File

@@ -0,0 +1,60 @@
/*
* Copyright (C) 2023 GNOME Foundation Inc.
*
* 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: Alice Mikhaylenko <alicem@gnome.org>
*/
#pragma once
#include "gtk/css/gtkcssvariablevalueprivate.h"
G_BEGIN_DECLS
typedef struct _GtkCssVariableSet GtkCssVariableSet;
struct _GtkCssVariableSet
{
int ref_count;
GHashTable *variables;
GtkCssVariableSet *parent;
};
GtkCssVariableSet * gtk_css_variable_set_new (void);
GtkCssVariableSet * gtk_css_variable_set_ref (GtkCssVariableSet *self);
void gtk_css_variable_set_unref (GtkCssVariableSet *self);
GtkCssVariableSet * gtk_css_variable_set_copy (GtkCssVariableSet *self);
void gtk_css_variable_set_set_parent (GtkCssVariableSet *self,
GtkCssVariableSet *parent);
void gtk_css_variable_set_add (GtkCssVariableSet *self,
int id,
GtkCssVariableValue *value);
void gtk_css_variable_set_resolve_cycles (GtkCssVariableSet *self);
GtkCssVariableValue *gtk_css_variable_set_lookup (GtkCssVariableSet *self,
int id,
GtkCssVariableSet **source);
GArray * gtk_css_variable_set_list_ids (GtkCssVariableSet *self);
gboolean gtk_css_variable_set_equal (GtkCssVariableSet *set1,
GtkCssVariableSet *set2);
G_END_DECLS

View File

@@ -1576,7 +1576,8 @@ gtk_grid_view_get_tab_behavior (GtkGridView *self)
/**
* gtk_grid_view_scroll_to:
* @self: The gridview to scroll in
* @pos: position of the item
* @pos: position of the item. Must be less than the number of
* items in the view.
* @flags: actions to perform
* @scroll: (nullable) (transfer full): details of how to perform
* the scroll operation or %NULL to scroll into view
@@ -1596,6 +1597,7 @@ gtk_grid_view_scroll_to (GtkGridView *self,
GtkScrollInfo *scroll)
{
g_return_if_fail (GTK_IS_GRID_VIEW (self));
g_return_if_fail (pos < gtk_list_base_get_n_items (GTK_LIST_BASE (self)));
gtk_list_base_scroll_to (GTK_LIST_BASE (self), pos, flags, scroll);
}

View File

@@ -1356,7 +1356,8 @@ gtk_list_view_get_tab_behavior (GtkListView *self)
/**
* gtk_list_view_scroll_to:
* @self: The listview to scroll in
* @pos: position of the item
* @pos: position of the item. Must be less than the number of
* items in the view.
* @flags: actions to perform
* @scroll: (nullable) (transfer full): details of how to perform
* the scroll operation or %NULL to scroll into view
@@ -1376,6 +1377,7 @@ gtk_list_view_scroll_to (GtkListView *self,
GtkScrollInfo *scroll)
{
g_return_if_fail (GTK_IS_LIST_VIEW (self));
g_return_if_fail (pos < gtk_list_base_get_n_items (GTK_LIST_BASE (self)));
gtk_list_base_scroll_to (GTK_LIST_BASE (self), pos, flags, scroll);
}

View File

@@ -142,7 +142,7 @@ gtk_print_setup_unref (GtkPrintSetup *setup)
* They may be different from the `GtkPrintDialog`'s settings
* if the user changed them during the setup process.
*
* Returns: (nullable) (transfer none): the print settings, or `NULL`
* Returns: (transfer none): the print settings, or `NULL`
*
* Since: 4.14
*/
@@ -168,7 +168,7 @@ gtk_print_setup_set_print_settings (GtkPrintSetup *setup,
* It may be different from the `GtkPrintDialog`'s page setup
* if the user changed it during the setup process.
*
* Returns: (nullable) (transfer none): the page setup, or `NULL`
* Returns: (transfer none): the page setup, or `NULL`
*
* Since: 4.14
*/
@@ -585,7 +585,7 @@ gtk_print_dialog_set_modal (GtkPrintDialog *self,
*
* Returns the page setup.
*
* Returns: (transfer none): the page setup
* Returns: (nullable) (transfer none): the page setup
*
* Since: 4.14
*/
@@ -623,7 +623,7 @@ gtk_print_dialog_set_page_setup (GtkPrintDialog *self,
*
* Returns the print settings for the print dialog.
*
* Returns: (transfer none): the settings
* Returns: (nullable) (transfer none): the settings
*
* Since: 4.14
*/
@@ -1502,7 +1502,7 @@ gtk_print_dialog_setup (GtkPrintDialog *self,
* which contains the print settings and page setup information that
* will be used to print.
*
* Returns: (nullable): The `GtkPrintSetup` object that resulted from the call,
* Returns: The `GtkPrintSetup` object that resulted from the call,
* or `NULL` if the call was not successful
*
* Since: 4.14
@@ -1628,7 +1628,7 @@ gtk_print_dialog_print (GtkPrintDialog *self,
* call may not be instant as it operation will for the printer to finish
* printing.
*
* Returns: (nullable) (transfer full): a [class@Gio.OutputStream]
* Returns: (transfer full): a [class@Gio.OutputStream]
*
* Since: 4.14
*/

View File

@@ -208,6 +208,29 @@ gtk_style_cascade_lookup (GtkStyleProvider *provider,
gtk_style_cascade_iter_clear (&iter);
}
static void
gtk_style_cascade_emit_error (GtkStyleProvider *provider,
GtkCssSection *section,
const GError *error)
{
GtkStyleCascade *cascade = GTK_STYLE_CASCADE (provider);
GtkStyleCascadeIter iter;
GtkStyleProvider *item;
for (item = gtk_style_cascade_iter_init (cascade, &iter);
item;
item = gtk_style_cascade_iter_next (cascade, &iter))
{
if (gtk_style_provider_has_section (item, section))
{
gtk_style_provider_emit_error (item, section, (GError *) error);
break;
}
}
gtk_style_cascade_iter_clear (&iter);
}
static void
gtk_style_cascade_provider_iface_init (GtkStyleProviderInterface *iface)
{
@@ -216,6 +239,7 @@ gtk_style_cascade_provider_iface_init (GtkStyleProviderInterface *iface)
iface->get_scale = gtk_style_cascade_get_scale;
iface->get_keyframes = gtk_style_cascade_get_keyframes;
iface->lookup = gtk_style_cascade_lookup;
iface->emit_error = gtk_style_cascade_emit_error;
}
G_DEFINE_TYPE_EXTENDED (GtkStyleCascade, _gtk_style_cascade, G_TYPE_OBJECT, 0,

View File

@@ -170,6 +170,19 @@ gtk_style_provider_emit_error (GtkStyleProvider *provider,
iface->emit_error (provider, section, error);
}
gboolean
gtk_style_provider_has_section (GtkStyleProvider *provider,
GtkCssSection *section)
{
GtkStyleProviderInterface *iface;
iface = GTK_STYLE_PROVIDER_GET_INTERFACE (provider);
if (iface->has_section)
return iface->has_section (provider, section);
return FALSE;
}
/* These apis are misnamed, and the rest of GtkStyleContext is deprecated,
* so put them here for now
@@ -230,4 +243,3 @@ gtk_style_context_remove_provider_for_display (GdkDisplay *display,
cascade = _gtk_settings_get_style_cascade (gtk_settings_get_for_display (display), 1);
_gtk_style_cascade_remove_provider (cascade, provider);
}

View File

@@ -52,6 +52,8 @@ struct _GtkStyleProviderInterface
const GError *error);
/* signal */
void (* changed) (GtkStyleProvider *provider);
gboolean (* has_section) (GtkStyleProvider *provider,
GtkCssSection *section);
};
GtkSettings * gtk_style_provider_get_settings (GtkStyleProvider *provider);
@@ -71,6 +73,8 @@ void gtk_style_provider_changed (GtkStyleProvid
void gtk_style_provider_emit_error (GtkStyleProvider *provider,
GtkCssSection *section,
GError *error);
gboolean gtk_style_provider_has_section (GtkStyleProvider *provider,
GtkCssSection *section);
G_END_DECLS

View File

@@ -366,9 +366,10 @@ gtk_tooltip_trigger_tooltip_query (GtkWidget *widget)
GdkSeat *seat;
GdkDevice *device;
GdkSurface *surface;
double x, y;
graphene_point_t p;
double px, py;
int x, y;
GtkWidget *toplevel;
GtkWidget *target_widget;
g_return_if_fail (GTK_IS_WIDGET (widget));
@@ -381,7 +382,7 @@ gtk_tooltip_trigger_tooltip_query (GtkWidget *widget)
else
device = NULL;
if (device)
surface = gdk_device_get_surface_at_position (device, &x, &y);
surface = gdk_device_get_surface_at_position (device, &px, &py);
else
surface = NULL;
if (!surface)
@@ -395,10 +396,12 @@ gtk_tooltip_trigger_tooltip_query (GtkWidget *widget)
if (gtk_native_get_surface (GTK_NATIVE (toplevel)) != surface)
return;
if (!gtk_widget_compute_point (toplevel, widget, &GRAPHENE_POINT_INIT (x, y), &p))
graphene_point_init (&p, x, y);
x = round (px);
y = round (py);
gtk_tooltip_handle_event_internal (GDK_MOTION_NOTIFY, surface, widget, p.x, p.y);
target_widget = _gtk_widget_find_at_coords (surface, x, y, &x, &y);
gtk_tooltip_handle_event_internal (GDK_MOTION_NOTIFY, surface, target_widget, x, y);
}
static void

View File

@@ -28,6 +28,7 @@
#include "gtklabel.h"
#include "gtk/gtkwidgetprivate.h"
#include "gtkcsscustompropertypoolprivate.h"
#include "gtkcssproviderprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkcssstyleprivate.h"
@@ -600,6 +601,33 @@ bind_node_state (GtkSignalListItemFactory *factory,
g_free (text);
}
static int
compare_name_cb (gconstpointer a,
gconstpointer b,
gpointer user_data)
{
const CssProperty *prop_a = a;
const CssProperty *prop_b = b;
gboolean a_var = prop_a->name[0] == '-' && prop_a->name[1] == '-';
gboolean b_var = prop_b->name[0] == '-' && prop_b->name[1] == '-';
gboolean a_gtk = prop_a->name[0] == '-' && prop_a->name[1] != '-';
gboolean b_gtk = prop_b->name[0] == '-' && prop_b->name[1] != '-';
int ret;
if (a_var && !b_var)
ret = 1;
else if (b_var && !a_var)
ret = -1;
else if (a_gtk && !b_gtk)
ret = 1;
else if (b_gtk && !a_gtk)
ret = -1;
else
ret = g_utf8_collate (prop_a->name, prop_b->name);
return gtk_ordering_from_cmpfunc (ret);
}
static void
gtk_inspector_css_node_tree_init (GtkInspectorCssNodeTree *cnt)
{
@@ -676,7 +704,7 @@ gtk_inspector_css_node_tree_init (GtkInspectorCssNodeTree *cnt)
g_signal_connect (factory, "setup", G_CALLBACK (setup_label), NULL);
g_signal_connect (factory, "bind", G_CALLBACK (bind_name), NULL);
gtk_column_view_column_set_factory (column, factory);
sorter = GTK_SORTER (gtk_string_sorter_new (gtk_property_expression_new (css_property_get_type (), NULL, "name")));
sorter = GTK_SORTER (gtk_custom_sorter_new ((GCompareDataFunc) compare_name_cb, NULL, NULL));
gtk_column_view_column_set_sorter (column, sorter);
gtk_column_view_sort_by_column (GTK_COLUMN_VIEW (priv->prop_tree), column, GTK_SORT_ASCENDING);
g_object_unref (sorter);
@@ -773,9 +801,14 @@ gtk_inspector_css_node_tree_update_style (GtkInspectorCssNodeTree *cnt,
GtkCssStyle *new_style)
{
GtkInspectorCssNodeTreePrivate *priv = cnt->priv;
int i;
GtkCssCustomPropertyPool *pool = gtk_css_custom_property_pool_get ();
GArray *custom_props;
int i, n, n_props;
for (i = 0; i < _gtk_css_style_property_get_n_properties (); i++)
n_props = _gtk_css_style_property_get_n_properties ();
n = g_list_model_get_n_items (G_LIST_MODEL (priv->prop_model));
for (i = 0; i < n_props; i++)
{
GtkCssStyleProperty *prop;
const char *name;
@@ -789,7 +822,7 @@ gtk_inspector_css_node_tree_update_style (GtkInspectorCssNodeTree *cnt,
if (new_style)
{
value = _gtk_css_value_to_string (gtk_css_style_get_value (new_style, i));
value = gtk_css_value_to_string (gtk_css_style_get_value (new_style, i));
section = gtk_css_style_get_section (new_style, i);
if (section)
@@ -809,6 +842,47 @@ gtk_inspector_css_node_tree_update_style (GtkInspectorCssNodeTree *cnt,
g_free (location);
g_free (value);
}
g_list_store_splice (priv->prop_model, n_props, n - n_props, NULL, 0);
if (new_style)
{
custom_props = gtk_css_style_list_custom_properties (new_style);
if (custom_props)
{
for (i = 0; i < custom_props->len; i++)
{
GtkCssVariableValue *var_value;
int id;
const char *name;
GtkCssSection *section;
char *location;
char *value;
CssProperty *property;
id = g_array_index (custom_props, int, i);
name = gtk_css_custom_property_pool_get_name (pool, id);
var_value = gtk_css_style_get_custom_property (new_style, id);
value = gtk_css_variable_value_to_string (var_value);
section = var_value->section;
if (section)
location = gtk_css_section_to_string (section);
else
location = NULL;
property = css_property_new (name, value, location);
g_list_store_append (priv->prop_model, property);
g_free (location);
g_free (value);
}
g_array_unref (custom_props);
}
}
}
static void

View File

@@ -53,6 +53,7 @@ gtk_private_sources = files([
'gtkcsscalcvalue.c',
'gtkcsscolorvalue.c',
'gtkcsscornervalue.c',
'gtkcsscustompropertypool.c',
'gtkcssdimensionvalue.c',
'gtkcssdynamic.c',
'gtkcsseasevalue.c',
@@ -84,6 +85,7 @@ gtk_private_sources = files([
'gtkcssnumbervalue.c',
'gtkcsspalettevalue.c',
'gtkcsspositionvalue.c',
'gtkcssreferencevalue.c',
'gtkcssrepeatvalue.c',
'gtkcssselector.c',
'gtkcssshadowvalue.c',
@@ -101,6 +103,7 @@ gtk_private_sources = files([
'gtkcsstypes.c',
'gtkcssunsetvalue.c',
'gtkcssvalue.c',
'gtkcssvariableset.c',
'gtkcsswidgetnode.c',
'gtkdrop.c',
'gtkfilechooserentry.c',

479
po/ca.po

File diff suppressed because it is too large Load Diff

445
po/hu.po

File diff suppressed because it is too large Load Diff

268
po/ka.po
View File

@@ -11,8 +11,8 @@ msgid ""
msgstr ""
"Project-Id-Version: gtk\n"
"Report-Msgid-Bugs-To: https://gitlab.gnome.org/GNOME/gtk/-/issues/\n"
"POT-Creation-Date: 2024-03-30 09:15+0000\n"
"PO-Revision-Date: 2024-03-30 19:22+0100\n"
"POT-Creation-Date: 2024-05-11 03:40+0000\n"
"PO-Revision-Date: 2024-05-13 02:43+0200\n"
"Last-Translator: Ekaterine Papava <papava.e@gtu.ge>\n"
"Language-Team: Georgian <http://mail.gnome.org/mailman/listinfo/gnome-ge-"
"list>\n"
@@ -55,7 +55,7 @@ msgstr "შემცველობის %s-ად გამოტანა შ
msgid "The current backend does not support OpenGL"
msgstr "მიმდინარე უკანაბოლოს OpenGL-ის მხარდაჭერა არ გააჩნია"
#: gdk/gdkdisplay.c:1315 gdk/gdkvulkancontext.c:1600
#: gdk/gdkdisplay.c:1315 gdk/gdkvulkancontext.c:1636
msgid "Vulkan support disabled via GDK_DEBUG"
msgstr "Vulkan-ის მხარდაჭერა გამორთულია GDK_DEBUG-ით"
@@ -139,7 +139,7 @@ msgstr "აპლიკაციას %s-ის API-ის მხარდა
#. translators: This is about OpenGL backend names, like
#. * "Trying to use X11 GLX, but EGL is already in use"
#: gdk/gdkglcontext.c:2123
#: gdk/gdkglcontext.c:2121
#, c-format
msgid "Trying to use %s, but %s is already in use"
msgstr "%s გამოყენების მცდელობა, მაგრამ %s უკვე გამოიყენება"
@@ -535,7 +535,7 @@ msgstr "JPEG გამოსახულების ფაილის კი
msgid "Unsupported JPEG colorspace (%d)"
msgstr "მხარდაუჭერელი JPEG ფერთა სივრცე (%d)"
#: gdk/loaders/gdkjpeg.c:203 gdk/loaders/gdkpng.c:286 gdk/loaders/gdktiff.c:472
#: gdk/loaders/gdkjpeg.c:203 gdk/loaders/gdkpng.c:289 gdk/loaders/gdktiff.c:472
#, c-format
msgid "Not enough memory for image size %ux%u"
msgstr "არასაკმარისი მეხსიერება გამოსახულების ჩასატვირთად %ux%u"
@@ -545,17 +545,17 @@ msgstr "არასაკმარისი მეხსიერება გ
msgid "Error reading png (%s)"
msgstr "PNG-ის წაკითხვის შეცდომა (%s)"
#: gdk/loaders/gdkpng.c:212
#: gdk/loaders/gdkpng.c:215
#, c-format
msgid "Unsupported depth %u in png image"
msgstr "PNG გამოსახულების მხარდაუჭერელი ფერთა სიღრმე %u"
#: gdk/loaders/gdkpng.c:262
#: gdk/loaders/gdkpng.c:265
#, c-format
msgid "Unsupported color type %u in png image"
msgstr "PNG გამოსახულების ფერების მხარდაუჭერელი ტიპი %u"
#: gdk/loaders/gdkpng.c:272
#: gdk/loaders/gdkpng.c:275
#, c-format
msgid "Image stride too large for image size %ux%u"
msgstr "გამოსახულებს ბიჯი მეტისმეტად დიდია გამოსახულების ზომისთვის %ux%u"
@@ -2274,7 +2274,7 @@ msgstr "ფაილი ამ სახელით უკვე არსე
#: gtk/gtkmessagedialog.c:179 gtk/gtkmountoperation.c:608
#: gtk/print/gtkpagesetupunixdialog.c:282 gtk/print/gtkprintbackend.c:638
#: gtk/print/gtkprintunixdialog.c:682 gtk/print/gtkprintunixdialog.c:839
#: gtk/gtkwindow.c:6256 gtk/ui/gtkappchooserdialog.ui:48
#: gtk/gtkwindow.c:6257 gtk/ui/gtkappchooserdialog.ui:48
#: gtk/ui/gtkassistant.ui:52 gtk/ui/gtkcolorchooserdialog.ui:36
#: gtk/ui/gtkfontchooserdialog.ui:27
msgid "_Cancel"
@@ -2362,7 +2362,7 @@ msgid "If you delete an item, it will be permanently lost."
msgstr "თუ წაშლით ელემენტს, ის სამუდამოდ დაიკარგება."
#: gtk/gtkfilechooserwidget.c:1188 gtk/gtkfilechooserwidget.c:1786
#: gtk/gtklabel.c:5712 gtk/gtktext.c:6194 gtk/gtktextview.c:9099
#: gtk/gtklabel.c:5745 gtk/gtktext.c:6194 gtk/gtktextview.c:9099
msgid "_Delete"
msgstr "წაშლა"
@@ -2688,7 +2688,7 @@ msgstr "სტილის ვარიაციები"
msgid "Character Variations"
msgstr "სიმბოლოების ვარიანტები"
#: gtk/gtkglarea.c:309
#: gtk/gtkglarea.c:316
msgid "OpenGL context creation failed"
msgstr "OpenGL-ის კონტექსტის შექმნის შეცდომა"
@@ -2701,31 +2701,31 @@ msgstr "დახურვა"
msgid "Close the infobar"
msgstr "საინფორმაციო ზოლის დახურვა"
#: gtk/gtklabel.c:5709 gtk/gtktext.c:6182 gtk/gtktextview.c:9087
#: gtk/gtklabel.c:5742 gtk/gtktext.c:6182 gtk/gtktextview.c:9087
msgid "Cu_t"
msgstr "ამოჭრა"
#: gtk/gtklabel.c:5710 gtk/gtktext.c:6186 gtk/gtktextview.c:9091
#: gtk/gtklabel.c:5743 gtk/gtktext.c:6186 gtk/gtktextview.c:9091
msgid "_Copy"
msgstr "ასლი"
#: gtk/gtklabel.c:5711 gtk/gtktext.c:6190 gtk/gtktextview.c:9095
#: gtk/gtklabel.c:5744 gtk/gtktext.c:6190 gtk/gtktextview.c:9095
msgid "_Paste"
msgstr "ჩასმა"
#: gtk/gtklabel.c:5717 gtk/gtktext.c:6203 gtk/gtktextview.c:9120
#: gtk/gtklabel.c:5750 gtk/gtktext.c:6203 gtk/gtktextview.c:9120
msgid "Select _All"
msgstr "ყველაფრის _მონიშვნა"
#: gtk/gtklabel.c:5722
#: gtk/gtklabel.c:5755
msgid "_Open Link"
msgstr "_ბმულის გახსნა"
#: gtk/gtklabel.c:5726
#: gtk/gtklabel.c:5759
msgid "Copy _Link Address"
msgstr "დაა_კოპირე ბმულის მისამართი"
#: gtk/gtklabel.c:5770 gtk/gtktext.c:2723 gtk/gtktextview.c:9169
#: gtk/gtklabel.c:5803 gtk/gtktext.c:2723 gtk/gtktextview.c:9169
msgid "Context menu"
msgstr "კონტექსტური მენიუ"
@@ -2733,7 +2733,7 @@ msgstr "კონტექსტური მენიუ"
msgid "_Copy URL"
msgstr "URL-ის _კოპირება"
#: gtk/gtklinkbutton.c:567
#: gtk/gtklinkbutton.c:589
msgid "Invalid URI"
msgstr "მცდარი URI"
@@ -2796,7 +2796,7 @@ msgid "Play"
msgstr "დაკვრა"
#: gtk/gtkmessagedialog.c:162 gtk/gtkmessagedialog.c:180
#: gtk/print/gtkprintbackend.c:639 gtk/gtkwindow.c:6257
#: gtk/print/gtkprintbackend.c:639 gtk/gtkwindow.c:6258
msgid "_OK"
msgstr "_დიახ"
@@ -3414,7 +3414,7 @@ msgstr "არ არის ქაღალდი"
#. Translators: this is a printer status.
#: gtk/print/gtkprintoperation-win32.c:640
#: modules/printbackends/gtkprintbackendcpdb.c:1528
#: modules/printbackends/gtkprintbackendcpdb.c:1533
#: modules/printbackends/gtkprintbackendcups.c:2639
msgid "Paused"
msgstr "შეჩერებულია"
@@ -3485,42 +3485,42 @@ msgstr "პრინტერის ინფორმაციის მიღ
#. * multiple pages on a sheet when printing
#.
#: gtk/print/gtkprintunixdialog.c:2753
#: modules/printbackends/gtkprintbackendcups.c:5672
#: modules/printbackends/gtkprintbackendcups.c:5677
msgid "Left to right, top to bottom"
msgstr "მარცხნიდან მარჯვნივ, ქვევიდან ზემოთ"
#: gtk/print/gtkprintunixdialog.c:2753
#: modules/printbackends/gtkprintbackendcups.c:5672
#: modules/printbackends/gtkprintbackendcups.c:5677
msgid "Left to right, bottom to top"
msgstr "მარცხნიდან მარჯვნივ, ქვემოდან ზემოთ"
#: gtk/print/gtkprintunixdialog.c:2754
#: modules/printbackends/gtkprintbackendcups.c:5673
#: modules/printbackends/gtkprintbackendcups.c:5678
msgid "Right to left, top to bottom"
msgstr "მარჯვნიდან მარცხნივ, ზევიდან ქვემოთ"
#: gtk/print/gtkprintunixdialog.c:2754
#: modules/printbackends/gtkprintbackendcups.c:5673
#: modules/printbackends/gtkprintbackendcups.c:5678
msgid "Right to left, bottom to top"
msgstr "მარჯვნიდან მარცხნივ, ქვემოდან ზემოთ"
#: gtk/print/gtkprintunixdialog.c:2755
#: modules/printbackends/gtkprintbackendcups.c:5674
#: modules/printbackends/gtkprintbackendcups.c:5679
msgid "Top to bottom, left to right"
msgstr "ზემოდან ქვემოთ, მარცხნიდან მარჯვნივ"
#: gtk/print/gtkprintunixdialog.c:2755
#: modules/printbackends/gtkprintbackendcups.c:5674
#: modules/printbackends/gtkprintbackendcups.c:5679
msgid "Top to bottom, right to left"
msgstr "ზემოდან ქვემოთ, მარჯვნიდან მარცხნივ"
#: gtk/print/gtkprintunixdialog.c:2756
#: modules/printbackends/gtkprintbackendcups.c:5675
#: modules/printbackends/gtkprintbackendcups.c:5680
msgid "Bottom to top, left to right"
msgstr "ქვემოდან ზემოთ, მარცხნიდან მარჯვნივ"
#: gtk/print/gtkprintunixdialog.c:2756
#: modules/printbackends/gtkprintbackendcups.c:5675
#: modules/printbackends/gtkprintbackendcups.c:5680
msgid "Bottom to top, right to left"
msgstr "ქვემოდან ზემოთ, მარჯვნიდან მარცხნივ"
@@ -3672,12 +3672,12 @@ msgstr "_დაბრუნება"
msgid "_Redo"
msgstr "_გამეორება"
#: gtk/gtkwindow.c:6245
#: gtk/gtkwindow.c:6246
#, c-format
msgid "Do you want to use GTK Inspector?"
msgstr "გნებავთ GTK-ის ინსპექტორის გამოყენება?"
#: gtk/gtkwindow.c:6247
#: gtk/gtkwindow.c:6248
#, c-format
msgid ""
"GTK Inspector is an interactive debugger that lets you explore and modify "
@@ -3688,7 +3688,7 @@ msgstr ""
"ნებისმიერი GTK აპლიკაციის შიდა პარამეტრები დაათვალიეროთ და შეცვალოთ. მისი "
"გამოყენებით ასევე შეიძლება პროგრამა ავარიულად დასრულდეს."
#: gtk/gtkwindow.c:6252
#: gtk/gtkwindow.c:6253
msgid "Dont show this message again"
msgstr "მეტჯერ აღარ მაჩვენო ეს გაფრთხილება"
@@ -3866,37 +3866,37 @@ msgstr "სტილის კლასები"
msgid "CSS Property"
msgstr "CSS-ის თვისება"
#: gtk/inspector/general.c:370
#: gtk/inspector/general.c:371
msgctxt "GL version"
msgid "None"
msgstr "არცერთი"
#: gtk/inspector/general.c:461
#: gtk/inspector/general.c:462
msgctxt "GL version"
msgid "Unknown"
msgstr "უცნობი"
#: gtk/inspector/general.c:523
#: gtk/inspector/general.c:524
msgctxt "Vulkan device"
msgid "Disabled"
msgstr "გამორთულია"
#: gtk/inspector/general.c:524 gtk/inspector/general.c:525
#: gtk/inspector/general.c:525 gtk/inspector/general.c:526
msgctxt "Vulkan version"
msgid "Disabled"
msgstr "გამორთულია"
#: gtk/inspector/general.c:576
#: gtk/inspector/general.c:577
msgctxt "Vulkan device"
msgid "None"
msgstr "არცერთი"
#: gtk/inspector/general.c:577 gtk/inspector/general.c:578
#: gtk/inspector/general.c:578 gtk/inspector/general.c:579
msgctxt "Vulkan version"
msgid "None"
msgstr "არცერთი"
#: gtk/inspector/general.c:924
#: gtk/inspector/general.c:930
msgid "IM Context is hardcoded by GTK_IM_MODULE"
msgstr "IM-ის კონტექსტი GTK_IM_MODULE-ში ხელითაა ჩაწერილი"
@@ -4206,7 +4206,7 @@ msgstr "წყარო:"
msgid "Defined At"
msgstr "აღწერის წერტილი"
#: gtk/inspector/recorder.c:1941
#: gtk/inspector/recorder.c:1950
#, c-format
msgid "Saving RenderNode failed"
msgstr "RenderNode-ის შენახვის შეცდომა"
@@ -4344,7 +4344,7 @@ msgstr "იერარქია"
msgid "Implements"
msgstr "იმპლემენტაციას უკეთებს"
#: gtk/inspector/visual.c:765 gtk/inspector/visual.c:784
#: gtk/inspector/visual.c:690 gtk/inspector/visual.c:708
msgid "Theme is hardcoded by GTK_THEME"
msgstr "თემა ჩადგმულია GTK_THEME-ის მიერ"
@@ -4389,43 +4389,28 @@ msgid "Slowdown"
msgstr "შენელება"
#: gtk/inspector/visual.ui:362
msgid "Antialiasing"
msgstr "მომრგვალება"
msgid "Rendering"
msgstr "რენდერი"
#: gtk/inspector/visual.ui:387
msgid "Hinting"
msgstr "მომრგვალება"
#: gtk/inspector/visual.ui:377
msgctxt "Font rendering"
msgid "Automatic"
msgstr "ავტომატური"
#: gtk/inspector/visual.ui:402
msgid "None"
msgstr "არცერთი"
#: gtk/inspector/visual.ui:403
msgid "Slight"
msgstr "ოდნავ"
#: gtk/inspector/visual.ui:404 modules/printbackends/gtkprintbackendcpdb.c:541
#: modules/printbackends/gtkprintbackendcups.c:5667
msgid "Medium"
msgstr "საშუალო"
#: gtk/inspector/visual.ui:378
msgctxt "Font rendering"
msgid "Manual"
msgstr "ხელით"
#: gtk/inspector/visual.ui:405
msgid "Full"
msgstr "სრული"
#: gtk/inspector/visual.ui:422
msgid "Metrics Hinting"
msgstr "მეტრიკის მომრგვალება"
#: gtk/inspector/visual.ui:457
msgid "Show Framerate"
msgstr "კადრების სიხშირის ჩვენება"
#: gtk/inspector/visual.ui:482
#: gtk/inspector/visual.ui:430
msgid "Show Graphic Updates"
msgstr "გრაფიკული განახლებების ჩვენება"
#: gtk/inspector/visual.ui:502
#: gtk/inspector/visual.ui:450
msgid ""
"Tints all the places where the current renderer uses Cairo instead of the "
"GPU."
@@ -4433,47 +4418,47 @@ msgstr ""
"შეღებავს ყველა ადგილს, სადაც მიმდინარე რენდერერი GPU-ის მაგიერ Cairo-ს "
"იყენებს."
#: gtk/inspector/visual.ui:508
#: gtk/inspector/visual.ui:456
msgid "Show Cairo Rendering"
msgstr "Cairo-ის რენდერის ჩვენება"
#: gtk/inspector/visual.ui:533
#: gtk/inspector/visual.ui:481
msgid "Show Baselines"
msgstr "საბაზისო ხაზების ჩვენება"
#: gtk/inspector/visual.ui:561
#: gtk/inspector/visual.ui:509
msgid "Show Layout Borders"
msgstr "განლაგების საზღვრების ჩვენება"
#: gtk/inspector/visual.ui:618
#: gtk/inspector/visual.ui:566
msgid "CSS Padding"
msgstr "CSS-ის შეწევა"
#: gtk/inspector/visual.ui:628
#: gtk/inspector/visual.ui:576
msgid "CSS Border"
msgstr "CSS-ის საზღვარი"
#: gtk/inspector/visual.ui:638
#: gtk/inspector/visual.ui:586
msgid "CSS Margin"
msgstr "CSS-ის შეწევა"
#: gtk/inspector/visual.ui:648
#: gtk/inspector/visual.ui:596
msgid "Widget Margin"
msgstr "ვიჯეტის შეწევა"
#: gtk/inspector/visual.ui:683
#: gtk/inspector/visual.ui:631
msgid "Show Focus"
msgstr "ფოკუსის ჩვენება"
#: gtk/inspector/visual.ui:708
#: gtk/inspector/visual.ui:656
msgid "Show Accessibility warnings"
msgstr "წვდომადობის გაფრთხილებების ჩვენება"
#: gtk/inspector/visual.ui:733
#: gtk/inspector/visual.ui:681
msgid "Show Graphics Offload"
msgstr "გრაფიკის რენდერის გატანის ჩვენება"
#: gtk/inspector/visual.ui:765
#: gtk/inspector/visual.ui:713
msgid "Inspect Inspector"
msgstr "კონტროლის ინსპექტორი"
@@ -6599,29 +6584,35 @@ msgstr "დამატებითი"
msgid "Some of the settings in the dialog conflict"
msgstr "კონფლიქტი ფანჯრის რამდენიმე პარამეტრს შორის"
#. Translators: These strings name the possible values of the
#. * job priority option in the print dialog
#.
#: modules/printbackends/gtkprintbackendcpdb.c:541
#: modules/printbackends/gtkprintbackendcups.c:5667
#: modules/printbackends/gtkprintbackendcpdb.c:542
#: modules/printbackends/gtkprintbackendcups.c:5668
msgctxt "Print job priority"
msgid "Urgent"
msgstr "გადაუდებელი"
#: modules/printbackends/gtkprintbackendcpdb.c:541
#: modules/printbackends/gtkprintbackendcups.c:5667
#: modules/printbackends/gtkprintbackendcpdb.c:543
#: modules/printbackends/gtkprintbackendcups.c:5669
msgctxt "Print job priority"
msgid "High"
msgstr "მაღალი"
#: modules/printbackends/gtkprintbackendcpdb.c:541
#: modules/printbackends/gtkprintbackendcups.c:5667
#: modules/printbackends/gtkprintbackendcpdb.c:544
#: modules/printbackends/gtkprintbackendcups.c:5670
msgctxt "Print job priority"
msgid "Medium"
msgstr "საშუალო"
#: modules/printbackends/gtkprintbackendcpdb.c:545
#: modules/printbackends/gtkprintbackendcups.c:5671
msgctxt "Print job priority"
msgid "Low"
msgstr "დაბალი"
#. Translators, this is the label used for the option in the print
#. * dialog that controls the front cover page.
#.
#: modules/printbackends/gtkprintbackendcpdb.c:562
#: modules/printbackends/gtkprintbackendcups.c:5809
#: modules/printbackends/gtkprintbackendcpdb.c:567
#: modules/printbackends/gtkprintbackendcups.c:5814
msgctxt "printer option"
msgid "Before"
msgstr "ჯერ"
@@ -6629,33 +6620,33 @@ msgstr "ჯერ"
#. Translators, this is the label used for the option in the print
#. * dialog that controls the back cover page.
#.
#: modules/printbackends/gtkprintbackendcpdb.c:569
#: modules/printbackends/gtkprintbackendcups.c:5824
#: modules/printbackends/gtkprintbackendcpdb.c:574
#: modules/printbackends/gtkprintbackendcups.c:5829
msgctxt "printer option"
msgid "After"
msgstr "შემდეგ"
#: modules/printbackends/gtkprintbackendcpdb.c:592
#: modules/printbackends/gtkprintbackendcpdb.c:597
msgid "Print at"
msgstr "დაბეჭდვის დრო"
#: modules/printbackends/gtkprintbackendcpdb.c:602
#: modules/printbackends/gtkprintbackendcpdb.c:607
msgid "Print at time"
msgstr "დაბეჭდვის დრო"
#: modules/printbackends/gtkprintbackendcpdb.c:665
#: modules/printbackends/gtkprintbackendcpdb.c:670
msgctxt "print option"
msgid "Borderless"
msgstr "საზღვრების გარეშე"
#. Translators: this is a printer status.
#: modules/printbackends/gtkprintbackendcpdb.c:1525
#: modules/printbackends/gtkprintbackendcpdb.c:1530
#: modules/printbackends/gtkprintbackendcups.c:2636
msgid "Paused; Rejecting Jobs"
msgstr "შეყოვნებულია; დავალებების უარყოფა"
#. Translators: this is a printer status.
#: modules/printbackends/gtkprintbackendcpdb.c:1531
#: modules/printbackends/gtkprintbackendcpdb.c:1536
#: modules/printbackends/gtkprintbackendcups.c:2642
msgid "Rejecting Jobs"
msgstr "დავალებების უარყოფა"
@@ -7021,51 +7012,51 @@ msgstr "ნაგულისხმევი პრინტერი"
#. Translators, this string is used to label the job priority option
#. * in the print dialog
#.
#: modules/printbackends/gtkprintbackendcups.c:5697
#: modules/printbackends/gtkprintbackendcups.c:5702
msgid "Job Priority"
msgstr "ამოცანის პრიორიტეტი"
#. Translators, this string is used to label the billing info entry
#. * in the print dialog
#.
#: modules/printbackends/gtkprintbackendcups.c:5708
#: modules/printbackends/gtkprintbackendcups.c:5713
msgid "Billing Info"
msgstr "ანგარიშთა ინფორმაცია"
#. Translators, these strings are names for various 'standard' cover
#. * pages that the printing system may support.
#.
#: modules/printbackends/gtkprintbackendcups.c:5732
#: modules/printbackends/gtkprintbackendcups.c:5737
msgctxt "cover page"
msgid "None"
msgstr "არცერთი"
#: modules/printbackends/gtkprintbackendcups.c:5733
#: modules/printbackends/gtkprintbackendcups.c:5738
msgctxt "cover page"
msgid "Classified"
msgstr "საიდუმლო"
#: modules/printbackends/gtkprintbackendcups.c:5734
#: modules/printbackends/gtkprintbackendcups.c:5739
msgctxt "cover page"
msgid "Confidential"
msgstr "კონფიდენციალური"
#: modules/printbackends/gtkprintbackendcups.c:5735
#: modules/printbackends/gtkprintbackendcups.c:5740
msgctxt "cover page"
msgid "Secret"
msgstr "სამხედრო საიდუმლო"
#: modules/printbackends/gtkprintbackendcups.c:5736
#: modules/printbackends/gtkprintbackendcups.c:5741
msgctxt "cover page"
msgid "Standard"
msgstr "სტანდარტული"
#: modules/printbackends/gtkprintbackendcups.c:5737
#: modules/printbackends/gtkprintbackendcups.c:5742
msgctxt "cover page"
msgid "Top Secret"
msgstr "უმაღლესი დონის საიდუმლო"
#: modules/printbackends/gtkprintbackendcups.c:5738
#: modules/printbackends/gtkprintbackendcups.c:5743
msgctxt "cover page"
msgid "Unclassified"
msgstr "არასაიდუმლო"
@@ -7073,7 +7064,7 @@ msgstr "არასაიდუმლო"
#. Translators, this string is used to label the pages-per-sheet option
#. * in the print dialog
#.
#: modules/printbackends/gtkprintbackendcups.c:5750
#: modules/printbackends/gtkprintbackendcups.c:5755
msgctxt "printer option"
msgid "Pages per Sheet"
msgstr "გვერდები ფურცელზე"
@@ -7081,7 +7072,7 @@ msgstr "გვერდები ფურცელზე"
#. Translators, this string is used to label the option in the print
#. * dialog that controls in what order multiple pages are arranged
#.
#: modules/printbackends/gtkprintbackendcups.c:5767
#: modules/printbackends/gtkprintbackendcups.c:5772
msgctxt "printer option"
msgid "Page Ordering"
msgstr "გვერდის დალაგება"
@@ -7090,7 +7081,7 @@ msgstr "გვერდის დალაგება"
#. * a print job is printed. Possible values are 'now', a specified time,
#. * or 'on hold'
#.
#: modules/printbackends/gtkprintbackendcups.c:5844
#: modules/printbackends/gtkprintbackendcups.c:5849
msgctxt "printer option"
msgid "Print at"
msgstr "დაბეჭდვის დრო"
@@ -7098,7 +7089,7 @@ msgstr "დაბეჭდვის დრო"
#. Translators: this is the name of the option that allows the user
#. * to specify a time when a print job will be printed.
#.
#: modules/printbackends/gtkprintbackendcups.c:5855
#: modules/printbackends/gtkprintbackendcups.c:5860
msgctxt "printer option"
msgid "Print at time"
msgstr "დაბეჭდვის დრო"
@@ -7108,19 +7099,19 @@ msgstr "დაბეჭდვის დრო"
#. * the width and height in points. E.g: "Custom
#. * 230.4x142.9"
#.
#: modules/printbackends/gtkprintbackendcups.c:5902
#: modules/printbackends/gtkprintbackendcups.c:5907
#, c-format
msgid "Custom %s×%s"
msgstr "ხელით %s×%s"
#. TRANSLATORS: this is the ICC color profile to use for this job
#: modules/printbackends/gtkprintbackendcups.c:6013
#: modules/printbackends/gtkprintbackendcups.c:6018
msgctxt "printer option"
msgid "Printer Profile"
msgstr "პრინტერის პროფილი"
#. TRANSLATORS: this is when color profile information is unavailable
#: modules/printbackends/gtkprintbackendcups.c:6020
#: modules/printbackends/gtkprintbackendcups.c:6025
msgctxt "printer option value"
msgid "Unavailable"
msgstr "მიუწვდომელია"
@@ -7181,22 +7172,22 @@ msgstr "მიმდინარის მაგიერ ამ საქაღ
msgid "Generate debug output"
msgstr "პროგრამის გამართვის ინფორმაციის გენერაცია"
#: tools/encodesymbolic.c:92
#: tools/encodesymbolic.c:95
#, c-format
msgid "Invalid size %s\n"
msgstr "არასწორი ზომა: %s\n"
#: tools/encodesymbolic.c:104 tools/encodesymbolic.c:113
#: tools/encodesymbolic.c:107 tools/encodesymbolic.c:116
#, c-format
msgid "Cant load file: %s\n"
msgstr "ფაილის ჩატვირთვა შეუძლებელია: \"%s\"\n"
#: tools/encodesymbolic.c:141 tools/encodesymbolic.c:147
#: tools/encodesymbolic.c:144 tools/encodesymbolic.c:162
#, c-format
msgid "Cant save file %s: %s\n"
msgstr "ფაილის შენახვა შეუძლებელია: \"%s\": %s\n"
#: tools/encodesymbolic.c:153
#: tools/encodesymbolic.c:168
#, c-format
msgid "Cant close stream"
msgstr "ნაკადის დახურვა შეუძლებელია"
@@ -7269,7 +7260,7 @@ msgstr "სტილის CSS ფაილიდან გამოყენე
#: tools/gtk-builder-tool-preview.c:187 tools/gtk-builder-tool-screenshot.c:370
#: tools/gtk-builder-tool-validate.c:268
#: tools/gtk-rendernode-tool-benchmark.c:106
#: tools/gtk-rendernode-tool-render.c:203 tools/gtk-rendernode-tool-show.c:113
#: tools/gtk-rendernode-tool-render.c:262 tools/gtk-rendernode-tool-show.c:113
#, c-format
msgid "Could not initialize windowing system\n"
msgstr "ფანჯრული სისტემის ინიციალიზაციის შეცდომა\n"
@@ -7314,13 +7305,13 @@ msgstr ""
"თავზე გადასაწერად გამოიყენეთ --force.\n"
#: tools/gtk-builder-tool-screenshot.c:332
#: tools/gtk-rendernode-tool-render.c:171
#: tools/gtk-rendernode-tool-render.c:230
#, c-format
msgid "Output written to %s.\n"
msgstr "გამოტანილი ინფორმაცია ჩაწერილია %s-ში.\n"
#: tools/gtk-builder-tool-screenshot.c:336
#: tools/gtk-rendernode-tool-render.c:175
#: tools/gtk-rendernode-tool-render.c:234
#, c-format
msgid "Failed to save %s: %s\n"
msgstr "\"%s'-ის შენახვის შეცდომა: %s\n"
@@ -7339,7 +7330,7 @@ msgstr "არსებულ ფაილზე გადაწერა"
#: tools/gtk-builder-tool-screenshot.c:363
#: tools/gtk-rendernode-tool-benchmark.c:97
#: tools/gtk-rendernode-tool-render.c:196
#: tools/gtk-rendernode-tool-render.c:255
msgid "FILE…"
msgstr "FILE…"
@@ -7835,7 +7826,7 @@ msgstr "რენდერერის დამატება ტესტი
#: tools/gtk-rendernode-tool-benchmark.c:94
#: tools/gtk-rendernode-tool-compare.c:65
#: tools/gtk-rendernode-tool-render.c:195
#: tools/gtk-rendernode-tool-render.c:254
msgid "RENDERER"
msgstr "რენდერერი"
@@ -7856,7 +7847,7 @@ msgid "Benchmark rendering of a .node file."
msgstr ".node ფაილის სატესტო რენდერი."
#: tools/gtk-rendernode-tool-benchmark.c:127
#: tools/gtk-rendernode-tool-info.c:236 tools/gtk-rendernode-tool-render.c:224
#: tools/gtk-rendernode-tool-info.c:236 tools/gtk-rendernode-tool-render.c:283
#: tools/gtk-rendernode-tool-show.c:134
#, c-format
msgid "No .node file specified\n"
@@ -7868,7 +7859,7 @@ msgid "Can only benchmark a single .node file\n"
msgstr "შეგიძლიათ მხოლოდ ერთი .node ფაილის დატესტვა\n"
#: tools/gtk-rendernode-tool-compare.c:65
#: tools/gtk-rendernode-tool-render.c:195
#: tools/gtk-rendernode-tool-render.c:254
msgid "Renderer to use"
msgstr "გამოყენებული რენდერერი"
@@ -7890,7 +7881,7 @@ msgid "Must specify two files\n"
msgstr "აუცილებელია ორი ფაილის მითითება\n"
#: tools/gtk-rendernode-tool-compare.c:102
#: tools/gtk-rendernode-tool-render.c:150
#: tools/gtk-rendernode-tool-render.c:209
#, c-format
msgid "Failed to create renderer: %s\n"
msgstr "რენდერერის შექმნა ჩავარდა: %s\n"
@@ -7951,7 +7942,7 @@ msgstr "შეიყვანეთ ინფორმაცია რენდ
msgid "Can only accept a single .node file\n"
msgstr "შეგიძლიათ მხოლოდ ერთი .node ფაილის მიღება\n"
#: tools/gtk-rendernode-tool-render.c:123
#: tools/gtk-rendernode-tool-render.c:170
#, c-format
msgid ""
"File %s exists.\n"
@@ -7961,16 +7952,17 @@ msgstr ""
"თუ გნებავთ, თავზე გადააწეროთ, ფაილის სახელი მიუთითეთ.\n"
"\n"
#: tools/gtk-rendernode-tool-render.c:137
#: tools/gtk-rendernode-tool-render.c:184
#: tools/gtk-rendernode-tool-render.c:196
#, c-format
msgid "Failed to generate SVG: %s\n"
msgstr "შეცდომა SVG-ის გენერაციისას: %s\n"
#: tools/gtk-rendernode-tool-render.c:211
#: tools/gtk-rendernode-tool-render.c:270
msgid "Render a .node file to an image."
msgstr ".ui ფაილის რენდერი გამოსახულებაში."
#: tools/gtk-rendernode-tool-render.c:230
#: tools/gtk-rendernode-tool-render.c:289
#, c-format
msgid "Can only render a single .node file to a single output file\n"
msgstr "ერთი .node ფაილის მხოლოდ ერთ გამოტანის ფაილში რენდერი შეგიძლიათ\n"
@@ -8106,6 +8098,24 @@ msgstr ""
"თუ მართლა გნებავთ, ხატულების კეში აქ შექმნათ, --ignore-theme-index "
"გამოიყენეთ.\n"
#~ msgid "Antialiasing"
#~ msgstr "მომრგვალება"
#~ msgid "Hinting"
#~ msgstr "მომრგვალება"
#~ msgid "None"
#~ msgstr "არცერთი"
#~ msgid "Slight"
#~ msgstr "ოდნავ"
#~ msgid "Full"
#~ msgstr "სრული"
#~ msgid "Metrics Hinting"
#~ msgstr "მეტრიკის მომრგვალება"
#~ msgid "Backend does not support window scaling"
#~ msgstr "უკანაბოლოს ფანჯრის მასშტაბირების მხარდაჭერა არ გააჩნია"

1522
po/pt.po

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,14 @@
/* test variable changes */
box {
--test: red;
color: var(--test, green);
}
label:hover {
--test: blue;
}
label:active {
--test: initial;
}

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