Compare commits

...

1295 Commits

Author SHA1 Message Date
Nelson Benítez León
64a708559a fix detection of gio/gdesktopappinfo.h
Header file gio/gdesktopappinfo.h is currently never found
by Meson because it's inside gio-unix-2.0 directory.

This bug was introduced by commit 13b94dab10 which
fixed the build for MacOS but caused the header file
to not be detected by Linux anymore.

One possible fix would be to replace 'gio/gdesktopappinfo.h'
with 'gio-unix-2.0/gio/gdesktopappinfo.h', but as it's a
unix only header we move the check to an appropiate place
where other unix specific handling is done.
2023-11-12 21:46:27 +00:00
Ekaterine Papava
cc2d3fa7d6 Update Georgian translation 2023-11-09 09:41:14 +00:00
Benjamin Otte
a9e4993184 Merge branch 'wip/otte/enable-debug' into 'main'
Remove G_ENABLE_DEBUG around debug checks

See merge request GNOME/gtk!6546
2023-11-07 15:12:11 +00:00
Benjamin Otte
33703bfe01 Merge branch 'wip/otte/for-main' into 'main'
dmabuf: Set same YUV colorspace as elsewhere

See merge request GNOME/gtk!6548
2023-11-07 05:11:10 +00:00
Benjamin Otte
7ba5cf5309 inspector: Add more info about GL
Print all the variables queryable via glGetString().

And remove them from the Windows backend.
2023-11-07 05:33:48 +01:00
Benjamin Otte
bb890f6004 inspector: Don't list unused EGL extension
We don't use that extension and I don't even know what it is about -
which is a good reason to get rid of showing it.
2023-11-07 05:12:57 +01:00
Benjamin Otte
1c7a0e7a15 inspector: Use right name for Vulkan validation layer
The name got changed a while ago, so let's reflect that.
2023-11-07 05:12:57 +01:00
Benjamin Otte
cd7e1c1387 dmabuf: Modify gdk_gl_context_import_dmabuf()
Move a bunch of code - namely the target selection - into the function.

I want to use the same code in the NGL renderer, so no need to duplicate
it.
2023-11-07 05:12:57 +01:00
Benjamin Otte
a2e1e727c5 testsuite: Make texture-scale-magnify tests have roundable numbers
Use a number that's 2^N * 255 to get floating point awesomeness combined
with uint8_t awesomeness.

Fixes rounding errors in samplers.
2023-11-07 05:12:57 +01:00
Benjamin Otte
61207f81c3 dmabuf: Set same YUV colorspace as elsewhere
We use ITU.601 full range everywhere, so ensure it's used here, too.
2023-11-07 05:12:57 +01:00
Benjamin Otte
f624586a75 testsuite: Don't skip test
The test now works without debugging as debug messages are always
available.
2023-11-05 11:16:23 +01:00
Benjamin Otte
1a93967e1f gdk: Remove debug modes in gdk_debug_parse_var()
Always support all variables.
2023-11-05 11:16:23 +01:00
Benjamin Otte
310ab7b531 Remove G_ENABLE_DEBUG around debug checks
It started out as busywork, but it does many separate things. If I could
start over, I'd take them apart into multiple commits:

1. Remove G_ENABLE_DEBUG around GDK_DEBUG_*() calls
   This is not needed at all, the calls themselves take care of it.

2. Remove G_ENABLE_DEBUG around profiling code
   This now enables profiling support in release builds.

3. Stop poking _gdk_debug_flags and use GDK_DEBUG_CHECK()
   This was old code that was never updated.

4. Make !G_ENABLE_DEBUG turn off GDK_DEBUG_CHECK()
   The code used to
     #define GDK_DEBUG_CHECK(...) false
     #define GDK_DEBUG(...)
   which would compile away all the code inside those macros. This
   means a lot of variable definitions and debug utility functions
   would suddenly no longer be used and cause compiler errors.
2023-11-05 11:16:23 +01:00
Benjamin Otte
d55801c8ba debug: Turn gdk_debug_message() into a function
1. MSVC can't deal with the nonstandard ##__VA_ARGS__

2. It allows setting a breakpoint on it.
2023-11-05 10:21:54 +01:00
Matthias Clasen
b1809bfd88 Merge branch 'matthiasc/for-main' into 'main'
print dialog: Improve local fallback

See merge request GNOME/gtk!6547
2023-11-04 23:20:53 +00:00
Matthias Clasen
deb8a35ea0 print dialog: Improve local fallback
We need to set embed-page-setup for the paper size and orientation
combos to work.
2023-11-05 01:00:39 +02:00
Jordi Mas i Hernandez
c5ce24c82c Update Catalan translation 2023-11-04 18:28:38 +00:00
Artur S0
54815e4771 Update Russian translation 2023-11-04 02:09:09 +00:00
Matthias Clasen
5a99790a87 Merge branch 'examples-gtk-widget-show' into 'main'
docs: Replace deprecated gtk_widget_show with gtk_widget_set_visible

See merge request GNOME/gtk!6538
2023-11-03 15:29:39 +00:00
Matthias Clasen
8aa7174bfb Merge branch 'faster-fps-overlay' into 'main'
inspector: Speed up the fps overlay

See merge request GNOME/gtk!6544
2023-11-01 22:44:44 +00:00
Benjamin Otte
9df5e3cbd6 inspector: Replace "no glyph" with space glyph
This makes right-aligning the text work again.
2023-11-01 21:57:56 +01:00
Benjamin Otte
8b5194c016 inspector: Use the right font for the fps overlay
Initialize the font only when we have a widget that provides it. That
way we don't pick a terrible default font, but the widget's preferred
one.
2023-11-01 21:32:55 +01:00
Matthias Clasen
9a63172cf5 Some minor fpsoverlay improvements
Avoid some allocations.
2023-11-01 14:45:57 -04:00
Matthias Clasen
3ade9ae184 inspector: Speed up the fps overlay
Do less work!
2023-11-01 14:00:42 -04:00
Benjamin Otte
76349ff6e5 Merge branch 'wip/otte/for-main' into 'main'
testsuite: Add render test for texture placement

See merge request GNOME/gtk!6543
2023-11-01 14:36:07 +00:00
Benjamin Otte
dd530b45e2 gstmediafile: Handle premultiplied alpha
1. Check GStreamer caps for premultiplied alpha and select
   GdkMemoryFormat accordingly

2. Set a GdkMemoryFormat for GL textures

Fixes the video in widget-factory being treated as premultiplied when it
isn't.
2023-11-01 08:01:27 +01:00
Benjamin Otte
00ce51472c testsuite: Add render test for texture placement
Make sure that texture nodes sample from the texture properly.
2023-11-01 08:01:27 +01:00
Matthias Clasen
b6bcbeae23 Merge branch 'matthiasc/for-main' into 'main'
inspector: Show more EGL extensions

See merge request GNOME/gtk!6542
2023-10-31 23:12:54 +00:00
Robert Ancell
cf86cc1184 docs: Use gtk_window_present instead of gtk_widget_set_visible 2023-11-01 10:54:33 +13:00
Matthias Clasen
b503b60a49 inspector: Show more EGL extensions
We care about these now.
2023-10-31 17:53:25 -04:00
Matthias Clasen
5850055b68 Merge branch 'progressbar_overflow_fix' into 'main'
GtkProgressBar: Fix: progress can overflow trough

See merge request GNOME/gtk!6445
2023-10-31 11:22:32 +00:00
Matthias Clasen
b224e66a9f Merge branch 'scale_overflow_fix' into 'main'
GtkScale: Fix: highlight can overflow trough

Closes #5751

See merge request GNOME/gtk!6444
2023-10-31 11:22:02 +00:00
Robert Ancell
8aef682079 docs: Replace deprecated gtk_widget_show with gtk_widget_set_visible 2023-10-31 13:27:26 +13:00
Benjamin Otte
fe4b7a5159 Merge branch 'wip/otte/for-main' into 'main'
rendernode-tool: Add --undecorated to show command

See merge request GNOME/gtk!6537
2023-10-31 00:23:18 +00:00
Benjamin Otte
7ba4ba05e1 gl: Fix padding in icon library
The previous code would not pad the left side with the left column of
pixels but with the top row.

Test attached.
2023-10-31 00:50:00 +01:00
Benjamin Otte
85e1088171 gsk: Fix texture-scale node Cairo drawing
The code was interpreting x/y coordinates wrong sometimes and causing
things to not be drawn at the correct offset.

Testcase included.
2023-10-31 00:36:27 +01:00
Benjamin Otte
c1ed034367 rendernode: Use an exisiting function instead of reimplementing it 2023-10-31 00:36:27 +01:00
Benjamin Otte
cc3e25b163 testsuite: Be more resistant against rounding errors
Make a test use numbers that are less likely to cause rounding
issues in GPUs (read: use powers of 2).
2023-10-31 00:36:27 +01:00
Benjamin Otte
bdb3e345c8 testsuite: Add test for scaling texture-scale node
Finally figured out a way to test that a texture-scale node using
NEAREST that is upscaled using a transform node doesn't use NEAREST but
LINEAR.
2023-10-31 00:36:27 +01:00
Benjamin Otte
a30e9dcfeb testsuite: Add a test for nearest vs linear scales 2023-10-31 00:36:27 +01:00
Benjamin Otte
76007c4d09 rendernode-tool: Add --undecorated to show command
This is to get exactly just the rendernode drawn when testing, and not
any extra drawing code.
2023-10-31 00:36:27 +01:00
Matthias Clasen
020ef51cb0 Merge branch 'matthiasc/for-main' into 'main'
Revert "glcontext: Better debug spew"

See merge request GNOME/gtk!6536
2023-10-29 19:04:26 +00:00
Matthias Clasen
1914adc344 dmabuf: Don't check for image storage
I was wrong about this extension, and it isn't even a GL extension
to begin with, so revert all this.
2023-10-29 14:45:20 -04:00
Matthias Clasen
6e236b9459 Revert "gl context: Check for more GL extensions"
This reverts commit b8b5835fc6.
2023-10-29 14:44:46 -04:00
Matthias Clasen
11715760f9 Revert "glcontext: Better debug spew"
This reverts commit 30e14f73fa.
2023-10-29 14:44:29 -04:00
Matthias Clasen
f19c08ffda Merge branch 'add-view-grid-symbolic-icon' into 'main'
icons: Add view-grid-symbolic

Closes #6184

See merge request GNOME/gtk!6534
2023-10-29 15:32:27 +00:00
Kleis Auke Wolthuizen
d0f76b6ab4 widget-factory: Remove insert-image icon
This icon is already present in the hicolor icon theme.
2023-10-28 20:25:53 +02:00
Kleis Auke Wolthuizen
4c7206343a widget-factory: Remove view-grid-symbolic icon
No longer needed as it's included in the hicolor icon theme now.
2023-10-28 20:25:53 +02:00
Kleis Auke Wolthuizen
dfae2cb3a5 icons: Add view-grid-symbolic
This showed up as missing icon in the file chooser when used with
the hicolor icon theme.

Resolves: https://gitlab.gnome.org/GNOME/gtk/-/issues/6184
2023-10-28 20:05:27 +02:00
Matthias Clasen
de74d38039 Merge branch 'improve-msvc-force-include' into 'main'
MSVC builds: Improve build process (was: MSVC builds: Always enable items from msvc_recommended_pragmas.h)

See merge request GNOME/gtk!6114
2023-10-27 22:11:06 +00:00
Matthias Clasen
fb20542fcc Merge branch 'fix_name_computation' into 'main'
a11y: When using rule 2.E for computing accessible name, use it only if appropriate

See merge request GNOME/gtk!6495
2023-10-27 17:32:14 +00:00
Lukáš Tyrychtr
a26e289d5c Adjust tests 2023-10-26 09:44:59 +02:00
Lukáš Tyrychtr
892d3b9530 a11y: When using rule 2.E for computing accessible name, use it only if appropriate
We were using it in all cases, so, we were using it to compute descriptions,
and also for non-embedded controls. That was overriding descriptions
set, for example, in Gnome settings, and was causing the value of spinboxes
to be read multiple times.
2023-10-26 09:40:30 +02:00
Chun-wei Fan
8477dcfeff builds: Require -Zc:preprocessor for Visual Studio debug builds
This flag is actually required for the debugging code to successfully build,
so check that it is really there for debug-enabled Visual Studio builds.
2023-10-26 10:40:17 +08:00
Chun-wei Fan
25835afd9c MSVC Builds: Don't enable -utf-8 explicitly
We already require a Meson release that enables -utf-8 by default, so we don't
really need to explicitly enable it here.
2023-10-26 10:40:17 +08:00
Matthias Clasen
06dda4e12b Merge branch 'memory-format-swizzle-check' into 'main'
gl: Check all swizzle values

See merge request GNOME/gtk!6524
2023-10-26 02:38:35 +00:00
Chun-wei Fan
26edfe6d18 build: Add msvc_recommended_pragmas.h
We really always want to force-include msvc_recommended_pragmas.h to check for
things at compile time so that we can avoid stuff like missing includes or
attempting to return a value in a function that is supposed to have a
void-return-type.

The current problem is that, as indicated in the Visual Studio CI job, that we
couldn't locate msvc_recommended_pragmas.h during the build if GLib is built
as a subproject, and/or when msvc_recommended_pragmas.h is not in the paths
indicated by %INCLUDE%, meaning that the aforementioned issues would not be
caught by CI, which will then break builds on Visual Studio for people when
msvc_recommended_pragmas.h is found during their builds.

It would also be nice to be quiet from the warnings that we can really
disregard anyways.

So, add a copy of msvc_recommended_pragmas.h from GLib and update the build
files to look for it in build-aux/msvc, so that it can always be used during
the build, especially by the CI.
2023-10-26 10:38:14 +08:00
Matthias Clasen
4a749aee6e Fix swizzle values for some memory formats
For opaque formats with 3 channels, we should use the default
GL_ALPHA, but for opaque formats with an ignored 4th channel,
we must use GL_ONE.
2023-10-25 21:39:52 -04:00
Matthias Clasen
99a8417142 Merge branch 'add-bn-hi-po-translated' into 'main'
translated bn.po and hi.po

See merge request GNOME/gtk!6530
2023-10-25 16:34:19 +00:00
Matthias Clasen
20e2075a10 Merge branch 'allow-implicit-modifiers' into 'main'
Allow implicit modifiers

See merge request GNOME/gtk!6529
2023-10-25 02:52:49 +00:00
Matthias Clasen
d8c649b57f Merge branch 'matthiasc/for-main' into 'main'
dmabuf: No mipmaps for dmabuf textures

See merge request GNOME/gtk!6531
2023-10-25 02:43:19 +00:00
Matthias Clasen
bb2b8bf2c3 dmabuf: Refine the handling of implicit modifiers
If all formats with a given fourcc are external, treat the
fourcc with implicit modifiers as external too, following a
sugestion by Benjamin Otte.
2023-10-24 22:33:45 -04:00
Matthias Clasen
eb048c91be dmabuf: Allow implicit modifiers
Remove all the roadblocks we've put up to keep implicit modifiers
out. Our importing code already handles them as a signal that says
'No modifiers, please!'. Now we just hope for the best and pass
things along.

This is necessary since some drivers won't produce any explicit
modifiers.
2023-10-24 22:33:45 -04:00
Matthias Clasen
358779dfb2 dmabuf: No mipmaps for dmabuf textures
Calling glGenerateMipmap on imported dmabufs does not work, so
don't do it.
2023-10-24 22:03:31 -04:00
Matthias Clasen
8f90ddb906 dmabuf: Cache egl formats
Only call eglQueryDmaBufModifiersEXT once, and reuse the results.
2023-10-24 21:53:09 -04:00
Matthias Clasen
ed54aa8acf Merge branch 'matthiasc/for-main' into 'main'
Fix annotations

See merge request GNOME/gtk!6522
2023-10-24 15:04:16 +00:00
Matthias Clasen
a90ffb117f docs: Some additions
Add a link to the kernel docs about dmabufs.
2023-10-24 10:50:46 -04:00
Matthias Clasen
29681717ed Fix annotations
It is always org.gtk.Property, even if we are in gdk.
2023-10-24 07:16:42 -04:00
sudip
e0cd2b756f translated bn.po and hi.po
Resolves:https://gitlab.gnome.org/GNOME/gtk/-/issues/6164
2023-10-24 16:20:24 +05:30
Matthias Clasen
2c85060b5f Merge branch 'msvc-for-main' into 'main'
Few small fixes for Visual Studio builds

See merge request GNOME/gtk!6521
2023-10-24 10:44:22 +00:00
Chun-wei Fan
864c5b4608 testsuite: Disable dmabuftexture test on Windows
It's not meaningful there.
2023-10-24 14:08:16 +08:00
Chun-wei Fan
1ab501649e gsk/gskcurve.c: Avoid returning value in void-retype function
This is considered a compiler error with later GLib releases with Visual Studio
builds, so avoid that.
2023-10-24 13:18:26 +08:00
Benjamin Otte
2d874e601c Merge branch 'wip/otte/for-main' into 'main'
gl: Remove optimization that does the wrong thing

See merge request GNOME/gtk!6528
2023-10-24 02:51:02 +00:00
Benjamin Otte
c9b83dfa1d testsuite: Add a test for texture-scale filters
Check that the right filter is chosen and that that filter is
implemented correctly.

The test is disabled for Cairo because Cairo (or rather Pixman)
doesn't follow the filtering specifications for GL/Vulkan and in
particular the nearest filter picks a different pixel.
2023-10-24 01:41:25 +02:00
Benjamin Otte
dd7a38069f gl: Remove optimization that does the wrong thing
Drawing a texture-scale node like a texture node when the filter is set
to "linear" doesn't work, because the texture node switches to
trilinear when mipmaps are available.
2023-10-24 01:37:38 +02:00
Benjamin Otte
51a181af7a Merge branch 'wip/otte/for-main' into 'main'
dmabuf: Seek back to the start

See merge request GNOME/gtk!6526
2023-10-23 19:57:21 +00:00
Benjamin Otte
8fcd9bc0c4 gl: Make sure render_texture() sets the right format for high depth
Setting the format got lost when converting this coe to the texture
builder, because that codepaths avods the texture sniffing and always
uses RGBA8.
2023-10-23 21:22:17 +02:00
Benjamin Otte
e2edf693f5 gdk: Make float32 report its true depth
I have no idea how this is the only value that is wrong.
2023-10-23 21:22:17 +02:00
Benjamin Otte
323300e92a dmabuf: Seek back to the start
https://docs.kernel.org/driver-api/dma-buf.html recommends doing that,
so we do that.
2023-10-23 17:57:57 +02:00
Benjamin Otte
e688be1cff gdk: Add some debug messages around dmabuf initialization 2023-10-23 17:57:57 +02:00
Guillaume Bernard
611d5cf844 Update French translation
(cherry picked from commit 3b8c1189f4)
2023-10-23 15:22:29 +00:00
Matthias Clasen
677e78bdce gl: Check all swizzle values
There is no reason not check the alpha swizzle for being different
from its default value. I am thinking about implementing RGBx
upload with a swizzle of rgb1, and that would break here.
2023-10-23 07:55:39 -04:00
Matthias Clasen
51cb1aeb4e Merge branch 'matthiasc/for-main' into 'main'
Matthiasc/for main

See merge request GNOME/gtk!6519
2023-10-23 04:11:04 +00:00
Matthias Clasen
625eb508e8 dmabuftexturebuilder: Fix doc formatting 2023-10-22 23:24:46 -04:00
Matthias Clasen
2718e1715d display: Add details to the docs 2023-10-22 23:24:27 -04:00
Matthias Clasen
6ddcad6b33 dmabuf: Update a comment 2023-10-22 23:14:07 -04:00
Matthias Clasen
0c23997f70 Merge branch 'matthiasc/for-main' into 'main'
Cosmetics

See merge request GNOME/gtk!6518
2023-10-23 03:13:41 +00:00
Matthias Clasen
4d1ef63009 gsk: Ensure dmabuf formats are initialized
We just poking at display members here, there is no guarantee that
dmabuf formats have been initialized. So do it explicitly.

This prevents a crash in the inspector when viewing a recorded frame
containing a dmabuf texture, since the inspector uses a separate
display connection.
2023-10-22 22:48:18 -04:00
Matthias Clasen
30e14f73fa glcontext: Better debug spew
Print out all the extensions we checked.
2023-10-22 22:41:53 -04:00
Matthias Clasen
39e205aa78 dmabuf: Don't print unsupported formats
We were confusingly printing "supported format" for dmabuf formats
that we end up not adding to our list of supported formats. Don't
do that, it is confusing. At the same time, we shuold print out
the linear formats we support via mmap.
2023-10-22 22:29:44 -04:00
Matthias Clasen
f0ec1660c1 Make testdmabuf fall back to memfd
If we can't open /dev/dma_heap/system, fall back to using memfd_create.
It does not let us make a 'proper' dmabuf, but it is good enough to
test our handling of linear buffers in various formats.
2023-10-22 22:18:30 -04:00
Matthias Clasen
79f98f3a13 Cosmetics
Typo fix.
2023-10-22 22:18:30 -04:00
Benjamin Otte
5f0557027d Merge branch 'wip/otte/for-main' into 'main'
dmabuf: Add NV16, NV61, NV24 and NV42

See merge request GNOME/gtk!6517
2023-10-23 01:49:30 +00:00
Benjamin Otte
a579e3bc6d build: Fix up header includes
These weren't fixed in the merge request in
  https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/6489
to the change from
  https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/6514
2023-10-23 03:12:09 +02:00
Benjamin Otte
8f70f4b85e dmabuf: Add support for 3 plane YUV formats 2023-10-23 02:54:23 +02:00
Benjamin Otte
911198cddd dmabuf: Add NV16, NV61, NV24 and NV42
and sanitize them and NV21.
2023-10-23 02:54:23 +02:00
Matthias Clasen
ca5247a995 Post-release version bump 2023-10-22 19:04:54 -04:00
Matthias Clasen
004a881521 4.13.2 2023-10-22 18:58:50 -04:00
Matthias Clasen
65993ed0e0 Merge branch 'dont-claim-external-formats' into 'main'
dmabuf: We don't support external formats on GL

See merge request GNOME/gtk!6516
2023-10-22 22:40:48 +00:00
Matthias Clasen
a4d0a5bda5 dmabuf: We don't support external formats on GL
Filter out external-only formats unless we are on GLES.
2023-10-22 17:54:18 -04:00
Matthias Clasen
33bc276639 Merge branch 'dmabuf-texture-gl-downloader' into 'main'
dmabuf: Add an EGL downloader

See merge request GNOME/gtk!6489
2023-10-22 21:13:58 +00:00
Matthias Clasen
06822581f7 gsk: Use external textures
When we are running under GLES, we can use GL_TEXTURE_EXTERNAL_OES
to support YUV formats.

Since we don't want to deal with the combinatorial explosion of
compiling all our shaders with all combinations  of sampler2D vs
samplerExternalOES for all their textures, we copy the external
textures to a regular texture before using them.
2023-10-22 16:50:43 -04:00
Matthias Clasen
976143fbe9 gsk: Add a shader for external textures
This shader uses samplerExternalOES to sample an external texture
and blit it into a 'normal' texture. It only works in GLES, but
we won't use it outside of GLES.
2023-10-22 16:42:17 -04:00
Matthias Clasen
9fd4feef0c gsk: Use some GLES extensions
Allow our shaders to use samplerExternalOES, by declaring
that we use the relevant extension. Unfortunately, this
only works for gles, and requires different extensions for
gles2 and gles3. Yay
2023-10-22 16:42:17 -04:00
Matthias Clasen
5eed13bd07 gsk: Define GSK_GLES3 if we have gles3
The compiler defines GSK_GLES only for gles2. Add another define
for gles3, so we can differentiate where we need to.

This took a week to find!
2023-10-22 16:42:17 -04:00
Matthias Clasen
d02d45dd8d gsk: Allow shaders without clip variants
Add a GSK_GL_DEFINE_PROGRAM_NO_CLIP, which is like
GSK_GL_DEFINE_PROGRAM but compiles the shader just once,
with NO_CLIP defined.

This will be used in the future for shaders that do
texture conversion.
2023-10-22 16:42:17 -04:00
Matthias Clasen
13d0e311b7 gsk: Prepare for external textures
Prepare the plumbing in the GL renderer for textures that use
target GL_TEXTURE_EXTERNAL_OES. These need to use a special sampler,
so make sure our sampler machinery does not run over it.
2023-10-22 16:42:17 -04:00
Matthias Clasen
52254f755f gsk: Support dmabuf textures
Defer handling of dmabuf textures to the driver,
and add the necessary code in load_texture.
2023-10-22 16:42:17 -04:00
Matthias Clasen
494154beb6 dmabuf: Add an EGL downloader
Add an implementation of GdkDmabufDownloader that uses
gsk_renderer_render_texture + GL texture download.

Since gsk isn't threadsafe, we do the download in the main thread,
taking care to not disturb the current GL context of whatever is
going on there at the time.

And since gsk renderers are expensive to create, we cache it
in the display.

Note that gsk does not yet have any special support for
dmabuf textures, so for now, they will always get downloaded
and then reuploaded as GL textures.
2023-10-22 16:42:17 -04:00
Matthias Clasen
adde188eca gsk: Add a helper for converting textures
This is a simple helper that feed a GdkTexture
through a renderer and returns the resulting
texture. This will be used to convert dmabuf
textures to 'native' textures.
2023-10-22 16:39:24 -04:00
Matthias Clasen
8fb0ab2b43 gl context: Add private dmabuf API
Add API to import a dmabuf into a texture,
and to export a texture to a dmabuf.

All this is implemented using the relevant
EGL and GL extensions.
2023-10-22 16:39:24 -04:00
Matthias Clasen
b8b5835fc6 gl context: Check for more GL extensions
These will be used in future commits.
2023-10-22 16:39:24 -04:00
Matthias Clasen
463307655c display: Check for more EGL extensions
We are going to rely on this in future commits.
2023-10-22 16:39:24 -04:00
Matthias Clasen
d17d8e04a6 Add a few dmabuf texture tests
Test some basic import and export of dmabufs.

For now, put the test into the 'failing' suite,
since it does not work in CI, and also fails
on AMD hw.
2023-10-22 16:39:24 -04:00
Matthias Clasen
d8d1dfd8f3 Merge branch 'matthiasc/for-main' into 'main'
gsk: Restore bigendian support

See merge request GNOME/gtk!6515
2023-10-22 20:34:30 +00:00
Matthias Clasen
f581280811 gsk: Restore bigendian support
Restore the bigendian support that was lost in b0e26873f6,
by just not using GL_BGRA with GLES on bigendian. Should be a
very rare combination, but still.
2023-10-22 16:19:31 -04:00
Benjamin Otte
3a9aea44df Merge branch 'wip/otte/for-main' into 'main'
build: Change where we get drm_fourcc.h from

See merge request GNOME/gtk!6514
2023-10-22 19:33:27 +00:00
Benjamin Otte
e05764806a build: Change where we get drm_fourcc.h from
The canonical source for userspace is libdrm, not kernel headers.

Fixes compilation on Arch Linux.
2023-10-22 20:40:20 +02:00
Benjamin Otte
5ca65f04fe Merge branch 'wip/otte/for-main' into 'main'
dmabuf: Allow downloaders to fail initialization

See merge request GNOME/gtk!6513
2023-10-22 17:19:16 +00:00
Benjamin Otte
32ba1e389c build: Check for drm/drm_fourcc.h too
It's part of the kernel headers package so I did not check for libdrm.

As a side effect I checked the #define to HAVE_DMABUF.
2023-10-22 17:27:11 +02:00
Benjamin Otte
beb9e0c906 dmabuf: Add gdk_dmabuf_is_disjoint()
No users yet, but Vulkan will use this later. So have it available
already.
2023-10-22 17:03:15 +02:00
Benjamin Otte
98f02f6221 dmabuf: Reject the INVALID modifier
Trying to use it is a programming error, applications should have code
that uses real modifiers.

Also add a check to the formatsbuilder so our code doesn't include the
invalid modifier by accident.

We don't really know how to deal with it, so better force applications
to figure out what to do.
2023-10-22 17:03:15 +02:00
Benjamin Otte
13848969f4 dmabuf: Allow downloaders to fail initialization
When adding the formats of a downloader, allow them to return FALSE to
mean "This method is not supported", which is a useful way to opt out
when checking GL or Vulkan extensions and finding out that the desired
one isn't supported.
2023-10-22 17:03:13 +02:00
Matthias Clasen
0817dfe67f Merge branch 'matthiasc/for-main' into 'main'
dmabuf: Give downloaders a name

See merge request GNOME/gtk!6511
2023-10-21 23:42:10 +00:00
Matthias Clasen
9e3f537a15 dmabuf: Give downloaders a name
Add name to the downloader struct, and add it
to the debug spew for newly created dmabuf
textures.
2023-10-21 19:19:21 -04:00
Matthias Clasen
612e0e29f9 Merge branch 'matthiasc/for-main' into 'main'
testdmabuf: Add a --download-to option

See merge request GNOME/gtk!6510
2023-10-21 21:39:36 +00:00
Matthias Clasen
e1cbc96b8c testdmabuf: Add a --download-to option
The next option we add will tilt the balance
towards GOptionContext.
2023-10-21 17:26:53 -04:00
Matthias Clasen
410240fe7b Merge branch 'matthiasc/for-main' into 'main'
Cosmetics

See merge request GNOME/gtk!6509
2023-10-21 20:34:36 +00:00
Matthias Clasen
73cf3a92f9 cosmetics 2023-10-21 16:10:09 -04:00
Matthias Clasen
dd15122ccb dmabuf: Add some debug spew 2023-10-21 14:44:28 -04:00
Benjamin Otte
5299f1384f Merge branch 'wip/otte/for-main' into 'main'
dmabuf: Require valid fds for all planes

See merge request GNOME/gtk!6508
2023-10-21 15:15:57 +00:00
Benjamin Otte
58a0e4ffaa testdmabuf: Add --disjoint and --undecorated
The code now by default puts all planes into the same fd - like
v4l does, too.

The old behavior of one fd per plane can be enabled via --disjoint.

Also, am --undecorated option has been added so that the window
isn't decorated and all that the renderer has to do is display the
dmabuf.
This is useful when debugging just the dmabuf rendering.
2023-10-21 17:02:05 +02:00
Benjamin Otte
7ab9056c11 testdmabuf: Fix NV12
The code was computing the wrong size.
2023-10-21 16:42:16 +02:00
Benjamin Otte
2d9fbb16bc testdmabuf: Use the actual pixel
The previous code would subsample the luma channel, too. Don't do that.
2023-10-21 16:42:15 +02:00
Benjamin Otte
cbfd8542c6 dmabuf: Require valid fds for all planes
This seems to be what everyone does, so we should do it, too.

Previously it was assumed that an fd of -1 would mean reusing the
previous fd with a different offset, but that seems to be uncommon.
2023-10-21 16:42:15 +02:00
Piotr Drąg
7679504134 Update POTFILES.in 2023-10-21 14:14:02 +02:00
Sabri Ünal
446d461ad2 Update Turkish translation 2023-10-21 09:16:05 +00:00
Matthias Clasen
5b6fcfe8c9 Merge branch 'misc-dmabuf-fixes' into 'main'
Make a test app with dma heaps

See merge request GNOME/gtk!6507
2023-10-21 02:06:20 +00:00
Matthias Clasen
59ce7ab222 dmabuf: Improve the debug message
Printing the format can only help.
2023-10-20 20:03:27 -04:00
Matthias Clasen
0992837b08 dmabuf: Fix the mmap logic
We want to unmap the buffers we mapped in
the first loop, so pass the right pointers
here.
2023-10-20 20:03:11 -04:00
Matthias Clasen
aca02916ad dmabuf: Fix NV12 import
We were not seeking in the right fd,
so our sizes were wrong, and crashes
happened.
2023-10-20 19:53:33 -04:00
Matthias Clasen
98e883f9b4 Make a test app with dma heaps
This uses the dma-heap kernel api to create a dma-buf
and use it for a GdkDmabufTexture. It supports a few
formats to test how well GL conversion of YUV works.

The YUV code is adapted from weston tests.
2023-10-20 19:53:33 -04:00
Matthias Clasen
2c66aa0c15 Merge branch 'matthiasc/for-main' into 'main'
dmabuf: Fix format mapping for RGB formats

See merge request GNOME/gtk!6506
2023-10-20 23:44:52 +00:00
Matthias Clasen
8843c0d504 dmabuf: Fix format mapping for RGB formats
The channel order was reversed.
2023-10-20 19:22:00 -04:00
Matthias Clasen
8858f1c9ec Merge branch 'xrgb-formats' into 'main'
Add XRGB memory formats

Closes #6172

See merge request GNOME/gtk!6505
2023-10-20 22:34:19 +00:00
Matthias Clasen
a1c5c20e2c dmabuf: Add xrgb formats 2023-10-20 18:14:45 -04:00
Matthias Clasen
1da674423d vulkan: Add xrgb formats
For now, we just fall back to RGB.
2023-10-20 18:14:45 -04:00
Matthias Clasen
10250a0a6a Add XRGB memory formats
These are not uncommon in dmabufs,
and supporting them is easy.

Fixes: #6172
2023-10-20 17:58:06 -04:00
Matthias Clasen
c0a2f9fbc3 Merge branch 'missing-argb-format' into 'main'
Add GDK_MEMORY_A8B8G8R8_PREMULTIPLIED

See merge request GNOME/gtk!6504
2023-10-20 21:12:43 +00:00
Matthias Clasen
bd974b08b3 Add GDK_MEMORY_A8B8G8R8_PREMULTIPLIED
We did have 4 ordering variations of ARGB straight,
but only 3 premultiplied. Add the missing one.

Update all the places where we switch over memory formats.
2023-10-20 16:42:40 -04:00
Matthias Clasen
d289c0d4f1 Merge branch 'matthiasc/for-main' into 'main'
rendernodeparser: Use private memoryformat api

See merge request GNOME/gtk!6502
2023-10-20 14:00:55 +00:00
Matthias Clasen
f4722289f7 Merge branch 'more-bgra' into 'main'
gsk: Use has_bgra in more places

See merge request GNOME/gtk!6500
2023-10-20 13:43:51 +00:00
Benjamin Otte
389af3591c Merge branch 'wip/otte/for-main' into 'main'
dmabuf refactoring

See merge request GNOME/gtk!6503
2023-10-20 12:48:53 +00:00
Benjamin Otte
008d9e5327 vulkan: Actually check for GDK_DEBUG=vulkan-disable
The dmabuf code would happily init Vulkan even if it was told we don't
want it.
2023-10-20 14:26:59 +02:00
Benjamin Otte
09723d79c6 dmabuf: Support YUYV and friends
Same as the NV12 support, but necessary for the poor people stuck on
Intel laptops.
2023-10-20 14:26:59 +02:00
Benjamin Otte
4586af5876 dmabuf: Add support for NV12 and NV21
This is as-good-as-necessary and doesn't do any fancy colorspace magic
or chroma whatevering.

That's a task for the future.
2023-10-20 14:26:59 +02:00
Benjamin Otte
193d9cd31a dmabuf: Improve download
1. Split out the download function from the mmap'ing of the plane(s)

2. Make the code mmap() all the planes

3. Determine size using lseek() as documented by libdrm, instead of
   trying to guess it from the format.

4. Fix some bugs, like switcheroos of width and height
2023-10-20 14:26:59 +02:00
Benjamin Otte
f29303dea7 dmabuf: Allocate the intermediate buffer properly.
We should use the stride from the buffer's format, not from the dmabuf.
2023-10-20 14:26:59 +02:00
Benjamin Otte
4e47d0d71e dmabuf: Ensure the number of planes is sane
Make it a programming error when setting planes to 0 and throw a GError
if somebody uses more than GDK_DMABUF_MAX_PLANES.
2023-10-20 14:26:59 +02:00
Benjamin Otte
dd8c6e9f51 dmabuf: Add gdk_dmabuf_sanitize()
Tries to sanitize the dmabuf to conform to the values expected
by Vulkan/EGL which should also be the values expected by
Wayland compositors

We put these sanitized values into the GdkDmabufTexture, by
sanitizing the input from GdkDmabufTextureBuilder, which are
controlled by the callers.

Things we do here:

1. Disallow any dmabuf format that we do not know.

1. Treat the INVALID modifier the same as LINEAR.

2. Ignore all other modifiers.

3. Try and fix various inconsistencies between V4L and Mesa,
   like NV12.

*** WARNING ***

This function is not absolutely perfect, you do not have a
perfect dmabuf afterwards.

In particular, it doesn't check sizes.
2023-10-20 13:58:22 +02:00
Matthias Clasen
65676150c4 rendernodeparser: Use private memoryformat api
No need to open-code a list of all formats here,
we can just use the private depth api to do this
much simpler.
2023-10-20 07:41:53 -04:00
Matthias Clasen
b0e26873f6 gsk: Use has_bgra in more places
The glyph and icon libaries were also checking for GLES to
decide if data needs to be transformed from BGRA to RGBA.

Use the new has_bgra getter instead.

This will probably break on bigendian, because the
GL_BGRA + GL_UNSIGNED_BYTE combination is not equivalent
to the cairo format on bigendian, but this was already
broken for the gl format information that we get from
gdk_memory_format_gl_format.
2023-10-20 07:39:08 -04:00
Matthias Clasen
f4a67ebcbb Merge branch 'gles-vao' into 'main'
glcontext: Add api to check for vertex arrays

Closes #6173

See merge request GNOME/gtk!6501
2023-10-20 10:52:53 +00:00
Matthias Clasen
000c876953 gsk: Use vertex arrays when we can
Use the new has_vertex_arrays api to determine
whether we can use vertex arrays in GL.`

Fixes: #6173
2023-10-19 22:43:20 -04:00
Matthias Clasen
b8ffceaebb glcontext: Add api to check for vertex arrays
Vertex arrays are available in GL and in GLES >= 3.

We don't check for the GLES extension that provided
vertex arrays in older GLES, since that requires
using different API.

This api avoids version checks all over the place.
2023-10-19 22:43:13 -04:00
Matthias Clasen
148b8e5cd8 Merge branch 'gles-bgra' into 'main'
memoryformat: Check for BGRA support in GL

Closes #6171

See merge request GNOME/gtk!6498
2023-10-19 21:34:44 +00:00
Matthias Clasen
583ad47b03 memoryformat: Check for BGRA support
Check for whether the GL context we are using
supports uploads with GL_BGRA before returning
that memory format.

Fixes: #6171
2023-10-19 16:44:18 -04:00
Matthias Clasen
b95d8ebdd3 memoryformat: Change some private API
Make gdk_memory_format_gl_format take the GdkGLContext,
instead of just a gles boolean. This will let us
check for extensions that may be needed for certain
formats.

Update all callers.
2023-10-19 16:44:18 -04:00
Benjamin Otte
677a601d11 Merge branch 'wip/otte/for-main' into 'main'
dmabuf: Init the dmabuf subsystem before creating texture

See merge request GNOME/gtk!6499
2023-10-19 19:30:23 +00:00
Benjamin Otte
194db51fba dmabuf: Make Builder::display non-nullable
We always have a display - the default display - so there's no need to
accept NULL.

Plus, we need a display when building the texture, so accepthing NULL
wouldn't even make sense.

Includes update to defaultvalue test.
2023-10-19 20:51:51 +02:00
Matthias Clasen
d55fa0dfef glcontext: Check for GL_EXT_texture_format_BGRA8888
Check for this GLES extension and add a private getter.
2023-10-19 13:55:18 -04:00
Benjamin Otte
612b5416af dmabuf: Init the dmabuf subsystem before creating texture
We did not do that, so when the dmabuf building looked at the list of
downloaders, it was empty and the result was an error. That's not good.
2023-10-19 19:12:46 +02:00
Matthias Clasen
54637ae3b3 Merge branch 'matthiasc/for-main' into 'main'
gdk: Add an annotation

Closes #6167

See merge request GNOME/gtk!6496
2023-10-19 15:35:22 +00:00
Matthias Clasen
014adb841e gdk: Add an annotation
We are returning interned strings here, and
g-i seems to have trouble interpreting the const,
so lets help it out by being more explicit with
our annotations.

Fixes: #6167
2023-10-19 10:06:53 -04:00
Benjamin Otte
a5c6a40b3c Merge branch 'wip/otte/for-main' into 'main'
testsuite: fix "empty" linear-gradient compare test

See merge request GNOME/gtk!6493
2023-10-19 12:30:56 +00:00
Benjamin Otte
402a51b876 testsuite: Use a better opacity in the test
Using the default opacity of 0.5 makes it unclear if 0xFF should be
mapped to 0x7F or 0x80.

0.6 should hopefully map to 0x99 always.
2023-10-19 13:38:47 +02:00
Benjamin Otte
d1e091279c testsuite: fix "empty" linear-gradient compare test
We need to provide color stops to avoid rounding errors with different
shaders.

That makes the empty linear gradient somewhat less empty, but I think
it's the emptiest we can make it.
2023-10-19 13:38:47 +02:00
Matthias Clasen
7325121c63 Merge branch 'matthiasc/for-main' into 'main'
gsk: Cosmetics

See merge request GNOME/gtk!6490
2023-10-17 03:50:40 +00:00
Matthias Clasen
31abe56b7a gsk: Cosmetics 2023-10-16 23:32:37 -04:00
Matthias Clasen
ca3fd16039 Merge branch 'matthiasc/for-main' into 'main'
dmabuf: Add a display getter

See merge request GNOME/gtk!6488
2023-10-17 02:45:33 +00:00
Matthias Clasen
4417509515 dmabuf: Add a display getter
Add private api to get the display of
a dmabuf texture. We will need it in
the following commit.
2023-10-16 22:29:20 -04:00
Matthias Clasen
9dc2e554e5 dmabuf: Tweak error messages 2023-10-16 22:29:10 -04:00
Matthias Clasen
bfb01f5a4b Merge branch 'dmabuf-downloader' into 'main'
dmabuf: Split out GdkDmabuf and GdkDmabufDownloader

See merge request GNOME/gtk!6487
2023-10-16 23:31:21 +00:00
Benjamin Otte
570e80a9ff dmabuf: Split out GdkDmabuf and GdkDmabufDownloader
GdkDmabuf is a struct encapsulating all the values of a dmabuf, so
nothing to see here.

GdkDmabufDownloader is a vtable for a thing that can download dmabufs.
For now only one implementation exists, so this just looks like a ton
of work for no benefit.

The only neat thing is that gdkdmabuftexture.c got a whole lot tidier.
2023-10-16 18:56:52 -04:00
Artur S0
6d90d25a74 Update Russian translation 2023-10-16 11:57:47 +00:00
Matthias Clasen
a7f6e65291 Merge branch 'matthiasc/for-main' into 'main'
Add a dmabuf debug flag

See merge request GNOME/gtk!6486
2023-10-15 16:43:45 +00:00
Matthias Clasen
59641b3c7b docs: Sync the list of debug flags
Make the docs for GDK_DEBUG match current reality.
2023-10-15 12:00:23 -04:00
Matthias Clasen
2f842b087c dmabuf: Cosmetics 2023-10-15 12:00:23 -04:00
Matthias Clasen
699f6a7993 Add a dmabuf debug flag
Add a new debug flag for dmabuf-related information,
and use it in gdkdmabuftexture.c.

This will let us separate out dmabuf debug spew from
opengl debug spew.
2023-10-15 11:05:32 -04:00
Matthias Clasen
f04ba3bc60 Merge branch 'remove_ref_sink_on_gtk_filter' into 'main'
gtkfilechooserwidget: Replace g_object_ref_sink () with g_object_ref () on file filter

See merge request GNOME/gtk!6484
2023-10-15 11:28:29 +00:00
Matthias Clasen
09aac114d4 Merge branch 'fix-title-truncation' into 'main'
Fix window titles unexpectedly getting truncated

See merge request GNOME/gtk!6472
2023-10-15 11:27:40 +00:00
Matthias Clasen
9132600e1f Merge branch 'gbsneto/filechoosernativeportal-reverse' into 'main'
filechooserportal: Reverse file list

See merge request GNOME/gtk!6482
2023-10-15 11:26:25 +00:00
Matthias Clasen
5dcd6c7e12 Merge branch 'matthiasc/for-main' into 'main'
dmabufformatsbuilder: Make it work

See merge request GNOME/gtk!6485
2023-10-15 03:38:25 +00:00
Matthias Clasen
9f8d34ab01 dmabufformatsbuilder: Make it work
The qsort arguments were mixed up, leading to nonsense.
2023-10-14 23:04:00 -04:00
sid
7a4580fa89 gtkfilechooserwidget: Replace g_object_ref_sink () with g_object_ref () on file filter
GtkFileFilter doesn't inherit from GInitiallyUnowned anymore.
2023-10-14 21:54:49 +00:00
Matthias Clasen
45a7617cc8 Merge branch 'wip/otte/dmabuf-cleanups' into 'main'
Various dmabuf reworks

See merge request GNOME/gtk!6483
2023-10-14 20:54:27 +00:00
Benjamin Otte
57d8cc08a3 gdk: Add GDK_DEBUG=dmabuf-disable
I chose the name for consistency with gl-disable and vulkan-disable.
2023-10-14 22:30:17 +02:00
Benjamin Otte
1ca067a478 dmabuf: Add a GError to gdk_dmabuf_texture_builder_build() 2023-10-14 22:30:17 +02:00
Benjamin Otte
7a13e4f9b9 docs: Remove docs for private GdkDmabufFormat struct
This is a leftover from the design of the GdkDmabufFormats struct.
2023-10-14 22:30:17 +02:00
Benjamin Otte
d101e17608 dmabuf: Use the new FormatsBuilder to initialize formats 2023-10-14 22:30:17 +02:00
Benjamin Otte
203a4fc45e dmabufformats: Add GdkDmabufFormatsBuilder
This is a utility object that helps in constructing GdkDmabufFormats.
2023-10-14 22:29:10 +02:00
Benjamin Otte
a9823e05bb array: constify the additions array
We can only do that for by-value arrays, because compilers get confused
with const when there's too many dereferences going on.
2023-10-14 22:11:44 +02:00
Benjamin Otte
6f5833df28 dmabufformats: Mark a bunch of functions as pure 2023-10-14 22:11:44 +02:00
Sabri Ünal
5631ab6711 Update Turkish translation 2023-10-14 07:08:23 +00:00
Georges Basile Stavracas Neto
62fedf4eed filechooserportal: Reverse file list
To avoid O(n²) behaviour, GtkFileChooserNativePortal uses the
classic prepend tatict. However, it does not reverse the file
list after building it.

It's not a big deal since the portal does not specify the order
in which the files are sent. But it's nice nonetheless to send
the file list in the order in which files were passed originally.

Reversing the list has no meaningful performance impact.

Patch originally made by Bastien Nocera.

See https://github.com/flatpak/xdg-desktop-portal/issues/548
2023-10-13 16:12:12 -03:00
Emmanuele Bassi
c274d073e0 Merge branch 'mzur-main-patch-48638' into 'main'
Fix docs for gtk_color_dialog_button_get_rgba

Closes #6155

See merge request GNOME/gtk!6479
2023-10-13 09:54:56 +00:00
Martin Zurowietz
8dda753505 Fix docs for gtk_color_dialog_button_get_rgba
The signal was incorrectly called "notify::color" but
it is "notify::rgba".

Resolves https://gitlab.gnome.org/GNOME/gtk/-/issues/6155
2023-10-13 06:57:05 +00:00
Matthias Clasen
4e66df79c4 Merge branch 'michaelweghorn/a11y_send_dbus_reply_on_set_current_value' into 'main'
a11y atspi: Send proper dbus reply when (not) changing value

Closes #6150

See merge request GNOME/gtk!6476
2023-10-12 14:05:49 +00:00
Emmanuele Bassi
71c7e61162 Merge branch 'michaelweghorn/a11y_dont_confuse_char_and_byte_count' into 'main'
a11y atspi: Don't use char count as byte count

Closes #6151

See merge request GNOME/gtk!6477
2023-10-12 13:40:40 +00:00
Michael Weghorn
e39ecbf16d a11y atspi: Don't use char count as byte count
As mentioned in

    commit 368f2af634
    Author: Matthias Clasen <mclasen@redhat.com>
    Date:   Mon Oct 2 08:47:53 2023 -0400

        a11y: Be safe against non-UTF8 text

, the string insertion APIs take string + length
and only insert up to `length` bytes of the
given string.

The AT-SPI "TextChanged" event however
is using a character count, and `emit_text_changed`
also gets called with the character count
along with the string.

However, `g_strndup` used in `emit_text_changed`
so far takes a byte count, not a character count.

Adapt `emit_text_changed` to just use the
passed text as is and make it the responsibility
of the callers to pass only the actually
inserted/removed string.

Most of the callers in `gtk/a11y/gtkatspitext.c`
already did that. Adapt two missing ones to do
likewise.

Fixes: #6151
2023-10-12 11:58:32 +02:00
Michael Weghorn
0dbd2bd09e a11y atspi: Send proper dbus reply when (not) changing value
`gtk_accessible_range_default_set_current_value` needs
to return TRUE independent of whether the value was
actually changed, since that return value is required
for the proper dbus reply to be sent to AT-SPI.

Fixes a crash/assertion seen e.g. with the "Hypertext" gtk4-demo
example when trying to change "CurrentValue" for the
level bar via the AT-SPI Value interface:

    GLib-GIO:ERROR:../../../gio/gdbusconnection.c:4354:invoke_set_property_in_idle_cb: assertion failed: (error != NULL)
    Bail out! GLib-GIO:ERROR:../../../gio/gdbusconnection.c:4354:invoke_set_property_in_idle_cb: assertion failed: (error != NULL)
    Aborted

Fixes: #6150
2023-10-12 09:09:53 +02:00
Matthias Clasen
1297cc188d Merge branch 'add-six-lang' into 'main'
add hi-ja-et-fi-nb-th for gtkemojichooser

See merge request GNOME/gtk!6475
2023-10-11 22:13:54 +00:00
Benjamin Otte
e584d17aad Merge branch 'dmabuf-texture-api' into 'main'
Add API for dmabuf textures

See merge request GNOME/gtk!6463
2023-10-11 20:25:50 +00:00
Matthias Clasen
4936965fb6 display: Get supported dmabuf formats
These are the dmabuf formats that we can import
into a GL context as an EGLImage, and successfully
download.

We skip the GdkDisplay:dmabuf-formats property
in the default value tests, since the nominal
default value is NULL, but the actual value is
constructed on demand.
2023-10-11 15:43:01 -04:00
Matthias Clasen
e9cc53796e build: Error out if linux/dma-buf.h isn't found
This should always be present on Linux.
2023-10-11 15:43:01 -04:00
Matthias Clasen
c93efe85dd Add GdkDmabufTexture
Add an implementation of GdkDmabufTexture.

For now, this implementation is rather minimal,
since we need a roundtrip through GL to convert
most nottrivial formats.
2023-10-11 15:43:01 -04:00
Matthias Clasen
44daa847ff Merge branch 'michaelweghorn/a11y_convert_negative_index_on_text_deletion' into 'main'
a11y: Convert negative text deletion index to actual offset

Closes #6149

See merge request GNOME/gtk!6473
2023-10-11 19:32:11 +00:00
Matthias Clasen
d23e13aced Add GdkDmabufTextureBuilder
Add a builder for a new GdkTexture subclass that
wraps dmabuf buffers on Linux. For now, this is
just an API. The implementation will follow in
subsequent commits.
2023-10-11 14:54:21 -04:00
Matthias Clasen
40102a2b61 Add GdkDmabufFormats
This is an immutable struct containing information
about supported dma-buf formats and their properties.
2023-10-11 14:53:06 -04:00
sudip
49fbbfb6cc add hi-ja-et-fi-nb-th for gtkemojichooser 2023-10-12 00:07:59 +05:30
Michael Weghorn
fefd856d67 a11y: Convert negative text deletion index to actual offset
`gtk_editable_delete_text` can be called with a
negative `end_pos`, in which case the characters
from the start pos to the end of the text are
removed. [1]

It e.g. gets called this way from
`gtk_editable_set_text`.

So far, that negative index was not converted,
but passed as is in the AT-SPI callback
`delete_text_cb` when calling the `text_changed`
handler (`emit_text_changed` in
`gtk/a11y/gtkatspicontext.c`) which just uses the
index as is, also in it's call to `g_strndup`,
resulting in a crash when negative indices are
used.

Fix this by converting negative values to the
actual end index in `delete_text_cb` before
calling the handler.

[1] https://docs.gtk.org/gtk3/method.Editable.delete_text.html

Fixes: #6149
2023-10-11 15:51:17 +02:00
Sergey Bugaev
39dab6d7bd widget: Queue a resize on Pango context changes
Updating a Pango context can influence the layout of widget, in
particular that of a GtkLabel, not only its rendering. Make sure to
queue a resize when updating the context.

In particular, this fixes window titles getting suddenly truncated when
moving a window from a HiDPI display to a low DPI one, after
https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/6190 has made font
hinting depend on the widget scale. With hinting enabled on low DPI,
the Pango layout needs ever so slightly more width to not get truncated.
There is plenty of space in the header bar that could be allocated to
the label, but for that to happen, it needs to know to queue a resize.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-10-11 15:39:37 +03:00
Matthias Clasen
7b5b78b065 Merge branch 'fix-a11y-text-signals-again' into 'main'
a11y: Avoid a crash

Closes #6146

See merge request GNOME/gtk!6470
2023-10-11 01:06:55 +00:00
Matthias Clasen
005b5042f6 Merge branch 'demo-frame-time' into 'main'
demo: Use the frame time for animation

See merge request GNOME/gtk!6468
2023-10-11 00:39:38 +00:00
Matthias Clasen
b5149a483f Merge branch 'wip/chergert/update-stb' into 'main'
gsk/gl: update stb_rect_pack()

See merge request GNOME/gtk!6466
2023-10-11 00:38:36 +00:00
Matthias Clasen
15c43e5284 a11y: Avoid a crash
It is not safe to access text[end],
if text may not be NUL-terminated.

Fixes: #6146
2023-10-10 18:54:27 -04:00
Matthias Clasen
fc4c0f769c Merge branch 'no-enums-in-bitfields' into 'main'
Stop using enums in bitfields

See merge request GNOME/gtk!6467
2023-10-10 22:48:11 +00:00
Sergey Bugaev
e8ecbb2009 demo: Use the frame time for animation
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-10-10 11:38:13 +03:00
Sergey Bugaev
964affb1cc Stop using enums in bitfields
The C standard does not specify whether the underlying type of an enum
is signed or unsigned, and until C23 there was no way to control this
explicitly. GCC appears to make enums unsigned unless there is a
negative value among cases of the enum, in which case it becomes signed.
MSCV appears to make enums signed by default.

A bitfield of an enum type (which is not specificied in the C standard
either) behaves as if it was an instance of a numeric type with a
reduced value range. Specifically, a 'signed int val : 2;' bitfield will
have the possible values of -2, -1, 0, and 1, with the usual wraparound
behavior for the values that don't fit (although this too is
implementation-defined).

This causes the following issue, if we have:

typedef enum
{
  GTK_ZERO,
  GTK_ONE,
  GTK_TWO
} GtkFoo;

struct _GtkBar
{
  GtkFoo foo : 2;
};

and then assign bar.foo = GTK_TWO and read it back, it will have the
expected value of 2 (aka GTK_TWO) on GCC, but a value of -2 (not
matching any of the enum variants) on MSVC.

There does not seem to be any way to influence signedness of an enum
prior to C23, nor is there a 'unsigned GtkFoo foo : 2;' syntax. The only
remaining options seems to be never using enums in bitfields, which is
what this change implements.

In practice, this fixes GdkPipeIOStream crashing with an assertion when
trying to copy-paste in-app in MSVC builds on GTK.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-10-10 11:23:08 +03:00
Christian Hergert
05b51af2d5 gsk/gl: update stb_rect_pack() 2023-10-09 22:42:57 -07:00
Emmanuele Bassi
28e51c763b Merge branch 'disable_ccache_macos' into 'main'
Disable ccache in macOS job

See merge request GNOME/gtk!6458
2023-10-09 12:23:31 +00:00
Matthias Clasen
ebf8e18319 Merge branch 'add-bn' into 'main'
add bengali language bn.data for gtkemojichooser

See merge request GNOME/gtk!6459
2023-10-09 03:03:10 +00:00
Christian Hergert
d8bbe1c296 testsuite/gsk: add render test for mask(texture|color) 2023-10-06 10:52:53 -07:00
Christian Hergert
c1417d3d4a gsk/gl: add fast path for texture masking color
This is useful for colorizing in the same fashion we do for the glyph
texture atlas. In fact, for small GdkTexture, you will end up in something
like the icon texture atlas.

The primary motivator for this optimization is to draw various glyph-like
features from VTE such as many forms of boxes, lines, arrows, etc.
2023-10-05 20:30:00 -07:00
René de Hesselle
3b4359d76d ci: Disable ccache in macOS job
As it turns out, ccache accelerates the build so much that it can
trigger a race condition in the gobject-introspection subproject. This
only surfaced recently as the introspection feature was previously
disabled due to missing build time dependencies.

The race condition surfaces as follows: the build breaks because
gobject-introspection starts to build Gdk-4.0.gir before
GdkPixbuf-2.0.gir, despite Gdk-4.0.gir depending on GdkPixbuf-2.0.gir.
2023-10-04 20:07:47 +02:00
sudip
16806294e3 add bengali language bn.data for gtkemojichooser 2023-10-04 18:52:10 +05:30
Luca Bacci
822425072b Merge branch '5724_gdk_win32_ignore_invalid_client_rect' into 'main'
Gdk4 Win32: ignore invalid client rects

Closes #5724

See merge request GNOME/gtk!6414
2023-10-04 07:58:55 +00:00
Emmanuele Bassi
7cc1283a26 Merge branch 'macos_introspec' into 'main'
Enable introspection in macOS CI

Closes Infrastructure/Infrastructure#935

See merge request GNOME/gtk!6453
2023-10-03 22:46:23 +00:00
René de Hesselle
f4198706d1 Enable introspection in macOS CI
This requires providing pkg-config and bison as well as pre-built
wheels for Pycairo and PyGObject to make it work.
2023-10-03 21:00:14 +02:00
Jordi Mas i Hernandez
8478ba66fe Update Catalan translation
(cherry picked from commit d6fecef605)
2023-10-03 06:56:01 +00:00
Matthias Clasen
1d58de6ffb Merge branch 'a11y-textview-crash' into 'main'
a11y: Be safe against non-UTF8

Closes #6131

See merge request GNOME/gtk!6448
2023-10-02 17:34:21 +00:00
Emmanuele Bassi
f5cec5c0f2 Apply 1 suggestion(s) to 1 file(s) 2023-10-02 13:16:17 +00:00
Matthias Clasen
368f2af634 a11y: Be safe against non-UTF8 text
The string we're passed here may not be zero-terminated
since our text insertion APIs take string + length. So
So be safe and copy the text we are interested in if
necessary.

Fixes: #6131
2023-10-02 08:49:41 -04:00
Matthias Clasen
66a9fee071 a11y: Emit text-changed after the insertion
This is necessary, since it is the default handler
that positions the iter at the inserted text, which
is what we assume here.
2023-10-02 08:49:31 -04:00
Matthias Clasen
6e0ac83d99 Merge branch 'print-dialog-revision' into 'main'
print dialog: Some API revisions

See merge request GNOME/gtk!6443
2023-10-01 14:01:33 +00:00
Matthias Clasen
12ad6b3157 gtk-demo: Add a demo for printing a stream
Add a Print button to the path fill demo,
and implement it using gtk_print_dialog_print.
2023-10-01 09:30:38 -04:00
Matthias Clasen
fda9fd5ced print dialog: Some API revisions
Make gtk_print_dialog_setup_finish return a GtkPrintSetup
object, which encapsulates all the data that needs to be
transferred between the setup and print calls, and make
the print_file and print methods take an extra GtkPrintSetup
argument.

Change the print call to return an output stream, rather
than take an input stream. The results are now returned
when the output stream is closed.

With some further cleanup, this makes the GtkPrintDialog
object a proper builder object - you can create multiple
print dialogs from the same GtkPrintDialog object, in
parallel, and they won't interfere with each other.
2023-10-01 09:30:38 -04:00
Matthias Clasen
029ce83a69 print dialog: Cosmetics
Some minor cleanups.
2023-09-30 21:30:22 -04:00
Matthias Clasen
5ced6be416 printjob: Work with non-seekable fds
We want to pass a pipe fd in the future,
and those aren't seekable.
2023-09-30 21:30:22 -04:00
Matthias Clasen
bbda833b01 demos: Cosmetics 2023-09-30 21:30:15 -04:00
Jonas Ådahl
c86bc00330 Merge branch 'master' into 'main'
GdkSurface: prevent popups from appearing offscreen in edge cases

See merge request GNOME/gtk!5320
2023-09-30 15:03:33 +00:00
Mazhar Hussain
8367411785 GtkProgressBar: Fix: progress can overflow trough
For visual explanation, visit https://gitlab.gnome.org/GNOME/gtk/-/issues/5751
The linked issue tracker is for GtkScale but GtkProgressBar has the exact same problem as well
2023-09-30 14:11:47 +05:00
Mazhar Hussain
17e37dc42a GtkScale: Fix: highlight can overflow trough
For visual explanation, visit https://gitlab.gnome.org/GNOME/gtk/-/issues/5751
2023-09-30 13:39:00 +05:00
Matthias Clasen
68755c0fd2 Post-release version bump 2023-09-28 10:49:46 -04:00
Matthias Clasen
9090c28125 4.13.1 2023-09-28 09:50:16 -04:00
Matthias Clasen
3a3244891e Merge branch 'wip-print-dialog' into 'main'
wip: print dialog api

See merge request GNOME/gtk!5484
2023-09-28 01:18:26 +00:00
Matthias Clasen
b55117334c gtk-demo: Add a print dialog 2023-09-27 20:50:52 -04:00
Matthias Clasen
02e5c7b9ad Add a print dialog
Add a simplified print api that only supports
printing preexisting pdf content. For now, it
only has a portal implementation.
2023-09-27 20:50:52 -04:00
Matthias Clasen
7268167f4c Merge branch 'matthiasc/for-main' into 'main'
print portal: Report errors properly

See merge request GNOME/gtk!6441
2023-09-27 21:52:13 +00:00
Matthias Clasen
93c7502cf7 printer: Add private search api 2023-09-27 17:37:11 -04:00
Matthias Clasen
789705cfe4 print portal: Report errors properly
The portal printoperation inmplementation
relies on the file printbackend to be available.
If it isn't, we should report a proper error
status insetad of running into assertions deep
inside the printoperation code.
2023-09-27 17:33:34 -04:00
Emmanuele Bassi
741471a1f8 Merge branch 'michaelweghorn/a11y_add_paragraph_role' into 'main'
a11y: Add paragraph role

See merge request GNOME/gtk!6432
2023-09-27 12:20:19 +00:00
Matthias Clasen
f8da751cc2 Merge branch 'wip/chergert/rendernode-type-checks-for-refcount' into 'main'
gsk: remove excessive type checking within GSK

See merge request GNOME/gtk!6439
2023-09-27 12:12:18 +00:00
Matthias Clasen
8174842d9f Merge branch 'wip/chergert/rendernode-type-check' into 'main'
gsk/gl: remove TypeNode conformity checking for renderjob

See merge request GNOME/gtk!6438
2023-09-27 12:10:52 +00:00
Matthias Clasen
e872952f36 Merge branch 'mcatanzaro/#6122' into 'main'
printoperation: fix case where operation may complete multiple twice

Closes #6122

See merge request GNOME/gtk!6437
2023-09-27 10:37:23 +00:00
Christian Hergert
b010e46d13 gsk/gl: remove TypeNode conformity checking for renderjob
We don't need to be calling type node conformity checking from the tight
loop of the renderjob. Hoist that into the private header and use that
intead through via the Class pointer.
2023-09-26 18:36:56 -07:00
Christian Hergert
eb646a8e8b gsk: remove excessive type checking within GSK
Anything that includes gskrendernodeprivate.h will get an alternate form
of ref/unref for render nodes which does not need to do type checking on
the parameter. We can expect that things are correct within GTK itself and
this saves excessive amounts of TypeNode conformities checking.
2023-09-26 18:28:34 -07:00
Michael Catanzaro
1e2975147d printoperation: fix some strange line spacing 2023-09-26 19:28:12 -05:00
Michael Catanzaro
653c10e8b6 printoperation: add some assertions
Let's assert that we schedule the idle callback exactly once.

These assertions are not perfect because if the callback executes before
we schedule it, then the assertion itself would be a use-after-free,
since I'm using the PrinterFinder to track whether the callback that
frees it has been scheduled. But in practice when using loupe's print
dialog, I was noticing the callback scheduled twice before it was
executed. The assertion would have caught this problem.
2023-09-26 19:25:41 -05:00
Michael Catanzaro
dfbafdf047 printoperation: fix another case where operation may complete twice
This is a little tricky. At first, I thought we had a codepath where we
fail to schedule the idle that completes the print operation: if we take
the gtk_print_backend_printer_list_is_done path for each printer
backend, then printer_list_done_cb() is never executed and we never
schedule the idle. But in fact, in this case, then backends == NULL at
the bottom of find_printer(), and we'll schedule the idle there, so it's
OK. Except it's not really OK, because we'll schedule it even if a
printer was already found, resulting in the callback completing twice
and a double free.

Simplify this. Schedule the idle in find_printer() only if there are
*initially* no backends, not also if all backends are immediately ready
and already removed from consideration. Instead, always call
printer_list_done_cb() for every backend in find_printer_init(). After
the previous commit, printer_list_done_cb() will schedule the idle when
appropriate.

printer_list_done_cb() additionally disconnects signals that we did not
connect in this codepath, but it does so using
g_signal_handlers_disconnect_by_func, which is harmless. Otherwise, the
only extra work it's doing is scheduling the idle, and that's exactly
what find_printer_init() is missing.
2023-09-26 19:08:46 -05:00
Michael Catanzaro
d8c821a851 printoperation: fix case where operation may complete multiple twice
If we are the final backend, then after removing ourselves there is no
backend remaining. We will schedule the idle even if it has already been
scheduled. This idle is required to run exactly once and executing it
twices results in a double free that crashes loupe when printing. It
also causes the user callback to execute twice, which could cause
similar problems.

Fixes #6122
2023-09-26 18:47:01 -05:00
Matthias Clasen
83376648d7 Merge branch 'wip/chergert/fix-clips-uaf' into 'main'
Fix potential UAF in renderjob clipping

See merge request GNOME/gtk!6436
2023-09-26 21:59:56 +00:00
Christian Hergert
089c34fa03 gsk/gl: use GdkArrayImpl for tracking modelview
Like the previous change, this uses GdkArrayImpl instead of GArray for
tracking modelview changes. This is less important than clip tracking
simple due to being used less, but it keeps the implementation synchronous
with the Clip tracking code.
2023-09-26 13:58:38 -07:00
Christian Hergert
c846f8d745 gsk/gl: use GdkArrayImpl for Clip tracking
We can end up spending a lot of time in g_array_maybe_expand() through the
use of g_array_set_size() for clip tracking. That is somewhat due to the
simple nature of GArray being size-dynamic. Instead, we can use
GdkArrayImpl and let the compiler do what it does best to elide some
work and hoist other work into the calling function.

This also fixes a potential UAF in gsk_gl_render_job_push_contained_clip().
2023-09-26 13:58:35 -07:00
Emmanuele Bassi
79ebd76ac8 Merge branch 'wip/chergert/fix-gdkarrayimpl-from-c++' into 'main'
gdk: add missing G_END_DECLS to gdkarrayimpl.c

See merge request GNOME/gtk!6435
2023-09-26 18:48:02 +00:00
Christian Hergert
6eb9836eb0 gdk: add missing G_END_DECLS to gdkarrayimpl.c 2023-09-26 10:46:21 -07:00
Matthias Clasen
4a8f8a6eea Merge branch 'broadway-renderer-leak' into 'main'
broadway: Plug a leak in the GSK renderer

Closes #6120

See merge request GNOME/gtk!6434
2023-09-26 15:13:38 +00:00
Emmanuele Bassi
3ea723730b broadway: Do not add an extra reference when caching textures
We just created a GdkTexture, so we don't need to acquire a reference if
we're transferring the ownership to the node cache.
2023-09-26 14:44:05 +01:00
Emmanuele Bassi
90be2baf8b broadway: Plug another leak
When getting a colorized texture we're downloading the texture as a
Cairo surface, and then feeding it to another texture, but we never drop
the reference of the new surface.
2023-09-26 14:40:37 +01:00
Emmanuele Bassi
0b64fa88a1 docs: Clarify the behaviour of gdk_texture_new_for_surface()
Cairo surfaces are not GObject instances, so we should be more explicit
in the behaviour of the memory management, to avoid leaks.
2023-09-26 12:57:52 +01:00
Emmanuele Bassi
c6cc446e63 broadway: Plug a leak in the GSK renderer
We are leaking the Cairo image surface when creating a new node.

Fixes: #6120
2023-09-26 12:49:32 +01:00
Benjamin Otte
0cad37760e Merge branch 'wip/otte/for-main' into 'main'
treeview: Fix crash in assertion

Closes #6114

See merge request GNOME/gtk!6433
2023-09-26 09:29:08 +00:00
Benjamin Otte
e720008dca glcontext: Add gdk_gl_context_get_glsl_version_string()
This is in preparation for the new renderer.
2023-09-26 11:08:59 +02:00
Benjamin Otte
9c636a6136 array: Compute new size properly
Using "1 << x" means that we are shifting a signed 32bit integer, but we
want a gsize, which is an unsigned 64bit integer.

So now we don't overflow anymore if the array reaches a size of 2GB.
2023-09-26 11:08:59 +02:00
Benjamin Otte
1e24aa425e gdk: Fix compiler warning
gcc's -Wlto-type-mismatch found the hack, where we copied the wrong
prototype.
2023-09-26 11:08:59 +02:00
Benjamin Otte
a8c597005a treeview: Fix crash in assertion
The fix in commit a267dfac5d is wrong.
The function can return FALSE in normal operation.

Instead do a check for node == NULL that gracefully returns FALSE instead.

Fixes: #6114
2023-09-26 11:08:32 +02:00
Aurimas Černius
97a781b380 Update Lithuanian translation
(cherry picked from commit 61276e9a76)
2023-09-25 19:58:12 +00:00
Rafael Fontenelle
313cadefe6 Update Brazilian Portuguese translation
(cherry picked from commit 90b8dcdf33)
2023-09-25 12:58:47 +00:00
Michael Weghorn
9f078bd5c9 a11y: Add paragraph role
Add new GTK_ACCESSIBLE_ROLE_PARAGRAPH role
for paragraphs.

ARIA has a paragraph role as well.

The paragraph role is used e.g. in document editors
like LibreOffice or web browsers like Firefox.

According to the ARIA spec [1], naming paragraphs
is forbidden (§ 5.2.8.6), and the superclass role
is section.

This role will be more useful once a way to expose
the textual data via the AT-SPI Text interface is
also available (s. issue #5912 [2]).

[1] https://www.w3.org/TR/wai-aria-1.2/
[2] https://gitlab.gnome.org/GNOME/gtk/-/issues/5912
2023-09-25 11:30:14 +02:00
Matthias Clasen
8ff4e27103 Merge branch 'wip/alice/dialog-crash' into 'main'
dialog: Check header bar type before calling track_default_decoration()

Closes #6116

See merge request GNOME/gtk!6430
2023-09-24 13:24:49 +00:00
Matthias Clasen
8389ca633d Merge branch 'matthiasc/for-main' into 'main'
tests: Split off some path utilities

See merge request GNOME/gtk!6431
2023-09-24 13:07:45 +00:00
Matthias Clasen
18fbec0fe1 Improve FOO_DEBUG=help output
Explain the all value a bit better.
2023-09-24 08:33:22 -04:00
Alice Mikhaylenko
eb0a00067d dialog: Check header bar type before calling track_default_decoration()
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/6116
2023-09-24 15:38:19 +04:00
Alice Mikhaylenko
91216408e5 header-bar: Add a precondition to track_default_decoration() 2023-09-24 15:21:55 +04:00
Matthias Clasen
6da5b8cb25 tests: Split off some path utilities
Thes can be reused in different test sources.
2023-09-23 15:28:35 -04:00
Kristjan SCHMIDT
7bee7bf5fc Update Esperanto translation
(cherry picked from commit ecc42c506b)
2023-09-23 16:41:38 +00:00
Danial Behzadi
fac66ade01 Update Persian translation 2023-09-23 15:29:04 +00:00
Matthias Clasen
96eae5f62e Merge branch 'matthiasc/for-main' into 'main'
gtk-demo: Fix a refcounting mishap

Closes #6113

See merge request GNOME/gtk!6427
2023-09-23 13:20:04 +00:00
Matthias Clasen
1cc99847f4 Deprecate gtk_window_present_with_time
It is often difficult or impossible to get a suitable
timestamp. Instead, we should do the right thing in
the simpler API.

See #6095
2023-09-23 08:06:47 -04:00
Matthias Clasen
d8b14cd3e3 gtk-demo: Fix a refcounting mishap
gtk_font_dialog_button_new's argument is
transfer full.

Fixes: #6113
2023-09-23 07:47:09 -04:00
Matthias Clasen
0c80eb5afb Merge branch 'matthiasc/for-main' into 'main'
Remove sysprof leftovers

See merge request GNOME/gtk!6425
2023-09-22 22:01:31 +00:00
Matthias Clasen
fdcb1d92c5 Remove sysprof leftovers
This is a followup to 5dd0d39a6b.
2023-09-22 17:33:09 -04:00
Matthias Clasen
d65dc6c730 Merge branch 'matthiasc/for-main' into 'main'
path-tool: Fix the restrict command

See merge request GNOME/gtk!6424
2023-09-22 00:21:22 +00:00
Matthias Clasen
c721c4d6ef path-tool: Fix the restrict command 2023-09-21 15:36:25 -04:00
Matthias Clasen
1a7ba3c512 Merge branch 'update-cursor-images' into 'main'
docs: Update cursor images

See merge request GNOME/gtk!6422
2023-09-21 18:54:04 +00:00
Matthias Clasen
25ee1a7784 Merge branch 'drop-performance-tests' into 'main'
Drop performance tests

Closes #6112

See merge request GNOME/gtk!6421
2023-09-21 17:59:08 +00:00
kramo
0b2cebe3d8 docs: Update cursor images 2023-09-21 19:51:11 +02:00
Matthias Clasen
5dd0d39a6b Drop performance tests
These were an experient, and not actively used,
and libsysprof has been changing api so they broke.

Fixes: #6112
2023-09-21 13:14:48 -04:00
Matthias Clasen
9f3ff427c1 Merge branch 'matthiasc/for-main' into 'main'
contour: Simplify add_segment for circles

See merge request GNOME/gtk!6420
2023-09-21 16:51:37 +00:00
Matthias Clasen
14e60d21ac ci: Skip the headless tests
Despite waiting for a long time, these still
regularly time out on slow runners.
2023-09-21 12:17:47 -04:00
Matthias Clasen
65c3796135 Merge branch 'ebassi/doc-fixes' into 'main'
docs: Add a link to the DropDown:selected property

See merge request GNOME/gtk!6419
2023-09-21 15:50:50 +00:00
Matthias Clasen
25acc26531 contour: Simplify add_segment for circles
We no longer need to translate path points.
2023-09-21 11:40:25 -04:00
Emmanuele Bassi
859bf8b15d docs: Mention for what GtkStringObject:string is useful 2023-09-21 15:28:37 +01:00
Emmanuele Bassi
e0bf96f329 docs: Link GtkStringObject from GtkStringList
A frequently asked question is: "what is the object type inside a
GtkStringList", so let's make the answer more obvious.
2023-09-21 15:27:35 +01:00
Emmanuele Bassi
11c5ea1fec docs: Add a link to the DropDown:selected property
The main description is a bit too coy, and some newcomers don't
understand the concept of properties and notification.
2023-09-21 15:20:46 +01:00
Daniel Rusek
bc063350ef Update Czech translation 2023-09-21 12:42:28 +00:00
Luca Bacci
347b0317e5 Merge branch 'fix-issue-6080' into 'main'
GdkWin32: Unref GdkMonitor after calling gdk_monitor_invalidate ()

Closes #6080

See merge request GNOME/gtk!6411
2023-09-21 12:41:55 +00:00
Matthias Clasen
72d832a4f3 Merge branch 'matthiasc/for-main' into 'main'
gtk-demo: Update some ifdefed code

See merge request GNOME/gtk!6416
2023-09-21 02:53:33 +00:00
Matthias Clasen
76df3ade18 gtk-demo: Update some ifdefed code
This was from a time when we had arcs.
2023-09-20 22:12:09 -04:00
Matthias Clasen
d849a53b98 contour: Fix get_closest_point for circles 2023-09-20 22:11:47 -04:00
Matthias Clasen
ef6d3af6b9 Merge branch 'revert-sassc-wrapdb' into 'main'
Revert "build-aux/flatpak: use sassc from wrapdb"

See merge request GNOME/gtk!6415
2023-09-20 22:46:33 +00:00
Christoph Reiter
f513914306 Revert "meson: Move libsass/sassc subprojects to use wrapdb"
This reverts commit 7eb999720a.
2023-09-19 21:28:28 +02:00
Christoph Reiter
7135f80094 Revert "build-aux/flatpak: use sassc from wrapdb"
This reverts commit cac0cb7f02.

This doesn't work since CI currently mixes flatpak-builder and the host git repo
and doesn't download the gtk sources, so all subprojects are missing.
2023-09-19 21:27:46 +02:00
Matthias Clasen
ef82e0ce4e Merge branch 'matthiasc/for-main' into 'main'
gtk4-demo: Fix a crash

Closes #6107

See merge request GNOME/gtk!6413
2023-09-19 19:12:58 +00:00
Matthias Clasen
1910834f8f Merge branch 'sassc-wrapdb' into 'main'
meson: Move libsass/sassc subprojects to use wrapdb

See merge request GNOME/gtk!6410
2023-09-19 18:49:50 +00:00
Matthias Clasen
f94a0624fa gtk4-demo: Fix a crash
This conversion of GtkStatusbar was a bit too
quick.

Fixes: #6107
2023-09-19 14:47:59 -04:00
G.Willems
4c46f5a8f7 GdkWin32: ignore invalid client rects
Gdk-Win32 uses GetClientRect() internally to query the surfaces coordinates,
but this API may fail in some transient contexts (observed when iconifying
a maximized window).
Check if the rect area is null, and don't update the surface position in
that case. This will keep the current surface size, until Win32 notifies
the new valid window state later.
This prevents using a nulled next_layout for toplevel size computation,
which would break widgets allocation once notified on gtk side.

Fixes #5724
Closes #5724
2023-09-19 20:29:04 +02:00
Luca Bacci
17c59d6da6 GdkWin32: Unref GdkMonitor after calling gdk_monitor_invalidate ()
Ensure that we have a reference when calling gdk_monitor_invalidate ()

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/6080
2023-09-19 18:46:41 +02:00
Andre Klapper
56c0aa596e DOAP: Replace non-existing mailing lists with GNOME Discourse URL 2023-09-19 18:21:17 +02:00
Sabri Ünal
a1c73a9b2e Update Turkish translation 2023-09-19 15:36:36 +00:00
Christoph Reiter
cac0cb7f02 build-aux/flatpak: use sassc from wrapdb
Instead of building the projects from my forks, build them as gtk
subprojects.

To avoid meson hitting the network for those wraps, add the required
files as extra sources and put them into subprojects/packagecache,
so meson can find them at build time.
2023-09-19 17:25:28 +02:00
Christoph Reiter
7eb999720a meson: Move libsass/sassc subprojects to use wrapdb
They were pointing to my personal fork, but I've now added
them to wrapdb:

* https://github.com/mesonbuild/wrapdb/pull/1153
* https://github.com/mesonbuild/wrapdb/pull/1185
2023-09-19 16:51:53 +02:00
Nathan Follens
05e15241b4 Update Dutch translation
(cherry picked from commit d66f590a86)
2023-09-19 12:31:41 +00:00
Boyuan Yang
a730867778 Update Chinese (China) translation 2023-09-19 01:47:20 +00:00
Matthias Clasen
8513621709 Merge branch 'wip/carlosg/for-main' into 'main'
Some fixes

Closes #5820, #6098, and #5529

See merge request GNOME/gtk!6407
2023-09-18 22:28:10 +00:00
Carlos Garnacho
14d99bacbc gdk/wayland: Use toplevel surface for activation
At the moment of launching/activating an application, the
keyboard focus may be on a transient surface that quickly
disappears after activation. If this happens, and the
compositor handles surface destruction before the activated
application gets to reply, the activation request may be
deemed outdated, and the "demands attention" paths be taken.

Peek the toplevel from the focus surface, as that has larger
guarantees to remain valid for the whole duration of the
operation.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5820
2023-09-18 22:04:32 +02:00
Carlos Garnacho
cbbd3e8fc3 demos: Add step/page-increment to path_walk demo spinbutton
It had 0 defaults, so it didn't get to spin when interacted.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/6098
2023-09-18 20:09:42 +02:00
Carlos Garnacho
8fa45d5fef gtkwindow: Pick a suitable widget to continue the implicit grab
When a widget in the GtkPointerFocus stack becomes insensitive, we've
so far broken the implicit grab entirely. This has the side effect of
breaking accounting of the active state on the widgets that are
ancestors of the widget that became insensitive.

The easiest, and most consistent thing to do (i.e. giving widgets
in the GtkPointerFocus stack certain level of isolation wrt state
changes in other widgets) is to transfer the implicit grab to the
topmost actor of the GtkPointerFocus stack that can keep handling
events.

This fixes the unbalanced accounting of active state on ancestors
of widgets becoming insensitive, and avoids thorny questions about
how to handle implicit active state with broken implicit grabs.
2023-09-18 19:53:33 +02:00
Carlos Garnacho
3e1706679c gtkwindow: Clear active state on sensitiveness changes
When altering the broken implicit grab due to sensitiveness changes,
also ensure to clear the active state from the affected actors. This
fixes unbalanced implicit active state accounting on the widgets going
insensitive.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5529
2023-09-18 19:50:53 +02:00
Carlos Garnacho
7f359e31c6 gtkmain: Drop redundant code
The common ancestor is already figured out at the beginning of the
function, no need to find it again.
2023-09-18 16:56:29 +02:00
Rūdolfs Mazurs
e4af2c4d80 Update Latvian translation
(cherry picked from commit 7b6b31f0d8)
2023-09-18 13:29:58 +00:00
Matthias Clasen
2d121c07c9 Merge branch 'default_theme_relative_font_sizes' into 'main'
theme: use relative font sizes

See merge request GNOME/gtk!6372
2023-09-18 11:16:10 +00:00
Matthias Clasen
cc904698a6 Merge branch 'matthiasc/for-main' into 'main'
contour: Make circles and rounded rects match

See merge request GNOME/gtk!6405
2023-09-18 11:14:39 +00:00
Matthias Clasen
a5fdd1228f Merge branch 'focus-on-click' into 'main'
Focus-on-click improvements

See merge request GNOME/gtk!6336
2023-09-18 10:41:52 +00:00
Sergey Bugaev
271d7632cb text: Respect focus-on-click property
It does make sense to have GtkText not focus on click in some cases,
such as when its editable property is set to false.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-09-18 12:03:54 +03:00
Sergey Bugaev
a8613377a5 colorbutton, fontbutton: Propagate focus-on-click to inner buttons
These widgets wrap a GtkButton internally. Make it possible to prevent
the inner button from grabbing focus on click by propagating the value
of the focus-on-click property from the widget to the inner button.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-09-18 12:03:54 +03:00
Benjamin Otte
d7cf5c2b1b Merge branch 'wip/otte/for-main' into 'main'
gl: gradients should transition in unpremultiplied space

See merge request GNOME/gtk!6406
2023-09-18 06:20:32 +00:00
Benjamin Otte
95865cb1bf gsk: Fix clipping error when drawing shadows
When shadows were offset - in particular when offset so the original
source was out of bounds of the result - the drawing code would create a
pattern for it that didn't include enough of it to compose a shadow.

Fix that by not creating those patterns anymore, but instead drawing the
source (potentially multiple times) at the required offsets.

While that does more drawing, it simplifies the shadow node draw code,
and that's the primary goal of the Cairo rendering.

Test included.
2023-09-18 07:53:03 +02:00
Benjamin Otte
0b813de72a gl: gradients should transition in unpremultiplied space
So make the gradient shaders do that.
2023-09-18 07:53:03 +02:00
Matthias Clasen
9c159cf129 path: Tweak printing a bit more
We are dealing with floats here, so using
g_ascii_dtostr isn't really the best.

Update affected tests.
2023-09-17 22:35:33 -04:00
Matthias Clasen
957d494090 contour: Make circles and rounded rects match
Make sure that we print the weights in the
same way (as floats).

Update affected tests.
2023-09-17 20:32:32 -04:00
Matthias Clasen
968b4237a9 Merge branch 'matthiasc/for-main' into 'main'
path: Fix parsing rounded rects

See merge request GNOME/gtk!6404
2023-09-17 21:19:42 +00:00
Matthias Clasen
f67c57b1f8 path: Fix parsing rounded rects
We were messing up the bottom left corner.

Test included.
2023-09-17 17:01:44 -04:00
Matthias Clasen
84f8c2d91d Merge branch 'matthiasc/for-main' into 'main'
inspector: Don't set a NULL fontdesc

Closes #5988

See merge request GNOME/gtk!6403
2023-09-17 19:17:28 +00:00
Matthias Clasen
8f1d8d7cb5 path: Split off gskpathparse.c
This is a standalone piece of code,
and nicely fits into its own source file.
2023-09-17 12:29:46 -04:00
Matthias Clasen
e98d9d62eb inspector: Don't set a NULL fontdesc
The font dialog button does not like that.

Fixes: #5988
2023-09-17 10:19:05 -04:00
Matthias Clasen
5a0b65c611 Merge branch 'path-builder-simplify' into 'main'
pathbuilder: Simplify degenerate curves

See merge request GNOME/gtk!6402
2023-09-17 13:55:32 +00:00
Matthias Clasen
5777587e7a docs: Add details for GskPathBuilder
Mention that GskPathBuilder will simplify
added Bézier curves.
2023-09-17 09:31:59 -04:00
Matthias Clasen
ecfc661054 Adapt tests to new path builder behavior
Some tests were expecting to get elevated curves
from GskPathBuilder. But they won't, anymore.
2023-09-17 08:53:10 -04:00
Emmanuele Bassi
e00722dee6 Merge branch 'submenu_reporting' into 'main'
a11y: When a menu item opens a submenu, set its expandable state

See merge request GNOME/gtk!5850
2023-09-17 11:02:33 +00:00
Piotr Drąg
5af21e70ec Update Polish translation 2023-09-17 12:15:52 +02:00
Matthias Clasen
7e13cfea91 path builder: Handle degenerate cubics
Replace cubics by lines or quadratics
when possible, and split at cusps.
2023-09-17 00:23:53 -04:00
Matthias Clasen
68b4d9c35e Add gsk_curve_get_cusps 2023-09-17 00:23:53 -04:00
Matthias Clasen
1f3b69e7db path builder: Handle degenerate conics
Do the same we do for quads here. Also,
conics with weight 1 are just quads.
2023-09-17 00:23:53 -04:00
Matthias Clasen
ca63552cf8 path builder: Handle degenerate quads
Quads that have a cusp need to be replaced by
two lines.
2023-09-17 00:23:53 -04:00
Matthias Clasen
a6d2d983b8 Add gsk_bounding_box_get_corner
This will be used in the following commits.
2023-09-16 21:57:31 -04:00
Matthias Clasen
7cd97192e5 pathbuilder: Simplify degenerate curves
When a quadratic or conic has identical points,
replace it with a line.
2023-09-16 14:32:12 -04:00
Matthias Clasen
8ac8bca52a Fix an indentation mishap 2023-09-16 13:39:21 -04:00
Benjamin Otte
cf8f6d254e Merge branch 'wip/otte/for-main' into 'main'
treemodelfilter: Yes gcc, both if branches are empty

See merge request GNOME/gtk!6401
2023-09-16 17:07:10 +00:00
Benjamin Otte
a267dfac5d treeview: No gcc, node is not NULL
... so I'll add an assertion just for you.
2023-09-16 12:18:58 -04:00
Benjamin Otte
745b28ef38 treemodelfilter: Yes gcc, both if branches are empty
... if assertions are disabled.
2023-09-16 12:17:57 -04:00
Matthias Clasen
5c27899efa Merge branch 'matthiasc/for-main' into 'main'
NEWS: Updates

See merge request GNOME/gtk!6400
2023-09-16 15:23:02 +00:00
Matthias Clasen
fd006592b5 Merge branch 'wip/corey/file-chooser-columns' into 'main'
File Chooser Move Column Visible to Column Header Menu

See merge request GNOME/gtk!6377
2023-09-16 14:27:52 +00:00
Matthias Clasen
201f27fe19 NEWS: Updates 2023-09-16 09:52:18 -04:00
Matthias Clasen
36c4dc8aea Merge branch 'contour-cosmetics' into 'main'
contour: Fixes for circles

See merge request GNOME/gtk!6399
2023-09-16 13:18:29 +00:00
Matthias Clasen
f0bd0c3e50 contour: Add more tests for circles
Cover the radius 0 case, in particular.
2023-09-16 08:31:52 -04:00
Matthias Clasen
4d71ff6da1 contour: Fixes for circles
Make circle contours use 'foreach coordinates' for
its points. This works here, but not for general
conics. As with the other custom contours, avoid
emitting collapsed conics.
2023-09-16 08:27:18 -04:00
Matthias Clasen
6d16776e27 tests: Cosmetics 2023-09-16 08:27:08 -04:00
Piotr Drąg
7cdff6bbb3 Update Polish translation 2023-09-16 13:34:39 +02:00
Martin
bf43859bdc Update Slovenian translation
(cherry picked from commit f0e0332ada)
2023-09-16 10:12:14 +00:00
Matthias Clasen
4b45f8415f Merge branch 'contour-cosmetics' into 'main'
contour: Fixes for rects and rounded rects

See merge request GNOME/gtk!6397
2023-09-15 22:30:13 +00:00
Matthias Clasen
86e0d5c13e Merge branch 'switch-rtl' into 'main'
switch: Respect text direction

Closes #1489

See merge request GNOME/gtk!6396
2023-09-15 21:59:15 +00:00
Matthias Clasen
d21ee115d0 Update private path tests
Our parser only recognizes 'complete' rounded
rects, so don't test roundtrips for incomplete
ones.
2023-09-15 16:46:23 -04:00
Matthias Clasen
2dd8e3b0eb contour: Add more tests for rounded rects
This is covering special cases where some
of the curves are omitted.
2023-09-15 16:46:23 -04:00
Matthias Clasen
6d001f79f9 contour: Fixes for rounded rects
Similar to the fixes for rect contours:
Handle all the special cases where empty curves
are omitted, and omit 'empty' curves in foreach.
2023-09-15 16:31:09 -04:00
Matthias Clasen
eb6ca8f39a contour: Add more tests for rects
Spot-check the special cases:
rects with zero height or width.
2023-09-15 16:31:09 -04:00
Matthias Clasen
abebd92b19 contour: Fixes for rect contours
Handle all the special cases (zero width and/or height),
and omit 'empty' curves in foreach.
2023-09-15 16:31:09 -04:00
Matthias Clasen
014ca76334 docs: Add details
Spell out what gsk_path_point_get_tangent does
if there is no tangent: we return 0,0.
2023-09-15 16:31:09 -04:00
Matthias Clasen
a520f9fcf7 pathbuilder: Skip trivial curves
Don't add quads, cubics or conics that collapse
to a single point. This matches what we do for
lines.
2023-09-15 16:31:09 -04:00
Matthias Clasen
de724b2a57 contour: Fix some corner cases
Adding segments of rects or rounded rects was
not working right in cases where some of the
curves are trivial. Fix that.
2023-09-15 16:31:09 -04:00
Matthias Clasen
061637f4eb contour: Small refactoring
Move some utilities out.
2023-09-15 16:31:09 -04:00
Matthias Clasen
dab1897d4e contour: Circle cosmetics 2023-09-15 16:31:09 -04:00
Andre Klapper
9ebb030c78 CONTRIBUTING: No more mailing lists; list Matrix/Discourse as irc.gnome.org is defunct 2023-09-15 22:26:44 +02:00
Benjamin Otte
93477ec019 Merge branch 'wip/otte/for-main' into 'main'
rendernode: Shadow nodes need offscreen for opacity

See merge request GNOME/gtk!6382
2023-09-15 16:08:42 +00:00
Benjamin Otte
f2a71898b1 array: Add gdk_array_steal()
Like gdk_array_clear() but returns the previous contents.
2023-09-15 16:34:00 +02:00
Benjamin Otte
24048dce43 render-node-tool: Actually load files properly 2023-09-15 16:34:00 +02:00
Benjamin Otte
41af8ee2e2 testsuite: Add another test
his is the opposite of the test in 1502c21e97.

Also change the numbers in that test so it doesn't need a ref file.

Related: #6075
2023-09-15 16:34:00 +02:00
Benjamin Otte
60c20fa6ed vulkan: Require Vulkan 1.2
We need to inist on the nonuniform access beuing available and that
requires Vulkan 1.2.

Also simplifies the descriptor indexing stuff, because that's all part
of Vulkan 1.2, too.
2023-09-15 16:34:00 +02:00
Benjamin Otte
5152c13081 vulkan: Change rounded_rect_shrink()
Same fix as with the GL renderer
2023-09-15 16:34:00 +02:00
Benjamin Otte
e9089f65e3 gl: Change rounded_rect_shrink()
The code now follows gsk_rounded_rect_shrink() and with it the behavior
of the Cairo renderer and Webkit.

The old code did what the GL renderer and Cairo do, but I consider that
wrong.

I did not test Chrome.

Test attached
2023-09-15 16:34:00 +02:00
Benjamin Otte
9aaec91f95 css: Snapshot opacity filter as opacity node
We were using color-matrix because it was easier, but opacity can often
be optimized when color-matrix needs offscreens.
2023-09-15 03:46:27 +02:00
Benjamin Otte
1c971c595f glrenderer: Shadows without offset do exist
Not for opaque contents, but stuff can be semi-transparent.

Testcase included.
2023-09-15 03:46:27 +02:00
Benjamin Otte
f8627755b5 rendernode: Shadow nodes need offscreen for opacity
Otherwise the shadow will not be properly computed as opaque regions
become translucent after applying opacity.

Testcase included.
2023-09-15 03:46:27 +02:00
Benjamin Otte
55ae8dc39e gsk: Move GskRoundedRect typedef
typedef should go into *types.h headers so that other headers only need
to include those.
2023-09-15 03:46:27 +02:00
Matthias Clasen
dd7d145249 Merge branch 'matthiasc/for-main' into 'main'
gtk-demo: Add sound to the path maze

See merge request GNOME/gtk!6395
2023-09-14 18:24:09 +00:00
Sergey Bugaev
0b2c249de3 switch: Fix CSS nodes documentation
A switch contains two GtkImage's whose nodes are named 'image',
not 'label'.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-09-14 19:35:00 +03:00
Sergey Bugaev
ea6b95f60d switch: Respect text direction
In RTL, we want the active state to mean the handle is on the left.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/1489

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-09-14 19:35:00 +03:00
Matthias Clasen
ed44f37de4 gtk-demo: Add sound to the path maze
Its a game, after all.
2023-09-14 11:32:22 -04:00
Matthias Clasen
3780a5ed6a Merge branch 'fix_visit_file' into 'main'
gtkfilechooserwidget: fix "Visit file" not scrolling to file

Closes #5799

See merge request GNOME/gtk!6392
2023-09-14 03:01:11 +00:00
Nelson Benítez León
fec3f0191a gtkfilechooserwidget: fix "Visit file" not scrolling to file
In the "Recent" view of GtkFileChooser widget, when right
clicking and selecting "Visit file" action, the action was
failing to scroll to target file.

Fix that by using gtk_column_view_scroll_to() which can
select, focus and scroll to the file.

Fixes #5799
2023-09-13 23:47:47 +01:00
Matthias Clasen
359fa99945 Merge branch 'fun-renderer-bug' into 'main'
gl renderer: Keep track of source

Closes #6094

See merge request GNOME/gtk!6391
2023-09-13 21:31:30 +00:00
Matthias Clasen
5441ed2227 Merge branch 'mcatanzaro/put-event' into 'main'
Fix documentation of gdk_display_put_event()

See merge request GNOME/gtk!6383
2023-09-13 21:27:22 +00:00
Matthias Clasen
ec1a1d0e34 gl renderer: Don't assume an atlas
The source uniform may or may not point
to a glyph atlas. The optimization we do
for color nodes is only possible if it does,
so check this.

Fixes: #6094
2023-09-13 16:56:47 -04:00
Matthias Clasen
8f4fb45715 gl renderer: Keep track of source
We have an optimization that depends on having
the source be a glyph atlas, so keep track of
that information in the render job.
2023-09-13 16:55:01 -04:00
Matthias Clasen
9db2288064 Merge branch 'matthiasc/for-main' into 'main'
rendernode: Fix handling of color glyphs

See merge request GNOME/gtk!6390
2023-09-13 20:14:41 +00:00
Matthias Clasen
1502c21e97 rendernode: Fix handling of color glyphs
The rendernode parser was mixing up its flags.

Test included.

Related: #6075
2023-09-13 15:37:57 -04:00
Matthias Clasen
408dd4b34d Merge branch 'macos' into 'main'
macOS: Clamp damage region to surface size

Closes #5812 and #6038

See merge request GNOME/gtk!6388
2023-09-13 15:33:01 +00:00
Luca Bacci
609e1f54ef macOS: Clamp damage region to surface size
...in _gdk_macos_cairo_context_begin_frame ()

GdkMacosCairoContext needs regions that are clamped to the
actual surface size.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/5812
2023-09-13 17:13:33 +02:00
Luca Bacci
f49d0fbbf6 macOS: Fix typos 2023-09-13 16:53:27 +02:00
Michael Catanzaro
dde47b7966 Fix documentation of gdk_display_put_event()
This function is deprecated, but we should still document it properly.
It appends, not prepends. This is clear enough from its implementation,
but also we have practical experience with WebKit in:

https://github.com/WebKit/WebKit/pull/8663

Matthias prefers to avoid the prepend, append, start, and end
terminology altogether.
2023-09-13 08:19:11 -05:00
Matthias Clasen
f84da62740 Merge branch 'wip/corey/gridcell' into 'main'
gtkfilechoosercell: Don't use ColumnViewCell

See merge request GNOME/gtk!6378
2023-09-12 19:47:09 +00:00
Matthias Clasen
cbfbe6dc23 Merge branch 'baseline-fixes' into 'main'
Baseline & measuring fixes

See merge request GNOME/gtk!6373
2023-09-12 19:46:12 +00:00
Corey Berla
2c63a34791 Apply 1 suggestion(s) to 1 file(s) 2023-09-12 17:05:33 +00:00
Matthias Clasen
9ab07553a3 Merge branch 'wip/fix-suspend-state' into 'main'
wayland: Bind correct xdg_wm_base version

See merge request GNOME/gtk!6385
2023-09-12 16:51:50 +00:00
Rafael Fontenelle
c29fb838e9 Update Brazilian Portuguese translation
(cherry picked from commit 066b101c57)
2023-09-12 16:42:31 +00:00
Jonas Ådahl
aecc76d916 wayland: Bind correct xdg_wm_base version
Otherwise we won't get the suspend state.
2023-09-12 21:51:59 +08:00
Michael Catanzaro
713a5188cf Fix typo 2023-09-08 11:46:26 -05:00
Changwoo Ryu
911f3bf555 Update Korean translation
(cherry picked from commit 1abfeff0d1)
2023-09-07 16:59:49 +00:00
Benjamin Otte
c752598a3d Merge branch 'wip/otte/for-main' into 'main'
Various fixes

Closes #6083

See merge request GNOME/gtk!6380
2023-09-07 16:10:46 +00:00
Benjamin Otte
9dfdb1b65b rendernode-tool: Fix array size
Also add an assertion, so things explode properly if we forget to
update the array size when adding new nodes, instead of writing random
memory.
2023-09-07 16:19:20 +02:00
Benjamin Otte
a05a021fd1 rendernode: Fix Cairo rendering of repeating gradients
Cairo and the GL renderer have a different idea of how to handle
transitioning of colors outside the defined range.

Consider these stops:
  black 50%, white 50%

What color is at 0%?

Cairo would transition between the last and first stop, ie it'd do a
white-to-black transition and end up at rgb(0.5,0.5,0.5) at 0%.
GL would behave as it would for non-repeating gradients and use black
for the range [0%..50%] and white for [50%..100%].
The web would rescale the range so the first stop would be at 0% and
the last stop would be at 100%, so this gradient would be illegal.

Considering that it's possible for code to transition between the
different behaviors by adding explicit stops at 0%/100%, I could choose
any method.
So I chose the simplest one, which is what the GL renderer does and
which treats repeating and non-repeating gradients the same.

Tests attached.
2023-09-07 16:19:20 +02:00
Benjamin Otte
9ffd7840ba pathpoint: Add G_GNUC_EXTENSION to struct definition
This allows compilation with gcc -pedantic.

GTKmm uses this as part of their recommended compiler flags.

Fixes #6083
2023-09-07 16:19:20 +02:00
Daniel Rusek
dd64084b44 Update Czech translation 2023-09-07 13:42:13 +00:00
Bruce Cowan
21277a37d6 Update British English translation
(cherry picked from commit c71f8d0838)
2023-09-06 11:39:24 +00:00
Corey Berla
ddc7e36543 gtkfilechoosercell: Don't use ColumnViewCell
This partially reverts ccae75022b.
Since FileChooserCell is used for ColumnView and GridView we should
treat the list item as a GtkListItem, not a ColumnViewCell otherwise
the menu fails to generate properly.
2023-09-05 12:45:34 -07:00
Corey Berla
f429dff03e gtkfilechooserwidget: Move column menu items to the column header menu
The main menu is too long and the column options belong in the column
header menu to begin with.  Since this is only available in column
view, we should always show the menu items.
2023-09-05 12:24:27 -07:00
Corey Berla
6f07c6a3f1 gtkfilechooserwidget: Use property actions for column visibility
It's a lot less code
2023-09-05 12:24:27 -07:00
Corey Berla
4cb4aa1029 gtkfilechooserwidget: Bind column visibility to settings
It's less hacky and lets us drop even more code in the next commit.
2023-09-05 12:24:27 -07:00
Matthias Clasen
cecab7801e Merge branch 'point-color' into 'main'
Point color

See merge request GNOME/gtk!6374
2023-09-04 06:03:22 +00:00
Matthias Clasen
ea7fd1ff5a contour: Fixup for 1-point contours
If we return a path point for a 1-point contour,
make it { n, 0, 1 }.
2023-09-04 00:55:21 +02:00
Matthias Clasen
ad474a60c0 path-tool: Update docs 2023-09-03 23:47:10 +02:00
Matthias Clasen
1e8e7e0c00 path-tool: Make render match show 2023-09-03 23:47:10 +02:00
Matthias Clasen
1e9e8d24c3 path-tool: Add a --point-color option 2023-09-03 23:47:10 +02:00
Matthias Clasen
9bd9b6f2ca contour: Make sure stroke bounds are sufficient 2023-09-03 23:04:47 +02:00
Aurimas Černius
913a6ddcc9 Update Lithuanian translation
(cherry picked from commit 5d54bb1359)
2023-09-03 18:20:17 +00:00
Sergey Bugaev
31da6f60d0 entry, searchentry: Fix measuring baseline
If the entry has icons, we may end up increasing our minimum and natural
height compared to the values the text child returned. In that case, we
should also adjust the baseline values to account for the text being
shifted down.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-09-03 21:07:52 +03:00
Sergey Bugaev
c4c118e425 centerlayout: Fix measuring in presence of baselines
The measure logic (unlike the allocation logic) was enforcing strict
baseline alignment of child widgets even if no child widget had valign
set to baseline. This was causing GtkCenterLayout to request more size
than it actually needed.

Instead, bring the logic closer to that of GtkBoxLayout by introducing
explicit have_baseline and align_baseline variables. We track and report
baseline if have_baseline gets set, but it only affects our reported
minimum and natural sizes if align_baseline ends up set, which happens
if there's a child widget that has valign set to either one of the two
baseline values, and itself reports a valid baseline.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-09-03 21:07:52 +03:00
Ask Hjorth Larsen
02599acf4d Update Danish translation
(cherry picked from commit cc4d94d197)
2023-09-03 14:34:00 +00:00
Piotr Drąg
6a653e4675 Update POTFILES.in 2023-09-02 12:56:56 +02:00
Amn Alam
29e92d6a0e Update Punjabi translation 2023-09-02 04:21:39 +00:00
Ekaterine Papava
b4fcc8b5f0 Update Georgian translation 2023-09-02 03:26:30 +00:00
G.Willems
b00333c603 theme: use relative font sizes
This allows text to properly scale when changing the default font size.
2023-09-02 00:04:54 +02:00
Matthias Clasen
63614727a3 Merge branch 'matthiasc/for-main' into 'main'
path-tool: Factor out dash parsing

See merge request GNOME/gtk!6369
2023-08-31 12:06:47 +00:00
Matthias Clasen
061a56d213 path-tool: Add a way to show controls 2023-08-31 03:19:25 -04:00
Matthias Clasen
3f63ba36ce path-tool: Factor out dash parsing
No need to do this in two places.
2023-08-31 03:19:17 -04:00
Davide Ferracin
d9b96c34be Update Italian translation
(cherry picked from commit 043c89dbe2)
2023-08-30 08:36:02 +00:00
Matthias Clasen
39a8c64624 Merge branch 'matthiasc/for-main' into 'main'
curve: Add a vfunc for get_at_length

See merge request GNOME/gtk!6366
2023-08-30 02:42:54 +00:00
Matthias Clasen
360b77cc50 curve: Add a vfunc for get_at_length
We can do this precisely for lines, so lets do it.
2023-08-29 22:09:59 -04:00
Matthias Clasen
1186eff1b7 Merge branch 'gtk-compose-test-case-single-char' into 'main'
composetable: Accept short compose sequences

See merge request GNOME/gtk!6358
2023-08-29 19:46:00 +00:00
Matthias Clasen
0b8582ccba Merge branch 'gsk-header-cleanup' into 'main'
gsk: Clean up standalone headers

See merge request GNOME/gtk!6364
2023-08-29 19:11:36 +00:00
Matthias Clasen
dc2914e1f9 composetable: Warn for things we can't handle
The compose table stores the keyvals to match against
in a guint16 array, so it can't handle directly encoded
Unicode codepoints (which have a high bit set). Warn
if we encounter those.
2023-08-29 13:32:32 -04:00
Matthias Clasen
a0d8678a9c composetable: Accept short compose sequences
Followup to 8931169e00. That commit did
not do enough work to actually accept sequences
of lenth 1, as pointed by Mike Fabian.
2023-08-29 13:30:05 -04:00
Mike FABIAN
c8a43da526 Add test case for single char compose sequence 2023-08-29 13:30:05 -04:00
Matthias Clasen
90ee05ae64 gsk: Clean up standalone headers
We require folks to include gskglrenderer.h in order
to create a GL renderer. So we be careful to only
include header in gskglrenderer.h that won't trigger
ugly warnings.

See !6363
2023-08-29 12:58:30 -04:00
Matthias Clasen
67a7602080 Merge branch 'tests-svg-dimensions' into 'main'
testsuite/gsk: add explicit dimensions to <svg> elements

See merge request GNOME/gtk!6359
2023-08-29 04:43:22 +00:00
Matthias Clasen
37db270d19 Merge branch 'contour-foreach' into 'main'
Drop tolerance from gsk_contour_foreach

See merge request GNOME/gtk!6361
2023-08-29 01:58:39 +00:00
Matthias Clasen
f3312f677b measure: Cosmetics 2023-08-28 21:14:28 -04:00
Matthias Clasen
05547d98d6 path: Cosmetics
Reorganize this source file into sections.
2023-08-28 21:13:58 -04:00
Matthias Clasen
11b219bc61 Drop tolerance from gsk_contour_foreach
There is no decomposition going on for any contours,
and the tolerance argument is entirely unused.
Decomposition and tolerance is handled entirely
in gskpath.c by its trampoline.
2023-08-28 20:52:22 -04:00
Matthias Clasen
5721c3cb8f demos: Drop an unused variable 2023-08-28 20:50:38 -04:00
Fran Dieguez
f90ca697af Update Galician translation 2023-08-28 22:36:51 +00:00
Michael Orlitzky
7a0e27b6e8 testsuite/gsk: add explicit dimensions to <svg> elements
Without an explicit width, height, and viewBox, there is no single
correct way to render an SVG. In the absense of said information,
librsvg is capable of making a guess by rendering the SVG to a Cairo
surface and then analyzing that surface; however, this process is
merely heuristic.

There are three GTK tests for SVG images that are missing dimensions.
While this is not a violation of the SVG specification, it does
implicitly couple the test to the librsvg rendering heuristic. In this
commit we add that dimension information so that the expected result
is unambiguous.
2023-08-28 17:14:18 -04:00
Matthias Clasen
e81aa18c82 Merge branch 'closest-point-distance' into 'main'
Change gsk_path_get_closest_point to return distance

See merge request GNOME/gtk!6357
2023-08-28 15:53:51 +00:00
Matthias Clasen
827bbc0cc1 Change gsk_path_get_closest_point to return distance
We already compute it, so lets return it.
Bindings seems fine with this change - they
already return (success, point) as a tuple
anyway.
2023-08-28 11:22:30 -04:00
Matthias Clasen
7095a67910 Merge branch 'matthiasc/for-main' into 'main'
path-tool: Add a reverse command

See merge request GNOME/gtk!6356
2023-08-28 04:38:42 +00:00
Matthias Clasen
dcbca3f0d7 path-tool: Add a reverse command
It does what it says.
2023-08-28 00:27:29 -04:00
Matthias Clasen
702d7c238a Merge branch 'matthiasc/for-main' into 'main'
contour: Simplify gsk_circle_contour_foreach

See merge request GNOME/gtk!6355
2023-08-28 04:18:48 +00:00
Matthias Clasen
5a3ed65ad8 Improve precondition checks for path points
Add a helper function for checking that a
path point is valid for a path, and use it.
2023-08-28 00:07:50 -04:00
Matthias Clasen
2e24a9ece4 Make GskPathPoint public
The contents are still /*< private >*/, but we
let our tests and the debugger see them, which
helps.
2023-08-28 00:07:50 -04:00
Matthias Clasen
2a17320314 Limit rect variation in path builder
Make gsk_path_builder_add_rect always
produce a clockwise rectangle. This matches
what we do for circles and rounded rects,
which also go clockwise. Note that we
still need to allow negative widths in
the contour code, to implement reverse().
2023-08-28 00:07:50 -04:00
Matthias Clasen
0dbff14555 Allow circles with radius of zero
Not very useful, but we allow rects with
width and height of zero, so lets be consistent.
Curvature is infinite for such contours.

Tests included.
2023-08-28 00:07:50 -04:00
Matthias Clasen
c5d89d00f1 Merge branch 'zbrown/tooltips' into 'main'
tooltip: don't cross native boundaries

Closes #1234, #5998, gnome-calendar#1038, and nautilus#3063

See merge request GNOME/gtk!6346
2023-08-28 03:25:44 +00:00
Matthias Clasen
6f3be310f4 contour: Simplify gsk_circle_contour_foreach
Use the same approach as the rounded rect contour.
2023-08-27 21:31:40 -04:00
Matthias Clasen
0ea6b70d55 Merge branch 'matthiasc/for-main' into 'main'
gtk-demo: Add a few path benchmarks

See merge request GNOME/gtk!6353
2023-08-27 23:45:59 +00:00
Matthias Clasen
2ca9982b91 rect contour: Avoid nans in corner cases
The length of rect contours can be zero,
so we much check before we divide.
2023-08-27 19:17:02 -04:00
Matthias Clasen
a40282b2fb Add gsk_path_point_print
Another private debug API.
2023-08-27 19:06:39 -04:00
Matthias Clasen
ad9fb1e101 Improve quad and conic decomposition
If the control point is equal to either
start or end, just emit a line. This improves
the rendering of rounded rectangles with such
corners.
2023-08-27 16:57:03 -04:00
Matthias Clasen
02a9652af4 Use a more compact representation for circles
Print circles as M-o-o-o-o-z.
2023-08-27 14:32:21 -04:00
Matthias Clasen
6f823d2d0d gtk-demo: Add a few path benchmarks
The Tiger and Graph examples in the fishbowl test
path handling.
2023-08-27 12:59:10 -04:00
Matthias Clasen
a5c9cd5657 Merge branch 'rectangle-contour' into 'main'
Add a rectangle contour

See merge request GNOME/gtk!6351
2023-08-27 16:46:12 +00:00
Matthias Clasen
21ab5b6fa3 Merge branch 'matthiasc/for-main' into 'main'
Add a test for rectangle segments

See merge request GNOME/gtk!6352
2023-08-27 16:45:58 +00:00
Benjamin Otte
2582fd45e4 demos: Add cute maze demo 2023-08-27 12:45:25 -04:00
Matthias Clasen
0a28a5d53a Add a rectangle contour
Add a contour that optimizes some things for
rectangles. Also add rectangle detection to the
path parser, and add tests similar to what we
have for the other special contours.
2023-08-27 12:36:56 -04:00
Matthias Clasen
ddd4855bbc Add a test for rectangle segments 2023-08-27 12:36:30 -04:00
Matthias Clasen
204216e3d5 Merge branch 'matthiasc/for-main' into 'main'
Drop unused code

See merge request GNOME/gtk!6350
2023-08-27 16:19:16 +00:00
Matthias Clasen
1e6a124665 Correct the docs of gsk_path_builder_add_rect
The path does *not* always go clockwise!
2023-08-27 12:18:36 -04:00
Matthias Clasen
78c5aff956 Test special contours harder
Check that the start- and endpoint work
as expected and verify that their winding
numbers match the ones of the standard contour,
and are negated when the contour is reversed.
2023-08-27 11:47:40 -04:00
Matthias Clasen
8d1844135b path: Add a comment 2023-08-27 10:10:08 -04:00
Matthias Clasen
b5dd9dae0d rounded rect contour: Fix an oversight
The close operation takes 2 points, so our array
was one too short. Oops.
2023-08-27 10:09:32 -04:00
Matthias Clasen
ebcb518e4f Cosmetics 2023-08-27 09:50:16 -04:00
Matthias Clasen
b7ea22f168 Drop unused code
Nobody is calling gsk_contour_get_start_end, so drop
this internal API.
2023-08-27 09:39:59 -04:00
Matthias Clasen
f0b3381660 Merge branch 'rounded-rect-contour' into 'main'
path: Add a rounded rect contour

See merge request GNOME/gtk!6347
2023-08-27 13:36:53 +00:00
Matthias Clasen
0796c72049 Add roundtrip tests for rounded rect contours
These should survive roundtrips through the
path parser as well now.
2023-08-27 09:31:17 -04:00
Matthias Clasen
822e988efe path: Recognize rounded rects when parsing
We can look out for M-L-O-L-O-L-O-L-O-Z patterns
with matching numbers.
2023-08-27 09:31:17 -04:00
Matthias Clasen
cee043f977 Add a rounded rect contour
This special contour takes advantage of its
rounded-rect-ness for speeding up bounding
boxes and winding numbers. It falls back
to the standard contour code for everything
else.
2023-08-27 09:29:19 -04:00
Matthias Clasen
b420540b15 Merge branch 'matthiasc/for-main' into 'main'
Simplify the path spinner demo

See merge request GNOME/gtk!6349
2023-08-27 13:27:50 +00:00
Matthias Clasen
031c0ec3e5 pathpoint: Add some debug API
Add a private gsk_path_point_to_string that
can be called in the debugger if you want
to see the contents of a GskPathPoint and
are too lazy to cast it to GskRealPathPoint
yourself.
2023-08-27 09:14:47 -04:00
Matthias Clasen
43b6822eb0 Add roundtrip tests for special contours
So far, we only have a circle contour.
Check that it survives a roundtrip through
gsk_path_to_string and gsk_path_parse.
2023-08-27 09:14:03 -04:00
Matthias Clasen
ba3a657c48 contour: Add some debug API
Add a private  way to get the class of a contour,
so we can test that roundtrips through gsk_path_parse
work as expected.
2023-08-27 09:13:32 -04:00
Matthias Clasen
5f2f116c28 circle contour: Fix a typo 2023-08-27 07:43:55 -04:00
Matthias Clasen
1db75e521d Simplify the path spinner demo
The transforms were obscuring a simple
calculation here.
2023-08-27 07:43:55 -04:00
Matthias Clasen
2297a353b8 Merge branch 'circle-contour' into 'main'
path: Add a circle contour

See merge request GNOME/gtk!6345
2023-08-27 11:12:51 +00:00
Matthias Clasen
80903e5f44 Merge branch 'bilelmoussaoui/gi' into 'main'
gi: Add missing since annotation

See merge request GNOME/gtk!6348
2023-08-27 11:05:31 +00:00
Bilal Elmoussaoui
7342ce5bca gi: Add missing since annotation 2023-08-27 08:17:00 +00:00
Matthias Clasen
167b38dfa1 contour: Some reactoring
Make a default print implementation, and use it.
2023-08-26 23:42:52 -04:00
Matthias Clasen
ead88c36ec path: Add circle tests 2023-08-26 23:42:52 -04:00
Matthias Clasen
b8a3d7fa00 path: Recognize circles when parsing
We can look out for the tell-tale
M-O-O-O-O-Z and turn it into a circle
contour.
2023-08-26 23:42:52 -04:00
Matthias Clasen
0fce24674a path: Add a circle contour
This special contour takes advantage of the
circle definition to speed up things like
hit testing and closest point determination.
2023-08-26 23:42:52 -04:00
Zander Brown
739084e9bc tooltip: don't cross native boundaries
When walking the tree looking for tooltips we shouldn't cross from, say,
a popover to it's parent window

Fix: https://gitlab.gnome.org/GNOME/gtk/-/issues/1234
Fix: https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/1038
Fix: https://gitlab.gnome.org/GNOME/gtk/-/issues/5998
Fix: https://gitlab.gnome.org/GNOME/nautilus/-/issues/3063
See: https://gitlab.gnome.org/GNOME/console/-/issues/318
2023-08-27 02:36:51 +01:00
Matthias Clasen
99ad585252 Merge branch 'measure-speedups' into 'main'
contour: Stop doing the roundtrip test

See merge request GNOME/gtk!6342
2023-08-27 01:13:41 +00:00
Matthias Clasen
949b6692ac Merge branch 'matthiasc/for-main' into 'main'
Drop unused code

See merge request GNOME/gtk!6344
2023-08-26 16:46:49 +00:00
Piotr Drąg
eb0479d8ed Update POTFILES.in and POTFILES.skip 2023-08-26 17:52:22 +02:00
Matthias Clasen
6defdb4e8a Drop unused code
we are not using any gsk_spline functions currently.
2023-08-26 11:29:09 -04:00
Matthias Clasen
9fdad6d4ee Make randomized path tests less precise
Bump the epsilon in test_split to make these
tests survive longer. They still fail eventually,
unfortunately.
2023-08-26 11:23:02 -04:00
Matthias Clasen
b6e285844f Make curve tests pass 2023-08-26 11:22:58 -04:00
Matthias Clasen
c989a06718 pathmeasure: compute samples on demand
Only do the work for a curve the first time
we need it. This should greatly speed up
use cases where you only create a measure
to get the length of the path.
2023-08-26 10:23:02 -04:00
Matthias Clasen
1c8bd8658d curve: Cosmetics 2023-08-26 10:23:02 -04:00
Matthias Clasen
ab50cba4e9 curve: Reduce the order of our approximation
Use 24 samples instead of 32.
2023-08-26 10:23:02 -04:00
Matthias Clasen
57918813e2 contour: Stop doing the roundtrip test
Doing inverse arclength computations is
a very high overhead operation. And the
tests still pass without it.
2023-08-26 09:39:49 -04:00
Matthias Clasen
a4df8d8818 Merge branch 'path-node-tests' into 'main'
css: Replace border rendering code with GskPath

See merge request GNOME/gtk!6341
2023-08-26 12:13:04 +00:00
Matthias Clasen
4b00cfc1ce Merge branch 'macos_ci' into 'main'
Disable macOS CI for forks

See merge request GNOME/gtk!6337
2023-08-26 11:43:57 +00:00
Matthias Clasen
889688c978 Add more fill and stroke node tests 2023-08-26 07:39:23 -04:00
Matthias Clasen
0bf1ae033d Document node format for stroke and fill nodes 2023-08-26 07:39:23 -04:00
Jordi Mas
994afcaeed Update Catalan translation 2023-08-26 09:50:31 +02:00
Matthias Clasen
b69cc832ef Merge branch 'path-tool-restrict' into 'main'
path-tool: Add a restrict command

See merge request GNOME/gtk!6340
2023-08-26 04:24:06 +00:00
Matthias Clasen
ca188b41ae post-release version bump 2023-08-25 22:29:09 -04:00
Matthias Clasen
81c8d1dd28 path-tool: Add length to info output
This requires GskPathMeasure.
2023-08-25 22:26:54 -04:00
Matthias Clasen
32d00ca9ed path-tool: Add a restrict command
This lets you subset a path between two given lengths.
2023-08-25 22:26:54 -04:00
Matthias Clasen
01b9997590 4.13.0 2023-08-25 22:21:27 -04:00
Matthias Clasen
677e19042d Docs: Cosmetics 2023-08-25 22:21:27 -04:00
Matthias Clasen
bd79f61cc5 pathpoint: Update the docs
We have gained some more ways of getting points.
2023-08-25 22:03:42 -04:00
Matthias Clasen
361cdecfe4 Merge branch 'path-measure-reredone' into 'main'
Add GskPathMeasure

See merge request GNOME/gtk!6326
2023-08-26 01:05:19 +00:00
Matthias Clasen
581ad5fc04 Make curve tests more robust
Add a few fudge factors that let these
tests survive extended runs.
2023-08-25 20:23:08 -04:00
Matthias Clasen
ff40dcffec Make the measure tests waste less time
No need to produce multiple contours, when
the test is just about splitting a single
curve.
2023-08-25 20:23:08 -04:00
Matthias Clasen
eb2fa4195a Make the measure tests run in ci
Marking them as slow has the unintended
side-effect of keeping them from running.
2023-08-25 20:23:08 -04:00
Benjamin Otte
e2d2b57f0e demos: Add a text-on-path demo 2023-08-25 20:23:08 -04:00
Matthias Clasen
6c1a128ea3 Make the map demo more interesting
Add marching arrows to it.

With this, it can also serve as a performance
test for rendering medium complexity paths.
2023-08-25 20:23:08 -04:00
Matthias Clasen
cfaa31eeb8 Expand docs for GskPathMeasure 2023-08-25 20:23:08 -04:00
Matthias Clasen
2097b15f9c Add randomized measure tests
Test that lengths behave as expected when
we split paths, do roundtrips through points,
and subset paths.
2023-08-25 20:16:49 -04:00
Matthias Clasen
46a8f57735 Add tests for path length 2023-08-25 20:16:49 -04:00
Matthias Clasen
2e5639a077 Add a circle test 2023-08-25 20:16:49 -04:00
Matthias Clasen
007cfeac94 Add GskPathMeasure
GskPathMeasure is the public API for path lengths.
2023-08-25 20:16:49 -04:00
Matthias Clasen
553499522c contour: Add measure API
In order to compute path lengths efficiently, we need
to cache lookup tables. This commit adds API to let
contours allocate and free such measure data, as well
as API to use the data to go length -> point and
vice versa.
2023-08-25 20:16:49 -04:00
René de Hesselle
2782daadb4 ci: Do not create macOS jobs for forks
The runner is not available in forks (on purpose / for security
reasons), so jobs created there will be stuck indefinitely until they
timeout and fail the pipeline, which is undesireable.

That also means that the initial goal to enable macOS jobs for all MRs
is out of reach: if you are an external contributor (read: non-project
member), your MR pipelines run in your fork, therefore have no access
to the runner.
2023-08-26 01:56:59 +02:00
Benjamin Otte
81821978ae Merge branch 'wip/otte/for-main' into 'main'
gltexture: Restore previous GL context

See merge request GNOME/gtk!6335
2023-08-25 21:44:17 +00:00
Matthias Clasen
787b1a661e curve: Add tests for length
Add some tests for gsk_curve_get_length.
2023-08-25 16:13:36 -04:00
Matthias Clasen
04e6fc3f74 curve: Add length computation
Add api to go t<>length.

The code here is inspired by
https://pomax.github.io/bezierinfo/#arclength
2023-08-25 16:13:36 -04:00
Benjamin Otte
54d2f0063a Merge branch 'replay' into 'main'
Node replay tests

See merge request GNOME/gtk!6299
2023-08-25 19:45:34 +00:00
Benjamin Otte
ae7ec40cf2 rendernodeparser: Generate better default child
... for fill and stroke nodes.

It's most likely we want the path bounds (or path stroke bounds),
so make the parser use those by default.
2023-08-25 21:12:12 +02:00
Matthias Clasen
d586a5c67c Merge branch 'fix-gears-demo' into 'main'
demo: Fix a bug without GL

Closes #6059

See merge request GNOME/gtk!6333
2023-08-25 14:34:13 +00:00
Matthias Clasen
c97dc6e903 Merge branch 'conics-revisited' into 'main'
path: Switch back to conics

See merge request GNOME/gtk!6332
2023-08-25 14:26:33 +00:00
Matthias Clasen
eec90d1026 pathbuilder: Add rel-variants for arc-to
Add rel-variants for all our arc-to APIs. This is
a pretty harmless addition, and it is more consistent
to have these for all ..._to functions.
2023-08-25 09:45:45 -04:00
Matthias Clasen
f4fb4d04e5 Some pathbuilder doc clarifications
Mention the end point of the html arc-to call.
2023-08-25 09:37:07 -04:00
Matthias Clasen
3283157352 Bring arc_to back as convenience API
It is our main use of conics, so make it an API,
and use it internally.
2023-08-25 09:31:19 -04:00
Sergey Bugaev
d07a6b8566 snapshot, gsktransform: Mention that rotation happens around (0, 0)
...and not around the center of the render node, as one could expect
given that the render node syntax for rotation, transform: rotate(90);,
happens to match the CSS syntax for the same thing, and CSS does rotate
around the center by default.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-08-25 15:54:05 +03:00
Sergey Bugaev
4e8e59cd58 snapshot: Fix push_repeat () with empty child bounds
The logic would confuse empty child bounds (in which case nothing should
get rendered) with NULL child bounds (in which case the child node's own
bounds should get used). In fact, if the child bounds are empty, we can
discard the descendant render nodes completely, getting a nice little
optimization.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-08-25 15:54:05 +03:00
Sergey Bugaev
9f811ccee5 testsuite: Add color-matrix-merge testcase
This tests the merging of nested color matrix nodes feature of
GtkSnapshot, which was broken before commit 082fdfdb24.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-08-25 15:54:05 +03:00
Sergey Bugaev
6cd6da050b testsuite: Add render node replay tests
This takes a render node tree and "replays" it by using the GtkSnapshot
machinery. We don't necesserily expect to get back an exactly equal
render node tree back, since GtkSnapshot applies various small
optimizations where possible, but the original and the replayed nodes
should render to identical textures.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-08-25 15:54:05 +03:00
Matthias Clasen
a906dbea35 demo: Fix a bug without GL
The gears widget was just not unrealizing properly
when GL is not available. Fix that.

Fixes: #6059
2023-08-25 08:37:22 -04:00
Matthias Clasen
5bc82f4141 Change curve derivative api
We don't need to have the derivative as a curve,
it is enough for us to compute values of the
derivative at a given t, which we can also do
for conics.
2023-08-25 07:33:16 -04:00
Matthias Clasen
25e6231a88 path: Switch back to conics
Arcs were appealing, but they have a fatal flaw: we can't
split our arcs without changing the ellipse they trace.
That could be fixed by adding an extra parameter, but then
it is no longer any better than conics.

So switch back to conics, which have the advantage that they
are used elsewhere.
2023-08-25 07:33:16 -04:00
Matthias Clasen
650e4b1920 Merge branch 'matthiasc/for-main' into 'main'
path docs: Clarify curvature

See merge request GNOME/gtk!6331
2023-08-24 19:55:36 +00:00
Matthias Clasen
5dc0cbc20f Expand the path docs a bit 2023-08-24 15:00:14 -04:00
Matthias Clasen
e1faf28310 Make curvature api more flexible
Add an extra direction argument to get_curvature to
allow picking the limit on either side, for sharp turns.

Update all callers.
2023-08-24 14:32:33 -04:00
Matthias Clasen
854c695153 pathpoint docs: Fix a link
Links gsk->gtk must be done manually, since we
don't have a dependency.
2023-08-24 13:41:39 -04:00
Matthias Clasen
ebd4ceca15 path docs: Clarify curvature
The curvature of lines is zero, not infinite.
2023-08-24 11:15:51 -04:00
Matthias Clasen
d873643407 path docs: Add another illustration 2023-08-24 11:09:28 -04:00
Matthias Clasen
8a789d0234 path docs: Cosmetics 2023-08-24 10:54:23 -04:00
Emmanuele Bassi
286b4cbc72 Merge branch 'macos_ci' into 'main'
interim solution for macOS CI

See merge request GNOME/gtk!6274
2023-08-24 14:10:03 +00:00
René de Hesselle
b4428029af Change workflow to enable MR pipelines
This makes it possible to have macOS CI run for everything inside the
main repository and for merge requests.
2023-08-24 15:30:03 +02:00
René de Hesselle
9aeb5be8ad gdk: Use subpixel_layout on macOS 2023-08-24 15:30:03 +02:00
René de Hesselle
007dd55a71 Re-enable macOS CI on new self-hosted runner 2023-08-24 15:30:03 +02:00
Matthias Clasen
7a05e40ce7 Merge branch 'matthiasc/for-main' into 'main'
Add some more arc tests

See merge request GNOME/gtk!6330
2023-08-24 12:20:13 +00:00
Matthias Clasen
8d0654db6b Add some more arc tests 2023-08-24 07:40:05 -04:00
Matthias Clasen
63d5615fe7 Merge branch 'dboles/issue6001-ShortcutsWindow-programmatic' into 'main'
Add API to programmatically build ShortcutsWindow

Closes #6001

See merge request GNOME/gtk!6249
2023-08-24 10:40:34 +00:00
Matthias Clasen
37d18816be menubutton: Don't assume the root is a window
The only thing this assumption does is cause
criticals, so remove it.

Fixes: #6055
2023-08-24 06:30:55 -04:00
Matthias Clasen
f1de7a524c Merge branch 'matthiasc/for-main' into 'main'
demo cosmetics

See merge request GNOME/gtk!6329
2023-08-24 10:17:44 +00:00
Fran Dieguez
644692a2e0 Update Galician translation 2023-08-24 06:19:48 +00:00
Matthias Clasen
da2e8b78c2 Merge branch 'matthiasc/for-main' into 'main'
demo cosmetics

See merge request GNOME/gtk!6329
2023-08-24 03:47:00 +00:00
Matthias Clasen
0b5a6ecbff demos: Cosmetics 2023-08-23 23:20:17 -04:00
Matthias Clasen
9a6aac0459 path spinner demo: Don't crash 2023-08-23 23:18:59 -04:00
Benjamin Otte
8aaecc3416 gltexture: Restore previous GL context
Texture downloads can be initiated due to the weirdest reasons - and if
they cause a GL context to be changed, it'd be basically unpredictable
when the GL context changes.

An example is the Cairo renderer - if it needs to draw a GL texture, it
will download it.

Now that no longer changes the GL context.
2023-08-24 05:00:29 +02:00
Matthias Clasen
d3f9b3e28a Merge branch 'matthiasc/for-main' into 'main'
arc: Fix the derivative

See merge request GNOME/gtk!6328
2023-08-24 02:45:58 +00:00
Matthias Clasen
4229a37e90 arc: Fix the derivative
Scale the derivative such that computing the arc length
of a unit quarter circle wil produce the expected result
of PI/2.
2023-08-23 22:18:52 -04:00
Matthias Clasen
12297fd88a arc curve: Simplify derivative 2023-08-23 22:11:22 -04:00
Matthias Clasen
7943610066 curve: Fix arc decomposition 2023-08-23 22:11:15 -04:00
Matthias Clasen
e19246d2db tests: Include arcs in curve tests 2023-08-23 22:10:51 -04:00
Matthias Clasen
e70117bd9f Merge branch 'mcatanzaro/#6056' into 'main'
notebook: fix critical when switching page

Closes #6056

See merge request GNOME/gtk!6327
2023-08-24 01:09:19 +00:00
Michael Catanzaro
20c4e24b74 notebook: fix critical when switching page
It's expected that gtk_widget_get_root() will return NULL if the widget
tree does not contain a root widget. I don't know what that means or why
it happens, but it's true in gnome-control-center's network panel when
displaying the OpenVPN configuration dialog. We need to handle it.

Fixes #6056
2023-08-23 15:51:08 -05:00
Matthias Clasen
3c5efbc77e Merge branch 'wip/matthiasc/arcs' into 'main'
path: Add arcs

See merge request GNOME/gtk!6313
2023-08-23 19:17:01 +00:00
Matthias Clasen
f6c2b6bb88 Make foreach work efficiently with arcs 2023-08-23 14:51:31 -04:00
Matthias Clasen
4ab03e79b7 Drop some unnecessary code
We tell path_foreach to split into lines or cubics,
so no point in having code to handle quads and arcs.
2023-08-23 14:33:25 -04:00
Matthias Clasen
7a12abdea3 Incorporate review feedback 2023-08-23 14:16:43 -04:00
Matthias Clasen
36ca1f10dc Add an arc demo
Make a circular spinner to see how well arcs
do for circles.
2023-08-23 13:45:12 -04:00
Matthias Clasen
07a92c1690 Merge branch 'matthiasc/for-main' into 'main'
docs: Fix gsk->gtk links

See merge request GNOME/gtk!6324
2023-08-23 16:45:26 +00:00
Matthias Clasen
0f7b9e686c Add a rounded rect test
This checks that our path-in-fill computations
agree with rounded_rect_contains_point. Sadly,
they don't do that, 100%.
2023-08-23 12:43:52 -04:00
Matthias Clasen
71584107b0 Add gsk_path_builder_html_arc_to
This one draws circular arcs with a given radius.
2023-08-23 12:43:52 -04:00
Matthias Clasen
88c0ace644 Make gsk_path_builder_svg_arc_to public
This is useful to port SVG paths using this syntax.
2023-08-23 12:43:52 -04:00
Matthias Clasen
d33ed4f9ab path: Add elliptical arcs
Add a new curve type for elliptical arcs
and use it for rounded rectangles and circles.
We use the 'E' command to represent elliptical
arcs in serialized paths.
2023-08-23 12:43:52 -04:00
Matthias Clasen
a63af177a4 docs: Fix gsk->gtk links
gi-docgen can't handle these, since we don't have
a dependency.
2023-08-23 11:38:13 -04:00
Piotr Drąg
43c8e136b5 Update Polish translation 2023-08-23 16:43:05 +02:00
Matthias Clasen
efd597c6ed Merge branch 'default-get-current-image' into 'main'
Implement gdk_paintable_default_get_current_image ()

See merge request GNOME/gtk!6303
2023-08-23 10:53:12 +00:00
Fran Dieguez
024a753a6a Update Galician translation 2023-08-23 07:24:01 +00:00
Danial Behzadi
e1dd3fb801 Update Persian translation 2023-08-23 00:18:33 +00:00
Ekaterine Papava
82011569ce Update Georgian translation 2023-08-22 21:14:18 +00:00
Sabri Ünal
747c9c4f94 Update Turkish translation 2023-08-22 20:18:57 +00:00
Matthias Clasen
7d7a090875 Merge branch 'wip/smcv/i387' into 'main'
tests: Accept slightly different numeric results

Closes #6051

See merge request GNOME/gtk!6320
2023-08-22 17:34:10 +00:00
Simon McVittie
0f125aad90 tests: Accept slightly different numeric results
FLT_EPSILON is the distance between 1.0 and the next distinct floating
point number, and doesn't necessarily have anything to do with the
precision we can expect from a series of floating-point calculations.
Experimentally, 1e-6 is achievable, even on platforms with unusual
floating point implementations like i387.

Resolves: https://gitlab.gnome.org/GNOME/gtk/-/issues/6051
Bug-Debian: https://bugs.debian.org/1050076
Signed-off-by: Simon McVittie <smcv@debian.org>
2023-08-22 17:24:17 +01:00
Matthias Clasen
a7d5796750 Merge branch 'path-tool-tweak' into 'main'
path-tool: Reorganize options

See merge request GNOME/gtk!6323
2023-08-22 16:19:19 +00:00
Matthias Clasen
79e132ab7b path-tool: Reorganize options
Put fill and stroke options into their own group.
This helps produce understandable --help output.
2023-08-22 09:56:43 -04:00
Danial Behzadi
85957b5d3e Update Persian translation 2023-08-22 13:39:46 +00:00
Matthias Clasen
373972b8ca Merge branch 'fix-wayland-crash' into 'main'
wayland: Don't assume the shell protocol

Closes #6048

See merge request GNOME/gtk!6322
2023-08-22 13:13:51 +00:00
Matthias Clasen
30e6d70b14 Merge branch 'matthiasc/for-main' into 'main'
docs: Tweaks

See merge request GNOME/gtk!6321
2023-08-22 13:07:42 +00:00
Matthias Clasen
c78b34649b wayland: Don't assume the shell protocol
The gtk_shell proxy will be NULL if the compositor
is not gnome-shell. Handle that without crashing.

Fixes: #6048
2023-08-22 08:27:23 -04:00
Matthias Clasen
b3fe68ca95 docs: Tweaks 2023-08-22 07:56:27 -04:00
Daniel Mustieles
417888f847 Updated Spanish translation 2023-08-22 13:25:53 +02:00
Benjamin Otte
de8fdd822c Merge branch 'wip/otte/for-main' into 'main'
widget: Remove unused headers from gtkwidget.h

See merge request GNOME/gtk!6319
2023-08-22 07:38:57 +00:00
Matthias Clasen
ee8e6ac546 Merge branch 'matthiasc/for-main' into 'main'
Make sure stroke bounds are big enough

See merge request GNOME/gtk!6318
2023-08-22 05:36:16 +00:00
Matthias Clasen
486674927a Make sure stroke bounds are big enough
Our standard 'empty path' in gtk4-node-editor
was getting its pointy corners cut off.
2023-08-21 23:59:08 -04:00
Matthias Clasen
acf9612ed8 docs: Start a section on paths 2023-08-21 23:59:08 -04:00
Matthias Clasen
8c664b669c Merge branch 'matthiasc/for-main' into 'main'
docs: Drop a nonexisting enum value

See merge request GNOME/gtk!6317
2023-08-22 03:47:30 +00:00
Matthias Clasen
b367bf83b4 docs: Tweaks 2023-08-21 22:40:22 -04:00
Matthias Clasen
b84f60877d docs: Drop a nonexisting enum value 2023-08-21 21:52:53 -04:00
Matthias Clasen
8a84024a54 Merge branch 'bilelmoussaoui/gi' into 'main'
gi: Fix missing namespace

See merge request GNOME/gtk!6316
2023-08-22 00:47:05 +00:00
Bilal Elmoussaoui
56cb614f79 gi: Fix missing namespace 2023-08-21 21:11:12 +00:00
Matthias Clasen
957d8845fd Merge branch 'kabus/x11-clipboard-leak' into 'main'
gdk/x11/clipboard: Fix Slist leak

See merge request GNOME/gtk!6314
2023-08-21 20:39:29 +00:00
Georges Basile Stavracas Neto
231c0ad77f Merge branch 'gbsneto/windows-ci-linker' into 'main'
ci: Limit parallel linking on Windows CI

See merge request GNOME/gtk!6315
2023-08-21 18:53:53 +00:00
Matthias Clasen
da635d6392 Merge branch '5777_texthistory_restore_modified_flag_on_redo' into 'main'
gtktexthistory: restore 'modified' flag on redo

Closes #5777

See merge request GNOME/gtk!6302
2023-08-21 18:41:28 +00:00
Matthias Clasen
b8a103b993 Merge branch 'matthiasc/for-main' into 'main'
curve: Add a get_crossing vfunc

See merge request GNOME/gtk!6312
2023-08-21 18:35:01 +00:00
Georges Basile Stavracas Neto
162759f34b ci: Limit parallel linking on Windows CI
Linking on Windows can easily run out of memory, and limiting it
to a single link operation (i.e. disabling parallelization) should
be enough to avoid this problem.
2023-08-21 15:29:51 -03:00
Khalid Abu Shawarib
79fa785dbc gdk/x11/clipboard: Fix Slist leak 2023-08-21 20:32:42 +03:00
Anders Jonsson
2a03e50030 Update Swedish translation 2023-08-21 15:55:55 +00:00
Matthias Clasen
fb0f5b5c14 curve: Add a get_crossing vfunc 2023-08-21 11:29:14 -04:00
Matthias Clasen
cd7726bb31 Merge branch 'matthiasc/for-main' into 'main'
docs: Add more illustrations

See merge request GNOME/gtk!6311
2023-08-21 05:49:23 +00:00
Matthias Clasen
2b4e577b53 docs: Add more illustrations
Add illustrations to the various curve_to methods
of GskPathBuilder.
2023-08-20 22:28:06 -07:00
Matthias Clasen
1ed695931f Merge branch 'matthiasc/for-main' into 'main'
path: Don't accept 'O' as path command

See merge request GNOME/gtk!6305
2023-08-21 04:15:27 +00:00
Matthias Clasen
51a44ddd1d Merge branch 'bilelmoussaoui/gi-docgen-links' into 'main'
docs: Stop using C symbols as links

See merge request GNOME/gtk!6310
2023-08-21 04:14:57 +00:00
Benjamin Otte
29cdac18e8 rendernodeparser: Handle dashing in strokes
That part of the original MR got lost while refactoring.

Put it back.
2023-08-21 05:23:44 +02:00
Benjamin Otte
418f6b35af gsk: Add gsk_rect_to_float()
... and use it.
2023-08-21 05:23:42 +02:00
Benjamin Otte
96a6e05f0b build: Add -Woverride-init
That's a gcc warning (clang has the equivalent -Winitializer-overrides,
but that one is included in -Wall) that complains about things like:

  VkOffset3D offset = { .x = pt.x, .x = pt.y, .y = 0 };

So you don't have to spend a few hours trying to understand what's going
on before realizing your copy/paste skills are substandard.
2023-08-21 05:20:31 +02:00
Benjamin Otte
d665d2fb89 vulkan: Add nonuniformEXT() where needed
The magical term to know about (because the GLSL compiler or the
validation layers sure as hell don't) is:

  "dynamically uniform expression"

because if you don't have that when indexing a texture or buffer array,
you need to add nonuniformEXT() around the index variable.

Fixes the close icon on AMD having glitches of the previous icon visible
in some pixels.
2023-08-21 05:19:44 +02:00
Benjamin Otte
8862666b5a build: GSK doesn't depend on gdk-pixbuf 2023-08-21 05:19:37 +02:00
Benjamin Otte
3adf02445f build: Don't use configure_file() when custom_target() works
These two files don't need to be built when configuring, they are only
needed during build.
2023-08-21 05:19:37 +02:00
Benjamin Otte
bfdd325d36 widget: Remove unused headers from gtkwidget.h
... and put them back in places where they are needed.
2023-08-21 05:19:37 +02:00
Jürgen Benvenuti
ac76cadf32 Update German translation
(cherry picked from commit f237c85c8f)
2023-08-20 17:47:37 +00:00
Bilal Elmoussaoui
5516ff6a02 docs: Stop using C symbols as links
They are much harder for the bindings to figure out the type back from it and usually just break
2023-08-20 10:59:49 +02:00
Baurzhan Muftakhidinov
f2578fcfb9 Update Kazakh translation 2023-08-19 18:04:04 +00:00
Piotr Drąg
4da80520b8 Update Polish translation 2023-08-19 17:18:25 +02:00
Matthias Clasen
b12a27083d path: Drop special contour parsing
This is not used currently, since we don't
have custom contours.
2023-08-18 18:06:44 -04:00
Matthias Clasen
07ec266a00 curve: Add a get_derivative vfunc 2023-08-18 13:46:42 -04:00
Sabri Ünal
965b3025d9 Update Turkish translation 2023-08-18 17:35:14 +00:00
Matthias Clasen
88e74ca21e path: Don't accept 'O' as path command
We don't have conics atm.
2023-08-18 13:19:48 -04:00
Matthias Clasen
148da12cfc Cosmetics 2023-08-18 13:19:33 -04:00
Matthias Clasen
3ded6ada0c Merge branch 'matthiasc/for-main' into 'main'
contour: Optimize bounds

See merge request GNOME/gtk!6304
2023-08-18 14:35:09 +00:00
Matthias Clasen
0c39890e0f contour: Optimize bounds
Cache the bounds in the contour, and compute
the stroke bounds based on it as well.
2023-08-18 10:02:14 -04:00
Sergey Bugaev
e45cba13ed paintable: Implement gdk_paintable_default_get_current_image ()
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-08-18 11:10:22 +03:00
G.Willems
b4977decc1 gtktexthistory: restore 'modified' flag on redo
When redoing a history entry, its `is_modified` flag is not
reflected to the history state tracker. So GtkTextBuffers may
expose a modified=FALSE status, despite a change was actually
applied to the buffer.

For the undo case, an `is_modified_set` flag was set on the last
entry of the undo queue when a change of the modified state of
the history is requested. This commit does the same on the first
entry of the redo queue.

Closes #5777
2023-08-17 22:26:00 +02:00
Jiri Grönroos
2da9d5862f Update Finnish translation 2023-08-17 17:51:26 +00:00
Matthias Clasen
b948e03e8a Merge branch 'dboles/popover-menu-flags-property' into 'main'
PopoverMenu: Make :flags a property for use in UI…

Closes #6030

See merge request GNOME/gtk!6298
2023-08-17 10:26:16 +00:00
Daniel Boles
2c90cadef4 PopoverMenu: Make :flags a property for use in UI…
…files, or other cases other than calling new_from_model_full(), which
generally makes it far easier to experiment with the effect of flags,
including by changing the value of the property in the Inspector.

fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/6030#note_1818229
2023-08-17 10:52:35 +01:00
Matthias Clasen
08c064d79a Merge branch 'matthiasc/for-main' into 'main'
Rename an internal function

See merge request GNOME/gtk!6301
2023-08-16 20:40:12 +00:00
Matthias Clasen
73853f1a6b contour: Add an assertion 2023-08-16 16:18:38 -04:00
Matthias Clasen
8634d67cff Some fixes for gsk_path_builder_add_segment
We must be careful with single-point contours
that contain just a move. These never occur in
practice, but our randomized tests produce them
regularly.
2023-08-16 16:15:26 -04:00
Matthias Clasen
125ea90894 Rename an internal function
We want the number of ops, not the number of points.
2023-08-16 15:54:46 -04:00
Matthias Clasen
ffba5a3f42 Merge branch 'matthiasc/for-main' into 'main'
build: Drop some unused variables

See merge request GNOME/gtk!6297
2023-08-16 19:28:12 +00:00
Matthias Clasen
60df21213b Merge branch 'dboles/popover-css-nodes' into 'main'
Popover: Fix & add to CSS nodes documentation

See merge request GNOME/gtk!6300
2023-08-16 19:16:12 +00:00
Sabri Ünal
14ba577acb Update Turkish translation 2023-08-16 18:31:30 +00:00
Benjamin Otte
7d5ef1117e Merge branch 'color-matrix' into 'main'
Color matrix node fixes & clarifications

See merge request GNOME/gtk!6290
2023-08-16 17:07:35 +00:00
Daniel Boles
af0e2bff94 Popover: Fix & add to CSS nodes documentation
* The `.background` class gets put on `popover`, not `content`
* Use backticks to style node and class names with monospace
* Link to GtkPopoverMenu
* Add to PopoverMenu a bit outlining how items and sections look in CSS.
2023-08-16 17:11:45 +01:00
Matthias Clasen
7d65f81d7f Merge branch 'path-world-resource' into 'main'
Fix MSVC build (turn world map path into a resource)

See merge request GNOME/gtk!6296
2023-08-16 13:51:32 +00:00
Matthias Clasen
b08ecfcf9e build: Drop some unused variables
We are not using gtk_private_packages at all,
so drop it.
2023-08-16 09:43:34 -04:00
Matthias Clasen
e2cd362f24 Merge branch 'fg_color_docs' into 'main'
gsk: Update docs for gtk_snapshot_append_layout

See merge request GNOME/gtk!6295
2023-08-16 12:52:43 +00:00
Yuri Chornoivan
1a1b6fe66b Update Ukrainian translation 2023-08-16 11:37:47 +00:00
Sergey Bugaev
122176a3a1 gtk-demo: Turn world map path into a resource
The C string literal way way too long for MSVC.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-08-16 14:35:35 +03:00
Matthias Clasen
5beccc8208 Merge branch 'fix-pc-files' into 'main'
meson: Add wayland-client to gtk4-wayland requires

See merge request GNOME/gtk!6293
2023-08-16 11:29:39 +00:00
Matthias Clasen
6715a3267a Merge branch 'remove-out-caller-allocates-from-pod-types' into 'main'
introspection: Remove 'caller-allocates' from POD types

See merge request GNOME/gtk!6294
2023-08-16 11:29:25 +00:00
Alexandros Theodotou
313078b77c gsk: Update docs for gtk_snapshot_append_layout
Mention how to get the current theme's foreground color.
2023-08-16 20:09:15 +09:00
Sergey Bugaev
246a7cfeab rendernode, snapshot: Slightly expand color matrix docs
Based on reverse engineering the color node and contrary to my
expectations, the matrix/offset is expressed in, and applied to,
unpremultiplied colors. The colors are being explicitly
unpremultiplied, transformed according to the matrix/offset, and
premultiplied back (see color_matrix.glsl). The matrix is getting
transposed.

Also, copy the same blurb to the corresponding GtkSnapshot function.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-08-16 13:55:04 +03:00
Sergey Bugaev
082fdfdb24 snapshot: Fix merging color matrix nodes
The code was appliying the matrices in the wrong order: we have to apply
the inner node's matrix first, and the outer one second. Due to the
matrices being implicitly transposed, the matrix multiplication was done
in the right order, yet the wrong matrix was being mutliplied by the
wrong offset vector.

To make the code a little easier to follow, create explicit variables
for the resulting matrix and offset (instead of reusing matrix2 and
offset2), and fix & expand the comment to document how matrix
transposition factors into this.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-08-16 13:54:54 +03:00
Philip Chimento
823cb714ec introspection: Remove 'caller-allocates' from POD types
The (out caller-allocates) and (out callee-allocates) annotations are
meant for structured or pointer types. Plain old data types are just
regular out parameters and don't need the annotation about who allocates
them.

See glib!2005, gjs#570
2023-08-15 22:30:27 -07:00
Ekaterine Papava
cc93347fe6 Update Georgian translation 2023-08-16 03:36:32 +00:00
Xavier Claessens
d6a07cd617 meson: Add x11_dep to gtk4-x11 requires 2023-08-15 21:17:39 -04:00
Fran Dieguez
858bd9f84c Update Galician translation 2023-08-15 23:40:15 +00:00
Matthias Clasen
be7e5c866f Merge branch 'matthiasc/for-main' into 'main'
gsk: Add more details to the docs

See merge request GNOME/gtk!6292
2023-08-15 19:27:59 +00:00
Matthias Clasen
93a90bafc3 Add some statistics to the map demo 2023-08-15 13:55:46 -04:00
Xavier Claessens
090e01b383 meson: Add wayland-client to gtk4-wayland requires 2023-08-15 13:35:46 -04:00
Matthias Clasen
03a511aab4 path-tool: Make info show statistics
It is somewhat interesting to know how many
contours, lines, etc. a path consists of.
2023-08-15 13:33:23 -04:00
Matthias Clasen
5cf9a09c07 gsk: Add more details to the docs 2023-08-15 12:38:24 -04:00
Matthias Clasen
9558c70683 Merge branch 'dboles/signal-factory-typos' into 'main'
SignalListItemFactory: small doc grammar+sense fix

See merge request GNOME/gtk!6291
2023-08-15 14:36:35 +00:00
Daniel Boles
57d98a12fa SignalListItemFactory: small doc grammar+sense fix
* "to to" => "to"
* "a object" => "an object"
* "its new prop is about to be unset" => "its prop is about to be unset"
2023-08-15 10:47:30 +01:00
Danial Behzadi
3dd40049a9 Update Persian translation 2023-08-14 22:35:12 +00:00
Matthias Clasen
225e626ada Merge branch 'matthiasc/for-main' into 'main'
Fix GskStandardContour to have a 'good' size

See merge request GNOME/gtk!6289
2023-08-14 20:28:46 +00:00
Matthias Clasen
081f504ae4 Tweak the directions illustration
Still not 100% happy with it, but it is better.
2023-08-14 16:09:27 -04:00
Matthias Clasen
45aa8e4e00 Fix GskStandardContour to have a 'good' size
We need the size of GskStandardContour to be
at least as aligned as graphene_point_t, or
things break in hard to debug ways.
2023-08-14 15:59:45 -04:00
Matthias Clasen
87430be658 Fix up a testcase
I had gotten the path direction enum mixed up here.
2023-08-14 15:59:45 -04:00
Matthias Clasen
012c16ccd6 Merge branch 'matthiasc/for-main' into 'main'
gtk-demo: Clean up path walk demo

See merge request GNOME/gtk!6288
2023-08-14 19:20:57 +00:00
Matthias Clasen
de0cef5d4d Merge branch 'path-convenience' into 'main'
pathpoint: Add gsk_path_get_rotation

See merge request GNOME/gtk!6284
2023-08-14 19:20:40 +00:00
Matthias Clasen
e807a84967 gtk-demo: Clean up path walk demo 2023-08-14 15:19:42 -04:00
Matthias Clasen
b5e105d4f4 snapshot: Add more path api
Add convenience methods to fill or stroke
a path with a color.
2023-08-14 14:58:22 -04:00
Matthias Clasen
a85ab3585e Revise gsk_path_point_get_tangent
Update the directions enum to allow all four
tangents to be obtained. Add an illustration
to the docs for clarity.

Update all callers.
2023-08-14 14:58:22 -04:00
Matthias Clasen
a1d40c5236 Add gsk_path_point_get_rotation
This returns the tangent in the form of an angle.
2023-08-14 14:58:22 -04:00
Matthias Clasen
95ea6b2615 Merge branch 'path-point-api-revision2' into 'main'
pathpoint: Revise argument order

See merge request GNOME/gtk!6287
2023-08-14 18:53:23 +00:00
Ekaterine Papava
82d8bc9403 Update Georgian translation 2023-08-14 18:34:10 +00:00
Matthias Clasen
536d432444 Merge branch 'path-map-demo' into 'main'
demos: Add a map demo

See merge request GNOME/gtk!6285
2023-08-14 17:49:26 +00:00
Yuri Chornoivan
3b8c26a116 Update Ukrainian translation 2023-08-14 17:30:53 +00:00
Matthias Clasen
6ace4b60d8 pathpoint: Revise argument order
In order for introspection and documentation to
not be confused, we need to have the GskPathPoint
be the first argument.

Update all callers.
2023-08-14 13:20:34 -04:00
Matthias Clasen
7601b89561 Merge branch 'fix-4986' into 'main'
Fix native filechooser on macOS

Closes #4986

See merge request GNOME/gtk!6272
2023-08-14 16:26:15 +00:00
Matthias Clasen
0cdd2e7008 Merge branch 'color-dialog-button-activate' into 'main'
Make new-style dialog buttons activatable

See merge request GNOME/gtk!6255
2023-08-14 16:26:13 +00:00
Piotr Drąg
595152bdba Update POTFILES.in 2023-08-14 15:16:29 +02:00
Benjamin Otte
90f0733673 demos: Add a map demo
For now, this just shows a world map.

Once we have measures, we can make this
a little more interesting.
2023-08-14 08:41:16 -04:00
Matthias Clasen
625e83e1de Merge branch 'wip/alice/menu-button' into 'main'
menubutton: Fix focus on the internal gizmo

Closes #6025

See merge request GNOME/gtk!6283
2023-08-14 11:19:21 +00:00
Matthias Clasen
daac04be82 Merge branch 'bilelmoussaoui/gi' into 'main'
gi: Add missing since annotation

See merge request GNOME/gtk!6282
2023-08-14 11:15:28 +00:00
Matthias Clasen
8ec9bba892 Merge branch 'dboles/inspector-object-tree-flash' into 'main'
inspector/object-tree: Fix ! flash @ select widget

Closes #6022

See merge request GNOME/gtk!6279
2023-08-14 11:14:49 +00:00
Alice Mikhaylenko
b63e365fd2 menubutton: Fix focus on the internal gizmo
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/6025
2023-08-14 14:24:06 +04:00
Daniel Boles
859a25b0e7 Inspector: Fix ! flash on select widget @ obj tree
Widgets are flashed by the window when it receives Tree::object-selected
- but we were emitting said signal from select_object(), i.e. if we were
made to select by an external caller. We should also emit it if the user
interactively selects an item, so the window receives+flashes the widget

fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/6022
2023-08-14 10:48:26 +01:00
Bilal Elmoussaoui
f5d47a4658 gi: Add missing since annotation 2023-08-14 08:41:12 +00:00
Matthias Clasen
fa6645f157 Merge branch 'fix-add-segment' into 'main'
Fix gsk_path_builder_add_segment

See merge request GNOME/gtk!6280
2023-08-14 01:01:37 +00:00
Joshua Lee
69b6067c5e fontdialogbutton: Make activatable 2023-08-14 01:26:23 +01:00
Joshua Lee
e645f59748 colordialogbutton: Make activatable 2023-08-14 01:26:20 +01:00
Efstathios Iosifidis
2929686c1d Update Greek translation 2023-08-13 21:18:23 +00:00
Andika Triwidada
c83256e080 Update Indonesian translation 2023-08-13 13:42:39 +00:00
Matthias Clasen
4b7e1b1233 Fix gsk_path_builder_add_segment
We were splitting the last segment, but did not
actually use the result of the split. Oops.
2023-08-13 09:40:19 -04:00
Matthias Clasen
95a8821614 text: Track user changes better
Make all the action signal handlers call
begin/end_change(), so we can rely on
change_count being >0 to check later if
an action is user-initiated or programmatic.

Fixes: #6018
2023-08-13 09:31:42 -04:00
Benjamin Otte
73500f9ebb Merge branch 'wip/otte/for-main' into 'main'
treeviewcolumn: Set ascending class for ascending order

Closes #6002

See merge request GNOME/gtk!6277
2023-08-13 03:54:19 +00:00
Matthias Clasen
eae38756c2 Merge branch 'matthiasc/for-main' into 'main'
path-tool: Make the docs match

See merge request GNOME/gtk!6278
2023-08-12 23:51:21 +00:00
Matthias Clasen
8bf7187b89 path-tool: Make the docs match
We've removed various things from the tool,
and forgot to keep the docs up-to-date.
2023-08-12 19:29:27 -04:00
Matthias Clasen
e7fb8842b5 Merge branch 'path-for-merge-8' into 'main'
Add gtk-path-tool

See merge request GNOME/gtk!6263
2023-08-12 21:39:15 +00:00
Matthias Clasen
aaac0cb4a1 Merge branch 'bilelmoussaoui/linkify' into 'main'
docs: Drop uneeded ` in gi-docgen links

See merge request GNOME/gtk!6276
2023-08-12 21:23:13 +00:00
Benjamin Otte
67a4279d3f rendernode: Put typedef into gsktypes.h
Makes includes simpler for headers that want to use GskRenderNode.
2023-08-12 23:13:47 +02:00
Benjamin Otte
dd4b8a4c89 gl: Pass swizzle array directly
There's no need to pass pointers to arrays, as arrays are already
pointers.
2023-08-12 23:13:23 +02:00
Benjamin Otte
4cc5a54da3 viewport: Fix leak
Fixes #6002
2023-08-12 23:13:23 +02:00
Benjamin Otte
07add0144e columnview: Fix refcounting woes
The new code did not deal with the GtkScrollInfo properly.

Related: #6002
2023-08-12 23:13:23 +02:00
Benjamin Otte
d1c7376b05 gdkcontext: Make has_unpack_subimage() do the version check
Makes the code look simpler when we actually use that function.
2023-08-12 23:13:23 +02:00
Benjamin Otte
a71388d2d6 treeviewcolumn: Set ascending class for ascending order
The alternative button order confused the code and so the "ascending"
class was set for descending order by default, not when alternate order
is set.
2023-08-12 23:13:23 +02:00
Matthias Clasen
62176a3bd0 tools: Add gtk4-path-tool
This comes in handy for testing, among other things.

For now, this supports decomposing, reversing, rendering,
info and preview.
2023-08-12 16:34:19 -04:00
Bilal Elmoussaoui
8475a29836 docs: Drop uneeded ` in gi-docgen links
Causes the rust docs to fail parsing those as links
2023-08-12 22:26:25 +02:00
Matthias Clasen
44bc5a139c Add rounded rects to the tests 2023-08-12 16:09:31 -04:00
Matthias Clasen
11f48f3c5b Add gsk_path_builder_add_rounded_rect
For now, this is using gsk_path_builder_svg_arc_to
to approximate elliptical arcs.
2023-08-12 15:34:54 -04:00
Matthias Clasen
fa4ad1590d Merge branch 'matthiasc/for-main' into 'main'
path: Some documentation improvements

See merge request GNOME/gtk!6273
2023-08-11 16:42:25 +00:00
Matthias Clasen
47ddc742fc path: Some documentation improvements
Among other things, add a quick summary of
SVG path syntax, and add a few illustrations.
2023-08-11 12:09:12 -04:00
Matthias Clasen
31d994837b Merge branch 'path-tests-3' into 'main'
path builder: Fix add_cairo_path

Closes #6011

See merge request GNOME/gtk!6270
2023-08-11 12:44:00 +00:00
Matthias Clasen
83d692e2d3 path: Add tests for gsk_path_builder_add methods
Check that they all end the current contour.

Fixes: #6011
2023-08-11 07:24:19 -04:00
Qiu Wenbo
2a96dde115 macos: use NSPopUpButton for filter selection in native filechooser
On macOS 14, NSComboBox can't popup the dropdown list of filters. That
makes native filechooser on macOS completed broken. And NSComboBox is
more complex since it is a widget focused on edit capability.
NSPopUpButton is more suitable for plain selectable dropdown list.

Fixes: 4986

Signed-off-by: Qiu Wenbo <qiuwenbo@kylinos.com.cn>
2023-08-11 16:19:48 +08:00
Qiu Wenbo
f55b3c68ad filefilter: fix UTI type conversion on macOS
GContentType on macOS switched to UTI since glib 2.51. We should not assume it as MIME type anymore.

Fixes: #4986

Signed-off-by: Qiu Wenbo <qiuwenbo@kylinos.com.cn>
2023-08-11 16:19:38 +08:00
Matthias Clasen
f2835bb48b pathbuilder: Treat current point consistently
Arrange that none of the 'add' methods change
the current point.
2023-08-10 22:56:47 -04:00
Fran Dieguez
857c22db32 Update Galician translation 2023-08-11 00:35:58 +00:00
Matthias Clasen
fff1645060 path builder: Fix add_cairo_path
We were forgetting to end the current contour.
2023-08-10 16:08:32 -04:00
Matthias Clasen
4f0c3c81fb Merge branch 'matthiasc/for-main' into 'main'
Matthiasc/for main

See merge request GNOME/gtk!6269
2023-08-10 04:28:26 +00:00
Matthias Clasen
421365cfc3 Add more path point tests 2023-08-09 23:55:08 -04:00
Matthias Clasen
59c5b41f3d Cosmetics 2023-08-09 23:48:50 -04:00
Matthias Clasen
267367355f Merge branch 'path-fill-tests2' into 'main'
Add more path fill tests

See merge request GNOME/gtk!6268
2023-08-10 03:10:14 +00:00
Matthias Clasen
0aa3356499 Add more path fill tests
These also used to live with measure tests.
2023-08-09 22:47:13 -04:00
Matthias Clasen
14a3b35333 Merge branch 'path-fill-tests' into 'main'
Add path fill tests

See merge request GNOME/gtk!6267
2023-08-10 02:21:34 +00:00
Matthias Clasen
77def95659 Add path fill tests
These used to live with the measure tests, but
path_in_fill no longer involves a measure.
2023-08-09 21:50:29 -04:00
Matthias Clasen
4e91cd1155 Merge branch 'matthiasc/for-main' into 'main'
pathpoint: Use the right type

See merge request GNOME/gtk!6266
2023-08-09 20:37:14 +00:00
Matthias Clasen
2d923d362f Merge branch 'bilelmoussaoui/gi-gsk' into 'main'
gsk/gi: new Path api fixes

See merge request GNOME/gtk!6265
2023-08-09 19:40:53 +00:00
Matthias Clasen
b7544636d4 contour: Skip the move
When jumping between segments, we always
need to skip index 0, since thats the move.

This fixes the tangent checks in the
rectangle tests.
2023-08-09 15:12:58 -04:00
Matthias Clasen
6220baf230 get_closest_point: Prefer earlier points
Only switch to a later point if it is strictly
closer than the existing match. This fixes
start- vs endpoint confusion in the rectangle
tests.
2023-08-09 15:12:52 -04:00
Matthias Clasen
917307a6a4 pathpoint: Use the right type 2023-08-09 14:37:14 -04:00
Matthias Clasen
5f49b7b492 Merge branch 'matthiasc/for-main' into 'main'
pathpoint: Clarify docs

See merge request GNOME/gtk!6262
2023-08-09 18:36:05 +00:00
Bilal Elmoussaoui
b03abea402 gsk: Don't change the GskRenderNodeType order
As we use their values to check that a node can be downcasted to a node
type in the Rust bindings
such change would break existing code
2023-08-09 20:26:46 +02:00
Bilal Elmoussaoui
d4fcc883cb gsk/gi: Add missing since annotations & docs 2023-08-09 20:26:46 +02:00
Daniel Boles
ca2a2697d6 Merge branch 'dboles/for-main' into 'main'
docs: Add/fix some links; avoid pluralisation

See merge request GNOME/gtk!6261
2023-08-09 16:57:19 +00:00
Matthias Clasen
68c6f63e90 pathpoint: Clarify docs
Add a paragraph explaining the situation
for comparing the start- and endpoint of
a closed path.
2023-08-09 11:30:26 -04:00
Daniel Boles
0e89fed8ed docs: Add/fix some links; avoid pluralisation
Appending `s` breaks the [type@NS.Object] notation, so fix that in
ListHeader. Add links to ListItem and Overlay, and avoid appending `s`
after `backtick`s just for consistency with the [type@NS.Object] issue.
2023-08-09 15:35:12 +01:00
Benjamin Otte
4d726543d0 Merge branch 'path-for-merge-6' into 'main'
Simplify GskPathPoint

See merge request GNOME/gtk!6260
2023-08-09 14:24:33 +00:00
Matthias Clasen
2bcc998e90 Add tests for gsk_path_builder_add_segment
Test at least some of the special cases:
- start and end point on the same contour
- start and end point on the same segment
- end before start
2023-08-09 07:01:01 -04:00
Matthias Clasen
f707185248 Add gsk_path_builder_add_segment
With GskPathPoint, we can subset paths without
a measure object.
2023-08-09 07:01:01 -04:00
Matthias Clasen
ded30049db path: Add gsk_path_get_start/end_point
These are useful to have, now that we are
relying more on GskPathPoint in our api.
2023-08-08 22:05:34 -04:00
Matthias Clasen
5c55e9d11e Add gsk_path_point_equal/compare
These just make sense to have.
2023-08-08 22:05:34 -04:00
Matthias Clasen
c35bb11c18 Simplify GskPathPoint
Use simple representation of just
{ contour index, segment index, t value }
2023-08-08 20:31:56 -04:00
Matthias Clasen
cc19781d27 Merge branch 'cpdb-fix' into 'main'
print: Update printerprivate header location for cpdb backend

See merge request GNOME/gtk!6259
2023-08-08 23:01:12 +00:00
Jeremy Bícha
08d08678e8 print: Update printerprivate header location for cpdb backend
This fixes the print-cpdb build option
2023-08-08 17:55:54 -04:00
Matthias Clasen
11b632a691 Merge branch 'timezone' into 'main'
test-calendar: Update timezone name

See merge request GNOME/gtk!6258
2023-08-08 19:31:31 +00:00
Jeremy Bícha
4881ef251e test-calendar: Update timezone name
Debian no longer provides the MET timezone
but instead provides geographical region and city name
2023-08-08 15:01:42 -04:00
Luca Bacci
5b39abd1a4 Merge branch 'fix-server-side-decorations' into 'main'
win32: Fix minimize and maximize buttons missing on ssd

Closes #5142

See merge request GNOME/gtk!6052
2023-08-08 15:17:09 +00:00
Daniel Mustieles
f0089097dd Update Spanish translation 2023-08-08 10:41:17 +00:00
Fran Dieguez
d603925ab2 Update Galician translation 2023-08-08 00:05:18 +00:00
Matthias Clasen
6af9dc8612 Merge branch 'xry111/issue6003' into 'main'
print: Revert "Start sorting apart includes" change for gtkprinteroptionprivate.h

Closes #6003

See merge request GNOME/gtk!6250
2023-08-07 22:52:43 +00:00
Benjamin Otte
35b313f9b0 Merge branch 'path-for-merge-3' into 'main'
gskpath: Add stroking

See merge request GNOME/gtk!6248
2023-08-07 22:17:53 +00:00
Matthias Clasen
fe84ce8686 gsk: Try to fix flipped fallback rendering
This patch is pretty much a blind guess, but
it seems to fix flipped rendering of fill
and stroke nodes.
2023-08-07 17:53:49 -04:00
Matthias Clasen
02a4e5a457 Add compare tests for fill and stroke nodes 2023-08-07 13:02:57 -04:00
Matthias Clasen
a548a91e6d Add nodeparser tests for fill and stroke nodes 2023-08-07 13:02:57 -04:00
Matthias Clasen
fc3c2e0942 gsk: Implement parsing fill and stroke nodes
Make serialization and deserialization work for stroke and
fill nodes.
2023-08-07 13:02:57 -04:00
Matthias Clasen
60e07335a1 demos: Add stroking to the path fill demo 2023-08-07 13:02:57 -04:00
Benjamin Otte
cb6b968fb5 snapshot: Add gtk_snapshot_push_stroke()
This is the obvious GtkSnapshot API to go
along with the new stroke nodes.
2023-08-07 13:02:57 -04:00
Benjamin Otte
3aa3816125 gsk: Add GskStrokeNode
Take a rendernode as source and a GskPath and GskStroke,
and fill the area that is covered when stroking the path
with the given stroke parameters, like cairo_stroke() would.
2023-08-07 13:02:57 -04:00
Matthias Clasen
c37c29422a Add gsk_path_get_stroke_bounds
This is a helper to compute the bounds for
stroke nodes. We keep it private for now.
2023-08-07 13:02:57 -04:00
Matthias Clasen
db71c07f8f Add GskStroke
A GskStroke struct collects the parameters that are
needed for stroking a path.
2023-08-07 13:02:57 -04:00
Emmanuele Bassi
bf1b97efd3 Merge branch 'gdk-macos-depth-fix' into 'main'
gdk: Fix compilation on macos

See merge request GNOME/gtk!6208
2023-08-07 14:46:47 +00:00
Xi Ruoyao
4d7277f72c print: Revert "Start sorting apart includes" change for gtkprinteroptionprivate.h
The print backends needs the functions in gtkprinteroptionprivate.h to
be exported.

Fixes #6003.
2023-08-07 22:29:10 +08:00
Matthias Clasen
3296f01edf Merge branch 'path-fixes' into 'main'
Fix path point preconditions

See merge request GNOME/gtk!6251
2023-08-07 13:00:18 +00:00
Matthias Clasen
dbcbf0523b Add tests for GskPathPoint
As always, untested code doesn't work...
2023-08-07 08:33:05 -04:00
Matthias Clasen
888abb6f24 path: Make get_closest_point work
We weren't setting point->path. Oops.
Good to have tests.
2023-08-07 08:33:05 -04:00
Matthias Clasen
9b916b329a pathpoint: Implement get_tangent fully
We were not taking the direction into account
at all.
2023-08-07 08:33:05 -04:00
Matthias Clasen
eb3ada6386 Fix path point preconditions
These were inverted and did not work. Oops.
2023-08-07 08:32:50 -04:00
Daniel Boles
eebe370e0a Add API to programmatically build ShortcutsWindow
and friends. This used to work OK via Container.add() but stopped
working in GTK4. While we have some ways left to TRY to add children
(via GtkWindow and Box), those don't work and result in broken layout
and assertion failures. Add basic API that can allow this to work again.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/6001
2023-08-07 11:37:10 +01:00
Matthias Clasen
2a725b658b Merge branch 'path-for-merge-2' into 'main'
GskPath for merge, part 0

See merge request GNOME/gtk!6247
2023-08-07 01:31:37 +00:00
Benjamin Otte
97f605f811 demos: Add a simple demo filling a path 2023-08-06 21:01:11 -04:00
Benjamin Otte
4e7d578881 rendernode: Implement fast-path for solid fills
They happen so often that it's worth avoiding the clip + paint path
there.
2023-08-06 21:01:11 -04:00
Benjamin Otte
438d936f57 gtk: Add gtk_snapshot_push_fill()
This is the obvious GtkSnapshot API to go
along with the new fill nodes.
2023-08-06 21:01:11 -04:00
Benjamin Otte
fc4a464b47 gsk: Add GskFillNode
Take a rendernode as source and a GskPath and fill
the region inside the path with the source, just like
cairo_fill() would.
2023-08-06 21:01:11 -04:00
Matthias Clasen
785b9541f6 gsk: Add tests for GskPath 2023-08-06 21:01:11 -04:00
Matthias Clasen
a4cbabb80f gsk: Add tests for GskCurve 2023-08-06 20:48:09 -04:00
Matthias Clasen
1b5dfcba7e gsk: Add GskPath
This commit adds the basic infrastructure for paths.
The public APIs consists of GskPath, GskPathPoint and
GskPathBuilder.

GskPath is a data structure for paths that consists
of contours, which in turn might contain Bézier curves.
The Bezier data structure is inspired by Skia, with separate
arrays for points and operations. One advantage of this
arrangement is that start and end points are shared
between adjacent curves.

A GskPathPoint represents a point on a path, which can
be queried for various properties.

GskPathBuilder is an auxiliary builder object for paths.
2023-08-06 20:48:09 -04:00
Matthias Clasen
ba41edf531 gsk: Add tests for GskBoundingBox 2023-08-06 17:16:46 -04:00
Matthias Clasen
bf3892caed gsk: Add a bounding box type
graphene_rect_t is not well-suited for this purpose,
since you end up with floating-point precision problems
at the upper bound (x + width, y + height).
2023-08-06 17:16:30 -04:00
Benjamin Otte
1e6a95aa1b Merge branch 'grid-scroll-crash' into 'main'
gtkgridview: Fix crash on scroll to 0 sized tile

Closes #5945

See merge request GNOME/gtk!6228
2023-08-06 17:56:57 +00:00
tszymanski
70a9d08e21 gtkgridview: return empty area for empty tiles during scroll 2023-08-06 10:26:32 -07:00
Piotr Drąg
7511d4e281 Update Polish translation 2023-08-06 14:22:51 +02:00
Asier Sarasua Garmendia
53ea97decb Update Basque translation 2023-08-06 07:20:22 +00:00
Matthias Clasen
28190ded71 Merge branch 'matthiasc/for-main' into 'main'
Update tests

See merge request GNOME/gtk!6244
2023-08-05 19:32:56 +00:00
Matthias Clasen
8083cb0e47 Merge branch 'smaller-than' into 'main'
section-accessibility: Close tag

See merge request GNOME/gtk!6243
2023-08-05 19:21:44 +00:00
Matthias Clasen
d241ec4f3e Update tests 2023-08-05 15:02:00 -04:00
Hari Rana
544320a961 section-accessibility: Close tag 2023-08-05 12:25:23 -04:00
Florentina Musat
ee5a95ba24 Update Romanian translation 2023-08-05 15:54:45 +00:00
Jordi Mas
232260b86b Update Catalan translation 2023-08-05 17:30:28 +02:00
Matthias Clasen
857f50649c Merge branch 'microoptimize-label-wfh' into 'main'
Microoptimize GtkLabel width-for-height computation

See merge request GNOME/gtk!6219
2023-08-05 15:15:55 +00:00
Matthias Clasen
a39d9d60a7 Merge branch 'bilelmoussaoui/tree-deprecated' into 'main'
gi: Mark more GtkTreeModel types as deprecated

See merge request GNOME/gtk!6241
2023-08-05 12:09:25 +00:00
Bilal Elmoussaoui
5f9bc97291 gi: Mark more GtkTreeModel types as deprecated
They show up in rust docs as not deprecated without this
2023-08-05 13:10:52 +02:00
Matthias Clasen
01b3b096fe Post-release version bump 2023-08-05 05:42:32 -04:00
Matthias Clasen
fef69881a7 4.12.0 2023-08-05 00:01:26 -04:00
Matthias Clasen
be0eaa64ed Merge branch 'matthiasc/for-main' into 'main'
build: Rename docs build options

See merge request GNOME/gtk!6239
2023-08-05 03:37:05 +00:00
Matthias Clasen
62087b1ab5 README: Some updates 2023-08-04 22:30:13 -04:00
Matthias Clasen
6af55a31d7 build: Rename docs build options
Rename gtk_doc to documentation and update_screenshots
to screenshots. The old names are still accepted.
2023-08-04 22:30:13 -04:00
Matthias Clasen
8e57818a52 Merge branch 'wip/otte/scroll-to' into 'main'
a scroll_to() for list widgets

See merge request GNOME/gtk!6227
2023-08-05 02:20:38 +00:00
Benjamin Otte
a447c439f4 inspector: Use scroll_to() in the object tree search 2023-08-05 03:51:55 +02:00
Benjamin Otte
2120ef38d9 columnview: Implement gtk_column_view_scroll_to()
It's basically the listview version, but with an (optional) column to do
cell-based scrolling/focusing.
2023-08-05 03:51:54 +02:00
Matthias Clasen
6077ea4f48 Add gtk_grid_view_scroll_to
This does the same as gtk_list_view_scroll_to, just
for a grid view.
2023-08-05 03:51:53 +02:00
Benjamin Otte
c278c78378 gtk-demo: Make arrowing in suggestionentry scroll the dropdown 2023-08-05 03:51:53 +02:00
Benjamin Otte
b64dc75e3a listview: Implement gtk_list_view_scroll_to()
This adds a flags enum so we can also do select/focus at the same time.

It's implemented in GtkListBase, so adding support forgridview should be
easy.
2023-08-05 03:51:53 +02:00
Benjamin Otte
447c07bf5e viewport: Use gtk_viewport_scroll_to() for focus scrolling 2023-08-05 03:51:51 +02:00
Benjamin Otte
2a5f1dc6c7 viewport: Add gtk_viewport_scroll_to()
First implementation of GtkScrollInfo
2023-08-05 03:51:50 +02:00
Benjamin Otte
105be5a457 gtk: Add GtkScrollInfo
This struct carries information about scrolling a scrollable, so that
individual scrollables can share this struct for their scrolling APIs.

For now, there's not much information here, we're still trying to cook
up an API that works well.
2023-08-05 03:51:50 +02:00
Matthias Clasen
0b6b6b0984 Merge branch 'format' into 'main'
adjustment: Properly use <code> tag

See merge request GNOME/gtk!6238
2023-08-05 00:20:21 +00:00
Hari Rana
a0429c8218 adjustment: Properly use <code> tag 2023-08-04 19:51:22 -04:00
Yuri Chornoivan
56649007d0 Update Ukrainian translation 2023-08-04 19:43:39 +00:00
Matthias Clasen
42d0590d80 Merge branch 'more-deprecation-cleanup' into 'main'
Drop old style deprecation handling

See merge request GNOME/gtk!6237
2023-08-04 14:57:30 +00:00
Matthias Clasen
ce4fbcef8e examples: More deprecation cleanup
Remove GtkDialog use from bloatpad.
2023-08-04 09:47:49 -04:00
Matthias Clasen
7c8171f069 Drop old style deprecation handling
We don't use this anymore.
2023-08-04 08:38:55 -04:00
Matthias Clasen
33fe93d9f2 examples: Deprecation cleanup 2023-08-04 08:38:00 -04:00
Matthias Clasen
a8d092f978 Merge branch 'matthiasc/for-main' into 'main'
wayland: Fix gtk-shell protocol handling

See merge request GNOME/gtk!6236
2023-08-04 12:34:30 +00:00
Matthias Clasen
645043d5a2 wayland: Fix gtk-shell protocol handling
The protocol spec isn't clear about the relationship
between the capability enum and the uint in the capability
event.

Fix things to use the same relationship as mutter.
2023-08-04 07:57:33 -04:00
Matthias Clasen
c6693b7fb7 Merge branch 'matthiasc/for-main' into 'main'
build: Set the default visibility

See merge request GNOME/gtk!6235
2023-08-04 11:48:10 +00:00
Matthias Clasen
5c4bb1f93b build: Set the default visibility
While working on deprecation cleanups, I noticed
that removing GDK_DEPRECATED_IN... from headers
does not have the effect of making the symbols
disappear, since we were forgetting to set the
default visibility to hidden.
2023-08-04 06:15:13 -04:00
Matthias Clasen
d05628c66a testsuite: Don't rely on default visibility
The builder test was relying on default visiblity
for non-static functions. Make it explicit that we
want to export these functions, so the test keeps
working when we change the default visibility.
2023-08-04 06:15:13 -04:00
Matthias Clasen
0e2db8090b Merge branch 'deprecation-cleanups' into 'main'
gtk-demo: Deprecation cleanup

See merge request GNOME/gtk!6233
2023-08-04 02:34:10 +00:00
Matthias Clasen
b4ab398e0d constraint-editor: Deprecation cleanup
Drop all uses of deprecated API.
2023-08-03 22:15:27 -04:00
Matthias Clasen
26018107d6 print-editor: Deprecation cleanup
Drop all uses of deprecated API.
2023-08-03 22:15:27 -04:00
Matthias Clasen
3e066a0a15 gtk-demo: Deprecation cleanup
Remove many uses of deprecated api in gtk4-demo.

Remaining uses are demos of wholly deprecated objects
that will just be dropped in GTK5.
2023-08-03 22:15:27 -04:00
Matthias Clasen
23222a97fc Merge branch 'wip/alice/center-layout' into 'main'
centerlayout: Fix child sizing

See merge request GNOME/gtk!6234
2023-08-04 01:10:09 +00:00
Alice Mikhaylenko
d4a5872fb0 centerlayout: Invert :shrink-center-last
Make what it does match its name.
2023-08-04 04:34:48 +04:00
Alice Mikhaylenko
24714cb91c centerlayout: Fix child sizing
For some reason the start/end child size is restricted to
(width - title width) / 2. This is generally unexpected, so stop doing
that.
2023-08-04 02:00:28 +04:00
Artur So
b51d8a22ef Update Russian translation 2023-08-03 16:06:21 +00:00
Matthias Clasen
aa0afab960 Merge branch 'matthiasc/for-main' into 'main'
gtk-demo: Use GtkBuilderScope more

See merge request GNOME/gtk!6232
2023-08-03 14:39:56 +00:00
Matthias Clasen
111269019f Merge branch 'bilelmoussaoui/gi' into 'main'
gtk: Add missing since annotations

See merge request GNOME/gtk!6231
2023-08-03 13:43:27 +00:00
Matthias Clasen
f0d974c6f5 AUTHORS: Some updates 2023-08-02 20:14:02 +00:00
Matthias Clasen
d30adc48d4 RELEASE-HOWTO: Some updates 2023-08-02 20:07:00 +00:00
Matthias Clasen
40d3b30770 gtk-demo: Use GtkBuilderScope more
Under circumstances I haven't fully tracked down,
these demos refuse to run, failing to locate their
callbacks. So use the machinery we have, and set up
a GtkBuilderCScope for each of the problematic cases.
2023-08-02 19:49:03 +00:00
Bilal Elmoussaoui
2e7291d0e7 gtk: Add missing since annotations
Follow up of 7f946eff01
2023-08-02 18:19:23 +00:00
Matthias Clasen
48d1dfd195 Merge branch 'gdk-win32-cleanup' into 'main'
GdkWin32 cleanup

See merge request GNOME/gtk!6230
2023-08-02 17:09:41 +00:00
Matthias Clasen
caeccfd2da Merge branch 'cetner-layout-compute-expand' into 'main'
Fix computing expand in GtkCenterLayout

See merge request GNOME/gtk!6229
2023-08-02 16:24:46 +00:00
Luca Bacci
a9082fa5fa GdkWin32: Remove unused members from GdkWin32Surface 2023-08-02 18:08:31 +02:00
Luca Bacci
eb10af0dac GdkWin32: No need to set the active keyboard layout
It's already done as part of GdkWin32Keymap initialization
(in update_keymap ())
2023-08-02 18:08:31 +02:00
Luca Bacci
3387dc8ec3 GdkWin32: Remove gdk_synchronize 2023-08-02 18:08:10 +02:00
Matthias Clasen
f663617724 Merge branch 'ebassi/hint-font-lodpi' into 'main'
Enable subpixel positioning for text only on high scaling factors

See merge request GNOME/gtk!6190
2023-08-02 15:56:08 +00:00
Sergey Bugaev
b42760da4d centerlayout: Fix computing expand
It was calling get_hexpand () / get_vexpand (), which only get whether
the expand properties are set on the widget itself. Use
compute_expand (), which properly walks the widget tree and finds
whether exapnd is set on the widget or any of its descendants.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-08-02 18:43:45 +03:00
Matthias Clasen
ea72e7e5b3 reftests: Fix one reftest
The xalign property of GtkLabel defaults to 0.5,
meaning that the contents will be centered, which
is not what GtkInscription does.
2023-08-02 16:32:40 +01:00
Matthias Clasen
a51003661e label: Another tweak to wrapping handling
This fixes a few reftests that were failing after
the previous change because they ended up with x == -1.
2023-08-02 16:32:15 +01:00
tszymanski
a483fb2d96 gtkgridview: Fix crash on scroll to 0 sized tile
No longer crashes with my listview_clocks demo or in real scrolling in
my application. "GtkGridView failed to scroll to given position. Ignoring..."
warnings are printed when it would have crashed.

Sometimes the scroll jumps incorrectly when it doesn't crash, but that's
a separate bug but is probably related to whatever is causing this
crash.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/5945, at least in
terms of the immediate crash.
2023-08-01 22:17:54 -07:00
Matthias Clasen
f13c8a3cb4 Merge branch 'radioactiveman-main-patch-77429' into 'main'
docs: Fix typo

See merge request GNOME/gtk!6226
2023-08-02 03:25:19 +00:00
Thomas Lange
51e617daf3 docs: Fix typo 2023-08-01 23:51:34 +00:00
Matthias Clasen
f9f96637d7 Merge branch 'wip/sophie-h/ask' into 'main'
filelauncher: Add 'ask' property

Closes #5942

See merge request GNOME/gtk!6225
2023-08-01 19:52:51 +00:00
Sophie Herold
1df5857b07 filelauncher: Add 'always-ask' property
The 'ask' property is part of the portal. It forces always asking
the user with which app to open a file.

Closes #5942
2023-08-01 20:39:20 +02:00
Danial Behzadi
d637398ab0 Update Persian translation 2023-08-01 05:53:37 +00:00
Ekaterine Papava
20ead71c0b Update Georgian translation 2023-08-01 04:05:01 +00:00
Benjamin Otte
abcfa21c12 Merge branch 'wip/otte/vulkan-for-main' into 'main'
inspector: Make the measure map buttons work again

Closes #5992

See merge request GNOME/gtk!6223
2023-07-31 22:52:46 +00:00
Benjamin Otte
424c4b4150 inspector: Make the measure map buttons work again
The show/hide => set_visible() cleanups had broken things.

Fixes #5992
2023-08-01 00:14:53 +02:00
Benjamin Otte
5d18ea621d Merge branch 'wip/otte/vulkan-for-main' into 'main'
vulkan: Remove unused variable

See merge request GNOME/gtk!6222
2023-07-31 15:14:37 +00:00
Benjamin Otte
e00e6f3d5d vulkan: Clear Cairo surfaces on upload
The memory isn't guaranteed to be all zeroes and we don't want glitches.
2023-07-31 16:51:03 +02:00
Benjamin Otte
e98ae233fc vulkan: Fix a memleak 2023-07-31 16:51:03 +02:00
Benjamin Otte
2ad11e12d4 vulkan: Plug a memleak
Yay, we no longer leak swapchain images
2023-07-31 16:51:03 +02:00
Benjamin Otte
3f16f7e0d4 rendernode-tool: Add another magic format
Make .svg use the Cairo renderer to save to an SVG file.

It's useful when comparing rendering behavior and times with
web browsers (as long as one is aware that browsers build a full
DOM tree out of those SVGs).
2023-07-31 16:51:03 +02:00
Benjamin Otte
166777dd55 rendernode-tool: Move code
No functional changes yet.
2023-07-31 16:51:03 +02:00
Benjamin Otte
c8f385e3bc vulkancontext: Do proper refcounting
- fix a memleak
- call unref() instead of new()
- remove idle handler on dispose

What was I doing when I wrote the pipeline cache code?
2023-07-31 16:51:03 +02:00
Benjamin Otte
89b4f12b38 vulkan: Plug a memleak 2023-07-31 16:51:03 +02:00
Benjamin Otte
ae509406f1 memorytexture: Add a check
Sophie Herold was running into this problem while coding, so let's help
people by catching it early.
2023-07-31 16:51:03 +02:00
Benjamin Otte
1aa7f18b23 vulkan: Remove unused variable
It's only used when printing debug stuff. Debug stuff is not that
important.
2023-07-31 16:51:03 +02:00
Benjamin Otte
cf39c80fe2 docs: Update for recent rendernode-tool changes 2023-07-31 16:51:03 +02:00
Danial Behzadi
24fe66a5f3 Update Persian translation 2023-07-30 23:15:41 +00:00
Balázs Úr
51b786b799 Update Hungarian translation 2023-07-30 20:52:37 +00:00
Matthias Clasen
9685030632 Merge branch 'gtk-wip/inactive-state' into 'main'
gtk: Add suspended window state

See merge request GNOME/gtk!6221
2023-07-30 11:39:49 +00:00
Emmanuele Bassi
09be7f65d5 Add a single test runner
Running the whole test suite is not fun, and the magic incantations for
running a specific backend are too complicated to remember.
2023-07-30 13:29:36 +03:00
Emmanuele Bassi
2f4d931d0d label: Let Pango align the layout
Just like GtkInscription does since commit 883011f2. The layout offsets
are maintained as floats, and only converted to integers when exposing
them to callers.
2023-07-30 13:26:27 +03:00
Emmanuele Bassi
61df8d941b Fix indentation in GtkInscription 2023-07-30 13:25:50 +03:00
Matthias Clasen
327c93066d build: Don't require bleeding-edge wayland-protocols
The 1.32 wayland-protocols release is not in distribution
builds yet, so a hard dependency on it is not helpful.
2023-07-30 11:40:09 +03:00
Jonas Ådahl
7f946eff01 gtk: Add suspended window state
This is implemented using a new xdg_toplevel `suspended` state, and is
meant for allowing applications to know when they can stop doing
unnecessary work and thus save power.

In the other backends, the `suspended` state is set at the same time as
`minimized` as it's the closest there is to traditional windowing
systems.
2023-07-30 11:40:09 +03:00
Benjamin Otte
03a8b9cf17 Merge branch 'no-list-items' into 'main'
listitemmanager: Handle null roots in get_nearest_tile

Closes #5970

See merge request GNOME/gtk!6220
2023-07-29 23:15:13 +00:00
Emmanuele Bassi
ba89a22a4d Enable subpixel positioning for text only on high scaling factors
With our current font rendering stack, subpixel positioning simply does
not look good on non-HiDPI displays compared to font hinting.

While we have a setting as a way to restore font hinting, it's fairly
clunky to use with sandboxed applications, since it requires injecting a
settings.ini file in every application's configuration directory, or
adding the user's own configuration directory into the sandbox.

As a workaround, we can check the scaling factor used by GTK, and only
enable subpixel positioning if the factor is greater than one.
2023-07-29 11:14:57 +03:00
tszymanski
657c018242 listitemmanager: Handle null roots in get_nearest_tile
Rubberbanding still fails with "No item" warnings, but it no longer
crashes.

Closes #5970
2023-07-28 19:12:46 -07:00
Danial Behzadi
83db8e41a6 Update Persian translation 2023-07-29 01:58:52 +00:00
Yuri Chornoivan
57e7112781 Update Ukrainian translation 2023-07-28 17:32:38 +00:00
Yuri Chornoivan
96f92ee207 Update Ukrainian translation 2023-07-28 17:31:22 +00:00
Sergey Bugaev
d27e7e0180 label: Microoptimize width-for-height computation
We told Pango to limit width to mid pixels, and it returned a layout
size of text_width by text_height; text_width can be considerably
smaller than mid. If the layout fits, we know that it fits at
text_width, so set max to that. This lets us skip many iterations in a
typical case.
2023-07-28 18:42:17 +03:00
Matthias Clasen
5c8bd49383 Merge branch 'matthiasc/for-main' into 'main'
glyph cache: Add debug output

See merge request GNOME/gtk!6163
2023-07-28 08:51:14 +00:00
Matthias Clasen
e82bdd8c0d Merge branch 'dboles/issue5946' into 'main'
MenuSectionBox: use-markup on labels of submenus

Closes #5946

See merge request GNOME/gtk!6209
2023-07-28 08:47:33 +00:00
Yosef Or Boczko
72f52751c2 Update Hebrew translation 2023-07-28 07:13:47 +00:00
Matthias Clasen
98269a29b1 Merge branch 'fix-issue-5775-gtk4' into 'main'
GtkApplicationImplDBus: Cancel DBus method calls on shutdown

Closes #5775

See merge request GNOME/gtk!6181
2023-07-28 07:11:52 +00:00
Matthias Clasen
8bb968bc01 Merge branch 'dboles/range_highlight_with_page_size' into 'main'
Range: Fix hilight not drawn to value if page-size

Closes #5976

See merge request GNOME/gtk!6206
2023-07-28 06:13:27 +00:00
Matthias Clasen
c61313cbfe build: Check for objcopy options
Check that objcopy understands the --set-section-alignment
option that we are now using.
2023-07-28 09:06:14 +03:00
Matthias Clasen
96145ae8ed tools: Update the docs
Mention that the render command can produce png or tiff
images.
2023-07-28 09:06:14 +03:00
Benjamin Otte
1f848bf9fd rendernode-tool: Save to tiff
If the save filename ends in .tiff, save to tiff instead.

For now this is a sneaky autodetect feature, not sure if/how to make it
more explicit.
2023-07-28 09:06:14 +03:00
Matthias Clasen
7a8a27bd60 ci: Mark the clipboard test as flaky
Lets give up on trying to run this successfully
in ci. More green in more places!
2023-07-28 09:06:14 +03:00
Matthias Clasen
3e9c47e6f7 glyph cache: Add debug output
Show the size of data uploaded per glyph.
2023-07-28 09:06:14 +03:00
Matthias Clasen
69cf0a75c5 gdk: Build fix 2023-07-28 09:06:14 +03:00
Matthias Clasen
a8d3aa133c Merge branch 'wip/chergert/fix-objcopy' into 'main'
demo: use --set-section-alignment when using objcopy

See merge request GNOME/gtk!6218
2023-07-28 06:01:43 +00:00
Ekaterine Papava
e1d4385026 Update Georgian translation 2023-07-28 04:48:23 +00:00
Christian Hergert
7cc29ce236 demo: use --set-section-alignment when using objcopy
If we don't set the alignment then there is a chance that it ends up
commonly on a 4-byte boundary and GResources will have to malloc/memcpy
the static data.

With --set-section-alignment (which takes a byte offset not ^2) available
in objcopy >= 2.33 we ensure that expectation is met.
2023-07-27 17:09:43 -07:00
Matthias Clasen
f998505e27 Merge branch 'zbrown/fix-inspector' into 'main'
inspector: drop overlooked reference

See merge request GNOME/gtk!6215
2023-07-27 20:55:24 +00:00
Matthias Clasen
64f50b33e4 Merge branch 'wip/chergert/fix-inspector' into 'main'
inspector: fix runtime errors with missing widgets

Closes #5986

See merge request GNOME/gtk!6217
2023-07-26 20:16:35 +00:00
Christian Hergert
bc20af2741 inspector: fix runtime errors with missing widgets
Fixes #5986
2023-07-26 12:15:21 -07:00
Matthias Clasen
25f61dd5d5 Merge branch 'alatiera/doc-links' into 'main'
docs: getting_started: Update links to some guides

See merge request GNOME/gtk!6216
2023-07-26 12:55:31 +00:00
Jordan Petridis
0e5f2cd6f6 docs: getting_started: Update links to some guides 2023-07-26 15:37:13 +03:00
Zander Brown
5aef534871 inspector: drop overlooked reference
Fix: 0751f59ee8
2023-07-26 06:19:22 +01:00
Benjamin Otte
f0f7613adb Merge branch 'zbrown/pending' into 'main'
filterlistmodel: emit ::notify::pending after ::items-changed

See merge request GNOME/gtk!6213
2023-07-26 04:39:13 +00:00
Zander Brown
72a1bd64e6 filterlistmodel: emit ::notify::pending after ::items-changed 2023-07-26 05:03:28 +01:00
Balázs Meskó
bd1b3447c4 Update Hungarian translation
(cherry picked from commit 7a3a82749b)
2023-07-25 23:43:12 +00:00
Matthias Clasen
6653f2b4c3 Merge branch 'fix-file-dialog-assert' into 'main'
filedialog: Don't assert too much

Closes #5975

See merge request GNOME/gtk!6207
2023-07-24 21:52:57 +00:00
Matthias Clasen
b00b0902ca Merge branch 'pgriffis/fix-no-introspection-build' into 'main'
build: Fix building with introspection disabled and testsuite enabled

See merge request GNOME/gtk!6210
2023-07-24 21:11:17 +00:00
Patrick Griffis
59941930f7 build: Fix building with introspection disabled and testsuite enabled
The headless tests are written in Python and need g-i.
2023-07-23 19:30:30 -05:00
Jayson Reis
aa888c0b3f gdk: Remove a leftover reference to the renamed variable prefers_high_depth 2023-07-23 23:13:47 +02:00
Sébastien Le Roux
c12a09d24e MenuSectionBox: use-markup on labels of submenus
To use markup label in menu items, when the menu item has a submenu.

Small additions to 'gtk/gtkmenusectionbox.c' to set the markup attribute
for menu items with submenus.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5946
2023-07-23 20:32:54 +01:00
Matthias Clasen
79721d64ad filedialog: Don't assert too much
The GtkFileDialog code was asserting that
we get exactly one file back. But the function
is nullable anyway, so lets just return NULL
if we don't have a file.

Fixes: #5975
2023-07-23 12:33:47 -04:00
Daniel Boles
62e68f72d6 Range: Fix hilight not drawn to value if page-size
If we have a non-zero Adjustment:page-size, the actual amount we draw is
reduced by that page-size. We account for this in various places, but we
did not when deciding how far to allocate the highlight widget, so we
were drawing the highlight not far enough, falling short of the value.
This fixes by subtracting the page-size from the drawn range here too.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/5976
2023-07-23 11:11:40 +01:00
Benjamin Otte
0b1bcf8bee Merge branch 'wip/otte/vulkan-for-main' into 'main'
tools: No need for --force when specifying filename

See merge request GNOME/gtk!6205
2023-07-22 21:48:29 +00:00
Matthias Clasen
477fb8fdfb Merge branch 'drop-touchscreen-debug' into 'main'
Drop GTK_DEBUG_TOUCHSCREEN

Closes #5893

See merge request GNOME/gtk!6204
2023-07-22 21:48:14 +00:00
Benjamin Otte
1bd820fc60 vulkan: Clean up renderpass/offscreen creation
Instead of scale and whatnot, pass:
1. The image size
2. The viewport to map to that image size
and compute everything else from there.

In particular, we set the Vulkan viewport to the image dimensions
instead of the viewport size.

All of this makes things a lot simpler while keeping the required
functionality.
2023-07-22 23:30:15 +02:00
Benjamin Otte
a4247f1358 vulkan: Plug a memleak
This one was introduced in 4d9e7d30b0.
2023-07-22 23:30:15 +02:00
Benjamin Otte
00b5df6b06 vulkan: Plug a memleak
This one was introduced in cd84f5a56e.
2023-07-22 23:30:15 +02:00
Benjamin Otte
1e75fc35c8 tools: No need for --force when specifying filename
If people specify the filename, they should know what they're doing.

If they don't, abort if the guessed filename already exists and insist
on the user explicitly giving it.
2023-07-22 23:30:15 +02:00
Matthias Clasen
0751f59ee8 Drop GTK_DEBUG_TOUCHSCREEN
This flag was never doing much, and is only raising
the wrong expectations. Remove it.

Fixes: #5893
2023-07-22 16:43:20 -04:00
Matthias Clasen
b5b797b0aa Merge branch 'textview-keynav-backspace' into 'main'
textview: Match entry behavior for backspace

Closes #3417

See merge request GNOME/gtk!6203
2023-07-22 15:45:42 +00:00
Matthias Clasen
ddfe9f15af Merge branch 'fix-issue-5965' into 'main'
gtktextview: return early when resetting gesture / event controller

Closes #5965

See merge request GNOME/gtk!6200
2023-07-22 13:51:32 +00:00
Matthias Clasen
9929726eb2 textview: Match entry behavior for backspace
As pointed out in #3417, there is a long-standing
difference in how GtkEntry and GtkTextView treat
Ctrl-Shift-Backspace (and other variations): GtkEntry
always operates on the selection first, if it exists.
GtkTextView only handled plain Backspace that way, and
ignores the selection for other variations.

There is no good reason for this difference, so just
remove it and make GtkTextView behave the same as
GtkEntry.

Fixes: #3417
2023-07-22 09:40:17 -04:00
Ekaterine Papava
1aa6e721ae Update Georgian translation 2023-07-22 13:24:50 +00:00
Ngọc Quân Trần
87d2ce1332 Update Vietnamese translation 2023-07-22 08:54:03 +00:00
Daniel Boles
6260a33e8e Merge branch 'dboles/PopoverMenu-png' into 'main'
Fix broken image menu.png in Gtk.PopoverMenu intro

See merge request GNOME/gtk!6187
2023-07-22 08:43:25 +00:00
Daniel Boles
2024913cc2 Merge branch 'dboles/for-main' into 'main'
tools: Replace references to GTK+ with GTK no plus

See merge request GNOME/gtk!6199
2023-07-22 08:43:06 +00:00
Ngọc Quân Trần
0978a794ac Update Vietnamese translation
(cherry picked from commit e944cd8916)
2023-07-22 08:16:29 +00:00
Benjamin Otte
da51c90d5c Merge branch 'wip/otte/vulkan-for-main' into 'main'
gsk: Add gskrectprivate.h

See merge request GNOME/gtk!6201
2023-07-22 02:43:11 +00:00
Benjamin Otte
b1b8a98568 gdk: Add function to query alpha format for depth
It's meant to be used in renderers.
2023-07-22 01:33:44 +02:00
Benjamin Otte
4a8122f685 gdk: Make A8 and A16 formats premultiplied
The relevant question here is about details, because we have to choose
if we declare alpha-only formats as having their (nonexistant) color
channels premultiplied or not, so that the code paths using them can do
the right thing.

Because we are premultiplied by default, it makes sense to treat alpha
like that, because then the alpha-only code doesn't need to do
workarounds for straight alpha.

Where this is relevant of course is when expanding the alpha channel
into color channels, where we want to end up with white.
So make sure we do color = alpha there instead of color = 1 like we did
before.
2023-07-22 01:33:44 +02:00
Benjamin Otte
7a58439977 memoryformat: Copy idea from tiff code
The static assertion makes sure that newer formats get added.
2023-07-22 01:33:44 +02:00
Benjamin Otte
27fbdcbecb gdk: Add A16_FLOAT and A32_FLOAT formats
We need them for mask-only textures.

For tiffs, we convert the formats to RGBA (the idea that tiff can save
everything needs to be buried I guess) as tiffs can't do alpha-only.
2023-07-22 01:33:44 +02:00
Benjamin Otte
5bd13ccf15 vulkan: Remove unused struct 2023-07-22 01:33:44 +02:00
Benjamin Otte
d30a9e7fa9 gsk: Add gskrectprivate.h
Add a bunch of inline functions for graphene_rectangle_t.

We use those quite extensively in tight loops so making them as fast as
possible via inlining has massive benefits.

The current render-heavy benchmark I am playing (th paris-30k in node-editor)
went from 49fps to 85fps on my AMD.
2023-07-22 01:33:44 +02:00
Benjamin Otte
6e75e26a0c vulkan: Add new error code 2023-07-22 01:33:44 +02:00
Efstathios Iosifidis
6562338502 Update Greek translation
(cherry picked from commit 9d633773b0)
2023-07-21 22:29:53 +00:00
Luca Bacci
cd5cdad31d GtkApplicationImplDBus: Cancel DBus method calls on shutdown
We do that for method calls where we pass a valid GAsyncReadyCallback

Fixes #5775
2023-07-21 16:49:22 +02:00
Luca Bacci
5da01ec4af gtktextview: return early when resetting gesture / event controller
Fixes #5965
2023-07-21 15:33:45 +02:00
Daniel Boles
8da96b9353 tools: Replace references to GTK+ with GTK no plus 2023-07-21 12:05:25 +01:00
Matthias Clasen
e042db9348 Merge branch 'render-tool' into 'main'
Add gtk4-render-tool

See merge request GNOME/gtk!6197
2023-07-21 10:56:14 +00:00
Matthias Clasen
601011ccc0 Add a gtk4-rendernode-tool
This is meant to work with serialized render nodes.
2023-07-21 06:26:11 -04:00
Daniel Boles
5958abae1d Merge branch 'dboles/for-main' into 'main'
ShortcutController: Add links to docs, fix heading

See merge request GNOME/gtk!6198
2023-07-21 09:35:30 +00:00
Daniel Boles
a056063395 ShortcutController: Add links to docs, fix heading
to be "as GtkBuildable", not "as a GtkBuildable", as no other file uses
the latter.
2023-07-21 10:01:56 +01:00
Matthias Clasen
537669e2b0 Merge branch 'wip/kabus/calendar-select-signal' into 'main'
gtk/calendar: Avoid emision of day-selected signal from nav buttons

Closes #5769

See merge request GNOME/gtk!6196
2023-07-21 03:38:58 +00:00
Khalid Abu Shawarib
216a368f22 gtk/calendar: Avoid emision of day-selected signal from nav buttons 2023-07-21 03:38:58 +00:00
Matthias Clasen
fd4da47125 gdk: Drop unnecessary conditionals
We require GLib 2.76 now.
2023-07-20 15:18:13 -04:00
Matthias Clasen
411e0c5fbd tools: Use #pragma once
We are trying to be consistent about this.
2023-07-20 15:18:13 -04:00
Matthias Clasen
e523d3a50e tools: Drop unnecessary conditionals
We require GLib 2.76 now.
2023-07-20 15:18:13 -04:00
Matthias Clasen
99d6a15049 Merge branch 'gtk-fix-issue-4990' into 'main'
Add check for large compose files

Closes #4990

See merge request GNOME/gtk!6195
2023-07-20 17:39:06 +00:00
Matthias Clasen
7fb6c04e99 Make the new compose table test work
This just copies what we do already for other
tests that check parser failures.
2023-07-20 11:48:13 -04:00
Benjamin Otte
08fd9e1f2e Merge branch 'wip/otte/vulkan-for-main' into 'main'
vulkan: Various smallish things

See merge request GNOME/gtk!6193
2023-07-19 19:51:57 +00:00
Benjamin Otte
dd641867a2 vulkan: Be more careful with supported images
Now that we can upload all these fancy formats, we need to make sure
that we actually can.
2023-07-19 21:30:35 +02:00
Benjamin Otte
2cbe89de7d memoryformat: fast-path copies of the same format
Basically, memcpy() asap if possible.

This happens a lot in Vulkan, where we gdk_memory_conert() image
data from memory textures straight into the VulkanBuffer.

And usually we support the format.
2023-07-19 21:30:35 +02:00
Benjamin Otte
4d9e7d30b0 vulkan: Add premultiply step to texture upload
When a GdkMemoryFormat is not supported natively and there's
postprocessing required, add a way to mark a VulkanImage as such via the
new postprocess flags.

Also allow texting such iamges only with new_for_upload() and detect
when that is the case and then run a postprocessing step that converts
that image to a suitable format.
This is done with a new "convert" shader/op.

This now supports all formats natively, no conversions happen on the CPU
anymore (unless the GPU is old).
2023-07-19 21:30:35 +02:00
Benjamin Otte
65224f4533 vulkan: Change fallback formats
Always fall back to a format that isn't swizzled.

That way it can be used as a target format for rendering.
2023-07-19 21:30:35 +02:00
Benjamin Otte
cd84f5a56e vulkan: Split renderpass op into 2
Add an explicit begin() and an end() op. For now, this looks like
overkill, but it allows doing renderpasses with custom ops that are not
meant to render a rendernode.

Examples for this are pre/postprocessing passes or 2-pass blur.
2023-07-19 21:30:35 +02:00
Benjamin Otte
4311d17cb1 vulkan: Don't store the renderpass
It's only used when parsing.
2023-07-19 21:30:35 +02:00
Benjamin Otte
11a0646281 vulkan: Pass rectangles where no regions are used
The API was using regions because it always had. But all the code ever
did was get the extents of the region.

So simplify everything by using rectangles everywhere.
2023-07-19 21:30:35 +02:00
Benjamin Otte
492507af11 vulkan: Stop keeping the context around
These days, we can query it with gsk_vulkan_render_get_context().

Makes quite a few functions require one less argument.
And it also makes the GskVulkanRenderPass empty. Gotta figure out what
to do with it.
2023-07-19 21:30:35 +02:00
Benjamin Otte
67a3929583 vulkan: Remove unused stuff fom renderpass
... and move it to the one place where it is used.
2023-07-19 21:30:35 +02:00
Benjamin Otte
413d3819cf vulkan: Free storage buffer when disposing render object
This caused a lot of leaked memory on the GPU when rendering textures.
(Read: inside node-editor)
2023-07-19 21:30:35 +02:00
Benjamin Otte
0f289fddf7 vulkan: Fix leaks with pipeline cache
In particular, we were leaking the actual cache and then created a new
one.
2023-07-19 21:30:35 +02:00
Benjamin Otte
92038d6b7f build: Move the glslc check into the top meson file
Put it with the other Vulkan checks, so it's easy to find.
2023-07-19 21:30:35 +02:00
Benjamin Otte
6e27579d1f vulkan: Remove the pre-compiled shaders
Instead, build-depnd on glslc to build them.

glslc is available in all important distros for a while:
  Fedora >= 28
  Ubuntu >= 23.04
  Debian >= 12
  Arch
  Opensuse >= 15.2
  msys2
are the ones I checked.

So we can depend on it and avoid having to deal with keeping spirv files
up-to-date in all commits.

It's also 700kB of data, and not updating it helps.
2023-07-19 21:30:35 +02:00
Benjamin Otte
390a104ddd ci: Include glslc for Vulkan builds 2023-07-19 21:30:29 +02:00
Luca Bacci
31727a4ec5 Add test for large compose file
See #4990
2023-07-19 17:49:05 +02:00
Luca Bacci
add197bcf7 Add check for large compose files
Fixes #4990
2023-07-19 17:47:22 +02:00
Daniel Boles
e73c4fe133 Merge branch 'dboles/theme-no-backdrop-list-view-text' into 'main'
theme: Don't dim text in backdropped list/listview

See merge request GNOME/gtk!6175
2023-07-19 13:02:28 +00:00
Benjamin Otte
2e6b7b5b78 Merge branch 'wip/otte/vulkan-for-main' into 'main'
vulkan: Make RenderOps into proper structs

See merge request GNOME/gtk!6188
2023-07-16 12:22:35 +00:00
Benjamin Otte
90e933a6aa vulkan: Rebuild the shaders
Just to be sure I didn't forget rebuilding some shader at some point.
2023-07-16 13:52:15 +02:00
Benjamin Otte
e7549f3359 vulkan: Redo barriers
We now store all the relevant state of the image inside the VulkanImage
struct, so we can delay barriers for as long as possible.

Whenever we want to use an image, we call the new
gsk_vulkan_image_transition() and it will add a barrier to the desired
state if one is necessary.
2023-07-16 13:16:43 +02:00
Benjamin Otte
fee497f9e1 vulkan: Track the current pipeline stage of images
This way, we can in theory properly transition images because we know
which stage to transition from.

IN practice this is happening in future commits.
2023-07-16 13:16:43 +02:00
Benjamin Otte
ef4930723b vulkan: Handle images in the ShaderOp
This looks more convoluted in this commit, but future commits will
hopefully make up for it.
2023-07-16 13:16:43 +02:00
Benjamin Otte
a8ff291a12 vulkan: Make clip type an enum
and add gsk_vulkan_shader_op_alloc() that sets it properly.
2023-07-16 13:16:43 +02:00
Benjamin Otte
f366ccc0b2 vulkan: Introduce GskVulkanShaderOp
It's the new base class for shaders now.

We're doing deep inheritance now, woohoo!

Also, port all the shader ops to it.
2023-07-16 13:16:43 +02:00
Benjamin Otte
ca69fd2b7a vulkan: Remove GskVulkanUploader
... and all the remaining functions still using it.

It's all unused and has been replaced by upload and download ops.

With this change, all GPU operations now go via GskVulkanOp.command()
and no more side channels exist.
2023-07-16 13:16:43 +02:00
Benjamin Otte
db2029d931 vulkan: Add GskVulkanDownloadOp
This op queues a download of an image. The image will only be available
once the commands finished executing, so it requires waiting for the
render to finish, which makes the API a bit awkward.

Included is also a download_png_op() useful for debugging.
2023-07-16 13:16:43 +02:00
Benjamin Otte
6f2fd001a0 vulkan: Properly update image layouts
The render pass ops were not updating the image's layout to the final
layout when a render pass ends.

Fix that.

Also make the layouts explicit arguments to the render pass op.
2023-07-16 13:16:43 +02:00
Benjamin Otte
3327a6ba08 vulkan: Simplify render API
Merge reset() and draw() into a single render() function.

Also clean up some naming on the way.
2023-07-16 13:16:43 +02:00
Benjamin Otte
4954e6962f vulkan: Remove the VulkanOp.upload() vfunc
It's not used anymore.
2023-07-16 13:16:43 +02:00
Benjamin Otte
93db1cc89e vulkan: Add an UploadGlyphOp
Now all the uploads have their own op.
2023-07-16 13:16:43 +02:00
Benjamin Otte
68b337d457 vulkan: Split out a function
Split out the function that uploads using a buffer, so that it can be
used with an area to only update parts of the image.

That feature is not used yet, but will be in future commits.
2023-07-16 13:16:43 +02:00
Benjamin Otte
0d5e54986a vulkan: Remove unused functions 2023-07-16 13:16:43 +02:00
Benjamin Otte
822641c161 vulkan: Merge the two upload ops
Now they both use the same upload code.
2023-07-16 13:16:43 +02:00
Benjamin Otte
385ab74922 vulkan: Merge te 2 upload ops
They are about to share a ton of code, sothey should be in the same
source file.

This commit just does the copying, no functional changes.
2023-07-16 13:16:43 +02:00
Benjamin Otte
fcf65c7caa vulkan: Fold functions into only caller
Now that the VulkanOp does begin/end of render passes, there's no need
to have a renderpass function for it anymore.
2023-07-16 13:16:43 +02:00
Benjamin Otte
ece4e59e99 tests: Reduce number of random fonts
We were clowing through all the Pango caches for no benefit.

It made the test generation stuck in fontconfig loops instead of
quickly generating tests.

So don't do that and limit the different fonts to some reasonable list
of options.
2023-07-16 13:16:43 +02:00
Benjamin Otte
6eea08ff99 vulkan: Don't merge too many drawing commands
If a command takes too long to execute, Vulkan drivers will think they
are inflooping and abort what they were doing.

For the simple color shader with smallish nodes, this happens around
10M instances, as tested with the output of
  ./tests/rendernode-create-tests 10000000 colors.node

So just limit it to way lower, so that we barely never hit it, ut still
pick a big number so this optimization stays noticable.
2023-07-16 13:16:43 +02:00
Benjamin Otte
372dcba9c9 vulkan: Simplify
The renderpassop always has a matching end op, so there is no need to
check for the end of operations and emit one manually.
2023-07-16 13:16:43 +02:00
Benjamin Otte
af817a3362 vulkan: Merge function into only caller
The renderpass reshuffling means we can move a bunch of functions now.

This is one of them.
2023-07-16 13:16:43 +02:00
Benjamin Otte
0edd7547c1 vulkan: Don't try that hard to use clear
For small regions, the optimization doesn't matter that much, so we
don't need to do lots of work on the CPU.

In particular, this should catch icons and their backgrounds (32x32),
but I was generous in selecting the number.

Gets my discrete AMD on widget-factory back to the 1900fps it had before
this optimization while making the driver clock the GPU's shader at
1.7GHz instead of the 2.1GHz it used before.
2023-07-16 13:16:43 +02:00
Benjamin Otte
ce042f7ba1 vulkan: Try really hard to use clear
Using clear avoids the shader engine (see last commit), so if we can get
pixels out of it, we should.

So we detect the overlap with the rounded corners of the clip region and
emit shaders for those, but then use Clear() for the rest.

With this in place, widget-factory on my integrated Intel TigerLake gets
a 60% performance boost.
2023-07-16 13:16:41 +02:00
Benjamin Otte
bb2cd7225e vulkan: Add a clear op
The op emits a vkCmdClearAttachments() with a given color. That can be
used with color nodes that are pixel-aligned and opaque to significantly
speed up rendering when the window background is a solid color.

However, currently this fails a bit outside of fullscreen when rounded
clip rectangles are in use to draw rounded corners.
2023-07-16 13:16:15 +02:00
Benjamin Otte
5e1fd56345 vulkan: Adapt a function
I want to use it for more operations when we can break those down to
operations on the pixels directly, and this function is what's needed
for that.
2023-07-16 12:13:00 +02:00
Benjamin Otte
c72588748b vulkan: Implement direct upload for the cairo op 2023-07-16 12:13:00 +02:00
Benjamin Otte
48e1d48e7f vulkan: Upload cairo images "directly"
Instead of using the upload vfunc and going via the code in
GskVulkanImage, copy/paste the relevant code into the command() vfunc.

This is meant to achieve multiple things:
1. Get rid of GskVulkanUploader and its own command buffer and general
   non-integration with operations.
2. Get rid of GskVulkanOp:upload()
3. Get the upload/download code machinery for GskVulkanImage and put it
   with the actual operations.

The current code can't do direct upload/download, that will follow in a
future commit.
2023-07-16 12:13:00 +02:00
Benjamin Otte
70a12c4efb vulkan: Split out a function
This is refactoring for future changes.
2023-07-16 12:13:00 +02:00
Benjamin Otte
6f76c37fed vulkan: Emit a renderpass op
... instead of doing the equivalent things manually by creating a
RenderPass and calling the relevant functions.

Now all renderpass operations are indeed stored in ops.

Also reshuffle the command emission code, because we no longer need to
emit the ops for the base renderpass.

As a result we only submit a single command buffer containing all the
render passes instead of once per render pass.
We also bind vertex buffers and descriptor sets only once now at the
start instead of once per renderpass.
2023-07-16 12:13:00 +02:00
Benjamin Otte
cc5cab65a1 vulkan: Sort the ops
Use the OpClass.stage to order operations:

1. Put upload ops first
   This way we can ensure they are executed first.
2. Move subpasses for offscreens in front of the pass using them.
2023-07-16 12:13:00 +02:00
Benjamin Otte
f3823eff87 vulkan: Store a pointer to the first op
This is not yet useful, but will be soon.
2023-07-16 12:13:00 +02:00
Benjamin Otte
13d6e691c2 vulkan: Indent verbose prints again
This feature was lost when refactoring, restore it.
2023-07-16 12:13:00 +02:00
Benjamin Otte
0bf16d738e vulkan: Rename offscreenp to renderpassop
They should be used for all renderpasses, not just offscreens.
2023-07-16 12:13:00 +02:00
Benjamin Otte
2aba50efa0 vulkan: Move the render ops to the Render
This is a massive refactoring because it collects all the renderops
of all renderpasses into one long array in the Render object.

Lots of code in there is still flaky and needs cleanup. That will
follow in further commits.

Other than that it does work fine though.
2023-07-16 12:13:00 +02:00
Benjamin Otte
63ad234391 vulkan: Batch together multiple draw calls
If multiple instances of the same op appear in order, we can emit one
vkCmdDraw() for all of them together.

So do that.
2023-07-16 12:13:00 +02:00
Benjamin Otte
21d2372396 vulkan: Unify some functions
All the ops that just execute a shader do pretty much the same stuff, so
put it all in a single function that they all call.

It's basically faking a base class for them.
2023-07-16 12:13:00 +02:00
Benjamin Otte
c0b185bee9 vulkan: Make Op->command() return the next op
This way, ops can batch themselves.

They don't dothat yet, but you know where this is going...
2023-07-16 12:13:00 +02:00
Benjamin Otte
da4a4f6a25 vulkan: Add a Stage enum
It's declaring at which stage this command should run. So far nothing is
using it, but that will follow in future commits.
2023-07-16 12:13:00 +02:00
Benjamin Otte
d7764cc6b3 vulkan: Bind descriptor sets early
Simplfies the code and doesn't change anything.
2023-07-16 12:13:00 +02:00
Benjamin Otte
a6b2bcbf24 vulkan: Remove unused arguments from Op vfuncs
Makes code a lot simpler.
2023-07-16 12:13:00 +02:00
Benjamin Otte
7fa159e94a vulkan: Cache VkRenderPasses in render object
Instead of recreating the same renderpass object in every frame and for
every offscreen, just reuse it.

Technically, we can save this per-renderer or even per-display (it
should really be cached by VkDevice), but we have no infrastructure for
that.
2023-07-16 12:13:00 +02:00
Benjamin Otte
05c9f3442c vulkan: Rename function
The function name gsk_vulkan_render_get_pipeline() had been used for
GskVulkanPipeline. Since those are gone now, we can use that name for
VkPipelines.
2023-07-16 12:13:00 +02:00
Benjamin Otte
cef87b102c vulkan: Cache framebuffer in image
Instead of recreating them every frame for every render pass, reuse the
same framebuffer.
2023-07-16 12:13:00 +02:00
Benjamin Otte
70c9521cae vulkan: Put the vertex buffer into the render object
Renderpasses get recreated every frame, but we keep render objects
around. So if we keep the vertex buffer in the render object, we can
also keep it around and just reuse it.

Also, we only need one buffer for all the render passes, which is
another bonus.

The initial buffer size is chosen at 128kB. Maximized Nautilus,
gnome-text-editor with an open file and widget-factory take ~100kB when
doing a full redraw. Other apps are between 30-50kB usually.

So I chose a value that is not too big, but catches ~90% of cases.
2023-07-16 12:13:00 +02:00
Benjamin Otte
1abcf3d48a vulkan: Add an offscreen end op
This is basically a fancy no-op for now, but reordering of ops will need
it to indicate end of offscreen commands.
2023-07-16 12:13:00 +02:00
Benjamin Otte
6363f27f95 vulkan: Don't intern strings
Interning strings is slow, especially if we can instead do direct
pointer compares.

Also refactor the pipeline lookup code a bit to make use of the
refactored code.
2023-07-16 12:13:00 +02:00
Benjamin Otte
f35053b837 vulkan: Add VulkanOp->next
Set it after creating all the ops and then use it for iterating.

Note that we cannot set it while creating the ops because the array may
be realloc()ed into a different memory region which would invalidate all
the pointers.

It currently has no use, but that will come later.

Also put the typedefs into headers in gsk/vulkan, they have nthing to do
outside that directory.
2023-07-16 12:13:00 +02:00
Benjamin Otte
d669e3ab6a vulkan: Remove all the semaphores
They aren't necessary with just one queue.
2023-07-16 12:13:00 +02:00
Benjamin Otte
5707551b79 vulkan: Remove unused stuff from render object
Neither cleanup images nor multiple renderpasses are used anymore since
both of those are now handled inside the render ops.
2023-07-16 12:13:00 +02:00
Benjamin Otte
a7c247bccd vulkan: Pass the node when setting up
Remove the function to add a node from both the GskVulkanRender and the
GskVulkanRenderPass.

That means they are both now meant to draw exactly one node.
2023-07-16 12:13:00 +02:00
Benjamin Otte
d86d4c5597 vulkan: Add infrastructure for printing ops
... and add a GSK_DEBUG=verbose setting making use of it.
2023-07-16 12:13:00 +02:00
Benjamin Otte
73f1dfc762 vulkan: Repurpose mask shader
Use if for mask nodes to do the generic source image + mask image
operation with the 4 available mask modes.
2023-07-16 12:13:00 +02:00
Benjamin Otte
a621bd066b vulkan: Remove op.get_pipeline()
It's unused now that GskVulkanPipeline is gone.
2023-07-16 12:13:00 +02:00
Benjamin Otte
143ca0e17d vulkan: Remove GskVulkanPipeline
Pipelines are handled differently now.
2023-07-16 12:13:00 +02:00
Benjamin Otte
58c318a4dc vulkan: Add gskvulkanprivate.h
It's the new place for all the common stuff.

Because the old place is about to go away.
2023-07-16 12:13:00 +02:00
Benjamin Otte
210cb3eecd vulkan: Turn push constants into an op
This removes the last remaining original op from the gskvulkanrenderpass.c,
so that file got some cleanup, too.
2023-07-16 12:13:00 +02:00
Benjamin Otte
6e6fa3daed vulkan: Make glyphs use new node ops
This is a rudimentary - but working - port.
Glyph uploads are still using the old machinery, a bunch of functions
still exist that probably aren't necessary anymore and each glyph emits
its own node.

This will need to be improved in further commits.
2023-07-16 12:13:00 +02:00
Benjamin Otte
2d6ebbb4d5 vulkan: Add a glyph shader
This shader is an updated version of the mask shader, but I want to use
the mask name for the mask node and that's a different functionality.

Also, add an operation for it and partially implement the mask node
using it, so we can test that this shader works.

Replacing the shader used for text rendering is the next step.
2023-07-16 12:12:59 +02:00
Benjamin Otte
efa4cae949 vulkan: Remove hacky function arguments
They're unused now that we removed the old render ops.
2023-07-16 12:12:36 +02:00
Benjamin Otte
5e72914c48 vulkan: Port linear gradient to new ops
This was the last user of GskVulkanOpRender, so delete that one, too.
2023-07-16 12:12:36 +02:00
Benjamin Otte
f3aab662c3 vulkan: Make border shader use new ops 2023-07-16 12:12:36 +02:00
Benjamin Otte
c598fa9147 vulkan: Add a blur op and use it
This removes the last old user of offscreens, so those functions are now
gone, too.
2023-07-16 12:12:36 +02:00
Benjamin Otte
b2296a1918 vulkan: Port inset and outset shadow to new ops 2023-07-16 12:12:36 +02:00
Benjamin Otte
594595d9cd vulkan: Port blend mode to new ops 2023-07-16 12:12:36 +02:00
Benjamin Otte
9ac36aeb42 vulkan: Add cross-fade op
The benefit here is that we can now properly cross-fade when one of
start/end is fully clipped out by just replacing it with an opacity op
for the other.

This was not possible with the old way we did things.
2023-07-16 12:12:36 +02:00
Benjamin Otte
a61fe61318 vulkan: Factor out call to opacity op
I want to reuse it for crossfades (see next commit).
2023-07-16 12:12:36 +02:00
Benjamin Otte
99085605a8 vulkan: Convert color op to new method
This is a straightforward and simple port.
2023-07-16 12:12:36 +02:00
Benjamin Otte
9da1055575 vulkan: Create pipeline differently for ops
Instead of creating a pipeline GObject, just ask for the VkPipeline.

And instead of having the Op handle it, just let the renderpass look
up/create the relevant pipeline while creating commands so that it can
insert vkCmdBindPipeline calls as-needed.
2023-07-16 12:12:36 +02:00
Benjamin Otte
b049990356 Revert "vulkan: Always render clip extents"
This reverts commit 0f184d3270.

The renderer is good enough to make use of the clip region.

Or rather: If it isn't, the renderpass should take care of that, not the
render object.
2023-07-16 12:12:36 +02:00
Benjamin Otte
8207c548cc vulkan: Combine textures and samplers again
This reverts most of commit f420c143e0
again because it turns out GPUs like combined images and samplers.

But: The one thing we don't revert is allowing the C code to select any
combination of sampler and image:
gsk_vulkan_render_get_image_descriptor() now takes a 2nd argument
specifying the sampler.

This allows the same flexibility as before, we just combine things
early.

This change was inspired by
https://developer.nvidia.com/blog/vulkan-dos-donts/
2023-07-16 12:12:36 +02:00
Benjamin Otte
83960622e3 vulkan: Store shaders in the display
Have a resource path => vkShaderModule hash table instead of doing fancy
custom objects.

A benefit is that shader modules are now shared between all renderers
and pipelines.
2023-07-16 12:12:36 +02:00
Benjamin Otte
7cf7870254 vulkan: Initialize ops differently
Instead of creating the op manually, just pass in the renderpass and
have the op created from there.

This way ops aren't really initialized anymore, they are more appended
to the queue, so instead of foo_op_init() we can just call the function
foo_op().
2023-07-16 12:12:36 +02:00
Benjamin Otte
7763e883d6 vulkan: Use VkPipeline instead of GskVulkanPipeline
This is in preparation for getting rid of GskVulkanPipelines.
2023-07-16 12:12:36 +02:00
Benjamin Otte
8bacfad171 vulkan: Use new ops for repeat nodes
The new code always uses an offscreen, even for children that are
exactly fitting texture nodes.
I would have had to write more code and didn't consider it worth it,
especially because it would have required complicating the
get_as_image() function.

This was the last node using the texture pipeline.
2023-07-16 12:12:36 +02:00
Benjamin Otte
53e7277584 vulkan: Implement fallback using new nodes
With Cairo upload and texture nodes being available, we can do that now.
2023-07-16 12:12:36 +02:00
Benjamin Otte
e43b7902be vulkan: Pass bounds to texture op
This way the node can do the normalization (and maybe stop doing it
in the future).
2023-07-16 12:12:36 +02:00
Benjamin Otte
f1d81bb7df vulkan: Add a Cairo upload node
... and use it for cairo nodes.
2023-07-16 12:12:36 +02:00
Benjamin Otte
84cf6de36d vulkan: Port opacity to new ops 2023-07-16 12:12:36 +02:00
Benjamin Otte
aaa219497b vulkan: Add offscreen and color-matrix op
.. and use them for color-matrix operations.
2023-07-16 12:12:36 +02:00
Benjamin Otte
8515224921 vulkan: Split out a function
We'll need it elsewhere soon.
2023-07-16 12:12:36 +02:00
Benjamin Otte
f53da409e5 vulkan: Add an argument to vfunc
We need this in the future.
2023-07-16 12:12:36 +02:00
Benjamin Otte
b45a2025d9 vulkan: Remove nonexisting function from header 2023-07-16 12:12:36 +02:00
Benjamin Otte
0946b0b333 vulkan: Split out a function
Making that function externally usable allows having render passes
managed externally.

Also remove a nonexisting function from the header.
2023-07-16 12:12:36 +02:00
Benjamin Otte
1d9ad55c54 vulkan: Use new ops for TextureScale nodes 2023-07-16 12:12:36 +02:00
Benjamin Otte
94a64329c2 vulkan: Add new renderops for texture rendering
Adds 2 ops:

- Upload
  Creates a new Vulkan image and uploads data into it

- Texture
  Draws a given image

These 2 ops are then used for GskTextureNodes.
2023-07-16 12:12:36 +02:00
Benjamin Otte
ba502a5009 vulkan: Split texture caching code
Instead of having one function that gets the image for the texture and
uploads it if it doesn't exist yet, make it 2 functions:

One to get the texture if it exists.
One to assign an uploaded image to the texture.

This way, we can potentially do the upload ourselves.
2023-07-16 12:12:36 +02:00
Benjamin Otte
e1d2477485 vulkan: Actually run the op_finish()
It's a no-op for all current ops, so it isn't really necessary. But
that's about to change.
2023-07-16 12:12:36 +02:00
Benjamin Otte
2fef53b154 vulkan: Pass context, not uploader
We don't need the uploader when creating the image, only when uploading.
2023-07-16 12:12:36 +02:00
Benjamin Otte
742ef96748 vulkan: Create the first real VulkanOp
Split out the scissor op into its own implementation as a proof of
concept of how ops are meant to look when they are actually working.
2023-07-16 12:12:36 +02:00
Benjamin Otte
8d928ad340 vulkan: Allocate render ops differently
Allocate the memory up front instead of passing the Op into it.

This way, we can split ops into their own source file and use
init/finish style to use them.
2023-07-16 12:12:36 +02:00
Benjamin Otte
32e123fa67 vulkan: Invent a new abstraction
GskVulkanOp is meant to be a proper abstraction of operations
the Vulkan renderer will be doing.

For now it's an atrocious clunky piece of junk wedged into the
renderpass codebase.

It's so temporary that I didn't even adjust indentation of the code.
2023-07-16 12:12:36 +02:00
Benjamin Otte
df0dd296e9 vulkan: Use the actual RenderOp type
... instead of the generic one.

This is again preparation for future changes.
2023-07-16 12:12:36 +02:00
Benjamin Otte
34e13556b4 vulkan: Use a byte array for render ops
This allows allocating only as much memory as is needed for each op.

We don't do that yet, this is still preparation.
2023-07-16 12:12:36 +02:00
Benjamin Otte
bdbb1398db vulkan: Split out a function
This is preparation for future changes.
2023-07-16 12:12:36 +02:00
Daniel Boles
9fbd582951 Fix broken image menu.png in Gtk.PopoverMenu intro
The previous menu.png appears to be just a wide transparent box. Let's
just replace it with a snip of a popover menu from the widget-factory.
2023-07-16 09:33:07 +01:00
Emmanuele Bassi
b00ca0d699 Merge branch 'dboles/EventControllerKeyModifiersDocs' into 'main'
EventControllerKey: doc fixes re Modifiers

See merge request GNOME/gtk!6186
2023-07-14 14:04:47 +00:00
Daniel Boles
8c4245da2f EventControllerKey: Remove redundant/unliked "See"
Saying "See [Thing]" is not very helpful without it being a link to
Thing, and we already get that for free as the "Type:" of the param.
2023-07-14 14:22:57 +01:00
Daniel Boles
7e7aa17484 EventControllerKey: Remove wrong signal arg, which
caused the resulting parameter to be called keyval, but it must be state
2023-07-14 14:22:25 +01:00
Ekaterine Papava
4e6a04152b Update Georgian translation 2023-07-14 11:48:35 +00:00
Emmanuele Bassi
fb56929791 Merge branch 'nielsdg/fix-sectionmodel-signal-doc' into 'main'
sectionmodel: Fix GIR comment for sections-changed

See merge request GNOME/gtk!6185
2023-07-13 23:40:03 +00:00
Niels De Graef
c9022ac2d5 sectionmodel: Fix GIR comment for sections-changed
Make sure to end the signal name with a colon so GIR recognizes the
signal. This should also fix the problem that the documentation for that
signal is currently missing in the rendered gi-docgen output.
2023-07-14 01:03:21 +02:00
Benjamin Otte
0b6392c0a8 Merge branch 'vulkan-resize-fix' into 'main'
vulkan: Wait for device to be idle before create/recreating swapchain

See merge request GNOME/gtk!6183
2023-07-13 13:19:29 +00:00
José Roberto de Souza
526c0404c2 vulkan: Wait for device to be idle before create/recreating swapchain
Wait for device to be idle because this function is also called in
window resizes.
And if we destroy old swapchain it also destroy the old VkImages,
those images could be in use by a vulkan render.

This fixes a issue reported in Mesa repository when running
GTK with Xe KMD.

Fixes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9044
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
2023-07-13 05:40:55 -07:00
Matthias Clasen
cdacfc5a21 Merge branch 'fix-validate-crash' into 'main'
buildertool: Exit orderly

Closes #5948

See merge request GNOME/gtk!6182
2023-07-12 20:11:46 +00:00
Matthias Clasen
ab809d1dc3 buildertool: Exit orderly
The validate command does need a display connection,
for better or worse. So exit in an orderly fashion
if we don't have one, instead of crashing.

Fixes: #5948
2023-07-12 15:49:11 -04:00
Benjamin Otte
6dd9048c6d Merge branch 'wip/otte/for-main' into 'main'
textbtree: Remove unnecessary check

See merge request GNOME/gtk!6179
2023-07-11 00:04:17 +00:00
Benjamin Otte
3523d56122 vulkan: Change the clip intersection check
Intersection with a roudned clip takes too long.

Instead, rename the function to may_intersect() to be clear about what
it does and then just intersect with the regular rectangle.
2023-07-11 01:39:25 +02:00
Benjamin Otte
5c601b673e vulkan: intersect rects also for CLIP_NONE
If we don't clip anything, we stil have bounds - either the framebuffer
size or (more likely) the scissor rect. And we don't want to draw
anything that is outside these bounds.

So clip in those cases, too.

Stops gtk4-demo --run=listbox from trying to render the whole listbox
instead of only the visible parts.
2023-07-10 06:32:01 +02:00
Benjamin Otte
465a34e6b0 rendernode: Implement proper GSK_IS_RENDERNODE()
Use G_TYPE_CHECK_INSTANCE_TYPE() instead of just checking for != NULL.
After all, this is a GTypeInstance.

Also fixes some gcc complaints when checking
  node == NULL || GSK_IS_RENDERNODE (node)
which gcc was convinced would be always true.
2023-07-10 06:32:01 +02:00
Benjamin Otte
aa82a400df textbtree: Remove unnecessary check
Since a93614409e we don't allocate the
stack anymore, so this NULL check is unnecessary now - and it's flagged
by compilers.
2023-07-10 06:32:01 +02:00
Daniel Boles
4d673e9c9a theme: Don't dim text in backdropped list/listview
We have largely moved away from changing styles when :backdropped, aside
for some things in HeaderBars and Buttons. So we probably should not be
automatically dimming text in labels in list[view]s anymore either, as
that introduces differences if text happens to be in such widgets vs not
2023-07-09 09:49:25 +01:00
Matthias Clasen
1f3db35271 Merge branch 'dboles/image-notify-storage-type' into 'main'
Image—Notify when :storage-type changes from EMPTY

See merge request GNOME/gtk!6170
2023-07-07 01:15:56 +00:00
Emmanuele Bassi
18cce46ed2 Merge branch 'wip/corey/listitemleak' into 'main'
gtklistitemmanager: Stop leaking item

Closes #5940

See merge request GNOME/gtk!6171
2023-07-06 23:57:16 +00:00
Corey Berla
e78148bae5 gtklistitemmanager: Stop leaking item
Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5940
2023-07-06 16:24:29 -07:00
Daniel Boles
41237509ad Image—Notify when :storage-type changes from EMPTY
PROP_STORAGE_TYPE was only notified if it was changing *to* EMPTY, in
gtk_image_clear_internal(). We did not notify when it changes *from*
EMPTY to something non-empty. We should as not doing so is confusing,
e.g. if a user wants to bind :storage-type to :visible if non-empty,
which I just did! So, in functions that apply an ImageType, now notify.

Also do so in gtk_image_set_from_definition, declared in imageprivate.h,
even though none of the function there are currently used anywhere.
(Should they be removed?)
2023-07-06 23:08:20 +01:00
Yosef Or Boczko
576e8a2090 Update Hebrew translation 2023-07-06 09:38:02 +00:00
Matthias Clasen
d0f77c1db4 Merge branch 'wip/carlosg/switch-stylus-buttons' into 'main'
gdk/wayland: Switch behavior of BTN_STYLUS/STYLUS2 as middle/right click

Closes #5935

See merge request GNOME/gtk!6168
2023-07-05 23:38:38 +00:00
Carlos Garnacho
e28ff79bec gdk/wayland: Switch behavior of BTN_STYLUS/STYLUS2 as middle/right click
This mapping of stylus evdev input event codes into GDK button numbers
makes gdk/wayland inconsistent with gdk/x11, so depending on the backend
the same button middle-click pastes or right-click pops up menus.

Make the wayland backend consistent with X11, so that a GNOME wayland
session gets these buttons consistently mapped across all kinds of
clients.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5935
2023-07-05 16:54:54 +02:00
Daniel Boles
dccf6b55bd GdkTexture: Don't mention private new_from_surface
The stuff about Cairo Surfaces is in gdktextureprivate.h, & so end users
will not be able to use them; we shouldn't confuse by implying they can.
2023-07-05 12:07:33 +01:00
Daniel Boles
d5ea376e7b docs/list-widget: links, DirList, correct Sections
* Add links to various symbols.
* Mention DirectoryList in the "ready-made choices available" section.
* Don't say that GridView can display headers: it makes no attempt to.
2023-07-05 12:02:08 +01:00
Matthias Clasen
40707a6af0 Merge branch 'ebassi/issue-5934' into 'main'
Lower the Python requirement

Closes #5934

See merge request GNOME/gtk!6167
2023-07-05 10:57:45 +00:00
Emmanuele Bassi
9b71c9dfc6 Do not use bleeding edge Python
The match operator was added in Python 3.10, which is a bit too new for
some downstreams.

While at it, let's fix the flake8 errors and warnings.

Fixes: #5934
2023-07-05 10:19:18 +01:00
Emmanuele Bassi
64308317f8 Add flake8 configuration file
Ignore long lines; most of our Python scripts generate code or other
types of files, which makes long lines a necessity.

We should validate all our Python script in our CI as well.
2023-07-05 10:12:20 +01:00
Daniel Boles
f920723eae AlertDialog: Remove spurious/unmatched backtick 2023-07-04 22:42:50 +01:00
Daniel Boles
c581f4c96f ListBase: Fix a typo 2023-07-04 19:44:56 +01:00
Matthias Clasen
4998c90b10 Merge branch 'update-uac-script-format' into 'main'
tools/generate-uac-manifest.py: Fix formatting (unify with copy in GLib)

See merge request GNOME/gtk!6164
2023-07-03 23:37:36 +00:00
Benjamin Otte
412b23a146 Merge branch 'wip/otte/for-main' into 'main'
gsk: Catch values < 0 before bad things happen

See merge request GNOME/gtk!6165
2023-07-03 20:40:30 +00:00
Benjamin Otte
c179013790 testsuite: Add a test for mask out of bounds effects
Inverted alpha masks have an effect on the source, even if the mask
doesn't cover the source at all - or worse, is completely clipped out.

The GL renderer handles this fine, but Cairo and Vulkan had
optimizations that got this wrong.
2023-07-03 22:02:44 +02:00
Benjamin Otte
c6eb7fd483 gsk: Fix luminance in Cairo and GL renderer
In particular, fix the combination of luminance and alpha. We want to do
  mask = luminance * alpha
and for inverted
  mask = (1.0 - luminance) * alpha
so add a test that makes sure we do that and then fix the code and
existing tests to conform to it.
2023-07-03 22:02:44 +02:00
Benjamin Otte
7c58370673 rendernode: Work around a Cairo bug
When color-matrix modifying a clear surface, the surface would remain
clear according to Cairo.

That's very unfortunate when we prepare a mask for inverted-alpha
masking.
2023-07-03 22:02:44 +02:00
Benjamin Otte
84737a5159 build: Include the right things
If we build our own targets, we need to include those.

This is only relevant when adding new shaders because meson will
complain that the (unused) sources don't exist as it tries to include
those.
And that will make the build.ninja file not be generated which would
have build those shaders and would have allowed to copy them into the
sources.

Note that this makes builds with glslc not care about all the shader
files being included with the sources, but we have CI to check that.
2023-07-03 22:02:44 +02:00
Benjamin Otte
48804c81f3 rendernode: Mask nodes with different modes are different
So treat them as such.

Fixes the node editor not updating when I edit the mask mode.
2023-07-03 22:02:44 +02:00
Benjamin Otte
c79ec355af gsk: Catch values < 0 before bad things happen
In particular, catch radius values being < 0 by return_if_fail()ing in
the rendernode creation code, and by erroring out in the rendernode
parser.

I try too much dumb stuff in the node editor.
2023-07-03 22:02:44 +02:00
Benjamin Otte
ce5d74d7df glcontext: Fix typo in Apple extension name 2023-07-03 22:02:44 +02:00
Matthias Clasen
5bcc943ec3 Post-release version bump 2023-07-03 14:56:49 -04:00
Matthias Clasen
f5d68bb586 4.11.4 2023-07-03 14:12:53 -04:00
Chun-wei Fan
6d1537647c tools/generate-uac-manifest.py: Fix formatting
As this script is now also used in GLib, unify the formatting between
GLib and GTK. Make the formatting of the script conformant to the
Black[1] tool, as GLib requires, and add a copyright header to this
script.

[1]: https://black.readthedocs.io/en/stable/, see also
$(glibsrcroot)/.gitlab-ci/run-bash.sh
2023-07-03 12:50:55 +08:00
Matthias Clasen
ae2c10996a Merge branch 'fix_atcontext_refleaks' into 'main'
a11y: Fix some GtkATContext reference leaks

See merge request GNOME/gtk!6160
2023-07-01 18:06:19 +00:00
Barnabás Pőcze
81e9de3778 a11y: Fix some GtkATContext reference leaks
`gtk_accessible_get_at_context()` is transfer-full, so the returned
reference needs to be dropped. This was missing in a couple places.
2023-07-01 16:40:11 +02:00
Chun-wei Fan
42a704fefb Merge branch 'gdk-win32-input-fixes' into 'main'
GdkWin32 input fixes

Closes #5877

See merge request GNOME/gtk!6131
2023-06-30 04:33:08 +00:00
Matthias Clasen
e57eaf16b4 Merge branch 'wip/chergert/map-as-sectionmodel' into 'main'
maplistmodel: implement GtkSectionModel

See merge request GNOME/gtk!6154
2023-06-30 01:50:07 +00:00
Matthias Clasen
9aabb0e98d Add section model tests for GtkMapListModel 2023-06-29 21:30:11 -04:00
Matthias Clasen
9590a5f45e maplistmodel: Handle the ::sections-changed signal
Wrapper section models need to listen to and pass
on the ::sections-changed signal from the underlying
model.
2023-06-29 21:29:11 -04:00
Daniel Boles
7bee50c4f6 Image: Fix missing closing backtick 2023-06-29 14:33:29 +01:00
Matthias Clasen
bad2324318 Merge branch 'dboles/gtk-demo_dnd_dark' into 'main'
gtk-demo/dnd: Fix, generalise detecting dark theme

See merge request GNOME/gtk!6157
2023-06-29 10:26:41 +00:00
Matthias Clasen
dd15accb79 Merge branch 'matthiasc/for-main' into 'main'
build: Try harder to work with nongnu ld

See merge request GNOME/gtk!6159
2023-06-28 23:31:41 +00:00
Matthias Clasen
1d1f35576a build: Try harder to work with nongnu ld
Only try to be fast with gnu ld.
2023-06-28 16:54:34 -04:00
Daniel Boles
15458b5af3 gtk-demo/dnd: Fix, generalise detecting dark theme
Our default theme is now Default, not Adwaita, & HighContrastInverse was
renamed to Default-hc. So these checks did not work anymore. Rather than
hard-coding the new names, & possibly running into the same issue again,
we can just look for the convention of appending -dark to the theme name
and/or the Settings:prefer-dark-theme prop. The latter, we can & likely
SHOULD also apply to all themes - not just ours as before. We also check
for the :dark suffix as that means the theme variant - & before checking
GtkSettings check the GTK_THEME env var, just as GtkSettings itself does
2023-06-28 14:40:06 +01:00
Matthias Clasen
5ffe9a68ed Merge branch 'matthiasc/for-main' into 'main'
build: Move objcopy checks to one place

Closes #5672

See merge request GNOME/gtk!6156
2023-06-28 12:06:49 +00:00
Matthias Clasen
f341bd563b build: Look for ld.bfd
The objcopy+ld approach to fast resource building
relies on behavior that is specific to the binutils
linker, and does not work with the llvm one.

Therefore, check for ld.bfd. We still fall back
to trying with just ld, since I'm not 100% sure
if binutils unconditionally installs ld.bfd.

Fixes: #5672
2023-06-28 07:12:07 -04:00
Matthias Clasen
70edacc68d build: Move objcopy checks to one place
We were doing the same thing in three places.
Move it to the toplevel meson.build, so we
can change it in one place.
2023-06-28 07:11:51 -04:00
Matthias Clasen
091176ae48 Updates 2023-06-28 06:47:32 -04:00
Matthias Clasen
d9cfb94a80 Merge branch 'fix_dropdown_set_expression' into 'main'
GtkDropDown: Force redisplay of the drop-down items after expression change

See merge request GNOME/gtk!6145
2023-06-28 09:57:04 +00:00
Lukáš Tyrychtr
3c7ca28f1f dropdown: Handle expression changes
The expression is used by the default factory, so we
need to track whether we are using the default factory
and recreate it if the expression changes.
2023-06-28 08:18:01 +02:00
Matthias Clasen
25e518326c Merge branch 'matthiasc/for-main' into 'main'
Plug a memory leak in gsk_render_node_serialize

See merge request GNOME/gtk!6155
2023-06-28 02:42:47 +00:00
Matthias Clasen
a853307fb7 ci: Ignore more leaks in dependencies
libxkbcommon shows up quite a bit in leak sanitizer
reports. Ignore it.
2023-06-27 22:08:22 -04:00
Matthias Clasen
0ae541671d gsk: Plug a memory leak in mask node fallback
We were forgetting to free the mask pattern.
Found by asan.
2023-06-27 21:54:15 -04:00
Matthias Clasen
ef0d6c7290 gsk: Plug a memory leak in the gl renderer
Found by asan.
2023-06-27 21:52:08 -04:00
Matthias Clasen
2217509701 Plug a memory leak in gsk tests
Pointed out by asan.
2023-06-27 21:48:12 -04:00
Matthias Clasen
16e46a73f3 Plug a memory leak in gsk_render_node_serialize
This was introduced in 0d6a6a5997 with named
textures.
2023-06-27 21:43:17 -04:00
Christian Hergert
32a3690a3c maplistmodel: implement GtkSectionModel
This just wraps the underlying GListModel if it is a GtkSectionModel.
2023-06-27 18:08:20 -07:00
Benjamin Otte
526771751f Merge branch 'dboles/issue5922-DropTarget-reject-enter-critical' into 'main'
DropTarget: Fix critical if `reject()` drop before `::enter`

Closes #5922

See merge request GNOME/gtk!6152
2023-06-27 21:30:03 +00:00
Daniel Boles
dfa6591675 DropTarget: Fix critical if reject drop pre-enter
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/5922

The docs of `Gtk.DropTarget::accept` say this:
> If the decision whether the drop will be accepted or rejected depends
> on the data, [`::accept`] should return `TRUE`, [`:preload`] should be
> set and the value should be inspected via the `::notify:value` signal,
> calling `gtk_drop_target_reject()` if required.

But this pattern causes a CRITICAL, given these steps:
* Create a `DragSource` and `DropTarget`
* Keep the default `::accept` handler and set `:preload` to `TRUE`
* Connect to `notify::value` and therein call `DropTarget.reject()`
* CRITICAL at `DropTarget.enter()`→`Drop.get_actions()` on NULL instance

We should let the documented case work without a CRITICAL or worse, null
deref. And per @otte on the bug, we should bail earlier before `::enter`
& setting `GTK_STATE_FLAG_DROP_ACTIVE`; neither should occur if rejected

This fixes that, by checking after `start_drop()` when notifications are
thawed, whether any handler has `reject()`ed & set our `drop` to `NULL`.
2023-06-27 21:37:32 +01:00
Daniel Boles
6252517aac DropTarget: Fix if block indented 1 step too far 2023-06-27 21:37:20 +01:00
Matthias Clasen
51e440fa03 Merge branch 'fix-asan-ifunc' into 'main'
Fix fp16 with asan

See merge request GNOME/gtk!6153
2023-06-27 19:55:28 +00:00
Matthias Clasen
d82fb6f20a Fix fp16 with asan
The IFUNC resolvers that we are using here get
run early, before asan had a chance to set up its
plumbing, and therefore things go badly if they
are compiled with asan. Turning it off makes things
work again.

The gcc bug tracking this problem:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110442

Thanks to Jakub Jelinek and Florian Weimer for
analyzing this and recommending the workaround.
2023-06-27 15:17:56 -04:00
Matthias Clasen
44de6a6cbe Merge branch 'wip/sadiq/fix-use-after-free' into 'main'
gldriver: Fix a possible use-after-free

See merge request GNOME/gtk!6151
2023-06-27 18:46:28 +00:00
Mohammed Sadiq
64e27cd87d gldriver: Fix a possible use-after-free
g_hash_table_insert() frees the given key if it already exists
in the hashtable.  But since we use the same pointer in the
following line, it will result in use-after-free.

So instead, insert the key only if it doesn't exist.
2023-06-27 22:45:07 +05:30
Benjamin Otte
60e75f8a2a Merge branch 'wip/otte/for-vulkan' into 'main'
vulkan: Generate vertex array headers from shaders

See merge request GNOME/gtk!6149
2023-06-27 16:20:29 +00:00
Matthias Clasen
57eda94dde Merge branch 'matthiasc/for-main' into 'main'
gtk4-builder-tool: Fix naming

See merge request GNOME/gtk!6150
2023-06-27 11:24:08 +00:00
Matthias Clasen
723fb6c8be gtk4-builder-tool: Fix naming
We install the tool as gtk4-builder-tool, so that
is what it should call itself.

String change.
2023-06-27 07:09:04 -04:00
Benjamin Otte
6c85ed1ba1 vulkan: Generate vertex array headers from shaders
The script is pretty dumb but it does its job.
2023-06-27 07:11:48 +02:00
Benjamin Otte
2e58274f23 vulkan: Rename crossfade => cross-fade
Preparation for the future.
2023-06-27 06:46:57 +02:00
Benjamin Otte
4ade0afe03 vulkan: Rename blendmode to blend-mode
Preparation for future changes, nothing to see here.
2023-06-27 06:46:57 +02:00
Benjamin Otte
93fb45c689 Merge branch 'wip/otte/vulkan-for-main' into 'main'
vulkan: Add a pipeline cache

See merge request GNOME/gtk!6148
2023-06-26 18:52:48 +00:00
Benjamin Otte
684a015c98 vulkan: Add a pipeline cache
Make the display handle the cache, because we only need one.

We store the cache in
  $CACHE_DIR/gtk-4.0/vulkan-pipeline-cache/$UUID.$VERSION
so we regenerate caches for each different device (different UUID) and
each different driver version.

We also keep track of the etag of the cache file, so if 2 different
applications update the cache, we can detect that.
Vulkan allows merging caches, so the 2nd app reloads the new cache file
and merges it into its cache before saving.
2023-06-26 20:28:11 +02:00
Matthias Clasen
f7fcd2e425 Merge branch 'main' into 'main'
Add settable search match mode in dropdown

See merge request GNOME/gtk!6146
2023-06-26 18:18:14 +00:00
Matthias Clasen
c6c637fe21 Merge branch 'matthiasc/for-main' into 'main'
buildertool: Make render an alias for screenshot

See merge request GNOME/gtk!6147
2023-06-26 15:38:32 +00:00
Matthias Clasen
33fc4d6495 buildertool: Make render an alias for screenshot
Its a more neutral name and will align better with
other tools.
2023-06-26 10:58:35 -04:00
al_SeveR
33ff927522 Add settable search match mode in dropdown 2023-06-26 14:14:39 +00:00
Leônidas Araújo
2d39cdbff8 Update Brazilian Portuguese translation
(cherry picked from commit 98a2aae5ac)
2023-06-26 13:08:53 +00:00
Daniel Boles
8d675810e8 GtkText: Link to descendents/monospace CSS nodes
Change the descendent classes from `monospace`-without-links to links.
Add `monospace` around the names of CSS nodes and classes for clarity.
2023-06-26 13:05:39 +01:00
Matthias Clasen
8b25481c26 widget-factory: Set a11y labels on scale buttons
Just to check that this works now.
2023-06-25 22:28:23 -04:00
Ekaterine Papava
5fdf96f496 Update Georgian translation 2023-06-25 13:39:03 +00:00
Matthias Clasen
b61991a023 Merge branch 'gtkstack_fix_pages_param_check' into 'main'
stack: fix pages list bounds check

See merge request GNOME/gtk!6141
2023-06-24 12:08:18 +00:00
G.Willems
91d302a201 stack: fix pages list bounds check
Fix integer underflow when children->len is 0.
Add missing bounds check in select_item()
2023-06-24 03:05:37 +02:00
Matthias Clasen
35a1a62d50 Merge branch 'ebassi/builder-docs' into 'main'
docs: Clean up section on UI definitions

See merge request GNOME/gtk!6139
2023-06-23 23:45:05 +00:00
Matthias Clasen
ac7a4cb94c Merge branch 'wip/chergert/gdatetime-from-gtkbuilder' into 'main'
builder: add support for parsing GDateTime

See merge request GNOME/gtk!6140
2023-06-23 23:43:28 +00:00
Christian Hergert
bacd7ef92f builder: add support for parsing GDateTime
This will parse a <property/> containing the ISO 8601 format for a date
for use in GDateTime properties. For example:

  <property name="sampled-at">2023-06-23T00:00:00.00</property>
2023-06-23 14:11:37 -07:00
Emmanuele Bassi
980dc44f4a docs: Clean up section on UI definitions
The current documentation is narrative, but it lacks examples and proper
formatting, which makes it harder to read and visually scan.

Let's split off paragraphs and sections, so they can be easily linkend,
and add a few examples for each description.
2023-06-23 14:31:57 +01:00
Daniel Boles
2d648f84a9 docs/ref/gtk/running: Mention GDK_DEBUG=no-portals
It was omitted from !5336
2023-06-23 14:24:47 +01:00
Daniel Boles
aef0943f61 FileDialog: Fix typos of "inital" to "initial" 2023-06-23 13:50:53 +01:00
Matthias Clasen
3e146171cb Merge branch 'dboles/FileDialog_initial-folder_from_initial-file' into 'main'
Fix FileDialog: initial-file doesnʼt set initial-folder

See merge request GNOME/gtk!6137
2023-06-23 01:14:15 +00:00
Matthias Clasen
24bbaceaa4 Merge branch 'always-more-a11y-fixes' into 'main'
scalebutton: Use the group role

See merge request GNOME/gtk!6138
2023-06-23 01:06:57 +00:00
Matthias Clasen
318cf132e9 a11y: Extend the nested button hack to volume buttons 2023-06-22 18:37:10 -04:00
Matthias Clasen
8bbc143ed1 scalebutton: Use the group role
This is needed for accessible labels to work.
2023-06-22 18:36:39 -04:00
Daniel Boles
220d130c0f FileDialog: initial-file didnʼt set initial-folder
We always set :initial-folder to NULL and then notified about that,
instead of setting it to the folder of the :initial-file as we say.
2023-06-22 22:33:14 +01:00
Jordi Mas
e28a32a7c7 Update Catalan translation 2023-06-22 21:00:28 +02:00
Matthias Clasen
88f8b77d77 Merge branch 'matthiasc/for-main' into 'main'
docs: Mention GtkAccessibleRange

See merge request GNOME/gtk!6136
2023-06-22 02:40:08 +00:00
Matthias Clasen
1066374909 docs: Mention GtkAccessibleRange
In the accessibility docs about custom widgets,
mention GtkAccessibleRange as the best way to
implement custom range widgets.
2023-06-21 22:15:59 -04:00
Matthias Clasen
34a2595dfb Merge branch 'more-a11y-fixes' into 'main'
widget: Don't let abstract role slip through

See merge request GNOME/gtk!6135
2023-06-22 00:47:03 +00:00
Matthias Clasen
76fcd5cf25 Add another a11y test
This one catches the lingering 'widget' role
that only happens when widgets are realized
and rooted.
2023-06-21 19:55:46 -04:00
Matthias Clasen
32e6ed4eca a11y: Use group role for color and font buttons
This is needed since generic does not allow naming.
2023-06-21 19:55:46 -04:00
Matthias Clasen
2983c0be70 widget: Don't let abstract role slip through
When there isn't an accessible role set on the
instance or in class_init, we want to default
to 'generic'. There was one place where we
failed to do so.
2023-06-21 16:18:33 -04:00
Matthias Clasen
e0bf6585de Cosmetics: typo fix 2023-06-21 16:18:33 -04:00
Daniel Boles
c045b0be4c Settings: prop typo => "No description available."
Fix the typo so that we'll actually get documentation for
gtk-entry-select-on-focus.
2023-06-21 20:48:17 +01:00
Matthias Clasen
d8c094944a Merge branch 'more-a11y-fixes' into 'main'
a11y: Don't forget to space-separate computed names

See merge request GNOME/gtk!6134
2023-06-21 18:52:35 +00:00
Matthias Clasen
510bf86268 Add another a11y test
Test that roles come out right for custom widgets.
2023-06-21 14:24:52 -04:00
Matthias Clasen
f3bea027a0 Dropdown: Explicitly set a role
For some reason I haven't been able to track down,
the listitemwidget comes up wit the abstract widget
role otherwise.
2023-06-21 14:17:52 -04:00
Matthias Clasen
bce3b6f34a aboutdialog: Fix roles one more time
We are more picky about generic, so use group.
2023-06-21 13:47:59 -04:00
Matthias Clasen
01274dfbb9 shortcutswindow: Fix up roles and labels again 2023-06-21 13:18:58 -04:00
Matthias Clasen
533a2cf9ec a11y: Don't forget to space-separate computed names
This was overlooked in one place.
2023-06-21 13:18:07 -04:00
Luca Bacci
43af0ee514 Define this_module with (void) argument
Fixes a compiler warning about K&R (old-style) function definition
2023-06-21 16:18:40 +02:00
Luca Bacci
3912d6aba9 GdkWin32: Fix keyboard state for WinPointer input
The dwKeyStates field of the POINTER_INFO structure
is always set to 0, no matter what. Use GetKeyState
instead.

Forward-port of !4327 to GTK4
2023-06-21 16:18:01 +02:00
Luca Bacci
871685e271 GdkWin32: Use double coordinates for mouse events
Mouse coordinates reported by the system are still integers,
but go sub-pixel when dividing by the window scale factor.
2023-06-21 16:07:55 +02:00
Luca Bacci
5e9daa9728 GdkWin32: Unscaled coordinates in current_root_x, current_root_y
Also modify gdk_win32_surface_do_move_resize_drag() to take
unscaled root coordinates.

Fixes #5877
2023-06-21 16:01:42 +02:00
Luca Bacci
412bc1713a GdkWin32: Keep track of the last cursor position in move / resize contexts
...and avoid doing any work if the position hasn't changed.
2023-06-21 15:31:48 +02:00
Matthias Clasen
5dbc5bbf22 Merge branch 'wip/antoniof/my-mistake' into 'main'
Fix my a mistake

See merge request GNOME/gtk!6130
2023-06-21 12:01:00 +00:00
António Fernandes
79c999cf76 columnviewrowwidget: Reset roles on teardown
This was added to the wrong file in e245883f91

Fix the mistake.
2023-06-21 12:23:39 +01:00
Matthias Clasen
e375bc8838 Merge branch 'wip/antoniof/columnviewrow-accessible-label' into 'main'
columnviewrow: Add accessible-label and -description

Closes #5903

See merge request GNOME/gtk!6129
2023-06-21 10:22:41 +00:00
Matthias Clasen
79505f940b Merge branch 'always-more-a11y-fixes' into 'main'
range: Don't use an abstract role

See merge request GNOME/gtk!6127
2023-06-21 10:07:57 +00:00
Matthias Clasen
0f087deb2a Merge branch 'bump-glib' into 'main'
Bump GLib requirement to 2.76.0

See merge request GNOME/gtk!6128
2023-06-21 10:07:40 +00:00
António Fernandes
e245883f91 columnviewrow: Add accessible-label and -description
Echoing the same changes introduced for GtkListItem by these commits:
* df8d28f5fe
* f2b682dd9c

Resolves https://gitlab.gnome.org/GNOME/gtk/-/issues/5903
2023-06-21 10:27:39 +01:00
Chun-wei Fan
4e9bd13892 Visual Studio: Remove workarounds for <= glib-2.74.x
We now need glib-2.76.0 or later, which removes our needs for the workarounds
that we need to build the media backends against GLib-2.74.x or earlier, so
clean up things a bit.
2023-06-21 12:29:38 +08:00
Chun-wei Fan
65e9b8fe66 glib.wrap: Use 2.76.0
We are now using APIs that were introduced in 2.75.x, so let's use glib-2.76.0
here for our glib subproject.

Update the build and gobject-introspection items accordingly
2023-06-21 12:27:41 +08:00
Matthias Clasen
e9f870fee6 Make generic really the default role
If nothing else has been set for the instance
or the class, return GTK_ACCESSIBLE_ROLE_GENERIC.
2023-06-20 22:02:37 -04:00
Matthias Clasen
e5e5966934 frame: Use the group role 2023-06-20 21:58:55 -04:00
Matthias Clasen
5c407365e3 ci: Use the current build options for flatpaks
These were changed a while ago.
2023-06-20 20:49:29 -04:00
Matthias Clasen
7e251d81c2 a11y: Fix the stack switcher selection implementation
This was listening for signals on the wrong object.
2023-06-20 20:49:29 -04:00
Matthias Clasen
92d1d52c59 NEWS: updates 2023-06-20 20:49:29 -04:00
Matthias Clasen
ef436e4dce range: Don't use an abstract role
This snuck through, because the range wasn't
setting any role at all, it just ends up using
the initial, abstract role of widget.
2023-06-20 20:49:29 -04:00
Benjamin Otte
1a07e336bf Merge branch 'wip/otte/for-vulkan' into 'main'
vulkan: Fix a bunch of validation-layer complaints

See merge request GNOME/gtk!6126
2023-06-20 18:38:41 +00:00
Benjamin Otte
169355f771 vulkan: Rebuild the precompiled shaders
We forgot that with all the changes.
2023-06-20 20:17:06 +02:00
Benjamin Otte
299c6a3d6f vulkan: Take offscreen fromat from context
We want to create offscreens in compatible formats, and in particular we
want to ideally use the same format as rendering would use.
2023-06-20 20:15:12 +02:00
Benjamin Otte
17698bfd2e vulkan: Use 3 descriptor sets, not 3 bindings
It turns out variable length is only supported for the last binding in
a set, not for every binding.
So we need to create one set for each of our arrays.

[ VUID-VkDescriptorSetLayoutBindingFlagsCreateInfo-pBindingFlags-03004 ] Object 0: handle = 0x33a9f10, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0xd3f353a | vkCreateDescriptorSetLayout(): pBindings[0] has VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT but 0 is the largest value of all the bindings. The Vulkan spec states: If an element of pBindingFlags includes VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT, then all other elements of VkDescriptorSetLayoutCreateInfo::pBindings must have a smaller value of binding (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkDescriptorSetLayoutBindingFlagsCreateInfo-pBindingFlags-03004)
2023-06-20 20:15:12 +02:00
Benjamin Otte
377592cb62 vulkan: Use the right flags
Somebody (me) had flipped the 2 flags in commit ba28971a18:

[ VUID-vkCmdCopyBufferToImage-srcBuffer-00174 ] Object 0: handle = 0x3cfaac0, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0x430000000043, type = VK_OBJECT_TYPE_BUFFER; | MessageID = 0xe1b276a1 | Invalid usage flag for VkBuffer 0x430000000043[] used by vkCmdCopyBufferToImage. In this case, VkBuffer should have VK_BUFFER_USAGE_TRANSFER_SRC_BIT set during creation. The Vulkan spec states: srcBuffer must have been created with VK_BUFFER_USAGE_TRANSFER_SRC_BIT usage flag (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkCmdCopyBufferToImage-srcBuffer-00174)
2023-06-20 20:15:12 +02:00
Benjamin Otte
015cebc046 vulkan: Set descriptorBindingStorageBufferUpdateAfterBind
It's necessary now that we use storage buffers for gradients:

[ VUID-VkDescriptorSetLayoutBindingFlagsCreateInfo-descriptorBindingStorageBufferUpdateAfterBind-03008 ] Object 0: handle = 0x1e72d70, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x943cc552 | vkCreateDescriptorSetLayout(): pBindings[0] can't have VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT for VK_DESCRIPTOR_TYPE_STORAGE_BUFFER since descriptorBindingStorageBufferUpdateAfterBind is not enabled. The Vulkan spec states: If VkPhysicalDeviceDescriptorIndexingFeatures::descriptorBindingStorageBufferUpdateAfterBind is not enabled, all bindings with descriptor type VK_DESCRIPTOR_TYPE_STORAGE_BUFFER must not use VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkDescriptorSetLayoutBindingFlagsCreateInfo-descriptorBindingStorageBufferUpdateAfterBind-03008)
2023-06-20 20:15:12 +02:00
Benjamin Otte
0a5e5023a8 vulkan: Remove unused declaration from shader 2023-06-20 20:15:12 +02:00
Matthias Clasen
a9b8ad6181 Merge branch 'always-more-a11y-fixes' into 'main'
Add a comment about accessible naming

See merge request GNOME/gtk!6125
2023-06-20 17:13:51 +00:00
Matthias Clasen
7331683c01 a11y: Improve name computation
We only want to settle on subtree content
if it provides nonempty text. Otherwise,
the tooltip should still win.

This was clarified in the current Editor Draft
of the accessible name computation spec.
2023-06-20 12:34:51 -04:00
Matthias Clasen
cca6a66518 a11y: Fix tests
The change to make hidden follow mappedness
means that we now need to arrange for our
test cases to be mapped.
2023-06-20 12:33:02 -04:00
Matthias Clasen
891462e5af Add some more a11y tests
Check that the hidden state is as it should be.
2023-06-20 11:05:22 -04:00
Matthias Clasen
95cd6fe206 menubutton: Remove all the labelled-by relations
This was a bit much, and should not be necessary anymore,
now that our name computation handles nested buttons.
2023-06-20 10:58:18 -04:00
Matthias Clasen
63534fd9eb widget: Fix accessible hidden state
Make this track the widgets' mapped state
instead of visible. Also, set hidden to FALSE
initially, since the accessible name computation
checks for hidden==FALSE.
2023-06-20 10:40:12 -04:00
Matthias Clasen
e836e3380e Add a comment about accessible naming
Put a note on why there are a few differences
to ARIA.
2023-06-20 06:54:59 -04:00
Matthias Clasen
f693beab57 NEWS: Updates 2023-06-20 06:54:40 -04:00
Matthias Clasen
2d2df42a94 Merge branch 'listitem-a11y' into 'main'
listitem: Add accessible-label and -description

See merge request GNOME/gtk!6123
2023-06-20 09:55:58 +00:00
Matthias Clasen
fb0a4fa457 a11y: Stop recommending tab list labels
There is no good way to set an explicit label
on the tab list of a GtkNotebook, so showing
a blue overlay on it is annoying more than
helpful.

This is another little deviation from the ARIA
authoring guidelines.
2023-06-19 22:20:05 -04:00
Matthias Clasen
be0003c108 a11y: Stop recommending against listitem labels
Due to the way listviews are set up, there is not
much of an alternative to setting labels on the
listitems, so don't recommend against doing it.

This is a little deviation from the ARIA authoring
guidelines.
2023-06-19 22:20:05 -04:00
Matthias Clasen
eb1e24a5bf gizmo: Stop using abstract roles
This was overlooked.
2023-06-19 22:20:05 -04:00
Matthias Clasen
a3e98558d3 gtk-demo: Some a11y improvements
Add missing labels to the applauncher demo
and the clocks demo.
2023-06-19 22:19:54 -04:00
Matthias Clasen
f2b682dd9c listitemwidget: Clean up in teardown 2023-06-19 21:50:45 -04:00
Matthias Clasen
b826ef4f4d Merge branch 'a11y-work' into 'main'
A11y role changes

See merge request GNOME/gtk!6101
2023-06-20 01:23:13 +00:00
Matthias Clasen
a2fdeb99e0 gtk-demo: Improve a11y for applauncher
Use the new listitem properties to make
orca read the selected item in the applauncher
demo.
2023-06-19 21:21:55 -04:00
Matthias Clasen
df8d28f5fe listitem: Add accessible-label and -description
Add properties to GtkListItem to set the accessible
label and description of the listitem widget. This
is important, since orca will read these if the
listitem widget ends up with the focus.
2023-06-19 21:21:55 -04:00
Matthias Clasen
838c51cc92 a11y: Add the ARIA ontology
Add a helper function to find out which roles are
superclasses of each other.

This isn't used yet (apart from the existing use for
ranges), but it might be in the future.
2023-06-19 18:38:58 -04:00
Matthias Clasen
315ded687c Docs: update 2023-06-19 18:38:58 -04:00
Matthias Clasen
6855346269 a11y: Treat widget and window as abstract roles
We no longer use these, so we can enforce
that they are abstract.
2023-06-19 18:38:58 -04:00
Matthias Clasen
c2d6f900d9 window: Use application as accessible role
ARIA deems the window role to be abstract,
so lets use the application role instead.

Update affected tests.
2023-06-19 18:38:58 -04:00
Matthias Clasen
85c2d5f14e Add the application role
ARIA has this role. We left it out initially, but
it is an ok fit for toplevel windows, and better
than window, since that is meant to be abstract.
2023-06-19 18:38:58 -04:00
Matthias Clasen
b3eb912cf3 Use generic as default accessible role
The ARIA specs want widget to be abstract role.
We should respect that and use 'generic' instead.
2023-06-19 18:38:58 -04:00
Matthias Clasen
81d9205369 widget: Warn for abstract accessible roles
These should not be used for widgets, so warn if
they are passed to gtk_widget_set_accessible_role()
or gtk_widget_class_set_accessible_role().
2023-06-19 18:38:32 -04:00
Matthias Clasen
152a335cee Add gtk_accessible_role_is_abstract
Move this code from the a11y overlay in the inspector.
It will be used more widely, going forward.
2023-06-19 18:30:41 -04:00
Matthias Clasen
b84650c2a3 Add another a11y test 2023-06-19 18:30:41 -04:00
Matthias Clasen
722bea2943 Merge branch 'a11y-defeat' into 'main'
Give up on warning ATs into submission

See merge request GNOME/gtk!6121
2023-06-19 21:06:13 +00:00
Matthias Clasen
6c337b949d Merge branch 'fix-issue-5899' into 'main'
GtkFileChooserWidget: Fix condition on visit action

Closes #5899

See merge request GNOME/gtk!6103
2023-06-19 20:52:15 +00:00
Matthias Clasen
db97a35dc7 a11y: Remove the unrealized warning
This warning triggers quite a lot when opening
a window while orca is running, which clearly
shows that what it warns about happens in
practice. But fixing it is reentry hell, and
not a battle I'm up for today.
2023-06-19 16:41:39 -04:00
Matthias Clasen
c2fda63b0d Give up on warning ATs into submission
Its been more than a decade since Wayland
has not supported screen coordinates. Clearly
spamming every apps stderr with warnings is
never going to make ATs stop asking for screen
coordinates.

Just give up. Go home
2023-06-19 16:41:20 -04:00
Benjamin Otte
5da64e9e34 Merge branch 'unaligned-access' into 'main'
gtk: Align key_size up to key_align

Closes #5907

See merge request GNOME/gtk!6120
2023-06-19 20:26:18 +00:00
Matt Turner
3f360aa883 gtk: Align key_size up to key_align
Avoids unaligned accesses when e.g. the key_size is 12 and key_align is
8. We need to round the key size up to 16 to ensure that all keys are
appropriately aligned.

This manifested as a failure in the `gtk:gtk / sorter` unit test on
sparc.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5907
2023-06-19 15:55:09 -04:00
Matt Turner
a444045386 gtk: Pass G_ALIGNOF (...) to gtk_sort_keys_new
The sizeof and G_ALIGNOF are often, but not always, identical.
2023-06-19 15:54:51 -04:00
Daniel Boles
584a807ed6 Widget: Also mention get_height in get_alloc depʼn
The deprecation notice seems to have been copied from
get_allocated_width(), but for get_allocation() height is also relevant.
2023-06-19 20:29:23 +01:00
Matthias Clasen
72e5697804 Merge branch 'redo-a11y-name-computation' into 'main'
Reimplement a11y name computation

See merge request GNOME/gtk!6119
2023-06-19 17:49:22 +00:00
Matthias Clasen
93aff8a129 Add more name computation tests
Test the fallback for range values.

This was not working at all before
the previous commit.
2023-06-19 12:40:33 -04:00
Matthias Clasen
c3cfaab479 a11y: Fix name computation for ranges
There were two problems here:

First, the code was checking for the abstract
range role, instead of its subclasses.

Second, the code was calling a string value
getter on a number value. Oops.
2023-06-19 12:40:32 -04:00
Matthias Clasen
663e3d0811 Add tests for accessible name computation 2023-06-19 12:38:51 -04:00
Matthias Clasen
2dc35ec0c1 a11y: Quietly allow realizing unrooted at context
We can't set the display if we don't have a root,
but the default display is more than good enough
for the tests which otherwise would need to do
quite a bit more setup work to make their test
widgets rooted.
2023-06-19 12:38:51 -04:00
Matthias Clasen
a791f235e6 a11y: Only allow get_name/description when realized
These functions rely on self->accessible_role
being set, and that is only the case for realized
contexts.

In practice, this is not a problem. Contexts are
realized before ATs can get their names or descriptions,
and the inspector realizes contexts too, nowadays.

The only place where this caused a hickup is the
testsuite.
2023-06-19 12:38:51 -04:00
Matthias Clasen
7df9cc1b47 label: Stop overriding accessible label
There's no need to, the accessible name computation
picks the content up where it is allowed (and not
overridden by explicit attributes).
2023-06-19 12:38:51 -04:00
Matthias Clasen
4449344fad a11y: Reimplement name computation
Reimplement the name computation to follow the spec
(https://www.w3.org/TR/accname-1.2) more closely.

Also, unify the functions for name and description,
since their only difference is which property/relation
they use.
2023-06-19 12:38:51 -04:00
Matthias Clasen
e1c9f50d26 a11y: Cosmetics
No need to have two code paths doing the same.
2023-06-19 12:38:51 -04:00
Matthias Clasen
1f029229dc Merge branch 'a11y-inspector-tweaks' into 'main'
Move the a11y naming data into gtk proper

See merge request GNOME/gtk!6118
2023-06-19 16:21:31 +00:00
Matthias Clasen
a80dd28e35 a11y: Move naming data to gtkatcontext.c
This is in preparation for using this information
in the name computation.
2023-06-19 11:17:47 -04:00
Matthias Clasen
16077fbdac inspector: Tweak the a11y overlay
Shorten the warnings, and lower some of the
errors to 'not recommended' (where the authoring
guidelines say 'do not label', but aria doesn't
prohibit labels outright).
2023-06-19 11:17:47 -04:00
Matthias Clasen
1906bb5263 a11y: Update the name-prohibited list
ARIA has the time role in this as well.

It does not matter in practice since we don't
have a widget with this role, but lets match
the specs.
2023-06-19 11:17:47 -04:00
Matthias Clasen
a8b907a33c a11y: Cover the printer option widget case too
This is another case of nested control, in this
case it goes two levels deep. Since we already
have this hack, lets use it for all the cases.
This avoids some more complicated workaround.
2023-06-19 11:17:47 -04:00
Matthias Clasen
f2a2e97004 docs: Add guidance on container roles
Provide some guidance on whether group or generic
is a more suitable role for containers.
2023-06-19 11:17:47 -04:00
Matthias Clasen
a86923de94 a11y: Change the role for many containers
The group role that we've used before has some
implications of semantic grouping, whereas these
containers are mainly about layout, so use the
generic role instead.

This should not affect the translation to AT-SPI
at all.

The affected containers are: box, grid, centerbox,
scrolledwindow, viewport, windowhandle, aspectframe.

The role of GtkTreeExpander has been changed to
button instead, since it acts as a button.
2023-06-19 11:15:48 -04:00
Matthias Clasen
4412f25c9f a11y: Treat none and presentation the same
ARIA says these roles are aliases, so treat them
the same.
2023-06-19 11:15:48 -04:00
Luca Bacci
16bdaa11ce GtkFileChooserWidget: Use GTK_INVALID_LIST_POSITION
...instead of G_MAXUINT
2023-06-17 15:51:22 +02:00
Luca Bacci
46afb4a9a4 GtkFileChooserWidget: Fix condition on visit action
Fixes #5899
2023-06-17 15:50:50 +02:00
dgsasha
5240d8cdf5 win32: Fix minimize and maximize buttons missing on ssd
Completely fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/5142
2023-06-10 23:08:21 -04:00
Lukáš Tyrychtr
afbcbb8404 a11y: When a menu item opens a submenu, set its expandable state
To help distinguish submenu opening items, mark them as expandable.
Previously, they only indicated that they had a popup, which is too general.
2023-04-19 11:18:48 +02:00
Campbell Jones
5c00dc7ef4 GdkSurface: prevent popups from appearing offscreen in edge cases
This commit adds a single additional condition to the maybe_flip_position
function in gdksurface.c. If a popup's unflipped position is below the
bounds of its containing area, the popup uses its flipped position
instead. This prevents tooltips from appearing below the bounds of the
screen when a small widget is positioned very close to the bottom edge of
the screen, such as in Budgie and XFCE panel applets.
2023-01-07 11:08:33 -05:00
905 changed files with 152185 additions and 65779 deletions

2
.flake8 Normal file
View File

@@ -0,0 +1,2 @@
[flake8]
ignore = E501

View File

@@ -26,12 +26,20 @@ variables:
BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true"
FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled -Dbuild-testsuite=true -Dintrospection=enabled"
MESON_TEST_TIMEOUT_MULTIPLIER: 3
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v46"
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v48"
workflow:
rules:
- if: $CI_COMMIT_TAG
# run merge request pipelines
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
# do not run branch pipelines if corresponding merge requests exist...
# (this avoids duplicate pipelines)
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
# ...but otherwise run branch pipelines
- if: $CI_COMMIT_BRANCH
# run tag pipelines
- if: $CI_COMMIT_TAG
default:
retry:
@@ -197,28 +205,44 @@ msys2-mingw64:
paths:
- "${CI_PROJECT_DIR}/_build/gtkdll.tar.gz"
macos:
# Sadly, this fails regularly, and its failure is never enlightening
allow_failure: true
macos-x86_64:
rules:
# Do not run in forks as the runner is not available there.
- if: $CI_PROJECT_NAMESPACE == "GNOME"
stage: build
tags:
- macos
- macosintel
needs: []
variables:
MESON_FORCE_BACKTRACKE: 1
TMPDIR: /Users/Shared/work/tmp
SDKROOT: /opt/sdks/MacOSX10.13.4.sdk
PIP_CACHE_DIR: /Users/Shared/build/cache
PIPENV_CACHE_DIR: $PIP_CACHE_DIR
PYTHONPYCACHEPREFIX: $PIP_CACHE_DIR
EXTRA_MESON_FLAGS: "-Dgobject-introspection:werror=false"
before_script:
# Not using ccache on purpose as it accelerates the build so much that it
# can trigger race conditions in the gobject-introspection subproject.
- bash .gitlab-ci/show-info-osx.sh
- pip3 install --user meson~=1.0
- pip3 install --user ninja
- export PATH=/Users/gitlabrunner/Library/Python/3.7/bin:$PATH
- export MESON_FORCE_BACKTRACE=1
- /opt/macports/bin/python3.10 -m venv .venv
- ln -s /opt/cmake/CMake.app/Contents/bin/cmake .venv/bin
- ln -s /opt/pkg-config/bin/pkg-config .venv/bin
- ln -s /opt/bison/bin/bison .venv/bin
- source .venv/bin/activate
- pip3 install meson==1.2.0
- pip3 install ninja==1.11.1
- pip3 install /Users/Shared/build/pkgs/PyGObject-3.44.0-cp310-cp310-macosx_10_13_x86_64.whl
/Users/Shared/build/pkgs/pycairo-1.23.0-cp310-cp310-macosx_10_13_x86_64.whl
script:
- meson setup ${COMMON_MESON_FLAGS}
- meson setup
${COMMON_MESON_FLAGS}
${EXTRA_MESON_FLAGS}
-Dx11-backend=false
-Dbroadway-backend=true
-Dmacos-backend=true
-Dmedia-gstreamer=disabled
-Dintrospection=disabled
-Dintrospection=enabled
-Dcpp_std=c++11
-Dpixman:tests=disabled
-Dlibjpeg-turbo:simd=disabled
@@ -418,10 +442,11 @@ reference:
--buildtype=release
--force-fallback-for=gdk-pixbuf,pango
-Dintrospection=enabled
-Ddocumentation=true
-Dgtk_doc=true
-Dgdk-pixbuf:gtk_doc=true
-Dpango:gtk_doc=true
-Ddemos=false
-Dbuild-demos=false
-Dbuild-examples=false
-Dbuild-tests=false
-Dbuild-testsuite=false

View File

@@ -32,6 +32,7 @@ RUN dnf -y install \
glib2-static \
glibc-devel \
glibc-headers \
glslc \
gnupg2 \
gobject-introspection-devel \
graphene-devel \

View File

@@ -23,8 +23,8 @@ flatpak build ${builddir} meson \
-Dbuild-testsuite=false \
-Dbuild-examples=false \
-Dintrospection=disabled \
-Ddemos=true \
-Dprofile=devel \
-Dbuild-demos=true \
-Ddemo-profile=devel \
_flatpak_build
flatpak build ${builddir} ninja -C _flatpak_build install

32
.gitlab-ci/run-single-test.sh Executable file
View File

@@ -0,0 +1,32 @@
#!/usr/bin/sh
#
builddir=$1
suite=$2
unit=$3
echo "** builddir: ${builddir}"
echo "** suite: ${suite}"
echo "** unit: ${unit}"
export XDG_RUNTIME_DIR="$(mktemp -p $(pwd) -d xdg-runtime-XXXXXX)"
weston --backend=headless-backend.so --socket=wayland-5 --idle-time=0 &
compositor=$!
export WAYLAND_DISPLAY=wayland-5
meson test -C ${builddir} \
--print-errorlogs \
--setup=wayland \
--suite=${suite} \
--no-suite=failing \
--no-suite=flaky \
--no-suite=wayland_failing \
--no-suite=gsk-compare-broadway \
--verbose \
"${unit}"
exit_code=$?
kill ${compositor}
exit ${exit_code}

View File

@@ -23,6 +23,7 @@ case "${backend}" in
--suite=gtk \
--no-suite=failing \
--no-suite=flaky \
--no-suite=headless \
--no-suite=gsk-compare-broadway
# Store the exit code for the CI run, but always
@@ -45,6 +46,7 @@ case "${backend}" in
--suite=gtk \
--no-suite=failing \
--no-suite=flaky \
--no-suite=headless \
--no-suite=${backend}_failing \
--no-suite=gsk-compare-broadway
exit_code=$?
@@ -67,6 +69,7 @@ case "${backend}" in
--suite=gtk \
--no-suite=failing \
--no-suite=flaky \
--no-suite=headless \
--no-suite=gsk-compare-opengl
kill ${server}

View File

@@ -6,7 +6,7 @@ call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliar
:: FIXME: make warnings fatal
pip3 install --upgrade --user meson~=0.64 || goto :error
meson -Ddebug=false -Dmedia-gstreamer=disabled _build || goto :error
meson setup -Dbackend_max_links=1 -Ddebug=false -Dmedia-gstreamer=disabled _build || goto :error
ninja -C _build || goto :error
goto :EOF

View File

@@ -32,7 +32,8 @@ pacman --noconfirm -S --needed \
mingw-w64-$MSYS2_ARCH-fribidi \
mingw-w64-$MSYS2_ARCH-gst-plugins-bad-libs \
mingw-w64-$MSYS2_ARCH-shared-mime-info \
mingw-w64-$MSYS2_ARCH-python-gobject
mingw-w64-$MSYS2_ARCH-python-gobject \
mingw-w64-$MSYS2_ARCH-shaderc
mkdir -p _ccache
export CCACHE_BASEDIR="$(pwd)"

45
AUTHORS
View File

@@ -7,7 +7,7 @@ Peter Mattis <petm@xcf.berkeley.edu>
Spencer Kimball <spencer@xcf.berkeley.edu>
Josh MacDonald <jmacd@xcf.berkeley.edu>
The Team that build GTK 2 (in alphabetical order)
The team that build GTK 2 (in alphabetical order)
-------------------------------------------------
Shawn T. Amundson <amundson@gtk.org>
Jerome Bolliet <bolliet@gtk.org>
@@ -28,9 +28,8 @@ Jay Painter <jpaint@gtk.org>
Manish Singh <manish@gtk.org>
Owen Taylor <otaylor@gtk.org>
The current team (GTK 3 and 4)
------------------------------
The team that built GTK 3
-------------------------
Jonas Ådahl <jadahl@gmail.com>
Tim Bäder <mail@baedert.org>
Emmanuele Bassi <ebassi@gnome.org>
@@ -40,6 +39,16 @@ Carlos Garnacho <mrgarnacho@gmail.com>
Alexander Larsson <alexl@redhat.com>
Benjamin Otte <otte@gnome.org>
The current team (GTK 4)
------------------------
Jonas Ådahl <jadahl@gmail.com>
Emmanuele Bassi <ebassi@gnome.org>
Christian Hergert <chergert@gnome.org>
Chun-wei Fan <fanchunwei@src.gnome.org>
Matthias Clasen <mclasen@redhat.com>
Carlos Garnacho <mrgarnacho@gmail.com>
Benjamin Otte <otte@gnome.org>
There are many others who have contributed patches; we thank them,
GTK is much better because of them.
@@ -49,35 +58,15 @@ Over time, GTK has incorporated some pieces of software which
started as independent projects. We list the original authors here:
MS-Windows theme engine
-----------------------
Raymond Penners
Dom Lachowicz
Pixbuf theme engine
-------------------
Owen Taylor
IME input method
----------------
Takuro Ashie
Kazuki IWAMOTO
Mac OS X backend
----------------
MacOS backend
-------------
Anders Carlsson
DirectFB backend
----------------
Denis Oliver Kropp
Sven Neumann
Mike Emmel
gtkparasite
-----------
GtkInspector (originally gtkparasite)
-------------------------------------
Christian Hammond

View File

@@ -35,8 +35,7 @@ The issue tracker is meant to be used for actionable issues only.
You should not open a new issue for security related questions.
When in doubt, send an email to the [security](mailto:security@gnome.org)
mailing list.
When in doubt, follow [security](https://security.gnome.org/).
### Bug reports
@@ -244,13 +243,11 @@ people committing to GTK to follow a few rules:
code, you should always ask. If your change is minor and you've been
working on GTK for a while it probably isn't necessary to ask. But when
in doubt, ask. Even if your change is correct, somebody may know a
better way to do things. If you are making changes to GTK, you should
be subscribed to the [gtk-devel](https://mail.gnome.org/mailman/listinfo/gtk-devel-list)
mailing list; this is a good place to ask about intended changes.
The `#gtk` IRC channel on irc.gnome.org is also a good place to find GTK
developers to discuss changes, but if you live outside of the EU/US time
zones, an email to the gtk-devel mailing list is the most certain and
preferred method.
better way to do things.
The `gtk` [room on matrix](https://matrix.to/#/#gtk:gnome.org) is also a
good place to find GTK developers to discuss changes, but if you live
outside of the EU/US time zones, the [gtk tag on the GNOME Discourse instance](https://discourse.gnome.org/tag/gtk)
is the most certain and preferred method.
0. Ask _first_.

412
NEWS
View File

@@ -1,6 +1,416 @@
Overview of Changes in 4.11.4, xx-xx-xxxx
Overview of Changes in 4.13.3, xx-xx-xxxx
=========================================
Overview of Changes in 4.13.2, 22-10-2023
=========================================
* GtkPrintdialog:
- New async-style api to replace GtkPrintOperation
* GtkEmojiChooser:
- Add more languages: Bengali, Hindi, Japanese, Finnish,
Thai and Norwegian bokmål
* Accessibility:
- Fix some utf8 handling issues
* GDK:
- Add support for dmabuf textures, with GdkDmabufTextureBuilder
- Add a few more supported memory formats for textures
* GSK:
- Add a fast-path for masking color
- Add support for importing dmabuf textures
- Handle GLES better by using some extensions
* Translation updates:
Catalan
Russian
Turkish
Overview of Changes in 4.13.1, 28-09-2023
=========================================
* GtkTooltip:
- Don't cross native boundaries when looking for tooltips
* GtkCenterLayout, GtkEntry, GtkSearchEntry:
- Fix some issues with baseline handling
* GtkColorButton, GtkFontButton:
- Propagate focus-on-click
* GtkFileChooser:
- Make "Visit file" scroll to the file
* GtkSwitch:
- Respect text direction
* GtkWindow:
- Don't assume titlebars are GtkHeaderBars
* Printing:
- Fix some problems with the portal implementation
- Add a new simple print API: GtkPrintDialog
* Paths:
- GskPathMeasure performance has been improved
- Add custom contours for circles, rounded rectangles and rectangles
- Simplify GskPathPoint handling
- gsk_path_point_get_closest_point now returns the distance as well
- Make GskPathBuilder simplify curves
* Input:
- Handle (some) single-key compose sequences
- Fix active state tracking with sensitivity changes and grabs
* GSK:
- Make the repeated gradients match between GL and cairo
- Make rounded rect shrinking match between Vulkan, GL and cairo
- Fix parsing of text nodes with color glyphs
- Restrict an optimization to the cases where it is crrect
- Fix rendering of shadows with opacity
- The Vulkan renderer now requires Vulkan 1.2
- GL: Transition gradients unpremultiplied
- GL: Fix clipping of shadows
- GL: Some optimizations
- Broadway: Fix memory leaks in the renderer
* Wayland:
- Make activation more reliable
* macOS:
- Clamp damage regions to the surface size
* Tools:
- gtk4-path-tool gained restrict and reverse commands
- gtk4-path-tool show and render can show control points
* Demos:
- Add a demo for hit testing with paths
* Build:
- Fix build problems with C++ compilers
* Deprecations:
- gtk_window_present_with_time
* Translation updates
Brazilian Portuguese
British English
Catalan
Chinese (China)
Czech
Danish
Dutch
Esperanto
Galician
Georgian
Italian
Korean
Latvian
Lithuanian
Persian
Polish
Punjabi
Slovenian
Turkish
Overview of Changes in 4.13.0, 25-08-2023
=========================================
* GskPath, GskPathBuilder, GskPathMeasure:
Data types and APIs for path rendering. These APIs are still
considered experimental, and may change until 4.14. Please try
them out and give us feedback. Documentation can be found
here: https://docs.gtk.org/gsk4/paths.html
* GtkGridView:
- Fix a crash when scrolling
* GtkColumnView:
- Fix a refcounting issue in the new scroll_to api
* GtkTreeView
- Fix style classes for sort arrows
* GtkEntry:
- Improve tracking of user changes (for undo)
* GtkNotebook:
- Fix a critical when switching pages
* GtkColor/FontDialogButton:
- Make these widgets activatable
* GtkMenuButton:
- Fix problems with focus handling
- Fix problems with DND
- Make flags a settable property
* GtkShortcutsWindow:
- Add API to build shortcuts windows programmatically
* Printing
- Fix the cpdb backend build
* MacOS:
- Make file filters work again
* GSK:
- Fix issues with color matrix nodes
* Wayland:
- Fix a crash with compositors other than gnome-shell
* Deprecations:
- Remaining GtkTreeModel-related types
* Demos:
- Add a few path demos to gtk4-demo
* Tools:
- gtk4-path-tool provides a commandline interface for paths
* Translation updates:
Basque
Catalan
Finnish
Galician
Georgian
German
Greek
Indonesian
Kazakh
Persian
Polish
Romanian
Spanish
Swedish
Turkish
Ukrainian
Overview of Changes in 4.12.0, 05-08-2023
=========================================
* List widgets:
- Add scroll_to APIs
* GtkFileLauncher:
- Add an always-ask property
* GtkTextView:
- Make backspace behavior match GtkEntry
* gsk:
- Fix handling of luminance in mask nodes
* Text rendering:
- Automate the setting of gtk-hint-font-metrics from the
scale factor. This improves font rendering in flatpaks
* Wayland:
- Fix behavior of stylus buttons
- Support suspended window state
* Vulkan:
- Many improvements
* Tools:
- Add gtk4-rendernode-tool
* Debugging:
- Drop the GTK_DEBUG_TOUCHSCREEN flag
* Build:
- Some build options have been renamed:
gtk_doc -> documentation
update_screenshots -> screenshots
The old names still work
* Translation updates:
Georgian
Greek
Hebrew
Persian
Vietnamese
* Contributors:
Aleksandr Melman
Alexander Mikhaylenko
Alexander Shopov
Alexandre Franke
Alice Mikhaylenko
António Fernandes
Arjan Molenaar
Asier Sarasua Garmendia
Balázs Meskó
Balázs Úr
Barnabás Pőcze
Bart Jacobs
Benjamin Otte
Bilal Elmoussaoui
Boyuan Yang
Bruce Cowan
Calvin Walton
Cam Cook
Chris Mayo
Christian Hergert
Christopher Davis
Chun-wei Fan
Corey Berla
Danial Behzadi
Daniel Boles
Daniel Rusek
Efstathios Iosifidis
Ekaterine Papava
Emin Tufan Çetin
Emmanuele Bassi
Erik Schilling
Fabio Tomat
FeRD (Frank Dana)
Fina Wilke
FineFindus
Fran Dieguez
G.Willems
Georges Basile Stavracas Neto
Guillaume Bernard
Hugo Carvalho
Ivan Molodetskikh
Jason Francis
Jonas Ådahl
Jordan Petridis
Jordi Mas
José Expósito
José Roberto de Souza
Khalid Abu Shawarib
Kévin Commaille
Leônidas Araújo
Luca Bacci
Ludovico de Nittis
Lukáš Tyrychtr
Marc-André Lureau
Marco Trevisan (Treviño)
Matt Turner
Matthias Clasen
Maximiliano Sandoval R
Michael Catanzaro
Michel Dänzer
Mohammed Sadiq
Nathan Follens
Nelson Benítez León
Ngọc Quân Trần
Niels De Graef
Olivier Crête
Patrick Griffis
Piotr Drąg
Sabri Ünal
Sebastian Keller
Sophie Herold
Sébastien Le Roux
Takao Fujiwara
Thomas Lange
Yiğit Burak
Yosef Or Boczko
Yuri Chornoivan
Zander Brown
al_SeveR
dgsasha
sumibi-yakitori
tszymanski
velsinki
Алексей Шилин
Арсений Засыпкин
Overview of Changes in 4.11.4, 03-07-2023
=========================================
* GtkFileChooser:
- Default to sorting folders first
- Fix a crash when visiting recent files
* GtkTextView:
- Fix corner cases in word navigation
* GtkMenuButton:
- Normalize label layout
* GtkDropDown:
- Add support for sections
* GtkVideo:
- Make the overlay icon clickable
* GtkWindow:
- Clear the resize cursors to avoid artifacts
* GtkFileDialog:
- Always set initial-folder
* GtkDropDown:
- Update on expression changes
* GtkMapListModel:
- Implement GtkSectionModel
* Accessibility:
- Improvements all over the place: GtkButton, GtkPasswordEntry,
GtkFontChooserDialog, GtkColorChooserDialog, GtkShortcutsWindow,
GtkMenuButton, GtkAboutDialog, GtkFileChooserDialog, GtkStackSidebar,
GtkStackSwitcher, GtkMediaControls, GtkColorDialogButton, GtkDropDown,
GtkInfoBar, GtkNotebook, GtkPrintUnixDialog, GtkModelButton
- Make name computation follow the ARIA spec more closely
- Adapt name computation for the common 'nested button' scenario
- Change many containers to use `generic` instead of `group`
- Use `generic` as the default role
- Use `application` instead of `window` for windows
- Add properties for accessible names of not directly exposed
widgets in GtkListView, GtkGridView and GtkColumnView
* DND:
- Fix criticals when drops are rejected
* X11:
- Fix regressions in GLX setup
* Windows:
- Center newly created transient windows
* Vulkan:
- Add antialising for gradients
- Do less work on clipped away nodes
- Redo image uploading
- Support different image depths and formats
- Add a pipeline cache
* Demos:
- gtk4-demo: Improve window sizing
- gtk4-demo: Improve focus behavior
- gtk4-demo: Add many missing a11y properties
* Tools:
- gtk4-builder-tool: Make render an alias screenshot
* Inspector:
- Show more information in the a11y tab
- Add an accessibility overlay with warnings and recommendations
- Limit the width of the a11y tab
* Build:
- Require GLib 2.76
- Make asan builds work again
- Fix the build if ld is not ld.bdf
* Translation updates:
Brazilian Portuguese
Catalan
Czech
Georgian
Overview of Changes in 4.11.3, 05-06-2023
=========================================

View File

@@ -67,6 +67,13 @@ building for:
- [Graphene](https://github.com/ebassi/graphene)
- [Xkb-common](https://github.com/xkbcommon/libxkbcommon)
If you are building the Wayland backend, you will also need:
- Wayland-client
- Wayland-protocols
- Wayland-cursor
- Wayland-EGL
If you are building the X11 backend, you will also need:
- Xlib, and the following X extensions:
@@ -79,32 +86,24 @@ If you are building the X11 backend, you will also need:
- xdamage
- xcomposite
If you are building the Wayland backend, you will also need:
- Wayland-client
- Wayland-protocols
- Wayland-cursor
- Wayland-EGL
Once you have all the necessary dependencies, you can build GTK by using
Meson:
```sh
$ meson _build .
$ cd _build
$ ninja
$ meson setup _build
$ meson compile -C_build
```
You can run the test suite using:
```sh
$ meson test
$ meson test -C_build
```
And, finally, you can install GTK using:
```
$ sudo ninja install
$ sudo meson install -C_build
```
Complete information about installing GTK and related libraries

View File

@@ -0,0 +1,41 @@
#ifndef _MSC_VER
#pragma error "This header is for Microsoft VC or clang-cl only."
#endif /* _MSC_VER */
/* Make MSVC more pedantic, this is a recommended pragma list
* from _Win32_Programming_ by Rector and Newcomer.
*/
#ifndef __clang__
#pragma warning(error:4002) /* too many actual parameters for macro */
#pragma warning(error:4003) /* not enough actual parameters for macro */
#pragma warning(1:4010) /* single-line comment contains line-continuation character */
#pragma warning(error:4013) /* 'function' undefined; assuming extern returning int */
#pragma warning(1:4016) /* no function return type; using int as default */
#pragma warning(error:4020) /* too many actual parameters */
#pragma warning(error:4021) /* too few actual parameters */
#pragma warning(error:4027) /* function declared without formal parameter list */
#pragma warning(error:4029) /* declared formal parameter list different from definition */
#pragma warning(error:4033) /* 'function' must return a value */
#pragma warning(error:4035) /* 'function' : no return value */
#pragma warning(error:4045) /* array bounds overflow */
#pragma warning(error:4047) /* different levels of indirection */
#pragma warning(error:4049) /* terminating line number emission */
#pragma warning(error:4053) /* An expression of type void was used as an operand */
#pragma warning(error:4071) /* no function prototype given */
#pragma warning(disable:4101) /* unreferenced local variable */
#pragma warning(error:4150)
/* G_NORETURN */
#pragma warning(error:4646) /* function declared with __declspec(noreturn) has non-void return type */
#pragma warning(error:4715) /* 'function': not all control paths return a value */
#pragma warning(error:4098) /* 'void' function returning a value */
#pragma warning(disable:4244) /* No possible loss of data warnings */
#pragma warning(disable:4305) /* No truncation from int to char warnings */
#pragma warning(error:4819) /* The file contains a character that cannot be represented in the current code page */
#endif /* __clang__ */
/* work around Microsoft's premature attempt to deprecate the C-Library */
#define _CRT_SECURE_NO_WARNINGS
#define _CRT_NONSTDC_NO_WARNINGS

View File

@@ -483,6 +483,8 @@ constraint_editor_window_class_init (ConstraintEditorWindowClass *class)
GObjectClass *object_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
g_type_ensure (CONSTRAINT_VIEW_TYPE);
object_class->dispose = constraint_editor_window_dispose;
gtk_widget_class_set_template_from_resource (widget_class,

View File

@@ -20,8 +20,7 @@
#include "config.h"
#include "constraint-editor.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
#include "constraint-view.h"
struct _ConstraintEditor
{
@@ -66,7 +65,7 @@ static const char *
get_target_name (GtkConstraintTarget *target)
{
if (target == NULL)
return "super";
return "Super";
else if (GTK_IS_WIDGET (target))
return gtk_widget_get_name (GTK_WIDGET (target));
else if (GTK_IS_CONSTRAINT_GUIDE (target))
@@ -80,62 +79,29 @@ constraint_target_combo (GListModel *model,
GtkWidget *combo,
gboolean is_source)
{
GtkStringList *targets;
int i;
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "super", "Super");
targets = gtk_string_list_new (NULL);
gtk_string_list_append (targets, "Super");
if (model)
{
for (i = 0; i < g_list_model_get_n_items (model); i++)
{
GObject *item = g_list_model_get_object (model, i);
const char *name;
if (GTK_IS_CONSTRAINT (item))
continue;
name = get_target_name (GTK_CONSTRAINT_TARGET (item));
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), name, name);
gtk_string_list_append (targets, get_target_name (GTK_CONSTRAINT_TARGET (item)));
g_object_unref (item);
}
}
}
static void
constraint_attribute_combo (GtkWidget *combo,
gboolean is_source)
{
if (is_source)
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "none", "None");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "left", "Left");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "right", "Right");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "top", "Top");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "bottom", "Bottom");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "start", "Start");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "end", "End");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "width", "Width");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "height", "Height");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "center-x", "Center X");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "center-y", "Center Y");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "baseline", "Baseline");
}
static void
constraint_relation_combo (GtkWidget *combo)
{
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "le", "");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "eq", "=");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "ge", "");
}
static void
constraint_strength_combo (GtkWidget *combo)
{
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "weak", "Weak");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "medium", "Medium");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "strong", "Strong");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "required", "Required");
gtk_drop_down_set_model (GTK_DROP_DOWN (combo), G_LIST_MODEL (targets));
g_object_unref (targets);
}
static gpointer
@@ -147,7 +113,7 @@ get_target (GListModel *model,
if (id == NULL)
return NULL;
if (strcmp ("super", id) == 0)
if (strcmp ("Super", id) == 0)
return NULL;
for (i = 0; i < g_list_model_get_n_items (model); i++)
@@ -171,16 +137,65 @@ get_target (GListModel *model,
return NULL;
}
static GtkConstraintAttribute
get_target_attr (const char *id)
static void
select_target (GtkDropDown *combo,
const char *target_name)
{
GtkConstraintAttribute attr;
GEnumClass *class = g_type_class_ref (GTK_TYPE_CONSTRAINT_ATTRIBUTE);
GEnumValue *value = g_enum_get_value_by_nick (class, id);
attr = value->value;
g_type_class_unref (class);
GListModel *model = gtk_drop_down_get_model (combo);
return attr;
for (unsigned int i = 0; i < g_list_model_get_n_items (model); i++)
{
GtkStringObject *s = g_list_model_get_item (model, i);
g_object_unref (s);
if (strcmp (target_name, gtk_string_object_get_string (s)) == 0)
{
gtk_drop_down_set_selected (GTK_DROP_DOWN (combo), i);
return;
}
}
}
static GtkConstraintAttribute
get_attr (unsigned int id)
{
switch (id)
{
case 0: return GTK_CONSTRAINT_ATTRIBUTE_NONE;
case 1: return GTK_CONSTRAINT_ATTRIBUTE_LEFT;
case 2: return GTK_CONSTRAINT_ATTRIBUTE_RIGHT;
case 3: return GTK_CONSTRAINT_ATTRIBUTE_TOP;
case 4: return GTK_CONSTRAINT_ATTRIBUTE_BOTTOM;
case 5: return GTK_CONSTRAINT_ATTRIBUTE_START;
case 6: return GTK_CONSTRAINT_ATTRIBUTE_END;
case 7: return GTK_CONSTRAINT_ATTRIBUTE_WIDTH;
case 8: return GTK_CONSTRAINT_ATTRIBUTE_HEIGHT;
case 9: return GTK_CONSTRAINT_ATTRIBUTE_CENTER_X;
case 10: return GTK_CONSTRAINT_ATTRIBUTE_CENTER_Y;
case 11: return GTK_CONSTRAINT_ATTRIBUTE_BASELINE;
default: g_assert_not_reached ();
}
}
static unsigned int
get_attr_id (GtkConstraintAttribute attr)
{
switch (attr)
{
case GTK_CONSTRAINT_ATTRIBUTE_NONE: return 0;
case GTK_CONSTRAINT_ATTRIBUTE_LEFT: return 1;
case GTK_CONSTRAINT_ATTRIBUTE_RIGHT: return 2;
case GTK_CONSTRAINT_ATTRIBUTE_TOP: return 3;
case GTK_CONSTRAINT_ATTRIBUTE_BOTTOM: return 4;
case GTK_CONSTRAINT_ATTRIBUTE_START: return 5;
case GTK_CONSTRAINT_ATTRIBUTE_END: return 6;
case GTK_CONSTRAINT_ATTRIBUTE_WIDTH: return 7;
case GTK_CONSTRAINT_ATTRIBUTE_HEIGHT: return 8;
case GTK_CONSTRAINT_ATTRIBUTE_CENTER_X: return 9;
case GTK_CONSTRAINT_ATTRIBUTE_CENTER_Y: return 10;
case GTK_CONSTRAINT_ATTRIBUTE_BASELINE: return 11;
default: g_assert_not_reached ();
}
}
static const char *
@@ -195,15 +210,27 @@ get_attr_nick (GtkConstraintAttribute attr)
}
static GtkConstraintRelation
get_relation (const char *id)
get_relation (unsigned int id)
{
GtkConstraintRelation relation;
GEnumClass *class = g_type_class_ref (GTK_TYPE_CONSTRAINT_RELATION);
GEnumValue *value = g_enum_get_value_by_nick (class, id);
relation = value->value;
g_type_class_unref (class);
switch (id)
{
case 0: return GTK_CONSTRAINT_RELATION_LE;
case 1: return GTK_CONSTRAINT_RELATION_EQ;
case 2: return GTK_CONSTRAINT_RELATION_GE;
default: g_assert_not_reached ();
}
}
return relation;
static unsigned int
get_relation_id (GtkConstraintRelation relation)
{
switch (relation)
{
case GTK_CONSTRAINT_RELATION_LE: return 0;
case GTK_CONSTRAINT_RELATION_EQ: return 1;
case GTK_CONSTRAINT_RELATION_GE: return 2;
default: g_assert_not_reached ();
}
}
static const char *
@@ -234,15 +261,29 @@ get_relation_display_name (GtkConstraintRelation relation)
}
static GtkConstraintStrength
get_strength (const char *id)
{
GtkConstraintStrength strength;
GEnumClass *class = g_type_class_ref (GTK_TYPE_CONSTRAINT_STRENGTH);
GEnumValue *value = g_enum_get_value_by_nick (class, id);
strength = value->value;
g_type_class_unref (class);
get_strength (unsigned int id)
{
switch (id)
{
case 0: return GTK_CONSTRAINT_STRENGTH_WEAK;
case 1: return GTK_CONSTRAINT_STRENGTH_MEDIUM;
case 2: return GTK_CONSTRAINT_STRENGTH_STRONG;
case 3: return GTK_CONSTRAINT_STRENGTH_REQUIRED;
default: g_assert_not_reached ();
}
}
return strength;
static unsigned int
get_strength_id (GtkConstraintStrength strength)
{
switch (strength)
{
case GTK_CONSTRAINT_STRENGTH_WEAK: return 0;
case GTK_CONSTRAINT_STRENGTH_MEDIUM: return 1;
case GTK_CONSTRAINT_STRENGTH_STRONG: return 2;
case GTK_CONSTRAINT_STRENGTH_REQUIRED: return 3;
default: g_assert_not_reached ();
}
}
static const char *
@@ -294,7 +335,7 @@ static void
create_constraint (GtkButton *button,
ConstraintEditor *editor)
{
const char *id;
gpointer obj;
gpointer target;
GtkConstraintAttribute target_attr;
gpointer source;
@@ -305,25 +346,27 @@ create_constraint (GtkButton *button,
int strength;
GtkConstraint *constraint;
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->target));
target = get_target (editor->model, id);
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->target_attr));
target_attr = get_target_attr (id);
obj = gtk_drop_down_get_selected_item (GTK_DROP_DOWN (editor->target));
if (obj)
target = get_target (editor->model, gtk_string_object_get_string (GTK_STRING_OBJECT (obj)));
else
target = NULL;
target_attr = get_attr (gtk_drop_down_get_selected (GTK_DROP_DOWN (editor->target_attr)));
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->source));
source = get_target (editor->model, id);
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->source_attr));
source_attr = get_target_attr (id);
obj = gtk_drop_down_get_selected_item (GTK_DROP_DOWN (editor->source));
if (obj)
source = get_target (editor->model, gtk_string_object_get_string (GTK_STRING_OBJECT (obj)));
else
source = NULL;
source_attr = get_attr (gtk_drop_down_get_selected (GTK_DROP_DOWN(editor->source_attr)));
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->relation));
relation = get_relation (id);
relation = get_relation (gtk_drop_down_get_selected (GTK_DROP_DOWN (editor->relation)));
multiplier = g_ascii_strtod (gtk_editable_get_text (GTK_EDITABLE (editor->multiplier)), NULL);
constant = g_ascii_strtod (gtk_editable_get_text (GTK_EDITABLE (editor->constant)), NULL);
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->strength));
strength = get_strength (id);
strength = get_strength (gtk_drop_down_get_selected (GTK_DROP_DOWN (editor->strength)));
constraint = gtk_constraint_new (target, target_attr,
relation,
@@ -338,12 +381,9 @@ create_constraint (GtkButton *button,
static void
source_attr_changed (ConstraintEditor *editor)
{
const char *id;
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->source_attr));
if (strcmp (id, "none") == 0)
if (get_attr (gtk_drop_down_get_selected (GTK_DROP_DOWN (editor->source_attr))) == GTK_CONSTRAINT_ATTRIBUTE_NONE)
{
gtk_combo_box_set_active (GTK_COMBO_BOX (editor->source), -1);
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->source), GTK_INVALID_LIST_POSITION);
gtk_editable_set_text (GTK_EDITABLE (editor->multiplier), "");
gtk_widget_set_sensitive (editor->source, FALSE);
gtk_widget_set_sensitive (editor->multiplier, FALSE);
@@ -409,7 +449,7 @@ update_preview (ConstraintEditor *editor)
GString *str;
const char *name;
const char *attr;
char *relation;
const char *relation;
const char *multiplier;
const char *constant;
double c, m;
@@ -419,23 +459,22 @@ update_preview (ConstraintEditor *editor)
str = g_string_new ("");
name = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->target));
attr = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->target_attr));
relation = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (editor->relation));
name = gtk_string_object_get_string (GTK_STRING_OBJECT (gtk_drop_down_get_selected_item (GTK_DROP_DOWN (editor->target))));
attr = get_attr_nick (get_attr (gtk_drop_down_get_selected ((GTK_DROP_DOWN (editor->target_attr)))));
relation = get_relation_nick (get_relation (gtk_drop_down_get_selected (GTK_DROP_DOWN (editor->relation))));
if (name == NULL)
name = "[ ]";
g_string_append_printf (str, "%s.%s %s ", name, attr, relation);
g_free (relation);
constant = gtk_editable_get_text (GTK_EDITABLE (editor->constant));
c = g_ascii_strtod (constant, NULL);
attr = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->source_attr));
attr = get_attr_nick (get_attr (gtk_drop_down_get_selected (GTK_DROP_DOWN (editor->source_attr))));
if (strcmp (attr, "none") != 0)
{
name = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->source));
name = gtk_string_object_get_string (GTK_STRING_OBJECT (gtk_drop_down_get_selected_item (GTK_DROP_DOWN (editor->source))));
multiplier = gtk_editable_get_text (GTK_EDITABLE (editor->multiplier));
m = g_ascii_strtod (multiplier, NULL);
@@ -463,12 +502,18 @@ update_preview (ConstraintEditor *editor)
static void
update_button (ConstraintEditor *editor)
{
const char *target = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->target));
const char *source = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->source));
const char *source_attr = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->source_attr));
gpointer obj;
const char *target;
const char *source;
GtkConstraintAttribute source_attr = get_attr (gtk_drop_down_get_selected (GTK_DROP_DOWN (editor->source_attr)));
if (target &&
(source || (source_attr && get_target_attr (source_attr) == GTK_CONSTRAINT_ATTRIBUTE_NONE)))
obj = gtk_drop_down_get_selected_item (GTK_DROP_DOWN (editor->target));
target = obj ? gtk_string_object_get_string (GTK_STRING_OBJECT (obj)) : NULL;
obj = gtk_drop_down_get_selected_item (GTK_DROP_DOWN (editor->source));
source = obj ? gtk_string_object_get_string (GTK_STRING_OBJECT (obj)) : NULL;
if (target && (source || (source_attr == GTK_CONSTRAINT_ATTRIBUTE_NONE)))
gtk_widget_set_sensitive (editor->button, TRUE);
else
gtk_widget_set_sensitive (editor->button, FALSE);
@@ -486,12 +531,7 @@ constraint_editor_constructed (GObject *object)
ConstraintEditor *editor = CONSTRAINT_EDITOR (object);
constraint_target_combo (editor->model, editor->target, FALSE);
constraint_attribute_combo (editor->target_attr, FALSE);
constraint_relation_combo (editor->relation);
constraint_target_combo (editor->model, editor->source, TRUE);
constraint_attribute_combo (editor->source_attr, TRUE);
constraint_strength_combo (editor->strength);
if (editor->constraint)
{
@@ -499,30 +539,24 @@ constraint_editor_constructed (GObject *object)
GtkConstraintAttribute attr;
GtkConstraintRelation relation;
GtkConstraintStrength strength;
const char *nick;
char *val;
double multiplier;
double constant;
target = gtk_constraint_get_target (editor->constraint);
nick = get_target_name (target);
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->target), nick);
select_target (GTK_DROP_DOWN (editor->target), get_target_name (target));
attr = gtk_constraint_get_target_attribute (editor->constraint);
nick = get_attr_nick (attr);
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->target_attr), nick);
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->target_attr), get_attr_id (attr));
target = gtk_constraint_get_source (editor->constraint);
nick = get_target_name (target);
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->source), nick);
select_target (GTK_DROP_DOWN (editor->source), get_target_name (target));
attr = gtk_constraint_get_source_attribute (editor->constraint);
nick = get_attr_nick (attr);
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->source_attr), nick);
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->source_attr), get_attr_id (attr));
relation = gtk_constraint_get_relation (editor->constraint);
nick = get_relation_nick (relation);
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->relation), nick);
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->relation), get_relation_id (relation));
multiplier = gtk_constraint_get_multiplier (editor->constraint);
val = g_strdup_printf ("%g", multiplier);
@@ -535,17 +569,16 @@ constraint_editor_constructed (GObject *object)
g_free (val);
strength = gtk_constraint_get_strength (editor->constraint);
nick = get_strength_nick (strength);
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->strength), nick);
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->strength), get_strength_id (strength));
gtk_button_set_label (GTK_BUTTON (editor->button), "Apply");
}
else
{
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->target_attr), "left");
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->source_attr), "left");
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->relation), "eq");
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->strength), "required");
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->target_attr), get_attr_id (GTK_CONSTRAINT_ATTRIBUTE_LEFT));
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->source_attr), get_attr_id (GTK_CONSTRAINT_ATTRIBUTE_LEFT));
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->relation), get_relation_id (GTK_CONSTRAINT_RELATION_EQ));
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->strength), get_strength_id (GTK_CONSTRAINT_STRENGTH_REQUIRED));
gtk_editable_set_text (GTK_EDITABLE (editor->multiplier), "1.0");
gtk_editable_set_text (GTK_EDITABLE (editor->constant), "0.0");

View File

@@ -1,5 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkStringList" id="targets">
<items>
<item>None</item>
<item>Left</item>
<item>Right</item>
<item>Top</item>
<item>Bottom</item>
<item>Start</item>
<item>End</item>
<item>Width</item>
<item>Height</item>
<item>Center X</item>
<item>Center Y</item>
<item>Baseline</item>
</items>
</object>
<template class="ConstraintEditor" parent="GtkWidget">
<child>
<object class="GtkGrid" id="grid">
@@ -19,9 +35,9 @@
</object>
</child>
<child>
<object class="GtkComboBoxText" id="target">
<signal name="changed" handler="update_preview" swapped="yes"/>
<signal name="changed" handler="update_button" swapped="yes"/>
<object class="GtkDropDown" id="target">
<signal name="notify::selected" handler="update_preview" swapped="yes"/>
<signal name="notify::selected" handler="update_button" swapped="yes"/>
<layout>
<property name="column">1</property>
<property name="row">1</property>
@@ -29,8 +45,9 @@
</object>
</child>
<child>
<object class="GtkComboBoxText" id="target_attr">
<signal name="changed" handler="update_preview" swapped="yes"/>
<object class="GtkDropDown" id="target_attr">
<property name="model">targets</property>
<signal name="notify::selected" handler="update_preview" swapped="yes"/>
<layout>
<property name="column">2</property>
<property name="row">1</property>
@@ -47,8 +64,17 @@
</object>
</child>
<child>
<object class="GtkComboBoxText" id="relation">
<signal name="changed" handler="update_preview" swapped="yes"/>
<object class="GtkDropDown" id="relation">
<signal name="notify::selected" handler="update_preview" swapped="yes"/>
<property name="model">
<object class="GtkStringList">
<items>
<item>≤</item>
<item>=</item>
<item>≥</item>
</items>
</object>
</property>
<layout>
<property name="column">1</property>
<property name="row">2</property>
@@ -65,9 +91,9 @@
</object>
</child>
<child>
<object class="GtkComboBoxText" id="source">
<signal name="changed" handler="update_preview" swapped="yes"/>
<signal name="changed" handler="update_button" swapped="yes"/>
<object class="GtkDropDown" id="source">
<signal name="notify::selected" handler="update_preview" swapped="yes"/>
<signal name="notify::selected" handler="update_button" swapped="yes"/>
<layout>
<property name="column">1</property>
<property name="row">3</property>
@@ -75,10 +101,11 @@
</object>
</child>
<child>
<object class="GtkComboBoxText" id="source_attr">
<signal name="changed" handler="update_preview" swapped="yes"/>
<signal name="changed" handler="source_attr_changed" swapped="yes"/>
<signal name="changed" handler="update_button" swapped="yes"/>
<object class="GtkDropDown" id="source_attr">
<property name="model">targets</property>
<signal name="notify::selected" handler="update_preview" swapped="yes"/>
<signal name="notify::selected" handler="source_attr_changed" swapped="yes"/>
<signal name="notify::selected" handler="update_button" swapped="yes"/>
<layout>
<property name="column">2</property>
<property name="row">3</property>
@@ -131,7 +158,17 @@
</object>
</child>
<child>
<object class="GtkComboBoxText" id="strength">
<object class="GtkDropDown" id="strength">
<property name="model">
<object class="GtkStringList">
<items>
<item>Weak</item>
<item>Medium</item>
<item>Strong</item>
<item>Required</item>
</items>
</object>
</property>
<layout>
<property name="column">1</property>
<property name="row">6</property>

View File

@@ -21,8 +21,6 @@
#include "guide-editor.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
struct _GuideEditor
{
GtkWidget parent_instance;
@@ -59,25 +57,30 @@ static guint signals[LAST_SIGNAL];
G_DEFINE_TYPE(GuideEditor, guide_editor, GTK_TYPE_WIDGET);
static void
guide_strength_combo (GtkWidget *combo)
static GtkConstraintStrength
get_strength (unsigned int id)
{
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "weak", "Weak");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "medium", "Medium");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "strong", "Strong");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "required", "Required");
switch (id)
{
case 0: return GTK_CONSTRAINT_STRENGTH_WEAK;
case 1: return GTK_CONSTRAINT_STRENGTH_MEDIUM;
case 2: return GTK_CONSTRAINT_STRENGTH_STRONG;
case 3: return GTK_CONSTRAINT_STRENGTH_REQUIRED;
default: g_assert_not_reached ();
}
}
static GtkConstraintStrength
get_strength (const char *id)
static unsigned int
get_strength_id (GtkConstraintStrength strength)
{
GtkConstraintStrength strength;
GEnumClass *class = g_type_class_ref (GTK_TYPE_CONSTRAINT_STRENGTH);
GEnumValue *value = g_enum_get_value_by_nick (class, id);
strength = value->value;
g_type_class_unref (class);
return strength;
switch (strength)
{
case GTK_CONSTRAINT_STRENGTH_WEAK: return 0;
case GTK_CONSTRAINT_STRENGTH_MEDIUM: return 1;
case GTK_CONSTRAINT_STRENGTH_STRONG: return 2;
case GTK_CONSTRAINT_STRENGTH_REQUIRED: return 3;
default: g_assert_not_reached ();
}
}
static const char *
@@ -118,11 +121,11 @@ static void
create_guide (GtkButton *button,
GuideEditor *editor)
{
const char *id;
int strength;
const char *name;
int w, h;
GtkConstraintGuide *guide;
unsigned int id;
if (editor->guide)
guide = g_object_ref (editor->guide);
@@ -144,7 +147,7 @@ create_guide (GtkButton *button,
h = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (editor->max_height));
gtk_constraint_guide_set_max_size (guide, w, h);
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->strength));
id = gtk_drop_down_get_selected (GTK_DROP_DOWN (editor->strength));
strength = get_strength (id);
gtk_constraint_guide_set_strength (guide, strength);
@@ -191,14 +194,9 @@ guide_editor_constructed (GObject *object)
{
GuideEditor *editor = GUIDE_EDITOR (object);
guide_strength_combo (editor->strength);
g_signal_connect (editor->min_width, "input", G_CALLBACK (min_input), NULL);
g_signal_connect (editor->min_height, "input", G_CALLBACK (min_input), NULL);
g_signal_connect (editor->max_width, "input", G_CALLBACK (max_input), NULL);
g_signal_connect (editor->max_height, "input", G_CALLBACK (max_input), NULL);
if (editor->guide)
@@ -224,8 +222,7 @@ guide_editor_constructed (GObject *object)
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->max_height), h);
strength = gtk_constraint_guide_get_strength (editor->guide);
nick = get_strength_nick (strength);
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->strength), nick);
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->strength), get_strength_id (strength));
gtk_button_set_label (GTK_BUTTON (editor->button), "Apply");
}
@@ -245,7 +242,7 @@ guide_editor_constructed (GObject *object)
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->max_width), G_MAXINT);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->max_height), G_MAXINT);
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->strength), "medium");
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->strength), get_strength_id (GTK_CONSTRAINT_STRENGTH_MEDIUM));
gtk_button_set_label (GTK_BUTTON (editor->button), "Create");
}

View File

@@ -167,7 +167,17 @@
</object>
</child>
<child>
<object class="GtkComboBoxText" id="strength">
<object class="GtkDropDown" id="strength">
<property name="model">
<object class="GtkStringList">
<items>
<item>Weak</item>
<item>Medium</item>
<item>Strong</item>
<item>Required</item>
</items>
</object>
</property>
<layout>
<property name="column">1</property>
<property name="row">4</property>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -2,8 +2,6 @@
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
typedef GtkApplication DemoApplication;
typedef GtkApplicationClass DemoApplicationClass;
@@ -216,6 +214,41 @@ activate_quit (GSimpleAction *action,
}
}
static void
delete_messages (gpointer data)
{
g_list_free_full ((GList *)data, g_free);
}
static void
pop_message (GtkWidget *status)
{
GList *messages = (GList *) g_object_steal_data (G_OBJECT (status), "messages");
if (messages)
{
char *message = messages->data;
messages = g_list_remove (messages, message);
g_object_set_data_full (G_OBJECT (status), "messages",
messages, delete_messages);
gtk_label_set_label (GTK_LABEL (status), message);
}
}
static void
push_message (GtkWidget *status,
const char *message)
{
GList *messages = (GList *) g_object_steal_data (G_OBJECT (status), "messages");
gtk_label_set_label (GTK_LABEL (status), message);
messages = g_list_prepend (messages, g_strdup (message));
g_object_set_data_full (G_OBJECT (status), "messages",
messages, delete_messages);
}
static void
update_statusbar (GtkTextBuffer *buffer,
DemoApplicationWindow *window)
@@ -226,7 +259,7 @@ update_statusbar (GtkTextBuffer *buffer,
GtkTextIter iter;
/* clear any previous message, underflow is allowed */
gtk_statusbar_pop (GTK_STATUSBAR (window->status), 0);
pop_message (window->status);
count = gtk_text_buffer_get_char_count (buffer);
@@ -240,7 +273,7 @@ update_statusbar (GtkTextBuffer *buffer,
msg = g_strdup_printf ("Cursor at row %d column %d - %d chars in document",
row, col, count);
gtk_statusbar_push (GTK_STATUSBAR (window->status), 0, msg);
push_message (window->status, msg);
g_free (msg);
}

View File

@@ -76,8 +76,13 @@
</object>
</child>
<child>
<object class="GtkStatusbar" id="status">
<object class="GtkLabel" id="status">
<property name="hexpand">1</property>
<property name="xalign">0</property>
<property name="margin-start">2</property>
<property name="margin-end">2</property>
<property name="margin-top">2</property>
<property name="margin-bottom">2</property>
<layout>
<property name="column">0</property>
<property name="row">3</property>

View File

@@ -1,5 +1,5 @@
/* Builder
* #Keywords: GMenu, GtkPopoverMenuBar, GtkBuilder, GtkStatusBar, GtkShortcutController, toolbar
* #Keywords: GMenu, GtkPopoverMenuBar, GtkBuilder, GtkShortcutController, toolbar
*
* Demonstrates a traditional interface, loaded from a XML description,
* and shows how to connect actions to the menu items and toolbar buttons.
@@ -37,30 +37,34 @@ remove_timeout (gpointer data)
g_source_remove (id);
}
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static gboolean
pop_status (gpointer data)
static int
pop_message (gpointer data)
{
gtk_statusbar_pop (GTK_STATUSBAR (data), 0);
g_object_set_data (G_OBJECT (data), "timeout", NULL);
GtkWidget *status = data;
gtk_label_set_label (GTK_LABEL (status), "");
g_object_set_data (G_OBJECT (status), "timeout", GUINT_TO_POINTER (0));
return G_SOURCE_REMOVE;
}
static void
status_message (GtkStatusbar *status,
const char *text)
status_message (GtkWidget *status,
const char *text)
{
guint id;
gtk_statusbar_push (GTK_STATUSBAR (status), 0, text);
id = g_timeout_add (5000, pop_status, status);
id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (status), "timeout"));
if (id)
g_source_remove (id);
gtk_label_set_text (GTK_LABEL (status), text);
id = g_timeout_add (5000, pop_message, status);
g_object_set_data_full (G_OBJECT (status), "timeout", GUINT_TO_POINTER (id), remove_timeout);
}
G_GNUC_END_IGNORE_DEPRECATIONS
static void
help_activate (GSimpleAction *action,
GVariant *parameter,
@@ -69,7 +73,7 @@ help_activate (GSimpleAction *action,
GtkWidget *status;
status = GTK_WIDGET (g_object_get_data (G_OBJECT (user_data), "status"));
status_message (GTK_STATUSBAR (status), "Help not available");
status_message (status, "Help not available");
}
static void
@@ -82,7 +86,7 @@ not_implemented (GSimpleAction *action,
text = g_strdup_printf ("Action “%s” not implemented", g_action_get_name (G_ACTION (action)));
status = GTK_WIDGET (g_object_get_data (G_OBJECT (user_data), "status"));
status_message (GTK_STATUSBAR (status), text);
status_message (status, text);
g_free (text);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 985 B

After

Width:  |  Height:  |  Size: 1019 B

View File

@@ -6,8 +6,6 @@
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static void
show_parsing_error (GtkCssProvider *provider,
GtkCssSection *section,
@@ -49,20 +47,23 @@ css_text_changed (GtkTextBuffer *buffer,
gtk_text_buffer_remove_all_tags (buffer, &start, &end);
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
gtk_css_provider_load_from_data (provider, text, -1);
gtk_css_provider_load_from_string (provider, text);
g_free (text);
}
static void
clear_provider (gpointer data)
{
GtkStyleProvider *provider = data;
gtk_style_context_remove_provider_for_display (gdk_display_get_default (), provider);
}
static void
apply_css (GtkWidget *widget, GtkStyleProvider *provider)
{
GtkWidget *child;
gtk_style_context_add_provider (gtk_widget_get_style_context (widget), provider, G_MAXUINT);
for (child = gtk_widget_get_first_child (widget);
child != NULL;
child = gtk_widget_get_next_sibling (child))
apply_css (child, provider);
gtk_style_context_add_provider_for_display (gdk_display_get_default (), provider, G_MAXUINT);
g_object_set_data_full (G_OBJECT (widget), "provider", provider, clear_provider);
}
GtkWidget *
@@ -81,6 +82,7 @@ do_css_basics (GtkWidget *do_widget)
gtk_window_set_title (GTK_WINDOW (window), "CSS Basics");
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
gtk_widget_add_css_class (window, "demo");
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
text = gtk_text_buffer_new (NULL);

View File

@@ -4,23 +4,24 @@
* anymore. :)
*/
/* This CSS resets all properties to their defaults values
* and overrides all user settings and the theme in use */
@import url("resource://css_basics/reset.css");
/* This resets all properties to their defaults values
* and overrides all user settings and the theme in use
*/
@import url("resource://css_shadows/reset.css");
/* Set a very futuristic style by default */
* {
.demo * {
color: green;
font-family: Monospace;
border: 1px solid;
}
window {
window.demo {
background-color: white;
}
/* Make sure selections are visible */
selection {
.demo selection {
background-color: darkGreen;
color: black;
}

View File

@@ -6,8 +6,6 @@
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static void
show_parsing_error (GtkCssProvider *provider,
GtkCssSection *section,
@@ -50,33 +48,23 @@ css_text_changed (GtkTextBuffer *buffer,
gtk_text_buffer_remove_all_tags (buffer, &start, &end);
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
gtk_css_provider_load_from_data (provider, text, -1);
gtk_css_provider_load_from_string (provider, text);
g_free (text);
}
static void
drawing_area_draw (GtkDrawingArea *da,
cairo_t *cr,
int width,
int height,
gpointer data)
clear_provider (gpointer data)
{
GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET (da));
GtkStyleProvider *provider = data;
gtk_render_background (context, cr, 0, 0, width, height);
gtk_render_frame (context, cr, 0, 0, width, height);
gtk_style_context_remove_provider_for_display (gdk_display_get_default (), provider);
}
static void
apply_css (GtkWidget *widget, GtkStyleProvider *provider)
{
GtkWidget *child;
gtk_style_context_add_provider (gtk_widget_get_style_context (widget), provider, G_MAXUINT);
for (child = gtk_widget_get_first_child (widget);
child != NULL;
child = gtk_widget_get_next_sibling (child))
apply_css (child, provider);
gtk_style_context_add_provider_for_display (gdk_display_get_default (), provider, G_MAXUINT);
g_object_set_data_full (G_OBJECT (widget), "provider", provider, clear_provider);
}
GtkWidget *
@@ -95,16 +83,17 @@ do_css_multiplebgs (GtkWidget *do_widget)
gtk_window_set_title (GTK_WINDOW (window), "Multiple Backgrounds");
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
gtk_widget_add_css_class (window, "demo");
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
overlay = gtk_overlay_new ();
gtk_window_set_child (GTK_WINDOW (window), overlay);
child = gtk_drawing_area_new ();
/* Don't set a draw_func, since we are only interested in CSS drawing,
* which happens automatically.
*/
gtk_widget_set_name (child, "canvas");
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (child),
drawing_area_draw,
NULL, NULL);
gtk_overlay_set_child (GTK_OVERLAY (overlay), child);
child = gtk_button_new ();

View File

@@ -7,8 +7,6 @@
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static void
show_parsing_error (GtkCssProvider *provider,
GtkCssSection *section,
@@ -51,20 +49,23 @@ css_text_changed (GtkTextBuffer *buffer,
gtk_text_buffer_remove_all_tags (buffer, &start, &end);
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
gtk_css_provider_load_from_data (provider, text, -1);
gtk_css_provider_load_from_string (provider, text);
g_free (text);
}
static void
clear_provider (gpointer data)
{
GtkStyleProvider *provider = data;
gtk_style_context_remove_provider_for_display (gdk_display_get_default (), provider);
}
static void
apply_css (GtkWidget *widget, GtkStyleProvider *provider)
{
GtkWidget *child;
gtk_style_context_add_provider (gtk_widget_get_style_context (widget), provider, G_MAXUINT);
for (child = gtk_widget_get_first_child (widget);
child != NULL;
child = gtk_widget_get_next_sibling (child))
apply_css (child, provider);
gtk_style_context_add_provider_for_display (gdk_display_get_default (), provider, G_MAXUINT);
g_object_set_data_full (G_OBJECT (widget), "provider", provider, clear_provider);
}
GtkWidget *
@@ -83,6 +84,7 @@ do_css_pixbufs (GtkWidget *do_widget)
gtk_window_set_title (GTK_WINDOW (window), "Animated Backgrounds");
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
gtk_widget_add_css_class (window, "demo");
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
paned = gtk_paned_new (GTK_ORIENTATION_VERTICAL);

View File

@@ -50,7 +50,7 @@
100% { background-size: 12px, 96px, 12px, 96px, 12px, 96px, 12px, 96px, auto; }
}
window {
window.demo {
background-image: url("resource://css_pixbufs/images/apple-red.png"),
url("resource://css_pixbufs/images/gnome-applets.png"),
url("resource://css_pixbufs/images/gnome-calendar.png"),
@@ -66,11 +66,11 @@ window {
}
/* Make the text editor has a nice style */
.view, scrollbar, separator {
window.demo .view, scrollbar, separator {
color: black;
background-color: rgba(255,255,255,0.5);
}
.view:selected {
window.demo .view:selected {
background-color: rgba(127,127,255,0.5);
}

View File

@@ -5,8 +5,6 @@
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static void
show_parsing_error (GtkCssProvider *provider,
GtkCssSection *section,
@@ -48,20 +46,23 @@ css_text_changed (GtkTextBuffer *buffer,
gtk_text_buffer_remove_all_tags (buffer, &start, &end);
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
gtk_css_provider_load_from_data (provider, text, -1);
gtk_css_provider_load_from_string (provider, text);
g_free (text);
}
static void
clear_provider (gpointer data)
{
GtkStyleProvider *provider = data;
gtk_style_context_remove_provider_for_display (gdk_display_get_default (), provider);
}
static void
apply_css (GtkWidget *widget, GtkStyleProvider *provider)
{
GtkWidget *child;
gtk_style_context_add_provider (gtk_widget_get_style_context (widget), provider, G_MAXUINT);
for (child = gtk_widget_get_first_child (widget);
child != NULL;
child = gtk_widget_get_next_sibling (child))
apply_css (child, provider);
gtk_style_context_add_provider_for_display (gdk_display_get_default (), provider, G_MAXUINT);
g_object_set_data_full (G_OBJECT (widget), "provider", provider, clear_provider);
}
static GtkWidget *
@@ -101,6 +102,7 @@ do_css_shadows (GtkWidget *do_widget)
gtk_window_set_title (GTK_WINDOW (window), "Shadows");
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
gtk_widget_add_css_class (window, "demo");
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
paned = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
@@ -142,7 +144,7 @@ do_css_shadows (GtkWidget *do_widget)
}
if (!gtk_widget_get_visible (window))
gtk_widget_set_visible (window, TRUE);
gtk_window_present (GTK_WINDOW (window));
else
gtk_window_destroy (GTK_WINDOW (window));

View File

@@ -5,12 +5,13 @@
*/
/* This CSS resets all properties to their defaults values
* and overrides all user settings and the theme in use */
* and overrides all user settings and the theme in use
*/
@import url("resource://css_shadows/reset.css");
@import url("resource://css_shadows/cssview.css");
/* Get a nice background for the window */
.background {
window.demo.background {
background-color: #4870bc;
background-image: linear-gradient(to left, transparent, rgba(255,255,255,.07) 50%, transparent 50%),
linear-gradient(to left, transparent, rgba(255,255,255,.13) 50%, transparent 50%),
@@ -19,7 +20,7 @@
background-size: 29px, 59px, 73px, 109px;
}
button {
window.demo button {
color: black;
padding: 10px;
border-radius: 5px;
@@ -27,18 +28,15 @@ button {
border: 1px transparent solid;
}
button:hover {
window.demo button:hover {
text-shadow: 3px 3px 5px alpha(black, 0.75);
-gtk-icon-shadow: 3px 3px 5px alpha(black, 0.75);
box-shadow: 3px 3px 5px alpha(black, 0.5) inset;
border: solid 1px alpha(black, 0.75);
}
button:active {
window.demo button:active {
padding: 11px 9px 9px 11px;
text-shadow: 1px 1px 2.5px alpha(black, 0.6);
-gtk-icon-shadow: 1px 1px 2.5px alpha(black, 0.6);
}

View File

@@ -1,21 +1,21 @@
/* Make the text editor has a nice style */
.view {
window.demo .view {
color: #2e3436;
font-family: Monospace;
background-color: alpha(white, 0.30);
}
.view:selected {
window.demo .view:selected {
color: white;
background-color: #4a90d9;
}
scrollbar trough,
window.demo scrollbar trough,
.scrollbars-junction {
background-color: alpha(white, 0.80);
}
scrollbar slider {
window.demo scrollbar slider {
border-width: 3px;
border-style: solid;
border-radius: 10px;
@@ -24,11 +24,11 @@ scrollbar slider {
background-color: #999;
}
scrollbar slider:hover {
window.demo scrollbar slider:hover {
background-color: #555;
}
paned separator {
window.demo paned separator {
background-color: alpha(white, 0.80);
background-image: linear-gradient(transparent, transparent 1px, #999 1px, #999 4px, transparent 4px);
background-size: 40px auto;
@@ -36,6 +36,6 @@ paned separator {
background-position: center;
}
paned separator:hover {
window.demo paned separator:hover {
background-image: linear-gradient(transparent, transparent 1px, #555 1px, #555 4px, transparent 4px);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -127,6 +127,7 @@
<file>fishbowl.ui</file>
<file>gtkfishbowl.c</file>
<file>gtkfishbowl.h</file>
<file>tiger.node</file>
</gresource>
<gresource prefix="/frames">
<file>frames.ui</file>
@@ -335,6 +336,11 @@
<file>paintable_symbolic.c</file>
<file>panes.c</file>
<file>password_entry.c</file>
<file>path_fill.c</file>
<file>path_maze.c</file>
<file>path_spinner.c</file>
<file>path_walk.c</file>
<file>path_text.c</file>
<file>peg_solitaire.c</file>
<file>pickers.c</file>
<file>printing.c</file>
@@ -420,6 +426,13 @@
<gresource prefix="/fontrendering">
<file>fontrendering.ui</file>
</gresource>
<gresource prefix="/path_walk">
<file>path_walk.ui</file>
<file compressed="true">path_world.txt</file>
</gresource>
<gresource prefix="/path_text">
<file>path_text.ui</file>
</gresource>
<gresource prefix="/org/gtk/Demo4">
<file>icons/16x16/actions/application-exit.png</file>
<file>icons/16x16/actions/document-new.png</file>

View File

@@ -208,7 +208,13 @@
</object>
</child>
<child>
<object class="GtkStatusbar" id="statusbar1"/>
<object class="GtkLabel" id="statusbar1">
<property name="xalign">0</property>
<property name="margin-start">2</property>
<property name="margin-end">2</property>
<property name="margin-top">2</property>
<property name="margin-bottom">2</property>
</object>
</child>
</object>
</child>

View File

@@ -34,7 +34,7 @@ transition (GtkWidget *widget,
{
DemoWidget *self = DEMO_WIDGET (widget);
DemoLayout *demo_layout = DEMO_LAYOUT (gtk_widget_get_layout_manager (widget));
gint64 now = g_get_monotonic_time ();
gint64 now = gdk_frame_clock_get_frame_time (frame_clock);
gtk_widget_queue_allocate (widget);
@@ -66,11 +66,13 @@ clicked (GtkGestureClick *gesture,
gpointer data)
{
DemoWidget *self = data;
GdkFrameClock *frame_clock;
if (self->tick_id != 0)
return;
self->start_time = g_get_monotonic_time ();
frame_clock = gtk_widget_get_frame_clock (GTK_WIDGET (self));
self->start_time = gdk_frame_clock_get_frame_time (frame_clock);
self->tick_id = gtk_widget_add_tick_callback (GTK_WIDGET (self), transition, NULL, NULL);
}

View File

@@ -162,27 +162,39 @@ click_done (GtkGesture *gesture)
gtk_widget_insert_after (item, canvas, last_child);
}
/* GtkSettings treats `GTK_THEME=foo:dark` as theme name `foo`, variant `dark`,
* and our embedded CSS files let `foo-dark` work as an alias for `foo:dark`. */
static gboolean
has_dark_suffix (const char *theme)
{
return g_str_has_suffix (theme, ":dark") ||
g_str_has_suffix (theme, "-dark");
}
/* So we can make a good guess whether the current theme is dark by checking for
* either: it is suffixed `[:-]dark`, or Settings:…prefer-dark-theme is TRUE. */
static gboolean
theme_is_dark (void)
{
const char *env_theme;
GtkSettings *settings;
char *theme;
gboolean prefer_dark;
gboolean dark;
/* Like GtkSettings, 1st see if theme is overridden by environment variable */
env_theme = g_getenv ("GTK_THEME");
if (env_theme != NULL)
return has_dark_suffix (env_theme);
/* If not, test Settings:…theme-name in the same way OR :…prefer-dark-theme */
settings = gtk_settings_get_default ();
g_object_get (settings,
"gtk-theme-name", &theme,
"gtk-application-prefer-dark-theme", &prefer_dark,
NULL);
if ((strcmp (theme, "Adwaita") == 0 && prefer_dark) || strcmp (theme, "HighContrastInverse") == 0)
dark = TRUE;
else
dark = FALSE;
dark = prefer_dark || has_dark_suffix (theme);
g_free (theme);
return dark;
}
@@ -748,9 +760,7 @@ do_dnd (GtkWidget *do_widget)
GtkCssProvider *provider;
GString *css;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
button = gtk_color_button_new ();
G_GNUC_END_IGNORE_DEPRECATIONS
button = gtk_color_dialog_button_new (gtk_color_dialog_new ());
g_object_unref (g_object_ref_sink (button));
provider = gtk_css_provider_new ();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -10,8 +10,6 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static GtkWidget *window = NULL;
static void
@@ -45,21 +43,22 @@ do_expander (GtkWidget *do_widget)
if (!window)
{
toplevel = GTK_WIDGET (gtk_widget_get_root (do_widget));
window = gtk_message_dialog_new_with_markup (GTK_WINDOW (toplevel),
0,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
"<big><b>%s</b></big>",
"Something went wrong");
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (window),
"Here are some more details "
"but not the full story.");
area = gtk_message_dialog_get_message_area (GTK_MESSAGE_DIALOG (window));
label = gtk_widget_get_last_child (area);
window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (window), "Expander");
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (toplevel));
area = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
gtk_widget_set_margin_start (area, 10);
gtk_widget_set_margin_end (area, 10);
gtk_widget_set_margin_top (area, 10);
gtk_widget_set_margin_bottom (area, 10);
gtk_window_set_child (GTK_WINDOW (window), area);
label = gtk_label_new ("<big><b>Something went wrong</b></big>");
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
gtk_box_append (GTK_BOX (area), label);
label = gtk_label_new ("Here are some more details but not the full story");
gtk_label_set_wrap (GTK_LABEL (label), FALSE);
gtk_widget_set_vexpand (label, FALSE);
gtk_box_append (GTK_BOX (area), label);
expander = gtk_expander_new ("Details:");
gtk_widget_set_vexpand (expander, TRUE);
@@ -122,7 +121,7 @@ do_expander (GtkWidget *do_widget)
}
if (!gtk_widget_get_visible (window))
gtk_widget_set_visible (window, TRUE);
gtk_window_present (GTK_WINDOW (window));
else
gtk_window_destroy (GTK_WINDOW (window));

View File

@@ -11,6 +11,9 @@
#include "gtkgears.h"
#include "gskshaderpaintable.h"
#include "nodewidget.h"
#include "graphwidget.h"
const char *const css =
".blurred-button {"
" box-shadow: 0px 0px 5px 10px rgba(0, 0, 0, 0.5);"
@@ -68,13 +71,11 @@ create_blurred_button (void)
return w;
}
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static GtkWidget *
create_font_button (void)
{
return gtk_font_button_new ();
return gtk_font_dialog_button_new (gtk_font_dialog_new ());
}
G_GNUC_END_IGNORE_DEPRECATIONS
static GtkWidget *
create_level_bar (void)
@@ -203,6 +204,18 @@ create_menu_button (void)
return w;
}
static GtkWidget *
create_tiger (void)
{
return node_widget_new ("/fishbowl/tiger.node");
}
static GtkWidget *
create_graph (void)
{
return graph_widget_new ();
}
static const struct {
const char *name;
GtkWidget * (*create_func) (void);
@@ -220,6 +233,8 @@ static const struct {
{ "Switch", create_switch },
{ "Menubutton", create_menu_button },
{ "Shader", create_cogs },
{ "Tiger", create_tiger },
{ "Graph", create_graph },
};
static int selected_widget_type = -1;
@@ -310,11 +325,20 @@ do_fishbowl (GtkWidget *do_widget)
if (!window)
{
GtkBuilder *builder;
GtkBuilderScope *scope;
GtkWidget *bowl;
g_type_ensure (GTK_TYPE_FISHBOWL);
builder = gtk_builder_new_from_resource ("/fishbowl/fishbowl.ui");
scope = gtk_builder_cscope_new ();
gtk_builder_cscope_add_callback (GTK_BUILDER_CSCOPE (scope), fishbowl_prev_button_clicked_cb);
gtk_builder_cscope_add_callback (GTK_BUILDER_CSCOPE (scope), fishbowl_next_button_clicked_cb);
gtk_builder_cscope_add_callback (GTK_BUILDER_CSCOPE (scope), fishbowl_changes_toggled_cb);
gtk_builder_cscope_add_callback (GTK_BUILDER_CSCOPE (scope), format_header_cb);
builder = gtk_builder_new ();
gtk_builder_set_scope (builder, scope);
gtk_builder_add_from_resource (builder, "/fishbowl/fishbowl.ui", NULL);
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
@@ -326,6 +350,7 @@ do_fishbowl (GtkWidget *do_widget)
gtk_widget_realize (window);
g_object_unref (builder);
g_object_unref (scope);
}
if (!gtk_widget_get_visible (window))

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -0,0 +1,153 @@
#include "graphwidget.h"
struct _GraphWidget
{
GtkWidget parent_instance;
GskPath *path;
GskStroke *stroke;
GdkRGBA color;
guint tick_cb;
guint64 start_time;
double period;
double amplitude;
};
struct _GraphWidgetClass
{
GtkWidgetClass parent_class;
};
G_DEFINE_TYPE (GraphWidget, graph_widget, GTK_TYPE_WIDGET)
static void
update_path (GraphWidget *self,
float amplitude)
{
graphene_point_t p[20];
GskPathBuilder *builder;
g_clear_pointer (&self->path, gsk_path_unref);
for (int i = 0; i < 20; i++)
{
p[i].x = 10 * i;
p[i].y = 50;
if (i % 4 == 1 || i % 4 == 2)
{
if (i % 8 < 4)
p[i].y += amplitude;
else
p[i].y -= amplitude;
}
}
builder = gsk_path_builder_new ();
gsk_path_builder_move_to (builder, p[0].x, p[0].y);
for (int i = 0; i < 20; i += 4)
gsk_path_builder_cubic_to (builder,
p[i+1].x, p[i+1].y,
p[i+2].x, p[i+2].y,
p[i+3].x, p[i+3].y);
self->path = gsk_path_builder_free_to_path (builder);
}
static gboolean
tick_cb (GtkWidget *widget,
GdkFrameClock *frame_clock,
gpointer user_data)
{
GraphWidget *self = GRAPH_WIDGET (widget);
guint64 now;
double angle;
now = gdk_frame_clock_get_frame_time (frame_clock);
if (self->start_time == 0)
self->start_time = now;
angle = 360 * (now - self->start_time) / (double)(self->period * G_TIME_SPAN_MINUTE);
update_path (self, sin (angle) * self->amplitude);
gtk_widget_queue_draw (widget);
return G_SOURCE_CONTINUE;
}
static void
graph_widget_init (GraphWidget *self)
{
self->color.red = g_random_double_range (0, 1);
self->color.green = g_random_double_range (0, 1);
self->color.blue = g_random_double_range (0, 1);
self->color.alpha = 1;
self->period = g_random_double_range (0.5, 1);
self->amplitude = g_random_double_range (10, 25);
self->stroke = gsk_stroke_new (2);
update_path (self, 0);
self->start_time = 0;
self->tick_cb = gtk_widget_add_tick_callback (GTK_WIDGET (self), tick_cb, NULL, NULL);
}
static void
graph_widget_dispose (GObject *object)
{
GraphWidget *self = GRAPH_WIDGET (object);
g_clear_pointer (&self->path, gsk_path_unref);
gsk_stroke_free (self->stroke);
G_OBJECT_CLASS (graph_widget_parent_class)->dispose (object);
}
static void
graph_widget_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot)
{
GraphWidget *self = GRAPH_WIDGET (widget);
gtk_snapshot_append_stroke (snapshot, self->path, self->stroke, &self->color);
}
static void
graph_widget_measure (GtkWidget *widget,
GtkOrientation orientation,
int for_size,
int *minimum,
int *natural,
int *minimum_baseline,
int *natural_baseline)
{
if (orientation == GTK_ORIENTATION_HORIZONTAL)
*minimum = *natural = 200;
else
*minimum = *natural = 100;
}
static void
graph_widget_class_init (GraphWidgetClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
object_class->dispose = graph_widget_dispose;
widget_class->snapshot = graph_widget_snapshot;
widget_class->measure = graph_widget_measure;
}
GtkWidget *
graph_widget_new (void)
{
return g_object_new (GRAPH_TYPE_WIDGET, NULL);
}

View File

@@ -0,0 +1,8 @@
#pragma once
#include <gtk/gtk.h>
#define GRAPH_TYPE_WIDGET (graph_widget_get_type ())
G_DECLARE_FINAL_TYPE (GraphWidget, graph_widget, GRAPH, WIDGET, GtkWidget)
GtkWidget * graph_widget_new (void);

View File

@@ -840,24 +840,24 @@ gtk_gears_unrealize (GtkWidget *widget)
GtkGearsPrivate *priv = gtk_gears_get_instance_private ((GtkGears *) widget);
gtk_gl_area_make_current (glarea);
if (gtk_gl_area_get_error (glarea) != NULL)
return;
if (gtk_gl_area_get_error (glarea) == NULL)
{
/* Release the resources associated with OpenGL */
if (priv->gear_vbo[0] != 0)
glDeleteBuffers (1, &(priv->gear_vbo[0]));
/* Release the resources associated with OpenGL */
if (priv->gear_vbo[0] != 0)
glDeleteBuffers (1, &(priv->gear_vbo[0]));
if (priv->gear_vbo[1] != 0)
glDeleteBuffers (1, &(priv->gear_vbo[1]));
if (priv->gear_vbo[1] != 0)
glDeleteBuffers (1, &(priv->gear_vbo[1]));
if (priv->gear_vbo[2] != 0)
glDeleteBuffers (1, &(priv->gear_vbo[2]));
if (priv->gear_vbo[2] != 0)
glDeleteBuffers (1, &(priv->gear_vbo[2]));
if (priv->vao != 0)
glDeleteVertexArrays (1, &priv->vao);
if (priv->vao != 0)
glDeleteVertexArrays (1, &priv->vao);
if (priv->program != 0)
glDeleteProgram (priv->program);
if (priv->program != 0)
glDeleteProgram (priv->program);
}
priv->ModelViewProjectionMatrix_location = 0;
priv->NormalMatrix_location = 0;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -354,10 +354,18 @@ do_iconscroll (GtkWidget *do_widget)
if (!window)
{
GtkBuilder *builder;
GtkBuilderScope *scope;
GtkWidget *label;
guint id;
builder = gtk_builder_new_from_resource ("/iconscroll/iconscroll.ui");
scope = gtk_builder_cscope_new ();
gtk_builder_cscope_add_callback (GTK_BUILDER_CSCOPE (scope), iconscroll_prev_clicked_cb);
gtk_builder_cscope_add_callback (GTK_BUILDER_CSCOPE (scope), iconscroll_next_clicked_cb);
builder = gtk_builder_new ();
gtk_builder_set_scope (builder, scope);
gtk_builder_add_from_resource (builder, "/iconscroll/iconscroll.ui", NULL);
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
gtk_window_set_display (GTK_WINDOW (window),
@@ -375,6 +383,7 @@ do_iconscroll (GtkWidget *do_widget)
GUINT_TO_POINTER (id), remove_timeout);
g_object_unref (builder);
g_object_unref (scope);
}
if (!gtk_widget_get_visible (window))

View File

@@ -52,6 +52,10 @@ setup_listitem_cb (GtkListItemFactory *factory,
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
image = gtk_image_new ();
gtk_accessible_update_property (GTK_ACCESSIBLE (image),
GTK_ACCESSIBLE_PROPERTY_LABEL,
"App icon",
-1);
gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
gtk_box_append (GTK_BOX (box), image);
label = gtk_label_new ("");
@@ -79,6 +83,7 @@ bind_listitem_cb (GtkListItemFactory *factory,
gtk_image_set_from_gicon (GTK_IMAGE (image), g_app_info_get_icon (app_info));
gtk_label_set_label (GTK_LABEL (label), g_app_info_get_display_name (app_info));
gtk_list_item_set_accessible_label (list_item, g_app_info_get_display_name (app_info));
}
/* In more complex code, we would also need functions to unbind and teardown

View File

@@ -431,6 +431,9 @@ setup_listitem_cb (GtkListItemFactory *factory,
picture = gtk_picture_new ();
gtk_expression_bind (expression, picture, "paintable", picture);
gtk_box_append (GTK_BOX (box), picture);
gtk_accessible_update_relation (GTK_ACCESSIBLE (picture),
GTK_ACCESSIBLE_RELATION_LABELLED_BY, location_label, NULL,
-1);
/* And finally, everything comes together.
@@ -487,6 +490,9 @@ do_listview_clocks (GtkWidget *do_widget)
model = GTK_SELECTION_MODEL (gtk_no_selection_new (create_clocks_model ()));
gridview = gtk_grid_view_new (model, factory);
gtk_accessible_update_property (GTK_ACCESSIBLE (gridview),
GTK_ACCESSIBLE_PROPERTY_LABEL, "Clocks",
-1);
gtk_scrollable_set_hscroll_policy (GTK_SCROLLABLE (gridview), GTK_SCROLL_NATURAL);
gtk_scrollable_set_vscroll_policy (GTK_SCROLLABLE (gridview), GTK_SCROLL_NATURAL);

View File

@@ -72,6 +72,11 @@ demos = files([
'paintable_symbolic.c',
'panes.c',
'password_entry.c',
'path_fill.c',
'path_maze.c',
'path_spinner.c',
'path_walk.c',
'path_text.c',
'peg_solitaire.c',
'pickers.c',
'printing.c',
@@ -136,6 +141,8 @@ extra_demo_sources = files([
'unicode-names.c',
'suggestionentry.c',
'language-names.c',
'nodewidget.c',
'graphwidget.c',
])
if os_unix
@@ -150,25 +157,13 @@ if librsvg_dep.found()
gtkdemo_deps += [ librsvg_dep ]
endif
gtkdemo_args = [ '-DGDK_DISABLE_DEPRECATED', '-DGTK_DISABLE_DEPRECATED', ]
demos_h = custom_target('gtk4 demo header',
output: 'demos.h',
input: demos,
command: [ find_program('geninclude.py'), '@OUTPUT@', '@INPUT@' ],
)
objcopy_supports_add_symbol = false
objcopy = find_program('objcopy', required : false)
if objcopy.found()
objcopy_supports_add_symbol = run_command(objcopy, '--help', check: false).stdout().contains('--add-symbol')
endif
ld = find_program('ld', required : false)
if not meson.is_cross_build() and build_machine.cpu_family() != 'arm' and build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_add_symbol and ld.found()
glib_compile_resources = find_program('glib-compile-resources')
if can_use_objcopy_for_resources
# Create the resource blob
gtkdemo_gresource = custom_target('gtkdemo.gresource',
input : 'demo.gresource.xml',
@@ -216,6 +211,7 @@ if not meson.is_cross_build() and build_machine.cpu_family() != 'arm' and build_
output : 'gtkdemo_resources2.o',
command : [objcopy,
'--strip-all',
'--set-section-alignment', '.data=8',
'--add-symbol','_g_binary_gtkdemo_resource_data=.data:0',
'@INPUT@',
'@OUTPUT@'])
@@ -244,7 +240,7 @@ gtkdemo_deps += [ demo_conf_h ]
executable('gtk4-demo',
sources: [demos, demos_h, extra_demo_sources, gtkdemo_resources],
c_args: gtkdemo_args + demo_cflags,
c_args: demo_cflags,
dependencies: gtkdemo_deps,
include_directories: confinc,
win_subsystem: 'windows',
@@ -254,7 +250,7 @@ executable('gtk4-demo',
executable('gtk4-demo-application',
sources: ['application.c', gtkdemo_resources],
c_args: gtkdemo_args + common_cflags,
c_args: common_cflags,
dependencies: gtkdemo_deps,
include_directories: confinc,
win_subsystem: 'windows',

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -0,0 +1,76 @@
#include "nodewidget.h"
struct _NodeWidget
{
GtkWidget parent_instance;
GskRenderNode *node;
};
struct _NodeWidgetClass
{
GtkWidgetClass parent_class;
};
G_DEFINE_TYPE (NodeWidget, node_widget, GTK_TYPE_WIDGET)
static void
node_widget_init (NodeWidget *self)
{
}
static void
node_widget_dispose (GObject *object)
{
NodeWidget *self = NODE_WIDGET (object);
gsk_render_node_unref (self->node);
G_OBJECT_CLASS (node_widget_parent_class)->dispose (object);
}
static void
node_widget_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot)
{
NodeWidget *self = NODE_WIDGET (widget);
gtk_snapshot_append_node (snapshot, self->node);
}
static void
node_widget_class_init (NodeWidgetClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
object_class->dispose = node_widget_dispose;
widget_class->snapshot = node_widget_snapshot;
}
GtkWidget *
node_widget_new (const char *resource)
{
NodeWidget *self;
GBytes *bytes;
GskRenderNode *node;
graphene_rect_t bounds;
float scale;
GskTransform *transform;
self = g_object_new (NODE_TYPE_WIDGET, NULL);
bytes = g_resources_lookup_data (resource, 0, NULL);
node = gsk_render_node_deserialize (bytes, NULL, NULL);
g_bytes_unref (bytes);
gsk_render_node_get_bounds (node, &bounds);
scale = MIN (100.0/bounds.size.width, 100.0/bounds.size.height);
transform = gsk_transform_scale (NULL, scale, scale);
self->node = gsk_transform_node_new (node, transform);
gsk_transform_unref (transform);
gsk_render_node_unref (node);
return GTK_WIDGET (self);
}

View File

@@ -0,0 +1,8 @@
#pragma once
#include <gtk/gtk.h>
#define NODE_TYPE_WIDGET (node_widget_get_type ())
G_DECLARE_FINAL_TYPE (NodeWidget, node_widget, NODE, WIDGET, GtkWidget)
GtkWidget * node_widget_new (const char *file);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -7,8 +7,6 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
enum {
COLOR_SET,
N_SIGNALS
@@ -124,19 +122,16 @@ drawing_area_unmap (GtkWidget *widget)
static void
drawing_area_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot)
GtkSnapshot *snapshot)
{
DrawingArea *area = (DrawingArea *) widget;
GtkAllocation allocation;
int width, height;
cairo_t *cr;
gtk_widget_get_allocation (widget, &allocation);
cr = gtk_snapshot_append_cairo (snapshot,
&GRAPHENE_RECT_INIT (
0, 0,
allocation.width,
allocation.height
));
width = gtk_widget_get_width (widget);
height = gtk_widget_get_height (widget);
cr = gtk_snapshot_append_cairo (snapshot, &GRAPHENE_RECT_INIT (0, 0, width, height));
cairo_set_source_rgb (cr, 1, 1, 1);
cairo_paint (cr);
@@ -145,7 +140,7 @@ drawing_area_snapshot (GtkWidget *widget,
cairo_paint (cr);
cairo_set_source_rgb (cr, 0.6, 0.6, 0.6);
cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
cairo_rectangle (cr, 0, 0, width, height);
cairo_stroke (cr);
cairo_destroy (cr);

295
demos/gtk-demo/path_fill.c Normal file
View File

@@ -0,0 +1,295 @@
/* Path/Fill and Stroke
*
* This demo shows how to use GskPath to draw shapes that are (a bit)
* more complex than a rounded rectangle.
*
* It also demonstrates printing to a stream with GtkPrintDialog.
*/
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <cairo-pdf.h>
#include "paintable.h"
#define GTK_TYPE_LOGO_PAINTABLE (gtk_logo_paintable_get_type ())
G_DECLARE_FINAL_TYPE (GtkLogoPaintable, gtk_logo_paintable, GTK, LOGO_PAINTABLE, GObject)
struct _GtkLogoPaintable
{
GObject parent_instance;
int width;
int height;
GskPath *path[3];
GdkRGBA color[3];
GskPath *stroke_path;
GskStroke *stroke1;
GskStroke *stroke2;
GdkRGBA stroke_color;
};
struct _GtkLogoPaintableClass
{
GObjectClass parent_class;
};
static int
gtk_logo_paintable_get_intrinsic_width (GdkPaintable *paintable)
{
GtkLogoPaintable *self = GTK_LOGO_PAINTABLE (paintable);
return self->width;
}
static int
gtk_logo_paintable_get_intrinsic_height (GdkPaintable *paintable)
{
GtkLogoPaintable *self = GTK_LOGO_PAINTABLE (paintable);
return self->height;
}
static void
gtk_logo_paintable_snapshot (GdkPaintable *paintable,
GdkSnapshot *snapshot,
double width,
double height)
{
GtkLogoPaintable *self = GTK_LOGO_PAINTABLE (paintable);
for (unsigned int i = 0; i < 3; i++)
{
gtk_snapshot_push_fill (snapshot, self->path[i], GSK_FILL_RULE_WINDING);
gtk_snapshot_append_color (snapshot,
&self->color[i],
&GRAPHENE_RECT_INIT (0, 0, width, height));
gtk_snapshot_pop (snapshot);
}
for (unsigned int i = 0; i < 3; i++)
{
gtk_snapshot_push_stroke (snapshot, self->stroke_path, self->stroke1);
gtk_snapshot_append_color (snapshot,
&self->stroke_color,
&GRAPHENE_RECT_INIT (0, 0, width, height));
gtk_snapshot_pop (snapshot);
}
gtk_snapshot_push_stroke (snapshot, self->stroke_path, self->stroke2);
gtk_snapshot_append_color (snapshot,
&self->stroke_color,
&GRAPHENE_RECT_INIT (0, 0, width, height));
gtk_snapshot_pop (snapshot);
}
static GdkPaintableFlags
gtk_logo_paintable_get_flags (GdkPaintable *paintable)
{
return GDK_PAINTABLE_STATIC_CONTENTS | GDK_PAINTABLE_STATIC_SIZE;
}
static void
gtk_logo_paintable_paintable_init (GdkPaintableInterface *iface)
{
iface->get_intrinsic_width = gtk_logo_paintable_get_intrinsic_width;
iface->get_intrinsic_height = gtk_logo_paintable_get_intrinsic_height;
iface->snapshot = gtk_logo_paintable_snapshot;
iface->get_flags = gtk_logo_paintable_get_flags;
}
/* When defining the GType, we need to implement the GdkPaintable interface */
G_DEFINE_TYPE_WITH_CODE (GtkLogoPaintable, gtk_logo_paintable, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
gtk_logo_paintable_paintable_init))
static void
gtk_logo_paintable_dispose (GObject *object)
{
GtkLogoPaintable *self = GTK_LOGO_PAINTABLE (object);
for (unsigned int i = 0; i < 3; i++)
gsk_path_unref (self->path[i]);
gsk_path_unref (self->stroke_path);
gsk_stroke_free (self->stroke1);
gsk_stroke_free (self->stroke2);
G_OBJECT_CLASS (gtk_logo_paintable_parent_class)->dispose (object);
}
static void
gtk_logo_paintable_class_init (GtkLogoPaintableClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->dispose = gtk_logo_paintable_dispose;
}
static void
gtk_logo_paintable_init (GtkLogoPaintable *self)
{
}
static GdkPaintable *
gtk_logo_paintable_new (void)
{
GtkLogoPaintable *self;
graphene_rect_t bounds, bounds2;
self = g_object_new (GTK_TYPE_LOGO_PAINTABLE, NULL);
/* Paths and colors extracted from gtk-logo.svg */
self->path[0] = gsk_path_parse ("m3.12,66.17 -2.06,-51.46 32.93,24.7 v55.58 l-30.87,-28.82 z");
self->path[1] = gsk_path_parse ("m34,95 49.4,-20.58 4.12,-51.46 -53.52,16.47 v55.58 z");
self->path[2] = gsk_path_parse ("m1.06,14.71 32.93,24.7 53.52,-16.47 -36.75,-21.88 -49.7,13.65 z");
gdk_rgba_parse (&self->color[0], "#e40000");
gdk_rgba_parse (&self->color[1], "#7fe719");
gdk_rgba_parse (&self->color[2], "#729fcf");
self->stroke_path = gsk_path_parse ("m50.6,51.3 -47.3,14 z l33,23 z v-50");
self->stroke1 = gsk_stroke_new (2.12);
self->stroke2 = gsk_stroke_new (1.25);
gdk_rgba_parse (&self->stroke_color, "#ffffff");
gsk_path_get_stroke_bounds (self->path[0], self->stroke1, &bounds);
gsk_path_get_stroke_bounds (self->path[1], self->stroke1, &bounds2);
graphene_rect_union (&bounds, &bounds2, &bounds);
gsk_path_get_stroke_bounds (self->path[2], self->stroke1, &bounds2);
graphene_rect_union (&bounds, &bounds2, &bounds);
gsk_path_get_stroke_bounds (self->stroke_path, self->stroke2, &bounds2);
graphene_rect_union (&bounds, &bounds2, &bounds);
self->width = bounds.origin.x + bounds.size.width;
self->height = bounds.origin.y + bounds.size.height;
return GDK_PAINTABLE (self);
}
static cairo_status_t
write_cairo (void *closure,
const unsigned char *data,
unsigned int length)
{
GOutputStream *stream = closure;
gsize written;
GError *error = NULL;
if (!g_output_stream_write_all (stream, data, length, &written, NULL, &error))
{
g_print ("Error writing pdf stream: %s\n", error->message);
g_error_free (error);
return CAIRO_STATUS_WRITE_ERROR;
}
return CAIRO_STATUS_SUCCESS;
}
static void
print_ready (GObject *source,
GAsyncResult *result,
gpointer data)
{
GtkPrintDialog *dialog = GTK_PRINT_DIALOG (source);
GError *error = NULL;
GOutputStream *stream;
GtkSnapshot *snapshot;
GdkPaintable *paintable;
GskRenderNode *node;
cairo_surface_t *surface;
cairo_t *cr;
stream = gtk_print_dialog_print_finish (dialog, result, &error);
if (stream == NULL)
{
g_print ("Failed to get output stream: %s\n", error->message);
g_error_free (error);
return;
}
snapshot = gtk_snapshot_new ();
paintable = gtk_picture_get_paintable (GTK_PICTURE (data));
gdk_paintable_snapshot (paintable, snapshot, 100, 100);
node = gtk_snapshot_free_to_node (snapshot);
surface = cairo_pdf_surface_create_for_stream (write_cairo, stream, 100, 100);
cr = cairo_create (surface);
gsk_render_node_draw (node, cr);
cairo_destroy (cr);
cairo_surface_destroy (surface);
gsk_render_node_unref (node);
if (!g_output_stream_close (stream, NULL, &error))
{
g_print ("Error from close: %s\n", error->message);
g_error_free (error);
}
g_object_unref (stream);
}
static void
print (GtkButton *button,
gpointer data)
{
GtkWidget *picture = data;
GtkPrintDialog *dialog;
dialog = gtk_print_dialog_new ();
gtk_print_dialog_print (dialog,
GTK_WINDOW (gtk_widget_get_root (picture)),
NULL,
NULL,
print_ready,
picture);
g_object_unref (dialog);
}
GtkWidget *
do_path_fill (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;
if (!window)
{
GtkWidget *header, *button, *label;
GtkWidget *picture;
GdkPaintable *paintable;
window = gtk_window_new ();
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
gtk_window_set_default_size (GTK_WINDOW (window), 100, 100);
gtk_window_set_title (GTK_WINDOW (window), "Fill and Stroke");
header = gtk_header_bar_new ();
button = gtk_button_new_from_icon_name ("printer-symbolic");
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), button);
label = gtk_label_new ("Fill and Stroke");
gtk_widget_add_css_class (label, "title");
gtk_header_bar_set_title_widget (GTK_HEADER_BAR (header), label);
gtk_window_set_titlebar (GTK_WINDOW (window), header);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
paintable = gtk_logo_paintable_new ();
picture = gtk_picture_new_for_paintable (paintable);
gtk_picture_set_content_fit (GTK_PICTURE (picture), GTK_CONTENT_FIT_CONTAIN);
gtk_picture_set_can_shrink (GTK_PICTURE (picture), FALSE);
g_object_unref (paintable);
g_signal_connect (button, "clicked", G_CALLBACK (print), picture);
gtk_window_set_child (GTK_WINDOW (window), picture);
}
if (!gtk_widget_get_visible (window))
gtk_window_present (GTK_WINDOW (window));
else
gtk_window_destroy (GTK_WINDOW (window));
return window;
}

369
demos/gtk-demo/path_maze.c Normal file
View File

@@ -0,0 +1,369 @@
/* Path/Maze
*
* This demo shows how to use a GskPath to create a maze and use
* gsk_path_get_closest_point() to check the mouse stays
* on the path.
*
* It also shows off the performance of GskPath (or not) as this
* is a rather complex path.
*/
#include "config.h"
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include "paintable.h"
#define MAZE_GRID_SIZE 20
#define MAZE_STROKE_SIZE_ACTIVE (MAZE_GRID_SIZE - 4)
#define MAZE_STROKE_SIZE_INACTIVE (MAZE_GRID_SIZE - 12)
#define MAZE_WIDTH 31
#define MAZE_HEIGHT 21
#define GTK_TYPE_MAZE (gtk_maze_get_type ())
G_DECLARE_FINAL_TYPE (GtkMaze, gtk_maze, GTK, MAZE, GtkWidget)
struct _GtkMaze
{
GtkWidget parent_instance;
int width;
int height;
GskPath *path;
GskPathMeasure *measure;
GdkPaintable *background;
gboolean active;
};
struct _GtkMazeClass
{
GtkWidgetClass parent_class;
};
G_DEFINE_TYPE (GtkMaze, gtk_maze, GTK_TYPE_WIDGET)
static void
gtk_maze_measure (GtkWidget *widget,
GtkOrientation orientation,
int for_size,
int *minimum,
int *natural,
int *minimum_baseline,
int *natural_baseline)
{
GtkMaze *self = GTK_MAZE (widget);
if (orientation == GTK_ORIENTATION_HORIZONTAL)
*minimum = *natural = self->width;
else
*minimum = *natural = self->height;
}
static void
gtk_maze_snapshot (GtkWidget *widget,
GdkSnapshot *snapshot)
{
GtkMaze *self = GTK_MAZE (widget);
double width = gtk_widget_get_width (widget);
double height = gtk_widget_get_height (widget);
GskStroke *stroke;
stroke = gsk_stroke_new (MAZE_STROKE_SIZE_INACTIVE);
if (self->active)
gsk_stroke_set_line_width (stroke, MAZE_STROKE_SIZE_ACTIVE);
gsk_stroke_set_line_join (stroke, GSK_LINE_JOIN_ROUND);
gsk_stroke_set_line_cap (stroke, GSK_LINE_CAP_ROUND);
gtk_snapshot_push_stroke (snapshot, self->path, stroke);
gsk_stroke_free (stroke);
if (self->background)
{
gdk_paintable_snapshot (self->background, snapshot, width, height);
}
else
{
gtk_snapshot_append_linear_gradient (snapshot,
&GRAPHENE_RECT_INIT (0, 0, width, height),
&GRAPHENE_POINT_INIT (0, 0),
&GRAPHENE_POINT_INIT (width, height),
(GskColorStop[8]) {
{ 0.0, { 1.0, 0.0, 0.0, 1.0 } },
{ 0.2, { 1.0, 0.0, 0.0, 1.0 } },
{ 0.3, { 1.0, 1.0, 0.0, 1.0 } },
{ 0.4, { 0.0, 1.0, 0.0, 1.0 } },
{ 0.6, { 0.0, 1.0, 1.0, 1.0 } },
{ 0.7, { 0.0, 0.0, 1.0, 1.0 } },
{ 0.8, { 1.0, 0.0, 1.0, 1.0 } },
{ 1.0, { 1.0, 0.0, 1.0, 1.0 } }
},
8);
}
gtk_snapshot_pop (snapshot);
}
static void
gtk_maze_dispose (GObject *object)
{
GtkMaze *self = GTK_MAZE (object);
g_clear_pointer (&self->path, gsk_path_unref);
g_clear_pointer (&self->measure, gsk_path_measure_unref);
if (self->background)
{
g_signal_handlers_disconnect_matched (self->background, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, self);
g_clear_object (&self->background);
}
G_OBJECT_CLASS (gtk_maze_parent_class)->dispose (object);
}
static void
gtk_maze_class_init (GtkMazeClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->dispose = gtk_maze_dispose;
widget_class->measure = gtk_maze_measure;
widget_class->snapshot = gtk_maze_snapshot;
}
static void
celebrate (gboolean win)
{
char *path;
GtkMediaStream *stream;
if (win)
path = g_build_filename (GTK_DATADIR, "sounds", "freedesktop", "stereo", "complete.oga", NULL);
else
path = g_build_filename (GTK_DATADIR, "sounds", "freedesktop", "stereo", "suspend-error.oga", NULL);
stream = gtk_media_file_new_for_filename (path);
gtk_media_stream_set_volume (stream, 1.0);
gtk_media_stream_play (stream);
g_signal_connect (stream, "notify::ended", G_CALLBACK (g_object_unref), NULL);
g_free (path);
}
static void
pointer_motion (GtkEventControllerMotion *controller,
double x,
double y,
GtkMaze *self)
{
GskPathPoint point;
float distance;
if (!self->active)
return;
if (gsk_path_get_closest_point (self->path,
&GRAPHENE_POINT_INIT (x, y),
INFINITY,
&point,
&distance))
{
if (distance < MAZE_STROKE_SIZE_ACTIVE / 2.f)
return;
}
celebrate (FALSE);
self->active = FALSE;
gtk_widget_queue_draw (GTK_WIDGET (self));
}
static void
pointer_leave (GtkEventControllerMotion *controller,
GtkMaze *self)
{
if (!self->active)
{
self->active = TRUE;
gtk_widget_queue_draw (GTK_WIDGET (self));
}
}
static void
gtk_maze_init (GtkMaze *self)
{
GtkEventController *controller;
controller = GTK_EVENT_CONTROLLER (gtk_event_controller_motion_new ());
g_signal_connect (controller, "motion", G_CALLBACK (pointer_motion), self);
g_signal_connect (controller, "leave", G_CALLBACK (pointer_leave), self);
gtk_widget_add_controller (GTK_WIDGET (self), controller);
self->active = TRUE;
}
static void
gtk_maze_set_path (GtkMaze *self,
GskPath *path)
{
g_clear_pointer (&self->path, gsk_path_unref);
g_clear_pointer (&self->measure, gsk_path_measure_unref);
self->path = gsk_path_ref (path);
self->measure = gsk_path_measure_new (path);
gtk_widget_queue_draw (GTK_WIDGET (self));
}
GtkWidget *
gtk_maze_new (GskPath *path,
GdkPaintable *background,
int width,
int height)
{
GtkMaze *self;
self = g_object_new (GTK_TYPE_MAZE, NULL);
gtk_maze_set_path (self, path);
gsk_path_unref (path);
self->background = background;
if (self->background)
{
g_signal_connect_swapped (self->background, "invalidate-contents", G_CALLBACK (gtk_widget_queue_draw), self);
g_signal_connect_swapped (self->background, "invalidate-size", G_CALLBACK (gtk_widget_queue_resize), self);
}
self->width = width;
self->height = height;
return GTK_WIDGET (self);
}
static void
add_point_to_maze (GtkBitset *maze,
GskPathBuilder *builder,
guint x,
guint y)
{
gboolean set[4] = { FALSE, FALSE, FALSE, FALSE };
guint dir;
gtk_bitset_add (maze, y * MAZE_WIDTH + x);
while (TRUE)
{
set[0] = set[0] || x == 0 || gtk_bitset_contains (maze, y * MAZE_WIDTH + x - 1);
set[1] = set[1] || y == 0 || gtk_bitset_contains (maze, (y - 1) * MAZE_WIDTH + x);
set[2] = set[2] || x + 1 == MAZE_WIDTH || gtk_bitset_contains (maze, y * MAZE_WIDTH + x + 1);
set[3] = set[3] || y + 1 == MAZE_HEIGHT || gtk_bitset_contains (maze, (y + 1) * MAZE_WIDTH + x);
if (set[0] && set[1] && set[2] && set[3])
return;
do
{
dir = g_random_int_range (0, 4);
}
while (set[dir]);
switch (dir)
{
case 0:
gsk_path_builder_move_to (builder, (x + 0.5) * MAZE_GRID_SIZE, (y + 0.5) * MAZE_GRID_SIZE);
gsk_path_builder_line_to (builder, (x - 0.5) * MAZE_GRID_SIZE, (y + 0.5) * MAZE_GRID_SIZE);
add_point_to_maze (maze, builder, x - 1, y);
break;
case 1:
gsk_path_builder_move_to (builder, (x + 0.5) * MAZE_GRID_SIZE, (y + 0.5) * MAZE_GRID_SIZE);
gsk_path_builder_line_to (builder, (x + 0.5) * MAZE_GRID_SIZE, (y - 0.5) * MAZE_GRID_SIZE);
add_point_to_maze (maze, builder, x, y - 1);
break;
case 2:
gsk_path_builder_move_to (builder, (x + 0.5) * MAZE_GRID_SIZE, (y + 0.5) * MAZE_GRID_SIZE);
gsk_path_builder_line_to (builder, (x + 1.5) * MAZE_GRID_SIZE, (y + 0.5) * MAZE_GRID_SIZE);
add_point_to_maze (maze, builder, x + 1, y);
break;
case 3:
gsk_path_builder_move_to (builder, (x + 0.5) * MAZE_GRID_SIZE, (y + 0.5) * MAZE_GRID_SIZE);
gsk_path_builder_line_to (builder, (x + 0.5) * MAZE_GRID_SIZE, (y + 1.5) * MAZE_GRID_SIZE);
add_point_to_maze (maze, builder, x, y + 1);
break;
default:
g_assert_not_reached ();
break;
}
}
}
static GskPath *
create_path_for_maze (GtkWidget *widget)
{
GskPathBuilder *builder;
GtkBitset *maze;
builder = gsk_path_builder_new ();
maze = gtk_bitset_new_empty ();
/* make sure the outer lines are unreachable:
* Set the full range, then remove the center again. */
gtk_bitset_add_range (maze, 0, MAZE_WIDTH * MAZE_HEIGHT);
gtk_bitset_remove_rectangle (maze, MAZE_WIDTH + 1, MAZE_WIDTH - 2, MAZE_HEIGHT - 2, MAZE_WIDTH);
/* Fill the maze */
add_point_to_maze (maze, builder, MAZE_WIDTH / 2, MAZE_HEIGHT / 2);
/* Add start and stop lines */
gsk_path_builder_move_to (builder, 1.5 * MAZE_GRID_SIZE, -0.5 * MAZE_GRID_SIZE);
gsk_path_builder_line_to (builder, 1.5 * MAZE_GRID_SIZE, 1.5 * MAZE_GRID_SIZE);
gsk_path_builder_move_to (builder, (MAZE_WIDTH - 1.5) * MAZE_GRID_SIZE, (MAZE_HEIGHT - 1.5) * MAZE_GRID_SIZE);
gsk_path_builder_line_to (builder, (MAZE_WIDTH - 1.5) * MAZE_GRID_SIZE, (MAZE_HEIGHT + 0.5) * MAZE_GRID_SIZE);
gtk_bitset_unref (maze);
return gsk_path_builder_free_to_path (builder);
}
GtkWidget *
do_path_maze (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;
if (!window)
{
GtkWidget *maze;
GtkMediaStream *stream;
GskPath *path;
window = gtk_window_new ();
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
gtk_window_set_title (GTK_WINDOW (window), "Follow the maze with the mouse");
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
#if 0
stream = gtk_media_file_new_for_resource ("/images/gtk-logo.webm");
#else
stream = gtk_nuclear_media_stream_new ();
#endif
gtk_media_stream_play (stream);
gtk_media_stream_set_loop (stream, TRUE);
path = create_path_for_maze (window);
maze = gtk_maze_new (path,
GDK_PAINTABLE (stream),
MAZE_WIDTH * MAZE_GRID_SIZE,
MAZE_HEIGHT * MAZE_GRID_SIZE);
gtk_window_set_child (GTK_WINDOW (window), maze);
}
if (!gtk_widget_get_visible (window))
gtk_window_present (GTK_WINDOW (window));
else
gtk_window_destroy (GTK_WINDOW (window));
return window;
}

View File

@@ -0,0 +1,323 @@
/* Path/Spinner
*
* This demo shows how to use GskPath to draw a simple animation
* that could be used as a spinner.
*/
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include "paintable.h"
#undef SHOW_CONTROLS
#define GTK_TYPE_SPINNER_PAINTABLE (gtk_spinner_paintable_get_type ())
G_DECLARE_FINAL_TYPE (GtkSpinnerPaintable, gtk_spinner_paintable, GTK, SPINNER_PAINTABLE, GObject)
struct _GtkSpinnerPaintable
{
GObject parent_instance;
gint64 start_time;
int width;
double angle;
double completion;
GskPath *circle;
GskPath *path;
GskStroke *stroke;
GdkRGBA color;
GdkRGBA circle_color;
#ifdef SHOW_CONTROLS
GskPath *controls;
GdkRGBA control_color;
#endif
};
struct _GtkSpinnerPaintableClass
{
GObjectClass parent_class;
};
static int
gtk_spinner_paintable_get_intrinsic_width (GdkPaintable *paintable)
{
GtkSpinnerPaintable *self = GTK_SPINNER_PAINTABLE (paintable);
return self->width;
}
static int
gtk_spinner_paintable_get_intrinsic_height (GdkPaintable *paintable)
{
GtkSpinnerPaintable *self = GTK_SPINNER_PAINTABLE (paintable);
return self->width;
}
static void
gtk_spinner_paintable_snapshot (GdkPaintable *paintable,
GdkSnapshot *snapshot,
double width,
double height)
{
GtkSpinnerPaintable *self = GTK_SPINNER_PAINTABLE (paintable);
gtk_snapshot_append_stroke (snapshot, self->circle, self->stroke, &self->circle_color);
gtk_snapshot_append_stroke (snapshot, self->path, self->stroke, &self->color);
#ifdef SHOW_CONTROLS
GskStroke *stroke = gsk_stroke_new (1);
gtk_snapshot_append_stroke (snapshot, self->controls, stroke, &self->control_color);
gsk_stroke_free (stroke);
#endif
}
static GdkPaintableFlags
gtk_spinner_paintable_get_flags (GdkPaintable *paintable)
{
return GDK_PAINTABLE_STATIC_SIZE;
}
static void
gtk_spinner_paintable_paintable_init (GdkPaintableInterface *iface)
{
iface->get_intrinsic_width = gtk_spinner_paintable_get_intrinsic_width;
iface->get_intrinsic_height = gtk_spinner_paintable_get_intrinsic_height;
iface->snapshot = gtk_spinner_paintable_snapshot;
iface->get_flags = gtk_spinner_paintable_get_flags;
}
/* When defining the GType, we need to implement the GdkPaintable interface */
G_DEFINE_TYPE_WITH_CODE (GtkSpinnerPaintable, gtk_spinner_paintable, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
gtk_spinner_paintable_paintable_init))
static void
gtk_spinner_paintable_dispose (GObject *object)
{
GtkSpinnerPaintable *self = GTK_SPINNER_PAINTABLE (object);
gsk_path_unref (self->circle);
gsk_path_unref (self->path);
#ifdef SHOW_CONTROLS
gsk_path_unref (self->controls);
#endif
gsk_stroke_free (self->stroke);
G_OBJECT_CLASS (gtk_spinner_paintable_parent_class)->dispose (object);
}
static void
gtk_spinner_paintable_class_init (GtkSpinnerPaintableClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->dispose = gtk_spinner_paintable_dispose;
}
static void
gtk_spinner_paintable_init (GtkSpinnerPaintable *self)
{
}
static GdkPaintable *
gtk_spinner_paintable_new (void)
{
GtkSpinnerPaintable *self;
GskPathBuilder *builder;
self = g_object_new (GTK_TYPE_SPINNER_PAINTABLE, NULL);
builder = gsk_path_builder_new ();
gsk_path_builder_add_circle (builder, &GRAPHENE_POINT_INIT (50, 50), 40);
self->circle = gsk_path_builder_free_to_path (builder);
self->width = 100;
self->angle = 0;
self->completion = 1;
gdk_rgba_parse (&self->color, "green");
gdk_rgba_parse (&self->circle_color, "lightgray");
#ifdef SHOW_CONTROLS
gdk_rgba_parse (&self->control_color, "black");
#endif
self->stroke = gsk_stroke_new (5);
return GDK_PAINTABLE (self);
}
#ifdef SHOW_CONTROLS
static gboolean
add_controls (GskPathOperation op,
const graphene_point_t *pts,
gsize n_pts,
float weight,
gpointer data)
{
GskPathBuilder *builder = data;
switch (op)
{
case GSK_PATH_MOVE:
gsk_path_builder_move_to (builder, pts[0].x, pts[0].y);
break;
case GSK_PATH_CLOSE:
case GSK_PATH_LINE:
gsk_path_builder_line_to (builder, pts[1].x, pts[1].y);
break;
case GSK_PATH_QUAD:
case GSK_PATH_CONIC:
gsk_path_builder_line_to (builder, pts[1].x, pts[1].y);
gsk_path_builder_line_to (builder, pts[2].x, pts[2].y);
break;
case GSK_PATH_CUBIC:
gsk_path_builder_line_to (builder, pts[1].x, pts[1].y);
gsk_path_builder_line_to (builder, pts[2].x, pts[2].y);
gsk_path_builder_line_to (builder, pts[3].x, pts[3].y);
break;
default:
g_assert_not_reached ();
}
return TRUE;
}
#endif
static void
update_path (GtkSpinnerPaintable *self)
{
GskPathBuilder *builder;
GskPathPoint start, end;
graphene_point_t p0, p1;
float start_angle, end_angle;
start_angle = self->angle;
end_angle = fmod (self->angle + 360 * self->completion / 100, 360);
p0 = GRAPHENE_POINT_INIT (50 + 40 * cos (M_PI * start_angle / 180),
50 + 40 * sin (M_PI * start_angle / 180));
p1 = GRAPHENE_POINT_INIT (50 + 40 * cos (M_PI * end_angle / 180),
50 + 40 * sin (M_PI * end_angle / 180));
g_clear_pointer (&self->path, gsk_path_unref);
gsk_path_get_closest_point (self->circle, &p0, INFINITY, &start, NULL);
gsk_path_get_closest_point (self->circle, &p1, INFINITY, &end, NULL);
builder = gsk_path_builder_new ();
gsk_path_builder_add_segment (builder, self->circle, &start, &end);
self->path = gsk_path_builder_free_to_path (builder);
#ifdef SHOW_CONTROLS
g_clear_pointer (&self->controls, gsk_path_unref);
builder = gsk_path_builder_new ();
gsk_path_foreach (self->path, -1, add_controls, builder);
self->controls = gsk_path_builder_free_to_path (builder);
#endif
gdk_paintable_invalidate_contents (GDK_PAINTABLE (self));
}
static void
gtk_spinner_paintable_set_completion (GtkSpinnerPaintable *self,
float completion)
{
self->completion = CLAMP (completion, 0, 100);
update_path (self);
}
static float
gtk_spinner_paintable_get_completion (GtkSpinnerPaintable *self)
{
return self->completion;
}
static void
gtk_spinner_paintable_set_frame_time (GtkSpinnerPaintable *self,
gint64 time)
{
double delta;
if (self->start_time == 0)
self->start_time = time;
delta = (time - self->start_time) / (double) G_TIME_SPAN_SECOND;
self->angle = fmod (60 * delta, 360);
update_path (self);
}
static gboolean
tick_cb (GtkWidget *widget,
GdkFrameClock *clock,
gpointer data)
{
GtkSpinnerPaintable *self = data;
gtk_spinner_paintable_set_frame_time (self, gdk_frame_clock_get_frame_time (clock));
return G_SOURCE_CONTINUE;
}
static gboolean
progress_timeout (gpointer data)
{
GtkSpinnerPaintable *self = data;
static float progress_delta = 0.5;
float progress;
progress = gtk_spinner_paintable_get_completion (self);
if (progress >= 100 || progress <= 0)
progress_delta = -progress_delta;
gtk_spinner_paintable_set_completion (self, progress + progress_delta);
return G_SOURCE_CONTINUE;
}
static void
unset_timeout (gpointer data)
{
g_source_remove (GPOINTER_TO_UINT (data));
}
GtkWidget *
do_path_spinner (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;
if (!window)
{
GtkWidget *picture;
GdkPaintable *paintable;
guint timeout_id;
window = gtk_window_new ();
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
gtk_window_set_title (GTK_WINDOW (window), "Spinner");
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
paintable = gtk_spinner_paintable_new ();
picture = gtk_picture_new_for_paintable (paintable);
gtk_picture_set_content_fit (GTK_PICTURE (picture), GTK_CONTENT_FIT_CONTAIN);
gtk_picture_set_can_shrink (GTK_PICTURE (picture), FALSE);
g_object_unref (paintable);
gtk_widget_add_tick_callback (picture, tick_cb, paintable, NULL);
timeout_id = g_timeout_add (100, progress_timeout, paintable);
g_object_set_data_full (G_OBJECT (picture), "timeout", GUINT_TO_POINTER (timeout_id), unset_timeout);
gtk_window_set_child (GTK_WINDOW (window), picture);
}
if (!gtk_widget_get_visible (window))
gtk_window_present (GTK_WINDOW (window));
else
gtk_window_destroy (GTK_WINDOW (window));
return window;
}

584
demos/gtk-demo/path_text.c Normal file
View File

@@ -0,0 +1,584 @@
/* Path/Text
*
* This demo shows how to use GskPath to transform a path along another path.
*
* It also demonstrates that paths can be filled with more interesting
* content than just plain colors.
*/
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#define GTK_TYPE_PATH_WIDGET (gtk_path_widget_get_type ())
G_DECLARE_FINAL_TYPE (GtkPathWidget, gtk_path_widget, GTK, PATH_WIDGET, GtkWidget)
#define POINT_SIZE 8
enum {
PROP_0,
PROP_TEXT,
PROP_EDITABLE,
N_PROPS
};
struct _GtkPathWidget
{
GtkWidget parent_instance;
char *text;
gboolean editable;
graphene_point_t points[4];
guint active_point;
GskPath *line_path;
GskPath *text_path;
GdkPaintable *background;
};
struct _GtkPathWidgetClass
{
GtkWidgetClass parent_class;
};
static GParamSpec *properties[N_PROPS] = { NULL, };
G_DEFINE_TYPE (GtkPathWidget, gtk_path_widget, GTK_TYPE_WIDGET)
static GskPath *
create_path_from_text (GtkWidget *widget,
const char *text,
graphene_point_t *out_offset)
{
PangoLayout *layout;
PangoFontDescription *desc;
GskPathBuilder *builder;
GskPath *result;
layout = gtk_widget_create_pango_layout (widget, text);
desc = pango_font_description_from_string ("sans bold 36");
pango_layout_set_font_description (layout, desc);
pango_font_description_free (desc);
builder = gsk_path_builder_new ();
gsk_path_builder_add_layout (builder, layout);
result = gsk_path_builder_free_to_path (builder);
if (out_offset)
graphene_point_init (out_offset, 0, - pango_layout_get_baseline (layout) / (double) PANGO_SCALE);
g_object_unref (layout);
return result;
}
typedef struct
{
GskPathMeasure *measure;
GskPathBuilder *builder;
graphene_point_t offset;
double scale;
} GtkPathTransform;
static void
gtk_path_transform_point (GskPathMeasure *measure,
const graphene_point_t *pt,
const graphene_point_t *offset,
float scale,
graphene_point_t *res)
{
graphene_vec2_t tangent;
GskPathPoint point;
if (gsk_path_measure_get_point (measure, (pt->x + offset->x) * scale, &point))
{
GskPath *path = gsk_path_measure_get_path (measure);
gsk_path_point_get_position (&point, path, res);
gsk_path_point_get_tangent (&point, path, GSK_PATH_TO_END, &tangent);
res->x -= (pt->y + offset->y) * scale * graphene_vec2_get_y (&tangent);
res->y += (pt->y + offset->y) * scale * graphene_vec2_get_x (&tangent);
}
}
static gboolean
gtk_path_transform_op (GskPathOperation op,
const graphene_point_t *pts,
gsize n_pts,
float weight,
gpointer data)
{
GtkPathTransform *transform = data;
switch (op)
{
case GSK_PATH_MOVE:
{
graphene_point_t res;
gtk_path_transform_point (transform->measure, &pts[0], &transform->offset, transform->scale, &res);
gsk_path_builder_move_to (transform->builder, res.x, res.y);
}
break;
case GSK_PATH_LINE:
{
graphene_point_t res;
gtk_path_transform_point (transform->measure, &pts[1], &transform->offset, transform->scale, &res);
gsk_path_builder_line_to (transform->builder, res.x, res.y);
}
break;
case GSK_PATH_QUAD:
{
graphene_point_t res[2];
gtk_path_transform_point (transform->measure, &pts[1], &transform->offset, transform->scale, &res[0]);
gtk_path_transform_point (transform->measure, &pts[2], &transform->offset, transform->scale, &res[1]);
gsk_path_builder_quad_to (transform->builder, res[0].x, res[0].y, res[1].x, res[1].y);
}
break;
case GSK_PATH_CUBIC:
{
graphene_point_t res[3];
gtk_path_transform_point (transform->measure, &pts[1], &transform->offset, transform->scale, &res[0]);
gtk_path_transform_point (transform->measure, &pts[2], &transform->offset, transform->scale, &res[1]);
gtk_path_transform_point (transform->measure, &pts[3], &transform->offset, transform->scale, &res[2]);
gsk_path_builder_cubic_to (transform->builder, res[0].x, res[0].y, res[1].x, res[1].y, res[2].x, res[2].y);
}
break;
case GSK_PATH_CONIC:
{
graphene_point_t res[2];
gtk_path_transform_point (transform->measure, &pts[1], &transform->offset, transform->scale, &res[0]);
gtk_path_transform_point (transform->measure, &pts[3], &transform->offset, transform->scale, &res[1]);
gsk_path_builder_conic_to (transform->builder, res[0].x, res[0].y, res[1].x, res[1].y, weight);
}
break;
case GSK_PATH_CLOSE:
gsk_path_builder_close (transform->builder);
break;
default:
g_assert_not_reached();
return FALSE;
}
return TRUE;
}
static GskPath *
gtk_path_transform (GskPath *line_path,
GskPath *path,
const graphene_point_t *offset)
{
GskPathMeasure *measure = gsk_path_measure_new (line_path);
GtkPathTransform transform = { measure, gsk_path_builder_new (), *offset };
graphene_rect_t bounds;
gsk_path_get_bounds (path, &bounds);
if (bounds.origin.x + bounds.size.width > 0)
transform.scale = gsk_path_measure_get_length (measure) / (bounds.origin.x + bounds.size.width);
else
transform.scale = 1.0f;
gsk_path_foreach (path, -1, gtk_path_transform_op, &transform);
gsk_path_measure_unref (measure);
return gsk_path_builder_free_to_path (transform.builder);
}
static void
gtk_path_widget_clear_text_path (GtkPathWidget *self)
{
g_clear_pointer (&self->text_path, gsk_path_unref);
}
static void
gtk_path_widget_clear_paths (GtkPathWidget *self)
{
gtk_path_widget_clear_text_path (self);
g_clear_pointer (&self->line_path, gsk_path_unref);
}
static void
gtk_path_widget_create_text_path (GtkPathWidget *self)
{
GskPath *path;
graphene_point_t offset;
gtk_path_widget_clear_text_path (self);
path = create_path_from_text (GTK_WIDGET (self), self->text, &offset);
self->text_path = gtk_path_transform (self->line_path, path, &offset);
gsk_path_unref (path);
}
static void
gtk_path_widget_create_paths (GtkPathWidget *self)
{
double width = gtk_widget_get_width (GTK_WIDGET (self));
double height = gtk_widget_get_height (GTK_WIDGET (self));
GskPathBuilder *builder;
gtk_path_widget_clear_paths (self);
if (width <= 0 || height <= 0)
return;
builder = gsk_path_builder_new ();
gsk_path_builder_move_to (builder,
self->points[0].x * width, self->points[0].y * height);
gsk_path_builder_cubic_to (builder,
self->points[1].x * width, self->points[1].y * height,
self->points[2].x * width, self->points[2].y * height,
self->points[3].x * width, self->points[3].y * height);
self->line_path = gsk_path_builder_free_to_path (builder);
gtk_path_widget_create_text_path (self);
}
static void
gtk_path_widget_allocate (GtkWidget *widget,
int width,
int height,
int baseline)
{
GtkPathWidget *self = GTK_PATH_WIDGET (widget);
GTK_WIDGET_CLASS (gtk_path_widget_parent_class)->size_allocate (widget, width, height, baseline);
gtk_path_widget_create_paths (self);
}
static void
gtk_path_widget_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot)
{
GtkPathWidget *self = GTK_PATH_WIDGET (widget);
double width = gtk_widget_get_width (widget);
double height = gtk_widget_get_height (widget);
GskPath *path;
GskStroke *stroke;
gsize i;
/* frosted glass the background */
gtk_snapshot_push_blur (snapshot, 100);
gdk_paintable_snapshot (self->background, snapshot, width, height);
gtk_snapshot_append_color (snapshot, &(GdkRGBA) { 1, 1, 1, 0.6 }, &GRAPHENE_RECT_INIT (0, 0, width, height));
gtk_snapshot_pop (snapshot);
/* draw the text */
if (self->text_path)
{
gtk_snapshot_push_fill (snapshot, self->text_path, GSK_FILL_RULE_WINDING);
gdk_paintable_snapshot (self->background, snapshot, width, height);
/* ... with an emboss effect */
stroke = gsk_stroke_new (2.0);
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT(1, 1));
gtk_snapshot_push_stroke (snapshot, self->text_path, stroke);
gtk_snapshot_append_color (snapshot, &(GdkRGBA) { 0, 0, 0, 0.2 }, &GRAPHENE_RECT_INIT (0, 0, width, height));
gsk_stroke_free (stroke);
gtk_snapshot_pop (snapshot);
gtk_snapshot_pop (snapshot);
}
if (self->editable && self->line_path)
{
GskPathBuilder *builder;
/* draw the control line */
stroke = gsk_stroke_new (1.0);
gtk_snapshot_push_stroke (snapshot, self->line_path, stroke);
gsk_stroke_free (stroke);
gtk_snapshot_append_color (snapshot, &(GdkRGBA) { 0, 0, 0, 1 }, &GRAPHENE_RECT_INIT (0, 0, width, height));
gtk_snapshot_pop (snapshot);
/* draw the points */
builder = gsk_path_builder_new ();
for (i = 0; i < 4; i++)
{
gsk_path_builder_add_circle (builder, &GRAPHENE_POINT_INIT (self->points[i].x * width, self->points[i].y * height), POINT_SIZE);
}
path = gsk_path_builder_free_to_path (builder);
gtk_snapshot_push_fill (snapshot, path, GSK_FILL_RULE_WINDING);
gtk_snapshot_append_color (snapshot, &(GdkRGBA) { 1, 1, 1, 1 }, &GRAPHENE_RECT_INIT (0, 0, width, height));
gtk_snapshot_pop (snapshot);
stroke = gsk_stroke_new (1.0);
gtk_snapshot_push_stroke (snapshot, path, stroke);
gsk_stroke_free (stroke);
gtk_snapshot_append_color (snapshot, &(GdkRGBA) { 0, 0, 0, 1 }, &GRAPHENE_RECT_INIT (0, 0, width, height));
gtk_snapshot_pop (snapshot);
gsk_path_unref (path);
}
}
static void
gtk_path_widget_set_text (GtkPathWidget *self,
const char *text)
{
if (g_strcmp0 (self->text, text) == 0)
return;
g_free (self->text);
self->text = g_strdup (text);
gtk_path_widget_create_paths (self);
gtk_widget_queue_draw (GTK_WIDGET (self));
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TEXT]);
}
static void
gtk_path_widget_set_editable (GtkPathWidget *self,
gboolean editable)
{
if (self->editable == editable)
return;
self->editable = editable;
gtk_widget_queue_draw (GTK_WIDGET (self));
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_EDITABLE]);
}
static void
gtk_path_widget_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GtkPathWidget *self = GTK_PATH_WIDGET (object);
switch (prop_id)
{
case PROP_TEXT:
gtk_path_widget_set_text (self, g_value_get_string (value));
break;
case PROP_EDITABLE:
gtk_path_widget_set_editable (self, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_path_widget_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GtkPathWidget *self = GTK_PATH_WIDGET (object);
switch (prop_id)
{
case PROP_TEXT:
g_value_set_string (value, self->text);
break;
case PROP_EDITABLE:
g_value_set_boolean (value, self->editable);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_path_widget_dispose (GObject *object)
{
GtkPathWidget *self = GTK_PATH_WIDGET (object);
gtk_path_widget_clear_paths (self);
G_OBJECT_CLASS (gtk_path_widget_parent_class)->dispose (object);
}
static void
gtk_path_widget_class_init (GtkPathWidgetClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->dispose = gtk_path_widget_dispose;
object_class->set_property = gtk_path_widget_set_property;
object_class->get_property = gtk_path_widget_get_property;
widget_class->size_allocate = gtk_path_widget_allocate;
widget_class->snapshot = gtk_path_widget_snapshot;
properties[PROP_TEXT] =
g_param_spec_string ("text",
"text",
"Text transformed along a path",
NULL,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
properties[PROP_EDITABLE] =
g_param_spec_boolean ("editable",
"editable",
"If the path can be edited by the user",
FALSE,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, N_PROPS, properties);
}
static void
drag_begin (GtkGestureDrag *gesture,
double x,
double y,
GtkPathWidget *self)
{
graphene_point_t mouse = GRAPHENE_POINT_INIT (x, y);
double width = gtk_widget_get_width (GTK_WIDGET (self));
double height = gtk_widget_get_height (GTK_WIDGET (self));
gsize i;
for (i = 0; i < 4; i++)
{
if (graphene_point_distance (&GRAPHENE_POINT_INIT (self->points[i].x * width, self->points[i].y * height), &mouse, NULL, NULL) <= POINT_SIZE)
{
self->active_point = i;
break;
}
}
if (i == 4)
{
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_DENIED);
return;
}
gtk_widget_queue_draw (GTK_WIDGET (self));
}
static void
drag_update (GtkGestureDrag *drag,
double offset_x,
double offset_y,
GtkPathWidget *self)
{
double width = gtk_widget_get_width (GTK_WIDGET (self));
double height = gtk_widget_get_height (GTK_WIDGET (self));
double start_x, start_y;
gtk_gesture_drag_get_start_point (drag, &start_x, &start_y);
self->points[self->active_point] = GRAPHENE_POINT_INIT ((start_x + offset_x) / width,
(start_y + offset_y) / height);
self->points[self->active_point].x = CLAMP (self->points[self->active_point].x, 0, 1);
self->points[self->active_point].y = CLAMP (self->points[self->active_point].y, 0, 1);
gtk_path_widget_create_paths (self);
gtk_widget_queue_draw (GTK_WIDGET (self));
}
static void
pointer_motion (GtkEventControllerMotion *controller,
double x,
double y,
GtkPathWidget *self)
{
GskPathPoint point;
if (gsk_path_get_closest_point (self->line_path,
&GRAPHENE_POINT_INIT (x, y),
INFINITY,
&point,
NULL))
{
gtk_widget_queue_draw (GTK_WIDGET (self));
}
}
static void
pointer_leave (GtkEventControllerMotion *controller,
GtkPathWidget *self)
{
gtk_widget_queue_draw (GTK_WIDGET (self));
}
static void
gtk_path_widget_init (GtkPathWidget *self)
{
GtkEventController *controller;
controller = GTK_EVENT_CONTROLLER (gtk_gesture_drag_new ());
g_signal_connect (controller, "drag-begin", G_CALLBACK (drag_begin), self);
g_signal_connect (controller, "drag-update", G_CALLBACK (drag_update), self);
g_signal_connect (controller, "drag-end", G_CALLBACK (drag_update), self);
gtk_widget_add_controller (GTK_WIDGET (self), controller);
controller = GTK_EVENT_CONTROLLER (gtk_event_controller_motion_new ());
g_signal_connect (controller, "enter", G_CALLBACK (pointer_motion), self);
g_signal_connect (controller, "motion", G_CALLBACK (pointer_motion), self);
g_signal_connect (controller, "leave", G_CALLBACK (pointer_leave), self);
gtk_widget_add_controller (GTK_WIDGET (self), controller);
self->points[0] = GRAPHENE_POINT_INIT (0.1, 0.9);
self->points[1] = GRAPHENE_POINT_INIT (0.3, 0.1);
self->points[2] = GRAPHENE_POINT_INIT (0.7, 0.1);
self->points[3] = GRAPHENE_POINT_INIT (0.9, 0.9);
self->background = GDK_PAINTABLE (gdk_texture_new_from_resource ("/sliding_puzzle/portland-rose.jpg"));
gtk_path_widget_set_text (self, "It's almost working");
}
GtkWidget *
gtk_path_widget_new (void)
{
GtkPathWidget *self;
self = g_object_new (GTK_TYPE_PATH_WIDGET, NULL);
return GTK_WIDGET (self);
}
GtkWidget *
do_path_text (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;
if (!window)
{
GtkBuilder *builder;
g_type_ensure (GTK_TYPE_PATH_WIDGET);
builder = gtk_builder_new_from_resource ("/path_text/path_text.ui");
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *) &window);
g_object_unref (builder);
}
if (!gtk_widget_get_visible (window))
gtk_window_present (GTK_WINDOW (window));
else
gtk_window_destroy (GTK_WINDOW (window));
return window;
}

View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkWindow" id="window">
<property name="title" translatable="yes">Text along a Path</property>
<child type="titlebar">
<object class="GtkHeaderBar">
<child type="end">
<object class="GtkToggleButton" id="edit-toggle">
<property name="icon-name">document-edit-symbolic</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkRevealer">
<property name="reveal-child" bind-source="edit-toggle" bind-property="active" bind-flags="sync-create"></property>
<child>
<object class="GtkEntry" id="text">
<property name="text">Through the looking glass</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkPathWidget" id="view">
<property name="editable" bind-source="edit-toggle" bind-property="active" bind-flags="sync-create"></property>
<property name="text" bind-source="text" bind-property="text" bind-flags="sync-create"></property>
<property name="hexpand">true</property>
<property name="vexpand">true</property>
</object>
</child>
</object>
</child>
</object>
</interface>

373
demos/gtk-demo/path_walk.c Normal file
View File

@@ -0,0 +1,373 @@
/* Path/Walk
*
* This demo draws a world map and shows how to animate objects along a GskPath.
*
* The world map that is used here is a path with 211 lines and 1569 cubic
* Bėzier segments in 121 contours.
*/
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#define GTK_TYPE_PATH_WALK (gtk_path_walk_get_type ())
G_DECLARE_FINAL_TYPE (GtkPathWalk, gtk_path_walk, GTK, PATH_WALK, GtkWidget)
#define POINT_SIZE 8
enum {
PROP_0,
PROP_N_POINTS,
PROP_PATH,
N_PROPS
};
struct _GtkPathWalk
{
GtkWidget parent_instance;
GskPath *path;
GskPathMeasure *measure;
graphene_rect_t bounds;
GskPath *arrow_path;
guint n_points;
};
struct _GtkPathWalkClass
{
GtkWidgetClass parent_class;
};
static GParamSpec *properties[N_PROPS] = { NULL, };
G_DEFINE_TYPE (GtkPathWalk, gtk_path_walk, GTK_TYPE_WIDGET)
static void
rgba_init_from_hsla (GdkRGBA *rgba,
float hue,
float saturation,
float lightness,
float alpha)
{
float m1, m2;
if (lightness <= 0.5)
m2 = lightness * (1 + saturation);
else
m2 = lightness + saturation - lightness * saturation;
m1 = 2 * lightness - m2;
rgba->alpha = alpha;
if (saturation == 0)
{
rgba->red = lightness;
rgba->green = lightness;
rgba->blue = lightness;
}
else
{
hue = 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 -= 120;
if (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 -= 120;
if (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;
}
}
static void
gtk_path_walk_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot)
{
GtkPathWalk *self = GTK_PATH_WALK (widget);
double width = gtk_widget_get_width (widget);
double height = gtk_widget_get_height (widget);
float length, progress;
GskStroke *stroke;
guint i;
if (self->path == NULL)
return;
gtk_snapshot_save (snapshot);
stroke = gsk_stroke_new (2.0);
gtk_snapshot_push_stroke (snapshot, self->path, stroke);
gtk_snapshot_append_color (snapshot, &(GdkRGBA) { 0, 0, 0, 1 }, &GRAPHENE_RECT_INIT (0, 0, width, height));
gtk_snapshot_pop (snapshot);
gsk_stroke_free (stroke);
length = gsk_path_measure_get_length (self->measure);
progress = 25.f * gdk_frame_clock_get_frame_time (gtk_widget_get_frame_clock (widget)) / G_USEC_PER_SEC;
stroke = gsk_stroke_new (1.0);
for (i = 0; i < self->n_points; i++)
{
GskPathPoint point;
graphene_point_t position;
float angle;
GdkRGBA color;
float distance;
distance = i * length / self->n_points;
distance = fmod (distance + progress, length);
gsk_path_measure_get_point (self->measure, distance, &point);
gsk_path_point_get_position (&point, self->path, &position);
angle = gsk_path_point_get_rotation (&point, self->path, GSK_PATH_FROM_START);
rgba_init_from_hsla (&color, 360.f * i / self->n_points, 1, 0.5, 1);
gtk_snapshot_save (snapshot);
gtk_snapshot_translate (snapshot, &position);
gtk_snapshot_rotate (snapshot, angle);
gtk_snapshot_append_fill (snapshot, self->arrow_path, GSK_FILL_RULE_EVEN_ODD, &color);
gtk_snapshot_append_stroke (snapshot, self->arrow_path, stroke, &(GdkRGBA) { 0, 0, 0, 1 });
gtk_snapshot_restore (snapshot);
}
gsk_stroke_free (stroke);
gtk_snapshot_restore (snapshot);
}
static void
gtk_path_walk_measure (GtkWidget *widget,
GtkOrientation orientation,
int for_size,
int *minimum,
int *natural,
int *minimum_baseline,
int *natural_baseline)
{
GtkPathWalk *self = GTK_PATH_WALK (widget);
if (orientation == GTK_ORIENTATION_HORIZONTAL)
*minimum = *natural = (int) ceilf (self->bounds.size.width);
else
*minimum = *natural = (int) ceilf (self->bounds.size.height);
}
static void
gtk_path_walk_set_n_points (GtkPathWalk *self,
gsize n_points)
{
if (self->n_points == n_points)
return;
self->n_points = n_points;
gtk_widget_queue_draw (GTK_WIDGET (self));
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_N_POINTS]);
}
static void
gtk_path_walk_set_path (GtkPathWalk *self,
GskPath *path)
{
if (self->path == path)
return;
g_clear_pointer (&self->path, gsk_path_unref);
graphene_rect_init (&self->bounds, 0, 0, 0, 0);
if (path)
{
GskStroke *stroke;
self->path = gsk_path_ref (path);
stroke = gsk_stroke_new (2.0);
gsk_path_get_stroke_bounds (path, stroke, &self->bounds);
gsk_stroke_free (stroke);
self->measure = gsk_path_measure_new (self->path);
}
gtk_widget_queue_resize (GTK_WIDGET (self));
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_PATH]);
}
static void
gtk_path_walk_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GtkPathWalk *self = GTK_PATH_WALK (object);
switch (prop_id)
{
case PROP_N_POINTS:
gtk_path_walk_set_n_points (self, g_value_get_uint (value));
break;
case PROP_PATH:
gtk_path_walk_set_path (self, g_value_get_boxed (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_path_walk_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GtkPathWalk *self = GTK_PATH_WALK (object);
switch (prop_id)
{
case PROP_N_POINTS:
g_value_set_uint (value, self->n_points);
break;
case PROP_PATH:
g_value_set_boxed (value, self->path);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_path_walk_dispose (GObject *object)
{
GtkPathWalk *self = GTK_PATH_WALK (object);
g_clear_pointer (&self->path, gsk_path_unref);
g_clear_pointer (&self->measure, gsk_path_measure_unref);
g_clear_pointer (&self->arrow_path, gsk_path_unref);
G_OBJECT_CLASS (gtk_path_walk_parent_class)->dispose (object);
}
static void
gtk_path_walk_class_init (GtkPathWalkClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->dispose = gtk_path_walk_dispose;
object_class->set_property = gtk_path_walk_set_property;
object_class->get_property = gtk_path_walk_get_property;
widget_class->snapshot = gtk_path_walk_snapshot;
widget_class->measure = gtk_path_walk_measure;
properties[PROP_N_POINTS] =
g_param_spec_uint ("n-points",
NULL, NULL,
1, G_MAXUINT,
500,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
properties[PROP_PATH] =
g_param_spec_boxed ("path",
NULL, NULL,
GSK_TYPE_PATH,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, N_PROPS, properties);
}
static gboolean
tick_tick_tick (GtkWidget *self,
GdkFrameClock *frame_clock,
gpointer unused)
{
gtk_widget_queue_draw (GTK_WIDGET (self));
return G_SOURCE_CONTINUE;
}
static void
gtk_path_walk_init (GtkPathWalk *self)
{
/* Data taken from
* https://commons.wikimedia.org/wiki/Maps_of_the_world#/media/File:Simplified_blank_world_map_without_Antartica_(no_borders).svg
*/
GBytes *data = g_resources_lookup_data ("/path_walk/path_world.txt", 0, NULL);
GskPath *path = gsk_path_parse (g_bytes_get_data (data, NULL));
g_bytes_unref (data);
gtk_path_walk_set_path (self, path);
gsk_path_unref (path);
self->arrow_path = gsk_path_parse ("M 5 0 L 0 -5. 0 -2, -5 -2, -5 2, 0 2, 0 5 Z");
self->n_points = 500;
gtk_widget_add_tick_callback (GTK_WIDGET (self), tick_tick_tick, NULL, NULL);
}
GtkWidget *
gtk_path_walk_new (void)
{
GtkPathWalk *self;
self = g_object_new (GTK_TYPE_PATH_WALK, NULL);
return GTK_WIDGET (self);
}
GtkWidget *
do_path_walk (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;
if (!window)
{
GtkBuilder *builder;
g_type_ensure (GTK_TYPE_PATH_WALK);
builder = gtk_builder_new_from_resource ("/path_walk/path_walk.ui");
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *) &window);
g_object_unref (builder);
}
if (!gtk_widget_get_visible (window))
gtk_window_present (GTK_WINDOW (window));
else
gtk_window_destroy (GTK_WINDOW (window));
return window;
}

View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkWindow" id="window">
<property name="title" translatable="yes">World Map</property>
<property name="titlebar">
<object class="GtkHeaderBar">
<child type="end">
<object class="GtkSpinButton">
<property name="adjustment">
<object class="GtkAdjustment" id="adjustment">
<property name="lower">0</property>
<property name="upper">5000</property>
<property name="value">500</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
</object>
</property>
</object>
</child>
</object>
</property>
<property name="child">
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkPathWalk" id="view">
<property name="n-points" bind-source="adjustment" bind-property="value"/>
<property name="hexpand">true</property>
<property name="vexpand">true</property>
</object>
</child>
</object>
</property>
</object>
</interface>

File diff suppressed because one or more lines are too long

View File

@@ -1,8 +1,9 @@
/* Pickers and Launchers
* #Keywords: GtkColorDialog, GtkFontDialog, GtkFileDialog, GtkFileLauncher, GtkUriLauncher
* #Keywords: GtkColorDialog, GtkFontDialog, GtkFileDialog, GtkPrintDialog, GtkFileLauncher, GtkUriLauncher
*
* The dialogs are mainly intended for use in preference dialogs.
* They allow to select colors, fonts and applications.
* They allow to select colors, fonts and files. There is also a
* print dialog.
*
* The launchers let you open files or URIs in applications that
* can handle them.
@@ -11,11 +12,13 @@
#include <gtk/gtk.h>
static GtkWidget *app_picker;
static GtkWidget *print_button;
static void
set_file (GFile *file,
gpointer data)
{
GFileInfo *info;
char *name;
if (!file)
@@ -31,6 +34,13 @@ set_file (GFile *file,
gtk_widget_set_sensitive (app_picker, TRUE);
g_object_set_data_full (G_OBJECT (app_picker), "file", g_object_ref (file), g_object_unref);
info = g_file_query_info (file, "standard::content-type", 0, NULL, NULL);
if (strcmp (g_file_info_get_content_type (info), "application/pdf") == 0)
{
gtk_widget_set_sensitive (print_button, TRUE);
g_object_set_data_full (G_OBJECT (print_button), "file", g_object_ref (file), g_object_unref);
}
}
static void
@@ -47,6 +57,10 @@ file_opened (GObject *source,
{
g_print ("%s\n", error->message);
g_error_free (error);
gtk_widget_set_sensitive (app_picker, FALSE);
g_object_set_data (G_OBJECT (app_picker), "file", NULL);
gtk_widget_set_sensitive (print_button, FALSE);
g_object_set_data (G_OBJECT (print_button), "file", NULL);
}
set_file (file, data);
@@ -114,6 +128,53 @@ open_app (GtkButton *picker)
g_object_unref (launcher);
}
static void
print_file_done (GObject *source,
GAsyncResult *result,
gpointer data)
{
GtkPrintDialog *dialog = GTK_PRINT_DIALOG (source);
GError *error = NULL;
GCancellable *cancellable;
unsigned int id;
cancellable = g_task_get_cancellable (G_TASK (result));
id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (cancellable), "timeout"));
if (id)
g_source_remove (id);
if (!gtk_print_dialog_print_file_finish (dialog, result, &error))
{
g_print ("%s\n", error->message);
g_error_free (error);
}
}
static void
print_file (GtkButton *picker)
{
GtkWindow *parent = GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (picker)));
GtkPrintDialog *dialog;
GCancellable *cancellable;
GFile *file;
unsigned int id;
file = G_FILE (g_object_get_data (G_OBJECT (picker), "file"));
dialog = gtk_print_dialog_new ();
cancellable = g_cancellable_new ();
id = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT,
20,
abort_mission, g_object_ref (cancellable), g_object_unref);
g_object_set_data (G_OBJECT (cancellable), "timeout", GUINT_TO_POINTER (id));
gtk_print_dialog_print_file (dialog, parent, NULL, file, cancellable, print_file_done, NULL);
g_object_unref (cancellable);
g_object_unref (dialog);
}
static void
open_uri_done (GObject *source,
GAsyncResult *result,
@@ -234,8 +295,14 @@ do_pickers (GtkWidget *do_widget)
gtk_widget_set_sensitive (app_picker, FALSE);
g_signal_connect (app_picker, "clicked", G_CALLBACK (open_app), NULL);
gtk_box_append (GTK_BOX (picker), app_picker);
gtk_grid_attach (GTK_GRID (table), picker, 1, 2, 1, 1);
print_button = gtk_button_new_from_icon_name ("printer-symbolic");
gtk_widget_set_tooltip_text (print_button, "Print file");
gtk_widget_set_sensitive (print_button, FALSE);
g_signal_connect (print_button, "clicked", G_CALLBACK (print_file), NULL);
gtk_box_append (GTK_BOX (picker), print_button);
gtk_grid_attach (GTK_GRID (table), picker, 1, 2, 1, 1);
label = gtk_label_new ("URI:");
gtk_widget_set_halign (label, GTK_ALIGN_START);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -6,6 +6,6 @@
* Also, when adding new style properties, please add them here.
*/
* {
window.demo * {
all: unset;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -188,10 +188,20 @@ do_spinbutton (GtkWidget *do_widget)
if (!window)
{
GtkBuilder *builder;
GtkBuilderScope *scope;
GtkAdjustment *adj;
GtkWidget *label;
builder = gtk_builder_new_from_resource ("/spinbutton/spinbutton.ui");
scope = gtk_builder_cscope_new ();
builder = gtk_builder_new ();
gtk_builder_cscope_add_callback (GTK_BUILDER_CSCOPE (scope), spinbutton_hex_spin_input);
gtk_builder_cscope_add_callback (GTK_BUILDER_CSCOPE (scope), spinbutton_hex_spin_output);
gtk_builder_cscope_add_callback (GTK_BUILDER_CSCOPE (scope), spinbutton_time_spin_input);
gtk_builder_cscope_add_callback (GTK_BUILDER_CSCOPE (scope), spinbutton_time_spin_output);
gtk_builder_cscope_add_callback (GTK_BUILDER_CSCOPE (scope), spinbutton_month_spin_input);
gtk_builder_cscope_add_callback (GTK_BUILDER_CSCOPE (scope), spinbutton_month_spin_output);
gtk_builder_set_scope (builder, scope);
gtk_builder_add_from_resource (builder, "/spinbutton/spinbutton.ui", NULL);
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
@@ -233,6 +243,7 @@ do_spinbutton (GtkWidget *do_widget)
NULL, NULL);
g_object_unref (builder);
g_object_unref (scope);
}
if (!gtk_widget_get_visible (window))

View File

@@ -27,7 +27,6 @@ GtkWidget *
do_spinner (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;
GtkWidget *content_area;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *button;
@@ -35,28 +34,19 @@ do_spinner (GtkWidget *do_widget)
if (!window)
{
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
window = gtk_dialog_new_with_buttons ("Spinner",
GTK_WINDOW (do_widget),
0,
_("_Close"),
GTK_RESPONSE_NONE,
NULL);
window = gtk_window_new ();
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Spinner");
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
g_signal_connect (window, "response",
G_CALLBACK (gtk_window_destroy), NULL);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
content_area = gtk_dialog_get_content_area (GTK_DIALOG (window));
G_GNUC_END_IGNORE_DEPRECATIONS
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
gtk_widget_set_margin_start (vbox, 5);
gtk_widget_set_margin_end (vbox, 5);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
gtk_widget_set_margin_top (vbox, 5);
gtk_widget_set_margin_bottom (vbox, 5);
gtk_box_append (GTK_BOX (content_area), vbox);
gtk_widget_set_margin_start (vbox, 5);
gtk_widget_set_margin_end (vbox, 5);
gtk_window_set_child (GTK_WINDOW (window), vbox);
/* Sensitive */
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);

View File

@@ -801,7 +801,7 @@ suggestion_entry_key_pressed (GtkEventControllerKey *controller,
selected = matches - 1;
}
gtk_single_selection_set_selected (self->selection, selected);
gtk_list_view_scroll_to (GTK_LIST_VIEW (self->list), selected, GTK_LIST_SCROLL_SELECT, NULL);
return TRUE;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 844 B

After

Width:  |  Height:  |  Size: 1.1 KiB

2218
demos/gtk-demo/tiger.node Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 823 B

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@@ -147,6 +147,19 @@ Creates a node like `gsk_cross_fade_node_new()` with the given properties.
Creates a node like `gsk_debug_node_new()` with the given properties.
### fill
| property | syntax | default | printed |
| --------- | --------------- | ---------------------- | ----------- |
| child | `<node>` | *see below* | always |
| path | `<string>` | "" | always |
| fill-rule | `<fill-rule>` | winding | always |
Creates a node like `gsk_fill_node_new()` with the given properties.
The default child node is the default color node, but created with the
bounds of the path.
### glshader
| property | syntax | default | printed |
@@ -289,6 +302,24 @@ Creates a node like `gsk_rounded_clip_node_new()` with the given properties.
Creates a node like `gsk_shadow_node_new()` with the given properties.
### stroke
| property | syntax | default | printed |
| ----------- | ------------------ | ----------------- | ----------- |
| child | `<node>` | *see below* | always |
| path | `<string>` | "" | always |
| line-width | `<number>` | 0 | non-default |
| line-cap | `<line-cap>` | butt | always |
| line-join | `<line-join>` | miter | always |
| miter-limit | `<number>` | 4 | non-default |
| dash | `<number>{+}|none` | none | non-default |
| dash-offset | `<number>` | 0 | non-default |
Creates a node like `gsk_stroke_node_new()` with the given properties.
The default child node is the default color node, but created with the
stroke bounds of the path.
### text
| property | syntax | default | printed |

View File

@@ -6,8 +6,6 @@
#include "demo_conf.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static GtkWidget *main_window;
static GFile *filename = NULL;
static GtkPageSetup *page_setup = NULL;
@@ -43,7 +41,7 @@ update_statusbar (void)
GtkTextIter iter;
const char *print_str;
gtk_statusbar_pop (GTK_STATUSBAR (statusbar), 0);
gtk_label_set_label (GTK_LABEL (statusbar), "");
gtk_text_buffer_get_iter_at_mark (buffer,
&iter,
@@ -61,10 +59,10 @@ update_statusbar (void)
msg = g_strdup_printf ("%d, %d%s %s",
row, col,
file_changed?" - Modified":"",
print_str);
file_changed?" - Modified":"",
print_str);
gtk_statusbar_push (GTK_STATUSBAR (statusbar), 0, msg);
gtk_label_set_label (GTK_LABEL (statusbar), msg);
g_free (msg);
}
@@ -827,7 +825,12 @@ activate (GApplication *app)
contents);
/* Create statusbar */
statusbar = gtk_statusbar_new ();
statusbar = gtk_label_new ("");
gtk_label_set_xalign (GTK_LABEL (statusbar), 0);
gtk_widget_set_margin_start (statusbar, 2);
gtk_widget_set_margin_end (statusbar, 2);
gtk_widget_set_margin_top (statusbar, 2);
gtk_widget_set_margin_bottom (statusbar, 2);
gtk_box_append (GTK_BOX (box), statusbar);
/* Show text widget info in the statusbar */

Binary file not shown.

Before

Width:  |  Height:  |  Size: 533 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 B

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path d="M3.384 3h3.231c.213 0 .385.224.385.502v2.996C7 6.776 6.828 7 6.615 7h-3.23C3.17 7 3 6.776 3 6.498V3.502C3 3.224 3.17 3 3.384 3zm6 0h3.231c.213 0 .385.224.385.502v2.996c0 .278-.172.502-.385.502h-3.23C9.17 7 9 6.776 9 6.498V3.502C9 3.224 9.17 3 9.384 3zm-6 6h3.231c.213 0 .385.224.385.502v2.996c0 .278-.172.502-.385.502h-3.23C3.17 13 3 12.776 3 12.498V9.502C3 9.224 3.17 9 3.384 9zm6 0h3.231c.213 0 .385.224.385.502v2.996c0 .278-.172.502-.385.502h-3.23C9.17 13 9 12.776 9 12.498V9.502C9 9.224 9.17 9 9.384 9z" style="marker:none" overflow="visible" color="#000" fill="#474747"/></svg>

Before

Width:  |  Height:  |  Size: 654 B

View File

@@ -1,16 +1,6 @@
# demos/widget-factory
objcopy_supports_add_symbol = false
objcopy = find_program('objcopy', required : false)
if objcopy.found()
objcopy_supports_add_symbol = run_command(objcopy, '--help', check: false).stdout().contains('--add-symbol')
endif
ld = find_program('ld', required : false)
if not meson.is_cross_build() and build_machine.cpu_family() != 'arm' and build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_add_symbol and ld.found()
glib_compile_resources = find_program('glib-compile-resources')
if can_use_objcopy_for_resources
# Create the resource blob
widgetfactory_gresource = custom_target('widgetfactory.gresource',
input : 'widget-factory.gresource.xml',

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