Compare commits

..

194 Commits

Author SHA1 Message Date
Matthias Clasen 49e93f6ee4 textview: Don't validate during snapshot
Do it during size_allocate, and go back there
if needed.
2023-02-21 15:04:30 -05:00
Matthias Clasen 4ec2234537 widget: Warn for invalidation during paint 2023-02-21 15:04:30 -05:00
Matthias Clasen 5a3755b233 frameclock: Add a debug helper
Begin able to query the current phase
is useful for debugging purposes.
2023-02-21 15:04:30 -05:00
Daniel cad5771a66 Updated Spanish translation 2023-02-21 12:07:49 +01:00
Emmanuele Bassi 378f1421f0 Merge branch 'main' into 'main'
button: Remove nullable annotation for new_from_icon_name()

Closes #5606

See merge request GNOME/gtk!5544
2023-02-20 21:30:05 +00:00
Philipp Hörist a209a73c69 button: Remove nullable annotation for new_from_icon_name()
This makes it more consistent with set_icon_name() which
does also not accept NULL.

Fixes #5606
2023-02-20 20:33:42 +01:00
Matthias Clasen 624458df9d Merge branch 'builder-tool-child-properties' into 'main'
gtk4-builder-tool: Prefer child properties

Closes #5609

See merge request GNOME/gtk!5543
2023-02-20 13:12:27 +00:00
Matthias Clasen fbfbaa484d Merge branch 'matthiasc/for-main' into 'main'
filechooser: Fix paned limits

See merge request GNOME/gtk!5542
2023-02-20 13:04:33 +00:00
Matthias Clasen 3de10847b9 gtk4-builder-tool: Prefer child properties
Rewrite <child> elements to use child properties
where that is easily possible.

Fixes: #5609
2023-02-19 21:48:56 -05:00
Kukuh Syafaat 8be601da4f Update Indonesian translation 2023-02-20 01:20:48 +00:00
Matthias Clasen 07b9a6fb75 filechooser: Fix paned limits
The intention of the ui file was to not let
the paned shrink both children down to nothing,
but using <child> for the children effectively
overrides the setting of the shrink properties.
Fix that by using child properties instead of
<child>.
2023-02-19 19:12:30 -05:00
Matthias Clasen 5105d607de Merge branch 'builder-tool-template-parent' into 'main'
builder-tool: Try harder to find template parents

Closes #5232

See merge request GNOME/gtk!5541
2023-02-20 00:05:06 +00:00
Matthias Clasen a9f03be588 builder-tool: Try harder to find template parents
This will make it work (in some cases) to add extra
libraries via LD_PRELOAD.

Based on work by Julian Sparber,
https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/5084

Fixes: #5232
2023-02-19 18:17:34 -05:00
Asier Sarasua Garmendia d67bdb96ad Update Basque translation 2023-02-19 20:44:24 +00:00
Yuri Chornoivan c8f4535ed2 Update Ukrainian translation 2023-02-19 20:23:35 +00:00
Aurimas Černius 21cbf98942 Update Lithuanian translation 2023-02-19 19:06:03 +00:00
Emmanuele Bassi 300540f6b8 Merge branch 'texturescalenode-type-annotations' into 'main'
Fix self-`(type)` annotations for `TextureScaleNode` methods

See merge request GNOME/gtk!5539
2023-02-19 17:18:01 +00:00
Sebastian Dröge 323ba14dde Fix self-(type) annotations for TextureScaleNode methods 2023-02-19 19:00:34 +02:00
Matthias Clasen aaee1ee5bd Merge branch 'fix_custom_accessible_hierarchy' into 'main'
Allow setting accessible parent and next sibling

See merge request GNOME/gtk!5517
2023-02-19 16:15:49 +00:00
Matthias Clasen 70a711882c Fix the build 2023-02-19 15:26:27 +00:00
Matthias Clasen 5717b95cad Miscellaneous formatting and documentation fixes 2023-02-19 15:09:25 +00:00
Matthias Clasen 1b0f324be5 Merge branch 'missing-since-markers' into 'main'
Add two missing `Since` markers

See merge request GNOME/gtk!5537
2023-02-19 14:56:51 +00:00
Sebastian Dröge ca93512106 Add two missing Since markers 2023-02-19 11:18:15 +02:00
Ekaterine Papava fbd4f06ee2 Update Georgian translation 2023-02-19 05:48:04 +00:00
Benjamin Otte d553f6941d Merge branch 'wip/otte/for-main' into 'main'
listview: Measure children only, not self

See merge request GNOME/gtk!5535
2023-02-19 05:33:59 +00:00
Matthias Clasen 2173b7ccaa Merge branch 'matthiasc/for-main' into 'main'
Drop some unnecessary includes

See merge request GNOME/gtk!5536
2023-02-19 05:01:53 +00:00
Matthias Clasen ca6642deed Drop some unnecessary includes 2023-02-18 23:42:04 -05:00
Benjamin Otte be6a4722c0 listview: Measure children only, not self
The previous code would include CSS padding/margin/border in the
measurement and that is wrong.

Until commit a96c75ff02 this was not actually visible, but afterwards
listitems were allocated 16px too wide.

Test included
2023-02-19 05:41:29 +01:00
Matthias Clasen 3b3b63062d Revert "Merge branch 'inscription-single-line' into 'main'"
This reverts commit 7ec90abf24, reversing
changes made to ec49a912aa.

We did not have agreement on this after all.
2023-02-18 19:04:00 -05:00
Matthias Clasen 7ec90abf24 Merge branch 'inscription-single-line' into 'main'
inscription: Add single-line-mode property

Closes #5444

See merge request GNOME/gtk!5504
2023-02-18 23:34:17 +00:00
Matthias Clasen ec49a912aa Merge branch 'wip/carlosg/dnd-x11-keys' into 'main'
gdk/x11: Also grab keyboard during XDnD grabs

Closes #5604

See merge request GNOME/gtk!5533
2023-02-18 22:20:30 +00:00
Carlos Garnacho ae94417f80 gdk/x11: Also grab keyboard during XDnD grabs
The drag source must handle events and messaging, this also
includes keyboard handling for accessibility and cancellation.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5604
2023-02-18 23:02:22 +01:00
Matthias Clasen 24a6803958 Merge branch 'matthiasc/for-main' into 'main'
gtksearchentry: Apply header capitalization to the "Clear entry" tooltip

See merge request GNOME/gtk!5532
2023-02-18 21:10:16 +00:00
Automeris naranja 4073371416 gtksearchentry: Apply header capitalization to the "Clear entry" tooltip
HIG advises to use header capitalization in tooltip texts.

https://developer.gnome.org/hig/patterns/feedback/tooltips.html
2023-02-18 15:53:54 -05:00
Matthias Clasen e5a391c0b9 Merge branch 'matthiasc/for-main' into 'main'
securememory: use function checks

Closes #5070

See merge request GNOME/gtk!5531
2023-02-18 17:21:15 +00:00
Matthias Clasen 6cb612ac15 gtk-demo: Fix build without sincos
We are getting into trouble here if
sincos isn't detected but still present
in headers. Avoid that.

Also fix the other copy of gtkgears.c.
2023-02-18 10:41:02 -05:00
Matthias Clasen 9f64202a60 meson: Consolidate function checks
Put all the function checks in one place.
Remove functions we don't actually use,
and add ones that we have #ifdefs for in
in the code. Also add enough includes to
make these checks actually work.

Fixes: #5070
2023-02-18 09:37:36 -05:00
Matthias Clasen 19c362f638 securememory: use function checks
Checking for getpagesize in meson.build is
useless if we don't check the resulting define
in the code. So do that.
2023-02-18 09:34:50 -05:00
Matthias Clasen e51fa8b65b Merge branch 'matthiasc/for-main' into 'main'
printing: Avoid getrandom

See merge request GNOME/gtk!5530
2023-02-17 22:39:04 +00:00
Matthias Clasen 06d3bbafaf printing: Avoid getrandom
GLib has perfectly serviceable random number
apis, and this breaks the macOs build.
2023-02-17 17:20:44 -05:00
Matthias Clasen da8a1f4683 Merge branch 'scalebutton-active-since-marker' into 'main'
Add missing `Since` marker to `GtkScaleButton:active`

See merge request GNOME/gtk!5529
2023-02-17 19:54:03 +00:00
Sebastian Dröge ad7d9bc409 Add missing Since marker to GtkScaleButton:active 2023-02-17 19:41:55 +02:00
Emmanuele Bassi 94cde8d702 Merge branch 'ebassi/ci-update-v41' into 'main'
ci: Update image

See merge request GNOME/gtk!5528
2023-02-17 12:55:50 +00:00
Emmanuele Bassi ec7b1f7208 ci: Add no-cache option to run-docker.sh script
Use `run-docker.sh build --no-cache` to discard the cached layers if you
need to rebuild the image without modifying the Dockerfile.
2023-02-17 12:24:09 +00:00
Emmanuele Bassi 864fbf89cd ci: Update image
Refresh the Fedora base (still at 37), and add the Python packaging
module for gi-docgen.
2023-02-17 12:24:09 +00:00
Emmanuele Bassi b8e928d703 Merge branch 'matthiasc/for-main' into 'main'
mask: Fix glsl

See merge request GNOME/gtk!5527
2023-02-17 12:23:36 +00:00
Matthias Clasen 0b4d41698b mask: Fix glsl 2023-02-17 06:26:42 -05:00
Matthias Clasen a9eca60b84 Merge branch 'wip/fix-mask-modes-regression' into 'main'
wayland/glcontext: Don't call wl_surface.offset on old objects

See merge request GNOME/gtk!5526
2023-02-17 11:25:06 +00:00
Jonas Ådahl 53c3f497f1 wayland: Clean up some dead code 2023-02-17 12:03:58 +01:00
Jonas Ådahl 3183a21347 wayland/glcontext: Don't call wl_surface.offset on old objects
The availability of wl_surface.offset depends on the compositor, so we
can't call it unconditionally. Add a version check to so we only call
offset if we know we won't raise a protocol error.

Fixes: 0eb791eaaa ("Make mask nodes more versatile")
2023-02-17 12:03:27 +01:00
Matthias Clasen 07f090f947 Merge branch 'test-invisible-text' into 'main'
Add a test for invisible text navigation

See merge request GNOME/gtk!5525
2023-02-17 03:01:42 +00:00
Matthias Clasen ad111087cc Add a test for invisible text navigation
This shows that (at least some) things
work as expected.

See: #1811
2023-02-16 14:27:44 -05:00
Jürgen Benvenuti 5092581be8 Update German translation 2023-02-16 17:18:16 +00:00
Matthias Clasen b261f7f533 Merge branch 'nielsdg/set-action-enabled-doc-ref' into 'main'
widget: mention action_set_enabled in install_action

See merge request GNOME/gtk!5524
2023-02-16 11:24:15 +00:00
Niels De Graef 779f9e5071 widget: mention action_set_enabled in install_action
When looking at `gtk_widget_class_install_action()`, it isn't
immediately obvious how actions can be enabled or disabled. Add a
reference to the `gtk_widget_action_set_enabled()` method so people have
a quick link to that.
2023-02-16 08:47:06 +01:00
Matthias Clasen b07d9d1912 Merge branch 'alatiera/flatpak-ci' into 'main'
ci: Build and publish aarch64 flatpaks

Closes #5594

See merge request GNOME/gtk!5523
2023-02-15 19:54:32 +00:00
Jordan Petridis 7b4692bcb0 ci: Add a simple auto-retry policy 2023-02-15 21:38:24 +02:00
Jordan Petridis f0a2b6f165 ci: Build and publish aarch64 flatpaks
Close GNOME/gtk#5594
2023-02-15 21:19:56 +02:00
Jordan Petridis 2dc6efd9ce ci: Switch from only/except to rules: keyword
It's more flexible and allows us to combine the flatpak jobs
2023-02-15 21:10:40 +02:00
Emmanuele Bassi 1f4adb60bb Merge branch 'fix-annotations' into 'main'
Fix a couple incorrect annotations for optional parameters

See merge request GNOME/gtk!5503
2023-02-15 16:27:11 +00:00
Lukáš Tyrychtr f507dd4962 Allow updating the next accessible sibling for a GtkAccessible 2023-02-15 12:29:16 +01:00
Matthias Clasen 1bdb368e8b Merge branch 'more-mask-modes' into 'main'
rendernodeparser: Fix mask mode handling

See merge request GNOME/gtk!5522
2023-02-15 03:54:01 +00:00
Matthias Clasen aec4bfcf3b gsk: Add a node parser test for mask modes 2023-02-14 21:47:54 -05:00
Matthias Clasen 7e18c2849b gsk: Add a render test for mask modes 2023-02-14 21:47:54 -05:00
Matthias Clasen 351abadee7 Make make not fallback match GL
We were not handling the inverted-luminance
case the same way, and it caused a test to
fail. Yay for tests.
2023-02-14 21:47:54 -05:00
Matthias Clasen 951db28f71 rendernodeparser: Fix mask mode handling
I had forgotten inverted-luminance, and also
to print an error.
2023-02-14 21:01:12 -05:00
Benjamin Otte 40e7a265a7 rendernodeparser: Print an error when failing to parse an enum 2023-02-14 21:01:12 -05:00
Matthias Clasen 9a539cec57 Merge branch 'mask-modes' into 'main'
Make mask nodes more versatile

See merge request GNOME/gtk!5521
2023-02-15 00:57:17 +00:00
Matthias Clasen 724cf6bd70 Merge branch 'wip/cdavis/menubutton-active' into 'main'
menubutton: Add `active` property and getter/setter

See merge request GNOME/gtk!5506
2023-02-15 00:44:17 +00:00
Matthias Clasen 5e4b43dcce Merge branch 'wip/otte/downloader' into 'main'
Add GdkTextureDownloader

See merge request GNOME/gtk!5515
2023-02-15 00:41:26 +00:00
Matthias Clasen fa43282695 Merge branch 'wip/otte/disable-style-check' into 'main'
CI: Don't run style-check-diff by default

See merge request GNOME/gtk!5520
2023-02-15 00:36:53 +00:00
Benjamin Otte 662c251cd0 demo: Spice up the mask demo
Also use all the mask modes, weeeee!
2023-02-14 19:07:01 -05:00
Matthias Clasen 0d97d03fc1 Document mask node parser format 2023-02-14 19:07:01 -05:00
Matthias Clasen cb0aaf0b2c Add more mask node tests 2023-02-14 19:07:01 -05:00
Matthias Clasen 0eb791eaaa Make mask nodes more versatile
Add a GskMaskMode enumeration and implement it
in the GL and cairo renderers.
2023-02-14 19:07:01 -05:00
Benjamin Otte 073c836f96 CI: Don't run style-check-diff by default
We don't use it most of the time and it's also confusing to new contributors who think it's important to fix it.

Keep it for manual runs, so that interested people can just click a button to see the results. It also makes it easy to turn back on later.
2023-02-14 23:53:02 +00:00
Matthias Clasen 0a0a03d913 Merge branch 'fix_4258' into 'main'
Don't tell the screen reader that a button is related to an image which has no useful label

Closes #4258

See merge request GNOME/gtk!4665
2023-02-14 23:50:18 +00:00
Lukáš Tyrychtr d43724f5fc Don't tell the screen reader that a button is related to an image which has no useful label 2023-02-14 23:50:18 +00:00
Matthias Clasen abf3cdb187 Merge branch 'cpdb' into 'main'
Update dependencies for CPDB print backend

Closes #5589

See merge request GNOME/gtk!5518
2023-02-14 23:48:43 +00:00
Benjamin Otte cca5de3c7f memorytexture: Export less private API
It's not needed anymore with GdkTextureDownloader now.
2023-02-15 00:39:18 +01:00
Benjamin Otte 774696011d glrenderer: Use GdkTexureDownloader 2023-02-15 00:39:18 +01:00
Benjamin Otte c9f54ca371 texture: Export gdk_texture_get_format()
The API docs outline why quite well.

This should make it possible to do saving of textures to image files
without any private API with the same featureset that GTK uses.

Also remove the gsktextureprivate.h include where
gdk_texture_get_format() was the only reason for it.
2023-02-15 00:39:18 +01:00
Benjamin Otte ce0123ea58 docs: Link from gdk_texture_download() to GdkTextureDownloader 2023-02-15 00:39:18 +01:00
Benjamin Otte b30af72125 tiff: Use GdkTexureDownloader when saving 2023-02-15 00:39:18 +01:00
Benjamin Otte eb45b8083a png: Use GdkTexureDownloader when saving 2023-02-15 00:39:18 +01:00
Benjamin Otte f05d801e28 jpeg: Use GdkTexureDownloader when saving 2023-02-15 00:39:18 +01:00
Benjamin Otte 4afec951c7 pixbuf: Use GdkTextureDownloader when downloading pixbufs 2023-02-15 00:39:18 +01:00
Benjamin Otte 51ed1442a2 gdk: Add GdkTextureDownloader
It's the new object that allows more control about accessing texture
data.
2023-02-15 00:39:18 +01:00
Benjamin Otte 01ff6c1c22 memorytexture: Use right size for GBytes
The GBytes were created with the wrong size.

Nobody seems to have looked at it.
2023-02-14 23:42:17 +01:00
Fran Dieguez 73f3ea9511 Update Galician translation 2023-02-14 20:04:07 +00:00
Emmanuele Bassi f1311dc053 Merge branch 'gsk-render-node-type-abi-breakage' into 'main'
gsk: Move new 4.10 `GskRenderNodeType`s to the end instead of inserting them in the middle

See merge request GNOME/gtk!5519
2023-02-14 19:28:36 +00:00
Sebastian Dröge a252aadadf gsk: Move new 4.10 GskRenderNodeTypes to the end instead of inserting them in the middle 2023-02-14 21:04:41 +02:00
tinytrebuchet 300670dad4 Update dependencies for CPDB print backend
Require cpdb-frontend 2.x for building CPDB print backend.
2023-02-14 23:39:13 +05:30
Matthias Clasen 44c95d3c96 Merge branch 'kjellahl/clang' into 'main'
gskglrenderjob: Fix compilation with clang

See merge request GNOME/gtk!5516
2023-02-14 14:18:29 +00:00
Lukáš Tyrychtr d566771262 Preserve the correct a11y tree in GtkStack
Now, when we can, ensure that the GtkStackPage is the parent of its widget.
2023-02-14 14:44:20 +01:00
Lukáš Tyrychtr 5f72b51105 Allow setting accessible parent and sibling explicitly
This allows to maintain the correct a11y hierarchy even when it contains
objects which are only GtkAccessibles.
2023-02-14 14:43:57 +01:00
Hugo Carvalho e0afd22c84 Update Portuguese translation 2023-02-14 11:39:50 +00:00
Kjell Ahlstedt 869ab1cd1b gskglrenderjob: Fix compilation with clang 2023-02-14 10:29:25 +01:00
Matthias Clasen 730593fab5 Merge branch 'texttag_textview_documentation' into 'main'
Update TextTag and TextView indent Documentation

See merge request GNOME/gtk!5507
2023-02-14 00:08:39 +00:00
Matthias Clasen d0798c9526 Merge branch 'matthiasc/for-main' into 'main'
gtk-demo: Fix hotspot handling in dnd

See merge request GNOME/gtk!5513
2023-02-14 00:03:55 +00:00
Matthias Clasen e6dfb8732a gtk-demo: Fix hotspot handling in dnd
We were not remembering the pointer coordinates.
2023-02-13 18:39:45 -05:00
Aurimas Černius 453ef8c7e1 Update Lithuanian translation 2023-02-13 21:07:37 +00:00
Sabri Ünal 819595d1a9 Update Turkish translation 2023-02-13 18:08:05 +00:00
Andre Klapper 306276b689 Fix invalid markup in Belarusian UI translation 2023-02-13 18:32:03 +01:00
Emmanuele Bassi bb15a7ef46 Merge branch 'faq-updates' into 'main'
faq: Some updates

See merge request GNOME/gtk!5512
2023-02-13 14:50:35 +00:00
Matthias Clasen cd0fe13dae faq: Add a question about parallel UIs 2023-02-13 08:54:36 -05:00
Matthias Clasen 3dcea74e85 faq: Don't number questions
The numbering makes it unnecessarily hard to add
and remove questions, and does not really seem
necessary. Just use bullets.
2023-02-13 08:52:04 -05:00
Matthias Clasen 537c2f6c7a faq: Some updates
Miscellaneous tweaks and changes, after reading
the whole thing.
2023-02-13 08:52:03 -05:00
Matthias Clasen 72379f64e9 Merge branch 'fix-font-chooser-filter' into 'main'
Fix an assertion in GtkFontChooserWidget when setting a filter.

See merge request GNOME/gtk!5511
2023-02-13 12:41:48 +00:00
Akira TAGOH 4532c3020b Fix an assertion in GtkFontChooserWidget when setting a filter. 2023-02-13 12:49:02 +09:00
Kukuh Syafaat b60bd8a73d Update Indonesian translation 2023-02-13 02:47:33 +00:00
Matthias Clasen 37f12e4bf9 Post-release version bump 2023-02-12 21:04:15 -05:00
Matthias Clasen 8967b2da01 4.9.4 2023-02-12 20:36:13 -05:00
Matthias Clasen dfb019509d docs: Document new build options 2023-02-12 20:36:13 -05:00
Matthias Clasen a770b429ec Merge branch 'fix-gst-gl-use' into 'main'
gstreamer: Fix gl context use

Closes #5586

See merge request GNOME/gtk!5508
2023-02-13 00:41:51 +00:00
Matthias Clasen 7430bd7780 gstreamer: Fix gl context use
We were not activating the context in which
we want to wait for the fence. This caused
a stream of critical warnings.

Fixes: #5586
2023-02-12 19:29:04 -05:00
Jacob Mealey 272a40a01a Update TextTag and TextView indent Documentation
Change the documentation for both to be in line with Pango documentation
specifically regarding hanging indentation.
2023-02-12 23:12:51 +00:00
Matthias Clasen f121f607ae Merge branch 'search_entry_placeholder' into 'main'
gtksearchentry: Add getter/setter for placeholder text

See merge request GNOME/gtk!4312
2023-02-12 22:06:36 +00:00
Christopher Davis ff45145eac menubutton: Add active property and getter/setter
GtkMenuButton currently does not provide a way to tell
if it's open programmatically. The existing methods,
`popup()` and `popdown()`, do not expose any state
to callers. If someone wanted to know whether or not
a menubutton was open, they needed the popover. Given
that GtkMenuButton can manage the popovers itself,
that's not always an option for app developers.

This commit adds the `active` property and associated
methods, where `gtk_menu_button_set_active ()` replaces
both `gtk_menu_popup ()` and `gtk_menu_popdown ()`.
This addition also mirrors changes in other places,
Such as `GtkWidget:visible` vs `show()`/`hide()`.
2023-02-12 16:47:59 -05:00
Matthias Clasen 83c5f5ff0f Apply 4 suggestion(s) to 2 file(s) 2023-02-13 06:47:06 +09:00
Alexandros Theodotou 87d21dc5c9 gtksearchentry: Add getter/setter for placeholder text 2023-02-13 06:46:31 +09:00
Matthias Clasen cef7e6b741 Merge branch 'mark-deprecations' into 'main'
docs: Mark various deprecations

See merge request GNOME/gtk!5502
2023-02-12 21:44:00 +00:00
Yuri Chornoivan 84b5e94ffd Update Ukrainian translation 2023-02-12 17:56:09 +00:00
Matthias Clasen 679d510059 Merge branch 'template-child-dispose-order' into 'main'
gtk: Set widget template children to NULL before destroy unref

See merge request GNOME/gtk!4611
2023-02-12 16:36:52 +00:00
Marco Melorio d2755e0385 inscription: Add single-line-mode property
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/5444.
2023-02-12 17:35:56 +01:00
Matthias Clasen 0c2b437643 Merge branch 'main' into 'main'
Add note about widgets implementing the interface adding the `horizontal`/`vertical` CSS classes

See merge request GNOME/gtk!5391
2023-02-12 16:28:12 +00:00
madmurphy 0764cf0c9c Add note about widgets implementing the interface adding the horizontal/vertical CSS classes 2023-02-12 16:28:12 +00:00
Marco Melorio 2504215459 docs: Mark everything in GtkVolumeButton as deprecated 2023-02-12 17:20:11 +01:00
Marco Melorio d45db3a961 docs: Mark everything in GtkStatusBar as deprecated 2023-02-12 17:20:11 +01:00
Matthias Clasen 557a1ed879 Merge branch 'no-more-lpr' into 'main'
printing: Drop the lpr backend

See merge request GNOME/gtk!5500
2023-02-12 15:29:27 +00:00
Matthias Clasen c28b6a3ee6 Merge branch 'texture-atlas-crash' into 'main'
gl: Avoid a crash in the texture library

Closes #5175

See merge request GNOME/gtk!5501
2023-02-12 15:28:06 +00:00
Marco Melorio b34c139028 docs: Mark everything in GtkLockButton as deprecated 2023-02-12 16:12:17 +01:00
Matthias Clasen dd22e2aea9 printing: Drop the lpr backend
We want to consolidate and get to fewer print
backends (ideally only one), and the future is cpdb.
2023-02-12 10:10:06 -05:00
Marco Melorio 6e6f2f652c docs: Mark everything in GtkCellAreaContext as deprecated 2023-02-12 16:09:39 +01:00
Marco Melorio 3aac70f245 docs: Mark everything in GtkAssistant as deprecated 2023-02-12 16:09:25 +01:00
Matthias Clasen 7f3ea15d80 Update POTFILES.in 2023-02-12 10:09:22 -05:00
Matthias Clasen d3dfdd214f gl: Avoid a crash in the texture library
entry->texture can be NULL, so check before
using it.

Fixes: #5175
2023-02-12 10:01:11 -05:00
Matthias Clasen b6c3cf4eee gl: Maintain state when truncating
When we truncate the command queue because it
is too big, we were messing up our state accounting
and running into criticals as a consequence.

This can be reproduced by opening a well-populated
fishbowl demo in the inspectors recorder.

Fixes: #5188
2023-02-12 09:56:32 -05:00
Matthias Clasen 157ef1d395 Deprecate GtkVolumeButton
Too specialized.
2023-02-12 09:48:49 -05:00
Matthias Clasen d0263f563a NEWS: Updates 2023-02-12 09:21:38 -05:00
Matthias Clasen 83b48bb25f Merge branch 'mask-nodes-rebased' into 'main'
gsk: Introduce mask nodes

See merge request GNOME/gtk!5497
2023-02-12 14:11:47 +00:00
Matthias Clasen 81e9eca256 Merge branch 'nacho/scalebutton-active' into 'main'
gtkscalebutton: add active property

See merge request GNOME/gtk!5492
2023-02-12 14:01:27 +00:00
Ignacio Casal Quinteiro 44c2d585b8 gtkscalebutton: add active property 2023-02-12 14:01:26 +00:00
Matthias Clasen 348803af7d Add a mask node demo 2023-02-12 08:35:25 -05:00
Matthias Clasen c8bfea7aa1 Add a test for mask nodes 2023-02-12 08:35:25 -05:00
Matthias Clasen 8f47e885f0 Add gtk_snapshot_push_mask 2023-02-12 08:35:25 -05:00
Matthias Clasen a9f50f1f7a gl: Support mask nodes
Add a shader for masking.
2023-02-12 08:35:25 -05:00
Matthias Clasen 0d58e5365d gsk: Introduce mask nodes
Add GskMaskNode, and support it in the render node
parser, in the inspector and in GtkSnapshot.

The rendering is just fallback for now.

Based on old work by Timm Bäder.
2023-02-12 08:35:25 -05:00
Ekaterine Papava d00d4c4475 Update Georgian translation 2023-02-12 12:30:05 +00:00
Piotr Drąg a6e7c38236 Update POTFILES.in 2023-02-12 13:20:48 +01:00
Matthias Clasen eee7e59265 Merge branch 'fix_editable_label' into 'main'
Remove timeout when disposing GtkEditableLabel

Closes #5584

See merge request GNOME/gtk!5499
2023-02-12 02:55:45 +00:00
Matthias Clasen c2cb1ffe9e Merge branch 'wip/wl-dispatch-helper' into 'main'
wayland: Add event queue dispatch helper

See merge request GNOME/gtk!5498
2023-02-12 01:01:29 +00:00
Alexandros Theodotou d918a77d34 Remove timeout when disposing GtkEditableLabel
Fixes: #5584
2023-02-12 09:45:07 +09:00
Matthias Clasen 2285ef3824 Merge branch 'scaled-textures' into 'main'
Scaled textures

