Compare commits
270 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3ff7c86b65 | |||
| 79a0f183ec | |||
| e8c8be8e37 | |||
| bfc80c32ea | |||
| 5f48764ac8 | |||
| cc6fcbfc09 | |||
| ea7185bdb1 | |||
| 429dfcf483 | |||
| be3f352b59 | |||
| 5b8896f1db | |||
| 4e27de7df9 | |||
| 2712f536c2 | |||
| a1f7073ff5 | |||
| 9770872d12 | |||
| de24b4f91b | |||
| 650fd9c291 | |||
| b509809f34 | |||
| 60ff231fac | |||
| 958005317b | |||
| 15c36aaa1e | |||
| 482b73c376 | |||
| 4a8bf6e13d | |||
| 3e2e6633b0 | |||
| 4724f9907c | |||
| 26e84a7b8c | |||
| d5838f14f9 | |||
| 5c532104e4 | |||
| 2f42e1fb89 | |||
| b5200bd076 | |||
| aa5bd38137 | |||
| 0eba833595 | |||
| 1e0ea21297 | |||
| e91e75173d | |||
| 927fdb9a83 | |||
| 041f410838 | |||
| c71c8919fe | |||
| 3f28399f7d | |||
| 3c15fa96bc | |||
| 0a0a059397 | |||
| 18e83fe16d | |||
| 90d7ed5dd1 | |||
| 3c6e7569ff | |||
| 4e2ec2d68d | |||
| 1af72eac21 | |||
| 640273a0e2 | |||
| a14a0c6315 | |||
| 38481680e1 | |||
| 12a540c284 | |||
| 289bf078bf | |||
| 58ab9ddc40 | |||
| c78036fc51 | |||
| 120f2768e6 | |||
| 592b33cb48 | |||
| 7a9bc1f1d8 | |||
| 9cc6f3ee29 | |||
| 9efaa0b51d | |||
| f0967fa5e4 | |||
| f8529983f9 | |||
| 919c08d4fd | |||
| e9b06b6346 | |||
| 949c783187 | |||
| 814a4a781a | |||
| 676f875bf6 | |||
| 140c5c5333 | |||
| cebf2b2009 | |||
| 86b437a1b6 | |||
| 773ae0cd0f | |||
| 564793d5b5 | |||
| 9142aa0f51 | |||
| af9a578d68 | |||
| ecb072fdd0 | |||
| ef053ebb4a | |||
| 8d18d93742 | |||
| 10fcdd88e3 | |||
| 5d9509c51b | |||
| c9cac5fbc3 | |||
| aa9054a5f1 | |||
| 9ebf3fac73 | |||
| 569294070b | |||
| be35c46ce9 | |||
| dbbcb13721 | |||
| edeaf9c040 | |||
| 61f709811c | |||
| f7c4375509 | |||
| 52fb900ced | |||
| 031944ad30 | |||
| bf8b974f68 | |||
| 6ad2a049e7 | |||
| 3d85d53e5d | |||
| 094a346539 | |||
| 162814f969 | |||
| e39b5c99f1 | |||
| 8883243aaa | |||
| 89511eecf1 | |||
| 2c304ca80d | |||
| bf4102e664 | |||
| b86153cee3 | |||
| 7985d277b3 | |||
| 752da5c2a5 | |||
| de4b8d547b | |||
| 1048ad1a01 | |||
| 4d11158d97 | |||
| 293b81cad2 | |||
| 65c38111f9 | |||
| ec8db379a6 | |||
| 1484b4ae9f | |||
| 4cecbf1654 | |||
| 234ba90e2b | |||
| bdd2244f75 | |||
| cd7ec8ac92 | |||
| cc5edbbbb2 | |||
| 94d9e34dd3 | |||
| 3dbf5038fa | |||
| 456a2f3bcf | |||
| 8e1fa52d14 | |||
| cbf2feb633 | |||
| afe8ee501c | |||
| 4644dab081 | |||
| b37a69d76c | |||
| 51bc6ce2e4 | |||
| 988ebc2248 | |||
| 9f31e95420 | |||
| 3a076e26f7 | |||
| e3e85fc6f3 | |||
| ad3a35b4c5 | |||
| 454caa3eec | |||
| 0ffe67ffed | |||
| 8eb46bbfb2 | |||
| d8e8b3c235 | |||
| 79f273348d | |||
| fc99081658 | |||
| aba14e6a43 | |||
| 8ebcef97ff | |||
| 00956a3770 | |||
| 11f3b7730c | |||
| f63e6394ac | |||
| bbca4c38df | |||
| 28f5d26719 | |||
| bf2620f041 | |||
| 870b82b541 | |||
| 1635d9fb78 | |||
| 20fb155e8c | |||
| da59c77ae2 | |||
| 0d0bdaa02e | |||
| 04cf5044da | |||
| b005cd0bbd | |||
| f5379d2047 | |||
| 98c247ec29 | |||
| 38e2f9138d | |||
| 3cc7d9b8c0 | |||
| 1ac9400712 | |||
| 10d5705b70 | |||
| 2d0d579735 | |||
| ac0f524722 | |||
| 2cd0e5f60b | |||
| d83502d054 | |||
| 9e539a7f59 | |||
| c60247f51f | |||
| 06321511ad | |||
| 2e7923cad0 | |||
| 3c66c27caa | |||
| 7f4bd6917e | |||
| b89376da55 | |||
| a1dd6521e8 | |||
| 0088f840fe | |||
| 1b698c896e | |||
| 04000f28e7 | |||
| 976a05f6eb | |||
| b15902bf44 | |||
| 5ac7529771 | |||
| bbf68c0d9d | |||
| eeb3dd3511 | |||
| 7b0ce11e46 | |||
| 8ef1d6a49c | |||
| 7db60f958d | |||
| 30043e072e | |||
| 5ee7606779 | |||
| 25409c5a5a | |||
| 51122dd287 | |||
| ec9159f983 | |||
| f3d77d1c21 | |||
| 1258fcaaf4 | |||
| 00fd60aaa8 | |||
| c7a7d0582a | |||
| b6e7acfb90 | |||
| 40eae298d5 | |||
| 09a9131a10 | |||
| c93c9f5c2a | |||
| 7f08adc23e | |||
| f41012080f | |||
| 786e9d351c | |||
| 3d2cf97fbf | |||
| 1fe6fb6739 | |||
| 6710eb5eb3 | |||
| 80b1d55683 | |||
| 1cebc4316b | |||
| 20895d6f3f | |||
| 65a4118d50 | |||
| 4857829aaa | |||
| 2ea4574caf | |||
| 102b74f9eb | |||
| 8a0d4dfa94 | |||
| b4e645862a | |||
| ea48506a32 | |||
| 23f0a29260 | |||
| 9249717cf4 | |||
| 4196dfc374 | |||
| 23af707b41 | |||
| 421088c3a0 | |||
| 749f1a7c00 | |||
| 344f9fcf05 | |||
| 4c971cd4da | |||
| 43d553dcfb | |||
| 66264f9a3d | |||
| 269f369541 | |||
| 1973019962 | |||
| fe515c4c1c | |||
| 14f0a0addb | |||
| 64a2d0221c | |||
| 0ef91c3ba8 | |||
| 2adcb7be71 | |||
| a332f2402a | |||
| 131a61c51b | |||
| 39d5dd89c5 | |||
| 341efe9a40 | |||
| 5ed6f89b4a | |||
| 4d609149d2 | |||
| 0d790505aa | |||
| a486536925 | |||
| e808fb424a | |||
| 6c54abeca7 | |||
| d24b8a094c | |||
| c46391420f | |||
| 68df7527f7 | |||
| 5a3c3d8210 | |||
| 95ceb49770 | |||
| 0bde58ffd7 | |||
| ccd9827b63 | |||
| db189cfb9f | |||
| 7527f181d5 | |||
| c05b418512 | |||
| e97d996fe4 | |||
| 0537b167ca | |||
| 40446201ff | |||
| fff6b35821 | |||
| 75f2d7583f | |||
| 1fd8d3b487 | |||
| a1216599ff | |||
| 8fff0e0fdf | |||
| 439727a84a | |||
| 3a18a6dddf | |||
| d7050c63ae | |||
| b7c88ec87d | |||
| 5985b62f60 | |||
| e7c29b989c | |||
| 2100e427d9 | |||
| 2550d6dc63 | |||
| ca72fae884 | |||
| 4fc1af14a7 | |||
| 1a30ec6da6 | |||
| e77d519482 | |||
| 59806eee38 | |||
| 5968b10b0b | |||
| e6f0103940 | |||
| cbaad3dbd9 | |||
| ee43a6a603 | |||
| 1ac1147ecb | |||
| 1edbc1f1f9 | |||
| 601dfeeff9 | |||
| 2c9f2325e2 |
@@ -65,6 +65,7 @@ RUN dnf -y install \
|
||||
libxslt \
|
||||
mesa-dri-drivers \
|
||||
mesa-libEGL-devel \
|
||||
mesa-libGLES-devel \
|
||||
mesa-libwayland-egl-devel \
|
||||
ninja-build \
|
||||
pango-devel \
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM registry.gitlab.gnome.org/gnome/gtk/fedora-base:v25
|
||||
FROM registry.gitlab.gnome.org/gnome/gtk/fedora-base:v27
|
||||
|
||||
# Enable sudo for wheel users
|
||||
RUN sed -i -e 's/# %wheel/%wheel/' -e '0,/%wheel/{s/%wheel/# %wheel/}' /etc/sudoers
|
||||
|
||||
@@ -8,7 +8,8 @@ builddir=$1
|
||||
backend=$2
|
||||
|
||||
# Ignore memory leaks lower in dependencies
|
||||
export LSAN_OPTIONS=suppressions=$srcdir/lsan.supp
|
||||
export LSAN_OPTIONS=suppressions=$srcdir/lsan.supp:print_suppressions=0
|
||||
export G_SLICE=always-malloc
|
||||
|
||||
case "${backend}" in
|
||||
x11)
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
<!--
|
||||
Please, read the CONTRIBUTING.md guide on how to file a new issue.
|
||||
|
||||
https://gitlab.gnome.org/GNOME/gtk/-/blob/master/CONTRIBUTING.md
|
||||
-->
|
||||
## Steps to reproduce
|
||||
<!--
|
||||
Please, explain the sequence of actions necessary to reproduce the
|
||||
bug
|
||||
-->
|
||||
|
||||
1. ...
|
||||
2. ...
|
||||
@@ -32,5 +41,8 @@
|
||||
## Additional information
|
||||
<!--
|
||||
- Screenshots or screen recordings are useful for visual errors
|
||||
- Attaching a screenshot or a video without explaining the current
|
||||
behavior and the actions necessary to reproduce the bug will lead
|
||||
to the bug being closed
|
||||
- Please report any warning or message printed on the terminal
|
||||
-->
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
<!--
|
||||
Please, read the CONTRIBUTING.md guide on how to file a new issue.
|
||||
|
||||
https://gitlab.gnome.org/GNOME/gtk/-/blob/master/CONTRIBUTING.md
|
||||
-->
|
||||
|
||||
## Steps to reproduce
|
||||
<!--
|
||||
Please, explain the sequence of actions necessary to reproduce the
|
||||
crash
|
||||
-->
|
||||
|
||||
1. ...
|
||||
2. ...
|
||||
|
||||
@@ -1,55 +1,56 @@
|
||||
Overview of Changes in 4.0.3
|
||||
Overview of Changes in 4.1.0
|
||||
============================
|
||||
|
||||
* GtkWidget:
|
||||
- Enforce the can-focus property
|
||||
* GtkCheckButton:
|
||||
- Add back an activate signal
|
||||
|
||||
* GtkSearchBar, GtkSearchEntry:
|
||||
- Capture events in the bubble phase
|
||||
|
||||
* GtkEmojiChooser:
|
||||
- Adapt to small screen sizes
|
||||
|
||||
* GtkVideo:
|
||||
- Avoid tearing when using gstreamer with GL
|
||||
|
||||
* Accessibility:
|
||||
- Speed up cache population
|
||||
- Make context realization lazier
|
||||
|
||||
* CSS:
|
||||
- Fix shadow transitions
|
||||
- Fix issues with GL support
|
||||
|
||||
* Themes:
|
||||
- Adwaita: Allow suggested and destructive action in lists
|
||||
- Set sort arrows in CSS
|
||||
- Set menu button arrows in CSS
|
||||
- Make scrollbars larger
|
||||
- Supprt circular menubuttons
|
||||
|
||||
* GDK:
|
||||
- Remove warnings about exceeding size bounds
|
||||
* CSS:
|
||||
- Implement transform-origin
|
||||
- Support overlines on text
|
||||
- Support colors in cross-fade()
|
||||
- More complete text-decoration-line support
|
||||
|
||||
* Vulkan:
|
||||
- Fix uploading image regions
|
||||
* Text layout:
|
||||
- Use subpixel positioning with new enough cairo
|
||||
|
||||
* Inspector:
|
||||
- Fix slowness in navigation
|
||||
- Redo the controllers and shortcuts pages
|
||||
|
||||
* Accessibility:
|
||||
- Create AT context objects lazily
|
||||
|
||||
* Wayland:
|
||||
- Abort if the shared memory pool cannot be created
|
||||
- Explicitly announce ssd for kwin
|
||||
- Signal gtk-shell surface destruction to mutter
|
||||
- Fix decoration negotiation under kwin
|
||||
|
||||
* X11:
|
||||
- Fix several DND problems
|
||||
* GSK:
|
||||
- Optimize gradient shaders
|
||||
- Implement repeating gradients in shaders
|
||||
|
||||
* Windows:
|
||||
- Avoid UAC in gtk4-update-icon-cache on 32bit Windows
|
||||
|
||||
* MacOS:
|
||||
- Use correct module file extension
|
||||
|
||||
* tools:
|
||||
- Make gtk-builder-tool translate GtkImage:pixbuf to :file
|
||||
|
||||
* Translation updates:
|
||||
Brazilian Portuguese
|
||||
Czech
|
||||
Galician
|
||||
Greek
|
||||
Portuguese
|
||||
Punjabi
|
||||
Slovenian
|
||||
Spanish
|
||||
Swedish
|
||||
* Translation updates
|
||||
- Czech
|
||||
- Greek
|
||||
- Hungarian
|
||||
- Persian
|
||||
- Punjabi
|
||||
- Romanian
|
||||
- Swedish
|
||||
- Ukrainian
|
||||
|
||||
|
||||
Overview of Changes in 4.0.2
|
||||
|
||||
@@ -700,6 +700,16 @@ out:
|
||||
g_free (source_dir);
|
||||
}
|
||||
|
||||
static void
|
||||
dark_mode_cb (GtkToggleButton *button,
|
||||
GParamSpec *pspec,
|
||||
NodeEditorWindow *self)
|
||||
{
|
||||
g_object_set (gtk_widget_get_settings (GTK_WIDGET (self)),
|
||||
"gtk-application-prefer-dark-theme", gtk_toggle_button_get_active (button),
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
node_editor_window_finalize (GObject *object)
|
||||
{
|
||||
@@ -814,6 +824,7 @@ node_editor_window_class_init (NodeEditorWindowClass *class)
|
||||
gtk_widget_class_bind_template_callback (widget_class, export_image_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, testcase_save_clicked_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, testcase_name_entry_changed_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, dark_mode_cb);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
@@ -910,6 +921,26 @@ node_editor_window_init (NodeEditorWindow *self)
|
||||
self->text_buffer = gtk_text_buffer_new (self->tag_table);
|
||||
g_signal_connect (self->text_buffer, "changed", G_CALLBACK (text_changed), self);
|
||||
gtk_text_view_set_buffer (GTK_TEXT_VIEW (self->text_view), self->text_buffer);
|
||||
|
||||
/* Default */
|
||||
gtk_text_buffer_set_text (self->text_buffer,
|
||||
"shadow {\n"
|
||||
" child: texture {\n"
|
||||
" bounds: 0 0 128 128;\n"
|
||||
" texture: url(\"resource:///org/gtk/gtk4/node-editor/icons/apps/org.gtk.gtk4.NodeEditor.Devel.svg\");\n"
|
||||
" }\n"
|
||||
" shadows: rgba(0,0,0,0.5) 0 1 12;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"transform {\n"
|
||||
" child: text {\n"
|
||||
" color: rgb(46,52,54);\n"
|
||||
" font: \"Cantarell Bold 11\";\n"
|
||||
" glyphs: \"GTK Node Editor\";\n"
|
||||
" offset: 8 14.418;\n"
|
||||
" }\n"
|
||||
" transform: translate(0, 140);\n"
|
||||
"}", -1);
|
||||
}
|
||||
|
||||
NodeEditorWindow *
|
||||
|
||||
@@ -139,6 +139,15 @@
|
||||
<property name="icon-name">open-menu-symbolic</property>
|
||||
</object>
|
||||
</child>
|
||||
<child type="end">
|
||||
<object class="GtkToggleButton" id="dark_bg_button">
|
||||
<property name="valign">center</property>
|
||||
<property name="has-frame">0</property>
|
||||
<property name="icon-name">display-brightness-symbolic</property>
|
||||
<property name="tooltip-text" translatable="yes">Use a dark background</property>
|
||||
<signal name="notify::active" handler="dark_mode_cb" swapped="0"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
|
||||
@@ -18,9 +18,9 @@ Length
|
||||
Percentage
|
||||
: %, calc()
|
||||
Angle
|
||||
: deg | grad | turn, calc()
|
||||
: deg, grad, turn, calc()
|
||||
Time
|
||||
: s | ms, calc()
|
||||
: s, ms, calc()
|
||||
|
||||
Length values with the em or ex units are resolved using the font
|
||||
size value, unless they occur in setting the font-size itself, in
|
||||
@@ -32,7 +32,7 @@ not quite the same as the CSS definition of rem.
|
||||
The calc() notation adds considerable expressive power. There are limits
|
||||
on what types can be combined in such an expression (e.g. it does not make
|
||||
sense to add a number and a time). For the full details, see the
|
||||
[CSS3 VAlues and Units](https://www.w3.org/TR/css3-values/#calc-notation)
|
||||
[CSS3 Values and Units](https://www.w3.org/TR/css3-values/#calc-notation)
|
||||
spec.
|
||||
|
||||
A common pattern among shorthand properties (called 'four sides') is one
|
||||
@@ -80,6 +80,31 @@ and in some cases a number as arguments.
|
||||
|
||||
## Images
|
||||
|
||||
CSS allows to specify images in various forms, the most simple one being
|
||||
a url for an image file. Beyond that, images can be specified as
|
||||
|
||||
`linear-gradient(Angle, ColorStops)`
|
||||
`repeating-linear-gradient(Angle, ColorStops)`
|
||||
: creates a linear gradient.
|
||||
|
||||
`radial-gradient(Shape, ColorStops)`
|
||||
`repeating-radial-gradient(Shape, ColorStops)`
|
||||
: creates a radial gradient.
|
||||
|
||||
`conic-gradient(Angle, ColorStops)`
|
||||
: creates a conic gradient.
|
||||
|
||||
`cross-fade(Percentage Image,…)`
|
||||
: combines two or more images.
|
||||
|
||||
`image(Image,… Color)`
|
||||
: falls back to the first valid image, or to a solid color.
|
||||
|
||||
`filter(Image, Filters)`
|
||||
: applies filters to an image.
|
||||
|
||||
For more details, see [CSS Image Level 4](https://www.w3.org/TR/css-images-4/).
|
||||
|
||||
GTK extends the CSS syntax for images and also uses it for specifying icons.
|
||||
To load a themed icon, use
|
||||
|
||||
@@ -129,7 +154,7 @@ done with
|
||||
|:-----------|:----------|:------|
|
||||
|color | [CSS Color Level 3](https://www.w3.org/TR/css3-color/#foreground) | |
|
||||
|opacity | [CSS Color Level 3](https://www.w3.org/TR/css3-color/#opacity) | |
|
||||
|filter | [CSS Filter Effect Level 1](https://drafts.fxtf.org/filters/#FilterProperty) | CSS allows drop-shadow |
|
||||
|filter | [CSS Filter Effect Level 1](https://drafts.fxtf.org/filters/#FilterProperty) | |
|
||||
|font-family | [CSS Fonts Level 3](https://www.w3.org/TR/css3-fonts/#font-family-prop) | defaults to gtk-font-name setting |
|
||||
|font-size | [CSS Fonts Level 3](https://www.w3.org/TR/css3-fonts/#font-size-prop) | defaults to gtk-font-name setting |
|
||||
|font-style | [CSS Fonts Level 3](https://www.w3.org/TR/css3-fonts/#font-style-prop) | |
|
||||
@@ -151,7 +176,7 @@ done with
|
||||
|caret-color|[CSS Basic User Interface Level 3](https://www.w3.org/TR/css3-ui/#caret-color) | CSS allows an auto value |
|
||||
|-gtk-secondary-caret-color|[Color](https://www.w3.org/TR/css-color-3/#valuea-def-color) | used for the secondary caret in bidirectional text |
|
||||
|letter-spacing| [CSS Text Level 3](https://www.w3.org/TR/css3-text/#letter-spacing) | |
|
||||
|text-decoration-line| [CSS Text Decoration Level 3](https://www.w3.org/TR/css-text-decor-3/#text-decoration-line-property) | CSS allows overline |
|
||||
|text-decoration-line| [CSS Text Decoration Level 3](https://www.w3.org/TR/css-text-decor-3/#text-decoration-line-property) | |
|
||||
|text-decoration-color| [CSS Text Decoration Level 3](https://www.w3.org/TR/css-text-decor-3/#text-decoration-color-property) | |
|
||||
|text-decoration-style| [CSS Text Decoration Level 3](https://www.w3.org/TR/css-text-decor-3/#text-decoration-style-property) | CSS allows dashed and dotted |
|
||||
|text-shadow| [CSS Text Decoration Level 3](https://www.w3.org/TR/css-text-decor-3/#text-shadow-property) | |
|
||||
@@ -159,11 +184,12 @@ done with
|
||||
|-gtk-icon-source| [Image](https://www.w3.org/TR/css-backgrounds-3/#typedef-image), `builtin` or `none` | used for builtin icons in buttons and expanders |
|
||||
|-gtk-icon-size| [Length](https://www.w3.org/TR/css3-values/#length-value) | size used for builtin icons in buttons and expanders |
|
||||
|-gtk-icon-style| `requested`, `regular` or `symbolic` | preferred style for application-loaded icons |
|
||||
|-gtk-icon-transform| [Transform list](https://drafts.csswg.org/css-transforms-1/#typedef-transform-list) or `none` | applied to builtin and application-loaded icons |
|
||||
|-gtk-icon-transform| [Transform list](https://www.w3.org/TR/css-transforms-1/#typedef-transform-list) or `none` | applied to builtin and application-loaded icons |
|
||||
|-gtk-icon-palette| Color palette, as explained above | used to recolor symbolic icons |
|
||||
|-gtk-icon-shadow| [Shadow](https://www.w3.org/TR/css-backgrounds-3/#typedef-shadow) or `none` | applied to builtin and application-loaded icons |
|
||||
|-gtk-icon-filter| [Filter value list](https://www.w3.org/TR/filter-effects-1/#typedef-filter-value-list) or `none` | applied to builtin and application-loaded icons |
|
||||
|transform| [CSS Transforms Level 2](https://drafts.csswg.org/css-transforms-2/) | |
|
||||
|transform| [CSS Transforms Level 1](https://www.w3.org/TR/css-transforms-1/#transform-property) | |
|
||||
|transform-origin| [CSS Transforms Level 1](https://www.w3.org/TR/css-transforms-1/#transform-origin-property) | CSS allows specifying a z component|
|
||||
|min-width| [CSS Box Model Level 3](https://www.w3.org/TR/css3-box/#min-width) | CSS allows percentages |
|
||||
|min-height| [CSS Box Model Level 3](https://www.w3.org/TR/css3-box/#min-height) | CSS allows percentages |
|
||||
|margin-top| [CSS Box Model Level 3](https://www.w3.org/TR/css3-box/#margin-top) | CSS allows percentages or auto |
|
||||
@@ -217,7 +243,7 @@ done with
|
||||
|background-size| [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#background-size) | |
|
||||
|background-position| [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#background-position) | |
|
||||
|background-repeat| [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#background-repeat) | |
|
||||
|background-image| [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#background-image) | not supported: urls without quotes, colors in crossfades |
|
||||
|background-image| [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#background-image) | not supported: urls without quotes |
|
||||
|box-shadow| [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#box-shadow) | |
|
||||
|background-blend-mode| [CSS Compositing and Blending Level 1](https://www.w3.org/TR/compositing-1/#propdef-background-blend-mode) | only affects multiple backgrounds |
|
||||
|background| [CSS Backgrounds and Borders Level 3](https://www.w3.org/TR/css3-background/#background) | |
|
||||
|
||||
@@ -343,20 +343,19 @@ Many widgets, like buttons, do all their drawing themselves. You just tell
|
||||
them the label you want to see, and they figure out what font to use, draw
|
||||
the button outline and focus rectangle, etc. Sometimes, it is necessary to
|
||||
do some custom drawing. In that case, a GtkDrawingArea might be the right
|
||||
widget to use. It offers a canvas on which you can draw by connecting to
|
||||
the ::draw signal.
|
||||
widget to use. It offers a canvas on which you can draw by setting its
|
||||
draw function.
|
||||
|
||||
The contents of a widget often need to be partially or fully redrawn,
|
||||
e.g. when another window is moved and uncovers part of the widget, or
|
||||
when the window containing it is resized. It is also possible to explicitly
|
||||
cause part or all of the widget to be redrawn, by calling
|
||||
gtk_widget_queue_draw() or its variants. GTK takes care of most of the
|
||||
details by providing a ready-to-use cairo context to the ::draw signal
|
||||
handler.
|
||||
cause a widget to be redrawn, by calling gtk_widget_queue_draw(). GTK takes
|
||||
care of most of the details by providing a ready-to-use cairo context to the
|
||||
draw function.
|
||||
|
||||
The following example shows a ::draw signal handler. It is a bit more
|
||||
complicated than the previous examples, since it also demonstrates
|
||||
input event handling by means of event controllers.
|
||||
The following example shows how to use a draw function with GtkDrawingArea.
|
||||
It is a bit more complicated than the previous examples, since it also
|
||||
demonstrates input event handling with event controllers.
|
||||
|
||||

|
||||
|
||||
|
||||
@@ -1831,7 +1831,6 @@ GtkIMContextSimple
|
||||
gtk_im_context_simple_new
|
||||
gtk_im_context_simple_add_table
|
||||
gtk_im_context_simple_add_compose_file
|
||||
GTK_MAX_COMPOSE_LEN
|
||||
<SUBSECTION Standard>
|
||||
GTK_IM_CONTEXT_SIMPLE
|
||||
GTK_IS_IM_CONTEXT_SIMPLE
|
||||
|
||||
+16
-4
@@ -2960,8 +2960,8 @@ gdk_surface_request_motion (GdkSurface *surface)
|
||||
* gdk_surface_translate_coordinates:
|
||||
* @from: the origin surface
|
||||
* @to: the target surface
|
||||
* @x: coordinates to translate
|
||||
* @y: coordinates to translate
|
||||
* @x: (inout): coordinates to translate
|
||||
* @y: (inout): coordinates to translate
|
||||
*
|
||||
* Translates the given coordinates from being
|
||||
* relative to the @from surface to being relative
|
||||
@@ -2980,9 +2980,18 @@ gdk_surface_translate_coordinates (GdkSurface *from,
|
||||
double *x,
|
||||
double *y)
|
||||
{
|
||||
double in_x, in_y, out_x, out_y;
|
||||
int x1, y1, x2, y2;
|
||||
GdkSurface *f, *t;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_SURFACE (from), FALSE);
|
||||
g_return_val_if_fail (GDK_IS_SURFACE (to), FALSE);
|
||||
g_return_val_if_fail (x != NULL, FALSE);
|
||||
g_return_val_if_fail (y != NULL, FALSE);
|
||||
|
||||
in_x = *x;
|
||||
in_y = *y;
|
||||
|
||||
x1 = 0;
|
||||
y1 = 0;
|
||||
f = from;
|
||||
@@ -3006,8 +3015,11 @@ gdk_surface_translate_coordinates (GdkSurface *from,
|
||||
if (f != t)
|
||||
return FALSE;
|
||||
|
||||
*x += x1 - x2;
|
||||
*y += y1 - y2;
|
||||
out_x = in_x + (x1 - x2);
|
||||
out_y = in_y + (y1 - y2);
|
||||
|
||||
*x = out_x;
|
||||
*y = out_y;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -78,6 +78,14 @@
|
||||
*/
|
||||
#define GDK_VERSION_4_0 (G_ENCODE_VERSION (4, 0))
|
||||
|
||||
/**
|
||||
* GDK_VERSION_4_2:
|
||||
*
|
||||
* A macro that evaluates to the 4.2 version of GDK, in a format
|
||||
* that can be used by the C pre-processor.
|
||||
*/
|
||||
#define GDK_VERSION_4_2 (G_ENCODE_VERSION (4, 2))
|
||||
|
||||
|
||||
/* evaluates to the current stable version; for development cycles,
|
||||
* this means the next stable target, with a hard backstop to the
|
||||
@@ -175,4 +183,19 @@
|
||||
# define GDK_DEPRECATED_IN_4_0_FOR(f) _GDK_EXTERN
|
||||
#endif
|
||||
|
||||
|
||||
#if GDK_VERSION_MAX_ALLOWED < GDK_VERSION_4_2
|
||||
# define GDK_AVAILABLE_IN_4_2 GDK_UNAVAILABLE(4, 2)
|
||||
#else
|
||||
# define GDK_AVAILABLE_IN_4_2 _GDK_EXTERN
|
||||
#endif
|
||||
|
||||
#if GDK_VERSION_MIN_REQUIRED >= GDK_VERSION_4_2
|
||||
# define GDK_DEPRECATED_IN_4_2 GDK_DEPRECATED
|
||||
# define GDK_DEPRECATED_IN_4_2_FOR(f) GDK_DEPRECATED_FOR(f)
|
||||
#else
|
||||
# define GDK_DEPRECATED_IN_4_2 _GDK_EXTERN
|
||||
# define GDK_DEPRECATED_IN_4_2_FOR(f) _GDK_EXTERN
|
||||
#endif
|
||||
|
||||
#endif /* __GDK_VERSION_MACROS_H__ */
|
||||
|
||||
@@ -547,6 +547,20 @@ _gdk_macos_display_surface_resigned_key (GdkMacosDisplay *self,
|
||||
_gdk_macos_display_clear_sorting (self);
|
||||
}
|
||||
|
||||
/* Raises a transient window.
|
||||
*/
|
||||
static void
|
||||
raise_transient (GdkMacosSurface *surface)
|
||||
{
|
||||
GdkMacosSurface *parent_surface = GDK_MACOS_SURFACE (GDK_SURFACE (surface)->transient_for);
|
||||
|
||||
NSWindow *parent = _gdk_macos_surface_get_native (parent_surface);
|
||||
NSWindow *window = _gdk_macos_surface_get_native (surface);
|
||||
|
||||
[parent removeChildWindow:window];
|
||||
[parent addChildWindow:window ordered:NSWindowAbove];
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_macos_display_surface_became_main (GdkMacosDisplay *self,
|
||||
GdkMacosSurface *surface)
|
||||
@@ -559,6 +573,9 @@ _gdk_macos_display_surface_became_main (GdkMacosDisplay *self,
|
||||
|
||||
g_queue_push_head_link (&self->main_surfaces, &surface->main);
|
||||
|
||||
if (GDK_SURFACE (surface)->transient_for)
|
||||
raise_transient (surface);
|
||||
|
||||
_gdk_macos_display_clear_sorting (self);
|
||||
}
|
||||
|
||||
|
||||
+33
-54
@@ -296,20 +296,15 @@ gdk_x11_drag_find (GdkDisplay *display,
|
||||
static void
|
||||
precache_target_list (GdkDrag *drag)
|
||||
{
|
||||
GdkContentFormats *formats;
|
||||
GdkContentFormats *formats = gdk_drag_get_formats (drag);
|
||||
const char * const *atoms;
|
||||
gsize n_atoms;
|
||||
|
||||
formats = gdk_content_formats_ref (gdk_drag_get_formats (drag));
|
||||
formats = gdk_content_formats_union_serialize_mime_types (formats);
|
||||
|
||||
atoms = gdk_content_formats_get_mime_types (formats, &n_atoms);
|
||||
|
||||
_gdk_x11_precache_atoms (gdk_drag_get_display (drag),
|
||||
(const char **) atoms,
|
||||
n_atoms);
|
||||
|
||||
gdk_content_formats_unref (formats);
|
||||
}
|
||||
|
||||
/* Utility functions */
|
||||
@@ -922,12 +917,8 @@ xdnd_set_targets (GdkX11Drag *drag_x11)
|
||||
const char * const *atoms;
|
||||
gsize i, n_atoms;
|
||||
GdkDisplay *display = gdk_drag_get_display (drag);
|
||||
GdkContentFormats *formats;
|
||||
|
||||
formats = gdk_content_formats_ref (gdk_drag_get_formats (drag));
|
||||
formats = gdk_content_formats_union_serialize_mime_types (formats);
|
||||
|
||||
atoms = gdk_content_formats_get_mime_types (formats, &n_atoms);
|
||||
atoms = gdk_content_formats_get_mime_types (gdk_drag_get_formats (drag), &n_atoms);
|
||||
atomlist = g_new (Atom, n_atoms);
|
||||
for (i = 0; i < n_atoms; i++)
|
||||
atomlist[i] = gdk_x11_get_xatom_by_name_for_display (display, atoms[i]);
|
||||
@@ -941,8 +932,6 @@ xdnd_set_targets (GdkX11Drag *drag_x11)
|
||||
g_free (atomlist);
|
||||
|
||||
drag_x11->xdnd_targets_set = 1;
|
||||
|
||||
gdk_content_formats_unref (formats);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1106,8 +1095,6 @@ xdnd_send_enter (GdkX11Drag *drag_x11)
|
||||
}
|
||||
|
||||
xdnd_send_xevent (drag_x11, &xev);
|
||||
|
||||
gdk_content_formats_unref (formats);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1347,7 +1334,7 @@ _gdk_x11_display_get_drag_protocol (GdkDisplay *display,
|
||||
|
||||
static GdkSurfaceCache *
|
||||
drag_find_window_cache (GdkX11Drag *drag_x11,
|
||||
GdkDisplay *display)
|
||||
GdkDisplay *display)
|
||||
{
|
||||
if (!drag_x11->cache)
|
||||
drag_x11->cache = gdk_surface_cache_get (display);
|
||||
@@ -1378,7 +1365,7 @@ gdk_x11_drag_find_surface (GdkDrag *drag,
|
||||
drag_surface && GDK_IS_X11_SURFACE (drag_surface) ?
|
||||
GDK_SURFACE_XID (drag_surface) : None,
|
||||
x_root * screen_x11->surface_scale,
|
||||
y_root * screen_x11->surface_scale);
|
||||
y_root * screen_x11->surface_scale);
|
||||
|
||||
if (drag_x11->dest_xid != dest)
|
||||
{
|
||||
@@ -1408,8 +1395,8 @@ gdk_x11_drag_find_surface (GdkDrag *drag,
|
||||
|
||||
static void
|
||||
move_drag_surface (GdkDrag *drag,
|
||||
guint x_root,
|
||||
guint y_root)
|
||||
guint x_root,
|
||||
guint y_root)
|
||||
{
|
||||
GdkX11Drag *drag_x11 = GDK_X11_DRAG (drag);
|
||||
|
||||
@@ -1420,14 +1407,14 @@ move_drag_surface (GdkDrag *drag,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_x11_drag_drag_motion (GdkDrag *drag,
|
||||
Window proxy_xid,
|
||||
GdkDragProtocol protocol,
|
||||
int x_root,
|
||||
int y_root,
|
||||
GdkDragAction suggested_action,
|
||||
GdkDragAction possible_actions,
|
||||
guint32 time)
|
||||
gdk_x11_drag_drag_motion (GdkDrag *drag,
|
||||
Window proxy_xid,
|
||||
GdkDragProtocol protocol,
|
||||
int x_root,
|
||||
int y_root,
|
||||
GdkDragAction suggested_action,
|
||||
GdkDragAction possible_actions,
|
||||
guint32 time)
|
||||
{
|
||||
GdkX11Drag *drag_x11 = GDK_X11_DRAG (drag);
|
||||
|
||||
@@ -1619,8 +1606,8 @@ gdk_x11_drag_get_drag_surface (GdkDrag *drag)
|
||||
|
||||
static void
|
||||
gdk_x11_drag_set_hotspot (GdkDrag *drag,
|
||||
int hot_x,
|
||||
int hot_y)
|
||||
int hot_x,
|
||||
int hot_y)
|
||||
{
|
||||
GdkX11Drag *x11_drag = GDK_X11_DRAG (drag);
|
||||
|
||||
@@ -1636,8 +1623,8 @@ gdk_x11_drag_set_hotspot (GdkDrag *drag,
|
||||
|
||||
static void
|
||||
gdk_x11_drag_default_output_done (GObject *drag,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
@@ -1649,17 +1636,17 @@ gdk_x11_drag_default_output_done (GObject *drag,
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_x11_drag_default_output_handler (GOutputStream *stream,
|
||||
const char *mime_type,
|
||||
gpointer user_data)
|
||||
gdk_x11_drag_default_output_handler (GOutputStream *stream,
|
||||
const char *mime_type,
|
||||
gpointer user_data)
|
||||
{
|
||||
gdk_drag_write_async (GDK_DRAG (user_data),
|
||||
mime_type,
|
||||
stream,
|
||||
G_PRIORITY_DEFAULT,
|
||||
NULL,
|
||||
gdk_x11_drag_default_output_done,
|
||||
NULL);
|
||||
mime_type,
|
||||
stream,
|
||||
G_PRIORITY_DEFAULT,
|
||||
NULL,
|
||||
gdk_x11_drag_default_output_done,
|
||||
NULL);
|
||||
g_object_unref (stream);
|
||||
}
|
||||
|
||||
@@ -1688,7 +1675,7 @@ gdk_x11_drag_xevent (GdkDisplay *display,
|
||||
if (xevent->xselectionclear.time < x11_drag->timestamp)
|
||||
{
|
||||
GDK_DISPLAY_NOTE (display, CLIPBOARD, g_printerr ("ignoring SelectionClear with too old timestamp (%lu vs %lu)\n",
|
||||
xevent->xselectionclear.time, x11_drag->timestamp));
|
||||
xevent->xselectionclear.time, x11_drag->timestamp));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1698,7 +1685,6 @@ gdk_x11_drag_xevent (GdkDisplay *display,
|
||||
|
||||
case SelectionRequest:
|
||||
{
|
||||
GdkContentFormats *formats;
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
const char *target, *property;
|
||||
#endif
|
||||
@@ -1717,30 +1703,23 @@ gdk_x11_drag_xevent (GdkDisplay *display,
|
||||
if (xevent->xselectionrequest.requestor == None)
|
||||
{
|
||||
GDK_DISPLAY_NOTE (display, CLIPBOARD, g_printerr ("got SelectionRequest for %s @ %s with NULL window, ignoring\n",
|
||||
target, property));
|
||||
target, property));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GDK_DISPLAY_NOTE (display, CLIPBOARD, g_printerr ("got SelectionRequest for %s @ %s\n",
|
||||
target, property));
|
||||
|
||||
formats = gdk_content_formats_ref (gdk_drag_get_formats (drag));
|
||||
formats = gdk_content_formats_union_serialize_mime_types (formats);
|
||||
target, property));
|
||||
|
||||
gdk_x11_selection_output_streams_create (display,
|
||||
formats,
|
||||
gdk_drag_get_formats (drag),
|
||||
xevent->xselectionrequest.requestor,
|
||||
xevent->xselectionrequest.selection,
|
||||
xevent->xselectionrequest.target,
|
||||
xevent->xselectionrequest.property
|
||||
? xevent->xselectionrequest.property
|
||||
: xevent->xselectionrequest.target,
|
||||
xevent->xselectionrequest.property ? xevent->xselectionrequest.property
|
||||
: xevent->xselectionrequest.target,
|
||||
xevent->xselectionrequest.time,
|
||||
gdk_x11_drag_default_output_handler,
|
||||
drag);
|
||||
|
||||
gdk_content_formats_unref (formats);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -149,10 +149,10 @@ render_glyph (GlyphCacheKey *key,
|
||||
glyph_info.glyph = key->data.glyph;
|
||||
glyph_info.geometry.width = value->draw_width * 1024;
|
||||
if (glyph_info.glyph & PANGO_GLYPH_UNKNOWN_FLAG)
|
||||
glyph_info.geometry.x_offset = 0;
|
||||
glyph_info.geometry.x_offset = 250 * key->data.xshift;
|
||||
else
|
||||
glyph_info.geometry.x_offset = - value->draw_x * 1024;
|
||||
glyph_info.geometry.y_offset = - value->draw_y * 1024;
|
||||
glyph_info.geometry.x_offset = 250 * key->data.xshift - value->draw_x * 1024;
|
||||
glyph_info.geometry.y_offset = 250 * key->data.yshift - value->draw_y * 1024;
|
||||
|
||||
glyph_string.num_glyphs = 1;
|
||||
glyph_string.glyphs = &glyph_info;
|
||||
|
||||
+49
-36
@@ -1452,6 +1452,7 @@ render_linear_gradient_node (GskGLRenderer *self,
|
||||
ops_set_linear_gradient (builder,
|
||||
n_color_stops,
|
||||
stops,
|
||||
gsk_render_node_get_node_type (node) == GSK_REPEATING_LINEAR_GRADIENT_NODE,
|
||||
builder->dx + start->x,
|
||||
builder->dy + start->y,
|
||||
builder->dx + end->x,
|
||||
@@ -1485,6 +1486,7 @@ render_radial_gradient_node (GskGLRenderer *self,
|
||||
ops_set_radial_gradient (builder,
|
||||
n_color_stops,
|
||||
stops,
|
||||
gsk_render_node_get_node_type (node) == GSK_REPEATING_RADIAL_GRADIENT_NODE,
|
||||
builder->dx + center->x,
|
||||
builder->dy + center->y,
|
||||
start, end,
|
||||
@@ -1510,7 +1512,7 @@ render_conic_gradient_node (GskGLRenderer *self,
|
||||
{
|
||||
const GskColorStop *stops = gsk_conic_gradient_node_get_color_stops (node, NULL);
|
||||
const graphene_point_t *center = gsk_conic_gradient_node_get_center (node);
|
||||
const float rotation = gsk_conic_gradient_node_get_rotation (node);
|
||||
const float angle = gsk_conic_gradient_node_get_angle (node);
|
||||
|
||||
ops_set_program (builder, &self->programs->conic_gradient_program);
|
||||
ops_set_conic_gradient (builder,
|
||||
@@ -1518,7 +1520,7 @@ render_conic_gradient_node (GskGLRenderer *self,
|
||||
stops,
|
||||
builder->dx + center->x,
|
||||
builder->dy + center->y,
|
||||
rotation);
|
||||
angle);
|
||||
|
||||
load_vertex_data (ops_draw (builder, NULL), &node->bounds, builder);
|
||||
}
|
||||
@@ -3041,14 +3043,19 @@ apply_linear_gradient_op (const Program *program,
|
||||
op->n_color_stops.value * 5,
|
||||
(float *)op->color_stops.value);
|
||||
|
||||
glUniform2f (program->linear_gradient.start_point_location, op->start_point[0], op->start_point[1]);
|
||||
glUniform2f (program->linear_gradient.end_point_location, op->end_point[0], op->end_point[1]);
|
||||
glUniform4f (program->linear_gradient.points_location,
|
||||
op->start_point[0], op->start_point[1],
|
||||
op->end_point[0] - op->start_point[0], op->end_point[1] - op->start_point[1]);
|
||||
glUniform1i (program->linear_gradient.repeat_location, op->repeat);
|
||||
}
|
||||
|
||||
static inline void
|
||||
apply_radial_gradient_op (const Program *program,
|
||||
const OpRadialGradient *op)
|
||||
{
|
||||
float scale;
|
||||
float bias;
|
||||
|
||||
OP_PRINT (" -> Radial gradient");
|
||||
if (op->n_color_stops.send)
|
||||
glUniform1i (program->radial_gradient.num_color_stops_location, op->n_color_stops.value);
|
||||
@@ -3058,16 +3065,23 @@ apply_radial_gradient_op (const Program *program,
|
||||
op->n_color_stops.value * 5,
|
||||
(float *)op->color_stops.value);
|
||||
|
||||
glUniform1f (program->radial_gradient.start_location, op->start);
|
||||
glUniform1f (program->radial_gradient.end_location, op->end);
|
||||
glUniform2f (program->radial_gradient.radius_location, op->radius[0], op->radius[1]);
|
||||
glUniform2f (program->radial_gradient.center_location, op->center[0], op->center[1]);
|
||||
scale = 1.0f / (op->end - op->start);
|
||||
bias = -op->start * scale;
|
||||
|
||||
glUniform1i (program->radial_gradient.repeat_location, op->repeat);
|
||||
glUniform2f (program->radial_gradient.range_location, scale, bias);
|
||||
glUniform4f (program->radial_gradient.geometry_location,
|
||||
op->center[0], op->center[1],
|
||||
1.0f / op->radius[0], 1.0f / op->radius[1]);
|
||||
}
|
||||
|
||||
static inline void
|
||||
apply_conic_gradient_op (const Program *program,
|
||||
const OpConicGradient *op)
|
||||
{
|
||||
float bias;
|
||||
float scale;
|
||||
|
||||
OP_PRINT (" -> Conic gradient");
|
||||
if (op->n_color_stops.send)
|
||||
glUniform1i (program->conic_gradient.num_color_stops_location, op->n_color_stops.value);
|
||||
@@ -3077,8 +3091,9 @@ apply_conic_gradient_op (const Program *program,
|
||||
op->n_color_stops.value * 5,
|
||||
(float *)op->color_stops.value);
|
||||
|
||||
glUniform1f (program->conic_gradient.rotation_location, op->rotation);
|
||||
glUniform2f (program->conic_gradient.center_location, op->center[0], op->center[1]);
|
||||
scale = 0.5f * M_1_PI;
|
||||
bias = op->angle * scale + 2.0f;
|
||||
glUniform4f (program->conic_gradient.geometry_location, op->center[0], op->center[1], scale, bias);
|
||||
}
|
||||
|
||||
static inline void
|
||||
@@ -3368,22 +3383,20 @@ gsk_gl_renderer_create_programs (GskGLRenderer *self,
|
||||
/* linear gradient */
|
||||
INIT_PROGRAM_UNIFORM_LOCATION (linear_gradient, color_stops);
|
||||
INIT_PROGRAM_UNIFORM_LOCATION (linear_gradient, num_color_stops);
|
||||
INIT_PROGRAM_UNIFORM_LOCATION (linear_gradient, start_point);
|
||||
INIT_PROGRAM_UNIFORM_LOCATION (linear_gradient, end_point);
|
||||
INIT_PROGRAM_UNIFORM_LOCATION (linear_gradient, repeat);
|
||||
INIT_PROGRAM_UNIFORM_LOCATION (linear_gradient, points);
|
||||
|
||||
/* radial gradient */
|
||||
INIT_PROGRAM_UNIFORM_LOCATION (radial_gradient, color_stops);
|
||||
INIT_PROGRAM_UNIFORM_LOCATION (radial_gradient, num_color_stops);
|
||||
INIT_PROGRAM_UNIFORM_LOCATION (radial_gradient, center);
|
||||
INIT_PROGRAM_UNIFORM_LOCATION (radial_gradient, start);
|
||||
INIT_PROGRAM_UNIFORM_LOCATION (radial_gradient, end);
|
||||
INIT_PROGRAM_UNIFORM_LOCATION (radial_gradient, radius);
|
||||
INIT_PROGRAM_UNIFORM_LOCATION (radial_gradient, repeat);
|
||||
INIT_PROGRAM_UNIFORM_LOCATION (radial_gradient, geometry);
|
||||
INIT_PROGRAM_UNIFORM_LOCATION (radial_gradient, range);
|
||||
|
||||
/* conic gradient */
|
||||
INIT_PROGRAM_UNIFORM_LOCATION (conic_gradient, color_stops);
|
||||
INIT_PROGRAM_UNIFORM_LOCATION (conic_gradient, num_color_stops);
|
||||
INIT_PROGRAM_UNIFORM_LOCATION (conic_gradient, center);
|
||||
INIT_PROGRAM_UNIFORM_LOCATION (conic_gradient, rotation);
|
||||
INIT_PROGRAM_UNIFORM_LOCATION (conic_gradient, geometry);
|
||||
|
||||
/* blur */
|
||||
INIT_PROGRAM_UNIFORM_LOCATION (blur, blur_radius);
|
||||
@@ -3729,10 +3742,12 @@ gsk_gl_renderer_add_render_ops (GskGLRenderer *self,
|
||||
break;
|
||||
|
||||
case GSK_LINEAR_GRADIENT_NODE:
|
||||
case GSK_REPEATING_LINEAR_GRADIENT_NODE:
|
||||
render_linear_gradient_node (self, node, builder);
|
||||
break;
|
||||
|
||||
case GSK_RADIAL_GRADIENT_NODE:
|
||||
case GSK_REPEATING_RADIAL_GRADIENT_NODE:
|
||||
render_radial_gradient_node (self, node, builder);
|
||||
break;
|
||||
|
||||
@@ -3799,8 +3814,6 @@ gsk_gl_renderer_add_render_ops (GskGLRenderer *self,
|
||||
render_gl_shader_node (self, node, builder);
|
||||
break;
|
||||
|
||||
case GSK_REPEATING_LINEAR_GRADIENT_NODE:
|
||||
case GSK_REPEATING_RADIAL_GRADIENT_NODE:
|
||||
case GSK_CAIRO_NODE:
|
||||
default:
|
||||
{
|
||||
@@ -3820,7 +3833,7 @@ add_offscreen_ops (GskGLRenderer *self,
|
||||
{
|
||||
const float dx = builder->dx;
|
||||
const float dy = builder->dy;
|
||||
float width, height;
|
||||
float scaled_width, scaled_height;
|
||||
float scale_x;
|
||||
float scale_y;
|
||||
int render_target;
|
||||
@@ -3876,8 +3889,6 @@ add_offscreen_ops (GskGLRenderer *self,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
width = bounds->size.width;
|
||||
height = bounds->size.height;
|
||||
scale_x = builder->scale_x;
|
||||
scale_y = builder->scale_y;
|
||||
|
||||
@@ -3888,23 +3899,23 @@ add_offscreen_ops (GskGLRenderer *self,
|
||||
{
|
||||
const int max_texture_size = gsk_gl_driver_get_max_texture_size (self->gl_driver);
|
||||
|
||||
width = ceilf (width * scale_x);
|
||||
if (width > max_texture_size)
|
||||
scaled_width = ceilf (bounds->size.width * scale_x);
|
||||
if (scaled_width > max_texture_size)
|
||||
{
|
||||
scale_x *= (float)max_texture_size / width;
|
||||
width = max_texture_size;
|
||||
scale_x *= (float)max_texture_size / scaled_width;
|
||||
scaled_width = max_texture_size;
|
||||
}
|
||||
|
||||
height = ceilf (height * scale_y);
|
||||
if (height > max_texture_size)
|
||||
scaled_height = ceilf (bounds->size.height * scale_y);
|
||||
if (scaled_height > max_texture_size)
|
||||
{
|
||||
scale_y *= (float)max_texture_size / height;
|
||||
height = max_texture_size;
|
||||
scale_y *= (float)max_texture_size / scaled_height;
|
||||
scaled_height = max_texture_size;
|
||||
}
|
||||
}
|
||||
|
||||
gsk_gl_driver_create_render_target (self->gl_driver,
|
||||
width, height,
|
||||
scaled_width, scaled_height,
|
||||
filter, filter,
|
||||
&texture_id, &render_target);
|
||||
if (gdk_gl_context_has_debug (self->gl_context))
|
||||
@@ -3919,9 +3930,11 @@ add_offscreen_ops (GskGLRenderer *self,
|
||||
render_target);
|
||||
}
|
||||
|
||||
viewport = GRAPHENE_RECT_INIT ((bounds->origin.x + dx) * scale_x,
|
||||
(bounds->origin.y + dy) * scale_y,
|
||||
width, height);
|
||||
ops_transform_bounds_modelview (builder, bounds, &viewport);
|
||||
/* Code above will scale the size with the scale we use in the render ops,
|
||||
* but for the viewport size, we need our own size limited by the texture size */
|
||||
viewport.size.width = scaled_width;
|
||||
viewport.size.height = scaled_height;
|
||||
|
||||
init_projection_matrix (&item_proj, &viewport);
|
||||
prev_render_target = ops_set_render_target (builder, render_target);
|
||||
@@ -3949,7 +3962,7 @@ add_offscreen_ops (GskGLRenderer *self,
|
||||
g_type_name_from_instance ((GTypeInstance *) child_node),
|
||||
child_node,
|
||||
k ++),
|
||||
width, height);
|
||||
scaled_width, scaled_height);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -859,6 +859,7 @@ void
|
||||
ops_set_linear_gradient (RenderOpBuilder *self,
|
||||
guint n_color_stops,
|
||||
const GskColorStop *color_stops,
|
||||
gboolean repeat,
|
||||
float start_x,
|
||||
float start_y,
|
||||
float end_x,
|
||||
@@ -912,6 +913,7 @@ ops_set_linear_gradient (RenderOpBuilder *self,
|
||||
sizeof (GskColorStop) * real_n_color_stops);
|
||||
}
|
||||
|
||||
op->repeat = repeat;
|
||||
op->start_point[0] = start_x;
|
||||
op->start_point[1] = start_y;
|
||||
op->end_point[0] = end_x;
|
||||
@@ -922,6 +924,7 @@ void
|
||||
ops_set_radial_gradient (RenderOpBuilder *self,
|
||||
guint n_color_stops,
|
||||
const GskColorStop *color_stops,
|
||||
gboolean repeat,
|
||||
float center_x,
|
||||
float center_y,
|
||||
float start,
|
||||
@@ -945,6 +948,7 @@ ops_set_radial_gradient (RenderOpBuilder *self,
|
||||
op->radius[1] = vradius;
|
||||
op->start = start;
|
||||
op->end = end;
|
||||
op->repeat = repeat;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -953,7 +957,7 @@ ops_set_conic_gradient (RenderOpBuilder *self,
|
||||
const GskColorStop *color_stops,
|
||||
float center_x,
|
||||
float center_y,
|
||||
float rotation)
|
||||
float angle)
|
||||
{
|
||||
const guint real_n_color_stops = MIN (GL_MAX_GRADIENT_STOPS, n_color_stops);
|
||||
OpConicGradient *op;
|
||||
@@ -967,6 +971,6 @@ ops_set_conic_gradient (RenderOpBuilder *self,
|
||||
op->color_stops.send = true;
|
||||
op->center[0] = center_x;
|
||||
op->center[1] = center_y;
|
||||
op->rotation = rotation;
|
||||
op->angle = angle;
|
||||
}
|
||||
|
||||
|
||||
@@ -118,22 +118,20 @@ struct _Program
|
||||
struct {
|
||||
int num_color_stops_location;
|
||||
int color_stops_location;
|
||||
int start_point_location;
|
||||
int end_point_location;
|
||||
int points_location;
|
||||
int repeat_location;
|
||||
} linear_gradient;
|
||||
struct {
|
||||
int num_color_stops_location;
|
||||
int color_stops_location;
|
||||
int center_location;
|
||||
int start_location;
|
||||
int end_location;
|
||||
int radius_location;
|
||||
int geometry_location;
|
||||
int range_location;
|
||||
int repeat_location;
|
||||
} radial_gradient;
|
||||
struct {
|
||||
int num_color_stops_location;
|
||||
int color_stops_location;
|
||||
int center_location;
|
||||
int rotation_location;
|
||||
int geometry_location;
|
||||
} conic_gradient;
|
||||
struct {
|
||||
int blur_radius_location;
|
||||
@@ -319,6 +317,7 @@ void ops_set_unblurred_outset_shadow (RenderOpBuilder *se
|
||||
void ops_set_linear_gradient (RenderOpBuilder *self,
|
||||
guint n_color_stops,
|
||||
const GskColorStop *color_stops,
|
||||
gboolean repeat,
|
||||
float start_x,
|
||||
float start_y,
|
||||
float end_x,
|
||||
@@ -326,6 +325,7 @@ void ops_set_linear_gradient (RenderOpBuilder *self,
|
||||
void ops_set_radial_gradient (RenderOpBuilder *self,
|
||||
guint n_color_stops,
|
||||
const GskColorStop *color_stops,
|
||||
gboolean repeat,
|
||||
float center_x,
|
||||
float center_y,
|
||||
float start,
|
||||
@@ -337,7 +337,7 @@ void ops_set_conic_gradient (RenderOpBuilder *self,
|
||||
const GskColorStop *color_stops,
|
||||
float center_x,
|
||||
float center_y,
|
||||
float rotation);
|
||||
float angle);
|
||||
|
||||
GskQuadVertex * ops_draw (RenderOpBuilder *builder,
|
||||
const GskQuadVertex vertex_data[GL_N_VERTICES]);
|
||||
|
||||
@@ -234,7 +234,7 @@ gsk_gl_shader_builder_create_program (GskGLShaderBuilder *self,
|
||||
glAttachShader (program_id, vertex_id);
|
||||
glAttachShader (program_id, fragment_id);
|
||||
glBindAttribLocation (program_id, 0, "aPosition");
|
||||
glBindAttribLocation (program_id, 1, "vUv");
|
||||
glBindAttribLocation (program_id, 1, "aUv");
|
||||
glLinkProgram (program_id);
|
||||
glDetachShader (program_id, vertex_id);
|
||||
glDetachShader (program_id, fragment_id);
|
||||
|
||||
+3
-1
@@ -146,6 +146,7 @@ typedef struct
|
||||
IntUniformValue n_color_stops;
|
||||
float start_point[2];
|
||||
float end_point[2];
|
||||
gboolean repeat;
|
||||
} OpLinearGradient;
|
||||
|
||||
typedef struct
|
||||
@@ -156,6 +157,7 @@ typedef struct
|
||||
float end;
|
||||
float radius[2];
|
||||
float center[2];
|
||||
gboolean repeat;
|
||||
} OpRadialGradient;
|
||||
|
||||
typedef struct
|
||||
@@ -163,7 +165,7 @@ typedef struct
|
||||
ColorStopUniformValue color_stops;
|
||||
IntUniformValue n_color_stops;
|
||||
float center[2];
|
||||
float rotation;
|
||||
float angle;
|
||||
} OpConicGradient;
|
||||
|
||||
typedef struct
|
||||
|
||||
@@ -257,6 +257,8 @@ const graphene_point_t * gsk_conic_gradient_node_get_center (GskRenderNo
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
float gsk_conic_gradient_node_get_rotation (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
float gsk_conic_gradient_node_get_angle (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gsize gsk_conic_gradient_node_get_n_color_stops (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const GskColorStop * gsk_conic_gradient_node_get_color_stops (GskRenderNode *node,
|
||||
|
||||
@@ -782,6 +782,7 @@ struct _GskConicGradientNode
|
||||
|
||||
graphene_point_t center;
|
||||
float rotation;
|
||||
float angle;
|
||||
|
||||
gsize n_stops;
|
||||
GskColorStop *stops;
|
||||
@@ -1023,6 +1024,12 @@ gsk_conic_gradient_node_new (const graphene_rect_t *bounds,
|
||||
self->stops = g_malloc_n (n_color_stops, sizeof (GskColorStop));
|
||||
memcpy (self->stops, color_stops, n_color_stops * sizeof (GskColorStop));
|
||||
|
||||
self->angle = 90.f - self->rotation;
|
||||
self->angle = G_PI * self->angle / 180.f;
|
||||
self->angle = fmodf (self->angle, 2.f * G_PI);
|
||||
if (self->angle < 0.f)
|
||||
self->angle += 2.f * G_PI;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -1095,6 +1102,26 @@ gsk_conic_gradient_node_get_rotation (GskRenderNode *node)
|
||||
return self->rotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_conic_gradient_node_get_angle:
|
||||
* @node: (type GskConicGradientNode): a #GskRenderNode for a conic gradient
|
||||
*
|
||||
* Retrieves the angle for the gradient in radians, normalized in [0, 2 * PI]
|
||||
*
|
||||
* The angle is starting at the top and going clockwise, as expressed
|
||||
* in the css specification:
|
||||
* angle = 90 - gsk_conic_gradient_node_get_rotation()
|
||||
*
|
||||
* Returns: the angle for the gradient
|
||||
*/
|
||||
float
|
||||
gsk_conic_gradient_node_get_angle (GskRenderNode *node)
|
||||
{
|
||||
GskConicGradientNode *self = (GskConicGradientNode *) node;
|
||||
|
||||
return self->angle;
|
||||
}
|
||||
|
||||
/*** GSK_BORDER_NODE ***/
|
||||
|
||||
/**
|
||||
|
||||
@@ -689,14 +689,16 @@ create_ascii_glyphs (PangoFont *font)
|
||||
for (i = MIN_ASCII_GLYPH; i < MAX_ASCII_GLYPH; i++)
|
||||
{
|
||||
const char text[2] = { i, 0 };
|
||||
PangoShapeFlags flags = 0;
|
||||
|
||||
pango_shape_with_flags (text,
|
||||
1,
|
||||
text,
|
||||
1,
|
||||
if (cairo_version () < CAIRO_VERSION_ENCODE (1, 17, 4))
|
||||
flags = PANGO_SHAPE_ROUND_POSITIONS;
|
||||
|
||||
pango_shape_with_flags (text, 1,
|
||||
text, 1,
|
||||
¬_a_hack,
|
||||
glyph_string,
|
||||
PANGO_SHAPE_ROUND_POSITIONS);
|
||||
flags);
|
||||
|
||||
if (glyph_string->num_glyphs != 1)
|
||||
{
|
||||
|
||||
@@ -1,34 +1,17 @@
|
||||
// VERTEX_SHADER
|
||||
uniform vec2 u_center;
|
||||
uniform float u_rotation;
|
||||
uniform float u_color_stops[6 * 5];
|
||||
uniform int u_num_color_stops;
|
||||
uniform vec4 u_geometry;
|
||||
|
||||
const float PI = 3.1415926535897932384626433832795;
|
||||
|
||||
_OUT_ vec2 center;
|
||||
_OUT_ float rotation;
|
||||
_OUT_ vec4 color_stops[6];
|
||||
_OUT_ float color_offsets[6];
|
||||
_NOPERSPECTIVE_ _OUT_ vec2 coord;
|
||||
|
||||
void main() {
|
||||
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
|
||||
gl_Position = u_projection * (u_modelview * vec4(aPosition, 0.0, 1.0));
|
||||
|
||||
// The -90 is because conics point to the top by default
|
||||
rotation = mod (u_rotation - 90.0, 360.0);
|
||||
if (rotation < 0.0)
|
||||
rotation += 360.0;
|
||||
rotation = PI / 180.0 * rotation;
|
||||
vec2 mv0 = u_modelview[0].xy;
|
||||
vec2 mv1 = u_modelview[1].xy;
|
||||
vec2 offset = aPosition - u_geometry.xy;
|
||||
|
||||
center = (u_modelview * vec4(u_center, 0, 1)).xy;
|
||||
|
||||
for (int i = 0; i < u_num_color_stops; i ++) {
|
||||
color_offsets[i] = u_color_stops[(i * 5) + 0];
|
||||
color_stops[i] = gsk_premultiply(vec4(u_color_stops[(i * 5) + 1],
|
||||
u_color_stops[(i * 5) + 2],
|
||||
u_color_stops[(i * 5) + 3],
|
||||
u_color_stops[(i * 5) + 4]));
|
||||
}
|
||||
coord = vec2(dot(mv0, offset),
|
||||
dot(mv1, offset));
|
||||
}
|
||||
|
||||
// FRAGMENT_SHADER:
|
||||
@@ -38,32 +21,53 @@ uniform int u_num_color_stops;
|
||||
uniform highp int u_num_color_stops; // Why? Because it works like this.
|
||||
#endif
|
||||
|
||||
const float PI = 3.1415926535897932384626433832795;
|
||||
uniform vec4 u_geometry;
|
||||
uniform float u_color_stops[6 * 5];
|
||||
|
||||
_IN_ vec2 center;
|
||||
_IN_ float rotation;
|
||||
_IN_ vec4 color_stops[6];
|
||||
_IN_ float color_offsets[6];
|
||||
_NOPERSPECTIVE_ _IN_ vec2 coord;
|
||||
|
||||
float get_offset(int index) {
|
||||
return u_color_stops[5 * index];
|
||||
}
|
||||
|
||||
vec4 get_color(int index) {
|
||||
int base = 5 * index + 1;
|
||||
|
||||
return vec4(u_color_stops[base],
|
||||
u_color_stops[base + 1],
|
||||
u_color_stops[base + 2],
|
||||
u_color_stops[base + 3]);
|
||||
}
|
||||
|
||||
void main() {
|
||||
// Position relative to center
|
||||
vec2 pos = gsk_get_frag_coord() - center;
|
||||
|
||||
// direction of point in range [-PI, PI]
|
||||
float angle = atan (pos.y, pos.x);
|
||||
// rotate, it's now [-2 * PI, PI]
|
||||
angle -= rotation;
|
||||
vec2 pos = floor(coord);
|
||||
float angle = atan(pos.y, pos.x);
|
||||
|
||||
// fract() does the modulo here, so now we have progress
|
||||
// into the current conic
|
||||
float offset = fract (angle / 2.0 / PI + 2.0);
|
||||
float offset = fract(angle * u_geometry.z + u_geometry.w);
|
||||
|
||||
vec4 color = color_stops[0];
|
||||
for (int i = 1; i < u_num_color_stops; i ++) {
|
||||
if (offset >= color_offsets[i - 1]) {
|
||||
float o = (offset - color_offsets[i - 1]) / (color_offsets[i] - color_offsets[i - 1]);
|
||||
color = mix(color_stops[i - 1], color_stops[i], clamp(o, 0.0, 1.0));
|
||||
if (offset < get_offset(0)) {
|
||||
gskSetOutputColor(gsk_scaled_premultiply(get_color(0), u_alpha));
|
||||
return;
|
||||
}
|
||||
|
||||
int n = u_num_color_stops - 1;
|
||||
for (int i = 0; i < n; i++) {
|
||||
float curr_offset = get_offset(i);
|
||||
float next_offset = get_offset(i + 1);
|
||||
|
||||
if (offset >= curr_offset && offset < next_offset) {
|
||||
float f = (offset - curr_offset) / (next_offset - curr_offset);
|
||||
vec4 curr_color = gsk_premultiply(get_color(i));
|
||||
vec4 next_color = gsk_premultiply(get_color(i + 1));
|
||||
vec4 color = mix(curr_color, next_color, f);
|
||||
|
||||
gskSetOutputColor(color * u_alpha);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
gskSetOutputColor(color * u_alpha);
|
||||
gskSetOutputColor(gsk_scaled_premultiply(get_color(n), u_alpha));
|
||||
}
|
||||
|
||||
@@ -1,35 +1,41 @@
|
||||
// VERTEX_SHADER
|
||||
uniform vec2 u_start_point;
|
||||
uniform vec2 u_end_point;
|
||||
uniform float u_color_stops[6 * 5];
|
||||
uniform int u_num_color_stops;
|
||||
uniform vec4 u_points;
|
||||
|
||||
_OUT_ vec2 startPoint;
|
||||
_OUT_ vec2 endPoint;
|
||||
_OUT_ float maxDist;
|
||||
_OUT_ vec2 gradient;
|
||||
_OUT_ float gradientLength;
|
||||
_OUT_ vec4 color_stops[6];
|
||||
_OUT_ float color_offsets[6];
|
||||
_NOPERSPECTIVE_ _OUT_ vec4 info;
|
||||
|
||||
void main() {
|
||||
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
|
||||
gl_Position = u_projection * (u_modelview * vec4(aPosition, 0.0, 1.0));
|
||||
|
||||
startPoint = (u_modelview * vec4(u_start_point, 0, 1)).xy;
|
||||
endPoint = (u_modelview * vec4(u_end_point, 0, 1)).xy;
|
||||
maxDist = length(endPoint - startPoint);
|
||||
vec2 mv0 = u_modelview[0].xy;
|
||||
vec2 mv1 = u_modelview[1].xy;
|
||||
vec2 offset = aPosition - u_points.xy;
|
||||
vec2 coord = vec2(dot(mv0, offset),
|
||||
dot(mv1, offset));
|
||||
|
||||
// Gradient direction
|
||||
gradient = endPoint - startPoint;
|
||||
gradientLength = length(gradient);
|
||||
// Original equation:
|
||||
// VS | maxDist = length(end - start);
|
||||
// VS | gradient = end - start;
|
||||
// VS | gradientLength = length(gradient);
|
||||
// FS | pos = frag_coord - start
|
||||
// FS | proj = (dot(gradient, pos) / (gradientLength * gradientLength)) * gradient
|
||||
// FS | offset = length(proj) / maxDist
|
||||
|
||||
for (int i = 0; i < u_num_color_stops; i ++) {
|
||||
color_offsets[i] = u_color_stops[(i * 5) + 0];
|
||||
color_stops[i] = gsk_premultiply(vec4(u_color_stops[(i * 5) + 1],
|
||||
u_color_stops[(i * 5) + 2],
|
||||
u_color_stops[(i * 5) + 3],
|
||||
u_color_stops[(i * 5) + 4]));
|
||||
}
|
||||
// Simplified formula derivation:
|
||||
// 1. Notice that maxDist = gradientLength:
|
||||
// offset = length(proj) / gradientLength
|
||||
// 2. Let gnorm = gradient / gradientLength, then:
|
||||
// proj = (dot(gnorm * gradientLength, pos) / (gradientLength * gradientLength)) * (gnorm * gradientLength) =
|
||||
// = dot(gnorm, pos) * gnorm
|
||||
// 3. Since gnorm is unit length then:
|
||||
// length(proj) = length(dot(gnorm, pos) * gnorm) = dot(gnorm, pos)
|
||||
// 4. We can avoid the FS division by passing a scaled pos from the VS:
|
||||
// offset = dot(gnorm, pos) / gradientLength = dot(gnorm, pos / gradientLength)
|
||||
// 5. 1.0 / length(gradient) is inversesqrt(dot(gradient, gradient)) in GLSL
|
||||
vec2 gradient = vec2(dot(mv0, u_points.zw),
|
||||
dot(mv1, u_points.zw));
|
||||
float rcp_gradient_length = inversesqrt(dot(gradient, gradient));
|
||||
|
||||
info = rcp_gradient_length * vec4(coord, gradient);
|
||||
}
|
||||
|
||||
// FRAGMENT_SHADER:
|
||||
@@ -39,32 +45,51 @@ uniform int u_num_color_stops;
|
||||
uniform highp int u_num_color_stops; // Why? Because it works like this.
|
||||
#endif
|
||||
|
||||
_IN_ vec2 startPoint;
|
||||
_IN_ vec2 endPoint;
|
||||
_IN_ float maxDist;
|
||||
_IN_ vec2 gradient;
|
||||
_IN_ float gradientLength;
|
||||
_IN_ vec4 color_stops[6];
|
||||
_IN_ float color_offsets[6];
|
||||
uniform float u_color_stops[6 * 5];
|
||||
uniform bool u_repeat;
|
||||
|
||||
_NOPERSPECTIVE_ _IN_ vec4 info;
|
||||
|
||||
float get_offset(int index) {
|
||||
return u_color_stops[5 * index];
|
||||
}
|
||||
|
||||
vec4 get_color(int index) {
|
||||
int base = 5 * index + 1;
|
||||
|
||||
return vec4(u_color_stops[base],
|
||||
u_color_stops[base + 1],
|
||||
u_color_stops[base + 2],
|
||||
u_color_stops[base + 3]);
|
||||
}
|
||||
|
||||
void main() {
|
||||
// Position relative to startPoint
|
||||
vec2 pos = gsk_get_frag_coord() - startPoint;
|
||||
float offset = dot(info.xy, info.zw);
|
||||
|
||||
// Current pixel, projected onto the line between the start point and the end point
|
||||
// The projection will be relative to the start point!
|
||||
vec2 proj = (dot(gradient, pos) / (gradientLength * gradientLength)) * gradient;
|
||||
if (u_repeat) {
|
||||
offset = fract(offset);
|
||||
}
|
||||
|
||||
// Offset of the current pixel
|
||||
float offset = length(proj) / maxDist;
|
||||
if (offset < get_offset(0)) {
|
||||
gskSetOutputColor(gsk_scaled_premultiply(get_color(0), u_alpha));
|
||||
return;
|
||||
}
|
||||
|
||||
vec4 color = color_stops[0];
|
||||
for (int i = 1; i < u_num_color_stops; i ++) {
|
||||
if (offset >= color_offsets[i - 1]) {
|
||||
float o = (offset - color_offsets[i - 1]) / (color_offsets[i] - color_offsets[i - 1]);
|
||||
color = mix(color_stops[i - 1], color_stops[i], clamp(o, 0.0, 1.0));
|
||||
int n = u_num_color_stops - 1;
|
||||
for (int i = 0; i < n; i++) {
|
||||
float curr_offset = get_offset(i);
|
||||
float next_offset = get_offset(i + 1);
|
||||
|
||||
if (offset >= curr_offset && offset < next_offset) {
|
||||
float f = (offset - curr_offset) / (next_offset - curr_offset);
|
||||
vec4 curr_color = gsk_premultiply(get_color(i));
|
||||
vec4 next_color = gsk_premultiply(get_color(i + 1));
|
||||
vec4 color = mix(curr_color, next_color, f);
|
||||
|
||||
gskSetOutputColor(color * u_alpha);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
gskSetOutputColor(color * u_alpha);
|
||||
gskSetOutputColor(gsk_scaled_premultiply(get_color(n), u_alpha));
|
||||
}
|
||||
|
||||
@@ -5,10 +5,12 @@ precision highp float;
|
||||
#if defined(GSK_GLES) || defined(GSK_LEGACY)
|
||||
#define _OUT_ varying
|
||||
#define _IN_ varying
|
||||
#define _NOPERSPECTIVE_
|
||||
#define _GSK_ROUNDED_RECT_UNIFORM_ vec4[3]
|
||||
#else
|
||||
#define _OUT_ out
|
||||
#define _IN_ in
|
||||
#define _NOPERSPECTIVE_ noperspective
|
||||
#define _GSK_ROUNDED_RECT_UNIFORM_ GskRoundedRect
|
||||
#endif
|
||||
|
||||
@@ -39,3 +41,11 @@ gsk_create_rect(vec4[3] data)
|
||||
vec4 gsk_premultiply(vec4 c) {
|
||||
return vec4(c.rgb * c.a, c.a);
|
||||
}
|
||||
|
||||
vec4 gsk_scaled_premultiply(vec4 c, float s) {
|
||||
// Fast version of gsk_premultiply(c) * s
|
||||
// 4 muls instead of 7
|
||||
float a = s * c.a;
|
||||
|
||||
return vec4(c.rgb * a, a);
|
||||
}
|
||||
|
||||
@@ -1,31 +1,18 @@
|
||||
// VERTEX_SHADER
|
||||
uniform float u_start;
|
||||
uniform float u_end;
|
||||
uniform float u_color_stops[6 * 5];
|
||||
uniform int u_num_color_stops;
|
||||
uniform vec2 u_radius;
|
||||
uniform vec2 u_center;
|
||||
uniform vec4 u_geometry;
|
||||
|
||||
_OUT_ vec2 center;
|
||||
_OUT_ vec4 color_stops[6];
|
||||
_OUT_ float color_offsets[6];
|
||||
_OUT_ float start;
|
||||
_OUT_ float end;
|
||||
_NOPERSPECTIVE_ _OUT_ vec2 coord;
|
||||
|
||||
void main() {
|
||||
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
|
||||
gl_Position = u_projection * (u_modelview * vec4(aPosition, 0.0, 1.0));
|
||||
|
||||
center = (u_modelview * vec4(u_center, 0, 1)).xy;
|
||||
start = u_start;
|
||||
end = u_end;
|
||||
vec2 mv0 = u_modelview[0].xy;
|
||||
vec2 mv1 = u_modelview[1].xy;
|
||||
vec2 offset = aPosition - u_geometry.xy;
|
||||
vec2 dir = vec2(dot(mv0, offset),
|
||||
dot(mv1, offset));
|
||||
|
||||
for (int i = 0; i < u_num_color_stops; i ++) {
|
||||
color_offsets[i] = u_color_stops[(i * 5) + 0];
|
||||
color_stops[i] = gsk_premultiply(vec4(u_color_stops[(i * 5) + 1],
|
||||
u_color_stops[(i * 5) + 2],
|
||||
u_color_stops[(i * 5) + 3],
|
||||
u_color_stops[(i * 5) + 4]));
|
||||
}
|
||||
coord = dir * u_geometry.zw;
|
||||
}
|
||||
|
||||
// FRAGMENT_SHADER:
|
||||
@@ -35,50 +22,53 @@ uniform int u_num_color_stops;
|
||||
uniform highp int u_num_color_stops;
|
||||
#endif
|
||||
|
||||
uniform vec2 u_radius;
|
||||
uniform float u_end;
|
||||
uniform bool u_repeat;
|
||||
uniform vec2 u_range;
|
||||
uniform float u_color_stops[6 * 5];
|
||||
|
||||
_IN_ vec2 center;
|
||||
_IN_ vec4 color_stops[6];
|
||||
_IN_ float color_offsets[6];
|
||||
_IN_ float start;
|
||||
_IN_ float end;
|
||||
_NOPERSPECTIVE_ _IN_ vec2 coord;
|
||||
|
||||
// The offsets in the color stops are relative to the
|
||||
// start and end values of the gradient.
|
||||
float abs_offset(float offset) {
|
||||
return start + ((end - start) * offset);
|
||||
float get_offset(int index) {
|
||||
return u_color_stops[5 * index];
|
||||
}
|
||||
|
||||
vec4 get_color(int index) {
|
||||
int base = 5 * index + 1;
|
||||
|
||||
return vec4(u_color_stops[base],
|
||||
u_color_stops[base + 1],
|
||||
u_color_stops[base + 2],
|
||||
u_color_stops[base + 3]);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 pixel = gsk_get_frag_coord();
|
||||
vec2 rel = (center - pixel) / (u_radius);
|
||||
float d = sqrt(dot(rel, rel));
|
||||
// Reverse scale
|
||||
float offset = length(coord) * u_range.x + u_range.y;
|
||||
|
||||
if (d < abs_offset (color_offsets[0])) {
|
||||
gskSetOutputColor(color_stops[0] * u_alpha);
|
||||
if (u_repeat) {
|
||||
offset = fract(offset);
|
||||
}
|
||||
|
||||
if (offset < get_offset(0)) {
|
||||
gskSetOutputColor(gsk_scaled_premultiply(get_color(0), u_alpha));
|
||||
return;
|
||||
}
|
||||
|
||||
if (d > end) {
|
||||
gskSetOutputColor(color_stops[u_num_color_stops - 1] * u_alpha);
|
||||
return;
|
||||
}
|
||||
int n = u_num_color_stops - 1;
|
||||
for (int i = 0; i < n; i++) {
|
||||
float curr_offset = get_offset(i);
|
||||
float next_offset = get_offset(i + 1);
|
||||
|
||||
vec4 color = vec4(0, 0, 0, 0);
|
||||
for (int i = 1; i < u_num_color_stops; i++) {
|
||||
float last_offset = abs_offset(color_offsets[i - 1]);
|
||||
float this_offset = abs_offset(color_offsets[i]);
|
||||
if (offset >= curr_offset && offset < next_offset) {
|
||||
float f = (offset - curr_offset) / (next_offset - curr_offset);
|
||||
vec4 curr_color = gsk_premultiply(get_color(i));
|
||||
vec4 next_color = gsk_premultiply(get_color(i + 1));
|
||||
vec4 color = mix(curr_color, next_color, f);
|
||||
|
||||
// We have color_stops[i - 1] at last_offset and color_stops[i] at this_offset.
|
||||
// We now need to map `d` between those two offsets and simply mix linearly between them
|
||||
if (d >= last_offset && d <= this_offset) {
|
||||
float f = (d - last_offset) / (this_offset - last_offset);
|
||||
|
||||
color = mix(color_stops[i - 1], color_stops[i], f);
|
||||
break;
|
||||
gskSetOutputColor(color * u_alpha);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
gskSetOutputColor(color * u_alpha);
|
||||
gskSetOutputColor(gsk_scaled_premultiply(get_color(n), u_alpha));
|
||||
}
|
||||
|
||||
@@ -63,17 +63,12 @@ xml += '\n'
|
||||
for f in get_files('theme/HighContrast/assets', '.svg'):
|
||||
xml += ' <file>theme/HighContrast/assets/{0}</file>\n'.format(f)
|
||||
|
||||
for f in get_files('gesture', '.symbolic.png'):
|
||||
xml += ' <file alias=\'icons/64x64/actions/{0}\'>gesture/{0}</file>\n'.format(f)
|
||||
|
||||
xml += '\n'
|
||||
|
||||
for f in get_files('ui', '.ui'):
|
||||
xml += ' <file preprocess=\'xml-stripblanks\'>ui/{0}</file>\n'.format(f)
|
||||
|
||||
xml += '\n'
|
||||
|
||||
for s in ['16x16', '24x24', '32x32', '48x48', 'scalable']:
|
||||
for s in ['16x16', '32x32', '64x64', 'scalable']:
|
||||
for c in ['actions', 'categories', 'emblems', 'emotes', 'devices', 'mimetypes', 'places', 'status']:
|
||||
icons_dir = 'icons/{0}/{1}'.format(s,c)
|
||||
if os.path.exists(os.path.join(srcdir,icons_dir)):
|
||||
|
||||
@@ -67,7 +67,6 @@
|
||||
#include "gtkprivate.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtksizerequest.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -25,9 +25,9 @@
|
||||
#include "gtkorientable.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtksizerequest.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkcssnodeprivate.h"
|
||||
|
||||
/**
|
||||
* SECTION:gtkboxlayout
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtkcssnodeprivate.h"
|
||||
#include "gtkcssnumbervalueprivate.h"
|
||||
#include "gtkbuiltiniconprivate.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
@@ -80,10 +80,11 @@ gtk_builtin_icon_measure (GtkWidget *widget,
|
||||
int *minimum_baseline,
|
||||
int *natural_baseline)
|
||||
{
|
||||
GtkCssValue *icon_size;
|
||||
GtkCssStyle *style;
|
||||
|
||||
icon_size = _gtk_style_context_peek_property (gtk_widget_get_style_context (widget), GTK_CSS_PROPERTY_ICON_SIZE);
|
||||
*minimum = *natural = _gtk_css_number_value_get (icon_size, 100);
|
||||
style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
|
||||
|
||||
*minimum = *natural = _gtk_css_number_value_get (style->icon->icon_size, 100);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -310,14 +310,10 @@ click_pressed_cb (GtkGestureClick *gesture,
|
||||
{
|
||||
GtkButton *button = GTK_BUTTON (widget);
|
||||
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
|
||||
GdkEventSequence *sequence;
|
||||
|
||||
if (gtk_widget_get_focus_on_click (widget) && !gtk_widget_has_focus (widget))
|
||||
gtk_widget_grab_focus (widget);
|
||||
|
||||
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
|
||||
gtk_gesture_set_sequence_state (GTK_GESTURE (gesture), sequence, GTK_EVENT_SEQUENCE_CLAIMED);
|
||||
|
||||
if (!priv->activate_timeout)
|
||||
priv->button_down = TRUE;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,6 @@
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkrendericonprivate.h"
|
||||
#include "gtksnapshot.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkgestureclick.h"
|
||||
#include "gtkgesturedrag.h"
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
#include "gtklayoutchild.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtksizerequest.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkcssnodeprivate.h"
|
||||
|
||||
/**
|
||||
* SECTION:gtkcenterlayout
|
||||
@@ -58,12 +58,13 @@ G_DEFINE_TYPE (GtkCenterLayout, gtk_center_layout, GTK_TYPE_LAYOUT_MANAGER)
|
||||
|
||||
static int
|
||||
get_spacing (GtkCenterLayout *self,
|
||||
GtkStyleContext *style_context)
|
||||
GtkCssNode *node)
|
||||
{
|
||||
GtkCssStyle *style = gtk_css_node_get_style (node);
|
||||
GtkCssValue *border_spacing;
|
||||
int css_spacing;
|
||||
|
||||
border_spacing = _gtk_style_context_peek_property (style_context, GTK_CSS_PROPERTY_BORDER_SPACING);
|
||||
border_spacing = style->size->border_spacing;
|
||||
if (self->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
css_spacing = _gtk_css_position_value_get_x (border_spacing, 100);
|
||||
else
|
||||
@@ -226,7 +227,7 @@ gtk_center_layout_measure_orientation (GtkCenterLayout *self,
|
||||
int spacing;
|
||||
int i;
|
||||
|
||||
spacing = get_spacing (self, _gtk_widget_get_style_context (widget));
|
||||
spacing = get_spacing (self, gtk_widget_get_css_node (widget));
|
||||
|
||||
for (i = 0; i < 3; i ++)
|
||||
{
|
||||
@@ -386,7 +387,7 @@ gtk_center_layout_allocate (GtkLayoutManager *layout_manager,
|
||||
int i;
|
||||
int spacing;
|
||||
|
||||
spacing = get_spacing (self, _gtk_widget_get_style_context (widget));
|
||||
spacing = get_spacing (self, gtk_widget_get_css_node (widget));
|
||||
|
||||
if (self->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
{
|
||||
|
||||
+53
-3
@@ -34,7 +34,8 @@
|
||||
#include "gtkintl.h"
|
||||
#include "gtklabel.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtkshortcuttrigger.h"
|
||||
#include "gtkcssnodeprivate.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkmodelbuttonprivate.h"
|
||||
|
||||
@@ -94,6 +95,7 @@ enum {
|
||||
|
||||
enum {
|
||||
TOGGLED,
|
||||
ACTIVATE,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
@@ -276,8 +278,6 @@ click_pressed_cb (GtkGestureClick *gesture,
|
||||
{
|
||||
if (gtk_widget_get_focus_on_click (widget) && !gtk_widget_has_focus (widget))
|
||||
gtk_widget_grab_focus (widget);
|
||||
|
||||
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -293,6 +293,8 @@ click_released_cb (GtkGestureClick *gesture,
|
||||
if (priv->active && (priv->group_prev || priv->group_next))
|
||||
return;
|
||||
|
||||
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
|
||||
|
||||
gtk_check_button_set_active (self, !priv->active);
|
||||
|
||||
if (priv->action_helper)
|
||||
@@ -442,11 +444,26 @@ gtk_check_button_focus (GtkWidget *widget,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_check_button_real_activate (GtkCheckButton *check_button)
|
||||
{
|
||||
gtk_check_button_set_active (check_button,
|
||||
!gtk_check_button_get_active (check_button));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_check_button_class_init (GtkCheckButtonClass *class)
|
||||
{
|
||||
const guint activate_keyvals[] = {
|
||||
GDK_KEY_space,
|
||||
GDK_KEY_KP_Space,
|
||||
GDK_KEY_Return,
|
||||
GDK_KEY_ISO_Enter,
|
||||
GDK_KEY_KP_Enter
|
||||
};
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
||||
GtkShortcutAction *activate_action;
|
||||
|
||||
object_class->dispose = gtk_check_button_dispose;
|
||||
object_class->set_property = gtk_check_button_set_property;
|
||||
@@ -454,6 +471,8 @@ gtk_check_button_class_init (GtkCheckButtonClass *class)
|
||||
|
||||
widget_class->focus = gtk_check_button_focus;
|
||||
|
||||
class->activate = gtk_check_button_real_activate;
|
||||
|
||||
props[PROP_ACTIVE] =
|
||||
g_param_spec_boolean ("active",
|
||||
P_("Active"),
|
||||
@@ -507,6 +526,37 @@ gtk_check_button_class_init (GtkCheckButtonClass *class)
|
||||
NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
/**
|
||||
* GtkCheckButton::activate:
|
||||
* @widget: the object which received the signal.
|
||||
*
|
||||
* The ::activate signal on GtkCheckButton is an action signal and
|
||||
* emitting it causes the button to animate press then release.
|
||||
* Applications should never connect to this signal, but use the
|
||||
* #GtkCheckButton::toggled signal.
|
||||
*/
|
||||
signals[ACTIVATE] =
|
||||
g_signal_new (I_ ("activate"),
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
|
||||
G_STRUCT_OFFSET (GtkCheckButtonClass, activate),
|
||||
NULL, NULL,
|
||||
NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
gtk_widget_class_set_activate_signal (widget_class, signals[ACTIVATE]);
|
||||
|
||||
activate_action = gtk_signal_action_new ("activate");
|
||||
for (guint i = 0; i < G_N_ELEMENTS (activate_keyvals); i++)
|
||||
{
|
||||
GtkShortcut *activate_shortcut = gtk_shortcut_new (gtk_keyval_trigger_new (activate_keyvals[i], 0),
|
||||
g_object_ref (activate_action));
|
||||
|
||||
gtk_widget_class_add_shortcut (widget_class, activate_shortcut);
|
||||
g_object_unref (activate_shortcut);
|
||||
}
|
||||
g_object_unref (activate_action);
|
||||
|
||||
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BOX_LAYOUT);
|
||||
gtk_widget_class_set_css_name (widget_class, I_("checkbutton"));
|
||||
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_CHECKBOX);
|
||||
|
||||
@@ -56,9 +56,10 @@ struct _GtkCheckButtonClass
|
||||
GtkWidgetClass parent_class;
|
||||
|
||||
void (* toggled) (GtkCheckButton *check_button);
|
||||
void (* activate) (GtkCheckButton *check_button);
|
||||
|
||||
/*< private >*/
|
||||
gpointer padding[8];
|
||||
gpointer padding[7];
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
#include "gtkpopovermenu.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtksnapshot.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkeventcontrollerkey.h"
|
||||
#include "gtknative.h"
|
||||
|
||||
+2
-2
@@ -39,7 +39,7 @@
|
||||
#include "gtkadjustment.h"
|
||||
#include "gtkgesturedrag.h"
|
||||
#include "gtkeventcontrollermotion.h"
|
||||
#include "gtkdragsource.h"
|
||||
#include "gtkdragsourceprivate.h"
|
||||
#include "gtkeventcontrollerkey.h"
|
||||
#include "gtkgestureclick.h"
|
||||
|
||||
@@ -1128,7 +1128,7 @@ header_drag_update (GtkGestureDrag *gesture,
|
||||
|
||||
if (!self->in_column_resize && !self->in_column_reorder)
|
||||
{
|
||||
if (gtk_drag_check_threshold (GTK_WIDGET (self), 0, 0, offset_x, 0))
|
||||
if (gtk_drag_check_threshold_double (GTK_WIDGET (self), 0, 0, offset_x, 0))
|
||||
{
|
||||
GtkColumnViewColumn *column;
|
||||
GtkWidget *header;
|
||||
|
||||
+10
-10
@@ -28,7 +28,7 @@
|
||||
#include "gtklabel.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkbox.h"
|
||||
#include "gtkimage.h"
|
||||
#include "gtkbuiltiniconprivate.h"
|
||||
#include "gtkgestureclick.h"
|
||||
#include "gtkpopovermenu.h"
|
||||
#include "gtknative.h"
|
||||
@@ -266,7 +266,7 @@ gtk_column_view_title_init (GtkColumnViewTitle *self)
|
||||
self->title = gtk_label_new (NULL);
|
||||
gtk_box_append (GTK_BOX (self->box), self->title);
|
||||
|
||||
self->sort = gtk_image_new ();
|
||||
self->sort = gtk_builtin_icon_new ("sort-indicator");
|
||||
gtk_box_append (GTK_BOX (self->box), self->sort);
|
||||
|
||||
gesture = gtk_gesture_click_new ();
|
||||
@@ -308,15 +308,15 @@ gtk_column_view_title_update (GtkColumnViewTitle *self)
|
||||
active = gtk_column_view_sorter_get_sort_column (view_sorter, &inverted);
|
||||
|
||||
gtk_widget_show (self->sort);
|
||||
if (self->column == active)
|
||||
{
|
||||
if (inverted)
|
||||
gtk_image_set_from_icon_name (GTK_IMAGE (self->sort), "pan-down-symbolic");
|
||||
else
|
||||
gtk_image_set_from_icon_name (GTK_IMAGE (self->sort), "pan-up-symbolic");
|
||||
}
|
||||
gtk_widget_remove_css_class (self->sort, "ascending");
|
||||
gtk_widget_remove_css_class (self->sort, "descending");
|
||||
gtk_widget_remove_css_class (self->sort, "unsorted");
|
||||
if (self->column != active)
|
||||
gtk_widget_add_css_class (self->sort, "unsorted");
|
||||
else if (inverted)
|
||||
gtk_widget_add_css_class (self->sort, "descending");
|
||||
else
|
||||
gtk_image_clear (GTK_IMAGE (self->sort));
|
||||
gtk_widget_add_css_class (self->sort, "ascending");
|
||||
}
|
||||
else
|
||||
gtk_widget_hide (self->sort);
|
||||
|
||||
+567
-177
@@ -26,16 +26,17 @@
|
||||
#include "gtkcomposetable.h"
|
||||
#include "gtkimcontextsimple.h"
|
||||
|
||||
#include "gtkimcontextsimpleprivate.h"
|
||||
|
||||
|
||||
#define GTK_COMPOSE_TABLE_MAGIC "GtkComposeTable"
|
||||
#define GTK_COMPOSE_TABLE_VERSION (1)
|
||||
#define GTK_COMPOSE_TABLE_VERSION (2)
|
||||
|
||||
/* Maximum length of sequences we parse */
|
||||
|
||||
#define MAX_COMPOSE_LEN 20
|
||||
|
||||
typedef struct {
|
||||
gunichar *sequence;
|
||||
gunichar value[2];
|
||||
char *comment;
|
||||
gunichar *sequence;
|
||||
char *value;
|
||||
} GtkComposeData;
|
||||
|
||||
|
||||
@@ -43,7 +44,7 @@ static void
|
||||
gtk_compose_data_free (GtkComposeData *compose_data)
|
||||
{
|
||||
g_free (compose_data->sequence);
|
||||
g_free (compose_data->comment);
|
||||
g_free (compose_data->value);
|
||||
g_slice_free (GtkComposeData, compose_data);
|
||||
}
|
||||
|
||||
@@ -76,58 +77,82 @@ parse_compose_value (GtkComposeData *compose_data,
|
||||
const char *val,
|
||||
const char *line)
|
||||
{
|
||||
char **words = g_strsplit (val, "\"", 3);
|
||||
gunichar uch;
|
||||
char *word;
|
||||
const char *p;
|
||||
gsize len;
|
||||
GString *value;
|
||||
gunichar ch;
|
||||
char *endp;
|
||||
|
||||
if (g_strv_length (words) < 3)
|
||||
len = strlen (val);
|
||||
if (val[0] != '"' || val[len - 1] != '"')
|
||||
{
|
||||
g_warning ("Need to double-quote the value: %s: %s", val, line);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
uch = g_utf8_get_char (words[1]);
|
||||
word = g_strndup (val + 1, len - 2);
|
||||
|
||||
if (uch == 0)
|
||||
{
|
||||
g_warning ("Invalid value: %s: %s", val, line);
|
||||
goto fail;
|
||||
}
|
||||
else if (uch == '\\')
|
||||
{
|
||||
uch = words[1][1];
|
||||
value = g_string_new ("");
|
||||
|
||||
/* The escaped string "\"" is separated with '\\' and '"'. */
|
||||
if (uch == '\0' && words[2][0] == '"')
|
||||
uch = '"';
|
||||
/* The escaped octal */
|
||||
else if (uch >= '0' && uch <= '8')
|
||||
uch = g_ascii_strtoll(words[1] + 1, NULL, 8);
|
||||
/* If we need to handle other escape sequences. */
|
||||
else if (uch != '\\')
|
||||
p = word;
|
||||
while (*p)
|
||||
{
|
||||
if (*p == '\\')
|
||||
{
|
||||
g_warning ("Invalid escape sequence: %s: %s", val, line);
|
||||
if (p[1] == '"')
|
||||
{
|
||||
g_string_append_c (value, '"');
|
||||
p += 2;
|
||||
}
|
||||
else if (p[1] == '\\')
|
||||
{
|
||||
g_string_append_c (value, '\\');
|
||||
p += 2;
|
||||
}
|
||||
else if (p[1] >= '0' && p[1] < '8')
|
||||
{
|
||||
ch = g_ascii_strtoll (p + 1, &endp, 8);
|
||||
if (ch == 0)
|
||||
{
|
||||
g_warning ("Invalid escape sequence: %s: %s", val, line);
|
||||
goto fail;
|
||||
}
|
||||
g_string_append_unichar (value, ch);
|
||||
p = endp;
|
||||
}
|
||||
else if (p[1] == 'x' || p[1] == 'X')
|
||||
{
|
||||
ch = g_ascii_strtoll (p + 2, &endp, 16);
|
||||
if (ch == 0)
|
||||
{
|
||||
g_warning ("Invalid escape sequence: %s: %s", val, line);
|
||||
goto fail;
|
||||
}
|
||||
g_string_append_unichar (value, ch);
|
||||
p = endp;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("Invalid escape sequence: %s: %s", val, line);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ch = g_utf8_get_char (p);
|
||||
g_string_append_unichar (value, ch);
|
||||
p = g_utf8_next_char (p);
|
||||
}
|
||||
}
|
||||
|
||||
if (g_utf8_get_char (g_utf8_next_char (words[1])) > 0)
|
||||
{
|
||||
g_warning ("GTK supports to output one char only: %s: %s", val, line);
|
||||
goto fail;
|
||||
}
|
||||
compose_data->value = g_string_free (value, FALSE);
|
||||
|
||||
compose_data->value[1] = uch;
|
||||
|
||||
if (uch == '"')
|
||||
compose_data->comment = g_strdup (g_strstrip (words[2] + 1));
|
||||
else
|
||||
compose_data->comment = g_strdup (g_strstrip (words[2]));
|
||||
|
||||
g_strfreev (words);
|
||||
g_free (word);
|
||||
|
||||
return TRUE;
|
||||
|
||||
fail:
|
||||
g_strfreev (words);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -189,10 +214,10 @@ parse_compose_sequence (GtkComposeData *compose_data,
|
||||
}
|
||||
|
||||
g_strfreev (words);
|
||||
if (0 == n || n >= GTK_MAX_COMPOSE_LEN)
|
||||
if (0 == n || n > MAX_COMPOSE_LEN)
|
||||
{
|
||||
g_warning ("The max number of sequences is %d: %s",
|
||||
GTK_MAX_COMPOSE_LEN, line);
|
||||
g_warning ("Suspicious compose sequence length (%d). Are you sure this is right?: %s",
|
||||
n, line);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -214,7 +239,10 @@ parse_compose_line (GList **compose_list,
|
||||
return;
|
||||
|
||||
if (g_str_has_prefix (line, "include "))
|
||||
return;
|
||||
{
|
||||
g_warning ("include in Compose files not supported: %s", line);
|
||||
return;
|
||||
}
|
||||
|
||||
components = g_strsplit (line, ":", 2);
|
||||
|
||||
@@ -244,6 +272,8 @@ fail:
|
||||
gtk_compose_data_free (compose_data);
|
||||
}
|
||||
|
||||
extern const GtkComposeTableCompact gtk_compose_table_compact;
|
||||
|
||||
static GList *
|
||||
gtk_compose_list_parse_file (const char *compose_file)
|
||||
{
|
||||
@@ -279,18 +309,19 @@ gtk_compose_list_check_duplicated (GList *compose_list)
|
||||
|
||||
for (list = compose_list; list != NULL; list = list->next)
|
||||
{
|
||||
static guint16 keysyms[GTK_MAX_COMPOSE_LEN + 1];
|
||||
static guint16 keysyms[MAX_COMPOSE_LEN + 1];
|
||||
int i;
|
||||
int n_compose = 0;
|
||||
gboolean compose_finish;
|
||||
gunichar output_char;
|
||||
char buf[8] = { 0, };
|
||||
|
||||
compose_data = list->data;
|
||||
|
||||
for (i = 0; i < GTK_MAX_COMPOSE_LEN + 1; i++)
|
||||
for (i = 0; i < MAX_COMPOSE_LEN + 1; i++)
|
||||
keysyms[i] = 0;
|
||||
|
||||
for (i = 0; i < GTK_MAX_COMPOSE_LEN + 1; i++)
|
||||
for (i = 0; i < MAX_COMPOSE_LEN + 1; i++)
|
||||
{
|
||||
gunichar codepoint = compose_data->sequence[i];
|
||||
keysyms[i] = (guint16) codepoint;
|
||||
@@ -301,20 +332,21 @@ gtk_compose_list_check_duplicated (GList *compose_list)
|
||||
n_compose++;
|
||||
}
|
||||
|
||||
if (gtk_check_compact_table (>k_compose_table_compact,
|
||||
keysyms,
|
||||
n_compose,
|
||||
&compose_finish,
|
||||
NULL,
|
||||
&output_char) &&
|
||||
if (gtk_compose_table_compact_check (>k_compose_table_compact,
|
||||
keysyms, n_compose,
|
||||
&compose_finish,
|
||||
NULL,
|
||||
&output_char) &&
|
||||
compose_finish)
|
||||
{
|
||||
if (compose_data->value[1] == output_char)
|
||||
g_unichar_to_utf8 (output_char, buf);
|
||||
if (strcmp (compose_data->value, buf) == 0)
|
||||
removed_list = g_list_prepend (removed_list, compose_data);
|
||||
}
|
||||
else if (gtk_check_algorithmically (keysyms, n_compose, &output_char))
|
||||
{
|
||||
if (compose_data->value[1] == output_char)
|
||||
g_unichar_to_utf8 (output_char, buf);
|
||||
if (strcmp (compose_data->value, buf) == 0)
|
||||
removed_list = g_list_prepend (removed_list, compose_data);
|
||||
}
|
||||
}
|
||||
@@ -343,7 +375,7 @@ gtk_compose_list_check_uint16 (GList *compose_list)
|
||||
int i;
|
||||
|
||||
compose_data = list->data;
|
||||
for (i = 0; i < GTK_MAX_COMPOSE_LEN; i++)
|
||||
for (i = 0; i < MAX_COMPOSE_LEN; i++)
|
||||
{
|
||||
gunichar codepoint = compose_data->sequence[i];
|
||||
|
||||
@@ -384,7 +416,7 @@ gtk_compose_list_format_for_gtk (GList *compose_list,
|
||||
for (list = compose_list; list != NULL; list = list->next)
|
||||
{
|
||||
compose_data = list->data;
|
||||
for (i = 0; i < GTK_MAX_COMPOSE_LEN + 1; i++)
|
||||
for (i = 0; i < MAX_COMPOSE_LEN + 1; i++)
|
||||
{
|
||||
codepoint = compose_data->sequence[i];
|
||||
if (codepoint == 0)
|
||||
@@ -401,17 +433,6 @@ gtk_compose_list_format_for_gtk (GList *compose_list,
|
||||
if (p_n_index_stride)
|
||||
*p_n_index_stride = max_compose_len + 2;
|
||||
|
||||
for (list = compose_list; list != NULL; list = list->next)
|
||||
{
|
||||
compose_data = list->data;
|
||||
codepoint = compose_data->value[1];
|
||||
if (codepoint > 0xffff)
|
||||
{
|
||||
compose_data->value[0] = codepoint / 0x10000;
|
||||
compose_data->value[1] = codepoint - codepoint / 0x10000 * 0x10000;
|
||||
}
|
||||
}
|
||||
|
||||
return compose_list;
|
||||
}
|
||||
|
||||
@@ -436,61 +457,6 @@ gtk_compose_data_compare (gpointer a,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_compose_list_print (GList *compose_list,
|
||||
int max_compose_len,
|
||||
int n_index_stride)
|
||||
{
|
||||
GList *list;
|
||||
int i, j;
|
||||
GtkComposeData *compose_data;
|
||||
int total_size = 0;
|
||||
gunichar upper;
|
||||
gunichar lower;
|
||||
const char *comment;
|
||||
const char *keyval;
|
||||
|
||||
for (list = compose_list; list != NULL; list = list->next)
|
||||
{
|
||||
compose_data = list->data;
|
||||
g_printf (" ");
|
||||
|
||||
for (i = 0; i < max_compose_len; i++)
|
||||
{
|
||||
if (compose_data->sequence[i] == 0)
|
||||
{
|
||||
for (j = i; j < max_compose_len; j++)
|
||||
{
|
||||
if (j == max_compose_len - 1)
|
||||
g_printf ("0,\n");
|
||||
else
|
||||
g_printf ("0, ");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
keyval = gdk_keyval_name (compose_data->sequence[i]);
|
||||
if (i == max_compose_len - 1)
|
||||
g_printf ("%s,\n", keyval ? keyval : "(null)");
|
||||
else
|
||||
g_printf ("%s, ", keyval ? keyval : "(null)");
|
||||
}
|
||||
upper = compose_data->value[0];
|
||||
lower = compose_data->value[1];
|
||||
comment = compose_data->comment;
|
||||
|
||||
if (list == g_list_last (compose_list))
|
||||
g_printf (" %#06X, %#06X /* %s */\n", upper, lower, comment);
|
||||
else
|
||||
g_printf (" %#06X, %#06X, /* %s */\n", upper, lower, comment);
|
||||
|
||||
total_size += n_index_stride;
|
||||
}
|
||||
|
||||
g_printerr ("TOTAL_SIZE: %d\nMAX_COMPOSE_LEN: %d\nN_INDEX_STRIDE: %d\n",
|
||||
total_size, max_compose_len, n_index_stride);
|
||||
}
|
||||
|
||||
/* Implemented from g_str_hash() */
|
||||
static guint32
|
||||
gtk_compose_table_data_hash (gconstpointer v, int length)
|
||||
@@ -546,6 +512,7 @@ gtk_compose_table_serialize (GtkComposeTable *compose_table,
|
||||
guint16 max_seq_len = compose_table->max_seq_len;
|
||||
guint16 index_stride = max_seq_len + 2;
|
||||
guint16 n_seqs = compose_table->n_seqs;
|
||||
guint16 n_chars = compose_table->n_chars;
|
||||
guint32 i;
|
||||
|
||||
g_return_val_if_fail (compose_table != NULL, NULL);
|
||||
@@ -553,44 +520,34 @@ gtk_compose_table_serialize (GtkComposeTable *compose_table,
|
||||
g_return_val_if_fail (index_stride > 0, NULL);
|
||||
|
||||
length = strlen (header);
|
||||
total_length = length + sizeof (guint16) * (3 + index_stride * n_seqs);
|
||||
total_length = length + sizeof (guint16) * (4 + index_stride * n_seqs) + n_chars;
|
||||
if (count)
|
||||
*count = total_length;
|
||||
|
||||
p = contents = g_slice_alloc (total_length);
|
||||
p = contents = g_malloc (total_length);
|
||||
|
||||
memcpy (p, header, length);
|
||||
p += length;
|
||||
|
||||
/* Copy by byte for endian */
|
||||
#define BYTE_COPY_FROM_BUF(element) \
|
||||
bytes = GUINT16_TO_BE ((element)); \
|
||||
memcpy (p, &bytes, length); \
|
||||
p += length; \
|
||||
if (p - contents > total_length) \
|
||||
{ \
|
||||
g_warning ("data size %lld is bigger than %" G_GSIZE_FORMAT, \
|
||||
(long long) (p - contents), total_length); \
|
||||
g_free (contents); \
|
||||
if (count) \
|
||||
{ \
|
||||
*count = 0; \
|
||||
} \
|
||||
return NULL; \
|
||||
}
|
||||
#define APPEND_GUINT16(elt) \
|
||||
bytes = GUINT16_TO_BE (elt); \
|
||||
memcpy (p, &bytes, sizeof (guint16)); \
|
||||
p += sizeof (guint16);
|
||||
|
||||
length = sizeof (guint16);
|
||||
|
||||
BYTE_COPY_FROM_BUF (version);
|
||||
BYTE_COPY_FROM_BUF (max_seq_len);
|
||||
BYTE_COPY_FROM_BUF (n_seqs);
|
||||
APPEND_GUINT16 (version);
|
||||
APPEND_GUINT16 (max_seq_len);
|
||||
APPEND_GUINT16 (n_seqs);
|
||||
APPEND_GUINT16 (n_chars);
|
||||
|
||||
for (i = 0; i < (guint32) index_stride * n_seqs; i++)
|
||||
{
|
||||
BYTE_COPY_FROM_BUF (compose_table->data[i]);
|
||||
APPEND_GUINT16 (compose_table->data[i]);
|
||||
}
|
||||
|
||||
#undef BYTE_COPY_FROM_BUF
|
||||
if (compose_table->n_chars > 0)
|
||||
memcpy (p, compose_table->char_data, compose_table->n_chars);
|
||||
|
||||
#undef APPEND_GUINT16
|
||||
|
||||
return contents;
|
||||
}
|
||||
@@ -614,16 +571,17 @@ gtk_compose_table_load_cache (const char *compose_file)
|
||||
GStatBuf original_buf;
|
||||
GStatBuf cache_buf;
|
||||
gsize total_length;
|
||||
gsize length;
|
||||
GError *error = NULL;
|
||||
guint16 bytes;
|
||||
guint16 version;
|
||||
guint16 max_seq_len;
|
||||
guint16 index_stride;
|
||||
guint16 n_seqs;
|
||||
guint16 n_chars;
|
||||
guint32 i;
|
||||
guint16 *gtk_compose_seqs = NULL;
|
||||
GtkComposeTable *retval;
|
||||
char *char_data = NULL;
|
||||
|
||||
hash = g_str_hash (compose_file);
|
||||
if ((path = gtk_compose_hash_get_cache_path (hash)) == NULL)
|
||||
@@ -642,16 +600,10 @@ gtk_compose_table_load_cache (const char *compose_file)
|
||||
goto out_load_cache;
|
||||
}
|
||||
|
||||
/* Copy by byte for endian */
|
||||
#define BYTE_COPY_TO_BUF(element) \
|
||||
memcpy (&bytes, p, length); \
|
||||
element = GUINT16_FROM_BE (bytes); \
|
||||
p += length; \
|
||||
if (p - contents > total_length) \
|
||||
{ \
|
||||
g_warning ("Broken cache content %s in %s", path, #element); \
|
||||
goto out_load_cache; \
|
||||
}
|
||||
#define GET_GUINT16(elt) \
|
||||
memcpy (&bytes, p, sizeof (guint16)); \
|
||||
elt = GUINT16_FROM_BE (bytes); \
|
||||
p += sizeof (guint16);
|
||||
|
||||
p = contents;
|
||||
if (g_ascii_strncasecmp (p, GTK_COMPOSE_TABLE_MAGIC,
|
||||
@@ -660,6 +612,7 @@ gtk_compose_table_load_cache (const char *compose_file)
|
||||
g_warning ("The file is not a GtkComposeTable cache file %s", path);
|
||||
goto out_load_cache;
|
||||
}
|
||||
|
||||
p += strlen (GTK_COMPOSE_TABLE_MAGIC);
|
||||
if (p - contents > total_length)
|
||||
{
|
||||
@@ -667,9 +620,7 @@ gtk_compose_table_load_cache (const char *compose_file)
|
||||
goto out_load_cache;
|
||||
}
|
||||
|
||||
length = sizeof (guint16);
|
||||
|
||||
BYTE_COPY_TO_BUF (version);
|
||||
GET_GUINT16 (version);
|
||||
if (version != GTK_COMPOSE_TABLE_VERSION)
|
||||
{
|
||||
g_warning ("cache version is different %u != %u",
|
||||
@@ -677,8 +628,9 @@ gtk_compose_table_load_cache (const char *compose_file)
|
||||
goto out_load_cache;
|
||||
}
|
||||
|
||||
BYTE_COPY_TO_BUF (max_seq_len);
|
||||
BYTE_COPY_TO_BUF (n_seqs);
|
||||
GET_GUINT16 (max_seq_len);
|
||||
GET_GUINT16 (n_seqs);
|
||||
GET_GUINT16 (n_chars);
|
||||
|
||||
if (max_seq_len == 0 || n_seqs == 0)
|
||||
{
|
||||
@@ -691,13 +643,22 @@ gtk_compose_table_load_cache (const char *compose_file)
|
||||
|
||||
for (i = 0; i < (guint32) index_stride * n_seqs; i++)
|
||||
{
|
||||
BYTE_COPY_TO_BUF (gtk_compose_seqs[i]);
|
||||
GET_GUINT16 (gtk_compose_seqs[i]);
|
||||
}
|
||||
|
||||
if (n_chars > 0)
|
||||
{
|
||||
char_data = g_new (char, n_chars + 1);
|
||||
memcpy (char_data, p, n_chars);
|
||||
char_data[n_chars] = '\0';
|
||||
}
|
||||
|
||||
retval = g_new0 (GtkComposeTable, 1);
|
||||
retval->data = gtk_compose_seqs;
|
||||
retval->max_seq_len = max_seq_len;
|
||||
retval->n_seqs = n_seqs;
|
||||
retval->char_data = char_data;
|
||||
retval->n_chars = n_chars;
|
||||
retval->id = hash;
|
||||
|
||||
g_free (contents);
|
||||
@@ -705,10 +666,11 @@ gtk_compose_table_load_cache (const char *compose_file)
|
||||
|
||||
return retval;
|
||||
|
||||
#undef BYTE_COPY_TO_BUF
|
||||
#undef GET_GUINT16
|
||||
|
||||
out_load_cache:
|
||||
g_free (gtk_compose_seqs);
|
||||
g_free (char_data);
|
||||
g_free (contents);
|
||||
g_free (path);
|
||||
return NULL;
|
||||
@@ -739,7 +701,7 @@ gtk_compose_table_save_cache (GtkComposeTable *compose_table)
|
||||
}
|
||||
|
||||
out_save_cache:
|
||||
g_slice_free1 (length, contents);
|
||||
g_free (contents);
|
||||
g_free (path);
|
||||
}
|
||||
|
||||
@@ -756,6 +718,8 @@ gtk_compose_table_new_with_list (GList *compose_list,
|
||||
GList *list;
|
||||
GtkComposeData *compose_data;
|
||||
GtkComposeTable *retval = NULL;
|
||||
gunichar codepoint;
|
||||
GString *char_data;
|
||||
|
||||
g_return_val_if_fail (compose_list != NULL, NULL);
|
||||
|
||||
@@ -763,6 +727,8 @@ gtk_compose_table_new_with_list (GList *compose_list,
|
||||
|
||||
gtk_compose_seqs = g_new0 (guint16, length * n_index_stride);
|
||||
|
||||
char_data = g_string_new ("");
|
||||
|
||||
for (list = compose_list; list != NULL; list = list->next)
|
||||
{
|
||||
compose_data = list->data;
|
||||
@@ -776,8 +742,24 @@ gtk_compose_table_new_with_list (GList *compose_list,
|
||||
}
|
||||
gtk_compose_seqs[n++] = (guint16) compose_data->sequence[i];
|
||||
}
|
||||
gtk_compose_seqs[n++] = (guint16) compose_data->value[0];
|
||||
gtk_compose_seqs[n++] = (guint16) compose_data->value[1];
|
||||
|
||||
if (g_utf8_strlen (compose_data->value, -1) > 1)
|
||||
{
|
||||
if (char_data->len > 0)
|
||||
g_string_append_c (char_data, 0);
|
||||
|
||||
codepoint = char_data->len | (1 << 31);
|
||||
|
||||
g_string_append (char_data, compose_data->value);
|
||||
}
|
||||
else
|
||||
{
|
||||
codepoint = g_utf8_get_char (compose_data->value);
|
||||
g_assert ((codepoint & (1 << 31)) == 0);
|
||||
}
|
||||
|
||||
gtk_compose_seqs[n++] = (codepoint & 0xffff0000) >> 16;
|
||||
gtk_compose_seqs[n++] = codepoint & 0xffff;
|
||||
}
|
||||
|
||||
retval = g_new0 (GtkComposeTable, 1);
|
||||
@@ -785,6 +767,8 @@ gtk_compose_table_new_with_list (GList *compose_list,
|
||||
retval->max_seq_len = max_compose_len;
|
||||
retval->n_seqs = length;
|
||||
retval->id = hash;
|
||||
retval->n_chars = char_data->len;
|
||||
retval->char_data = g_string_free (char_data, FALSE);
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -816,9 +800,6 @@ gtk_compose_table_new_with_file (const char *compose_file)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (g_getenv ("GTK_COMPOSE_TABLE_PRINT") != NULL)
|
||||
gtk_compose_list_print (compose_list, max_compose_len, n_index_stride);
|
||||
|
||||
compose_table = gtk_compose_table_new_with_list (compose_list,
|
||||
max_compose_len,
|
||||
n_index_stride,
|
||||
@@ -841,9 +822,10 @@ gtk_compose_table_list_add_array (GSList *compose_tables,
|
||||
guint16 *gtk_compose_seqs = NULL;
|
||||
|
||||
g_return_val_if_fail (data != NULL, compose_tables);
|
||||
g_return_val_if_fail (max_seq_len <= GTK_MAX_COMPOSE_LEN, compose_tables);
|
||||
g_return_val_if_fail (max_seq_len >= 0, compose_tables);
|
||||
g_return_val_if_fail (n_seqs >= 0, compose_tables);
|
||||
|
||||
n_index_stride = MIN (max_seq_len, GTK_MAX_COMPOSE_LEN) + 2;
|
||||
n_index_stride = max_seq_len + 2;
|
||||
if (!g_size_checked_mul (&length, n_index_stride, n_seqs))
|
||||
{
|
||||
g_critical ("Overflow in the compose sequences");
|
||||
@@ -864,12 +846,14 @@ gtk_compose_table_list_add_array (GSList *compose_tables,
|
||||
compose_table->max_seq_len = max_seq_len;
|
||||
compose_table->n_seqs = n_seqs;
|
||||
compose_table->id = hash;
|
||||
compose_table->char_data = NULL;
|
||||
compose_table->n_chars = 0;
|
||||
|
||||
return g_slist_prepend (compose_tables, compose_table);
|
||||
}
|
||||
|
||||
GSList *
|
||||
gtk_compose_table_list_add_file (GSList *compose_tables,
|
||||
gtk_compose_table_list_add_file (GSList *compose_tables,
|
||||
const char *compose_file)
|
||||
{
|
||||
guint32 hash;
|
||||
@@ -891,3 +875,409 @@ gtk_compose_table_list_add_file (GSList *compose_tables,
|
||||
gtk_compose_table_save_cache (compose_table);
|
||||
return g_slist_prepend (compose_tables, compose_table);
|
||||
}
|
||||
|
||||
static int
|
||||
compare_seq (const void *key, const void *value)
|
||||
{
|
||||
int i = 0;
|
||||
const guint16 *keysyms = key;
|
||||
const guint16 *seq = value;
|
||||
|
||||
while (keysyms[i])
|
||||
{
|
||||
if (keysyms[i] < seq[i])
|
||||
return -1;
|
||||
else if (keysyms[i] > seq[i])
|
||||
return 1;
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* gtk_compose_table_check:
|
||||
* @table: the table to check
|
||||
* @compose_buffer: the key vals to match
|
||||
* @n_compose: number of non-zero key vals in @compose_buffer
|
||||
* @compose_finish: (out): return location for whether there may be longer matches
|
||||
* @compose_match: (out): return location for whether there is a match
|
||||
* @output: (out) (caller-allocates): return location for the match values
|
||||
*
|
||||
* Looks for matches for a key sequence in @table.
|
||||
*
|
||||
* Returns: %TRUE if there were any matches, %FALSE otherwise
|
||||
*/
|
||||
gboolean
|
||||
gtk_compose_table_check (const GtkComposeTable *table,
|
||||
const guint16 *compose_buffer,
|
||||
int n_compose,
|
||||
gboolean *compose_finish,
|
||||
gboolean *compose_match,
|
||||
GString *output)
|
||||
{
|
||||
int row_stride = table->max_seq_len + 2;
|
||||
guint16 *seq;
|
||||
|
||||
*compose_finish = FALSE;
|
||||
*compose_match = FALSE;
|
||||
|
||||
g_string_set_size (output, 0);
|
||||
|
||||
/* Will never match, if the sequence in the compose buffer is longer
|
||||
* than the sequences in the table. Further, compare_seq (key, val)
|
||||
* will overrun val if key is longer than val.
|
||||
*/
|
||||
if (n_compose > table->max_seq_len)
|
||||
return FALSE;
|
||||
|
||||
seq = bsearch (compose_buffer,
|
||||
table->data, table->n_seqs,
|
||||
sizeof (guint16) * row_stride,
|
||||
compare_seq);
|
||||
|
||||
if (seq)
|
||||
{
|
||||
guint16 *prev_seq;
|
||||
|
||||
/* Back up to the first sequence that matches to make sure
|
||||
* we find the exact match if there is one.
|
||||
*/
|
||||
while (seq > table->data)
|
||||
{
|
||||
prev_seq = seq - row_stride;
|
||||
if (compare_seq (compose_buffer, prev_seq) != 0)
|
||||
break;
|
||||
seq = prev_seq;
|
||||
}
|
||||
|
||||
if (n_compose == table->max_seq_len ||
|
||||
seq[n_compose] == 0) /* complete sequence */
|
||||
{
|
||||
guint16 *next_seq;
|
||||
gunichar value;
|
||||
|
||||
value = (seq[table->max_seq_len] << 16) | seq[table->max_seq_len + 1];
|
||||
if ((value & (1 << 31)) != 0)
|
||||
g_string_append (output, &table->char_data[value & ~(1 << 31)]);
|
||||
else
|
||||
g_string_append_unichar (output, value);
|
||||
|
||||
*compose_match = TRUE;
|
||||
|
||||
/* We found a tentative match. See if there are any longer
|
||||
* sequences containing this subsequence
|
||||
*/
|
||||
next_seq = seq + row_stride;
|
||||
if (next_seq < table->data + row_stride * table->n_seqs)
|
||||
{
|
||||
if (compare_seq (compose_buffer, next_seq) == 0)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
*compose_finish = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int
|
||||
compare_seq_index (const void *key, const void *value)
|
||||
{
|
||||
const guint16 *keysyms = key;
|
||||
const guint16 *seq = value;
|
||||
|
||||
if (keysyms[0] < seq[0])
|
||||
return -1;
|
||||
else if (keysyms[0] > seq[0])
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_compose_table_compact_check (const GtkComposeTableCompact *table,
|
||||
const guint16 *compose_buffer,
|
||||
int n_compose,
|
||||
gboolean *compose_finish,
|
||||
gboolean *compose_match,
|
||||
gunichar *output_char)
|
||||
{
|
||||
int row_stride;
|
||||
guint16 *seq_index;
|
||||
guint16 *seq;
|
||||
int i;
|
||||
gboolean match;
|
||||
gunichar value;
|
||||
|
||||
if (compose_finish)
|
||||
*compose_finish = FALSE;
|
||||
if (compose_match)
|
||||
*compose_match = FALSE;
|
||||
if (output_char)
|
||||
*output_char = 0;
|
||||
|
||||
/* Will never match, if the sequence in the compose buffer is longer
|
||||
* than the sequences in the table. Further, compare_seq (key, val)
|
||||
* will overrun val if key is longer than val.
|
||||
*/
|
||||
if (n_compose > table->max_seq_len)
|
||||
return FALSE;
|
||||
|
||||
seq_index = bsearch (compose_buffer,
|
||||
table->data,
|
||||
table->n_index_size,
|
||||
sizeof (guint16) * table->n_index_stride,
|
||||
compare_seq_index);
|
||||
|
||||
if (!seq_index)
|
||||
return FALSE;
|
||||
|
||||
if (n_compose == 1)
|
||||
return TRUE;
|
||||
|
||||
seq = NULL;
|
||||
match = FALSE;
|
||||
value = 0;
|
||||
|
||||
for (i = n_compose - 1; i < table->max_seq_len; i++)
|
||||
{
|
||||
row_stride = i + 1;
|
||||
|
||||
if (seq_index[i + 1] - seq_index[i] > 0)
|
||||
{
|
||||
seq = bsearch (compose_buffer + 1,
|
||||
table->data + seq_index[i],
|
||||
(seq_index[i + 1] - seq_index[i]) / row_stride,
|
||||
sizeof (guint16) * row_stride,
|
||||
compare_seq);
|
||||
|
||||
if (seq)
|
||||
{
|
||||
if (i == n_compose - 1)
|
||||
{
|
||||
value = seq[row_stride - 1];
|
||||
match = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (output_char)
|
||||
*output_char = value;
|
||||
if (match)
|
||||
{
|
||||
if (compose_match)
|
||||
*compose_match = TRUE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (match)
|
||||
{
|
||||
if (compose_match)
|
||||
*compose_match = TRUE;
|
||||
if (compose_finish)
|
||||
*compose_finish = TRUE;
|
||||
if (output_char)
|
||||
*output_char = value;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Checks if a keysym is a dead key.
|
||||
* Dead key keysym values are defined in ../gdk/gdkkeysyms.h and the
|
||||
* first is GDK_KEY_dead_grave. As X.Org is updated, more dead keys
|
||||
* are added and we need to update the upper limit.
|
||||
*/
|
||||
#define IS_DEAD_KEY(k) \
|
||||
((k) >= GDK_KEY_dead_grave && (k) <= GDK_KEY_dead_greek)
|
||||
|
||||
/* This function receives a sequence of Unicode characters and tries to
|
||||
* normalize it (NFC). We check for the case where the resulting string
|
||||
* has length 1 (single character).
|
||||
* NFC normalisation normally rearranges diacritic marks, unless these
|
||||
* belong to the same Canonical Combining Class.
|
||||
* If they belong to the same canonical combining class, we produce all
|
||||
* permutations of the diacritic marks, then attempt to normalize.
|
||||
*/
|
||||
static gboolean
|
||||
check_normalize_nfc (gunichar *combination_buffer,
|
||||
int n_compose)
|
||||
{
|
||||
gunichar *combination_buffer_temp;
|
||||
char *combination_utf8_temp = NULL;
|
||||
char *nfc_temp = NULL;
|
||||
int n_combinations;
|
||||
gunichar temp_swap;
|
||||
int i;
|
||||
|
||||
combination_buffer_temp = g_alloca (n_compose * sizeof (gunichar));
|
||||
|
||||
n_combinations = 1;
|
||||
|
||||
for (i = 1; i < n_compose; i++)
|
||||
n_combinations *= i;
|
||||
|
||||
/* Xorg reuses dead_tilde for the perispomeni diacritic mark.
|
||||
* We check if base character belongs to Greek Unicode block,
|
||||
* and if so, we replace tilde with perispomeni.
|
||||
*/
|
||||
if (combination_buffer[0] >= 0x390 && combination_buffer[0] <= 0x3FF)
|
||||
{
|
||||
for (i = 1; i < n_compose; i++ )
|
||||
if (combination_buffer[i] == 0x303)
|
||||
combination_buffer[i] = 0x342;
|
||||
}
|
||||
|
||||
memcpy (combination_buffer_temp, combination_buffer, n_compose * sizeof (gunichar) );
|
||||
|
||||
for (i = 0; i < n_combinations; i++)
|
||||
{
|
||||
g_unicode_canonical_ordering (combination_buffer_temp, n_compose);
|
||||
combination_utf8_temp = g_ucs4_to_utf8 (combination_buffer_temp, n_compose, NULL, NULL, NULL);
|
||||
nfc_temp = g_utf8_normalize (combination_utf8_temp, -1, G_NORMALIZE_NFC);
|
||||
|
||||
if (g_utf8_strlen (nfc_temp, -1) == 1)
|
||||
{
|
||||
memcpy (combination_buffer, combination_buffer_temp, n_compose * sizeof (gunichar) );
|
||||
|
||||
g_free (combination_utf8_temp);
|
||||
g_free (nfc_temp);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
g_free (combination_utf8_temp);
|
||||
g_free (nfc_temp);
|
||||
|
||||
if (n_compose > 2)
|
||||
{
|
||||
temp_swap = combination_buffer_temp[i % (n_compose - 1) + 1];
|
||||
combination_buffer_temp[i % (n_compose - 1) + 1] = combination_buffer_temp[(i+1) % (n_compose - 1) + 1];
|
||||
combination_buffer_temp[(i+1) % (n_compose - 1) + 1] = temp_swap;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_check_algorithmically (const guint16 *compose_buffer,
|
||||
int n_compose,
|
||||
gunichar *output_char)
|
||||
|
||||
{
|
||||
int i;
|
||||
gunichar *combination_buffer;
|
||||
char *combination_utf8, *nfc;
|
||||
|
||||
combination_buffer = alloca (sizeof (gunichar) * (n_compose + 1));
|
||||
|
||||
if (output_char)
|
||||
*output_char = 0;
|
||||
|
||||
for (i = 0; i < n_compose && IS_DEAD_KEY (compose_buffer[i]); i++)
|
||||
;
|
||||
if (i == n_compose)
|
||||
return TRUE;
|
||||
|
||||
if (i > 0 && i == n_compose - 1)
|
||||
{
|
||||
combination_buffer[0] = gdk_keyval_to_unicode (compose_buffer[i]);
|
||||
combination_buffer[n_compose] = 0;
|
||||
i--;
|
||||
while (i >= 0)
|
||||
{
|
||||
switch (compose_buffer[i])
|
||||
{
|
||||
#define CASE(keysym, unicode) \
|
||||
case GDK_KEY_dead_##keysym: combination_buffer[i+1] = unicode; break
|
||||
|
||||
CASE (grave, 0x0300);
|
||||
CASE (acute, 0x0301);
|
||||
CASE (circumflex, 0x0302);
|
||||
CASE (tilde, 0x0303); /* Also used with perispomeni, 0x342. */
|
||||
CASE (macron, 0x0304);
|
||||
CASE (breve, 0x0306);
|
||||
CASE (abovedot, 0x0307);
|
||||
CASE (diaeresis, 0x0308);
|
||||
CASE (abovering, 0x30A);
|
||||
CASE (hook, 0x0309);
|
||||
CASE (doubleacute, 0x030B);
|
||||
CASE (caron, 0x030C);
|
||||
CASE (cedilla, 0x0327);
|
||||
CASE (ogonek, 0x0328); /* Legacy use for dasia, 0x314.*/
|
||||
CASE (iota, 0x0345);
|
||||
CASE (voiced_sound, 0x3099); /* Per Markus Kuhn keysyms.txt file. */
|
||||
CASE (semivoiced_sound, 0x309A); /* Per Markus Kuhn keysyms.txt file. */
|
||||
CASE (belowdot, 0x0323);
|
||||
CASE (horn, 0x031B); /* Legacy use for psili, 0x313 (or 0x343). */
|
||||
CASE (stroke, 0x335);
|
||||
CASE (abovecomma, 0x0313); /* Equivalent to psili */
|
||||
CASE (abovereversedcomma, 0x0314); /* Equivalent to dasia */
|
||||
CASE (doublegrave, 0x30F);
|
||||
CASE (belowring, 0x325);
|
||||
CASE (belowmacron, 0x331);
|
||||
CASE (belowcircumflex, 0x32D);
|
||||
CASE (belowtilde, 0x330);
|
||||
CASE (belowbreve, 0x32e);
|
||||
CASE (belowdiaeresis, 0x324);
|
||||
CASE (invertedbreve, 0x32f);
|
||||
CASE (belowcomma, 0x326);
|
||||
CASE (lowline, 0x332);
|
||||
CASE (aboveverticalline, 0x30D);
|
||||
CASE (belowverticalline, 0x329);
|
||||
CASE (longsolidusoverlay, 0x338);
|
||||
CASE (a, 0x363);
|
||||
CASE (A, 0x363);
|
||||
CASE (e, 0x364);
|
||||
CASE (E, 0x364);
|
||||
CASE (i, 0x365);
|
||||
CASE (I, 0x365);
|
||||
CASE (o, 0x366);
|
||||
CASE (O, 0x366);
|
||||
CASE (u, 0x367);
|
||||
CASE (U, 0x367);
|
||||
CASE (small_schwa, 0x1DEA);
|
||||
CASE (capital_schwa, 0x1DEA);
|
||||
#undef CASE
|
||||
default:
|
||||
combination_buffer[i+1] = gdk_keyval_to_unicode (compose_buffer[i]);
|
||||
}
|
||||
i--;
|
||||
}
|
||||
|
||||
/* If the buffer normalizes to a single character, then modify the order
|
||||
* of combination_buffer accordingly, if necessary, and return TRUE.
|
||||
*/
|
||||
if (check_normalize_nfc (combination_buffer, n_compose))
|
||||
{
|
||||
combination_utf8 = g_ucs4_to_utf8 (combination_buffer, -1, NULL, NULL, NULL);
|
||||
nfc = g_utf8_normalize (combination_utf8, -1, G_NORMALIZE_NFC);
|
||||
|
||||
if (output_char)
|
||||
*output_char = g_utf8_get_char (nfc);
|
||||
|
||||
g_free (combination_utf8);
|
||||
g_free (nfc);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
+28
-7
@@ -29,8 +29,10 @@ typedef struct _GtkComposeTableCompact GtkComposeTableCompact;
|
||||
struct _GtkComposeTable
|
||||
{
|
||||
guint16 *data;
|
||||
char *char_data;
|
||||
int max_seq_len;
|
||||
int n_seqs;
|
||||
int n_chars;
|
||||
guint32 id;
|
||||
};
|
||||
|
||||
@@ -42,13 +44,32 @@ struct _GtkComposeTableCompact
|
||||
int n_index_stride;
|
||||
};
|
||||
|
||||
GtkComposeTable * gtk_compose_table_new_with_file (const char *compose_file);
|
||||
GSList *gtk_compose_table_list_add_array (GSList *compose_tables,
|
||||
const guint16 *data,
|
||||
int max_seq_len,
|
||||
int n_seqs);
|
||||
GSList *gtk_compose_table_list_add_file (GSList *compose_tables,
|
||||
const char *compose_file);
|
||||
GtkComposeTable * gtk_compose_table_new_with_file (const char *compose_file);
|
||||
GSList * gtk_compose_table_list_add_array (GSList *compose_tables,
|
||||
const guint16 *data,
|
||||
int max_seq_len,
|
||||
int n_seqs);
|
||||
GSList * gtk_compose_table_list_add_file (GSList *compose_tables,
|
||||
const char *compose_file);
|
||||
|
||||
gboolean gtk_compose_table_check (const GtkComposeTable *table,
|
||||
const guint16 *compose_buffer,
|
||||
int n_compose,
|
||||
gboolean *compose_finish,
|
||||
gboolean *compose_match,
|
||||
GString *output);
|
||||
|
||||
gboolean gtk_compose_table_compact_check (const GtkComposeTableCompact *table,
|
||||
const guint16 *compose_buffer,
|
||||
int n_compose,
|
||||
gboolean *compose_finish,
|
||||
gboolean *compose_match,
|
||||
gunichar *output_char);
|
||||
|
||||
gboolean gtk_check_algorithmically (const guint16 *compose_buffer,
|
||||
int n_compose,
|
||||
gunichar *output);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -440,6 +440,10 @@ gtk_css_animated_style_set_animated_value (GtkCssAnimatedStyle *animated,
|
||||
unshare_other (animated);
|
||||
gtk_css_take_value (&style->other->transform, value);
|
||||
break;
|
||||
case GTK_CSS_PROPERTY_TRANSFORM_ORIGIN:
|
||||
unshare_other (animated);
|
||||
gtk_css_take_value (&style->other->transform_origin, value);
|
||||
break;
|
||||
case GTK_CSS_PROPERTY_MIN_WIDTH:
|
||||
unshare_size (animated);
|
||||
gtk_css_take_value (&style->size->min_width, value);
|
||||
|
||||
+93
-51
@@ -545,57 +545,6 @@ _gtk_css_font_stretch_value_get (const GtkCssValue *value)
|
||||
return value->value;
|
||||
}
|
||||
|
||||
/* GtkTextDecorationLine */
|
||||
|
||||
static const GtkCssValueClass GTK_CSS_VALUE_TEXT_DECORATION_LINE = {
|
||||
"GtkCssTextDecorationLineValue",
|
||||
gtk_css_value_enum_free,
|
||||
gtk_css_value_enum_compute,
|
||||
gtk_css_value_enum_equal,
|
||||
gtk_css_value_enum_transition,
|
||||
NULL,
|
||||
NULL,
|
||||
gtk_css_value_enum_print
|
||||
};
|
||||
|
||||
static GtkCssValue text_decoration_line_values[] = {
|
||||
{ >K_CSS_VALUE_TEXT_DECORATION_LINE, 1, TRUE, GTK_CSS_TEXT_DECORATION_LINE_NONE, "none" },
|
||||
{ >K_CSS_VALUE_TEXT_DECORATION_LINE, 1, TRUE, GTK_CSS_TEXT_DECORATION_LINE_UNDERLINE, "underline" },
|
||||
{ >K_CSS_VALUE_TEXT_DECORATION_LINE, 1, TRUE, GTK_CSS_TEXT_DECORATION_LINE_LINE_THROUGH, "line-through" },
|
||||
};
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_text_decoration_line_value_new (GtkTextDecorationLine line)
|
||||
{
|
||||
g_return_val_if_fail (line < G_N_ELEMENTS (text_decoration_line_values), NULL);
|
||||
|
||||
return _gtk_css_value_ref (&text_decoration_line_values[line]);
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_text_decoration_line_value_try_parse (GtkCssParser *parser)
|
||||
{
|
||||
guint i;
|
||||
|
||||
g_return_val_if_fail (parser != NULL, NULL);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (text_decoration_line_values); i++)
|
||||
{
|
||||
if (gtk_css_parser_try_ident (parser, text_decoration_line_values[i].name))
|
||||
return _gtk_css_value_ref (&text_decoration_line_values[i]);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GtkTextDecorationLine
|
||||
_gtk_css_text_decoration_line_value_get (const GtkCssValue *value)
|
||||
{
|
||||
g_return_val_if_fail (value->class == >K_CSS_VALUE_TEXT_DECORATION_LINE, GTK_CSS_TEXT_DECORATION_LINE_NONE);
|
||||
|
||||
return value->value;
|
||||
}
|
||||
|
||||
/* GtkTextDecorationStyle */
|
||||
|
||||
static const GtkCssValueClass GTK_CSS_VALUE_TEXT_DECORATION_STYLE = {
|
||||
@@ -1203,6 +1152,99 @@ gtk_css_value_flags_print (const FlagsValue *values,
|
||||
}
|
||||
}
|
||||
|
||||
/* GtkTextDecorationLine */
|
||||
|
||||
static FlagsValue text_decoration_line_values[] = {
|
||||
{ GTK_CSS_TEXT_DECORATION_LINE_NONE, "none" },
|
||||
{ GTK_CSS_TEXT_DECORATION_LINE_UNDERLINE, "underline" },
|
||||
{ GTK_CSS_TEXT_DECORATION_LINE_OVERLINE, "overline" },
|
||||
{ GTK_CSS_TEXT_DECORATION_LINE_LINE_THROUGH, "line-through" },
|
||||
};
|
||||
|
||||
static void
|
||||
gtk_css_text_decoration_line_value_print (const GtkCssValue *value,
|
||||
GString *string)
|
||||
{
|
||||
gtk_css_value_flags_print (text_decoration_line_values,
|
||||
G_N_ELEMENTS (text_decoration_line_values),
|
||||
value, string);
|
||||
}
|
||||
|
||||
static const GtkCssValueClass GTK_CSS_VALUE_TEXT_DECORATION_LINE = {
|
||||
"GtkCssTextDecorationLine",
|
||||
gtk_css_value_enum_free,
|
||||
gtk_css_value_enum_compute,
|
||||
gtk_css_value_flags_equal,
|
||||
gtk_css_value_enum_transition,
|
||||
NULL,
|
||||
NULL,
|
||||
gtk_css_text_decoration_line_value_print
|
||||
};
|
||||
|
||||
static gboolean
|
||||
text_decoration_line_is_valid (GtkTextDecorationLine line)
|
||||
{
|
||||
if ((line & GTK_CSS_TEXT_DECORATION_LINE_NONE) &&
|
||||
(line != GTK_CSS_TEXT_DECORATION_LINE_NONE))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_text_decoration_line_value_new (GtkTextDecorationLine line)
|
||||
{
|
||||
GtkCssValue *value;
|
||||
|
||||
if (!text_decoration_line_is_valid (line))
|
||||
return NULL;
|
||||
|
||||
value = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_TEXT_DECORATION_LINE);
|
||||
value->value = line;
|
||||
value->name = NULL;
|
||||
value->is_computed = TRUE;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
GtkTextDecorationLine
|
||||
_gtk_css_text_decoration_line_try_parse_one (GtkCssParser *parser,
|
||||
GtkTextDecorationLine base)
|
||||
{
|
||||
guint i;
|
||||
GtkTextDecorationLine value = 0;
|
||||
|
||||
g_return_val_if_fail (parser != NULL, 0);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (text_decoration_line_values); i++)
|
||||
{
|
||||
if (gtk_css_parser_try_ident (parser, text_decoration_line_values[i].name))
|
||||
{
|
||||
value = text_decoration_line_values[i].value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (value == 0)
|
||||
return base; /* not parsing this value */
|
||||
|
||||
if ((base | value) == base)
|
||||
return 0; /* repeated value */
|
||||
|
||||
if (!text_decoration_line_is_valid (base | value))
|
||||
return 0; /* bad combination */
|
||||
|
||||
return base | value;
|
||||
}
|
||||
|
||||
GtkTextDecorationLine
|
||||
_gtk_css_text_decoration_line_value_get (const GtkCssValue *value)
|
||||
{
|
||||
g_return_val_if_fail (value->class == >K_CSS_VALUE_TEXT_DECORATION_LINE, GTK_CSS_TEXT_DECORATION_LINE_NONE);
|
||||
|
||||
return value->value;
|
||||
}
|
||||
|
||||
/* GtkCssFontVariantLigature */
|
||||
|
||||
static FlagsValue font_variant_ligature_values[] = {
|
||||
|
||||
@@ -54,11 +54,12 @@ GtkCssValue * _gtk_css_font_stretch_value_new (PangoStretch stretc
|
||||
GtkCssValue * _gtk_css_font_stretch_value_try_parse (GtkCssParser *parser);
|
||||
PangoStretch _gtk_css_font_stretch_value_get (const GtkCssValue *value);
|
||||
|
||||
GtkCssValue * _gtk_css_text_decoration_line_value_new (GtkTextDecorationLine line);
|
||||
GtkCssValue * _gtk_css_text_decoration_line_value_try_parse (GtkCssParser *parser);
|
||||
GtkTextDecorationLine _gtk_css_text_decoration_line_value_get (const GtkCssValue *value);
|
||||
GtkCssValue * _gtk_css_text_decoration_line_value_new (GtkTextDecorationLine line);
|
||||
GtkTextDecorationLine _gtk_css_text_decoration_line_try_parse_one (GtkCssParser *parser,
|
||||
GtkTextDecorationLine base);
|
||||
GtkTextDecorationLine _gtk_css_text_decoration_line_value_get (const GtkCssValue *value);
|
||||
|
||||
GtkCssValue * _gtk_css_text_decoration_style_value_new (GtkTextDecorationStyle style);
|
||||
GtkCssValue * _gtk_css_text_decoration_style_value_new (GtkTextDecorationStyle style);
|
||||
GtkCssValue * _gtk_css_text_decoration_style_value_try_parse (GtkCssParser *parser);
|
||||
GtkTextDecorationStyle _gtk_css_text_decoration_style_value_get (const GtkCssValue *value);
|
||||
|
||||
|
||||
+64
-20
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "gtkcssfiltervalueprivate.h"
|
||||
#include "gtkcssnumbervalueprivate.h"
|
||||
#include "gtkcssshadowvalueprivate.h"
|
||||
|
||||
typedef union _GtkCssFilter GtkCssFilter;
|
||||
|
||||
@@ -46,7 +47,7 @@ union _GtkCssFilter {
|
||||
struct {
|
||||
GtkCssFilterType type;
|
||||
GtkCssValue *value;
|
||||
} brightness, contrast, grayscale, hue_rotate, invert, opacity, saturate, sepia, blur;
|
||||
} blur, brightness, contrast, drop_shadow, grayscale, hue_rotate, invert, opacity, saturate, sepia;
|
||||
};
|
||||
|
||||
struct _GtkCssValue {
|
||||
@@ -90,8 +91,10 @@ gtk_css_filter_clear (GtkCssFilter *filter)
|
||||
case GTK_CSS_FILTER_BLUR:
|
||||
_gtk_css_value_unref (filter->blur.value);
|
||||
break;
|
||||
case GTK_CSS_FILTER_NONE:
|
||||
case GTK_CSS_FILTER_DROP_SHADOW:
|
||||
_gtk_css_value_unref (filter->drop_shadow.value);
|
||||
break;
|
||||
case GTK_CSS_FILTER_NONE:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
@@ -131,8 +134,10 @@ gtk_css_filter_init_identity (GtkCssFilter *filter,
|
||||
case GTK_CSS_FILTER_BLUR:
|
||||
filter->blur.value = _gtk_css_number_value_new (0, GTK_CSS_PX);
|
||||
break;
|
||||
case GTK_CSS_FILTER_NONE:
|
||||
case GTK_CSS_FILTER_DROP_SHADOW:
|
||||
filter->drop_shadow.value = gtk_css_shadow_value_new_filter ();
|
||||
break;
|
||||
case GTK_CSS_FILTER_NONE:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
@@ -347,8 +352,11 @@ gtk_css_filter_compute (GtkCssFilter *dest,
|
||||
dest->blur.value = _gtk_css_value_compute (src->blur.value, property_id, provider, style, parent_style);
|
||||
return dest->blur.value == src->blur.value;
|
||||
|
||||
case GTK_CSS_FILTER_NONE:
|
||||
case GTK_CSS_FILTER_DROP_SHADOW:
|
||||
dest->drop_shadow.value = _gtk_css_value_compute (src->drop_shadow.value, property_id, provider, style, parent_style);
|
||||
return dest->drop_shadow.value == src->drop_shadow.value;
|
||||
|
||||
case GTK_CSS_FILTER_NONE:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
return FALSE;
|
||||
@@ -428,8 +436,10 @@ gtk_css_filter_equal (const GtkCssFilter *filter1,
|
||||
case GTK_CSS_FILTER_BLUR:
|
||||
return _gtk_css_value_equal (filter1->blur.value, filter2->blur.value);
|
||||
|
||||
case GTK_CSS_FILTER_NONE:
|
||||
case GTK_CSS_FILTER_DROP_SHADOW:
|
||||
return _gtk_css_value_equal (filter1->drop_shadow.value, filter2->drop_shadow.value);
|
||||
|
||||
case GTK_CSS_FILTER_NONE:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
return FALSE;
|
||||
@@ -517,8 +527,11 @@ gtk_css_filter_transition (GtkCssFilter *result,
|
||||
result->blur.value = _gtk_css_value_transition (start->blur.value, end->blur.value, property_id, progress);
|
||||
break;
|
||||
|
||||
case GTK_CSS_FILTER_NONE:
|
||||
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);
|
||||
break;
|
||||
|
||||
case GTK_CSS_FILTER_NONE:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
@@ -663,8 +676,13 @@ gtk_css_filter_print (const GtkCssFilter *filter,
|
||||
g_string_append (string, ")");
|
||||
break;
|
||||
|
||||
case GTK_CSS_FILTER_NONE:
|
||||
case GTK_CSS_FILTER_DROP_SHADOW:
|
||||
g_string_append (string, "drop-shadow(");
|
||||
_gtk_css_value_print (filter->drop_shadow.value, string);
|
||||
g_string_append (string, ")");
|
||||
break;
|
||||
|
||||
case GTK_CSS_FILTER_NONE:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
@@ -709,12 +727,12 @@ static GtkCssValue *
|
||||
gtk_css_filter_value_alloc (guint n_filters)
|
||||
{
|
||||
GtkCssValue *result;
|
||||
|
||||
|
||||
g_return_val_if_fail (n_filters > 0, NULL);
|
||||
|
||||
|
||||
result = _gtk_css_value_alloc (>K_CSS_VALUE_FILTER, sizeof (GtkCssValue) + sizeof (GtkCssFilter) * (n_filters - 1));
|
||||
result->n_filters = n_filters;
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -737,7 +755,7 @@ gtk_css_filter_parse_number (GtkCssParser *parser,
|
||||
{
|
||||
GtkCssValue **values = data;
|
||||
|
||||
values[n] = _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_NUMBER | GTK_CSS_PARSE_PERCENT);
|
||||
values[n] = _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_NUMBER | GTK_CSS_PARSE_PERCENT | GTK_CSS_POSITIVE_ONLY);
|
||||
if (values[n] == NULL)
|
||||
return 0;
|
||||
|
||||
@@ -751,7 +769,7 @@ gtk_css_filter_parse_length (GtkCssParser *parser,
|
||||
{
|
||||
GtkCssValue **values = data;
|
||||
|
||||
values[n] = _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_LENGTH);
|
||||
values[n] = _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_LENGTH | GTK_CSS_POSITIVE_ONLY);
|
||||
if (values[n] == NULL)
|
||||
return 0;
|
||||
|
||||
@@ -772,6 +790,20 @@ gtk_css_filter_parse_angle (GtkCssParser *parser,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static guint
|
||||
gtk_css_filter_parse_shadow (GtkCssParser *parser,
|
||||
guint n,
|
||||
gpointer data)
|
||||
{
|
||||
GtkCssValue **values = data;
|
||||
|
||||
values[n] = gtk_css_shadow_value_parse_filter (parser);
|
||||
if (values[n] == NULL)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
gtk_css_filter_value_parse (GtkCssParser *parser)
|
||||
{
|
||||
@@ -861,6 +893,14 @@ gtk_css_filter_value_parse (GtkCssParser *parser)
|
||||
filter.type = GTK_CSS_FILTER_SEPIA;
|
||||
computed = computed && gtk_css_value_is_computed (filter.sepia.value);
|
||||
}
|
||||
else if (gtk_css_parser_has_function (parser, "drop-shadow"))
|
||||
{
|
||||
if (!gtk_css_parser_consume_function (parser, 1, 1, gtk_css_filter_parse_shadow, &filter.drop_shadow.value))
|
||||
goto fail;
|
||||
|
||||
filter.type = GTK_CSS_FILTER_DROP_SHADOW;
|
||||
computed = computed && gtk_css_value_is_computed (filter.drop_shadow.value);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
@@ -899,7 +939,6 @@ gtk_css_filter_value_push_snapshot (const GtkCssValue *filter,
|
||||
graphene_matrix_t matrix;
|
||||
graphene_vec4_t offset;
|
||||
int i, j;
|
||||
double radius;
|
||||
|
||||
if (gtk_css_filter_value_is_none (filter))
|
||||
return;
|
||||
@@ -909,16 +948,18 @@ gtk_css_filter_value_push_snapshot (const GtkCssValue *filter,
|
||||
{
|
||||
j = gtk_css_filter_value_compute_matrix (filter, i, &matrix, &offset);
|
||||
if (i < j)
|
||||
gtk_snapshot_push_color_matrix (snapshot,
|
||||
&matrix,
|
||||
&offset);
|
||||
gtk_snapshot_push_color_matrix (snapshot, &matrix, &offset);
|
||||
|
||||
if (j < filter->n_filters)
|
||||
{
|
||||
if (filter->filters[j].type == GTK_CSS_FILTER_BLUR)
|
||||
{
|
||||
radius = _gtk_css_number_value_get (filter->filters[j].blur.value, 100.0);
|
||||
gtk_snapshot_push_blur (snapshot, radius);
|
||||
double std_dev = _gtk_css_number_value_get (filter->filters[j].blur.value, 100.0);
|
||||
gtk_snapshot_push_blur (snapshot, 2 * std_dev);
|
||||
}
|
||||
else if (filter->filters[j].type == GTK_CSS_FILTER_DROP_SHADOW)
|
||||
{
|
||||
gtk_css_shadow_value_push_snapshot (filter->filters[j].drop_shadow.value, snapshot);
|
||||
}
|
||||
else
|
||||
g_warning ("Don't know how to handle filter type %d", filter->filters[j].type);
|
||||
@@ -942,15 +983,18 @@ gtk_css_filter_value_pop_snapshot (const GtkCssValue *filter,
|
||||
{
|
||||
for (j = i; j < filter->n_filters; j++)
|
||||
{
|
||||
if (filter->filters[j].type == GTK_CSS_FILTER_BLUR)
|
||||
if (filter->filters[j].type == GTK_CSS_FILTER_BLUR ||
|
||||
filter->filters[j].type == GTK_CSS_FILTER_DROP_SHADOW)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i < j)
|
||||
gtk_snapshot_pop (snapshot);
|
||||
|
||||
if (j < filter->n_filters)
|
||||
if (filter->filters[j].type == GTK_CSS_FILTER_BLUR)
|
||||
gtk_snapshot_pop (snapshot);
|
||||
else if (filter->filters[j].type == GTK_CSS_FILTER_DROP_SHADOW)
|
||||
gtk_css_shadow_value_pop_snapshot (filter->filters[j].drop_shadow.value, snapshot);
|
||||
|
||||
i = j + 1;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "gtk/gtkcssimageurlprivate.h"
|
||||
#include "gtk/gtkcssimagescaledprivate.h"
|
||||
#include "gtk/gtkcssimagerecolorprivate.h"
|
||||
#include "gtk/gtkcssimagefilterprivate.h"
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE (GtkCssImage, _gtk_css_image, G_TYPE_OBJECT)
|
||||
|
||||
@@ -524,6 +525,7 @@ gtk_css_image_get_parser_type (GtkCssParser *parser)
|
||||
{ "repeating-radial-gradient", _gtk_css_image_radial_get_type },
|
||||
{ "conic-gradient", gtk_css_image_conic_get_type },
|
||||
{ "cross-fade", gtk_css_image_cross_fade_get_type },
|
||||
{ "filter", gtk_css_image_filter_get_type },
|
||||
{ "image", _gtk_css_image_fallback_get_type }
|
||||
};
|
||||
guint i;
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#include "gtkcssimagecrossfadeprivate.h"
|
||||
|
||||
#include "gtkcssnumbervalueprivate.h"
|
||||
#include "gtkcssimagefallbackprivate.h"
|
||||
#include "gtkcsscolorvalueprivate.h"
|
||||
|
||||
|
||||
typedef struct _CrossFadeEntry CrossFadeEntry;
|
||||
|
||||
@@ -308,8 +311,19 @@ parse_image (GtkCssParser *parser,
|
||||
{
|
||||
GtkCssImage **image = option_data;
|
||||
|
||||
*image = _gtk_css_image_new_parse (parser);
|
||||
if (*image == NULL)
|
||||
if (_gtk_css_image_can_parse (parser))
|
||||
*image = _gtk_css_image_new_parse (parser);
|
||||
else if (gtk_css_color_value_can_parse (parser))
|
||||
{
|
||||
GtkCssValue *color;
|
||||
|
||||
color = _gtk_css_color_value_parse (parser);
|
||||
if (color == NULL)
|
||||
return FALSE;
|
||||
|
||||
*image = _gtk_css_image_fallback_new_for_color (color);
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
@@ -325,7 +339,7 @@ gtk_css_image_cross_fade_parse_arg (GtkCssParser *parser,
|
||||
GtkCssImage *image = NULL;
|
||||
GtkCssParseOption options[] =
|
||||
{
|
||||
{ (void *) gtk_css_number_value_can_parse, parse_progress, &progress },
|
||||
{ (void *)gtk_css_number_value_can_parse, parse_progress, &progress },
|
||||
{ NULL, parse_image, &image },
|
||||
};
|
||||
|
||||
|
||||
@@ -148,11 +148,11 @@ 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,
|
||||
provider,
|
||||
style,
|
||||
parent_style);
|
||||
|
||||
/* image($color) that didn't change */
|
||||
if (computed_color && !fallback->images &&
|
||||
@@ -331,3 +331,14 @@ _gtk_css_image_fallback_init (GtkCssImageFallback *image_fallback)
|
||||
{
|
||||
image_fallback->used = -1;
|
||||
}
|
||||
|
||||
GtkCssImage *
|
||||
_gtk_css_image_fallback_new_for_color (GtkCssValue *color)
|
||||
{
|
||||
GtkCssImageFallback *image;
|
||||
|
||||
image = g_object_new (GTK_TYPE_CSS_IMAGE_FALLBACK, NULL);
|
||||
image->color = gtk_css_value_ref (color);
|
||||
|
||||
return (GtkCssImage *)image;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,9 @@ struct _GtkCssImageFallbackClass
|
||||
GtkCssImageClass parent_class;
|
||||
};
|
||||
|
||||
GType _gtk_css_image_fallback_get_type (void) G_GNUC_CONST;
|
||||
GType _gtk_css_image_fallback_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkCssImage *_gtk_css_image_fallback_new_for_color (GtkCssValue *color);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -0,0 +1,216 @@
|
||||
/*
|
||||
* Copyright © 2021 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: Matthias Clasen <mclasen@redhat.com>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gtkcssimagefilterprivate.h"
|
||||
|
||||
#include "gtkcssfiltervalueprivate.h"
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GtkCssImageFilter, gtk_css_image_filter, GTK_TYPE_CSS_IMAGE)
|
||||
|
||||
static int
|
||||
gtk_css_image_filter_get_width (GtkCssImage *image)
|
||||
{
|
||||
GtkCssImageFilter *self = GTK_CSS_IMAGE_FILTER (image);
|
||||
|
||||
return _gtk_css_image_get_width (self->image);
|
||||
}
|
||||
|
||||
static int
|
||||
gtk_css_image_filter_get_height (GtkCssImage *image)
|
||||
{
|
||||
GtkCssImageFilter *self = GTK_CSS_IMAGE_FILTER (image);
|
||||
|
||||
return _gtk_css_image_get_height (self->image);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_image_filter_equal (GtkCssImage *image1,
|
||||
GtkCssImage *image2)
|
||||
{
|
||||
GtkCssImageFilter *filter1 = GTK_CSS_IMAGE_FILTER (image1);
|
||||
GtkCssImageFilter *filter2 = GTK_CSS_IMAGE_FILTER (image2);
|
||||
|
||||
return _gtk_css_image_equal (filter1->image, filter2->image) &&
|
||||
_gtk_css_value_equal (filter1->filter, filter2->filter);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_image_filter_is_dynamic (GtkCssImage *image)
|
||||
{
|
||||
GtkCssImageFilter *self = GTK_CSS_IMAGE_FILTER (image);
|
||||
|
||||
return gtk_css_image_is_dynamic (self->image);
|
||||
}
|
||||
|
||||
static GtkCssImage *
|
||||
gtk_css_image_filter_get_dynamic_image (GtkCssImage *image,
|
||||
gint64 monotonic_time)
|
||||
{
|
||||
GtkCssImageFilter *self = GTK_CSS_IMAGE_FILTER (image);
|
||||
|
||||
return gtk_css_image_filter_new (gtk_css_image_get_dynamic_image (self->image, monotonic_time),
|
||||
self->filter);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_image_filter_snapshot (GtkCssImage *image,
|
||||
GtkSnapshot *snapshot,
|
||||
double width,
|
||||
double height)
|
||||
{
|
||||
GtkCssImageFilter *self = GTK_CSS_IMAGE_FILTER (image);
|
||||
|
||||
gtk_css_filter_value_push_snapshot (self->filter, snapshot);
|
||||
gtk_css_image_snapshot (self->image, snapshot, width, height);
|
||||
gtk_css_filter_value_pop_snapshot (self->filter, snapshot);
|
||||
}
|
||||
|
||||
static guint
|
||||
gtk_css_image_filter_parse_arg (GtkCssParser *parser,
|
||||
guint arg,
|
||||
gpointer data)
|
||||
{
|
||||
GtkCssImageFilter *self = data;
|
||||
|
||||
switch (arg)
|
||||
{
|
||||
case 0:
|
||||
self->image = _gtk_css_image_new_parse (parser);
|
||||
if (self->image == NULL)
|
||||
return 0;
|
||||
return 1;
|
||||
|
||||
case 1:
|
||||
self->filter = gtk_css_filter_value_parse (parser);
|
||||
if (self->filter == NULL)
|
||||
return 0;
|
||||
return 1;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_image_filter_parse (GtkCssImage *image,
|
||||
GtkCssParser *parser)
|
||||
{
|
||||
if (!gtk_css_parser_has_function (parser, "filter"))
|
||||
{
|
||||
gtk_css_parser_error_syntax (parser, "Expected 'filter('");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return gtk_css_parser_consume_function (parser, 2, 2, gtk_css_image_filter_parse_arg, image);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_image_filter_print (GtkCssImage *image,
|
||||
GString *string)
|
||||
{
|
||||
GtkCssImageFilter *self = GTK_CSS_IMAGE_FILTER (image);
|
||||
|
||||
g_string_append (string, "filter(");
|
||||
_gtk_css_image_print (self->image, string);
|
||||
g_string_append (string, ",");
|
||||
_gtk_css_value_print (self->filter, string);
|
||||
g_string_append (string, ")");
|
||||
}
|
||||
|
||||
static GtkCssImage *
|
||||
gtk_css_image_filter_compute (GtkCssImage *image,
|
||||
guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
GtkCssImageFilter *self = GTK_CSS_IMAGE_FILTER (image);
|
||||
|
||||
return gtk_css_image_filter_new (_gtk_css_image_compute (self->image, property_id, provider, style, parent_style),
|
||||
_gtk_css_value_compute (self->filter, property_id, provider, style, parent_style));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_image_filter_dispose (GObject *object)
|
||||
{
|
||||
GtkCssImageFilter *self = GTK_CSS_IMAGE_FILTER (object);
|
||||
|
||||
g_clear_object (&self->image);
|
||||
g_clear_pointer (&self->filter, _gtk_css_value_unref);
|
||||
|
||||
G_OBJECT_CLASS (gtk_css_image_filter_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_image_filter_is_computed (GtkCssImage *image)
|
||||
{
|
||||
GtkCssImageFilter *self = GTK_CSS_IMAGE_FILTER (image);
|
||||
|
||||
return gtk_css_image_is_computed (self->image) &&
|
||||
gtk_css_value_is_computed (self->filter);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_image_filter_class_init (GtkCssImageFilterClass *klass)
|
||||
{
|
||||
GtkCssImageClass *image_class = GTK_CSS_IMAGE_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
image_class->get_width = gtk_css_image_filter_get_width;
|
||||
image_class->get_height = gtk_css_image_filter_get_height;
|
||||
image_class->compute = gtk_css_image_filter_compute;
|
||||
image_class->equal = gtk_css_image_filter_equal;
|
||||
image_class->snapshot = gtk_css_image_filter_snapshot;
|
||||
image_class->is_dynamic = gtk_css_image_filter_is_dynamic;
|
||||
image_class->get_dynamic_image = gtk_css_image_filter_get_dynamic_image;
|
||||
image_class->parse = gtk_css_image_filter_parse;
|
||||
image_class->print = gtk_css_image_filter_print;
|
||||
image_class->is_computed = gtk_css_image_filter_is_computed;
|
||||
|
||||
object_class->dispose = gtk_css_image_filter_dispose;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_image_filter_init (GtkCssImageFilter *self)
|
||||
{
|
||||
}
|
||||
|
||||
GtkCssImage *
|
||||
gtk_css_image_filter_new (GtkCssImage *image,
|
||||
GtkCssValue *filter)
|
||||
{
|
||||
GtkCssImageFilter *self;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_CSS_IMAGE (image), NULL);
|
||||
|
||||
self = g_object_new (GTK_TYPE_CSS_IMAGE_FILTER, NULL);
|
||||
|
||||
self->image = g_object_ref (image);
|
||||
self->filter = gtk_css_value_ref (filter);
|
||||
|
||||
return GTK_CSS_IMAGE (self);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright © 2021 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: Matthias Clasen <mclasen@redhat.com>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_CSS_IMAGE_FILTER_PRIVATE_H__
|
||||
#define __GTK_CSS_IMAGE_FILTER_PRIVATE_H__
|
||||
|
||||
#include "gtk/gtkcssimageprivate.h"
|
||||
#include "gtk/gtkcssvalueprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_CSS_IMAGE_FILTER (gtk_css_image_filter_get_type ())
|
||||
#define GTK_CSS_IMAGE_FILTER(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GTK_TYPE_CSS_IMAGE_FILTER, GtkCssImageFilter))
|
||||
#define GTK_CSS_IMAGE_FILTER_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST (cls, GTK_TYPE_CSS_IMAGE_FILTER, GtkCssImageFilterClass))
|
||||
#define GTK_IS_CSS_IMAGE_FILTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GTK_TYPE_CSS_IMAGE_FILTER))
|
||||
#define GTK_IS_CSS_IMAGE_FILTER_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE (obj, GTK_TYPE_CSS_IMAGE_FILTER))
|
||||
#define GTK_CSS_IMAGE_FILTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CSS_IMAGE_FILTER, GtkCssImageFilterClass))
|
||||
|
||||
typedef struct _GtkCssImageFilter GtkCssImageFilter;
|
||||
typedef struct _GtkCssImageFilterClass GtkCssImageFilterClass;
|
||||
|
||||
struct _GtkCssImageFilter
|
||||
{
|
||||
GtkCssImage parent;
|
||||
|
||||
GtkCssImage *image;
|
||||
GtkCssValue *filter;
|
||||
};
|
||||
|
||||
struct _GtkCssImageFilterClass
|
||||
{
|
||||
GtkCssImageClass parent_class;
|
||||
};
|
||||
|
||||
GType gtk_css_image_filter_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkCssImage * gtk_css_image_filter_new (GtkCssImage *image,
|
||||
GtkCssValue *filter);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_CSS_IMAGE_FILTER_PRIVATE_H__ */
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "gtkcssinheritvalueprivate.h"
|
||||
|
||||
#include "gtkcssinitialvalueprivate.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtkcssstyleprivate.h"
|
||||
|
||||
struct _GtkCssValue {
|
||||
GTK_CSS_VALUE_BASE
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include "gtkcssshorthandpropertyprivate.h"
|
||||
#include "gtksettingsprivate.h"
|
||||
#include "gtkstyleprovider.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtkstylepropertyprivate.h"
|
||||
#include "gtkstyleproviderprivate.h"
|
||||
#include "gtkmarshalers.h"
|
||||
|
||||
+86
-24
@@ -25,7 +25,6 @@
|
||||
#include "gtkcssnumbervalueprivate.h"
|
||||
#include "gtkcsscolorvalueprivate.h"
|
||||
#include "gtksnapshotprivate.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtkpango.h"
|
||||
|
||||
#include "gsk/gskcairoblurprivate.h"
|
||||
@@ -45,12 +44,14 @@ typedef struct {
|
||||
|
||||
struct _GtkCssValue {
|
||||
GTK_CSS_VALUE_BASE
|
||||
guint is_filter : 1; /* values stored in radius are std_dev, for drop-shadow */
|
||||
guint n_shadows;
|
||||
ShadowValue shadows[1];
|
||||
};
|
||||
|
||||
static GtkCssValue * gtk_css_shadow_value_new (ShadowValue *shadows,
|
||||
guint n_shadows);
|
||||
guint n_shadows,
|
||||
gboolean is_filter);
|
||||
|
||||
static void
|
||||
shadow_value_for_transition (ShadowValue *result,
|
||||
@@ -134,7 +135,7 @@ gtk_css_value_shadow_compute (GtkCssValue *value,
|
||||
shadows[i].inset = shadow->inset;
|
||||
}
|
||||
|
||||
return gtk_css_shadow_value_new (shadows, value->n_shadows);
|
||||
return gtk_css_shadow_value_new (shadows, value->n_shadows, value->is_filter);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -228,7 +229,7 @@ gtk_css_value_shadow_transition (GtkCssValue *start,
|
||||
}
|
||||
}
|
||||
|
||||
return gtk_css_shadow_value_new (shadows, len);
|
||||
return gtk_css_shadow_value_new (shadows, len, start->is_filter);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -285,7 +286,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_SHADOW = {
|
||||
gtk_css_value_shadow_print
|
||||
};
|
||||
|
||||
static GtkCssValue shadow_none_singleton = { >K_CSS_VALUE_SHADOW, 1, TRUE, 0 };
|
||||
static GtkCssValue shadow_none_singleton = { >K_CSS_VALUE_SHADOW, 1, TRUE, FALSE, 0 };
|
||||
|
||||
GtkCssValue *
|
||||
gtk_css_shadow_value_new_none (void)
|
||||
@@ -295,7 +296,8 @@ gtk_css_shadow_value_new_none (void)
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_shadow_value_new (ShadowValue *shadows,
|
||||
guint n_shadows)
|
||||
guint n_shadows,
|
||||
gboolean is_filter)
|
||||
{
|
||||
GtkCssValue *retval;
|
||||
guint i;
|
||||
@@ -305,6 +307,7 @@ gtk_css_shadow_value_new (ShadowValue *shadows,
|
||||
|
||||
retval = _gtk_css_value_alloc (>K_CSS_VALUE_SHADOW, sizeof (GtkCssValue) + sizeof (ShadowValue) * (n_shadows - 1));
|
||||
retval->n_shadows = n_shadows;
|
||||
retval->is_filter = is_filter;
|
||||
|
||||
memcpy (retval->shadows, shadows, sizeof (ShadowValue) * n_shadows);
|
||||
|
||||
@@ -327,6 +330,21 @@ gtk_css_shadow_value_new (ShadowValue *shadows,
|
||||
return retval;
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
gtk_css_shadow_value_new_filter (void)
|
||||
{
|
||||
ShadowValue value;
|
||||
|
||||
value.inset = FALSE;
|
||||
value.hoffset = _gtk_css_number_value_new (0, GTK_CSS_NUMBER);
|
||||
value.voffset = _gtk_css_number_value_new (0, GTK_CSS_NUMBER);
|
||||
value.radius = _gtk_css_number_value_new (0, GTK_CSS_NUMBER);
|
||||
value.spread = _gtk_css_number_value_new (0, GTK_CSS_NUMBER);
|
||||
value.color = _gtk_css_color_value_new_current_color ();
|
||||
|
||||
return gtk_css_shadow_value_new (&value, 1, TRUE);
|
||||
}
|
||||
|
||||
enum {
|
||||
HOFFSET,
|
||||
VOFFSET,
|
||||
@@ -417,9 +435,9 @@ parse_color (GtkCssParser *parser,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_gtk_css_shadow_value_parse_one (GtkCssParser *parser,
|
||||
gboolean box_shadow_mode,
|
||||
ShadowValue *result)
|
||||
gtk_css_shadow_value_parse_one (GtkCssParser *parser,
|
||||
gboolean box_shadow_mode,
|
||||
ShadowValue *result)
|
||||
{
|
||||
GtkCssValue *values[N_VALUES] = { NULL, };
|
||||
GtkCssValue *color = NULL;
|
||||
@@ -465,8 +483,8 @@ fail:
|
||||
|
||||
#define MAX_SHADOWS 64
|
||||
GtkCssValue *
|
||||
_gtk_css_shadow_value_parse (GtkCssParser *parser,
|
||||
gboolean box_shadow_mode)
|
||||
gtk_css_shadow_value_parse (GtkCssParser *parser,
|
||||
gboolean box_shadow_mode)
|
||||
{
|
||||
ShadowValue shadows[MAX_SHADOWS];
|
||||
int n_shadows = 0;
|
||||
@@ -476,7 +494,7 @@ _gtk_css_shadow_value_parse (GtkCssParser *parser,
|
||||
return gtk_css_shadow_value_new_none ();
|
||||
|
||||
do {
|
||||
if (_gtk_css_shadow_value_parse_one (parser, box_shadow_mode, &shadows[n_shadows]))
|
||||
if (gtk_css_shadow_value_parse_one (parser, box_shadow_mode, &shadows[n_shadows]))
|
||||
n_shadows++;
|
||||
|
||||
if (n_shadows > MAX_SHADOWS)
|
||||
@@ -486,7 +504,7 @@ _gtk_css_shadow_value_parse (GtkCssParser *parser,
|
||||
}
|
||||
} while (gtk_css_parser_try_token (parser, GTK_CSS_TOKEN_COMMA));
|
||||
|
||||
return gtk_css_shadow_value_new (shadows, n_shadows);
|
||||
return gtk_css_shadow_value_new (shadows, n_shadows, FALSE);
|
||||
|
||||
fail:
|
||||
for (i = 0; i < n_shadows; i++)
|
||||
@@ -498,6 +516,17 @@ fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
gtk_css_shadow_value_parse_filter (GtkCssParser *parser)
|
||||
{
|
||||
ShadowValue shadow;
|
||||
|
||||
if (gtk_css_shadow_value_parse_one (parser, FALSE, &shadow))
|
||||
return gtk_css_shadow_value_new (&shadow, 1, TRUE);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_shadow_value_get_extents (const GtkCssValue *value,
|
||||
GtkBorder *border)
|
||||
@@ -513,6 +542,8 @@ gtk_css_shadow_value_get_extents (const GtkCssValue *value,
|
||||
|
||||
spread = _gtk_css_number_value_get (shadow->spread, 0);
|
||||
radius = _gtk_css_number_value_get (shadow->radius, 0);
|
||||
if (value->is_filter)
|
||||
radius = radius * 2;
|
||||
clip_radius = gsk_cairo_blur_compute_pixels (radius);
|
||||
hoffset = _gtk_css_number_value_get (shadow->hoffset, 0);
|
||||
voffset = _gtk_css_number_value_get (shadow->voffset, 0);
|
||||
@@ -530,6 +561,8 @@ gtk_css_shadow_value_snapshot_outset (const GtkCssValue *value,
|
||||
const GskRoundedRect *border_box)
|
||||
{
|
||||
guint i;
|
||||
double dx, dy, spread, radius;
|
||||
const GdkRGBA *color;
|
||||
|
||||
g_return_if_fail (value->class == >K_CSS_VALUE_SHADOW);
|
||||
|
||||
@@ -540,17 +573,20 @@ gtk_css_shadow_value_snapshot_outset (const GtkCssValue *value,
|
||||
if (shadow->inset)
|
||||
continue;
|
||||
|
||||
color = gtk_css_color_value_get_rgba (shadow->color);
|
||||
|
||||
/* We don't need to draw invisible shadows */
|
||||
if (gdk_rgba_is_clear (gtk_css_color_value_get_rgba (shadow->color)))
|
||||
if (gdk_rgba_is_clear (color))
|
||||
continue;
|
||||
|
||||
gtk_snapshot_append_outset_shadow (snapshot,
|
||||
border_box,
|
||||
gtk_css_color_value_get_rgba (shadow->color),
|
||||
_gtk_css_number_value_get (shadow->hoffset, 0),
|
||||
_gtk_css_number_value_get (shadow->voffset, 0),
|
||||
_gtk_css_number_value_get (shadow->spread, 0),
|
||||
_gtk_css_number_value_get (shadow->radius, 0));
|
||||
dx = _gtk_css_number_value_get (shadow->hoffset, 0);
|
||||
dy = _gtk_css_number_value_get (shadow->voffset, 0);
|
||||
spread = _gtk_css_number_value_get (shadow->spread, 0);
|
||||
radius = _gtk_css_number_value_get (shadow->radius, 0);
|
||||
if (value->is_filter)
|
||||
radius = 2 * radius;
|
||||
|
||||
gtk_snapshot_append_outset_shadow (snapshot, border_box, color, dx, dy, spread, radius);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -572,15 +608,18 @@ gtk_css_shadow_value_snapshot_inset (const GtkCssValue *value,
|
||||
if (!shadow->inset)
|
||||
continue;
|
||||
|
||||
color = gtk_css_color_value_get_rgba (shadow->color);
|
||||
|
||||
/* We don't need to draw invisible shadows */
|
||||
if (gdk_rgba_is_clear (gtk_css_color_value_get_rgba (shadow->color)))
|
||||
if (gdk_rgba_is_clear (color))
|
||||
continue;
|
||||
|
||||
dx = _gtk_css_number_value_get (shadow->hoffset, 0);
|
||||
dy = _gtk_css_number_value_get (shadow->voffset, 0);
|
||||
spread = _gtk_css_number_value_get (shadow->spread, 0);
|
||||
radius = _gtk_css_number_value_get (shadow->radius, 0);
|
||||
color = gtk_css_color_value_get_rgba (shadow->color);
|
||||
if (value->is_filter)
|
||||
radius = 2 * radius;
|
||||
|
||||
/* These are trivial to do with a color node */
|
||||
if (spread == 0 && radius == 0 &&
|
||||
@@ -676,7 +715,6 @@ gtk_css_shadow_value_push_snapshot (const GtkCssValue *value,
|
||||
gboolean need_shadow = FALSE;
|
||||
guint i;
|
||||
|
||||
/* TODO: We can save this as a flag once and then reuse it */
|
||||
for (i = 0; i < value->n_shadows; i++)
|
||||
{
|
||||
const ShadowValue *shadow = &value->shadows[i];
|
||||
@@ -700,6 +738,8 @@ gtk_css_shadow_value_push_snapshot (const GtkCssValue *value,
|
||||
shadows[i].dy = _gtk_css_number_value_get (shadow->voffset, 0);
|
||||
shadows[i].color = *gtk_css_color_value_get_rgba (shadow->color);
|
||||
shadows[i].radius = _gtk_css_number_value_get (shadow->radius, 0);
|
||||
if (value->is_filter)
|
||||
shadows[i].radius *= 2;
|
||||
}
|
||||
|
||||
gtk_snapshot_push_shadow (snapshot, shadows, value->n_shadows);
|
||||
@@ -707,3 +747,25 @@ gtk_css_shadow_value_push_snapshot (const GtkCssValue *value,
|
||||
|
||||
return need_shadow;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_shadow_value_pop_snapshot (const GtkCssValue *value,
|
||||
GtkSnapshot *snapshot)
|
||||
{
|
||||
gboolean need_shadow = FALSE;
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < value->n_shadows; i++)
|
||||
{
|
||||
const ShadowValue *shadow = &value->shadows[i];
|
||||
|
||||
if (!gdk_rgba_is_clear (gtk_css_color_value_get_rgba (shadow->color)))
|
||||
{
|
||||
need_shadow = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (need_shadow)
|
||||
gtk_snapshot_pop (snapshot);
|
||||
}
|
||||
|
||||
@@ -34,10 +34,12 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GtkCssValue * gtk_css_shadow_value_new_none (void);
|
||||
GtkCssValue * gtk_css_shadow_value_new_none (void);
|
||||
GtkCssValue * gtk_css_shadow_value_new_filter (void);
|
||||
|
||||
GtkCssValue * _gtk_css_shadow_value_parse (GtkCssParser *parser,
|
||||
GtkCssValue * gtk_css_shadow_value_parse (GtkCssParser *parser,
|
||||
gboolean box_shadow_mode);
|
||||
GtkCssValue * gtk_css_shadow_value_parse_filter (GtkCssParser *parser);
|
||||
|
||||
void gtk_css_shadow_value_get_extents (const GtkCssValue *shadow,
|
||||
GtkBorder *border);
|
||||
@@ -53,6 +55,8 @@ gboolean gtk_css_shadow_value_is_none (const GtkCssValue
|
||||
|
||||
gboolean gtk_css_shadow_value_push_snapshot (const GtkCssValue *value,
|
||||
GtkSnapshot *snapshot);
|
||||
void gtk_css_shadow_value_pop_snapshot (const GtkCssValue *value,
|
||||
GtkSnapshot *snapshot);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -865,16 +865,26 @@ parse_text_decoration (GtkCssShorthandProperty *shorthand,
|
||||
GtkCssValue **values,
|
||||
GtkCssParser *parser)
|
||||
{
|
||||
GtkTextDecorationLine line = 0;
|
||||
|
||||
do
|
||||
{
|
||||
if (values[0] == NULL &&
|
||||
(values[0] = _gtk_css_text_decoration_line_value_try_parse (parser)))
|
||||
GtkTextDecorationLine parsed_line;
|
||||
|
||||
parsed_line = _gtk_css_text_decoration_line_try_parse_one (parser, line);
|
||||
|
||||
if (parsed_line == 0 && line != 0)
|
||||
{
|
||||
if (values[0] == NULL)
|
||||
return FALSE;
|
||||
gtk_css_parser_error_value (parser, "Invalid combination of text-decoration-line values");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (parsed_line != line)
|
||||
{
|
||||
line = parsed_line;
|
||||
}
|
||||
else if (values[1] == NULL &&
|
||||
(values[1] = _gtk_css_text_decoration_style_value_try_parse (parser)))
|
||||
(values[1] = _gtk_css_text_decoration_style_value_try_parse (parser)))
|
||||
{
|
||||
if (values[1] == NULL)
|
||||
return FALSE;
|
||||
@@ -895,6 +905,16 @@ parse_text_decoration (GtkCssShorthandProperty *shorthand,
|
||||
}
|
||||
while (!value_is_done_parsing (parser));
|
||||
|
||||
if (line != 0)
|
||||
{
|
||||
values[0] = _gtk_css_text_decoration_line_value_new (line);
|
||||
if (values[0] == NULL)
|
||||
{
|
||||
gtk_css_parser_error_value (parser, "Invalid combination of text-decoration-line values");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -163,6 +163,7 @@ static const int other_props[] = {
|
||||
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,
|
||||
};
|
||||
@@ -593,6 +594,9 @@ gtk_css_static_style_set_value (GtkCssStaticStyle *sstyle,
|
||||
case GTK_CSS_PROPERTY_TRANSFORM:
|
||||
gtk_css_take_value (&style->other->transform, value);
|
||||
break;
|
||||
case GTK_CSS_PROPERTY_TRANSFORM_ORIGIN:
|
||||
gtk_css_take_value (&style->other->transform_origin, value);
|
||||
break;
|
||||
case GTK_CSS_PROPERTY_MIN_WIDTH:
|
||||
gtk_css_take_value (&style->size->min_width, value);
|
||||
break;
|
||||
@@ -880,6 +884,7 @@ gtk_css_other_create_initial_values (void)
|
||||
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);
|
||||
|
||||
|
||||
+20
-8
@@ -235,6 +235,8 @@ gtk_css_style_get_value (GtkCssStyle *style,
|
||||
return style->size->border_spacing;
|
||||
case GTK_CSS_PROPERTY_TRANSFORM:
|
||||
return style->other->transform;
|
||||
case GTK_CSS_PROPERTY_TRANSFORM_ORIGIN:
|
||||
return style->other->transform_origin;
|
||||
case GTK_CSS_PROPERTY_MIN_WIDTH:
|
||||
return style->size->min_width;
|
||||
case GTK_CSS_PROPERTY_MIN_HEIGHT:
|
||||
@@ -395,6 +397,12 @@ get_pango_underline_from_style (GtkTextDecorationStyle style)
|
||||
g_return_val_if_reached (PANGO_UNDERLINE_SINGLE);
|
||||
}
|
||||
|
||||
static PangoOverline
|
||||
get_pango_overline_from_style (GtkTextDecorationStyle style)
|
||||
{
|
||||
return PANGO_OVERLINE_SINGLE;
|
||||
}
|
||||
|
||||
static PangoAttrList *
|
||||
add_pango_attr (PangoAttrList *attrs,
|
||||
PangoAttribute *attr)
|
||||
@@ -443,25 +451,29 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
|
||||
? style->font_variant->text_decoration_color
|
||||
: style->core->color);
|
||||
|
||||
switch (decoration_line)
|
||||
if (decoration_line & GTK_CSS_TEXT_DECORATION_LINE_UNDERLINE)
|
||||
{
|
||||
case GTK_CSS_TEXT_DECORATION_LINE_UNDERLINE:
|
||||
attrs = add_pango_attr (attrs, pango_attr_underline_new (get_pango_underline_from_style (decoration_style)));
|
||||
if (!gdk_rgba_equal (color, decoration_color))
|
||||
attrs = add_pango_attr (attrs, pango_attr_underline_color_new (decoration_color->red * 65535. + 0.5,
|
||||
decoration_color->green * 65535. + 0.5,
|
||||
decoration_color->blue * 65535. + 0.5));
|
||||
break;
|
||||
case GTK_CSS_TEXT_DECORATION_LINE_LINE_THROUGH:
|
||||
}
|
||||
if (decoration_line & GTK_CSS_TEXT_DECORATION_LINE_OVERLINE)
|
||||
{
|
||||
attrs = add_pango_attr (attrs, pango_attr_overline_new (get_pango_overline_from_style (decoration_style)));
|
||||
if (!gdk_rgba_equal (color, decoration_color))
|
||||
attrs = add_pango_attr (attrs, pango_attr_overline_color_new (decoration_color->red * 65535. + 0.5,
|
||||
decoration_color->green * 65535. + 0.5,
|
||||
decoration_color->blue * 65535. + 0.5));
|
||||
}
|
||||
if (decoration_line & GTK_CSS_TEXT_DECORATION_LINE_LINE_THROUGH)
|
||||
{
|
||||
attrs = add_pango_attr (attrs, pango_attr_strikethrough_new (TRUE));
|
||||
if (!gdk_rgba_equal (color, decoration_color))
|
||||
attrs = add_pango_attr (attrs, pango_attr_strikethrough_color_new (decoration_color->red * 65535. + 0.5,
|
||||
decoration_color->green * 65535. + 0.5,
|
||||
decoration_color->blue * 65535. + 0.5));
|
||||
break;
|
||||
case GTK_CSS_TEXT_DECORATION_LINE_NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* letter-spacing */
|
||||
|
||||
@@ -208,6 +208,7 @@ struct _GtkCssOtherValues {
|
||||
GtkCssValue *icon_transform;
|
||||
GtkCssValue *icon_filter;
|
||||
GtkCssValue *transform;
|
||||
GtkCssValue *transform_origin;
|
||||
GtkCssValue *opacity;
|
||||
GtkCssValue *filter;
|
||||
};
|
||||
|
||||
@@ -317,14 +317,38 @@ parse_letter_spacing (GtkCssStyleProperty *property,
|
||||
return _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_LENGTH);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
value_is_done_parsing (GtkCssParser *parser)
|
||||
{
|
||||
return gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_EOF) ||
|
||||
gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_COMMA) ||
|
||||
gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_SEMICOLON) ||
|
||||
gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_CLOSE_CURLY);
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
parse_text_decoration_line (GtkCssStyleProperty *property,
|
||||
GtkCssParser *parser)
|
||||
{
|
||||
GtkCssValue *value = _gtk_css_text_decoration_line_value_try_parse (parser);
|
||||
GtkCssValue *value = NULL;
|
||||
GtkTextDecorationLine line;
|
||||
|
||||
line = 0;
|
||||
do {
|
||||
GtkTextDecorationLine parsed;
|
||||
|
||||
parsed = _gtk_css_text_decoration_line_try_parse_one (parser, line);
|
||||
if (parsed == 0 || parsed == line)
|
||||
{
|
||||
gtk_css_parser_error_syntax (parser, "Not a valid value");
|
||||
return NULL;
|
||||
}
|
||||
line = parsed;
|
||||
} while (!value_is_done_parsing (parser));
|
||||
|
||||
value = _gtk_css_text_decoration_line_value_new (line);
|
||||
if (value == NULL)
|
||||
gtk_css_parser_error_syntax (parser, "unknown text decoration line value");
|
||||
gtk_css_parser_error_syntax (parser, "Invalid combination of values");
|
||||
|
||||
return value;
|
||||
}
|
||||
@@ -353,15 +377,6 @@ parse_font_kerning (GtkCssStyleProperty *property,
|
||||
return value;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
value_is_done_parsing (GtkCssParser *parser)
|
||||
{
|
||||
return gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_EOF) ||
|
||||
gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_COMMA) ||
|
||||
gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_SEMICOLON) ||
|
||||
gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_CLOSE_CURLY);
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
parse_font_variant_ligatures (GtkCssStyleProperty *property,
|
||||
GtkCssParser *parser)
|
||||
@@ -497,14 +512,14 @@ static GtkCssValue *
|
||||
box_shadow_value_parse (GtkCssStyleProperty *property,
|
||||
GtkCssParser *parser)
|
||||
{
|
||||
return _gtk_css_shadow_value_parse (parser, TRUE);
|
||||
return gtk_css_shadow_value_parse (parser, TRUE);
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
shadow_value_parse (GtkCssStyleProperty *property,
|
||||
GtkCssParser *parser)
|
||||
{
|
||||
return _gtk_css_shadow_value_parse (parser, FALSE);
|
||||
return gtk_css_shadow_value_parse (parser, FALSE);
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
@@ -790,6 +805,13 @@ background_position_parse (GtkCssStyleProperty *property,
|
||||
return _gtk_css_array_value_parse (parser, _gtk_css_position_value_parse);
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
transform_origin_parse (GtkCssStyleProperty *property,
|
||||
GtkCssParser *parser)
|
||||
{
|
||||
return _gtk_css_position_value_parse (parser);
|
||||
}
|
||||
|
||||
/*** REGISTRATION ***/
|
||||
|
||||
G_STATIC_ASSERT (GTK_CSS_PROPERTY_COLOR == 0);
|
||||
@@ -1248,6 +1270,13 @@ _gtk_css_style_property_init_properties (void)
|
||||
GTK_CSS_AFFECTS_TRANSFORM,
|
||||
transform_value_parse,
|
||||
_gtk_css_transform_value_new_none ());
|
||||
gtk_css_style_property_register ("transform-origin",
|
||||
GTK_CSS_PROPERTY_TRANSFORM_ORIGIN,
|
||||
GTK_STYLE_PROPERTY_ANIMATED,
|
||||
GTK_CSS_AFFECTS_TRANSFORM,
|
||||
transform_origin_parse,
|
||||
_gtk_css_position_value_new (_gtk_css_number_value_new (50, GTK_CSS_PERCENT),
|
||||
_gtk_css_number_value_new (50, GTK_CSS_PERCENT)));
|
||||
gtk_css_style_property_register ("min-width",
|
||||
GTK_CSS_PROPERTY_MIN_WIDTH,
|
||||
GTK_STYLE_PROPERTY_ANIMATED,
|
||||
|
||||
@@ -254,6 +254,7 @@ enum { /*< skip >*/
|
||||
GTK_CSS_PROPERTY_ICON_FILTER,
|
||||
GTK_CSS_PROPERTY_BORDER_SPACING,
|
||||
GTK_CSS_PROPERTY_TRANSFORM,
|
||||
GTK_CSS_PROPERTY_TRANSFORM_ORIGIN,
|
||||
GTK_CSS_PROPERTY_MIN_WIDTH,
|
||||
GTK_CSS_PROPERTY_MIN_HEIGHT,
|
||||
GTK_CSS_PROPERTY_TRANSITION_PROPERTY,
|
||||
@@ -324,9 +325,10 @@ typedef enum /*< skip >*/ {
|
||||
} GtkCssFontSize;
|
||||
|
||||
typedef enum /*< skip >*/ {
|
||||
GTK_CSS_TEXT_DECORATION_LINE_NONE,
|
||||
GTK_CSS_TEXT_DECORATION_LINE_UNDERLINE,
|
||||
GTK_CSS_TEXT_DECORATION_LINE_LINE_THROUGH
|
||||
GTK_CSS_TEXT_DECORATION_LINE_NONE = 1 << 0,
|
||||
GTK_CSS_TEXT_DECORATION_LINE_UNDERLINE = 1 << 1,
|
||||
GTK_CSS_TEXT_DECORATION_LINE_OVERLINE = 1 << 2,
|
||||
GTK_CSS_TEXT_DECORATION_LINE_LINE_THROUGH = 1 << 3
|
||||
} GtkTextDecorationLine;
|
||||
|
||||
typedef enum /*< skip >*/ {
|
||||
|
||||
+2
-2
@@ -260,8 +260,8 @@ _gtk_css_value_transition (GtkCssValue *start,
|
||||
guint property_id,
|
||||
double progress)
|
||||
{
|
||||
gtk_internal_return_val_if_fail (start != NULL, FALSE);
|
||||
gtk_internal_return_val_if_fail (end != NULL, FALSE);
|
||||
gtk_internal_return_val_if_fail (start != NULL, NULL);
|
||||
gtk_internal_return_val_if_fail (end != NULL, NULL);
|
||||
|
||||
if (start->class != end->class)
|
||||
return NULL;
|
||||
|
||||
+19
-2
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkdragsource.h"
|
||||
#include "gtkdragsourceprivate.h"
|
||||
|
||||
#include "gtkgesturedrag.h"
|
||||
#include "gtkgesturesingleprivate.h"
|
||||
@@ -292,7 +292,7 @@ gtk_drag_source_update (GtkGesture *gesture,
|
||||
|
||||
widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture));
|
||||
|
||||
if (gtk_drag_check_threshold (widget, source->start_x, source->start_y, x, y))
|
||||
if (gtk_drag_check_threshold_double (widget, source->start_x, source->start_y, x, y))
|
||||
{
|
||||
gtk_drag_source_drag_begin (source);
|
||||
}
|
||||
@@ -796,3 +796,20 @@ gtk_drag_check_threshold (GtkWidget *widget,
|
||||
return (ABS (current_x - start_x) > drag_threshold ||
|
||||
ABS (current_y - start_y) > drag_threshold);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_drag_check_threshold_double (GtkWidget *widget,
|
||||
double start_x,
|
||||
double start_y,
|
||||
double current_x,
|
||||
double current_y)
|
||||
{
|
||||
int drag_threshold;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
|
||||
|
||||
drag_threshold = gtk_settings_get_dnd_drag_threshold (gtk_widget_get_settings (widget));
|
||||
|
||||
return (ABS (current_x - start_x) > drag_threshold ||
|
||||
ABS (current_y - start_y) > drag_threshold);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2020 Alexander Mikhaylenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_DRAG_SOURCE_PRIVATE_H__
|
||||
#define __GTK_DRAG_SOURCE_PRIVATE_H__
|
||||
|
||||
#include "gtkdragsource.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
gboolean gtk_drag_check_threshold_double (GtkWidget *widget,
|
||||
double start_x,
|
||||
double start_y,
|
||||
double current_x,
|
||||
double current_y);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_DRAG_SOURCE_PRIVATE_H__ */
|
||||
+22
-3
@@ -1081,16 +1081,35 @@ keynav_failed (GtkWidget *box,
|
||||
GtkEmojiChooser *chooser)
|
||||
{
|
||||
EmojiSection *next;
|
||||
GtkWidget *focus;
|
||||
GtkWidget *focus;
|
||||
GtkWidget *child;
|
||||
GtkWidget *sibling;
|
||||
int i;
|
||||
int column;
|
||||
int n_columns = 7;
|
||||
int child_x;
|
||||
|
||||
focus = gtk_root_get_focus (gtk_widget_get_root (box));
|
||||
if (focus == NULL)
|
||||
return FALSE;
|
||||
|
||||
/* determine the number of columns */
|
||||
child_x = -1;
|
||||
for (i = 0; i < 20; i++)
|
||||
{
|
||||
GtkAllocation alloc;
|
||||
|
||||
gtk_widget_get_allocation (GTK_WIDGET (gtk_flow_box_get_child_at_index (GTK_FLOW_BOX (box), i)),
|
||||
&alloc);
|
||||
if (alloc.x > child_x)
|
||||
child_x = alloc.x;
|
||||
else
|
||||
{
|
||||
n_columns = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
child = gtk_widget_get_ancestor (focus, GTK_TYPE_EMOJI_CHOOSER_CHILD);
|
||||
|
||||
i = 0;
|
||||
@@ -1099,7 +1118,7 @@ keynav_failed (GtkWidget *box,
|
||||
sibling = gtk_widget_get_next_sibling (sibling))
|
||||
i++;
|
||||
|
||||
column = i % 7;
|
||||
column = i % n_columns;
|
||||
|
||||
if (direction == GTK_DIR_DOWN)
|
||||
{
|
||||
@@ -1131,7 +1150,7 @@ keynav_failed (GtkWidget *box,
|
||||
sibling;
|
||||
sibling = gtk_widget_get_next_sibling (sibling), i++)
|
||||
{
|
||||
if ((i % 7) == column)
|
||||
if ((i % n_columns) == column)
|
||||
child = sibling;
|
||||
}
|
||||
if (child)
|
||||
|
||||
+7
-7
@@ -54,7 +54,6 @@
|
||||
#include "gtkprogressbar.h"
|
||||
#include "gtksettings.h"
|
||||
#include "gtksnapshot.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtktextprivate.h"
|
||||
#include "gtktexthandleprivate.h"
|
||||
#include "gtktextutil.h"
|
||||
@@ -66,7 +65,7 @@
|
||||
#include "gtkwindow.h"
|
||||
#include "gtknative.h"
|
||||
#include "gtkgestureclick.h"
|
||||
#include "gtkdragsource.h"
|
||||
#include "gtkdragsourceprivate.h"
|
||||
#include "gtkdragicon.h"
|
||||
#include "gtkwidgetpaintable.h"
|
||||
|
||||
@@ -1587,32 +1586,33 @@ icon_released_cb (GtkGestureClick *gesture,
|
||||
|
||||
static void
|
||||
icon_drag_update_cb (GtkGestureDrag *gesture,
|
||||
double x,
|
||||
double y,
|
||||
double offset_x,
|
||||
double offset_y,
|
||||
GtkEntry *entry)
|
||||
{
|
||||
GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry);
|
||||
double start_x, start_y;
|
||||
GtkEntryIconPosition pos;
|
||||
EntryIconInfo *icon_info;
|
||||
|
||||
gtk_gesture_drag_get_start_point (gesture, &start_x, &start_y);
|
||||
pos = get_icon_position_from_controller (entry, GTK_EVENT_CONTROLLER (gesture));
|
||||
icon_info = priv->icons[pos];
|
||||
|
||||
if (icon_info->content != NULL &&
|
||||
gtk_drag_check_threshold (icon_info->widget, start_x, start_y, x, y))
|
||||
gtk_drag_check_threshold_double (icon_info->widget, 0, 0, offset_x, offset_y))
|
||||
{
|
||||
GdkPaintable *paintable;
|
||||
GdkSurface *surface;
|
||||
GdkDevice *device;
|
||||
GdkDrag *drag;
|
||||
double start_x, start_y;
|
||||
|
||||
icon_info->in_drag = TRUE;
|
||||
|
||||
surface = gtk_native_get_surface (gtk_widget_get_native (GTK_WIDGET (entry)));
|
||||
device = gtk_gesture_get_device (GTK_GESTURE (gesture));
|
||||
|
||||
gtk_gesture_drag_get_start_point (gesture, &start_x, &start_y);
|
||||
|
||||
drag = gdk_drag_begin (surface, device, icon_info->content, icon_info->actions, start_x, start_y);
|
||||
paintable = gtk_widget_paintable_new (icon_info->widget);
|
||||
gtk_drag_icon_set_from_paintable (drag, paintable, -2, -2);
|
||||
|
||||
@@ -127,7 +127,6 @@
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkmain.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -66,7 +66,6 @@
|
||||
#include "gtkshow.h"
|
||||
#include "gtkmain.h"
|
||||
#include "gtkscrollable.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtkpopover.h"
|
||||
#include "gtkrevealer.h"
|
||||
#include "gtkspinner.h"
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
#include "gtkscrolledwindow.h"
|
||||
#include "gtksearchentry.h"
|
||||
#include "gtkspinbutton.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtktextview.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtksettings.h"
|
||||
|
||||
@@ -31,8 +31,6 @@
|
||||
#include "gtkintl.h"
|
||||
#include "gtkbuildable.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtkcssstylepropertyprivate.h"
|
||||
#include "gtklabel.h"
|
||||
|
||||
/**
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#include "gtkgesturelongpressprivate.h"
|
||||
#include "gtkgestureprivate.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkdragsource.h"
|
||||
#include "gtkdragsourceprivate.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkmarshalers.h"
|
||||
@@ -159,7 +159,7 @@ gtk_gesture_long_press_update (GtkGesture *gesture,
|
||||
priv = gtk_gesture_long_press_get_instance_private (GTK_GESTURE_LONG_PRESS (gesture));
|
||||
gtk_gesture_get_point (gesture, sequence, &x, &y);
|
||||
|
||||
if (gtk_drag_check_threshold (widget, priv->initial_x, priv->initial_y, x, y))
|
||||
if (gtk_drag_check_threshold_double (widget, priv->initial_x, priv->initial_y, x, y))
|
||||
{
|
||||
if (priv->timeout_id)
|
||||
{
|
||||
|
||||
+60
-1
@@ -29,7 +29,7 @@
|
||||
#include "gtkorientable.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtksizerequest.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtkcssnodeprivate.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
|
||||
|
||||
@@ -48,6 +48,65 @@
|
||||
* from the grid, use gtk_grid_remove(). The behaviour of GtkGrid when
|
||||
* several children occupy the same grid cell is undefined.
|
||||
*
|
||||
* # GtkGrid as GtkBuildable
|
||||
*
|
||||
* Every child in a GtkGrid has access to a custom #GtkBuildable element, called ´<layout>´.
|
||||
* It can by used to specify a position in the grid and optionally spans.
|
||||
* All properties that can be used in the ´<layout>´ element are implemented by #GtkGridLayoutChild.
|
||||
*
|
||||
* It is implemented by #GtkWidget using #GtkLayoutManager.
|
||||
*
|
||||
* To showcase it, here is a simple example:
|
||||
*
|
||||
* |[
|
||||
* <object class="GtkGrid" id="my_grid">
|
||||
* <child>
|
||||
* <object class="GtkButton" id="button1">
|
||||
* <property name="label">Button 1</property>
|
||||
* <layout>
|
||||
* <property name="column">0</property>
|
||||
* <property name="row">0</property>
|
||||
* </layout>
|
||||
* </object>
|
||||
* </child>
|
||||
* <child>
|
||||
* <object class="GtkButton" id="button2">
|
||||
* <property name="label">Button 2</property>
|
||||
* <layout>
|
||||
* <property name="column">1</property>
|
||||
* <property name="row">0</property>
|
||||
* </layout>
|
||||
* </object>
|
||||
* </child>
|
||||
* <child>
|
||||
* <object class="GtkButton" id="button3">
|
||||
* <property name="label">Button 3</property>
|
||||
* <layout>
|
||||
* <property name="column">2</property>
|
||||
* <property name="row">0</property>
|
||||
* <property name="row-span">2</property>
|
||||
* </layout>
|
||||
* </object>
|
||||
* </child>
|
||||
* <child>
|
||||
* <object class="GtkButton" id="button4">
|
||||
* <property name="label">Button 4</property>
|
||||
* <layout>
|
||||
* <property name="column">0</property>
|
||||
* <property name="row">1</property>
|
||||
* <property name="column-span">2</property>
|
||||
* </layout>
|
||||
* </object>
|
||||
* </child>
|
||||
* </object>
|
||||
* ]|
|
||||
*
|
||||
* It organizes the first two buttons side-by-side in one cell each.
|
||||
* The third button is in the last column but spans across two rows.
|
||||
* This is defined by the ´row-span´ property.
|
||||
* The last button is located in the second row and spans across two columns,
|
||||
* which is defined by the ´column-span´ property.
|
||||
*
|
||||
* # CSS nodes
|
||||
*
|
||||
* GtkGrid uses a single CSS node with name `grid`.
|
||||
|
||||
+1
-1
@@ -51,8 +51,8 @@
|
||||
#include "gtkorientable.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtksizerequest.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkcssnodeprivate.h"
|
||||
|
||||
/* {{{ GtkGridLayoutChild */
|
||||
typedef struct {
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include "gtkcssenumvalueprivate.h"
|
||||
#include "gtkcssnumbervalueprivate.h"
|
||||
#include "gtkcssstyleprivate.h"
|
||||
#include "gtkcssstylepropertyprivate.h"
|
||||
#include "gtkcsstransientnodeprivate.h"
|
||||
#include "gtkiconthemeprivate.h"
|
||||
#include "gtkrendericonprivate.h"
|
||||
|
||||
+5
-5
@@ -26,7 +26,7 @@
|
||||
#include "gtkcellrenderer.h"
|
||||
#include "gtkcellrendererpixbuf.h"
|
||||
#include "gtkcellrenderertext.h"
|
||||
#include "gtkdragsource.h"
|
||||
#include "gtkdragsourceprivate.h"
|
||||
#include "gtkentry.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkmain.h"
|
||||
@@ -5884,10 +5884,10 @@ gtk_icon_view_maybe_begin_drag (GtkIconView *icon_view,
|
||||
if (icon_view->priv->pressed_button < 0)
|
||||
goto out;
|
||||
|
||||
if (!gtk_drag_check_threshold (GTK_WIDGET (icon_view),
|
||||
icon_view->priv->press_start_x,
|
||||
icon_view->priv->press_start_y,
|
||||
x, y))
|
||||
if (!gtk_drag_check_threshold_double (GTK_WIDGET (icon_view),
|
||||
icon_view->priv->press_start_x,
|
||||
icon_view->priv->press_start_y,
|
||||
x, y))
|
||||
goto out;
|
||||
|
||||
model = gtk_icon_view_get_model (icon_view);
|
||||
|
||||
@@ -133,8 +133,8 @@ struct _GtkIconViewPrivate
|
||||
/* Drag-and-drop. */
|
||||
GdkModifierType start_button_mask;
|
||||
int pressed_button;
|
||||
int press_start_x;
|
||||
int press_start_y;
|
||||
double press_start_x;
|
||||
double press_start_y;
|
||||
|
||||
GdkContentFormats *source_formats;
|
||||
GtkDropTargetAsync *dest;
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
|
||||
#include "gtkimageprivate.h"
|
||||
|
||||
#include "gtkcssstylepropertyprivate.h"
|
||||
#include "gtkiconhelperprivate.h"
|
||||
#include "gtkicontheme.h"
|
||||
#include "gtkintl.h"
|
||||
|
||||
+176
-486
@@ -32,7 +32,6 @@
|
||||
#include "gtkcomposetable.h"
|
||||
#include "gtkimmoduleprivate.h"
|
||||
|
||||
#include "gtkimcontextsimpleprivate.h"
|
||||
#include "gtkimcontextsimpleseqs.h"
|
||||
#include "gdk/gdkprofilerprivate.h"
|
||||
|
||||
@@ -61,8 +60,9 @@
|
||||
|
||||
struct _GtkIMContextSimplePrivate
|
||||
{
|
||||
guint16 compose_buffer[GTK_MAX_COMPOSE_LEN + 1];
|
||||
gunichar tentative_match;
|
||||
guint16 *compose_buffer;
|
||||
int compose_buffer_len;
|
||||
GString *tentative_match;
|
||||
int tentative_match_len;
|
||||
|
||||
guint in_hex_sequence : 1;
|
||||
@@ -174,8 +174,7 @@ gtk_im_context_simple_init_compose_table (void)
|
||||
g_free (path);
|
||||
return;
|
||||
}
|
||||
g_free (path);
|
||||
path = NULL;
|
||||
g_clear_pointer (&path, g_free);
|
||||
|
||||
home = g_get_home_dir ();
|
||||
if (home == NULL)
|
||||
@@ -190,8 +189,7 @@ gtk_im_context_simple_init_compose_table (void)
|
||||
g_free (path);
|
||||
return;
|
||||
}
|
||||
g_free (path);
|
||||
path = NULL;
|
||||
g_clear_pointer (&path, g_free);
|
||||
|
||||
locale = g_getenv ("LC_CTYPE");
|
||||
if (locale == NULL)
|
||||
@@ -224,8 +222,7 @@ gtk_im_context_simple_init_compose_table (void)
|
||||
|
||||
if (g_file_test (path, G_FILE_TEST_EXISTS))
|
||||
break;
|
||||
g_free (path);
|
||||
path = NULL;
|
||||
g_clear_pointer (&path, g_free);
|
||||
}
|
||||
|
||||
g_free (x11_compose_file_dir);
|
||||
@@ -237,8 +234,7 @@ gtk_im_context_simple_init_compose_table (void)
|
||||
global_tables = gtk_compose_table_list_add_file (global_tables, path);
|
||||
G_UNLOCK (global_tables);
|
||||
}
|
||||
g_free (path);
|
||||
path = NULL;
|
||||
g_clear_pointer (&path, g_free);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -271,14 +267,27 @@ init_compose_table_async (GCancellable *cancellable,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_im_context_simple_init (GtkIMContextSimple *im_context_simple)
|
||||
gtk_im_context_simple_init (GtkIMContextSimple *context_simple)
|
||||
{
|
||||
im_context_simple->priv = gtk_im_context_simple_get_instance_private (im_context_simple);
|
||||
GtkIMContextSimplePrivate *priv;
|
||||
|
||||
priv = context_simple->priv = gtk_im_context_simple_get_instance_private (context_simple);
|
||||
|
||||
priv->compose_buffer_len = gtk_compose_table_compact.max_seq_len + 1;
|
||||
priv->compose_buffer = g_new0 (guint16, priv->compose_buffer_len);
|
||||
priv->tentative_match = g_string_new ("");
|
||||
priv->tentative_match_len = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_im_context_simple_finalize (GObject *obj)
|
||||
{
|
||||
GtkIMContextSimple *context_simple = GTK_IM_CONTEXT_SIMPLE (obj);
|
||||
GtkIMContextSimplePrivate *priv = context_simple->priv;;
|
||||
|
||||
g_free (priv->compose_buffer);
|
||||
g_string_free (priv->tentative_match, TRUE);
|
||||
|
||||
G_OBJECT_CLASS (gtk_im_context_simple_parent_class)->finalize (obj);
|
||||
}
|
||||
|
||||
@@ -296,396 +305,29 @@ gtk_im_context_simple_new (void)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_im_context_simple_commit_char (GtkIMContext *context,
|
||||
gunichar ch)
|
||||
{
|
||||
GtkIMContextSimple *context_simple = GTK_IM_CONTEXT_SIMPLE (context);
|
||||
GtkIMContextSimplePrivate *priv = context_simple->priv;
|
||||
char buf[10];
|
||||
int len;
|
||||
|
||||
g_return_if_fail (g_unichar_validate (ch));
|
||||
|
||||
len = g_unichar_to_utf8 (ch, buf);
|
||||
buf[len] = '\0';
|
||||
|
||||
if (priv->tentative_match || priv->in_hex_sequence)
|
||||
{
|
||||
priv->in_hex_sequence = FALSE;
|
||||
priv->tentative_match = 0;
|
||||
priv->tentative_match_len = 0;
|
||||
g_signal_emit_by_name (context_simple, "preedit-changed");
|
||||
g_signal_emit_by_name (context_simple, "preedit-end");
|
||||
}
|
||||
|
||||
g_signal_emit_by_name (context, "commit", &buf);
|
||||
}
|
||||
|
||||
static int
|
||||
compare_seq_index (const void *key, const void *value)
|
||||
{
|
||||
const guint16 *keysyms = key;
|
||||
const guint16 *seq = value;
|
||||
|
||||
if (keysyms[0] < seq[0])
|
||||
return -1;
|
||||
else if (keysyms[0] > seq[0])
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
compare_seq (const void *key, const void *value)
|
||||
{
|
||||
int i = 0;
|
||||
const guint16 *keysyms = key;
|
||||
const guint16 *seq = value;
|
||||
|
||||
while (keysyms[i])
|
||||
{
|
||||
if (keysyms[i] < seq[i])
|
||||
return -1;
|
||||
else if (keysyms[i] > seq[i])
|
||||
return 1;
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
check_table (GtkIMContextSimple *context_simple,
|
||||
const GtkComposeTable *table,
|
||||
int n_compose)
|
||||
gtk_im_context_simple_commit_string (GtkIMContextSimple *context_simple,
|
||||
const char *str)
|
||||
{
|
||||
GtkIMContextSimplePrivate *priv = context_simple->priv;
|
||||
int row_stride = table->max_seq_len + 2;
|
||||
guint16 *seq;
|
||||
|
||||
/* Will never match, if the sequence in the compose buffer is longer
|
||||
* than the sequences in the table. Further, compare_seq (key, val)
|
||||
* will overrun val if key is longer than val. */
|
||||
if (n_compose > table->max_seq_len)
|
||||
return FALSE;
|
||||
|
||||
seq = bsearch (priv->compose_buffer,
|
||||
table->data, table->n_seqs,
|
||||
sizeof (guint16) * row_stride,
|
||||
compare_seq);
|
||||
priv->in_hex_sequence = FALSE;
|
||||
g_string_set_size (priv->tentative_match, 0);
|
||||
priv->tentative_match_len = 0;
|
||||
priv->compose_buffer[0] = 0;
|
||||
|
||||
if (seq)
|
||||
{
|
||||
guint16 *prev_seq;
|
||||
|
||||
/* Back up to the first sequence that matches to make sure
|
||||
* we find the exact match if there is one.
|
||||
*/
|
||||
while (seq > table->data)
|
||||
{
|
||||
prev_seq = seq - row_stride;
|
||||
if (compare_seq (priv->compose_buffer, prev_seq) != 0)
|
||||
break;
|
||||
seq = prev_seq;
|
||||
}
|
||||
|
||||
if (n_compose == table->max_seq_len ||
|
||||
seq[n_compose] == 0) /* complete sequence */
|
||||
{
|
||||
guint16 *next_seq;
|
||||
gunichar value =
|
||||
0x10000 * seq[table->max_seq_len] + seq[table->max_seq_len + 1];
|
||||
|
||||
/* We found a tentative match. See if there are any longer
|
||||
* sequences containing this subsequence
|
||||
*/
|
||||
next_seq = seq + row_stride;
|
||||
if (next_seq < table->data + row_stride * table->n_seqs)
|
||||
{
|
||||
if (compare_seq (priv->compose_buffer, next_seq) == 0)
|
||||
{
|
||||
priv->tentative_match = value;
|
||||
priv->tentative_match_len = n_compose;
|
||||
|
||||
g_signal_emit_by_name (context_simple, "preedit-changed");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
gtk_im_context_simple_commit_char (GTK_IM_CONTEXT (context_simple), value);
|
||||
priv->compose_buffer[0] = 0;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
g_signal_emit_by_name (context_simple, "preedit-changed");
|
||||
g_signal_emit_by_name (context_simple, "preedit-end");
|
||||
g_signal_emit_by_name (context_simple, "commit", str);
|
||||
}
|
||||
|
||||
/* Checks if a keysym is a dead key. Dead key keysym values are defined in
|
||||
* ../gdk/gdkkeysyms.h and the first is GDK_KEY_dead_grave. As X.Org is updated,
|
||||
* more dead keys are added and we need to update the upper limit.
|
||||
* Currently, the upper limit is GDK_KEY_dead_dasia+1. The +1 has to do with
|
||||
* a temporary issue in the X.Org header files.
|
||||
* In future versions it will be just the keysym (no +1).
|
||||
*/
|
||||
#define IS_DEAD_KEY(k) \
|
||||
((k) >= GDK_KEY_dead_grave && (k) <= (GDK_KEY_dead_dasia+1))
|
||||
|
||||
gboolean
|
||||
gtk_check_compact_table (const GtkComposeTableCompact *table,
|
||||
guint16 *compose_buffer,
|
||||
int n_compose,
|
||||
gboolean *compose_finish,
|
||||
gboolean *compose_match,
|
||||
gunichar *output_char)
|
||||
static void
|
||||
gtk_im_context_simple_commit_char (GtkIMContextSimple *context_simple,
|
||||
gunichar ch)
|
||||
{
|
||||
int row_stride;
|
||||
guint16 *seq_index;
|
||||
guint16 *seq;
|
||||
int i;
|
||||
gboolean match;
|
||||
gunichar value;
|
||||
char buf[8] = { 0, };
|
||||
|
||||
if (compose_finish)
|
||||
*compose_finish = FALSE;
|
||||
if (compose_match)
|
||||
*compose_match = FALSE;
|
||||
if (output_char)
|
||||
*output_char = 0;
|
||||
g_unichar_to_utf8 (ch, buf);
|
||||
|
||||
/* Will never match, if the sequence in the compose buffer is longer
|
||||
* than the sequences in the table. Further, compare_seq (key, val)
|
||||
* will overrun val if key is longer than val.
|
||||
*/
|
||||
if (n_compose > table->max_seq_len)
|
||||
return FALSE;
|
||||
|
||||
seq_index = bsearch (compose_buffer,
|
||||
table->data,
|
||||
table->n_index_size,
|
||||
sizeof (guint16) * table->n_index_stride,
|
||||
compare_seq_index);
|
||||
|
||||
if (!seq_index)
|
||||
return FALSE;
|
||||
|
||||
if (seq_index && n_compose == 1)
|
||||
return TRUE;
|
||||
|
||||
seq = NULL;
|
||||
match = FALSE;
|
||||
value = 0;
|
||||
|
||||
for (i = n_compose - 1; i < table->max_seq_len; i++)
|
||||
{
|
||||
row_stride = i + 1;
|
||||
|
||||
if (seq_index[i + 1] - seq_index[i] > 0)
|
||||
{
|
||||
seq = bsearch (compose_buffer + 1,
|
||||
table->data + seq_index[i],
|
||||
(seq_index[i + 1] - seq_index[i]) / row_stride,
|
||||
sizeof (guint16) * row_stride,
|
||||
compare_seq);
|
||||
|
||||
if (seq)
|
||||
{
|
||||
if (i == n_compose - 1)
|
||||
{
|
||||
value = seq[row_stride - 1];
|
||||
match = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (output_char)
|
||||
*output_char = value;
|
||||
if (match)
|
||||
{
|
||||
if (compose_match)
|
||||
*compose_match = TRUE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (match)
|
||||
{
|
||||
if (compose_match)
|
||||
*compose_match = TRUE;
|
||||
if (compose_finish)
|
||||
*compose_finish = TRUE;
|
||||
if (output_char)
|
||||
*output_char = value;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* This function receives a sequence of Unicode characters and tries to
|
||||
* normalize it (NFC). We check for the case where the resulting string
|
||||
* has length 1 (single character).
|
||||
* NFC normalisation normally rearranges diacritic marks, unless these
|
||||
* belong to the same Canonical Combining Class.
|
||||
* If they belong to the same canonical combining class, we produce all
|
||||
* permutations of the diacritic marks, then attempt to normalize.
|
||||
*/
|
||||
static gboolean
|
||||
check_normalize_nfc (gunichar* combination_buffer, int n_compose)
|
||||
{
|
||||
gunichar combination_buffer_temp[GTK_MAX_COMPOSE_LEN];
|
||||
char *combination_utf8_temp = NULL;
|
||||
char *nfc_temp = NULL;
|
||||
int n_combinations;
|
||||
gunichar temp_swap;
|
||||
int i;
|
||||
|
||||
n_combinations = 1;
|
||||
|
||||
for (i = 1; i < n_compose; i++ )
|
||||
n_combinations *= i;
|
||||
|
||||
/* Xorg reuses dead_tilde for the perispomeni diacritic mark.
|
||||
* We check if base character belongs to Greek Unicode block,
|
||||
* and if so, we replace tilde with perispomeni.
|
||||
*/
|
||||
if (combination_buffer[0] >= 0x390 && combination_buffer[0] <= 0x3FF)
|
||||
{
|
||||
for (i = 1; i < n_compose; i++ )
|
||||
if (combination_buffer[i] == 0x303)
|
||||
combination_buffer[i] = 0x342;
|
||||
}
|
||||
|
||||
memcpy (combination_buffer_temp, combination_buffer, GTK_MAX_COMPOSE_LEN * sizeof (gunichar) );
|
||||
|
||||
for (i = 0; i < n_combinations; i++ )
|
||||
{
|
||||
g_unicode_canonical_ordering (combination_buffer_temp, n_compose);
|
||||
combination_utf8_temp = g_ucs4_to_utf8 (combination_buffer_temp, -1, NULL, NULL, NULL);
|
||||
nfc_temp = g_utf8_normalize (combination_utf8_temp, -1, G_NORMALIZE_NFC);
|
||||
|
||||
if (g_utf8_strlen (nfc_temp, -1) == 1)
|
||||
{
|
||||
memcpy (combination_buffer, combination_buffer_temp, GTK_MAX_COMPOSE_LEN * sizeof (gunichar) );
|
||||
|
||||
g_free (combination_utf8_temp);
|
||||
g_free (nfc_temp);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
g_free (combination_utf8_temp);
|
||||
g_free (nfc_temp);
|
||||
|
||||
if (n_compose > 2)
|
||||
{
|
||||
temp_swap = combination_buffer_temp[i % (n_compose - 1) + 1];
|
||||
combination_buffer_temp[i % (n_compose - 1) + 1] = combination_buffer_temp[(i+1) % (n_compose - 1) + 1];
|
||||
combination_buffer_temp[(i+1) % (n_compose - 1) + 1] = temp_swap;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_check_algorithmically (const guint16 *compose_buffer,
|
||||
int n_compose,
|
||||
gunichar *output_char)
|
||||
|
||||
{
|
||||
int i;
|
||||
gunichar combination_buffer[GTK_MAX_COMPOSE_LEN];
|
||||
char *combination_utf8, *nfc;
|
||||
|
||||
if (output_char)
|
||||
*output_char = 0;
|
||||
|
||||
if (n_compose >= GTK_MAX_COMPOSE_LEN)
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < n_compose && IS_DEAD_KEY (compose_buffer[i]); i++)
|
||||
;
|
||||
if (i == n_compose)
|
||||
return TRUE;
|
||||
|
||||
if (i > 0 && i == n_compose - 1)
|
||||
{
|
||||
combination_buffer[0] = gdk_keyval_to_unicode (compose_buffer[i]);
|
||||
combination_buffer[n_compose] = 0;
|
||||
i--;
|
||||
while (i >= 0)
|
||||
{
|
||||
switch (compose_buffer[i])
|
||||
{
|
||||
#define CASE(keysym, unicode) \
|
||||
case GDK_KEY_dead_##keysym: combination_buffer[i+1] = unicode; break
|
||||
|
||||
CASE (grave, 0x0300);
|
||||
CASE (acute, 0x0301);
|
||||
CASE (circumflex, 0x0302);
|
||||
CASE (tilde, 0x0303); /* Also used with perispomeni, 0x342. */
|
||||
CASE (macron, 0x0304);
|
||||
CASE (breve, 0x0306);
|
||||
CASE (abovedot, 0x0307);
|
||||
CASE (diaeresis, 0x0308);
|
||||
CASE (hook, 0x0309);
|
||||
CASE (abovering, 0x030A);
|
||||
CASE (doubleacute, 0x030B);
|
||||
CASE (caron, 0x030C);
|
||||
CASE (abovecomma, 0x0313); /* Equivalent to psili */
|
||||
CASE (abovereversedcomma, 0x0314); /* Equivalent to dasia */
|
||||
CASE (horn, 0x031B); /* Legacy use for psili, 0x313 (or 0x343). */
|
||||
CASE (belowdot, 0x0323);
|
||||
CASE (cedilla, 0x0327);
|
||||
CASE (ogonek, 0x0328); /* Legacy use for dasia, 0x314.*/
|
||||
CASE (iota, 0x0345);
|
||||
CASE (voiced_sound, 0x3099); /* Per Markus Kuhn keysyms.txt file. */
|
||||
CASE (semivoiced_sound, 0x309A); /* Per Markus Kuhn keysyms.txt file. */
|
||||
|
||||
/* The following cases are to be removed once xkeyboard-config,
|
||||
* xorg are fully updated.
|
||||
*/
|
||||
/* Workaround for typo in 1.4.x xserver-xorg */
|
||||
case 0xfe66: combination_buffer[i+1] = 0x314; break;
|
||||
/* CASE (dasia, 0x314); */
|
||||
/* CASE (perispomeni, 0x342); */
|
||||
/* CASE (psili, 0x343); */
|
||||
#undef CASE
|
||||
default:
|
||||
combination_buffer[i+1] = gdk_keyval_to_unicode (compose_buffer[i]);
|
||||
}
|
||||
i--;
|
||||
}
|
||||
|
||||
/* If the buffer normalizes to a single character, then modify the order
|
||||
* of combination_buffer accordingly, if necessary, and return TRUE.
|
||||
*/
|
||||
if (check_normalize_nfc (combination_buffer, n_compose))
|
||||
{
|
||||
combination_utf8 = g_ucs4_to_utf8 (combination_buffer, -1, NULL, NULL, NULL);
|
||||
nfc = g_utf8_normalize (combination_utf8, -1, G_NORMALIZE_NFC);
|
||||
|
||||
if (output_char)
|
||||
*output_char = g_utf8_get_char (nfc);
|
||||
|
||||
g_free (combination_utf8);
|
||||
g_free (nfc);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
gtk_im_context_simple_commit_string (context_simple, buf);
|
||||
}
|
||||
|
||||
/* In addition to the table-driven sequences, we allow Unicode hex
|
||||
@@ -716,7 +358,7 @@ check_hex (GtkIMContextSimple *context_simple,
|
||||
char *nptr = NULL;
|
||||
char buf[7];
|
||||
|
||||
priv->tentative_match = 0;
|
||||
g_string_set_size (priv->tentative_match, 0);
|
||||
priv->tentative_match_len = 0;
|
||||
|
||||
str = g_string_new (NULL);
|
||||
@@ -756,7 +398,8 @@ check_hex (GtkIMContextSimple *context_simple,
|
||||
|
||||
if (g_unichar_validate (n))
|
||||
{
|
||||
priv->tentative_match = n;
|
||||
g_string_set_size (priv->tentative_match, 0);
|
||||
g_string_append_unichar (priv->tentative_match, n);
|
||||
priv->tentative_match_len = n_compose;
|
||||
}
|
||||
|
||||
@@ -792,18 +435,25 @@ no_sequence_matches (GtkIMContextSimple *context_simple,
|
||||
/* No compose sequences found, check first if we have a partial
|
||||
* match pending.
|
||||
*/
|
||||
if (priv->tentative_match)
|
||||
if (priv->tentative_match_len > 0)
|
||||
{
|
||||
int len = priv->tentative_match_len;
|
||||
int i;
|
||||
|
||||
gtk_im_context_simple_commit_char (context, priv->tentative_match);
|
||||
priv->compose_buffer[0] = 0;
|
||||
|
||||
guint16 *compose_buffer;
|
||||
char *str;
|
||||
|
||||
compose_buffer = alloca (sizeof (guint16) * priv->compose_buffer_len);
|
||||
|
||||
memcpy (compose_buffer, priv->compose_buffer, sizeof (guint16) * priv->compose_buffer_len);
|
||||
|
||||
str = g_strdup (priv->tentative_match->str);
|
||||
gtk_im_context_simple_commit_string (context_simple, str);
|
||||
g_free (str);
|
||||
|
||||
for (i = 0; i < n_compose - len - 1; i++)
|
||||
{
|
||||
{
|
||||
GdkTranslatedKey translated;
|
||||
translated.keyval = priv->compose_buffer[len + i];
|
||||
translated.keyval = compose_buffer[len + i];
|
||||
translated.consumed = 0;
|
||||
translated.layout = 0;
|
||||
translated.level = 0;
|
||||
@@ -811,7 +461,7 @@ no_sequence_matches (GtkIMContextSimple *context_simple,
|
||||
gdk_event_get_surface (event),
|
||||
gdk_event_get_device (event),
|
||||
gdk_event_get_time (event),
|
||||
priv->compose_buffer[len + i],
|
||||
compose_buffer[len + i],
|
||||
gdk_event_get_modifier_state (event),
|
||||
FALSE,
|
||||
&translated,
|
||||
@@ -831,13 +481,15 @@ no_sequence_matches (GtkIMContextSimple *context_simple,
|
||||
if (n_compose > 1) /* Invalid sequence */
|
||||
{
|
||||
beep_surface (gdk_event_get_surface (event));
|
||||
g_signal_emit_by_name (context, "preedit-changed");
|
||||
g_signal_emit_by_name (context, "preedit-end");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
ch = gdk_keyval_to_unicode (keyval);
|
||||
if (ch != 0 && !g_unichar_iscntrl (ch))
|
||||
{
|
||||
gtk_im_context_simple_commit_char (context, ch);
|
||||
gtk_im_context_simple_commit_char (context_simple, ch);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
@@ -921,7 +573,7 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
|
||||
gunichar output_char;
|
||||
guint keyval, state;
|
||||
|
||||
while (priv->compose_buffer[n_compose] != 0)
|
||||
while (priv->compose_buffer[n_compose] != 0 && n_compose < priv->compose_buffer_len)
|
||||
n_compose++;
|
||||
|
||||
keyval = gdk_key_event_get_keyval (event);
|
||||
@@ -933,11 +585,11 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
|
||||
(keyval == GDK_KEY_Control_L || keyval == GDK_KEY_Control_R ||
|
||||
keyval == GDK_KEY_Shift_L || keyval == GDK_KEY_Shift_R))
|
||||
{
|
||||
if (priv->tentative_match &&
|
||||
g_unichar_validate (priv->tentative_match))
|
||||
if (priv->tentative_match->len > 0)
|
||||
{
|
||||
gtk_im_context_simple_commit_char (context, priv->tentative_match);
|
||||
priv->compose_buffer[0] = 0;
|
||||
char *str = g_strdup (priv->tentative_match->str);
|
||||
gtk_im_context_simple_commit_string (context_simple, str);
|
||||
g_free (str);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -952,7 +604,7 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
|
||||
/* invalid hex sequence */
|
||||
beep_surface (surface);
|
||||
|
||||
priv->tentative_match = 0;
|
||||
g_string_set_size (priv->tentative_match, 0);
|
||||
priv->in_hex_sequence = FALSE;
|
||||
priv->compose_buffer[0] = 0;
|
||||
|
||||
@@ -1036,14 +688,27 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!priv->in_hex_sequence && n_compose > 0 && is_backspace)
|
||||
{
|
||||
n_compose--;
|
||||
priv->compose_buffer[n_compose] = 0;
|
||||
|
||||
g_signal_emit_by_name (context_simple, "preedit-changed");
|
||||
|
||||
if (n_compose == 0)
|
||||
g_signal_emit_by_name (context_simple, "preedit-end");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Check for hex sequence restart */
|
||||
if (priv->in_hex_sequence && have_hex_mods && is_hex_start)
|
||||
{
|
||||
if (priv->tentative_match &&
|
||||
g_unichar_validate (priv->tentative_match))
|
||||
if (priv->tentative_match->len > 0)
|
||||
{
|
||||
gtk_im_context_simple_commit_char (context, priv->tentative_match);
|
||||
priv->compose_buffer[0] = 0;
|
||||
char *str = g_strdup (priv->tentative_match->str);
|
||||
gtk_im_context_simple_commit_string (context_simple, str);
|
||||
g_free (str);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1051,7 +716,7 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
|
||||
if (n_compose > 0)
|
||||
beep_surface (surface);
|
||||
|
||||
priv->tentative_match = 0;
|
||||
g_string_set_size (priv->tentative_match, 0);
|
||||
priv->in_hex_sequence = FALSE;
|
||||
priv->compose_buffer[0] = 0;
|
||||
}
|
||||
@@ -1063,7 +728,7 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
|
||||
priv->compose_buffer[0] = 0;
|
||||
priv->in_hex_sequence = TRUE;
|
||||
priv->modifiers_dropped = FALSE;
|
||||
priv->tentative_match = 0;
|
||||
g_string_set_size (priv->tentative_match, 0);
|
||||
|
||||
g_signal_emit_by_name (context_simple, "preedit-start");
|
||||
g_signal_emit_by_name (context_simple, "preedit-changed");
|
||||
@@ -1074,7 +739,7 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
|
||||
/* Then, check for compose sequences */
|
||||
if (priv->in_hex_sequence)
|
||||
{
|
||||
if (hex_keyval)
|
||||
if (hex_keyval && n_compose < 6)
|
||||
priv->compose_buffer[n_compose++] = hex_keyval;
|
||||
else if (is_escape)
|
||||
{
|
||||
@@ -1083,13 +748,21 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
|
||||
}
|
||||
else if (!is_hex_end)
|
||||
{
|
||||
/* non-hex character in hex sequence */
|
||||
/* non-hex character in hex sequence, or sequence too long */
|
||||
beep_surface (surface);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
priv->compose_buffer[n_compose++] = keyval;
|
||||
{
|
||||
if (n_compose + 1 == priv->compose_buffer_len)
|
||||
{
|
||||
priv->compose_buffer_len += 1;
|
||||
priv->compose_buffer = g_renew (guint16, priv->compose_buffer, priv->compose_buffer_len);
|
||||
}
|
||||
|
||||
priv->compose_buffer[n_compose++] = keyval;
|
||||
}
|
||||
|
||||
priv->compose_buffer[n_compose] = 0;
|
||||
|
||||
@@ -1101,18 +774,18 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
|
||||
/* space or return ends the sequence, and we eat the key */
|
||||
if (n_compose > 0 && is_hex_end)
|
||||
{
|
||||
if (priv->tentative_match &&
|
||||
g_unichar_validate (priv->tentative_match))
|
||||
if (priv->tentative_match->len > 0)
|
||||
{
|
||||
gtk_im_context_simple_commit_char (context, priv->tentative_match);
|
||||
priv->compose_buffer[0] = 0;
|
||||
char *str = g_strdup (priv->tentative_match->str);
|
||||
gtk_im_context_simple_commit_string (context_simple, str);
|
||||
g_free (str);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* invalid hex sequence */
|
||||
beep_surface (surface);
|
||||
|
||||
priv->tentative_match = 0;
|
||||
g_string_set_size (priv->tentative_match, 0);
|
||||
priv->in_hex_sequence = FALSE;
|
||||
priv->compose_buffer[0] = 0;
|
||||
}
|
||||
@@ -1131,65 +804,81 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
|
||||
else
|
||||
{
|
||||
gboolean success = FALSE;
|
||||
GString *output;
|
||||
|
||||
output = g_string_new ("");
|
||||
|
||||
G_LOCK (global_tables);
|
||||
|
||||
tmp_list = global_tables;
|
||||
while (tmp_list)
|
||||
{
|
||||
if (check_table (context_simple, tmp_list->data, n_compose))
|
||||
if (gtk_compose_table_check ((GtkComposeTable *)tmp_list->data,
|
||||
priv->compose_buffer, n_compose,
|
||||
&compose_finish, &compose_match,
|
||||
output))
|
||||
{
|
||||
if (compose_finish)
|
||||
{
|
||||
if (compose_match)
|
||||
gtk_im_context_simple_commit_string (context_simple, output->str);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (compose_match)
|
||||
{
|
||||
g_string_assign (priv->tentative_match, output->str);
|
||||
priv->tentative_match_len = n_compose;
|
||||
}
|
||||
g_signal_emit_by_name (context_simple, "preedit-changed");
|
||||
}
|
||||
|
||||
success = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
G_UNLOCK (global_tables);
|
||||
|
||||
g_string_free (output, TRUE);
|
||||
|
||||
if (success)
|
||||
return TRUE;
|
||||
|
||||
if (gtk_check_compact_table (>k_compose_table_compact,
|
||||
priv->compose_buffer,
|
||||
n_compose, &compose_finish,
|
||||
&compose_match, &output_char))
|
||||
if (gtk_compose_table_compact_check (>k_compose_table_compact,
|
||||
priv->compose_buffer, n_compose,
|
||||
&compose_finish, &compose_match,
|
||||
&output_char))
|
||||
{
|
||||
if (compose_finish)
|
||||
{
|
||||
if (compose_match)
|
||||
{
|
||||
gtk_im_context_simple_commit_char (GTK_IM_CONTEXT (context_simple),
|
||||
output_char);
|
||||
priv->compose_buffer[0] = 0;
|
||||
}
|
||||
gtk_im_context_simple_commit_char (context_simple, output_char);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (compose_match)
|
||||
{
|
||||
priv->tentative_match = output_char;
|
||||
g_string_set_size (priv->tentative_match, 0);
|
||||
g_string_append_unichar (priv->tentative_match, output_char);
|
||||
priv->tentative_match_len = n_compose;
|
||||
}
|
||||
if (output_char)
|
||||
g_signal_emit_by_name (context_simple, "preedit-changed");
|
||||
g_signal_emit_by_name (context_simple, "preedit-changed");
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
if (gtk_check_algorithmically (priv->compose_buffer, n_compose, &output_char))
|
||||
{
|
||||
if (output_char)
|
||||
{
|
||||
gtk_im_context_simple_commit_char (GTK_IM_CONTEXT (context_simple),
|
||||
output_char);
|
||||
priv->compose_buffer[0] = 0;
|
||||
}
|
||||
return TRUE;
|
||||
gtk_im_context_simple_commit_char (context_simple, output_char);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* The current compose_buffer doesn't match anything */
|
||||
return no_sequence_matches (context_simple, n_compose, (GdkEvent *)event);
|
||||
}
|
||||
@@ -1202,66 +891,69 @@ gtk_im_context_simple_reset (GtkIMContext *context)
|
||||
|
||||
priv->compose_buffer[0] = 0;
|
||||
|
||||
if (priv->tentative_match || priv->in_hex_sequence)
|
||||
if (priv->tentative_match->len > 0 || priv->in_hex_sequence)
|
||||
{
|
||||
priv->in_hex_sequence = FALSE;
|
||||
priv->tentative_match = 0;
|
||||
g_string_set_size (priv->tentative_match, 0);
|
||||
priv->tentative_match_len = 0;
|
||||
g_signal_emit_by_name (context_simple, "preedit-changed");
|
||||
g_signal_emit_by_name (context_simple, "preedit-end");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
static void
|
||||
gtk_im_context_simple_get_preedit_string (GtkIMContext *context,
|
||||
char **str,
|
||||
PangoAttrList **attrs,
|
||||
int *cursor_pos)
|
||||
char **str,
|
||||
PangoAttrList **attrs,
|
||||
int *cursor_pos)
|
||||
{
|
||||
GtkIMContextSimple *context_simple = GTK_IM_CONTEXT_SIMPLE (context);
|
||||
GtkIMContextSimplePrivate *priv = context_simple->priv;
|
||||
char outbuf[37]; /* up to 6 hex digits */
|
||||
int len = 0;
|
||||
GString *s;
|
||||
int i;
|
||||
|
||||
s = g_string_new ("");
|
||||
|
||||
if (priv->in_hex_sequence)
|
||||
{
|
||||
int hexchars = 0;
|
||||
|
||||
outbuf[0] = 'u';
|
||||
len = 1;
|
||||
g_string_append_c (s, 'u');
|
||||
|
||||
while (priv->compose_buffer[hexchars] != 0)
|
||||
{
|
||||
len += g_unichar_to_utf8 (gdk_keyval_to_unicode (priv->compose_buffer[hexchars]),
|
||||
outbuf + len);
|
||||
++hexchars;
|
||||
}
|
||||
|
||||
g_assert (len < 25);
|
||||
for (i = 0; priv->compose_buffer[i]; i++)
|
||||
g_string_append_unichar (s, gdk_keyval_to_unicode (priv->compose_buffer[i]));
|
||||
}
|
||||
else if (priv->tentative_match->len > 0 && priv->compose_buffer[0] != 0)
|
||||
{
|
||||
g_string_append (s, priv->tentative_match->str);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; priv->compose_buffer[i]; i++)
|
||||
{
|
||||
if (priv->compose_buffer[i] == GDK_KEY_Multi_key)
|
||||
g_string_append_unichar (s, 0x2384); /* U+2384 COMPOSITION SYMBOL */
|
||||
else
|
||||
g_string_append_unichar (s, gdk_keyval_to_unicode (priv->compose_buffer[i]));
|
||||
}
|
||||
}
|
||||
else if (priv->tentative_match)
|
||||
len = g_unichar_to_utf8 (priv->tentative_match, outbuf);
|
||||
|
||||
outbuf[len] = '\0';
|
||||
|
||||
if (str)
|
||||
*str = g_strdup (outbuf);
|
||||
if (cursor_pos)
|
||||
*cursor_pos = s->len;
|
||||
|
||||
if (attrs)
|
||||
{
|
||||
*attrs = pango_attr_list_new ();
|
||||
|
||||
if (len)
|
||||
{
|
||||
PangoAttribute *attr = pango_attr_underline_new (PANGO_UNDERLINE_SINGLE);
|
||||
attr->start_index = 0;
|
||||
attr->end_index = len;
|
||||
pango_attr_list_insert (*attrs, attr);
|
||||
}
|
||||
|
||||
if (s->len)
|
||||
{
|
||||
PangoAttribute *attr = pango_attr_underline_new (PANGO_UNDERLINE_SINGLE);
|
||||
attr->start_index = 0;
|
||||
attr->end_index = s->len;
|
||||
pango_attr_list_insert (*attrs, attr);
|
||||
}
|
||||
}
|
||||
|
||||
if (cursor_pos)
|
||||
*cursor_pos = len;
|
||||
if (str)
|
||||
*str = g_string_free (s, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1269,7 +961,6 @@ gtk_im_context_simple_get_preedit_string (GtkIMContext *context,
|
||||
* @context_simple: A #GtkIMContextSimple
|
||||
* @data: (array): the table
|
||||
* @max_seq_len: Maximum length of a sequence in the table
|
||||
* (cannot be greater than #GTK_MAX_COMPOSE_LEN)
|
||||
* @n_seqs: number of sequences in the table
|
||||
*
|
||||
* Adds an additional table to search to the input context.
|
||||
@@ -1313,8 +1004,7 @@ gtk_im_context_simple_add_compose_file (GtkIMContextSimple *context_simple,
|
||||
|
||||
G_LOCK (global_tables);
|
||||
|
||||
global_tables = gtk_compose_table_list_add_file (global_tables,
|
||||
compose_file);
|
||||
global_tables = gtk_compose_table_list_add_file (global_tables, compose_file);
|
||||
|
||||
G_UNLOCK (global_tables);
|
||||
}
|
||||
|
||||
@@ -27,10 +27,9 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* GTK_MAX_COMPOSE_LEN:
|
||||
*
|
||||
* The maximum length of sequences in compose tables.
|
||||
/*
|
||||
* No longer used by GTK, just left here on the off chance that some
|
||||
* 3rd party code used this define.
|
||||
*/
|
||||
#define GTK_MAX_COMPOSE_LEN 7
|
||||
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2000 Red Hat Software
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_IM_CONTEXT_SIMPLE_PRIVATE_H__
|
||||
#define __GTK_IM_CONTEXT_SIMPLE_PRIVATE_H__
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "gdk/gdkkeysyms.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
extern const GtkComposeTableCompact gtk_compose_table_compact;
|
||||
|
||||
gboolean gtk_check_algorithmically (const guint16 *compose_buffer,
|
||||
int n_compose,
|
||||
gunichar *output);
|
||||
gboolean gtk_check_compact_table (const GtkComposeTableCompact *table,
|
||||
guint16 *compose_buffer,
|
||||
int n_compose,
|
||||
gboolean *compose_finish,
|
||||
gboolean *compose_match,
|
||||
gunichar *output_char);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
#endif /* __GTK_IM_CONTEXT_SIMPLE_PRIVATE_H__ */
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <string.h>
|
||||
#include <wayland-client-protocol.h>
|
||||
|
||||
#include "gtk/gtkdragsourceprivate.h"
|
||||
#include "gtk/gtkimcontextwayland.h"
|
||||
#include "gtk/gtkintl.h"
|
||||
#include "gtk/gtkimmoduleprivate.h"
|
||||
@@ -524,10 +525,10 @@ released_cb (GtkGestureClick *gesture,
|
||||
if (global->focused &&
|
||||
n_press == 1 &&
|
||||
(hints & GTK_INPUT_HINT_INHIBIT_OSK) == 0 &&
|
||||
!gtk_drag_check_threshold (context->widget,
|
||||
context->press_x,
|
||||
context->press_y,
|
||||
x, y))
|
||||
!gtk_drag_check_threshold_double (context->widget,
|
||||
context->press_x,
|
||||
context->press_y,
|
||||
x, y))
|
||||
{
|
||||
zwp_text_input_v3_enable (global->text_input);
|
||||
g_signal_emit_by_name (global->current, "retrieve-surrounding", &result);
|
||||
|
||||
+2
-7
@@ -27,16 +27,12 @@
|
||||
#include "gtklabelprivate.h"
|
||||
|
||||
#include "gtkbuildable.h"
|
||||
#include "gtkbuilderprivate.h"
|
||||
#include "gtkcssstylepropertyprivate.h"
|
||||
#include "gtkeventcontrollermotion.h"
|
||||
#include "gtkeventcontrollerfocus.h"
|
||||
#include "gtkgesturedrag.h"
|
||||
#include "gtkgestureclick.h"
|
||||
#include "gtkgesturesingle.h"
|
||||
#include "gtkimage.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkmain.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtknotebook.h"
|
||||
#include "gtkpango.h"
|
||||
@@ -51,10 +47,9 @@
|
||||
#include "gtktooltip.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkwindow.h"
|
||||
#include "gtkpopovermenu.h"
|
||||
#include "gtknative.h"
|
||||
#include "gtkdragsource.h"
|
||||
#include "gtkdragsourceprivate.h"
|
||||
#include "gtkdragicon.h"
|
||||
#include "gtkcsscolorvalueprivate.h"
|
||||
|
||||
@@ -4278,7 +4273,7 @@ gtk_label_drag_gesture_update (GtkGestureDrag *gesture,
|
||||
|
||||
if (info->in_drag)
|
||||
{
|
||||
if (gtk_drag_check_threshold (widget, info->drag_start_x, info->drag_start_y, x, y))
|
||||
if (gtk_drag_check_threshold_double (widget, info->drag_start_x, info->drag_start_y, x, y))
|
||||
{
|
||||
GdkDrag *drag;
|
||||
GdkSurface *surface;
|
||||
|
||||
+1
-2
@@ -124,13 +124,12 @@
|
||||
#include "gtkbinlayout.h"
|
||||
#include "gtkbuildable.h"
|
||||
#include "gtkbuilderprivate.h"
|
||||
#include "gtkcssstylepropertyprivate.h"
|
||||
#include "gtkgizmoprivate.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtklevelbar.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkorientable.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtkcssnodeprivate.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
|
||||
|
||||
+2
-3
@@ -23,7 +23,7 @@
|
||||
|
||||
#include "gtkadjustment.h"
|
||||
#include "gtkbitset.h"
|
||||
#include "gtkdragsource.h"
|
||||
#include "gtkdragsourceprivate.h"
|
||||
#include "gtkdropcontrollermotion.h"
|
||||
#include "gtkgesturedrag.h"
|
||||
#include "gtkgizmoprivate.h"
|
||||
@@ -34,7 +34,6 @@
|
||||
#include "gtkscrollable.h"
|
||||
#include "gtksingleselection.h"
|
||||
#include "gtksnapshot.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
|
||||
@@ -1710,7 +1709,7 @@ gtk_list_base_drag_update (GtkGestureDrag *gesture,
|
||||
|
||||
if (!priv->rubberband)
|
||||
{
|
||||
if (!gtk_drag_check_threshold (GTK_WIDGET (self), 0, 0, offset_x, offset_y))
|
||||
if (!gtk_drag_check_threshold_double (GTK_WIDGET (self), 0, 0, offset_x, offset_y))
|
||||
return;
|
||||
|
||||
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
|
||||
|
||||
+3
-3
@@ -724,13 +724,13 @@ gtk_list_box_init (GtkListBox *box)
|
||||
* gtk_list_box_get_selected_row:
|
||||
* @box: a #GtkListBox
|
||||
*
|
||||
* Gets the selected row.
|
||||
* Gets the selected row, or %NULL if no rows are selected.
|
||||
*
|
||||
* Note that the box may allow multiple selection, in which
|
||||
* case you should use gtk_list_box_selected_foreach() to
|
||||
* find all selected rows.
|
||||
*
|
||||
* Returns: (transfer none): the selected row
|
||||
* Returns: (transfer none) (nullable): the selected row or %NULL
|
||||
*/
|
||||
GtkListBoxRow *
|
||||
gtk_list_box_get_selected_row (GtkListBox *box)
|
||||
@@ -746,7 +746,7 @@ gtk_list_box_get_selected_row (GtkListBox *box)
|
||||
* @index_: the index of the row
|
||||
*
|
||||
* Gets the n-th child in the list (not counting headers).
|
||||
* If @_index is negative or larger than the number of items in the
|
||||
* If @index_ is negative or larger than the number of items in the
|
||||
* list, %NULL is returned.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the child #GtkWidget or %NULL
|
||||
|
||||
+11
-1
@@ -332,7 +332,7 @@ gtk_list_item_widget_click_gesture_pressed (GtkGestureClick *gesture,
|
||||
|
||||
if (!priv->list_item || priv->list_item->activatable)
|
||||
{
|
||||
if (n_press == 2 || priv->single_click_activate)
|
||||
if (n_press == 2 && !priv->single_click_activate)
|
||||
{
|
||||
gtk_widget_activate_action (GTK_WIDGET (self),
|
||||
"list.activate-item",
|
||||
@@ -356,6 +356,16 @@ gtk_list_item_widget_click_gesture_released (GtkGestureClick *gesture,
|
||||
{
|
||||
GtkListItemWidgetPrivate *priv = gtk_list_item_widget_get_instance_private (self);
|
||||
|
||||
if (priv->single_click_activate)
|
||||
{
|
||||
gtk_widget_activate_action (GTK_WIDGET (self),
|
||||
"list.activate-item",
|
||||
"u",
|
||||
priv->position);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!priv->list_item || priv->list_item->selectable)
|
||||
{
|
||||
GdkModifierType state;
|
||||
|
||||
+17
-12
@@ -2149,7 +2149,7 @@ gtk_list_store_has_default_sort_func (GtkTreeSortable *sortable)
|
||||
/**
|
||||
* gtk_list_store_insert_with_values:
|
||||
* @list_store: A #GtkListStore
|
||||
* @iter: (out) (allow-none): An unset #GtkTreeIter to set to the new row, or %NULL
|
||||
* @iter: (out) (optional): An unset #GtkTreeIter to set to the new row
|
||||
* @position: position to insert the new row, or -1 to append after existing
|
||||
* rows
|
||||
* @...: pairs of column number and value, terminated with -1
|
||||
@@ -2161,7 +2161,8 @@ gtk_list_store_has_default_sort_func (GtkTreeSortable *sortable)
|
||||
*
|
||||
* Calling
|
||||
* `gtk_list_store_insert_with_values (list_store, iter, position...)`
|
||||
* has the same effect as calling
|
||||
* has the same effect as calling:
|
||||
*
|
||||
* |[<!-- language="C" -->
|
||||
* static void
|
||||
* insert_value (GtkListStore *list_store,
|
||||
@@ -2175,12 +2176,15 @@ gtk_list_store_has_default_sort_func (GtkTreeSortable *sortable)
|
||||
* );
|
||||
* }
|
||||
* ]|
|
||||
* with the difference that the former will only emit a row_inserted signal,
|
||||
* while the latter will emit row_inserted, row_changed and, if the list store
|
||||
* is sorted, rows_reordered. Since emitting the rows_reordered signal
|
||||
* repeatedly can affect the performance of the program,
|
||||
* gtk_list_store_insert_with_values() should generally be preferred when
|
||||
* inserting rows in a sorted list store.
|
||||
*
|
||||
* with the difference that the former will only emit #GtkTreeModel::row-inserted
|
||||
* once, while the latter will emit #GtkTreeModel::row-inserted,
|
||||
* #GtkTreeModel::row-changed and, if the list store is sorted,
|
||||
* #GtkTreeModel::rows-reordered for every inserted value.
|
||||
*
|
||||
* Since emitting the #GtkTreeModel::rows-reordered signal repeatedly can
|
||||
* affect the performance of the program, gtk_list_store_insert_with_values()
|
||||
* should generally be preferred when inserting rows in a sorted list store.
|
||||
*/
|
||||
void
|
||||
gtk_list_store_insert_with_values (GtkListStore *list_store,
|
||||
@@ -2244,9 +2248,9 @@ gtk_list_store_insert_with_values (GtkListStore *list_store,
|
||||
|
||||
|
||||
/**
|
||||
* gtk_list_store_insert_with_valuesv:
|
||||
* gtk_list_store_insert_with_valuesv: (rename-to gtk_list_store_insert_with_values)
|
||||
* @list_store: A #GtkListStore
|
||||
* @iter: (out) (allow-none): An unset #GtkTreeIter to set to the new row, or %NULL.
|
||||
* @iter: (out) (optional): An unset #GtkTreeIter to set to the new row
|
||||
* @position: position to insert the new row, or -1 for last
|
||||
* @columns: (array length=n_values): an array of column numbers
|
||||
* @values: (array length=n_values): an array of GValues
|
||||
@@ -2254,8 +2258,9 @@ gtk_list_store_insert_with_values (GtkListStore *list_store,
|
||||
*
|
||||
* A variant of gtk_list_store_insert_with_values() which
|
||||
* takes the columns and values as two arrays, instead of
|
||||
* varargs. This function is mainly intended for
|
||||
* language-bindings.
|
||||
* varargs.
|
||||
*
|
||||
* This function is mainly intended for language-bindings.
|
||||
*/
|
||||
void
|
||||
gtk_list_store_insert_with_valuesv (GtkListStore *list_store,
|
||||
|
||||
+30
-15
@@ -107,12 +107,22 @@
|
||||
* |[<!-- language="plain" -->
|
||||
* menubutton
|
||||
* ╰── button.toggle
|
||||
* ╰── [content]
|
||||
* ╰── <content>
|
||||
* ╰── [arrow]
|
||||
*]|
|
||||
*
|
||||
* GtkMenuButton has a single CSS node with name menubutton
|
||||
* which contains a toggle button node.
|
||||
*
|
||||
* Inside the toggle button content, there is an arrow node for
|
||||
* the indicator, which will carry one of the .none, .up, .down,
|
||||
* .left or .right style classes to indicate the direction that
|
||||
* the menu will appear in. The CSS is expected to provide a suitable
|
||||
* image for each of these cases using the -gtk-icon-source property.
|
||||
*
|
||||
* Optionally, the menubutton node can carry the .circular style class
|
||||
* to request a round appearance.
|
||||
*
|
||||
* # Accessibility
|
||||
*
|
||||
* GtkMenuButton uses the #GTK_ACCESSIBLE_ROLE_BUTTON role.
|
||||
@@ -121,7 +131,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkactionable.h"
|
||||
#include "gtkimage.h"
|
||||
#include "gtkbuiltiniconprivate.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkmain.h"
|
||||
#include "gtkmenubutton.h"
|
||||
@@ -440,35 +450,40 @@ gtk_menu_button_class_init (GtkMenuButtonClass *klass)
|
||||
}
|
||||
|
||||
static void
|
||||
set_arrow_type (GtkImage *image,
|
||||
set_arrow_type (GtkWidget *arrow,
|
||||
GtkArrowType arrow_type,
|
||||
gboolean visible)
|
||||
{
|
||||
gtk_widget_remove_css_class (arrow, "none");
|
||||
gtk_widget_remove_css_class (arrow, "down");
|
||||
gtk_widget_remove_css_class (arrow, "up");
|
||||
gtk_widget_remove_css_class (arrow, "left");
|
||||
gtk_widget_remove_css_class (arrow, "right");
|
||||
switch (arrow_type)
|
||||
{
|
||||
case GTK_ARROW_NONE:
|
||||
gtk_image_set_from_icon_name (image, "open-menu-symbolic");
|
||||
gtk_widget_add_css_class (arrow, "none");
|
||||
break;
|
||||
case GTK_ARROW_DOWN:
|
||||
gtk_image_set_from_icon_name (image, "pan-down-symbolic");
|
||||
gtk_widget_add_css_class (arrow, "down");
|
||||
break;
|
||||
case GTK_ARROW_UP:
|
||||
gtk_image_set_from_icon_name (image, "pan-up-symbolic");
|
||||
gtk_widget_add_css_class (arrow, "up");
|
||||
break;
|
||||
case GTK_ARROW_LEFT:
|
||||
gtk_image_set_from_icon_name (image, "pan-start-symbolic");
|
||||
gtk_widget_add_css_class (arrow, "left");
|
||||
break;
|
||||
case GTK_ARROW_RIGHT:
|
||||
gtk_image_set_from_icon_name (image, "pan-end-symbolic");
|
||||
gtk_widget_add_css_class (arrow, "right");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (visible)
|
||||
gtk_widget_show (GTK_WIDGET (image));
|
||||
gtk_widget_show (arrow);
|
||||
else
|
||||
gtk_widget_hide (GTK_WIDGET (image));
|
||||
gtk_widget_hide (arrow);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -476,8 +491,8 @@ add_arrow (GtkMenuButton *self)
|
||||
{
|
||||
GtkWidget *arrow;
|
||||
|
||||
arrow = gtk_image_new ();
|
||||
set_arrow_type (GTK_IMAGE (arrow), self->arrow_type, TRUE);
|
||||
arrow = gtk_builtin_icon_new ("arrow");
|
||||
set_arrow_type (arrow, self->arrow_type, TRUE);
|
||||
gtk_button_set_child (GTK_BUTTON (self->button), arrow);
|
||||
self->arrow_widget = arrow;
|
||||
}
|
||||
@@ -668,7 +683,7 @@ gtk_menu_button_set_direction (GtkMenuButton *menu_button,
|
||||
if (is_image_button && (menu_button->arrow_widget != gtk_button_get_child (GTK_BUTTON (menu_button->button))))
|
||||
return;
|
||||
|
||||
set_arrow_type (GTK_IMAGE (menu_button->arrow_widget),
|
||||
set_arrow_type (menu_button->arrow_widget,
|
||||
menu_button->arrow_type,
|
||||
is_image_button || (menu_button->arrow_type != GTK_ARROW_NONE));
|
||||
update_popover_direction (menu_button);
|
||||
@@ -848,9 +863,9 @@ gtk_menu_button_set_label (GtkMenuButton *menu_button,
|
||||
gtk_button_get_use_underline (GTK_BUTTON (menu_button->button)));
|
||||
gtk_widget_set_hexpand (label_widget, TRUE);
|
||||
gtk_widget_set_halign (label_widget, GTK_ALIGN_CENTER);
|
||||
arrow = gtk_image_new ();
|
||||
arrow = gtk_builtin_icon_new ("arrow");
|
||||
menu_button->arrow_widget = arrow;
|
||||
set_arrow_type (GTK_IMAGE (arrow), menu_button->arrow_type, menu_button->arrow_type != GTK_ARROW_NONE);
|
||||
set_arrow_type (arrow, menu_button->arrow_type, menu_button->arrow_type != GTK_ARROW_NONE);
|
||||
gtk_box_append (GTK_BOX (box), label_widget);
|
||||
gtk_box_append (GTK_BOX (box), arrow);
|
||||
gtk_button_set_child (GTK_BUTTON (menu_button->button), box);
|
||||
|
||||
@@ -49,7 +49,6 @@
|
||||
#include "gtkicontheme.h"
|
||||
#include "gtkmain.h"
|
||||
#include "gtksettings.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtkdialogprivate.h"
|
||||
#include "gtkgestureclick.h"
|
||||
#include "gtkmodelbuttonprivate.h"
|
||||
|
||||
+10
-8
@@ -31,7 +31,6 @@
|
||||
#include "gtkboxlayout.h"
|
||||
#include "gtkbuildable.h"
|
||||
#include "gtkbutton.h"
|
||||
#include "gtkcssstylepropertyprivate.h"
|
||||
#include "gtkdroptarget.h"
|
||||
#include "gtkdragicon.h"
|
||||
#include "gtkdropcontrollermotion.h"
|
||||
@@ -51,7 +50,7 @@
|
||||
#include "gtkstack.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkdragsource.h"
|
||||
#include "gtkdragsourceprivate.h"
|
||||
#include "gtkwidgetpaintable.h"
|
||||
#include "gtknative.h"
|
||||
|
||||
@@ -249,14 +248,14 @@ struct _GtkNotebook
|
||||
GList *first_tab; /* The first tab visible (for scrolling notebooks) */
|
||||
GList *focus_tab;
|
||||
|
||||
int drag_begin_x;
|
||||
int drag_begin_y;
|
||||
double drag_begin_x;
|
||||
double drag_begin_y;
|
||||
int drag_offset_x;
|
||||
int drag_offset_y;
|
||||
int drag_surface_x;
|
||||
int drag_surface_y;
|
||||
int mouse_x;
|
||||
int mouse_y;
|
||||
double mouse_x;
|
||||
double mouse_y;
|
||||
int pressed_button;
|
||||
|
||||
GQuark group;
|
||||
@@ -2935,8 +2934,11 @@ gtk_notebook_motion (GtkEventController *controller,
|
||||
|
||||
if (page->reorderable &&
|
||||
(notebook->operation == DRAG_OPERATION_REORDER ||
|
||||
gtk_drag_check_threshold (widget, notebook->drag_begin_x, notebook->drag_begin_y,
|
||||
notebook->mouse_x, notebook->mouse_y)))
|
||||
gtk_drag_check_threshold_double (widget,
|
||||
notebook->drag_begin_x,
|
||||
notebook->drag_begin_y,
|
||||
notebook->mouse_x,
|
||||
notebook->mouse_y)))
|
||||
{
|
||||
GtkNotebookPointerPosition pointer_position = get_pointer_position (notebook);
|
||||
|
||||
|
||||
+1
-2
@@ -27,7 +27,6 @@
|
||||
#include "gtkpaned.h"
|
||||
|
||||
#include "gtkcssboxesprivate.h"
|
||||
#include "gtkcssstylepropertyprivate.h"
|
||||
#include "gtkeventcontrollermotion.h"
|
||||
#include "gtkgesturepan.h"
|
||||
#include "gtkgesturesingle.h"
|
||||
@@ -37,7 +36,7 @@
|
||||
#include "gtkorientable.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkrendericonprivate.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtkcssnodeprivate.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkcssboxesprivate.h"
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkcsspositionvalueprivate.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtkcssnodeprivate.h"
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
#include "gtkgestureclick.h"
|
||||
#include "gtkgesturedrag.h"
|
||||
#include "gtknative.h"
|
||||
#include "gtkdragsource.h"
|
||||
#include "gtkdragsourceprivate.h"
|
||||
#include "gtkdragicon.h"
|
||||
|
||||
/*< private >
|
||||
@@ -3451,7 +3451,7 @@ on_row_dragged (GtkGestureDrag *gesture,
|
||||
return;
|
||||
}
|
||||
|
||||
if (gtk_drag_check_threshold (GTK_WIDGET (row), 0, 0, x, y))
|
||||
if (gtk_drag_check_threshold_double (GTK_WIDGET (row), 0, 0, x, y))
|
||||
{
|
||||
double start_x, start_y;
|
||||
double drag_x, drag_y;
|
||||
|
||||
+15
-11
@@ -360,7 +360,9 @@ did_flip_vertically (GdkGravity original_gravity,
|
||||
|
||||
static void
|
||||
update_popover_layout (GtkPopover *popover,
|
||||
GdkPopupLayout *layout)
|
||||
GdkPopupLayout *layout,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
GtkPopoverPrivate *priv = gtk_popover_get_instance_private (popover);
|
||||
GdkRectangle final_rect;
|
||||
@@ -413,7 +415,9 @@ update_popover_layout (GtkPopover *popover,
|
||||
break;
|
||||
}
|
||||
|
||||
if (priv->final_position != position)
|
||||
if (priv->final_position != position ||
|
||||
priv->final_rect.width != width ||
|
||||
priv->final_rect.height != height)
|
||||
{
|
||||
gtk_widget_queue_allocate (GTK_WIDGET (popover));
|
||||
g_clear_pointer (&priv->arrow_render_node, gsk_render_node_unref);
|
||||
@@ -545,9 +549,9 @@ create_popup_layout (GtkPopover *popover)
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
layout = gdk_popup_layout_new (&rect,
|
||||
parent_anchor,
|
||||
surface_anchor);
|
||||
anchor_hints |= GDK_ANCHOR_RESIZE;
|
||||
|
||||
layout = gdk_popup_layout_new (&rect, parent_anchor, surface_anchor);
|
||||
gdk_popup_layout_set_anchor_hints (layout, anchor_hints);
|
||||
|
||||
if (priv->x_offset || priv->y_offset)
|
||||
@@ -560,17 +564,17 @@ static gboolean
|
||||
present_popup (GtkPopover *popover)
|
||||
{
|
||||
GtkPopoverPrivate *priv = gtk_popover_get_instance_private (popover);
|
||||
GtkRequisition req;
|
||||
GtkRequisition nat;
|
||||
GdkPopupLayout *layout;
|
||||
|
||||
layout = create_popup_layout (popover);
|
||||
gtk_widget_get_preferred_size (GTK_WIDGET (popover), NULL, &req);
|
||||
gtk_widget_get_preferred_size (GTK_WIDGET (popover), NULL, &nat);
|
||||
|
||||
if (gdk_popup_present (GDK_POPUP (priv->surface),
|
||||
MAX (req.width, 1),
|
||||
MAX (req.height, 1),
|
||||
nat.width, nat.height,
|
||||
layout))
|
||||
{
|
||||
update_popover_layout (popover, layout);
|
||||
update_popover_layout (popover, layout, nat.width, nat.height);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -631,7 +635,7 @@ gtk_popover_native_layout (GtkNative *native,
|
||||
GtkPopoverPrivate *priv = gtk_popover_get_instance_private (popover);
|
||||
GtkWidget *widget = GTK_WIDGET (popover);
|
||||
|
||||
update_popover_layout (popover, gdk_popup_layout_ref (priv->layout));
|
||||
update_popover_layout (popover, gdk_popup_layout_ref (priv->layout), width, height);
|
||||
|
||||
if (gtk_widget_needs_allocate (widget))
|
||||
{
|
||||
|
||||
@@ -27,15 +27,12 @@
|
||||
#include "gtkprogressbar.h"
|
||||
|
||||
#include "gtkboxlayout.h"
|
||||
#include "gtkcssnumbervalueprivate.h"
|
||||
#include "gtkcssstylepropertyprivate.h"
|
||||
#include "gtkgizmoprivate.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtklabel.h"
|
||||
#include "gtkorientable.h"
|
||||
#include "gtkprogresstrackerprivate.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "gtkcsscornervalueprivate.h"
|
||||
#include "gtkcssnumbervalueprivate.h"
|
||||
#include "gtkcsstypesprivate.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
@@ -38,8 +38,6 @@
|
||||
#include "gtkorientable.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkrangeprivate.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtkstylepropertyprivate.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user