Compare commits

...

1344 Commits

Author SHA1 Message Date
Matthias Clasen
0b30e9a63b gdk: Spread the errors
Call gdk_ensure_initialized() directly in gdk_display_open_default(),
gdk_display_open(), gdk_x11_display_open() and gdk_display_get_default(),
so we get the right function name in the error message. These functions
are likely candidates that people might call without ensuring that GDK is
initialized.
2024-10-21 12:55:07 -04:00
Matthias Clasen
1a7ab5dc9a gdk: No displays before init
Don't allow to create displays before gdk has been initialized.

Note that this error triggers in nautilus 47.0, but we consider
what it is doing unsupported and broken.

Related: #7035
2024-10-21 12:32:35 -04:00
Matthias Clasen
57b9435e13 print: Avoid calling gdk_display_get_default
Check if GTK has been initialized before trying to get a display
in a class_init function. The introspection property dumper code
will instantiate all types and run into the new introduced errors
if we try to get a display in class_init.
2024-10-21 12:32:35 -04:00
Matthias Clasen
212ba47646 tests: Cosmetics
Our test setups aready enforce GSETTINGS_BACKEND=memory, don't set
it again in code.
2024-10-21 12:32:25 -04:00
Matthias Clasen
66367bf5d9 tests: Fix the textbuffer tests
Don't needlessly open a display before gtk_init.
2024-10-21 12:32:25 -04:00
Matthias Clasen
31683469c1 Merge branch 'for-main' into 'main'
Misc cleanups

See merge request GNOME/gtk!7832
2024-10-21 16:06:02 +00:00
Matthias Clasen
b9a382878d build: Rename meson_options.txt to meson.options
This is the preferred name since meson 1.1, and we require 1.2 now.
2024-10-21 11:39:04 -04:00
Matthias Clasen
9dd51aa985 docs: Typo fix 2024-10-21 11:39:04 -04:00
Matthias Clasen
24c1afac49 docs: Update tests
Remote the gdk docs check from the failing testsuite, since they pass.
Add a (failing) docs check for the gdk-x11 docs.
2024-10-21 11:39:04 -04:00
Matthias Clasen
ce92ce6d36 gdk: Add missing color state docs
Document the getters for oklab/okch.
2024-10-21 11:39:04 -04:00
Matthias Clasen
5366f83711 demos: Beef up about dialogs 2024-10-21 11:39:04 -04:00
Matthias Clasen
3ffc194e9c demos: Drop the icon-browser fully
This was forgotten in 32d03a548e.
2024-10-21 11:39:04 -04:00
Matthias Clasen
0170f8e261 Drop expandtab from vim modelines
This is already covered by our editorconfig.
2024-10-21 11:39:04 -04:00
Matthias Clasen
7de9e47cfc build: Cosmetics
Reuse a variable.
2024-10-21 11:39:04 -04:00
Matthias Clasen
655736b05f gdk: Bling up debug spew slightly
We use ✓ and ✗ in some other places already, be consistent.
2024-10-21 11:39:04 -04:00
Matthias Clasen
aa268b31f2 vulkan: Cosmetics
Rename gsk_vulkan_feature_keys to gdk_vulkan_feature_keys, since
these keys live in gdk.
2024-10-21 11:38:34 -04:00
Matthias Clasen
0b9685fb41 Merge branch 'wip/smcv/issue7093' into 'main'
vulkan: Only log the list of extensions if debugging is enabled

Closes #7093

See merge request GNOME/gtk!7847
2024-10-21 15:26:08 +00:00
Matthias Clasen
d26f323bfe Merge branch 'semicolon' into 'main'
Remove a couple of stray semicolons

See merge request GNOME/gtk!7839
2024-10-21 15:05:10 +00:00
Matthias Clasen
51908dd8d7 Merge branch 'amolenaar/macos-fix-dnd-crash' into 'main'
macos: fix crashes when dragging libadwaita TabView tabs

Closes #7097

See merge request GNOME/gtk!7849
2024-10-21 15:02:31 +00:00
Arjan Molenaar
5332cfb177 macos: Add dummy pasteboard item if no mimetypes have been translated
Not all mime types will be translated to pasteboard types, hence we
need to check if any are translated. If not add an internal type.
2024-10-20 11:51:37 +02:00
Benjamin Otte
3e4c92f86e Merge branch 'wip/otte/windows' into 'main'
Make vscode work

See merge request GNOME/gtk!7838
2024-10-19 18:20:19 +00:00
Simon McVittie
d7e3d73efb vulkan: Only log the list of extensions if debugging is enabled
Logging them with `g_print()` will write to stdout, which can interfere
with machine-readable output, for example when gnome-control-center
displays the GPU/driver name.

Resolves: https://gitlab.gnome.org/GNOME/gtk/-/issues/7093
Signed-off-by: Simon McVittie <smcv@debian.org>
2024-10-18 20:21:53 +01:00
Benjamin Otte
95c2b6d5f4 Merge branch 'wip/otte/wgl-quirks' into 'main'
win32: Always try WGL_SUPPORT_GDI_ARB

See merge request GNOME/gtk!7844
2024-10-18 11:14:00 +00:00
Benjamin Otte
11671c0537 Remove accidentally committed file 2024-10-18 12:02:03 +02:00
Benjamin Otte
0876ad6212 gitignore: Add .vscode directory 2024-10-18 12:02:03 +02:00
Benjamin Otte
036f481753 gitignore: Add all wrap files
meson has a tendency to dump wrap files of subprojects into this directory.
So we have to ignore them when using wrap files.

I think meson should put them into its builddir, but oh well...
2024-10-18 12:02:03 +02:00
Benjamin Otte
cc03f04380 build: Configure GStreamer subproject without Python
Our plugin doesn't use gst-python, so build without it.
2024-10-18 12:02:03 +02:00
Benjamin Otte
60d46ccc6c build: Add wrap file for GStreamer
We require 1.24.0 so lets use that for now. This is necessary to get
working media support.
2024-10-18 12:02:03 +02:00
Benjamin Otte
06532e583a build: Add devenv with GTK_PATH
For meson devenv - which is used by the meson vscode plugin to run
applications - setting GTK_PATH is necessary to get uninstalled modules
working.
2024-10-18 12:02:03 +02:00
Benjamin Otte
84d4fbaa85 build: require meson 1.2
Update the requirement in meson.build and the CI runners to meson 1.2

This keeps things in line with glib and avoids unexpected suprises from
using meson versions that are way too old.
2024-10-18 12:02:03 +02:00
Benjamin Otte
b28b2ea768 win32: Embed quirks struct in display struct
No need to manually allocate it (and then not freeing it in dispose ;)).
2024-10-18 11:59:04 +02:00
Benjamin Otte
d96f2bcde6 win32: Always try WGL_SUPPORT_GDI_ARB
We can avoid a quirk here by always trying WGL_SUPPORT_GDI_ARB
first and falling back when it's not supported.
2024-10-18 11:59:04 +02:00
Віктар Гаўрылавец
f0c0af4d68 Update Belarusian translation
(cherry picked from commit 3a1cf43028)
2024-10-18 09:17:00 +00:00
Andi Chandler
4eb6d6bc7d Update British English translation
(cherry picked from commit fa2f49ee7c)
2024-10-17 13:07:48 +00:00
Arjan Molenaar
64b52db5c3 Merge branch 'amolenaar/macos-fix-double-release' into 'main'
macos: Fix double emission of mouse release event

Closes #7021

See merge request GNOME/gtk!7803
2024-10-17 10:46:41 +00:00
Martin
a37dac626e Update Slovenian translation 2024-10-16 21:42:08 +00:00
Bruce Cowan
1ca97dbdfe gdk: Remove a couple of stray semicolons 2024-10-16 16:01:09 +01:00
Matthias Clasen
68d74b380f Merge branch 'wip/smcv/cups-dbus-error' into 'main'
printing: Treat any G_DBUS_ERROR contacting Avahi as non-problematic

See merge request GNOME/gtk!7835
2024-10-15 15:50:32 +00:00
Simon McVittie
9d9e665f34 printing: Treat any G_DBUS_ERROR contacting Avahi as non-problematic
If we get an error from the message bus (dbus-daemon or dbus-broker),
for example ServiceUnknown if Avahi is not installed or perhaps
SpawnFailed if the service is disabled, it is mapped to a GLib GError.
The errors typically emitted by the message bus belong to the GDBusError
domain, but if nobody has registered the G_DBUS_ERROR domain yet,
then they might be mapped to G_IO_ERROR_DBUS_ERROR instead.

Previously, this code ignored G_IO_ERROR_DBUS_ERROR, but emitted a
warning if the error happens to have been mapped to G_DBUS_ERROR.
This resulted in action-at-a-distance: an unrelated component
triggering registration of the G_DBUS_ERROR domain would make printing
dialogs log the warning. This seems undesirable, and in particular it
can cause test failures, because GLib's test framework makes warnings
fatal by default.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-10-15 15:44:33 +01:00
Simon McVittie
7dc72303aa printing: If we cannot contact Avahi, debug-log the error message
If we get a G_IO_ERROR_DBUS_ERROR here, we shouldn't make too much noise
about it by default, but it's still a useful data point for debugging
and diagnosis.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-10-15 15:44:33 +01:00
Matthias Clasen
0d650bd9d2 Merge branch 'fix_listview_accessible_selection' into 'main'
a11y: Fix GtkListview's selection interface implementation

See merge request GNOME/gtk!7834
2024-10-15 13:04:34 +00:00
Lukáš Tyrychtr
d60630ea8d a11y: Fix GtkListview's selection interface implementation
When determining the number of selected children, we were properly
counting only items, but in the rest, we were confused by row headers.
Because the GtkListItemBase methods did not throw a warning on inappropriate
pointer type passed, we happily passed the row headers, got some private
data object as the wrong type, and then returned nonsense, for example, 2
for gtk_list_item_base_get_selected.
2024-10-15 14:25:14 +02:00
Benjamin Otte
3349996af5 Merge branch 'wip/otte/for-main' into 'main'
flatpak: Fix build

See merge request GNOME/gtk!7831
2024-10-15 00:25:52 +00:00
Benjamin Otte
e81582ae29 flatpak: Fix build
I should have remembered that CI doesn't build flatpaks before
merging.

Fixes: !7830
2024-10-15 01:38:03 +02:00
Benjamin Otte
7f3f70f66e Merge branch 'wip/otte/for-main' into 'main'
flatpak: Drop GSK_RENDERER env var

See merge request GNOME/gtk!7830
2024-10-14 23:15:48 +00:00
Benjamin Otte
e225a353b8 flatpak: Drop GSK_RENDERER env var
We want to use the default renderer.

This env var was introduced in
commit df4c57c001 to work around an
inspector bug.

But it's not 2020 anymore and Vulkan actually works now.
2024-10-15 00:46:23 +02:00
Matthias Clasen
0202960a5d Merge branch 'fix-vulkan-swapchain' into 'main'
vulkan: Add some more debug

Closes #7079

See merge request GNOME/gtk!7827
2024-10-14 16:05:25 +00:00
Matthias Clasen
969001a1e3 vulkan: Release swapchain images
With the swapchain maintenance extension, we have a way to release
the acquired swapchain image before recreating the swapchain, in
the VK_SUBOPTIMAL_KHR case. Use it.

Tested by toggling fullscreen in the bloatpad example, which causes
mesa to return VK_SUBOPTIMAL_KHR (since dmabuf modifiers change).
2024-10-14 10:53:03 -04:00
Matthias Clasen
caf2a7724f vulkan: Avoid a validation error
If vkAcquireNextImageKHR returns VK_SUBOPTIMAL_KHR, the semaphore
is in use, but vkDeviceWaitIdle will not wait for it, since it is
not associated with a queue. Make sure that is the case, so we don't
run into a validation error when we try vkAcquireNextImageKHR with
the same semaphore, after recreating the swap chain.

See https://github.com/KhronosGroup/Vulkan-Docs/issues/1059 for
some related discussion.

Fixes: #7079
2024-10-14 10:32:37 -04:00
Matthias Clasen
f66b32dca7 vulkan: Add some more debug
Move the "Recreating the swapchain" message to where we do so, and
add some more debug logging there.
2024-10-14 10:32:37 -04:00
Matthias Clasen
4ac2ed4d81 Merge branch 'inspector-vulkan' into 'main'
inspector: Improve Vulkan info

See merge request GNOME/gtk!7829
2024-10-14 14:29:30 +00:00
Matthias Clasen
e697e30f3c inspector: Improve Vulkan info
Redo the lists of layers and extensions to show the things we use.
2024-10-14 09:54:54 -04:00
Matthias Clasen
1d2fe52e96 Merge branch 'for-main' into 'main'
ci: Drop icon browser jobs

See merge request GNOME/gtk!7826
2024-10-13 16:22:07 +00:00
Matthias Clasen
8955d9b15c Merge branch 'wip/wayland-system-bell' into 'main'
wayland: Add support for the system bell protocol

See merge request GNOME/gtk!7825
2024-10-13 15:02:12 +00:00
Matthias Clasen
f71732055f ci: Drop icon browser jobs
I overlooked the ci jobs whn I dropped this demo in 32d03a548e.
2024-10-13 10:18:25 -04:00
Jonas Ådahl
50bd8b85a1 inspector/general: Remove trailing whitespace
The .editor_config told my editor to do so, so I will comply as well.
2024-10-13 09:54:46 -04:00
Jonas Ådahl
0b60e553dc wayland: Add support for the system bell protocol
This is an upstream protocol providing equivalent functionality as the
system bell request in gtk-shell.

This commit includes a copy of xdg-system-bell-v1.xml, since we don't
depend on wayland-protocols 1.38 yet.
2024-10-13 09:54:09 -04:00
Rūdolfs Mazurs
94d2d92d02 Update Latvian translation
(cherry picked from commit 5cefdf58a1)
2024-10-13 13:53:23 +00:00
Matthias Clasen
04be13492f Merge branch 'gsk_border_node_fix_dead_cleanup_code' into 'main'
gsk: gsk_border_node_new(): Fix dead cleanup code

See merge request GNOME/gtk!7823
2024-10-13 13:14:51 +00:00
Barnabás Pőcze
3b0a4386a8 gsk: gsk_border_node_new(): Fix dead cleanup code
The `gdk_color_finish()` calls are currently after the `return`,
so they are never executed. Move the `return` below the cleanup
code to avoid that.

Fixes: bd3d1f7715 ("gsk: Add private border node api")
2024-10-12 23:06:02 +02:00
Matthias Clasen
06b8863bf7 Merge branch 'oklab-support' into 'main'
oklab and oklch support

See merge request GNOME/gtk!7801
2024-10-12 18:44:03 +00:00
Matthias Clasen
d754f5c1b4 Merge branch 'css-color-hookup-6' into 'main'
Make non-srgb css colors work for gradients

See merge request GNOME/gtk!7584
2024-10-12 18:29:31 +00:00
Matthias Clasen
89248bd006 Merge branch 'a11y-leak-fix' into 'main'
a11y: Fix a leak

Closes #7074

See merge request GNOME/gtk!7822
2024-10-12 05:29:20 +00:00
Matthias Clasen
18350b6662 a11y: Fix a leak
This was already fixed in ca702b45 and regressed.

Fixes: #7074
2024-10-11 23:17:26 -04:00
Luca Bacci
834f20e2a7 Merge branch 'gdk-win32-cleanup' into 'main'
GdkWin32 Cleanup

See merge request GNOME/gtk!7810
2024-10-10 19:26:54 +00:00
Matthias Clasen
97b34f839f Merge branch 'accessible_relation_set_size_fix' into 'main'
gtk/gtkaccessiblevalue.c: Fix GTK_ACCESSIBLE_RELATION_SET_SIZE collect_rels value

See merge request GNOME/gtk!7818
2024-10-10 13:58:31 +00:00
Luca Bacci
a0c823e11d Meson: Define _WIN32_WINNT in the toplevel meson.build file 2024-10-10 14:34:28 +02:00
Luca Bacci
419758576f Win32: Do not define STRICT
STRICT is defined automatically by Windows SDK and mingw-w64 headers
2024-10-10 10:58:35 +02:00
Luca Bacci
0ee985bd5b Remove unneeded defines 2024-10-10 10:58:26 +02:00
Luca Bacci
be2adb1838 Merge branch 'msys2-switch-to-ucrt64' into 'main'
MSYS2: Switch to UCRT64

See merge request GNOME/gtk!7812
2024-10-10 08:26:45 +00:00
Luca Bacci
0113fdc8d5 Merge branch 'gdk-win32-purge-globals' into 'main'
GDK/Win32: Drop most of the global variables

See merge request GNOME/gtk!7804
2024-10-10 08:26:30 +00:00
Juan Pablo Ugarte
09dfc5a51d gtk/gtkaccessiblevalue.c: Fix GTK_ACCESSIBLE_RELATION_SET_SIZE collect_rels value 2024-10-09 18:10:07 -04:00
Matthias Clasen
53cbc64f41 Merge branch 'alatiera/sysprof-uri' into 'main'
gtkcssprovider: Only add the marker if the file is not null

See merge request GNOME/gtk!7807
2024-10-09 15:40:12 +00:00
Jordan Petridis
83387608ee gtkcssprovider: Use g_file_peek_path to get the uri for the sysprof marker
This avoids an extra allocation.

Additionally avoid calling it if file is already null.
2024-10-09 17:39:08 +03:00
Benjamin Otte
a5b4d2b500 Merge branch 'typo-fix' into 'main'
Fix a typo

Closes #6984

See merge request GNOME/gtk!7816
2024-10-08 23:30:07 +00:00
ARAKHNID
1b83d87cf5 Fix a typo
Closes #6984
2024-10-08 13:41:04 -05:00
Emmanuele Bassi
6c2eb08b07 Merge branch 'wip/chergert/fix-a11y-default-attributes' into 'main'
gtk/accessibletext: handle NULL default values

Closes #7069

See merge request GNOME/gtk!7813
2024-10-08 18:10:26 +00:00
Christian Hergert
ab1c85830c gtk/accessibletext: handle NULL default values
The default implementation for get_default_attributes() returns NULL for
both names and values yet the code which iterates them is assuming they
will never be NULL.

Since the interface implies that if the values are set, they will return
valid strings, make the default implementation do that.

Fixes: #7069
2024-10-08 10:41:19 -07:00
Luca Bacci
d154decbb5 CI/MSYS2: Switch to UCRT64 2024-10-08 14:01:32 +02:00
Luca Bacci
c7705f156a Rework test-msys2.sh a bit 2024-10-08 13:59:43 +02:00
Luca Bacci
20bdb0d7d5 Merge branch 'wgl-updates' into 'main'
WGL: Avoid using swap exchange on NVidia drivers

Closes #7019

See merge request GNOME/gtk!7776
2024-10-08 10:24:02 +00:00
Luca Bacci
f840ae1337 WGL: Avoid using swap method exchange on NVidia drivers
It seems that NVidia sets PFD_SWAP_EXCHANGE / WGL_SWAP_EXCHANGE_ARB
on pixel formats but doesn't guarantee that the backbuffer age is
constantly 2. My guess is that they use swap exchange only to signal
usage of a flip present method.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/7019
2024-10-08 11:27:05 +02:00
Benjamin Otte
02feba87f2 Merge branch 'wip/otte/for-main' into 'main'
gpu: Remove warning

See merge request GNOME/gtk!7805
2024-10-07 10:20:37 +00:00
Benjamin Otte
220d7a3d5e picture: Queue a redraw when not resizing
When changing the code to do the resize only when the size changed, I
forgot to queue a draw when the size did not change.

Fixes: 5031f30f28
Related: !7786
2024-10-07 11:35:50 +02:00
Benjamin Otte
39686daa23 gpu: Remove warning
The warning gets triggered by rounding errors.

In particular when using fractional scales, the final tile may end up
not accurately matching the computed final value (in the example I was
debugging it was computing 1 vs 1.00000036 for the final tile index,
but that result computed a 0px wide tile size.
And for that tile size we hit that exit condition.
2024-10-07 11:31:34 +02:00
Chun-wei Fan
b6269a3234 gdkevents-win32.c: Drop AeroSnap global variables
Put them into our GdkWin32Display under an appropriate sub-struct.
2024-10-07 14:37:40 +08:00
Chun-wei Fan
2879f6a99b gdkevents-win32.c: Drop event debug indent global variable
Tuck it as appropriate into our GdkWin32Display.
2024-10-07 14:37:40 +08:00
Chun-wei Fan
03a86b4667 GDK/Win32: Drop global variable on both shifts pressed 2024-10-07 14:37:39 +08:00
Chun-wei Fan
7eb96c39c5 GDK/Win32: Drop global variable tracking IME state
Tuck it into our GdkDisplay structure under an appropriate sub-struct.
2024-10-07 14:37:38 +08:00
Chun-wei Fan
b4c5a7af69 GDK/Win32: Fold pen input global vars into GdkDeviceManagerWin32
This way, we just grab and set the values from there.
2024-10-07 14:37:38 +08:00
Chun-wei Fan
d120aaf6ee GDK/Win32: Drop global variables from GdkKeys implementation
We get to create our GdkKey with a display as a property for free, so
just stuff the default keymap and keymap serial (to track IME state
changes and so) into our GdkWin32Display under an existing sub-struct
that is for holding these items.
2024-10-07 14:37:23 +08:00
Chun-wei Fan
004d787cb2 Gdk/Win32: Drop _gdk_display global variable
On Windows, we really only support a single GdkDisplay, so we can just
make the GdkDisplay that we obtain a property of our GdkDeviceManagerWin32
and GdkWin32Screen objects, and so we can just do away with the global
_gdk_display global variable.

This way, we can also drop the venerable gdkglobals-win32.c source file.
Yay!
2024-10-07 12:07:05 +08:00
Chun-wei Fan
7b554240f3 GDK/Win32: Drop modal surface-related global variables
Tuck them into GdkWin32Display as we track these operations.
2024-10-07 12:01:08 +08:00
Chun-wei Fan
7837f342e9 GdkDeviceManagerWin32: Drop global variables
Tuck the wintab global variables into the GdkDeviceManagerWin32
structure, and initialize and utilize items accordingly.
2024-10-07 12:01:07 +08:00
Chun-wei Fan
236139c78a gdkdisplay-win32.c: Drop debug_indent global variable
Instead, use [Set|Get]WindowLongPtr(), to store and retrieve that
value from the notification window HWND that we are using, as it
is where we are using that value.
2024-10-07 12:01:06 +08:00
Chun-wei Fan
789bb83b5a GDK/Win32: Drop surface tracking global variables
...including the list of modal surfaces and hashes of opened HWNDs for
various surfaces, and tuck them into GdkWin32Display.
2024-10-07 12:00:59 +08:00
Chun-wei Fan
0a65221721 GDK/Win32: Drop global variables in Direct Manipuation code
Tuck them into GdkWin32Display.
2024-10-07 11:56:21 +08:00
Chun-wei Fan
b37947ff20 GDK/Win32: Drop global variables related to GdkDevice
Tuck the _win32_device_manager global variable into GdkWin32Display, and
drop the global variables that have to do with GdkDeviceManagerWin32.

Also improve how we query the WinPointer APIs from user32.dll, so that
we are sure that it is done once and only once.
2024-10-07 11:56:20 +08:00
Chun-wei Fan
0d4f827de8 GDK/Win32: Drop Clipdrop/DND global variables
Tuck the GdkWin32Clipdrop that we create in our GdkWin32Display, and
tuck the other associated global variables into GdkWin32ClipDrop and
GdkWin32Drag, as appropriate.

Also, since we are already registering "GDK_WORKER_THREAD_WAKEUP" as our
custom message to look for in our DND/clipboard ops, only register it
once, not twice, as it's not really necessary to do so since
RegisterWindowMessage() returns the same value for the same identifier
that is being used.,
2024-10-07 11:56:12 +08:00
Chun-wei Fan
1f52048e77 GDK/Win32: Drop global variable to track main thread
Instead, record the current thread in the GdkDisplay, under a structure
for DND items, which will hold other relevant Windows Clipbord/DND global
variables.

Add a new function in gdkdrag-win32.c to check whether the current
thread is (or is not) equivilant to the thread that is initiated when
the GdkDisplay is initialized (which also returns true if there is no
GdkDisplay that is associated with the GdkDrag in question).
2024-10-07 11:54:26 +08:00
Chun-wei Fan
7600d44995 GDK/Win32: Drop _gdk_ignore_input_core global variable
...and fold it into GdkWin32Display under pointer_device_items.
2024-10-07 11:50:21 +08:00
Chun-wei Fan
8bb806cd85 gdkmain-win32.c: Tuck global varianbles into local variables
...and use g_once_init_[enter|leave]() to mark that GDK did or did not
indeed successfully initialize COM and OLE2.
2024-10-07 11:39:04 +08:00
Chun-wei Fan
28aacf3db4 GDK/Win32: Drop input locale global variables
Rename gdkwin32id.c as gdkwin32misc.c.

Fold these items into GdkWin32Display, and also fold gdkproperty-win32.c
and gdkwin32langnoticiation.[c|h] into gdkwin32misc.c and gdkdisplay-win32.h as
appropriate.

This way, we get rid of few more global variables, and these items
should have been initialized (and registered with the system) when we
open a GdkWin32Display anyways.
2024-10-07 11:37:14 +08:00
Chun-wei Fan
95ad05181c gdksurface-win32.c: Drop a global variable
Use the gdk_win32_surface_parent_class that is given to us by
G_DEFINE_TYPE() instead of using a global variable to store up the
parent class of GdkWin32Surface.
2024-10-07 10:28:34 +08:00
Arjan Molenaar
0ea35efec4 macos: Fix double emission of mouse release event
The event is propagated anyway.

Fixes #7021.
2024-10-06 14:08:05 +02:00
Martin
b4a54bb9cb Update Slovenian translation 2024-10-05 18:36:53 +00:00
Matthias Clasen
df31bbf9e5 gsk: Support hue interpolation in cairo
Since cairos gradient code isn't flexible enough to let us
interpolate in oklch, add additional color stops and let cairo
interpolate in the ccs. This isn't as accurate as interpolating
in oklch, but it gets an ok result for fallback situations.
2024-10-05 13:32:16 -04:00
Matthias Clasen
12dd5be649 Merge branch '3to4-separator' into 'main'
gtk4-builder-tool: Rewrite Gtk{H,V}Seperator

See merge request GNOME/gtk!7800
2024-10-05 14:52:30 +00:00
Guido Günther
c86e45c432 gtk4-builder-tool: Rewrite Gtk{H,V}Seperator
One less UI element to worry about when migrating from GTK3.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2024-10-05 15:54:49 +02:00
Matthias Clasen
1ad5943cd8 Merge branch 'for-main' into 'main'
image tool: Better color state support

See merge request GNOME/gtk!7799
2024-10-05 13:38:07 +00:00
Matthias Clasen
34c69b2868 build: Don't use / in target names
It is unnecessary, and meson doesn't like it.
2024-10-05 08:55:50 -04:00
Matthias Clasen
28817b4bb2 image tool: Better color state support
Show cicp color states with their tuple.
2024-10-05 08:16:07 -04:00
Matthias Clasen
b0acf2a7a8 Merge branch 'for-main' into 'main'
docs: Update GSK_GPU_DISABLE docs

See merge request GNOME/gtk!7798
2024-10-05 02:05:34 +00:00
Matthias Clasen
32d03a548e Drop some demos
The gtk4-icon-browser and gtk4-constraint-editor demos are basically
unmaintained, and not great showcases for GTK, so lets drop them.
2024-10-04 21:24:11 -04:00
Matthias Clasen
4de67b2fe5 gtk: Don't optimize gradients away too eagerly
Even if the stops are the same color, with hue interpolation,
it might still make a beautiful rainbow.
2024-10-04 21:21:32 -04:00
Matthias Clasen
6d878bd21c css: Pass oklab and oklch color states through 2024-10-04 21:16:36 -04:00
Matthias Clasen
965fd476a5 node parser: handle oklab and oklch 2024-10-04 21:16:36 -04:00
Matthias Clasen
3bce60c433 gsk: Handle hue-interpolation in ops
Make all our gradient ops adjust the hue according to
the hue interpolation.

This is currently modifying the values in the vertex array.
If reading those values back is bad, we may need to change that.
2024-10-04 21:16:36 -04:00
Matthias Clasen
8083456599 gsk: Handle oklab and oklch color states 2024-10-04 21:16:35 -04:00
Matthias Clasen
2a1b8c4fcc gdk: Add oklab and oklch color states
These are new default color states.

Tests for the tf and matrices included.
2024-10-04 20:37:09 -04:00
Matthias Clasen
ed9e759917 Add a test for gradient rendering
This tests that gradients get interpolated differently in
srgb and rec2100-linear.
2024-10-04 17:13:27 -04:00
Matthias Clasen
f69d7f804a tests: Use the new gradient node apis
Properly replay gradient nodes with color state information.
2024-10-04 17:13:27 -04:00
Matthias Clasen
4368583cbe gsk: Make non-default interpolation cs work
If the interpolation color state is not a default one, use the
offscreen we already for rendering big gradients, interpolate
the gradient into it, and then use a cicp convert shader to
convert the result to the ccs.
2024-10-04 15:08:34 -04:00
Matthias Clasen
c44efc31ba inspector: Show full gradient information
Use the new gradient apis to show color stops, and show
interpolation color state and hue interpolation as well.
2024-10-04 15:08:34 -04:00
Matthias Clasen
3c6cc6c362 gtk: Use the new private snapshot api
Preserve color states from css as much as possible.
2024-10-04 15:08:34 -04:00
Matthias Clasen
eff0d5b37b gtk: Add new snapshot api for gradients
These are private snapshot apis that uses the new gradient node
constructors to create nodes with the given color states.
2024-10-04 15:08:34 -04:00
Matthias Clasen
579878a855 css: Add helper functions
We need to be able to translate css color spaces into gdk color
states, and css hue interplation into gsk hue interpolation.
2024-10-04 15:08:34 -04:00
Matthias Clasen
b43294c1c3 nodeparser: Handle color states for gradients
Test included.
2024-10-04 15:08:34 -04:00
Matthias Clasen
5d8e801d80 gsk: Use new gradient node apis
This requires changing the gradient ops again too,
so we can pass GskColorStop2 arrays to them.
2024-10-04 14:51:33 -04:00
Matthias Clasen
4c7631a645 gsk: Add new private gradient node api
These new apis take GskColorStop2 instead of GskColorStop.
2024-10-04 14:50:23 -04:00
Matthias Clasen
9fe78d9f75 cairo: Add gdk_cairo_pattern_add_color_stop_color
This is a generalization of gdk_cairo_pattern_add_color_stop_rgba_ccs
to allow non-sRGB sources.
2024-10-04 14:50:23 -04:00
Matthias Clasen
9a7d84b441 gsk: Change gradient op apis
Pass the ccs, opacity, interpolation color state and hue
interpolation explicitly, and change the argument order to
match other ops.

Since we now apply opacity in the op, change the node processor
to pass colors as-is. For now, it always passes GDK_COLOR_STATE_SRGB
for ics and GSK_HUE_INTERPOLATION_SHORTER for hue interpolation.
2024-10-04 14:50:11 -04:00
Matthias Clasen
1fe9918f3c gsk: Add GskHueInterpolation enum
This will be used in gradient-related apis.
2024-10-04 14:48:50 -04:00
Matthias Clasen
cd04aa1cd4 gsk: Change a precondition
It is nicer if gsk_gpu_color_states_create_explicit (a, a) works
regardless of whether the two are default colorstates or not.

The gradient shaders will rely on this when the ics is a non-default
color state and we use ccs == ics.
2024-10-04 14:48:50 -04:00
Matthias Clasen
fecadae80c docs: Update GSK_GPU_DISABLE docs
Add `repeat`.
2024-10-04 14:42:38 -04:00
Matthias Clasen
2d1367ccdc Merge branch 'wip/otte/this-looks-correct-but-is-it' into 'main'
listitemfactory: Don't rebind on position or selection changes

See merge request GNOME/gtk!7420
2024-10-04 18:32:08 +00:00
Matthias Clasen
ac1c0d37c6 Merge branch 'gstreamer-no-gl' into 'main'
gstreamer: Fix gl context creation

See merge request GNOME/gtk!7796
2024-10-04 15:57:46 +00:00
Matthias Clasen
ea6bcdbd3d gstreamer: Fix gl context creation
We may not have a surface (since realizing media streams is optional),
so use the display when creating a gl context.
2024-10-04 11:18:48 -04:00
Matthias Clasen
fe83b06eaf Merge branch 'gbsneto/fix-a11y-nonwidget-recurse' into 'main'
atcontext: Only recurse parents for non-widget accessibles

Closes #7058

See merge request GNOME/gtk!7793
2024-10-04 13:19:07 +00:00
Matthias Clasen
be5fd3d89f Merge branch 'gstreamer-no-gl' into 'main'
gstreamer: Make dmabufs work without GL

Closes #7048

See merge request GNOME/gtk!7787
2024-10-04 13:09:42 +00:00
Matthias Clasen
bef38bd9c4 gstreamer: Tweak gl context handling
Just create the context when it is needed.
2024-10-04 08:21:58 -04:00
Georges Basile Stavracas Neto
06f08ea804 atcontext: Only recurse parents for non-widget accessibles
The original intent was to only realize parents recursively for
non-widget accessible objects. The implementation, however, always
try to realize parents. In the case of GtkStackPage, which is a
non-widget accessible with a widget accessible child, this breaks.

Only realize non-widget accessible parents recursively if the
current accessible is not a widget as well.

Closes https://gitlab.gnome.org/GNOME/gtk/-/issues/7058
Fixes 6074a18e3e
2024-10-04 09:19:57 -03:00
Matthias Clasen
79bb805a02 gstreamer: Simplify
Add a uses-gl property to our sink implementation, and use
it in the paintable code. This avoids juggling a second gl
context, with the risk of leaking it.
2024-10-04 07:49:07 -04:00
Matthias Clasen
d70c005021 gstreamer: Improve caps handling
Separate out the caps for dmabuf, gl and memory and add them
when appropriate.
2024-10-04 07:44:20 -04:00
Matthias Clasen
9fc7d8e947 Restructure gtk_gst_paintable_video_renderer_create_video_sink
This code had too many early exits and was leaking GL contexts
and Gstreamer elements. Simplify.
2024-10-04 07:44:20 -04:00
Matthias Clasen
b06ac9826c gstreamer: Use the default display if needed
Calling gtk_media_stream_realize is not mandatory, but we can
still try to make dmabufs happen. Tested by removing the realize
call from GtkVideo and using GDK_DISABLE=gl.
2024-10-04 07:44:20 -04:00
Matthias Clasen
94cacd79f9 gstreamer: Restructure gtk_gst_sink_propose_allocation
Split this clearly into two cases: dmabuf or gl memory.
2024-10-04 07:44:20 -04:00
Matthias Clasen
17d3631605 gstreamer: Make dmabufs work without GL
We only need a display to negotiate dmabuf formats. Pass that
directly, instead of getting the display of the GL context as
we did so far.

With this,

GSK_RENDERER=vulkan GL_DISABLE=gl gtk4-demo --run video_player

still uses dmabufs.

Related: #7048
2024-10-04 07:44:20 -04:00
Matthias Clasen
3b027cf466 Merge branch 'for-main' into 'main'
gpu: Add GSK_GPU_DISABLE=repeat

See merge request GNOME/gtk!7791
2024-10-04 00:48:58 +00:00
Matthias Clasen
5d4f2822d0 Fix testsuite setup
We no longer say GDK_DEBUG=gl-prefer-gl, we say GDK_DISABLE=gles-api.
2024-10-03 20:11:00 -04:00
Benjamin Otte
5a11ee7b9c gpu: Add GSK_GPU_DISABLE=repeat
This is useful for testing of repeat nodes - both performance
and conformance, and potentially even driver issues with GL_REPEAT.

We have code for manual repeating anyway, so adding a flag to force
always using it is easy.
2024-10-03 20:11:00 -04:00
Matthias Clasen
874410129e Merge branch 'fix-scrolled-window-criticals' into 'main'
scrolledwindow: Fix measuring non-overlay, always visible scrollbars

See merge request GNOME/gtk!7790
2024-10-03 17:52:16 +00:00
Sergey Bugaev
2cf1651235 scrolledwindow: Fix measuring non-overlay, always visible scrollbars
The last part of logic in gtk_scrolled_window_measure () that accounted
for scrollbars was handling the hscrollbar first, and vscrollbar second.
For each of them, it looked at the orientation we're being measured in,
and either added or MAX'ed scrollbar's size request into ours (or not,
depending on scrollbar policy and whether overlay scrolling is used).

In case of GTK_ORIENTATION_HORIZONTAL, this resulted in

    // MAX in hscrollbar width.
    minimum_req = MAX (minimum_req, min_scrollbar_width + sborder.left + sborder.right);
    // Add in vscrollbar width.
    minimum_req += min_scrollbar_width;

whereas for GTK_ORIENTATION_VERTICAL, it was

    // Add in hscrollbar height.
    minimum_req += min_scrollbar_height;
    // MAX in vscrollbar height.
    minimum_req = MAX (minimum_req, min_scrollbar_height + sborder.top + sborder.bottom);

The former is correct and the latter is wrong: we should be adding the
size requests of the scrollbars together, and MAX'ing them with the
content size request.

Fix this by refactoring the logic to first handle the MAX'ing, and then
the addition.

This fixes the following criticals:

Gtk-CRITICAL **: 17:26:51.406: Allocation height too small. Tried to allocate 15x31, but GtkScrollbar 0x2a00fac0 needs at least 15x46.

that were happening when all of:
- scrollbar policy was set to ALWAYS,
- overlay scrolling was disabled,
- the scrollable child was really small.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2024-10-03 19:04:15 +03:00
Matthias Clasen
ad2221ce29 Merge branch 'fix-filechooser-crash' into 'main'
window: Fix crash when unexporting unrealized window

See merge request GNOME/gtk!7769
2024-10-03 15:53:44 +00:00
Sergey Bugaev
6dd0be2f06 printdialog: Call gtk_window_unexport_handle
We need to track the handle and properly unexport it.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2024-10-03 17:14:11 +03:00
Sergey Bugaev
2103ab99a5 window: Fix crash when unexporting unrealized window
It is possible that the window gets unrealized while a handle to its
surface is exported. This, naturally, invalidates the handle, so there
is nothing left to unexport. We should just note that and do nothing,
rather than crashing.

Fixes a crash when a portal-backed file dialog parented to a window is
closed after the window it was parented to.

Reported-by: Ivan Molodetskikh <yalterz@gmail.com>
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2024-10-03 17:14:11 +03:00
Sergey Bugaev
d7ab7e9628 window: Fix a typo
Fortunately, it didn't impact string length.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2024-10-03 17:14:11 +03:00
Matthias Clasen
3d7ac47e5e Merge branch 'gbsneto/atspi-socket-realize' into 'main'
atcontext: Always realize non-widget accessibles

See merge request GNOME/gtk!7784
2024-10-03 09:46:40 +00:00
Chun-wei Fan
c373e2c76b Merge branch 'gdk-win32-rename' into 'main'
GDK/Win32: Rename instances of "window" as in the GTK+-3.x-era GdkWindow as appropriate

See merge request GNOME/gtk!7738
2024-10-03 05:44:07 +00:00
Matthias Clasen
ec3b27bb68 Merge branch 'for-main' into 'main'
Don't draw transparent fillers

See merge request GNOME/gtk!7788
2024-10-03 03:43:54 +00:00
Benjamin Otte
5b87dba1a3 Merge branch 'wip/otte/for-main' into 'main'
picture: Only queue_resize() if necessary

See merge request GNOME/gtk!7786
2024-10-03 01:10:53 +00:00
Matthias Clasen
12dcaf1e7a Don't draw transparent fillers
Repeat nodes take child bounds that let us achieve the desired
spacing without resorting to transparent fillers.
2024-10-02 21:05:21 -04:00
Benjamin Otte
5031f30f28 picture: Only queue_resize() if necessary
When setting a new paintable, we don't need to queue_resize() when it's
the same size as the old paintable.

This is especially useful when pictures are used in a listview or
gridview and different rows display images of the same size.
2024-10-03 02:56:12 +02:00
Matthias Clasen
ad465e81aa Merge branch 'for-main' into 'main'
ci: Stop using catch

See merge request GNOME/gtk!7785
2024-10-03 00:41:40 +00:00
Matthias Clasen
39374c7209 gtk4-demo: Make demos standalone
Making the demo windows transient and modal makes gnome-shell
treat them like dialogs, which is not right.
2024-10-02 19:15:31 -04:00
Matthias Clasen
170a1cd941 ci: Stop using catch
It is useful to track down mysterious crashes in ci, but it causes
sporadic test failures, so disable it for now, until we have another
mysterious crash.
2024-10-02 19:15:31 -04:00
Georges Basile Stavracas Neto
6074a18e3e atcontext: Always realize non-widget accessibles
Upon joining the a11y tree. And do so recursively, as long as the parent
is also not a widget.

As for the explanation, please grab a mug of your favorite drink. It's
a little complicated.

GTK realizes AT contexts in 3 situations:

 1. When it's a toplevel, it's realized unconditionally
 2. When the widget is focused
 3. When the accessible is appended to a realized parent

Most importantly, GTK lazily realizes accessibles, and does not realize
child accessibles recursively.

Clearly, conditions 1 and 2 only ever happen for GtkWidgets, which are
accessible objects themselves. These two conditions will handle the vast
majority of cases of apps and platform libraries.

However, there are non-widget accessibles out there. GTK itself offers a
non-widget accessible implementation - GtkAtspiSocket - which is used by
WebKitGTK.

Now, let's look at WebKitGTK use case. It'll demonstrate the problem
nicely.

WebKitGTK creates the GtkAtspiSocket object *after* loading most of the
page. At this point, there are 2 possibilities:

 1. The web view widget is focused. In this case, the AT context of the
    web view is realized, and GTK will realize the GtkAtspiSocket when
    it is added to the a11y tree (condition 3 above).

 2. The web view widget is *not* focused. At some point the user focuses
    the web view, and GTK will realize the AT context of the web view.
    But remember, GTK does not realize child accessibles! That means
    GtkAtspiSocket won't be realized.

This example demonstrates a general problem with non-widget accessibles:
non-widget accessibles cannot trigger conditions 1 and 2, so they're
never realized. The only way they're realized in if they happen to be
added to an already realized accessible (condition 3).

To fix that, the following is proposed: always realize non-widget
accessibles, and also of their non-widget accessible parents. This is
not ideal, of course, as it might generate some D-Bus chattery, but GTK
does not have enough information to realize these objects at more
appropriate times.
2024-10-02 16:07:30 -03:00
Georges Basile Stavracas Neto
5d5b612630 atcontext: Factor out some code
Move the code that realizes an AT context if the parent is realized,
into to a separate function. This will make the next patch easier to
read.

No functional changes.
2024-10-02 14:51:33 -03:00
Matthias Clasen
5942252175 Merge branch 'scrolling-underline-demo' into 'main'
gtk4-demo: Add another scrolling case

See merge request GNOME/gtk!7781
2024-10-02 17:32:22 +00:00
Benjamin Otte
9a3898fe89 Merge branch 'wip/otte/for-main' into 'main'
dmabuf: Change a debug message

See merge request GNOME/gtk!7782
2024-10-02 12:36:02 +00:00
Benjamin Otte
c6a3efaf70 dmabuf: Unify initialization debug messages
... and print if a format is advertised.

We now use the same style of message and use the term "advertise" for
formats that will be available via GdkDisplay::dmabuf-formats and
"supports" for formats the backend pretends it can handle but don't
want to advertise them.
2024-10-02 13:39:48 +02:00
Benjamin Otte
9870234294 dmabuf: Change a debug message
Instead of only printing the advertised dmabuf formats, print all
supported ones. This is now useful information because we will try to
use them when downloading.

Fixes me looking like I don't know what I'm talking about on IRC when
claiming that llvmpipe can't do dmabufs, because it only supports linear
ones and we didn't print those.
2024-10-02 13:39:48 +02:00
Matthias Clasen
64ecb972cf gtk4-demo: Add another scrolling case
Add a case for text with various underlines. In particular error
underlines, since these are more complicated and use repeat nodes
and offscreens.
2024-10-02 07:21:41 -04:00
Matthias Clasen
ded6d400d7 gtk-demo: Make scrolling benchmark resizable
The small window does not really tax our renderer much. Make it
resizable, so we can test fullscreen scrolling.
2024-10-02 07:20:36 -04:00
Chun-wei Fan
979a37d3f7 GDK/Win32: Rename _gdk_win32_get_window_rect()
... to gdk_win32_get_surface_hwnd_rect(), so that things are a bit
clearer.
2024-10-02 12:52:44 +08:00
Chun-wei Fan
270e6165f4 GDK/Win32: Rename GtkShowWindow() to GtkShowSurfaceHWND()
Makes this function a bit clearer on what is being done.
2024-10-02 12:52:44 +08:00
Chun-wei Fan
df51d474fc GDK/Win32: Rename "window" for event handling code
We want to make the distinction between GdkSurface's and native Windows
HWNDs clearer.
2024-10-02 12:52:44 +08:00
Chun-wei Fan
1e0ab6f249 gdkprivate-win32.h: Rename "window" as needed
We want to make the distinction between GdkSurface's and native Windows
HWNDs clearer.
2024-10-02 12:52:44 +08:00
Chun-wei Fan
deb4de6332 gdkvulkancontext-win32.c: Rename "window" as needed
We want to make the distinction between GdkSurface's and native Windows
HWNDs clear, and we don't want to confuse between GdkSurface's and
Vulkan surfaces.
2024-10-02 12:52:44 +08:00
Chun-wei Fan
b4c7dd770c GDK/Win32: Rename "window" for DND/clipboard code
We want to make the distinction between GdkSurface's and native Windows
HWND clearer.
2024-10-02 12:52:44 +08:00
Chun-wei Fan
7488644176 gdkdisplay-win32.c: Rename "window" as appropriate
We want to make the distinction between GDK surfaces and the native
(underlying) Windows HWNDs clearer.
2024-10-02 12:52:44 +08:00
Chun-wei Fan
9ed7cecd42 GDK/Win32: Rename "window" in GdkDevice/GdkDeviceManager code
Make the distinction between GdkSurfaces and the underlying native
Windows HWND clearer in the code and in the comments.
2024-10-02 12:52:44 +08:00
Chun-wei Fan
df36ab3f93 GDK/Win32: Rename "window" items in Cairo context code
Make the distinction between GDK surfaces and native Windows HWNDs
clearer.
2024-10-02 12:52:44 +08:00
Chun-wei Fan
7e4fdea71b GDK/Win32: Rename "window" in gdksurface-win32.* code
In order to help us in our refactoring, make the distinction between Gdk
surfaces and native Win32 HWND clearer in terms of the variables that we
used, and in the comments in the code.

Also, group forward function prototype declarations in one place, and
drop some unneeded items in gdkprivate-win32.h to fold them into
gdksurface-win32.c, as they are only used there.
2024-10-02 12:52:44 +08:00
Matthias Clasen
ea8062e86a Merge branch 'for-main' into 'main'
gsk: Allow Vulkan software rendering as fallback

See merge request GNOME/gtk!7780
2024-10-02 01:31:05 +00:00
Matthias Clasen
c4efe7709b Drop GDK_VULKAN_DEVICE support
We don't need our own mechanism for device selection; mesa has a
Vulkan layer that works perfectly fine for this purpose; just set
MESA_VK_DEVICE_SELECT.
2024-10-01 21:00:16 -04:00
Matthias Clasen
fdea496883 gsk: Allow Vulkan software rendering as fallback
There is no reason to exclude lavapipe when we accept llvmpipe,
and lavapipe has the advantage that it supports dmabufs.
2024-10-01 20:57:49 -04:00
Matthias Clasen
60878e4186 Merge branch 'for-main' into 'main'
gsk: Prefer ngl over cairo

See merge request GNOME/gtk!7779
2024-10-02 00:45:13 +00:00
Matthias Clasen
02297138f3 gsk: Tweak renderer selection debug spew
Print a message for every get_renderer function that returns
FALSE, so the debug spew lets us get a clear picture of what
possibilities were tried.
2024-10-01 20:12:17 -04:00
Benjamin Otte
6603e02beb Merge branch 'wip/otte/for-main' into 'main'
Revert "tools: Drop support for the gl renderer"

See merge request GNOME/gtk!7778
2024-10-01 23:57:20 +00:00
Matthias Clasen
bfb7573810 gsk: Prefer ngl over cairo
Now that the gl renderer is no longer in our fallback sequence, use
ngl instead. With current ngl, llvmpipe is still better than cairo.
2024-10-01 19:42:08 -04:00
Benjamin Otte
6847c3469d testsuite: Keep bounds for clip tests
The hope here is that it makes clip tests more reproducible because the
coordinates in device pixels are still the same as before.
2024-10-02 01:26:24 +02:00
Benjamin Otte
7a1e5b4418 compare-render: Add a KEEP_BOUNDS flag
If that flag is set, we keep the bounds of the original node when
rendering the modified node.

Gets around the replay test having to draw a transparent color node to
ensure the same bounds.
2024-10-02 01:26:24 +02:00
Benjamin Otte
76980e10a0 Revert "tools: Drop support for the gl renderer"
This reverts commit fd02afa2e4.

We don't want to remove the GL renderer from our tools yet, because we
use those tools for manual testing and having it available is useful.

In particular, reinstate the GL renderer for rendernode-tool benchmark.
2024-10-02 01:25:30 +02:00
Matthias Clasen
34f4a06691 Merge branch 'gl-renderer-memorytexture-test' into 'main'
Stop using a gl renderer in the memorytexture text

See merge request GNOME/gtk!7773
2024-10-01 21:29:29 +00:00
Matthias Clasen
2dea5ae958 Merge branch 'for-main' into 'main'
inspector: Plug a  memory leak

See merge request GNOME/gtk!7775
2024-10-01 15:52:05 +00:00
Matthias Clasen
5856716188 inspector: Plug a memory leak
Found by code inspection of all the places where we use texture
builders.
2024-10-01 08:59:52 -04:00
Matthias Clasen
1c4a0dae62 Merge branch 'gst-texture-builder-leak' into 'main'
gst: Don't leak texture builders

See merge request GNOME/gtk!7774
2024-10-01 12:20:48 +00:00
Matthias Clasen
b7fba6298f gst: Don't leak texture builders
Found by code inspection. The leak was introduced in 4707784755.

Might help for #4184
2024-10-01 07:18:32 -04:00
Matthias Clasen
5ce196fe9f Rename memory texture tests from ngl to gl 2024-09-30 21:59:59 -04:00
Matthias Clasen
c31c89c794 Drop gl renderer tests from memory texture test 2024-09-30 21:55:33 -04:00
Matthias Clasen
1eb8c3ea34 tests: Add ngl-released in memory texture test
This is parallel to the gl-released method, but for ngl.
2024-09-30 21:52:16 -04:00
Matthias Clasen
b2414b1ecd Merge branch 'for-main' into 'main'
gtk4-demo: Drop the glshader demos

See merge request GNOME/gtk!7771
2024-10-01 01:47:09 +00:00
Matthias Clasen
fd3dfaf2c3 Merge branch 'dmabuf-import-fixup' into 'main'
gl: Treat internal textures as special case

See merge request GNOME/gtk!7772
2024-10-01 01:46:44 +00:00
Benjamin Otte
43a6c8c5f5 gl: Treat internal textures as special case
Treat external as the normal case, and only try importing dmabufs
as non-external images if their format is on the internal formats
list.

Also add internal linear formats to the internal formats list.

This fixes an issue where AR24:0 dmabufs were imported as external
textures, causing some of the compare tests to fail.
2024-09-30 21:16:41 -04:00
Matthias Clasen
3789191853 docs: Stop mentioning the gl renderer
It is going away.
2024-09-30 19:24:42 -04:00
Matthias Clasen
eb4fb2af0e gsk: Stop falling back to the gl renderer
The GL renderer is going away. For now, it is still possible
to use it explicitly, with GSK_RENDERER=gl.
2024-09-30 19:22:54 -04:00
Matthias Clasen
fd02afa2e4 tools: Drop support for the gl renderer
The GL renderer is going away in 4.18.
2024-09-30 19:22:54 -04:00
Matthias Clasen
55bb77cffc tests: Use the ngl renderer in one more place 2024-09-30 19:22:54 -04:00
Matthias Clasen
119ba5844f testsuite: Drop glshader tests
And drop the gl renderer test here, but add ngl and Vulkan
equivalents.
2024-09-30 19:22:54 -04:00
Matthias Clasen
9b2b5ebb65 gsk: Stop supporting gl shaders
The GL shader code uses the GL renderer for compilation, and that
renderer is going away.
2024-09-30 19:22:54 -04:00
Matthias Clasen
1624455a32 gsk: Use the ngl renderer for serializing to png
This is a step towards dropping the GL renderer.
2024-09-30 18:58:33 -04:00
Matthias Clasen
d483883f38 node-editor: Use NGL for exporting images
This is a step towards dropping the GL renderer.
2024-09-30 18:58:33 -04:00
Matthias Clasen
0dc0bea1d5 gtk4-demo: Drop the glshader demos
The GL renderer will be going away in 4.18, and with that, shader
nodes will stop working for good. It is time to start preparing
for that.
2024-09-30 18:58:33 -04:00
Matthias Clasen
55e31b972c Merge branch 'dmabuf-failable-download' into 'main'
Make gdk_dmabuf_downloader_download failable

See merge request GNOME/gtk!7720
2024-09-30 22:41:57 +00:00
Matthias Clasen
1013874de8 gpu: Drop get_dmabuf_formats
This vfunc is no longer needed.
2024-09-30 18:37:20 -04:00
Matthias Clasen
c397460c11 Drop gdk_dmabuf_downloader_supports
It is not used anymore.
2024-09-30 18:37:20 -04:00
Matthias Clasen
ff0045b8c9 dmabuftexture: Stop having a fixed downloader
Change things from picking a download method at creation time to
trying all methods at download time until one succeeds.
2024-09-30 18:37:20 -04:00
Matthias Clasen
d0b409d349 Make gsk_gpu_frame_download_texture return status
Importing a dmabuf can fail, even if the format is supported
in princicple, In these cases, gsk_gpu_frame_download_texture
will return FALSE.
2024-09-30 18:37:20 -04:00
Matthias Clasen
c0cb10262d Make gdk_dmabuf_download_mmap return status
Make this function return whether it was successful, and only emit
a debug message if we succeeded. In particular, make it return FALSE
if the dmabuf format is not linear.
2024-09-30 18:37:20 -04:00
Matthias Clasen
279a5f7825 Make gdk_dmabuf_downloader_download failable
This will enable us to try multiple downloaders in a row.
2024-09-30 18:37:20 -04:00
Matthias Clasen
6fa87d4f37 gsk renderer: Add a debug message
Add a debug message so we can see what downloaders are used
for dmabufs.
2024-09-30 18:37:20 -04:00
Matthias Clasen
fe35daaf34 Merge branch 'wip/otte/dont-download-the-upload-of-the-download' into 'main'
gpu: Don't use copies for dmabuf downloads

Closes #7046

See merge request GNOME/gtk!7770
2024-09-30 22:30:58 +00:00
Benjamin Otte
c3b836951a gl: ref the previous context
The current context might be the last reference to the context, which
would make it go away when the renderer calls make_current().

See commit 0fa2ae48d4 for a similar case.
2024-09-30 23:54:08 +02:00
Matthias Clasen
ec10f1fe16 gsk: Don't lose context during download
When we use download in the middle of an upload operation (or the
other way around), we may end up making a different GL context
current. The downloader code is reponsible for reestablishing
the previous context when it is done. The old GL renderer was
doing that, NGL wasn't, until now.
2024-09-30 23:49:59 +02:00
Benjamin Otte
ae741a06c0 gpu: Compare fourccs, not GdkMemoryFormat
For dmabufs, the format is not an exact description of the data, it only
gives the closest memory format for a given fourcc.
This of course means that multiple different fourccs may report the same
format.

So when deciding if we need to copy the image to get the right data to
download, we need to check if the fourcc is correct, not if the format
is.

Related: #7046
2024-09-30 22:14:38 +02:00
Benjamin Otte
754c9cb323 gpu: Don't use copies for dmabuf downloads
When we want to download a dmabuf, we want to download the actual
dmabuf.

If we just grab the cached image and use that, we might get the
(reuploaded) copy of the dmabuf. This happens when this renderer
doesn't support downloading this dmabuf but has used it before.

Worse, this is a reentrancy issue, where this renderer is trying to
render the dmabuf and has already scheduled the upload but the upload
has not finished. We will then download from an empty image, which is
very wrong.

The way to check that we have the actual dmabuf is a bit brittle, but it
should work.

Fixes #7046
2024-09-30 19:52:30 +02:00
Benjamin Otte
a3683a080b Merge branch 'wip/otte/global-globals' into 'main'
ngl: Use a single buffer for globals

See merge request GNOME/gtk!7753
2024-09-30 17:09:52 +00:00
Matthias Clasen
0673d74986 Merge branch 'for-main' into 'main'
Cosmetics

See merge request GNOME/gtk!7768
2024-09-30 13:53:51 +00:00
Matthias Clasen
8c46df425e Merge branch 'default-cursor-xdg' into 'main'
wayland: Look for default cursor theme in XDG directories

See merge request GNOME/gtk!7766
2024-09-30 13:27:57 +00:00
Ilya Fedin
ff78e1888b wayland: Look for default cursor theme in XDG directories
Currently it's looked up only in /usr/share what is a problem for non-FHS distros like NixOS
2024-09-30 15:50:11 +04:00
Matthias Clasen
f2f219f304 Cosmetics
Make the debug message match the rest: FORMAT:MODIFIER.
2024-09-30 07:40:48 -04:00
Matthias Clasen
bb46edcc21 dmabuf: Initizalize some memory
I've seen valgrind complain about external_only being uninitialized
after the call, when using llvmpipe. Better be safe than sorry, and
initialize these arrays.
2024-09-30 06:55:57 -04:00
Matthias Clasen
24173e3f93 Cosmetics
No point in having an early return since EGL_NO_IMAGE is what we
want to return anyway.
2024-09-30 06:50:20 -04:00
Anders Jonsson
ec73bcb05b Update Swedish translation
(cherry picked from commit 82f08089f1)
2024-09-29 22:16:13 +00:00
Juliano de Souza Camargo
6c74c9c970 Update Brazilian Portuguese translation
(cherry picked from commit 1610ecbbac)
2024-09-29 16:30:00 +00:00
Matthias Clasen
c9c35ae41d Merge branch 'for-main' into 'main'
testsuite: Don't assert more than guaranteed

See merge request GNOME/gtk!7763
2024-09-29 14:33:35 +00:00
Matthias Clasen
95cea06462 Revamp GDK_VULKAN_DEVICE slightly
Support a "help" value, as we do for other env vars.
2024-09-29 09:54:24 -04:00
Matthias Clasen
d01ca53bde testsuite: Don't assert more than guaranteed
Compositors don't guarantee that there's any physical devices
around to correspond to the input capabilities.

This was found running the tests against mutter headless.
2024-09-29 09:30:56 -04:00
Matthias Clasen
3d3cafefc8 Merge branch 'clear-settings-portal' into 'main'
wayland: Clear settings_portal when going to fallback with no portal settings

See merge request GNOME/gtk!7756
2024-09-29 13:25:15 +00:00
Matthias Clasen
86cdb0ceb2 Merge branch '7040-improve-video-input-stream-error-message' into 'main'
gstmediafile: improve error message when there is an input stream.

Closes #7040

See merge request GNOME/gtk!7747
2024-09-29 13:22:28 +00:00
nee
0c97c86573 gstmediafile: improve error message when there is an input stream.
Previously it was unclear why passing an input stream would crash a video,
unless you went into the source and read it.

This adds a clarifying message that only file based media files are supported.
2024-09-29 13:41:17 +02:00
Benjamin Otte
10fa570195 Merge branch 'wip/otte/for-main' into 'main'
gpu: Consider scissor when intersecting with recangle

Closes #7044

See merge request GNOME/gtk!7762
2024-09-29 04:55:12 +00:00
Benjamin Otte
e18c553457 gpu: Consider scissor when intersecting with recangle
The clip might be different from the scissor due to incompatible
intersections.

But the resulting intersection might be fully clipped, so we should
consider it.

Testsuite with longer explanation attached.

Fixes #7044
2024-09-29 06:29:47 +02:00
Matthias Clasen
187763d286 Merge branch 'for-main' into 'main'
wayland: Bring back the pointer viewporter

See merge request GNOME/gtk!7761
2024-09-29 00:21:36 +00:00
Fran Dieguez
e6ae136de0 Update Galician translation
(cherry picked from commit 8360bfc772)
2024-09-28 21:50:23 +00:00
Matthias Clasen
81efb63073 emojichooser: insert before closing the popover
Doing otherwise risks that the focus is moved back to the entry,
causing everything to be selected, and then replaced by the Emoji
we insert. Which is not the desired effect!
2024-09-28 14:53:12 -04:00
Matthias Clasen
cbadb1ed8e Merge branch 'pointer-viewporter-again' into 'main'
wayland: Bring back the pointer viewporter

See merge request GNOME/gtk!7760
2024-09-28 16:13:06 +00:00
Matthias Clasen
103e98f570 Merge branch 'default-cursor-size' into 'main'
wayland: Use the same default cursor size as gsettings schema

Closes #7043

See merge request GNOME/gtk!7754
2024-09-28 14:32:48 +00:00
Matthias Clasen
3768c751c5 wayland: Improve our cursor size selection
When picking a cursor image size for a given size, look for sizes
that do better when scaled by the viewporter:
- exact size
- twice the size
- closest larger size
- closest size
2024-09-28 10:26:42 -04:00
Matthias Clasen
e42014573a wayland: Bring back the pointer viewporter
This was a thinko in 403da9a2d5. We have the cursor
image in device pixels, but we still need to apply the viewporter
to inform the compositor about the desired pointer size in
application pixels.
2024-09-28 10:01:04 -04:00
Ilya Fedin
a9f1ff471b wayland: Use the same default cursor size as gsettings schema
Fixes: #7043
2024-09-28 16:50:05 +04:00
Ilya Fedin
e26a1bbda9 wayland: Clear settings_portal when going to fallback with no portal settings
All other code paths with goto fallback clear it, this makes the behavior consistent with them
2024-09-28 16:41:13 +04:00
Matthias Clasen
b2ae7a2448 Merge branch 'for-main' into 'main'
Cosmetics

See merge request GNOME/gtk!7751
2024-09-28 01:16:53 +00:00
Matthias Clasen
cb682c759d Cosmetics
No newlines in g_warning.
2024-09-27 20:54:46 -04:00
Benjamin Otte
b154c9caf4 ngL: Use a single buffer for globals
Instead of using glBuffer(Sub)Data() every time we set new globals, fill
a single buffer with all the globals and use glBindBufferRange() on that
buffer to set the current globals.
2024-09-28 02:25:40 +02:00
Matthias Clasen
523fca21e9 Merge branch 'wip/kabus/a11y-present-label' into 'main'
label: Don't set a11y label when role is presentation

See merge request GNOME/gtk!7750
2024-09-27 17:34:39 +00:00
Matthias Clasen
73ddde6eda Merge branch 'cursor-size-again' into 'main'
inspector: Tweak the cursor size control

See merge request GNOME/gtk!7749
2024-09-27 17:29:41 +00:00
Matthias Clasen
403da9a2d5 wayland: Redo cursor loading
Stop using a viewporter to scale cursors. Instead, just pass
the surface scale to the cursor loading code, and take the
buffer dimensions and hotspot that it returns, unchanged.

This avoids problems with cursor themes like Breeze, where
buffer dimensions are different from the nominal cursor size.

Make the cursor loading code take a floating point scale,
and return the closest sized cursor that it can find.
2024-09-27 12:37:25 -04:00
Khalid Abu Shawarib
fb6f211869 label: Don't set a11y label when role is presentation
This resolves issue with labels of model buttons being set to
presentation a11y role but still have a11y label.

See: b7e5a79468/gtk/gtkmodelbutton.c (L1539)
2024-09-27 19:15:41 +03:00
Matthias Clasen
c358606a46 inspector: Tweak the cursor size control
Useful for debugging our cursor loading code.
2024-09-27 12:11:31 -04:00
Matthias Clasen
b7e5a79468 Merge branch 'listbox_tab_behavior' into 'main'
listbox: Introduce tab-behavior property

See merge request GNOME/gtk!7739
2024-09-27 11:42:14 +00:00
Benjamin Otte
06bcb0ee47 Merge branch 'wip/otte/ngl-downloader' into 'main'
Use NGL renderer for dmabuf downloads

See merge request GNOME/gtk!7741
2024-09-26 20:58:01 +00:00
Matthias Clasen
58ce0a39dc dmabuf: Use the ngl downloader
It works, now and is faster than the old GL downloader.

Playing the Barbie trailer @ 4k with hardware decoding but the Cairo
renderer on a 4k screen:

downloader  windowed  fullscreen
GL          12fps     19fps
NGL         16fps     29fps
Vulkan      16fps     29fps
no dmabufs  12fps     19fps
2024-09-26 22:06:18 +02:00
Benjamin Otte
6d3c333208 gpu: Actually ensure a downloadable dmabuf
For some formats, we could not download the dmabuf directly - in
particular YUV formats.
For those, do a copy on the GPU into the correct format.

While we're at it, also check the desired format and colorstate and if
they don't match, do the conversion on the GPU instead of using
gdk_memory_convert().
Reserve the CPU conversion for situations where the GPU doesn't support
the final format - like for example G8A8 (or often also RGB16).
2024-09-26 22:06:18 +02:00
Benjamin Otte
62c3923e5a gpu: Handle all colorstates in cache
Make gsk_gpu_cache_cache_texture_image() API safer by accepting all
color states as input and just not caching the images for colorstates we
don't care about.
2024-09-26 22:06:18 +02:00
Benjamin Otte
3be8b1d927 gpu: Check if the image is cached in right colorstate
This is most likely not a very likely check, but just to be sure, check
if the image exists in the cache in the desired colorstate already.
2024-09-26 22:06:18 +02:00
Benjamin Otte
27a61e221f gpu: Shuffle function arguments
Instead of passing down the depth and extracting format/srgb from it at
the end, extract format/srgb in the nodeprocessor and pass it down.

This allows creating offscreens for weirder formats in the future.
2024-09-26 22:06:18 +02:00
Benjamin Otte
52df3481d6 gpu: Add a gsk_gpu_download_into_op()
... and use it for the dmabuf downloader

Splits the download op into 2 separate ops: One for downloading textures
and one for downloading into preallocated memory.

The download into memory is the fallback for the texture downloading op,
so they need to share code.

But keeping them separate ensures that the different codepaths for
dmabuf download and render_texture() don't get mixed up in weird ways
that potentially call into each other.

By passing the emory down into the op we can also avoid an extra memcpy
which can lead to quite large speedups for big textures.
2024-09-26 22:06:17 +02:00
Benjamin Otte
ccb993d87b gpu: Split out a function
I want to use it from elsewhere in future commits.
2024-09-26 22:06:17 +02:00
Benjamin Otte
5fdaa4a232 gl: Move function
We want to share the texture download function with the renderers, so
they can download textures without needing to wrap them in a
GdkGLTexture.

Move it into gdkglcontext.c for that purpose.
2024-09-26 22:06:17 +02:00
Benjamin Otte
8b166dff74 gltexture: Split out a function
No functional changes
2024-09-26 22:06:17 +02:00
Benjamin Otte
f6b3f321a4 dmabuf: Refactor GPU renderer
We don't want to ever try fallback uploads in the dmabuf path. So
refactor gdk_frame_upload_texture() to have a flag that turns that off.
2024-09-26 22:06:17 +02:00
Benjamin Otte
a314143a83 gpu: Pass color state to download op
Previously we were always implicitly using SRGB, which was correct more
or less by accident.
2024-09-26 22:06:17 +02:00
Benjamin Otte
6c7abf425a Merge branch 'wip/otte/for-main' into 'main'
testsuite: Remove leftover test.in files

See merge request GNOME/gtk!7744
2024-09-26 18:47:49 +00:00
Matthias Clasen
b11e45762b Merge branch 'cursor-update-now' into 'main'
wayland: Make cursor changes effective immediately

Closes #6909

See merge request GNOME/gtk!7745
2024-09-26 18:07:28 +00:00
Benjamin Otte
d041a681a5 Merge branch 'wip/otte/drop-gles2' into 'main'
Drop support for GLES 2 and GL < 3.3

See merge request GNOME/gtk!7743
2024-09-26 17:51:09 +00:00
Matthias Clasen
d22d2f77a6 wayland: Make cursor changes effective immediately
When the cursor theme changes, update the cursors of our surfaces.

Fixes: #6909
2024-09-26 12:53:38 -04:00
Benjamin Otte
7458461d06 gl: Remove unpack-subimage checks
GLES 3.0 supports it unconditionally.
2024-09-26 18:41:13 +02:00
Benjamin Otte
283615936b gl: Remove check for half-float vertex data
All supported versions require it after we dropped support for GLES 2.
2024-09-26 18:41:13 +02:00
Benjamin Otte
2274bca95b gl: Require support for GLsync
It's supported by GL >= 3.2 and GLES >= 3.0 and we require both now.
2024-09-26 18:41:13 +02:00
Benjamin Otte
f8b4deeac0 gdk: Drop support for GL < 3.3
The new renderers need features from GL 3.3 and GLSync is very required
these days, too.

Note that this is about GL proper, not GLES.
2024-09-26 18:41:13 +02:00
Benjamin Otte
afa503c2e0 gl: Remove GLES 2 specific parts of format checks 2024-09-26 18:41:13 +02:00
Benjamin Otte
105f5f1137 gpu: Remove check for GLES 2
GLES 2 is no longer supported.
2024-09-26 18:41:13 +02:00
Benjamin Otte
b83ad60a1f gdk: Drop support for GLES 2
We now require GLES 3.
2024-09-26 18:41:13 +02:00
Benjamin Otte
58b44ebc1c testsuite: Remove GLES 2 tests
We want to drop GLES 2 support.
2024-09-26 18:41:13 +02:00
Benjamin Otte
b598f21506 testsuite: Remove leftover test.in files
We stopped supporting installed tests in 3121f88265 but forgot to remove
these files.
2024-09-26 16:35:47 +00:00
Matthias Clasen
d3c166d511 Merge branch 'for-main' into 'main'
gtk-demo: Stop using g_time_zone_new

See merge request GNOME/gtk!7742
2024-09-26 15:35:06 +00:00
Matthias Clasen
76e93206f3 Stop using G_APPLICATION_FLAGS_NONE
It has been deprecated in favor of G_APPLICATION_DEFAULT_FLAGS.
2024-09-25 22:03:23 -04:00
Matthias Clasen
ecfe47af73 docs: Drop a note about old GLib
We require GLib 2.76 now.
2024-09-25 22:00:38 -04:00
Matthias Clasen
f20ca9067e gtk-demo: Stop using g_time_zone_new
It is deprecated in favor of g_time_zone_new_identifier.
2024-09-25 21:57:49 -04:00
Matthias Clasen
8f3cd4733c Merge branch 'for-main' into 'main'
Stop using g_memdup

See merge request GNOME/gtk!7740
2024-09-26 01:22:23 +00:00
Matthias Clasen
402ee9b39c Tweak the issue template
Ask for more relevant information.
2024-09-26 02:53:54 +02:00
Matthias Clasen
becbf4e1f9 Update the README slightly 2024-09-26 02:53:54 +02:00
Matthias Clasen
67407d5dcf tools: Minor cleanup
No need to register all types here.
2024-09-26 02:53:54 +02:00
Matthias Clasen
fcc0f243cf Stop using g_pattern_match_string
It has been deprecated in favor of g_pattern_spec_match_string.
2024-09-26 02:53:54 +02:00
Matthias Clasen
282dcfa9ac Apply review feedback, mostly formatting. 2024-09-25 11:21:52 +00:00
Matthias Clasen
8c04801f6a Stop using g_memdup
Its deprecated in favor of g_memdup2
2024-09-25 10:56:36 +02:00
Lukáš Tyrychtr
abe2d1cb16 listbox: Introduce tab-behavior property
This is similar to the other tab-behavior properties, and allows
to control how the tabbing behaves in context of a GtkListBox.

It allows to make gnome-initial-setup#216 history, for example.
2024-09-25 10:07:43 +02:00
Benjamin Otte
e407d22b1e Merge branch 'wip/otte/for-main' into 'main'
keynames: Use C types

See merge request GNOME/gtk!7737
2024-09-25 02:07:23 +00:00
Benjamin Otte
37cefde5b0 demo: Unmix argument names 2024-09-25 02:50:22 +02:00
Benjamin Otte
310a4a3bf6 gdk: Fix parameter names
Believe in your self!
2024-09-25 02:50:22 +02:00
Benjamin Otte
e6896aa8dc gpu: Fix argument names 2024-09-25 02:50:22 +02:00
Benjamin Otte
36ce68a3ca textbuffer: includes go before G_BEGIN_DECLS 2024-09-25 02:50:22 +02:00
Benjamin Otte
797343da59 gtkpango: Fix argument names 2024-09-25 02:50:22 +02:00
Benjamin Otte
bd3223d452 testsuite: Add missing headers 2024-09-25 02:50:22 +02:00
Benjamin Otte
87a1a17868 memoryformat: Rename parameter
It's meant to match the prototype.
2024-09-25 02:50:22 +02:00
Benjamin Otte
70f386bd68 keynames: Use C types
Then we don't need to include glib.h
2024-09-25 02:50:22 +02:00
Benjamin Otte
0af89088ba gdk: Include missing header 2024-09-25 02:50:22 +02:00
Benjamin Otte
7342317c31 gdk: Fix parameter names 2024-09-25 02:50:22 +02:00
Benjamin Otte
8d8bd4efba broadway: Fix argument name 2024-09-25 02:50:22 +02:00
Benjamin Otte
0ae3c8968e gdk: Add missing header 2024-09-25 02:50:22 +02:00
Benjamin Otte
5e3f13acd1 filetransferportal: Include missing header 2024-09-25 02:50:22 +02:00
Benjamin Otte
32cdf35583 broadway: Fix argument name 2024-09-25 02:50:22 +02:00
Benjamin Otte
2f670bdc59 demo: Fix typo 2024-09-25 02:50:22 +02:00
Benjamin Otte
8d5660b4ab demo: Fix argument name 2024-09-25 02:50:22 +02:00
Benjamin Otte
2a39f427e1 testsuite: include missing headers 2024-09-25 02:50:22 +02:00
Benjamin Otte
ca86294325 tools: Include missing headers 2024-09-25 02:50:22 +02:00
Benjamin Otte
820ba1ef13 demo: Correct argument name 2024-09-25 02:50:22 +02:00
Benjamin Otte
9507130dbc demo: Unmix argument names 2024-09-25 02:50:22 +02:00
Benjamin Otte
d2dede635b demo: include missing header 2024-09-25 02:50:22 +02:00
Benjamin Otte
5a7fc4054b memoryformat: Fix argument names in prototype 2024-09-25 02:50:22 +02:00
Benjamin Otte
7fe22845e3 Merge branch 'wip/otte/fix-ci' into 'main'
testsuite: Use RGBA8 reference images

See merge request GNOME/gtk!7735
2024-09-24 17:52:55 +00:00
Matthias Clasen
6c9a7cc708 Merge branch 'gtk-find' into 'main'
Add gtk_string_list_find method

See merge request GNOME/gtk!7733
2024-09-24 17:24:10 +00:00
Benjamin Otte
feeca98270 testsuite: Use RGBA8 reference images
Due to a Mesa bug, RGBA16 images aren't properly handled sometimes and
can cause random failures.
In this case, generating the modified reference images for the tests
fails.

Fixes CI breakage.

Related: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11750
2024-09-24 13:57:09 +00:00
taozuhong
7c27241479 Add gtk_string_list_find method
This is a convenience API to find a given string's position.

Test included.
2024-09-24 15:44:04 +02:00
Matthias Clasen
fb73040d70 Merge branch 'for-main' into 'main'
Fix tests for 4.17

See merge request GNOME/gtk!7736
2024-09-24 13:42:25 +00:00
Matthias Clasen
bbe74abf51 Fix tests for 4.17 2024-09-24 14:23:31 +02:00
Matthias Clasen
34bd3fc854 Merge branch 'scale-focus-fix' into 'main'
theme: Fix scale sizing during .fine-tune

See merge request GNOME/gtk!7659
2024-09-24 11:54:21 +00:00
Benjamin Otte
940b5af2a8 Merge branch 'wip/otte/for-main' into 'main'
Revert "dmabuf: Use the ngl downloader"

See merge request GNOME/gtk!7734
2024-09-24 10:05:27 +00:00
Benjamin Otte
0929d77f7f Revert "Fix the ngl downloader"
This reverts commit c7dfb8cb55.
2024-09-24 11:29:59 +02:00
Benjamin Otte
617297ddd7 Revert "gpu: Make gsk_gpu_copy_image available"
This reverts commit 42d26720d6.
2024-09-24 11:29:59 +02:00
Benjamin Otte
67cec180ca Revert "gsk: Make downloaders work fully"
This reverts commit de74fa0836.
2024-09-24 11:29:59 +02:00
Benjamin Otte
bab8f2f976 Revert "dmabuf: Use the ngl downloader"
This reverts commit 97e0f872a2.
2024-09-24 11:29:59 +02:00
Matthias Clasen
4801c3275e Merge branch 'wip/otte/win32-remove-sync' into 'main'
win32: Remove gdk_display_sync()

See merge request GNOME/gtk!7727
2024-09-24 07:03:53 +00:00
Matthias Clasen
39354b3b99 Merge branch 'wip/otte/x11-remove-sync' into 'main'
x11: Remove gdk_display_sync() call

See merge request GNOME/gtk!7728
2024-09-24 07:03:20 +00:00
Matthias Clasen
661e953558 Merge branch 'dmabuf-downloader-investigations' into 'main'
Fix the ngl downloader

See merge request GNOME/gtk!7731
2024-09-24 07:02:09 +00:00
Matthias Clasen
039b97ef9e Start 4.17 2024-09-24 08:42:21 +02:00
Matthias Clasen
630699fb68 Post-release version bump 2024-09-24 08:37:11 +02:00
Matthias Clasen
3f4a414b1d 4.16.2 2024-09-24 08:14:26 +02:00
Matthias Clasen
4569b1ab40 Merge branch '5917-stack-sidebar-object-ref' into 'main'
stack-sidebar: Hold reference to page

Closes #5917

See merge request GNOME/gtk!6144
2024-09-23 20:51:06 +00:00
Peter Bloomfield
a484e8fc37 stack-sidebar: Hold reference to page 2024-09-23 20:51:05 +00:00
Matthias Clasen
d51bf6d905 Merge branch 'fix-gl-texture-leak' into 'main'
gsk: Don't leak gl textures

Closes #7013

See merge request GNOME/gtk!7725
2024-09-23 20:50:30 +00:00
Matthias Clasen
358b0b4d13 Merge branch 'wip/state-driven-controller-changes' into 'main'
gtkwidget: Check for destroyed controllers while propagating state

Closes #6924

See merge request GNOME/gtk!7668
2024-09-23 20:45:01 +00:00
Matthias Clasen
97e0f872a2 dmabuf: Use the ngl downloader
It works, now.
2024-09-23 21:14:53 +02:00
Matthias Clasen
de74fa0836 gsk: Make downloaders work fully
Use gsk_gpu_copy_image when necessary to get the image converted
into the right format before downloading it.
2024-09-23 21:14:19 +02:00
Matthias Clasen
42d26720d6 gpu: Make gsk_gpu_copy_image available
This was a static helper in gsknodeprocessor.c, but we want to
use it elsewhere, so make it available.
2024-09-23 21:14:19 +02:00
Matthias Clasen
c7dfb8cb55 Fix the ngl downloader
The image is already associated with the original texture, the
one that the download op creates is purely to hand it to the
downloader, it should not be associated with the image.

This makes the ngl downloader work as well as the vulkan one
(ie rgba dmabufs work, yuv ones don't, since we don't convert
them).
2024-09-23 21:14:08 +02:00
Daniel
8648a67c10 Updated Spanish translation 2024-09-23 09:39:29 +02:00
Matthias Clasen
f9b3ce95c2 Merge branch 'inspector-clipboard-criticals' into 'main'
inspector: Avoid criticals in the clipboard code

Closes #7026

See merge request GNOME/gtk!7730
2024-09-22 08:45:08 +00:00
Matthias Clasen
c828813d78 Merge branch 'not-a-mimetype-no-no' into 'main'
wayland: Be more careful with mimetypes

See merge request GNOME/gtk!7729
2024-09-22 08:43:44 +00:00
Matthias Clasen
5935dc174f inspector: Avoid criticals in the clipboard code
We keep a pointer to the GdkDrop object without a reference, and
then it dies on us. Be more careful, and clean up the dnd section
when the we drop object goes away.

Fixes: #7026
2024-09-22 09:58:31 +02:00
Matthias Clasen
b623b2acef wayland: Be more careful with mimetypes
Sometimes, jokers send us 'mimetypes' like DELETE or
org.webkitgtk.WebKit.custom-pasteboard-data, and gdk_intern_mime_type
will return NULL for such things. Handle that by just closing the fd.

Better than running into an assertion further down.
2024-09-22 09:25:44 +02:00
Yaron Shahrabani
cc867eeccf Update Hebrew translation 2024-09-21 19:39:39 +00:00
Benjamin Otte
17bdb4c8fb Merge branch 'wip/otte/for-main' into 'main'
wayland: Don't call gdk_display_sync()

Closes #7022 and #7025

See merge request GNOME/gtk!7726
2024-09-21 17:01:19 +00:00
Benjamin Otte
236b6d1cd6 x11: Remove gdk_display_sync() call
This is unnecessary.
Worse, it is reentrant and can cause all sorts of avoc when processing
events halfway through initializing the Vulkan context.

It was introduced in commit e11a6a0e68 but back then GTK was barely
branched for GTK4 and Vulkan drivers were very new, and it looks like an
unnecessary workaround.

Testing did not seem to indicate any issues with just removing it, so
here it goes.

Related: #7022
2024-09-21 18:59:49 +02:00
Matthias Clasen
9ded3e64a2 Merge branch 'fix-rtl-centered-labels' into 'main'
Fix centered text in labels

Closes #6836

See merge request GNOME/gtk!7724
2024-09-21 16:39:42 +00:00
Benjamin Otte
6e714722c4 win32: Remove gdk_display_sync()
This is unnecessary.
Worse, it is reentrant and causes all sorts of avoc when processing
events halfway through initializing the context.

It only exists because in commit c4244ea1 the win32 Vulkan code was
copy/pasted from another backend.

Related: #7022
2024-09-21 18:19:26 +02:00
Benjamin Otte
60b1496091 wayland: Don't call gdk_display_sync()
It is not necessary.
Worse, it is reentrant and causes all sorts of avoc when processing
events halfway through initializing the context.

It only exists because in commit 3887548 the Wayland Vulkan code
was copy/pasted from X11.

Fixes #7022
Fixes #7025
2024-09-21 18:18:29 +02:00
Matthias Clasen
dc1b2d4117 gsk: Don't leak gl textures
We need to fix all the textures we own. This broke in 65c8320a.

Fixes: #7013
2024-09-21 10:51:26 +02:00
Matthias Clasen
e205f13495 Fix centered text in labels
When the text is rtl, pango will put the text at the right end of
its given width, causing the logical.x to be big, and in turn, our
computed position to be negative. If we don't allow that, centered
text will end up at the right side if it is rtl.

Fixes: #6836
2024-09-21 10:06:33 +02:00
Benjamin Otte
72718b7193 Merge branch 'wip/otte/critical-warning' into 'main'
vulkan: Demote g_critical() to g_warning()

See merge request GNOME/gtk!7723
2024-09-20 22:54:18 +00:00
Benjamin Otte
db95e37e15 vulkan: Demote g_critical() to g_warning()
For VK_DEBUG_REPORT_WARNING_BIT_EXT we should always have used
g_warning().

For VK_DEBUG_REPORT_ERROR_BIT_EXT g_critical() is technically the right
choice, but Mesa has been using this flag for normal warnings, so until
that gets fixed, we don't want to throw criticals.

Related: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31292
Fixes: !7020
2024-09-20 23:02:15 +02:00
Juliano de Souza Camargo
f9714cc054 Update Brazilian Portuguese translation 2024-09-20 00:03:31 +00:00
Ekaterine Papava
58c49ce6b0 Update Georgian translation 2024-09-19 23:03:39 +00:00
Florian Heiser
13364cea74 Update German translation 2024-09-19 08:25:48 +00:00
Andika Triwidada
f6014bdc08 Update Indonesian translation 2024-09-19 01:05:51 +00:00
Hugo Carvalho
6070edfa61 Update Portuguese translation 2024-09-18 21:52:59 +00:00
Emin Tufan Çetin
0600357373 Update Turkish translation 2024-09-18 07:05:11 +00:00
Yuri Chornoivan
7873ebac2a Update Ukrainian translation 2024-09-18 06:39:12 +00:00
Luming Zh
8edd376ab8 Update Chinese (China) translation 2024-09-18 01:21:37 +00:00
Piotr Drąg
6f300557bf Update Polish translation 2024-09-17 18:44:48 +02:00
Martin
bcda071d7d Update Slovenian translation 2024-09-17 15:22:00 +00:00
Jordi Mas i Hernandez
9df3a50c87 Update Catalan translation 2024-09-17 10:45:22 +00:00
Danial Behzadi
70d41583b3 Update Persian translation 2024-09-17 10:32:44 +00:00
Matthias Clasen
a50df37d52 Merge branch 'iss-5072' into 'main'
gtk/print/gtkprintoperation{,-unix,-portal}.c: add CAIRO_HAS checks

Closes #5072

See merge request GNOME/gtk!7717
2024-09-17 10:05:18 +00:00
Matthias Clasen
b7d07ae190 Merge branch 'dmabuf-init-refactor' into 'main'
Refactor dmabuf initialization

See merge request GNOME/gtk!7714
2024-09-17 09:56:25 +00:00
Thomas Devoogdt
3610ac0fd1 gsk/gskrendernodeparser.c: add CAIRO_HAS check
resolves #5072

Signed-off-by: Thomas Devoogdt <thomas@devoogdt.com>
2024-09-17 10:55:41 +02:00
Thomas Devoogdt
9f855eecb1 modules/printbackends/gtkprintbackendfile.c: add CAIRO_HAS checks
This is similar to the checks in tools/gtk-rendernode-tool-render.c.

resolves #5072

Signed-off-by: Thomas Devoogdt <thomas@devoogdt.com>
2024-09-17 10:55:40 +02:00
Thomas Devoogdt
ffc8f34dfd gtk/print/gtkprintoperation{,-unix,-portal}.c: add CAIRO_HAS checks
This is similar to the checks in tools/gtk-rendernode-tool-render.c.

resolves #5072

Signed-off-by: Thomas Devoogdt <thomas@devoogdt.com>
2024-09-17 10:55:39 +02:00
Matthias Clasen
7acc1c0125 Make dmabuf initialization lazier
Only initialize the Vulkan or EGL parts where possible.

When dmabufs or dmabuf formats are actually used, we still
initialize fully by creating both a Vulkan and EGL downloader.

This shortens the time to first commit from 149ms to 108ms.
2024-09-17 09:46:01 +02:00
Matthias Clasen
6059eaf355 gdk: Reorganize dmabuf initialization
Change the xxx_get_downloader() functions to init_dmabuf_xxx(),
and make them initialize both xxx_dmabuf_formats and xxx_downloader.
2024-09-17 09:46:01 +02:00
Alexander Shopov
26971c48d4 Update Bulgarian translation 2024-09-17 07:42:50 +00:00
Matthias Clasen
b42caef0ed Merge branch 'builder-tool-box-position' into 'main'
builder-tool: Handle pack-type, position, and center child in GtkBox

See merge request GNOME/gtk!7715
2024-09-17 05:42:46 +00:00
Elliott Sales de Andrade
b3706daf90 builder-tool: Handle pack-type, position, and center child in GtkBox
This takes the `position` property and ensures children are sorted by
it, splits children by `pack-type` (also reversing the order of `end`
children), and handles children with `type="center"`.

If either a center child or end children exist, then the `GtkBox` is
converted to a `GtkCenterBox`, with `start-widget`/`end-widget` being a
nested `GtkBox` with the relevant children.

The splitting does cause some non-`object` children to sort differently
(hence the change to `office-runner.expected`.)
2024-09-16 05:12:54 -04:00
Matthias Clasen
24dc9dc653 Drop the dmabuf_downloaders array
Just use two individual fields, so we can track if we've already
created each one. This also matches the individual fields we have
for the dmabuf formats.

And change preference order of downloaders

Previously, our order was mmap > vulkan > egl.

But depending on the hw (discrete vs integrated gpu), mmap
can be catastrophically slower (on the order of 20ms vs 1.5s).

So, change the order to egl > vulkan > mmap.

Note that this currently has less effect than we'd like to,
since we don't let the downloaders claim linear formats.
2024-09-16 09:55:31 +02:00
Elliott Sales de Andrade
172dfb14c4 builder-tool: Convert node children after the node itself
Some nodes like `GtkBox` need to process removed-in-GTK4 attributes to
correctly convert their contents. If the node children are processed
first, then those attributes are removed prematurely.
2024-09-16 02:39:47 -04:00
Jordi Mas i Hernandez
3b43078b08 Update Catalan translation 2024-09-15 12:15:18 +00:00
Benjamin Otte
f2e75529cb Merge branch 'wip/otte/for-main' into 'main'
vulkan: Actually return the preferred memory format

See merge request GNOME/gtk!7713
2024-09-15 08:19:53 +00:00
Benjamin Otte
eed58b4051 gpu: Split out rect grid snapping function
We might want to use it outside of the nodeprocessor.

The function is now called gsk_rect_snap_to_grid().
2024-09-15 02:31:02 +02:00
Benjamin Otte
28a01ca954 gpu: Print some tex rects in verbose output
In the colorize and texture ops, print the tex rect. This is useful
because when adding new features with textures (like atlas usage), these
are the ops that I use for testing.
2024-09-15 02:31:02 +02:00
Benjamin Otte
efd5395ecf rendernode-tool: Download in the texture's format
When downloading textures, download the in the actual format of the
texture. We don't want to benchmark conversion, we want to benchmark
renderers.
2024-09-15 02:31:02 +02:00
Benjamin Otte
376dbe9def memoryformat: Move fast path into the threaded path
We don't want to get slower in the fast path.
2024-09-15 02:31:02 +02:00
Benjamin Otte
bba7979670 memoryformat: Add a fastpath for RGBA8 <=> BGRA8
Cairo is using BGRA8 but we want to use RGBA8 because it's the canonical
GL format.

So getting this fast sounds useful.
2024-09-15 02:31:02 +02:00
Benjamin Otte
01aafc6e65 memoryformat: Don't always convert to rec2100-linear and back
It turns out we lost the check to see if color states are equal when we
multithreaded things in !7657

Whoops.
2024-09-15 02:31:01 +02:00
Benjamin Otte
fa86bfcb55 gpu: Use existing frame in render_texture()
Instead of recreating frames from scratch every time, use an existing one.

This ensures that renderers don't need to recreate GPU resources every
time (like buffers and everything else that frames manage). It also
speeds up occasional render_texture() calls in default renderers.

This speeds up in particular the Vulkan renderer.
2024-09-15 02:31:01 +02:00
Benjamin Otte
c3d9f4a9ac gpu: Move a function
No functional changes.
2024-09-15 02:31:01 +02:00
Benjamin Otte
d11ac3585d gpu: Clean up the frame after we're done waiting for it
This is useful because cleaning up will do the final copies of texture
data.

It also means we use less memory, as we're going to release images that
were used in ops.
2024-09-15 02:31:01 +02:00
Benjamin Otte
8f78a0f809 gpu: Add an internal is_clean() check
If no ops are recorded, then we don't need to wait for any ops to
finish.

Also fix the initial fence creation on Vulkan - we no longer need to
create it fixed because of the random cleanup() call at startup does no
longer happen.
2024-09-15 02:30:59 +02:00
Benjamin Otte
3286d9f1b5 vulkan: Actually return the preferred memory format
We were just exiting the loop, but not remembering the index.

Speeds up various memory operations, sometimes by quite a lot.
2024-09-15 00:07:47 +02:00
Matthias Clasen
ee38c96ee3 Merge branch 'matthiasc/for-main' into 'main'
gsk: Add another profiler mark

See merge request GNOME/gtk!7712
2024-09-13 16:14:17 +00:00
Matthias Clasen
e5705bd141 gsk: Add another profiler mark
This lets us compare the cost of realizing the new renderers vs
the old GL renderer.
2024-09-13 11:02:52 -04:00
Matthias Clasen
753d74d676 Post-release version bump 2024-09-13 10:34:06 -04:00
Matthias Clasen
670b4aabac 4.16.1 2024-09-13 10:11:36 -04:00
Matthias Clasen
eba9316c12 Merge branch 'gtkcalendar-issue-6406' into 'main'
GtkCalendar: Avoid ending up with invalid dates

Closes #6406

See merge request GNOME/gtk!6851
2024-09-13 13:43:36 +00:00
Matthias Clasen
7f3835cc4f Merge branch 'phase-docs' into 'main'
docs: Fix typo and improve wording in drawing model docs

See merge request GNOME/gtk!7711
2024-09-12 16:21:51 +00:00
Matthias Clasen
be89fa7919 Merge branch 'docs-typo' into 'main'
gtklistitem: Fix a minor typo in the docs

See merge request GNOME/gtk!7681
2024-09-12 13:58:04 +00:00
Philip Withnall
20d6938a90 docs: Fix typo and improve wording in drawing model docs
There was a typo ‘phases happens’, but also some spurious whitespace and
slightly odd-sounding use of ‘we’ so I changed it to be phrased
passively.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-09-12 14:06:39 +01:00
Matthias Clasen
6f4f4d0123 Merge branch 'gbsneto/atspiroot-flatpak-portal-session-bus' into 'main'
a11y: Use session bus to check Flatpak portal

See merge request GNOME/gtk!7709
2024-09-12 10:24:27 +00:00
Arjan Molenaar
250322deb0 Merge branch 'amolenaar/dnd-icon-on-top' into 'main'
macos: Keep DnD windows always on top

Closes #6809 and #6818

See merge request GNOME/gtk!7706
2024-09-12 09:25:05 +00:00
Matthias Clasen
bdee95c32c Merge branch 'wip/otte/for-main' into 'main'
gpu: Don't crash when there's no ops

Closes #6992

See merge request GNOME/gtk!7710
2024-09-12 00:27:29 +00:00
Georges Basile Stavracas Neto
1ffd23dbab a11y: Use session bus to check Flatpak portal
The Flatpak portal (and so far all other portals) live in the session
bus, not in the a11y bus.

Use the session bus to get the Flatpak portal version. Avoid too many
synchronous D-Bus calls on startup by using g_once_init_* helpers.
2024-09-11 10:43:47 -03:00
Arjan Molenaar
e92bd4d9ce macOS: drag surfaces should ignore all events
This fixes the Dnd demo.
2024-09-11 14:59:03 +02:00
Georges Basile Stavracas Neto
24841a8d5b a11y: Correct return type of D-Bus call
org.freedesktop.DBus.Properties.Get() returns "(v)" which then
must be unpacked into an uint32 ("u") variant.
2024-09-11 08:53:38 -03:00
Matthias Clasen
c2dc459167 Merge branch 'label-docs-fix' into 'main'
gtkenums: Fix missing backtick in docs

See merge request GNOME/gtk!7683
2024-09-11 10:13:13 +00:00
Matthias Clasen
d87ce14869 Merge branch 'vulkan-294' into 'main'
vulkan: Add another two error codes

See merge request GNOME/gtk!7708
2024-09-11 10:12:40 +00:00
Benjamin Otte
e9735f0c35 gpu: Move GskGpuClip declaration into types header
Makes it possible to use it in multiple places.
2024-09-11 08:34:41 +02:00
Benjamin Otte
d320373262 gpu: Clarify a function
It does functionally the same now, but it makes it mroe clear how it
works.

As a bonus, it will now trigger for -Wswitch-enum, too.
2024-09-11 08:33:22 +02:00
Arjan Molenaar
a84fe6bde6 macos: Put DnD windows on status level
This will make sure the dragged window will stay visible.
2024-09-11 08:19:39 +02:00
Benjamin Otte
a8748598b6 gpu: verbose-print if shaders are inside merged ops
This is useful when trying to get more ops merged for performance
reasons.
2024-09-11 08:17:58 +02:00
Benjamin Otte
748acaf654 gpu: Use a better character for debug print
Instead of 🞨 which isn't supported in many places, use ⬚.

⬚ also fits better with □ and ▢ for describing clip regions.
2024-09-11 08:17:58 +02:00
Benjamin Otte
1ff9d1545d Revert "vulkan: Set VK_SWAPCHAIN_CREATE_DEFERRED_MEMORY_ALLOCATION_BIT_EXT"
This reverts commit ffae0010c4.

The commit doesn't work with the nvidia driver and it's not necessary to
use it, so drop it for now.

Fixes #6992
2024-09-11 08:17:43 +02:00
Benjamin Otte
e35670a014 gpu: Don't crash when there's no ops
In the rare situation (read: I triggered it with obscure hacks) where no
ops are emitted, we could end up pointing into invalid memory and
crashing.

Don't do that.
2024-09-11 08:17:43 +02:00
Benjamin Otte
9690c87736 docs: Remove duplicated text 2024-09-11 08:17:43 +02:00
Philip Withnall
a60d96a9ac gtkenums: Fix missing backtick in docs
Fixes the formatting for `GtkAlign`.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-09-11 00:35:47 +00:00
Matthias Clasen
0a9b501743 Merge branch 'plug-leak' into 'main'
filechooser: Plug a leak

See merge request GNOME/gtk!7705
2024-09-11 00:09:05 +00:00
Emmanuel Gil Peyrot
6dd55e381d vulkan: Fix error string
This one got added in 66ba1f76ba but didn’t end
the sentence with a dot, and didn’t have its enum name between parentheses so
that people can debug more easily which error code got generated.
2024-09-10 22:46:29 +00:00
Emmanuel Gil Peyrot
abd8d40bf9 vulkan: Add another two error codes
Those two come from the VK_KHR_pipeline_binary extension and have been added in
Vulkan 1.3.294.
2024-09-10 22:45:41 +00:00
Matthias Clasen
348e938698 Merge branch 'matthiasc/for-main' into 'main'
print dialog: Fix initial selection

Closes #6996

See merge request GNOME/gtk!7704
2024-09-10 18:35:08 +00:00
Sergey Bugaev
4e0a909ca9 directorylist: Fix criticals if monitoring fails
g_file_monitor_directory () can fail.  We're ignoring the actual error
by passing NULL for the error argument, but we shouldn't be trying to
connect to a signal on the NULL value that gets returned on error.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2024-09-10 18:38:56 +03:00
Sergey Bugaev
8964f6f0cc filechooser: Plug a leak
gtk_file_chooser_get_current_folder () is transfer full, while
g_list_store_append () is transfer none.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2024-09-10 18:29:45 +03:00
Matthias Clasen
b807b84e16 print dialog: Fix initial selection
This broke with recent fixes to GtkSingleSelection.

Fixes: #6996
2024-09-10 10:59:36 -04:00
Matthias Clasen
97a2c3a656 Merge branch 'wip/smcv/issue6995' into 'main'
gdkgltexture: Avoid use-after-free when switching GdkGLContext

Closes #6995

See merge request GNOME/gtk!7703
2024-09-10 11:23:30 +00:00
Bruce Cowan
5925c4c51f Update British English translation 2024-09-10 10:15:31 +00:00
Simon McVittie
0fa2ae48d4 gdkgltexture: Avoid use-after-free when switching GdkGLContext
`thread_current_context` might be holding the last reference to
`previous`, in which case `gdk_gl_context_make_current` on the new
context will free `previous`, leaving it a dangling pointer.
Avoid this by making sure to hold a reference.

Fixes: 41cd0c6f "gl: Fix initial EGL context creation on X11"
Resolves: https://gitlab.gnome.org/GNOME/gtk/-/issues/6995
Signed-off-by: Simon McVittie <smcv@debian.org>
2024-09-10 00:11:18 +01:00
Matthias Clasen
43303bf7e5 Merge branch 'matthiasc/for-main' into 'main'
Revert "css: Simplify theme loading"

Closes #6991

See merge request GNOME/gtk!7702
2024-09-09 12:35:57 +00:00
Anders Jonsson
f26f491d58 Update Swedish translation 2024-09-09 11:22:40 +00:00
Matthias Clasen
a9b46e8409 Revert "css: Simplify theme loading"
This reverts commit c033de9b83.

This change unintentionally broke use of relative paths in Adwaita.

Fixes: #6991
2024-09-09 06:51:34 -04:00
Daniel Mustieles
b27e67999b Update Spanish translation 2024-09-09 09:26:15 +00:00
Balázs Úr
3177fd14f9 Update Hungarian translation 2024-09-09 06:26:41 +00:00
Benjamin Otte
9ba41ed6e8 Merge branch 'wip/otte/blur-and-blit' into 'main'
Fix blur for opaque textures

Closes #6980

See merge request GNOME/gtk!7697
2024-09-09 04:46:43 +00:00
Matthias Clasen
70f2e2e09c Merge branch 'matthiasc/for-main' into 'main'
docs: Sync docs for GDK_VULKAN_DISABLE

See merge request GNOME/gtk!7700
2024-09-09 03:53:50 +00:00
Benjamin Otte
56fc8f0077 gpu: Blur opaque textures correctly
Opaque textures don't clamp to transparent but instead to black.
We didn't consider this, so we were blurring their edges into blackness
not into transparency.

Fix this by adding the GSK_GPU_AS_IMAGE_SAMPLED_OUT_OF_BOUNDS flag
and respecting it in the implementation that uses it.

Test included.

Fixes #6980
2024-09-09 05:10:51 +02:00
Benjamin Otte
85abff343e ngl: Images are not blittable if they have a swizzle
Swizzling is not respected for blitting.
See commit 058252e895 for the same change in Vulkan.
Apparently that never made it to ngl.

The next commit will have a test for this.
2024-09-09 04:18:13 +02:00
Benjamin Otte
6cefdfeddd testsuite: Fix udmabuf creation
We were using the wrong format and color state when downloading the
data.

Tests not included in this commit, but a few commits later.
2024-09-09 04:18:13 +02:00
Matthias Clasen
75fa51ef6d Cosmetics
Fix a typo
2024-09-08 19:35:53 -04:00
Matthias Clasen
4181b4b142 docs: Sync docs for GDK_VULKAN_DISABLE
Add swapchain-maintenance, and remove some no longer used values.
2024-09-08 19:35:00 -04:00
Benjamin Otte
7b55d2cf1a Merge branch 'wip/otte/for-main' into 'main'
vulkan: Enable VK_EXT_swapchain_maintenance1 if available

See merge request GNOME/gtk!7696
2024-09-08 23:25:36 +00:00
Benjamin Otte
03230181ce gpu: Add GskGpuAsImageFlags
I've had a need for flags for the get_as_image() call but so far have
been able to work around it. But now it seems I might finally need it.

This just introduces the flags but doesn't add any.

Related: #6980
2024-09-09 01:25:03 +02:00
Benjamin Otte
5e4f692e63 tiff: Store RGBx images as 4 channels
Set the alpha channel to "undefined" in this case.

Gimp doesn't seem to like this when opening the image and insists to
doing something with it, that's a bit of a bummer.

But it allows GTK to load RGBx textures.
2024-09-09 01:25:03 +02:00
Matthias Clasen
e9a046c439 Merge branch 'dead-hamza' into 'main'
imcontextsimple: Handle dead_hamza

See merge request GNOME/gtk!7699
2024-09-08 22:58:11 +00:00
Mohamed Akram
182de7c957 imcontextsimple: Handle dead_hamza 2024-09-09 00:02:29 +04:00
Aurimas Černius
6c939819a3 Update Lithuanian translation 2024-09-08 19:12:24 +00:00
Matthias Clasen
6288be286f Merge branch 'matthiasc/for-main' into 'main'
gsk: Small optimization

See merge request GNOME/gtk!7698
2024-09-08 17:29:27 +00:00
Matthias Clasen
76a13596aa gpu: Reduce per-glyph overhead
Pull the shader clip computation out of the loop in the common
case that the entire node is contained in the clip.
2024-09-08 12:57:31 -04:00
Matthias Clasen
c18cd6050b gpu: Use gsk_gpu_colorize_op2
This reduces the cost of these calls significantly, and this is
the inner loop of the node processor.
2024-09-08 12:43:02 -04:00
Matthias Clasen
60f5d4c93e gpu: Add a variant of gsk_gpu_colorize_op
This variant takes the color_states, instead of computing it
anew from the ccs and the color state of the color. This will
be used to pull this work out of the loop in add_glyph_node.
2024-09-08 12:41:48 -04:00
Matthias Clasen
03840151ac gsk: Drop an unused variable
We're not using last_image for anything.
2024-09-08 11:48:43 -04:00
Matthias Clasen
2e44f3e2ff gsk: Get the text node color once
We don't need to do this in the loop.
2024-09-08 11:48:43 -04:00
Matthias Clasen
4f9fd5cf1d Add gsk_text_node_get_font_hint_style
Getting the hint style is one of the more expensive calls we do
when adding glyph nodes, so cache this information in the node.
2024-09-08 11:48:43 -04:00
Matthias Clasen
59f334622b rendernode: Inline gsk_render_node_get_node_type
This is the most-called function on render nodes.
2024-09-08 11:48:43 -04:00
Matthias Clasen
c505a08e46 gsk: Small optimization
Avoid calling gsk_container_node_get_child in a loop.
2024-09-08 11:48:43 -04:00
Benjamin Otte
ffae0010c4 vulkan: Set VK_SWAPCHAIN_CREATE_DEFERRED_MEMORY_ALLOCATION_BIT_EXT
It seems Mesa doesn't support that yet, but having it doesn't hurt.

And it allows drivers to allocate less memory for the swapchains,
because we don't need all the 4 images we request in minImageCount.
But drivers tend to take that minimum image count as gospel, so we need
to use a higher number to not cause lag in corner cases.
2024-09-08 16:22:49 +02:00
Benjamin Otte
6c72a223f5 vulkan: Enable VK_EXT_swapchain_maintenance1 if available
This just adds the plumbing, usage will happen later.

For testing, GDK_VULKAN_DISABLE=swapchain-maintenance will turn it off.
2024-09-08 16:22:49 +02:00
Benjamin Otte
5a027594c3 vulkan: Add gdk_vulkan_context_has_feature()
A siimplification that will come in handy in the future.
2024-09-08 16:22:49 +02:00
Ask Hjorth Larsen
ebc3600f78 Update Danish translation 2024-09-08 14:15:54 +00:00
Arjan Molenaar
ae0cf9ff54 Merge branch 'amolenaar/focus-im-popups' into 'main'
macos: Fix popup window and keyboard input

Closes #6950 and #5049

See merge request GNOME/gtk!7653
2024-09-08 12:54:24 +00:00
Andi Chandler
08bf8b7464 Update British English translation 2024-09-08 12:26:07 +00:00
Hugo Carvalho
0201abca5e Update Portuguese translation 2024-09-08 10:38:11 +00:00
Asier Sarasua Garmendia
d87b566c59 Update Basque translation 2024-09-08 08:03:53 +00:00
Ekaterine Papava
572b4140f9 Update Georgian translation 2024-09-08 03:58:29 +00:00
Matthias Clasen
6241471f3e Merge branch 'matthiasc/for-main' into 'main'
gpu: Print blur colors

See merge request GNOME/gtk!7695
2024-09-07 18:46:10 +00:00
Matthias Clasen
1ae9cdb4c9 gpu: Print blur colors
Relevant information when debugging shadows.
2024-09-07 12:34:04 -04:00
Daniel Rusek
c1e1b54034 Update Czech translation 2024-09-07 15:52:31 +00:00
Matthias Clasen
f654cb7d3b Merge branch 'docs-remove-gtk-attribute' into 'main'
docs: Remove custom org.gtk.Method and org.gtk.Property annotations

See merge request GNOME/gtk!7335
2024-09-07 14:39:19 +00:00
Alexander Shopov
85beb4fa20 Update Bulgarian translation 2024-09-07 12:50:50 +00:00
twlvnn kraftwerk
a0e81996eb Update Bulgarian translation
(cherry picked from commit 090fcfe503)
2024-09-07 12:13:48 +00:00
Maximiliano Sandoval
ec477ef71d docs: Document property annotations in README.md 2024-09-07 09:51:33 +02:00
Maximiliano Sandoval
3afc760644 docs: Manually remove property annotations
We remove the annotations that did not match the regex of the previous commits.
2024-09-07 09:51:33 +02:00
Maximiliano Sandoval
ba32140671 docs: Remove all org.gtk.Method annotations
Removed via regex and grep.
2024-09-07 09:51:32 +02:00
Maximiliano Sandoval
91d36dd410 docs: Remove all org.gtk.Property annotations
Removed via regex and grep.

The following were intentionally not removed:

- GtkImage:file: (attributes org.gtk.Property.set=gtk_image_set_from_file)
- GtkImage:resource: (attributes org.gtk.Property.set=gtk_image_set_from_resource)

As they have no getter and (setter PROP) without a (getter PROP) crash
gobject-introspection. This is fixed by
ad3118eb51.
2024-09-07 09:51:32 +02:00
Maximiliano Sandoval
4fd1e32752 docs: Use correct property gir annotations
The annotations should only be set when the name of the setter or getter
for a property "GtkClassName:prop-name" is not gtk_class_name_g(s)et_property_name.
2024-09-07 09:51:26 +02:00
Matthias Clasen
b538adf2c0 Post-release version bump 2024-09-06 23:07:08 -04:00
Matthias Clasen
d16c9fbaca 4.16.0 2024-09-06 22:51:07 -04:00
Ahmed Baizid
9b6063c07c GtkCalendar: The focus cannot be moved to out of range dates
Out of range dates are in insensitive tabel cells.
2024-09-06 23:49:03 +01:00
Ahmed Baizid
d1a4740894 GtkCalendar: move_focus() invalidates days
calendar_invalidate_day() calls are no more disseminated.
2024-09-06 23:49:03 +01:00
Ahmed Baizid
5186c4dc45 GtkCalendar: Not allowed with the mouse, not allowed with the keyboard
Month/year navigation with the keyboard checks if the corresponding
widget is sensitive or not.
2024-09-06 23:49:03 +01:00
Ahmed Baizid
ca9664cdfd GtkCalendar: Disable navigation buttons for out of range months
`GtkCalendar`s span 0001-01/9999-12.
2024-09-06 23:49:03 +01:00
Ahmed Baizid
6c9edbf0da GtkCalendar: Out of range dates are neither displayed nor sensitive
`GDateTime`s span 0001-01-01/9999-12-31.
2024-09-06 23:49:03 +01:00
Ahmed Baizid
b8d2b1d3ce GtkCalendar: Extract calendar_update_day_labels()
calendar_select_day_internal() is too big, doing so many things.
2024-09-06 23:49:03 +01:00
Matthias Clasen
0274294a6f Merge branch 'wip/otte/cpu-mipmap' into 'main'
gpu: Allow uploading of mipmap levels when tiling

See merge request GNOME/gtk!7657
2024-09-06 22:14:37 +00:00
Matthias Clasen
03b19d8861 docs: Recommend glycin for image loading
Best to send people elsewhere to avoid misunderstandings of our api.
2024-09-06 16:52:47 -04:00
Matthias Clasen
171612671f demo: Beef up the image scaling demo
Add buttons for loading the Portland Rose, and a nameless large
png. Make them load the texture in a thread, to demonstrate better
handling of large images.
2024-09-06 16:14:24 -04:00
Matthias Clasen
d3db28b3f4 memory format: Add profiler marks
Add profiler marks to our long-running threaded operations.
To avoid spamming profiles too much, only report runs that take
at least 0.5 ms.
2024-09-06 16:14:24 -04:00
Benjamin Otte
896ea5b753 memoryformat: Add linear/nearest choice for mipmaping
linear will average all the pixels for the lod, nearest will just pick
one (using the same method as OpenGL/Vulkan, picking bottom right
center).

This doesn't really make linear/nearest filtering work as it should
(because it's still a form of mipmaps), but it has 2 advantages:

1. it gets closer to the desired effect

2. it is a lot faster

Because only 1 pixel is chosen from the original image, instead of
averaging all pixels, a lot less memory needs to be accessed, and
because memory access is the bottleneck for large images, the speedup is
almost linear with the number of pixels not accessed.
And that means that even for lot level 3, aka 1/8th scale, only 1/64 of
the pixels need to be accessed, and everything is 50x faster.

Switching gtk4-demo --run=image_scaling to linear/nearest makes all the
lag go away for me, even with a 64k x 64k image.
2024-09-06 15:47:35 -04:00
Benjamin Otte
5498b077fd memoryformat: Parallelize gdk_memory_mipmap() 2024-09-06 15:47:34 -04:00
Benjamin Otte
534a9b6ba0 memoryformat: Add fast path for mipmap
We have fast conversion functions, use those directly instead of calling
into gdk_memory_convert().

This is useful because as mentioned before, the main optimization here
is RGB8 => RGBA8 and we have a fastpath for that.
2024-09-06 15:47:34 -04:00
Benjamin Otte
cea961f4f4 memoryformat: Take src_format and dest_format
Why do we need this? Because RGB images are provided in RGB format but
GPUs can't handle RGB, only RGBA, so we need to convert.

And we need to do that without allocating too much memory, because
allocating memory is slow. Which means in aprticular we need to do the
conversion after mipmapping, not before (like we were doing).
2024-09-06 15:47:34 -04:00
Benjamin Otte
848c6815d3 gpu: Allow uploading of mipmap levels when tiling
This allows uploading less memory but requires computing lod levels on
the CPU which is slow because it reads through all of the memory and so
far entirely not optimized.

However, it uses significantly less VRAM.

This is done by adding a gdk_memory_mipmap() function that does this
task.
The texture upload op now accepts a lod level and if that is >0 it uses
gdk_memory_mipmap() on the source texture.
2024-09-06 15:47:34 -04:00
Benjamin Otte
46559039f3 memoryformat: Parallelize gdk_memory_convert_color_state() 2024-09-06 15:47:34 -04:00
Benjamin Otte
eb7a42bc13 memoryformat: Parallelize generic path of gdk_memory_convert() 2024-09-06 15:47:34 -04:00
Benjamin Otte
ffe56fe6b3 memoryformat: Parallelize
Refactor code so that it uses g_parallel_task_run().
2024-09-06 15:47:34 -04:00
Benjamin Otte
d4ba57fcc3 gdk: Add gdk_parallel_task_run()
This is just the API. Users will come later.

I considered putting it into gdkmemoryformat.c because it's likely gonna
be the only user and this one function is so little code, but it didn't
fit at all.
So now it's a new file.
2024-09-06 15:47:34 -04:00
Benjamin Otte
a95c9ebc51 memoryformat: Split out a function
Allow querying the fast conversion functions outside of
gdk_memory_convert().
2024-09-06 15:47:34 -04:00
Benjamin Otte
9195c39756 build: Alphabetic order is hard 2024-09-06 15:47:34 -04:00
Mat
e0ffeb8ded macos: simplify access to native widget. 2024-09-06 16:12:56 +00:00
Matthias Clasen
d9bb434c1f Merge branch 'bad-relative-color' into 'main'
css: Avoid a crash with relative colors

Closes #6985

See merge request GNOME/gtk!7693
2024-09-06 15:05:27 +00:00
Juliano de Souza Camargo
866c83909c Update Brazilian Portuguese translation 2024-09-06 13:00:13 +00:00
Luca Bacci
4965b7b6fa Merge branch 'wgl-updates' into 'main'
WGL Updates

Closes #6975

See merge request GNOME/gtk!7692
2024-09-06 12:47:41 +00:00
Matthias Clasen
45f3e86457 css: Allocate less when searching themes
We trawl through a whole bunch of directories, but we can do it
without allocation quite so much.
2024-09-06 07:54:59 -04:00
Matthias Clasen
c033de9b83 css: Simplify theme loading
There is no need to do a detour through a GFile here.
Just load the resource.
2024-09-06 07:54:37 -04:00
Matthias Clasen
3f7f9b705e css: Avoid a crash with relative colors
rgba(from @foo ...) would crash if @foo was not a named color.
Handle it as we do elsewhere, by returning NULL from resolve().

Test included.

Fixes: #6985
2024-09-06 07:54:37 -04:00
Matthias Clasen
b6d19f4c8b Fix css tests
Disable css deprecation warnings for the style tests. We want to
be able to do tests with named colors here.
2024-09-06 07:54:37 -04:00
Andika Triwidada
3a2b8f94ec Update Indonesian translation 2024-09-06 04:13:55 +00:00
Matthias Clasen
3a5933a519 Merge branch 'mcatanzaro/#6983' into 'main'
popover: fix critical on pop down

Closes #6983

See merge request GNOME/gtk!7691
2024-09-06 00:14:09 +00:00
Matthias Clasen
4c295dc49c popover: Avoid unnecessary work
If the popover isn't visible, no need to do any extra
'cascade' work. This also helps to avoid running into
trouble during finalization when the parents are already
gone.
2024-09-05 15:27:55 -04:00
Emin Tufan Çetin
03ebb41262 Update Turkish translation 2024-09-05 18:02:12 +00:00
Yaron Shahrabani
b0c3265561 Update Hebrew translation 2024-09-05 12:43:43 +00:00
Danial Behzadi
98943b28aa Update Persian translation 2024-09-05 12:16:59 +00:00
Vasil Pupkin
c354c5a63d Update Belarusian translation 2024-09-05 10:03:35 +00:00
Tim Sabsch
2f8cb9b2d0 Update German translation 2024-09-04 18:21:04 +00:00
Luca Bacci
7559a87e8a WGL: Detect MESA D3D12 driver and request GDI compatibility
This way we get a non-opaque framebuffer / render target

Fixes #6975

References:
  [1] https://gitlab.gnome.org/GNOME/gtk/-/issues/6975
  [2] https://gitlab.freedesktop.org/mesa/mesa/-/issues/11828
2024-09-04 20:02:44 +02:00
Luca Bacci
b2394691cc Inspector: Fix append_wgl_extension_row()
wglGetExtensionsStringARB takes an HDC argument even though it
checks extensions for the current context. This was done for future
extensibility. From [1]:

>    Should this function take an hdc? It seems like a good idea. At
>    some point MS may want to incorporate this into OpenGL32. If they
>    do this and and they want to support more than one ICD, then an HDC
>    would be needed.

Currently the HDC argument is unused, but still wglGetExtensionsStringARB()
is required to check if HDC is valid:

>    If <hdc> does not indicate a valid device context then the function
>    fails and the error ERROR_DC_NOT_FOUND is generated. If the function
>    fails, the return value is NULL. To get extended error information,
>    call GetLastError.

So wglGetExtensionsStringARB fails if we pass NULL. Here we can pass any
valid HDC, like for example the screen DC returned by GetDC(NULL), but
probably using wglGetCurrentDC() makes most sense.

Reference:
  [1] - https://registry.khronos.org/OpenGL/extensions/ARB/WGL_ARB_extensions_string.txt
2024-09-04 20:02:29 +02:00
Yuri Chornoivan
5a94004b59 Update Ukrainian translation 2024-09-04 16:46:15 +00:00
Michael Catanzaro
3bd609d77c popover: fix critical on pop down
It's expected that there may be no parent widget to grab focus.

This fixes 2299c02639.

Fixes #6983
2024-09-04 11:25:50 -05:00
Luca Bacci
84d2961a91 Inspector: Sync WGL extensions with GdkWin32GLContextWGL
Replace WGL_EXT_pixel_format with WGL_ARB_pixel_format and drop
WGL_ARB_MULTISAMPLE (unused).
2024-09-04 17:10:39 +02:00
Luca Bacci
3a9f26113f WGL: Fix attribs_remove_last() 2024-09-04 17:07:01 +02:00
Luca Bacci
6a240c36ac WGL: Swap core / compat in debug output 2024-09-04 17:04:58 +02:00
Luca Bacci
aaf4261969 WGL: Include renderer string in debug output 2024-09-04 17:03:54 +02:00
Arjan Molenaar
0211299846 macos: Fix input source popup placement in popovers 2024-09-04 17:03:14 +02:00
Arjan Molenaar
aca11d6879 macos: Only allow keyboard focus on toplevel windows
This avoids the focus to move to a popup or popover window.
The red/yellow/green buttons remain colored.
2024-09-04 17:03:14 +02:00
Luca Bacci
5dceb7f7d2 WGL: Make context current to get debug info
Otherwise we get NULL from glGetString()
2024-09-04 17:02:20 +02:00
Martin
3372b1a84b Update Slovenian translation 2024-09-04 14:26:58 +00:00
Luming Zh
75a4eca13a Update Chinese (China) translation 2024-09-04 13:21:40 +00:00
Jordi Mas i Hernandez
13f0ab881e Update Catalan translation 2024-09-04 12:40:06 +00:00
Fran Dieguez
d4b45526b2 Update Galician translation 2024-09-04 06:34:09 +00:00
Fran Dieguez
c06e1f4848 Update Galician translation 2024-09-04 06:11:36 +00:00
Matthias Clasen
6a4a52d110 Merge branch 'Enokilis-main-patch-44493' into 'main'
Typo in gtk/gtkcssprovider.c

See merge request GNOME/gtk!7688
2024-09-03 21:07:50 +00:00
Matthias Clasen
ed6f5b8755 Merge branch 'stroke-autoptr' into 'main'
gsk: Add autoptr cleanup function for GskStroke

See merge request GNOME/gtk!7690
2024-09-03 17:15:10 +00:00
Philip Withnall
e87b4dca71 gsk: Add autoptr cleanup function for GskStroke
It appeared to be missing, while other GSK types already have cleanup
functions defined.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-09-03 16:50:10 +01:00
Benjamin Otte
567c8b5ab3 Merge branch 'wip/smcv/debug-gsk-scaling-test' into 'main'
gsk/scaling test: Improve debuggability on failure

See merge request GNOME/gtk!7680
2024-09-03 15:30:32 +00:00
Benjamin Otte
7aeca0512c Merge branch 'wip/smcv/bug6977' into 'main'
scaling test: Fix intermittent failure with alpha = 0

Closes #6977

See merge request GNOME/gtk!7684
2024-09-03 15:27:20 +00:00
Matthias Clasen
5567934fc9 Merge branch 'wip/smcv/misc-realize' into 'main'
testsuite: If gsk_renderer_realize() fails, say why

See merge request GNOME/gtk!7686
2024-09-03 11:11:11 +00:00
Daniel Mustieles
63bece1fe7 Update Spanish translation 2024-09-03 09:25:56 +00:00
Simon McVittie
ad3c285fc6 scaling test: Show the input and expected average after each failed test
Signed-off-by: Simon McVittie <smcv@debian.org>
2024-09-03 10:19:16 +01:00
Simon McVittie
47c461b25b testsuite: Show pixel format of texture pixels that differ
Signed-off-by: Simon McVittie <smcv@debian.org>
2024-09-03 10:05:32 +01:00
Simon McVittie
97f0aa7875 testsuite: Share memorytexture version of compare_textures()
Unlike the version in scaling.c, this one incorporates debugging code
to print the pixels that differ.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-09-03 10:05:32 +01:00
Simon McVittie
8e54460a48 testsuite: Extract common code from gdk/memorytexture and gsk/scaling
Signed-off-by: Simon McVittie <smcv@debian.org>
2024-09-03 10:05:32 +01:00
Simon McVittie
4c4d260199 scaling test: Avoid dividing zero by zero
If all four of the random colours have alpha channel exactly 0.0,
then the computed premultiplied average will also be zero.
Normalize the expected colour to (0,0,0,0) rather than (NaN,NaN,NaN,0).

Resolves: https://gitlab.gnome.org/GNOME/gtk/-/issues/6977
Signed-off-by: Simon McVittie <smcv@debian.org>
2024-09-03 10:03:58 +01:00
Jürgen Benvenuti
b18c6b5781 Update German translation 2024-09-03 05:06:47 +00:00
Enokilis
d76e241558 Fixed typo that prevented theme update in the GTK4 demo. 2024-09-03 02:34:49 +00:00
Simon McVittie
13cbd9fcc7 testsuite: If gsk_renderer_realize() fails, say why
Showing the error message is usually more useful for debugging than
just saying that something failed.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-09-03 02:44:24 +01:00
Matthias Clasen
6e54589d9e Merge branch 'matthiasc/for-main' into 'main'
gtk-demo: Cosmetics

See merge request GNOME/gtk!7678
2024-09-02 22:16:01 +00:00
Fran Dieguez
c781c0ff24 Update Galician translation 2024-09-02 17:23:04 +00:00
Philip Withnall
105ff3a25f gtklistitem: Fix a minor typo in the docs
Ye olde worlde typoe.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-09-02 16:47:47 +01:00
Benjamin Otte
0277e26152 Merge branch 'wip/otte/for-main' into 'main'
gpu: Use right GL context when exporting texture

See merge request GNOME/gtk!7679
2024-09-01 23:08:49 +00:00
Benjamin Otte
563cce5530 gsk: Use gsk_rect_init_offset() everywhere
... and make it use a graphene_point_t as argument, because that's what
the callers want.
2024-09-02 00:22:37 +02:00
Benjamin Otte
b0e4be7fda rendernode: Colors should not influence depth decisions
Depth of a rendernode should be determined by the textures used and the
compositing colorstate requirements.
Colors influence the colorstate choice, so they indirectly influence the
depth, but they should not influence the depth directly.

Otherwise a single color in a border being rec2100-pq would make us
switch to 16bit float.

Also remove gdk_color_get_depth(), because it was only used here and
because again: Colors should not influence depth decisions.
2024-09-02 00:22:37 +02:00
Benjamin Otte
e29701a203 gl: Handle GDK_MEMORY_NONE depth
In rare circumstances a rendernode can be MEMORY_NONE and we don't want
to render it as a float texture then.
2024-09-02 00:22:37 +02:00
Benjamin Otte
6a1cd87480 gpu: Use builder for memory texture 2024-09-01 22:49:34 +02:00
Benjamin Otte
3db858b45f window: Remove unused code 2024-09-01 22:49:34 +02:00
Benjamin Otte
49ee69f316 gpu: Use right GL context when exporting texture
We want to use the display's context on the resulting texture,
but we do not want to use it for the stufff we need to do while
exporting - most importantly the GLsync.

Fixes #6976
2024-09-01 22:49:34 +02:00
Aurimas Černius
b43e0a3423 Update Lithuanian translation 2024-09-01 20:16:16 +00:00
Arjan Molenaar
8054099d0e Merge branch 'amolenaar/macos-maximize-and-transparency' into 'main'
macos: Fix maximizing windows

See merge request GNOME/gtk!7650
2024-09-01 19:22:38 +00:00
Matthias Clasen
a8e49cc21f gtk-demo: Cosmetics
Don't print out when the user just canceled the print dialog,
in the fill and stroke demo.
2024-09-01 10:33:27 -04:00
Matthias Clasen
5f1ec18550 Merge branch 'popover-menu-resize' into 'main'
MenuSectionBox: Increase priority of separator sync function

Closes #5166

See merge request GNOME/gtk!6699
2024-09-01 14:04:07 +00:00
Matthias Clasen
6b5c5714e5 Merge branch 'gdksurface-broadway-fix' into 'main'
gdk: Add missed compute_size and request_layout vfunc to GdkBroadwaySurface

Closes #4527

See merge request GNOME/gtk!4277
2024-09-01 13:48:22 +00:00
Maxim Zakharov
9a8e5b07ae gdk: Add missed compute_size and request_layout vfunc to GdkBroadwaySurface 2024-09-01 13:48:22 +00:00
Matthias Clasen
3f4cf65686 Merge branch 'fix_model_button_states' into 'main'
a11y: Set expanded states properly when switching to a submenu

See merge request GNOME/gtk!7305
2024-09-01 11:59:47 +00:00
Lukáš Tyrychtr
345eca1efe a11y: Set expanded states properly when switching to a submenu 2024-09-01 11:59:47 +00:00
Matthias Clasen
166afbf8e8 Merge branch 'ebassi/a11y-event-listeners' into 'main'
a11y: Add missing value free function

See merge request GNOME/gtk!7677
2024-09-01 11:20:56 +00:00
Matthias Clasen
9120d1c834 Merge branch 'proper_focus_during_popover_cascaded_popdown' into 'main'
a11y: Ensure the focus lands on the correct element during cascaded popover popdown

See merge request GNOME/gtk!7318
2024-08-31 23:09:04 +00:00
Matthias Clasen
083f9e7723 Merge branch 'numeric-spinbutton-no-emoji' into 'main'
spinbutton: No emoji for numeric input

See merge request GNOME/gtk!7676
2024-08-31 23:04:56 +00:00
Emmanuele Bassi
a0cfc6c404 a11y: Turn criticals into debugging messages
It seems we can get spurious de-registrations, so let's avoid spamming
the logs, and also avoid crashes from applications whose maintainer
decided to turn all critical warnings into assertions.
2024-08-31 23:41:21 +01:00
Matthias Clasen
edc50c85ef spinbutton: No emoji for numeric input
Continuing from cfc871f031, when a spin button is in numeric mode,
set the no-emoji input hint, since Emoji aren't useful in numeric
input.
2024-08-31 18:23:49 -04:00
Matthias Clasen
4794bc3db6 Remove duplicate semicolon 2024-08-31 22:16:25 +00:00
Lukáš Tyrychtr
2299c02639 a11y: Ensure the focus lands on the correct element during cascaded popover popdown
Previously it ended on the immediate parent of the lowest level popover,
which was not good, as it very likely was some even already hidden widget, or
at least, the a11y machinery thought so.
2024-08-31 22:16:25 +00:00
Emmanuele Bassi
ae13a82a9a a11y: Add missing value free function
We allocate the reference counter, so we need to free it.
2024-08-31 22:40:16 +01:00
Matthias Clasen
6c88713f82 Merge branch 'emoji-multi-click' into 'main'
emojichooser: Avoid extra work

Closes #6336

See merge request GNOME/gtk!7675
2024-08-31 21:34:29 +00:00
Matthias Clasen
5c6fedae17 emojichooser: Avoid extra work
When selecting an emoji in the recent section, there is no need
to add it to the recent section again. This avoids a sequence of
unfortunate events, where we reconstruct the entire recent section,
thereby removing the focus child, causing the focus to revert to
the entry, causing the entry to select the entire text. In the
case of Ctrl-clicking to select multiple Emoji, the effect is that
the section Emoji will replace the entire entry text, which is
suprising and unintended.

Fixes: #6336
2024-08-31 16:28:20 -04:00
Hugo Carvalho
5faa1c3d6e Update Portuguese translation 2024-08-31 20:14:46 +00:00
Matthias Clasen
074bcd33be Merge branch 'x11-input-setup-mess' into 'main'
x11: Cosmetics

Closes #6840

See merge request GNOME/gtk!7674
2024-08-31 16:57:55 +00:00
Matthias Clasen
5b6b42b5a9 x11: Fix initialization mess
When prepare_gl fails in the right way (or the wrong way?), we
end up creating the leader window twice, and as a side effect,
creating two instances of the "Virtual core pointer" device, which
is bad news for grabs.

Fixes: #6840
2024-08-31 11:28:52 -04:00
Matthias Clasen
ae8a06cdca x11: Cosmetics
Don't return FALSE from a function returning a pointer.
2024-08-31 11:28:52 -04:00
Carlos Garnacho
cba4ce03e5 gtkwidget: Check for destroyed controllers while propagating state
Keep a hard copy of the widget event controllers to handle state
changes across, and check for controllers that might have been detached.
This makes us:

- Tiptoe over controllers that might have been removed directly or
  indirectly as a result of a signal emitted here, which is great and
  fixes possible crashes.
- Ignore new controllers that might have been added in the handling
  of these signals, which is fair enough since these controllers did
  not handle any input related to the state change.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/6924
2024-08-31 16:37:58 +02:00
Carlos Garnacho
5e82ad3ea7 gtkeventcontroller: Reset controller when detaching from a widget
We want internal state ensured to be forgotten, and the controller
to be ready for use for any future time it might be added to a
widget again.
2024-08-31 16:37:35 +02:00
Piotr Drąg
c9bbf5820b Update Polish translation 2024-08-31 15:00:38 +02:00
Simon McVittie
bb0b764172 Merge branch 'wip/smcv/bug6971' into 'main'
testsuite: Add a suite for tests that require /dev/udmabuf

See merge request GNOME/gtk!7671
2024-08-31 11:53:32 +00:00
Matthias Clasen
ae8e9ef650 Merge branch 'vulkan-dnd-offset' into 'main'
vulkan: Use wl_surface_offset

Closes #6972

See merge request GNOME/gtk!7673
2024-08-31 11:47:53 +00:00
Matthias Clasen
8df7ff75bb Merge branch 'radio_role_for_check_button_groups' into 'main'
a11y: Set the correct role for check button groups

See merge request GNOME/gtk!6551
2024-08-31 11:20:16 +00:00
Matthias Clasen
bbfd8e0e89 vulkan: Use wl_surface_offset
Call wl_surface_offset in end_frame to apply the offset for drag
surfaces. This matches what the GL draw context already does, and
it fixes drag surfaces jumping at the beginning of the drag.

Fixes: #6972
2024-08-31 07:15:08 -04:00
Matthias Clasen
467212877f Merge branch 'wip/smcv/css-endian' into 'main'
CSS: Fix test failures on 64-bit big-endian machines

See merge request GNOME/gtk!7672
2024-08-31 11:04:45 +00:00
Simon McVittie
204b8857a1 testsuite: Add a suite for tests that require /dev/udmabuf
On GTK's official upstream CI, all Linux runners are meant to have
/dev/udmabuf available, so this should pass. On developer machines or
downstream build environments, this can't be guaranteed (not all kernel
configurations offer that device, and on those that do, an autobuilder
might not have access to it) so make it possible to skip this with
`--no-suite=needs-udmabuf`.

Any future tests that rely on /dev/udmabuf (as opposed to using it for
optional better coverage if available, like replay-node does) can be
aded to the same suite.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-08-31 10:22:49 +01:00
Simon McVittie
a524524ffd gtkcssprovider: Fix sorting of custom property IDs on 64-bit big-endian
This function is used to sort a GPtrArray of "pointers" which are
actually GINT_TO_POINTER (id), so a and b are pointers to pointer-sized
quantities.

Previously it was assuming that both were int-sized quantities,
dereferencing them to get the first sizeof(int) bytes, and then
redundantly casting those bytes to int. However, on a 64-bit big-endian
platform, the first few bytes of a larger-than-int quantity are the
most significant part, in practice 0, causing an out-of-bounds array
access and a crash. This was visible in the
`gtk:css / parser variables.css` automated test.

Bug-Debian: https://bugs.debian.org/1079546
Signed-off-by: Simon McVittie <smcv@debian.org>
2024-08-31 02:26:57 +01:00
Simon McVittie
3ef1f448a3 gtkcssvariableset: Fix listing IDs on big-endian machines
Previously this code assumed that if we have an int stored in a hash
table via GINT_TO_POINTER, we can retrieve the pointer value and treat
its first sizeof(int) bytes as an item to append to a GArray of int.

However, on a 64-bit big-endian system, the first sizeof(int)
bytes of the pointer will be zero, which is not a valid ID for a
GtkCssCustomPropertyPool, causing an out-of-bounds array access and
a crash. This was visible in the `gtk:css / style` automated test.

Bug-Debian: https://bugs.debian.org/1079546
Signed-off-by: Simon McVittie <smcv@debian.org>
2024-08-31 02:04:00 +01:00
Matthias Clasen
a5df8f2f35 Merge branch 'dead-hamza-yay' into 'main'
Update a script slightly

Closes #6968

See merge request GNOME/gtk!7670
2024-08-31 00:14:25 +00:00
Emmanuele Bassi
b56a8c7f88 Merge branch 'wip/fina/accessible-atspi-fix-error-message' into 'main'
a11y: Consistently use list type for errormessage relation

See merge request GNOME/gtk!7528
2024-08-31 00:08:52 +00:00
Fina Wilke
649782b547 a11y: Consistently use list type for errormessage relation
This more closely matches the spec. This is an API break, however the
atspi backend already assumed that this was a list, and would throw
criticals whenever this relation was set. Therefore it can be assumed
that this relation was not previously in active use.
2024-08-30 20:22:59 +00:00
Matthias Clasen
97245e9baa Merge branch 'ebassi/lazier-a11y' into 'main'
a11y: Watch EventListenerRegistered/Deregistered signals

See merge request GNOME/gtk!7298
2024-08-30 20:17:17 +00:00
Matthias Clasen
0f3c27c8a5 composetable: Handle dead_hamza
A new dead key has been invented.

Fixes: #6968
2024-08-30 16:10:20 -04:00
Matthias Clasen
3273637179 Update keyname tables 2024-08-30 16:03:40 -04:00
Matthias Clasen
1eaa0e9b74 gdkkeysyms.h: Regenerate for libX11 1.8.10 2024-08-30 15:52:58 -04:00
Matthias Clasen
28d1bce2d4 Update a script slightly
Make gdkkeysyms-update.pl use #pragma once, as our headers
do nowadays.
2024-08-30 15:52:14 -04:00
Emmanuele Bassi
b8072d8562 a11y: Add a check for sandboxed accessibility bus
When sandboxed, the accessibility bus needs a recent version of Flatpak
and its D-Bus proxy in order to relay event registrations.
2024-08-30 14:24:55 +01:00
Luca Bacci
da9886d822 Merge branch 'fix-gdk-win32-display-name' into 'main'
GDK/Win32: Fix gdk_display_get_name()

See merge request GNOME/gtk!7664
2024-08-30 12:32:16 +00:00
Matthias Clasen
747f2e5af6 Merge branch 'demos-window-icons' into 'main'
demos: Set icon for the windows

See merge request GNOME/gtk!7661
2024-08-30 11:14:18 +00:00
Matthias Clasen
aeb3ee0969 Merge branch 'update-on-print-comboentry-change' into 'main'
printeroptionwidget: Update on combo-entry change

Closes #6782

See merge request GNOME/gtk!7532
2024-08-30 11:11:55 +00:00
Benjamin Otte
e248f1a4b5 Merge branch 'wip/otte/compare-render' into 'main'
Bring compare-render into 21st century

See merge request GNOME/gtk!7648
2024-08-30 11:00:36 +00:00
Arjan Molenaar
d23833285e macos: Set transparent background for toplevel window
Toplevel window background is almost transparent.
For fully transparent windows the (macOS) shadow calculatation
becomes really slow.
2024-08-30 12:06:18 +02:00
Daniel Rusek
ff9fe6857f Update Czech translation 2024-08-30 09:49:04 +00:00
Emmanuele Bassi
58f2d3fbe7 a11y: Add reference counting to event listeners
Event listeners can register themselves multiple times, and deregister
themselves as well. We need to remove an event listener only if it
dropped all its events.
2024-08-30 09:27:39 +01:00
Emmanuele Bassi
d9f75581be a11y: Get event listeners on root registration
We ask the AT-SPI registry for event listeners already registered when
connecting the root object, in case an AT is running.
2024-08-30 09:27:39 +01:00
Emmanuele Bassi
307efe2172 a11y: Do not emit event signals if there are no listeners
Now that we track event listeners, we can skip the accessibility event
emission altogether if we know nothing is on the other side.
2024-08-30 09:27:39 +01:00
Emmanuele Bassi
4ea4dc9176 a11y: Watch EventListenerRegistered/Deregistered signals
Assistive technologies using AT-SPI typically register themselves on the
accessibility bus through the org.a11y.atspi.Registry.RegisterEvent
method, which will emit the EventListenerRegistered signal. We can use
that signal (and its corresponding EventListenerDeregistered sibling) to
know whether there is at least an AT on the other side of the
accessibility bus.
2024-08-30 09:27:39 +01:00
Benjamin Otte
fa25015e8c compare-render: Appease clang and MSVC
clang wants consts not initialized from consts.

MSVC can't deal with arrays in initializers.
2024-08-30 06:28:58 +02:00
Benjamin Otte
296b6b1ed5 compare-render: Make the test runner generic
Instead of manually running each of the tests, use a loop and just
invoke the test runner.
2024-08-30 06:28:58 +02:00
Benjamin Otte
b88fe301be compare-render: Run clip tests using new runner
This requires adding infrastructure to generate per-test data, so that
the random clip rect can be computed and reused for both test and
reference generation.

So add this infrastructure.
2024-08-30 06:28:58 +02:00
Benjamin Otte
ffd836e6f4 compare-render: Run replay tests using new runner 2024-08-30 06:28:58 +02:00
Benjamin Otte
457cf66d0d compare-render: Run mask tests using new runner 2024-08-30 06:28:58 +02:00
Benjamin Otte
36765745a1 compare-render: Run rotate tests using new runner 2024-08-30 06:28:58 +02:00
Benjamin Otte
46c19a3d28 compare-render: Run repeat tests using new runner 2024-08-30 06:28:58 +02:00
Benjamin Otte
6cf928eb6c compare-render: Run flip tests using new runner 2024-08-30 06:28:58 +02:00
Benjamin Otte
a0d076f01a compare-render: Run plain tests using new runner
Extend the runner so NULL is accepted as a method to create
reference/test, in which case the unmodified original will be used.
2024-08-30 06:28:58 +02:00
Benjamin Otte
37c744759c compare-render: Add a generic test runner
... and port the colorflip test.

This is so we can factor out generic parts of the code. This allows
making changes easier to those parts, like if we want to introduce
rules for what colorstates and memory depths to do diffs in.
2024-08-30 06:28:58 +02:00
Benjamin Otte
277a05eb8c compare-render: Use consistent naming for files
Instead of the adverb, use the verb term. That matches the argument
passed on the cmdline, so only one string is necessary.
2024-08-30 06:28:58 +02:00
Chun-wei Fan
0376e4668c GDK/Win32: Fix gdk_display_get_name()
We switched to using the Unicode (UTF-16) versions of the Windows API by
default, so we also obtain the display name in UTF-16 form as well.

This updates the implementation in the Windows backend so that we
properly acquire the names that we need in UTF-16, and then convert the
results to UTF-8, which is what we use in GTK/GLib.
2024-08-30 08:47:01 +08:00
Changwoo Ryu
9d5652de64 Update Korean translation 2024-08-29 23:29:49 +00:00
Matthias Clasen
bb109b5d9e Merge branch 'matthiasc/for-main' into 'main'
docs: Mention that Broadway is an experiment

See merge request GNOME/gtk!7665
2024-08-29 22:52:39 +00:00
Benjamin Otte
d630ddd182 compare-render: Pick colorstate from reference when comparing
When comparing textures, always pick the colorstate from the reference
texture. This allows us to define what color state we expect.

For now, there's no check that the color states are equal, because they
don't really have to be as long as the pixels are.
2024-08-29 20:34:23 +02:00
Benjamin Otte
e268041a42 reftest-compare: Respect color states when diffing
Always pick the color state from texture1 and download the data and
generate the diff in that color state.

That now means the order of the 2 arguments matters.
2024-08-29 20:34:23 +02:00
Benjamin Otte
f9cbeeeedc reftest-compare: Compare high depth images in high depth
I first tried porting everything to float, but it turns out that that
makes a compare-render run (with all 1520 tests succeeding) 9s slower
so I decided to keep the existing U8 code.

A side benefit is that saving the diff to PNG will continue creating
U8 PNGs.
2024-08-29 20:34:23 +02:00
Benjamin Otte
62542f836f compare-render: Create rotated reference without gdk-pixbuf
We use the renderer to create the reference for the rotate test by
applying the same rotate transform to the reference image instead of the
tested node.

This is somewhat suboptimal because they run very similar codepaths, but
this method works with high bit depth content and different colorstates

This concludes the port away from gdk-pixbuf and means that all rendered
content and reference images can now use high bit depth and colorstates.
2024-08-29 20:34:23 +02:00
Benjamin Otte
6d4c74fdce compare-render: Create masked reference without gdk-pixbuf
We use the renderer to create the reference for the mask test by
rendering the reference clipped.
2024-08-29 20:34:23 +02:00
Benjamin Otte
3dac4a01c6 compare-render: Create colorflipped reference without gdk-pixbuf
We use the renderer to create the reference for the colorflip test by
applying the same colorflip matrix to the reference image instead of the
tested node.

This is somewhat suboptimal because they run very similar codepaths, but
this method works with high bit depth content and different colorstates
2024-08-29 20:34:23 +02:00
Benjamin Otte
f598ec00f5 compare-render: Create clipped reference without gdk-pixbuf
We use the renderer to create the reference for the clip test by
applying the same clip node to the reference image instead of the
tested node.

This is somewhat suboptimal because they run very similar codepaths, but
this method works with high bit depth content and different colorstates
2024-08-29 20:34:23 +02:00
Benjamin Otte
6fc18f4b37 compare-render: Create flipped reference without gdk-pixbuf
We use the renderer to create the reference for the flip test by
applying the same transform node to the reference image instead of the
tested node.

This is somewhat suboptimal because they run very similar codepaths, but
this method works with high bit depth content and different colorstates
and the gdk-pixbuf method does not.
2024-08-29 20:34:23 +02:00
Benjamin Otte
8c9f16fa7a compare-render: Create repeated reference without gdk-pixbuf
We use the renderer to create the reference for the repeat test by
applying the same repeat node to the reference image instead of the
tested node.

This is somewhat suboptimal because they run very similar codepaths, but
this method works with high bit depth content and different colorstates
and the gdk-pixbuf method does not.
2024-08-29 20:34:23 +02:00
Benjamin Otte
001ca0a982 compare-render: Split test variant name from extension name
This is preparation for further patches where we want to use a common
codepath for all variants.
2024-08-29 20:34:23 +02:00
Benjamin Otte
b23c0248ba compare-render: Don't load reference file twice
Instead, convert from texture to pixbuf.

Ultimately, we want to avoid pixbufs entirely, but we're not there yet.
2024-08-29 20:34:23 +02:00
Benjamin Otte
c4c352facc compare-render: Use TAP for the test 2024-08-29 20:34:23 +02:00
Benjamin Otte
30af6d1159 compare-render: Turn into a real test
Use g_test_run() like any other test.
2024-08-29 20:34:23 +02:00
Benjamin Otte
1fac3fe44e compare-render: Compare to reference texture
There's no need to render the original node and compare to its result,
we know that that is equal to the reference image.

Avoids duplicate renderings.
2024-08-29 20:34:23 +02:00
Benjamin Otte
8ac6c08f00 compare-render: Create the reference texture at startup
This allows exiting early when it doesn't exist.
2024-08-29 20:34:23 +02:00
Benjamin Otte
5b62f29b5e compare-render: Rename variables
They conflict with the next commit otherwise.
2024-08-29 20:34:23 +02:00
Benjamin Otte
817cfb09f8 compare-render: Failing to load an image is a failure 2024-08-29 20:34:23 +02:00
Benjamin Otte
8da478ab34 testsuite: Disable a bunch of tests on the GL renderer
We want to generate reference images with the renderers and the GL
renderer can't deal with textures well enough to generate these
reference images.
2024-08-29 20:34:20 +02:00
Matthias Clasen
8d866c5980 docs: Mention that Broadway is an experiment 2024-08-29 07:35:17 -04:00
Jordi Mas
467e622778 Update Catalan translation 2024-08-29 07:13:12 +02:00
Benjamin Otte
aa81df921b testsuite: Correct values for red
The value used was for rec2020 (9/14/0/1), not rec2100-pq (9/16/0/1).
2024-08-29 03:01:30 +02:00
Benjamin Otte
328020b241 Merge branch 'wip/otte/for-main' into 'main'
gl: Fix initial EGL context creation on X11

Closes #6964

See merge request GNOME/gtk!7663
2024-08-29 00:36:19 +00:00
Benjamin Otte
41cd0c6f13 gl: Fix initial EGL context creation on X11
After commit 447bc18c48 EGL on X11 broke.

But the handling of the GL context also was quite awkward because it was
unclear who was responsible for ensuring it got reset.

Change that by making gdk_gl_context_clear_current_if_surface() return
the context (with a reference because it might be the last reference) it
had unset, so that after changing EGL properties the code that caused
the clearing can re-make it current.

This moves the responsibility to the actual code that is dealing with
updating properties and frees the outer layers of code from that task.

And that means the X11 EGL code doesn't need to care and the code in the
Wayland backend that did care can be removed.

Related: !7662
Fixes: #6964 on X11
2024-08-29 01:31:47 +02:00
Benjamin Otte
db02abe54e Merge branch 'wip/otte/to-make-current-or-not-make-current' into 'main'
wayland: Rework how we handle EGLWindows

Closes #6964

See merge request GNOME/gtk!7662
2024-08-28 18:14:03 +00:00
Benjamin Otte
447bc18c48 wayland: Rework how we handle EGLWindows
This essentially reverts the changes from
c230546a2c but implies new semantics.

Namely, surface-attached contexts can now be bound to EGL_NO_SURFACE if
the windowing system isn't ready yet.

It is the task of the windowing system to make sure the context is
properly rebound when the contents become available.
We ensure this by checking in begin_frame() if we created the EGL window
and if we did, we make_current(). This works because creating the EGL
window creates the EGL surface and that does a clear_current(), so this
is always going to have the desired effect of re-making the current
context.

It is very convoluted though.

Fixes: #6964
Related: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11784
2024-08-28 19:09:45 +02:00
Balló György
283c66251b demos: Set icon for the windows 2024-08-28 17:02:44 +02:00
Luca Bacci
63b68d2f5e Merge branch 'gdk-win32-incremental-rendering-fixes' into 'main'
GdkWin32: Incremental rendering fixes

See merge request GNOME/gtk!7655
2024-08-28 09:30:29 +00:00
Marek Kašík
7e09a5648a Merge branch gtk:main into update-on-print-comboentry-change 2024-08-28 09:12:42 +00:00
Lukáš Tyrychtr
4a0b833548 Apply some review feedback
Namely be sure to set the new role of the widget in all cases
and do it always, even when we need to recreate the AT context.
2024-08-28 10:42:17 +02:00
Lukáš Tyrychtr
86bec01640 a11y: Set the correct role for check button groups
Up-until now, when a group of check boxes was created, they were
still presented as checkboxes, even they semantically were radio buttons.

Note that this approach will not always work, because we're not recreating the
AT context, but it works for the usual pattern where the group is set during
object construction
2024-08-28 10:27:46 +02:00
Matthias Clasen
b07a2a968d Merge branch 'wayland-destroy-ordering' into 'main'
wayland: Fix an ordering problem

Closes #6965

See merge request GNOME/gtk!7658
2024-08-28 01:14:45 +00:00
Benjamin Otte
997d553520 Merge branch 'wip/corey/file-chooser-select' into 'main'
Implement set_selection in GtkSingleSelection

See merge request GNOME/gtk!6376
2024-08-28 00:24:51 +00:00
Corey Berla
8eb05850cb single-selection: Don't allow unselecting with autoselect
According to the documentation, when autoselect is TRUE it will
"will disallow unselecting the current item".
2024-08-27 21:18:56 +00:00
Corey Berla
98eaec99ee gtksingleselection: Implement unselect_all
The default implementation of unselect_all calls
set_selection, which SingleSelection does not have
an implementation for (it's unclear what it would
do with multiple selections).  Add a straightforward
implementation for unselect_all.
2024-08-27 21:18:56 +00:00
Matthias Clasen
8fb946f6e8 Merge branch 'scale-hotfix' into 'main'
theme: Fix positioning of scale values (hotfix!)

See merge request GNOME/gtk!7656
2024-08-27 21:07:40 +00:00
Matthias Clasen
a10670c991 wayland: Fix an ordering problem
When setting an event queue on a proxy, we should not destroy
the queue before the proxy.

May fix: #6965
2024-08-27 16:35:46 -04:00
Matthijs Velsink
2e2dab9c3d theme: Fix scale sizing during .fine-tune
Using fine-tune on a GtkScale is maybe a little known feature, but it's
also quite wonky. It causes marks, values, and sliders to jump around
when activated. This is because it's implemented with less padding
around the scale and an increased minimum size.

For example a value drawn left or right of a horizontal scale, as then
the height of the scale is the value height plus padding. So fine-tuning
compresses the scale vertically.

We can fix this by adding negative margin on the trough instead, without
any changes to the padding or minimum size of the scale.

Also, because the trough now grows 3px in all directions, the slider has
to do that to, so that margin increases by 3px in all directions
compared to what it was, also for the cases with marks.

One last minor detail is that for vertical scales, fine-tuning causes
the height of the mark indicators to grow, whereas their width should
decrease. That's also fixed.
2024-08-27 22:35:02 +02:00
Matthijs Velsink
a6eea6ba3c theme: Fix positioning of scale values
Commit d58b545f fixed a double counting of value size, but didn't check
whether that actually looked great. It doesn't.

Because the slider has negative margins, we need to add margin to the
value if it's on a side with no marks. If it is on a side with marks,
the scale will make it touch the marks. We therefore apply a mark's size
of margin to have the value be in the same place, with or without marks.
2024-08-27 22:33:54 +02:00
Danial Behzadi
48f347e62b Update Persian translation 2024-08-27 10:34:00 +00:00
Matthijs Velsink
ed1c047cf2 theme: Fix positioning of scale values
Commit d58b545f fixed a double counting of value size, but didn't check
whether that actually looked great. It doesn't.

Because the slider has negative margins, we need to add margin to the
value if it's on a side with no marks. If it is on a side with marks,
the scale will make it touch the marks. We therefore apply a mark's size
of margin to have the value be in the same place, with or without marks.
2024-08-27 04:47:49 +02:00
Matthias Clasen
ea9c2a72d9 Post-release version bump 2024-08-26 19:55:03 -04:00
Matthias Clasen
15edfe4ffa 4.15.6 2024-08-26 19:26:14 -04:00
Benjamin Otte
c2698e2be9 Merge branch 'wip/otte/for-main' into 'main'
gpu: Fix memleak in GL dmabuf export

See merge request GNOME/gtk!7652
2024-08-26 21:08:48 +00:00
Benjamin Otte
0defdc4af5 gpu: Plug fd leak in fallback path
If we can't construct a dmabuf texture, we need to clear the dmabuf fd.
2024-08-26 20:31:08 +02:00
Benjamin Otte
ea9b47f1b6 gpu: Use common cleanup function
Just simple cleanup, both functions do the same thing.
2024-08-26 20:31:08 +02:00
Benjamin Otte
65c8320a32 gpu: Fix fd leak in GL dmabuf export
The texture ID is not deleted on dmabuf export; a copy is made, the
GskGpuImage retains ownership.

However when doing GL export, the texture *does* take ownership, so we
need the stealing semantics for that case.
2024-08-26 20:31:08 +02:00
Matthias Clasen
a7afde2e7d Merge branch 'scale-fixes-2' into 'main'
scale: Fix two more drawing/sizing issues

Closes #5171 and #6639

See merge request GNOME/gtk!7654
2024-08-26 18:04:27 +00:00
Matthias Clasen
a876a829e4 Merge branch 'scale-fixes' into 'main'
scale: (Re)fix value alignment again (reverting !6935)

Closes #5171 and #6639

See merge request GNOME/gtk!7651
2024-08-26 18:00:20 +00:00
Luca Bacci
f4bd883003 GdkWin32: Try to call _gdk_surface_update_size() only when the size actually changed
Otherwise we adapt Vulkan and OpenGL swap chains a lot and we effectively
disable incremental rendering.

Note that the fix is not complete.
2024-08-26 17:05:19 +02:00
Luca Bacci
0fcdadc531 GdkWin32GLContextWGL: Use the previous frames paint regions kept by GdkGLContext
We do this because:

 a) The parent class (GdkGLContext) already stores the paint regions of
    previous frames, no need to do the same.
 b) The painted region passed to end_frame () includes the backbuffer's
    damage region, so it's not really what we want.

This also fixes a leak of cairo_region_t that I introduced by mistake
in !7418
2024-08-26 17:05:13 +02:00
Matthijs Velsink
d58b545ffb scale: Don't apply borders twice for value
The measured size of the range already includes borders that the scale
calculates. This includes the drawn value. So in the measurement of
scale, the size of the value shouldn't just be added to the size of the
scale, as then the size is effectively added twice.

To fix this, we first measure the minimum size of the range. Then, we
determine the minimum size of our scale. Only then do we set the minimum
size to maximum of those two values.
2024-08-26 13:20:21 +02:00
Matthijs Velsink
8ca299e82b scale: Fix GTK_POS_TOP marks and value order
If both marks are set on top, and the value is drawn on top, the value
should be drawn outside the marks for a horizontal scale.

Currently, that order is incorrect, with the marks shifted up and the
value drawn between the slider and the marks.

This fixes that order.
2024-08-26 13:04:23 +02:00
Scrambled 777
a231a2114a Update Hindi translation 2024-08-26 06:03:28 +00:00
Matthias Clasen
ab41a549f8 Merge branch 'app_menubar_a11y_label' into 'main'
applicationwindow: set menubar a11y label

See merge request GNOME/gtk!7640
2024-08-25 23:45:23 +00:00
Matthijs Velsink
a9997a3af6 scale: Always align value with the trough
We can get the position of the trough from the parent GtkRange class,
and can therefore align directly to that. There is no need to add
symmetry, which can always be added in CSS if needed.

Fixes #5171, #6639
2024-08-25 19:41:25 +02:00
Matthijs Velsink
6d86b16dbe scale: Refactor value allocation logic slightly
This only makes the value allocation logic easier to understand, but
doesn't change anything, apart from not mixing integer and floating
operations anymore which can give a warning under some compiler
settings.
2024-08-25 19:37:38 +02:00
Matthijs Velsink
779d32747d Revert "Merge branch 'scalefix' into 'main'"
This reverts commit 2799632c02, reversing
changes made to 154035e76f.

That MR tried to fix #5171, but by doing a forced symmetry it introduced
another issue for users on Libadwaita, see #6639.

The logic can be much simplified, as the next commits show.
2024-08-25 19:23:54 +02:00
Arjan Molenaar
ffeca06bd6 macos: Revert "macos: fix window transparency"
This reverts commit 84847e46fa.

It breaks maximizing windows.
2024-08-25 12:00:51 +02:00
Asier Sarasua Garmendia
83b387e782 Update Basque translation 2024-08-25 06:01:05 +00:00
Benjamin Otte
b41fe2e093 Merge branch 'wip/otte/slow-down' into 'main'
CI: Reduce max number of tests to 8/4

See merge request GNOME/gtk!7649
2024-08-25 03:50:54 +00:00
Benjamin Otte
93573218d4 CI: Reduce max number of tests to 8/4
CI is hitting various limits after we started out with 32. In
particular, the default runners hit 90s test timeouts.

And the asan runner runs into max threads limits, so reduce that one to
4 tests max.
2024-08-25 04:57:11 +02:00
Matthias Clasen
076968dc1e Merge branch 'ci-do-less-work' into 'main'
compare-render: Do less work for replay

See merge request GNOME/gtk!7647
2024-08-25 01:39:52 +00:00
Matthias Clasen
5e6cf622e3 compare-render: Do less work for replay
We don't need to render the node, we have a reference image.
2024-08-24 20:11:32 -04:00
Matthias Clasen
90c65e3611 Merge branch 'wip/otte/ci-fixes' into 'main'
CI improvements

See merge request GNOME/gtk!7639
2024-08-24 20:25:30 +00:00
Matthias Clasen
afe75aedc2 Merge branch 'dmabufize-experiment' into 'main'
tests: Use dmabufs in compare tests

See merge request GNOME/gtk!7642
2024-08-24 20:25:17 +00:00
Matthias Clasen
8b215a453c Merge branch 'settings_parse_enums' into 'main'
settings: allow parsing enums nicknames from settings.ini

See merge request GNOME/gtk!7641
2024-08-24 17:59:08 +00:00
Matthias Clasen
c3329123a3 Merge branch 'matthiasc/for-main' into 'main'
Add a since tag to GDK_TOPLEVEL_STATE_SUSPENDED

See merge request GNOME/gtk!7645
2024-08-24 17:33:23 +00:00
Matthias Clasen
107ef2017c tests: Use dmabufs in compare tests
Make the --replay mode of compare-render randomly turn textures it
finds into dmabuf textures, using /dev/udmabuf.
2024-08-24 13:10:25 -04:00
Matthias Clasen
acad180cee Add dmabuf tests that can run in ci
This is a test balloon tests that use /dev/udmabuf to produce
dmabufs that we can use in ci, even if we don't have a GPU.
Currently, the tests we can do are somewhat limited, since mesas
software renderers don't support dmabufs yet.
2024-08-24 13:10:25 -04:00
Benjamin Otte
504ca9c0c8 CI: run tests in a single dbus session
Instead of every test spawning their own dbus, make the tests share the
same server, just like they share their own compositor.

This should speed up things a bit and avoid weird interactions when
multiple dbus processes exist.
2024-08-24 18:36:23 +02:00
Benjamin Otte
2d9f28c0ff CI: Make asan a child of the default fedora build
Effects of that:

1. Keep artifacts
2. Produce a test report
3. Caching for ccache
2024-08-24 18:36:23 +02:00
Benjamin Otte
07b3e8785c CI: Limit maximum number of test processes to 32
There are spurious failures happening in CI runs and I blame those on
too many processes running at the same time overloading either the
compositor we're running against, or causing OOM situations or just
genereally slowing things down and hitting timeout limits.

The choice of 32 is rather arbitrary. I just picked a number that felt
good.
2024-08-24 18:36:23 +02:00
Benjamin Otte
68ef86ac4f wayland: Don't ask dbus about settings we don't care about
When running with default settings, we don't care what dbus thinks about
non-default settings.
2024-08-24 18:36:23 +02:00
Piotr Drąg
beb20fb1db Update POTFILES.in and POTFILES.skip 2024-08-24 14:58:15 +02:00
Juliano de Souza Camargo
3a965088a2 Update Brazilian Portuguese translation 2024-08-24 12:55:30 +00:00
Matthias Clasen
89118ee7ba Add a since tag to GDK_TOPLEVEL_STATE_SUSPENDED
We've changed the way we document additions in enums.
2024-08-24 08:38:19 -04:00
Arjan Molenaar
4b5d503cf0 Merge branch 'macos-control-click' into 'main'
macos: Add Ctrl+left-click mapping for context menus

Closes #6724

See merge request GNOME/gtk!7523
2024-08-24 11:42:35 +00:00
Sabri Ünal
aeac103fbc Update Turkish translation 2024-08-24 06:44:18 +00:00
Luming Zh
cd153e8a53 Update Chinese (China) translation 2024-08-24 04:05:37 +00:00
Benjamin Otte
5369b07eb0 Merge branch 'wip/otte/for-main' into 'main'
vulkan: Don't print errors on vkCreateInstance() failure

Closes #6947

See merge request GNOME/gtk!7643
2024-08-23 21:37:12 +00:00
Benjamin Otte
58f7b966d0 reftests: Make glarea-gl-only test XFAIL
With CI now using udmabufs, we run into bugs in Mesa. So we disable
some tests for now.

https://gitlab.freedesktop.org/mesa/mesa/-/issues/11773 is the bug
report for this one.
2024-08-23 22:53:13 +02:00
Benjamin Otte
4be1d754b7 vulkan: Don't spam stderr on failed Vulkan import
We write a debug message and then handle things using fallback.

Fixes error messages when trying to import incompatible dmabufs.
(in my case: llvmpipe dmabufs into radv)
2024-08-23 22:53:13 +02:00
g.willems
c1351fb659 settings: allow parsing enums nicknames from settings.ini
The value of `gtk-font-rendering` currently can't be specified
in "settings.ini", as the parser doesn't handle enums.
Allow reading values by enum nicknames.

Also cleanup obsolete references to rc files.
2024-08-23 21:09:37 +02:00
Benjamin Otte
d8926de40e vulkan: Don't print errors on vkCreateInstance() failure
We handle the error case right below with a proper GError, there's no
need to use the fallback error reporting.

Fixes #6947
2024-08-23 20:04:46 +02:00
Benjamin Otte
73c94cf1d6 gpu: Use the shared GL context when creating GL textures
The non-shared context's surface must survive the lifetime of the
GL texture, and when the renderer gets unrealized the surface goes away,
but we cannot guarantee that all GL textures have been destroyed by
then.

So better use a context we know will survive becuase it isn't bound to a
surface.

This is the same fix for NGL as f3ac0535f8
was for GL.
2024-08-23 20:04:46 +02:00
Benjamin Otte
c2a637f68a inspector: Add KHR version of swap_buffers_with_damage
Related: #6941
2024-08-23 19:01:05 +02:00
Benjamin Otte
6a986f03b6 gpu: Simplify the blur op a bit
I was looking through it and thought this looks better.

It's also 21 lineas of code less.
2024-08-23 19:01:05 +02:00
Ekaterine Papava
a52ae238ab Update Georgian translation 2024-08-23 09:55:42 +00:00
Yuri Chornoivan
8a0d688a61 Update Ukrainian translation 2024-08-23 04:43:09 +00:00
g.willems
3260b8f142 applicationwindow: set menubar a11y label
This fixes a warning from the inspector's accessibility checker.

Users only control the menu model, not the menubar widget,
so this can only be done in gtk.
2024-08-22 22:46:30 +02:00
Jordi Mas i Hernandez
dc8e01d469 Update Catalan translation 2024-08-22 18:46:28 +00:00
Matthias Clasen
0105da3238 Merge branch 'main' into 'main'
textbuffer: Clear paste point override from empty middle clicks

Closes #5530

See merge request GNOME/gtk!6811
2024-08-22 18:11:05 +00:00
Yosef Or Boczko
8979515aa4 Update Hebrew translation 2024-08-22 15:41:53 +00:00
Vasil Pupkin
a8c827455d Update Belarusian translation 2024-08-22 00:25:24 +00:00
Benjamin Otte
798edf5300 Merge branch 'wip/otte/for-leio' into 'main'
Only run a single renderpass

See merge request GNOME/gtk!7594
2024-08-21 20:11:52 +00:00
Benjamin Otte
54758bee1f gpu: Only run a single renderpass
Instead of running one renderpass per clip region, run one renderpass for
the whole clip extents, and just set the scissor to the individual clip
rects.

This means that we need to use LOAD_OP_LOAD in cases where we don't
redraw the full extents, but nonetheless, the eprformance wins of
avoiding renderpasses are worth it, in particualr on tilers like the
Raspberry Pi or other mobile chips and the Apple M1/2.
2024-08-21 21:13:34 +02:00
Benjamin Otte
cfe0da1eed gpu: Add GskGpuLoadOp
We want to differentiate between CLEAR, DONT_CARE and LOAD in the
future, and the current boolean doesn't allow that.

Also implement support for the the different ops in the Vulkan
renderpass code.
2024-08-21 21:13:34 +02:00
Benjamin Otte
1198dc76a4 gpu: Add gsk_gpu_first_node_begin_rendering()
This starts the renderpass at the given scissor rect.

It just splits out the gsk_gpu_render_pass_begin_op() call into a
simpler function, so it's harder to mess up.
2024-08-21 21:13:34 +02:00
Benjamin Otte
bed3e9918b gpu: Add GskGpuFirstNodeInfo
Just encapsulate all the data for the add_first_node() call into a
single struct.
2024-08-21 21:13:34 +02:00
Benjamin Otte
d76bb2991a gpu: Refactoring: Pull out nodeprocessor
Add gsk_gpu_node_processor_set_scissor() that allows resetting the
nodeprocessor's scissor and clip rectangle.
That in turn allows using the same nodeprocessor instance for all the
rects we draw for the clip region.
2024-08-21 21:13:34 +02:00
Benjamin Otte
e962e86fcd gpu: Split out a function
converting an image to any colorstate (not just ccs-capable default
colorstates) can go in its own function.
2024-08-21 21:13:34 +02:00
Benjamin Otte
dd59c90842 rendernode: repeeat nodes with empty child bounds are transparent
So they must not copy the fully_opaque flag from the child.

Adapted the testcase that accidentally caught it do now always catch it
by setting a proper background.
2024-08-21 21:13:26 +02:00
Emmanuele Bassi
c03720879e Merge branch 'fix-text-a11y-more' into 'main'
a11y: More text interface fixes

Closes #6951

See merge request GNOME/gtk!7638
2024-08-21 16:12:55 +00:00
Matthias Clasen
a62787ebb2 a11y: More text interface fixes
The old bytes-vs-chars problem exists in more places.

Fixes: #6951
2024-08-21 11:33:11 -04:00
Matthias Clasen
2a7541342c Merge branch 'migration-docs-fix' into 'main'
docs: Fix various minor typos and improve formatting in the 4-to-5 migration guide

See merge request GNOME/gtk!7637
2024-08-21 15:17:59 +00:00
Philip Withnall
f96d6cdb2b docs: Improve code tagging and API cross-reference links in 4-to-5 guide
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-08-21 15:03:44 +01:00
Philip Withnall
3ea6ddd321 docs: Improve Unicode usage in 4-to-5 migration guide
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-08-21 13:10:29 +01:00
Philip Withnall
17f7d80fcf docs: Fix various minor typos in the 4-to-5 migration guide
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-08-21 13:08:14 +01:00
Scrambled 777
e3437c748a Update Hindi translation 2024-08-21 08:57:29 +00:00
Benjamin Otte
f1d80727d0 Merge branch 'wip/otte/i-see-dead-textures' into 'main'
gpu: Be more aggressive about GC'ing dead textures

See merge request GNOME/gtk!7636
2024-08-21 08:18:53 +00:00
Benjamin Otte
c7fabe2897 gpu: Be more aggressive about GC'ing dead textures
When we encounter many dead textures, we want to GC. Textures can take
up fds (potentially even more than 1) and when we are not collecting
them quickly enough, we may run out of fds.

So GC when more then 50 dead textures exist.

An example for this happening is recent Mesa with llvmpipe udmabuf
support, which takes 2 fds per texture and the test in
testsuite/gdk/memorytexture that creates 800 textures of ~1 pixel each,
which it diligently releases but doesn't GC.

Related: #6917
2024-08-21 09:45:05 +02:00
Chun-wei Fan
cc1c3799b6 Merge branch 'wgl-report-damage' into 'main'
GdkWin32GLContextWGL: Add support for incremental rendering

See merge request GNOME/gtk!7418
2024-08-21 02:37:41 +00:00
Martin
a196bf1132 Update Slovenian translation 2024-08-20 04:54:07 +00:00
Matthias Clasen
4bcfeebdea Merge branch 'emoji-chooser-size' into 'main'
emojichooser: Resize according to screen height

See merge request GNOME/gtk!7631
2024-08-20 02:02:16 +00:00
Matthias Clasen
740965016f Merge branch 'matthiasc/for-main' into 'main'
Add a GDK_DISABLE env var

See merge request GNOME/gtk!7632
2024-08-20 01:58:54 +00:00
Matthias Clasen
39e6301f42 win32: Adapt to default flag changes
I hope this change does the right thing.
2024-08-19 21:37:49 -04:00
Matthias Clasen
fd02c885e9 docs: Remove outdated information
We no longer disable debug flags in non-debug builds.
2024-08-19 20:40:32 -04:00
Matthias Clasen
26a2966a7b gdk: Beef up gdk_parse_debug_var
Add a docstring for the variable itself, and print it as part
of the help message. Update all callers to provide a docstring.
2024-08-19 20:40:32 -04:00
Matthias Clasen
29cfcbdc97 wayland: Respect GDK_DISABLE=color-mgmt
If the color-mgmt feature is disabled, don't use the
xx-color-management-v4 protocol.
2024-08-19 20:40:32 -04:00
Matthias Clasen
de62ea96ab Add GDK_DISABLE=color-mgmt
This flag is meant to turn off color management features of GDK.
If this is set, all surfaces will report sRGB as their preferred
color state.
2024-08-19 20:40:32 -04:00
Matthias Clasen
2d230f79a6 Change the offload-disable flag
Move this from GSK_DEBUG=offload-disable to GDK_DISABLE=offload.
2024-08-19 20:40:32 -04:00
Matthias Clasen
cde094a0df Add a GDK_DISABLE env var
This is taking over the feature-disabling keys from GDK_DEBUG.
2024-08-19 20:40:32 -04:00
Benjamin Otte
2fb3dc8c90 Merge branch 'wip/otte/for-main' into 'main'
wayland: Create EGL window in make_current() if necessary

Closes #6930

See merge request GNOME/gtk!7633
2024-08-19 23:34:35 +00:00
Benjamin Otte
f6a8ba0ccb gpu: The colorstate op doesn't need a colorstates arg
It's using the same colorstate all the time: any premultiplied.

So just hardcode it.
2024-08-20 01:05:20 +02:00
Benjamin Otte
f650f96b69 egl: Don't bind to NULL surface unless surfaceless
We need to ensure that an EGL surface exists before we call
eglMakeCurrent() with it. Otherwise we might end up binding to
EGL_NO_SURFACE and then never revising that decision.
Which leads to not rendering to the backbuffer, but into the void.

Fixes X11 rendering being black

Fixes #6930
2024-08-20 01:05:20 +02:00
Benjamin Otte
c230546a2c wayland: Create EGL window in make_current() if necessary
We make_current() before begin_frame() so doing it only in begin_frame()
is too late.
2024-08-20 01:05:20 +02:00
Benjamin Otte
f3ac0535f8 gl: Use the shared GL context when creating GL textures
the non-shared context's surface must survive the lifetime of the
GL texture, and when the renderer gets unrealized the surface goes away,
but we cannot guarantee that all GL textures have been destroyed by
then.

So better use a context we know will survive becuase it isn't bound to a
surface.
2024-08-20 01:05:20 +02:00
Artur S0
7ce942d3fb Update Russian translation 2024-08-19 14:07:35 +00:00
Mat
56a8e947df emojichooser: Resize according to screen height
Since a4cc95b293, the emoji chooser
can fail to appear on smaller screens, depending on where its parent
widget is located. Stop requesting a fixed height to prevent this
issue.
2024-08-19 08:19:04 +03:00
Chun-wei Fan
f592a303e4 Merge branch 'vulkan-win32-fix-resize' into 'main'
gdksurface-win32.c: Call _gdk_surface_update_size() more (fix resizing on Vulkan on certain drivers)

Closes #6565

See merge request GNOME/gtk!7562
2024-08-19 03:53:29 +00:00
Chun-wei Fan
e14670d457 gdksurface-win32.c: Call _gdk_surface_update_size() more
The current resizing implementation in the GDK-Win32 backend is not
telling GDK early enough for Vulkan that a resize in the surface (i.e.
HWND) is done, so that GDK can re-create swapchain in time, which is
apparent on nVidia drivers (and AMD drivers that utilize the mailbox
presentation mode on Windows) when the HWND is being enlarged
interactively.

To work around this, bar a refactor in the Windows resizing/presentation
code, is to call _gdk_surface_update_size() when we really did resize
the HWND when we handle queued resizes via SetWindowsPos().

The existing call in gdksurface-win32.c in
_gdk_win32_surface_compute_size() remains required, otherwise the
surface won't display initially.

Thanks to Benjamin Otte for pointing this possibility out.
2024-08-19 11:25:50 +08:00
Matthias Clasen
0acf9caa8e Merge branch 'matthiasc/for-main' into 'main'
node-editor: Make Ctrl-Shift-V undoable

See merge request GNOME/gtk!7629
2024-08-19 02:20:52 +00:00
Matthias Clasen
22860389de node-editor: Make Ctrl-Shift-V undoable 2024-08-18 21:45:25 -04:00
Matthias Clasen
16e764b402 wayland: Use interface names defined by protocol
We don't need to hardcode all the interface names as string literals,
since they come as part of the wl_interface structs in the protocol
bindings we use.
2024-08-18 18:23:18 -04:00
Matthias Clasen
85862c4e22 Merge branch 'matthiasc/for-main' into 'main'
Document new inspector functionality

See merge request GNOME/gtk!7628
2024-08-18 21:37:55 +00:00
Matthias Clasen
eb764d43f8 Document new inspector functionality
Mention the new shortcuts for recording.
2024-08-18 17:14:28 -04:00
Matthias Clasen
6b57f596f7 Merge branch 'matthiasc/for-main' into 'main'
inspector: Add event traces

See merge request GNOME/gtk!7627
2024-08-18 21:00:01 +00:00
Matthias Clasen
cefaec5d6f node-editor: Add Ctrl-Shift-V
Make Ctrl-Shift-V trigger a 'paste-as-node' action which replaces
the current content with the render node in the clipboard.
2024-08-18 15:44:40 -04:00
Matthias Clasen
29b6eab0ea inspector: Add some shortcuts
While the inspector is open, look for some shortcuts:

Super-r to toggle recording
Super-c to take a screenshot

A screenshot here means just a single-frame recording.
For convenience, we put the recorded frame onto the
clipboard too.
2024-08-18 15:44:40 -04:00
Matthias Clasen
360674f523 inspector: Add a snapshot function
Add a function that records just a single frame, and puts it
on the clipboard.
2024-08-18 15:44:40 -04:00
Matthias Clasen
7900f91e46 widget: Record event traces
Use the newly introduced inspector api to add event traces.
2024-08-18 15:44:40 -04:00
Matthias Clasen
e4248503cf inspector: Add event traces
When recording events, make it possible to add 'traces' of the
events journey, and show those in the recorder.
2024-08-18 15:44:40 -04:00
Matthias Clasen
168bab34f7 inspector: Simplify
We can just put the render node on the clipboard directly, no
manual serialization required.
2024-08-18 15:44:40 -04:00
Matthias Clasen
46e7ea8c1e Fix a misleading comment 2024-08-18 15:44:40 -04:00
Matthias Clasen
1ce7de0fb8 Cosmetics 2024-08-18 10:44:38 -04:00
Matthias Clasen
d9a0f3cfe2 Merge branch 'matthiasc/for-main' into 'main'
node parser: Move parse_color even earlier

See merge request GNOME/gtk!7625
2024-08-17 23:35:44 +00:00
Matthias Clasen
200cec3321 inspector: Minor GdkRGBA -> GdkColor porting 2024-08-17 18:56:05 -04:00
Matthias Clasen
d4e730db0c node parser: Move parse_color even earlier
It will be used by parse_stops in the future, so move it above.

No functional change.
2024-08-17 16:24:20 -04:00
Benjamin Otte
ca78d845df Merge branch 'wip/otte/for-main' into 'main'
gsk: Don't print any sRGB color as rgb() or rgba()

See merge request GNOME/gtk!7624
2024-08-17 20:19:01 +00:00
Benjamin Otte
9ff31dd29b testsuite: Improve testcase
This should have gone into !7619 but gitlab managed to finish the CI run
just as I was pushing a new version to the MR with
merge_request.merge_when_pipeline_succeeds and apparently gitlab applied
that to the previous version or something.

So now that MR merged an incomplete version to main. And here's the fix
for that.
2024-08-17 21:31:14 +02:00
Benjamin Otte
0815359a20 Merge branch 'wip/otte/for-main' into 'main'
gsk: Don't print any sRGB color as rgb() or rgba()

See merge request GNOME/gtk!7619
2024-08-17 19:28:07 +00:00
Benjamin Otte
96139a902d gsk: Don't print any sRGB color as rgb() or rgba()
If the color value is not inside the proper range for rgb() or rgba()
values being integers, use color() instead.

Tests added/adapted.
2024-08-17 21:09:25 +02:00
Benjamin Otte
a6233ac852 rendernodeparser: Check color values aren't out of range
Use the clamp() API from the previous commit to:

1. Clamp values into range
2. Emit an error if values were out of range

Unlike CSS, which just clamps and doesn't emit an error, we do want to
emit one because we care about colors being correct in our node files.
2024-08-17 18:12:23 +02:00
Matthias Clasen
4e9ebb5299 gdk: Add gdk_color_state_clamp()
Allows clamping values into the correct range to construct valid colors.
2024-08-17 18:12:23 +02:00
Benjamin Otte
585f31fa2e rendernodeparser: Rename function
There's no need to name a function parse_color2() when parse_color()
doesn't exist.
2024-08-17 16:03:46 +02:00
Benjamin Otte
69e7838461 rendernodeparser: Don't have unnecessary forward declarations
Reorders functions to not have them.

No functional changes.
2024-08-17 16:03:46 +02:00
Matthias Clasen
3fe3800b7c Merge branch 'small-scale' into 'main'
monitor: Don't forbid scales < 1

Closes #6928

See merge request GNOME/gtk!7623
2024-08-17 13:22:15 +00:00
Matthias Clasen
491275b444 Merge branch 'radiobutton-focus' into 'main'
checkbutton: Add a 'grouped' style class

Closes #6936

See merge request GNOME/gtk!7622
2024-08-17 12:44:35 +00:00
Matthias Clasen
1cd107d5ab monitor: Don't forbid scales < 1
With fractional scaling, people try out things like 0.75 scaling,
and there's no reason for us to prohibit that from working.

Fixes: #6928
2024-08-17 08:26:55 -04:00
Matthias Clasen
5af2d95bff checkbutton: Add a 'grouped' style class
This will make it easier for themes to style radio buttons
differently from check buttons, since out CSS does not have
:has().

The concrete desire here is to use a different outline for
the focus rectangle.

Update affected tests.

Fixes: #6936
2024-08-17 08:22:54 -04:00
Benjamin Otte
62f5db06a1 Merge branch 'fix-opaque-surface-crash' into 'main'
Avoid a crash in gdk_surface_is_opaque

Closes #6938

See merge request GNOME/gtk!7621
2024-08-17 11:26:27 +00:00
Matthias Clasen
e32a12f877 Avoid a crash in gdk_surface_is_opaque
Nothing in gtk calls gdk_surface_set_opaque_region anymore, so
the opaque region will normally be NULL.

Fixes: #6938
2024-08-17 07:03:57 -04:00
Ekaterine Papava
584733f034 Update Georgian translation 2024-08-17 03:49:13 +00:00
Matthias Clasen
c3c1819e12 Merge branch 'css-variables-fixes2' into 'main'
css: Set the parent of the variable set earlier

Closes #6881

See merge request GNOME/gtk!7618
2024-08-16 16:52:34 +00:00
Matthias Clasen
3f36ebc6e7 Merge branch 'matthiasc/for-main' into 'main'
textview: Fix a regression in selection drawing

Closes #6931

See merge request GNOME/gtk!7620
2024-08-16 16:06:14 +00:00
Matthias Clasen
4aea2d2e09 css: Don't pass style variables redundantly
The context->variables field is expected by the resolve code to be
the keyframe variables. That code takes the style variables from
context->style anyway, so no need to pass them as context->variables
too. And crucially, the lookup code treats the keyframes variables
differently to the style variables, since it doesn't expect the
hierarchical structure that comes from parent styles. This change
fixes infinite recursion in variable lookup with css like

:root {
  --a: var(--b);
}

.foo {
  --b: var(--a);
  color: var(--a);
}

Test included.

Fixes: #6881
2024-08-16 11:38:56 -04:00
Matthias Clasen
4e9107d4b1 widget: Fail properly in compute_transform
We don't currently support computing transforms across native
boundaries. This could be added by using gdk_popup_get_position_x/y.
For now, just fail in this case.

Related: #6355
2024-08-16 10:07:53 -04:00
Matthias Clasen
7d895720be textview: Fix a regression in selection drawing
We were no longer respecting the text color or the selection being
clear.

Fixes: #6931
2024-08-16 08:44:35 -04:00
Benjamin Otte
323dde2b10 Merge branch 'wip/otte/for-main' into 'main'
wayland: Implement GdkToplevel::decorated

See merge request GNOME/gtk!7617
2024-08-16 00:01:54 +00:00
Benjamin Otte
ac16e375c7 wayland: Implement GdkToplevel::decorated
... and use that instead of custom announce_csd/announce_ssd APIs.
2024-08-16 01:38:55 +02:00
Matthias Clasen
31143f9611 Merge branch 'kjellahl/docs-window' into 'main'
docs: Improve gtk_window_set_interactive_debugging() docs

See merge request GNOME/gtk!7614
2024-08-15 16:57:00 +00:00
Matthias Clasen
7da4844dcc Merge branch 'css-variables-crash' into 'main'
css: Fix a crash in variables

Closes #6935

See merge request GNOME/gtk!7615
2024-08-15 15:15:48 +00:00
Matthias Clasen
c9e4abcd3a css: Fix a crash in variables
We were not careful enough when checking for reference cycles.

Fixes: #6935

Test included.
2024-08-15 10:16:47 -04:00
Matthias Clasen
6e80fde45f Merge branch 'accessibility-docs-fix' into 'main'
docs: Fix a typo in a code example on the accessibility page

See merge request GNOME/gtk!7616
2024-08-15 13:49:29 +00:00
Philip Withnall
d182b133a9 docs: Fix a typo in a code example on the accessibility page
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-08-15 14:18:31 +01:00
Matthias Clasen
5e3240a32f Merge branch 'matthiasc/for-main' into 'main'
colorstate: Don't leak names

See merge request GNOME/gtk!7611
2024-08-14 18:06:36 +00:00
Matthias Clasen
436989d745 gsk: Apply the same transfer fixes
These are copied from gdkcolordefs.h.
2024-08-14 13:21:28 -04:00
Matthias Clasen
f62606105e Fix up transfer function symmetry
The easiest things trigger the silliest mistakes. Add tests
for various properties we want our transfer functions to have,
such as:
- be inverse of each other
- stay within the defined ranges
- by symmetric around 0
2024-08-14 11:45:25 -04:00
Matthias Clasen
0f85a40a25 colorstate: Plug a leak and allocate less
We don't need to allocate the matrices, but we do neet to free
the name of cicp color states.
2024-08-14 11:00:10 -04:00
Matthias Clasen
16ad1e428f colorstate: Don't leak names
The cicp colorstates allocate their names, so they should free
them too.
2024-08-14 11:00:10 -04:00
Matthias Clasen
a6e0028899 Merge branch 'wip/otte/for-kwin' into 'main'
Fix various issues with Kwin git

See merge request GNOME/gtk!7612
2024-08-14 14:58:08 +00:00
Kjell Ahlstedt
dc3def1afd docs: Improve gtk_window_set_interactive_debugging() docs
This function is recommended only if you override the default
key shortcuts for the Inspector.
2024-08-14 16:57:55 +02:00
Kjell Ahlstedt
a14e426fb5 docs: Improve gtk_window_set_interactive_debugging() docs
This function is recommended only if you override the default
key shortcuts for the inspector.
2024-08-14 15:51:56 +02:00
Bruce Cowan
a1a4026867 Update British English translation 2024-08-14 10:27:24 +00:00
Benjamin Otte
aff1b88c92 wayland: Work where the primaries have no name
Set primaries without name if supported, when named primaries are not.
But prefer named primaries if available.

This is just an attempt at defensive coding.
2024-08-14 08:30:55 +02:00
Benjamin Otte
dc072f881c wayland: Accept primaries/primaries_named interchangably
If we get sent primaries with the values as named primaries, treat them
like named primaries.

Fixes colorstate support on Kwin, which never sends named primaries.
2024-08-14 08:30:55 +02:00
Benjamin Otte
824ccfc562 gpu: Add an assertion
If the wrong color states get passed, we need to figure that out, before
we run shaders with junk values doing god knows what.
2024-08-14 08:30:55 +02:00
Benjamin Otte
8c6e5ca131 subsurface: Fully covered backgrounds don't need to be drawn
If the texture covers all of the black background (like when watching a
1080p stream fullscreen on a 1080p monitor) we don't need a compositor
with single pixel support.

Fixes offloading in Kwin.
2024-08-14 08:30:55 +02:00
Benjamin Otte
a7b69ad9b5 subsurface: Don't create a bg_subsurface until we need it
There's a ton of error checking happening that we want to do.

Because it turns out it is not really useful to create a subsurface for
the single pixel buffer when we don't even support single pixel buffers.
2024-08-14 08:30:55 +02:00
Benjamin Otte
3cd25516ab gdk: Improve GDK_DEBUG=linear
Keep a linear and a non-linear rendering colorstate around. That way, we
don't "return self;" from cicp colorstates and then end up with a cicp
ccs.
2024-08-14 08:30:40 +02:00
Benjamin Otte
f3c8c5a9c0 Merge branch 'wip/otte/for-main' into 'main'
color: Handle negative values in all transfer functions

See merge request GNOME/gtk!7609
2024-08-13 23:52:32 +00:00
Matthias Clasen
6878200ccf Merge branch 'matthiasc/for-main' into 'main'
drawcontext: Fix up color state ownership

See merge request GNOME/gtk!7608
2024-08-13 21:42:46 +00:00
Matthias Clasen
e1fbd52c29 gdk: Handle negative values in all transfer function
Make sure that for all eotfs/oetfs, eotf(x) == -eotf(-x)

In particular, don't pass negative values to pow() and cause
undefined behavior.
2024-08-13 15:47:17 -04:00
Benjamin Otte
79c2df8392 color: Handle negative values in all transfer functions
Make sure that for all eotfs/oetfs, eotf(x) == -eotf(-x)

In particular, don't pass negative values to pow() and cause undefined
behavior.
2024-08-13 20:47:40 +02:00
Scrambled 777
0888402cea Update Hindi translation 2024-08-13 18:38:21 +00:00
Matthias Clasen
3dae3205e7 drawcontext: Fix up color state ownership
begin_frame_full does not return a reference, we assume that the
color state is staying alive for the duration of the frame anyway,
so end_frame simply sets priv->color_state to NULL.
2024-08-13 13:23:20 -04:00
Matthias Clasen
4858122d17 Merge branch 'matthiasc/for-main' into 'main'
icon helper: Fix an argument order mishap

See merge request GNOME/gtk!7606
2024-08-13 16:50:31 +00:00
Matthias Clasen
a19023277f icon helper: Fix an argument order mishap
It seems that for a long time, no compiler saw it fit to warn
about this, even though they argument types are not the same.
2024-08-13 10:36:12 -04:00
Emmanuele Bassi
72dc9e3bf1 Merge branch 'fix_popover_docs_typo' into 'main'
docs: Fix popover docs typo

See merge request GNOME/gtk!7605
2024-08-13 12:29:37 +00:00
Mikael Forsberg
5f814cc30a docs: Fix popover docs typo 2024-08-13 13:50:47 +02:00
Martin
23aafbf09f Update Slovenian translation 2024-08-13 05:55:59 +00:00
Matthias Clasen
761dc7cad0 Merge branch 'matthiasc/for-main' into 'main'
testsuite: build fix

See merge request GNOME/gtk!7603
2024-08-13 03:31:47 +00:00
Matthias Clasen
f62a873eef inspector: Show color state of surfaces
Put this information in the misc tab for surfaces.
2024-08-12 22:25:08 -04:00
Benjamin Otte
03c99ebc99 Merge branch 'wip/otte/for-matthiasc' into 'main'
vulkan: Round damage rectangles properly

See merge request GNOME/gtk!7602
2024-08-13 00:24:47 +00:00
Matthias Clasen
cb339f85b8 testsuite: build fix
The statically linked tests need to have -DGTK_COMPILATION=1
in their cflags.
2024-08-12 19:19:15 -04:00
Benjamin Otte
5d056eabf6 egl: Round damage rectangles properly
We need to round outwards and a 1x1 rectangle with offset 0.5,0.5 should
end up as a 3x3 rectangle with offset 0,0 when rounded, not as a 2x2
rectangle.
2024-08-13 00:36:11 +02:00
Benjamin Otte
4e77667ab8 vulkan: Round damage rectangles properly
We need to round outwards and a 1x1 rectangle with offset 0.5,0.5 should
end up as a 3x3 rectangle with offset 0,0 when rounded, not as a 2x2
rectangle.
2024-08-13 00:36:11 +02:00
Luca Bacci
d3e3ddf897 WGL: Report paint region when presenting (SwapBuffers)
Report the paint region to the OpenGL driver, which in turn may
report it to the system compositor (DWM).
2024-08-12 18:56:45 +02:00
Luca Bacci
fca983e81e WGL: Report backbuffer's damage to GDK
The backbuffer's damage region is the region of the backbuffer
that doesn't contain up-to-date contents. This is determined
by the backbuffer's age and previous frame's paint regions.

This enables incremental rendering
2024-08-12 18:56:34 +02:00
Luca Bacci
b1995d0d77 Merge branch 'gtkshowwin32' into 'main'
Hook up file/URI launching to ShellExecute

See merge request GNOME/gtk!7556
2024-08-12 14:17:27 +00:00
Matthias Clasen
8ccfda4972 Merge branch 'docs-fix' into 'main'
docs: fix since annotation

See merge request GNOME/gtk!7600
2024-08-12 10:14:35 +00:00
Yosef Or Boczko
9a47c0f923 Update Hebrew translation 2024-08-12 09:58:40 +00:00
Sergey Bugaev
b33b679b13 Hook up gtk_show_uri_full () to gtk_show_uri_win32 ()
On Windows, always use gtk_show_uri_win32 () instead of going through
GAppInfo.  Hook up gtk_file_launcher_launch () to gtk_show_uri_win32 ()
as well, always extracting the file path (and not a URI) and propagating
the always-ask flag.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2024-08-12 11:18:23 +03:00
Sergey Bugaev
8d41ecff3e Add gtk_show_uri_win32 ()
This is a new internal utility to open/show/launch/execute URIs and
files on Windows, using Windows's native ShellExecuteEx () and
SHOpenWithDialog () APIs.

The advantages this has over using the win32 implementation of
g_app_info_launch_default_for_uri ():

* the implementation here is fairly simple;
* it doesn't involve trying to grok the registry for app / file	type
  registrations (at least not inside GLib/GTK side, the implementations
  of ShellExecuteEx/SHOpenWithDialog presumably do that internally);
* it doesn't require convoluted formatting / escaping of invocation
  command lines that GWin32AppInfo / gspawn-win32 has to do otherwise
  (again, presumably the Windows libraries implement this internally);
* it's certain to end up opening the file/URI the same way other apps
  in the system would;
* it can/will open the native system UI for picking an app in case there
  are multiple options (or when so requested programmatically with the
  always-ask flag), or if there is no app installed that can handle the
  URI scheme / file type;
* it lets us pass the parent window handle, much like the portal APIs;
  presumably Windows would use this for positioning the picking UI, or
  placing the launched app's window;
* presumably, this will properly elevate privileges with a User Access
  Control (UAC) prompt if the app being launched requires administrator
  access; this presumably is impossible with the wspawn* APIs that
  gspawn-win32 uses;
* this has a much better chance to work properly with the win32 app
  isolation (AppContainer) technology.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2024-08-12 11:18:17 +03:00
Jan Willem
85bcf9a366 docs: fix since annotation 2024-08-12 07:05:47 +00:00
Matthias Clasen
b27e3631f0 Merge branch 'matthiasc/for-main' into 'main'
colorstate: Avoid a memcpy

See merge request GNOME/gtk!7599
2024-08-11 22:00:03 +00:00
Matthias Clasen
4d5ba0631d colorstate: Avoid a memcpy
We don't need it here, and this call can happen with
values being in memory that is not amenable to fast memcpy.
2024-08-11 16:31:42 -04:00
Matthias Clasen
0f618ae29e Cosmetics 2024-08-11 16:31:35 -04:00
Matthias Clasen
13d415f2f6 Add a comment 2024-08-11 16:31:18 -04:00
Matthias Clasen
e7b14ae26e Post-release version bump 2024-08-11 15:52:33 -04:00
Matthias Clasen
07658347a9 4.15.5 2024-08-11 15:43:54 -04:00
Matthias Clasen
0436801a9c Merge branch 'matthiasc/for-main' into 'main'
docs: Mark the docs check as failing

See merge request GNOME/gtk!7598
2024-08-11 19:43:16 +00:00
Matthias Clasen
4da593a3de Merge branch 'printdialog_fix_sporadic_win32_build_failures' into 'main'
printdialog: fix sporadic win32 build failures

See merge request GNOME/gtk!7464
2024-08-11 19:35:32 +00:00
Matthias Clasen
f5194bbf83 gdk: Mark the docs check as failing
It complains about get_type functions, which really don't need
or want docs.
2024-08-11 15:03:13 -04:00
Matthias Clasen
15552e5478 docs: Mark the docs check as failing
Despite promises, and after fixing the configuration, the test still
complains about deprecated api not having docs. Not useful.
2024-08-11 15:01:59 -04:00
Matthias Clasen
d9616c1993 docs: Try to fix the docs check 2024-08-11 15:00:54 -04:00
Matthias Clasen
5dbce5ce9b docs: Add a missing bit 2024-08-11 14:47:59 -04:00
Matthias Clasen
1f47c36e49 docs: Fix a typo 2024-08-11 14:47:48 -04:00
Benjamin Otte
ed05890740 Merge branch 'wip/otte/for-main' into 'main'
gl: Interpolate gradient colors as premultiplied

See merge request GNOME/gtk!7597
2024-08-11 17:41:41 +00:00
Benjamin Otte
68d73dcce5 nodeparser: Handle disallowed values for radial gradients
Make sure the radii are strictly positive.

Also handle the case where start >= end.
We can't really underline that error, because we don't track the
locations of the start/end properties until we know that there's an
error.
So just underline the whole radial gradient declaration.

Test included
2024-08-11 19:07:40 +02:00
Benjamin Otte
9643a21827 gl: Interpolate gradient colors as premultiplied
Tests included
2024-08-11 19:07:40 +02:00
Matthias Clasen
07b64c2f0f Merge branch 'matthiasc/for-main' into 'main'
docs: Updates

See merge request GNOME/gtk!7596
2024-08-11 15:53:11 +00:00
Matthias Clasen
3df3ec2a29 css: Fix a copy-paste error
We want to use the decoration color if has_decoration_color is
TRUE, not if it is FALSE.
2024-08-11 10:02:03 -04:00
Matthias Clasen
0015fda94c docs: Updates
Keep the docs for our debug variables in sync with reality.
2024-08-11 09:02:35 -04:00
Matthias Clasen
589f483e7b NEWS: Updates 2024-08-11 08:50:42 -04:00
Daniel Șerbănescu
a77f8c9f62 Update Romanian translation
(cherry picked from commit cfbfaeae01)
2024-08-11 11:14:37 +00:00
Matthias Clasen
1d7aa9e40b Merge branch 'matthiasc/for-main' into 'main'
Small cleanups

See merge request GNOME/gtk!7592
2024-08-11 11:01:58 +00:00
Benjamin Otte
8de4b04819 Merge branch 'wip/otte/for-main' into 'main'
color: NEVER EVER use memcpy() in critical path

See merge request GNOME/gtk!7593
2024-08-11 05:39:26 +00:00
Benjamin Otte
175dba86fd color: NEVER EVER use memcpy() in critical path
Unless there is a very good reason to use memcpy(), don't use it.

Not using it makes the compiler not screw up and waste tons of CPU that
it could have not wasted.

Gets my framerate back from 1250 => 1750 and makes sysprof no longer
report ~40% of render time spent in gsk_gpu_colorize_op().
2024-08-11 06:51:58 +02:00
Matthias Clasen
767b9b9405 Docs: Add the image tool to the list 2024-08-10 22:47:02 -04:00
Matthias Clasen
202a51d9e3 Cosmetics 2024-08-10 22:41:31 -04:00
Matthias Clasen
3014d36a61 Merge branch 'matthiasc/for-main' into 'main'
inspector: Show fine transform categories

See merge request GNOME/gtk!7591
2024-08-11 02:40:25 +00:00
Matthias Clasen
d718fda057 memory texture: Fix a memory leak
The callers assumed that gdk_memory_sanitize is transfer full in
both directions, but it wasn't. Make it so.
2024-08-10 22:24:29 -04:00
Matthias Clasen
bbb7b365d5 inspector: Show roles for nodes
For some node types, the child nodes play different roles. E.g.
for a mask node, one of the two children is the source, the other
the mask. Show this information in the inspector.
2024-08-10 21:51:06 -04:00
Matthias Clasen
740e485160 NEWS: Updates 2024-08-10 21:09:29 -04:00
Matthias Clasen
5a69127862 inspector: Show fine transform categories
This is information we care about in particular for offloading,
so show it.
2024-08-10 21:08:53 -04:00
Matthias Clasen
798883f21a Merge branch 'css-color-hookup-5' into 'main'
Make non-srgb css colors work for text nodes

See merge request GNOME/gtk!7558
2024-08-10 16:28:31 +00:00
Matthias Clasen
bec71a15b4 Merge branch 'matthiasc/for-main' into 'main'
Fix a copy-paste error

See merge request GNOME/gtk!7589
2024-08-10 12:55:32 +00:00
Matthias Clasen
c4baf60044 inspector: Rename add_color2_row to add_color_row
The original add_color_row is gone now, so we can rename its
successor back.
2024-08-10 08:16:40 -04:00
Matthias Clasen
d32081401f inspector: Show more details for text nodes
Show the color state, and create textures with the full color
information.

The GdkRGBA-based helper functions are no longer used with this
commit and have been dropped.
2024-08-10 08:16:40 -04:00
Matthias Clasen
ed119ae246 gtk: Port selection drawing to new apis
Preserve color state information when drawing selections or block
cursors in GtkTextView.
2024-08-10 08:16:40 -04:00
Matthias Clasen
51768d0e16 gtk: Port caret drawing to new apis
Preserve color state information here.
2024-08-10 08:16:40 -04:00
Matthias Clasen
6f1a4e5bb9 gtk: Use the new apis
It is not perfect, since PangoRenderer, GtkTextAppearance and
GtkTextTag all carry colors as PangoColor or GdkRGBA. But at least,
we get glowing foreground colors.
2024-08-10 08:14:23 -04:00
Matthias Clasen
e323d2a93e gtk: Add gtk_snapshot_append_text2/layout2
These are private snapshot functions that use the new constructor
to create a text node with a given color state.
2024-08-10 07:48:18 -04:00
Matthias Clasen
23922eebf1 gl: Handle text colors with color states
Since we don't have proper color management here, just convert
any color we meet to sRGB and hope for the best.
2024-08-10 07:48:18 -04:00
Matthias Clasen
92bd85ba30 nodeparser: Support color states in text nodes
Test included.
2024-08-10 07:37:01 -04:00
Matthias Clasen
ca7aa30bc5 gsk: Use private text node api 2024-08-10 07:37:01 -04:00
Matthias Clasen
d17972427a gsk: Add private text node api
Add a constructor that takes a GdkColor and a corresponding getter.
2024-08-10 07:37:01 -04:00
Matthias Clasen
25f0c81530 Fix a copy-paste error
This was introduced in ea28dc8cff.
2024-08-10 07:11:56 -04:00
Matthias Clasen
4f95d126ba Merge branch 'matthiasc/for-main' into 'main'
gl: Handle box shadow colors with color states

See merge request GNOME/gtk!7588
2024-08-10 03:05:26 +00:00
Matthias Clasen
310196cc59 gl: Handle box shadow colors with color states
Since we don't have proper color management here, just convert
any color we meet to sRGB and hope for the best.
2024-08-09 22:27:57 -04:00
Matthias Clasen
8052bcc69c Updates 2024-08-09 22:11:35 -04:00
Benjamin Otte
04ee41d7b0 Merge branch 'wip/otte/for-main' into 'main'
lots of small things

See merge request GNOME/gtk!7585
2024-08-10 01:10:12 +00:00
Benjamin Otte
23af1cd8ad gpu: When transforming to simpler transform, we might be all clipped
When transforming back from a complex transform to a simpler transform,
the resulting clip might turn out to clip everything, because clips can
grow while transforming, but the scissor rect won't. So when this
process happens, we can end up with an empty clip by transforming:

1. Set a clip that also sets the scissor
2. transform in a way that grows the clip, say rotate(45)
3. modify the clip to shrink it
4. transform in a way that simplifies the transform, say another
   rotate(45)
5. Figure out that this clip and the scissor rect do no longer overlap

Catch this case and avoid drawing anything.
2024-08-10 02:38:13 +02:00
Benjamin Otte
4426194ee6 Merge branch 'css-color-hookup-4' into 'main'
Make non-srgb css colors work for shadows

See merge request GNOME/gtk!7557
2024-08-10 00:36:28 +00:00
Matthias Clasen
92c119e12c testsuite: Replay shadow nodes properly
Use the new apis for this.
2024-08-09 20:17:04 -04:00
Matthias Clasen
ff02665407 inspector: Show more shadow node details
Show the color state, and create textures with the full color
information.

With this commit, add_color_row and get_color_texture are no longer
used and have been dropped.
2024-08-09 20:17:04 -04:00
Matthias Clasen
d471ed5912 gtk: Use new shadow snapshot apis
Preserve color states from css as much as possible.
2024-08-09 20:17:04 -04:00
Matthias Clasen
b92ca5da02 gtk: Add gtk_snapshot_push_shadow2
This is a private snapshot function that uses the new constructor
to create a shadow node with the given color states.
2024-08-09 20:17:04 -04:00
Matthias Clasen
0f7c0f616c nodeparser: Handle shadows with color state
Test included.
2024-08-09 20:09:31 -04:00
Matthias Clasen
5551f30400 gsk: Use private shadow node api 2024-08-09 20:09:31 -04:00
Matthias Clasen
2c10d72fe5 gsk: Add private shadow node api
Add a new GskShadow2 struct that has a GdkColor instead of
a GdkRGBA, and a new constructor and getter to go along with
it.

With this commit, my_color_get_depth is no longer used and
has been dropped.
2024-08-09 20:09:31 -04:00
Matthias Clasen
44fe51247c gsk: Change the blur op api
Pass the ccs, opacity and GdkColor to the op to let it make
decisions about color conversion.

Update the callers.
2024-08-09 20:09:31 -04:00
Matthias Clasen
3a99f1e9f1 gsk: Change the colorize op api
Pass the ccs, opacity and GdkColors to the op to let it make
decisions about color conversion.

Update the callers.
2024-08-09 20:09:30 -04:00
Matthias Clasen
d233f0ca3e node parser: Move parse_color2 up
We will use this function more so move it where it belongs.
2024-08-09 20:09:30 -04:00
Matthias Clasen
c548bdc3fe css: Add gtk_css_parser_consume_number_or_percentage
This comes in handy in the render node parser.
2024-08-09 20:09:30 -04:00
Benjamin Otte
839d797292 build: Don't set G_SLICE=always-malloc
That environment variable has been gone since GSlice went away in glib
2.76. Which is our minimum requirement.
2024-08-10 01:53:46 +02:00
Benjamin Otte
f8a30ddfc1 gdk: Deprecate gdk_surface_set_opaque_region() 2024-08-10 01:40:46 +02:00
Benjamin Otte
bb0eb3af45 gtk: Stop calling gdk_window_set_opaque_region()
Now that GDK can figure it out from the rendernode, doing all this work
trying to figure it out is no longer necessary.

Plus, it was sometimes wrong and lead to obscure artifacts.
2024-08-10 01:40:46 +02:00
Benjamin Otte
999d9bc73b gdk: Introduce gdk_surface_is_opaque()
... and use it in the mac backend instead of a hand-rolled version.
2024-08-10 01:40:46 +02:00
Benjamin Otte
16c7003acb gdk: Pass the opaque rect to begin_frame() actually
We know it at begin_frame() time, so if we pass it there instead of
end_frame(), we can use it then to make decisions about opacity.

For example, we could notice that the whole surface is opaque and choose
an RGBx format.
We don't do that yet, but now we could.
2024-08-10 01:40:46 +02:00
Benjamin Otte
f64045c229 gdk: Pass the opaque rect on to the opaque region
The opaque rect from the rendernodes are now used to set the opaque
region in the backend.

This means applications can now set a transparent window background and
make indivual parts of their window opaque.
But because this is a best effort method, it is not guaranteed to
succeed in finding all opaque regions, in particular if the rendernodes
used to build it are not straightforward to analyze.
2024-08-10 01:40:46 +02:00
Benjamin Otte
58aebc4447 surface: Put opaque_region in the priv structure
This is in preparation for future patches.
2024-08-10 01:40:46 +02:00
Benjamin Otte
3b3b6036f8 mac: Remove clear optimization
1. We want to get rid of exposing the opaque region

2. Cairo optimizes clearing the whole surface
2024-08-10 01:40:46 +02:00
Benjamin Otte
75748f4ae9 gl: Remove update_area() trick
This is poking into the surface directly, so not a good idea.
And I want to hide that struct in the priv member.

Technically, this code should look at the opaque region, but I am lazy
and the GL renderer is on its way out, so I think it's not worth doing.
2024-08-10 01:40:46 +02:00
Benjamin Otte
f90fb68aec gdk: Deprecate public begin/end_frame() APIs
We are using so many internal extra features that it is no longer a good
idea to use these functions.
And they aren't really used anyway.

These extra features are also constantly in flux and rely on internal
APIs, so exposing them would just cause extra pain.
2024-08-10 01:40:45 +02:00
Benjamin Otte
4fa3943e51 gdk: "inline" gdk_draw_context_get_frame_region()
By using the inlining macro trick, we can work around deprecation
warnings from removing this function as a public API, which will happen
in the next commits.
2024-08-10 01:40:45 +02:00
Benjamin Otte
0a92f741b3 vulkan: Remove 2 unneeded return_if_fail() checks
I want to deprecate that function, so getting rid of calls to it sounds
like a good idea.
2024-08-10 01:40:45 +02:00
Benjamin Otte
a35f8d52d6 gsk: Clear current context after unrealize()
Make sure both GL renderers don't leave their contexts alive via the
current context, but ensure they dispose of them properly.

Fixes issues when the corresponding GL resources in the surfaces they
were attached to go away.
2024-08-10 01:40:45 +02:00
Benjamin Otte
b08ccc0bec ngl: Stop crashing with zink and llvmpipe
We were not calling make_current() early enough anymore after the
Vulkan validation-layer fixes in !7468

Change that by calling it earlier.
2024-08-10 01:40:45 +02:00
Benjamin Otte
523cd0dff7 glcontext: Add a surface_attached flag
GLContexts marked as surface_attached are always attached to the surface
in make_current().
Other contexts continue to only get attached to their surface between
begin_frame() and end_frame().

All our renderer use surface-attached contexts now.
Public API only gives out non-surface-attached contexts.

The benefit here is that we can now choose whenever we want to
call make_current() because it will not cause a re-make_current() if we
call it outside vs inside the begin/end_frame() region.

Or in other words: I want to call make_current() before begin_frame()
without a performance penalty, and now I can.
2024-08-10 01:40:45 +02:00
Benjamin Otte
8ac1806015 gdk: Use begin_frame_full() everywhere
begin_frame() is going to go away, so we should use the "real" function.
2024-08-10 01:40:45 +02:00
Benjamin Otte
0b2275774f gdk: Add gdk_draw_context_end_frame_full()
... and pass the opaque region of the node.

We don't do anything with it yet, this is just the plumbing.

The original function still exists, it passes NULL which is the value
for no opaque region at all.
2024-08-10 01:40:45 +02:00
Benjamin Otte
4fbfe9b041 gsk: Warn about unused result in gsk_render_node_get_opaque_rect()
It's a function to easily forget to check the return value.

In fact I just did that.
2024-08-10 01:40:45 +02:00
Benjamin Otte
b6c848d711 x11: Remove special casing from get_damage() call
This function is only ever called while inside a frame, so the check is
not necessary.
2024-08-10 01:40:45 +02:00
Benjamin Otte
a467cfd060 inspector: Use a higher priority than USER
We want to override user settings, so make sure we do that.
2024-08-10 01:40:45 +02:00
Benjamin Otte
f24be8476e wayland: Clean up after ourselves in the xx-color code
If an image description query is running while the surface gets
destroyed, we were not properly cleaning up, causing the callbacks to be
emitted on freed variables.
2024-08-10 01:40:45 +02:00
Benjamin Otte
904b1815b5 nodeprocessor: Consult scissor after rounded clip
If we apply a rounded clip, we might change the clip in a way that makes
it intersectable with the scissor again, if both had diverged before.

So try and intersect with the clip.
2024-08-10 01:40:45 +02:00
Benjamin Otte
d6322c6389 gsk: Switch box shadow nodes to use offsets
Instead of
  float dx;
  float dy;
have a
  graphene_point_t offset;
in the object and in all APIs relating to them.
2024-08-10 01:40:45 +02:00
Benjamin Otte
2ee16e5dd9 gl: Set correct context when disposing GLDriver 2024-08-10 01:40:45 +02:00
Matthias Clasen
f846315a6a Merge branch 'matthiasc/for-main' into 'main'
docs: More details for the node format

See merge request GNOME/gtk!7586
2024-08-09 16:46:30 +00:00
Matthias Clasen
5329b7d211 docs: More details for the node format
Add some more details.
2024-08-09 12:16:06 -04:00
Matthias Clasen
ac18a665d5 node-format.md: formatting tweaks 2024-08-09 11:54:12 -04:00
Matthias Clasen
c492e71aed Merge branch 'css-color-hookup-3' into 'main'
Make non-srgb css colors work for box shadows

See merge request GNOME/gtk!7552
2024-08-08 22:52:12 +00:00
Matthias Clasen
4ea1319c6b Replay inset and outset shadow nodes properly 2024-08-08 16:01:06 -04:00
Matthias Clasen
2aac3c2cc9 inspector: Show more details for box shadow nodes
Show the color state, and create textures with the full color
information.
2024-08-08 16:01:06 -04:00
Matthias Clasen
55d18bdc06 gtk: Use new box shadow snapshot apis
Preserve color states from css as much as possible.
2024-08-08 16:01:06 -04:00
Matthias Clasen
abefa0ab00 gtk: Add gtk_snapshot_append_{in,out}set_shadow2
These are private snapshot functions that use the new constructors
to create a box shadow nodes with a given color state.
2024-08-08 16:01:06 -04:00
Matthias Clasen
ea28dc8cff nodeparser: Support color states for box shadows
Just switch from parse_color to parse_color2, and apply the
corresponding changes to serialization too.

Test included.
2024-08-08 15:49:55 -04:00
Matthias Clasen
d3b9eb7fc8 gsk: Use private box shadow api 2024-08-08 15:43:49 -04:00
Matthias Clasen
cdb61923af gsk: Add private box shadow node api
Add a constructor that takes a GdkColor, and a getter for it.
2024-08-08 15:43:49 -04:00
Matthias Clasen
070ddcd14b Change box shadow op api
Pass the ccs, opacity and GdkColor and let the op decide about
color conversions. Update all callers.
2024-08-08 15:43:49 -04:00
Matthias Clasen
355890b421 gsk: Port the cairo blur to GdkColor
Update all callers.
2024-08-08 15:43:49 -04:00
Matthias Clasen
d86407f263 Merge branch 'wip/otte/optional-dependencies' into 'main'
gstreamer: Always build dmabuf support

See merge request GNOME/gtk!7201
2024-08-08 19:29:13 +00:00
Benjamin Otte
a24a7db72b build: bump GStreamer dep to 1.24.0
Depend on a release version, not a prerelease.
2024-08-08 19:03:31 +00:00
Benjamin Otte
2096a29b06 build: Remove an old workaround
The workaround only triggered in GStreamer < 1.19.1 but we require 1.23
now.
2024-08-08 19:03:31 +00:00
Benjamin Otte
ce352b5538 build: Move GStreamer dependency checks
Put them where all the other checks go so that it's easy for people
reading build files to see what GTK depends on.

Also reindent properly.
2024-08-08 19:03:31 +00:00
Benjamin Otte
4bcd2c75cc gstreamer: Require the same version for all GStreamer deps
We don't want people to have different GStramer library versions.

GStreamer now is developed in a monorepo, so the versions are in sync.
2024-08-08 19:03:31 +00:00
Benjamin Otte
3c3bf0192d gstreamer: Always build dmabuf support
I just spent an hour trying to figure out why things don't work. And it
was an optional dependency hidden 3 layers deep in some meson file.

This really has to stop.

And because just like in GTK, GStreamer's dmabuf APIs are always
available (they will just fail on Windows etc), there's no need to have
any conditions.

The only difference is that the GStreamer media backend now requires
GStreamer 1.24.
2024-08-08 19:03:31 +00:00
Benjamin Otte
cf84d999d8 dmabuf: Add DRM_FORMAT_MOD_INVALID to our formats
That's gonna be necessary for the next commits.
2024-08-08 19:03:31 +00:00
Matthias Clasen
668628941e Merge branch 'ci-update-f40' into 'main'
ci: Update to Fedora 40

See merge request GNOME/gtk!7583
2024-08-08 19:02:22 +00:00
Matthias Clasen
33f8fa331d fp16: Mark ifuncs as unused to pacify clang
clang in F40 seems to have forgotten what fp16 is, and doesn't
use the resolver functions for anything, and then complains that
they are unused...
2024-08-08 14:40:19 -04:00
Matthias Clasen
7814d1fd75 ci: Fix a Vulkan problem in the F40 image
Drop the powervr Vulkan driver, which otherwise interferes with
proper functioning of our ci.
2024-08-08 14:19:25 -04:00
Matthias Clasen
b57c3008a3 ci: Update to Fedora 40
Crucially, this gives us gstreamer 1.24.
2024-08-08 12:57:33 -04:00
Benjamin Otte
99d291eb69 Merge branch 'wip/otte/occlusion' into 'main'
Implement advanced occlusion culling

See merge request GNOME/gtk!7570
2024-08-08 14:22:22 +00:00
Benjamin Otte
8e35398371 Merge branch 'wip/otte/for-main' into 'main'
vulkan: Turn debug messages into warnings

See merge request GNOME/gtk!7579
2024-08-08 04:25:35 +00:00
Benjamin Otte
3313fd4e2b vulkan: Turn debug messages into warnings
Vulkan errors are quire critical, so we want to see them.

Our code is good enough to handle all non-critical errors.
2024-08-08 04:41:16 +02:00
Matthias Clasen
56c02dd7d1 Merge branch 'css-color-hookup-2' into 'main'
Make non-srgb css colors work for borders

See merge request GNOME/gtk!7550
2024-08-07 23:14:35 +00:00
Benjamin Otte
4e4ed1e2d5 gpu: Implement occlusion for subsurface nodes
In the case of no offloading, we want to pass through to the child
(which is likely a big texture doing occlusion).

In the case of punching a hole, we want to punch the hole and not draw
anything behind it, so we start an occlusion pass with transparency.

And in the final case with offloading active, we don't draw anything,
so we don't draw anything.

This should fix concerns about drawing the background behind the video
as mentioned for example in
https://github.com/Rafostar/clapper/issues/343#issuecomment-1445425004
2024-08-07 23:26:03 +02:00
Benjamin Otte
82aa2cb5c2 gpu: Implement add_first_node for debug nodes
As always, we want to have no influence on any results
from these nodes.
2024-08-07 23:26:03 +02:00
Benjamin Otte
e9944148d5 gpu: Add GSK_DEBUG=occlusion
Draws a semi-transparent white overlay over all regions that have
been chosen for occlusion.
2024-08-07 23:26:03 +02:00
Benjamin Otte
afa4eb7d35 gpu: Make containers check opaque size for early exit
Container nodes save their opaque region, so it's quick to access. Use
that to check if the largest opaque region even qualifies for culling -
and if not, just exit.

Speeds up walking node trees by a lot.
2024-08-07 23:26:03 +02:00
Benjamin Otte
55597d88a4 gpu: Run full check for every clip rect
Now that we can specify the min size for an occlusion pass, we can
specify that we want the full clip rect to be occluded for occlusion to
trigger.

The benefit of this is that for partial redraws we almost
always get the background color to cover the redrawn rectangle, so
occlusion will kick in.
2024-08-07 23:26:03 +02:00
Benjamin Otte
ac37b589b6 gpu: Require an occlusion path to be 10% of image
That way we are guaranteed to run <=10 occlusion passes.
2024-08-07 23:26:03 +02:00
Benjamin Otte
b9d868b8eb gpu: Pass min occlusion size as argument
That allows as to vary the number. We don't do that yet, but we could
now.
2024-08-07 23:26:03 +02:00
Benjamin Otte
30e5bfcbf0 gpu: Refactor culling function
Split the loop into 2: One for the culling and one for later, once we've
decided to not try culling anymore.
2024-08-07 23:26:03 +02:00
Benjamin Otte
57e21683a6 gpu: Try largest clip rect first
When trying to cull, try culling from the largest rectangle of the
remaining draw region first. That region has the biggest chance of
containing a large area to skip.

As a side effect, we can stop trying to cull once the largest rectangle
isn't big enough anymore to contain anything worth culling.
2024-08-07 23:26:03 +02:00
Benjamin Otte
852ecf7c20 gpu: Consult scissor for clip bounds
When querying clip bounds, also check the scissor rect, because
sometimes that one is tighter than the clip bounds, because the clip
bounds need to track some larger rounded corners.

Makes a few tests harder to break.
2024-08-07 23:26:03 +02:00
Benjamin Otte
5976debfcd gpu: Change how occlusion passes work
Instead of requiring an occlusion pass to cover the whole given scissor
rect, allow using a smaller rect to start the pass.

When starting such a pass, we adjust the scissor rect to the size of
that pass and do not grow it again until the pass is done.
The rectangle subtraction at the end will then take care of subtraction
that rectangle from the remaining pixels.

To not end up with lots of tiny occlusion passes, add a limit for how
small such a pass may be.
For now that limit is arbitrarily chosen at 100k pixels.
2024-08-07 23:26:03 +02:00
Benjamin Otte
08fcba63d0 gpu: Split out a function
gsk_gpu_node_processor_rect_to_device() is a useful function to have,
even if it has to return FALSE sometimes when there is no simple 1:1
mapping - ie when the modelview contains a rotation.
2024-08-07 23:26:03 +02:00
Benjamin Otte
1abe9760ab gpu: Change the way clip rectangles are processed
Instead of just iterating over all the rectangles of the region,
always draw the first rectangle of the region and subtract it when done.

This sounds more complicated, but it will allow us to modify the
rectangle in future commits.
2024-08-07 23:26:03 +02:00
Benjamin Otte
9a4d8453ed gpu: Remove unused argument
the clip is already available via node->scissor so no need to track
that.
2024-08-07 23:26:03 +02:00
Benjamin Otte
b637c3e201 gpu: Pass the clip region even further down
We are now handling the region inside the nodeprocessor.
2024-08-07 23:26:03 +02:00
Benjamin Otte
292f54dd60 gpu: Split out render function
Makes the code easier to understand
2024-08-07 23:26:03 +02:00
Benjamin Otte
1328c1409a gpu: Make the region argument transfer full
I want to modify the region while using it, and everybody destroys it
right after, so now there's no need to do a copy.
2024-08-07 23:26:03 +02:00
Benjamin Otte
dbeddd4417 gpu: Always pass a clip region to render()
This way, we can remove the code that checks for its existence in that
function, making the code simpler.
2024-08-07 23:26:03 +02:00
Benjamin Otte
add5dec4a9 rect: Add another utility function
Add gsk_rect_to_cairo_shrink() to match gsk_rect_to_cairo_grow()
2024-08-07 23:26:03 +02:00
Benjamin Otte
97b51dc070 inspector: Print opaque rect of nodes
Also change the way rectangles are printed by including the bottom right
coordinate, too.

I'm still not sure what the best way is, but at least I no longer get
confused and it has the infos I want.
2024-08-07 23:26:03 +02:00
Benjamin Otte
88c9a30f77 testsuite: Half the runtime of offscreens test
It times out too much in CI.
2024-08-07 23:26:03 +02:00
Marek Kasik
83035c1d4b printeroptionwidget: Maintain cursor position in combo-entry
Maintain cursor position even if the text in the entry has been filtered.
This is achieved by maintaining the same position with respect to
the end of the text buffer as we suppose that the text after the cursor
hasn't changed. This is measured in characters not bytes.

Fixes #6782
2024-08-07 20:26:57 +02:00
Matthias Clasen
50c19a6534 Merge branch 'hdr-content' into 'main'
gsk: Track whether nodes require wide gamut

See merge request GNOME/gtk!7575
2024-08-07 17:34:02 +00:00
Benjamin Otte
5c071cb02e dmabuf: Fix a check
We were comparing with destination stride, not with source stride, and
in rare cases when those were different, this would trigger aborts in
the testsuite.
2024-08-07 19:06:02 +02:00
Matthias Clasen
6edb526561 Merge branch 'plug-gtask-leaks' into 'main'
Plug GTask leaks

See merge request GNOME/gtk!7551
2024-08-07 16:26:52 +00:00
Matthias Clasen
ee18156675 gsk: Add gsk_render_node_is_hdr
Add a function that tracks whether a render node's content is
in a wide gamut color state (in practice, that means non-sRGB).

This will be used in render_texture to determine the color
state to use when creating a texture.
2024-08-07 11:14:21 -04:00
Matthias Clasen
e70a961ac1 Merge branch 'matthiasc/for-main' into 'main'
memoryformat: Add a debug helper

See merge request GNOME/gtk!7571
2024-08-07 14:51:05 +00:00
Matthias Clasen
ffdc8c8f60 gsk: Drop some unused code
Nobody is using gsk_gpu_download_png_op, and we are going to
refactor the download op code.
2024-08-07 08:39:53 -04:00
Matthias Clasen
fd78bd3eaf memoryformat: Add a debug helper
I need this often enough that I'll just put it here.
2024-08-07 08:22:05 -04:00
Matthias Clasen
f2ccba0988 Merge branch 'wip/test-parser-data-additions' into 'main'
testsuite: add more files to test_data

See merge request GNOME/gtk!7569
2024-08-07 03:30:20 +00:00
Jeremy Bícha
8ee465c630 testsuite: add more files to test_data 2024-08-06 20:28:58 -04:00
Matthias Clasen
31b655c9eb Merge branch 'wip/dont-leak-egl-surface' into 'main'
gdk/surface: Don't leak the EGLSurface

See merge request GNOME/gtk!7568
2024-08-06 22:54:31 +00:00
Jonas Ådahl
7fd65cc3c1 gdk/surface: Don't leak the EGLSurface
Each time we create a new window, we create a new EGLSurface. Each time
we destroy a window, we failed to destroy the EGLSurface, due to passing
a GdkDisplay instead of a EGLDisplay to eglDestroySurface().

This effectively leaked not only the EGL surface metadata, but also the
associated DMA buffers. For applications where one opens and closes many
windows over the lifetime of the application, and where the application
runs for a long time; for example a terminal emulator server, this
causes a significant memory leak, as the memory will only ever be freed
once once the application process itself exits, if ever.

Fix this passing an actual EGLDisplay instead of an GdkDisplay, to
eglDestroySurface().
2024-08-06 23:42:11 +02:00
Jonas Ådahl
8089222fc3 gsk/gpu/downloadop: Include glib-unix.h
It's needed by g_close().
2024-08-06 23:41:46 +02:00
Benjamin Otte
0667bd39fb Merge branch 'wip/otte/for-main' into 'main'
gpu: Consult target colorstate for depth

See merge request GNOME/gtk!7567
2024-08-06 21:07:44 +00:00
Benjamin Otte
a4854dfa9e memoryformat: Use "(p)" as premultiplied indicator in names
This matches what the gpu renderer does when printing
colorstates.

It also avoids it printing "S*RGBA8" for the format and instead prints
"SRGBA8(p)" now.
2024-08-06 22:15:17 +02:00
Benjamin Otte
6c54d0a7e2 gpu: Consult target colorstate for depth
When creating images for use with different colorstates, ensure that
they have the depth of that colorstate. Otherwise we might lose accuracy
due to quantization.

Fixes mipmaps in rec2100 being rendered as RGBA8.
2024-08-06 22:15:17 +02:00
Matthias Clasen
341860eb4d Merge branch 'small-fixes' into 'main'
colorstate: Drop xyz for now

See merge request GNOME/gtk!7565
2024-08-06 20:06:38 +00:00
Matthias Clasen
876445f080 inspector: Show color states of textures 2024-08-06 15:38:31 -04:00
Matthias Clasen
03ef6a7719 colorstate: Drop xyz for now
Converting to and from xyz turns out to be more difficult than
expected, depending on what whitepoint you choose, And different
specs choose different whitepoints, so we can't directly map
css xyz to cicp xyz anyway.
2024-08-06 15:38:31 -04:00
Benjamin Otte
fde8c6df79 Merge branch 'wip/otte/for-main' into 'main'
rendrenodeparser: Use simpler function

See merge request GNOME/gtk!7564
2024-08-06 16:18:13 +00:00
Benjamin Otte
6c06e1855e roaring: Fix a compiler warning
This is a simple fix, I did not investigate if NULL is actually possible
here.

In function ‘bitset_container_empty’,
    inlined from ‘bitset_container_const_nonzero_cardinality’ at ../gtk/roaring/roaring.h:1942:13,
    inlined from ‘container_nonzero_cardinality’ at ../gtk/roaring/roaring.h:4055:20,
    inlined from ‘roaring_bitmap_lazy_xor’ at ../gtk/roaring/roaring.c:9727:17:
../gtk/roaring/roaring.h:1928:13: error: potential null pointer dereference [-Werror=null-dereference]
 1928 |   if (bitset->cardinality == BITSET_UNKNOWN_CARDINALITY) {
      |       ~~~~~~^~~~~~~~~~~~~
2024-08-06 17:53:41 +02:00
Benjamin Otte
c60ae0b575 textview: Fix compiler warning
../gtk/gtktextview.c: In function ‘gtk_text_view_add_default_attributes’:
../gtk/gtktextview.c:10681:8: error: potential null pointer dereference [-Werror=null-dereference]
2024-08-06 17:50:57 +02:00
Benjamin Otte
e58f9ea1b4 rendrenodeparser: Use simpler function
We don't need to peek tokens.
2024-08-06 17:50:43 +02:00
Matthias Clasen
2960bb7cb2 Add a compare test for colorstates in borders 2024-08-06 07:35:00 -04:00
Matthias Clasen
161c0f0963 inspector: Show more detail for border nodes
Show the color state, and create textures with the full color
information.
2024-08-06 07:35:00 -04:00
Matthias Clasen
3002591d08 gtk: Use new border snapshot api
Preserve color states from css as much as possible.
2024-08-06 07:35:00 -04:00
Matthias Clasen
1b2b9726f8 gtk: Add gtk_snapshot_append_border2
This is a private snapshot function that uses the new constructor
to create a border node with the given GdkColors.
2024-08-06 07:35:00 -04:00
Matthias Clasen
a3691d311b nodeparser: Support color states in border nodes
Test included.
2024-08-06 07:35:00 -04:00
Matthias Clasen
89d449352f testsuite: Replay border nodes properly
Use the new apis for this.
2024-08-06 07:35:00 -04:00
Matthias Clasen
e220e6dae7 gsk: Use private border node api
Use the GdkColors returned by this function instead of assuming
the colors of a border node are always sRGB.
2024-08-06 07:35:00 -04:00
Matthias Clasen
bd3d1f7715 gsk: Add private border node api
Add a constructor that takes GdkColors, and a getter for those.

To support the existing api, we convert the colors to GdkRGBA
as needed.
2024-08-06 07:35:00 -04:00
Matthias Clasen
f3ffa99f6a gsk: Change the border op api
Pass the ccs, opacity and GdkColors to the op to let it make
decisions about color conversion. Also, reorder the offset to
follow the same order as the color ops.

Update the callers.
2024-08-06 07:35:00 -04:00
Matthias Clasen
3d55d733dc Merge branch 'fix-premul-for-colorize' into 'main'
Colors are always unpremultiplied

See merge request GNOME/gtk!7563
2024-08-06 11:33:38 +00:00
Matthias Clasen
582dba54b1 Try to fix win32 build of compare-render 2024-08-06 07:10:04 -04:00
Matthias Clasen
0775432ed9 Add a compare test for premultiplied colors
This test checks a that a specific combination of mask with alpha
inside opacity works as expected. We were treating the mask color
as premultiplied here, although it isn't.
2024-08-06 00:59:23 -04:00
Matthias Clasen
d9e15ff6e9 Colors are always unpremultiplied
We can't use gsk_gpu_node_processor_color_states_self() for ops which
apply alt to colors that don't come from textures, since those are
always unpremultiplied.

This fixes the + and - in disabled spin buttons appearing completely
white.
2024-08-06 00:59:23 -04:00
Matthias Clasen
c04edfc76e Merge branch 'matthiasc/for-main' into 'main'
rewrite color parsing in the node parser

See merge request GNOME/gtk!7560
2024-08-06 04:54:04 +00:00
Matthias Clasen
71d6392572 nodeparser: Rewrite the color parsing
Use gtk_css_parser_consume_function, for better error handling.
We are now getting the expected error for

  color(srgb 1 2 3 4 5 6)

Test included.
2024-08-06 00:23:07 -04:00
Matthias Clasen
dbd16cd9da Rename GDK_COLOR_INIT_SRGB
Rename the macro to GDK_COLOR_SRGB, and make it usable as
a compound literal as well.

Update all users.
2024-08-06 00:06:41 -04:00
Matthias Clasen
950d266894 Merge branch 'wip/chergert/fix-6133-commit-funcs' into 'main'
textbuffer: Add GtkTextBufferCommitNotify

Closes #6133

See merge request GNOME/gtk!7524
2024-08-06 01:41:23 +00:00
Matthias Clasen
884974eeaa Merge branch 'matthiasc/for-main' into 'main'
gsk: Improve handling of fill and stroke nodes

See merge request GNOME/gtk!7559
2024-08-05 21:01:54 +00:00
Christian Hergert
e836166664 textbuffer: Add GtkTextBufferCommitNotify
Add a new function callback called GtkTetBufferCommitNotify to be notified
of changes to a GtkTextBuffer without being involved in a signal chain.

This is necessary for some situations because signal handlers may modify
the parameters as they proceed down to default handler. As such, the signal
is unsuitable for applications heavily utilizing plug-ins such as Builder
due to non-deterministic signal connection ordering.

This technique has been used in Builder for the better part of a decade
and now would also vastly help in situations like libspelling where you
also want to know about changes to the buffer right before they are
committed to the b-tree.

Fixes: #6133
2024-08-05 13:28:59 -07:00
Matthias Clasen
c1a99bf901 tests: Link compare-render statically
This is a temporary change, only needed until we make the new
snapshot and rendernode apis public.
2024-08-05 16:09:42 -04:00
Matthias Clasen
f9c9a03404 gsk: Improve handling of fill and stroke nodes
Use GdkColor here. We still convert to sRGB as the last step, though.
2024-08-05 15:59:28 -04:00
Matthias Clasen
3a337824e6 Merge branch 'css-color-hookup-1' into 'main'
Add GdkColor, make non-srgb css colors work for color nodes

See merge request GNOME/gtk!7546
2024-08-05 16:11:39 +00:00
Matthias Clasen
7dab23e38a gl: Handle color nodes with color states
Since we don't have proper color management here, just convert
any color we meet to sRGB and hope for the best.
2024-08-05 11:11:15 -04:00
Matthias Clasen
78935ec83c Make node-format.md part of the docs
This makes useful information more easily available, and it also
serves to validate the markdown.
2024-08-05 11:11:15 -04:00
Matthias Clasen
b8989b7ff6 Add a compare test for color states
This checks that the red values in all 4 default color states
come out identical to a plain old red png.
2024-08-05 11:11:15 -04:00
Matthias Clasen
96cd47d0a0 inspector: Show more color node details
Show the color state, and create textures with the full color
information.
2024-08-05 11:11:15 -04:00
Matthias Clasen
d6a6cfe6c5 gtk: Fix gtk_snapshot_collect_repeat
This creates a new color node that is meant to be identical to
an existing one, so we need to use gsk_color_node_new2 to preserve
the color state information.

Test included.
2024-08-05 11:11:15 -04:00
Matthias Clasen
501356116d gtk: Preserve css background color spaces
When rendering css backgrounds, use the new gtk_css_color_get_color
and gtk_snapshot_append_color2 apis to preserve color spaces as
far as possible.
2024-08-05 11:11:15 -04:00
Matthias Clasen
e11e5525db gtk: Add gtk_snapshot_append_color2
This is a private snapshot function that uses the new color
node constructor to create a color node with a given color state.
2024-08-05 11:11:15 -04:00
Matthias Clasen
16431da3f2 nodeparser: Add support for cicp color states
Allow defining cicp color states with an @-rule:

    @cicp "jpeg" {
      primaries: 1;
      transfer: 13;
      matrix: 6;
      range: full;
    }

And allow using them in color() like this:

    color("jpeg" 50% 0.5 1 / 75%)

Note that custom color states use a string, unlike default color
states which use an ident.

Test included.
2024-08-05 11:11:15 -04:00
Matthias Clasen
842949fcf3 nodeparser: Support color states
And allow using color states for colors with a syntax similar
to modern css color syntax.

color(srgb 50% 0.5 1 / 75%)

Both floating point numbers and percentages can be used.

Currently, this is only supported for color nodes.

Test included.
2024-08-05 11:11:15 -04:00
Matthias Clasen
3d3e935c91 offload: Use gsk_color_node_get_color2
We want the blackest black.
2024-08-05 11:11:15 -04:00
Matthias Clasen
d5ae94ca5d testsuite: Update replay nodes
We can't currently recreate color nodes with public api, so cheat
and reuse the node we got.
2024-08-05 11:11:15 -04:00
Matthias Clasen
87e9c940a4 gsk: Use the private color node api
Use the color state returned by this function instead of assuming
the color of a color node is always sRGB.

Node colors are converted to the css on the cpu. That is necessary
since we don't know if they are in one of the default color states,
and our shaders can't deal with non-default color states.
2024-08-05 11:11:14 -04:00
Matthias Clasen
6a02fa4be8 gsk: Add private color node api
Add a constructor that takes a color state, a getter for it, and
also a getter for the color coordinates that avoids GdkRGBA.
2024-08-05 11:11:14 -04:00
Matthias Clasen
9f548efd32 gsk: Change color op apis
Make color-related ops take the ccs and a GdkColor, and make
decisions about color conversion on the cpu vs the gpu.

This makes the node processor code simpler, and lets use convert
the color directly into the op instance without extra copying.

We also pass opacity to the op, so it can be applied when we
write the color into the instance.

Lastly, rorder the offset to come right after the opacity argument.

Treat the color and rounded color ops the same way.

Update all callers.

With this, the prepare_color apis in gskgpunodeprocessor.c are
no longer used and have been dropped.
2024-08-05 11:11:14 -04:00
Matthias Clasen
9eebe8e547 gsk: Change the clear op api
A clear op is just a fancy memcpy. Make it the callers responsibility
to convert the color to the right color state before passing it
to the clear op.
2024-08-05 11:11:14 -04:00
Matthias Clasen
f9612533c2 css: Add gtk_css_color_to_color
This api lets one obtain a color state and color values from
a GtkCssColor. We don't want to force everything though sRGB,
but we can't quite avoid conversion here, since we don't have
a 100% match between the css color spaces and color states.

css color cleanup
2024-08-05 11:11:14 -04:00
Matthias Clasen
c9c0d444a2 cairo: Add gdk_cairo_set_source_color
This lets us set a GdkColor as a cairo source.
2024-08-05 11:11:14 -04:00
Matthias Clasen
13a8704f51 Add GdkColor
For now, this is all private api.

Parts of it will be opened up in 4.18.
2024-08-05 11:11:14 -04:00
Arjan Molenaar
f20714262c Merge branch 'macos-fix-window-transparency' into 'main'
macos: fix window transparency

Closes #6838

See merge request GNOME/gtk!7544
2024-08-05 12:20:32 +00:00
Matthias Clasen
11ffeeb55c Merge branch 'wip/otte/for-alice' into 'main'
Fix warning on startup

See merge request GNOME/gtk!7547
2024-08-05 12:18:00 +00:00
Sergey Bugaev
85830c059e Plug GTask leaks
The error-prone pattern seems to be:

  GTask *task = g_task_new (...);

  if (condition)
    {
      g_task_return_... (task, ...);
      /* need g_object_unref (task) here! */
      return;
    }

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2024-08-05 14:38:23 +03:00
Matthias Clasen
ffc89e40a0 colorstate: Add a color conversion function
Add a function for converting a single color from one
color state to another. This is a generalization of the
already existing function to convert a GdkRGBA to another
color state.
2024-08-04 14:21:15 -04:00
Matthias Clasen
1c92f2d963 Merge branch 'matthiasc/for-main' into 'main'
Disable blur-performance build

See merge request GNOME/gtk!7549
2024-08-04 02:52:53 +00:00
Matthias Clasen
12e0ec0b48 Add gtk_css_parser_has_percentage 2024-08-03 22:31:32 -04:00
Matthias Clasen
5574bf59f6 Disable blur-performance build
This is an old test that isn't very relevant anymore, and it has
some linking problems because it includes private headers that
have inlined functions.
2024-08-03 22:31:21 -04:00
Matthias Clasen
7ee27cc0ad Merge branch 'matthiasc/for-main' into 'main'
gpu: Rename function

See merge request GNOME/gtk!7548
2024-08-04 01:23:41 +00:00
Benjamin Otte
040974c8a2 iconhelper: Size no longer depends on scale
This is a leftover from GTK3 when iconhelper sizes depended on the
texture size.

Now we only need to queue a redraw with the new icon.

Fixes warnings about resizes during allocate caused by scale change
notification during allocation of GtkWindow.
2024-08-04 03:11:56 +02:00
Benjamin Otte
126d689086 gpu: Rename function
We want to reuse gsk_gpu_color_to_float() for use with GdkColor and this
function will be replaced. But until that's fully done, we need 2
different names.

So rename this one to something else
2024-08-03 20:59:40 -04:00
Benjamin Otte
8e676c7360 windowcontrols: No need to listen to scale factor changes
This is a GTK3 leftover where the icons were manually drawn and sized.
Now that they're managed by actual widgets that enforce a correct size
that is independent of scale factor, this is no longer necessary.

Fixes warnings about resizes during allocate caused by scale change
notification during allocation of GtkWindow.
2024-08-04 01:23:07 +02:00
Arjan Molenaar
84847e46fa macos: fix window transparency
Revert window decoration changes from
a6ce506714.
2024-08-02 17:30:48 +02:00
Matthias Clasen
3fca84f974 Merge branch 'matthiasc/for-main' into 'main'
Fix a copy-paste error

See merge request GNOME/gtk!7543
2024-08-02 13:45:40 +00:00
Matthias Clasen
2be48a8f86 Pass ccs to the cairo blur code
This is needed to set the color properly.
2024-08-02 09:13:41 -04:00
Matthias Clasen
389d246af8 Fix up the blur-performance test
Add a hack to work aroundt he fact that the blur performance test
includes private headers which inline accesses to non-exported
variables.
2024-08-02 09:12:37 -04:00
Matthias Clasen
9e0f41bd05 Fix a copy-paste error
We were using the wrong api to get the color of an outset shadow
node. This just worked by luck.
2024-08-02 09:00:51 -04:00
Matthias Clasen
564a237454 Merge branch 'matthiasc/for-main' into 'main'
Cosmetics: Remove a leftover line

See merge request GNOME/gtk!7540
2024-08-01 22:24:55 +00:00
Matthias Clasen
86b59ba643 Cosmetics: Remove a leftover line
This looks just like a copy-paste leftover. Suprisingly, it compiled
just fine and worked too.
2024-08-01 17:19:50 -04:00
Matthias Clasen
487e568722 Merge branch 'matthiasc/for-main' into 'main'
vulkan: Don't try srgb for the atlas

Closes #6887

See merge request GNOME/gtk!7539
2024-08-01 19:40:00 +00:00
Matthias Clasen
67080dab21 vulkan: Don't try srgb for the atlas
This makes the Emoji rendering come out wrong.

Fixes: #6887
2024-08-01 14:43:49 -04:00
Benjamin Otte
0809e6585d Merge branch 'wip/otte/for-main' into 'main'
vulkan: Add error checking in a place

See merge request GNOME/gtk!7538
2024-08-01 11:14:12 +00:00
Benjamin Otte
809b98c96e vulkan: Don't leak fds
It makes sense to close the fds before doing an early return.
D'oh.
2024-08-01 12:51:46 +02:00
Benjamin Otte
059af1365a vulkan: Add error checking in a place
Doesn't hurt to have, but I just added it while debugging something
unrelated.
2024-08-01 12:51:46 +02:00
Matthias Clasen
fbcffb36c8 Merge branch 'matthiasc/for-main' into 'main'
Drop debug code

See merge request GNOME/gtk!7536
2024-08-01 01:31:16 +00:00
Matthias Clasen
3af0cfb53b Drop debug code
The dmabuf download code for P010 had a hack left in it that
was preventing it from working.
2024-07-31 21:08:14 -04:00
Matthias Clasen
96422fcf52 Merge branch 'no-cursor-viewport' into 'main'
wayland: No viewporter for cursors

See merge request GNOME/gtk!7531
2024-07-31 20:23:34 +00:00
Matthias Clasen
2754f2be2d Merge branch 'test-cal-31' into 'main'
ci: avoid another date-dependent failure

See merge request GNOME/gtk!7535
2024-07-31 20:12:16 +00:00
Marek Kasik
6435d5083a printeroptionwidget: Update on combo-entry change
Connect to "changed" signal of the entry displayed with combobox
for some options (e.g. watermark text or passcode). This ensures
that the strings are propagated to the printer backend.

Fixes #6782
2024-07-31 16:59:11 +02:00
Matthias Clasen
3d802177be wayland: No viewporter for cursors
The outlook for mutter supporting this in GNOME 47 are cloudy,
so lets flip the switch back. You can still set
USE_POINTER_VIEWPORT in the environment to try this code.
2024-07-31 07:44:48 -04:00
Matthias Clasen
a02d4ba2a1 Merge branch 'matthiasc/for-main' into 'main'
dmabuf: Fix the disjointness check

See merge request GNOME/gtk!7529
2024-07-31 05:04:02 +00:00
Matthias Clasen
249cf0833c dmabuf: Fix the disjointness check
We were checking the wrong fds here.

This came up while toying with udmabuf and creating multi-plane
NV12 buffers.
2024-07-30 23:44:07 -04:00
Jeremy Bícha
20b00d3947 ci: avoid another date-dependent failure
Set the day before setting the month to avoid
failure when running the test on the 31st day of a month
2024-07-30 15:50:12 -04:00
Matthias Clasen
269dcaaadf Post-release version bump 2024-07-30 15:14:25 -04:00
Matthias Clasen
322bbd2376 4.15.4 2024-07-30 12:50:22 -04:00
Benjamin Otte
52bec248ce Merge branch 'wip/otte/for-main' into 'main'
gpu: Fix shadows even more

See merge request GNOME/gtk!7527
2024-07-30 16:29:59 +00:00
Benjamin Otte
9f71528a05 gpu: Fix shadows even more
Math is hard.

But this time, it comes with a test!
2024-07-30 18:01:45 +02:00
Benjamin Otte
65e02a3bae Merge branch 'wip/otte/for-main' into 'main'
gpu: Fix shadows some more

Closes #6896

See merge request GNOME/gtk!7526
2024-07-30 14:48:34 +00:00
Benjamin Otte
defc4d335e gpu: Fix shadows some more
It turns out the "step" variable could up as 0 when p.y ~= 3.0 ||
p.y ~= r.y - 3.0
That was not enough to trigger it though because if "start" and "end"
were the same value, the "y <= end" check in the loop would immediately
terminate it.

However, if start + epsilon == end so that end != start but (end - start)
/ 7 == 0, then step would end up as 0 and the loop would never
terminate.

And if that happened, it would bring down GPUs.
So recode this whole machinery to make it impossible to infloop.

Fixes #6896
2024-07-30 16:09:38 +02:00
Benjamin Otte
bdcfcfa5b9 Merge branch 'wip/otte/for-main' into 'main'
gpu: Draw proper shadows again

Closes #6888

See merge request GNOME/gtk!7518
2024-07-30 00:19:37 +00:00
Benjamin Otte
4a94c91772 gpu: Don't blur tiny blur radii
We get those wrong, and there's not really a visual effect.

And since we do a check anyway, just disallow them and treat them as
unblurred.
2024-07-30 01:50:56 +02:00
Benjamin Otte
cc3ed89e34 gpu: Draw proper shadows again
The fix in commit 5e7f227d broke shadows while trying to make them
faster.
So use a better way to make them faster.

With the normalized blur radius, we can now conclude that all the values
too far from p.y will cause the gauss() call to return close to 0, so we
can skip any y value that is too far from p.y.

And that allows us to put an upper limit on the loop iterations.

Tests included

Fixes #6888
2024-07-30 01:50:56 +02:00
Arjan Molenaar
f0925e4ef2 docs: Update function docs for gdk_event_triggers_context_menu
Include macOS, make code snipper easier identifyable.
2024-07-29 20:07:13 +02:00
Arjan Molenaar
df87b1820b macos: Add Ctrl+left-click mapping for context menus
Update GdkEvent.triggers_context_menu to trigger a context menu
on macOS.
2024-07-29 19:59:29 +02:00
Benjamin Otte
87e8265a2d Merge branch 'wip/otte/colomplications' into 'main'
wayland: Do not use compositor-provided image descriptions

See merge request GNOME/gtk!7522
2024-07-29 17:56:41 +00:00
Matthias Clasen
9fd6d431e3 Merge branch 'fix-ephy-crash' into 'main'
subsurface: Avoid a crash

Closes #6891

See merge request GNOME/gtk!7521
2024-07-29 17:39:05 +00:00
Benjamin Otte
5059ae1d7b gpu: Simplify box-shadow shader
Instead of doing complicated math, normalize the values to a sigma
of 1.0, and then use that.
This should also be beneficial for shader performance, because 1.0 is a
constant and constant-elimination can kick in on the inlined functions.
2024-07-29 19:14:10 +02:00
Benjamin Otte
50bb42f0f3 gl: Don't crash on box shadows with negative scales
Some places didn't fabs() the scale values properly, leading to
assertions when offscreens with negative sizes were created.
2024-07-29 19:14:10 +02:00
Benjamin Otte
d71a7c901d wayland: Do not use compositor-provided image descriptions
When the compositor sends us an image description, we currently happily
reuse it.

However, those image descriptions may contain optional properties that
we do not handle - example: reference white level. So if we were to
reuse that image description, we would set a wrong reference white
level.

To avoid issues like that, never use compositor-provided image
descriptions.

However, query those image descriptions and map them to the closest
GdkColorState, so that we can quickly look up *our* version of that
image description and use that one.
2024-07-29 18:45:41 +02:00
Matthias Clasen
65f727731c subsurface: Avoid a crash
When finalizing a subsurface, we need to make sure it is removed
from the sibling lists in its parent, or bad things will happen.

This should crashes seen in Epiphany nightly.

Fixes: #6891
2024-07-29 11:54:10 -04:00
Matthias Clasen
ff60b19e4b Merge branch 'matthiasc/for-main' into 'main'
image-tool: Add an --undecorated option

See merge request GNOME/gtk!7520
2024-07-29 15:52:42 +00:00
Matthias Clasen
b8f12c5d28 cicp: Improve the docs
Fix some formatting issues, and document GdkCicpRange.
2024-07-29 11:17:13 -04:00
Matthias Clasen
bfb779ac2f gsk: Add missing cicp transfer functions
This was overlooked in 50ea9450ea.
2024-07-29 10:35:32 -04:00
Matthias Clasen
84c28d2efb image-tool: Add an --undecorated option
This is useful if you want to debug things and don't want to end
up in the decoration rendering code paths.
2024-07-29 08:13:21 -04:00
Matthias Clasen
06372c5f2a Merge branch 'matthiasc/for-main' into 'main'
Fix indirect color state conversions

See merge request GNOME/gtk!7519
2024-07-29 11:11:28 +00:00
Matthias Clasen
3d75292c4d Fix indirect color state conversions
convert_func2 is a 'from' conversion function, ie it expects to
be passed the target color state. This was wrong both in
gdk_memory_convert and gdk_memory_convert_color_state.
2024-07-28 23:40:59 -04:00
Matthias Clasen
541ffbe4b5 Merge branch 'matthiasc/for-main' into 'main'
gst: Fix a wrong unref function

See merge request GNOME/gtk!7517
2024-07-28 23:35:16 +00:00
Matthias Clasen
17524f2794 gst: Fix a wrong unref function
Use gdk_color_state_unref on a color state.
2024-07-28 19:09:05 -04:00
Matthias Clasen
1040d7c7e4 Merge branch 'matthiasc/for-main' into 'main'
cicp: Fill in some more transfer functions

See merge request GNOME/gtk!7515
2024-07-28 20:51:40 +00:00
Matthias Clasen
1b53359cd3 Merge branch 'wip/smcv/ubsan' into 'main'
Avoid undefined behaviour in a few simple cases

See merge request GNOME/gtk!7508
2024-07-28 20:00:06 +00:00
Matthias Clasen
1987738d16 Merge branch 'wip/smcv/c11' into 'main'
README: Officially require C11, matching GLib 2.81.x

See merge request GNOME/gtk!7516
2024-07-28 19:58:51 +00:00
Benjamin Otte
b8890ca27d Merge branch 'wip/smcv/warnings' into 'main'
Fix compiler warnings on 32-bit

See merge request GNOME/gtk!7507
2024-07-28 18:40:46 +00:00
Benjamin Otte
2e7916cf4f Merge branch 'wip/smcv/align-gsk-ops' into 'main'
gskpathop: Align graphene_point_t to match gskpathop assumptions where required

Closes #6395

See merge request GNOME/gtk!7510
2024-07-28 17:54:35 +00:00
Simon McVittie
24cf5b6df8 README: Officially require C11, matching GLib 2.81.x
Previously GTK required a C99 compiler, but as discussed on
GNOME/gtk!7510 there's at least one anonymous union in public API
(in `GskPathPoint`), and that's a C11 feature.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-28 17:47:47 +01:00
Simon McVittie
214f5a6f98 gskpathop: Introduce a type to represent an aligned graphene_point_t
When we allocate a graphene_point_t on the stack, there's no guarantee
that it will be aligned at an 8-byte boundary, which is an assumption
made by gsk_pathop_encode() (which wants to use the lowest 3 bits to
encode the operation). In the places where it matters, force the
points on the stack and embedded in structs to be nicely aligned.

By using a distinct type for this (a union with a suitable size and
alignment), we ensure that the compiler will warn or error whenever we
can't prove that a particular point is, in fact, suitably aligned.
We can go from a `GskAlignedPoint *` to a `graphene_point_t *`
(which is always valid, because the `GskAlignedPoint` is aligned)
via &aligned_points[0].pt, but we cannot go back the other way
(which is not always valid, because the `graphene_point_t` is not
necessarily aligned nicely) without a cast.

In practice, it seems that a graphene_point_t on x86_64 *is* usually
placed at an 8-byte boundary, but this is not the case on 32-bit
architectures or on s390x.

In many cases we can avoid needing an explicit reference to the more
complicated type by making use of a transparent union. There's already
at least one transparent union in GSK's public API, so it's presumably
portable enough to match GTK's requirements.

Increasing the alignment of GskAlignedPoint also requires adjusting how
a GskStandardContour is allocated and initialized. This data structure
allocates extra memory to hold an array of GskAlignedPoint outside the
bounds of the struct itself, and that array now needs to be aligned
suitably. Previously the array started with at next byte after the
flexible array of gskpathop, but the alignment of a gskpathop is only
4 bytes on 32-bit architectures, so depending on the number of gskpathop
in the trailing flexible array, that pointer might be an unsuitable
location to allocate a GskAlignedPoint.

Resolves: https://gitlab.gnome.org/GNOME/gtk/-/issues/6395
Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-28 17:31:41 +01:00
Matthias Clasen
50ea9450ea cicp: Fill in some more transfer functions
Handle gamma 2.2 and gamma 2.8.
2024-07-28 11:56:43 -04:00
Matthias Clasen
d2028c7323 Cosmetics 2024-07-28 11:33:39 -04:00
Benjamin Otte
76c1ea0449 Merge branch 'wip/smcv/gsize-is-guintptr' into 'main'
gdk: Codify the requirement that gsize is pointer-sized

See merge request GNOME/gtk!7514
2024-07-28 14:12:59 +00:00
Simon McVittie
a97f378d64 gdk: Codify the requirement that gsize is pointer-sized
This is widely assumed, but is not guaranteed by Standard C, and is
known to be false on CHERI architectures (which have 64-bit sizes and
128-bit tagged pointers). Add a static assertion to ensure that GTK
will not build on platforms where this assumption does not hold.

As discussed on GNOME/gtk!7510, if GTK switches from gsize to uintptr_t
as its representation of the underlying bits in a pointer, GTK maintainers
would prefer that to be done project-wide so that it's done consistently,
after which this static assertion could be removed.

At the time of writing, GLib makes the same assumption (GNOME/glib#2842),
but GLib contributors are gradually removing it (mostly by replacing gsize
with uintptr_t where a pointer-sized quantity is needed). Finishing
that work in GLib would be a prerequisite for being able to make GTK
work on the affected platforms.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-28 14:31:31 +01:00
Matthias Clasen
ffe82b7641 Merge branch 'wip/smcv/ubsan-half-float' into 'main'
gsk, testsuite: Avoid undefined behaviour converting float <-> fp16

See merge request GNOME/gtk!7509
2024-07-28 02:59:59 +00:00
Matthias Clasen
785709d51c Merge branch 'matthiasc/for-main' into 'main'
Cosmetics

See merge request GNOME/gtk!7512
2024-07-28 02:55:57 +00:00
Matthias Clasen
8406c34166 Cosmetics 2024-07-27 22:11:39 -04:00
Matthias Clasen
2ee1f3e8cf Merge branch 'matthiasc/for-main' into 'main'
image-tool: Allow specifying cicp tuples

See merge request GNOME/gtk!7511
2024-07-27 23:45:21 +00:00
Matthias Clasen
1373a7a6f0 Change the matrix implementation
Go from float[3][3] to float[9]. That is easier to manage in
static initialization.
2024-07-27 19:20:14 -04:00
Matthias Clasen
a5aac30843 jpeg: Load grayscale as-is
We can handle grayscale textures just fine nowadays, so no need to
convert them to RGB.
2024-07-27 19:20:14 -04:00
Matthias Clasen
3149493679 jpeg: Set downloader color state explictly
This avoids surprises.
2024-07-27 19:02:59 -04:00
Matthias Clasen
a60cda3daa image-tool: Allow specifying cicp tuples
Accept --cicp=1/13/6/0 and similar to specify color states.
2024-07-27 18:42:39 -04:00
Simon McVittie
660c6c8d6f gsk, testsuite: Avoid undefined behaviour in half_to_float_one()
Similar to the previous commit, to avoid undefined behaviour we need
to avoid evaluating out-of-bounds shifts, even if their result is going
to ignored by being multiplied by 0 later.

Detected by running a subset of the test suite with
-Dsanitize=address,undefined on x86_64.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-27 20:22:09 +01:00
Simon McVittie
ad679187d3 gsk, testsuite: Avoid undefined behaviour in float_to_half_one()
If, for example, e == 0, it is undefined behaviour to compute an
expression involving an out-of-range shift by (125 - e), even if the
result is in fact irrelevant because it's going to be multiplied by 0.

This was already fixed for the memorytexture test in
commit 5d1b839 "testsuite: Fix another ubsan warning", so use the
implementation from that test everywhere. It's in the header as an
inline function to keep the linking of the relevant tests simple:
its only caller in production code is fp16.c, so there will be no
duplication outside the test suite.

Detected by running a subset of the test suite with
-Dsanitize=address,undefined on x86_64.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-27 20:22:09 +01:00
Simon McVittie
b769295682 gtkcssnodedeclaration: Avoid signed left shift by 31 bits
Left-shifting a signed 32-bit integer by 31 bits (such that the value
overflows into the sign bit) is undefined behaviour. Use an unsigned
integer instead.

Detected by running a subset of the test suite with
-Dsanitize=address,undefined on x86_64.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-27 20:16:21 +01:00
Simon McVittie
6649af5ec6 Avoid calling memcpy with n == 0
Some callers of these functions ask to copy 0 items from a NULL source,
which would be valid if they were copied in a loop (because NULL would
never be dereferenced), but is declared to be undefined behaviour for
Standard C memcpy. Guard the call to memcpy so that we only call it
if we have more than 0 items, and therefore should have a non-NULL
source pointer.

Detected by running a subset of the test suite with
-Dsanitize=address,undefined on x86_64.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-27 20:16:21 +01:00
Simon McVittie
ca7094296c gtktimsort: Avoid undefined behaviour on 32-bit
Shifting a 32-bit type by 32 bits is formally undefined behaviour,
even if it happens in code that is unreachable at runtime. Use a
compile-time check against GLib's GLIB_SIZEOF_SIZE_T, instead of hoping
a runtime check will be optimized away.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-27 20:16:21 +01:00
Simon McVittie
15a09c79f9 Fix debug format strings for non-LP64 platforms
Unfortunately the format string for a size_t, `%zu`, is not portable
to all Windows compilers, and the appropriate format string for the
fundamental type that implements size_t varies between platforms
(typically `%u` on 32-bit platforms, `%lu` on 64-bit Linux or
`%llu` on 64-bit Windows).

In gtk-demo, cast the number of search results to long, to avoid
breaking up a translatable string.

Elsewhere, use GLib's abstraction for this.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-27 18:14:31 +01:00
Simon McVittie
e2a7dc5427 vulkan: Fix compiler warnings on 32-bit
Vulkan handles are pointers on 64-bit, but 64-bit integers on 32-bit.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-27 15:14:57 +01:00
Stuart Hayhurst
170f099ce1 textbuffer: Clear paste point override from empty middle clicks
Middle clicking without a selection left a paste point override behind.
This meant actual pastes were going to the location of the middle click,
instead of the cursor

Closes #5530
2024-07-27 12:33:35 +01:00
Benjamin Otte
d301d16aee Merge branch 'wip/otte/for-main' into 'main'
wayland: Redo the image description code

See merge request GNOME/gtk!7505
2024-07-27 06:09:15 +00:00
Benjamin Otte
ec489e673c wayland: Add preferred formats to the hash tables
So we don't look them up all the time.
2024-07-27 07:26:51 +02:00
Benjamin Otte
a904da12b7 wayland: Don't query preferred colorstate if we don't care
If there's no change callback connected, exit early, because all this
lot of work would be for invoking that callback.
2024-07-27 07:26:51 +02:00
Benjamin Otte
91865d172b wayland: Track color information identities
So we don't need to query them all the time.

Or so I thought, because I get different ones for the same colorstate.
Thx Mutter.
2024-07-27 07:26:51 +02:00
Benjamin Otte
adedb89779 wayland: Actually sync the colorstate with the compositor 2024-07-27 07:26:51 +02:00
Benjamin Otte
514dbcacd4 wayland: Actually query the preferred colorstate
We weren't doing that, so everything looked like it wanted SRGB.
2024-07-27 07:26:51 +02:00
Benjamin Otte
25c812fa87 wayland: Redo the image description code
Main changes:

1. Avoid invalid writes by not passing pointers to a GArray that
   realloc()s its data
2. Use a hash table to store image defs, instead of an array. This
   requires a custom hash/equal function
3. Make image desc computation sync, so that setting a cs always
   succeeds or always fails and doesn't depend on timing.
4. Add a few debug messages in failure paths. For lack of a category,
   they ended up in MISC.
2024-07-27 07:26:51 +02:00
Matthias Clasen
45e76c1604 Merge branch 'wip/smcv/a11y-tests' into 'main'
tests: Fix signature of GtkTestATContext::update-selection-bound handlers

Closes #6490

See merge request GNOME/gtk!7504
2024-07-27 04:50:14 +00:00
Matthias Clasen
a9c3163a64 Merge branch 'main' into 'main'
Tests: add GtkPicture builder test

See merge request GNOME/gtk!7486
2024-07-27 03:08:15 +00:00
Simon McVittie
a8bb71383a tests: Fix signature of GtkTestATContext::update-selection-bound handlers
The signal is declared in GtkTestATContext with 0 parameters, but these
handlers were written as if the signal had one `guint` parameter.
On some architectures this accidentally works as intended, but on
others (reproduced on i386 and riscv64) the test tries to use arbitrary
stack contents as the `TestData *` and crashes when it tries to
dereference the resulting non-pointer.

Resolves: https://gitlab.gnome.org/GNOME/gtk/-/issues/6490
Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-27 00:59:03 +01:00
Matthias Clasen
3b08f8026e Merge branch 'matthiasc/for-main' into 'main'
jpeg: Port to GdkMemoryTextureBuilder

See merge request GNOME/gtk!7502
2024-07-26 23:09:27 +00:00
Matthias Clasen
2cdc2287a5 Merge branch 'amolenaar/macos-open-panel-create-folders' into 'main'
macos: Propagate the create-folders option also for Open panels

Closes #6872

See merge request GNOME/gtk!7492
2024-07-26 22:35:43 +00:00
Juan Pablo Ugarte
c80c4ee75c Tests: add GtkPicture builder test
Add test for GtkPicture::file GFile property.
2024-07-26 18:30:58 -04:00
Juan Pablo Ugarte
082691ba16 GtkBuilder: add support for paths and relative uris for GFile properties. 2024-07-26 18:30:58 -04:00
Matthias Clasen
d09a610433 Merge branch 'spinbutton-hint' into 'main'
gtkspinbutton: Set number input hint for text field

See merge request GNOME/gtk!7485
2024-07-26 22:05:34 +00:00
Matthias Clasen
ea9f8b2f77 downloader: Add some docs
Mention the default format and color state.
2024-07-26 17:38:27 -04:00
Matthias Clasen
e2d337740f gpu: Don't mess up color states
When uploading textures, we were unintentionally converting to
srgb. Avoid that, so that yuv data survives unmolested.
2024-07-26 17:34:48 -04:00
Matthias Clasen
45c5b250b9 texture: Don't mess up color states
gdk_texture_download_surface was converting twice from the texture
color state to the target color state, with predictably bad results.
2024-07-26 17:27:20 -04:00
Matthias Clasen
f4b35093bd jpeg: Port to GdkMemoryTextureBuilder
This is in preparation for some color state handling.
2024-07-26 16:43:54 -04:00
Matthias Clasen
5e52cefb28 Merge branch 'rtl-label-hickup' into 'main'
label: Clear layout when text direction changes

Closes #6836

See merge request GNOME/gtk!7497
2024-07-26 18:13:28 +00:00
Benjamin Otte
bf43aee690 Merge branch 'wip/otte/for-main' into 'main'
gstreamer: Specify values for unspecified values

See merge request GNOME/gtk!7500
2024-07-26 14:38:01 +00:00
Matthias Clasen
62f359a494 Merge branch 'css-relative-font' into 'main'
css: Fix relative font sizes

Closes #6868

See merge request GNOME/gtk!7498
2024-07-26 14:24:42 +00:00
Benjamin Otte
cbe09373a5 gstreamer: Specify values for unspecified values
When the cicp values coming out of GStreamer are unspecified, replace
them with the default cicp values for YUV video: 1/13/6.

We still may end up with unspecified values inside the params, because
GStreamer returns unspecified for primaries/tfs/matrices that aren't
supported by cicp.

See also https://github.com/AOMediaCodec/libavif/wiki/CICP#unspecified
fora similar discussion.
2024-07-26 15:16:05 +02:00
Matthias Clasen
b3451dda04 css: Fix relative font sizes
This regression was introduced in aeac2b54.

We need percentage values to stay non-computed, since we otherwise
fail to compute relative font sizes properly. But we want percentages
not to stick around in relative colors, so tweak things to be more
aggressive with simplication when creating relative color values.

Update affected tests.

Fixes: #6868
2024-07-26 08:45:58 -04:00
Matthias Clasen
d477bf3d93 Merge branch 'image-tool-side-by-side' into 'main'
image-tool: Allow showing images side-by-side

See merge request GNOME/gtk!7501
2024-07-26 12:08:12 +00:00
Matthias Clasen
12c7f2d4fd Merge branch 'matthiasc/for-main' into 'main'
gpu: More debug spew

See merge request GNOME/gtk!7499
2024-07-26 12:07:55 +00:00
Matthias Clasen
feca09b8a4 image-tool: Allow showing images side-by-side
This is useful for comparisons.
2024-07-26 07:44:31 -04:00
Matthias Clasen
150f57f706 gpu: Fix the cicp conversion
The fragment shader was mixing up pixel and color variables.
And the compilers don't have 'uninitialized variable' warnings :(
2024-07-26 07:24:48 -04:00
Matthias Clasen
33131ad24d gpu: Fix the cicp conversion shader for ngl
The compiler was unhappy with using signed labels with an unsigned
variable in a switch. Talk about being picky.
2024-07-26 07:23:18 -04:00
Matthias Clasen
d53b3f9941 gpu: More debug spew
Print out the direction of the cicp conversion.
2024-07-26 07:22:45 -04:00
Martin
da07f1221f Update Slovenian translation 2024-07-26 09:36:52 +00:00
Matthias Clasen
9aed7ab25f Merge branch 'matthiasc/for-main' into 'main'
Add an image tool

See merge request GNOME/gtk!7496
2024-07-26 03:36:57 +00:00
Matthias Clasen
5ae225fe52 Add an image tool
This is meant to provide a convenient way to produce images in
specific color states and memory formats.
2024-07-25 18:20:59 -06:00
Matthias Clasen
cc8fa39110 tools: Improve localization 2024-07-25 18:20:59 -06:00
Matthias Clasen
c673a0bcc3 label: Clear layout when text direction changes
Otherwise, wrong alignment settings may linger in the layout.

Fixes: #6836
2024-07-25 17:06:58 -06:00
Benjamin Otte
efc6d15dde Merge branch 'wip/otte/for-main' into 'main'
gpu: Don't run long loops in shaders

See merge request GNOME/gtk!7495
2024-07-25 20:42:55 +00:00
Benjamin Otte
50403fbca8 wayland: Actually compare the right values
Wayland primaries/transfer functions aren't cicp values, so we can't
compare them.
2024-07-25 22:06:56 +02:00
Benjamin Otte
7de91d1777 wayland: We use v4 of the protocol 2024-07-25 22:06:56 +02:00
Benjamin Otte
6f9a70bd4e gpu: Add a version of a function
With the changes in !7473 we now use sampler2D arguments in functions.
However, when there's a function we call with a samplerExternalOES -
which means we need to overload it with that shader variant.
2024-07-25 18:53:55 +02:00
Benjamin Otte
de1dfb99bc gpu: Add shader name to error message
When a shader cant be compiled, we produce a long error dump, but
nowhere did we mention the actual shader.

Fix that.
2024-07-25 18:53:55 +02:00
Benjamin Otte
103296d948 gstsink: Make it usable again
The later CICP changes made the cicp params we were setting unustable.

Set ones that work in the current state of git main. They are still
imperfect, but they reflect the current code.
2024-07-25 18:53:55 +02:00
Benjamin Otte
0001562850 dmabuf: Fix Vulkan formats for P010 and friends
The P01x and P21x formats were swapped.
2024-07-25 18:53:55 +02:00
Benjamin Otte
1f3c88b995 build: Skip vulkan parts in generated GLSL
Make the #include parsing script able to skip a predefined list of terms
with #ifdef

Put "VULKAN" in that list to skip the vulkan parts.
2024-07-25 17:32:19 +02:00
Benjamin Otte
5e7f227d92 gpu: Don't run long loops in shaders
If the border radius is too big, take bigger steps when computing the
shadow.

I randomly chose 8 because that looked good and was fast enough.
2024-07-25 17:32:19 +02:00
Arjan Molenaar
6bbda619f9 macos: Propagate the create-folders option also for Open panels
When opening a folder, it may come in handy to create a folder.

Fixes #6872.
2024-07-25 11:32:14 +02:00
Matthias Clasen
e216fa3b6d Merge branch 'cicp-color-states' into 'main'
Fix the hlg transfer function

See merge request GNOME/gtk!7493
2024-07-25 01:19:02 +00:00
Matthias Clasen
c9443dd04d Fix the hlg transfer function
Fix a bug in the formula, and enable hlg as a transfer function.

The tests are passing now.
2024-07-24 18:59:18 -06:00
Matthias Clasen
29cb5051d4 Merge branch 'cicp-color-states' into 'main'
colorstate: Add cicp support

See merge request GNOME/gtk!7453
2024-07-25 00:48:57 +00:00
Matthias Clasen
5f2e70df8e Drop hlg for now
For some reason, roundtrip tests  with the hlg tf are failing,
so we don't support it.
2024-07-24 17:53:12 -06:00
Matthias Clasen
d8775d0194 gsk: Make shader matrices match
We were using slightly different numbers here, which isn't good.

The matrices in gdkcolordefs.h are tested in the colorstate-internal
tests, so they are at least properly inverse, and the products match.

It would be better to generate the glsl definitions, somehow.
2024-07-24 16:45:21 -06:00
Matthias Clasen
8d87ed1a6a Add tests
Add some more texture conversion roundtrips. They are currently
ifdefed out, since they need cicp api.

Also add another test binary for internal tests.
2024-07-24 16:45:21 -06:00
Matthias Clasen
a46bcc2755 Move transfer functions and matrices to a header
This way, we can write tests against them without static linking.
2024-07-24 16:45:21 -06:00
Matthias Clasen
229edc5225 wayland: Normalize cicp values
We don't want to create multiple image descriptions for functionally
equivalent tuples.
2024-07-24 16:45:21 -06:00
Benjamin Otte
b1962de51a gtksink: Add colorstate handling
The part for matrix coefficients and range is commented out so far.

It requires fixes so the dmabuf handling code can properly deal with it.
2024-07-24 16:45:21 -06:00
Matthias Clasen
fb10b61528 gdk: Add public api for cicp
Add a GdkCicpParams object that acts a bit like a builder for
cicp color states.
2024-07-24 16:45:21 -06:00
Matthias Clasen
e415ec9ca5 gsk: Use the cicp convert shader
When we the image color state is not a default one, use the cicp
convert op to convert it to the ccs. And when the target color
state is a non-default one, use the shader in the reverse direction.
2024-07-24 08:16:08 -06:00
Matthias Clasen
226652edb0 gsk: Add a cicp convert shader
This shader receives cicp parameters via uniforms, and converts
the texture data from or to the output colorstate. It computes
the matrix in the vertex shader, and then picks the eotf/oetf
according to the cicp parameters in the fragment shader.
2024-07-24 08:16:08 -06:00
Matthias Clasen
64f4967867 png: Make loader use cicp api
This should make non-default color states work with our png
loading and saving machinery.
2024-07-24 08:16:08 -06:00
Matthias Clasen
c37fa3a895 wayland: Use cicp color states
This is entirely untested, and the Wayland protocol makes it very
annoying.
2024-07-24 08:16:08 -06:00
Matthias Clasen
d907c0a42e colorstate: Add cicp support
This adds machinery to create colorstate objects from cicp
tuples, as well as a function to return a cicp tuple for a
colorstate.

Still missing: a conversion shader for non-default colorstates.
2024-07-24 08:16:08 -06:00
Matthias Clasen
4255230e36 colorstate: Cosmetics
Document a private api.
2024-07-24 07:46:05 -06:00
Matthias Clasen
d8a0915ada colorstate: Slight reorg
Move the conversion functions out of the default section, since
we will reuse the conversion functions for cicp. No functional
changes.
2024-07-24 07:46:05 -06:00
Matthias Clasen
32b348776e memoryformat: Allow indirect conversions
If we don't have a direct conversion function between two
colorstates, go indirectly via rec2100-linear.
2024-07-24 07:46:05 -06:00
Matthias Clasen
bbe552d6a8 Add gdk_color_state_get_convert_from
Our conversion machinery supports converting from any color
state to any default color state or back. Direct conversion
between two non-default color states isn't guaranteed. For
converting *to* a cicp color state, we need this function.
2024-07-24 07:46:05 -06:00
Luca Bacci
ccc6f7c24e GdkWin32: Drop unused variable
We still check whether depth buffer bits must be > 0,
we just don't use that variable anymore.
2024-07-24 15:36:25 +02:00
Luca Bacci
41b21b6634 WGL: Search pixel format with defined swap method (opengl32)
We want to get PFD_SWAP flags as that's required to enable incremental
rendering. However, as documented on MSDN, ChoosePixelFormat ignores
PFD_SWAP flags.

We may get PFD_SWAP flags or not depending on the way the OpenGL driver
orders its pixel formats. While PFD_SWAP flags are very important for
GUI toolkits, they are best avoided by games, as most games render the
scene in its entirety on each frame. Drivers optimized for games tend
to order pixel formats with no PFD_SWAP flags first.

Se we implement our own method to select the best pixel format. We check
for usable pixel formats and assign penalties for each one, until we find
a format with 0 penalty or the sequence ends. Then the best pixel format
is selected.
2024-07-24 15:36:25 +02:00
Luca Bacci
b46a900d71 WGL: Search pixel format with defined swap method (arb)
Getting a defined swap method is necessary to enable incremental
rendering. We cannot just add a swap method attribute since
exchange is generally preferred, but is not always available.
Here we try to infer what the driver prefers, then ask for
exchange or copy, in sequence.
2024-07-24 15:35:40 +02:00
Pablo Correa Gómez
cfc871f031 gtkspinbutton: Set number input hint for text field if numeric
The main reason to do this is so that the OSK shows a numeric touchpad
instead of the regular keyboard when the spin button only accepts
numbers
2024-07-24 10:39:37 +02:00
Matthias Clasen
b435f3c543 Merge branch 'matthiasc/for-main' into 'main'
wayland: Switch to v4 of the color management protocol

See merge request GNOME/gtk!7489
2024-07-24 06:24:20 +00:00
Matthias Clasen
ebc4bb2363 wayland: Switch to v4 of the color management protocol 2024-07-23 23:37:00 -06:00
Matthias Clasen
23e4c788fa Merge branch 'dmabuf-formats-autoptr' into 'main'
gdkdmabufformats: Add autoptr definition

See merge request GNOME/gtk!7484
2024-07-23 19:48:01 +00:00
Jordan Petridis
4e0a64c46c Merge branch 'alatiera/vulkan-semaphore' into 'main'
gdkvulkancontext: set the VkSemaphore to VK_NULL_HANDLE

See merge request GNOME/gtk!7483
2024-07-23 18:05:23 +00:00
Marco Trevisan (Treviño)
e46e61643c gdkdmabufformats: Add autoptr definition 2024-07-23 19:55:47 +02:00
Jordan Petridis
cc5526e019 gdkvulkancontext: set the VkSemaphore to VK_NULL_HANDLE
Vulkan objects are integers on 32bit and it's failing when it's set to
just NULL.

```
../gdk/gdkvulkancontext.c:677:24: error: assignment to ‘VkSemaphore’ {aka ‘long long unsigned int’} from ‘void *’ makes integer from pointer without a cast [-Wint-conversion]
  677 |   priv->draw_semaphore = NULL;
```
2024-07-23 18:01:56 +02:00
Benjamin Otte
e6cafa890d Merge branch 'wip/otte/for-main' into 'main'
gpu: Use correct shader clip mode for glyph nodes

See merge request GNOME/gtk!7480
2024-07-23 08:51:35 +00:00
Benjamin Otte
293d2fd19f gpu: Use correct shader clip mode for glyph nodes
We were passing the wrong rect to the clip mode computation, resulting
in a rounded rect every time, even though it should pretty much always
be unclipped.

The visual results are unaffected, because the clip sent to the shader
was still correct.
2024-07-23 10:03:11 +02:00
Benjamin Otte
7bca467e01 Merge branch 'wip/otte/kill-descriptors' into 'main'
Redo descriptors/texture binding

Closes #6564, #6574, and #6654

See merge request GNOME/gtk!7473
2024-07-22 23:49:46 +00:00
Benjamin Otte
40e25218e2 gpu: Compile with AMD's compiler, too
Apparently AMD's GLSL compiler doesn't like our #if statements. Turn
them into simple #ifdefs and compute them in the preamble instead.
2024-07-22 19:40:24 +02:00
Benjamin Otte
9e27acb0a6 gpu: Allocate Vulkan descriptor pools dynamically
Instead of allocating one large descriptor pool and hoping we never run
out of descriptors, allocate small ones dynamically, so we know we never
run out.

Test incldued, though the test doesn't fail in CI, because llvmpipe
doesn't care about pool size limits. It does fail on my AMD though.

A fun side note about that test is that the GL renderer handles it best
in normal operationbecause it caches offscreens per node and we draw the
same node repeatedly.
But, the replay test expands them to duplicated unique nodes, and then
the GL renderer runs out of command queue length, so I had to disable
the test on it.
2024-07-22 19:40:24 +02:00
Benjamin Otte
67b9fb43d0 gpu: Completely revamp YCbCr handling
There is now a GskGpuYcbcr struct that maintains all the Vulkan
machinery related to YCbCrConversions.
It's a GskGpuCached, so it will make itself go away when it is no longer
used, ie a video stopped playing.
2024-07-22 19:40:24 +02:00
Benjamin Otte
762b981dfe gpu: Make the device queryable from the cache
That's needed in cached subclasses during destruction, when they want to
destroy system resources.
2024-07-22 19:40:24 +02:00
Benjamin Otte
5e027ae5d9 gpu: Allow creating GskGpuCached objects externally
Export the GskGpuCached and GskGpuCachedClass objects in the header, and
make gsk_gpu_cached_new() available.
2024-07-22 19:40:24 +02:00
Benjamin Otte
7dd3680d7d gpu: Refactor code a bit
Turn the 2 ways to construct cached items into 2 constructors.

Useful for next commit.
2024-07-22 19:40:24 +02:00
Benjamin Otte
14a7b4b4b4 vulkan: Remove unused features
Now that we don't use the fancy features anymore, we don't need to
enable them.
And that also means we don't need an env var to disable it for testing.
2024-07-22 19:40:24 +02:00
Benjamin Otte
f5096fd11a vulkan: No need for different shaders anymore
Now that we don't do fancy texture stuff anymore, we don't need fancy
shaders either, so we can just compile against Vulkan 1.0 again.

And that means we need no fallback shaders for Vulkan 1.0 anymore.
2024-07-22 19:40:24 +02:00
Benjamin Otte
9c5ac13301 gpu: Remove now unused variables
No need to track them anymore.
2024-07-22 19:40:24 +02:00
Benjamin Otte
ecc33d6e62 gpu: Add the same cache as the GL shader uses
This avoids unnecessary rebinds of textures.

I can't really measure a performance change with it though.
2024-07-22 19:40:24 +02:00
Benjamin Otte
03c34021af gpu: Completely revamp descriptor set handling
Instead of trying to cram all descriptors into one large array and only
binding it at the start, we now keep 1 descriptor set per image+sampler
combo and just rebind it every time we switch textures.

This is the very dumb solution that essentially maps to what GL does,
but the performance impact is negligible compared to the complicated
dance we were attempting before.
2024-07-22 19:40:24 +02:00
Benjamin Otte
1b2156493b gpu: Remove descriptors
They are no longer a thing with the new way we manage textures.
2024-07-22 19:40:24 +02:00
Benjamin Otte
7b76170f46 gpu: Flip the big switch
Rewrite all shaders to use 2 predefined samplers called GSK_TEXTURE0 and
GSK_TEXTURE1 instead of wrapper functions.

On GL and Vulkan compat mode, these map directly to samplers.
On Vulkan proper, they map to 2 indices into the texture array, like
before.

From now on, the old nvidia GPUs - ie the 3xx drivers - should start
working again.

Fixes: #6564
Fixes: #6574
Fixes: #6654
2024-07-22 19:40:14 +02:00
Benjamin Otte
8109e8e3b6 gpu: Add GskGpuShaderFlags
This is just blowing up GskGpuShaderClip to hold more information so
that we don't need even more specialization constants.
2024-07-22 18:37:07 +02:00
Benjamin Otte
163278af0d gpu: Add infrastructure to write texture vertex data
This allows GskGpuFrame implementations to store data per vertex
attribute.

This is just the plumbing, no actual implementation is done in this
commit.
2024-07-22 18:37:07 +02:00
Benjamin Otte
677b6c1a81 gpu: Force new descriptors every time
This guarantees that the images get ID 0 and 1 (on GL), which is going
to be quite important for the next steps.

Just for funsies, here's fps numbers on my desktop for this change:
NGL     1500 => 1400
Vulkan  2650 => 2250
2024-07-22 18:37:07 +02:00
Benjamin Otte
1331a10e88 gpu: Remove buffer handling
We don't use buffers atm, and if we want to bring them back later, we
can just look at reverting this commit.

And it's in the way while refactoring.
2024-07-22 18:37:07 +02:00
Benjamin Otte
dc9f0869b1 gpu: Pass used images to shader ops
This by itself is just more work refcounting all those images, but
there's actually a goal here, that will become visible in future
commits.

But this is split out for correctness and benchmarking purposes (the
overhead from refcounting seems to be negligible on my computer).
2024-07-22 18:37:07 +02:00
Benjamin Otte
ea6253c1df gpu: Add a member in ShaderOpClass for number of textures
This just puts the number from the header into a strcut where it can be
accessed.
2024-07-22 18:37:07 +02:00
Benjamin Otte
b481fd854f gpu: Encode number of textures use in every shader
Just define GSK_N_TEXTURES in every glsl file, extract that #define in
the python parser and emit a static const uint variable
"{shader_name}_n_textures" in the generated header.
2024-07-22 18:37:07 +02:00
Benjamin Otte
68baa93460 gpu: Use GskGpuShaderImage for blur ops 2024-07-22 18:37:07 +02:00
Benjamin Otte
52db54e803 gpu: Use GskGpuShaderImage for crossfade ops 2024-07-22 18:37:07 +02:00
Benjamin Otte
71e412e8f8 gpu: Use GskGpuShaderImage for convert ops 2024-07-22 18:37:07 +02:00
Benjamin Otte
9644fc2e8f gpu: Use GskGpuShaderImage for mask ops 2024-07-22 18:37:07 +02:00
Benjamin Otte
0795d86df7 gpu: Use GskGpuShaderImage for colormatrix ops 2024-07-22 18:37:07 +02:00
Benjamin Otte
21988ea700 gpu: Use GskGpuShaderImage for blendmode ops 2024-07-22 18:37:07 +02:00
Benjamin Otte
23081d2bc4 gpu: Use GskGpuShaderImage for texture ops 2024-07-22 18:37:07 +02:00
Benjamin Otte
b1e441d18a gpu: Introduce GskGpuShaderImage
It's a struct collecting all relevant info for a texture passed to a
shader.

The ultimate goal is to get rid of the descriptors and let ops
manage them on thir own.
2024-07-22 18:37:07 +02:00
Benjamin Otte
a118cbb3ff Merge branch 'wip/otte/for-main' into 'main'
gpu: Move code around

See merge request GNOME/gtk!7477
2024-07-22 16:30:45 +00:00
Benjamin Otte
4639b3bc4c gpu: Make cache keep track of time
If GskGpuCache has an idea of what time it is, cached items can use that
time to update their last-use time instead of having to carry it around
throught function calls everywhere.
2024-07-22 17:10:37 +02:00
Benjamin Otte
821eb92dfb gpu: Handle corner-case
Port an optimization of the GL renderer where it fast-paths crossfades
with progress <= 0 and >=1 - which should really never happen because
nobody should emit them in the first place, but oh well.
2024-07-22 17:10:37 +02:00
Benjamin Otte
0370043775 gpu: Add missing string
This made debug output kinda not so good.
2024-07-22 17:10:37 +02:00
Benjamin Otte
82bcc05ca1 gpu: Move code around
Move the atlas code to the top of the file, so that other code can use
it.

No functional changes.
2024-07-22 17:10:37 +02:00
Benjamin Otte
527852e1b8 Merge branch 'wip/otte/colorstates-are-as-fun-as-dmabufs' into 'main'
dmabuf: Make NULL the default colorstate in the builder

See merge request GNOME/gtk!7474
2024-07-22 13:09:56 +00:00
Benjamin Otte
2e1686091f dmabuf: Make NULL the default colorstate in the builder
YUV dmabufs are not sRGB.

So instead of making the dmabuf builder have sRGB as the default
colorstate, add a NULL default option that makes the builder choose
the colorstate based on fourcc when build() is called.

If that happens, we pick sRGB usually, but for YUV we pick narrow range
BT601, like we did in versions before colorstates.
2024-07-22 14:54:05 +02:00
Artur S0
5353e28dca Update Russian translation 2024-07-22 12:23:52 +00:00
Benjamin Otte
b58e89f380 Merge branch 'wip/otte/for-main' into 'main'
vulkan: dmabufs require ycbcr

See merge request GNOME/gtk!7476
2024-07-22 00:50:07 +00:00
Benjamin Otte
c1e008fa86 gpu: Improve cache stats printing
We no longer hardcode the few different classes we have, but generically
walk over all classes.

As a side effect we now get new classes added to stats automatically.

The content itself did not change.
2024-07-22 02:03:00 +02:00
Benjamin Otte
c47a3c54fd vulkan: Make images track the device
Now that the cache is a separate object, there are no longer cyclic
uncollectable references, so images can use the device like everyone
else.
2024-07-22 01:28:40 +02:00
Benjamin Otte
3bc1e0534f gpu: Clean up headers
After the device/cache split, this was forgotten.
2024-07-22 01:28:40 +02:00
Benjamin Otte
7fb11dfeb0 gpu: Print filename in exceptions
I want to know which shader I screwed up.
2024-07-22 01:28:40 +02:00
Benjamin Otte
6d09eed90e gpu: Remove unused argument
It's always passing NULL.
2024-07-22 01:28:40 +02:00
Benjamin Otte
496211727d vulkan: dmabufs require ycbcr
So make sure that GDK_VULKAN_DISABLE=ycbcr also disables dmabufs.
2024-07-22 01:28:39 +02:00
Benjamin Otte
ee5e3b5927 Merge branch 'fix-urilauncher-uaf' into 'main'
urilauncher: Fix use-after-free on GCC < 12

See merge request GNOME/gtk!7471
2024-07-21 12:57:36 +00:00
Benjamin Otte
2087595747 Merge branch 'wip/otte/for-main' into 'main'
ngl: Fix crash at startup

See merge request GNOME/gtk!7472
2024-07-19 20:17:14 +00:00
Benjamin Otte
25268c2086 gstsink: Don't use g_autoptr 2024-07-19 21:37:48 +02:00
Benjamin Otte
2a9056b49e ngl: Fix crash at startup
Commit 1580490670 included a reordering of
acquiring the frame before making the context current.

Sometimes (like at startup) new frames need to be created.

Setting up a new frame assumed the GL context was current.

Change it so that we delay the one GL setup we do in frames until later.
2024-07-19 21:37:48 +02:00
Sergey Bugaev
46363b617e urilauncher: Fix use-after-free on GCC < 12
Building GTK with GCC 8 results in the following warning:

  gtk/gtkurilauncher.c: In function ‘gtk_uri_launcher_launch’:
  gtk/gtkurilauncher.c:315:3: warning: this ‘else’ clause does not guard... [-Wmisleading-indentation]
     else
     ^~~~
  gtk/gtkurilauncher.c:317:1: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘else’
   G_GNUC_BEGIN_IGNORE_DEPRECATIONS
   ^~~

In the compiled code, gtk_show_uri_full () is invoked whether the portal
branch is taken or not, leading to use-after-free of the task.

It looks like GCC in versions older than 12 treats the _Pragma(s) that
G_GNUC_BEGIN_IGNORE_DEPRECATIONS expands to as C-level statements, and
therefore the pragma takes up the 'else' statement slot.

See https://godbolt.org/z/e5zqbaqxo for a simple reproducer.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2024-07-19 20:36:45 +03:00
Yaron Shahrabani
adb3baa7d2 Update Hebrew translation 2024-07-19 12:58:41 +00:00
Carlos Garnacho
31a79fbd9f Merge branch 'main' into 'main'
Ignore grabbing tablet devices without pads or tools

See merge request GNOME/gtk!7470
2024-07-18 12:10:36 +00:00
Jie Liu
d8919311b1 Ignore grabbing tablet devices without pads or tools
Signed-off-by: Jie Liu <liujie01@kylinos.cn>
2024-07-18 18:19:26 +08:00
Benjamin Otte
0e0158a825 Merge branch 'wip/otte/for-main' into 'main'
dmabuf: Do a naive implementation of P010, P012 and P016

See merge request GNOME/gtk!7469
2024-07-18 03:13:32 +00:00
Benjamin Otte
619926ec83 dmabuf: fix mmap() calls
* We cannot map with offset, because offsets need to be page-size
  aligned. And our code doesn't expect an offset anyway.
* The error return value from mmap() is MAP_FAILED aka -1, not NULL aka
  0.
2024-07-18 04:33:14 +02:00
Benjamin Otte
1afb832ff0 dmabuf: Do a naive implementation of P010, P012 and P016
These are the common HDR formats, so we better have the baseline of
those.
2024-07-18 04:33:14 +02:00
Benjamin Otte
823b529f89 gstsink: Remove unused member variable 2024-07-18 04:33:14 +02:00
Benjamin Otte
4707784755 gstsink: Use GdkMemoryTextureBuilder 2024-07-18 04:33:14 +02:00
Benjamin Otte
1ebcd27605 Merge branch 'wip/otte/for-main' into 'main'
Various Vulkan fixes

See merge request GNOME/gtk!7468
2024-07-17 21:19:02 +00:00
Benjamin Otte
300639e537 vulkan: Use right check for waiting on external image semaphore
Commit 3aa6c27c26 changed the initial layout of imported dmabuf images,
but did not adapt this check.
2024-07-17 22:59:23 +02:00
Benjamin Otte
ad218f0786 gpu: Pass the pass to frame_submit()
We will need that in the next commit.
2024-07-17 22:59:23 +02:00
Benjamin Otte
4966f8cdf8 vulkan: Add an acquire semaphore to frames
Vulkan requires us waiting on the image acquired from
vkAcquireNextImageKHR() before we start rendering to it, as that
function is allowed to return images that are still in use by the
compositor.
Because of that requirement, vkAcquireNextImageKHR() requires a
semaphore or fence to be passed that it can signal once it's done.

We now use a side channel to begin_frame() - calling
set_draw_semaphore() - to pass that semaphore so that the
vkAcquireNextImageKHR() call inside begin_frame() can use it, and then
we can wait on it later when we submit.

And yes, this is insanely convoluted, the Vulkan developers should
totally have thought about GTK's internal designs before coming up
with that idea.
2024-07-17 22:59:23 +02:00
Benjamin Otte
1580490670 gpu: add gsk_gpu_frame_begin/end()
These are just factoring out gdk_draw_context_begin/end_frame() so I can
add one tiny thing there later.

And I did both even though I only need one, because it felt wrong to
just do one.
2024-07-17 22:59:23 +02:00
Benjamin Otte
3cf5e8cf4e gpu: Move gc calls further to the edges of the function
Make the function look like that:

1. handle special case
2. maybe GC
3. draw
4. queue next gc
5. cleanup

This seems like the sanest approach to avoid gc() collecting things
necessary for drawing in the future.

And I need to refactor stuff, so having it out of the way is a good
idea.
2024-07-17 22:59:23 +02:00
Benjamin Otte
d21ac80178 gpu: Simplify a function
Now that we only ever use 2 images max per shader due to the removal of
the ubershader, we can just hardcode it in the function.
2024-07-17 22:59:23 +02:00
Martin
effbaa7770 Update Slovenian translation 2024-07-17 07:07:05 +00:00
Quentin PAGÈS
a9a61abc81 Update Occitan translation 2024-07-17 07:02:10 +00:00
Ekaterine Papava
e5b05424c8 Update Georgian translation 2024-07-16 21:45:51 +00:00
Matthias Clasen
8f920101f3 Merge branch 'wip/otte/texture-colorstate-api' into 'main'
Add support for color states to texture constructors/downloader

See merge request GNOME/gtk!7461
2024-07-16 21:09:48 +00:00
Matthias Clasen
1c59474f45 Merge branch 'inspector-crash' into 'main'
inspector: Fix a crash

See merge request GNOME/gtk!7467
2024-07-16 20:58:37 +00:00
Benjamin Otte
9be7104b71 testsuite: Add a save=>load cycle test for PNGs with colorstates 2024-07-16 22:04:11 +02:00
Benjamin Otte
31e0ec71f2 png: Add color state support
When loading or saving png files, encode the CICP flags of the color
state into the PNG.

When loading, decode the CICP flags if available and detect the
colorstate they use.
If we do not support the cicp tags, we do not load the image.

So far, we ignore the ICC profiles.

Includes regeneration of nodeparse test *reference* output to include
the new tags we write to PNGs.
The original tests do not include those tags, so we implicitly test that
we read untagged files correctly.
2024-07-16 22:04:10 +02:00
Benjamin Otte
6c33afc13c png: Move texture data download further down
We only download the data when we actually need it for writing into the
PNG stream.

This allows modifying the download parameters (in particular color state
in the next commit) while writing out their settings, so the code for
selecting the right colorstate liives in only one place.

We have to be careful though, because the download now happens after the
setjmp(), so we need to make sure the error path handles both cases
without leaking: Where the download has happened and where it hasn't.
2024-07-16 22:03:48 +02:00
Benjamin Otte
03daf42fb5 png: Port to MemoryTextureBuilder 2024-07-16 22:03:46 +02:00
Matthias Clasen
b33b68ef75 dmabuf texture: color state support 2024-07-16 21:23:44 +02:00
Matthias Clasen
0ee8ca43d1 gl texture: color state support 2024-07-16 21:23:44 +02:00
Benjamin Otte
77da45a173 testsuite: Update colorstate test 2024-07-16 21:23:44 +02:00
Benjamin Otte
5e1c3c5d69 gdk: Add GdkMemoryTexture::color-state
This allows setting the color state of textures.
2024-07-16 21:23:44 +02:00
Benjamin Otte
05953a20cc testsuite: Allow colorstate properties to have SRGB as default value
This needs custom code because boxed paramspecs always default to NULL.
But we want to always default to SRGB.
2024-07-16 21:23:44 +02:00
Benjamin Otte
3c8a93b972 gdk: Add GdkMemoryTextureBuilder
Same thing as dmabuf and GL texture builders. Preparation for adding
color state support to texture constructors.

As a bonus, we can now do update regions with memory textures.
2024-07-16 21:23:44 +02:00
Benjamin Otte
11543a229a texturedownloader: Add color state
... and plumb the color state through the downloading machinery, where
no matter what path it takes it ends up in
gdk_memory_convert_color_state() or gdk_memory_convert().

The 2nd of those has been expanded to optionally do colorstate
conversion when the 2 colorstates are different.
2024-07-16 21:23:44 +02:00
Robert Mader
d448e12cf4 inspector: Fix a crash
gdk_wayland_color_get_color_manager() rightfully is not NULL-safe.

Fixes: 2031ec1b57 ("inspector: Show the color management protocol")
2024-07-16 10:30:56 +02:00
Benjamin Otte
fee4ad0174 Merge branch 'wip/otte/for-main' into 'main'
gpu: Don't transition invalid cache items

Closes #6867

See merge request GNOME/gtk!7466
2024-07-16 01:40:16 +00:00
Matthias Clasen
38f01cf1f2 Merge branch 'fix-subsurface-crash' into 'main'
wayland/subsurface: Handle NULL-buffers in dmabuf_buffer_release

See merge request GNOME/gtk!7465
2024-07-16 01:25:41 +00:00
Benjamin Otte
37bea9d162 gpu: Don't transition invalid cache items
When a cache item is invalid, don't move it into the hash table.
Instead, just delete it.

Something like this could happen:

1. A texture is cached
In the case of #6867 this would be a webpage in epiphany.

2. The texture cache item is garbage-collected
For example, epiphany might switch to a new tab, and the previous page's
texture will remain. After 15s or so, we collect our item for that
texture.

3. The texture is cached again, but in the target colorspace
We now decide we need the texture again, but not in any colorspace, we
need it in the target colorspace. This might be because we run an
effect on it (like a crossfade) or because we want mipmaps (like in the
overview map, where its zoomed out).

4. The old invalid item is transitioned into the hash table
We now have an invalid item in the hash table. This is extra bad,
because it had only one reference (from the texture), but we treat it
like it has 2 (from us in the hash table and from the texture).
So depending on if the texture is freed before we reuse it, we get
different results: If it was free, we get invalid memory accesses, if it
was not freed, we treat it like a valid cache item and think the image
inside is still valid.

Fixes #6867
2024-07-16 03:15:36 +02:00
Robert Mader
b241fcd418 wayland/subsurface: Handle NULL-buffers in dmabuf_buffer_release
This happens when buffer creation fails in `get_dmabuf_wl_buffer()` and
we manually call `listener->release (data, NULL)`.

Fixes: 2478dd8322 ("subsurface: Split a function")
2024-07-16 01:43:15 +02:00
g.willems
4fa661b450 printdialog: fix sporadic win32 build failures
Private function `gtk_print_setup_get_printer` unconditionally calls
`gtk_printer_find()`, which does not exist on Win32.

But `gtk_print_setup_get_printer()` is never called either, so usually
that whole code gets optimized out.

Some compilation environment however do not cleanup unused functions,
leading to linker error as `gtk_printer_find()` is not found.

This patch should solve the link issue.
2024-07-15 23:05:13 +02:00
Benjamin Otte
86e735cd5c Merge branch 'wip/otte/for-main' into 'main'
vulkan: Remove draw semaphore

Closes #6861

See merge request GNOME/gtk!7460
2024-07-14 21:11:06 +00:00
Michael Catanzaro
4c40395a38 gpu: fix memory corruption in cache_gc_cb()
gsk_gpu_device_gc() may release the last ref on the GskGpuDevice,
leading to memory corruption when setting priv->cache_gc_source = 0.

Includes a bit of refactoring, so the ref/unref wraps nicely around the
actual code.

Fixes crashes seen after using the inspector and closing the window,
thereby closing all windows of a display and releasing all references to
the device.

Fixes #6861
2024-07-14 21:54:57 +02:00
Benjamin Otte
d32fd76b31 docs: Fix typo 2024-07-14 21:54:40 +02:00
Benjamin Otte
5f8e83d75d gpu: Fix memleak in texture-scale code 2024-07-14 21:54:40 +02:00
Benjamin Otte
b08a17064e vulkan: Remove draw semaphore
That's unused (or wrongly used) leftover code from 2017.

The validation layers also don't like it.
2024-07-14 21:54:40 +02:00
Benjamin Otte
3f39cb38c4 Merge branch 'wayland-color-states' into 'main'
Wayland color management

See merge request GNOME/gtk!7444
2024-07-14 19:46:56 +00:00
Matthias Clasen
2031ec1b57 inspector: Show the color management protocol 2024-07-14 14:58:00 -04:00
Matthias Clasen
533aaba5eb wayland: Support xx-color-management-v2
This is a still experimental protocol (thus the xx prefix).

We are using it go obtain information about the compositors
preferred color state, and pass that on to our rendering machinery.

The currently supported color states are srgb, srgb-linear, rec2100-pq
and rec2100-linear. We don't have any support for ICC profiles.

Unlike other protocols, keep the support code for this protocol
fairly isolated behind wrapper objects, since the protocol is
still subject to change.
2024-07-14 14:58:00 -04:00
Matthias Clasen
72c782af17 Merge branch 'matthiasc/for-main' into 'main'
colorstate: Add autoptr definitions

See merge request GNOME/gtk!7457
2024-07-14 18:12:34 +00:00
Matthias Clasen
af8a3eff10 Merge branch 'surface-color-state' into 'main'
surface: Add a color state

See merge request GNOME/gtk!7456
2024-07-14 17:21:51 +00:00
Matthias Clasen
ee7ba54a7f colorstate: Add autoptr definitions
A little convenience never hurts.
2024-07-14 12:52:56 -04:00
Matthias Clasen
53d99f5521 Use the surface colorstate in begin_frame
begin_frame is the place where we make decisions about the format,
depth and colorstate for our rendering. Make these calls take the
surface color state into account.

In particular, if the surface colorstate is suitable for GL_SRGB,
and we don't need high depth, set things up for that.
2024-07-14 12:51:05 -04:00
Matthias Clasen
52d2975af3 surface: Add a color state
This will be set by the backend, and it will be used to set up
the draw context properly. For now, this is always SRGB.
2024-07-14 12:46:20 -04:00
Matthias Clasen
926a651f12 Merge branch 'more-color-states' into 'main'
More color states

See merge request GNOME/gtk!7445
2024-07-13 19:37:54 +00:00
Matthias Clasen
7aeab7a63f Add a debug flag for hdr rendering
Set GDK_DEBUG=hdr to force the use of rec2100 as compositing
colorstate.
2024-07-13 15:11:07 -04:00
Matthias Clasen
a2389b3169 Cosmetics
Shift debug flags around so we can put hdr next to linear.
2024-07-13 15:11:07 -04:00
Matthias Clasen
54e5cc296f colorstate: Add rec2100-pq and rec2100-linear
These are wide-gamut, HDR colorstates that we will need for HDR support.
2024-07-13 15:11:07 -04:00
Matthias Clasen
457fd68168 gpu: Make color conversion extensible
Change the glsl convert_color function to proceed in stages:
- first unpremultiply
- then linearize
- then transform linearly
- then delinearize
- then premultiply
All the steps are only taken if needed.
2024-07-13 15:09:12 -04:00
Matthias Clasen
2d69f35e0e colorstate: More details in the docs
Add links to srgb definitions and references.
2024-07-13 15:09:12 -04:00
Benjamin Otte
648c780e91 gpu: Respect colorstate for offscreens
We want to render in at least the minimum required depth of the used
colorstate.
2024-07-13 14:51:49 -04:00
Benjamin Otte
f36618f02a Merge branch 'fix-columnviewcolumn-visibility' into 'main'
columnview: check column visibility when measuring

See merge request GNOME/gtk!7452
2024-07-13 17:47:49 +00:00
Christian Hergert
8548a1dd7f columnview: check column visibility when measuring
We only want to measure visible columns so that they may consume the
maximum width available to the widget. This fixes a situation where hidden
columns would cause less-than the whole width to be allocated. Additionally
that fixes warnings where some widgets expect more horizontal space than
they would ultimately be allocated.
2024-07-13 10:12:41 -07:00
Matthias Clasen
5e1d58c41c Merge branch 'matthiasc/for-main' into 'main'
vulkan: Remove GDK_DEBUG=vulkan-validate

See merge request GNOME/gtk!7451
2024-07-13 13:19:54 +00:00
Benjamin Otte
a61d7f3864 vulkan: Remove GDK_DEBUG=vulkan-validate
The modern incantation to get validation layers enabled is via

VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation

Vulkan has a bunch of environment variables to toggle stuff, let's use
those instead of doing our own.
2024-07-13 08:52:28 -04:00
Benjamin Otte
c7fcaaf443 Merge branch 'wip/otte/for-main' into 'main'
gpu: Fix color convert path to not crash

See merge request GNOME/gtk!7450
2024-07-13 10:41:38 +00:00
Benjamin Otte
6d263f8680 gpu: Add GSK_GPU_BLEND_NONE
Allows writing without blending. This is useful when copying/converting
textures.

In particular, we use it for colorspace conversions.
2024-07-13 10:56:47 +02:00
Benjamin Otte
d9ab6495ef gpu: Fix color convert path to not crash
The occlusion culling reorganization messed up this branch.

Make it work again.
2024-07-13 10:56:47 +02:00
Ekaterine Papava
ceac0ce9aa Update Georgian translation 2024-07-13 05:34:08 +00:00
Benjamin Otte
e975d6db17 Merge branch 'wip/otte/for-main' into 'main'
gpu: Remove unused macro

See merge request GNOME/gtk!7449
2024-07-13 01:25:35 +00:00
Benjamin Otte
d54b68b93c gpu: Convert values to float[4] from GdkRGBA
We need to make sure our clear values are in the right colorstate, not
in sRGB.

The occluision culling managed to sneak through the big transition for
that.
2024-07-13 02:07:15 +02:00
Benjamin Otte
761346ed5a gpu: Remove unused macro
This is a leftover from the pre-color-managed times
2024-07-13 02:07:15 +02:00
Matthias Clasen
6d71dd0025 Merge branch 'matthiasc/for-main' into 'main'
colorstate: Consistent naming

See merge request GNOME/gtk!7448
2024-07-12 23:58:28 +00:00
Matthias Clasen
d0e2d9e2f4 colorstate: Small reorg
Introduce a helper macro.
2024-07-12 18:15:28 -04:00
Matthias Clasen
b0effee9b3 colorstate: Add tests for conversions
Test roundtrip tests between color states.

For now, this just tests srgb<>srgb-linear.
2024-07-12 18:14:54 -04:00
Matthias Clasen
abb7e85260 colorstate: Consistent naming
Make the conversion functions use srgb_linear in their names, since
the name of the color state is srgb-linear.
2024-07-12 18:14:44 -04:00
Matthias Clasen
3ccd03e226 Updates 2024-07-12 16:55:49 -04:00
Benjamin Otte
2ae345aa8f Merge branch 'wip/otte/big-bigger-oom' into 'main'
Implement tiling for large textures

Closes #6324

See merge request GNOME/gtk!7447
2024-07-12 17:47:53 +00:00
Benjamin Otte
1c1b78aa1c gpu: Implement tiling for texture-scale nodes
This is actually the node Loupe is using, so having tiling work with it
is important.

Because of the previous commit, different filters are supported fine.

Fixes: #6324
2024-07-12 18:09:46 +02:00
Benjamin Otte
cdb2308ddd gpu: Add filter support to tiled images
This allows mipmapping if downscaled a lot, like we do for non-tiled
images.

A side effect is that due to the simpler caching for tiles, we can only
cache the mipmapped images in one colorstate. But we need to pick a
potentially non-default one, because we want to mipmap in a linear
colorstate.

So this is somewhat suboptimal. Patches with improvements accepted.
2024-07-12 17:31:36 +02:00
Benjamin Otte
c581f722bd gpu: Split out a function
We'll need mapping scaling filters to samplers elsewhere soon.
2024-07-12 17:31:36 +02:00
Benjamin Otte
340c98c6cd gpu: Split a function
Split drawing the tiles from setting up the offscreen for drawing the
tiles.
2024-07-12 17:31:36 +02:00
Benjamin Otte
39f5c5bf49 gpu: Implement tiling for texture nodes
Use the new cache feature to split oversized textures into tiles the
size given by the new device API.

Then number those tiles from left to right and top to bottom and use
that number as the tile id.
2024-07-12 17:31:36 +02:00
Benjamin Otte
392f6855ca gpu: Add gsk_gpu_device_get_tile_size()
This allows managing tiling of images. And I'd like this value to live
somewhere prominent instead of as a hardcoded number in the
nodeprocessor.
2024-07-12 17:31:36 +02:00
Benjamin Otte
1cae48ab93 gpu: Add a tile cache
Nobody is using it yet, but it's the API.

It's very simple and just allows adding tiles by an index. What that
index means is up to the caller.
2024-07-12 17:31:36 +02:00
Benjamin Otte
25f04f3c37 Merge branch 'wip/otte/for-main' into 'main'
dmabuf: Add DRM_FORMAT_INVALID to our formats

See merge request GNOME/gtk!7446
2024-07-12 15:29:40 +00:00
Benjamin Otte
d0f8ef09a0 gpu: Do a GC run after every tile of large images
When we draw large images, we absolutely do not want to keep memory that
we do not need. So do a GC run after every tile. That otentially slows
down things, but it also improves the chances of not running out of
memory.

Here's the node for the image I managed to create after I applied this
patch:

repeat {
  bounds: 0 0 50000 50000;
  child: text {
    font: "Noto Color Emoji 10000px";
    glyphs: 661 0 0 0 color;
    offset: 0 10000;
    hint-style: none;
  }
}
2024-07-12 16:57:23 +02:00
Benjamin Otte
0516dca116 vulkan: Don't try to use nonexisting formats
Handle the error that new rgba format exists.
2024-07-12 16:56:23 +02:00
Benjamin Otte
ebc6a043c9 gpu: Cleanups 2024-07-12 16:56:23 +02:00
Benjamin Otte
8e2ae79875 gpu: Change function to (transfer full)
Functions should behave as I expect, and I just spent an hour debugging
a refcount issue because I assumed our image creation functions return
refrences. Which is a very sane assumption.
2024-07-12 16:55:59 +02:00
Benjamin Otte
27ac764653 gpu: Don't multiply by 1/x, divide by x
This is less error-prone with floating point math, even though it is
somewhat slower.
2024-07-12 16:55:59 +02:00
Matthias Clasen
80df6e2b8d Merge branch 'matthiasc/for-main' into 'main'
wayland: Fix handling of the font-rendering setting

Closes #6855

See merge request GNOME/gtk!7443
2024-07-12 00:55:02 +00:00
Matthias Clasen
bfda8cf820 stylecontext: fix gtk_style_context_lookup_color
We need to ensure the value is computed.

Fixes: #6855
2024-07-11 19:58:55 -04:00
Matthias Clasen
cb91f96fd3 wayland: Fix handling of the font-rendering setting
The settings portal is reporting enums as string values, so
we need to translate this setting back to what we need.

Fixes

(gtk4-demo:18902): GLib-CRITICAL **: 19:06:14.783: g_variant_get_int32: assertion 'g_variant_is_of_type (value, G_VARIANT_TYPE_INT32)' failed

that could be seen in recent nightly flatpaks.
2024-07-11 19:06:50 -04:00
Matthias Clasen
549ec0aac8 Merge branch 'matthiasc/for-main' into 'main'
Small doc fixes

See merge request GNOME/gtk!7442
2024-07-11 21:15:10 +00:00
Matthias Clasen
5cea9f9e17 Small doc fixes
Pointed out be Emmanuele Bassi.
2024-07-11 16:56:10 -04:00
Benjamin Otte
a9cce55693 dmabuf: Add DRM_FORMAT_INVALID to our formats
That's gonna be necessary for the next commit.
2024-07-11 18:39:14 +02:00
Benjamin Otte
3a8e1c55e1 listitemfactory: Don't rebind on position or selection changes
When the item doesn't change and only the position / selection state,
then the signal list item factory should not emit bind + unbind signals.

This used to work, but probably broke while refactoring for ColumnView
during 4.10.

This caused excessive rebinding when items got inserted at the top of a
list instead of add the end.
2024-07-07 05:38:22 +02:00
robxnano
4da8d39ec5 MenuSectionBox: Increase priority of separator sync function
This ensures that the separators are made visible before a popover
menu is shown. Previously the menu would jump in size after it
appeared.

Closes https://gitlab.gnome.org/GNOME/gtk/-/issues/5166
2023-12-14 18:57:04 +00:00
918 changed files with 86028 additions and 46245 deletions

2
.gitignore vendored
View File

@@ -1,2 +1,4 @@
/subprojects/*/
.flatpak-builder/
.vscode/
subprojects/*.wrap

View File

@@ -26,7 +26,8 @@ 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:v49"
MESON_TEST_MAX_PROCESSES: 8
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v52"
workflow:
rules:
@@ -67,7 +68,6 @@ style-check-diff:
- "${CI_PROJECT_DIR}/_build/report-x11.xml"
- "${CI_PROJECT_DIR}/_build/report-wayland.xml"
- "${CI_PROJECT_DIR}/_build/report-wayland_gl.xml"
- "${CI_PROJECT_DIR}/_build/report-wayland_gles2.xml"
- "${CI_PROJECT_DIR}/_build/report-broadway.xml"
name: "gtk-${CI_COMMIT_REF_NAME}"
paths:
@@ -118,8 +118,9 @@ release-build:
script:
- .gitlab-ci/show-info-linux.sh
- mkdir _install
- export PATH="$HOME/.local/bin:${CI_PROJECT_DIR}/_install/bin:$PATH"
- .gitlab-ci/install-meson-project.sh --prefix ${CI_PROJECT_DIR}/_install https://gitlab.gnome.org/jadahl/catch.git main
# don't use catch by default, since it causes sporadic test failures
# - export PATH="$HOME/.local/bin:${CI_PROJECT_DIR}/_install/bin:$PATH"
# - .gitlab-ci/install-meson-project.sh --prefix ${CI_PROJECT_DIR}/_install https://gitlab.gnome.org/jadahl/catch.git main
- meson subprojects download
- meson subprojects update --reset
- meson setup
@@ -134,8 +135,6 @@ release-build:
- PKG_CONFIG_PATH=${CI_PROJECT_DIR}/_install/lib64/pkgconfig:${CI_PROJECT_DIR}/_install/share/pkgconfig meson setup _build_hello examples/hello
- LD_LIBRARY_PATH=${CI_PROJECT_DIR}/_install/lib64 meson compile -C _build_hello
- .gitlab-ci/run-tests.sh _build wayland gtk
# only repeat test runs that are likely affected by test setups
- .gitlab-ci/run-tests.sh _build wayland_gles2 gtk:gdk,gtk:gsk-gl
fedora-clang:
extends: .build-fedora-default
@@ -199,11 +198,11 @@ fedora-mingw64:
- subprojects/libepoxy/
- subprojects/pango/
msys2-mingw64:
msys2-ucrt64:
extends: .mingw-defaults
needs: []
variables:
MSYSTEM: "MINGW64"
MSYSTEM: "UCRT64"
CHERE_INVOKING: "yes"
artifacts:
when: always
@@ -328,20 +327,6 @@ flatpak:widget-factory:aarch64:
variables:
APPID: org.gtk.WidgetFactory4
flatpak:icon-browser:
extends: '.flatpak-defaults'
needs: []
variables:
APPID: org.gtk.IconBrowser4
flatpak:icon-browser:aarch64:
extends: '.flatpak-defaults'
needs: []
tags:
- flatpak-aarch64
variables:
APPID: org.gtk.IconBrowser4
flatpak:node-editor:
extends: '.flatpak-defaults'
needs: []
@@ -375,14 +360,6 @@ nightly factory aarch64:
extends: '.publish_nightly'
needs: ['flatpak:widget-factory:aarch64']
nightly icon-browser:
extends: '.publish_nightly'
needs: ['flatpak:icon-browser']
nightly icon-browser aarch64:
extends: '.publish_nightly'
needs: ['flatpak:icon-browser:aarch64']
nightly node-editor:
extends: '.publish_nightly'
needs: ['flatpak:node-editor']
@@ -414,11 +391,12 @@ static-scan:
# Run tests with the address sanitizer. We need to turn off introspection
# and f16c, since they are incompatible with asan
asan-build:
image: $FEDORA_IMAGE
extends: .build-fedora-default
tags: [ asan ]
stage: analysis
needs: []
variables:
MESON_TEST_MAX_PROCESSES: 4
script:
- export PATH="$HOME/.local/bin:$PATH"
- CC=clang meson setup

View File

@@ -1,4 +1,4 @@
FROM fedora:39
FROM fedora:40
RUN dnf -y install \
adwaita-icon-theme \
@@ -99,8 +99,11 @@ RUN dnf -y install \
which \
wireplumber \
xorg-x11-server-Xvfb \
&& dnf -y update \
&& dnf clean all
RUN rm /usr/share/vulkan/icd.d/powervr_mesa_icd.x86_64.json
# Enable sudo for wheel users
RUN sed -i -e 's/# %wheel/%wheel/' -e '0,/%wheel/{s/%wheel/# %wheel/}' /etc/sudoers

View File

@@ -8,17 +8,19 @@ builddir=$1
setup=$2
suite=$3
multiplier=${MESON_TEST_TIMEOUT_MULTIPLIER:-1}
n_processes=${MESON_TEST_MAX_PROCESSES:-1}
# Ignore memory leaks lower in dependencies
export LSAN_OPTIONS=suppressions=$srcdir/lsan.supp:print_suppressions=0:detect_leaks=0:allocator_may_return_null=1
export G_SLICE=always-malloc
case "${setup}" in
x11*)
xvfb-run -a -s "-screen 0 1024x768x24 -noreset" \
dbus-run-session -- \
xvfb-run -a -s "-screen 0 1024x768x24 -noreset" \
meson test -C ${builddir} \
--quiet \
--timeout-multiplier "${multiplier}" \
--num-processes "${n_processes}" \
--print-errorlogs \
--setup=${setup} \
--suite=${suite//,/ --suite=} \
@@ -40,9 +42,11 @@ case "${setup}" in
compositor=$!
export WAYLAND_DISPLAY=wayland-5
meson test -C ${builddir} \
dbus-run-session -- \
meson test -C ${builddir} \
--quiet \
--timeout-multiplier "${multiplier}" \
--num-processes "${n_processes}" \
--print-errorlogs \
--setup=${setup} \
--suite=${suite//,/ --suite=} \
@@ -63,9 +67,11 @@ case "${setup}" in
server=$!
export BROADWAY_DISPLAY=:5
meson test -C ${builddir} \
dbus-run-session -- \
meson test -C ${builddir} \
--quiet \
--timeout-multiplier "${multiplier}" \
--num-processes "${n_processes}" \
--print-errorlogs \
--setup=${setup} \
--suite=${suite//,/ --suite=} \

View File

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

View File

@@ -2,12 +2,6 @@
set -e
if [[ "$MSYSTEM" == "MINGW32" ]]; then
export MSYS2_ARCH="i686"
else
export MSYS2_ARCH="x86_64"
fi
# Update everything
pacman --noconfirm -Suy
@@ -15,27 +9,27 @@ pacman --noconfirm -Suy
pacman --noconfirm -S --needed \
base-devel \
git \
mingw-w64-$MSYS2_ARCH-cc \
mingw-w64-$MSYS2_ARCH-ccache \
mingw-w64-$MSYS2_ARCH-pkgconf \
mingw-w64-$MSYS2_ARCH-gobject-introspection \
mingw-w64-$MSYS2_ARCH-meson \
mingw-w64-$MSYS2_ARCH-adwaita-icon-theme \
mingw-w64-$MSYS2_ARCH-atk \
mingw-w64-$MSYS2_ARCH-cairo \
mingw-w64-$MSYS2_ARCH-gdk-pixbuf2 \
mingw-w64-$MSYS2_ARCH-glib2 \
mingw-w64-$MSYS2_ARCH-graphene \
mingw-w64-$MSYS2_ARCH-json-glib \
mingw-w64-$MSYS2_ARCH-libepoxy \
mingw-w64-$MSYS2_ARCH-pango \
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-shaderc \
mingw-w64-$MSYS2_ARCH-vulkan \
mingw-w64-$MSYS2_ARCH-vulkan-headers
${MINGW_PACKAGE_PREFIX}-cc \
${MINGW_PACKAGE_PREFIX}-ccache \
${MINGW_PACKAGE_PREFIX}-pkgconf \
${MINGW_PACKAGE_PREFIX}-gobject-introspection \
${MINGW_PACKAGE_PREFIX}-meson \
${MINGW_PACKAGE_PREFIX}-adwaita-icon-theme \
${MINGW_PACKAGE_PREFIX}-atk \
${MINGW_PACKAGE_PREFIX}-cairo \
${MINGW_PACKAGE_PREFIX}-gdk-pixbuf2 \
${MINGW_PACKAGE_PREFIX}-glib2 \
${MINGW_PACKAGE_PREFIX}-graphene \
${MINGW_PACKAGE_PREFIX}-json-glib \
${MINGW_PACKAGE_PREFIX}-libepoxy \
${MINGW_PACKAGE_PREFIX}-pango \
${MINGW_PACKAGE_PREFIX}-fribidi \
${MINGW_PACKAGE_PREFIX}-gst-plugins-bad-libs \
${MINGW_PACKAGE_PREFIX}-shared-mime-info \
${MINGW_PACKAGE_PREFIX}-python-gobject \
${MINGW_PACKAGE_PREFIX}-shaderc \
${MINGW_PACKAGE_PREFIX}-vulkan \
${MINGW_PACKAGE_PREFIX}-vulkan-headers
mkdir -p _ccache
export CCACHE_BASEDIR="$(pwd)"

View File

@@ -34,7 +34,9 @@
<!--
- Which version of GTK you are using
- What operating system and version
- For Linux, which distribution
- What windowing system (X11 or Wayland)
- What graphics driver / mesa version
- For Linux, which distribution
- If you built GTK yourself, the list of options used to configure the build
-->

346
NEWS
View File

@@ -1,6 +1,350 @@
Overview of Changes in 4.15.4, xx-xx-xxxx
Overview of Changes in 4.17.0, xx-xx-xxxx
=========================================
Overview of Changes in 4.16.2, 09-25-2024
=========================================
* GtkLabel:
- Fix centered text in RTL
* Gsk:
- Speed up some Vulkan operations
- Improve startup speed by avoiding initialization
of GL and Vulkan in most cases
- Reduce critials at startup to warnings
- Fix a crash on startup with some Vulkan drivers
- Fix a big texture leak in NGL
* Gdk:
- Speed up memory format conversions
* Wayland:
- Be more careful with mimetypes during DND or copy-paste
* Tools:
- builder-tool: Improve conversion of boxes
* Translation updates:
Brazilian Portuguese
Bulgarian
Catalan
Chinese (China)
Georgian
German
Hebrew
Indonesian
Persian
Polish
Portuguese
Slovenian
Spanish
Turkish
Ukrainian
Overview of Changes in 4.16.1, 09-16-2024
=========================================
* GtkFileChooser:
- Plug a memory leak
* GtkCalendar:
- Avoid ending up with invalid dates
* Printing:
- Fix initial printer selection in the print dialog
* Gsk:
- Fix shadows for opaque textures
- Fix a crash in a corner case
* Css:
- Make relative paths work again in theme files
* Accessibility:
- Fix detection of the Flatpak portal
* MacOS:
- Fix keyboard input in popovers
- Keep DND icons above regular windows
- Ignore events from DND icons
* Translation updates
Basque
British English
Bulgarian
Czech
Danish
Georgian
Hungarian
Lithuanian
Portuguese
Spanish
Swedish
Overview of Changes in 4.16.0, 09-06-2024
=========================================
Note: This release changes the default GSK renderer to be Vulkan,
on Wayland. Other platforms still use ngl. The intent of this change
is to use the best available platform APIs. You can still override
the renderer choice using the GSK_RENDERER environment variable.
We believe that most of the problems reported with the new renderers
during the 4.13 and 4.15 development cycles have been addressed by now.
But the new renderers and dmabuf support are using graphics drivers
in different ways than the old gl renderer, and trigger new driver bugs.
Therefore, it is recommended to use the latest mesa release (24.2)
with the new renderers.
* GtkScale:
- Fix positioning of scale values
* GtkEmojiChooser:
- Make Control-clicks work for the recent section
* GtkPopover:
- Make sure focus lands on the right widget when cascading
* GtkSpinButton:
- Disable Emoji input for numeric spin buttons
* GtkSingleSelection:
- Implement unselect_all
* Accssibility:
- Fix roles for radio buttons
- Check if ATs are listening before exporting trees
- Add a check for sandboxed accessibility bus
- Fix handling of the error message relation
- Turn criticals into debug messages
- Set expanded states properly in menus
* CSS:
- Fix a few issues on bigendian systems
- Avoid a crash with relative colors
* GSK:
- Use the right GL context when exporting textures
- Don't let colors influence depth decisions
- Allow uploading of mipmap levels when tiling textures
* GDK:
- Update keysyms from libX11 1.8.10
- Implement cpu-side mipmapping
- Use a thread pool for color conversions and mipmapping
* Vulkan:
- Fix drag surface offsets
* Wayland:
- Fix a crash
- Associate EGL windows with context later
* X11:
- Fix initial EGL context creation
- Fix a problem with GL context creation
* Broadway:
- Implement compute_size and request_layout
* MacOS:
- Set transparent backgroiund for toplevel windows
* Windows:
- Improve debug output
- Detect Mesas d3d12 driver and request GDI compat
* Demos:
- Set window icons in demos
- Add a 64k x 64k image to the image scaling demo
* Translation updates
Belarusian
Brazilian Portuguese
Catalan
Czech
Galician
German
Hebrew
Indonesian
Korean
Lithuanian
Persian
Polish
Portuguese
Slovenian
Spanish
Turkish
Ukrainian
Overview of Changes in 4.15.6, 08-26-2024
=========================================
* GtkCheckButton:
- Add a grouped style class for radio buttons
* GtkScale:
- Fix alignment and positioning problems
* Css:
- Fix crashes in the variable support
* Gsk:
- Make graphics offloading work better with kwin
- Make colorstate transfer functions more robust
- GC dead textures more agressively
- Only use a single render pass per frame
* GL:
- Round damage rectangles properly
- Use the shared context when creating textures
- Fix a file descriptor leak in dmabuf export
* Vulkan:
- Round damage rectangles properly
* Wayland:
- Work with the kwin implementation of xx-color-management-v4
* Windows:
- Make gtk_show_uri use SHOpenWithDialog()
- Enable incremental rendering with WGL
* Macos:
- Open context menus on Ctrl-left click
* Debugging:
- Show color state information in the inspector
- Collect input event traces in the recorder
- Add shortcuts for toggling recording: Super-r
and for screenshots: Super-c
- Split the GDK_DEBUG env var into GDK_DEBUG and GDK_DISABLE
- Add GDK_DISABLE=color-mgmt and GDK_DISABLE=offload
* Tools:
- Add a 'Paste as node' action in gtk4-node-editor
* Translations updates
Basque
Belarusian
Brazilian Portuguese
Chinese (China)
Georgian
Hebrew
Hindi
Russian
Slovenian
Turkish
Ukrainian
Overview of Changes in 4.15.5, 11-08-2024
=========================================
* GtkTextView:
- ADd GtkTextBufferCommitNotify
* CSS:
- Propagate color state information to GSK for many features:
colors, borders, shadows, text
* Gdk:
- Fix an fd leak in the Vulkan code
- Fix a leak of EGLSurfaces and DMA buffers
- Set the opaque region of surfaces automatically based on their content
* Gsk:
- Fix Emoji rendering in Vulkan
- Rework color handling to take color states into account
- Implement more powerful occlusion culling
- Minimize our use of renderpasses
* Macos:
- Fix window transparency
* Debugging:
- The inspector shows details about color states
* Deprecations:
- gdk_draw_context_begin/end_frame
- gdk_surface_set_opaque_region
* Build:
- Require gstreamer 1.24
* Translation updates
Romanian
Overview of Changes in 4.15.4, 30-07-2024
=========================================
* GtkPopover:
- Fix size allocation with wrapping labels
* GtkColumnView:
- Check column visibility when measuring
* CSS:
- Fix fallout from recent changes
- Make implementation of currentcolor inheritance match browsers
* Gdk:
- Introduce GdkColorState for encoding color space information
Currently, we support srgb, srgb-linear, rec2100-pq and rec2100-linear
- Add color states to GdkTexture, as well as to the texture builder
and downloader objects, and convert as necessary
- Add GdkMemoryTextureBuilder
- Attach color states when loading or saving textures
- Add GdkCicpParams to create color state objects for cicp tuples
- Drop GDK_DEBUG=vulkan-validate
Use VK_INSTEANCE_LAYERS=VK_LAYER_KHRONOS_validation instead
* Gsk:
- Improve caching of glyphs and textures
- Remove the uber shader
- Numerous bug fixes
- Fix corner cases in offload handling
- Implement occlusion culling for opaque content
- Allow offloading (some) transformed textures
- Take colorstate into account when compositing
- Add GDK_DEBUG=linear to opt into linear compositing
- Implement tiling for large textures
- Stop using descriptors and go back to simpler texture
management that should work better with older GL
- Use correct shader clip mode for glyphs
- Improve shadow rendering
* Media:
- Attach color states to textures obtained from gstreamer
* Wayland:
- Allow offloading GL textures via dmabuf export
- Suppot the xx-color-management-v4 protocol
* Deprecations:
- GskGLShader and the render node
* Tools:
- Improve the rendernode tool extract command
- Add an image tool that is about manipulating textures
* Build:
- GTK now requires a C11 compiler
* Translation updates
Georgian
Hebrew
Hindi
Occitan
Slovenian
Overview of Changes in 4.15.3, 29-06-2024
=========================================

View File

@@ -53,7 +53,7 @@ Building and installing
In order to build GTK you will need:
- [a C99 compatible compiler](https://gitlab.gnome.org/GNOME/glib/-/blob/main/docs/toolchain-requirements.md)
- [a C11 compatible compiler](https://gitlab.gnome.org/GNOME/glib/-/blob/main/docs/toolchain-requirements.md)
- [Python 3](https://www.python.org/)
- [Meson](http://mesonbuild.com)
- [Ninja](https://ninja-build.org)
@@ -136,9 +136,13 @@ In the bug report please include:
- which version of GTK you are using
- what operating system and version
- what windowing system (X11 or Wayland)
- what graphics driver / mesa version
- for Linux, which distribution
- if you built GTK, the list of options used to configure the build
Most of this information can be found in the GTK inspector.
And anything else you think is relevant.
* How to reproduce the bug.

View File

@@ -196,10 +196,5 @@
}
]
}
],
"build-options" : {
"env" : {
"GSK_RENDERER" : "opengl"
}
}
]
}

View File

@@ -129,7 +129,6 @@
"build-options" : {
"env" : {
"DBUS_SESSION_BUS_ADDRESS" : "''",
"GSK_RENDERER" : "opengl",
"G_ENABLE_DEBUG" : "true"
}
}

View File

@@ -129,7 +129,6 @@
"build-options" : {
"env" : {
"DBUS_SESSION_BUS_ADDRESS" : "''",
"GSK_RENDERER" : "opengl",
"G_ENABLE_DEBUG" : "true"
}
}

View File

@@ -1,115 +0,0 @@
/*
* Copyright © 2019 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Matthias Clasen
*/
#include "config.h"
#include "constraint-editor-application.h"
#include "constraint-editor-window.h"
struct _ConstraintEditorApplication
{
GtkApplication parent_instance;
};
G_DEFINE_TYPE(ConstraintEditorApplication, constraint_editor_application, GTK_TYPE_APPLICATION);
static void
constraint_editor_application_init (ConstraintEditorApplication *app)
{
}
static void
quit_activated (GSimpleAction *action,
GVariant *parameter,
gpointer data)
{
g_application_quit (G_APPLICATION (data));
}
static GActionEntry app_entries[] =
{
{ "quit", quit_activated, NULL, NULL, NULL }
};
static void
constraint_editor_application_startup (GApplication *app)
{
const char *quit_accels[2] = { "<Ctrl>Q", NULL };
const char *open_accels[2] = { "<Ctrl>O", NULL };
GtkCssProvider *provider;
G_APPLICATION_CLASS (constraint_editor_application_parent_class)->startup (app);
g_action_map_add_action_entries (G_ACTION_MAP (app),
app_entries, G_N_ELEMENTS (app_entries),
app);
gtk_application_set_accels_for_action (GTK_APPLICATION (app), "app.quit", quit_accels);
gtk_application_set_accels_for_action (GTK_APPLICATION (app), "win.open", open_accels);
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_resource (provider, "/org/gtk/gtk4/constraint-editor/constraint-editor.css");
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
static void
constraint_editor_application_activate (GApplication *app)
{
ConstraintEditorWindow *win;
win = constraint_editor_window_new (CONSTRAINT_EDITOR_APPLICATION (app));
gtk_window_present (GTK_WINDOW (win));
}
static void
constraint_editor_application_open (GApplication *app,
GFile **files,
int n_files,
const char *hint)
{
ConstraintEditorWindow *win;
int i;
for (i = 0; i < n_files; i++)
{
win = constraint_editor_window_new (CONSTRAINT_EDITOR_APPLICATION (app));
constraint_editor_window_load (win, files[i]);
gtk_window_present (GTK_WINDOW (win));
}
}
static void
constraint_editor_application_class_init (ConstraintEditorApplicationClass *class)
{
GApplicationClass *application_class = G_APPLICATION_CLASS (class);
application_class->startup = constraint_editor_application_startup;
application_class->activate = constraint_editor_application_activate;
application_class->open = constraint_editor_application_open;
}
ConstraintEditorApplication *
constraint_editor_application_new (void)
{
return g_object_new (CONSTRAINT_EDITOR_APPLICATION_TYPE,
"application-id", "org.gtk.gtk4.ConstraintEditor",
"flags", G_APPLICATION_HANDLES_OPEN,
NULL);
}

View File

@@ -1,652 +0,0 @@
/*
* Copyright © 2019 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Matthias Clasen
*/
#include "config.h"
#include "constraint-editor-window.h"
#include "constraint-view.h"
#include "constraint-editor.h"
#include "guide-editor.h"
struct _ConstraintEditorWindow
{
GtkApplicationWindow parent_instance;
GtkWidget *paned;
GtkWidget *view;
GtkWidget *list;
};
G_DEFINE_TYPE(ConstraintEditorWindow, constraint_editor_window, GTK_TYPE_APPLICATION_WINDOW);
static GtkConstraintTarget *
find_target (GListModel *model,
GtkConstraintTarget *orig)
{
const char *name;
const char *model_name;
gpointer item;
int i;
if (orig == NULL)
return NULL;
if (GTK_IS_LABEL (orig))
name = gtk_label_get_label (GTK_LABEL (orig));
else if (GTK_IS_CONSTRAINT_GUIDE (orig))
name = gtk_constraint_guide_get_name (GTK_CONSTRAINT_GUIDE (orig));
else
{
g_warning ("Don't know how to handle %s targets", G_OBJECT_TYPE_NAME (orig));
return NULL;
}
for (i = 0; i < g_list_model_get_n_items (model); i++)
{
item = g_list_model_get_item (model, i);
g_object_unref (item);
if (GTK_IS_WIDGET (item))
model_name = gtk_widget_get_name (GTK_WIDGET (item));
else
model_name = gtk_constraint_guide_get_name (GTK_CONSTRAINT_GUIDE (item));
if (strcmp (name, model_name) == 0)
return GTK_CONSTRAINT_TARGET (item);
}
g_warning ("Failed to find target '%s'", name);
return NULL;
}
gboolean
constraint_editor_window_load (ConstraintEditorWindow *self,
GFile *file)
{
char *path;
GtkBuilder *builder;
GError *error = NULL;
GtkWidget *view;
GtkLayoutManager *layout;
GtkWidget *child;
const char *name;
gpointer item;
int i;
GListModel *list;
path = g_file_get_path (file);
builder = gtk_builder_new ();
if (!gtk_builder_add_from_file (builder, path, &error))
{
g_print ("Could not load %s: %s", path, error->message);
g_error_free (error);
g_free (path);
g_object_unref (builder);
return FALSE;
}
view = GTK_WIDGET (gtk_builder_get_object (builder, "view"));
if (!GTK_IS_BOX (view))
{
g_print ("Could not load %s: No GtkBox named 'view'", path);
g_free (path);
g_object_unref (builder);
return FALSE;
}
layout = gtk_widget_get_layout_manager (view);
if (!GTK_IS_CONSTRAINT_LAYOUT (layout))
{
g_print ("Could not load %s: Widget 'view' does not use GtkConstraintLayout", path);
g_free (path);
g_object_unref (builder);
return FALSE;
}
for (child = gtk_widget_get_first_child (view);
child;
child = gtk_widget_get_next_sibling (child))
{
if (!GTK_IS_LABEL (child))
{
g_print ("Skipping non-GtkLabel child\n");
continue;
}
name = gtk_label_get_label (GTK_LABEL (child));
constraint_view_add_child (CONSTRAINT_VIEW (self->view), name);
}
list = gtk_constraint_layout_observe_guides (GTK_CONSTRAINT_LAYOUT (layout));
for (i = 0; i < g_list_model_get_n_items (list); i++)
{
GtkConstraintGuide *guide, *clone;
int w, h;
item = g_list_model_get_item (list, i);
guide = GTK_CONSTRAINT_GUIDE (item);
/* need to clone here, to attach to the right targets */
clone = gtk_constraint_guide_new ();
gtk_constraint_guide_set_name (clone, gtk_constraint_guide_get_name (guide));
gtk_constraint_guide_set_strength (clone, gtk_constraint_guide_get_strength (guide));
gtk_constraint_guide_get_min_size (guide, &w, &h);
gtk_constraint_guide_set_min_size (clone, w, h);
gtk_constraint_guide_get_nat_size (guide, &w, &h);
gtk_constraint_guide_set_nat_size (clone, w, h);
gtk_constraint_guide_get_max_size (guide, &w, &h);
gtk_constraint_guide_set_max_size (clone, w, h);
constraint_view_add_guide (CONSTRAINT_VIEW (self->view), clone);
g_object_unref (guide);
g_object_unref (clone);
}
g_object_unref (list);
list = gtk_constraint_layout_observe_constraints (GTK_CONSTRAINT_LAYOUT (layout));
for (i = 0; i < g_list_model_get_n_items (list); i++)
{
GtkConstraint *constraint;
GtkConstraint *clone;
GtkConstraintTarget *target;
GtkConstraintTarget *source;
GtkConstraintAttribute source_attr;
item = g_list_model_get_item (list, i);
constraint = GTK_CONSTRAINT (item);
target = gtk_constraint_get_target (constraint);
source = gtk_constraint_get_source (constraint);
source_attr = gtk_constraint_get_source_attribute (constraint);
if (source == NULL && source_attr == GTK_CONSTRAINT_ATTRIBUTE_NONE)
clone = gtk_constraint_new_constant (find_target (constraint_view_get_model (CONSTRAINT_VIEW (self->view)), target),
gtk_constraint_get_target_attribute (constraint),
gtk_constraint_get_relation (constraint),
gtk_constraint_get_constant (constraint),
gtk_constraint_get_strength (constraint));
else
clone = gtk_constraint_new (find_target (constraint_view_get_model (CONSTRAINT_VIEW (self->view)), target),
gtk_constraint_get_target_attribute (constraint),
gtk_constraint_get_relation (constraint),
find_target (constraint_view_get_model (CONSTRAINT_VIEW (self->view)), source),
source_attr,
gtk_constraint_get_multiplier (constraint),
gtk_constraint_get_constant (constraint),
gtk_constraint_get_strength (constraint));
constraint_view_add_constraint (CONSTRAINT_VIEW (self->view), clone);
g_object_unref (constraint);
g_object_unref (clone);
}
g_object_unref (list);
g_free (path);
g_object_unref (builder);
return TRUE;
}
static void
open_response_cb (GObject *source,
GAsyncResult *result,
void *user_data)
{
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
ConstraintEditorWindow *self = user_data;
GFile *file;
file = gtk_file_dialog_open_finish (dialog, result, NULL);
if (file)
{
constraint_editor_window_load (self, file);
g_object_unref (file);
}
}
static void
open_cb (GtkWidget *button,
ConstraintEditorWindow *self)
{
GtkFileDialog *dialog;
GFile *cwd;
dialog = gtk_file_dialog_new ();
gtk_file_dialog_set_title (dialog, "Open file");
cwd = g_file_new_for_path (".");
gtk_file_dialog_set_initial_folder (dialog, cwd);
g_object_unref (cwd);
gtk_file_dialog_open (dialog, GTK_WINDOW (self), NULL, open_response_cb, self);
g_object_unref (dialog);
}
static void
serialize_child (GString *str,
int indent,
GtkWidget *child)
{
const char *name;
name = gtk_widget_get_name (child);
g_string_append_printf (str, "%*s<child>\n", indent, "");
g_string_append_printf (str, "%*s <object class=\"GtkLabel\" id=\"%s\">\n", indent, "", name);
g_string_append_printf (str, "%*s <property name=\"label\">%s</property>\n", indent, "", name);
g_string_append_printf (str, "%*s </object>\n", indent, "");
g_string_append_printf (str, "%*s</child>\n", indent, "");
}
static char *
serialize_model (GListModel *list)
{
GString *str = g_string_new ("");
int i;
g_string_append (str, "<interface>\n");
g_string_append (str, " <object class=\"GtkBox\" id=\"view\">\n");
g_string_append (str, " <property name=\"layout-manager\">\n");
g_string_append (str, " <object class=\"GtkConstraintLayout\">\n");
g_string_append (str, " <constraints>\n");
for (i = 0; i < g_list_model_get_n_items (list); i++)
{
gpointer item = g_list_model_get_item (list, i);
g_object_unref (item);
if (GTK_IS_CONSTRAINT (item))
constraint_editor_serialize_constraint (str, 10, GTK_CONSTRAINT (item));
else if (GTK_IS_CONSTRAINT_GUIDE (item))
guide_editor_serialize_guide (str, 10, GTK_CONSTRAINT_GUIDE (item));
}
g_string_append (str, " </constraints>\n");
g_string_append (str, " </object>\n");
g_string_append (str, " </property>\n");
for (i = 0; i < g_list_model_get_n_items (list); i++)
{
gpointer item = g_list_model_get_item (list, i);
g_object_unref (item);
if (GTK_IS_WIDGET (item))
serialize_child (str, 4, GTK_WIDGET (item));
}
g_string_append (str, " </object>\n");
g_string_append (str, "</interface>\n");
return g_string_free (str, FALSE);
}
static void
save_response_cb (GObject *source,
GAsyncResult *result,
void *user_data)
{
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
ConstraintEditorWindow *self = user_data;
GFile *file;
file = gtk_file_dialog_save_finish (dialog, result, NULL);
if (file)
{
GListModel *model;
char *text;
GError *error = NULL;
model = constraint_view_get_model (CONSTRAINT_VIEW (self->view));
text = serialize_model (model);
g_file_replace_contents (file, text, strlen (text),
NULL, FALSE,
G_FILE_CREATE_NONE,
NULL,
NULL,
&error);
if (error != NULL)
{
GtkAlertDialog *alert;
alert = gtk_alert_dialog_new ("Saving failed");
gtk_alert_dialog_set_detail (alert, error->message);
gtk_alert_dialog_show (alert,
GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (self))));
g_object_unref (alert);
g_error_free (error);
}
g_free (text);
g_object_unref (file);
}
}
static void
save_cb (GtkWidget *button,
ConstraintEditorWindow *self)
{
GtkFileDialog *dialog;
GFile *cwd;
dialog = gtk_file_dialog_new ();
gtk_file_dialog_set_title (dialog, "Save constraints");
cwd = g_file_new_for_path (".");
gtk_file_dialog_set_initial_folder (dialog, cwd);
g_object_unref (cwd);
gtk_file_dialog_save (dialog,
GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (button))),
NULL,
save_response_cb, self);
g_object_unref (dialog);
}
static void
constraint_editor_window_dispose (GObject *object)
{
gtk_widget_dispose_template (GTK_WIDGET (object), CONSTRAINT_EDITOR_WINDOW_TYPE);
G_OBJECT_CLASS (constraint_editor_window_parent_class)->dispose (object);
}
static int child_counter;
static int guide_counter;
static void
add_child (ConstraintEditorWindow *win)
{
char *name;
child_counter++;
name = g_strdup_printf ("Child %d", child_counter);
constraint_view_add_child (CONSTRAINT_VIEW (win->view), name);
g_free (name);
}
static void
add_guide (ConstraintEditorWindow *win)
{
char *name;
GtkConstraintGuide *guide;
guide_counter++;
name = g_strdup_printf ("Guide %d", guide_counter);
guide = gtk_constraint_guide_new ();
gtk_constraint_guide_set_name (guide, name);
g_free (name);
constraint_view_add_guide (CONSTRAINT_VIEW (win->view), guide);
}
static void
constraint_editor_done (ConstraintEditor *editor,
GtkConstraint *constraint,
ConstraintEditorWindow *win)
{
GtkConstraint *old_constraint;
g_object_get (editor, "constraint", &old_constraint, NULL);
if (old_constraint)
constraint_view_remove_constraint (CONSTRAINT_VIEW (win->view), old_constraint);
constraint_view_add_constraint (CONSTRAINT_VIEW (win->view), constraint);
g_clear_object (&old_constraint);
gtk_window_destroy (GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (editor), GTK_TYPE_WINDOW)));
}
static void
edit_constraint (ConstraintEditorWindow *win,
GtkConstraint *constraint)
{
GtkWidget *window;
ConstraintEditor *editor;
GListModel *model;
window = gtk_window_new ();
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (win));
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
if (constraint)
gtk_window_set_title (GTK_WINDOW (window), "Edit Constraint");
else
gtk_window_set_title (GTK_WINDOW (window), "Create Constraint");
model = constraint_view_get_model (CONSTRAINT_VIEW (win->view));
editor = constraint_editor_new (model, constraint);
gtk_window_set_child (GTK_WINDOW (window), GTK_WIDGET (editor));
g_signal_connect (editor, "done", G_CALLBACK (constraint_editor_done), win);
gtk_window_present (GTK_WINDOW (window));
}
static void
add_constraint (ConstraintEditorWindow *win)
{
edit_constraint (win, NULL);
}
static void
guide_editor_done (GuideEditor *editor,
GtkConstraintGuide *guide,
ConstraintEditorWindow *win)
{
gtk_window_destroy (GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (editor), GTK_TYPE_WINDOW)));
}
static void
edit_guide (ConstraintEditorWindow *win,
GtkConstraintGuide *guide)
{
GtkWidget *window;
GuideEditor *editor;
window = gtk_window_new ();
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (win));
gtk_window_set_title (GTK_WINDOW (window), "Edit Guide");
editor = guide_editor_new (guide);
gtk_window_set_child (GTK_WINDOW (window), GTK_WIDGET (editor));
g_signal_connect (editor, "done", G_CALLBACK (guide_editor_done), win);
gtk_window_present (GTK_WINDOW (window));
}
static void
row_activated (GtkListBox *list,
GtkListBoxRow *row,
ConstraintEditorWindow *win)
{
GObject *item;
item = G_OBJECT (g_object_get_data (G_OBJECT (row), "item"));
if (GTK_IS_CONSTRAINT (item))
edit_constraint (win, GTK_CONSTRAINT (item));
else if (GTK_IS_CONSTRAINT_GUIDE (item))
edit_guide (win, GTK_CONSTRAINT_GUIDE (item));
}
static void
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,
"/org/gtk/gtk4/constraint-editor/constraint-editor-window.ui");
gtk_widget_class_bind_template_child (widget_class, ConstraintEditorWindow, paned);
gtk_widget_class_bind_template_child (widget_class, ConstraintEditorWindow, view);
gtk_widget_class_bind_template_child (widget_class, ConstraintEditorWindow, list);
gtk_widget_class_bind_template_callback (widget_class, open_cb);
gtk_widget_class_bind_template_callback (widget_class, save_cb);
gtk_widget_class_bind_template_callback (widget_class, add_child);
gtk_widget_class_bind_template_callback (widget_class, add_guide);
gtk_widget_class_bind_template_callback (widget_class, add_constraint);
gtk_widget_class_bind_template_callback (widget_class, row_activated);
}
static void
row_edit (GtkButton *button,
ConstraintEditorWindow *win)
{
GtkWidget *row;
GObject *item;
row = gtk_widget_get_ancestor (GTK_WIDGET (button), GTK_TYPE_LIST_BOX_ROW);
item = (GObject *)g_object_get_data (G_OBJECT (row), "item");
if (GTK_IS_CONSTRAINT (item))
edit_constraint (win, GTK_CONSTRAINT (item));
else if (GTK_IS_CONSTRAINT_GUIDE (item))
edit_guide (win, GTK_CONSTRAINT_GUIDE (item));
}
static void
mark_constraints_invalid (ConstraintEditorWindow *win,
gpointer removed)
{
GtkWidget *child;
GObject *item;
for (child = gtk_widget_get_first_child (win->list);
child;
child = gtk_widget_get_next_sibling (child))
{
item = (GObject *)g_object_get_data (G_OBJECT (child), "item");
if (GTK_IS_CONSTRAINT (item))
{
GtkConstraint *constraint = GTK_CONSTRAINT (item);
if (gtk_constraint_get_target (constraint) == (GtkConstraintTarget *)removed ||
gtk_constraint_get_source (constraint) == (GtkConstraintTarget *)removed)
{
GtkWidget *button;
button = (GtkWidget *)g_object_get_data (G_OBJECT (child), "edit");
gtk_button_set_icon_name (GTK_BUTTON (button), "dialog-warning-symbolic");
gtk_widget_set_tooltip_text (button, "Constraint is invalid");
}
}
}
}
static void
row_delete (GtkButton *button,
ConstraintEditorWindow *win)
{
GtkWidget *row;
GObject *item;
row = gtk_widget_get_ancestor (GTK_WIDGET (button), GTK_TYPE_LIST_BOX_ROW);
item = (GObject *)g_object_get_data (G_OBJECT (row), "item");
if (GTK_IS_CONSTRAINT (item))
constraint_view_remove_constraint (CONSTRAINT_VIEW (win->view),
GTK_CONSTRAINT (item));
else if (GTK_IS_CONSTRAINT_GUIDE (item))
{
mark_constraints_invalid (win, item);
constraint_view_remove_guide (CONSTRAINT_VIEW (win->view),
GTK_CONSTRAINT_GUIDE (item));
}
else if (GTK_IS_WIDGET (item))
{
mark_constraints_invalid (win, item);
constraint_view_remove_child (CONSTRAINT_VIEW (win->view),
GTK_WIDGET (item));
}
}
static GtkWidget *
create_widget_func (gpointer item,
gpointer user_data)
{
ConstraintEditorWindow *win = user_data;
const char *name;
char *freeme = NULL;
GtkWidget *row, *box, *label, *button;
if (GTK_IS_WIDGET (item))
name = gtk_widget_get_name (GTK_WIDGET (item));
else if (GTK_IS_CONSTRAINT_GUIDE (item))
name = gtk_constraint_guide_get_name (GTK_CONSTRAINT_GUIDE (item));
else if (GTK_IS_CONSTRAINT (item))
name = freeme = constraint_editor_constraint_to_string (GTK_CONSTRAINT (item));
else
name = "";
row = gtk_list_box_row_new ();
g_object_set_data_full (G_OBJECT (row), "item", g_object_ref (item), g_object_unref);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
label = gtk_label_new (name);
if (GTK_IS_WIDGET (item) || GTK_IS_CONSTRAINT_GUIDE (item))
g_object_bind_property (item, "name",
label, "label",
G_BINDING_DEFAULT);
gtk_widget_set_margin_start (label, 10);
gtk_widget_set_margin_end (label, 10);
gtk_widget_set_margin_top (label, 10);
gtk_widget_set_margin_bottom (label, 10);
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
gtk_widget_set_hexpand (label, TRUE);
gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), box);
gtk_box_append (GTK_BOX (box), label);
if (GTK_IS_CONSTRAINT (item) || GTK_IS_CONSTRAINT_GUIDE (item))
{
button = gtk_button_new_from_icon_name ("document-edit-symbolic");
gtk_button_set_has_frame (GTK_BUTTON (button), FALSE);
g_signal_connect (button, "clicked", G_CALLBACK (row_edit), win);
g_object_set_data (G_OBJECT (row), "edit", button);
gtk_box_append (GTK_BOX (box), button);
button = gtk_button_new_from_icon_name ("edit-delete-symbolic");
gtk_button_set_has_frame (GTK_BUTTON (button), FALSE);
g_signal_connect (button, "clicked", G_CALLBACK (row_delete), win);
gtk_box_append (GTK_BOX (box), button);
}
else if (GTK_IS_WIDGET (item))
{
button = gtk_button_new_from_icon_name ("edit-delete-symbolic");
gtk_button_set_has_frame (GTK_BUTTON (button), FALSE);
g_signal_connect (button, "clicked", G_CALLBACK (row_delete), win);
gtk_box_append (GTK_BOX (box), button);
}
g_free (freeme);
return row;
}
static void
constraint_editor_window_init (ConstraintEditorWindow *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
gtk_list_box_bind_model (GTK_LIST_BOX (self->list),
constraint_view_get_model (CONSTRAINT_VIEW (self->view)),
create_widget_func,
self,
NULL);
}
ConstraintEditorWindow *
constraint_editor_window_new (ConstraintEditorApplication *application)
{
return g_object_new (CONSTRAINT_EDITOR_WINDOW_TYPE,
"application", application,
NULL);
}

View File

@@ -1,34 +0,0 @@
/*
* Copyright © 2019 Red Hat, Inc
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Matthias Clasen
*/
#pragma once
#include <gtk/gtk.h>
#include "constraint-editor-application.h"
#define CONSTRAINT_EDITOR_WINDOW_TYPE (constraint_editor_window_get_type ())
G_DECLARE_FINAL_TYPE (ConstraintEditorWindow, constraint_editor_window, CONSTRAINT, EDITOR_WINDOW, GtkApplicationWindow)
ConstraintEditorWindow * constraint_editor_window_new (ConstraintEditorApplication *application);
gboolean constraint_editor_window_load (ConstraintEditorWindow *self,
GFile *file);

View File

@@ -1,77 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="ConstraintEditorWindow" parent="GtkApplicationWindow">
<property name="title" translatable="yes">GTK Constraint Editor</property>
<property name="default-width">1024</property>
<property name="default-height">768</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="header">
<child type="start">
<object class="GtkButton">
<property name="icon-name">document-open-symbolic</property>
<property name="tooltip-text">Open ui file</property>
<signal name="clicked" handler="open_cb"/>
</object>
</child>
<child type="start">
<object class="GtkButton">
<property name="icon-name">document-save-symbolic</property>
<property name="tooltip-text">Save to ui file</property>
<signal name="clicked" handler="save_cb"/>
</object>
</child>
</object>
</child>
<child>
<object class="GtkPaned" id="paned">
<property name="orientation">horizontal</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<property name="orientation">horizontal</property>
<child>
<object class="GtkButton">
<property name="label">Add Child</property>
<signal name="clicked" handler="add_child" swapped="yes"/>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label">Add Guide</property>
<signal name="clicked" handler="add_guide" swapped="yes"/>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label">Add Constraint</property>
<signal name="clicked" handler="add_constraint" swapped="yes"/>
</object>
</child>
</object>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="hscrollbar-policy">never</property>
<property name="vscrollbar-policy">automatic</property>
<property name="vexpand">1</property>
<child>
<object class="GtkListBox" id="list">
<property name="show-separators">1</property>
<property name="selection-mode">none</property>
<signal name="row-activated" handler="row_activated"/>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="ConstraintView" id="view">
</object>
</child>
</object>
</child>
</template>
</interface>

View File

@@ -1,716 +0,0 @@
/*
* Copyright © 2019 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Matthias Clasen
*/
#include "config.h"
#include "constraint-editor.h"
#include "constraint-view.h"
struct _ConstraintEditor
{
GtkWidget parent_instance;
GtkWidget *grid;
GtkWidget *target;
GtkWidget *target_attr;
GtkWidget *relation;
GtkWidget *source;
GtkWidget *source_attr;
GtkWidget *multiplier;
GtkWidget *constant;
GtkWidget *strength;
GtkWidget *preview;
GtkWidget *button;
GtkConstraint *constraint;
GListModel *model;
gboolean constructed;
};
enum {
PROP_MODEL = 1,
PROP_CONSTRAINT,
LAST_PROP
};
static GParamSpec *pspecs[LAST_PROP];
enum {
DONE,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL];
G_DEFINE_TYPE(ConstraintEditor, constraint_editor, GTK_TYPE_WIDGET);
static const char *
get_target_name (GtkConstraintTarget *target)
{
if (target == NULL)
return "Super";
else if (GTK_IS_WIDGET (target))
return gtk_widget_get_name (GTK_WIDGET (target));
else if (GTK_IS_CONSTRAINT_GUIDE (target))
return gtk_constraint_guide_get_name (GTK_CONSTRAINT_GUIDE (target));
else
return "";
}
static void
constraint_target_combo (GListModel *model,
GtkWidget *combo,
gboolean is_source)
{
GtkStringList *targets;
int i;
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);
if (GTK_IS_CONSTRAINT (item))
continue;
gtk_string_list_append (targets, get_target_name (GTK_CONSTRAINT_TARGET (item)));
g_object_unref (item);
}
}
gtk_drop_down_set_model (GTK_DROP_DOWN (combo), G_LIST_MODEL (targets));
g_object_unref (targets);
}
static gpointer
get_target (GListModel *model,
const char *id)
{
int i;
if (id == NULL)
return NULL;
if (strcmp ("Super", id) == 0)
return NULL;
for (i = 0; i < g_list_model_get_n_items (model); i++)
{
GObject *item = g_list_model_get_object (model, i);
g_object_unref (item);
if (GTK_IS_CONSTRAINT (item))
continue;
else if (GTK_IS_WIDGET (item))
{
if (strcmp (id, gtk_widget_get_name (GTK_WIDGET (item))) == 0)
return item;
}
else if (GTK_IS_CONSTRAINT_GUIDE (item))
{
if (strcmp (id, gtk_constraint_guide_get_name (GTK_CONSTRAINT_GUIDE (item))) == 0)
return item;
}
}
return NULL;
}
static void
select_target (GtkDropDown *combo,
const char *target_name)
{
GListModel *model = gtk_drop_down_get_model (combo);
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 *
get_attr_nick (GtkConstraintAttribute attr)
{
GEnumClass *class = g_type_class_ref (GTK_TYPE_CONSTRAINT_ATTRIBUTE);
GEnumValue *value = g_enum_get_value (class, attr);
const char *nick = value->value_nick;
g_type_class_unref (class);
return nick;
}
static GtkConstraintRelation
get_relation (unsigned int id)
{
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 ();
}
}
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 *
get_relation_nick (GtkConstraintRelation relation)
{
GEnumClass *class = g_type_class_ref (GTK_TYPE_CONSTRAINT_RELATION);
GEnumValue *value = g_enum_get_value (class, relation);
const char *nick = value->value_nick;
g_type_class_unref (class);
return nick;
}
static const char *
get_relation_display_name (GtkConstraintRelation relation)
{
switch (relation)
{
case GTK_CONSTRAINT_RELATION_LE:
return "";
case GTK_CONSTRAINT_RELATION_EQ:
return "=";
case GTK_CONSTRAINT_RELATION_GE:
return "";
default:
return "?";
}
}
static GtkConstraintStrength
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 ();
}
}
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 *
get_strength_nick (GtkConstraintStrength strength)
{
GEnumClass *class = g_type_class_ref (GTK_TYPE_CONSTRAINT_STRENGTH);
GEnumValue *value = g_enum_get_value (class, strength);
const char *nick = value->value_nick;
g_type_class_unref (class);
return nick;
}
void
constraint_editor_serialize_constraint (GString *str,
int indent,
GtkConstraint *constraint)
{
const char *target;
const char *target_attr;
const char *relation;
const char *source;
const char *source_attr;
double multiplier;
double constant;
const char *strength;
target = get_target_name (gtk_constraint_get_target (constraint));
target_attr = get_attr_nick (gtk_constraint_get_target_attribute (constraint));
relation = get_relation_nick (gtk_constraint_get_relation (constraint));
source = get_target_name (gtk_constraint_get_source (constraint));
source_attr = get_attr_nick (gtk_constraint_get_source_attribute (constraint));
multiplier = gtk_constraint_get_multiplier (constraint);
constant = gtk_constraint_get_constant (constraint);
strength = get_strength_nick (gtk_constraint_get_strength (constraint));
g_string_append_printf (str, "%*s<constraint target=\"%s\" target-attribute=\"%s\"\n", indent, "", target, target_attr);
g_string_append_printf (str, "%*s relation=\"%s\"\n", indent, "", relation);
if (strcmp (source_attr, "none") != 0)
{
g_string_append_printf (str, "%*s source=\"%s\" source-attribute=\"%s\"\n", indent, "", source, source_attr);
g_string_append_printf (str, "%*s multiplier=\"%g\"\n", indent, "", multiplier);
}
g_string_append_printf (str, "%*s constant=\"%g\"\n", indent, "", constant);
g_string_append_printf (str, "%*s strength=\"%s\" />\n", indent, "", strength);
}
static void
create_constraint (GtkButton *button,
ConstraintEditor *editor)
{
gpointer obj;
gpointer target;
GtkConstraintAttribute target_attr;
gpointer source;
GtkConstraintAttribute source_attr;
GtkConstraintRelation relation;
double multiplier;
double constant;
int strength;
GtkConstraint *constraint;
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)));
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)));
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);
strength = get_strength (gtk_drop_down_get_selected (GTK_DROP_DOWN (editor->strength)));
constraint = gtk_constraint_new (target, target_attr,
relation,
source, source_attr,
multiplier,
constant,
strength);
g_signal_emit (editor, signals[DONE], 0, constraint);
g_object_unref (constraint);
}
static void
source_attr_changed (ConstraintEditor *editor)
{
if (get_attr (gtk_drop_down_get_selected (GTK_DROP_DOWN (editor->source_attr))) == GTK_CONSTRAINT_ATTRIBUTE_NONE)
{
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);
}
else
{
gtk_widget_set_sensitive (editor->source, TRUE);
gtk_widget_set_sensitive (editor->multiplier, TRUE);
gtk_editable_set_text (GTK_EDITABLE (editor->multiplier), "1");
}
}
char *
constraint_editor_constraint_to_string (GtkConstraint *constraint)
{
GString *str;
const char *name;
const char *attr;
const char *relation;
double c, m;
str = g_string_new ("");
name = get_target_name (gtk_constraint_get_target (constraint));
attr = get_attr_nick (gtk_constraint_get_target_attribute (constraint));
relation = get_relation_display_name (gtk_constraint_get_relation (constraint));
if (name == NULL)
name = "[ ]";
g_string_append_printf (str, "%s.%s %s ", name, attr, relation);
c = gtk_constraint_get_constant (constraint);
attr = get_attr_nick (gtk_constraint_get_source_attribute (constraint));
if (strcmp (attr, "none") != 0)
{
name = get_target_name (gtk_constraint_get_source (constraint));
m = gtk_constraint_get_multiplier (constraint);
if (name == NULL)
name = "[ ]";
g_string_append_printf (str, "%s.%s", name, attr);
if (m != 1.0)
g_string_append_printf (str, " × %g", m);
if (c > 0.0)
g_string_append_printf (str, " + %g", c);
else if (c < 0.0)
g_string_append_printf (str, " - %g", -c);
}
else
g_string_append_printf (str, "%g", c);
return g_string_free (str, FALSE);
}
static void
update_preview (ConstraintEditor *editor)
{
GString *str;
const char *name;
const char *attr;
const char *relation;
const char *multiplier;
const char *constant;
double c, m;
if (!editor->constructed)
return;
str = g_string_new ("");
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);
constant = gtk_editable_get_text (GTK_EDITABLE (editor->constant));
c = g_ascii_strtod (constant, NULL);
attr = get_attr_nick (get_attr (gtk_drop_down_get_selected (GTK_DROP_DOWN (editor->source_attr))));
if (strcmp (attr, "none") != 0)
{
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);
if (name == NULL)
name = "[ ]";
g_string_append_printf (str, "%s.%s", name, attr);
if (m != 1.0)
g_string_append_printf (str, " × %g", m);
if (c > 0.0)
g_string_append_printf (str, " + %g", c);
else if (c < 0.0)
g_string_append_printf (str, " - %g", -c);
}
else
g_string_append_printf (str, "%g", c);
gtk_label_set_label (GTK_LABEL (editor->preview), str->str);
g_string_free (str, TRUE);
}
static void
update_button (ConstraintEditor *editor)
{
gpointer obj;
const char *target;
const char *source;
GtkConstraintAttribute source_attr = get_attr (gtk_drop_down_get_selected (GTK_DROP_DOWN (editor->source_attr)));
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);
}
static void
constraint_editor_init (ConstraintEditor *editor)
{
gtk_widget_init_template (GTK_WIDGET (editor));
}
static void
constraint_editor_constructed (GObject *object)
{
ConstraintEditor *editor = CONSTRAINT_EDITOR (object);
constraint_target_combo (editor->model, editor->target, FALSE);
constraint_target_combo (editor->model, editor->source, TRUE);
if (editor->constraint)
{
GtkConstraintTarget *target;
GtkConstraintAttribute attr;
GtkConstraintRelation relation;
GtkConstraintStrength strength;
char *val;
double multiplier;
double constant;
target = gtk_constraint_get_target (editor->constraint);
select_target (GTK_DROP_DOWN (editor->target), get_target_name (target));
attr = gtk_constraint_get_target_attribute (editor->constraint);
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->target_attr), get_attr_id (attr));
target = gtk_constraint_get_source (editor->constraint);
select_target (GTK_DROP_DOWN (editor->source), get_target_name (target));
attr = gtk_constraint_get_source_attribute (editor->constraint);
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->source_attr), get_attr_id (attr));
relation = gtk_constraint_get_relation (editor->constraint);
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);
gtk_editable_set_text (GTK_EDITABLE (editor->multiplier), val);
g_free (val);
constant = gtk_constraint_get_constant (editor->constraint);
val = g_strdup_printf ("%g", constant);
gtk_editable_set_text (GTK_EDITABLE (editor->constant), val);
g_free (val);
strength = gtk_constraint_get_strength (editor->constraint);
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_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");
gtk_button_set_label (GTK_BUTTON (editor->button), "Create");
}
editor->constructed = TRUE;
update_preview (editor);
update_button (editor);
}
static void
constraint_editor_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
ConstraintEditor *self = CONSTRAINT_EDITOR (object);
switch (property_id)
{
case PROP_MODEL:
self->model = g_value_dup_object (value);
break;
case PROP_CONSTRAINT:
self->constraint = g_value_dup_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
static void
constraint_editor_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
ConstraintEditor *self = CONSTRAINT_EDITOR (object);
switch (property_id)
{
case PROP_MODEL:
g_value_set_object (value, self->model);
break;
case PROP_CONSTRAINT:
g_value_set_object (value, self->constraint);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
static void
constraint_editor_dispose (GObject *object)
{
ConstraintEditor *self = (ConstraintEditor *)object;
g_clear_object (&self->model);
g_clear_object (&self->constraint);
gtk_widget_dispose_template (GTK_WIDGET (object), CONSTRAINT_EDITOR_TYPE);
G_OBJECT_CLASS (constraint_editor_parent_class)->dispose (object);
}
static void
constraint_editor_class_init (ConstraintEditorClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
object_class->constructed = constraint_editor_constructed;
object_class->dispose = constraint_editor_dispose;
object_class->set_property = constraint_editor_set_property;
object_class->get_property = constraint_editor_get_property;
pspecs[PROP_CONSTRAINT] =
g_param_spec_object ("constraint", "constraint", "constraint",
GTK_TYPE_CONSTRAINT,
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY);
pspecs[PROP_MODEL] =
g_param_spec_object ("model", "model", "model",
G_TYPE_LIST_MODEL,
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_properties (object_class, LAST_PROP, pspecs);
signals[DONE] =
g_signal_new ("done",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
NULL,
G_TYPE_NONE, 1, GTK_TYPE_CONSTRAINT);
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gtk/gtk4/constraint-editor/constraint-editor.ui");
gtk_widget_class_bind_template_child (widget_class, ConstraintEditor, grid);
gtk_widget_class_bind_template_child (widget_class, ConstraintEditor, target);
gtk_widget_class_bind_template_child (widget_class, ConstraintEditor, target_attr);
gtk_widget_class_bind_template_child (widget_class, ConstraintEditor, relation);
gtk_widget_class_bind_template_child (widget_class, ConstraintEditor, source);
gtk_widget_class_bind_template_child (widget_class, ConstraintEditor, source_attr);
gtk_widget_class_bind_template_child (widget_class, ConstraintEditor, multiplier);
gtk_widget_class_bind_template_child (widget_class, ConstraintEditor, constant);
gtk_widget_class_bind_template_child (widget_class, ConstraintEditor, strength);
gtk_widget_class_bind_template_child (widget_class, ConstraintEditor, preview);
gtk_widget_class_bind_template_child (widget_class, ConstraintEditor, button);
gtk_widget_class_bind_template_callback (widget_class, update_preview);
gtk_widget_class_bind_template_callback (widget_class, update_button);
gtk_widget_class_bind_template_callback (widget_class, create_constraint);
gtk_widget_class_bind_template_callback (widget_class, source_attr_changed);
}
ConstraintEditor *
constraint_editor_new (GListModel *model,
GtkConstraint *constraint)
{
return g_object_new (CONSTRAINT_EDITOR_TYPE,
"model", model,
"constraint", constraint,
NULL);
}

View File

@@ -1,12 +0,0 @@
constraintview {
background: black;
color: white;
}
constraintview .child {
background: red;
}
constraintview .guide {
background: blue;
}

View File

@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gtk/gtk4/constraint-editor">
<file preprocess="xml-stripblanks">constraint-editor-window.ui</file>
<file preprocess="xml-stripblanks">constraint-editor.ui</file>
<file preprocess="xml-stripblanks">guide-editor.ui</file>
<file>constraint-editor.css</file>
</gresource>
</gresources>

View File

@@ -1,34 +0,0 @@
/*
* Copyright © 2019 Red Hat, Inc
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Matthias Clasen
*/
#pragma once
#include <gtk/gtk.h>
#define CONSTRAINT_EDITOR_TYPE (constraint_editor_get_type ())
G_DECLARE_FINAL_TYPE (ConstraintEditor, constraint_editor, CONSTRAINT, EDITOR, GtkWidget)
ConstraintEditor * constraint_editor_new (GListModel *model,
GtkConstraint *constraint);
void constraint_editor_serialize_constraint (GString *str,
int indent,
GtkConstraint *constraint);
char *constraint_editor_constraint_to_string (GtkConstraint *constraint);

View File

@@ -1,204 +0,0 @@
<?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">
<property name="margin-start">20</property>
<property name="margin-end">20</property>
<property name="margin-top">20</property>
<property name="margin-bottom">20</property>
<property name="row-spacing">10</property>
<property name="column-spacing">10</property>
<child>
<object class="GtkLabel">
<property name="label">Target</property>
<layout>
<property name="column">0</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<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>
</layout>
</object>
</child>
<child>
<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>
</layout>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Relation</property>
<layout>
<property name="column">0</property>
<property name="row">2</property>
</layout>
</object>
</child>
<child>
<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>
</layout>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Source</property>
<layout>
<property name="column">0</property>
<property name="row">3</property>
</layout>
</object>
</child>
<child>
<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>
</layout>
</object>
</child>
<child>
<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>
</layout>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Multiplier</property>
<layout>
<property name="column">0</property>
<property name="row">4</property>
</layout>
</object>
</child>
<child>
<object class="GtkEntry" id="multiplier">
<signal name="changed" handler="update_preview" swapped="yes"/>
<layout>
<property name="column">1</property>
<property name="row">4</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Constant</property>
<layout>
<property name="column">0</property>
<property name="row">5</property>
</layout>
</object>
</child>
<child>
<object class="GtkEntry" id="constant">
<signal name="changed" handler="update_preview" swapped="yes"/>
<layout>
<property name="column">1</property>
<property name="row">5</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Strength</property>
<layout>
<property name="column">0</property>
<property name="row">6</property>
</layout>
</object>
</child>
<child>
<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>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="preview">
<property name="xalign">0</property>
<layout>
<property name="column">1</property>
<property name="row">7</property>
<property name="column-span">2</property>
</layout>
<attributes>
<attribute name="scale" value="1.44"/>
</attributes>
</object>
</child>
<child>
<object class="GtkButton" id="button">
<property name="label">Create</property>
<signal name="clicked" handler="create_constraint"/>
<layout>
<property name="column">2</property>
<property name="row">8</property>
</layout>
</object>
</child>
</object>
</child>
</template>
</interface>

View File

@@ -1,93 +0,0 @@
/*
* Copyright © 2019 Red Hat, Inc
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Matthias Clasen
*/
#include "constraint-view-child.h"
struct _ConstraintViewChild
{
GObject parent_instance;
char *name;
};
enum {
PROP_NAME = 1,
LAST_PROP
};
static GParamSpec props[LAST_PROP];
G_DEFINE_TYPE (ConstraintViewChild, constraint_view_child, G_TYPE_OBJECT)
static void
constraint_view_child_init (ConstraintViewChild *child)
{
}
static void
constraint_view_child_finalize (GObject *object)
{
ConstraintViewChild *child = CONSTRAINT_VIEW_CHILD (object);
g_free (child->name);
G_OBJECT_CLASS (constraint_view_child_parent_class)->finalize (object);
}
static void
constraint_view_child_set_property (GObject *object,
static void
constraint_view_child_class_init (ConstraintViewChildClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->finalize = constraint_view_child_finalize;
object_class->get_property = constraint_view_child_get_property;
object_class->set_property = constraint_view_child_set_property;
props[PROP_NAME] =
g_param_spec_string ("name", "name", "name",
NULL,
G_PARAM_READWRITE);
g_object_class_install_properties (object_class, LAST_PROP, props);
}
#define CONSTRAINT_VIEW_CHILD_TYPE (constraint_view_get_type ())
G_DECLARE_TYPE (ConstraintViewChild, constraint_view_child, CONSTRAINT, VIEW_CHILD, GObject)
#define CONSTRAINT_VIEW_WIDGET_TYPE (constraint_view_widget_get_type ())
G_DECLARE_FINAL_TYPE (ConstraintViewWidget, constraint_view_widget, CONSTRAINT, VIEW_WIDGET, ConstraintViewChild)
ConstraintViewWidget * constraint_view_widget_new (void);
#define CONSTRAINT_VIEW_GUIDE_TYPE (constraint_view_guide_get_type ())
G_DECLARE_FINAL_TYPE (ConstraintViewGuide, constraint_view_guide, CONSTRAINT, VIEW_GUIDE, ConstraintViewChild)
ConstraintViewGuide * constraint_view_guide_new (void);
#define CONSTRAINT_VIEW_CONSTRAINT_TYPE (constraint_view_constraint_get_type ())
G_DECLARE_FINAL_TYPE (ConstraintViewConstraint, constraint_view_constraint, CONSTRAINT, VIEW_CONSTRAINT, ConstraintViewChild)
ConstraintViewGuide * constraint_view_constraint_new (void);

View File

@@ -1,44 +0,0 @@
/*
* Copyright © 2019 Red Hat, Inc
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Matthias Clasen
*/
#pragma once
#include <gtk/gtk.h>
#define CONSTRAINT_VIEW_CHILD_TYPE (constraint_view_get_type ())
G_DECLARE_TYPE (ConstraintViewChild, constraint_view_child, CONSTRAINT, VIEW_CHILD, GObject)
#define CONSTRAINT_VIEW_WIDGET_TYPE (constraint_view_widget_get_type ())
G_DECLARE_FINAL_TYPE (ConstraintViewWidget, constraint_view_widget, CONSTRAINT, VIEW_WIDGET, ConstraintViewChild)
ConstraintViewWidget * constraint_view_widget_new (void);
#define CONSTRAINT_VIEW_GUIDE_TYPE (constraint_view_guide_get_type ())
G_DECLARE_FINAL_TYPE (ConstraintViewGuide, constraint_view_guide, CONSTRAINT, VIEW_GUIDE, ConstraintViewChild)
ConstraintViewGuide * constraint_view_guide_new (void);
#define CONSTRAINT_VIEW_CONSTRAINT_TYPE (constraint_view_constraint_get_type ())
G_DECLARE_FINAL_TYPE (ConstraintViewConstraint, constraint_view_constraint, CONSTRAINT, VIEW_CONSTRAINT, ConstraintViewChild)
ConstraintViewGuide * constraint_view_constraint_new (void);

View File

@@ -1,345 +0,0 @@
/* Copyright (C) 2019 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include <gtk/gtk.h>
#include "constraint-view.h"
struct _ConstraintView
{
GtkWidget parent;
GListModel *model;
GtkWidget *drag_widget;
};
G_DEFINE_TYPE (ConstraintView, constraint_view, GTK_TYPE_WIDGET);
static void
constraint_view_dispose (GObject *object)
{
ConstraintView *view = CONSTRAINT_VIEW (object);
GtkWidget *child;
while ((child = gtk_widget_get_first_child (GTK_WIDGET (view))) != NULL)
gtk_widget_unparent (child);
g_clear_object (&view->model);
G_OBJECT_CLASS (constraint_view_parent_class)->dispose (object);
}
static void
constraint_view_class_init (ConstraintViewClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->dispose = constraint_view_dispose;
gtk_widget_class_set_css_name (widget_class, "constraintview");
}
static void
update_weak_position (ConstraintView *self,
GtkWidget *child,
double x,
double y)
{
GtkLayoutManager *manager;
GtkConstraint *constraint;
manager = gtk_widget_get_layout_manager (GTK_WIDGET (self));
constraint = (GtkConstraint *)g_object_get_data (G_OBJECT (child), "x-constraint");
if (constraint)
{
gtk_constraint_layout_remove_constraint (GTK_CONSTRAINT_LAYOUT (manager),
constraint);
g_object_set_data (G_OBJECT (child), "x-constraint", NULL);
}
if (x != -100)
{
constraint = gtk_constraint_new_constant (child,
GTK_CONSTRAINT_ATTRIBUTE_CENTER_X,
GTK_CONSTRAINT_RELATION_EQ,
x,
GTK_CONSTRAINT_STRENGTH_WEAK);
g_object_set_data (G_OBJECT (constraint), "internal", (char *)"yes");
gtk_constraint_layout_add_constraint (GTK_CONSTRAINT_LAYOUT (manager),
constraint);
g_object_set_data (G_OBJECT (child), "x-constraint", constraint);
}
constraint = (GtkConstraint *)g_object_get_data (G_OBJECT (child), "y-constraint");
if (constraint)
{
gtk_constraint_layout_remove_constraint (GTK_CONSTRAINT_LAYOUT (manager),
constraint);
g_object_set_data (G_OBJECT (child), "y-constraint", NULL);
}
if (y != -100)
{
constraint = gtk_constraint_new_constant (child,
GTK_CONSTRAINT_ATTRIBUTE_CENTER_Y,
GTK_CONSTRAINT_RELATION_EQ,
y,
GTK_CONSTRAINT_STRENGTH_WEAK);
g_object_set_data (G_OBJECT (constraint), "internal", (char *)"yes");
gtk_constraint_layout_add_constraint (GTK_CONSTRAINT_LAYOUT (manager),
constraint);
g_object_set_data (G_OBJECT (child), "y-constraint", constraint);
}
}
static void
drag_begin (GtkGestureDrag *drag,
double start_x,
double start_y,
ConstraintView *self)
{
GtkWidget *widget;
widget = gtk_widget_pick (GTK_WIDGET (self), start_x, start_y, GTK_PICK_DEFAULT);
if (GTK_IS_LABEL (widget))
{
widget = gtk_widget_get_ancestor (widget, GTK_TYPE_FRAME);
if (widget &&
gtk_widget_get_parent (widget) == (GtkWidget *)self)
{
self->drag_widget = widget;
}
}
}
static void
drag_update (GtkGestureDrag *drag,
double offset_x,
double offset_y,
ConstraintView *self)
{
double x, y;
if (!self->drag_widget)
return;
gtk_gesture_drag_get_start_point (drag, &x, &y);
update_weak_position (self, self->drag_widget, x + offset_x, y + offset_y);
}
static void
drag_end (GtkGestureDrag *drag,
double offset_x,
double offset_y,
ConstraintView *self)
{
self->drag_widget = NULL;
}
static gboolean
omit_internal (gpointer item, gpointer user_data)
{
if (g_object_get_data (G_OBJECT (item), "internal"))
return FALSE;
return TRUE;
}
static void
constraint_view_init (ConstraintView *self)
{
GtkLayoutManager *manager;
GtkEventController *controller;
GListStore *list;
GListModel *all_children;
GListModel *all_constraints;
GListModel *guides;
GListModel *children;
GListModel *constraints;
GtkFilter *filter;
manager = gtk_constraint_layout_new ();
gtk_widget_set_layout_manager (GTK_WIDGET (self), manager);
guides = gtk_constraint_layout_observe_guides (GTK_CONSTRAINT_LAYOUT (manager));
all_constraints = gtk_constraint_layout_observe_constraints (GTK_CONSTRAINT_LAYOUT (manager));
filter = GTK_FILTER (gtk_custom_filter_new (omit_internal, NULL, NULL));
constraints = (GListModel *)gtk_filter_list_model_new (all_constraints, filter);
all_children = gtk_widget_observe_children (GTK_WIDGET (self));
filter = GTK_FILTER (gtk_custom_filter_new (omit_internal, NULL, NULL));
children = (GListModel *)gtk_filter_list_model_new (all_children, filter);
list = g_list_store_new (G_TYPE_LIST_MODEL);
g_list_store_append (list, children);
g_list_store_append (list, guides);
g_list_store_append (list, constraints);
g_object_unref (children);
g_object_unref (guides);
g_object_unref (constraints);
self->model = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (list)));
controller = (GtkEventController *)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_end), self);
gtk_widget_add_controller (GTK_WIDGET (self), controller);
}
ConstraintView *
constraint_view_new (void)
{
return g_object_new (CONSTRAINT_VIEW_TYPE, NULL);
}
void
constraint_view_add_child (ConstraintView *view,
const char *name)
{
GtkWidget *frame;
GtkWidget *label;
label = gtk_label_new (name);
frame = gtk_frame_new (NULL);
gtk_widget_add_css_class (frame, "child");
gtk_widget_set_name (frame, name);
gtk_frame_set_child (GTK_FRAME (frame), label);
gtk_widget_set_parent (frame, GTK_WIDGET (view));
update_weak_position (view, frame, 100, 100);
}
void
constraint_view_remove_child (ConstraintView *view,
GtkWidget *child)
{
update_weak_position (view, child, -100, -100);
gtk_widget_unparent (child);
}
void
constraint_view_add_guide (ConstraintView *view,
GtkConstraintGuide *guide)
{
GtkConstraintLayout *layout;
GtkWidget *frame;
GtkWidget *label;
const char *name;
GtkConstraint *constraint;
struct {
const char *name;
GtkConstraintAttribute attr;
} names[] = {
{ "left-constraint", GTK_CONSTRAINT_ATTRIBUTE_LEFT },
{ "top-constraint", GTK_CONSTRAINT_ATTRIBUTE_TOP },
{ "width-constraint", GTK_CONSTRAINT_ATTRIBUTE_WIDTH },
{ "height-constraint", GTK_CONSTRAINT_ATTRIBUTE_HEIGHT },
};
int i;
name = gtk_constraint_guide_get_name (guide);
label = gtk_label_new (name);
g_object_bind_property (guide, "name",
label, "label",
G_BINDING_DEFAULT);
frame = gtk_frame_new (NULL);
gtk_widget_add_css_class (frame, "guide");
g_object_set_data (G_OBJECT (frame), "internal", (char *)"yes");
gtk_frame_set_child (GTK_FRAME (frame), label);
gtk_widget_insert_after (frame, GTK_WIDGET (view), NULL);
g_object_set_data (G_OBJECT (guide), "frame", frame);
layout = GTK_CONSTRAINT_LAYOUT (gtk_widget_get_layout_manager (GTK_WIDGET (view)));
gtk_constraint_layout_add_guide (layout, g_object_ref (guide));
for (i = 0; i < G_N_ELEMENTS (names); i++)
{
constraint = gtk_constraint_new (frame,
names[i].attr,
GTK_CONSTRAINT_RELATION_EQ,
guide,
names[i].attr,
1.0, 0.0,
GTK_CONSTRAINT_STRENGTH_REQUIRED);
g_object_set_data (G_OBJECT (constraint), "internal", (char *)"yes");
gtk_constraint_layout_add_constraint (layout, constraint);
g_object_set_data (G_OBJECT (guide), names[i].name, constraint);
}
update_weak_position (view, frame, 150, 150);
}
void
constraint_view_remove_guide (ConstraintView *view,
GtkConstraintGuide *guide)
{
GtkConstraintLayout *layout;
GtkWidget *frame;
GtkConstraint *constraint;
const char *names[] = {
"left-constraint",
"top-constraint",
"width-constraint",
"height-constraint"
};
int i;
layout = GTK_CONSTRAINT_LAYOUT (gtk_widget_get_layout_manager (GTK_WIDGET (view)));
for (i = 0; i < G_N_ELEMENTS (names); i++)
{
constraint = (GtkConstraint*)g_object_get_data (G_OBJECT (guide), names[i]);
gtk_constraint_layout_remove_constraint (layout, constraint);
}
frame = (GtkWidget *)g_object_get_data (G_OBJECT (guide), "frame");
update_weak_position (view, frame, -100, -100);
gtk_widget_unparent (frame);
gtk_constraint_layout_remove_guide (layout, guide);
}
void
constraint_view_add_constraint (ConstraintView *view,
GtkConstraint *constraint)
{
GtkLayoutManager *manager;
manager = gtk_widget_get_layout_manager (GTK_WIDGET (view));
gtk_constraint_layout_add_constraint (GTK_CONSTRAINT_LAYOUT (manager),
g_object_ref (constraint));
}
void
constraint_view_remove_constraint (ConstraintView *view,
GtkConstraint *constraint)
{
GtkLayoutManager *manager;
manager = gtk_widget_get_layout_manager (GTK_WIDGET (view));
gtk_constraint_layout_remove_constraint (GTK_CONSTRAINT_LAYOUT (manager),
constraint);
}
GListModel *
constraint_view_get_model (ConstraintView *view)
{
return view->model;
}

View File

@@ -1,45 +0,0 @@
/*
* Copyright © 2019 Red Hat, Inc
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Matthias Clasen
*/
#pragma once
#include <gtk/gtk.h>
#define CONSTRAINT_VIEW_TYPE (constraint_view_get_type ())
G_MODULE_EXPORT
G_DECLARE_FINAL_TYPE (ConstraintView, constraint_view, CONSTRAINT, VIEW, GtkWidget)
ConstraintView * constraint_view_new (void);
void constraint_view_add_child (ConstraintView *view,
const char *name);
void constraint_view_remove_child (ConstraintView *view,
GtkWidget *child);
void constraint_view_add_guide (ConstraintView *view,
GtkConstraintGuide *guide);
void constraint_view_remove_guide (ConstraintView *view,
GtkConstraintGuide *guide);
void constraint_view_guide_changed (ConstraintView *view,
GtkConstraintGuide *guide);
void constraint_view_add_constraint (ConstraintView *view,
GtkConstraint *constraint);
void constraint_view_remove_constraint (ConstraintView *view,
GtkConstraint *constraint);
GListModel * constraint_view_get_model (ConstraintView *view);

View File

@@ -1,355 +0,0 @@
/*
* Copyright © 2019 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Matthias Clasen
*/
#include "config.h"
#include "guide-editor.h"
struct _GuideEditor
{
GtkWidget parent_instance;
GtkWidget *grid;
GtkWidget *name;
GtkWidget *min_width;
GtkWidget *min_height;
GtkWidget *nat_width;
GtkWidget *nat_height;
GtkWidget *max_width;
GtkWidget *max_height;
GtkWidget *strength;
GtkWidget *button;
GtkConstraintGuide *guide;
gboolean constructed;
};
enum {
PROP_GUIDE = 1,
LAST_PROP
};
static GParamSpec *pspecs[LAST_PROP];
enum {
DONE,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL];
G_DEFINE_TYPE(GuideEditor, guide_editor, GTK_TYPE_WIDGET);
static GtkConstraintStrength
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 ();
}
}
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 *
get_strength_nick (GtkConstraintStrength strength)
{
GEnumClass *class = g_type_class_ref (GTK_TYPE_CONSTRAINT_STRENGTH);
GEnumValue *value = g_enum_get_value (class, strength);
const char *nick = value->value_nick;
g_type_class_unref (class);
return nick;
}
void
guide_editor_serialize_guide (GString *str,
int indent,
GtkConstraintGuide *guide)
{
int min_width, min_height;
int nat_width, nat_height;
int max_width, max_height;
const char *name;
const char *strength;
gtk_constraint_guide_get_min_size (guide, &min_width, &min_height);
gtk_constraint_guide_get_nat_size (guide, &nat_width, &nat_height);
gtk_constraint_guide_get_max_size (guide, &max_width, &max_height);
name = gtk_constraint_guide_get_name (guide);
strength = get_strength_nick (gtk_constraint_guide_get_strength (guide));
g_string_append_printf (str, "%*s<guide min-width=\"%d\" min-height=\"%d\"\n", indent, "", min_width, min_height);
g_string_append_printf (str, "%*s nat-width=\"%d\" nat-height=\"%d\"\n", indent, "", nat_width, nat_height);
g_string_append_printf (str, "%*s max-width=\"%d\" max-height=\"%d\"\n", indent, "", max_width, max_height);
g_string_append_printf (str, "%*s name=\"%s\" strength=\"%s\" />\n", indent, "", name, strength);
}
static void
create_guide (GtkButton *button,
GuideEditor *editor)
{
int strength;
const char *name;
int w, h;
GtkConstraintGuide *guide;
unsigned int id;
if (editor->guide)
guide = g_object_ref (editor->guide);
else
guide = gtk_constraint_guide_new ();
name = gtk_editable_get_text (GTK_EDITABLE (editor->name));
gtk_constraint_guide_set_name (guide, name);
w = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (editor->min_width));
h = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (editor->min_height));
gtk_constraint_guide_set_min_size (guide, w, h);
w = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (editor->nat_width));
h = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (editor->nat_height));
gtk_constraint_guide_set_nat_size (guide, w, h);
w = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (editor->max_width));
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_drop_down_get_selected (GTK_DROP_DOWN (editor->strength));
strength = get_strength (id);
gtk_constraint_guide_set_strength (guide, strength);
g_signal_emit (editor, signals[DONE], 0, guide);
g_object_unref (guide);
}
static void
guide_editor_init (GuideEditor *editor)
{
gtk_widget_init_template (GTK_WIDGET (editor));
}
static int guide_counter;
static int
min_input (GtkSpinButton *spin_button,
double *new_val)
{
if (strcmp (gtk_editable_get_text (GTK_EDITABLE (spin_button)), "") == 0)
{
*new_val = 0.0;
return TRUE;
}
return FALSE;
}
static int
max_input (GtkSpinButton *spin_button,
double *new_val)
{
if (strcmp (gtk_editable_get_text (GTK_EDITABLE (spin_button)), "") == 0)
{
*new_val = G_MAXINT;
return TRUE;
}
return FALSE;
}
static void
guide_editor_constructed (GObject *object)
{
GuideEditor *editor = GUIDE_EDITOR (object);
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)
{
GtkConstraintStrength strength;
const char *nick;
int w, h;
nick = gtk_constraint_guide_get_name (editor->guide);
if (nick)
gtk_editable_set_text (GTK_EDITABLE (editor->name), nick);
gtk_constraint_guide_get_min_size (editor->guide, &w, &h);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->min_width), w);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->min_height), h);
gtk_constraint_guide_get_nat_size (editor->guide, &w, &h);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->nat_width), w);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->nat_height), h);
gtk_constraint_guide_get_max_size (editor->guide, &w, &h);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->max_width), w);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->max_height), h);
strength = gtk_constraint_guide_get_strength (editor->guide);
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->strength), get_strength_id (strength));
gtk_button_set_label (GTK_BUTTON (editor->button), "Apply");
}
else
{
char *name;
guide_counter++;
name = g_strdup_printf ("Guide %d", guide_counter);
gtk_editable_set_text (GTK_EDITABLE (editor->name), name);
g_free (name);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->min_width), 0.0);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->min_height), 0.0);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->nat_width), 0.0);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->nat_height), 0.0);
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_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");
}
editor->constructed = TRUE;
}
static void
guide_editor_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GuideEditor *self = GUIDE_EDITOR (object);
switch (property_id)
{
case PROP_GUIDE:
self->guide = g_value_dup_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
static void
guide_editor_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GuideEditor *self = GUIDE_EDITOR (object);
switch (property_id)
{
case PROP_GUIDE:
g_value_set_object (value, self->guide);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
static void
guide_editor_dispose (GObject *object)
{
GuideEditor *self = (GuideEditor *)object;
g_clear_object (&self->guide);
gtk_widget_dispose_template (GTK_WIDGET (self), GUIDE_EDITOR_TYPE);
G_OBJECT_CLASS (guide_editor_parent_class)->dispose (object);
}
static void
guide_editor_class_init (GuideEditorClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
object_class->constructed = guide_editor_constructed;
object_class->dispose = guide_editor_dispose;
object_class->set_property = guide_editor_set_property;
object_class->get_property = guide_editor_get_property;
pspecs[PROP_GUIDE] =
g_param_spec_object ("guide", "guide", "guide",
GTK_TYPE_CONSTRAINT_GUIDE,
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_properties (object_class, LAST_PROP, pspecs);
signals[DONE] =
g_signal_new ("done",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
NULL,
G_TYPE_NONE, 1, GTK_TYPE_CONSTRAINT_GUIDE);
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gtk/gtk4/constraint-editor/guide-editor.ui");
gtk_widget_class_bind_template_child (widget_class, GuideEditor, grid);
gtk_widget_class_bind_template_child (widget_class, GuideEditor, name);
gtk_widget_class_bind_template_child (widget_class, GuideEditor, min_width);
gtk_widget_class_bind_template_child (widget_class, GuideEditor, min_height);
gtk_widget_class_bind_template_child (widget_class, GuideEditor, nat_width);
gtk_widget_class_bind_template_child (widget_class, GuideEditor, nat_height);
gtk_widget_class_bind_template_child (widget_class, GuideEditor, max_width);
gtk_widget_class_bind_template_child (widget_class, GuideEditor, max_height);
gtk_widget_class_bind_template_child (widget_class, GuideEditor, strength);
gtk_widget_class_bind_template_child (widget_class, GuideEditor, button);
gtk_widget_class_bind_template_callback (widget_class, create_guide);
}
GuideEditor *
guide_editor_new (GtkConstraintGuide *guide)
{
return g_object_new (GUIDE_EDITOR_TYPE,
"guide", guide,
NULL);
}

View File

@@ -1,32 +0,0 @@
/*
* Copyright © 2019 Red Hat, Inc
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Matthias Clasen
*/
#pragma once
#include <gtk/gtk.h>
#define GUIDE_EDITOR_TYPE (guide_editor_get_type ())
G_DECLARE_FINAL_TYPE (GuideEditor, guide_editor, GUIDE, EDITOR, GtkWidget)
GuideEditor * guide_editor_new (GtkConstraintGuide *guide);
void guide_editor_serialize_guide (GString *str,
int indent,
GtkConstraintGuide *guide);

View File

@@ -1,201 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkAdjustment" id="min_width_adj">
<property name="lower">0</property>
<property name="upper">2147483647</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
<property name="page-size">0</property>
</object>
<object class="GtkAdjustment" id="min_height_adj">
<property name="lower">0</property>
<property name="upper">2147483647</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
<property name="page-size">0</property>
</object>
<object class="GtkAdjustment" id="nat_width_adj">
<property name="lower">0</property>
<property name="upper">2147483647</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
<property name="page-size">0</property>
</object>
<object class="GtkAdjustment" id="nat_height_adj">
<property name="lower">0</property>
<property name="upper">2147483647</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
<property name="page-size">0</property>
</object>
<object class="GtkAdjustment" id="max_width_adj">
<property name="lower">0</property>
<property name="upper">2147483647</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
<property name="page-size">0</property>
</object>
<object class="GtkAdjustment" id="max_height_adj">
<property name="lower">0</property>
<property name="upper">2147483647</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
<property name="page-size">0</property>
</object>
<template class="GuideEditor" parent="GtkWidget">
<child>
<object class="GtkGrid" id="grid">
<property name="margin-start">20</property>
<property name="margin-end">20</property>
<property name="margin-top">20</property>
<property name="margin-bottom">20</property>
<property name="row-spacing">10</property>
<property name="column-spacing">10</property>
<child>
<object class="GtkLabel">
<property name="label">Name</property>
<layout>
<property name="column">0</property>
<property name="row">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkEntry" id="name">
<property name="max-width-chars">20</property>
<layout>
<property name="column">1</property>
<property name="row">0</property>
<property name="column-span">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Min Size</property>
<layout>
<property name="column">0</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkSpinButton" id="min_width">
<property name="adjustment">min_width_adj</property>
<property name="max-width-chars">5</property>
<layout>
<property name="column">1</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkSpinButton" id="min_height">
<property name="adjustment">min_height_adj</property>
<property name="max-width-chars">5</property>
<layout>
<property name="column">2</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Nat Size</property>
<layout>
<property name="column">0</property>
<property name="row">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkSpinButton" id="nat_width">
<property name="adjustment">nat_width_adj</property>
<property name="max-width-chars">5</property>
<layout>
<property name="column">1</property>
<property name="row">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkSpinButton" id="nat_height">
<property name="adjustment">nat_height_adj</property>
<property name="max-width-chars">5</property>
<layout>
<property name="column">2</property>
<property name="row">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Max Size</property>
<layout>
<property name="column">0</property>
<property name="row">3</property>
</layout>
</object>
</child>
<child>
<object class="GtkSpinButton" id="max_width">
<property name="adjustment">max_width_adj</property>
<property name="max-width-chars">5</property>
<layout>
<property name="column">1</property>
<property name="row">3</property>
</layout>
</object>
</child>
<child>
<object class="GtkSpinButton" id="max_height">
<property name="adjustment">max_height_adj</property>
<property name="max-width-chars">5</property>
<layout>
<property name="column">2</property>
<property name="row">3</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Strength</property>
<layout>
<property name="column">0</property>
<property name="row">4</property>
</layout>
</object>
</child>
<child>
<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>
<property name="column-span">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkButton" id="button">
<property name="label">Create</property>
<signal name="clicked" handler="create_guide"/>
<layout>
<property name="column">2</property>
<property name="row">5</property>
</layout>
</object>
</child>
</object>
</child>
</template>
</interface>

View File

@@ -1,28 +0,0 @@
/*
* Copyright © 2019 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Matthias Clasen <mclasen@redhat.com>
*/
#include "config.h"
#include <constraint-editor-application.h>
int
main (int argc, char *argv[])
{
return g_application_run (G_APPLICATION (constraint_editor_application_new ()), argc, argv);
}

View File

@@ -1,23 +0,0 @@
constraint_editor_sources = [
'main.c',
'constraint-editor-application.c',
'constraint-editor-window.c',
'constraint-view.c',
'constraint-editor.c',
'guide-editor.c',
]
constraint_editor_resources = gnome.compile_resources('constraint_editor_resources',
'constraint-editor.gresource.xml',
source_dir: meson.current_source_dir(),
)
executable('gtk4-constraint-editor',
sources: [ constraint_editor_sources, constraint_editor_resources, ],
c_args: common_cflags,
dependencies: libgtk_dep,
include_directories: confinc,
win_subsystem: 'windows',
link_args: extra_demo_ldflags,
install: false,
)

22315
demos/gtk-demo/Moby-Dick.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,26 +0,0 @@
uniform float u_time;
void
mainImage(out vec4 fragColor, in vec2 fragCoord, in vec2 resolution, in vec2 uv)
{
vec2 pos = (fragCoord.xy * 2.0 - resolution.xy)/ min (resolution.x, resolution.y) ;
float t0 = sin ((u_time + 0.00)*1.0);
float t1 = sin ((u_time + 0.30)*0.4);
float t2 = cos ((u_time + 0.23)*0.9);
float t3 = cos ((u_time + 0.41)*0.6);
float t4 = cos ((u_time + 0.11)*0.3);
vec2 p0 = vec2 (t1, t0) ;
vec2 p1 = vec2 (t2, t3) ;
vec2 p2 = vec2 (t4, t3) ;
float r = 1.0/distance (pos, p0);
float g = 1.0/distance (pos, p1);
float b = 1.0/distance (pos, p2);
float sum = r + g + b;
float alpha = 1.0 - pow (1.0/(sum), 40.0)*pow (10.0, 40.0*0.7);
fragColor = vec4 (r*0.5, g*0.5, b*0.5, 1.0) * alpha;
}

View File

@@ -1,226 +0,0 @@
uniform float iTime;
// Originally from: https://www.shadertoy.com/view/3ljyDD
// License CC0: Hexagonal tiling + cog wheels
// Nothing fancy, just hexagonal tiling + cog wheels
#define PI 3.141592654
#define TAU (2.0*PI)
#define MROT(a) mat2(cos(a), sin(a), -sin(a), cos(a))
float hash(in vec2 co) {
return fract(sin(dot(co.xy ,vec2(12.9898,58.233))) * 13758.5453);
}
float pcos(float a) {
return 0.5 + 0.5*cos(a);
}
void rot(inout vec2 p, float a) {
float c = cos(a);
float s = sin(a);
p = vec2(c*p.x + s*p.y, -s*p.x + c*p.y);
}
float modPolar(inout vec2 p, float repetitions) {
float angle = 2.0*PI/repetitions;
float a = atan(p.y, p.x) + angle/2.;
float r = length(p);
float c = floor(a/angle);
a = mod(a,angle) - angle/2.;
p = vec2(cos(a), sin(a))*r;
// For an odd number of repetitions, fix cell index of the cell in -x direction
// (cell index would be e.g. -5 and 5 in the two halves of the cell):
if (abs(c) >= (repetitions/2.0)) c = abs(c);
return c;
}
float pmin(float a, float b, float k) {
float h = clamp( 0.5+0.5*(b-a)/k, 0.0, 1.0 );
return mix( b, a, h ) - k*h*(1.0-h);
}
const vec2 sz = vec2(1.0, sqrt(3.0));
const vec2 hsz = 0.5*sz;
const float smallCount = 16.0;
vec2 hextile(inout vec2 p) {
// See Art of Code: Hexagonal Tiling Explained!
// https://www.youtube.com/watch?v=VmrIDyYiJBA
vec2 p1 = mod(p, sz)-hsz;
vec2 p2 = mod(p - hsz*1.0, sz)-hsz;
vec2 p3 = mix(p2, p1, vec2(length(p1) < length(p2)));
vec2 n = p3 - p;
p = p3;
return n;
}
float circle(vec2 p, float r) {
return length(p) - r;
}
float box(vec2 p, vec2 b) {
vec2 d = abs(p)-b;
return length(max(d,0.0)) + min(max(d.x,d.y),0.0);
}
float unevenCapsule(vec2 p, float r1, float r2, float h) {
p.x = abs(p.x);
float b = (r1-r2)/h;
float a = sqrt(1.0-b*b);
float k = dot(p,vec2(-b,a));
if( k < 0.0 ) return length(p) - r1;
if( k > a*h ) return length(p-vec2(0.0,h)) - r2;
return dot(p, vec2(a,b) ) - r1;
}
float cogwheel(vec2 p, float innerRadius, float outerRadius, float cogs, float holes) {
float cogWidth = 0.25*innerRadius*TAU/cogs;
float d0 = circle(p, innerRadius);
vec2 icp = p;
modPolar(icp, holes);
icp -= vec2(innerRadius*0.55, 0.0);
float d1 = circle(icp, innerRadius*0.25);
vec2 cp = p;
modPolar(cp, cogs);
cp -= vec2(innerRadius, 0.0);
float d2 = unevenCapsule(cp.yx, cogWidth, cogWidth*0.75, (outerRadius-innerRadius));
float d3 = circle(p, innerRadius*0.20);
float d = 1E6;
d = min(d, d0);
d = pmin(d, d2, 0.5*cogWidth);
d = min(d, d2);
d = max(d, -d1);
d = max(d, -d3);
return d;
}
float ccell1(vec2 p, float r) {
float d = 1E6;
const float bigCount = 60.0;
vec2 cp0 = p;
rot(cp0, -iTime*TAU/bigCount);
float d0 = cogwheel(cp0, 0.36, 0.38, bigCount, 5.0);
vec2 cp1 = p;
float nm = modPolar(cp1, 6.0);
cp1 -= vec2(0.5, 0.0);
rot(cp1, 0.2+TAU*nm/2.0 + iTime*TAU/smallCount);
float d1 = cogwheel(cp1, 0.11, 0.125, smallCount, 5.0);
d = min(d, d0);
d = min(d, d1);
return d;
}
float ccell2(vec2 p, float r) {
float d = 1E6;
vec2 cp0 = p;
float nm = modPolar(cp0, 6.0);
vec2 cp1 = cp0;
const float off = 0.275;
const float count = smallCount + 2.0;
cp0 -= vec2(off, 0.0);
rot(cp0, 0.+TAU*nm/2.0 - iTime*TAU/count);
float d0 = cogwheel(cp0, 0.09, 0.105, count, 5.0);
cp1 -= vec2(0.5, 0.0);
rot(cp1, 0.2+TAU*nm/2.0 + iTime*TAU/smallCount);
float d1 = cogwheel(cp1, 0.11, 0.125, smallCount, 5.0);
float l = length(p);
float d2 = l - (off+0.055);
float d3 = d2 + 0.020;;
vec2 tp0 = p;
modPolar(tp0, 60.0);
tp0.x -= off;
float d4 = box(tp0, vec2(0.0125, 0.005));
float ctime = -(iTime*0.05 + r)*TAU;
vec2 tp1 = p;
rot(tp1, ctime*12.0);
tp1.x -= 0.13;
float d5 = box(tp1, vec2(0.125, 0.005));
vec2 tp2 = p;
rot(tp2, ctime);
tp2.x -= 0.13*0.5;
float d6 = box(tp2, vec2(0.125*0.5, 0.0075));
float d7 = l - 0.025;
float d8 = l - 0.0125;
d = min(d, d0);
d = min(d, d1);
d = min(d, d2);
d = max(d, -d3);
d = min(d, d4);
d = min(d, d5);
d = min(d, d6);
d = min(d, d7);
d = max(d, -d8);
return d;
}
float df(vec2 p, float scale, inout vec2 nn) {
p /= scale;
nn = hextile(p);
nn = floor(nn + 0.5);
float r = hash(nn);
float d;;
if (r < 0.5) {
d = ccell1(p, r);
} else {
d = ccell2(p, r);
}
return d*scale;
}
vec3 postProcess(vec3 col, vec2 q) {
//col = saturate(col);
col=pow(clamp(col,0.0,1.0),vec3(0.75));
col=col*0.6+0.4*col*col*(3.0-2.0*col); // contrast
col=mix(col, vec3(dot(col, vec3(0.33))), -0.4); // satuation
col*=0.5+0.5*pow(19.0*q.x*q.y*(1.0-q.x)*(1.0-q.y),0.7); // vigneting
return col;
}
void mainImage(out vec4 fragColor, in vec2 fragCoord, in vec2 resolution, in vec2 uv) {
vec2 q = fragCoord/resolution.xy;
vec2 p = -1.0 + 2.0*q;
p.x *= resolution.x/resolution.y;
float tm = iTime*0.1;
p += vec2(cos(tm), sin(tm*sqrt(0.5)));
float z = mix(0.5, 1.0, pcos(tm*sqrt(0.3)));
float aa = 4.0 / resolution.y;
vec2 nn = vec2(0.0);
float d = df(p, z, nn);
vec3 col = vec3(160.0)/vec3(255.0);
vec3 baseCol = vec3(0.3);
vec4 logoCol = vec4(baseCol, 1.0)*smoothstep(-aa, 0.0, -d);
col = mix(col, logoCol.xyz, pow(logoCol.w, 8.0));
col += 0.4*pow(abs(sin(20.0*d)), 0.6);
col = postProcess(col, q);
fragColor = vec4(col, 1.0);
}

View File

@@ -1,27 +0,0 @@
uniform float progress;
uniform sampler2D u_texture1;
uniform sampler2D u_texture2;
vec4 getFromColor (vec2 uv) {
return GskTexture(u_texture1, uv);
}
vec4 getToColor (vec2 uv) {
return GskTexture(u_texture2, uv);
}
// Source: https://gl-transitions.com/editor/crosswarp
// Author: Eke Péter <peterekepeter@gmail.com>
// License: MIT
vec4 transition(vec2 p) {
float x = progress;
x=smoothstep(.0,1.0,(x*2.0+p.x-1.0));
return mix(getFromColor((p-.5)*(1.-x)+.5), getToColor((p-.5)*x+.5), x);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord, in vec2 resolution, in vec2 uv)
{
fragColor = transition(uv);
}

View File

@@ -146,21 +146,6 @@
<file>cogs.glsl</file>
<file>glowingstars.glsl</file>
</gresource>
<gresource prefix="/gltransition">
<file>gtkshaderstack.c</file>
<file>gtkshaderstack.h</file>
<file>gtkshaderbin.h</file>
<file>gtkshaderbin.c</file>
<file>gskshaderpaintable.h</file>
<file>gskshaderpaintable.c</file>
<file>wind.glsl</file>
<file>radial.glsl</file>
<file>crosswarp.glsl</file>
<file>kaleidoscope.glsl</file>
<file>cogs2.glsl</file>
<file>ripple.glsl</file>
<file>background.glsl</file>
</gresource>
<gresource prefix="/iconscroll">
<file>iconscroll.ui</file>
</gresource>
@@ -296,7 +281,6 @@
<file>gears.c</file>
<file>gestures.c</file>
<file>glarea.c</file>
<file>gltransition.c</file>
<file>headerbar.c</file>
<file>hypertext.c</file>
<file>iconscroll.c</file>
@@ -454,6 +438,10 @@
<file>icons/16x16/categories/applications-other.png</file>
<file>icons/48x48/status/starred.png</file>
<file alias="icons/scalable/apps/org.gtk.Demo4.svg">data/scalable/apps/org.gtk.Demo4.svg</file>
<file>portland-rose-thumbnail.png</file>
<file>large-image-thumbnail.png</file>
<file compressed="true">large-image.png</file>
<file compressed="true">Moby-Dick.txt</file>
</gresource>
<gresource prefix="/org/gtk/Demo4/gtk">
<file preprocess="xml-stripblanks">help-overlay.ui</file>

View File

@@ -55,7 +55,7 @@ mode_switch_state_set (GtkSwitch *sw,
{
gtk_widget_set_visible (label, TRUE);
gtk_accessible_update_relation (GTK_ACCESSIBLE (sw),
GTK_ACCESSIBLE_RELATION_ERROR_MESSAGE, label,
GTK_ACCESSIBLE_RELATION_ERROR_MESSAGE, label, NULL,
-1);
gtk_accessible_update_state (GTK_ACCESSIBLE (sw),
GTK_ACCESSIBLE_STATE_INVALID, GTK_ACCESSIBLE_INVALID_TRUE,

View File

@@ -9,7 +9,6 @@
#include "gtkfishbowl.h"
#include "gtkgears.h"
#include "gskshaderpaintable.h"
#include "nodewidget.h"
#include "graphwidget.h"
@@ -152,46 +151,6 @@ create_switch (void)
return w;
}
static gboolean
update_paintable (GtkWidget *widget,
GdkFrameClock *frame_clock,
gpointer user_data)
{
GskShaderPaintable *paintable;
gint64 frame_time;
paintable = GSK_SHADER_PAINTABLE (gtk_picture_get_paintable (GTK_PICTURE (widget)));
frame_time = gdk_frame_clock_get_frame_time (frame_clock);
gsk_shader_paintable_update_time (paintable, 0, frame_time);
return G_SOURCE_CONTINUE;
}
static GtkWidget *
create_cogs (void)
{
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
GtkWidget *picture;
static GskGLShader *cog_shader = NULL;
GdkPaintable *paintable;
if (cog_shader == NULL)
cog_shader = gsk_gl_shader_new_from_resource ("/gltransition/cogs2.glsl");
paintable = gsk_shader_paintable_new (g_object_ref (cog_shader), NULL);
picture = gtk_picture_new_for_paintable (paintable);
gtk_widget_set_size_request (picture, 150, 75);
gtk_widget_add_tick_callback (picture, update_paintable, NULL, NULL);
return picture;
G_GNUC_END_IGNORE_DEPRECATIONS
}
static gboolean
check_cogs (GtkFishbowl *fb)
{
return GSK_IS_GL_RENDERER (gtk_native_get_renderer (gtk_widget_get_native (GTK_WIDGET (fb))));
}
static void
mapped (GtkWidget *w)
{
@@ -241,7 +200,6 @@ static const struct {
{ "Gears", create_gears, NULL },
{ "Switch", create_switch, NULL },
{ "Menubutton", create_menu_button, NULL },
{ "Shader", create_cogs, check_cogs },
{ "Tiger", create_tiger, NULL },
{ "Graph", create_graph, NULL },
};

View File

@@ -1869,4 +1869,4 @@ do_font_features (GtkWidget *do_widget)
return window;
}
/* vim:set foldmethod=marker expandtab: */
/* vim:set foldmethod=marker: */

View File

@@ -276,7 +276,7 @@ gtk_font_plane_class_init (GtkFontPlaneClass *class)
GtkWidget *
gtk_font_plane_new (GtkAdjustment *weight_adj,
GtkAdjustment *width_adj)
GtkAdjustment *width_adj)
{
return g_object_new (GTK_TYPE_FONT_PLANE,
"weight-adjustment", weight_adj,

View File

@@ -55,7 +55,7 @@ struct _GtkFontPlaneClass
GType gtk_font_plane_get_type (void) G_GNUC_CONST;
GtkWidget * gtk_font_plane_new (GtkAdjustment *width_adj,
GtkAdjustment *weight_adj);
GtkWidget * gtk_font_plane_new (GtkAdjustment *weight_adj,
GtkAdjustment *width_adj);
G_END_DECLS

View File

@@ -1,366 +0,0 @@
/* OpenGL/Transitions and Effects
* #Keywords: OpenGL, shader, effect
*
* Create transitions between pages using a custom fragment shader.
*
* The example transitions here are taken from gl-transitions.com, and you
* can edit the shader code itself on the last page of the stack.
*
* The transitions work with arbitrary content. We use images, shaders
* GL areas and plain old widgets to demonstrate this.
*
* The demo also shows some over-the-top effects like wobbly widgets,
* and animated backgrounds.
*/
#include <math.h>
#include <gtk/gtk.h>
#include "gtkshaderstack.h"
#include "gtkshaderbin.h"
#include "gtkshadertoy.h"
#include "gskshaderpaintable.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static GtkWidget *demo_window = NULL;
static void
close_window (GtkWidget *widget)
{
/* Reset the state */
demo_window = NULL;
}
static void
text_changed (GtkTextBuffer *buffer,
GtkWidget *button)
{
gtk_widget_set_visible (button, TRUE);
}
static void
apply_text (GtkWidget *button,
GtkTextBuffer *buffer)
{
GtkWidget *stack;
GskGLShader *shader;
GtkTextIter start, end;
char *text;
stack = g_object_get_data (G_OBJECT (button), "the-stack");
gtk_text_buffer_get_bounds (buffer, &start, &end);
text = gtk_text_buffer_get_text (buffer, &start, &end, TRUE);
GBytes *bytes = g_bytes_new_take (text, strlen (text));
shader = gsk_gl_shader_new_from_bytes (bytes);
gtk_shader_stack_set_shader (GTK_SHADER_STACK (stack), shader);
g_object_unref (shader);
g_bytes_unref (bytes);
gtk_widget_set_visible (button, FALSE);
}
static void
go_back (GtkWidget *button,
GtkWidget *stack)
{
gtk_shader_stack_transition (GTK_SHADER_STACK (stack), FALSE);
}
static void
go_forward (GtkWidget *button,
GtkWidget *stack)
{
gtk_shader_stack_transition (GTK_SHADER_STACK (stack), TRUE);
}
static void
clicked_cb (GtkGestureClick *gesture,
guint n_pressed,
double x,
double y,
gpointer data)
{
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
}
static GtkWidget *
ripple_bin_new (void)
{
GtkWidget *bin = gtk_shader_bin_new ();
static GskGLShader *shader = NULL;
if (shader == NULL)
shader = gsk_gl_shader_new_from_resource ("/gltransition/ripple.glsl");
gtk_shader_bin_add_shader (GTK_SHADER_BIN (bin), shader, GTK_STATE_FLAG_PRELIGHT, GTK_STATE_FLAG_PRELIGHT, 20);
return bin;
}
static GtkWidget *
new_shadertoy (const char *path)
{
GBytes *shader;
GtkWidget *toy;
toy = gtk_shadertoy_new ();
shader = g_resources_lookup_data (path, 0, NULL);
gtk_shadertoy_set_image_shader (GTK_SHADERTOY (toy),
g_bytes_get_data (shader, NULL));
g_bytes_unref (shader);
return toy;
}
static gboolean
update_paintable (GtkWidget *widget,
GdkFrameClock *frame_clock,
gpointer user_data)
{
GskShaderPaintable *paintable;
gint64 frame_time;
paintable = GSK_SHADER_PAINTABLE (gtk_picture_get_paintable (GTK_PICTURE (widget)));
frame_time = gdk_frame_clock_get_frame_time (frame_clock);
gsk_shader_paintable_update_time (paintable, 0, frame_time);
return G_SOURCE_CONTINUE;
}
static GtkWidget *
make_shader_stack (const char *name,
const char *resource_path,
int active_child,
GtkWidget *scale)
{
GtkWidget *stack, *child, *widget, *vbox, *hbox, *bin;
GtkWidget *label, *button, *tv;
GskGLShader *shader;
GObjectClass *class;
GParamSpecFloat *pspec;
GtkAdjustment *adjustment;
GtkTextBuffer *buffer;
GBytes *bytes;
GtkEventController *controller;
GdkPaintable *paintable;
stack = gtk_shader_stack_new ();
shader = gsk_gl_shader_new_from_resource (resource_path);
gtk_shader_stack_set_shader (GTK_SHADER_STACK (stack), shader);
g_object_unref (shader);
child = gtk_picture_new_for_resource ("/css_blendmodes/ducky.png");
gtk_picture_set_can_shrink (GTK_PICTURE (child), TRUE);
gtk_shader_stack_add_child (GTK_SHADER_STACK (stack), child);
shader = gsk_gl_shader_new_from_resource ("/gltransition/cogs2.glsl");
paintable = gsk_shader_paintable_new (shader, NULL);
child = gtk_picture_new_for_paintable (paintable);
gtk_widget_add_tick_callback (child, update_paintable, NULL, NULL);
gtk_picture_set_can_shrink (GTK_PICTURE (child), TRUE);
gtk_shader_stack_add_child (GTK_SHADER_STACK (stack), child);
child = gtk_picture_new_for_resource ("/transparent/portland-rose.jpg");
gtk_picture_set_can_shrink (GTK_PICTURE (child), TRUE);
gtk_shader_stack_add_child (GTK_SHADER_STACK (stack), child);
child = new_shadertoy ("/shadertoy/neon.glsl");
gtk_shader_stack_add_child (GTK_SHADER_STACK (stack), child);
child = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
class = g_type_class_ref (GTK_TYPE_SHADER_STACK);
pspec = G_PARAM_SPEC_FLOAT (g_object_class_find_property (class, "duration"));
adjustment = gtk_range_get_adjustment (GTK_RANGE (scale));
if (gtk_adjustment_get_lower (adjustment) == 0.0 &&
gtk_adjustment_get_upper (adjustment) == 0.0)
{
gtk_adjustment_configure (adjustment,
pspec->default_value,
pspec->minimum,
pspec->maximum,
0.1, 0.5, 0);
}
g_type_class_unref (class);
g_object_bind_property (adjustment, "value",
stack, "duration",
G_BINDING_DEFAULT);
widget = gtk_scrolled_window_new ();
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (widget), TRUE);
gtk_widget_set_hexpand (widget, TRUE);
gtk_widget_set_vexpand (widget, TRUE);
controller = GTK_EVENT_CONTROLLER (gtk_gesture_click_new ());
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (controller), 0);
g_signal_connect (controller, "released", G_CALLBACK (clicked_cb), NULL);
gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_BUBBLE);
gtk_widget_add_controller (GTK_WIDGET (widget), controller);
tv = gtk_text_view_new ();
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (tv), 4);
gtk_text_view_set_right_margin (GTK_TEXT_VIEW (tv), 4);
gtk_text_view_set_top_margin (GTK_TEXT_VIEW (tv), 4);
gtk_text_view_set_bottom_margin (GTK_TEXT_VIEW (tv), 4);
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tv));
bytes = g_resources_lookup_data (resource_path, 0, NULL);
gtk_text_buffer_set_text (buffer,
(const char *)g_bytes_get_data (bytes, NULL),
g_bytes_get_size (bytes));
g_bytes_unref (bytes);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (widget), tv);
gtk_box_append (GTK_BOX (child), widget);
gtk_shader_stack_add_child (GTK_SHADER_STACK (stack), child);
gtk_shader_stack_set_active (GTK_SHADER_STACK (stack), active_child);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
widget = gtk_center_box_new ();
label = gtk_label_new (name);
gtk_widget_add_css_class (label, "title-4");
gtk_widget_set_size_request (label, -1, 26);
gtk_center_box_set_center_widget (GTK_CENTER_BOX (widget), label);
button = gtk_button_new_from_icon_name ("view-refresh-symbolic");
g_signal_connect (buffer, "changed", G_CALLBACK (text_changed), button);
g_object_set_data (G_OBJECT (button), "the-stack", stack);
g_signal_connect (button, "clicked", G_CALLBACK (apply_text), buffer);
gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
gtk_widget_add_css_class (button, "small");
gtk_widget_set_visible (button, FALSE);
gtk_center_box_set_end_widget (GTK_CENTER_BOX (widget), button);
gtk_box_append (GTK_BOX (vbox), widget);
GtkWidget *bin2 = ripple_bin_new ();
gtk_shader_bin_set_child (GTK_SHADER_BIN (bin2), stack);
gtk_box_append (GTK_BOX (vbox), bin2);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_widget_set_halign (hbox, GTK_ALIGN_CENTER);
gtk_box_append (GTK_BOX (vbox), hbox);
button = gtk_button_new_from_icon_name ("go-previous-symbolic");
g_signal_connect (button, "clicked", G_CALLBACK (go_back), stack);
bin = ripple_bin_new ();
gtk_shader_bin_set_child (GTK_SHADER_BIN (bin), button);
gtk_box_append (GTK_BOX (hbox), bin);
button = gtk_button_new_from_icon_name ("go-next-symbolic");
g_signal_connect (button, "clicked", G_CALLBACK (go_forward), stack);
bin = ripple_bin_new ();
gtk_shader_bin_set_child (GTK_SHADER_BIN (bin), button);
gtk_box_append (GTK_BOX (hbox), bin);
return vbox;
}
static void
remove_provider (gpointer data)
{
GtkStyleProvider *provider = GTK_STYLE_PROVIDER (data);
gtk_style_context_remove_provider_for_display (gdk_display_get_default (), provider);
g_object_unref (provider);
}
static GtkWidget *
create_gltransition_window (GtkWidget *do_widget)
{
GtkWidget *window, *headerbar, *scale, *outer_grid, *grid, *background;
GdkPaintable *paintable;
GtkCssProvider *provider;
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Transitions and Effects");
headerbar = gtk_header_bar_new ();
scale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, NULL);
gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
gtk_widget_set_size_request (scale, 100, -1);
gtk_widget_set_tooltip_text (scale, "Transition duration");
gtk_header_bar_pack_end (GTK_HEADER_BAR (headerbar), scale);
gtk_window_set_titlebar (GTK_WINDOW (window), headerbar);
gtk_window_set_default_size (GTK_WINDOW (window), 800, 600);
g_signal_connect (window, "destroy", G_CALLBACK (close_window), NULL);
outer_grid = gtk_grid_new ();
gtk_window_set_child (GTK_WINDOW (window), outer_grid);
paintable = gsk_shader_paintable_new (gsk_gl_shader_new_from_resource ("/gltransition/background.glsl"), NULL);
background = gtk_picture_new_for_paintable (paintable);
gtk_widget_add_tick_callback (background, update_paintable, NULL, NULL);
gtk_grid_attach (GTK_GRID (outer_grid),
background,
0, 0, 1, 1);
grid = gtk_grid_new ();
gtk_grid_attach (GTK_GRID (outer_grid),
grid,
0, 0, 1, 1);
gtk_widget_set_halign (grid, GTK_ALIGN_CENTER);
gtk_widget_set_valign (grid, GTK_ALIGN_CENTER);
gtk_widget_set_margin_start (grid, 12);
gtk_widget_set_margin_end (grid, 12);
gtk_widget_set_margin_top (grid, 12);
gtk_widget_set_margin_bottom (grid, 12);
gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
gtk_grid_set_row_homogeneous (GTK_GRID (grid), TRUE);
gtk_grid_set_column_homogeneous (GTK_GRID (grid), TRUE);
gtk_grid_attach (GTK_GRID (grid),
make_shader_stack ("Wind", "/gltransition/wind.glsl", 0, scale),
0, 0, 1, 1);
gtk_grid_attach (GTK_GRID (grid),
make_shader_stack ("Radial", "/gltransition/radial.glsl", 1, scale),
1, 0, 1, 1);
gtk_grid_attach (GTK_GRID (grid),
make_shader_stack ("Crosswarp", "/gltransition/crosswarp.glsl", 2, scale),
0, 1, 1, 1);
gtk_grid_attach (GTK_GRID (grid),
make_shader_stack ("Kaleidoscope", "/gltransition/kaleidoscope.glsl", 3, scale),
1, 1, 1, 1);
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_string (provider, "button.small { padding: 0; }");
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_set_data_full (G_OBJECT (window), "provider", provider, remove_provider);
return window;
}
GtkWidget *
do_gltransition (GtkWidget *do_widget)
{
if (!demo_window)
demo_window = create_gltransition_window (do_widget);
if (!gtk_widget_get_visible (demo_window))
gtk_widget_set_visible (demo_window, TRUE);
else
gtk_window_destroy (GTK_WINDOW (demo_window));
return demo_window;
}
G_GNUC_END_IGNORE_DEPRECATIONS

View File

@@ -1,338 +0,0 @@
/*
* Copyright © 2020 Red Hat, Inc
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Matthias Clasen <mclasen@redhat.com>
*/
#include "config.h"
#include <gtk/gtk.h>
#include "gskshaderpaintable.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
/**
* GskShaderPaintable:
*
* `GskShaderPaintable` is an implementation of the `GdkPaintable` interface
* that uses a `GskGLShader` to create pixels.
*
* You can set the uniform data that the shader needs for rendering
* using gsk_shader_paintable_set_args(). This function can
* be called repeatedly to change the uniform data for the next
* snapshot.
*
* Commonly, time is passed to shaders as a float uniform containing
* the elapsed time in seconds. The convenience API
* gsk_shader_paintable_update_time() can be called from a `GtkTickCallback`
* to update the time based on the frame time of the frame clock.
*/
struct _GskShaderPaintable
{
GObject parent_instance;
GskGLShader *shader;
GBytes *args;
gint64 start_time;
};
struct _GskShaderPaintableClass
{
GObjectClass parent_class;
};
enum {
PROP_0,
PROP_SHADER,
PROP_ARGS,
N_PROPS,
};
static GParamSpec *properties[N_PROPS] = { NULL, };
static void
gsk_shader_paintable_paintable_snapshot (GdkPaintable *paintable,
GdkSnapshot *snapshot,
double width,
double height)
{
GskShaderPaintable *self = GSK_SHADER_PAINTABLE (paintable);
gtk_snapshot_push_gl_shader (snapshot, self->shader, &GRAPHENE_RECT_INIT(0, 0, width, height), g_bytes_ref (self->args));
gtk_snapshot_pop (snapshot);
}
static void
gsk_shader_paintable_paintable_init (GdkPaintableInterface *iface)
{
iface->snapshot = gsk_shader_paintable_paintable_snapshot;
}
G_DEFINE_TYPE_EXTENDED (GskShaderPaintable, gsk_shader_paintable, G_TYPE_OBJECT, 0,
G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
gsk_shader_paintable_paintable_init))
static void
gsk_shader_paintable_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GskShaderPaintable *self = GSK_SHADER_PAINTABLE (object);
switch (prop_id)
{
case PROP_SHADER:
gsk_shader_paintable_set_shader (self, g_value_get_object (value));
break;
case PROP_ARGS:
gsk_shader_paintable_set_args (self, g_value_get_boxed (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gsk_shader_paintable_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GskShaderPaintable *self = GSK_SHADER_PAINTABLE (object);
switch (prop_id)
{
case PROP_SHADER:
g_value_set_object (value, self->shader);
break;
case PROP_ARGS:
g_value_set_boxed (value, self->args);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gsk_shader_paintable_finalize (GObject *object)
{
GskShaderPaintable *self = GSK_SHADER_PAINTABLE (object);
g_clear_pointer (&self->args, g_bytes_unref);
g_clear_object (&self->shader);
G_OBJECT_CLASS (gsk_shader_paintable_parent_class)->finalize (object);
}
static void
gsk_shader_paintable_class_init (GskShaderPaintableClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->get_property = gsk_shader_paintable_get_property;
gobject_class->set_property = gsk_shader_paintable_set_property;
gobject_class->finalize = gsk_shader_paintable_finalize;
properties[PROP_SHADER] =
g_param_spec_object ("shader", "Shader", "The shader",
GSK_TYPE_GL_SHADER,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
properties[PROP_ARGS] =
g_param_spec_boxed ("args", "Arguments", "The uniform arguments",
G_TYPE_BYTES,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (gobject_class, N_PROPS, properties);
}
static void
gsk_shader_paintable_init (GskShaderPaintable *self)
{
}
/**
* gsk_shader_paintable_new:
* @shader: (transfer full) (nullable): the shader to use
* @data: (transfer full) (nullable): uniform data
*
* Creates a paintable that uses the @shader to create
* pixels. The shader must not require input textures.
* If @data is %NULL, all uniform values are set to zero.
*
* Returns: (transfer full): a new `GskShaderPaintable`
*/
GdkPaintable *
gsk_shader_paintable_new (GskGLShader *shader,
GBytes *data)
{
GdkPaintable *ret;
g_return_val_if_fail (shader == NULL || GSK_IS_GL_SHADER (shader), NULL);
if (shader && !data)
{
int size = gsk_gl_shader_get_args_size (shader);
data = g_bytes_new_take (g_new0 (guchar, size), size);
}
ret = g_object_new (GSK_TYPE_SHADER_PAINTABLE,
"shader", shader,
"args", data,
NULL);
g_clear_object (&shader);
g_clear_pointer (&data, g_bytes_unref);
return ret;
}
/**
* gsk_shader_paintable_set_shader:
* @self: a `GskShaderPaintable`
* @shader: the `GskGLShader` to use
*
* Sets the shader that the paintable will use
* to create pixels. The shader must not require
* input textures.
*/
void
gsk_shader_paintable_set_shader (GskShaderPaintable *self,
GskGLShader *shader)
{
g_return_if_fail (GSK_IS_SHADER_PAINTABLE (self));
g_return_if_fail (shader == NULL || GSK_IS_GL_SHADER (shader));
g_return_if_fail (shader == NULL || gsk_gl_shader_get_n_textures (shader) == 0);
if (!g_set_object (&self->shader, shader))
return;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SHADER]);
gdk_paintable_invalidate_contents (GDK_PAINTABLE (self));
g_clear_pointer (&self->args, g_bytes_unref);
}
/**
* gsk_shader_paintable_get_shader:
* @self: a `GskShaderPaintable`
*
* Returns the shader that the paintable is using.
*
* Returns: (transfer none): the `GskGLShader` that is used
*/
GskGLShader *
gsk_shader_paintable_get_shader (GskShaderPaintable *self)
{
g_return_val_if_fail (GSK_IS_SHADER_PAINTABLE (self), NULL);
return self->shader;
}
/**
* gsk_shader_paintable_set_args:
* @self: a `GskShaderPaintable`
* @data: Data block with uniform data for the shader
*
* Sets the uniform data that will be passed to the
* shader when rendering. The @data will typically
* be produced by a `GskUniformDataBuilder`.
*
* Note that the @data should be considered immutable
* after it has been passed to this function.
*/
void
gsk_shader_paintable_set_args (GskShaderPaintable *self,
GBytes *data)
{
g_return_if_fail (GSK_IS_SHADER_PAINTABLE (self));
g_return_if_fail (data == NULL || g_bytes_get_size (data) == gsk_gl_shader_get_args_size (self->shader));
g_clear_pointer (&self->args, g_bytes_unref);
if (data)
self->args = g_bytes_ref (data);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ARGS]);
gdk_paintable_invalidate_contents (GDK_PAINTABLE (self));
}
/**
* gsk_shader_paintable_get_args:
* @self: a `GskShaderPaintable`
*
* Returns the uniform data set with
* gsk_shader_paintable_get_args().
*
* Returns: (transfer none): the uniform data
*/
GBytes *
gsk_shader_paintable_get_args (GskShaderPaintable *self)
{
g_return_val_if_fail (GSK_IS_SHADER_PAINTABLE (self), NULL);
return self->args;
}
/**
* gsk_shader_paintable_update_time:
* @self: a `GskShaderPaintable`
* @time_idx: the index of the uniform for time in seconds as float
* @frame_time: the current frame time, as returned by `GdkFrameClock`
*
* This function is a convenience wrapper for
* gsk_shader_paintable_set_args() that leaves all
* uniform values unchanged, except for the uniform with
* index @time_idx, which will be set to the elapsed time
* in seconds, since the first call to this function.
*
* This function is usually called from a `GtkTickCallback`.
*/
void
gsk_shader_paintable_update_time (GskShaderPaintable *self,
int time_idx,
gint64 frame_time)
{
GskShaderArgsBuilder *builder;
GBytes *args;
float time;
if (self->start_time == 0)
self->start_time = frame_time;
time = (frame_time - self->start_time) / (float)G_TIME_SPAN_SECOND;
builder = gsk_shader_args_builder_new (self->shader, self->args);
gsk_shader_args_builder_set_float (builder, time_idx, time);
args = gsk_shader_args_builder_free_to_args (builder);
gsk_shader_paintable_set_args (self, args);
g_bytes_unref (args);
}
G_GNUC_END_IGNORE_DEPRECATIONS

View File

@@ -1,47 +0,0 @@
/*
* Copyright © 2020 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Matthias Clasen <mclasen@redhat.com>
*/
#pragma once
#include <gdk/gdk.h>
#include <gsk/gsk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
G_BEGIN_DECLS
#define GSK_TYPE_SHADER_PAINTABLE (gsk_shader_paintable_get_type ())
G_DECLARE_FINAL_TYPE (GskShaderPaintable, gsk_shader_paintable, GSK, SHADER_PAINTABLE, GObject)
GdkPaintable * gsk_shader_paintable_new (GskGLShader *shader,
GBytes *data);
GskGLShader * gsk_shader_paintable_get_shader (GskShaderPaintable *self);
void gsk_shader_paintable_set_shader (GskShaderPaintable *self,
GskGLShader *shader);
GBytes * gsk_shader_paintable_get_args (GskShaderPaintable *self);
void gsk_shader_paintable_set_args (GskShaderPaintable *self,
GBytes *data);
void gsk_shader_paintable_update_time (GskShaderPaintable *self,
int time_idx,
gint64 frame_time);
G_END_DECLS
G_GNUC_END_IGNORE_DEPRECATIONS

View File

@@ -55,7 +55,7 @@ void gtk_fishbowl_set_animating (GtkFishbowl *fishbowl,
gboolean animating);
gboolean gtk_fishbowl_get_benchmark (GtkFishbowl *fishbowl);
void gtk_fishbowl_set_benchmark (GtkFishbowl *fishbowl,
gboolean animating);
gboolean benchmark);
double gtk_fishbowl_get_framerate (GtkFishbowl *fishbowl);
gint64 gtk_fishbowl_get_update_delay (GtkFishbowl *fishbowl);
void gtk_fishbowl_set_update_delay (GtkFishbowl *fishbowl,

View File

@@ -1,268 +0,0 @@
#include "gtkshaderbin.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
typedef struct {
GskGLShader *shader;
GtkStateFlags state;
GtkStateFlags state_mask;
float extra_border;
gboolean compiled;
gboolean compiled_ok;
} ShaderInfo;
struct _GtkShaderBin
{
GtkWidget parent_instance;
GtkWidget *child;
ShaderInfo *active_shader;
GPtrArray *shaders;
guint tick_id;
float time;
float mouse_x, mouse_y;
gint64 first_frame_time;
};
struct _GtkShaderBinClass
{
GtkWidgetClass parent_class;
};
G_DEFINE_TYPE (GtkShaderBin, gtk_shader_bin, GTK_TYPE_WIDGET)
static void
shader_info_free (ShaderInfo *info)
{
g_object_unref (info->shader);
g_free (info);
}
static void
gtk_shader_bin_finalize (GObject *object)
{
GtkShaderBin *self = GTK_SHADER_BIN (object);
g_ptr_array_free (self->shaders, TRUE);
G_OBJECT_CLASS (gtk_shader_bin_parent_class)->finalize (object);
}
static void
gtk_shader_bin_dispose (GObject *object)
{
GtkShaderBin *self = GTK_SHADER_BIN (object);
g_clear_pointer (&self->child, gtk_widget_unparent);
G_OBJECT_CLASS (gtk_shader_bin_parent_class)->dispose (object);
}
static gboolean
gtk_shader_bin_tick (GtkWidget *widget,
GdkFrameClock *frame_clock,
gpointer unused)
{
GtkShaderBin *self = GTK_SHADER_BIN (widget);
gint64 frame_time;
frame_time = gdk_frame_clock_get_frame_time (frame_clock);
if (self->first_frame_time == 0)
self->first_frame_time = frame_time;
self->time = (frame_time - self->first_frame_time) / (float)G_USEC_PER_SEC;
gtk_widget_queue_draw (widget);
return G_SOURCE_CONTINUE;
}
static void
motion_cb (GtkEventControllerMotion *controller,
double x,
double y,
GtkShaderBin *self)
{
self->mouse_x = x;
self->mouse_y = y;
}
static void
gtk_shader_bin_init (GtkShaderBin *self)
{
GtkEventController *controller;
self->shaders = g_ptr_array_new_with_free_func ((GDestroyNotify)shader_info_free);
controller = gtk_event_controller_motion_new ();
g_signal_connect (controller, "motion", G_CALLBACK (motion_cb), self);
gtk_widget_add_controller (GTK_WIDGET (self), controller);
}
void
gtk_shader_bin_update_active_shader (GtkShaderBin *self)
{
GtkStateFlags new_state = gtk_widget_get_state_flags (GTK_WIDGET (self));
ShaderInfo *new_shader = NULL;
for (int i = 0; i < self->shaders->len; i++)
{
ShaderInfo *info = g_ptr_array_index (self->shaders, i);
if ((info->state_mask & new_state) == info->state)
{
new_shader = info;
break;
}
}
if (self->active_shader == new_shader)
return;
self->active_shader = new_shader;
self->first_frame_time = 0;
if (self->active_shader)
{
if (self->tick_id == 0)
self->tick_id = gtk_widget_add_tick_callback (GTK_WIDGET (self),
gtk_shader_bin_tick,
NULL, NULL);
}
else
{
if (self->tick_id != 0)
{
gtk_widget_remove_tick_callback (GTK_WIDGET (self), self->tick_id);
self->tick_id = 0;
}
}
gtk_widget_queue_draw (GTK_WIDGET (self));
}
static void
gtk_shader_bin_state_flags_changed (GtkWidget *widget,
GtkStateFlags previous_state_flags)
{
GtkShaderBin *self = GTK_SHADER_BIN (widget);
gtk_shader_bin_update_active_shader (self);
}
void
gtk_shader_bin_add_shader (GtkShaderBin *self,
GskGLShader *shader,
GtkStateFlags state,
GtkStateFlags state_mask,
float extra_border)
{
ShaderInfo *info = g_new0 (ShaderInfo, 1);
info->shader = g_object_ref (shader);
info->state = state;
info->state_mask = state_mask;
info->extra_border = extra_border;
g_ptr_array_add (self->shaders, info);
gtk_shader_bin_update_active_shader (self);
}
void
gtk_shader_bin_set_child (GtkShaderBin *self,
GtkWidget *child)
{
if (self->child == child)
return;
g_clear_pointer (&self->child, gtk_widget_unparent);
if (child)
{
self->child = child;
gtk_widget_set_parent (child, GTK_WIDGET (self));
}
}
GtkWidget *
gtk_shader_bin_get_child (GtkShaderBin *self)
{
return self->child;
}
static void
gtk_shader_bin_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot)
{
GtkShaderBin *self = GTK_SHADER_BIN (widget);
int width, height;
width = gtk_widget_get_width (widget);
height = gtk_widget_get_height (widget);
if (self->active_shader)
{
if (!self->active_shader->compiled)
{
GtkNative *native = gtk_widget_get_native (widget);
GskRenderer *renderer = gtk_native_get_renderer (native);
GError *error = NULL;
self->active_shader->compiled = TRUE;
self->active_shader->compiled_ok =
gsk_gl_shader_compile (self->active_shader->shader,
renderer, &error);
if (!self->active_shader->compiled_ok)
{
g_warning ("GtkShaderBin failed to compile shader: %s", error->message);
g_error_free (error);
}
}
if (self->active_shader->compiled_ok)
{
float border = self->active_shader->extra_border;
graphene_vec2_t mouse;
graphene_vec2_init (&mouse, self->mouse_x + border, self->mouse_y + border);
gtk_snapshot_push_gl_shader (snapshot, self->active_shader->shader,
&GRAPHENE_RECT_INIT(-border, -border, width+2*border, height+2*border),
gsk_gl_shader_format_args (self->active_shader->shader,
"u_time", self->time,
"u_mouse", &mouse,
NULL));
gtk_widget_snapshot_child (widget, self->child, snapshot);
gtk_snapshot_gl_shader_pop_texture (snapshot);
gtk_snapshot_pop (snapshot);
return;
}
}
/* Non-shader fallback */
gtk_widget_snapshot_child (widget, self->child, snapshot);
}
static void
gtk_shader_bin_class_init (GtkShaderBinClass *class)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->finalize = gtk_shader_bin_finalize;
object_class->dispose = gtk_shader_bin_dispose;
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
widget_class->snapshot = gtk_shader_bin_snapshot;
widget_class->state_flags_changed = gtk_shader_bin_state_flags_changed;
}
GtkWidget *
gtk_shader_bin_new (void)
{
GtkShaderBin *self;
self = g_object_new (GTK_TYPE_SHADER_BIN, NULL);
return GTK_WIDGET (self);
}
G_GNUC_END_IGNORE_DEPRECATIONS

View File

@@ -1,24 +0,0 @@
#pragma once
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
G_BEGIN_DECLS
#define GTK_TYPE_SHADER_BIN (gtk_shader_bin_get_type ())
G_DECLARE_FINAL_TYPE (GtkShaderBin, gtk_shader_bin, GTK, SHADER_BIN, GtkWidget)
GtkWidget *gtk_shader_bin_new (void);
void gtk_shader_bin_add_shader (GtkShaderBin *self,
GskGLShader *shader,
GtkStateFlags state,
GtkStateFlags state_mask,
float extra_border);
void gtk_shader_bin_set_child (GtkShaderBin *self,
GtkWidget *child);
GtkWidget *gtk_shader_bin_get_child (GtkShaderBin *self);
G_END_DECLS
G_GNUC_END_IGNORE_DEPRECATIONS

View File

@@ -1,365 +0,0 @@
#include "gtkshaderstack.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
struct _GtkShaderStack
{
GtkWidget parent_instance;
GskGLShader *shader;
GPtrArray *children;
int current;
int next;
gboolean backwards;
guint tick_id;
float time;
float duration;
gint64 start_time;
};
struct _GtkShaderStackClass
{
GtkWidgetClass parent_class;
};
enum {
PROP_DURATION = 1,
NUM_PROPERTIES
};
static GParamSpec *properties[NUM_PROPERTIES] = { NULL };
G_DEFINE_TYPE (GtkShaderStack, gtk_shader_stack, GTK_TYPE_WIDGET)
static void
gtk_shader_stack_finalize (GObject *object)
{
GtkShaderStack *self = GTK_SHADER_STACK (object);
g_object_unref (self->shader);
G_OBJECT_CLASS (gtk_shader_stack_parent_class)->finalize (object);
}
static void
update_child_visible (GtkShaderStack *self)
{
int i;
for (i = 0; i < self->children->len; i++)
{
GtkWidget *child = g_ptr_array_index (self->children, i);
gtk_widget_set_child_visible (child,
i == self->current || i == self->next);
}
}
static gboolean
transition_cb (GtkWidget *widget,
GdkFrameClock *clock,
gpointer unused)
{
GtkShaderStack *self = GTK_SHADER_STACK (widget);
gint64 frame_time;
frame_time = gdk_frame_clock_get_frame_time (clock);
if (self->start_time == 0)
self->start_time = frame_time;
self->time = (frame_time - self->start_time) / (float)G_USEC_PER_SEC;
gtk_widget_queue_draw (widget);
if (self->time >= self->duration)
{
self->current = self->next;
self->next = -1;
update_child_visible (self);
return G_SOURCE_REMOVE;
}
else
return G_SOURCE_CONTINUE;
}
static void
start_transition (GtkShaderStack *self)
{
self->start_time = 0;
self->tick_id = gtk_widget_add_tick_callback (GTK_WIDGET (self),
transition_cb,
NULL, NULL);
}
static void
stop_transition (GtkShaderStack *self)
{
if (self->tick_id != 0)
{
gtk_widget_remove_tick_callback (GTK_WIDGET (self), self->tick_id);
self->tick_id = 0;
}
if (self->next != -1)
self->current = self->next;
self->next = -1;
update_child_visible (self);
}
static void
gtk_shader_stack_dispose (GObject *object)
{
GtkShaderStack *self = GTK_SHADER_STACK (object);
stop_transition (self);
g_clear_pointer (&self->children, g_ptr_array_unref);
G_OBJECT_CLASS (gtk_shader_stack_parent_class)->dispose (object);
}
void
gtk_shader_stack_transition (GtkShaderStack *self,
gboolean forward)
{
stop_transition (self);
self->backwards = !forward;
if (self->backwards)
self->next = (self->current + self->children->len - 1) % self->children->len;
else
self->next = (self->current + 1) % self->children->len;
update_child_visible (self);
start_transition (self);
}
static void
gtk_shader_stack_init (GtkShaderStack *self)
{
self->children = g_ptr_array_new_with_free_func ((GDestroyNotify)gtk_widget_unparent);
self->current = -1;
self->next = -1;
self->backwards = FALSE;
self->duration = 1.0;
}
static void
gtk_shader_stack_measure (GtkWidget *widget,
GtkOrientation orientation,
int for_size,
int *minimum,
int *natural,
int *minimum_baseline,
int *natural_baseline)
{
GtkShaderStack *self = GTK_SHADER_STACK (widget);
int i;
*minimum = 0;
*natural = 0;
for (i = 0; i < self->children->len; i++)
{
GtkWidget *child = g_ptr_array_index (self->children, i);
int child_min, child_nat;
if (gtk_widget_get_visible (child))
{
gtk_widget_measure (child, orientation, for_size, &child_min, &child_nat, NULL, NULL);
*minimum = MAX (*minimum, child_min);
*natural = MAX (*natural, child_nat);
}
}
}
static void
gtk_shader_stack_size_allocate (GtkWidget *widget,
int width,
int height,
int baseline)
{
GtkShaderStack *self = GTK_SHADER_STACK (widget);
GtkAllocation child_allocation;
GtkWidget *child;
int i;
child_allocation.x = 0;
child_allocation.y = 0;
child_allocation.width = width;
child_allocation.height = height;
for (i = 0; i < self->children->len; i++)
{
child = g_ptr_array_index (self->children, i);
if (gtk_widget_get_visible (child))
gtk_widget_size_allocate (child, &child_allocation, -1);
}
}
static void
gtk_shader_stack_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot)
{
GtkShaderStack *self = GTK_SHADER_STACK (widget);
int width, height;
GtkWidget *current, *next;
width = gtk_widget_get_width (widget);
height = gtk_widget_get_height (widget);
current = g_ptr_array_index (self->children, self->current);
if (self->next == -1)
{
gtk_widget_snapshot_child (widget, current, snapshot);
}
else
{
GtkNative *native = gtk_widget_get_native (widget);
GskRenderer *renderer = gtk_native_get_renderer (native);
float progress;
next = g_ptr_array_index (self->children, self->next);
progress = self->time / self->duration;
if (self->backwards)
{
GtkWidget *tmp = next;
next = current;
current = tmp;
progress = 1. - progress;
}
if (gsk_gl_shader_compile (self->shader, renderer, NULL))
{
gtk_snapshot_push_gl_shader (snapshot,
self->shader,
&GRAPHENE_RECT_INIT(0, 0, width, height),
gsk_gl_shader_format_args (self->shader,
"progress", progress,
NULL));
gtk_widget_snapshot_child (widget, current, snapshot);
gtk_snapshot_gl_shader_pop_texture (snapshot); /* current child */
gtk_widget_snapshot_child (widget, next, snapshot);
gtk_snapshot_gl_shader_pop_texture (snapshot); /* next child */
gtk_snapshot_pop (snapshot);
}
else
{
/* Non-shader fallback */
gtk_widget_snapshot_child (widget, current, snapshot);
}
}
}
static void
gtk_shader_stack_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GtkShaderStack *self = GTK_SHADER_STACK (object);
switch (prop_id)
{
case PROP_DURATION:
g_value_set_float (value, self->duration);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_shader_stack_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GtkShaderStack *self = GTK_SHADER_STACK (object);
switch (prop_id)
{
case PROP_DURATION:
self->duration = g_value_get_float (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_shader_stack_class_init (GtkShaderStackClass *class)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->finalize = gtk_shader_stack_finalize;
object_class->dispose = gtk_shader_stack_dispose;
object_class->get_property = gtk_shader_stack_get_property;
object_class->set_property = gtk_shader_stack_set_property;
widget_class->snapshot = gtk_shader_stack_snapshot;
widget_class->measure = gtk_shader_stack_measure;
widget_class->size_allocate = gtk_shader_stack_size_allocate;
properties[PROP_DURATION] =
g_param_spec_float ("duration", "Duration", "Duration",
0.1, 3.0, 1.0,
G_PARAM_READWRITE);
g_object_class_install_properties (object_class, NUM_PROPERTIES, properties);
}
GtkWidget *
gtk_shader_stack_new (void)
{
return g_object_new (GTK_TYPE_SHADER_STACK, NULL);
}
void
gtk_shader_stack_set_shader (GtkShaderStack *self,
GskGLShader *shader)
{
g_set_object (&self->shader, shader);
}
void
gtk_shader_stack_add_child (GtkShaderStack *self,
GtkWidget *child)
{
g_ptr_array_add (self->children, child);
gtk_widget_set_parent (child, GTK_WIDGET (self));
gtk_widget_queue_resize (GTK_WIDGET (self));
if (self->current == -1)
self->current = 0;
else
gtk_widget_set_child_visible (child, FALSE);
}
void
gtk_shader_stack_set_active (GtkShaderStack *self,
int index)
{
stop_transition (self);
self->current = MIN (index, self->children->len);
update_child_visible (self);
}
G_GNUC_END_IGNORE_DEPRECATIONS

View File

@@ -1,24 +0,0 @@
#pragma once
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
G_BEGIN_DECLS
#define GTK_TYPE_SHADER_STACK (gtk_shader_stack_get_type ())
G_DECLARE_FINAL_TYPE (GtkShaderStack, gtk_shader_stack, GTK, SHADER_STACK, GtkWidget)
GtkWidget * gtk_shader_stack_new (void);
void gtk_shader_stack_set_shader (GtkShaderStack *self,
GskGLShader *shader);
void gtk_shader_stack_add_child (GtkShaderStack *self,
GtkWidget *child);
void gtk_shader_stack_transition (GtkShaderStack *self,
gboolean forward);
void gtk_shader_stack_set_active (GtkShaderStack *self,
int index);
G_END_DECLS
G_GNUC_END_IGNORE_DEPRECATIONS

View File

@@ -1,5 +1,7 @@
#pragma once
#include <gdk/gdk.h>
typedef struct _GdkHSLA GdkHSLA;
struct _GdkHSLA {

View File

@@ -13,7 +13,7 @@ static GtkWidget *window = NULL;
static GtkWidget *scrolledwindow;
static int selected;
#define N_WIDGET_TYPES 8
#define N_WIDGET_TYPES 9
static int hincrement = 5;
@@ -73,30 +73,77 @@ populate_icons (void)
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scrolledwindow), grid);
}
static char *content;
static gsize content_len;
extern void fontify (const char *format, GtkTextBuffer *buffer);
enum {
PLAIN_TEXT,
HIGHLIGHTED_TEXT,
UNDERLINED_TEXT,
};
static void
populate_text (gboolean highlight)
underlinify (GtkTextBuffer *buffer)
{
GtkTextTagTable *tags;
GtkTextTag *tag[3];
GtkTextIter start, end;
tags = gtk_text_buffer_get_tag_table (buffer);
tag[0] = gtk_text_tag_new ("error");
tag[1] = gtk_text_tag_new ("strikeout");
tag[2] = gtk_text_tag_new ("double");
g_object_set (tag[0], "underline", PANGO_UNDERLINE_ERROR, NULL);
g_object_set (tag[1], "strikethrough", TRUE, NULL);
g_object_set (tag[2],
"underline", PANGO_UNDERLINE_DOUBLE,
"underline-rgba", &(GdkRGBA){0., 1., 1., 1. },
NULL);
gtk_text_tag_table_add (tags, tag[0]);
gtk_text_tag_table_add (tags, tag[1]);
gtk_text_tag_table_add (tags, tag[2]);
gtk_text_buffer_get_start_iter (buffer, &end);
while (TRUE)
{
gtk_text_iter_forward_word_end (&end);
start = end;
gtk_text_iter_backward_word_start (&start);
gtk_text_buffer_apply_tag (buffer, tag[g_random_int_range (0, 3)], &start, &end);
if (!gtk_text_iter_forward_word_ends (&end, 3))
break;
}
}
static void
populate_text (const char *resource, int kind)
{
GtkWidget *textview;
GtkTextBuffer *buffer;
char *content;
gsize content_len;
GBytes *bytes;
if (!content)
{
GBytes *bytes;
bytes = g_resources_lookup_data ("/sources/font_features.c", 0, NULL);
content = g_bytes_unref_to_data (bytes, &content_len);
}
bytes = g_resources_lookup_data (resource, 0, NULL);
content = g_bytes_unref_to_data (bytes, &content_len);
buffer = gtk_text_buffer_new (NULL);
gtk_text_buffer_set_text (buffer, content, (int)content_len);
if (highlight)
fontify ("c", buffer);
switch (kind)
{
case HIGHLIGHTED_TEXT:
fontify ("c", buffer);
break;
case UNDERLINED_TEXT:
underlinify (buffer);
break;
case PLAIN_TEXT:
default:
break;
}
textview = gtk_text_view_new ();
gtk_text_view_set_buffer (GTK_TEXT_VIEW (textview), buffer);
@@ -155,14 +202,6 @@ populate_image (void)
{
GtkWidget *image;
if (!content)
{
GBytes *bytes;
bytes = g_resources_lookup_data ("/sources/font_features.c", 0, NULL);
content = g_bytes_unref_to_data (bytes, &content_len);
}
image = gtk_picture_new_for_resource ("/sliding_puzzle/portland-rose.jpg");
gtk_picture_set_can_shrink (GTK_PICTURE (image), FALSE);
@@ -255,35 +294,40 @@ set_widget_type (int type)
case 1:
gtk_window_set_title (GTK_WINDOW (window), "Scrolling plain text");
populate_text (FALSE);
populate_text ("/sources/font_features.c", PLAIN_TEXT);
break;
case 2:
gtk_window_set_title (GTK_WINDOW (window), "Scrolling complex text");
populate_text (TRUE);
gtk_window_set_title (GTK_WINDOW (window), "Scrolling colored text");
populate_text ("/sources/font_features.c", HIGHLIGHTED_TEXT);
break;
case 3:
gtk_window_set_title (GTK_WINDOW (window), "Scrolling text with underlines");
populate_text ("/org/gtk/Demo4/Moby-Dick.txt", UNDERLINED_TEXT);
break;
case 4:
gtk_window_set_title (GTK_WINDOW (window), "Scrolling text with Emoji");
populate_emoji_text ();
break;
case 4:
case 5:
gtk_window_set_title (GTK_WINDOW (window), "Scrolling a big image");
populate_image ();
break;
case 5:
case 6:
gtk_window_set_title (GTK_WINDOW (window), "Scrolling a list");
populate_list ();
break;
case 6:
case 7:
gtk_window_set_title (GTK_WINDOW (window), "Scrolling a columned list");
populate_list2 ();
break;
case 7:
case 8:
gtk_window_set_title (GTK_WINDOW (window), "Scrolling a grid");
populate_grid ();
break;

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkWindow" id="window">
<property name="resizable">0</property>
<property name="resizable">1</property>
<property name="default-width">500</property>
<property name="default-height">500</property>
<child type="titlebar">

View File

@@ -14,6 +14,103 @@
#include <gtk/gtk.h>
#include "demo3widget.h"
static GtkWidget *window = NULL;
static GCancellable *cancellable = NULL;
static void
load_texture (GTask *task,
gpointer source_object,
gpointer task_data,
GCancellable *cable)
{
GFile *file = task_data;
GdkTexture *texture;
GError *error = NULL;
texture = gdk_texture_new_from_file (file, &error);
if (texture)
g_task_return_pointer (task, texture, g_object_unref);
else
g_task_return_error (task, error);
}
static void
set_wait_cursor (GtkWidget *widget)
{
gtk_widget_set_cursor_from_name (GTK_WIDGET (gtk_widget_get_root (widget)), "wait");
}
static void
unset_wait_cursor (GtkWidget *widget)
{
gtk_widget_set_cursor (GTK_WIDGET (gtk_widget_get_root (widget)), NULL);
}
static void
texture_loaded (GObject *source,
GAsyncResult *result,
gpointer data)
{
GdkTexture *texture;
GError *error = NULL;
texture = g_task_propagate_pointer (G_TASK (result), &error);
if (!texture)
{
g_print ("%s\n", error->message);
g_error_free (error);
return;
}
if (!window)
{
g_object_unref (texture);
return;
}
unset_wait_cursor (GTK_WIDGET (data));
g_object_set (G_OBJECT (data), "texture", texture, NULL);
}
static void
open_file_async (GFile *file,
GtkWidget *demo)
{
GTask *task;
set_wait_cursor (demo);
task = g_task_new (demo, cancellable, texture_loaded, demo);
g_task_set_task_data (task, g_object_ref (file), g_object_unref);
g_task_run_in_thread (task, load_texture);
g_object_unref (task);
}
static void
open_portland_rose (GtkWidget *button,
GtkWidget *demo)
{
GFile *file;
file = g_file_new_for_uri ("resource:///transparent/portland-rose.jpg");
open_file_async (file, demo);
g_object_unref (file);
}
static void
open_large_image (GtkWidget *button,
GtkWidget *demo)
{
GFile *file;
file = g_file_new_for_uri ("resource:///org/gtk/Demo4/large-image.png");
open_file_async (file, demo);
g_object_unref (file);
}
static void
file_opened (GObject *source,
GAsyncResult *result,
@@ -21,7 +118,6 @@ file_opened (GObject *source,
{
GFile *file;
GError *error = NULL;
GdkTexture *texture;
file = gtk_file_dialog_open_finish (GTK_FILE_DIALOG (source), result, &error);
@@ -32,17 +128,9 @@ file_opened (GObject *source,
return;
}
texture = gdk_texture_new_from_file (file, &error);
g_object_unref (file);
if (!texture)
{
g_print ("%s\n", error->message);
g_error_free (error);
return;
}
open_file_async (file, data);
g_object_set (G_OBJECT (data), "texture", texture, NULL);
g_object_unref (texture);
g_object_unref (file);
}
static void
@@ -116,11 +204,26 @@ transform_from (GBinding *binding,
return TRUE;
}
static void
free_cancellable (gpointer data)
{
g_cancellable_cancel (cancellable);
g_clear_object (&cancellable);
}
static gboolean
cancel_load (GtkWidget *widget,
GVariant *args,
gpointer data)
{
unset_wait_cursor (widget);
g_cancellable_cancel (G_CANCELLABLE (data));
return TRUE;
}
GtkWidget *
do_image_scaling (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;
if (!window)
{
GtkWidget *box;
@@ -130,6 +233,7 @@ do_image_scaling (GtkWidget *do_widget)
GtkWidget *scale;
GtkWidget *dropdown;
GtkWidget *button;
GtkEventController *controller;
window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (window), "Image Scaling");
@@ -138,6 +242,20 @@ do_image_scaling (GtkWidget *do_widget)
gtk_widget_get_display (do_widget));
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
cancellable = g_cancellable_new ();
g_object_set_data_full (G_OBJECT (window), "cancellable",
cancellable, free_cancellable);
controller = gtk_shortcut_controller_new ();
gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (controller),
gtk_shortcut_new (
gtk_keyval_trigger_new (GDK_KEY_Escape, 0),
gtk_callback_action_new (cancel_load, cancellable, NULL)
));
gtk_shortcut_controller_set_scope (GTK_SHORTCUT_CONTROLLER (controller),
GTK_SHORTCUT_SCOPE_GLOBAL);
gtk_widget_add_controller (window, controller);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_window_set_child (GTK_WINDOW (window), box);
@@ -156,6 +274,22 @@ do_image_scaling (GtkWidget *do_widget)
g_signal_connect (button, "clicked", G_CALLBACK (open_file), widget);
gtk_box_append (GTK_BOX (box2), button);
button = gtk_button_new ();
gtk_button_set_child (GTK_BUTTON (button),
gtk_image_new_from_resource ("/org/gtk/Demo4/portland-rose-thumbnail.png"));
gtk_widget_add_css_class (button, "image-button");
gtk_widget_set_tooltip_text (button, "Portland Rose");
g_signal_connect (button, "clicked", G_CALLBACK (open_portland_rose), widget);
gtk_box_append (GTK_BOX (box2), button);
button = gtk_button_new ();
gtk_button_set_child (GTK_BUTTON (button),
gtk_image_new_from_resource ("/org/gtk/Demo4/large-image-thumbnail.png"));
gtk_widget_add_css_class (button, "image-button");
gtk_widget_set_tooltip_text (button, "Large image");
g_signal_connect (button, "clicked", G_CALLBACK (open_large_image), widget);
gtk_box_append (GTK_BOX (box2), button);
button = gtk_button_new_from_icon_name ("object-rotate-right-symbolic");
gtk_widget_set_tooltip_text (button, "Rotate");
g_signal_connect (button, "clicked", G_CALLBACK (rotate), widget);
@@ -191,7 +325,9 @@ do_image_scaling (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_set_visible (window, TRUE);
else
gtk_window_destroy (GTK_WINDOW (window));
{
gtk_window_destroy (GTK_WINDOW (window));
}
return window;
}

View File

@@ -1,41 +0,0 @@
uniform float progress;
uniform sampler2D u_texture1;
uniform sampler2D u_texture2;
vec4 getFromColor (vec2 uv) {
return GskTexture(u_texture1, uv);
}
vec4 getToColor (vec2 uv) {
return GskTexture(u_texture2, uv);
}
// Source: https://gl-transitions.com/editor/kaleidoscope
// Author: nwoeanhinnogaehr
// License: MIT
const float speed = 1.0;
const float angle = 1.0;
const float power = 1.5;
vec4 transition(vec2 uv) {
vec2 p = uv.xy / vec2(1.0).xy;
vec2 q = p;
float t = pow(progress, power)*speed;
p = p -0.5;
for (int i = 0; i < 7; i++) {
p = vec2(sin(t)*p.x + cos(t)*p.y, sin(t)*p.y - cos(t)*p.x);
t += angle;
p = abs(mod(p, 2.0) - 1.0);
}
abs(mod(p, 1.0));
return mix(
mix(getFromColor(q), getToColor(q), progress),
mix(getFromColor(p), getToColor(p), progress), 1.0 - 2.0*abs(progress - 0.5));
}
void mainImage(out vec4 fragColor, in vec2 fragCoord, in vec2 resolution, in vec2 uv)
{
fragColor = transition(uv);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 622 KiB

View File

@@ -355,28 +355,28 @@ create_clocks_model (void)
g_list_store_append (result, clock);
g_object_unref (clock);
/* A bunch of timezones with GTK hackers */
clock = gtk_clock_new ("San Francisco", g_time_zone_new ("America/Los_Angeles"));
clock = gtk_clock_new ("San Francisco", g_time_zone_new_identifier ("America/Los_Angeles"));
g_list_store_append (result, clock);
g_object_unref (clock);
clock = gtk_clock_new ("Xalapa", g_time_zone_new ("America/Mexico_City"));
clock = gtk_clock_new ("Xalapa", g_time_zone_new_identifier ("America/Mexico_City"));
g_list_store_append (result, clock);
g_object_unref (clock);
clock = gtk_clock_new ("Boston", g_time_zone_new ("America/New_York"));
clock = gtk_clock_new ("Boston", g_time_zone_new_identifier ("America/New_York"));
g_list_store_append (result, clock);
g_object_unref (clock);
clock = gtk_clock_new ("London", g_time_zone_new ("Europe/London"));
clock = gtk_clock_new ("London", g_time_zone_new_identifier ("Europe/London"));
g_list_store_append (result, clock);
g_object_unref (clock);
clock = gtk_clock_new ("Berlin", g_time_zone_new ("Europe/Berlin"));
clock = gtk_clock_new ("Berlin", g_time_zone_new_identifier ("Europe/Berlin"));
g_list_store_append (result, clock);
g_object_unref (clock);
clock = gtk_clock_new ("Moscow", g_time_zone_new ("Europe/Moscow"));
clock = gtk_clock_new ("Moscow", g_time_zone_new_identifier ("Europe/Moscow"));
g_list_store_append (result, clock);
g_object_unref (clock);
clock = gtk_clock_new ("New Delhi", g_time_zone_new ("Asia/Kolkata"));
clock = gtk_clock_new ("New Delhi", g_time_zone_new_identifier ("Asia/Kolkata"));
g_list_store_append (result, clock);
g_object_unref (clock);
clock = gtk_clock_new ("Shanghai", g_time_zone_new ("Asia/Shanghai"));
clock = gtk_clock_new ("Shanghai", g_time_zone_new_identifier ("Asia/Shanghai"));
g_list_store_append (result, clock);
g_object_unref (clock);

View File

@@ -156,11 +156,6 @@ gtk_demo_run (GtkDemo *self,
if (result == NULL)
return FALSE;
if (GTK_IS_WINDOW (result))
{
gtk_window_set_transient_for (GTK_WINDOW (result), GTK_WINDOW (window));
gtk_window_set_modal (GTK_WINDOW (result), TRUE);
}
return TRUE;
}
@@ -170,10 +165,6 @@ activate_about (GSimpleAction *action,
gpointer user_data)
{
GtkApplication *app = user_data;
const char *authors[] = {
"The GTK Team",
NULL
};
char *version;
char *os_name;
char *os_version;
@@ -211,11 +202,11 @@ activate_about (GSimpleAction *action,
? "GTK Demo (Development)"
: "GTK Demo",
"version", version,
"copyright", "©1997—2021 The GTK Team",
"copyright", "©1997—2024 The GTK Team",
"license-type", GTK_LICENSE_LGPL_2_1,
"website", "http://www.gtk.org",
"comments", "Program to demonstrate GTK widgets",
"authors", authors,
"authors", (const char *[]) { "The GTK Team", NULL },
"logo-icon-name", "org.gtk.Demo4",
"title", "About GTK Demo",
"system-information", s->str,
@@ -832,9 +823,6 @@ static gboolean
demo_can_run (GtkWidget *window,
const char *name)
{
if (name != NULL && strcmp (name, "gltransition") == 0)
return GSK_IS_GL_RENDERER (gtk_native_get_renderer (GTK_NATIVE (window)));
return TRUE;
}
@@ -936,7 +924,7 @@ search_results_update (GObject *filter_model,
char *text;
if (n_items > 0)
text = g_strdup_printf (ngettext ("%ld search result", "%ld search results", n_items), n_items);
text = g_strdup_printf (ngettext ("%ld search result", "%ld search results", (long) n_items), (long) n_items);
else
text = g_strdup (_("No search results"));
@@ -1068,6 +1056,8 @@ command_line (GApplication *app,
window = gtk_application_get_windows (GTK_APPLICATION (app))->data;
gtk_window_set_icon_name (GTK_WINDOW (window), "org.gtk.Demo4");
if (name == NULL)
goto out;

View File

@@ -33,7 +33,6 @@ demos = files([
'gears.c',
'gestures.c',
'glarea.c',
'gltransition.c',
'headerbar.c',
'hypertext.c',
'iconscroll.c',
@@ -117,10 +116,7 @@ extra_demo_sources = files([
'gtkfishbowl.c',
'fontplane.c',
'gtkgears.c',
'gtkshaderbin.c',
'gtkshadertoy.c',
'gtkshaderstack.c',
'gskshaderpaintable.c',
'hsla.c',
'puzzlepiece.c',
'bluroverlay.c',

View File

@@ -5,4 +5,4 @@
#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);
GtkWidget * node_widget_new (const char *resource);

View File

@@ -225,7 +225,8 @@ print_ready (GObject *source,
if (!g_output_stream_close (stream, NULL, &error))
{
g_print ("Error from close: %s\n", error->message);
if (!g_error_matches (error, GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_DISMISSED))
g_print ("Error from close: %s\n", error->message);
g_error_free (error);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@@ -1,34 +0,0 @@
uniform float progress;
uniform sampler2D u_texture1;
uniform sampler2D u_texture2;
vec4 getFromColor (vec2 uv) {
return GskTexture(u_texture1, uv);
}
vec4 getToColor (vec2 uv) {
return GskTexture(u_texture2, uv);
}
// Source: https://gl-transitions.com/editor/Radial
// License: MIT
// Author: Xaychru
const float smoothness = 1.0;
const float PI = 3.141592653589;
vec4 transition(vec2 p) {
vec2 rp = p*2.-1.;
return mix(
getToColor(p),
getFromColor(p),
smoothstep(0., smoothness, atan(rp.y,rp.x) - (progress-.5) * PI * 2.5)
);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord, in vec2 resolution, in vec2 uv)
{
fragColor = transition(uv);
}

View File

@@ -1,43 +0,0 @@
uniform float u_time;
uniform vec2 u_mouse;
uniform sampler2D u_texture1;
#define PI 3.141592654
float decay(float v, float t)
{
return v * (1.0 / (1.0 + t*t));
}
void mainImage(out vec4 fragColor, in vec2 fragCoord, in vec2 resolution, in vec2 uv)
{
// Temporary to loop time every 1 sec
float time = u_time;
// we normalize all the effects according to the min height/width
float size = min(resolution.x, resolution.y);
// Animate one wave over size in 0.3 sec
float wave_speed = size / 0.3;
float wave_length = size / 1.0;
float wave_height = size * 0.1;
vec2 center = u_mouse;
vec2 direction_from_center = fragCoord - center;
float distance_from_center = length(direction_from_center);
/* Normalize direction */
direction_from_center = direction_from_center / distance_from_center;
float propagation_length = time * wave_speed;
float t = (propagation_length - distance_from_center) / wave_length;
float offset_magnitude = 0.0;
if (t > 0.0)
offset_magnitude = decay(wave_height * sin(t * 2.0 * PI), t);
vec2 offset = direction_from_center * min(offset_magnitude, distance_from_center);
vec2 source = fragCoord - offset;
vec2 uv2 = source / resolution;
fragColor = GskTexture(u_texture1, vec2(uv2.x, 1.0-uv2.y));
}

View File

@@ -43,7 +43,7 @@ GtkListItemFactory *
suggestion_entry_get_factory (SuggestionEntry *self);
void suggestion_entry_set_use_filter (SuggestionEntry *self,
gboolean use_ilter);
gboolean use_filter);
gboolean suggestion_entry_get_use_filter (SuggestionEntry *self);
void suggestion_entry_set_expression (SuggestionEntry *self,

View File

@@ -1,33 +0,0 @@
uniform float progress;
uniform sampler2D u_texture1;
uniform sampler2D u_texture2;
vec4 getFromColor (vec2 uv) {
return GskTexture(u_texture1, uv);
}
vec4 getToColor (vec2 uv) {
return GskTexture(u_texture2, uv);
}
// Source: https://gl-transitions.com/editor/wind
// Author: gre
// License: MIT
const float size = 0.2;
float rand(vec2 co) {
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}
vec4 transition(vec2 p) {
float r = rand(vec2(0, p.y));
float m = smoothstep(0.0, -size, p.x*(1.0-size) + size*r - (progress * (1.0 + size)));
return mix(getFromColor(p), getToColor(p), m);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord, in vec2 resolution, in vec2 uv)
{
fragColor = transition(uv);
}

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 5.2 KiB

View File

@@ -1,136 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
sodipodi:docname="org.gtk.IconBrowser4-symbolic.svg"
height="16.03125"
id="svg7384"
inkscape:version="0.92.4 5da689c313, 2019-01-14"
version="1.1"
width="16">
<metadata
id="metadata90">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title>Gnome Symbolic Icon Theme</dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview
inkscape:bbox-paths="true"
bordercolor="#666666"
borderopacity="1"
inkscape:current-layer="layer9"
inkscape:cx="-2.5662459"
inkscape:cy="11.558672"
gridtolerance="10"
inkscape:guide-bbox="true"
guidetolerance="10"
id="namedview88"
inkscape:object-nodes="false"
inkscape:object-paths="false"
objecttolerance="10"
pagecolor="#555753"
inkscape:pageopacity="1"
inkscape:pageshadow="2"
showborder="true"
showgrid="false"
showguides="true"
inkscape:snap-bbox="true"
inkscape:snap-bbox-midpoints="false"
inkscape:snap-global="true"
inkscape:snap-grids="true"
inkscape:snap-nodes="true"
inkscape:snap-others="false"
inkscape:snap-to-guides="true"
inkscape:window-height="1375"
inkscape:window-maximized="1"
inkscape:window-width="2560"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:zoom="1">
<inkscape:grid
empspacing="2"
enabled="true"
id="grid4866"
originx="-203"
originy="-251.96875"
snapvisiblegridlinesonly="true"
spacingx="1"
spacingy="1"
type="xygrid"
visible="true" />
</sodipodi:namedview>
<title
id="title9167">Gnome Symbolic Icon Theme</title>
<defs
id="defs7386">
<linearGradient
id="linearGradient7212"
osb:paint="solid">
<stop
id="stop7214"
offset="0"
style="stop-color:#000000;stop-opacity:1;" />
</linearGradient>
</defs>
<g
inkscape:groupmode="layer"
id="layer9"
inkscape:label="apps"
style="display:inline"
transform="translate(-444.0002,35)">
<path
style="display:inline;opacity:1;vector-effect:none;fill:#000000;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal;enable-background:new"
d="m 457.9846,-27.96875 v -3 h 1 l -3,-3 -3,3 h 1 v 3 z"
id="path2809"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccccccc" />
<path
style="display:inline;opacity:1;vector-effect:none;fill:#000000;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal;enable-background:new"
d="m 451.9846,-23.96875 v 2 h 1 l 2,2 v -6 l -2,2 z"
id="path2811"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccccc" />
<path
style="display:inline;opacity:1;vector-effect:none;fill:#000000;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal;enable-background:new"
d="m 455.9846,-24.96875 v 4 c 0,0 1,-1 1,-2 0,-1.31515 -1,-2 -1,-2 z"
id="path2813"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccsc" />
<path
style="display:inline;opacity:1;vector-effect:none;fill:#000000;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal;enable-background:new"
d="m 457.9846,-25.96875 v 6 c 0,0 1,-1.94591 1,-3 0,-1.05409 -1,-3 -1,-3 z"
id="path2815"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccsc" />
<path
inkscape:connector-curvature="0"
style="display:inline;opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:2;enable-background:new"
d="m 450.53751,-25.96846 c 0.24647,0 0.44708,0.19694 0.44708,0.44708 v 0.0289 c -0.008,3.05189 -2.48438,5.5237 -5.53812,5.5237 h -0.0148 c -0.25145,0 -0.44711,-0.20581 -0.44711,-0.4615 v -0.46152 -0.92302 c 0,-0.25567 0.20581,-0.4615 0.4615,-0.4615 h 0.92302 c 0.25569,0 0.46152,0.20581 0.46152,0.4615 v 0.21634 c 1.18002,-0.41715 2.10674,-1.34386 2.52389,-2.52388 h -0.21635 c -0.25566,0 -0.4615,-0.20581 -0.4615,-0.46152 v -0.92302 c 0,-0.25567 0.20581,-0.4615 0.4615,-0.4615 h 0.46152 0.4615 0.44709 0.0148 0.0148 z"
id="rect5922-7-3" />
<g
id="g904-6"
transform="matrix(0.26785369,0,0,0.26785369,436.44908,-87.00581)"
style="display:inline;fill:#000000;fill-opacity:1;stroke-width:3.73338151;enable-background:new">
<path
sodipodi:nodetypes="csscccssssccccccsccsssssccccccsssss"
inkscape:connector-curvature="0"
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:7.46676302;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
d="m 37,198.00759 c -2.76142,0 -5,2.23858 -5,5 0,2.76142 2.23858,5 5,5 0.89216,0 1.71236,-0.27804 2.4375,-0.6875 l 3.9375,3.6875 -3.9375,3.6875 c -0.72514,-0.40946 -1.54534,-0.6875 -2.4375,-0.6875 -2.76142,0 -5,2.23858 -5,5 0,2.76142 2.23858,5 5,5 2.76142,0 5,-2.23858 5,-5 0,-0.45832 -0.072,-0.89082 -0.1874,-1.3125 l 4.25,-4.125 8.9374,8.4375 h 3 v -2 l -16.1875,-15.6875 c 0.1156,-0.42168 0.1874,-0.85418 0.1874,-1.3125 0,-2.76142 -2.23858,-5 -5,-5 z m 0,3 c 1.10456,0 2,0.89544 2,2 0,1.10456 -0.89544,2 -2,2 -1.10456,0 -2,-0.89544 -2,-2 0,-1.10456 0.89544,-2 2,-2 z m 18,-1 -7.875,7.4375 2.625,2.5625 8.25,-8 v -2 z m -18,17 c 1.10456,0 2,0.89544 2,2 0,1.10456 -0.89544,2 -2,2 -1.10456,0 -2,-0.89544 -2,-2 0,-1.10456 0.89544,-2 2,-2 z"
id="path1079-7" />
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 7.1 KiB

View File

@@ -1,517 +0,0 @@
[volume]
Name=Volume
Description=Icons related to audio input and output volume
audio-volume-high=The icon used to indicate high audio volume
audio-volume-low=The icon used to indicate low audio volume
audio-volume-medium=The icon used to indicate medium audio volume
audio-volume-muted=The icon used to indicate the muted state for audio playback
microphone-sensitivity-high=The icon used to indicate high microphone sensitivity
microphone-sensitivity-low=The icon used to indicate low microphone sensitivity
microphone-sensitivity-medium=The icon used to indicate medium microphone sensitivity
microphone-sensitivity-muted=The icon used to indicate that a microphone is muted
[multimedia]
Name=Multimedia
Description=Icons related to playback of media
media-playlist-repeat=The icon for the repeat mode of a media player
media-playlist-repeat-song=The icon for repeating a song in a media player
media-playlist-shuffle=The icon for the shuffle mode of a media player
media-playlist-consecutive=The icon for consecutive mode of a media player
media-skip-backward=The icon for the skip backward action of a media player
media-seek-backward=The icon for the seek backward action of a media player
media-playback-start=The icon for the start playback action of a media player
media-seek-forward=The icon for the seek forward action of a media player
media-skip-forward=The icon for the skip forward action of a media player
media-playback-stop=The icon for the stop action of a media player
media-playback-pause=The icon for the pause action of a media player
media-eject=The icon for the eject action of a media player or file manager
media-record=The icon for the record action of a media application
media-view-subtitles=The icon used to show subtitles in a media player
[network]
Name=Network
Description=Icons related to network status
network-transmit-receive=The icon used data is being both transmitted and received simultaneously, while the computing device is connected to a network
network-transmit=The icon used when data is being transmitted, while the computing device is connected to a network
network-receive=The icon used when data is being received, while the computing device is connected to a network
network-idle=The icon used when no data is being transmitted or received, while the computing device is connected to a network
network-error=The icon used when an error occurs trying to initialize the network connection of the computing device
network-offline=The icon used when the computing device is disconnected from the network
[weather]
Name=Weather
Description=Icons about weather conditions
weather-clear=The icon used while the weather for a region is “clear skies”
weather-clear-night=The icon used while the weather for a region is “clear skies” during the night
weather-few-clouds=The icon used while the weather for a region is “partly cloudy”
weather-few-clouds-night=The icon used while the weather for a region is “partly cloudy” during the night
weather-fog=The icon used while the weather for a region is “foggy”
weather-overcast=The icon used while the weather for a region is “overcast”
weather-severe-alert=The icon used while a sever weather alert is in effect for a region
weather-showers=The icon used while rain showers are occurring in a region
weather-showers-scattered=The icon used while scattered rain showers are occurring in a region
weather-snow=The icon used while snow showers are occurring in a region
weather-storm=The icon used while storms are occurring in a region
weather-windy=The icon used while the weather is windy
[navigation]
Name=Navigation
Description=Icons for navigation in the user interface of a program
go-first=The icon for the go to the first item in a list
go-previous=The icon for the go to the previous item in a list
go-next=The icon for the go to the next item in a list
go-last=The icon for the go to the last item in a list
go-bottom=The icon for the go to bottom of a list
go-down=The icon for the go down in a list
go-up=The icon for the go up in a list
go-top=The icon for the go to the top of a list
go-home=The icon for the go to home location
go-jump=The icon for the jump to action
[editing]
Name=Editing
Description=Icons related to editing a document
format-indent-less=The icon for the decrease indent formatting action
format-indent-more=The icon for the increase indent formatting action
format-justify-center=The icon for the center justification formatting action
format-justify-fill=The icon for the fill justification formatting action
format-justify-left=The icon for the left justification formatting action
format-justify-right=The icon for the right justification action
format-text-direction-ltr=The icon for the left-to-right text formatting action
format-text-direction-rtl=The icon for the right-to-left formatting action
format-text-bold=The icon for the bold text formatting action
format-text-italic=The icon for the italic text formatting action
format-text-underline=The icon for the underlined text formatting action
format-text-strikethrough=The icon for the strikethrough text formatting action
edit-clear=The icon for the clear action
edit-clear-all=
edit-copy=The icon for the copy action
edit-cut=The icon for the cut action
edit-delete=The icon for the delete action
edit-find-replace=The icon for the find and replace action
edit-paste=The icon for the paste action
edit-redo=The icon for the redo action
edit-select-all=The icon for the select all action
edit-select=
edit-undo=The icon for the undo action
error-correct=
document-properties=The icon for the action to view the properties of a document in an application
document-new=The icon used for the action to create a new document
document-open=The icon used for the action to open a document
document-open-recent=The icon used for the action to open a document that was recently opened
document-save=The icon for the save action. Should be an arrow pointing down and toward a hard disk
document-save-as=The icon for the save as action
document-send=The icon for the send action. Should be an arrow pointing up and away from a hard disk
document-page-setup=The icon for the page setup action of a document editor
document-edit=The icon for the action to edit a document
object-flip-horizontal=The icon for the action to flip an object horizontally
object-flip-vertical=The icon for the action to flip an object vertically
object-rotate-left=The icon for the rotate left action performed on an object
object-rotate-right=The icon for the rotate right action performed on an object
insert-image=The icon for the insert image action of an application
insert-link=The icon for the insert link action of an application
insert-object=The icon for the insert object action of an application
insert-text=The icon for the insert text action of an application
accessories-text-editor=The icon used for the desktop's text editing accessory program
[view]
Name=View Controls
Description=Icons for view controls in a user interface
view-list=The icon used for “List“ view mode
view-grid=The icon used for “Grid“ view mode (as opposed to “List“)
view-fullscreen=The icon used for the “Fullscreen” item in the application's “View” menu
view-restore=The icon used by an application for leaving the fullscreen view, and returning to a normal windowed view
zoom-fit-best=The icon used for the “Best Fit” item in the application's “View” menu
zoom-in=The icon used for the “Zoom in” item in the application's “View” menu
zoom-out=The icon used for the “Zoom Out” item in the application's “View” menu
zoom-original=The icon used for the “Original Size” item in the application's “View” menu
view-continuous=The icon used for a continuous view mode
view-paged=The icon used for a paged view mode (as opposed to continuous)
view-dual=The icon used for a side-by-side view of paginated content
view-wrapped=The icon used to indicate a wrap-around to the beginning
view-pin=The icon used for 'pin a view'
[calendar]
Name=Calendar, Tasks and Alarms
Description=Icons related to calendars, tasks and alarms
task-due=The icon used when a task is due soon
task-past-due=The icon used when a task that was due, has been left incomplete
appointment-soon=The icon used when an appointment will occur soon
appointment-missed=The icon used when an appointment was missed
alarm=The icon used for alarms when a task or appointment is due
[communication]
Name=Communication
Description=Icons related email, phone calls, IM and other forms of communication
mail-unread=The icon used for an electronic mail that is unread
mail-read=The icon used for an electronic mail that is read
mail-replied=The icon used for an electronic mail that has been replied to
mail-attachment=The icon used for an electronic mail that contains attachments
mail-mark-important=The icon for the mark as important action of an electronic mail application
mail-send=The icon for the send action of an electronic mail application
mail-send-receive=The icon for the send and receive action of an electronic mail application
call-start=The icon used for initiating or accepting a call
call-stop=The icon used for stopping a current call
call-missed=The icon used to show a missed call
user-available=The icon used when a user on a chat network is available to initiate a conversation with
user-offline=The icon used when a user on a chat network is not available
user-idle=The icon used when a user on a chat network has not been an active participant in any chats on the network, for an extended period of time
user-invisible=The icon used when a user is on a chat network, but is invisible to others
user-busy=The icon used when a user is on a chat network, and has marked himself as busy
user-away=The icon used when a user on a chat network is away from their keyboard and the chat program
user-status-pending=The icon used when the current user status on a chat network is not known
[devices]
Name=Devices and Media
Description=Icons for devices and media
audio-input-microphone=The icon used for the microphone audio input device
camera-web=The fallback icon for web cameras
camera-photo=The icon used for a digital still camera devices
input-keyboard=The icon used for the keyboard input device
printer=The icon used for a printer device
video-display=The icon used for the monitor that video gets displayed to
computer=The icon used for the computing device as a whole
media-optical=The icon used for physical optical media such as CD and DVD
phone=The icon used for phone devices which support connectivity to the PC, such as VoIP, cellular, or possibly landline phones
input-dialpad=The icon used for dialpad input devices
input-touchpad=The icon used for touchpad input devices
scanner=The icon used for a scanner device
audio-card=The icon used for the audio rendering device
input-gaming=The icon used for the gaming input device
input-mouse=The icon used for the mousing input device
multimedia-player=The icon used for generic multimedia playing devices
audio-headphones=The icon used for headphones
audio-headset=The icon used for headsets
display-projector=The icon used for projectors
media-removable=The icon used for generic removable media
printer-network=The icon used for printers which are connected via the network
audio-speakers=The icon used for speakers
camera-video=The fallback icon for video cameras
drive-optical=The icon used for optical media drives such as CD and DVD
drive-removable-media=The icon used for removable media drives
input-tablet=The icon used for graphics tablet input devices
network-wireless=The icon used for wireless network connections
network-wired=The icon used for wired network connections
media-floppy=The icon used for physical floppy disk media
media-flash=The fallback icon used for flash media, such as memory stick and SD
[contenttypes]
Name=Content Types
Description=Icons for different types of data, such as audio or image files
application-certificate=
application-rss+xml=
application-x-appliance=
audio-x-generic=The icon used for generic audio file types
folder=The standard folder icon used to represent directories on local filesystems, mail folders, and other hierarchical groups
text-x-generic=The icon used for generic text file types
video-x-generic=The icon used for generic video file types
x-office-calendar=The icon used for generic calendar file types
[emotes]
Name=Emotes
Description=Icons for emotions that are expressed through text chat applications such as :-) or :-P in IRC or instant messengers
face-angel=The icon used for the 0:-) emote
face-angry=The icon used for the X-( emote
face-cool=The icon used for the B-) emote
face-crying=The icon used for the :'( emote
face-devilish=The icon used for the >:-) emote
face-embarrassed=The icon used for the :-[ emote
face-kiss=The icon used for the :-* emote
face-laugh=The icon used for the :-)) emote
face-monkey=The icon used for the :-(|) emote
face-plain=The icon used for the :-| emote
face-raspberry=The icon used for the :-P emote
face-sad=The icon used for the :-( emote
face-shutmouth=The 'shut mouth' emote
face-sick=The icon used for the :-& emote
face-smile=The icon used for the :-) emote
face-smile-big=The icon used for the :-D emote
face-smirk=The icon used for the :-! emote
face-surprise=The icon used for the :-0 emote
face-tired=The icon used for the |-) emote
face-uncertain=The icon used for the :-/ emote
face-wink=The icon used for the ;-) emote
face-worried=The icon used for the :-S emote
face-yawn=
[general]
Name=General
Description=Generally useful icons that don't fit in a particular category
edit-find=The icon for generic search actions
content-loading=The icon used to indicate that content is loading
open-menu=The icon used for a menu button in the header bar
view-more=The icon used for a “View More“ action
tab-new=The icon used for a “New Tab“ action
bookmark-new=The icon used for creating a new bookmark
mark-location=The icon used to mark a location on a map
find-location=The icon used for a “Search location“ action
send-to=The icon used for a “Send to“ action
object-select=The icon used for generic selection actions
window-close=The icon used for actions that close a view, such as window or tab close button
view-refresh=The icon used for the “Refresh” item in the application's “View” menu
process-stop=The icon used for the “Stop” action in applications with actions that may take a while to process, such as web page loading in a browser
action-unavailable=The icon used to indicate that an action is currently unavailable, such as “Pause“ when no media is playing
document-print=The icon for the print action of an application
printer-printing=The icon used while a print job is successfully being spooled to a printing device
printer-warning=The icon used when a recoverable problem occurs while attempting to printing
printer-error=The icon used when an error occurs while attempting to print
dialog-information=The icon used when a dialog is opened to give information to the user that may be pertinent to the requested action
dialog-question=The icon used when a dialog is opened to ask a simple question of the user
dialog-warning=The icon used when a dialog is opened to warn the user of impending issues with the requested action
dialog-password=The icon used when a dialog requesting the authentication credentials for a user is opened
dialog-error=The icon used when a dialog is opened to explain an error condition to the user
list-add=The icon for the add to list action
list-remove=The icon for the remove from list action
non-starred=The icon used to indicate that an object is not 'starred'
semi-starred=The icon used to indicate that an object has is 'half-starred'
starred=The icon used to indicate that an object is 'starred'
star-new=The used for the “New Star“ action
security-low=The icon used to indicate that the security level of a connection is presumed to be insecure, either by using weak encryption, or by using a certificate that the could not be automatically verified, and which the user has not chosent to trust
security-medium=The icon used to indicate that the security level of a connection is presumed to be secure, using strong encryption, and a certificate that could not be automatically verified, but which the user has chosen to trust
security-high=The icon used to indicate that the security level of a connection is known to be secure, using strong encryption and a valid certificate
user-trash=The icon for the user's “Trash” place in the file system
user-trash-full=The icon for the user's “Trash” in the file system, when there are items in the “Trash” waiting for disposal or recovery
emblem-system=The icon used as an emblem for directories that contain system libraries, settings, and data
avatar-default=The generic avatar icon, which is used to represent a user that doesn't have a personalized avatar
emblem-synchronizing=The icon used as an emblem to indicate that a synchronizing operation is in process
emblem-shared=The icon used as an emblem for files and directories that are shared to other users
help-browser=The icon used for the desktop's help browsing application
[other]
Name=Other
Description=Icons which have may be too specialized and not of general interest
changes-allow=
changes-prevent=
view-sort-ascending=The icon used for the “Sort Ascending” item in the application's “View” menu, or in a button for changing the sort method for a list
view-sort-descending=The icon used for the “Sort Descending” item in the application's “View” menu, or in a button for changing the sort method for a list
document-revert=The icon for the action of reverting to a previous version of a document
address-book-new=The icon used for the action to create a new address book
application-exit=The icon used for exiting an application. Typically this is seen in the application's menus as File->Quit
appointment-new=The icon used for the action to create a new appointment in a calendaring application
contact-new=The icon used for the action to create a new contact in an address book application
document-print-preview=The icon for the print preview action of an application
folder-new=The icon for creating a new folder
help-about=The icon for the About item in the Help menu
help-contents=The icon for Contents item in the Help menu
help-faq=The icon for the FAQ item in the Help menu
list-remove-all=
mail-forward=The icon for the forward action of an electronic mail application
mail-mark-junk=The icon for the mark as junk action of an electronic mail application
mail-mark-notjunk=The icon for the mark as not junk action of an electronic mail application
mail-mark-read=The icon for the mark as read action of an electronic mail application
mail-mark-unread=The icon for the mark as unread action of an electronic mail application
mail-message-new=The icon for the compose new mail action of an electronic mail application
mail-reply-all=The icon for the reply to all action of an electronic mail application
mail-reply-sender=The icon for the reply to sender action of an electronic mail application
pan-down=
pan-end=
pan-start=
pan-up=
system-lock-screen=The icon used for the “Lock Screen” item in the desktop's panel application
system-log-out=The icon used for the “Log Out” item in the desktop's panel application
system-run=The icon used for the “Run Application...” item in the desktop's panel application
system-search=The icon used for the “Search” item in the desktop's panel application
system-reboot=The icon used for the “Reboot” item in the desktop's panel application
system-shutdown=The icon used for the “Shutdown” item in the desktop's panel application
tools-check-spelling=The icon used for the “Check Spelling” item in the application's “Tools” menu
window-maximize=
window-minimize=
window-restore=
window-new=The icon used for the “New Window” item in the application's “Windows” menu
accessories-calculator=The icon used for the desktop's calculator accessory program
accessories-character-map=The icon used for the desktop's international and extended text character accessory program
accessories-dictionary=The icon used for the desktop's dictionary accessory program
multimedia-volume-control=The icon used for the desktop's hardware volume control application
preferences-desktop-accessibility=The icon used for the desktop's accessibility preferences
preferences-desktop-display=
preferences-desktop-font=The icon used for the desktop's font preferences
preferences-desktop-keyboard=The icon used for the desktop's keyboard preferences
preferences-desktop-keyboard-shortcuts=
preferences-desktop-locale=The icon used for the desktop's locale preferences
preferences-desktop-remote-desktop=
preferences-desktop-multimedia=The icon used for the desktop's multimedia preferences
preferences-desktop-screensaver=The icon used for the desktop's screen saving preferences
preferences-desktop-theme=The icon used for the desktop's theme preferences
preferences-desktop-wallpaper=The icon used for the desktop's wallpaper preferences
preferences-system-privacy=
preferences-system-windows=
system-file-manager=The icon used for the desktop's file management application
system-software-install=The icon used for the desktop's software installer application
system-software-update=The icon used for the desktop's software updating application
system-users=
user-info=
utilities-system-monitor=The icon used for the desktop's system resource monitor application
utilities-terminal=The icon used for the desktop's terminal emulation application.
application-x-addon=
application-x-executable=The icon used for executable file types
font-x-generic=The icon used for generic font file types
image-x-generic=The icon used for generic image file types
package-x-generic=The icon used for generic package file types
text-html=The icon used for HTML text file types
text-x-generic-template=The icon used for generic text templates
text-x-preview=
text-x-script=The icon used for script file types, such as shell scripts
x-office-address-book=The icon used for generic address book file types
x-office-document=The icon used for generic document and letter file types
x-office-document-template=
x-office-presentation=The icon used for generic presentation file types
x-office-presentation-template=
x-office-spreadsheet=The icon used for generic spreadsheet file types
x-office-spreadsheet-template=
x-package-repository=
applications-accessories=The icon for the “Accessories” sub-menu of the Programs menu
applications-development=The icon for the “Programming” sub-menu of the Programs menu
applications-engineering=The icon for the “Engineering” sub-menu of the Programs menu
applications-games=The icon for the “Games” sub-menu of the Programs menu
applications-graphics=The icon for the “Graphics” sub-menu of the Programs menu
applications-internet=The icon for the “Internet” sub-menu of the Programs menu
applications-multimedia=The icon for the “Multimedia” sub-menu of the Programs menu
applications-office=The icon for the “Office” sub-menu of the Programs menu
applications-other=The icon for the “Other” sub-menu of the Programs menu
applications-science=The icon for the “Science” sub-menu of the Programs menu
applications-system=The icon for the “System Tools” sub-menu of the Programs menu
applications-utilities=The icon for the “Utilities” sub-menu of the Programs menu
preferences-desktop=The icon for the “Desktop Preferences” category
preferences-desktop-peripherals=The icon for the “Peripherals” sub-category of the “Desktop Preferences” category
preferences-desktop-personal=The icon for the “Personal” sub-category of the “Desktop Preferences” category
preferences-other=The icon for the “Other” preferences category
preferences-system=The icon for the “System Preferences” category
preferences-system-network=The icon for the “Network” sub-category of the “System Preferences” category
system-help=The icon for the “Help” system category
battery=The icon used for the system battery device
computer-apple-ipad=
colorimeter-colorhug=
drive-harddisk=The icon used for hard disk drives
drive-harddisk-ieee1394=
drive-harddisk-system=
drive-multidisk=
media-optical-bd=
media-optical-cd-audio=
media-optical-dvd=
media-tape=The icon used for generic physical tape media
media-zip=
modem=The icon used for modem devices
multimedia-player-apple-ipod-touch=
network-vpn=
pda=This is the fallback icon for Personal Digital Assistant devices. Primary use of this icon is for PDA devices connected to the PC. Connection medium is not an important aspect of the icon. The metaphor for this fallback icon should be a generic PDA device icon
phone-apple-iphone=
uninterruptible-power-supply=
emblem-default=The icon used as an emblem to specify the default selection of a printer for example
emblem-documents=The icon used as an emblem for the directory where a user's documents are stored
emblem-downloads=The icon used as an emblem for the directory where a user's downloads from the internet are stored
emblem-favorite=The icon used as an emblem for files and directories that the user marks as favorites
emblem-generic=
emblem-important=The icon used as an emblem for files and directories that are marked as important by the user
emblem-mail=The icon used as an emblem to specify the directory where the user's electronic mail is stored
emblem-new=
emblem-ok=
emblem-package=
emblem-photos=The icon used as an emblem to specify the directory where the user stores photographs
emblem-readonly=The icon used as an emblem for files and directories which can not be written to by the user
emblem-symbolic-link=The icon used as an emblem for files and direcotires that are links to other files or directories on the filesystem
emblem-synchronized=The icon used as an emblem for files or directories that are configured to be synchronized to another device
emblem-unreadable=The icon used as an emblem for files and directories that are inaccessible.
emblem-urgent=
emblem-videos=
emblem-web=
folder-documents=
folder-download=The icon representing the location in the file system where downloaded files are stored
folder-music=
folder-pictures=
folder-publicshare=
folder-remote=The icon used for normal directories on a remote filesystem
folder-saved-search=
folder-templates=
folder-videos=
network-server=The icon used for individual host machines under the “Network Servers” place in the file manager
network-workgroup=The icon for the “Network Servers” place in the desktop's file manager, and workgroups within the network
start-here=The icon used by the desktop's main menu for accessing places, applications, and other features
user-bookmarks=The icon for the user's special “Bookmarks” place
user-desktop=The icon for the special “Desktop” directory of the user
user-home=The icon for the special “Home” directory of the user
airplane-mode=
battery-caution-charging=
battery-caution=The icon used when the battery is below 40%
battery-empty-charging=
battery-empty=
battery-full-charged=
battery-full-charging=
battery-full=
battery-good-charging=
battery-good=
battery-low-charging=
battery-low=The icon used when the battery is below 20%
battery-missing=
bluetooth-active=
bluetooth-disabled=
channel-insecure=
channel-secure=
computer-fail=
display-brightness=
keyboard-brightness=
folder-drag-accept=The icon used for a folder while an object is being dragged onto it, that is of a type that the directory can contain
folder-open=The icon used for folders, while their contents are being displayed within the same window. This icon would normally be shown in a tree or list view, next to the main view of a folder's contents
folder-visiting=The icon used for folders, while their contents are being displayed in another window. This icon would typically be used when using multiple windows to navigate the hierarchy, such as in Nautilus's spatial mode
image-loading=The icon used when another image is being loaded, such as thumnails for larger images in the file manager
image-missing=The icon used when another image could not be loaded
mail-signed=The icon used for an electronic mail that contains a signature
mail-signed-verified=The icon used for an electronic mail that contains a signature which has also been verified by the security system
network-cellular-3g=
network-cellular-4g=
network-cellular-edge=
network-cellular-gprs=
network-cellular-umts=
network-cellular-acquiring=
network-cellular-connected=
network-cellular-no-route=
network-cellular-offline=
network-cellular-signal-excellent=
network-cellular-signal-good=
network-cellular-signal-ok=
network-cellular-signal-weak=
network-cellular-signal-none=
network-vpn-acquiring=
network-vpn=
network-wired-acquiring=
network-wired-disconnected=
network-wired-no-route=
network-wired-offline=
network-wireless-acquiring=
network-wireless-connected=
network-wireless-encrypted=
network-wireless-hotspot=
network-wireless-no-route=
network-wireless-offline=
network-wireless-signal-excellent=
network-wireless-signal-good=
network-wireless-signal-ok=
network-wireless-signal-weak=
network-wireless-signal-none=
rotation-allowed=
rotation-locked=
software-update-available=The icon used when an update is available for software installed on the computing device, through the system software update program
software-update-urgent=The icon used when an urgent update is available through the system software update program
sync-error=The icon used when an error occurs while attempting to synchronize data from the computing device, to another device
sync-synchronizing=The icon used while data is successfully synchronizing to another device
touchpad-disabled=
trophy-bronze=
trophy-silver=
trophy-gold=
night-light=
daytime-sunrise=
daytime-sunset=
on=
off=

View File

@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gtk/iconbrowser/gtk">
<file preprocess="xml-stripblanks">window.ui</file>
<file>icon.list</file>
</gresource>
</gresources>

View File

@@ -1,158 +0,0 @@
#include "config.h"
#include <gtk/gtk.h>
#include "iconbrowserapp.h"
#include "iconbrowserwin.h"
#include "profile_conf.h"
struct _IconBrowserApp
{
GtkApplication parent;
};
struct _IconBrowserAppClass
{
GtkApplicationClass parent_class;
};
G_DEFINE_TYPE(IconBrowserApp, icon_browser_app, GTK_TYPE_APPLICATION);
static void
icon_browser_app_init (IconBrowserApp *app)
{
}
static void
quit_activated (GSimpleAction *action,
GVariant *parameter,
gpointer app)
{
g_application_quit (G_APPLICATION (app));
}
static void
inspector_activated (GSimpleAction *action,
GVariant *parameter,
gpointer app)
{
gtk_window_set_interactive_debugging (TRUE);
}
static void
about_activated (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
GtkApplication *app = user_data;
const char *authors[] = {
"The GTK Team",
NULL
};
char *icon_theme;
char *version;
GString *s;
char *os_name;
char *os_version;
g_object_get (gtk_settings_get_default (),
"gtk-icon-theme-name", &icon_theme,
NULL);
s = g_string_new ("");
os_name = g_get_os_info (G_OS_INFO_KEY_NAME);
os_version = g_get_os_info (G_OS_INFO_KEY_VERSION_ID);
if (os_name && os_version)
g_string_append_printf (s, "OS\t%s %s\n\n", os_name, os_version);
g_string_append (s, "System libraries\n");
g_string_append_printf (s, "\tGLib\t%d.%d.%d\n",
glib_major_version,
glib_minor_version,
glib_micro_version);
g_string_append_printf (s, "\tPango\t%s\n",
pango_version_string ());
g_string_append_printf (s, "\tGTK \t%d.%d.%d\n",
gtk_get_major_version (),
gtk_get_minor_version (),
gtk_get_micro_version ());
g_string_append_printf (s, "\nIcon theme\n\t%s", icon_theme);
version = g_strdup_printf ("%s%s%s\nRunning against GTK %d.%d.%d",
PACKAGE_VERSION,
g_strcmp0 (PROFILE, "devel") == 0 ? "-" : "",
g_strcmp0 (PROFILE, "devel") == 0 ? VCS_TAG : "",
gtk_get_major_version (),
gtk_get_minor_version (),
gtk_get_micro_version ());
gtk_show_about_dialog (GTK_WINDOW (gtk_application_get_active_window (app)),
"program-name", g_strcmp0 (PROFILE, "devel") == 0
? "GTK Icon Browser (Development)"
: "GTK Icon Browser",
"version", version,
"copyright", "©1997—2021 The GTK Team",
"license-type", GTK_LICENSE_LGPL_2_1,
"website", "http://www.gtk.org",
"comments", "Program to browse themed icons",
"authors", authors,
"logo-icon-name", "org.gtk.IconBrowser4",
"title", "About GTK Icon Browser",
"system-information", s->str,
NULL);
g_string_free (s, TRUE);
g_free (version);
g_free (icon_theme);
g_free (os_name);
g_free (os_version);
}
static GActionEntry app_entries[] =
{
{ "quit", quit_activated, NULL, NULL, NULL },
{ "inspector", inspector_activated, NULL, NULL, NULL },
{ "about", about_activated, NULL, NULL, NULL }
};
static void
icon_browser_app_startup (GApplication *app)
{
const char *quit_accels[2] = { "<Ctrl>Q", NULL };
G_APPLICATION_CLASS (icon_browser_app_parent_class)->startup (app);
g_action_map_add_action_entries (G_ACTION_MAP (app),
app_entries, G_N_ELEMENTS (app_entries),
app);
gtk_application_set_accels_for_action (GTK_APPLICATION (app),
"app.quit",
quit_accels);
}
static void
icon_browser_app_activate (GApplication *app)
{
IconBrowserWindow *win;
win = icon_browser_window_new (ICON_BROWSER_APP (app));
if (g_strcmp0 (PROFILE, "devel") == 0)
gtk_widget_add_css_class (GTK_WIDGET (win), "devel");
gtk_window_present (GTK_WINDOW (win));
}
static void
icon_browser_app_class_init (IconBrowserAppClass *class)
{
G_APPLICATION_CLASS (class)->startup = icon_browser_app_startup;
G_APPLICATION_CLASS (class)->activate = icon_browser_app_activate;
}
IconBrowserApp *
icon_browser_app_new (void)
{
return g_object_new (ICON_BROWSER_APP_TYPE,
"application-id", "org.gtk.IconBrowser4",
NULL);
}

View File

@@ -1,15 +0,0 @@
#pragma once
#include <gtk/gtk.h>
#define ICON_BROWSER_APP_TYPE (icon_browser_app_get_type ())
#define ICON_BROWSER_APP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ICON_BROWSER_APP_TYPE, IconBrowserApp))
typedef struct _IconBrowserApp IconBrowserApp;
typedef struct _IconBrowserAppClass IconBrowserAppClass;
GType icon_browser_app_get_type (void);
IconBrowserApp *icon_browser_app_new (void);

View File

@@ -1,156 +0,0 @@
#include "iconbrowsercontext.h"
struct _IbContext
{
GObject parent_instance;
char *id;
char *name;
char *description;
};
struct _IbContextClass
{
GObjectClass parent_class;
};
enum {
PROP_ID = 1,
PROP_NAME,
PROP_DESCRIPTION,
PROP_NUM_PROPERTIES
};
G_DEFINE_TYPE (IbContext, ib_context, G_TYPE_OBJECT)
static void
ib_context_init (IbContext *context)
{
}
static void
ib_context_finalize (GObject *object)
{
IbContext *context = IB_CONTEXT (object);
g_free (context->id);
g_free (context->name);
g_free (context->description);
G_OBJECT_CLASS (ib_context_parent_class)->finalize (object);
}
static void
ib_context_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
IbContext *context = IB_CONTEXT (object);
switch (property_id)
{
case PROP_ID:
g_free (context->id);
context->id = g_value_dup_string (value);
break;
case PROP_NAME:
g_free (context->name);
context->name = g_value_dup_string (value);
break;
case PROP_DESCRIPTION:
g_free (context->description);
context->description = g_value_dup_string (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
ib_context_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
IbContext *context = IB_CONTEXT (object);
switch (property_id)
{
case PROP_ID:
g_value_set_string (value, context->id);
break;
case PROP_NAME:
g_value_set_string (value, context->name);
break;
case PROP_DESCRIPTION:
g_value_set_string (value, context->description);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
ib_context_class_init (IbContextClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GParamSpec *pspec;
object_class->finalize = ib_context_finalize;
object_class->set_property = ib_context_set_property;
object_class->get_property = ib_context_get_property;
pspec = g_param_spec_string ("id", "Id", "Id",
NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_ID, pspec);
pspec = g_param_spec_string ("name", "Name", "Name",
NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_NAME, pspec);
pspec = g_param_spec_string ("description", "Description", "Description",
NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_DESCRIPTION, pspec);
}
IbContext *
ib_context_new (const char *id,
const char *name,
const char *description)
{
return g_object_new (IB_TYPE_CONTEXT,
"id", id,
"name", name,
"description", description,
NULL);
}
const char *
ib_context_get_id (IbContext *context)
{
return context->id;
}
const char *
ib_context_get_name (IbContext *context)
{
return context->name;
}
const char *
ib_context_get_description (IbContext *context)
{
return context->description;
}

View File

@@ -1,14 +0,0 @@
#pragma once
#include <gtk.h>
#define IB_TYPE_CONTEXT (ib_context_get_type ())
G_DECLARE_FINAL_TYPE (IbContext, ib_context, IB, CONTEXT, GObject)
IbContext *ib_context_new (const char *id,
const char *name,
const char *description);
const char *ib_context_get_id (IbContext *context);
const char *ib_context_get_name (IbContext *context);
const char *ib_context_get_description (IbContext *context);

View File

@@ -1,228 +0,0 @@
#include "iconbrowsericon.h"
struct _IbIcon
{
GObject parent_instance;
gboolean use_symbolic;
char *regular_name;
char *symbolic_name;
char *description;
char *context;
};
struct _IbIconClass
{
GObjectClass parent_class;
};
enum {
PROP_NAME = 1,
PROP_REGULAR_NAME,
PROP_SYMBOLIC_NAME,
PROP_USE_SYMBOLIC,
PROP_DESCRIPTION,
PROP_CONTEXT,
PROP_NUM_PROPERTIES
};
G_DEFINE_TYPE (IbIcon, ib_icon, G_TYPE_OBJECT)
static void
ib_icon_init (IbIcon *icon)
{
}
static void
ib_icon_finalize (GObject *object)
{
IbIcon *icon = IB_ICON (object);
g_free (icon->regular_name);
g_free (icon->symbolic_name);
g_free (icon->description);
g_free (icon->context);
G_OBJECT_CLASS (ib_icon_parent_class)->finalize (object);
}
static void
ib_icon_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
IbIcon *icon = IB_ICON (object);
switch (property_id)
{
case PROP_REGULAR_NAME:
g_free (icon->regular_name);
icon->regular_name = g_value_dup_string (value);
if (!icon->use_symbolic)
g_object_notify (object, "name");
break;
case PROP_SYMBOLIC_NAME:
g_free (icon->symbolic_name);
icon->symbolic_name = g_value_dup_string (value);
if (icon->use_symbolic)
g_object_notify (object, "name");
break;
case PROP_USE_SYMBOLIC:
icon->use_symbolic = g_value_get_boolean (value);
g_object_notify (object, "name");
break;
case PROP_DESCRIPTION:
g_free (icon->description);
icon->description = g_value_dup_string (value);
break;
case PROP_CONTEXT:
g_free (icon->context);
icon->context = g_value_dup_string (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
ib_icon_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
IbIcon *icon = IB_ICON (object);
switch (property_id)
{
case PROP_NAME:
g_value_set_string (value, ib_icon_get_name (icon));
break;
case PROP_REGULAR_NAME:
g_value_set_string (value, icon->regular_name);
break;
case PROP_SYMBOLIC_NAME:
g_value_set_string (value, icon->symbolic_name);
break;
case PROP_USE_SYMBOLIC:
g_value_set_boolean (value, icon->use_symbolic);
break;
case PROP_DESCRIPTION:
g_value_set_string (value, icon->description);
break;
case PROP_CONTEXT:
g_value_set_string (value, icon->context);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
ib_icon_class_init (IbIconClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GParamSpec *pspec;
object_class->finalize = ib_icon_finalize;
object_class->set_property = ib_icon_set_property;
object_class->get_property = ib_icon_get_property;
pspec = g_param_spec_string ("name", "Name", "Name",
NULL,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_NAME, pspec);
pspec = g_param_spec_string ("regular-name", "Regular Name", "Regular Name",
NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_REGULAR_NAME, pspec);
pspec = g_param_spec_string ("symbolic-name", "Symbolic Name", "Symbolic Name",
NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_SYMBOLIC_NAME, pspec);
pspec = g_param_spec_boolean ("use-symbolic", "Use Symbolic", "Use Symbolic",
FALSE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_USE_SYMBOLIC, pspec);
pspec = g_param_spec_string ("description", "Description", "Description",
NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_DESCRIPTION, pspec);
pspec = g_param_spec_string ("context", "Context", "Context",
NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_CONTEXT, pspec);
}
IbIcon *
ib_icon_new (const char *regular_name,
const char *symbolic_name,
const char *description,
const char *context)
{
return g_object_new (IB_TYPE_ICON,
"regular-name", regular_name,
"symbolic-name", symbolic_name,
"description", description,
"context", context,
NULL);
}
const char *
ib_icon_get_name (IbIcon *icon)
{
if (icon->use_symbolic)
return icon->symbolic_name;
else
return icon->regular_name;
}
const char *
ib_icon_get_regular_name (IbIcon *icon)
{
return icon->regular_name;
}
const char *
ib_icon_get_symbolic_name (IbIcon *icon)
{
return icon->symbolic_name;
}
gboolean
ib_icon_get_use_symbolic (IbIcon *icon)
{
return icon->use_symbolic;
}
const char *
ib_icon_get_description (IbIcon *icon)
{
return icon->description;
}
const char *
ib_icon_get_context (IbIcon *icon)
{
return icon->context;
}

View File

@@ -1,18 +0,0 @@
#pragma once
#include <gtk.h>
#define IB_TYPE_ICON (ib_icon_get_type ())
G_DECLARE_FINAL_TYPE (IbIcon, ib_icon, IB, ICON, GObject)
IbIcon *ib_icon_new (const char *regular_name,
const char *symbolic_name,
const char *description,
const char *context);
const char *ib_icon_get_name (IbIcon *icon);
const char *ib_icon_get_regular_name (IbIcon *icon);
const char *ib_icon_get_symbolic_name (IbIcon *icon);
gboolean ib_icon_get_use_symbolic (IbIcon *icon);
const char *ib_icon_get_description (IbIcon *icon);
const char *ib_icon_get_context (IbIcon *icon);

View File

@@ -1,460 +0,0 @@
#include <string.h>
#include "iconbrowserapp.h"
#include "iconbrowserwin.h"
#include "iconbrowsericon.h"
#include "iconbrowsercontext.h"
#include <gtk/gtk.h>
struct _IconBrowserWindow
{
GtkApplicationWindow parent;
GtkWidget *symbolic_radio;
GtkWidget *searchbar;
GListModel *icon_filter_model;
GListStore *icon_store;
GListModel *context_model;
GListStore *context_store;
GtkFilter *name_filter;
GtkFilter *search_mode_filter;
GtkWidget *details;
GtkWidget *image1;
GtkWidget *image2;
GtkWidget *image3;
GtkWidget *image4;
GtkWidget *image5;
GtkWidget *image6;
GtkWidget *image7;
GtkWidget *image8;
GtkWidget *label8;
GtkWidget *description;
};
struct _IconBrowserWindowClass
{
GtkApplicationWindowClass parent_class;
};
G_DEFINE_TYPE(IconBrowserWindow, icon_browser_window, GTK_TYPE_APPLICATION_WINDOW);
static GtkIconTheme *
icon_browser_window_get_icon_theme (IconBrowserWindow *win)
{
return gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (win)));
}
static void
add_icon (IconBrowserWindow *win,
const char *name,
const char *description,
const char *context)
{
GtkIconTheme *icon_theme = icon_browser_window_get_icon_theme (win);
char *regular_name;
char *symbolic_name;
IbIcon *icon;
regular_name = g_strdup (name);
if (!gtk_icon_theme_has_icon (icon_theme, regular_name))
{
g_free (regular_name);
regular_name = NULL;
}
symbolic_name = g_strconcat (name, "-symbolic", NULL);
if (!gtk_icon_theme_has_icon (icon_theme, symbolic_name))
{
g_free (symbolic_name);
symbolic_name = NULL;
}
icon = ib_icon_new (regular_name, symbolic_name, description, context);
g_object_bind_property (win->symbolic_radio, "active",
icon, "use-symbolic",
G_BINDING_DEFAULT);
g_list_store_append (win->icon_store, icon);
g_object_unref (icon);
}
static void
add_context (IconBrowserWindow *win,
const char *id,
const char *name,
const char *description)
{
IbContext *context;
context = ib_context_new (id, name, description);
g_list_store_append (win->context_store, context);
g_object_unref (context);
}
static void
populate (IconBrowserWindow *win)
{
GFile *file;
GKeyFile *kf;
char *data;
gsize length;
char **groups;
int i;
file = g_file_new_for_uri ("resource:/org/gtk/iconbrowser/gtk/icon.list");
g_file_load_contents (file, NULL, &data, &length, NULL, NULL);
kf = g_key_file_new ();
g_key_file_load_from_data (kf, data, length, G_KEY_FILE_NONE, NULL);
groups = g_key_file_get_groups (kf, &length);
for (i = 0; i < length; i++)
{
const char *context;
const char *name;
const char *description;
char **keys;
gsize len;
int j;
context = groups[i];
name = g_key_file_get_string (kf, context, "Name", NULL);
description = g_key_file_get_string (kf, context, "Description", NULL);
add_context (win, context, name, description);
keys = g_key_file_get_keys (kf, context, &len, NULL);
for (j = 0; j < len; j++)
{
const char *key = keys[j];
const char *value;
if (strcmp (key, "Name") == 0 || strcmp (key, "Description") == 0)
continue;
value = g_key_file_get_string (kf, context, key, NULL);
add_icon (win, key, value, context);
}
g_strfreev (keys);
}
g_strfreev (groups);
}
static gboolean
filter_by_icon_name (gpointer item,
gpointer data)
{
return ib_icon_get_name (IB_ICON (item)) != NULL;
}
static void
symbolic_toggled (IconBrowserWindow *win)
{
gtk_filter_changed (win->name_filter, GTK_FILTER_CHANGE_DIFFERENT);
}
static void
copy_to_clipboard (GtkButton *button,
IconBrowserWindow *win)
{
GdkClipboard *clipboard;
clipboard = gtk_widget_get_clipboard (GTK_WIDGET (win));
gdk_clipboard_set_text (clipboard, gtk_window_get_title (GTK_WINDOW (win->details)));
}
static void
set_image (GtkWidget *image, const char *name, int size)
{
gtk_image_set_from_icon_name (GTK_IMAGE (image), name);
gtk_image_set_pixel_size (GTK_IMAGE (image), size);
}
static void
item_activated (GtkGridView *view,
guint position,
IconBrowserWindow *win)
{
GListModel *model = G_LIST_MODEL (gtk_grid_view_get_model (view));
IbIcon *icon = g_list_model_get_item (model, position);
const char *name;
const char *description;
gboolean symbolic;
name = ib_icon_get_name (icon);
description = ib_icon_get_description (icon);
symbolic = ib_icon_get_use_symbolic (icon);
gtk_window_set_title (GTK_WINDOW (win->details), name);
set_image (win->image1, name, 8);
set_image (win->image2, name, 16);
set_image (win->image3, name, 18);
set_image (win->image4, name, 24);
set_image (win->image5, name, 32);
set_image (win->image6, name, 48);
set_image (win->image7, name, 64);
gtk_widget_set_visible (win->image8, symbolic);
gtk_widget_set_visible (win->label8, symbolic);
if (symbolic)
set_image (win->image8, name, 64);
gtk_widget_set_visible (win->description, description && description[0]);
if (description && description[0])
gtk_label_set_text (GTK_LABEL (win->description), description);
gtk_window_present (GTK_WINDOW (win->details));
g_object_unref (icon);
}
static GdkPaintable *
get_image_paintable (GtkImage *image)
{
const char *icon_name;
GtkIconTheme *icon_theme;
GtkIconPaintable *icon;
int size;
switch (gtk_image_get_storage_type (image))
{
case GTK_IMAGE_PAINTABLE:
return g_object_ref (gtk_image_get_paintable (image));
case GTK_IMAGE_ICON_NAME:
icon_name = gtk_image_get_icon_name (image);
size = gtk_image_get_pixel_size (image);
icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (image)));
icon = gtk_icon_theme_lookup_icon (icon_theme,
icon_name,
NULL,
size, 1,
gtk_widget_get_direction (GTK_WIDGET (image)),
0);
if (icon == NULL)
{
g_print ("no icon for %s\n", icon_name);
return NULL;
}
return GDK_PAINTABLE (icon);
case GTK_IMAGE_GICON:
case GTK_IMAGE_EMPTY:
default:
g_warning ("Image storage type %d not handled",
gtk_image_get_storage_type (image));
return NULL;
}
}
static void
drag_begin (GtkDragSource *source,
GdkDrag *drag,
GtkWidget *widget)
{
GdkPaintable *paintable;
paintable = get_image_paintable (GTK_IMAGE (widget));
if (paintable)
{
int w, h;
w = gdk_paintable_get_intrinsic_width (paintable);
h = gdk_paintable_get_intrinsic_height (paintable);
gtk_drag_source_set_icon (source, paintable, w, h);
g_object_unref (paintable);
}
}
static GdkContentProvider *
drag_prepare_texture (GtkDragSource *source,
double x,
double y,
GtkWidget *widget)
{
GdkPaintable *paintable = get_image_paintable (GTK_IMAGE (widget));
GtkSnapshot *snapshot;
double width, height;
GskRenderNode *node;
GskRenderer *renderer;
GdkTexture *texture;
GdkContentProvider *ret;
if (!GDK_IS_PAINTABLE (paintable))
return NULL;
snapshot = gtk_snapshot_new ();
width = gdk_paintable_get_intrinsic_width (paintable);
height = gdk_paintable_get_intrinsic_height (paintable);
gdk_paintable_snapshot (paintable, snapshot, width, height);
node = gtk_snapshot_free_to_node (snapshot);
renderer = gtk_native_get_renderer (gtk_widget_get_native (widget));
texture = gsk_renderer_render_texture (renderer, node, &GRAPHENE_RECT_INIT (0, 0, width, height));
ret = gdk_content_provider_new_typed (GDK_TYPE_TEXTURE, texture);
g_object_unref (texture);
gsk_render_node_unref (node);
return ret;
}
static GdkContentProvider *
drag_prepare_file (GtkDragSource *source,
double x,
double y,
GtkWidget *widget)
{
GdkContentProvider *content;
GtkIconTheme *icon_theme;
const char *name;
GtkIconPaintable *info;
name = gtk_image_get_icon_name (GTK_IMAGE (widget));
icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (widget));
info = gtk_icon_theme_lookup_icon (icon_theme,
name,
NULL,
32, 1,
gtk_widget_get_direction (widget),
0);
content = gdk_content_provider_new_typed (G_TYPE_FILE, gtk_icon_paintable_get_file (info));
g_object_unref (info);
return content;
}
static void
setup_image_dnd (GtkWidget *image)
{
GtkDragSource *source;
source = gtk_drag_source_new ();
g_signal_connect (source, "prepare", G_CALLBACK (drag_prepare_texture), image);
g_signal_connect (source, "drag-begin", G_CALLBACK (drag_begin), image);
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (source));
}
static void
setup_scalable_image_dnd (GtkWidget *image)
{
GtkDragSource *source;
source = gtk_drag_source_new ();
g_signal_connect (source, "prepare", G_CALLBACK (drag_prepare_file), image);
g_signal_connect (source, "drag-begin", G_CALLBACK (drag_begin), image);
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (source));
}
static void
search_mode_toggled (GtkSearchBar *searchbar,
GParamSpec *pspec,
IconBrowserWindow *win)
{
if (gtk_search_bar_get_search_mode (searchbar))
gtk_single_selection_set_selected (GTK_SINGLE_SELECTION (win->context_model), GTK_INVALID_LIST_POSITION);
else if (gtk_single_selection_get_selected (GTK_SINGLE_SELECTION (win->context_model)) == GTK_INVALID_LIST_POSITION)
gtk_single_selection_set_selected (GTK_SINGLE_SELECTION (win->context_model), 0);
gtk_filter_changed (win->search_mode_filter, GTK_FILTER_CHANGE_DIFFERENT);
}
static void
selected_name_changed (GtkSingleSelection *selection,
GParamSpec *pspec,
IconBrowserWindow *win)
{
if (gtk_single_selection_get_selected (selection) != GTK_INVALID_LIST_POSITION)
gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (win->searchbar), FALSE);
}
static void
icon_browser_window_init (IconBrowserWindow *win)
{
GtkFilter *filter;
gtk_widget_init_template (GTK_WIDGET (win));
setup_image_dnd (win->image1);
setup_image_dnd (win->image2);
setup_image_dnd (win->image3);
setup_image_dnd (win->image4);
setup_image_dnd (win->image5);
setup_image_dnd (win->image6);
setup_image_dnd (win->image7);
setup_scalable_image_dnd (win->image8);
gtk_window_set_transient_for (GTK_WINDOW (win->details), GTK_WINDOW (win));
gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (win->searchbar), GTK_WIDGET (win));
populate (win);
filter = gtk_filter_list_model_get_filter (GTK_FILTER_LIST_MODEL (win->icon_filter_model));
win->name_filter = GTK_FILTER (gtk_custom_filter_new (filter_by_icon_name, NULL, NULL));
gtk_multi_filter_append (GTK_MULTI_FILTER (filter), g_object_ref (win->name_filter));
g_signal_connect (win->searchbar, "notify::search-mode-enabled", G_CALLBACK (search_mode_toggled), win);
g_signal_connect (win->context_model, "notify::selected", G_CALLBACK (selected_name_changed), win);
}
static void
icon_browser_window_dispose (GObject *object)
{
gtk_widget_dispose_template (GTK_WIDGET (object), ICON_BROWSER_WINDOW_TYPE);
G_OBJECT_CLASS (icon_browser_window_parent_class)->dispose (object);
}
static void
icon_browser_window_finalize (GObject *object)
{
IconBrowserWindow *win = ICON_BROWSER_WINDOW (object);
g_clear_object (&win->name_filter);
G_OBJECT_CLASS (icon_browser_window_parent_class)->finalize (object);
}
static void
icon_browser_window_class_init (IconBrowserWindowClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->dispose = icon_browser_window_dispose;
object_class->finalize = icon_browser_window_finalize;
g_type_ensure (IB_TYPE_ICON);
g_type_ensure (IB_TYPE_CONTEXT);
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/iconbrowser/gtk/window.ui");
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, symbolic_radio);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, searchbar);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, icon_store);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, icon_filter_model);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, context_model);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, context_store);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, details);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, image1);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, image2);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, image3);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, image4);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, image5);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, image6);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, image7);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, image8);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, label8);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, description);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, search_mode_filter);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), item_activated);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), copy_to_clipboard);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), symbolic_toggled);
}
IconBrowserWindow *
icon_browser_window_new (IconBrowserApp *app)
{
return g_object_new (ICON_BROWSER_WINDOW_TYPE, "application", app, NULL);
}

View File

@@ -1,16 +0,0 @@
#pragma once
#include <gtk/gtk.h>
#include "iconbrowserapp.h"
#define ICON_BROWSER_WINDOW_TYPE (icon_browser_window_get_type ())
#define ICON_BROWSER_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ICON_BROWSER_WINDOW_TYPE, IconBrowserWindow))
typedef struct _IconBrowserWindow IconBrowserWindow;
typedef struct _IconBrowserWindowClass IconBrowserWindowClass;
GType icon_browser_window_get_type (void);
IconBrowserWindow *icon_browser_window_new (IconBrowserApp *app);

View File

@@ -1,8 +0,0 @@
#include <gtk/gtk.h>
#include <iconbrowserapp.h>
int
main (int argc, char *argv[])
{
return g_application_run (G_APPLICATION (icon_browser_app_new ()), argc, argv);
}

View File

@@ -1,41 +0,0 @@
iconbrowser_sources = [
'main.c',
'iconbrowserapp.c',
'iconbrowserwin.c',
'iconbrowsericon.c',
'iconbrowsercontext.c'
]
iconbrowser_resources = gnome.compile_resources('iconbrowser_resources',
'iconbrowser.gresource.xml',
source_dir: meson.current_source_dir(),
)
executable('gtk4-icon-browser',
sources: [iconbrowser_sources, iconbrowser_resources],
c_args: common_cflags,
dependencies: [ libgtk_dep, profile_conf_h ],
include_directories: confinc,
win_subsystem: 'windows',
link_args: extra_demo_ldflags,
install: true,
)
# icons
icontheme_dir = join_paths(gtk_datadir, 'icons/hicolor')
foreach size: ['scalable', 'symbolic']
install_subdir('data/' + size, install_dir: icontheme_dir)
endforeach
# desktop file
install_data('org.gtk.IconBrowser4.desktop', install_dir: gtk_applicationsdir)
# appdata
configure_file(
input: 'org.gtk.IconBrowser4.appdata.xml.in',
output: 'org.gtk.IconBrowser4.appdata.xml',
configuration: appdata_config,
install_dir: gtk_appdatadir
)

View File

@@ -1,41 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<id>org.gtk.IconBrowser4</id>
<launchable type="desktop-id">org.gtk.IconBrowser4.desktop</launchable>
<metadata_license>CC0-1.0</metadata_license>
<project_license>LGPL-2.1-or-later</project_license>
<name>GTK Icon Browser</name>
<summary>Program to browse themed icons</summary>
<description>
<p>
GTK Icon Browser is a simple application to show themed icons that
are available on the system.
</p>
</description>
<screenshots>
<screenshot>
<image>https://static.gnome.org/appdata/gtk4-icon-browser/gtk-icon-browser1.png</image>
<caption>Icon Browser</caption>
</screenshot>
<screenshot>
<image>https://static.gnome.org/appdata/gtk4-icon-browser/gtk-icon-browser2.png</image>
<caption>Search</caption>
</screenshot>
</screenshots>
<kudos>
<kudo>HiDpiIcon</kudo>
<kudo>ModernToolkit</kudo>
</kudos>
<url type="homepage">https://www.gtk.org</url>
<translation type="gettext">gtk-4.0</translation>
<update_contact>matthias.clasen_at_gmail.com</update_contact>
<developer_name>Matthias Clasen and others</developer_name>
<content_rating type="oars-1.1"/>
<releases>
<release version="@BUILD_VERSION@">
<description>
<p>A new build of GTK.</p>
</description>
</release>
</releases>
</component>

View File

@@ -1,9 +0,0 @@
[Desktop Entry]
Name=Icon Browser
Comment=An application that shows themed icons
Exec=gtk4-icon-browser
Icon=org.gtk.IconBrowser4
Terminal=false
Type=Application
StartupNotify=true
Categories=Development;GTK;

View File

@@ -1,482 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<menu id="gear_menu">
<section>
<item>
<attribute name="label" translatable="yes">_Inspector</attribute>
<attribute name="action">app.inspector</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_About GTK Icon Browser</attribute>
<attribute name="action">app.about</attribute>
</item>
</section>
</menu>
<template class="IconBrowserWindow" parent="GtkApplicationWindow">
<property name="title" translatable="yes">Icon Browser</property>
<property name="default-width">1024</property>
<property name="default-height">768</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="header">
<child type="title">
<object class="GtkBox">
<style>
<class name="linked"/>
</style>
<child>
<object class="GtkToggleButton" id="normal_radio">
<property name="focus-on-click">0</property>
<property name="label" translatable="yes">Normal</property>
<property name="active">1</property>
</object>
</child>
<child>
<object class="GtkToggleButton" id="symbolic_radio">
<property name="focus-on-click">0</property>
<property name="label" translatable="yes">Symbolic</property>
<property name="group">normal_radio</property>
<signal name="notify::active" handler="symbolic_toggled" swapped="yes" after="yes"/>
</object>
</child>
</object>
</child>
<child type="end">
<object class="GtkMenuButton" id="gear_menu_button">
<property name="focus-on-click">0</property>
<property name="valign">center</property>
<property name="menu-model">gear_menu</property>
<property name="icon-name">open-menu-symbolic</property>
</object>
</child>
<child type="end">
<object class="GtkToggleButton" id="search">
<property name="focus-on-click">0</property>
<style>
<class name="image-button"/>
</style>
<child>
<object class="GtkImage" id="search-icon">
<property name="icon-name">edit-find-symbolic</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<child>
<object class="GtkScrolledWindow">
<style>
<class name="sidebar"/>
</style>
<property name="hscrollbar-policy">never</property>
<child>
<object class="GtkListView">
<style>
<class name="navigation-sidebar"/>
</style>
<property name="model">
<object class="GtkSingleSelection" id="context_model">
<property name="model">
<object class="GListStore" id="context_store">
<property name="item-type">IbContext</property>
</object>
</property>
</object>
</property>
<property name="factory">
<object class="GtkBuilderListItemFactory">
<property name="bytes">
<![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GtkListItem">
<property name="child">
<object class="GtkLabel">
<property name="xalign">0</property>
<binding name="label">
<lookup name="name" type="IbContext">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
</object>
</property>
</template>
</interface>
]]>
</property>
</object>
</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox" id="content_box">
<property name="orientation">vertical</property>
<child>
<object class="GtkSearchBar" id="searchbar">
<property name="search-mode-enabled" bind-source="search" bind-property="active" bind-flags="bidirectional"/>
<child>
<object class="GtkSearchEntry" id="searchentry">
</object>
</child>
</object>
</child>
<child>
<object class="GtkScrolledWindow" id="sw">
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<property name="hscrollbar-policy">never</property>
<child>
<object class="GtkGridView" id="list">
<style>
<class name="content-view"/>
</style>
<signal name="activate" handler="item_activated"/>
<property name="single-click-activate">1</property>
<property name="model">
<object class="GtkNoSelection">
<property name="model">
<object class="GtkFilterListModel" id="icon_filter_model">
<property name="filter">
<object class="GtkEveryFilter">
<child>
<object class="GtkStringFilter">
<property name="expression">
<lookup name="name" type="IbIcon"/>
</property>
<binding name="search">
<lookup name="text" type="GtkSearchEntry">
searchentry
</lookup>
</binding>
</object>
</child>
<child>
<object class="GtkAnyFilter">
<child>
<object class="GtkBoolFilter" id="search_mode_filter">
<property name="expression">
<lookup name="search-mode-enabled">
searchbar
</lookup>
</property>
</object>
</child>
<child>
<object class="GtkStringFilter">
<property name="ignore-case">0</property>
<property name="match-mode">exact</property>
<property name="expression">
<lookup name="context" type="IbIcon"/>
</property>
<binding name="search">
<lookup name="id" type="IbContext">
<lookup name="selected-item" type="GtkSingleSelection">
context_model
</lookup>
</lookup>
</binding>
</object>
</child>
</object>
</child>
</object>
</property>
<property name="model">
<object class="GListStore" id="icon_store">
<property name="item-type">IbIcon</property>
</object>
</property>
</object>
</property>
</object>
</property>
<property name="factory">
<object class="GtkBuilderListItemFactory">
<property name="bytes">
<![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GtkListItem">
<property name="child">
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkImage">
<property name="pixel-size">48</property>
<binding name="icon-name">
<lookup name="name" type="IbIcon">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
</object>
</child>
<child>
<object class="GtkLabel">
<binding name="label">
<lookup name="name" type="IbIcon">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
</object>
</child>
</object>
</property>
</template>
</interface>
]]>
</property>
</object>
</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</template>
<object class="GtkDialog" id="details">
<property name="modal">1</property>
<property name="use-header-bar">1</property>
<property name="resizable">0</property>
<property name="hide-on-close">1</property>
<child internal-child="content_area">
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkGrid">
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="row-spacing">18</property>
<property name="column-spacing">18</property>
<property name="halign">center</property>
<child>
<object class="GtkImage" id="image1">
<property name="halign">center</property>
<property name="valign">end</property>
<layout>
<property name="column">0</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkImage" id="image2">
<property name="halign">center</property>
<property name="valign">end</property>
<layout>
<property name="column">1</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkImage" id="image3">
<property name="halign">center</property>
<property name="valign">end</property>
<layout>
<property name="column">2</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkImage" id="image4">
<property name="halign">center</property>
<property name="valign">end</property>
<layout>
<property name="column">3</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkImage" id="image5">
<property name="halign">center</property>
<property name="valign">end</property>
<layout>
<property name="column">4</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkImage" id="image6">
<property name="halign">center</property>
<property name="valign">end</property>
<layout>
<property name="column">5</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkImage" id="image7">
<property name="halign">center</property>
<property name="valign">end</property>
<layout>
<property name="column">6</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkImage" id="image8">
<property name="halign">center</property>
<property name="valign">end</property>
<layout>
<property name="column">7</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label1">
<property name="halign">center</property>
<property name="valign">baseline</property>
<property name="label">8×8</property>
<style>
<class name="dim-label"/>
</style>
<layout>
<property name="column">0</property>
<property name="row">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label2">
<property name="halign">center</property>
<property name="valign">baseline</property>
<property name="label">16×16</property>
<style>
<class name="dim-label"/>
</style>
<layout>
<property name="column">1</property>
<property name="row">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label3">
<property name="halign">center</property>
<property name="valign">baseline</property>
<property name="label">18×18</property>
<style>
<class name="dim-label"/>
</style>
<layout>
<property name="column">2</property>
<property name="row">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label4">
<property name="halign">center</property>
<property name="valign">baseline</property>
<property name="label">24×24</property>
<style>
<class name="dim-label"/>
</style>
<layout>
<property name="column">3</property>
<property name="row">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label5">
<property name="halign">center</property>
<property name="valign">baseline</property>
<property name="label">32×32</property>
<style>
<class name="dim-label"/>
</style>
<layout>
<property name="column">4</property>
<property name="row">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label6">
<property name="halign">center</property>
<property name="valign">baseline</property>
<property name="label">48×48</property>
<style>
<class name="dim-label"/>
</style>
<layout>
<property name="column">5</property>
<property name="row">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label7">
<property name="halign">center</property>
<property name="valign">baseline</property>
<property name="label">64×64</property>
<style>
<class name="dim-label"/>
</style>
<layout>
<property name="column">6</property>
<property name="row">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label8">
<property name="halign">center</property>
<property name="valign">baseline</property>
<property name="label">scalable</property>
<style>
<class name="dim-label"/>
</style>
<layout>
<property name="column">7</property>
<property name="row">2</property>
</layout>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">Copy to Clipboard</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="margin-start">20</property>
<property name="margin-end">20</property>
<property name="margin-top">20</property>
<property name="margin-bottom">20</property>
<signal name="clicked" handler="copy_to_clipboard"/>
</object>
</child>
<child>
<object class="GtkLabel" id="description">
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="wrap">1</property>
<property name="max-width-chars">60</property>
<property name="valign">start</property>
</object>
</child>
</object>
</child>
</object>
</interface>

View File

@@ -3,9 +3,7 @@
appdata_config = configuration_data()
appdata_config.set('BUILD_VERSION', meson.project_version())
subdir('constraint-editor')
subdir('gtk-demo')
subdir('icon-browser')
subdir('node-editor')
subdir('widget-factory')
subdir('print-editor')

View File

@@ -112,7 +112,7 @@ activate_about (GSimpleAction *action,
? "GTK Node Editor (Development)"
: "GTK Node Editor",
"version", version,
"copyright", "©2019—2021 The GTK Team",
"copyright", "©2019—2024 The GTK Team",
"license-type", GTK_LICENSE_LGPL_2_1,
"website", "http://www.gtk.org",
"comments", "Program to test GTK rendering",
@@ -121,8 +121,12 @@ activate_about (GSimpleAction *action,
"title", "About GTK Node Editor",
"system-information", s->str,
NULL);
gtk_about_dialog_add_credit_section (GTK_ABOUT_DIALOG (dialog),
"Artwork by", (const char *[]) { "Jakub Steiner", NULL });
gtk_about_dialog_add_credit_section (GTK_ABOUT_DIALOG (dialog),
"Artwork by", (const char *[]) { "Jakub Steiner", NULL });
gtk_about_dialog_add_credit_section (GTK_ABOUT_DIALOG (dialog),
"Maintained by", (const char *[]) { "The GTK Team", NULL });
gtk_window_present (GTK_WINDOW (dialog));
@@ -219,6 +223,8 @@ node_editor_application_activate (GApplication *app)
if (g_strcmp0 (PROFILE, "devel") == 0)
gtk_widget_add_css_class (GTK_WIDGET (win), "devel");
gtk_window_set_icon_name (GTK_WINDOW (win), "org.gtk.gtk4.NodeEditor");
gtk_window_present (GTK_WINDOW (win));
}

View File

@@ -925,7 +925,7 @@ export_image_response_cb (GObject *source,
GdkTexture *texture;
GskRenderer *renderer;
renderer = gsk_gl_renderer_new ();
renderer = gsk_ngl_renderer_new ();
if (!gsk_renderer_realize_for_display (renderer, gdk_display_get_default (), NULL))
{
g_object_unref (renderer);
@@ -1205,6 +1205,19 @@ node_editor_window_add_renderer (NodeEditorWindow *self,
g_object_unref (paintable);
}
static void
update_paste_action (GdkClipboard *clipboard,
GParamSpec *pspec,
gpointer data)
{
GtkWidget *widget = GTK_WIDGET (data);
gboolean has_node;
has_node = gdk_content_formats_contain_mime_type (gdk_clipboard_get_formats (clipboard), "application/x-gtk-render-node");
gtk_widget_action_set_enabled (widget, "paste-node", has_node);
}
static void
node_editor_window_realize (GtkWidget *widget)
{
@@ -1242,6 +1255,7 @@ node_editor_window_realize (GtkWidget *widget)
self->after_paint_handler = g_signal_connect (frameclock, "after-paint",
G_CALLBACK (after_paint), self);
g_signal_connect (gtk_widget_get_clipboard (widget), "notify::formats", G_CALLBACK (update_paste_action), widget);
}
static void
@@ -1251,6 +1265,8 @@ node_editor_window_unrealize (GtkWidget *widget)
GdkFrameClock *frameclock;
guint i;
g_signal_handlers_disconnect_by_func (gtk_widget_get_clipboard (widget), update_paste_action, widget);
frameclock = gtk_widget_get_frame_clock (widget);
g_signal_handler_disconnect (frameclock, self->after_paint_handler);
self->after_paint_handler = 0;
@@ -1615,6 +1631,41 @@ edit_action_cb (GtkWidget *widget,
node_editor_window_edit (self, &start);
}
static void
text_received (GObject *source,
GAsyncResult *result,
gpointer data)
{
GdkClipboard *clipboard = GDK_CLIPBOARD (source);
NodeEditorWindow *self = NODE_EDITOR_WINDOW (data);
char *text;
text = gdk_clipboard_read_text_finish (clipboard, result, NULL);
if (text)
{
GtkTextBuffer *buffer;
GtkTextIter start, end;
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self->text_view));
gtk_text_buffer_begin_user_action (buffer);
gtk_text_buffer_get_bounds (buffer, &start, &end);
gtk_text_buffer_delete (buffer, &start, &end);
gtk_text_buffer_insert (buffer, &start, text, -1);
gtk_text_buffer_end_user_action (buffer);
g_free (text);
}
}
static void
paste_node_cb (GtkWidget *widget,
const char *action_name,
GVariant *parameter)
{
GdkClipboard *clipboard = gtk_widget_get_clipboard (widget);
gdk_clipboard_read_text_async (clipboard, NULL, text_received, widget);
}
static void
node_editor_window_set_property (GObject *object,
guint prop_id,
@@ -1727,6 +1778,13 @@ node_editor_window_class_init (NodeEditorWindowClass *class)
action = gtk_named_action_new ("smart-edit");
shortcut = gtk_shortcut_new (trigger, action);
gtk_widget_class_add_shortcut (widget_class, shortcut);
gtk_widget_class_install_action (widget_class, "paste-node", NULL, paste_node_cb);
trigger = gtk_keyval_trigger_new (GDK_KEY_v, GDK_CONTROL_MASK | GDK_SHIFT_MASK);
action = gtk_named_action_new ("paste-node");
shortcut = gtk_shortcut_new (trigger, action);
gtk_widget_class_add_shortcut (widget_class, shortcut);
}
static GtkWidget *

View File

@@ -22,6 +22,10 @@
</menu>
<menu id="extra_menu">
<section>
<item>
<attribute name="label" translatable="yes">Paste _Node</attribute>
<attribute name="action">paste-node</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Assisted _Edit</attribute>
<attribute name="action">smart-edit</attribute>

View File

@@ -3,7 +3,7 @@
<gresource prefix="/org/gtk/gtk4/node-editor">
<file preprocess="xml-stripblanks">node-editor-window.ui</file>
<file preprocess="xml-stripblanks">help-window.ui</file>
<file>node-format.md</file>
<file alias='node-format.md'>../../docs/reference/gtk/node-format.md</file>
<file alias='icons/apps/org.gtk.gtk4.NodeEditor.svg'>data/scalable/apps/org.gtk.gtk4.NodeEditor.svg</file>
</gresource>
</gresources>

View File

@@ -576,18 +576,6 @@ activate_about (GSimpleAction *action,
int i;
char *os_name;
char *os_version;
const char *authors[] = {
"Alexander Larsson",
NULL
};
const char *artists[] = {
"Jakub Steiner",
NULL
};
const char *maintainers[] = {
"The GTK Team",
NULL
};
GtkWidget *dialog;
os_name = g_get_os_info (G_OS_INFO_KEY_NAME);
@@ -631,19 +619,21 @@ activate_about (GSimpleAction *action,
? "GTK Print Editor (Development)"
: "GTK Print Editor",
"version", version,
"copyright", "© 2006-2021 Red Hat, Inc",
"copyright", "© 2006-2024 Red Hat, Inc",
"license-type", GTK_LICENSE_LGPL_2_1,
"website", "http://www.gtk.org",
"comments", "Program to demonstrate GTK printing",
"authors", authors,
"authors", (const char *[]) { "Alexander Larsson", NULL },
"logo-icon-name", "org.gtk.PrintEditor4",
"title", "About GTK Print Editor",
"system-information", sysinfo->str,
NULL);
gtk_about_dialog_add_credit_section (GTK_ABOUT_DIALOG (dialog),
_("Artwork by"), artists);
_("Artwork by"), (const char *[]) { "Jakub Steiner", NULL });
gtk_about_dialog_add_credit_section (GTK_ABOUT_DIALOG (dialog),
_("Maintained by"), maintainers);
_("Maintained by"), (const char *[]) { "The GTK Team", NULL });
gtk_window_present (GTK_WINDOW (dialog));
@@ -798,7 +788,7 @@ activate (GApplication *app)
if (g_strcmp0 (PROFILE, "devel") == 0)
gtk_widget_add_css_class (GTK_WIDGET (main_window), "devel");
gtk_window_set_icon_name (GTK_WINDOW (main_window), "text-editor");
gtk_window_set_icon_name (GTK_WINDOW (main_window), "org.gtk.PrintEditor4");
gtk_window_set_default_size (GTK_WINDOW (main_window), 400, 600);
gtk_application_window_set_show_menubar (GTK_APPLICATION_WINDOW (main_window), TRUE);
update_title (GTK_WINDOW (main_window));

View File

@@ -294,15 +294,6 @@ activate_about (GSimpleAction *action,
GtkApplication *app = user_data;
GtkWindow *window;
GtkWidget *button;
const char *authors[] = {
"Andrea Cimitan",
"Cosimo Cecchi",
NULL
};
const char *maintainers[] = {
"The GTK Team",
NULL
};
char *version;
char *os_name;
char *os_version;
@@ -347,18 +338,18 @@ activate_about (GSimpleAction *action,
? "GTK Widget Factory (Development)"
: "GTK Widget Factory",
"version", version,
"copyright", "©1997—2021 The GTK Team",
"copyright", "©1997—2024 The GTK Team",
"license-type", GTK_LICENSE_LGPL_2_1,
"website", "http://www.gtk.org",
"comments", "Program to demonstrate GTK themes and widgets",
"authors", authors,
"authors", (const char *[]) { "Andrea Cimitan", "Cosimo Cecchi", NULL },
"logo-icon-name", "org.gtk.WidgetFactory4",
"title", "About GTK Widget Factory",
"system-information", s->str,
NULL);
gtk_about_dialog_add_credit_section (GTK_ABOUT_DIALOG (dialog),
_("Maintained by"), maintainers);
_("Maintained by"), (const char *[]) { "The GTK Team", NULL });
gtk_window_present (GTK_WINDOW (dialog));
@@ -2241,6 +2232,7 @@ activate (GApplication *app)
if (g_strcmp0 (PROFILE, "devel") == 0)
gtk_widget_add_css_class (GTK_WIDGET (window), "devel");
gtk_window_set_icon_name (window, "org.gtk.WidgetFactory4");
gtk_application_add_window (GTK_APPLICATION (app), window);
g_action_map_add_action_entries (G_ACTION_MAP (window),
win_entries, G_N_ELEMENTS (win_entries),

View File

@@ -151,10 +151,11 @@ Checks whether the widget is set to be visible or not.
- Methods are special functions whose first argument is always the instance
of a certain class. The instance argument for newly written code should be
called `self`.
- If a method is a setter or a getter for an object property, you should
add an `(attributes org.gtk.Method.set_property=property-name)` or a
an `(attributes org.gtk.Method.get_property=property-name)` annotation
to the method's identifier
- If a method is a setter or a getter for an object property
`GtkClassName:prop-name`, and if its name does not match the naming scheme
`gtk_class_name_{g,s}et_prop_name`, you should add a `(set-property
prop-name)` or a `(get-property prop-name)` annotation to the method's
identifier
- If a method changes one or more properties as side effect, link those
properties in the method's description
- If a method is a signal emitter, you should use the
@@ -192,9 +193,10 @@ Checks whether the widget is set to be visible or not.
purposes.
- Always note if setting a property has side effects, like causing another
property to change state.
- If the property has public accessors you should annotate it with
the `(attributes org.gtk.Property.set=setter_function)` and
`(attributes org.gtk.Property.get=getter_function)` attributes
- If a property `GtkClassName:prop-name` has a public getter or setter, and
they do not match the naming scheme `gtk_class_name_{g,s}et_prop_name` you
should annotate it with the `(setter setter_function)` and `(getter
getter_function)`.
- The syntax for property documentation is:
```c

View File

@@ -69,6 +69,18 @@ if get_option('documentation')
install: true,
install_dir: docs_dir,
)
test('doc-check-gdk-x11',
gidocgen,
args: [
'check',
'--config', gdk4x11_toml,
'--add-include-path=@0@'.format(meson.current_build_dir() / '../../../gtk'),
gdk_x11_gir[0],
],
depends: gdk_x11_gir[0],
suite: ['docs', 'failing'],
)
endif
if wayland_enabled

View File

@@ -1,12 +1,16 @@
Title: The Broadway windowing system
Slug: broadway
## Using GTK with Broadway
The GDK Broadway backend provides support for displaying GTK applications in
a web browser, using HTML5 and web sockets.
To run your application in this way, first run the broadway server,
Broadway was written as an experiment and is not the most actively developed
backend. It supports the features that were required of GDK backends in GTK 4.0,
but may not be up-to-date with the latest developments.
## Using GTK with Broadway
To run your application under Broadway, first run the broadway server,
`gtk-broadwayd`, that ships with GTK:
```

View File

@@ -66,8 +66,8 @@ The clock has several phases:
- Layout
- Paint
The phases happens in this order and we will always run each
phase through before going back to the start.
The phases happen in this order and all phases will always run
through before going back to the start.
The Events phase is a stretch of time between each redraw where
GTK processes input events from the user and other events

View File

@@ -66,10 +66,6 @@ You can compile the program above with GCC using:
gcc $( pkg-config --cflags gtk4 ) -o example-0 example-0.c $( pkg-config --libs gtk4 )
```
**Note**: If the above compilation does not work due to an error regarding `G_APPLICATION_DEFAULT_FLAGS`
this could be due to your OS providing an older version of GLib. For GLib versions older than 2.74 you
will need to replace `G_APPLICATION_DEFAULT_FLAGS` with `G_APPLICATION_FLAGS_NONE` in this example, and
others in this documentation.
For more information on how to compile a GTK application, please
refer to the [Compiling GTK Applications](compiling.html)
section in this reference.

View File

@@ -1,32 +0,0 @@
.. _gtk4-icon-browser(1):
=================
gtk4-icon-browser
=================
-----------------
List themed icons
-----------------
:Version: GTK
:Manual section: 1
:Manual group: GTK commands
SYNOPSIS
--------
| **gtk4-icon-browser** [OPTIONS...]
DESCRIPTION
-----------
``gtk4-icon-browser`` is a utility to explore the icons in the current icon
theme. It shows icons in various sizes, their symbolic variants where available,
as well as a description of the icon and its context.
OPTIONS
-------
``-h, --help``
Show the application help.

View File

@@ -0,0 +1,97 @@
.. _gtk4-image-tool(1):
====================
gtk4-image-tool
====================
-----------------------
Image Utility
-----------------------
:Version: GTK
:Manual section: 1
:Manual group: GTK commands
SYNOPSIS
--------
| **gtk4-image-tool** <COMMAND> [OPTIONS...] <FILE>...
|
| **gtk4-image-tool** compare [OPTIONS...] <FILE1> <FILE2>
| **gtk4-image-tool** convert [OPTIONS...] <FILE1> <FILE2>
| **gtk4-image-tool** info [OPTIONS...] <FILE>
| **gtk4-image-tool** relabel [OPTIONS...] <FILE1> <FILE2>
| **gtk4-image-tool** show [OPTIONS...] <FILE>...
DESCRIPTION
-----------
``gtk4-image-tool`` can perform various operations on images.
COMMANDS
--------
Information
^^^^^^^^^^^
The ``info`` command shows general information about the image, such
as its format and color state.
Showing
^^^^^^^
The ``show`` command displays one or more images, side-by-side.
``--undecorated``
Removes window decorations. This is meant for rendering of exactly the image
without any titlebar.
Compare
^^^^^^^
The ``compare`` command compares two images. If any differences are found,
the exit code is 1. If the images are identical, it is 0.
``--output=FILE``
Save the differences as a png image in ``FILE``.
``--quiet``
Don't write results to stdout.
Conversion
^^^^^^^^^^
The ``convert`` command converts the image to a different format or color state.
``--format=FORMAT``
Convert to the given format. The supported formats can be listed
with ``--format=list``.
``--color-state=COLORSTATE``
Convert to the given color state. The supported color states can be
listed with ``--format=list``.
``--cicp=CICP``
Convert to a color state that is specified as a cicp tuple. The cicp tuple
must be specified as four numbers, separated by /, e.g. 1/13/6/0.
Relabeling
^^^^^^^^^^
The ``relabel`` command changes the color state of an image without conversion.
This can be useful to produce wrong color renderings for diagnostics.
``--color-state=COLORSTATE``
Relabel to the given color state. The supported color states can be
listed with ``--format=list``.
``--cicp=CICP``
Relabel to a color state that is specified as a cicp tuple. The cicp tuple
must be specified as four numbers, separated by /, e.g. 1/13/6/0.

View File

@@ -85,6 +85,7 @@ content_files = [
"x11.md",
"tools.md",
"visual_index.md",
"node-format.md",
]
content_images = [
"../images/favicon.svg",
@@ -259,4 +260,4 @@ name = "StyleProvider"
hidden = true
[check]
skip_deprecated = true
ignore_deprecated = true

View File

@@ -74,7 +74,7 @@ if get_option('documentation')
gtk_gir[0],
],
depends: gtk_gir[0],
suite: ['docs'],
suite: ['docs', 'failing'],
)
endif
@@ -85,6 +85,7 @@ rst_files = [
[ 'gtk4-broadwayd', '1' ],
[ 'gtk4-builder-tool', '1' ],
[ 'gtk4-encode-symbolic-svg', '1', ],
[ 'gtk4-image-tool', '1' ],
[ 'gtk4-launch', '1', ],
[ 'gtk4-query-settings', '1', ],
[ 'gtk4-rendernode-tool', '1' ],
@@ -97,7 +98,6 @@ if get_option('build-demos')
[ 'gtk4-demo', '1', ],
[ 'gtk4-demo-application', '1', ],
[ 'gtk4-widget-factory', '1', ],
[ 'gtk4-icon-browser', '1', ],
[ 'gtk4-node-editor', '1', ],
]
endif

View File

@@ -24,36 +24,36 @@ the motivation and goals of larger API changes.
## Cell renderers are going away
Cell renderers were introduced in GTK 2 to support rendering of
"big data" UIs, in particular treeviews. Over the years, more
"data-like" widgets have started to use them, and cell renderers
big data UIs, in particular treeviews. Over the years, more
data-like widgets have started to use them, and cell renderers
have grown into a shadowy, alternative rendering infrastructure
that duplicates much of what widgets do, while duplicating the
code and adding their own dose of bugs.
In GTK 4, replacement widgets for GtkTreeView, GtkIconView and
GtkComboBox have appeared: GtkListView, GtkColumnView, GtkGridView
and GtkDropDown. For GTK 5, we will take the next step and remove
In GTK 4, replacement widgets for `GtkTreeView`, `GtkIconView` and
`GtkComboBox` have appeared: [class@Gtk.ListView], [class@Gtk.ColumnView], [class@Gtk.GridView]
and [class@Gtk.DropDown]. For GTK 5, we will take the next step and remove
all cell renderer-based widgets.
## Themed rendering APIs are going away
The old GTK 2 era rendering APIs for theme components like
gtk_render_frame() or gtk_render_check() have not been used by
`gtk_render_frame()` or `gtk_render_check()` have not been used by
GTK itself even in later GTK 3, but they have been kept around
for the benefit of "external drawing" users - applications that
for the benefit of external drawing users applications that
want their controls to look like GTK without using widgets.
Supporting this is increasingly getting in the way of making
the GTK CSS machinery fast and correct. One notable problem is
that temporary style changes (using gtk_style_context_save())
that temporary style changes (using `gtk_style_context_save()`)
is breaking animations. Therefore, these APIs will be going away
in GTK 5, together with their more modern GtkSnapshot variants
like gtk_snapshot_render_background() or gtk_snapshot_render_focus().
in GTK 5, together with their more modern [class@Gtk.Snapshot] variants
like `gtk_snapshot_render_background()` or `gtk_snapshot_render_focus()`.
The best way to render parts of your widget using CSS styling
is to use subwidgets. For example, to show a piece of text with
fonts, effects and shadows according to the current CSS style,
use a GtkLabel.
use a [class@Gtk.Label].
If you have a need for custom drawing that fits into the current
(dark or light) theme, e.g. for rendering a graph, you can still
@@ -62,28 +62,28 @@ get the current style foreground color, using
## Local stylesheets are going away
The cascading part of GTK's CSS implementation is complicated by
The cascading part of GTKs CSS implementation is complicated by
the existence of local stylesheets (i.e. those added with
gtk_style_context_add_provider()). And local stylesheets are
`gtk_style_context_add_provider()`). And local stylesheets are
unintuitive in that they do not apply to the whole subtree of
widgets, but just to the one widget where the stylesheet was
added.
GTK 5 will no longer provide this functionality. The recommendations
is to use a global stylesheet (i.e. gtk_style_context_add_provider_for_display())
GTK 5 will no longer provide this functionality. The recommendation
is to use a global stylesheet (i.e. [func@Gtk.StyleContext.add_provider_for_display])
and rely on style classes to make your CSS apply only where desired.
## Non-standard CSS extensions are going away
GTK's CSS machinery has a some non-standard extensions around colors:
named colors with \@define-color and color functions: lighter(), darker(),
shade(), alpha(), mix().
GTKs CSS machinery has a some non-standard extensions around colors:
named colors with `@define-color` and color functions: `lighter()`, `darker()`,
`shade()`, `alpha()`, `mix()`.
GTK now implements equivalent functionality from the CSS specs.
### \@define-color is going away
### `@define-color` is going away
\@define-color should be replaced by custom properties in the :root scope.
`@define-color` should be replaced by custom properties in the `:root` scope.
Instead of
@@ -117,9 +117,9 @@ spec.
### Color expressions are going away
The color functions can all be replaced by combinations of calc() and color-mix().
The color functions can all be replaced by combinations of `calc()` and `color-mix()`.
ligher(c) and darker(c) are just shade(c, 1.3) or shade(c, 0.7), respectively, and
`lighter(c)` and `darker(c)` are just `shade(c, 1.3)` or `shade(c, 0.7)`, respectively, and
thus can be handled the same way as shade in the examples below.
Replace
@@ -164,7 +164,7 @@ d {
Variations of these replacements are possible.
Note that GTK has historically computed mix() and shade() values in the SRGB and HSL
Note that GTK has historically computed `mix()` and `shade()` values in the SRGB and HSL
colorspaces, but using OKLAB instead might yield slightly better results.
For more information about color-mix(), see the
@@ -172,32 +172,32 @@ For more information about color-mix(), see the
## Chooser interfaces are going away
The GtkColorChooser, GtkFontChooser, GtkFileChooser and GtkAppChooser
The `GtkColorChooser`, `GtkFontChooser`, `GtkFileChooser` and `GtkAppChooser`
interfaces and their implementations as dialogs, buttons and widgets
are phased out. The are being replaced by a new family of async APIs
that will be more convenient to use from language bindings, in particular
for languages that have concepts like promises. The new APIs are
[class@Gtk.ColorDialog], [class@Gtk.FontDialog] and [class@Gtk.FileDialog],
There are also equivalents for some of the 'button' widgets:
There are also equivalents for some of the button widgets:
[class@Gtk.ColorDialogButton], [class@Gtk.FontDialogButton].
## GtkMessageDialog is going away
Like the Chooser interfaces, GtkMessageDialog has been replaced by
Like the Chooser interfaces, `GtkMessageDialog` has been replaced by
a new async API that will be more convenient, in particular for
language binding. The new API is [class@Gtk.AlertDialog].
## GtkDialog is going away
After gtk_dialog_run() was removed, the usefulness of GtkDialog
is much reduced, and it has awkward, archaice APIs. Therefore,
After `gtk_dialog_run()` was removed, the usefulness of `GtkDialog`
is much reduced, and it has awkward, archaic APIs. Therefore,
it is dropped. The recommended replacement is to just create
your own window and add buttons as required, either in the header
or elsewhere.
## GtkInfoBar is going away
GtkInfoBar had a dialog API, and with dialogs going away, it was time to
`GtkInfoBar` had a dialog API, and with dialogs going away, it was time to
retire it. If you need such a widget, it is relatively trivial to create one
using a [class@Gtk.Revealer] with labels and buttons.
@@ -205,11 +205,12 @@ Other libraries, such as libadwaita, may provide replacements as well.
## gtk_show_uri is being replaced
Instead of gtk_show_uri(), you should use GtkUriLauncher or GtkFileLauncher.
Instead of `gtk_show_uri()`, you should use [class@Gtk.UriLauncher]
or [class@Gtk.FileLauncher].
## GtkStatusbar is going away
This is an oldfashioned widget that does not do all that much anymore, since
This is an old fashioned widget that does not do all that much any more, since
it no longer has a resize handle for the window.
## GtkLockButton and GtkVolumeButton are going away
@@ -217,22 +218,22 @@ it no longer has a resize handle for the window.
These are very specialized widgets that should better live with the application
where they are used.
## Widget size api changes
## Widget size API changes
The functions gtk_widget_get_allocated_width() and gtk_widget_get_allocated_height()
The functions `gtk_widget_get_allocated_width()` and `gtk_widget_get_allocated_height()`
are going away. In most cases, [method@Gtk.Widget.get_width] and [method@Gtk.Widget.get_height]
are suitable replacements. Note that the semantics are slightly different though:
the old functions return the size of the CSS border area, while the new functions return
the size of the widgets content area. In places where this difference matters, you can
use `gtk_widget_compute_bounds (widget, widget, &bounds)` instead.
The function gtk_widget_get_allocation() is also going away. It does not have a direct
The function `gtk_widget_get_allocation()` is also going away. It does not have a direct
replacement, but the previously mentioned alternatives can be used for it too.
The function gtk_widget_get_allocated_baseline() has been renamed to [method@Gtk.Widget.get_baseline].
The function `gtk_widget_get_allocated_baseline()` has been renamed to [method@Gtk.Widget.get_baseline].
## Stop using GdkPixbuf
GTK is moving away from GdkPixbuf as the primary API for transporting image data, in favor
of GdkTexture. APIs that are accepting or returning GdkPixbufs are being replaced by equivalent
APIs using GdkTexture or GdkPaintable objects.
GTK is moving away from `GdkPixbuf` as the primary API for transporting image data, in favor
of [class@Gdk.Texture]. APIs that are accepting or returning `GdkPixbuf`s are being replaced by equivalent
APIs using `GdkTexture` or [iface@Gdk.Paintable] objects.

View File

@@ -1,13 +1,15 @@
# The Node file format
Title: The Node file format
GSK render nodes can be serialized and deserialized using APIs such as `gsk_render_node_serialize()` and `gsk_render_node_deserialize()`. The intended use for this is development - primarily the development of GTK - by allowing things such as creating testsuites and benchmarks, exchanging nodes in bug reports. GTK includes the `gtk4-node-editor` application for creating such test files.
The format is a text format that follows the [CSS syntax rules](https://drafts.csswg.org/css-syntax-3/). In particular, this means that every array of bytes will produce a render node when parsed, as there is a defined error recovery method. For more details on error handling, please refer to the documentation of the parsing APIs.
The grammar of a node text representation using [the CSS value definition syntax](https://drafts.csswg.org/css-values-3/#value-defs) looks like this:
**document**: `<node>\*`
**node**: container [ "name" ] { <document> } | `<node-type> [ "name" ] { <property>* }` | "name"
**property**: `<property-name>: <node> | <value> ;`
document: <@-rule>*<node>
@-rule: @cicp "name" { <property>* }
node: container [ "name" ] { <document> } | <node-type> [ "name" ] { <property>* } | "name"
property: <property-name>: <node> | <value> ;
Each node has its own `<node-type>` and supports a custom set of properties, each with their own `<property-name>` and syntax. The following paragraphs document each of the nodes and their properties.
@@ -25,6 +27,59 @@ Nodes can be given a name by adding a string after the `<node-type>` in their de
Just like nodes, textures can be referenced by name. When defining a named texture, the name has to be placed in front of the URL.
# Color states
Color states are represented either by an ident (for builtin ones) or a string
(for custom ones):
color-state: <ident> | <string>
Custom color states can be defined at the beginning of the document, with an @cicp rule.
The format for @cicp rules is
@cicp "name" {
...
}
The following properties can be set for custom color states:
| property | syntax | default | printed |
| --------- | ---------------- | -------- | ----------- |
| primaries | `<integer>` | 2 | always |
| transfer | `<integer>` | 2 | always |
| matrix | `<integer>` | 2 | always |
| range | `<range>` | full | non-default |
Note that the primaries, transfer and matrix properties always need
to be specified, since GTK does not allow creating color state objects
with these being set to 2 (== unspecified).
Range can have the following values:
range: narrow | full
# Colors
Colors can be specified with a variation of the modern CSS color syntax:
color(<color-state> <number> <number> <number> ["/" <number>])
The traditional syntax for sRGB colors still works as well:
rgba(<number>, <number>, <number>, <number)
rgb(<number, <number>, <number>)
# Rectangles
Rectangles can be specified just as four integers for x, y, width and height:
rect: <number> <number> <number> <number>
Rounded rectangles use a CSS-like syntax:
rounded-rect: <rect> [ "/" <number>{1,4} [ "/" <number>{1,4} ] ]
# Nodes
### container
@@ -41,6 +96,13 @@ The **container** node is a special node that allows specifying a list of child
Creates a node like `gsk_blend_node_new()` with the given properties.
Possible values for the mode property are:
blend-mode: normal | multiply | screen | overlay | darken |
lighten | color-dodge | color-burn | hard-light |
soft-light | difference | exclusion | color |
hue | saturation | luminosity
### blur
| property | syntax | default | printed |
@@ -119,15 +181,21 @@ matrix3d() production to specify all 16 values individually.
### conic-gradient
| property | syntax | default | printed |
| -------- | ---------------- | ---------------------- | ----------- |
| bounds | `<rect>` | 50 | always |
| center | `<point>` | 25, 25 | always |
| rotation | `<number>` | 0 | always |
| stops | `<color-stop>` | 0 #AF0, 1 #F0C | always |
| property | syntax | default | printed |
| ----------------- | --------------- | -------------- | ----------- |
| bounds | `<rect>` | 50 | always |
| center | `<point>` | 25, 25 | always |
| rotation | `<number>` | 0 | always |
| stops | `<color-stop>` | 0 #AF0, 1 #F0C | always |
| interpolation | `<color-state>` | srgb | non-default |
| hue-interpolation | `<hue-interp>` | shorter | non-default |
Creates a node like `gsk_conic_gradient_node_new()` with the given properties.
Possible values for the hue-interpolation property are:
hue-interpolation: shorter | longer | increasing | decreasing
### cross-fade
| property | syntax | default | printed |
@@ -160,6 +228,10 @@ 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.
Possible values for the fill-rule property are:
fill-rule: winding | even-odd
### glshader
| property | syntax | default | printed |
@@ -192,12 +264,14 @@ Creates a node like `gsk_inset_shadow_node_new()` with the given properties.
### linear-gradient
| property | syntax | default | printed |
| -------- | ---------------- | ---------------------- | ----------- |
| bounds | `<rect>` | 50 | always |
| start | `<point>` | 0 0 | always |
| end | `<point>` | 0 50 | always |
| stops | `<color-stop>` | 0 #AF0, 1 #F0C | always |
| property | syntax | default | printed |
| ----------------- | --------------- | -------------- | ----------- |
| bounds | `<rect>` | 50 | always |
| start | `<point>` | 0 0 | always |
| end | `<point>` | 0 50 | always |
| stops | `<color-stop>` | 0 #AF0, 1 #F0C | always |
| interpolation | `<color-state>` | srgb | non-default |
| hue-interpolation | `<hue-interp>` | shorter | non-default |
Creates a node like `gsk_linear_gradient_node_new()` with the given properties.
@@ -211,6 +285,10 @@ Creates a node like `gsk_linear_gradient_node_new()` with the given properties.
Creates a node like `gsk_mask_node_new()` with the given properties.
Possible values for the mode property are:
mask-mode: alpha | inverted-alpha | luminance | inverted-luminance
### opacity
| property | syntax | default | printed |
@@ -235,25 +313,27 @@ Creates a node like `gsk_outset_shadow_node_new()` with the given properties.
### radial-gradient
| property | syntax | default | printed |
| -------- | ---------------- | ---------------------- | ----------- |
| bounds | `<rect>` | 50 | always |
| center | `<point>` | 25 25 | always |
| hradius | `<number>` | 25 | always |
| vradius | `<number>` | 25 | always |
| start | `<number>` | 0 | always |
| end | `<number>` | 1 | always |
| stops | `<color-stop>` | 0 #AF0, 1 #F0C | always |
| property | syntax | default | printed |
| ----------------- | --------------- | -------------- | ----------- |
| bounds | `<rect>` | 50 | always |
| center | `<point>` | 25 25 | always |
| hradius | `<number>` | 25 | always |
| vradius | `<number>` | 25 | always |
| start | `<number>` | 0 | always |
| end | `<number>` | 1 | always |
| stops | `<color-stop>` | 0 #AF0, 1 #F0C | always |
| interpolation | `<color-state>` | srgb | non-default |
| hue-interpolation | `<hue-interp>` | shorter | non-default |
Creates a node like `gsk_radial_gradient_node_new()` with the given properties.
### repeat
| property | syntax | default | printed |
| ----------- | ---------------- | ---------------------- | ----------- |
| bounds | `<rect>` | *bounds of child node* | non-default |
| child | `<node>` | color { } | always |
| child-bounds| `<rect>` | *bounds of child node* | non-default |
| property | syntax | default | printed |
| ------------ | ---------- | ---------------------- | ----------- |
| bounds | `<rect>` | *bounds of child node* | non-default |
| child | `<node>` | color { } | always |
| child-bounds | `<rect>` | *bounds of child node* | non-default |
Creates a node like `gsk_repeat_node_new()` with the given properties.
@@ -320,6 +400,14 @@ 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.
Possible values for the line-cap property are:
line-cap: butt | round | square
Possible values for the line-join property are:
line-join: miter | round | bevel
### text
| property | syntax | default | printed |
@@ -328,9 +416,9 @@ stroke bounds of the path.
| font | `<string>` `<url>`? | "Cantarell 15px" | always |
| glyphs | `<glyphs>` | "Hello" | always |
| offset | `<point>` | 0 0 | non-default |
| hint-style | `<hint style>` | slight | non-default |
| hint-style | `<hint-style>` | slight | non-default |
| antialias | `<antialias>` | gray | non-default |
| hint-metrics | `<hint metrics>` | off | non-default |
| hint-metrics | `<hint-metrics>` | off | non-default |
Creates a node like `gsk_text_node_new()` with the given properties.
@@ -345,9 +433,17 @@ be specified as well, like this: 40 10 0 0 color.
If the given font does not exist or the given glyphs are invalid for the given
font, an error node will be returned.
Possible values for hint-style are none, slight or full.
Possible value for antialias are none or gray.
Possible value for hint-metrics are on or off.
Possible values for the hint-style property are:
hint-style: none | slight | full
Possible value for the antialias property are:
antialias: none | gray
Possible value for hint-metrics are:
hint-metrics: on | off
### texture
@@ -373,14 +469,15 @@ representation for this texture is `url("data:image/png;base64,iVBORw0KGgoAAAANS
| -------- | ---------------- | ---------------------- | ----------- |
| bounds | `<rect>` | 50 | always |
| texture | `<url>` | *see below* | always |
| filter | `filter` | *see below* | non-default |
| filter | `filter` | linear | non-default |
Creates a node like `gsk_texture_scale_node_new()` with the given properties.
The default texture is a 10x10 checkerboard, just like for texture.
The possible filter values are `linear`, `nearest` and `trilinear`, with
`linear` being the default.
Possible values for the filter property are:
filter: linear | nearest | trilinear
### transform

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