See merge request GNOME/gtk!5488
2023-02-11 22:16:43 +00:00
Jonas Ådahl b2a2bf819d wayland/launch-context: Use dispatch helper
Otherwise we risk a busy loop if e.g. the pipe broke.
2023-02-11 23:14:53 +01:00
Jonas Ådahl dd9433b50e wayland: Add event queue dispatch helper
Dispatch failing should always fatal; use a helper to centralize the
error handling everywhere.
2023-02-11 23:13:39 +01:00
Matthias Clasen 67c53e46f9 Add gtk_snapshot_append_scaled_texture
This is the snapshot api corresponding to
gsk_texture_scale_node_new.
2023-02-11 15:09:38 -05:00
Matthias Clasen 238e7ec351 Add a test for scaled textures 2023-02-11 15:09:38 -05:00
Matthias Clasen d916659781 gl: Handle GskTextureScaleNodes 2023-02-11 15:09:38 -05:00
Matthias Clasen 82c02574f1 gl: Make texture slicing more flexible
Allow to specify the filtering to use for the slices,
and allow forcing the number of slices. This will be
used in the next commit.
2023-02-11 15:09:38 -05:00
Matthias Clasen 26e6d2106b gl: Pass filters down from visit_texture_node
For now, we always pass GL_LINEAR.
2023-02-11 15:09:38 -05:00
Matthias Clasen 625ffa2d96 gtk-demo: Add filtering to the zoom demo 2023-02-11 15:09:38 -05:00
Matthias Clasen dd3eedd510 gtk-demo: Rewrite the zoom demo slightly
Use a texture directly instead of a paintable.
This will be used in the following commit to
introduce filters.
2023-02-11 15:09:38 -05:00
Matthias Clasen dc3a72cf38 nodeparser: Support texture-scale nodes 2023-02-11 15:09:38 -05:00
Matthias Clasen b937c19dd4 gsk: Introduce GskTextureScaleNode 2023-02-11 15:09:38 -05:00
Matthias Clasen 04c3af537c Merge branch 'wip/handle-more-wl-dispatch-failures' into 'main'
wayland: Handle dispatch failing in a couple of more places

See merge request GNOME/gtk!5495
2023-02-11 19:56:45 +00:00
Matthias Clasen cc43f5dcde gsk: Generate mipmaps when requested
If the min_filter requires it, call
glGenerateMipmap for our textures.
2023-02-11 09:29:03 -05:00
Matthias Clasen c74d7afce5 gsk: Don't limit filters too much
GL does not allow mipmapping for mag filters,
but it doesn't have a problem with it for min
filters.
2023-02-11 09:29:03 -05:00
Matthias Clasen 52e18eb7fb Merge branch 'matthiasc/for-main' into 'main'
gdkevents.c: Fix up folding

See merge request GNOME/gtk!5496
2023-02-11 14:18:42 +00:00
Matthias Clasen c0b5b4b8c1 gskrendernodeimpl.c: Use folding
Instead of homegrown markup.
2023-02-11 09:00:07 -05:00
Matthias Clasen d497e721c9 gdkevents.c: Fix up folding
The modeline was lost at some point,
and superfluous spacing inserted.
2023-02-11 08:59:51 -05:00
Jonas Ådahl a7fb9a6865 wayland: Handle dispatch failing in a couple of more places
Without doing this, we'll end up with risking GTK processes sitting
eating 100% CPU instead of just exit(1):ing.
2023-02-11 11:42:21 +01:00
Marek Kašík 2365d9be18 Merge branch 'cpdb' into 'main'
New CPDB print backend for GTK Print Dialog

See merge request GNOME/gtk!4930
2023-02-10 23:10:20 +00:00
tinytrebuchet 41b60bbd6c New CPDB print backend for GTK Print Dialog
The Common Print Dialog Backends (CPDB) concept has GUI-toolkit-independent
backends for each print technology (CUPS, Print to File, cloud printing
services, ...) and each print dialog (GTK, Qt, Chromium, ...) is supposed
to use this backend, so that changes in print technologies can be centrally
and quickly covered by changing the backends and everything new gets available
in all print dialogs.

This commit provides a GTK print dialog backend to add support for the CPDB
concept. It communicates with all installed CPDB backends and so gives support
for all these print technologies to the GTK print dialog.

To make use of CPDB the GTK print dialog is supposed to be installed with this
backend and the 'Print To File' backend, and not any others to prevent printer
duplication.
2023-02-11 01:13:48 +05:30
Emin Tufan Çetin f0d3d011ea Update Turkish translation 2023-02-10 05:57:42 +00:00
Cameron White 0cb3555a65 Fix a couple incorrect annotations for optional parameters
The 'optional' annotation should be used in these cases rather than 'nullable'.
NULL can provided to ignore these output parameters, but the function is
not setting the output parameter to NULL.
2023-02-09 22:46:43 -05:00
Matthias Clasen 48e141a42c Merge branch 'avoid-criticals-tracker' into 'main'
searchengine: Avoid criticals when tracker init failed

See merge request GNOME/gtk!5489
2023-02-09 19:43:31 +00:00
Gaël Bonithon 6215b38e64 searchengine: Emit a simple warning when tracker init failed
Failure is allowed by nature of GInitable, and this avoids unnecessary
crashing of programs running with G_DEBUG=fatal-criticals.
2023-02-09 19:46:30 +01:00
Gaël Bonithon 41490f9624 searchengine: Add missing sanity check 2023-02-09 19:25:04 +01:00
Vasil Pupkin 45e6e9a7d1 Update Belarusian translation 2023-02-08 21:48:28 +00:00
Matthias Clasen 9991d6834d Merge branch 'stop-testing-pixbuf-formats' into 'main'
Drop pixbuf format tests

See merge request GNOME/gtk!5486
2023-02-07 18:48:39 +00:00
Matthias Clasen ddf8c4dd1a Drop pixbuf format tests
We have our own loaders for the formats we
always want to support, so we don't need to
check for what gdk-pixbuf supports.
2023-02-07 07:54:22 -05:00
Matthias Clasen 970072ef65 Merge branch 'file-dialog-fixes' into 'main'
filedialog: Robustness fixes

See merge request GNOME/gtk!5485
2023-02-07 12:42:09 +00:00
Matthias Clasen f8321029fc filedialog: Robustness fixes
This code was not working well.
2023-02-06 23:16:17 +01:00
Matthias Clasen f83cab01ec filechooserportal: Fix an oversight 2023-02-06 20:28:35 +01:00
Sabri Ünal 8a74770ec1 Update Turkish translation 2023-02-06 09:19:35 +00:00
Matthias Clasen 39c503c108 Merge branch 'matthiasc/for-main' into 'main'
CONTRIBUTING: Updates

See merge request GNOME/gtk!5483
2023-02-06 06:53:14 +00:00
Matthias Clasen fc32b8242b CONTRIBUTING: Updates
Mention matrix instead of irc, and ask
for display/graphics as essential info
in issues.
2023-02-06 07:35:11 +01:00
Piotr Drąg 7c2b4eb0e7 Update Polish translation 2023-02-05 15:22:00 +01:00
Matthias Clasen d8b0aea6b7 Merge branch 'rename-openuri-portal' into 'main'
Use a Gtk prefix for dbus-generated code

Closes #5572

See merge request GNOME/gtk!5482
2023-02-05 08:27:09 +00:00
Matthias Clasen 190d8ef8ff Use a Gtk prefix for dbus-generated code
Copying this file from GIO without renaming it
was not the greatest idea in retrospect.

Fixes: #5572
2023-02-05 09:09:22 +01:00
Cheng-Chia Tseng 15e9194b59 Update Chinese (Taiwan) translation 2023-02-04 16:28:15 +00:00
Matthias Clasen 0257da6cc0 Post-release version bump 2023-02-04 17:01:51 +01:00
Jason Francis 3fc7c97979 gtk: Set widget template children to NULL before destroy unref 2022-05-14 10:13:39 -04:00
196 changed files with 18819 additions and 16571 deletions
+73 -56
View File
@@ -26,25 +26,31 @@ variables:
BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true"
FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled -Ddemos=false -Dbuild-examples=false -Dbuild-tests=false -Dbuild-testsuite=true"
MESON_TEST_TIMEOUT_MULTIPLIER: 3
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v40"
FLATPAK_IMAGE: "quay.io/gnome_infrastructure/gnome-runtime-images:gnome-master"
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v41"
.only-default:
only:
- branches
except:
- tags
workflow:
rules:
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH
default:
retry:
max: 2
when:
- 'runner_system_failure'
- 'stuck_or_timeout_failure'
- 'scheduler_failure'
- 'api_failure'
interruptible: true
style-check-diff:
extends: .only-default
image: $FEDORA_IMAGE
stage: check
allow_failure: true
when: manual
script:
- .gitlab-ci/run-style-check-diff.sh
.build-fedora-default:
extends: .only-default
image: $FEDORA_IMAGE
artifacts:
when: always
@@ -160,7 +166,6 @@ fedora-mingw64:
- ninja -C _build
.mingw-defaults:
extends: .only-default
stage: build
tags:
- win32-ps
@@ -192,9 +197,8 @@ msys2-mingw64:
macos:
# Sadly, this fails regularly, and its failure is never enlightening
allow_failure: true
extends: .only-default
only:
- branches@GNOME/gtk
rules:
- if: $CI_PROJECT_NAMESPACE == "GNOME"
stage: build
tags:
- macos
@@ -227,10 +231,9 @@ macos:
- "${CI_PROJECT_DIR}/_build/meson-logs"
vs2017-x64:
extends: .only-default
# TODO: Uncomment this when ready to merge.
#only:
# - branches@GNOME/gtk
# rules:
# - if: $CI_PROJECT_NAMESPACE == "GNOME"
stage: build
tags:
- win32-ps
@@ -243,7 +246,7 @@ vs2017-x64:
- "${CI_PROJECT_DIR}/_build/meson-logs"
.flatpak-defaults:
image: $FLATPAK_IMAGE
image: "quay.io/gnome_infrastructure/gnome-runtime-images:gnome-master"
stage: flatpak
allow_failure: true
tags:
@@ -253,65 +256,67 @@ vs2017-x64:
- "${APPID}-dev.flatpak"
- 'repo.tar'
expire_in: 1 day
rules:
# Only build Flatpak bundles automatically on main
- if: $CI_COMMIT_BRANCH == "main"
- if: $CI_COMMIT_BRANCH != "main"
when: "manual"
script:
- bash -x ./.gitlab-ci/flatpak-build.sh "${APPID}"
# Manual jobs, for branches and MRs
.flatpak-manual:
extends: .flatpak-defaults
when: manual
# Only build Flatpak bundles automatically on main
.flatpak-main:
extends: .flatpak-defaults
only:
- main
flatpak-manual:demo:
extends: .flatpak-manual
flatpak:demo:
extends: '.flatpak-defaults'
needs: []
variables:
APPID: org.gtk.Demo4
flatpak-main:demo:
extends: .flatpak-main
flatpak:demo:aarch64:
extends: '.flatpak-defaults'
needs: []
tags:
- flatpak-aarch64
variables:
APPID: org.gtk.Demo4
flatpak-manual:widget-factory:
extends: .flatpak-manual
flatpak:widget-factory:
extends: '.flatpak-defaults'
needs: []
variables:
APPID: org.gtk.WidgetFactory4
flatpak-main:widget-factory:
extends: .flatpak-main
flatpak:widget-factory:aarch64:
extends: '.flatpak-defaults'
needs: []
tags:
- flatpak-aarch64
variables:
APPID: org.gtk.WidgetFactory4
flatpak-manual:icon-browser:
extends: .flatpak-manual
flatpak:icon-browser:
extends: '.flatpak-defaults'
needs: []
variables:
APPID: org.gtk.IconBrowser4
flatpak-main:icon-browser:
extends: .flatpak-main
flatpak:icon-browser:aarch64:
extends: '.flatpak-defaults'
needs: []
tags:
- flatpak-aarch64
variables:
APPID: org.gtk.IconBrowser4
flatpak-manual:node-editor:
extends: .flatpak-manual
flatpak:node-editor:
extends: '.flatpak-defaults'
needs: []
variables:
APPID: org.gtk.gtk4.NodeEditor
flatpak-main:node-editor:
extends: .flatpak-main
flatpak:node-editor:aarch64:
extends: '.flatpak-defaults'
needs: []
tags:
- flatpak-aarch64
variables:
APPID: org.gtk.gtk4.NodeEditor
@@ -320,23 +325,35 @@ flatpak-main:node-editor:
# https://gitlab.gnome.org/GNOME/Initiatives/-/wikis/DevOps-with-Flatpak
nightly demo:
extends: '.publish_nightly'
dependencies: ['flatpak-main:demo']
needs: ['flatpak-main:demo']
needs: ['flatpak:demo']
nightly demo aarch64:
extends: '.publish_nightly'
needs: ['flatpak:demo:aarch64']
nightly factory:
extends: '.publish_nightly'
dependencies: ['flatpak-main:widget-factory']
needs: ['flatpak-main:widget-factory']
needs: ['flatpak:widget-factory']
nightly factory aarch64:
extends: '.publish_nightly'
needs: ['flatpak:widget-factory:aarch64']
nightly icon-browser:
extends: '.publish_nightly'
dependencies: ['flatpak-main:icon-browser']
needs: ['flatpak-main:icon-browser']
needs: ['flatpak:icon-browser']
nightly icon-browser aarch64:
extends: '.publish_nightly'
needs: ['flatpak:icon-browser:aarch64']
nightly node-editor:
extends: '.publish_nightly'
dependencies: ['flatpak-main:node-editor']
needs: ['flatpak-main:node-editor']
needs: ['flatpak:node-editor']
nightly node-editor aarch64:
extends: '.publish_nightly'
needs: ['flatpak:node-editor:aarch64']
static-scan:
image: $FEDORA_IMAGE
@@ -419,9 +436,9 @@ reference:
publish-docs:
image: fedora:latest
stage: publish
interruptible: false
needs: ['reference']
script:
- "curl -X POST -F token=${PAGES_TRIGGER_TOKEN} -F ref=docs-gtk-org https://gitlab.gnome.org/api/v4/projects/665/trigger/pipeline"
only:
refs:
- main
rules:
- if: $CI_COMMIT_REF_NAME == "main"
+1
View File
@@ -82,6 +82,7 @@ RUN dnf -y install \
python3-gobject \
python3-jinja2 \
python3-markdown \
python3-packaging \
python3-pip \
python3-pygments \
python3-typogrify \
+17 -5
View File
@@ -23,6 +23,7 @@ push=0
list=0
print_help=0
no_login=0
no_cache=0
while (($# > 0)); do
case "${1%%=*}" in
@@ -34,6 +35,7 @@ while (($# > 0)); do
--base|-b) read_arg base "$@" || shift;;
--version|-v) read_arg base_version "$@" || shift;;
--no-login) no_login=1;;
--no-cache) no_cache=1;;
*) echo -e "\e[1;31mERROR\e[0m: Unknown option '$1'"; exit 1;;
esac
shift
@@ -103,11 +105,21 @@ TAG="${REGISTRY}/gnome/gtk/${base}:${base_version}"
if [ $build == 1 ]; then
echo -e "\e[1;32mBUILDING\e[0m: ${base} as ${TAG}"
${CMD} build \
${format} \
--build-arg HOST_USER_ID="$UID" \
--tag "${TAG}" \
--file "${base}.Dockerfile" .
if [ $no_cache == 0 ]; then
${CMD} build \
${format} \
--build-arg HOST_USER_ID="$UID" \
--tag "${TAG}" \
--file "${base}.Dockerfile" .
else
${CMD} build \
${format} \
--no-cache \
--build-arg HOST_USER_ID="$UID" \
--tag "${TAG}" \
--file "${base}.Dockerfile" .
fi
exit $?
fi
+2 -1
View File
@@ -21,7 +21,7 @@ many things that we value:
Please, do not use the issue tracker for support questions. If you have
questions on how to use GTK effectively, you can use:
- the `#gtk` IRC channel on irc.gnome.org
- the `gtk` [room on matrix](https://matrix.to/#/#gtk:gnome.org)
- the [gtk tag on the GNOME Discourse instance](https://discourse.gnome.org/tag/gtk)
You can also look at the GTK tag on [Stack
@@ -44,6 +44,7 @@ If you're reporting a bug make sure to list:
0. which version of GTK are you using?
0. which operating system are you using?
0. what display and graphics driver are you using?
0. the necessary steps to reproduce the issue
0. the expected outcome
0. a description of the behavior; screenshots are also welcome
+40
View File
@@ -1,3 +1,43 @@
Overview of Changes in 4.9.5, xx-xx-xxxx
========================================
Overview of Changes in 4.9.4, 12-02-2023
========================================
* Printing:
- Add a CPDB backend
- Drop the lpr backend
* GtkFileDialog:
- Robustness fixes
* GtkScaleButton:
- Add an 'active' property
* GtkSearchEntry:
- Add placeholder text
* Fix conflicting type names between gtk and gio
* Gsk:
- Settable filtering for scaled textures
- Add mask nodes
- Some robustness and crash fixes
* Wayland:
- Handle dispatch failing in more places
* Deprecations:
- GtkVolumeButton
* Translation updates:
Belarusian
Chinese (Taiwan)
Georgian
Turkish
Ukrainian
Overview of Changes in 4.9.3, 04-02-2023
========================================
+7
View File
@@ -215,6 +215,12 @@
<file>demo3widget.h</file>
<file>demo3widget.ui</file>
</gresource>
<gresource prefix="/mask">
<file>demo4widget.c</file>
<file>demo4widget.h</file>
<file>hsla.h</file>
<file>hsla.c</file>
</gresource>
<gresource prefix="/paintable_svg">
<file>svgpaintable.h</file>
<file>svgpaintable.c</file>
@@ -311,6 +317,7 @@
<file>list_store.c</file>
<file>main.c</file>
<file>markup.c</file>
<file>mask.c</file>
<file>menu.c</file>
<file>overlay.c</file>
<file>overlay_decorative.c</file>
+43 -24
View File
@@ -3,7 +3,8 @@
enum
{
PROP_PAINTABLE = 1,
PROP_TEXTURE = 1,
PROP_FILTER,
PROP_SCALE
};
@@ -11,8 +12,9 @@ struct _Demo3Widget
{
GtkWidget parent_instance;
GdkPaintable *paintable;
GdkTexture *texture;
float scale;
GskScalingFilter filter;
GtkWidget *menu;
};
@@ -28,6 +30,7 @@ static void
demo3_widget_init (Demo3Widget *self)
{
self->scale = 1.f;
self->filter = GSK_SCALING_FILTER_LINEAR;
gtk_widget_init_template (GTK_WIDGET (self));
}
@@ -36,7 +39,7 @@ demo3_widget_dispose (GObject *object)
{
Demo3Widget *self = DEMO3_WIDGET (object);
g_clear_object (&self->paintable);
g_clear_object (&self->texture);
gtk_widget_dispose_template (GTK_WIDGET (self), DEMO3_TYPE_WIDGET);
@@ -50,12 +53,13 @@ demo3_widget_snapshot (GtkWidget *widget,
Demo3Widget *self = DEMO3_WIDGET (widget);
int x, y, width, height;
double w, h;
GskRenderNode *node;
width = gtk_widget_get_width (widget);
height = gtk_widget_get_height (widget);
w = self->scale * gdk_paintable_get_intrinsic_width (self->paintable);
h = self->scale * gdk_paintable_get_intrinsic_height (self->paintable);
w = self->scale * gdk_texture_get_width (self->texture);
h = self->scale * gdk_texture_get_height (self->texture);
x = MAX (0, (width - ceil (w)) / 2);
y = MAX (0, (height - ceil (h)) / 2);
@@ -63,7 +67,11 @@ demo3_widget_snapshot (GtkWidget *widget,
gtk_snapshot_push_clip (snapshot, &GRAPHENE_RECT_INIT (0, 0, width, height));
gtk_snapshot_save (snapshot);
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (x, y));
gdk_paintable_snapshot (self->paintable, snapshot, w, h);
node = gsk_texture_scale_node_new (self->texture,
&GRAPHENE_RECT_INIT (0, 0, w, h),
self->filter);
gtk_snapshot_append_node (snapshot, node);
gsk_render_node_unref (node);
gtk_snapshot_restore (snapshot);
gtk_snapshot_pop (snapshot);
}
@@ -81,9 +89,9 @@ demo3_widget_measure (GtkWidget *widget,
int size;
if (orientation == GTK_ORIENTATION_HORIZONTAL)
size = gdk_paintable_get_intrinsic_width (self->paintable);
size = gdk_texture_get_width (self->texture);
else
size = gdk_paintable_get_intrinsic_height (self->paintable);
size = gdk_texture_get_height (self->texture);
*minimum = *natural = self->scale * size;
}
@@ -113,9 +121,9 @@ demo3_widget_set_property (GObject *object,
switch (prop_id)
{
case PROP_PAINTABLE:
g_clear_object (&self->paintable);
self->paintable = g_value_dup_object (value);
case PROP_TEXTURE:
g_clear_object (&self->texture);
self->texture = g_value_dup_object (value);
gtk_widget_queue_resize (GTK_WIDGET (object));
break;
@@ -124,6 +132,11 @@ demo3_widget_set_property (GObject *object,
gtk_widget_queue_resize (GTK_WIDGET (object));
break;
case PROP_FILTER:
self->filter = g_value_get_enum (value);
gtk_widget_queue_resize (GTK_WIDGET (object));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -140,14 +153,18 @@ demo3_widget_get_property (GObject *object,
switch (prop_id)
{
case PROP_PAINTABLE:
g_value_set_object (value, self->paintable);
case PROP_TEXTURE:
g_value_set_object (value, self->texture);
break;
case PROP_SCALE:
g_value_set_float (value, self->scale);
break;
case PROP_FILTER:
g_value_set_enum (value, self->filter);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -205,16 +222,21 @@ demo3_widget_class_init (Demo3WidgetClass *class)
widget_class->measure = demo3_widget_measure;
widget_class->size_allocate = demo3_widget_size_allocate;
g_object_class_install_property (object_class, PROP_PAINTABLE,
g_param_spec_object ("paintable", "Paintable", "Paintable",
GDK_TYPE_PAINTABLE,
g_object_class_install_property (object_class, PROP_TEXTURE,
g_param_spec_object ("texture", NULL, NULL,
GDK_TYPE_TEXTURE,
G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_SCALE,
g_param_spec_float ("scale", "Scale", "Scale",
g_param_spec_float ("scale", NULL, NULL,
0.0, 10.0, 1.0,
G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_FILTER,
g_param_spec_enum ("filter", NULL, NULL,
GSK_TYPE_SCALING_FILTER, GSK_SCALING_FILTER_LINEAR,
G_PARAM_READWRITE));
/* These are the actions that we are using in the menu */
gtk_widget_class_install_action (widget_class, "zoom.in", NULL, zoom_cb);
gtk_widget_class_install_action (widget_class, "zoom.out", NULL, zoom_cb);
@@ -229,16 +251,13 @@ GtkWidget *
demo3_widget_new (const char *resource)
{
Demo3Widget *self;
GdkPixbuf *pixbuf;
GdkPaintable *paintable;
GdkTexture *texture;
pixbuf = gdk_pixbuf_new_from_resource (resource, NULL);
paintable = GDK_PAINTABLE (gdk_texture_new_for_pixbuf (pixbuf));
texture = gdk_texture_new_from_resource (resource);
self = g_object_new (DEMO3_TYPE_WIDGET, "paintable", paintable, NULL);
self = g_object_new (DEMO3_TYPE_WIDGET, "texture", texture, NULL);
g_object_unref (pixbuf);
g_object_unref (paintable);
g_object_unref (texture);
return GTK_WIDGET (self);
}
+226
View File
@@ -0,0 +1,226 @@
#include <math.h>
#include "demo4widget.h"
#include "hsla.h"
enum
{
PROP_0,
PROP_PROGRESS,
};
struct _Demo4Widget
{
GtkWidget parent_instance;
PangoLayout *layout;
GskColorStop stops[8];
gsize n_stops;
double progress;
guint tick;
};
struct _Demo4WidgetClass
{
GtkWidgetClass parent_class;
};
G_DEFINE_TYPE (Demo4Widget, demo4_widget, GTK_TYPE_WIDGET)
static void
rotate_color (GdkRGBA *rgba)
{
GdkHSLA hsla;
_gdk_hsla_init_from_rgba (&hsla, rgba);
hsla.hue -= 1;
_gdk_rgba_init_from_hsla (rgba, &hsla);
}
static gboolean
rotate_colors (GtkWidget *widget,
GdkFrameClock *clock,
gpointer user_data)
{
Demo4Widget *self = DEMO4_WIDGET (widget);
for (unsigned int i = 0; i < self->n_stops; i++)
rotate_color (&self->stops[i].color);
gtk_widget_queue_draw (widget);
return G_SOURCE_CONTINUE;
}
static void
demo4_widget_init (Demo4Widget *self)
{
PangoFontDescription *desc;
self->progress = 0.5;
self->n_stops = 8;
self->stops[0].offset = 0;
self->stops[0].color = (GdkRGBA) { 1, 0, 0, 1 };
for (unsigned int i = 1; i < self->n_stops; i++)
{
GdkHSLA hsla;
self->stops[i].offset = i / (double)(self->n_stops - 1);
_gdk_hsla_init_from_rgba (&hsla, &self->stops[i - 1].color);
hsla.hue += 360.0 / (double)(self->n_stops - 1);
_gdk_rgba_init_from_hsla (&self->stops[i].color, &hsla);
}
self->layout = gtk_widget_create_pango_layout (GTK_WIDGET (self), "123");
desc = pango_font_description_from_string ("Cantarell Bold 210");
pango_layout_set_font_description (self->layout, desc);
pango_font_description_free (desc);
self->tick = gtk_widget_add_tick_callback (GTK_WIDGET (self), rotate_colors, NULL, NULL);
}
static void
demo4_widget_dispose (GObject *object)
{
Demo4Widget *self = DEMO4_WIDGET (object);
g_clear_object (&self->layout);
gtk_widget_remove_tick_callback (GTK_WIDGET (self), self->tick);
G_OBJECT_CLASS (demo4_widget_parent_class)->dispose (object);
}
static void
demo4_widget_snapshot_content (GtkWidget *widget,
GtkSnapshot *snapshot,
GskMaskMode mode)
{
Demo4Widget *self = DEMO4_WIDGET (widget);
int width, height, layout_width, layout_height;
double scale;
width = gtk_widget_get_width (widget);
height = gtk_widget_get_height (widget);
gtk_snapshot_push_mask (snapshot, mode);
pango_layout_get_pixel_size (self->layout, &layout_width, &layout_height);
scale = MIN ((double) width / layout_width, (double) height / layout_height);
gtk_snapshot_translate (snapshot,
&GRAPHENE_POINT_INIT ((width - scale * layout_width) / 2,
(height - scale * layout_height) / 2));
gtk_snapshot_scale (snapshot, scale, scale);
gtk_snapshot_append_layout (snapshot, self->layout, &(GdkRGBA) { 0, 0, 0, 1 });
gtk_snapshot_pop (snapshot);
gtk_snapshot_append_linear_gradient (snapshot,
&GRAPHENE_RECT_INIT (0, 0, width, height),
&GRAPHENE_POINT_INIT (0, 0),
&GRAPHENE_POINT_INIT (width, height),
self->stops,
self->n_stops);
gtk_snapshot_pop (snapshot);
}
static void
demo4_widget_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot)
{
Demo4Widget *self = DEMO4_WIDGET (widget);
int width, height;
width = gtk_widget_get_width (widget);
height = gtk_widget_get_height (widget);
gtk_snapshot_push_mask (snapshot, GSK_MASK_MODE_INVERTED_LUMINANCE);
gtk_snapshot_append_linear_gradient (snapshot,
&GRAPHENE_RECT_INIT (0, 0, width, height),
&GRAPHENE_POINT_INIT (0, 0),
&GRAPHENE_POINT_INIT (width, 0),
(GskColorStop[2]) {
{ MAX (0.0, self->progress - 5.0 / width), { 1, 1, 1, 1 } },
{ MIN (1.0, self->progress + 5.0 / width), { 0, 0, 0, 1 } }
}, 2);
gtk_snapshot_pop (snapshot);
demo4_widget_snapshot_content (widget, snapshot, GSK_MASK_MODE_INVERTED_ALPHA);
gtk_snapshot_pop (snapshot);
gtk_snapshot_push_mask (snapshot, GSK_MASK_MODE_LUMINANCE);
gtk_snapshot_append_linear_gradient (snapshot,
&GRAPHENE_RECT_INIT (0, 0, width, height),
&GRAPHENE_POINT_INIT (0, 0),
&GRAPHENE_POINT_INIT (width, 0),
(GskColorStop[2]) {
{ MAX (0.0, self->progress - 5.0 / width), { 1, 1, 1, 1 } },
{ MIN (1.0, self->progress + 5.0 / width), { 0, 0, 0, 1 } }
}, 2);
gtk_snapshot_pop (snapshot);
demo4_widget_snapshot_content (widget, snapshot, GSK_MASK_MODE_ALPHA);
gtk_snapshot_pop (snapshot);
}
static void
demo4_widget_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
Demo4Widget *self = DEMO4_WIDGET (object);
switch (prop_id)
{
case PROP_PROGRESS:
self->progress = g_value_get_double (value);
gtk_widget_queue_draw (GTK_WIDGET (object));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
demo4_widget_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
Demo4Widget *self = DEMO4_WIDGET (object);
switch (prop_id)
{
case PROP_PROGRESS:
g_value_set_double (value, self->progress);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
demo4_widget_class_init (Demo4WidgetClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
object_class->dispose = demo4_widget_dispose;
object_class->get_property = demo4_widget_get_property;
object_class->set_property = demo4_widget_set_property;
widget_class->snapshot = demo4_widget_snapshot;
g_object_class_install_property (object_class, PROP_PROGRESS,
g_param_spec_double ("progress", NULL, NULL,
0.0, 1.0, 0.5,
G_PARAM_READWRITE));
}
GtkWidget *
demo4_widget_new (void)
{
return g_object_new (DEMO4_TYPE_WIDGET, NULL);
}
+8
View File
@@ -0,0 +1,8 @@
#pragma once
#include <gtk/gtk.h>
#define DEMO4_TYPE_WIDGET (demo4_widget_get_type ())
G_DECLARE_FINAL_TYPE (Demo4Widget, demo4_widget, DEMO4, WIDGET, GtkWidget)
GtkWidget * demo4_widget_new (void);
+12 -1
View File
@@ -356,6 +356,10 @@ canvas_item_start_editing (CanvasItem *item)
}
typedef struct {
double x, y;
} Hotspot;
static GdkContentProvider *
prepare (GtkDragSource *source,
double x,
@@ -363,6 +367,7 @@ prepare (GtkDragSource *source,
{
GtkWidget *canvas;
GtkWidget *item;
Hotspot *hotspot;
canvas = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (source));
item = gtk_widget_pick (canvas, x, y, GTK_PICK_DEFAULT);
@@ -373,6 +378,10 @@ prepare (GtkDragSource *source,
g_object_set_data (G_OBJECT (canvas), "dragged-item", item);
hotspot = g_new (Hotspot, 1);
gtk_widget_translate_coordinates (canvas, item, x, y, &hotspot->x, &hotspot->y);
g_object_set_data_full (G_OBJECT (canvas), "hotspot", hotspot, g_free);
return gdk_content_provider_new_typed (GTK_TYPE_WIDGET, item);
}
@@ -383,12 +392,14 @@ drag_begin (GtkDragSource *source,
GtkWidget *canvas;
CanvasItem *item;
GdkPaintable *paintable;
Hotspot *hotspot;
canvas = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (source));
item = CANVAS_ITEM (g_object_get_data (G_OBJECT (canvas), "dragged-item"));
hotspot = (Hotspot *) g_object_get_data (G_OBJECT (canvas), "hotspot");
paintable = canvas_item_get_drag_icon (item);
gtk_drag_source_set_icon (source, paintable, item->r, item->r);
gtk_drag_source_set_icon (source, paintable, hotspot->x, hotspot->y);
g_object_unref (paintable);
gtk_widget_set_opacity (GTK_WIDGET (item), 0.3);
+12 -10
View File
@@ -48,14 +48,16 @@
#define VERTICES_PER_TOOTH 34
#define GEAR_VERTEX_STRIDE 6
#ifndef HAVE_SINCOS
static void
sincos (double x, double *_sin, double *_cos)
static inline void
_sincos (double x, double *_sin, double *_cos)
{
#ifdef HAVE_SINCOS
sincos (x, _sin, _cos);
#else
*_sin = sin (x);
*_cos = cos (x);
}
#endif
}
/**
* Struct describing the vertices in triangle strip
@@ -307,11 +309,11 @@ create_gear (GLfloat inner_radius,
struct point p[7];
/* Calculate needed sin/cos for various angles */
sincos(i * 2.0 * G_PI / teeth + da * 0, &s[0], &c[0]);
sincos(i * 2.0 * M_PI / teeth + da * 1, &s[1], &c[1]);
sincos(i * 2.0 * M_PI / teeth + da * 2, &s[2], &c[2]);
sincos(i * 2.0 * M_PI / teeth + da * 3, &s[3], &c[3]);
sincos(i * 2.0 * M_PI / teeth + da * 4, &s[4], &c[4]);
_sincos(i * 2.0 * G_PI / teeth + da * 0, &s[0], &c[0]);
_sincos(i * 2.0 * M_PI / teeth + da * 1, &s[1], &c[1]);
_sincos(i * 2.0 * M_PI / teeth + da * 2, &s[2], &c[2]);
_sincos(i * 2.0 * M_PI / teeth + da * 3, &s[3], &c[3]);
_sincos(i * 2.0 * M_PI / teeth + da * 4, &s[4], &c[4]);
GEAR_POINT(p[0], r2, 1);
GEAR_POINT(p[1], r2, 2);
@@ -520,7 +522,7 @@ void perspective(GLfloat *m, GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloa
identity(tmp);
deltaZ = zFar - zNear;
sincos(radians, &sine, &cosine);
_sincos(radians, &sine, &cosine);
if ((deltaZ == 0) || (sine == 0) || (aspect == 0))
return;
+146
View File
@@ -0,0 +1,146 @@
#include <gdk/gdk.h>
#include "hsla.h"
void
_gdk_hsla_init_from_rgba (GdkHSLA *hsla,
const GdkRGBA *rgba)
{
float min;
float max;
float red;
float green;
float blue;
float delta;
g_return_if_fail (hsla != NULL);
g_return_if_fail (rgba != NULL);
red = rgba->red;
green = rgba->green;
blue = rgba->blue;
if (red > green)
{
if (red > blue)
max = red;
else
max = blue;
if (green < blue)
min = green;
else
min = blue;
}
else
{
if (green > blue)
max = green;
else
max = blue;
if (red < blue)
min = red;
else
min = blue;
}
hsla->lightness = (max + min) / 2;
hsla->saturation = 0;
hsla->hue = 0;
hsla->alpha = rgba->alpha;
if (max != min)
{
if (hsla->lightness <= 0.5)
hsla->saturation = (max - min) / (max + min);
else
hsla->saturation = (max - min) / (2 - max - min);
delta = max -min;
if (red == max)
hsla->hue = (green - blue) / delta;
else if (green == max)
hsla->hue = 2 + (blue - red) / delta;
else if (blue == max)
hsla->hue = 4 + (red - green) / delta;
hsla->hue *= 60;
if (hsla->hue < 0.0)
hsla->hue += 360;
}
}
void
_gdk_rgba_init_from_hsla (GdkRGBA *rgba,
const GdkHSLA *hsla)
{
float hue;
float lightness;
float saturation;
float m1, m2;
lightness = hsla->lightness;
saturation = hsla->saturation;
if (lightness <= 0.5)
m2 = lightness * (1 + saturation);
else
m2 = lightness + saturation - lightness * saturation;
m1 = 2 * lightness - m2;
rgba->alpha = hsla->alpha;
if (saturation == 0)
{
rgba->red = lightness;
rgba->green = lightness;
rgba->blue = lightness;
}
else
{
hue = hsla->hue + 120;
while (hue > 360)
hue -= 360;
while (hue < 0)
hue += 360;
if (hue < 60)
rgba->red = m1 + (m2 - m1) * hue / 60;
else if (hue < 180)
rgba->red = m2;
else if (hue < 240)
rgba->red = m1 + (m2 - m1) * (240 - hue) / 60;
else
rgba->red = m1;
hue = hsla->hue;
while (hue > 360)
hue -= 360;
while (hue < 0)
hue += 360;
if (hue < 60)
rgba->green = m1 + (m2 - m1) * hue / 60;
else if (hue < 180)
rgba->green = m2;
else if (hue < 240)
rgba->green = m1 + (m2 - m1) * (240 - hue) / 60;
else
rgba->green = m1;
hue = hsla->hue - 120;
while (hue > 360)
hue -= 360;
while (hue < 0)
hue += 360;
if (hue < 60)
rgba->blue = m1 + (m2 - m1) * hue / 60;
else if (hue < 180)
rgba->blue = m2;
else if (hue < 240)
rgba->blue = m1 + (m2 - m1) * (240 - hue) / 60;
else
rgba->blue = m1;
}
}
+15
View File
@@ -0,0 +1,15 @@
#pragma once
typedef struct _GdkHSLA GdkHSLA;
struct _GdkHSLA {
float hue;
float saturation;
float lightness;
float alpha;
};
void _gdk_hsla_init_from_rgba (GdkHSLA *hsla,
const GdkRGBA *rgba);
void _gdk_rgba_init_from_hsla (GdkRGBA *rgba,
const GdkHSLA *hsla);
+53
View File
@@ -0,0 +1,53 @@
/* Masking
*
* Demonstrates mask nodes.
*
* This demo uses a text node as mask for
* an animated linear gradient.
*/
#include <gtk/gtk.h>
#include "demo4widget.h"
GtkWidget *
do_mask (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;
if (!window)
{
GtkWidget *box;
GtkWidget *demo;
GtkWidget *scale;
window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (window), "Mask Nodes");
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_window_set_child (GTK_WINDOW (window), box);
demo = demo4_widget_new ();
gtk_widget_set_hexpand (demo, TRUE);
gtk_widget_set_vexpand (demo, TRUE);
gtk_box_append (GTK_BOX (box), demo);
scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 1, 0.1);
gtk_range_set_value (GTK_RANGE (scale), 0.5);
g_object_bind_property (gtk_range_get_adjustment (GTK_RANGE (scale)), "value", demo, "progress", 0);
gtk_box_append (GTK_BOX (box), scale);
}
if (!gtk_widget_get_visible (window))
gtk_widget_set_visible (window, TRUE);
else
gtk_window_destroy (GTK_WINDOW (window));
return window;
}
+12 -1
View File
@@ -22,9 +22,11 @@ do_menu (GtkWidget *do_widget)
if (!window)
{
GtkWidget *box;
GtkWidget *box2;
GtkWidget *sw;
GtkWidget *widget;
GtkWidget *scale;
GtkWidget *dropdown;
window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (window), "Menu");
@@ -43,10 +45,19 @@ do_menu (GtkWidget *do_widget)
widget = demo3_widget_new ("/transparent/portland-rose.jpg");
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), widget);
box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_append (GTK_BOX (box), box2);
scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0.01, 10.0, 0.1);
gtk_range_set_value (GTK_RANGE (scale), 1.0);
gtk_box_append (GTK_BOX (box), scale);
gtk_widget_set_hexpand (scale, TRUE);
gtk_box_append (GTK_BOX (box2), scale);
dropdown = gtk_drop_down_new (G_LIST_MODEL (gtk_string_list_new ((const char *[]){ "Linear", "Nearest", "Trilinear", NULL })), NULL);
gtk_box_append (GTK_BOX (box2), dropdown);
g_object_bind_property (dropdown, "selected", widget, "filter", G_BINDING_DEFAULT);
g_object_bind_property (gtk_range_get_adjustment (GTK_RANGE (scale)), "value",
widget, "scale",
G_BINDING_BIDIRECTIONAL);
+3
View File
@@ -46,6 +46,7 @@ demos = files([
'links.c',
'listbox.c',
'listbox_controls.c',
'mask.c',
'menu.c',
'flowbox.c',
'list_store.c',
@@ -114,6 +115,7 @@ extra_demo_sources = files([
'gtkshadertoy.c',
'gtkshaderstack.c',
'gskshaderpaintable.c',
'hsla.c',
'puzzlepiece.c',
'bluroverlay.c',
'demoimage.c',
@@ -126,6 +128,7 @@ extra_demo_sources = files([
'four_point_transform.c',
'demo2widget.c',
'demo3widget.c',
'demo4widget.c',
'pixbufpaintable.c',
'script-names.c',
'unicode-names.c',
+25
View File
@@ -178,6 +178,16 @@ Creates a node like `gsk_inset_shadow_node_new()` with the given properties.
Creates a node like `gsk_linear_gradient_node_new()` with the given properties.
### mask
| property | syntax | default | printed |
| -------- | ---------------- | ---------------------- | ----------- |
| source | `<node>` | color { } | always |
| mode | `<blend-mode>` | alpha | non-default |
| mask | `<node>` | color { } | always |
Creates a node like `gsk_mask_node_new()` with the given properties.
### opacity
| property | syntax | default | printed |
@@ -297,6 +307,21 @@ The default texture is a 10x10 checkerboard with the top left and bottom right
representation for this texture is `url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABmJLR0QA/wD/AP+gvaeTAAAAKUlEQVQYlWP8z3DmPwMaYGQwYUQXY0IXwAUGUCGGoxkYGBiweXAoeAYAz44F3e3U1xUAAAAASUVORK5CYII=")
`.
### texture-scale
| property | syntax | default | printed |
| -------- | ---------------- | ---------------------- | ----------- |
| bounds | `<rect>` | 50 | always |
| texture | `<url>` | *see below* | always |
| filter | `filter` | *see below* | non-default |
Creates a node like `gsk_texture_scale_node_new()` with the given properties.
The default texture is a 10x10 checkerboard, just like for texture.
The possible filter values are `linear`, `nearest` and `trilinear`, with
`linear` being the default.
### transform
| property | syntax | default | printed |
+5 -5
View File
@@ -239,14 +239,14 @@ control whether Vulkan should be used.
### `media-gstreamer` and `media-ffmpeg`
By default, GTK will try to build the gstreamer backend for
media playback support. These option can be used to explicitly
media playback support. These options can be used to explicitly
control which media backends should be built.
### `print-cups`
### `print-cups` and `print-cpdb`
By default, GTK will try to build various print backends
if their dependencies are found. This option can be used
to explicitly control whether the cups print backend should be built.
By default, GTK will try to build the cups and file print backends
if their dependencies are found. These options can be used to
explicitly control which print backends should be built.
### `cloudproviders`
+5
View File
@@ -33,6 +33,11 @@ Validation
The ``validate`` command validates the given UI definition file and reports
errors to ``stderr``.
Note that there are limitations to the validation that can be done for templates,
since they are closely tied to the class_init function they are used in.
If your UI file uses types from third-party libraries, it may help to add those
libraries to the `LD_PRELOAD` environment variable.
``--deprecations``
Warn about uses of deprecated types in the UI definition file.
+3 -3
View File
@@ -115,7 +115,7 @@ Instead of gtk_show_uri(), you should use GtkUriLauncher or GtkFileLauncher.
This is an oldfashioned widget that does not do all that much anymore, since
it no longer has a resize handle for the window.
## GtkLockButton is going away
## GtkLockButton and GtkVolumeButton are going away
This is an very specialized widget that should better live with the application
where it is used.
These are very specialized widgets that should better live with the application
where they are used.
+63 -47
View File
@@ -7,37 +7,50 @@ the question you have, this list is a good place to start.
## General Questions
1. How do I get started with GTK?
* How do I get started with GTK?
The GTK [website](https://www.gtk.org) offers some
[tutorials](https://www.gtk.org/documentation.php) and other documentation
(most of it about GTK 2.x and 3.x, but still somewhat applicable). This
reference manual also contains a introductory
This reference manual also contains a introductory
[Getting Started](#gtk-getting-started) part.
More documentation ranging from whitepapers to online books can be found at
the [GNOME developer's site](https://developer.gnome.org). After studying these
materials you should be well prepared to come back to this reference manual for details.
2. Where can I get help with GTK, submit a bug report, or make a feature request?
* Where can I get help with GTK, submit a bug report, or make a feature request?
See the [documentation](#gtk-resources) on this topic.
3. How do I port from one GTK version to another?
* How do I port from one GTK version to another?
See the [migration guide](#migrating). You may also find useful information in
the documentation for specific widgets and functions. If you have a question not
covered in the manual, feel free to ask, and please
Every major version of GTK comes with a [migration guide](#migrating). You may also
find useful information in the documentation for specific widgets and functions. If
you have a question not covered in the manual, feel free to ask, and please
[file a bug report](https://gitlab.gnome.org/GNOME/gtk/issues/new) against the
documentation.
4. How does memory management work in GTK? Should I free data returned from functions?
* Should I maintain parallel versions of my UI in GTK x and GTK y?
At the end of the day, that is up to you.
Our experience is that it is a lot of work, and usually not a good idea.
If you are not ready to make the jump to the next major version of GTK,
it is perfectly fine to stick with the stable release. We maintain them
for that reason.
* How does memory management work in GTK? Should I free data returned from functions?
See the documentation for `GObject` and `GInitiallyUnowned`. For `GObject` note
specifically `g_object_ref()` and `g_object_unref()`. `GInitiallyUnowned` is a
subclass of `GObject` so the same points apply, except that it has a "floating"
state (explained in its documentation).
In a widget tree, each container owns a reference to its children. The root
object (typically a `GtkWindow`) is owned by GTK. GTK will drop its reference
when you call [method@Gtk.Window.destroy].
For strings returned from functions, they will be declared "const" if they should
not be freed. Non-const strings should be freed with `g_free()`. Arrays follow the
same rule. If you find an undocumented exception to the rules, please
@@ -46,7 +59,7 @@ the question you have, this list is a good place to start.
The transfer annotations for gobject-introspection that are part of the
documentation can provide useful hints for memory handling semantics as well.
5. Why does my program leak memory, if I destroy a widget immediately
* Why does my program leak memory, if I destroy a widget immediately
after creating it?
If `GtkFoo` isn't a toplevel window, then
@@ -69,7 +82,7 @@ the question you have, this list is a good place to start.
the initial floating reference and you don't have to worry about reference
counting at all ... just remove the widget from the container to get rid of it.
6. How do I use GTK with threads?
* How do I use GTK with threads?
GTK requires that all GTK API calls are made from the same thread in which
the `GtkApplication` was created, or `gtk_init()` was called (the _main thread_).
@@ -79,7 +92,7 @@ the question you have, this list is a good place to start.
the results back to the main thread using `g_idle_add()` or `GAsyncQueue`. GIO
offers useful tools for such an approach such as `GTask`.
7. How do I internationalize a GTK program?
* How do I internationalize a GTK program?
Most people use [GNU gettext](https://www.gnu.org/software/gettext/),
already required in order to install GLib. On a UNIX or Linux system with
@@ -134,7 +147,7 @@ the question you have, this list is a good place to start.
#define _(x) dgettext (GETTEXT_PACKAGE, x)
8. How do I use non-ASCII characters in GTK programs ?
* How do I use non-ASCII characters in GTK programs ?
GTK uses [Unicode](http://www.unicode.org) (more exactly UTF-8) for all text.
UTF-8 encodes each Unicode codepoint as a sequence of one to six bytes and
@@ -217,7 +230,7 @@ the question you have, this list is a good place to start.
to call bind_textdomain_codeset() to ensure that translated strings
are returned in UTF-8 encoding.
9. How do I use GTK with C++?
* How do I use GTK with C++?
There are two ways to approach this. The GTK header files use the subset
of C that's also valid C++, so you can simply use the normal GTK API
@@ -242,19 +255,23 @@ the question you have, this list is a good place to start.
There are very few functions that require this cast, however.
10. How do I use GTK with other non-C languages?
* How do I use GTK with other non-C languages?
See the list of [language bindings](https://www.gtk.org/language-bindings.php)
on the GTK [website](https://www.gtk.org).
11. How do I load an image or animation from a file?
* How do I load an image or animation from a file?
To load an image file straight into a display widget, use
[ctor@Gtk.Image.new_from_file]. To load an image for another purpose, use
[ctor@Gdk.Texture.new_from_file]. To load a video from a file, use
[ctor@Gtk.MediaFile.new_for_file].
[ctor@Gtk.Picture.new_for_file] or [ctor@GTk.Picture.new_for_filename].
To load an image for another purpose, use [ctor@Gdk.Texture.new_from_file].
To load a video from a file, use [ctor@Gtk.MediaFile.new_for_file].
12. How do I draw text?
* How do I draw text?
If you just want to put text into your user interface somewhere, it is
usually easiest to just use one of ready-made widgets for this purpose,
such as [class@Gtk.Label].
To draw a piece of text onto a cairo surface, use a Pango layout and
[func@PangoCairo.show_layout].
@@ -272,7 +289,7 @@ the question you have, this list is a good place to start.
To draw a piece of text in a widget [vfunc@Gtk.Widget.snapshot] implementation,
use [method@Gtk.Snapshot.append_layout].
13. How do I measure the size of a piece of text?
* How do I measure the size of a piece of text?
To obtain the size of a piece of text, use a Pango layout and
[method@Pango.Layout.get_pixel_size], using code like the following:
@@ -287,7 +304,7 @@ the question you have, this list is a good place to start.
See also the [Layout Objects](https://developer.gnome.org/pango/stable/pango-Layout-Objects.html)
section of the [Pango documentation](https://developer.gnome.org/pango/stable/).
14. Why are types not registered if I use their `GTK_TYPE_BLAH` macro?
* Why are types not registered if I use their `GTK_TYPE_BLAH` macro?
The %GTK_TYPE_BLAH macros are defined as calls to gtk_blah_get_type(), and
the `_get_type()` functions are declared as %G_GNUC_CONST which allows the
@@ -298,14 +315,14 @@ the question you have, this list is a good place to start.
g_type_ensure (GTK_TYPE_BLAH);
15. How do I create a transparent toplevel window?
* How do I create a transparent toplevel window?
Any toplevel window can be transparent. It is just a matter of setting a
transparent background in the CSS style for it.
## Which widget should I use...
16. ...for lists and trees?
* ...for lists and trees?
This question has different answers, depending on the size of the dataset
and the required formatting flexibility.
@@ -321,7 +338,7 @@ the question you have, this list is a good place to start.
and widgetry inside the list, then you probably want to use a [class@Gtk.ListBox],
which uses regular widgets for display.
17. ...for multi-line text display or editing?
* ...for multi-line text display or editing?
See the [text widget overview](#TextWidget) -- you should use the
[class@Gtk.TextView] widget.
@@ -330,7 +347,7 @@ the question you have, this list is a good place to start.
of course. It can be made selectable with [method@Gtk.Label.set_selectable]. For a
single-line text entry, see [class@Gtk.Entry].
18. ...to display an image or animation?
* ...to display an image or animation?
GTK has two widgets that are dedicated to displaying images. [class@Gtk.Image], for
small, fixed-size icons and [class@Gtk.Picture] for content images.
@@ -346,17 +363,14 @@ the question you have, this list is a good place to start.
mediafile = gtk_media_file_new_for_filename ("example.webm");
picture = gtk_picture_new_for_paintable (GDK_PAINTABLE (mediafile));
19. ...for presenting a set of mutually-exclusive choices, where Windows
* ...for presenting a set of mutually-exclusive choices, where Windows
would use a combo box?
With GTK, a [class@Gtk.ComboBox] is the recommended widget to use for this use case.
If you need an editable text entry, use the [property@Gtk.ComboBox:has-entry] property.
A newer alternative is [class@Gtk.DropDown].
With GTK, a [class@Gtk.DropDown] is the recommended widget to use for this use case.
## Questions about GtkWidget
20. How do I change the color of a widget?
* How do I change the color of a widget?
The background color of a widget is determined by the CSS style that applies
to it. To change that, you can set style classes on the widget, and provide
@@ -364,7 +378,7 @@ the question you have, this list is a good place to start.
[method@Gtk.CssProvider.load_from_file] and its variants.
See [method@Gtk.StyleContext.add_provider].
21. How do I change the font of a widget?
* How do I change the font of a widget?
If you want to make the text of a label larger, you can use
gtk_label_set_markup():
@@ -388,14 +402,14 @@ the question you have, this list is a good place to start.
of this approach is that users can then override the font you have chosen.
See the `GtkStyleContext` documentation for more discussion.
22. How do I disable/ghost/desensitize a widget?
* How do I disable/ghost/desensitize a widget?
In GTK a disabled widget is termed _insensitive_.
See [method@Gtk.Widget.set_sensitive].
## GtkTextView questions
23. How do I get the contents of the entire text widget as a string?
* How do I get the contents of the entire text widget as a string?
See [method@Gtk.TextBuffer.get_bounds] and [method@Gtk.TextBuffer.get_text]
or [method@Gtk.TextIter.get_text].
@@ -410,14 +424,14 @@ the question you have, this list is a good place to start.
/* use text */
g_free (text);
24. How do I make a text widget display its complete contents in a specific font?
* How do I make a text widget display its complete contents in a specific font?
If you use [method@Gtk.TextBuffer.insert_with_tags] with appropriate tags to
select the font, the inserted text will have the desired appearance, but
text typed in by the user before or after the tagged block will appear in
the default style.
25. How do I make a text view scroll to the end of the buffer automatically ?
* How do I make a text view scroll to the end of the buffer automatically ?
A good way to keep a text buffer scrolled to the end is to place a
[mark](#GtkTextMark) at the end of the buffer, and give it right gravity.
@@ -432,21 +446,21 @@ the question you have, this list is a good place to start.
## GtkTreeView questions
26. How do I associate some data with a row in the tree?
* How do I associate some data with a row in the tree?
Remember that the [iface@Gtk.TreeModel] columns don't necessarily have to be
displayed. So you can put non-user-visible data in your model just
like any other data, and retrieve it with [method@Gtk.TreeModel.get].
See the [tree widget overview](#TreeWidget).
27. How do I put an image and some text in the same column?
* How do I put an image and some text in the same column?
You can pack more than one [class@Gtk.CellRenderer] into a single [class@Gtk.TreeViewColumn]
using [method@Gtk.TreeViewColumn.pack_start] or [method@Gtk.TreeViewColumn.pack_end].
So pack both a [class@Gtk.CellRendererPixbuf] and a [class@Gtk.CellRendererText] into the
column.
28. I can set data easily on my [class@Gtk.TreeStore] or [class@Gtk.ListStore] models using
* I can set data easily on my [class@Gtk.TreeStore] or [class@Gtk.ListStore] models using
[method@Gtk.ListStore.set] and [method@Gtk.TreeStore.set], but can't read it back?
Both the [class@Gtk.TreeStore] and the [class@Gtk.ListStore] implement the [iface@Gtk.TreeModel]
@@ -454,7 +468,7 @@ the question you have, this list is a good place to start.
implements. The easiest way to read a set of data back is to use
[method@Gtk.TreeModel.get].
29. How do I change the way that numbers are formatted by `GtkTreeView`?
* How do I change the way that numbers are formatted by `GtkTreeView`?
Use [method@Gtk.TreeView.insert_column_with_data_func] or
[method@Gtk.TreeViewColumn.set_cell_data_func] and do the conversion
@@ -528,19 +542,21 @@ the question you have, this list is a good place to start.
(gpointer)DOUBLE_COLUMN, NULL);
}
30. How do I hide the expander arrows in my tree view?
* How do I hide the expander arrows in my tree view?
Set the expander-column property of the tree view to a hidden column.
See [method@Gtk.TreeView.set_expander_column] and [method@Gtk.TreeViewColumn.set_visible].
## Using cairo with GTK
31. How do I use cairo to draw in GTK applications?
* How do I use cairo to draw in GTK applications?
Use [method@Gtk.Snapshot.append_cairo] in your [vfunc@Gtk.Widget.snapshot] vfunc
to obtain a cairo context and draw with that.
[class@Gtk.DrawingArea] is a ready-made widget for drawing with cairo.
32. Can I improve the performance of my application by using another backend
If you implement a custom widget, use [method@Gtk.Snapshot.append_cairo]
in your [vfunc@Gtk.Widget.snapshot] vfunc to obtain a cairo context and draw with that.
* Can I improve the performance of my application by using another backend
of cairo (such as GL)?
No. Most drawing in GTK is not done via cairo anymore (but instead
@@ -551,7 +567,7 @@ the question you have, this list is a good place to start.
If you are interested in using GL for your own drawing, see [class@Gtk.GLArea].
33. Can I use cairo to draw on a `GdkPixbuf`?
* Can I use cairo to draw on a `GdkPixbuf`?
No. The cairo image surface does not support the pixel format used by `GdkPixbuf`.
+1
View File
@@ -69,6 +69,7 @@
#include <gdk/gdksnapshot.h>
#include <gdk/gdksurface.h>
#include <gdk/gdktexture.h>
#include <gdk/gdktexturedownloader.h>
#include <gdk/gdktoplevel.h>
#include <gdk/gdktoplevellayout.h>
#include <gdk/gdktoplevelsize.h>
+2 -12
View File
@@ -1511,7 +1511,6 @@ gdk_button_event_get_button (GdkEvent *event)
}
/* }}} */
/* {{{ GdkKeyEvent */
/**
@@ -1972,7 +1971,6 @@ gdk_key_event_get_match (GdkEvent *event,
}
/* }}} */
/* {{{ GdkTouchEvent */
/**
@@ -2109,7 +2107,6 @@ gdk_touch_event_get_emulating_pointer (GdkEvent *event)
}
/* }}} */
/* {{{ GdkCrossingEvent */
/**
@@ -2253,7 +2250,6 @@ gdk_crossing_event_get_detail (GdkEvent *event)
}
/* }}} */
/* {{{ GdkDeleteEvent */
/**
@@ -2284,7 +2280,6 @@ gdk_delete_event_new (GdkSurface *surface)
}
/* }}} */
/* {{{ GdkFocusEvent */
/**
@@ -2341,7 +2336,6 @@ gdk_focus_event_get_in (GdkEvent *event)
}
/* }}} */
/* {{{ GdkScrollEvent */
/**
@@ -2600,7 +2594,6 @@ gdk_scroll_event_get_unit (GdkEvent *event)
}
/* }}} */
/* {{{ GdkTouchpadEvent */
/**
@@ -2859,7 +2852,6 @@ gdk_touchpad_event_get_pinch_scale (GdkEvent *event)
}
/* }}} */
/* {{{ GdkPadEvent */
/**
@@ -3033,7 +3025,6 @@ gdk_pad_event_get_group_mode (GdkEvent *event,
}
/* }}} */
/* {{{ GdkMotionEvent */
/**
@@ -3195,7 +3186,6 @@ gdk_event_get_history (GdkEvent *event,
}
/* }}} */
/* {{{ GdkProximityEvent */
/**
@@ -3258,7 +3248,6 @@ gdk_proximity_event_new (GdkEventType type,
}
/* }}} */
/* {{{ GdkDNDEvent */
/**
@@ -3364,7 +3353,6 @@ gdk_dnd_event_get_drop (GdkEvent *event)
}
/* }}} */
/* {{{ GdkGrabBrokenEvent */
/**
@@ -3442,3 +3430,5 @@ gdk_grab_broken_event_get_implicit (GdkEvent *event)
}
/* }}} */
/* vim:set foldmethod=marker expandtab: */
+11
View File
@@ -584,6 +584,8 @@ gdk_frame_clock_paint_idle (void *data)
{
priv->requested &= ~GDK_FRAME_CLOCK_PHASE_LAYOUT;
_gdk_frame_clock_emit_layout (clock);
if (priv->requested & GDK_FRAME_CLOCK_PHASE_LAYOUT)
g_print ("looping in layout %d\n", iter);
}
if (iter == 5)
g_warning ("gdk-frame-clock: layout continuously requested, giving up after 4 tries");
@@ -809,3 +811,12 @@ _gdk_frame_clock_idle_new (void)
return GDK_FRAME_CLOCK (clock);
}
GdkFrameClockPhase
gdk_frame_clock_get_current_phase (GdkFrameClock *clock)
{
GdkFrameClockIdle *clock_idle = GDK_FRAME_CLOCK_IDLE (clock);
GdkFrameClockIdlePrivate *priv = clock_idle->priv;
return priv->phase;
}
+2
View File
@@ -127,6 +127,8 @@ void _gdk_frame_clock_emit_paint (GdkFrameClock *frame_clock);
void _gdk_frame_clock_emit_after_paint (GdkFrameClock *frame_clock);
void _gdk_frame_clock_emit_resume_events (GdkFrameClock *frame_clock);
GdkFrameClockPhase gdk_frame_clock_get_current_phase (GdkFrameClock *frame_clock);
G_END_DECLS
#endif /* __GDK_FRAME_CLOCK_PRIVATE_H__ */
-1
View File
@@ -24,7 +24,6 @@
#include "gdkglcontextprivate.h"
#include "gdkmemoryformatprivate.h"
#include "gdkmemorytextureprivate.h"
#include "gdktextureprivate.h"
#include <epoxy/gl.h>
+6 -10
View File
@@ -222,7 +222,7 @@ gdk_memory_texture_from_texture (GdkTexture *texture,
data = g_malloc_n (stride, texture->height);
gdk_texture_do_download (texture, format, data, stride);
bytes = g_bytes_new_take (data, stride);
bytes = g_bytes_new_take (data, stride * texture->height);
result = gdk_memory_texture_new (texture->width,
texture->height,
format,
@@ -233,15 +233,11 @@ gdk_memory_texture_from_texture (GdkTexture *texture,
return GDK_MEMORY_TEXTURE (result);
}
const guchar *
gdk_memory_texture_get_data (GdkMemoryTexture *self)
GBytes *
gdk_memory_texture_get_bytes (GdkMemoryTexture *self,
gsize *out_stride)
{
return g_bytes_get_data (self->bytes, NULL);
}
gsize
gdk_memory_texture_get_stride (GdkMemoryTexture *self)
{
return self->stride;
*out_stride = self->stride;
return self->bytes;
}
+2 -2
View File
@@ -37,8 +37,8 @@ GdkTexture * gdk_memory_texture_new_subtexture (GdkMemoryTexture *
int width,
int height);
const guchar * gdk_memory_texture_get_data (GdkMemoryTexture *self);
gsize gdk_memory_texture_get_stride (GdkMemoryTexture *self);
GBytes * gdk_memory_texture_get_bytes (GdkMemoryTexture *self,
gsize *out_stride);
G_END_DECLS
+17 -12
View File
@@ -27,7 +27,7 @@
#include "gdkmemoryformatprivate.h"
#include "gdkmemorytextureprivate.h"
#include "gdksurface.h"
#include "gdktextureprivate.h"
#include "gdktexturedownloaderprivate.h"
#include <gdk-pixbuf/gdk-pixbuf.h>
@@ -218,9 +218,9 @@ gdk_pixbuf_get_from_surface (cairo_surface_t *surface,
static void
pixbuf_texture_unref_cb (guchar *pixels,
gpointer texture)
gpointer bytes)
{
g_object_unref (texture);
g_bytes_unref (bytes);
}
/**
@@ -238,22 +238,27 @@ pixbuf_texture_unref_cb (guchar *pixels,
GdkPixbuf *
gdk_pixbuf_get_from_texture (GdkTexture *texture)
{
GdkMemoryTexture *memtex;
GdkTextureDownloader downloader;
GBytes *bytes;
gsize stride;
gboolean alpha;
alpha = gdk_memory_format_alpha (gdk_texture_get_format (texture)) != GDK_MEMORY_ALPHA_OPAQUE;
memtex = gdk_memory_texture_from_texture (texture,
alpha ? GDK_MEMORY_GDK_PIXBUF_ALPHA
: GDK_MEMORY_GDK_PIXBUF_OPAQUE);
gdk_texture_downloader_init (&downloader, texture);
gdk_texture_downloader_set_format (&downloader,
alpha ? GDK_MEMORY_GDK_PIXBUF_ALPHA
: GDK_MEMORY_GDK_PIXBUF_OPAQUE);
bytes = gdk_texture_downloader_download_bytes (&downloader, &stride);
gdk_texture_downloader_finish (&downloader);
return gdk_pixbuf_new_from_data (gdk_memory_texture_get_data (memtex),
return gdk_pixbuf_new_from_data (g_bytes_get_data (bytes, NULL),
GDK_COLORSPACE_RGB,
alpha,
8,
gdk_texture_get_width (GDK_TEXTURE (memtex)),
gdk_texture_get_height (GDK_TEXTURE (memtex)),
gdk_memory_texture_get_stride (memtex),
gdk_texture_get_width (texture),
gdk_texture_get_height (texture),
stride,
pixbuf_texture_unref_cb,
memtex);
bytes);
}
+23
View File
@@ -722,6 +722,9 @@ gdk_texture_download_surface (GdkTexture *texture)
* cairo_image_surface_get_stride (surface));
* cairo_surface_mark_dirty (surface);
* ```
*
* For more flexible download capabilites, see
* [struct@Gdk.TextureDownloader].
*/
void
gdk_texture_download (GdkTexture *texture,
@@ -738,9 +741,29 @@ gdk_texture_download (GdkTexture *texture,
stride);
}
/**
* gdk_texture_get_format:
* @self: a GdkTexture
*
* Gets the memory format most closely associated with the data of
* the texture.
*
* Note that it may not be an exact match for texture data
* stored on the GPU or with compression.
*
* The format can give an indication about the bit depth and opacity
* of the texture and is useful to determine the best format for
* downloading the texture.
*
* Returns: the preferred format for the texture's data
*
* Since: 4.10
**/
GdkMemoryFormat
gdk_texture_get_format (GdkTexture *self)
{
g_return_val_if_fail (GDK_IS_TEXTURE (self), GDK_MEMORY_DEFAULT);
return self->format;
}
+3
View File
@@ -24,6 +24,7 @@
#endif
#include <gdk/gdkversionmacros.h>
#include <gdk/gdkenums.h>
#include <gdk/gdktypes.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
@@ -82,6 +83,8 @@ GDK_AVAILABLE_IN_ALL
int gdk_texture_get_width (GdkTexture *texture) G_GNUC_PURE;
GDK_AVAILABLE_IN_ALL
int gdk_texture_get_height (GdkTexture *texture) G_GNUC_PURE;
GDK_AVAILABLE_IN_4_10
GdkMemoryFormat gdk_texture_get_format (GdkTexture *self) G_GNUC_PURE;
GDK_AVAILABLE_IN_ALL
void gdk_texture_download (GdkTexture *texture,
+268
View File
@@ -0,0 +1,268 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2023 Benjamin Otte
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 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/>.
*/
/**
* GdkTextureDownloader:
*
* The `GdkTextureDownloader` is used to download the contents of a
* [class@Gdk.Texture].
*
* It is intended to be created as a short-term object for a single download,
* but can be used for multipe downloads of different textures or with different
* settings.
*
* `GdkTextureDownloader` can be used to convert data between different formats.
* Create a `GdkTexture` for the existing format and then download it in a
* different format.
*
* Since: 4.10
*/
#include "config.h"
#include "gdktexturedownloaderprivate.h"
#include "gdkmemoryformatprivate.h"
#include "gdkmemorytextureprivate.h"
#include "gdktextureprivate.h"
G_DEFINE_BOXED_TYPE (GdkTextureDownloader, gdk_texture_downloader,
gdk_texture_downloader_copy,
gdk_texture_downloader_free)
void
gdk_texture_downloader_init (GdkTextureDownloader *self,
GdkTexture *texture)
{
self->texture = g_object_ref (texture);
self->format = GDK_MEMORY_DEFAULT;
}
void
gdk_texture_downloader_finish (GdkTextureDownloader *self)
{
g_object_unref (self->texture);
}
/**
* gdk_texture_downloader_new:
* @texture: texture to download
*
* Creates a new texture downloader for @texture.
*
* Returns: A new texture downloader
*
* Since: 4.10
**/
GdkTextureDownloader *
gdk_texture_downloader_new (GdkTexture *texture)
{
GdkTextureDownloader *self;
g_return_val_if_fail (GDK_IS_TEXTURE (texture), NULL);
self = g_slice_new (GdkTextureDownloader);
gdk_texture_downloader_init (self, texture);
return self;
}
/**
* gdk_texture_downloader_copy:
* @self: the downloader to copy
*
* Creates a copy of the downloader.
*
* This function is meant for language bindings.
*
* Returns: A copy of the downloader
*
* Since: 4.10
**/
GdkTextureDownloader *
gdk_texture_downloader_copy (const GdkTextureDownloader *self)
{
GdkTextureDownloader *copy;
g_return_val_if_fail (self != NULL, NULL);
copy = gdk_texture_downloader_new (self->texture);
gdk_texture_downloader_set_format (copy, self->format);
return copy;
}
/**
* gdk_texture_downloader_free:
* @self: texture downloader to free
*
* Frees the given downloader and all its associated resources.
*
* Since: 4.10
**/
void
gdk_texture_downloader_free (GdkTextureDownloader *self)
{
g_return_if_fail (self != NULL);
gdk_texture_downloader_finish (self);
g_slice_free (GdkTextureDownloader, self);
}
/**
* gdk_texture_downloader_set_texture:
* @self: a texture downloader
* @texture: the new texture to download
*
* Changes the texture the downloader will download.
*
* Since: 4.10
**/
void
gdk_texture_downloader_set_texture (GdkTextureDownloader *self,
GdkTexture *texture)
{
g_return_if_fail (self != NULL);
g_return_if_fail (GDK_IS_TEXTURE (texture));
g_set_object (&self->texture, texture);
}
/**
* gdk_texture_downloader_get_texture:
* @self: a texture downloader
*
* Gets the texture that the downloader will download.
*
* Returns: (transfer none): The texture to download
*
* Since: 4.10
**/
GdkTexture *
gdk_texture_downloader_get_texture (const GdkTextureDownloader *self)
{
g_return_val_if_fail (self != NULL, NULL);
return self->texture;
}
/**
* gdk_texture_downloader_set_format:
* @self: a texture downloader
* @format: the format to use
*
* Sets the format the downloader will download.
*
* By default, GDK_MEMORY_DEFAULT is set.
*
* Since: 4.10
*/
void
gdk_texture_downloader_set_format (GdkTextureDownloader *self,
GdkMemoryFormat format)
{
g_return_if_fail (self != NULL);
self->format = format;
}
/**
* gdk_texture_downloader_get_format:
* @self: a texture downloader
*
* Gets the format that the data will be downloaded in.
*
* Returns: The format of the download
*
* Since: 4.10
**/
GdkMemoryFormat
gdk_texture_downloader_get_format (const GdkTextureDownloader *self)
{
g_return_val_if_fail (self != NULL, GDK_MEMORY_DEFAULT);
return self->format;
}
/**
* gdk_texture_downloader_download_into:
* @self: a texture downloader
* @data: (array): pointer to enough memory to be filled with the
* downloaded data of the texture
* @stride: rowstride in bytes
*
* Downloads the @texture into local memory.
*
* Since: 4.10
**/
void
gdk_texture_downloader_download_into (const GdkTextureDownloader *self,
guchar *data,
gsize stride)
{
g_return_if_fail (self != NULL);
g_return_if_fail (data != NULL);
g_return_if_fail (stride >= gdk_texture_get_width (self->texture) * gdk_memory_format_bytes_per_pixel (self->format));
gdk_texture_do_download (self->texture, self->format, data, stride);
}
/**
* gdk_texture_downloader_download_bytes:
* @self: the downloader
* @out_stride: (out): The stride of the resulting data in bytes.
*
* Downloads the given texture pixels into a `GBytes`. The rowstride will
* be stored in the stride value.
*
* This function will abort if it tries to download a large texture and
* fails to allocate memory. If you think that may happen, you should
* handle memory allocation yourself and use
* gdk_texture_downloader_download_into() once allocation succeeded.
*
* Returns: The downloaded pixels.
*
* Since: 4.10
**/
GBytes *
gdk_texture_downloader_download_bytes (const GdkTextureDownloader *self,
gsize *out_stride)
{
guchar *data;
gsize stride;
g_return_val_if_fail (self != NULL, NULL);
g_return_val_if_fail (out_stride != NULL, NULL);
if (GDK_IS_MEMORY_TEXTURE (self->texture) &&
gdk_texture_get_format (self->texture) == self->format)
{
GdkMemoryTexture *memtex = GDK_MEMORY_TEXTURE (self->texture);
return g_bytes_ref (gdk_memory_texture_get_bytes (memtex, out_stride));
}
stride = self->texture->width * gdk_memory_format_bytes_per_pixel (self->format);
data = g_malloc_n (stride, self->texture->height);
gdk_texture_do_download (self->texture, self->format, data, stride);
*out_stride = stride;
return g_bytes_new_take (data, stride * self->texture->height);
}
+69
View File
@@ -0,0 +1,69 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2023 Benjamin Otte
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 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_TEXTURE_DOWNLOADER_H__
#define __GTK_TEXTURE_DOWNLOADER_H__
#if !defined (__GDK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gdk/gdk.h> can be included directly."
#endif
#include <gdk/gdkversionmacros.h>
#include <gdk/gdkenums.h>
#include <gdk/gdktypes.h>
G_BEGIN_DECLS
#define GDK_TYPE_TEXTURE_DOWNLOADER (gdk_texture_downloader_get_type ())
GDK_AVAILABLE_IN_4_10
GType gdk_texture_downloader_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_4_10
GdkTextureDownloader * gdk_texture_downloader_new (GdkTexture *texture);
GDK_AVAILABLE_IN_4_10
GdkTextureDownloader * gdk_texture_downloader_copy (const GdkTextureDownloader *self);
GDK_AVAILABLE_IN_4_10
void gdk_texture_downloader_free (GdkTextureDownloader *self);
GDK_AVAILABLE_IN_4_10
void gdk_texture_downloader_set_texture (GdkTextureDownloader *self,
GdkTexture *texture);
GDK_AVAILABLE_IN_4_10
GdkTexture * gdk_texture_downloader_get_texture (const GdkTextureDownloader *self);
GDK_AVAILABLE_IN_4_10
void gdk_texture_downloader_set_format (GdkTextureDownloader *self,
GdkMemoryFormat format);
GDK_AVAILABLE_IN_4_10
GdkMemoryFormat gdk_texture_downloader_get_format (const GdkTextureDownloader *self);
GDK_AVAILABLE_IN_4_10
void gdk_texture_downloader_download_into (const GdkTextureDownloader *self,
guchar *data,
gsize stride);
GDK_AVAILABLE_IN_4_10
GBytes * gdk_texture_downloader_download_bytes (const GdkTextureDownloader *self,
gsize *out_stride);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkTextureDownloader, gdk_texture_downloader_free)
G_END_DECLS
#endif /* __GTK_TEXTURE_DOWNLOADER_H__ */
+41
View File
@@ -0,0 +1,41 @@
/* GTK - The GIMP Toolkit
*
* Copyright (C) 2023 Benjamin Otte
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_TEXTURE_DOWNLOADER_PRIVATE_H__
#define __GTK_TEXTURE_DOWNLOADER_PRIVATE_H__
#include "gdktexturedownloader.h"
G_BEGIN_DECLS
struct _GdkTextureDownloader
{
/*< private >*/
GdkTexture *texture;
GdkMemoryFormat format;
};
void gdk_texture_downloader_init (GdkTextureDownloader *self,
GdkTexture *texture);
void gdk_texture_downloader_finish (GdkTextureDownloader *self);
G_END_DECLS
#endif /* __GTK_TEXTURE_DOWNLOADER_PRIVATE_H__ */
-1
View File
@@ -43,7 +43,6 @@ void gdk_texture_do_download (GdkTexture
GdkMemoryFormat format,
guchar *data,
gsize stride);
GdkMemoryFormat gdk_texture_get_format (GdkTexture *self);
gboolean gdk_texture_set_render_data (GdkTexture *self,
gpointer key,
gpointer data,
+1
View File
@@ -77,6 +77,7 @@ typedef struct _GdkContentFormats GdkContentFormats;
typedef struct _GdkContentProvider GdkContentProvider;
typedef struct _GdkCursor GdkCursor;
typedef struct _GdkTexture GdkTexture;
typedef struct _GdkTextureDownloader GdkTextureDownloader;
typedef struct _GdkDevice GdkDevice;
typedef struct _GdkDrag GdkDrag;
typedef struct _GdkDrop GdkDrop;
+10 -8
View File
@@ -23,7 +23,7 @@
#include <glib/gi18n-lib.h>
#include "gdktexture.h"
#include "gdkmemorytextureprivate.h"
#include "gdktexturedownloaderprivate.h"
#include "gdkprofilerprivate.h"
@@ -251,7 +251,8 @@ gdk_save_jpeg (GdkTexture *texture)
guchar *data = NULL;
gulong size = 0;
guchar *input = NULL;
GdkMemoryTexture *memtex = NULL;
GdkTextureDownloader downloader;
GBytes *texbytes;
const guchar *texdata;
gsize texstride;
guchar *row;
@@ -270,7 +271,7 @@ gdk_save_jpeg (GdkTexture *texture)
free (data);
g_free (input);
jpeg_destroy_compress (&info);
g_clear_object (&memtex);
g_clear_pointer (&texbytes, g_bytes_unref);
return NULL;
}
@@ -289,10 +290,11 @@ gdk_save_jpeg (GdkTexture *texture)
jpeg_mem_dest (&info, &data, &size);
memtex = gdk_memory_texture_from_texture (texture,
GDK_MEMORY_R8G8B8);
texdata = gdk_memory_texture_get_data (memtex);
texstride = gdk_memory_texture_get_stride (memtex);
gdk_texture_downloader_init (&downloader, texture);
gdk_texture_downloader_set_format (&downloader, GDK_MEMORY_R8G8B8);
texbytes = gdk_texture_downloader_download_bytes (&downloader, &texstride);
gdk_texture_downloader_finish (&downloader);
texdata = g_bytes_get_data (texbytes, NULL);
jpeg_start_compress (&info, TRUE);
@@ -304,7 +306,7 @@ gdk_save_jpeg (GdkTexture *texture)
jpeg_finish_compress (&info);
g_object_unref (memtex);
g_bytes_unref (texbytes);
g_free (input);
jpeg_destroy_compress (&info);
+13 -11
View File
@@ -21,10 +21,9 @@
#include <glib/gi18n-lib.h>
#include "gdkmemoryformatprivate.h"
#include "gdkmemorytextureprivate.h"
#include "gdkmemorytexture.h"
#include "gdkprofilerprivate.h"
#include "gdktexture.h"
#include "gdktextureprivate.h"
#include "gdktexturedownloaderprivate.h"
#include "gsk/gl/fp16private.h"
#include <png.h>
#include <stdio.h>
@@ -297,11 +296,12 @@ gdk_save_png (GdkTexture *texture)
png_info *info;
png_io io = { NULL, 0, 0 };
int width, height;
int y;
GdkMemoryFormat format;
GdkTextureDownloader downloader;
GBytes *bytes;
gsize stride;
const guchar *data;
int y;
GdkMemoryTexture *memtex;
GdkMemoryFormat format;
int png_format;
int depth;
@@ -370,11 +370,15 @@ gdk_save_png (GdkTexture *texture)
return NULL;
}
memtex = gdk_memory_texture_from_texture (texture, format);
gdk_texture_downloader_init (&downloader, texture);
gdk_texture_downloader_set_format (&downloader, format);
bytes = gdk_texture_downloader_download_bytes (&downloader, &stride);
gdk_texture_downloader_finish (&downloader);
data = g_bytes_get_data (bytes, NULL);
if (sigsetjmp (png_jmpbuf (png), 1))
{
g_object_unref (memtex);
g_bytes_unref (bytes);
g_free (io.data);
png_destroy_read_struct (&png, &info, NULL);
return NULL;
@@ -394,8 +398,6 @@ gdk_save_png (GdkTexture *texture)
png_set_swap (png);
#endif
data = gdk_memory_texture_get_data (memtex);
stride = gdk_memory_texture_get_stride (memtex);
for (y = 0; y < height; y++)
png_write_row (png, data + y * stride);
@@ -403,7 +405,7 @@ gdk_save_png (GdkTexture *texture)
png_destroy_write_struct (&png, &info);
g_object_unref (memtex);
g_bytes_unref (bytes);
return g_bytes_new_take (io.data, io.size);
}
+13 -11
View File
@@ -21,10 +21,9 @@
#include <glib/gi18n-lib.h>
#include "gdkmemoryformatprivate.h"
#include "gdkmemorytextureprivate.h"
#include "gdkmemorytexture.h"
#include "gdkprofilerprivate.h"
#include "gdktexture.h"
#include "gdktextureprivate.h"
#include "gdktexturedownloaderprivate.h"
#include <tiffio.h>
@@ -260,11 +259,12 @@ GBytes *
gdk_save_tiff (GdkTexture *texture)
{
TIFF *tif;
int width, height, stride;
int width, height;
gsize stride;
const guchar *line;
const guchar *data;
GBytes *result = NULL;
GdkMemoryTexture *memtex;
GBytes *bytes, *result = NULL;
GdkTextureDownloader downloader;
GdkMemoryFormat format;
const FormatData *fdata = NULL;
@@ -292,9 +292,11 @@ gdk_save_tiff (GdkTexture *texture)
TIFFSetField (tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
TIFFSetField (tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
memtex = gdk_memory_texture_from_texture (texture, fdata->format);
data = gdk_memory_texture_get_data (memtex);
stride = gdk_memory_texture_get_stride (memtex);
gdk_texture_downloader_init (&downloader, texture);
gdk_texture_downloader_set_format (&downloader, fdata->format);
bytes = gdk_texture_downloader_download_bytes (&downloader, &stride);
gdk_texture_downloader_finish (&downloader);
data = g_bytes_get_data (bytes, NULL);
line = (const guchar *)data;
for (int y = 0; y < height; y++)
@@ -302,7 +304,7 @@ gdk_save_tiff (GdkTexture *texture)
if (TIFFWriteScanline (tif, (void *)line, y, 0) == -1)
{
TIFFClose (tif);
g_object_unref (memtex);
g_bytes_unref (bytes);
return NULL;
}
@@ -314,7 +316,7 @@ gdk_save_tiff (GdkTexture *texture)
g_assert (result);
g_object_unref (memtex);
g_bytes_unref (bytes);
return result;
}
+2
View File
@@ -43,6 +43,7 @@ gdk_public_sources = files([
'gdkseatdefault.c',
'gdksnapshot.c',
'gdktexture.c',
'gdktexturedownloader.c',
'gdkvulkancontext.c',
'gdksurface.c',
'gdkpopuplayout.c',
@@ -95,6 +96,7 @@ gdk_public_headers = files([
'gdkseat.h',
'gdksnapshot.h',
'gdktexture.h',
'gdktexturedownloader.h',
'gdktypes.h',
'gdkvulkancontext.h',
'gdksurface.h',
+1 -1
View File
@@ -87,7 +87,7 @@ gdk_wayland_app_launch_context_get_startup_notify_id (GAppLaunchContext *context
xdg_activation_token_v1_commit (token);
while (app_launch_data.token == NULL)
wl_display_dispatch_queue (display->wl_display, event_queue);
gdk_wayland_display_dispatch_queue (GDK_DISPLAY (display), event_queue);
xdg_activation_token_v1_destroy (token);
id = app_launch_data.token;
+14
View File
@@ -2694,3 +2694,17 @@ gdk_wayland_display_query_registry (GdkDisplay *display,
return FALSE;
}
void
gdk_wayland_display_dispatch_queue (GdkDisplay *display,
struct wl_event_queue *event_queue)
{
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
if (wl_display_dispatch_queue (display_wayland->wl_display, event_queue) == -1)
{
g_message ("Error %d (%s) dispatching to Wayland display.",
errno, g_strerror (errno));
_exit (1);
}
}
+3
View File
@@ -158,6 +158,9 @@ struct _GdkWaylandDisplayClass
gboolean gdk_wayland_display_prefers_ssd (GdkDisplay *display);
void gdk_wayland_display_dispatch_queue (GdkDisplay *display,
struct wl_event_queue *event_queue);
G_END_DECLS
#endif /* __GDK_WAYLAND_DISPLAY__ */
+8
View File
@@ -25,6 +25,7 @@
#include "gdkdisplay-wayland.h"
#include "gdksurface-wayland.h"
#include "gdksurface-wayland-private.h"
#include "gdkwaylanddisplay.h"
#include "gdkwaylandglcontext.h"
@@ -60,10 +61,17 @@ gdk_wayland_gl_context_end_frame (GdkDrawContext *draw_context,
cairo_region_t *painted)
{
GdkSurface *surface = gdk_draw_context_get_surface (draw_context);
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
int dx = impl->pending_buffer_offset_x;
int dy = impl->pending_buffer_offset_y;
gdk_wayland_surface_sync (surface);
gdk_wayland_surface_request_frame (surface);
if (wl_surface_get_version (impl->display_server.wl_surface) >=
WL_SURFACE_OFFSET_SINCE_VERSION)
wl_surface_offset (impl->display_server.wl_surface, dx, dy);
GDK_DRAW_CONTEXT_CLASS (gdk_wayland_gl_context_parent_class)->end_frame (draw_context, painted);
gdk_wayland_surface_notify_committed (surface);
+4 -3
View File
@@ -1334,8 +1334,6 @@ gdk_wayland_surface_present_popup (GdkWaylandPopup *wayland_popup,
GdkPopupLayout *layout)
{
GdkSurface *surface = GDK_SURFACE (wayland_popup);
GdkWaylandDisplay *display_wayland =
GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
GdkWaylandSurface *wayland_surface = GDK_WAYLAND_SURFACE (wayland_popup);
if (!wayland_surface->mapped)
@@ -1388,7 +1386,10 @@ gdk_wayland_surface_present_popup (GdkWaylandPopup *wayland_popup,
}
while (wayland_popup->display_server.xdg_popup && !is_relayout_finished (surface))
wl_display_dispatch_queue (display_wayland->wl_display, wayland_surface->event_queue);
{
gdk_wayland_display_dispatch_queue (surface->display,
wayland_surface->event_queue);
}
if (wayland_popup->display_server.xdg_popup)
{
+1 -22
View File
@@ -229,7 +229,7 @@ gdk_wayland_surface_update_size (GdkSurface *surface,
if (impl->display_server.egl_window)
wl_egl_window_resize (impl->display_server.egl_window, width * scale, height * scale, 0, 0);
if (impl->display_server.wl_surface)
if (impl->display_server.wl_surface && scale_changed)
wl_surface_set_buffer_scale (impl->display_server.wl_surface, scale);
gdk_surface_invalidate_rect (surface, NULL);
@@ -579,33 +579,12 @@ gdk_wayland_surface_attach_image (GdkSurface *surface,
}
}
static void
gdk_wayland_surface_sync_offset (GdkSurface *surface)
{
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
if (wl_surface_get_version (impl->display_server.wl_surface) <
WL_SURFACE_OFFSET_SINCE_VERSION)
return;
if (impl->pending_buffer_offset_x == 0 &&
impl->pending_buffer_offset_y == 0)
return;
wl_surface_offset (impl->display_server.wl_surface,
impl->pending_buffer_offset_x,
impl->pending_buffer_offset_y);
impl->pending_buffer_offset_x = 0;
impl->pending_buffer_offset_y = 0;
}
void
gdk_wayland_surface_sync (GdkSurface *surface)
{
gdk_wayland_surface_sync_shadow (surface);
gdk_wayland_surface_sync_opaque_region (surface);
gdk_wayland_surface_sync_input_region (surface);
gdk_wayland_surface_sync_offset (surface);
}
static gboolean
+4 -1
View File
@@ -2119,7 +2119,10 @@ gdk_wayland_toplevel_focus (GdkToplevel *toplevel,
xdg_activation_token_v1_commit (token);
while (startup_id == NULL)
wl_display_dispatch_queue (display_wayland->wl_display, event_queue);
{
gdk_wayland_display_dispatch_queue (GDK_DISPLAY (display_wayland),
event_queue);
}
xdg_activation_token_v1_destroy (token);
wl_event_queue_destroy (event_queue);
+1 -1
View File
@@ -1912,7 +1912,7 @@ drag_grab (GdkDrag *drag)
root = GDK_DISPLAY_XROOTWIN (display);
seat = gdk_device_get_seat (gdk_drag_get_device (drag));
capabilities = GDK_SEAT_CAPABILITY_ALL_POINTING;
capabilities = GDK_SEAT_CAPABILITY_ALL_POINTING | GDK_SEAT_CAPABILITY_KEYBOARD;
cursor = gdk_drag_get_cursor (drag, x11_drag->current_action);
g_set_object (&x11_drag->cursor, cursor);
+4
View File
@@ -250,6 +250,7 @@ collect_reused_child_nodes (GskRenderer *renderer,
/* Leaf nodes */
case GSK_TEXTURE_NODE:
case GSK_TEXTURE_SCALE_NODE:
case GSK_CAIRO_NODE:
case GSK_COLOR_NODE:
case GSK_BORDER_NODE:
@@ -269,6 +270,7 @@ collect_reused_child_nodes (GskRenderer *renderer,
case GSK_BLEND_NODE:
case GSK_CROSS_FADE_NODE:
case GSK_BLUR_NODE:
case GSK_MASK_NODE:
default:
@@ -845,6 +847,8 @@ gsk_broadway_renderer_add_node (GskRenderer *renderer,
}
break; /* Fallback */
case GSK_MASK_NODE:
case GSK_TEXTURE_SCALE_NODE:
case GSK_TEXT_NODE:
case GSK_RADIAL_GRADIENT_NODE:
case GSK_REPEATING_LINEAR_GRADIENT_NODE:
+17 -9
View File
@@ -27,8 +27,8 @@
#include <gdk/gdkglcontextprivate.h>
#include <gdk/gdkmemoryformatprivate.h>
#include <gdk/gdkmemorytextureprivate.h>
#include <gdk/gdkprofilerprivate.h>
#include <gdk/gdktexturedownloaderprivate.h>
#include <gsk/gskdebugprivate.h>
#include <gsk/gskroundedrectprivate.h>
@@ -570,7 +570,10 @@ gsk_gl_command_queue_end_draw (GskGLCommandQueue *self)
g_assert (self->batches.len > 0);
if (will_ignore_batch (self))
return;
{
self->in_draw = FALSE;
return;
}
batch = gsk_gl_command_batches_tail (&self->batches);
@@ -1356,7 +1359,8 @@ gsk_gl_command_queue_do_upload_texture (GskGLCommandQueue *self,
GdkGLContext *context;
const guchar *data;
gsize stride;
GdkMemoryTexture *memtex;
GBytes *bytes;
GdkTextureDownloader downloader;
GdkMemoryFormat data_format;
int width, height;
GLenum gl_internalformat;
@@ -1391,9 +1395,11 @@ gsk_gl_command_queue_do_upload_texture (GskGLCommandQueue *self,
}
}
memtex = gdk_memory_texture_from_texture (texture, data_format);
data = gdk_memory_texture_get_data (memtex);
stride = gdk_memory_texture_get_stride (memtex);
gdk_texture_downloader_init (&downloader, texture);
gdk_texture_downloader_set_format (&downloader, data_format);
bytes = gdk_texture_downloader_download_bytes (&downloader, &stride);
gdk_texture_downloader_finish (&downloader);
data = g_bytes_get_data (bytes, NULL);
bpp = gdk_memory_format_bytes_per_pixel (data_format);
glPixelStorei (GL_UNPACK_ALIGNMENT, gdk_memory_format_alignment (data_format));
@@ -1423,7 +1429,7 @@ gsk_gl_command_queue_do_upload_texture (GskGLCommandQueue *self,
}
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
g_object_unref (memtex);
g_bytes_unref (bytes);
}
int
@@ -1439,8 +1445,7 @@ gsk_gl_command_queue_upload_texture (GskGLCommandQueue *self,
g_assert (GSK_IS_GL_COMMAND_QUEUE (self));
g_assert (!GDK_IS_GL_TEXTURE (texture));
g_assert (min_filter == GL_LINEAR || min_filter == GL_NEAREST);
g_assert (mag_filter == GL_LINEAR || min_filter == GL_NEAREST);
g_assert (mag_filter == GL_LINEAR || mag_filter == GL_NEAREST);
width = gdk_texture_get_width (texture);
height = gdk_texture_get_height (texture);
@@ -1464,6 +1469,9 @@ gsk_gl_command_queue_upload_texture (GskGLCommandQueue *self,
gsk_gl_command_queue_do_upload_texture (self, texture);
if (min_filter == GL_LINEAR_MIPMAP_LINEAR)
glGenerateMipmap (GL_TEXTURE_2D);
/* Restore previous texture state if any */
if (self->attachments->textures[0].id > 0)
glBindTexture (self->attachments->textures[0].target,
+23 -14
View File
@@ -35,7 +35,6 @@
#include "gskgliconlibraryprivate.h"
#include "gskglprogramprivate.h"
#include "gskglshadowlibraryprivate.h"
#include "gskgltextureprivate.h"
#include "fp16private.h"
#include <gdk/gdkglcontextprivate.h>
@@ -753,7 +752,7 @@ gsk_gl_driver_load_texture (GskGLDriver *self,
{
if ((t = gdk_texture_get_render_data (texture, self)))
{
if (t->min_filter == min_filter && t->mag_filter == mag_filter)
if (t->min_filter == min_filter && t->mag_filter == mag_filter && t->texture_id)
return t->texture_id;
}
@@ -1195,6 +1194,10 @@ gsk_gl_driver_create_command_queue (GskGLDriver *self,
void
gsk_gl_driver_add_texture_slices (GskGLDriver *self,
GdkTexture *texture,
int min_filter,
int mag_filter,
guint min_cols,
guint min_rows,
GskGLTextureSlice **out_slices,
guint *out_n_slices)
{
@@ -1216,31 +1219,37 @@ gsk_gl_driver_add_texture_slices (GskGLDriver *self,
/* XXX: Too much? */
max_texture_size = self->command_queue->max_texture_size / 4;
tex_width = texture->width;
tex_height = texture->height;
cols = (texture->width / max_texture_size) + 1;
rows = (texture->height / max_texture_size) + 1;
cols = MAX ((texture->width / max_texture_size) + 1, min_cols);
rows = MAX ((texture->height / max_texture_size) + 1, min_rows);
n_slices = cols * rows;
if ((t = gdk_texture_get_render_data (texture, self)))
{
*out_slices = t->slices;
*out_n_slices = t->n_slices;
return;
if (t->n_slices == n_slices)
{
*out_slices = t->slices;
*out_n_slices = t->n_slices;
return;
}
gdk_texture_clear_render_data (texture);
}
n_slices = cols * rows;
slices = g_new0 (GskGLTextureSlice, n_slices);
memtex = gdk_memory_texture_from_texture (texture,
gdk_texture_get_format (texture));
for (guint col = 0; col < cols; col ++)
for (guint col = 0; col < cols; col++)
{
int slice_width = MIN (max_texture_size, texture->width - x);
int slice_width = col + 1 < cols ? tex_width / cols : tex_width - x;
for (guint row = 0; row < rows; row ++)
for (guint row = 0; row < rows; row++)
{
int slice_height = MIN (max_texture_size, texture->height - y);
int slice_height = row + 1 < rows ? tex_height / rows : tex_height - y;
int slice_index = (col * rows) + row;
GdkTexture *subtex;
guint texture_id;
@@ -1250,7 +1259,7 @@ gsk_gl_driver_add_texture_slices (GskGLDriver *self,
slice_width, slice_height);
texture_id = gsk_gl_command_queue_upload_texture (self->command_queue,
subtex,
GL_NEAREST, GL_NEAREST);
min_filter, mag_filter);
g_object_unref (subtex);
slices[slice_index].rect.x = x;
+15 -4
View File
@@ -177,6 +177,10 @@ GskGLTexture * gsk_gl_driver_mark_texture_permanent (GskGLDriver *s
guint texture_id);
void gsk_gl_driver_add_texture_slices (GskGLDriver *self,
GdkTexture *texture,
int min_filter,
int mag_filter,
guint min_cols,
guint min_rows,
GskGLTextureSlice **out_slices,
guint *out_n_slices);
GskGLProgram * gsk_gl_driver_lookup_shader (GskGLDriver *self,
@@ -228,6 +232,10 @@ gsk_gl_driver_lookup_texture (GskGLDriver *self,
static inline void
gsk_gl_driver_slice_texture (GskGLDriver *self,
GdkTexture *texture,
int min_filter,
int mag_filter,
guint min_cols,
guint min_rows,
GskGLTextureSlice **out_slices,
guint *out_n_slices)
{
@@ -235,12 +243,15 @@ gsk_gl_driver_slice_texture (GskGLDriver *self,
if ((t = gdk_texture_get_render_data (texture, self)))
{
*out_slices = t->slices;
*out_n_slices = t->n_slices;
return;
if (min_cols == 0 && min_rows == 0)
{
*out_slices = t->slices;
*out_n_slices = t->n_slices;
return;
}
}
gsk_gl_driver_add_texture_slices (self, texture, out_slices, out_n_slices);
gsk_gl_driver_add_texture_slices (self, texture, min_filter, mag_filter, min_cols, min_rows, out_slices, out_n_slices);
}
G_END_DECLS
+5
View File
@@ -60,6 +60,11 @@ GSK_GL_DEFINE_PROGRAM (linear_gradient,
GSK_GL_ADD_UNIFORM (3, LINEAR_GRADIENT_POINTS, u_points)
GSK_GL_ADD_UNIFORM (4, LINEAR_GRADIENT_REPEAT, u_repeat))
GSK_GL_DEFINE_PROGRAM (mask,
GSK_GL_SHADER_SINGLE (GSK_GL_SHADER_RESOURCE ("mask.glsl")),
GSK_GL_ADD_UNIFORM (1, MASK_SOURCE, u_mask)
GSK_GL_ADD_UNIFORM (2, MASK_MODE, u_mode))
GSK_GL_DEFINE_PROGRAM (outset_shadow,
GSK_GL_SHADER_SINGLE (GSK_GL_SHADER_RESOURCE ("outset_shadow.glsl")),
GSK_GL_ADD_UNIFORM (1, OUTSET_SHADOW_OUTLINE_RECT, u_outline_rect))
+224 -13
View File
@@ -3277,6 +3277,60 @@ gsk_gl_render_job_visit_blend_node (GskGLRenderJob *job,
gsk_gl_render_job_end_draw (job);
}
static inline void
gsk_gl_render_job_visit_mask_node (GskGLRenderJob *job,
const GskRenderNode *node)
{
const GskRenderNode *source = gsk_mask_node_get_source (node);
const GskRenderNode *mask = gsk_mask_node_get_mask (node);
GskGLRenderOffscreen source_offscreen = {0};
GskGLRenderOffscreen mask_offscreen = {0};
source_offscreen.bounds = &node->bounds;
source_offscreen.force_offscreen = TRUE;
source_offscreen.reset_clip = TRUE;
mask_offscreen.bounds = &node->bounds;
mask_offscreen.force_offscreen = TRUE;
mask_offscreen.reset_clip = TRUE;
mask_offscreen.do_not_cache = TRUE;
/* TODO: We create 2 textures here as big as the mask node, but both
* nodes might be a lot smaller than that.
*/
if (!gsk_gl_render_job_visit_node_with_offscreen (job, source, &source_offscreen))
{
gsk_gl_render_job_visit_node (job, source);
return;
}
g_assert (source_offscreen.was_offscreen);
if (!gsk_gl_render_job_visit_node_with_offscreen (job, mask, &mask_offscreen))
{
return;
}
g_assert (mask_offscreen.was_offscreen);
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, mask));
gsk_gl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
GL_TEXTURE0,
source_offscreen.texture_id);
gsk_gl_program_set_uniform_texture (job->current_program,
UNIFORM_MASK_SOURCE, 0,
GL_TEXTURE_2D,
GL_TEXTURE1,
mask_offscreen.texture_id);
gsk_gl_program_set_uniform1i (job->current_program,
UNIFORM_MASK_MODE, 0,
gsk_mask_node_get_mask_mode (node));
gsk_gl_render_job_draw_offscreen_rect (job, &node->bounds);
gsk_gl_render_job_end_draw (job);
}
static inline void
gsk_gl_render_job_visit_color_matrix_node (GskGLRenderJob *job,
const GskRenderNode *node)
@@ -3443,9 +3497,13 @@ gsk_gl_render_job_visit_gl_shader_node (GskGLRenderJob *job,
static void
gsk_gl_render_job_upload_texture (GskGLRenderJob *job,
GdkTexture *texture,
int min_filter,
int mag_filter,
GskGLRenderOffscreen *offscreen)
{
if (gsk_gl_texture_library_can_cache ((GskGLTextureLibrary *)job->driver->icons_library,
if (min_filter == GL_LINEAR &&
mag_filter == GL_LINEAR &&
gsk_gl_texture_library_can_cache ((GskGLTextureLibrary *)job->driver->icons_library,
texture->width,
texture->height) &&
!GDK_IS_GL_TEXTURE (texture))
@@ -3458,16 +3516,16 @@ gsk_gl_render_job_upload_texture (GskGLRenderJob *job,
}
else
{
offscreen->texture_id = gsk_gl_driver_load_texture (job->driver, texture, GL_LINEAR, GL_LINEAR);
offscreen->texture_id = gsk_gl_driver_load_texture (job->driver, texture, min_filter, mag_filter);
init_full_texture_region (offscreen);
}
}
static inline void
gsk_gl_render_job_visit_texture_node (GskGLRenderJob *job,
const GskRenderNode *node)
gsk_gl_render_job_visit_texture (GskGLRenderJob *job,
GdkTexture *texture,
const graphene_rect_t *bounds)
{
GdkTexture *texture = gsk_texture_node_get_texture (node);
int max_texture_size = job->command_queue->max_texture_size;
if G_LIKELY (texture->width <= max_texture_size &&
@@ -3475,7 +3533,7 @@ gsk_gl_render_job_visit_texture_node (GskGLRenderJob *job,
{
GskGLRenderOffscreen offscreen = {0};
gsk_gl_render_job_upload_texture (job, texture, &offscreen);
gsk_gl_render_job_upload_texture (job, texture, GL_LINEAR, GL_LINEAR, &offscreen);
g_assert (offscreen.texture_id);
g_assert (offscreen.was_offscreen == FALSE);
@@ -3486,21 +3544,21 @@ gsk_gl_render_job_visit_texture_node (GskGLRenderJob *job,
GL_TEXTURE_2D,
GL_TEXTURE0,
offscreen.texture_id);
gsk_gl_render_job_draw_offscreen (job, &node->bounds, &offscreen);
gsk_gl_render_job_draw_offscreen (job, bounds, &offscreen);
gsk_gl_render_job_end_draw (job);
}
else
{
float min_x = job->offset_x + node->bounds.origin.x;
float min_y = job->offset_y + node->bounds.origin.y;
float max_x = min_x + node->bounds.size.width;
float max_y = min_y + node->bounds.size.height;
float min_x = job->offset_x + bounds->origin.x;
float min_y = job->offset_y + bounds->origin.y;
float max_x = min_x + bounds->size.width;
float max_y = min_y + bounds->size.height;
float scale_x = (max_x - min_x) / texture->width;
float scale_y = (max_y - min_y) / texture->height;
GskGLTextureSlice *slices = NULL;
guint n_slices = 0;
gsk_gl_driver_slice_texture (job->driver, texture, &slices, &n_slices);
gsk_gl_driver_slice_texture (job->driver, texture, GL_NEAREST, GL_NEAREST, 0, 0, &slices, &n_slices);
g_assert (slices != NULL);
g_assert (n_slices > 0);
@@ -3535,6 +3593,151 @@ gsk_gl_render_job_visit_texture_node (GskGLRenderJob *job,
}
}
static inline void
gsk_gl_render_job_visit_texture_node (GskGLRenderJob *job,
const GskRenderNode *node)
{
GdkTexture *texture = gsk_texture_node_get_texture (node);
const graphene_rect_t *bounds = &node->bounds;
gsk_gl_render_job_visit_texture (job, texture, bounds);
}
static inline void
gsk_gl_render_job_visit_texture_scale_node (GskGLRenderJob *job,
const GskRenderNode *node)
{
GdkTexture *texture = gsk_texture_scale_node_get_texture (node);
const graphene_rect_t *bounds = &node->bounds;
GskScalingFilter scaling_filter = gsk_texture_scale_node_get_filter (node);
int min_filters[] = { GL_LINEAR, GL_NEAREST, GL_LINEAR_MIPMAP_LINEAR };
int mag_filters[] = { GL_LINEAR, GL_NEAREST, GL_LINEAR };
int min_filter = min_filters[scaling_filter];
int mag_filter = mag_filters[scaling_filter];
int max_texture_size = job->command_queue->max_texture_size;
if (scaling_filter == GSK_SCALING_FILTER_LINEAR)
{
gsk_gl_render_job_visit_texture (job, texture, bounds);
return;
}
if G_LIKELY (texture->width <= max_texture_size &&
texture->height <= max_texture_size)
{
GskGLRenderTarget *render_target;
GskGLRenderOffscreen offscreen = {0};
graphene_rect_t viewport;
graphene_rect_t prev_viewport;
graphene_matrix_t prev_projection;
float prev_alpha;
guint prev_fbo;
guint texture_id;
viewport = GRAPHENE_RECT_INIT (0, 0,
bounds->size.width,
bounds->size.height);
if (!gsk_gl_driver_create_render_target (job->driver,
(int) ceilf (viewport.size.width),
(int) ceilf (viewport.size.height),
get_target_format (job, node),
GL_LINEAR, GL_LINEAR,
&render_target))
{
/* viewport is too big, slice the texture and try again */
goto slice;
}
gsk_gl_render_job_upload_texture (job, texture, min_filter, mag_filter, &offscreen);
g_assert (offscreen.texture_id);
g_assert (offscreen.was_offscreen == FALSE);
gsk_gl_render_job_set_viewport (job, &viewport, &prev_viewport);
gsk_gl_render_job_set_projection_from_rect (job, &viewport, &prev_projection);
gsk_gl_render_job_set_modelview (job, NULL);
prev_alpha = gsk_gl_render_job_set_alpha (job, 1.0f);
gsk_gl_render_job_push_clip (job, &GSK_ROUNDED_RECT_INIT_FROM_RECT (viewport));
prev_fbo = gsk_gl_command_queue_bind_framebuffer (job->command_queue, render_target->framebuffer_id);
gsk_gl_command_queue_clear (job->command_queue, 0, &viewport);
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
gsk_gl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
GL_TEXTURE0,
offscreen.texture_id);
gsk_gl_render_job_draw_offscreen (job, &viewport, &offscreen);
gsk_gl_render_job_end_draw (job);
gsk_gl_render_job_pop_clip (job);
gsk_gl_render_job_pop_modelview (job);
gsk_gl_render_job_set_viewport (job, &prev_viewport, NULL);
gsk_gl_render_job_set_projection (job, &prev_projection);
gsk_gl_render_job_set_alpha (job, prev_alpha);
gsk_gl_command_queue_bind_framebuffer (job->command_queue, prev_fbo);
texture_id = gsk_gl_driver_release_render_target (job->driver, render_target, FALSE);
gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
gsk_gl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
GL_TEXTURE0,
texture_id);
gsk_gl_render_job_draw_offscreen_rect (job, bounds);
gsk_gl_render_job_end_draw (job);
}
else
slice:
{
float min_x = bounds->origin.x;
float min_y = bounds->origin.y;
float max_x = min_x + bounds->size.width;
float max_y = min_y + bounds->size.height;
float scale_x = (max_x - min_x) / texture->width;
float scale_y = (max_y - min_y) / texture->height;
GskGLTextureSlice *slices = NULL;
guint n_slices = 0;
GdkGLContext *context = gsk_gl_driver_get_context (job->driver);
guint rows, cols;
/* Slice enough that neither the original texture nor the scaled texture
* exceed the texture size limit
*/
cols = (int)(MAX (bounds->size.width, texture->width) / (max_texture_size / 4)) + 1;
rows = (int)(MAX (bounds->size.height, texture->height) / (max_texture_size / 4)) + 1;
gsk_gl_driver_slice_texture (job->driver, texture, GL_NEAREST, GL_NEAREST, cols, rows, &slices, &n_slices);
g_assert (slices != NULL);
g_assert (n_slices > 0);
for (guint i = 0; i < n_slices; i ++)
{
const GskGLTextureSlice *slice = &slices[i];
float x1, x2, y1, y2;
GdkTexture *sub_texture;
GskRenderNode *sub_node;
x1 = min_x + (scale_x * slice->rect.x);
x2 = x1 + (slice->rect.width * scale_x);
y1 = min_y + (scale_y * slice->rect.y);
y2 = y1 + (slice->rect.height * scale_y);
sub_texture = gdk_gl_texture_new (context, slice->texture_id, slice->rect.width, slice->rect.height, NULL, NULL);
sub_node = gsk_texture_scale_node_new (sub_texture, &GRAPHENE_RECT_INIT (x1, y1, x2 - x1, y2 - y1), scaling_filter);
gsk_gl_render_job_visit_node (job, sub_node);
gsk_render_node_unref (sub_node);
g_object_unref (sub_texture);
}
}
}
static inline void
gsk_gl_render_job_visit_repeat_node (GskGLRenderJob *job,
const GskRenderNode *node)
@@ -3720,6 +3923,10 @@ gsk_gl_render_job_visit_node (GskGLRenderJob *job,
gsk_gl_render_job_visit_as_fallback (job, node);
break;
case GSK_MASK_NODE:
gsk_gl_render_job_visit_mask_node (job, node);
break;
case GSK_OPACITY_NODE:
gsk_gl_render_job_visit_opacity_node (job, node);
break;
@@ -3762,6 +3969,10 @@ gsk_gl_render_job_visit_node (GskGLRenderJob *job,
gsk_gl_render_job_visit_texture_node (job, node);
break;
case GSK_TEXTURE_SCALE_NODE:
gsk_gl_render_job_visit_texture_scale_node (job, node);
break;
case GSK_TRANSFORM_NODE:
gsk_gl_render_job_visit_transform_node (job, node);
break;
@@ -3808,7 +4019,7 @@ gsk_gl_render_job_visit_node_with_offscreen (GskGLRenderJob *job,
offscreen->force_offscreen == FALSE)
{
GdkTexture *texture = gsk_texture_node_get_texture (node);
gsk_gl_render_job_upload_texture (job, texture, offscreen);
gsk_gl_render_job_upload_texture (job, texture, GL_LINEAR, GL_LINEAR, offscreen);
g_assert (offscreen->was_offscreen == FALSE);
return TRUE;
}
+2 -1
View File
@@ -112,7 +112,8 @@ gsk_gl_texture_library_real_compact (GskGLTextureLibrary *self,
{
if (!entry->accessed)
{
gsk_gl_driver_release_texture (self->driver, entry->texture);
if (entry->texture)
gsk_gl_driver_release_texture (self->driver, entry->texture);
g_hash_table_iter_remove (&iter);
dropped++;
}
+33
View File
@@ -0,0 +1,33 @@
// VERTEX_SHADER:
// mask.glsl
void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
vUv = vec2(aUv.x, aUv.y);
}
// FRAGMENT_SHADER:
// mask.glsl
uniform int u_mode;
uniform sampler2D u_mask;
void main() {
vec4 source = GskTexture(u_source, vUv);
vec4 mask = GskTexture(u_mask, vUv);
float mask_value;
if (u_mode == 0)
mask_value = mask.a;
else if (u_mode == 1)
mask_value = 1.0 - mask.a;
else if (u_mode == 2)
mask_value = (0.2126 * mask.r + 0.7152 * mask.g + 0.0722 * mask.b) * mask.a;
else if (u_mode == 3)
mask_value = 1.0 - (0.2126 * mask.r + 0.7152 * mask.g + 0.0722 * mask.b) * mask.a;
else
mask_value = 0.0;
gskSetOutputColor(vec4 (source * mask_value));
}
+25 -1
View File
@@ -50,6 +50,8 @@
* @GSK_BLUR_NODE: A node that applies a blur
* @GSK_DEBUG_NODE: Debug information that does not affect the rendering
* @GSK_GL_SHADER_NODE: A node that uses OpenGL fragment shaders to render
* @GSK_TEXTURE_SCALE_NODE: A node drawing a `GdkTexture` scaled and filtered (Since: 4.10)
* @GSK_MASK_NODE: A node that masks one child with another (Since: 4.10)
* The type of a node determines what the node is rendering.
*/
@@ -79,7 +81,9 @@ typedef enum {
GSK_TEXT_NODE,
GSK_BLUR_NODE,
GSK_DEBUG_NODE,
GSK_GL_SHADER_NODE
GSK_GL_SHADER_NODE,
GSK_TEXTURE_SCALE_NODE,
GSK_MASK_NODE
} GskRenderNodeType;
/**
@@ -251,5 +255,25 @@ typedef enum
GSK_GL_UNIFORM_TYPE_VEC4,
} GskGLUniformType;
/**
* GskMaskMode:
* @GSK_MASK_MODE_ALPHA: Use the alpha channel of the mask
* @GSK_MASK_MODE_INVERTED_ALPHA: Use the inverted alpha channel of the mask
* @GSK_MASK_MODE_LUMINANCE: Use the luminance of the mask,
* multiplied by mask alpha
* @GSK_MASK_MODE_INVERTED_LUMINANCE: Use the inverted luminance of the mask,
* multiplied by mask alpha
*
* The mask modes available for mask nodes.
*
* Since: 4.10
*/
typedef enum
{
GSK_MASK_MODE_ALPHA,
GSK_MASK_MODE_INVERTED_ALPHA,
GSK_MASK_MODE_LUMINANCE,
GSK_MASK_MODE_INVERTED_LUMINANCE
} GskMaskMode;
#endif /* __GSK_TYPES_H__ */
+29 -1
View File
@@ -142,6 +142,7 @@ GskRenderNode * gsk_render_node_deserialize (GBytes
#define GSK_TYPE_DEBUG_NODE (gsk_debug_node_get_type())
#define GSK_TYPE_COLOR_NODE (gsk_color_node_get_type())
#define GSK_TYPE_TEXTURE_NODE (gsk_texture_node_get_type())
#define GSK_TYPE_TEXTURE_SCALE_NODE (gsk_texture_scale_node_get_type())
#define GSK_TYPE_LINEAR_GRADIENT_NODE (gsk_linear_gradient_node_get_type())
#define GSK_TYPE_REPEATING_LINEAR_GRADIENT_NODE (gsk_repeating_linear_gradient_node_get_type())
#define GSK_TYPE_RADIAL_GRADIENT_NODE (gsk_radial_gradient_node_get_type())
@@ -163,11 +164,13 @@ GskRenderNode * gsk_render_node_deserialize (GBytes
#define GSK_TYPE_CROSS_FADE_NODE (gsk_cross_fade_node_get_type())
#define GSK_TYPE_TEXT_NODE (gsk_text_node_get_type())
#define GSK_TYPE_BLUR_NODE (gsk_blur_node_get_type())
#define GSK_TYPE_MASK_NODE (gsk_mask_node_get_type())
#define GSK_TYPE_GL_SHADER_NODE (gsk_gl_shader_node_get_type())
typedef struct _GskDebugNode GskDebugNode;
typedef struct _GskColorNode GskColorNode;
typedef struct _GskTextureNode GskTextureNode;
typedef struct _GskTextureScaleNode GskTextureScaleNode;
typedef struct _GskLinearGradientNode GskLinearGradientNode;
typedef struct _GskRepeatingLinearGradientNode GskRepeatingLinearGradientNode;
typedef struct _GskRadialGradientNode GskRadialGradientNode;
@@ -189,6 +192,7 @@ typedef struct _GskBlendNode GskBlendNode;
typedef struct _GskCrossFadeNode GskCrossFadeNode;
typedef struct _GskTextNode GskTextNode;
typedef struct _GskBlurNode GskBlurNode;
typedef struct _GskMaskNode GskMaskNode;
typedef struct _GskGLShaderNode GskGLShaderNode;
GDK_AVAILABLE_IN_ALL
@@ -217,6 +221,17 @@ GskRenderNode * gsk_texture_node_new (GdkTexture
GDK_AVAILABLE_IN_ALL
GdkTexture * gsk_texture_node_get_texture (const GskRenderNode *node) G_GNUC_PURE;
GDK_AVAILABLE_IN_4_10
GType gsk_texture_scale_node_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_4_10
GskRenderNode * gsk_texture_scale_node_new (GdkTexture *texture,
const graphene_rect_t *bounds,
GskScalingFilter filter);
GDK_AVAILABLE_IN_4_10
GdkTexture * gsk_texture_scale_node_get_texture (const GskRenderNode *node) G_GNUC_PURE;
GDK_AVAILABLE_IN_4_10
GskScalingFilter gsk_texture_scale_node_get_filter (const GskRenderNode *node) G_GNUC_PURE;
GDK_AVAILABLE_IN_ALL
GType gsk_linear_gradient_node_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
@@ -516,8 +531,21 @@ GskRenderNode * gsk_blur_node_get_child (const GskRender
GDK_AVAILABLE_IN_ALL
float gsk_blur_node_get_radius (const GskRenderNode *node) G_GNUC_PURE;
GDK_AVAILABLE_IN_4_10
GType gsk_mask_node_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_4_10
GskRenderNode * gsk_mask_node_new (GskRenderNode *source,
GskRenderNode *mask,
GskMaskMode mask_mode);
GDK_AVAILABLE_IN_4_10
GskRenderNode * gsk_mask_node_get_source (const GskRenderNode *node);
GDK_AVAILABLE_IN_4_10
GskRenderNode * gsk_mask_node_get_mask (const GskRenderNode *node);
GDK_AVAILABLE_IN_4_10
GskMaskMode gsk_mask_node_get_mask_mode (const GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
GType gsk_gl_shader_node_get_type (void) G_GNUC_CONST;
GType gsk_gl_shader_node_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_gl_shader_node_new (GskGLShader *shader,
const graphene_rect_t *bounds,
+501 -42
View File
@@ -58,7 +58,7 @@ rectangle_init_from_graphene (cairo_rectangle_int_t *cairo,
cairo->height = ceilf (graphene->origin.y + graphene->size.height) - cairo->y;
}
/*** GSK_COLOR_NODE ***/
/* {{{ GSK_COLOR_NODE */
/**
* GskColorNode:
@@ -147,7 +147,8 @@ gsk_color_node_new (const GdkRGBA *rgba,
return node;
}
/*** GSK_LINEAR_GRADIENT_NODE ***/
/* }}} */
/* {{{ GSK_LINEAR_GRADIENT_NODE */
/**
* GskRepeatingLinearGradientNode:
@@ -420,7 +421,8 @@ gsk_linear_gradient_node_get_color_stops (const GskRenderNode *node,
return self->stops;
}
/*** GSK_RADIAL_GRADIENT_NODE ***/
/* }}} */
/* {{{ GSK_RADIAL_GRADIENT_NODE */
/**
* GskRepeatingRadialGradientNode:
@@ -790,7 +792,8 @@ gsk_radial_gradient_node_get_end (const GskRenderNode *node)
return self->end;
}
/*** GSK_CONIC_GRADIENT_NODE ***/
/* }}} */
/* {{{ GSK_CONIC_GRADIENT_NODE */
/**
* GskConicGradientNode:
@@ -1147,7 +1150,8 @@ gsk_conic_gradient_node_get_angle (const GskRenderNode *node)
return self->angle;
}
/*** GSK_BORDER_NODE ***/
/* }}} */
/* {{{ GSK_BORDER_NODE */
/**
* GskBorderNode:
@@ -1459,7 +1463,8 @@ gsk_border_node_get_uniform_color (const GskRenderNode *self)
return node->uniform_color;
}
/*** GSK_TEXTURE_NODE ***/
/* }}} */
/* {{{ GSK_TEXTURE_NODE */
/**
* GskTextureNode:
@@ -1576,7 +1581,195 @@ gsk_texture_node_new (GdkTexture *texture,
return node;
}
/*** GSK_INSET_SHADOW_NODE ***/
/* }}} */
/* {{{ GSK_TEXTURE_SCALE_NODE */
/**
* GskTextureScaleNode:
*
* A render node for a `GdkTexture`.
*
* Since: 4.10
*/
struct _GskTextureScaleNode
{
GskRenderNode render_node;
GdkTexture *texture;
GskScalingFilter filter;
};
static void
gsk_texture_scale_node_finalize (GskRenderNode *node)
{
GskTextureScaleNode *self = (GskTextureScaleNode *) node;
GskRenderNodeClass *parent_class = g_type_class_peek (g_type_parent (GSK_TYPE_TEXTURE_SCALE_NODE));
g_clear_object (&self->texture);
parent_class->finalize (node);
}
static void
gsk_texture_scale_node_draw (GskRenderNode *node,
cairo_t *cr)
{
GskTextureScaleNode *self = (GskTextureScaleNode *) node;
cairo_surface_t *surface;
cairo_pattern_t *pattern;
cairo_matrix_t matrix;
cairo_filter_t filters[] = {
CAIRO_FILTER_BILINEAR,
CAIRO_FILTER_NEAREST,
CAIRO_FILTER_GOOD,
};
cairo_t *cr2;
cairo_surface_t *surface2;
surface2 = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
(int) ceilf (node->bounds.size.width),
(int) ceilf (node->bounds.size.height));
cr2 = cairo_create (surface2);
cairo_set_source_rgba (cr2, 0, 0, 0, 0);
cairo_paint (cr2);
surface = gdk_texture_download_surface (self->texture);
pattern = cairo_pattern_create_for_surface (surface);
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD);
cairo_matrix_init_scale (&matrix,
gdk_texture_get_width (self->texture) / node->bounds.size.width,
gdk_texture_get_height (self->texture) / node->bounds.size.height);
cairo_pattern_set_matrix (pattern, &matrix);
cairo_pattern_set_filter (pattern, filters[self->filter]);
cairo_set_source (cr2, pattern);
cairo_pattern_destroy (pattern);
cairo_surface_destroy (surface);
cairo_rectangle (cr2, 0, 0, node->bounds.size.width, node->bounds.size.height);
cairo_fill (cr2);
cairo_destroy (cr2);
cairo_save (cr);
pattern = cairo_pattern_create_for_surface (surface2);
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD);
cairo_matrix_init_identity (&matrix);
cairo_matrix_translate (&matrix,
-node->bounds.origin.x,
-node->bounds.origin.y);
cairo_pattern_set_matrix (pattern, &matrix);
cairo_set_source (cr, pattern);
cairo_pattern_destroy (pattern);
cairo_surface_destroy (surface2);
gsk_cairo_rectangle (cr, &node->bounds);
cairo_fill (cr);
cairo_restore (cr);
}
static void
gsk_texture_scale_node_diff (GskRenderNode *node1,
GskRenderNode *node2,
cairo_region_t *region)
{
GskTextureScaleNode *self1 = (GskTextureScaleNode *) node1;
GskTextureScaleNode *self2 = (GskTextureScaleNode *) node2;
if (graphene_rect_equal (&node1->bounds, &node2->bounds) &&
self1->texture == self2->texture &&
self1->filter == self2->filter)
return;
gsk_render_node_diff_impossible (node1, node2, region);
}
/**
* gsk_texture_scale_node_get_texture:
* @node: (type GskTextureScaleNode): a `GskRenderNode` of type %GSK_TEXTURE_SCALE_NODE
*
* Retrieves the `GdkTexture` used when creating this `GskRenderNode`.
*
* Returns: (transfer none): the `GdkTexture`
*
* Since: 4.10
*/
GdkTexture *
gsk_texture_scale_node_get_texture (const GskRenderNode *node)
{
const GskTextureScaleNode *self = (const GskTextureScaleNode *) node;
return self->texture;
}
/**
* gsk_texture_scale_node_get_filter:
* @node: (type GskTextureScaleNode): a `GskRenderNode` of type %GSK_TEXTURE_SCALE_NODE
*
* Retrieves the `GskScalingFilter` used when creating this `GskRenderNode`.
*
* Returns: (transfer none): the `GskScalingFilter`
*
* Since: 4.10
*/
GskScalingFilter
gsk_texture_scale_node_get_filter (const GskRenderNode *node)
{
const GskTextureScaleNode *self = (const GskTextureScaleNode *) node;
return self->filter;
}
/**
* gsk_texture_scale_node_new:
* @texture: the texture to scale
* @bounds: the size of the texture to scale to
* @filter: how to scale the texture
*
* Creates a node that scales the texture to the size given by the
* bounds and the filter and then places it at the bounds' position.
*
* This node is intended for tight control over scaling applied
* to a texture, such as in image editors and requires the
* application to be aware of the whole render tree as further
* transforms may be applied that conflict with the desired effect
* of this node.
*
* Returns: (transfer full) (type GskTextureScaleNode): A new `GskRenderNode`
*
* Since: 4.10
*/
GskRenderNode *
gsk_texture_scale_node_new (GdkTexture *texture,
const graphene_rect_t *bounds,
GskScalingFilter filter)
{
GskTextureScaleNode *self;
GskRenderNode *node;
g_return_val_if_fail (GDK_IS_TEXTURE (texture), NULL);
g_return_val_if_fail (bounds != NULL, NULL);
self = gsk_render_node_alloc (GSK_TEXTURE_SCALE_NODE);
node = (GskRenderNode *) self;
node->offscreen_for_opacity = FALSE;
self->texture = g_object_ref (texture);
graphene_rect_init_from_rect (&node->bounds, bounds);
self->filter = filter;
node->prefers_high_depth = gdk_memory_format_prefers_high_depth (gdk_texture_get_format (texture));
return node;
}
/* }}} */
/* {{{ GSK_INSET_SHADOW_NODE */
/**
* GskInsetShadowNode:
@@ -2132,7 +2325,8 @@ gsk_inset_shadow_node_get_blur_radius (const GskRenderNode *node)
return self->blur_radius;
}
/*** GSK_OUTSET_SHADOW_NODE ***/
/* }}} */
/* {{{ GSK_OUTSET_SHADOW_NODE */
/**
* GskOutsetShadowNode:
@@ -2438,7 +2632,8 @@ gsk_outset_shadow_node_get_blur_radius (const GskRenderNode *node)
return self->blur_radius;
}
/*** GSK_CAIRO_NODE ***/
/* }}} */
/* {{{ GSK_CAIRO_NODE */
/**
* GskCairoNode:
@@ -2576,7 +2771,8 @@ gsk_cairo_node_get_draw_context (GskRenderNode *node)
return res;
}
/**** GSK_CONTAINER_NODE ***/
/* }}} */
/* {{{ GSK_CONTAINER_NODE */
/**
* GskContainerNode:
@@ -2835,7 +3031,8 @@ gsk_container_node_is_disjoint (const GskRenderNode *node)
return self->disjoint;
}
/*** GSK_TRANSFORM_NODE ***/
/* }}} */
/* {{{ GSK_TRANSFORM_NODE */
/**
* GskTransformNode:
@@ -3058,7 +3255,8 @@ gsk_transform_node_get_translate (const GskRenderNode *node,
*dy = self->dy;
}
/*** GSK_OPACITY_NODE ***/
/* }}} */
/* {{{ GSK_OPACITY_NODE */
/**
* GskOpacityNode:
@@ -3185,7 +3383,8 @@ gsk_opacity_node_get_opacity (const GskRenderNode *node)
return self->opacity;
}
/*** GSK_COLOR_MATRIX_NODE ***/
/* }}} */
/* {{{ GSK_COLOR_MATRIX_NODE */
/**
* GskColorMatrixNode:
@@ -3213,29 +3412,18 @@ gsk_color_matrix_node_finalize (GskRenderNode *node)
}
static void
gsk_color_matrix_node_draw (GskRenderNode *node,
cairo_t *cr)
apply_color_matrix_to_pattern (cairo_pattern_t *pattern,
const graphene_matrix_t *color_matrix,
const graphene_vec4_t *color_offset,
gboolean multiply_alpha)
{
GskColorMatrixNode *self = (GskColorMatrixNode *) node;
cairo_pattern_t *pattern;
cairo_surface_t *surface, *image_surface;
graphene_vec4_t pixel;
guint32* pixel_data;
guchar *data;
gsize x, y, width, height, stride;
float alpha;
graphene_vec4_t pixel;
guint32* pixel_data;
cairo_save (cr);
/* clip so the push_group() creates a smaller surface */
gsk_cairo_rectangle (cr, &node->bounds);
cairo_clip (cr);
cairo_push_group (cr);
gsk_render_node_draw (self->child, cr);
pattern = cairo_pop_group (cr);
cairo_pattern_get_surface (pattern, &surface);
image_surface = cairo_surface_map_to_image (surface, NULL);
@@ -3262,12 +3450,20 @@ gsk_color_matrix_node_draw (GskRenderNode *node,
((pixel_data[x] >> 8) & 0xFF) / (255.0 * alpha),
( pixel_data[x] & 0xFF) / (255.0 * alpha),
alpha);
graphene_matrix_transform_vec4 (&self->color_matrix, &pixel, &pixel);
graphene_matrix_transform_vec4 (color_matrix, &pixel, &pixel);
}
graphene_vec4_add (&pixel, &self->color_offset, &pixel);
if (multiply_alpha)
graphene_vec4_init (&pixel,
graphene_vec4_get_x (&pixel),
graphene_vec4_get_y (&pixel),
graphene_vec4_get_z (&pixel),
alpha * graphene_vec4_get_w (&pixel));
graphene_vec4_add (&pixel, color_offset, &pixel);
alpha = graphene_vec4_get_w (&pixel);
if (alpha > 0.0)
{
alpha = MIN (alpha, 1.0);
@@ -3286,6 +3482,28 @@ gsk_color_matrix_node_draw (GskRenderNode *node,
cairo_surface_mark_dirty (image_surface);
cairo_surface_unmap_image (surface, image_surface);
}
static void
gsk_color_matrix_node_draw (GskRenderNode *node,
cairo_t *cr)
{
GskColorMatrixNode *self = (GskColorMatrixNode *) node;
cairo_pattern_t *pattern;
cairo_save (cr);
/* clip so the push_group() creates a smaller surface */
gsk_cairo_rectangle (cr, &node->bounds);
cairo_clip (cr);
cairo_push_group (cr);
gsk_render_node_draw (self->child, cr);
pattern = cairo_pop_group (cr);
apply_color_matrix_to_pattern (pattern, &self->color_matrix, &self->color_offset, FALSE);
cairo_set_source (cr, pattern);
cairo_paint (cr);
@@ -3406,7 +3624,8 @@ gsk_color_matrix_node_get_color_offset (const GskRenderNode *node)
return &self->color_offset;
}
/*** GSK_REPEAT_NODE ***/
/* }}} */
/* {{{ GSK_REPEAT_NODE */
/**
* GskRepeatNode:
@@ -3542,7 +3761,8 @@ gsk_repeat_node_get_child_bounds (const GskRenderNode *node)
return &self->child_bounds;
}
/*** GSK_CLIP_NODE ***/
/* }}} */
/* {{{ GSK_CLIP_NODE */
/**
* GskClipNode:
@@ -3676,7 +3896,8 @@ gsk_clip_node_get_clip (const GskRenderNode *node)
return &self->clip;
}
/*** GSK_ROUNDED_CLIP_NODE ***/
/* }}} */
/* {{{ GSK_ROUNDED_CLIP_NODE */
/**
* GskRoundedClipNode:
@@ -3810,7 +4031,8 @@ gsk_rounded_clip_node_get_clip (const GskRenderNode *node)
return &self->clip;
}
/*** GSK_SHADOW_NODE ***/
/* }}} */
/* {{{ GSK_SHADOW_NODE */
/**
* GskShadowNode:
@@ -4050,7 +4272,8 @@ gsk_shadow_node_get_n_shadows (const GskRenderNode *node)
return self->n_shadows;
}
/*** GSK_BLEND_NODE ***/
/* }}} */
/* {{{ GSK_BLEND_NODE */
/**
* GskBlendNode:
@@ -4244,7 +4467,8 @@ gsk_blend_node_get_blend_mode (const GskRenderNode *node)
return self->blend_mode;
}
/*** GSK_CROSS_FADE_NODE ***/
/* }}} */
/* {{{ GSK_CROSS_FADE_NODE */
/**
* GskCrossFadeNode:
@@ -4395,7 +4619,8 @@ gsk_cross_fade_node_get_progress (const GskRenderNode *node)
return self->progress;
}
/*** GSK_TEXT_NODE ***/
/* }}} */
/* {{{ GSK_TEXT_NODE */
/**
* GskTextNode:
@@ -4660,7 +4885,8 @@ gsk_text_node_get_offset (const GskRenderNode *node)
return &self->offset;
}
/*** GSK_BLUR_NODE ***/
/* }}} */
/* {{{ GSK_BLUR_NODE */
/**
* GskBlurNode:
@@ -4979,7 +5205,201 @@ gsk_blur_node_get_radius (const GskRenderNode *node)
return self->radius;
}
/*** GSK_DEBUG_NODE ***/
/* }}} */
/* {{{ GSK_MASK_NODE */
/**
* GskMaskNode:
*
* A render node masking one child node with another.
*
* Since: 4.10
*/
typedef struct _GskMaskNode GskMaskNode;
struct _GskMaskNode
{
GskRenderNode render_node;
GskRenderNode *mask;
GskRenderNode *source;
GskMaskMode mask_mode;
};
static void
gsk_mask_node_finalize (GskRenderNode *node)
{
GskMaskNode *self = (GskMaskNode *) node;
gsk_render_node_unref (self->source);
gsk_render_node_unref (self->mask);
}
static void
gsk_mask_node_draw (GskRenderNode *node,
cairo_t *cr)
{
GskMaskNode *self = (GskMaskNode *) node;
cairo_pattern_t *mask_pattern;
graphene_matrix_t color_matrix;
graphene_vec4_t color_offset;
cairo_push_group (cr);
gsk_render_node_draw (self->source, cr);
cairo_pop_group_to_source (cr);
cairo_push_group (cr);
gsk_render_node_draw (self->mask, cr);
mask_pattern = cairo_pop_group (cr);
switch (self->mask_mode)
{
case GSK_MASK_MODE_ALPHA:
break;
case GSK_MASK_MODE_INVERTED_ALPHA:
graphene_matrix_init_from_float (&color_matrix, (float[]){ 1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, -1 });
graphene_vec4_init (&color_offset, 0, 0, 0, 1);
apply_color_matrix_to_pattern (mask_pattern, &color_matrix, &color_offset, FALSE);
break;
case GSK_MASK_MODE_LUMINANCE:
graphene_matrix_init_from_float (&color_matrix, (float[]){ 1, 0, 0, 0.2126,
0, 1, 0, 0.7152,
0, 0, 1, 0.0722,
0, 0, 0, 0 });
graphene_vec4_init (&color_offset, 0, 0, 0, 0);
apply_color_matrix_to_pattern (mask_pattern, &color_matrix, &color_offset, TRUE);
break;
case GSK_MASK_MODE_INVERTED_LUMINANCE:
graphene_matrix_init_from_float (&color_matrix, (float[]){ 1, 0, 0, -0.2126,
0, 1, 0, -0.7152,
0, 0, 1, -0.0722,
0, 0, 0, 0 });
graphene_vec4_init (&color_offset, 0, 0, 0, 1);
apply_color_matrix_to_pattern (mask_pattern, &color_matrix, &color_offset, TRUE);
break;
default:
g_assert_not_reached ();
}
gsk_cairo_rectangle (cr, &node->bounds);
cairo_clip (cr);
cairo_mask (cr, mask_pattern);
}
static void
gsk_mask_node_diff (GskRenderNode *node1,
GskRenderNode *node2,
cairo_region_t *region)
{
GskMaskNode *self1 = (GskMaskNode *) node1;
GskMaskNode *self2 = (GskMaskNode *) node2;
gsk_render_node_diff (self1->source, self2->source, region);
gsk_render_node_diff (self1->mask, self2->mask, region);
}
/**
* gsk_mask_node_new:
* @source: The source node to be drawn
* @mask: The node to be used as mask
* @mask_mode: The mask mode to use
*
* Creates a `GskRenderNode` that will mask a given node by another.
*
* The @mask_mode determines how the 'mask values' are derived from
* the colors of the @mask. Applying the mask consists of multiplying
* the 'mask value' with the alpha of the source.
*
* Returns: (transfer full) (type GskMaskNode): A new `GskRenderNode`
*
* Since: 4.10
*/
GskRenderNode *
gsk_mask_node_new (GskRenderNode *source,
GskRenderNode *mask,
GskMaskMode mask_mode)
{
GskMaskNode *self;
g_return_val_if_fail (GSK_IS_RENDER_NODE (source), NULL);
g_return_val_if_fail (GSK_IS_RENDER_NODE (mask), NULL);
self = gsk_render_node_alloc (GSK_MASK_NODE);
self->source = gsk_render_node_ref (source);
self->mask = gsk_render_node_ref (mask);
self->mask_mode = mask_mode;
self->render_node.bounds = source->bounds;
self->render_node.prefers_high_depth = gsk_render_node_prefers_high_depth (source);
return &self->render_node;
}
/**
* gsk_mask_node_get_source:
* @node: (type GskMaskNode): a mask `GskRenderNode`
*
* Retrieves the source `GskRenderNode` child of the @node.
*
* Returns: (transfer none): the source child node
*
* Since: 4.10
*/
GskRenderNode *
gsk_mask_node_get_source (const GskRenderNode *node)
{
const GskMaskNode *self = (const GskMaskNode *) node;
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_MASK_NODE), NULL);
return self->source;
}
/**
* gsk_mask_node_get_mask:
* @node: (type GskMaskNode): a mask `GskRenderNode`
*
* Retrieves the mask `GskRenderNode` child of the @node.
*
* Returns: (transfer none): the mask child node
*
* Since: 4.10
*/
GskRenderNode *
gsk_mask_node_get_mask (const GskRenderNode *node)
{
const GskMaskNode *self = (const GskMaskNode *) node;
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_MASK_NODE), NULL);
return self->mask;
}
/**
* gsk_mask_node_get_mask_mode:
* @node: (type GskMaskNode): a blending `GskRenderNode`
*
* Retrieves the mask mode used by @node.
*
* Returns: the mask mode
*
* Since: 4.10
*/
GskMaskMode
gsk_mask_node_get_mask_mode (const GskRenderNode *node)
{
const GskMaskNode *self = (const GskMaskNode *) node;
return self->mask_mode;
}
/* }}} */
/* {{{ GSK_DEBUG_NODE */
/**
* GskDebugNode:
@@ -5104,7 +5524,8 @@ gsk_debug_node_get_message (const GskRenderNode *node)
return self->message;
}
/*** GSK_GL_SHADER_NODE ***/
/* }}} */
/* {{{ GSK_GL_SHADER_NODE */
/**
* GskGLShaderNode:
@@ -5309,6 +5730,8 @@ gsk_gl_shader_node_get_args (const GskRenderNode *node)
return self->args;
}
/* }}} */
GType gsk_render_node_types[GSK_RENDER_NODE_TYPE_N_TYPES];
#ifndef I_
@@ -5333,6 +5756,7 @@ GSK_DEFINE_RENDER_NODE_TYPE (gsk_repeating_radial_gradient_node, GSK_REPEATING_R
GSK_DEFINE_RENDER_NODE_TYPE (gsk_conic_gradient_node, GSK_CONIC_GRADIENT_NODE)
GSK_DEFINE_RENDER_NODE_TYPE (gsk_border_node, GSK_BORDER_NODE)
GSK_DEFINE_RENDER_NODE_TYPE (gsk_texture_node, GSK_TEXTURE_NODE)
GSK_DEFINE_RENDER_NODE_TYPE (gsk_texture_scale_node, GSK_TEXTURE_SCALE_NODE)
GSK_DEFINE_RENDER_NODE_TYPE (gsk_inset_shadow_node, GSK_INSET_SHADOW_NODE)
GSK_DEFINE_RENDER_NODE_TYPE (gsk_outset_shadow_node, GSK_OUTSET_SHADOW_NODE)
GSK_DEFINE_RENDER_NODE_TYPE (gsk_transform_node, GSK_TRANSFORM_NODE)
@@ -5346,6 +5770,7 @@ GSK_DEFINE_RENDER_NODE_TYPE (gsk_blend_node, GSK_BLEND_NODE)
GSK_DEFINE_RENDER_NODE_TYPE (gsk_cross_fade_node, GSK_CROSS_FADE_NODE)
GSK_DEFINE_RENDER_NODE_TYPE (gsk_text_node, GSK_TEXT_NODE)
GSK_DEFINE_RENDER_NODE_TYPE (gsk_blur_node, GSK_BLUR_NODE)
GSK_DEFINE_RENDER_NODE_TYPE (gsk_mask_node, GSK_MASK_NODE)
GSK_DEFINE_RENDER_NODE_TYPE (gsk_gl_shader_node, GSK_GL_SHADER_NODE)
GSK_DEFINE_RENDER_NODE_TYPE (gsk_debug_node, GSK_DEBUG_NODE)
@@ -5512,6 +5937,22 @@ gsk_render_node_init_types_once (void)
gsk_render_node_types[GSK_TEXTURE_NODE] = node_type;
}
{
const GskRenderNodeTypeInfo node_info =
{
GSK_TEXTURE_SCALE_NODE,
sizeof (GskTextureScaleNode),
NULL,
gsk_texture_scale_node_finalize,
gsk_texture_scale_node_draw,
NULL,
gsk_texture_scale_node_diff,
};
GType node_type = gsk_render_node_type_register_static (I_("GskTextureScaleNode"), &node_info);
gsk_render_node_types[GSK_TEXTURE_SCALE_NODE] = node_type;
}
{
const GskRenderNodeTypeInfo node_info =
{
@@ -5720,6 +6161,22 @@ gsk_render_node_init_types_once (void)
gsk_render_node_types[GSK_BLUR_NODE] = node_type;
}
{
const GskRenderNodeTypeInfo node_info =
{
GSK_MASK_NODE,
sizeof (GskMaskNode),
NULL,
gsk_mask_node_finalize,
gsk_mask_node_draw,
NULL,
gsk_mask_node_diff,
};
GType node_type = gsk_render_node_type_register_static (I_("GskMaskNode"), &node_info);
gsk_render_node_types[GSK_MASK_NODE] = node_type;
}
{
const GskRenderNodeTypeInfo node_info =
{
@@ -5884,3 +6341,5 @@ gsk_render_node_init_types (void)
g_once_init_leave (&register_types__volatile, initialized);
}
}
/* vim:set foldmethod=marker expandtab: */
+224 -9
View File
@@ -600,6 +600,34 @@ clear_shadows (gpointer inout_shadows)
g_array_set_size (*(GArray **) inout_shadows, 0);
}
static const struct
{
GskScalingFilter filter;
const char *name;
} scaling_filters[] = {
{ GSK_SCALING_FILTER_LINEAR, "linear" },
{ GSK_SCALING_FILTER_NEAREST, "nearest" },
{ GSK_SCALING_FILTER_TRILINEAR, "trilinear" },
};
static gboolean
parse_scaling_filter (GtkCssParser *parser,
gpointer out_filter)
{
for (unsigned int i = 0; i < G_N_ELEMENTS (scaling_filters); i++)
{
if (gtk_css_parser_try_ident (parser, scaling_filters[i].name))
{
*(GskScalingFilter *) out_filter = scaling_filters[i].filter;
return TRUE;
}
}
gtk_css_parser_error_syntax (parser, "Not a valid scaling filter.");
return FALSE;
}
static const struct
{
GskBlendMode mode;
@@ -623,6 +651,18 @@ static const struct
{ GSK_BLEND_MODE_LUMINOSITY, "luminosity" }
};
static const char *
get_blend_mode_name (GskBlendMode mode)
{
for (unsigned int i = 0; i < G_N_ELEMENTS (blend_modes); i++)
{
if (blend_modes[i].mode == mode)
return blend_modes[i].name;
}
return NULL;
}
static gboolean
parse_blend_mode (GtkCssParser *parser,
gpointer out_mode)
@@ -638,6 +678,51 @@ parse_blend_mode (GtkCssParser *parser,
}
}
gtk_css_parser_error_syntax (parser, "Not a valid blend mode.");
return FALSE;
}
static const struct
{
GskMaskMode mode;
const char *name;
} mask_modes[] = {
{ GSK_MASK_MODE_ALPHA, "alpha" },
{ GSK_MASK_MODE_INVERTED_ALPHA, "inverted-alpha" },
{ GSK_MASK_MODE_LUMINANCE, "luminance" },
{ GSK_MASK_MODE_INVERTED_LUMINANCE, "inverted-luminance" },
};
static const char *
get_mask_mode_name (GskMaskMode mode)
{
for (unsigned int i = 0; i < G_N_ELEMENTS (mask_modes); i++)
{
if (mask_modes[i].mode == mode)
return mask_modes[i].name;
}
return NULL;
}
static gboolean
parse_mask_mode (GtkCssParser *parser,
gpointer out_mode)
{
guint i;
for (i = 0; i < G_N_ELEMENTS (mask_modes); i++)
{
if (gtk_css_parser_try_ident (parser, mask_modes[i].name))
{
*(GskMaskMode *) out_mode = mask_modes[i].mode;
return TRUE;
}
}
gtk_css_parser_error_syntax (parser, "Not a valid mask mode.");
return FALSE;
}
@@ -1350,6 +1435,33 @@ parse_glshader_node (GtkCssParser *parser)
return node;
}
static GskRenderNode *
parse_mask_node (GtkCssParser *parser)
{
GskRenderNode *source = NULL;
GskRenderNode *mask = NULL;
GskMaskMode mode = GSK_MASK_MODE_ALPHA;
const Declaration declarations[] = {
{ "mode", parse_mask_mode, NULL, &mode },
{ "source", parse_node, clear_node, &source },
{ "mask", parse_node, clear_node, &mask },
};
GskRenderNode *result;
parse_declarations (parser, declarations, G_N_ELEMENTS(declarations));
if (source == NULL)
source = create_default_render_node ();
if (mask == NULL)
mask = gsk_color_node_new (&GDK_RGBA("AAFF00"), &GRAPHENE_RECT_INIT (0, 0, 50, 50));
result = gsk_mask_node_new (source, mask, mode);
gsk_render_node_unref (source);
gsk_render_node_unref (mask);
return result;
}
static GskRenderNode *
parse_border_node (GtkCssParser *parser)
{
@@ -1389,6 +1501,30 @@ parse_texture_node (GtkCssParser *parser)
return node;
}
static GskRenderNode *
parse_texture_scale_node (GtkCssParser *parser)
{
graphene_rect_t bounds = GRAPHENE_RECT_INIT (0, 0, 50, 50);
GdkTexture *texture = NULL;
GskScalingFilter filter = GSK_SCALING_FILTER_LINEAR;
const Declaration declarations[] = {
{ "bounds", parse_rect, NULL, &bounds },
{ "texture", parse_texture, clear_texture, &texture },
{ "filter", parse_scaling_filter, NULL, &filter }
};
GskRenderNode *node;
parse_declarations (parser, declarations, G_N_ELEMENTS (declarations));
if (texture == NULL)
texture = create_default_texture ();
node = gsk_texture_scale_node_new (texture, &bounds, filter);
g_object_unref (texture);
return node;
}
static GskRenderNode *
parse_cairo_node (GtkCssParser *parser)
{
@@ -1861,8 +1997,10 @@ parse_node (GtkCssParser *parser,
{ "shadow", parse_shadow_node },
{ "text", parse_text_node },
{ "texture", parse_texture_node },
{ "texture-scale", parse_texture_scale_node },
{ "transform", parse_transform_node },
{ "glshader", parse_glshader_node },
{ "mask", parse_mask_node },
};
GskRenderNode **node_p = out_node;
guint i;
@@ -2757,6 +2895,73 @@ render_node_print (Printer *p,
}
break;
case GSK_TEXTURE_SCALE_NODE:
{
GdkTexture *texture = gsk_texture_scale_node_get_texture (node);
GskScalingFilter filter = gsk_texture_scale_node_get_filter (node);
GBytes *bytes;
start_node (p, "texture-scale");
append_rect_param (p, "bounds", &node->bounds);
if (filter != GSK_SCALING_FILTER_LINEAR)
{
_indent (p);
for (unsigned int i = 0; i < G_N_ELEMENTS (scaling_filters); i++)
{
if (scaling_filters[i].filter == filter)
{
g_string_append_printf (p->str, "filter: %s;\n", scaling_filters[i].name);
break;
}
}
}
_indent (p);
switch (gdk_texture_get_format (texture))
{
case GDK_MEMORY_B8G8R8A8_PREMULTIPLIED:
case GDK_MEMORY_A8R8G8B8_PREMULTIPLIED:
case GDK_MEMORY_R8G8B8A8_PREMULTIPLIED:
case GDK_MEMORY_B8G8R8A8:
case GDK_MEMORY_A8R8G8B8:
case GDK_MEMORY_R8G8B8A8:
case GDK_MEMORY_A8B8G8R8:
case GDK_MEMORY_R8G8B8:
case GDK_MEMORY_B8G8R8:
case GDK_MEMORY_R16G16B16:
case GDK_MEMORY_R16G16B16A16_PREMULTIPLIED:
case GDK_MEMORY_R16G16B16A16:
bytes = gdk_texture_save_to_png_bytes (texture);
g_string_append (p->str, "texture: url(\"data:image/png;base64,");
break;
case GDK_MEMORY_R16G16B16_FLOAT:
case GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED:
case GDK_MEMORY_R16G16B16A16_FLOAT:
case GDK_MEMORY_R32G32B32_FLOAT:
case GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED:
case GDK_MEMORY_R32G32B32A32_FLOAT:
bytes = gdk_texture_save_to_tiff_bytes (texture);
g_string_append (p->str, "texture: url(\"data:image/tiff;base64,");
break;
case GDK_MEMORY_N_FORMATS:
default:
g_assert_not_reached ();
}
b64 = base64_encode_with_linebreaks (g_bytes_get_data (bytes, NULL),
g_bytes_get_size (bytes));
append_escaping_newlines (p->str, b64);
g_free (b64);
g_string_append (p->str, "\");\n");
end_node (p);
g_bytes_unref (bytes);
}
break;
case GSK_TEXT_NODE:
{
const graphene_point_t *offset = gsk_text_node_get_offset (node);
@@ -2959,21 +3164,13 @@ render_node_print (Printer *p,
case GSK_BLEND_NODE:
{
GskBlendMode mode = gsk_blend_node_get_blend_mode (node);
guint i;
start_node (p, "blend");
if (mode != GSK_BLEND_MODE_DEFAULT)
{
_indent (p);
for (i = 0; i < G_N_ELEMENTS (blend_modes); i++)
{
if (blend_modes[i].mode == mode)
{
g_string_append_printf (p->str, "mode: %s;\n", blend_modes[i].name);
break;
}
}
g_string_append_printf (p->str, "mode: %s;\n", get_blend_mode_name (mode));
}
append_node_param (p, "bottom", gsk_blend_node_get_bottom_child (node));
append_node_param (p, "top", gsk_blend_node_get_top_child (node));
@@ -2982,6 +3179,24 @@ render_node_print (Printer *p,
}
break;
case GSK_MASK_NODE:
{
GskMaskMode mode = gsk_mask_node_get_mask_mode (node);
start_node (p, "mask");
if (mode != GSK_MASK_MODE_ALPHA)
{
_indent (p);
g_string_append_printf (p->str, "mode: %s;\n", get_mask_mode_name (mode));
}
append_node_param (p, "source", gsk_mask_node_get_source (node));
append_node_param (p, "mask", gsk_mask_node_get_mask (node));
end_node (p);
}
break;
case GSK_NOT_A_RENDER_NODE:
g_assert_not_reached ();
break;
+1 -1
View File
@@ -13,7 +13,7 @@ typedef struct _GskRenderNodeClass GskRenderNodeClass;
* We don't add an "n-types" value to avoid having to handle
* it in every single switch.
*/
#define GSK_RENDER_NODE_TYPE_N_TYPES (GSK_GL_SHADER_NODE + 1)
#define GSK_RENDER_NODE_TYPE_N_TYPES (GSK_MASK_NODE + 1)
extern GType gsk_render_node_types[];
+1
View File
@@ -19,6 +19,7 @@ gsk_private_gl_shaders = [
'gl/resources/repeat.glsl',
'gl/resources/custom.glsl',
'gl/resources/filled_border.glsl',
'gl/resources/mask.glsl',
]
gsk_public_sources = files([
+6
View File
@@ -440,6 +440,9 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self,
g_array_append_val (self->render_ops, op);
return;
case GSK_TEXTURE_SCALE_NODE:
goto fallback;
case GSK_COLOR_NODE:
if (gsk_vulkan_clip_contains_rect (&constants->clip, &node->bounds))
pipeline_type = GSK_VULKAN_PIPELINE_COLOR;
@@ -501,6 +504,9 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self,
g_array_append_val (self->render_ops, op);
return;
case GSK_MASK_NODE:
goto fallback;
case GSK_COLOR_MATRIX_NODE:
if (gsk_vulkan_clip_contains_rect (&constants->clip, &node->bounds))
pipeline_type = GSK_VULKAN_PIPELINE_COLOR_MATRIX;
+74
View File
@@ -60,12 +60,16 @@
*
* `GtkAssistant` has a single CSS node with the name window and style
* class .assistant.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
/**
* GtkAssistantPage:
*
* `GtkAssistantPage` is an auxiliary object used by `GtkAssistant.
*
* Deprecated: 4.10: This object will be removed in GTK 5
*/
#include "config.h"
@@ -275,6 +279,8 @@ gtk_assistant_page_class_init (GtkAssistantPageClass *class)
* GtkAssistantPage:page-type:
*
* The type of the assistant page.
*
* Deprecated: 4.10: This object will be removed in GTK 5
*/
g_object_class_install_property (object_class,
CHILD_PROP_PAGE_TYPE,
@@ -287,6 +293,8 @@ gtk_assistant_page_class_init (GtkAssistantPageClass *class)
* GtkAssistantPage:title:
*
* The title of the page.
*
* Deprecated: 4.10: This object will be removed in GTK 5
*/
g_object_class_install_property (object_class,
CHILD_PROP_PAGE_TITLE,
@@ -301,6 +309,8 @@ gtk_assistant_page_class_init (GtkAssistantPageClass *class)
*
* GTK uses this information to control the sensitivity
* of the navigation buttons.
*
* Deprecated: 4.10: This object will be removed in GTK 5
*/
g_object_class_install_property (object_class,
CHILD_PROP_PAGE_COMPLETE,
@@ -312,6 +322,8 @@ gtk_assistant_page_class_init (GtkAssistantPageClass *class)
* GtkAssistantPage:child:
*
* The child widget.
*
* Deprecated: 4.10: This object will be removed in GTK 5
*/
g_object_class_install_property (object_class,
CHILD_PROP_CHILD,
@@ -518,6 +530,8 @@ gtk_assistant_class_init (GtkAssistantClass *class)
* @assistant: the `GtkAssistant`
*
* Emitted when then the cancel button is clicked.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
signals[CANCEL] =
g_signal_new (I_("cancel"),
@@ -538,6 +552,8 @@ gtk_assistant_class_init (GtkAssistantClass *class)
*
* A handler for this signal can do any preparations which are
* necessary before showing @page.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
signals[PREPARE] =
g_signal_new (I_("prepare"),
@@ -563,6 +579,8 @@ gtk_assistant_class_init (GtkAssistantClass *class)
* %GTK_ASSISTANT_PAGE_PROGRESS after the confirmation page and handle
* this operation within the [signal@Gtk.Assistant::prepare] signal of
* the progress page.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
signals[APPLY] =
g_signal_new (I_("apply"),
@@ -580,6 +598,8 @@ gtk_assistant_class_init (GtkAssistantClass *class)
* Emitted either when the close button of a summary page is clicked,
* or when the apply button in the last page in the flow (of type
* %GTK_ASSISTANT_PAGE_CONFIRM) is clicked.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
signals[CLOSE] =
g_signal_new (I_("close"),
@@ -595,6 +615,8 @@ gtk_assistant_class_init (GtkAssistantClass *class)
* @assistant: the `GtkAssistant`
*
* The action signal for the Escape binding.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
signals[ESCAPE] =
g_signal_new_class_handler (I_("escape"),
@@ -618,6 +640,8 @@ gtk_assistant_class_init (GtkAssistantClass *class)
*
* For technical reasons, this property is declared as an integer
* property, but you should only set it to %TRUE or %FALSE.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
g_object_class_install_property (gobject_class,
PROP_USE_HEADER_BAR,
@@ -1435,6 +1459,8 @@ gtk_assistant_close_request (GtkWindow *window)
* Creates a new `GtkAssistant`.
*
* Returns: a newly created `GtkAssistant`
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
GtkWidget*
gtk_assistant_new (void)
@@ -1455,6 +1481,8 @@ gtk_assistant_new (void)
* Returns: The index (starting from 0) of the current
* page in the @assistant, or -1 if the @assistant has no pages,
* or no current page
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
int
gtk_assistant_get_current_page (GtkAssistant *assistant)
@@ -1480,6 +1508,8 @@ gtk_assistant_get_current_page (GtkAssistant *assistant)
* Note that this will only be necessary in custom buttons,
* as the @assistant flow can be set with
* gtk_assistant_set_forward_page_func().
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
void
gtk_assistant_set_current_page (GtkAssistant *assistant,
@@ -1525,6 +1555,8 @@ gtk_assistant_set_current_page (GtkAssistant *assistant,
*
* This function is for use when creating pages of the
* %GTK_ASSISTANT_PAGE_CUSTOM type.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
void
gtk_assistant_next_page (GtkAssistant *assistant)
@@ -1548,6 +1580,8 @@ gtk_assistant_next_page (GtkAssistant *assistant)
*
* This function is for use when creating pages of the
* %GTK_ASSISTANT_PAGE_CUSTOM type.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
void
gtk_assistant_previous_page (GtkAssistant *assistant)
@@ -1581,6 +1615,8 @@ gtk_assistant_previous_page (GtkAssistant *assistant)
* Returns the number of pages in the @assistant
*
* Returns: the number of pages in the @assistant
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
int
gtk_assistant_get_n_pages (GtkAssistant *assistant)
@@ -1600,6 +1636,8 @@ gtk_assistant_get_n_pages (GtkAssistant *assistant)
*
* Returns: (nullable) (transfer none): the child widget, or %NULL
* if @page_num is out of bounds
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
GtkWidget*
gtk_assistant_get_nth_page (GtkAssistant *assistant,
@@ -1632,6 +1670,8 @@ gtk_assistant_get_nth_page (GtkAssistant *assistant,
* Prepends a page to the @assistant.
*
* Returns: the index (starting at 0) of the inserted page
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
int
gtk_assistant_prepend_page (GtkAssistant *assistant,
@@ -1651,6 +1691,8 @@ gtk_assistant_prepend_page (GtkAssistant *assistant,
* Appends a page to the @assistant.
*
* Returns: the index (starting at 0) of the inserted page
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
int
gtk_assistant_append_page (GtkAssistant *assistant,
@@ -1672,6 +1714,8 @@ gtk_assistant_append_page (GtkAssistant *assistant,
* Inserts a page in the @assistant at a given position.
*
* Returns: the index (starting from 0) of the inserted page
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
int
gtk_assistant_insert_page (GtkAssistant *assistant,
@@ -1770,6 +1814,8 @@ gtk_assistant_add_page (GtkAssistant *assistant,
* or -1 to remove the last page
*
* Removes the @page_nums page from @assistant.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
void
gtk_assistant_remove_page (GtkAssistant *assistant,
@@ -1805,6 +1851,8 @@ gtk_assistant_remove_page (GtkAssistant *assistant,
* Setting @page_func to %NULL will make the assistant to
* use the default forward function, which just goes to the
* next visible page.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
void
gtk_assistant_set_forward_page_func (GtkAssistant *assistant,
@@ -1853,6 +1901,8 @@ add_to_action_area (GtkAssistant *assistant,
* @child: a `GtkWidget`
*
* Adds a widget to the action area of a `GtkAssistant`.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
void
gtk_assistant_add_action_widget (GtkAssistant *assistant,
@@ -1881,6 +1931,8 @@ gtk_assistant_add_action_widget (GtkAssistant *assistant,
* @child: a `GtkWidget`
*
* Removes a widget from the action area of a `GtkAssistant`.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
void
gtk_assistant_remove_action_widget (GtkAssistant *assistant,
@@ -1910,6 +1962,8 @@ gtk_assistant_remove_action_widget (GtkAssistant *assistant,
*
* The title is displayed in the header area of the assistant
* when @page is the current page.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
void
gtk_assistant_set_page_title (GtkAssistant *assistant,
@@ -1939,6 +1993,8 @@ gtk_assistant_set_page_title (GtkAssistant *assistant,
* Gets the title for @page.
*
* Returns: the title for @page
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
const char *
gtk_assistant_get_page_title (GtkAssistant *assistant,
@@ -1968,6 +2024,8 @@ gtk_assistant_get_page_title (GtkAssistant *assistant,
* Sets the page type for @page.
*
* The page type determines the page behavior in the @assistant.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
void
gtk_assistant_set_page_type (GtkAssistant *assistant,
@@ -1997,6 +2055,8 @@ gtk_assistant_set_page_type (GtkAssistant *assistant,
* Gets the page type of @page.
*
* Returns: the page type of @page
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
GtkAssistantPageType
gtk_assistant_get_page_type (GtkAssistant *assistant,
@@ -2027,6 +2087,8 @@ gtk_assistant_get_page_type (GtkAssistant *assistant,
*
* This will make @assistant update the buttons state
* to be able to continue the task.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
void
gtk_assistant_set_page_complete (GtkAssistant *assistant,
@@ -2056,6 +2118,8 @@ gtk_assistant_set_page_complete (GtkAssistant *assistant,
* Gets whether @page is complete.
*
* Returns: %TRUE if @page is complete.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
gboolean
gtk_assistant_get_page_complete (GtkAssistant *assistant,
@@ -2089,6 +2153,8 @@ gtk_assistant_get_page_complete (GtkAssistant *assistant,
* One situation where it can be necessary to call this
* function is when changing a value on the current page
* affects the future page flow of the assistant.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
void
gtk_assistant_update_buttons_state (GtkAssistant *assistant)
@@ -2112,6 +2178,8 @@ gtk_assistant_update_buttons_state (GtkAssistant *assistant)
* or undone. For example, showing a progress page to track
* a long-running, unreversible operation after the user has
* clicked apply on a confirmation page.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
void
gtk_assistant_commit (GtkAssistant *assistant)
@@ -2189,6 +2257,8 @@ gtk_assistant_buildable_custom_finished (GtkBuildable *buildable,
* Returns the `GtkAssistantPage` object for @child.
*
* Returns: (transfer none): the `GtkAssistantPage` for @child
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
GtkAssistantPage *
gtk_assistant_get_page (GtkAssistant *assistant,
@@ -2205,6 +2275,8 @@ gtk_assistant_get_page (GtkAssistant *assistant,
* Returns the child to which @page belongs.
*
* Returns: (transfer none): the child to which @page belongs
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
GtkWidget *
gtk_assistant_page_get_child (GtkAssistantPage *page)
@@ -2316,6 +2388,8 @@ gtk_assistant_pages_new (GtkAssistant *assistant)
* Gets a list model of the assistant pages.
*
* Returns: (transfer full) (attributes element-type=GtkAssistantPage): A list model of the pages.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
GListModel *
gtk_assistant_get_pages (GtkAssistant *assistant)
+22 -10
View File
@@ -34,6 +34,8 @@
* same context which was used to request sizes for a given `GtkTreeModel`
* row also be used for the same row when calling other `GtkCellArea` APIs
* such as gtk_cell_area_render() and gtk_cell_area_event().
*
* Deprecated: 4.10: This object will be removed in GTK 5
*/
#include "config.h"
@@ -107,6 +109,8 @@ gtk_cell_area_context_class_init (GtkCellAreaContextClass *class)
* GtkCellAreaContext:area:
*
* The `GtkCellArea` this context was created by
*
* Deprecated: 4.10: This object will be removed in GTK 5
*/
g_object_class_install_property (object_class,
PROP_CELL_AREA,
@@ -120,6 +124,8 @@ gtk_cell_area_context_class_init (GtkCellAreaContextClass *class)
* The minimum width for the `GtkCellArea` in this context
* for all `GtkTreeModel` rows that this context was requested
* for using gtk_cell_area_get_preferred_width().
*
* Deprecated: 4.10: This object will be removed in GTK 5
*/
g_object_class_install_property (object_class,
PROP_MIN_WIDTH,
@@ -133,6 +139,8 @@ gtk_cell_area_context_class_init (GtkCellAreaContextClass *class)
* The natural width for the `GtkCellArea` in this context
* for all `GtkTreeModel` rows that this context was requested
* for using gtk_cell_area_get_preferred_width().
*
* Deprecated: 4.10: This object will be removed in GTK 5
*/
g_object_class_install_property (object_class,
PROP_NAT_WIDTH,
@@ -146,6 +154,8 @@ gtk_cell_area_context_class_init (GtkCellAreaContextClass *class)
* The minimum height for the `GtkCellArea` in this context
* for all `GtkTreeModel` rows that this context was requested
* for using gtk_cell_area_get_preferred_height().
*
* Deprecated: 4.10: This object will be removed in GTK 5
*/
g_object_class_install_property (object_class,
PROP_MIN_HEIGHT,
@@ -159,6 +169,8 @@ gtk_cell_area_context_class_init (GtkCellAreaContextClass *class)
* The natural height for the `GtkCellArea` in this context
* for all `GtkTreeModel` rows that this context was requested
* for using gtk_cell_area_get_preferred_height().
*
* Deprecated: 4.10: This object will be removed in GTK 5
*/
g_object_class_install_property (object_class,
PROP_NAT_HEIGHT,
@@ -309,7 +321,7 @@ gtk_cell_area_context_real_allocate (GtkCellAreaContext *context,
*
* Returns: (transfer none): the `GtkCellArea` this context was created by.
*
* Deprecated: 4.10
* Deprecated: 4.10: This object will be removed in GTK 5
*/
GtkCellArea *
gtk_cell_area_context_get_area (GtkCellAreaContext *context)
@@ -348,7 +360,7 @@ gtk_cell_area_context_get_area (GtkCellAreaContext *context)
* of all the displayed row heights using
* gtk_cell_area_get_preferred_height_for_width().
*
* Deprecated: 4.10
* Deprecated: 4.10: This object will be removed in GTK 5
*/
void
gtk_cell_area_context_reset (GtkCellAreaContext *context)
@@ -377,7 +389,7 @@ gtk_cell_area_context_reset (GtkCellAreaContext *context)
* rows. This is generally the case for `GtkTreeView` when
* `GtkTreeView:fixed-height-mode` is enabled.
*
* Deprecated: 4.10
* Deprecated: 4.10: This object will be removed in GTK 5
*/
void
gtk_cell_area_context_allocate (GtkCellAreaContext *context,
@@ -401,7 +413,7 @@ gtk_cell_area_context_allocate (GtkCellAreaContext *context,
* After gtk_cell_area_context_reset() is called and/or before ever
* requesting the size of a `GtkCellArea`, the returned values are 0.
*
* Deprecated: 4.10
* Deprecated: 4.10: This object will be removed in GTK 5
*/
void
gtk_cell_area_context_get_preferred_width (GtkCellAreaContext *context,
@@ -431,7 +443,7 @@ gtk_cell_area_context_get_preferred_width (GtkCellAreaContext *context,
* After gtk_cell_area_context_reset() is called and/or before ever
* requesting the size of a `GtkCellArea`, the returned values are 0.
*
* Deprecated: 4.10
* Deprecated: 4.10: This object will be removed in GTK 5
*/
void
gtk_cell_area_context_get_preferred_height (GtkCellAreaContext *context,
@@ -462,7 +474,7 @@ gtk_cell_area_context_get_preferred_height (GtkCellAreaContext *context,
* After gtk_cell_area_context_reset() is called and/or before ever
* requesting the size of a `GtkCellArea`, the returned values are -1.
*
* Deprecated: 4.10
* Deprecated: 4.10: This object will be removed in GTK 5
*/
void
gtk_cell_area_context_get_preferred_height_for_width (GtkCellAreaContext *context,
@@ -492,7 +504,7 @@ gtk_cell_area_context_get_preferred_height_for_width (GtkCellAreaContext *contex
* After gtk_cell_area_context_reset() is called and/or before ever
* requesting the size of a `GtkCellArea`, the returned values are -1.
*
* Deprecated: 4.10
* Deprecated: 4.10: This object will be removed in GTK 5
*/
void
gtk_cell_area_context_get_preferred_width_for_height (GtkCellAreaContext *context,
@@ -521,7 +533,7 @@ gtk_cell_area_context_get_preferred_width_for_height (GtkCellAreaContext *contex
* context was recently reset with gtk_cell_area_context_reset(),
* the returned value will be -1.
*
* Deprecated: 4.10
* Deprecated: 4.10: This object will be removed in GTK 5
*/
void
gtk_cell_area_context_get_allocation (GtkCellAreaContext *context,
@@ -553,7 +565,7 @@ gtk_cell_area_context_get_allocation (GtkCellAreaContext *context,
* progressively push the requested width over a series of
* gtk_cell_area_get_preferred_width() requests.
*
* Deprecated: 4.10
* Deprecated: 4.10: This object will be removed in GTK 5
*/
void
gtk_cell_area_context_push_preferred_width (GtkCellAreaContext *context,
@@ -597,7 +609,7 @@ gtk_cell_area_context_push_preferred_width (GtkCellAreaContext *context,
* progressively push the requested height over a series of
* gtk_cell_area_get_preferred_height() requests.
*
* Deprecated: 4.10
* Deprecated: 4.10: This object will be removed in GTK 5
*/
void
gtk_cell_area_context_push_preferred_height (GtkCellAreaContext *context,
-1
View File
@@ -20,7 +20,6 @@
#include "gtkcellrendererpixbuf.h"
#include "gtkiconhelperprivate.h"
#include "gtkicontheme.h"
#include "gtkprivate.h"
#include "gtksnapshot.h"
#include "gtkstylecontextprivate.h"
+20
View File
@@ -70,6 +70,8 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* [property@Gtk.LockButton:tooltip-lock],
* [property@Gtk.LockButton:tooltip-unlock] and
* [property@Gtk.LockButton:tooltip-not-authorized] properties.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
struct _GtkLockButton
@@ -271,6 +273,8 @@ gtk_lock_button_class_init (GtkLockButtonClass *klass)
* GtkLockButton:permission: (attributes org.gtk.Property.get=gtk_lock_button_get_permission org.gtk.Property.set=gtk_lock_button_set_permission)
*
* The `GPermission object controlling this button.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
g_object_class_install_property (gobject_class, PROP_PERMISSION,
g_param_spec_object ("permission", NULL, NULL,
@@ -282,6 +286,8 @@ gtk_lock_button_class_init (GtkLockButtonClass *klass)
* GtkLockButton:text-lock:
*
* The text to display when prompting the user to lock.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
g_object_class_install_property (gobject_class, PROP_TEXT_LOCK,
g_param_spec_string ("text-lock", NULL, NULL,
@@ -294,6 +300,8 @@ gtk_lock_button_class_init (GtkLockButtonClass *klass)
* GtkLockButton:text-unlock:
*
* The text to display when prompting the user to unlock.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
g_object_class_install_property (gobject_class, PROP_TEXT_UNLOCK,
g_param_spec_string ("text-unlock", NULL, NULL,
@@ -306,6 +314,8 @@ gtk_lock_button_class_init (GtkLockButtonClass *klass)
* GtkLockButton:tooltip-lock:
*
* The tooltip to display when prompting the user to lock.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
g_object_class_install_property (gobject_class, PROP_TOOLTIP_LOCK,
g_param_spec_string ("tooltip-lock", NULL, NULL,
@@ -318,6 +328,8 @@ gtk_lock_button_class_init (GtkLockButtonClass *klass)
* GtkLockButton:tooltip-unlock:
*
* The tooltip to display when prompting the user to unlock.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
g_object_class_install_property (gobject_class, PROP_TOOLTIP_UNLOCK,
g_param_spec_string ("tooltip-unlock", NULL, NULL,
@@ -330,6 +342,8 @@ gtk_lock_button_class_init (GtkLockButtonClass *klass)
* GtkLockButton:tooltip-not-authorized:
*
* The tooltip to display when the user cannot obtain authorization.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
g_object_class_install_property (gobject_class, PROP_TOOLTIP_NOT_AUTHORIZED,
g_param_spec_string ("tooltip-not-authorized", NULL, NULL,
@@ -511,6 +525,8 @@ gtk_lock_button_clicked (GtkButton *widget)
* Creates a new lock button which reflects the @permission.
*
* Returns: a new `GtkLockButton`
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
GtkWidget *
gtk_lock_button_new (GPermission *permission)
@@ -527,6 +543,8 @@ gtk_lock_button_new (GPermission *permission)
* Obtains the `GPermission` object that controls @button.
*
* Returns: (transfer none) (nullable): the `GPermission` of @button
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
GPermission *
gtk_lock_button_get_permission (GtkLockButton *button)
@@ -542,6 +560,8 @@ gtk_lock_button_get_permission (GtkLockButton *button)
* @permission: (nullable): a `GPermission` object
*
* Sets the `GPermission` object that controls @button.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
void
gtk_lock_button_set_permission (GtkLockButton *button,
+20
View File
@@ -77,6 +77,8 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* ## CSS node
*
* `GtkStatusbar` has a single CSS node with name `statusbar`.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
typedef struct _GtkStatusbarMsg GtkStatusbarMsg;
@@ -167,6 +169,8 @@ gtk_statusbar_class_init (GtkStatusbarClass *class)
* @text: the message that was pushed
*
* Emitted whenever a new message gets pushed onto a statusbar's stack.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
statusbar_signals[SIGNAL_TEXT_PUSHED] =
g_signal_new (I_("text-pushed"),
@@ -186,6 +190,8 @@ gtk_statusbar_class_init (GtkStatusbarClass *class)
* @text: the message that was just popped
*
* Emitted whenever a new message is popped off a statusbar's stack.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
statusbar_signals[SIGNAL_TEXT_POPPED] =
g_signal_new (I_("text-popped"),
@@ -225,6 +231,8 @@ gtk_statusbar_init (GtkStatusbar *statusbar)
* Creates a new `GtkStatusbar` ready for messages.
*
* Returns: the new `GtkStatusbar`
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
GtkWidget*
gtk_statusbar_new (void)
@@ -257,6 +265,8 @@ gtk_statusbar_update (GtkStatusbar *statusbar,
* Note that the description is not shown in the UI.
*
* Returns: an integer id
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
guint
gtk_statusbar_get_context_id (GtkStatusbar *statusbar,
@@ -317,6 +327,8 @@ gtk_statusbar_msg_free (GtkStatusbarMsg *msg)
*
* Returns: a message id that can be used with
* [method@Gtk.Statusbar.remove].
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
guint
gtk_statusbar_push (GtkStatusbar *statusbar,
@@ -351,6 +363,8 @@ gtk_statusbar_push (GtkStatusbar *statusbar,
* Note that this may not change the displayed message,
* if the message at the top of the stack has a different
* context id.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
void
gtk_statusbar_pop (GtkStatusbar *statusbar,
@@ -395,6 +409,8 @@ gtk_statusbar_pop (GtkStatusbar *statusbar,
*
* Forces the removal of a message from a statusbars stack.
* The exact @context_id and @message_id must be specified.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
void
gtk_statusbar_remove (GtkStatusbar *statusbar,
@@ -443,6 +459,8 @@ gtk_statusbar_remove (GtkStatusbar *statusbar,
*
* Forces the removal of all messages from a statusbar's
* stack with the exact @context_id.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
void
gtk_statusbar_remove_all (GtkStatusbar *statusbar,
@@ -499,6 +517,8 @@ gtk_statusbar_remove_all (GtkStatusbar *statusbar,
* Retrieves the contents of the label in `GtkStatusbar`.
*
* Returns: (transfer none): the contents of the statusbar
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
const char *
gtk_statusbar_get_message (GtkStatusbar *statusbar)
@@ -35,6 +35,8 @@
#include "gtkprivate.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
/**
* GtkVolumeButton:
*
@@ -42,6 +44,8 @@
* volume control.
*
* ![An example GtkVolumeButton](volumebutton.png)
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
typedef struct _GtkVolumeButtonClass GtkVolumeButtonClass;
@@ -166,6 +170,8 @@ gtk_volume_button_class_init (GtkVolumeButtonClass *klass)
*
* Note that if the symbolic icons are not available in your installed
* theme, then the normal (potentially colorful) icons will be used.
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
g_object_class_install_property (gobject_class,
PROP_SYMBOLIC,
@@ -198,6 +204,8 @@ gtk_volume_button_init (GtkVolumeButton *button)
* [class@Gtk.ScaleButton].
*
* Returns: a new `GtkVolumeButton`
*
* Deprecated: 4.10: This widget will be removed in GTK 5
*/
GtkWidget *
gtk_volume_button_new (void)
@@ -49,7 +49,7 @@ struct _GtkVolumeButton
GDK_AVAILABLE_IN_ALL
GType gtk_volume_button_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_10
GtkWidget* gtk_volume_button_new (void);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkVolumeButton, g_object_unref)
+2
View File
@@ -49,6 +49,7 @@ gtk_deprecated_sources = [
'deprecated/gtktreepopover.c',
'deprecated/gtktreeview.c',
'deprecated/gtktreeviewcolumn.c',
'deprecated/gtkvolumebutton.c',
]
gtk_deprecated_headers = [
@@ -106,4 +107,5 @@ gtk_deprecated_headers = [
'deprecated/gtktreestore.h',
'deprecated/gtktreeview.h',
'deprecated/gtktreeviewcolumn.h',
'deprecated/gtkvolumebutton.h',
]
-52
View File
@@ -1,52 +0,0 @@
/* GIO - GLib Input, Output and Streaming Library
*
* Copyright 2017 Red Hat, Inc.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*
* 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/>.
*/
#ifndef __G_OPEN_URI_PORTAL_H__
#include "gtkwindow.h"
#include <glib.h>
#include <gio/gio.h>
G_BEGIN_DECLS
gboolean g_openuri_portal_is_available (void);
void g_openuri_portal_open_async (GFile *file,
gboolean open_folder,
GtkWindow *window,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean g_openuri_portal_open_finish (GAsyncResult *result,
GError **error);
void g_openuri_portal_open_uri_async (const char *uri,
GtkWindow *window,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean g_openuri_portal_open_uri_finish (GAsyncResult *result,
GError **error);
G_END_DECLS
#endif
+1 -1
View File
@@ -290,7 +290,7 @@
#include <gtk/gtkversion.h>
#include <gtk/gtkvideo.h>
#include <gtk/gtkviewport.h>
#include <gtk/gtkvolumebutton.h>
#include <gtk/deprecated/gtkvolumebutton.h>
#include <gtk/gtkwidget.h>
#include <gtk/gtkwidgetpaintable.h>
#include <gtk/gtkwindow.h>
-7
View File
@@ -36,22 +36,15 @@
#include "gtkbutton.h"
#include "gtkgrid.h"
#include "gtkbox.h"
#include "gtkicontheme.h"
#include "gtkimage.h"
#include "gtklabel.h"
#include "gtkmarshalers.h"
#include "gtkstack.h"
#include "gtkorientable.h"
#include "gtkscrolledwindow.h"
#include "gtktextview.h"
#include "gtkmain.h"
#include "gtktogglebutton.h"
#include "gtktypebuiltins.h"
#include "gtkstack.h"
#include "gtkstackswitcher.h"
#include "gtksettings.h"
#include "gtkurilauncher.h"
#include "gtkheaderbar.h"
#include "gtkprivate.h"
#include <glib/gi18n-lib.h>
#include "gtkeventcontrollermotion.h"
+93 -2
View File
@@ -45,6 +45,11 @@
* [vfunc@Gtk.Accessible.get_next_accessible_sibling] virtual functions.
* Note that you can not create a top-level accessible object as of now,
* which means that you must always have a parent accessible object.
* Also note that when an accessible object does not correspond to a widget,
* and it has children, whose implementation you don't control,
* it is necessary to ensure the correct shape of the a11y tree
* by calling [method@Gtk.Accessible.set_accessible_parent] and
* updating the sibling by [method@Gtk.Accessible.update_next_accessible_sibling].
*/
#include "config.h"
@@ -89,6 +94,8 @@ gtk_accessible_default_init (GtkAccessibleInterface *iface)
* Retrieves the `GtkATContext` for the given `GtkAccessible`.
*
* Returns: (transfer none): the `GtkATContext`
*
* Since: 4.10
*/
GtkATContext *
gtk_accessible_get_at_context (GtkAccessible *self)
@@ -115,7 +122,85 @@ gtk_accessible_get_accessible_parent (GtkAccessible *self)
{
g_return_val_if_fail (GTK_IS_ACCESSIBLE (self), NULL);
return GTK_ACCESSIBLE_GET_IFACE (self)->get_accessible_parent (self);
GtkATContext *context;
GtkAccessible *parent = NULL;
context = gtk_accessible_get_at_context (self);
if (context != NULL)
parent = gtk_at_context_get_accessible_parent (context);
if (parent != NULL)
return parent;
else
return GTK_ACCESSIBLE_GET_IFACE (self)->get_accessible_parent (self);
}
/**
* gtk_accessible_set_accessible_parent:
* @self: an accessible object
* @parent: (nullable): the parent accessible object
* @next_sibling: (nullable): the sibling accessible object
*
* Sets the parent and sibling of an accessible object.
*
* This function is meant to be used by accessible implementations that are
* not part of the widget hierarchy, and but act as a logical bridge between
* widgets. For instance, if a widget creates an object that holds metadata
* for each child, and you want that object to implement the `GtkAccessible`
* interface, you will use this function to ensure that the parent of each
* child widget is the metadata object, and the parent of each metadata
* object is the container widget.
*
* Since: 4.10
*/
void
gtk_accessible_set_accessible_parent (GtkAccessible *self,
GtkAccessible *parent,
GtkAccessible *next_sibling)
{
g_return_if_fail (GTK_IS_ACCESSIBLE (self));
g_return_if_fail (parent == NULL || GTK_IS_ACCESSIBLE (parent));
g_return_if_fail (next_sibling == NULL || GTK_IS_ACCESSIBLE (parent));
GtkATContext *context;
context = gtk_accessible_get_at_context (self);
if (context != NULL)
{
gtk_at_context_set_accessible_parent (context, parent);
gtk_at_context_set_next_accessible_sibling (context, next_sibling);
}
}
/**
* gtk_accessible_update_next_accessible_sibling:
* @self: a `GtkAccessible`
* @new_sibling: (nullable): the new next accessible sibling to set
*
* Updates the next accessible sibling of @self.
* That might be useful when a new child of a custom `GtkAccessible`
* is created, and it needs to be linked to a previous child.
*
* Since: 4.10
*/
void
gtk_accessible_update_next_accessible_sibling (GtkAccessible *self,
GtkAccessible *new_sibling)
{
GtkATContext *context;
g_return_if_fail (GTK_IS_ACCESSIBLE (self));
context = gtk_accessible_get_at_context (self);
if (!context)
return;
if (gtk_at_context_get_accessible_parent (context) == NULL)
{
g_critical ("Failed to update next accessible sibling: no parent accessible set for this accessible");
return;
}
gtk_at_context_set_next_accessible_sibling (context, new_sibling);
}
/**
@@ -151,7 +236,13 @@ gtk_accessible_get_next_accessible_sibling (GtkAccessible *self)
{
g_return_val_if_fail (GTK_IS_ACCESSIBLE (self), NULL);
return GTK_ACCESSIBLE_GET_IFACE (self)->get_next_accessible_sibling (self);
GtkATContext *context;
context = gtk_accessible_get_at_context (self);
if (context != NULL && gtk_at_context_get_accessible_parent (context) != NULL)
return gtk_at_context_get_next_accessible_sibling (context);
else
return GTK_ACCESSIBLE_GET_IFACE (self)->get_next_accessible_sibling (self);
}
/**
+9
View File
@@ -164,11 +164,20 @@ gboolean gtk_accessible_get_platform_state (GtkAccessible *self,
GDK_AVAILABLE_IN_4_10
GtkAccessible * gtk_accessible_get_accessible_parent (GtkAccessible *self);
GDK_AVAILABLE_IN_4_10
void gtk_accessible_set_accessible_parent (GtkAccessible *self,
GtkAccessible *parent,
GtkAccessible *next_sibling);
GDK_AVAILABLE_IN_4_10
GtkAccessible * gtk_accessible_get_first_accessible_child (GtkAccessible *self);
GDK_AVAILABLE_IN_4_10
GtkAccessible * gtk_accessible_get_next_accessible_sibling (GtkAccessible *self);
GDK_AVAILABLE_IN_4_10
void gtk_accessible_update_next_accessible_sibling (GtkAccessible *self,
GtkAccessible *new_sibling);
GDK_AVAILABLE_IN_4_10
gboolean gtk_accessible_get_bounds (GtkAccessible *self,
-6
View File
@@ -23,10 +23,6 @@
#include "gtkapplication.h"
#include "gdkprofilerprivate.h"
#ifdef G_OS_UNIX
#include <gio/gunixfdlist.h>
#endif
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
@@ -36,10 +32,8 @@
#include "gtkapplicationprivate.h"
#include "gtkmarshalers.h"
#include "gtkmain.h"
#include "gtkrecentmanager.h"
#include "gtkicontheme.h"
#include "gtkbuilder.h"
#include "gtkshortcutswindow.h"
#include "gtkprivate.h"
/* NB: please do not add backend-specific GDK headers here. This should
-5
View File
@@ -24,16 +24,11 @@
#include "gtkapplicationprivate.h"
#include "gtkwidgetprivate.h"
#include "gtkwindowprivate.h"
#include "gtkheaderbar.h"
#include "gtkpopovermenubar.h"
#include "gtksettings.h"
#include "gtkshortcutswindowprivate.h"
#include "gtktooltipprivate.h"
#if defined(HAVE_GIO_UNIX) && !defined(__APPLE__)
#include <gio/gdesktopappinfo.h>
#endif
/**
* GtkApplicationWindow:
*
+64
View File
@@ -447,6 +447,70 @@ gtk_at_context_get_accessible_role (GtkATContext *self)
return self->accessible_role;
}
/*< private >
* gtk_at_context_get_accessible_parent:
* @self: a `GtkAtContext`
*
* Retrieves the parent accessible object of the given `GtkAtContext`.
*
* Returns: (nullable) (transfer none): the parent accessible object, or `NULL` if not set.
*/
GtkAccessible *
gtk_at_context_get_accessible_parent (GtkATContext *self)
{
g_return_val_if_fail (GTK_IS_AT_CONTEXT (self), NULL);
return self->accessible_parent;
}
/*< private >
* gtk_at_context_set_accessible_parent:
* @self: a `GtkAtContext`
* @parent: the parent `GtkAccessible` to set
*
* Sets the parent accessible object of the given `GtkAtContext`.
*/
void
gtk_at_context_set_accessible_parent (GtkATContext *self,
GtkAccessible *parent)
{
g_return_if_fail (GTK_IS_AT_CONTEXT (self));
g_set_object (&self->accessible_parent, parent);
}
/*< private >
* gtk_at_context_get_next_accessible_sibling:
* @self: a `GtkAtContext`
*
* Retrieves the next accessible sibling of the given `GtkAtContext`.
*
* Returns: (nullable) (transfer none): the next accessible sibling.
*/
GtkAccessible *
gtk_at_context_get_next_accessible_sibling (GtkATContext *self)
{
g_return_val_if_fail (GTK_IS_AT_CONTEXT (self), NULL);
return self->next_accessible_sibling;
}
/*< private >
* gtk_at_context_set_next_accessible_sibling:
* @self: a `GtkAtContext`
* @sibling: (nullable): the next accessible sibling
*
* Sets the next accessible sibling object of the given `GtkAtContext`.
*/
void
gtk_at_context_set_next_accessible_sibling (GtkATContext *self,
GtkAccessible *sibling)
{
g_return_if_fail (GTK_IS_AT_CONTEXT (self));
g_set_object (&self->next_accessible_sibling, sibling);
}
/*< private >
* gtk_at_context_set_display:
* @self: a `GtkATContext`
+13
View File
@@ -87,6 +87,8 @@ struct _GtkATContext
GtkAccessibleRole accessible_role;
GtkAccessible *accessible;
GtkAccessible *accessible_parent;
GtkAccessible *next_accessible_sibling;
GdkDisplay *display;
GtkAccessibleAttributeSet *states;
@@ -179,4 +181,15 @@ const char * gtk_accessible_property_get_attribute_name (GtkAccessiblePr
const char * gtk_accessible_relation_get_attribute_name (GtkAccessibleRelation relation);
const char * gtk_accessible_state_get_attribute_name (GtkAccessibleState state);
GtkAccessible *
gtk_at_context_get_accessible_parent (GtkATContext *self);
void
gtk_at_context_set_accessible_parent (GtkATContext *self,
GtkAccessible *parent);
GtkAccessible *
gtk_at_context_get_next_accessible_sibling (GtkATContext *self);
void
gtk_at_context_set_next_accessible_sibling (GtkATContext *self,
GtkAccessible *sibling);
G_END_DECLS
-1
View File
@@ -67,7 +67,6 @@
#include "gtkorientable.h"
#include "gtkprivate.h"
#include "gtktypebuiltins.h"
#include "gtksizerequest.h"
#include "gtkwidgetprivate.h"
-3
View File
@@ -216,13 +216,10 @@
#include "gtkdebug.h"
#include "gtkexpression.h"
#include "gtkmain.h"
#include "gtkicontheme.h"
#include "gtkprivate.h"
#include "gtkshortcutactionprivate.h"
#include "gtkshortcuttrigger.h"
#include "gtktestutils.h"
#include "gtktypebuiltins.h"
#include "gtkicontheme.h"
#include "gtkiconthemeprivate.h"
#include "gtkdebug.h"
+1 -6
View File
@@ -69,7 +69,6 @@
#include "gtkbinlayout.h"
#include "gtkimage.h"
#include "gtklabel.h"
#include "gtkmain.h"
#include "gtkmarshalers.h"
#include "gtkprivate.h"
#include "gtktypebuiltins.h"
@@ -639,7 +638,7 @@ gtk_button_new_with_label (const char *label)
/**
* gtk_button_new_from_icon_name:
* @icon_name: (nullable): an icon name
* @icon_name: an icon name
*
* Creates a new button containing an icon from the current icon theme.
*
@@ -969,10 +968,6 @@ gtk_button_set_icon_name (GtkButton *button,
gtk_image_set_from_icon_name (GTK_IMAGE (priv->child), icon_name);
}
gtk_accessible_update_relation (GTK_ACCESSIBLE (button),
GTK_ACCESSIBLE_RELATION_LABELLED_BY, priv->child, NULL,
-1);
gtk_button_set_child_type (button, ICON_CHILD);
g_object_notify_by_pspec (G_OBJECT (button), props[PROP_ICON_NAME]);
}
-1
View File
@@ -114,7 +114,6 @@
#include "gtkeventcontrollerfocus.h"
#include "gtkdragsource.h"
#include "gtknative.h"
#include "gtkicontheme.h"
#include "gtkdragicon.h"
#include "gtkbutton.h"
#include "gtkbox.h"
-2
View File
@@ -29,7 +29,6 @@
#include "gtkactionhelperprivate.h"
#include "gtkboxlayout.h"
#include "gtkbuiltiniconprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkgestureclick.h"
#include <glib/gi18n-lib.h>
#include "gtklabel.h"
@@ -37,7 +36,6 @@
#include "gtkshortcuttrigger.h"
#include "gtkcssnodeprivate.h"
#include "gtkwidgetprivate.h"
#include "gtkmodelbuttonprivate.h"
/**
* GtkCheckButton:
-1
View File
@@ -26,7 +26,6 @@
#include "gtkgesturelongpress.h"
#include "gtkgestureclick.h"
#include "gtkgesturesingle.h"
#include "gtkicontheme.h"
#include "gtkimage.h"
#include <glib/gi18n-lib.h>
#include "gtkmain.h"
-1
View File
@@ -23,7 +23,6 @@
#include "gtkcssimageprivate.h"
#include "gtkcsspalettevalueprivate.h"
#include "gtkcsscolorvalueprivate.h"
#include "gtkiconthemeprivate.h"
#include "gdkpixbufutilsprivate.h"
#include "gtkstyleproviderprivate.h"
-1
View File
@@ -35,7 +35,6 @@
#include "gtkdragicon.h"
#include "gtkprivate.h"
#include "gtkmarshalers.h"
#include "gtkicontheme.h"
#include "gtkpicture.h"
#include "gtksettingsprivate.h"
#include "gtkgesturesingle.h"
+10 -3
View File
@@ -72,6 +72,8 @@ struct _GtkEditableLabel
GtkWidget *stack;
GtkWidget *label;
GtkWidget *entry;
guint stop_editing_soon_id;
};
struct _GtkEditableLabelClass
@@ -196,10 +198,12 @@ static gboolean
stop_editing_soon (gpointer data)
{
GtkEventController *controller = data;
GtkWidget *widget = gtk_event_controller_get_widget (controller);
GtkEditableLabel *self = GTK_EDITABLE_LABEL (gtk_event_controller_get_widget (controller));
if (!gtk_event_controller_focus_contains_focus (GTK_EVENT_CONTROLLER_FOCUS (controller)))
gtk_editable_label_stop_editing (GTK_EDITABLE_LABEL (widget), TRUE);
gtk_editable_label_stop_editing (self, TRUE);
self->stop_editing_soon_id = 0;
return FALSE;
}
@@ -208,7 +212,8 @@ static void
gtk_editable_label_focus_out (GtkEventController *controller,
GtkEditableLabel *self)
{
g_timeout_add (100, stop_editing_soon, controller);
if (self->stop_editing_soon_id == 0)
self->stop_editing_soon_id = g_timeout_add (100, stop_editing_soon, controller);
}
static void
@@ -361,6 +366,8 @@ gtk_editable_label_dispose (GObject *object)
self->entry = NULL;
self->label = NULL;
g_clear_handle_id (&self->stop_editing_soon_id, g_source_remove);
G_OBJECT_CLASS (gtk_editable_label_parent_class)->dispose (object);
}
-8
View File
@@ -32,8 +32,6 @@
#include "gtkaccessibleprivate.h"
#include "gtkadjustment.h"
#include "gtkbox.h"
#include "gtkbutton.h"
#include "deprecated/gtkcelleditable.h"
#include "gtkdebug.h"
#include "gtkeditable.h"
@@ -41,25 +39,19 @@
#include "gtkemojicompletion.h"
#include "gtkentrybuffer.h"
#include "gtkgesturedrag.h"
#include "gtkimageprivate.h"
#include "gtkimcontextsimple.h"
#include <glib/gi18n-lib.h>
#include "gtklabel.h"
#include "gtkmain.h"
#include "gtkmarshalers.h"
#include "gtkpangoprivate.h"
#include "gtkpopover.h"
#include "gtkprivate.h"
#include "gtkprogressbar.h"
#include "gtksettings.h"
#include "gtksnapshot.h"
#include "gtktextprivate.h"
#include "gtktexthandleprivate.h"
#include "gtktextutilprivate.h"
#include "gtktooltip.h"
#include "gtktypebuiltins.h"
#include "gtkwidgetprivate.h"
#include "gtkwindow.h"
#include "gtknative.h"
#include "gtkgestureclick.h"
#include "gtkdragsourceprivate.h"
+1 -1
View File
@@ -207,7 +207,7 @@ send_close (FilechooserPortalData *data)
message = g_dbus_message_new_method_call (PORTAL_BUS_NAME,
PORTAL_OBJECT_PATH,
PORTAL_FILECHOOSER_INTERFACE,
PORTAL_REQUEST_INTERFACE,
"Close");
g_dbus_message_set_body (message,
g_variant_new ("(o)", data->portal_handle));
+1 -6
View File
@@ -60,10 +60,8 @@
#include "gtksizegroup.h"
#include "gtksizerequest.h"
#include "gtkstack.h"
#include "gtktooltip.h"
#include "gtkbox.h"
#include "gtkcheckbutton.h"
#include "gtkwindowgroup.h"
#include <glib/gi18n-lib.h>
#include "gtkfilelauncher.h"
#include "gtkmain.h"
@@ -71,8 +69,6 @@
#include "gtkpopover.h"
#include "gtkrevealer.h"
#include "gtkspinner.h"
#include "gtkseparator.h"
#include "gtkmodelbuttonprivate.h"
#include "gtkeventcontrollerkey.h"
#include "gtkdebug.h"
#include "gtkfilechoosererrorstackprivate.h"
@@ -86,7 +82,6 @@
#include "gtkshortcuttrigger.h"
#include "gtkshortcutaction.h"
#include "gtkshortcut.h"
#include "gtkstringlist.h"
#include "gtkfilterlistmodel.h"
#include "gtkcustomfilter.h"
#include "gtkcustomsorter.h"
@@ -96,7 +91,7 @@
#include "gtkexpression.h"
#ifndef G_OS_WIN32
#include "gopenuriportal.h"
#include "gtkopenuriportal.h"
#endif
#include <cairo-gobject.h>
+3 -3
View File
@@ -694,7 +694,7 @@ gtk_file_dialog_set_initial_file (GtkFileDialog *self,
GFile *folder;
GFileInfo *info;
if (g_file_equal (self->initial_file, file))
if (self->initial_file && g_file_equal (self->initial_file, file))
return;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_INITIAL_FILE]);
@@ -707,7 +707,7 @@ gtk_file_dialog_set_initial_file (GtkFileDialog *self,
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_INITIAL_FOLDER]);
info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME, 0, NULL, NULL);
if (g_file_info_get_edit_name (info) != NULL)
if (info && g_file_info_get_edit_name (info) != NULL)
{
if (g_set_str (&self->initial_name, g_file_info_get_edit_name (info)))
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_INITIAL_NAME]);
@@ -724,7 +724,7 @@ gtk_file_dialog_set_initial_file (GtkFileDialog *self,
g_free (name);
g_free (relative);
}
g_object_unref (info);
g_clear_object (&info);
g_object_unref (folder);
}
else
+6 -6
View File
@@ -22,7 +22,7 @@
#include "gtkfilelauncher.h"
#include "gtkdialogerror.h"
#include "gopenuriportal.h"
#include "gtkopenuriportal.h"
#include "deprecated/gtkshow.h"
#include <glib/gi18n-lib.h>
@@ -219,7 +219,7 @@ open_done (GObject *source,
GTask *task = G_TASK (data);
GError *error = NULL;
if (!g_openuri_portal_open_finish (result, &error))
if (!gtk_openuri_portal_open_finish (result, &error))
g_task_return_error (task, error);
else
g_task_return_boolean (task, TRUE);
@@ -367,9 +367,9 @@ gtk_file_launcher_launch (GtkFileLauncher *self,
}
#ifndef G_OS_WIN32
if (g_openuri_portal_is_available ())
if (gtk_openuri_portal_is_available ())
{
g_openuri_portal_open_async (self->file, FALSE, parent, cancellable, open_done, task);
gtk_openuri_portal_open_async (self->file, FALSE, parent, cancellable, open_done, task);
}
else
#endif
@@ -461,9 +461,9 @@ gtk_file_launcher_open_containing_folder (GtkFileLauncher *self,
}
#ifndef G_OS_WIN32
if (g_openuri_portal_is_available ())
if (gtk_openuri_portal_is_available ())
{
g_openuri_portal_open_async (self->file, TRUE, parent, cancellable, open_done, task);
gtk_openuri_portal_open_async (self->file, TRUE, parent, cancellable, open_done, task);
}
else
#endif
-1
View File
@@ -26,7 +26,6 @@
#include "deprecated/gtkfontchooserwidget.h"
#include "gtkfontchooserwidgetprivate.h"
#include "gtkfontchooserutils.h"
#include "gtkbox.h"
#include <glib/gi18n-lib.h>
#include "gtkbuildable.h"
#include "gtkprivate.h"
+1
View File
@@ -919,6 +919,7 @@ gtk_font_chooser_widget_class_init (GtkFontChooserWidgetClass *klass)
gtk_widget_class_bind_template_child (widget_class, GtkFontChooserWidget, selection);
gtk_widget_class_bind_template_child (widget_class, GtkFontChooserWidget, custom_filter);
gtk_widget_class_bind_template_child (widget_class, GtkFontChooserWidget, user_filter);
gtk_widget_class_bind_template_child (widget_class, GtkFontChooserWidget, multi_filter);
gtk_widget_class_bind_template_child (widget_class, GtkFontChooserWidget, preview);
gtk_widget_class_bind_template_child (widget_class, GtkFontChooserWidget, preview2);
gtk_widget_class_bind_template_child (widget_class, GtkFontChooserWidget, size_label);
+4 -4
View File
@@ -223,8 +223,8 @@ gtk_gesture_drag_new (void)
/**
* gtk_gesture_drag_get_start_point:
* @gesture: a `GtkGesture`
* @x: (out) (nullable): X coordinate for the drag start point
* @y: (out) (nullable): Y coordinate for the drag start point
* @x: (out) (optional): X coordinate for the drag start point
* @y: (out) (optional): Y coordinate for the drag start point
*
* Gets the point where the drag started.
*
@@ -263,8 +263,8 @@ gtk_gesture_drag_get_start_point (GtkGestureDrag *gesture,
/**
* gtk_gesture_drag_get_offset:
* @gesture: a `GtkGesture`
* @x: (out) (nullable): X offset for the current point
* @y: (out) (nullable): Y offset for the current point
* @x: (out) (optional): X offset for the current point
* @y: (out) (optional): Y offset for the current point
*
* Gets the offset from the start point.
*
-2
View File
@@ -26,9 +26,7 @@
#include "gtkbuildable.h"
#include "gtkcenterbox.h"
#include "gtklabel.h"
#include "gtknative.h"
#include "gtkprivate.h"
#include "gtksizerequest.h"
#include "gtktypebuiltins.h"
#include "gtkwidgetprivate.h"
#include "gtkwindowcontrols.h"
-1
View File
@@ -27,7 +27,6 @@
#include "gtkimageprivate.h"
#include "gtkiconhelperprivate.h"
#include "gtkicontheme.h"
#include "gtkprivate.h"
#include "gtksnapshot.h"
#include "gtktypebuiltins.h"
+3 -3
View File
@@ -606,9 +606,9 @@ gtk_list_view_size_allocate (GtkWidget *widget,
}
/* step 1: determine width of the list */
gtk_widget_measure (widget, opposite_orientation,
-1,
&min, &nat, NULL, NULL);
gtk_list_view_measure_across (widget, opposite_orientation,
-1,
&min, &nat);
self->list_width = orientation == GTK_ORIENTATION_VERTICAL ? width : height;
if (opposite_scroll_policy == GTK_SCROLL_MINIMUM)
self->list_width = MAX (min, self->list_width);

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