Compare commits

...

453 Commits

Author SHA1 Message Date
Matthias Clasen
f05eac610a Merge branch 'places_view_button_labels' into 'main'
gtkplacesview: Add some missing button tooltips

See merge request GNOME/gtk!7927
2024-11-15 15:51:38 +00:00
Sveinn í Felli
4e8eeba5bb Update Icelandic translation
(cherry picked from commit d07a62a940)
2024-11-15 15:25:16 +00:00
Lukáš Tyrychtr
6da8fcf5d9 gtkplacesview: Add some missing button tooltips
The remove server button and the server list one had only icons,
so fix it by adding tooltips to them.
2024-11-15 15:27:04 +01:00
Matthias Clasen
a34e95bc39 Merge branch 'for-main' into 'main'
surface: Add debug spew for color states

See merge request GNOME/gtk!7924
2024-11-14 23:04:07 +00:00
Matthias Clasen
ed2716f9ce inspector: Put surfaces and renderers in the tree
These are otherwise really hard to navigate to, and we already
have plenty of non-widget objects in the tree.
2024-11-14 16:58:44 -05:00
Matthias Clasen
841bd9c5c2 inspector: Avoid a critical 2024-11-14 16:09:45 -05:00
Matthias Clasen
b0344e1fd8 surface: Add debug spew for color states
Log the preferred color state events we get.
2024-11-14 15:33:35 -05:00
Matthias Clasen
77e340f23d Merge branch 'for-main' into 'main'
text: Try harder not to select inserted Emoji

See merge request GNOME/gtk!7921
2024-11-14 16:14:19 +00:00
Matthias Clasen
1d1ef311e3 text: Try harder not to select inserted Emoji
We had code trying to handle the case of focus coming from a
child, but it is running too late to be effective. Instead,
keep a flag that tells us if the Emoji picker is still open.
2024-11-14 10:49:42 -05:00
Sveinn í Felli
1ce19d3c77 Update Icelandic translation
(cherry picked from commit b3e794e4f5)
2024-11-13 16:05:16 +00:00
Sveinn í Felli
3e6e8e6dd5 Update Icelandic translation
(cherry picked from commit 482c55550c)
2024-11-13 16:01:01 +00:00
Matthias Clasen
78738fac3b Merge branch 'cm/fix-goptioncontext-leak' into 'main'
updateiconcache: Fix GOptionContext leak in main

See merge request GNOME/gtk!7918
2024-11-13 13:37:34 +00:00
correctmost
549f537445 updateiconcache: Fix GOptionContext leak in main 2024-11-12 21:16:18 -05:00
Matthias Clasen
e37d15f75c Merge branch 'vulkan-prepare' into 'main'
Drop vulkan refcounting

See merge request GNOME/gtk!7916
2024-11-12 22:56:40 +00:00
Matthias Clasen
ae180f85ca gsk: Move the platform check up
In some cases, we can know that we're not going to use Vulkan
without initializing it. Handle those before calling
gdk_display_prepare_vulkan.
2024-11-12 16:53:15 -05:00
Matthias Clasen
58036ece96 Drop vulkan refcounting
Change things to have a gdk_display_prepare_vulkan call which sets
up Vulkan support for the display. The Vulkan resources will be
dropped when the display is disposed. This matches what we do
for GL, and seems better than a refcounting approach where everybody
leaks the references.

Fixes: #7150
2024-11-12 16:53:15 -05:00
Matthias Clasen
9d8679e211 Merge branch 'wip/chergert/drop-g_debug-newline' into 'main'
gdk/wayland: remove trailing \n from g_debug()

See merge request GNOME/gtk!7913
2024-11-11 20:55:22 +00:00
Christian Hergert
bdb4d28acb gdk/wayland: remove trailing \n from g_debug()
Log messages do not need newlines.
2024-11-11 11:38:06 -08:00
Милош Поповић
11b28c24c2 Update Serbian (Latin) translation
(cherry picked from commit 60fec7db51)
2024-11-11 13:15:47 +00:00
Милош Поповић
aadf18579a Update Serbian translation
(cherry picked from commit 3c56a2915c)
2024-11-11 13:14:08 +00:00
Matthias Clasen
29fd4ee16e Merge branch 'for-main' into 'main'
rendernodeparser: Use advance width for glyphs

See merge request GNOME/gtk!7896
2024-11-10 02:11:32 +00:00
Matthias Clasen
d3b22413ec Merge branch 'font-chooser-default-width' into 'main'
fontchooser: Don't make default size translatable

See merge request GNOME/gtk!7905
2024-11-08 00:20:29 +00:00
Matthias Clasen
cb0c4d6e88 rendernodeparser: Use advance width for glyphs
Commit f5159e1ecb introduced more flexible ways of specifying
glyph strings in node files, but it used ink rect width instead
of the more appropriate advance width when reconstrucing the
glyph string.

Fix expected output of one test to match.
2024-11-07 15:46:09 -05:00
Matthias Clasen
331c6c130f fontchooser: Don't make default size translatable
That was a copy/paste error in 2ad2bae1ca.

Thanks to Anders Jonsson for spotting it.
2024-11-07 15:27:36 -05:00
Марко Костић
89d17ec86e Update Serbian translation
(cherry picked from commit 46d268cd47)
2024-11-07 18:03:38 +00:00
Matthias Clasen
0878727ce4 Merge branch 'ci-vs2019' into 'main'
CI: Use Visual Studio 2019 instead of 2017

See merge request GNOME/gtk!7904
2024-11-07 11:09:59 +00:00
Chun-wei Fan
36f5cbeb57 CI: Use Visual Studio 2019 instead of 2017
Visual Studio 2019 brings C11 support and is actually needed (or best
suited at least) if we are:

* Building with debugging code enabled (/Zc:preprocessor is required)
* Introspection works better on Visual Studio 2019 or later, also due to
  the preprocessor improvements.
* Pulling in bleeding edge Cairo (and possibly soon, GLib) already
  requires C11 support.
2024-11-07 17:29:22 +08:00
Matthias Clasen
4a0323d46d Post-release version bump 2024-11-06 21:23:45 -05:00
Matthias Clasen
a4ee14d94f 4.17.0 2024-11-06 20:44:02 -05:00
Chun-wei Fan
be70ff1772 Merge branch 'lb90/for-main' into 'main'
For main

Closes #7075

See merge request GNOME/gtk!7898
2024-11-06 09:39:15 +00:00
Matthias Clasen
d4afacc217 Merge branch 'ci-meson-junit' into 'main'
ci: Try to use llvm-symbolizer

See merge request GNOME/gtk!7900
2024-11-05 20:23:18 +00:00
Matthias Clasen
ed6f2a9693 Merge branch 'fix-demo-expander' into 'main'
demo: Fix "Expander" demonstration

See merge request GNOME/gtk!7887
2024-11-05 18:37:11 +00:00
Matthias Clasen
fc22b0862c Merge branch 'macos-modifier-keys' into 'main'
gtktext/gtktextview: Use correct modifier keys for macOS shortcuts

See merge request GNOME/gtk!7837
2024-11-05 18:34:18 +00:00
Matthias Clasen
6a02caf216 Merge branch 'fix-demo-dnd' into 'main'
demo: Fix drag and drop demo critical

See merge request GNOME/gtk!7892
2024-11-05 18:32:43 +00:00
Matthias Clasen
8802af1868 Merge branch 'appstream_xmlns' into 'main'
demos: Add xmlns to appstream metainfo files

See merge request GNOME/gtk!7894
2024-11-05 18:32:13 +00:00
Matthias Clasen
6f59f1f5a4 ci: Use meson junit output
Just use the junit xml that is produced by meson, it works now.
2024-11-05 13:18:36 -05:00
Matthias Clasen
af87994115 ci: Try to use llvm-symbolizer
It might help get some stacktraces out of crashes in asan.
2024-11-05 13:18:36 -05:00
Matthias Clasen
059b7d516e Merge branch 'fix-7141' into 'main'
application: NULL-check appid before using it

Closes #7141

See merge request GNOME/gtk!7899
2024-11-05 16:34:59 +00:00
Matthijs Velsink
a6ef6835ad application: NULL-check appid before using it
Fixes commit 3274a286cc.

Closes #7141
2024-11-05 15:08:28 +01:00
Benjamin Otte
14a19b423e Merge branch 'wip/otte/win32-fixes' into 'main'
various fixes

See merge request GNOME/gtk!7895
2024-11-05 13:01:56 +00:00
Luca Bacci
12b0613b34 GdkWin32: Pass the right arguments when calling modal_timer_proc directly
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/7075
2024-11-05 11:16:08 +01:00
Benjamin Otte
b8d24d0259 win32: Require Windows 10
All versions older than Windows 10 are out of support and no longer
receive updates, so we do not want to support them.

We also want to move towards APIs that requires Windows 10 - like
Direct3D 12 - and not having them optional simplifies our code.

See the discussion in !7895 for more details.
2024-11-05 02:45:37 +01:00
Benjamin Otte
01453c733c testsuite: Rename "diff" test to "not-diff"
3 things you need to know about this change:

1. We use diff(1) in various tests to check generated text against
   reference output
2. Windows locates executables not just in $PATH, it also looks in
   $cwd and the directory of the current process' binary
3. Multiple tests live together in the same directory

Windows is fun.
2024-11-05 02:45:37 +01:00
Benjamin Otte
3d578e8db5 win32: Use gdk_win32_com_clear() where appropriate 2024-11-05 02:45:37 +01:00
Benjamin Otte
2ed6867084 win32: Define COBJMACROS via project argument
We use it everywhere, so it makes sense to enable it everywhere.

For anyone not in the know, defining COBJMACROS makes Micrsoft headers
for COM objects provide C macros so that instead of having to call
  foo->lpVtbl->Release();
to unref a COM object, one can call
  IFoo_Release (foo);

Note that thes macros are implemented with inheritance as Release()
is defined on the IUnknown base interface (MS' equivalent to GObject)
and would otherwise require
  IUnknown_Release ((IUnknown *) foo);
That line works, too - but it is not necessary.
2024-11-05 02:45:37 +01:00
Benjamin Otte
ef839e6505 win32: Add gdk_win32_com_clear()
Like g_clear_object(), but for COM objects.
2024-11-05 02:45:37 +01:00
Benjamin Otte
2a7beb75e8 testsuite: Make offload test do actual diffs
We have a testutils.c version for that.
2024-11-05 02:45:37 +01:00
Benjamin Otte
bfbc3e7484 testsuite: Clarify error
200% is not a fractional scale, but it's still forbidden.
2024-11-05 02:45:37 +01:00
Benjamin Otte
2e8fac7789 testsuite: Make nodeparser use shared diffing code
We have a testutils.c version, use that one.
2024-11-05 01:07:22 +01:00
Benjamin Otte
dd93aa9f50 testsuite: Rewrite diff_with_file()
use the modern version using GSubprocess that already exists in
node-parser.

Also change from one function to two - so tests can diff GBytes and
strings, depending on which they prefer.
2024-11-05 01:07:22 +01:00
Benjamin Otte
6cd98bae3b testsuite: Add --strip-trailing-cr to diff call
On Windows, git defaults to maintaining line endings, which means it
changed \n to \r\n on all files it identifies as text. And that includes
our test output.

Luckily diff(1) has an option to undo that. And since we do not care
about line endings in those tests, we can just use it.
2024-11-04 22:02:28 +01:00
Benjamin Otte
0a6c4711bc gstreamer: Fix small memleak 2024-11-04 21:50:26 +01:00
Benjamin Otte
7085a58f01 gstreamer: Identify GL memory by looking at the memory
Instead of looking at availability of a GL context, check the
memory's type.

That's what we do everywhere else and GL is not special.
2024-11-04 21:50:26 +01:00
Benjamin Otte
8b1dff5b94 gstsink: Do not advertise dmabufs with no formats
We return an empty format list when dmabufs aren't supported, not NULL.

And the sink was treating the empty format list by setting no fourccs
on the caps, which GStreamer conveniently interpreted as "any",
not as "none".
2024-11-04 21:50:26 +01:00
Benjamin Otte
566c484317 cicpparams: Guard with BEGIN/END_DECLS
I want to include this header from DirectX C++ code.
2024-11-04 21:50:26 +01:00
Benjamin Otte
5822989e82 gdk: Add missing G_END_DECLS 2024-11-04 21:50:26 +01:00
Benjamin Otte
70c327993b win32: Remove unused macro 2024-11-04 21:50:26 +01:00
Benjamin Otte
e9c9d1d0a0 filechooser: Use g_clear_object() on potentially NULL objects
We can reach here in early exit paths when the shortcut_files have not
been initialized yet.
2024-11-04 21:50:26 +01:00
Martin
f71de6f646 Update Slovenian translation 2024-11-04 17:38:49 +00:00
Luca Bacci
7d45beb830 Gdk: Remove unused files 2024-11-04 10:13:53 +01:00
Luca Bacci
e75308ad11 GdkWin32: Rework display's beep vfunc to only use MessageBeep
Beep is synchronous, let's just move away from it.

Also add an explicit cast for signed to unsigned conversion.
2024-11-04 10:11:33 +01:00
Luca Bacci
ccecf5916f GdkWin32: Stub out the display's flush and sync vfuncs
There's nothing relevant to do
2024-11-04 10:05:45 +01:00
Luca Bacci
ddc9a6b597 Tools: exit with code 0 when showing --help output
This is in line with what most tools do when printing --help
(and GOptionContext alike)
2024-11-04 09:49:17 +01:00
Matthias Clasen
ea08d92bc2 Merge branch 'fontchooser-min-size' into 'main'
fontchooser: Make it more shrinkable

See merge request GNOME/gtk!7897
2024-11-04 02:54:08 +00:00
Matthias Clasen
2ad2bae1ca fontchooser: Make it more shrinkable
There were several places where unnecessarily big minimum sizes
were hardcoded. Instead, set a reasonable default size for the
dialog and the let window shrink further.

Helps for mobile situations.

Related: #7133
2024-11-03 20:57:13 -05:00
Emmanuele Bassi
08eab87c42 Merge branch 'meson_schema_install_tag' into 'main'
meson: set install_tag for schema files

See merge request GNOME/gtk!7893
2024-11-02 21:24:18 +00:00
Florian "sp1rit"​
036364f4d4 demos: Add xmlns to appstream metainfo files
Pixiewood expects well-formed XML files, whose tags match the AppStream
namespace. Note that AppStream itself does not do this, so picking a
prefix for the namespace is fine for pixiewood but not AppStream.
2024-11-02 20:43:54 +01:00
Florian "sp1rit"​
a048ca444c meson: set install_tag for schema files
To limit the amount of files installed by meson install, users can
specify specific classes of files they actually want to install.

Most to be installed files are automatically tagged by meson correctly
based on what function produced them, but it can't for some (esp. those
installed using install_data/subdir).

As gschema files *should typically* be available at runtime, give them
the "runtime" tag.

See https://mesonbuild.com/Installing.html#installation-tags
2024-11-02 20:32:34 +01:00
Florian "sp1rit"​
4b619930f2 demo: Fix drag and drop demo critical
Right now, child is NULL when starting a drag in the main area and
moving the pointer onto the colors, there releasing it.
To avoid gtk_widget_get_ancestor thowing a critical, early exit if child
is NULL.
2024-11-02 19:25:01 +01:00
Matthias Clasen
64dda64819 Merge branch 'fix-bt709-oetf' into 'main'
gsk: Fix wrong bt709_oetf

See merge request GNOME/gtk!7886
2024-11-01 00:27:59 +00:00
Benjamin Otte
7edb4ecddf Merge branch 'wip/otte/textbuffer-test-win32' into 'main'
win32: Fix textbuffer test

See merge request GNOME/gtk!7873
2024-10-31 16:19:05 +00:00
Matthias Clasen
9f714a9d0a Merge branch 'for-main' into 'main'
Bump the gdk-pixbuf subproject

See merge request GNOME/gtk!7888
2024-10-31 15:00:28 +00:00
Benjamin Otte
13aa4f5fe8 win32: Don't return existing display from gdk_display_open()
Existing code assumes displays are new connections and calls
gdk_display_close() on the display when done with whatever it was
doing.

If we return an existing display, that display gets closed...

It's also what the other backends do, including MacOS.

Fixes gsk/misc test.
2024-10-31 15:27:43 +01:00
Benjamin Otte
06d61c5d39 win32: Stop sending clipboard_hwnd to main thread
With the switch to using the glib main context in the clipboard thread,
the clipboard hwnd is no longer used for sending messages.

This means it's not necessary to know it in the main thread.

And that means there's no small window where the clipboard thread spins
up and the window doesn't exist and any copy operation fails.
The main context can be created before spinning up the thread so
that is avoided.

Fixes the gtk/textbuffer test in the testsuite.
2024-10-31 15:27:43 +01:00
Benjamin Otte
4b4e7276f6 win32: Do async clipboard thread via main loop
Instead of sending windows messages, use the main loop.
This is closer to the expectations of GTK developers and has better
thread safety handling as no HWND is needed as a messaging queue token.
2024-10-31 15:27:43 +01:00
Benjamin Otte
a4323259e5 win32: Split out a function 2024-10-31 15:27:43 +01:00
Benjamin Otte
ae5f581e47 win32: Remove useless code
The function is checking and early-exiting in this situation anyway.
2024-10-31 15:27:43 +01:00
Benjamin Otte
17f391b4e7 win32: "unpop" items from clipboard queue
We can indeed "unpop" items from the clipboard queue, the function is
called g_async_queue_push_front().

So do that instead of tracking a GList.
2024-10-31 15:27:43 +01:00
Benjamin Otte
a7670bfcc5 gdk: Add GDK_DISABLE=aerosnap
Disables the Aerosnap hook for Windows which is particularly useful
when debugging because the aerosnap hook slows down keyboard input.
2024-10-31 15:27:43 +01:00
Benjamin Otte
4b32ac3341 win32: Use the builder argument
We can straight build content formats these days, no need for a detour.
2024-10-31 15:27:43 +01:00
Benjamin Otte
6af853c7a0 win32: Some trivial cleanups
* Make a function static

* Don't lookup function that exists since Windows XP
2024-10-31 15:27:43 +01:00
Benjamin Otte
741b369b2a win32: Remove unused variable
The variable was last used in GTK3.
2024-10-31 15:27:42 +01:00
Benjamin Otte
0b62165bf2 clipboard: Run a GMainLoop in the clipboard thread
Use the new message source to do the task of processing messages.
2024-10-31 15:27:42 +01:00
Benjamin Otte
517ec1112c win32: Add GdkWin32MessageSource
The source does nothing but run PeekMessage() + DispatchMessage().
But we need it in every thread where we want to use a main loop.

No users yet.
2024-10-31 15:27:42 +01:00
Benjamin Otte
8767283722 win32: Don't crash if the settings are empty 2024-10-31 15:27:42 +01:00
Matthias Clasen
033b4c5aa2 build: Tweak gdk-pixbuf subproject
Use builtin loaders by default, so we don't make everybody figure
out how to make gdk-pixbuf find uninstalled loaders.
2024-10-31 09:52:03 -04:00
Matthias Clasen
1e55013228 Bump the gdk-pixbuf subproject
Use the latest release, 2.42.12.
2024-10-31 07:28:51 -04:00
Florian "sp1rit"​
56f0735e2b demo: Fix "Expander" demonstration
The expander window is not a dialog anymore, so attempting connecting to
its "response" is invalid and throws a critical:
  signal 'response' is invalid for instance '<PTR>' of type 'GtkWindow'
2024-10-31 08:59:49 +01:00
Matthias Clasen
ac37d66bd5 Merge branch 'wip/alice/default-icon' into 'main'
application: Set default window icon to appid by default

Closes #7120

See merge request GNOME/gtk!7885
2024-10-31 00:46:01 +00:00
Matthijs Velsink
b9f83265b6 gsk: Fix wrong bt709_oetf
And use the format from `gdkcolordefs.h` for good measure.
2024-10-30 23:41:47 +01:00
Aurimas Černius
dee4182dc9 Update Lithuanian translation
(cherry picked from commit d09597af8c)
2024-10-30 20:22:20 +00:00
Alice Mikhaylenko
3274a286cc application: Set default window icon to appid by default
Lots of newer apps that use their appid as their icon name don't set
window icons, since they aren't used in GNOME. Instead of setting it
manually in every app, just default to it.

Only set the icon if it exists in the icon theme.

Remove manually set default icons in the demo.

No tests as GtkApplication doesn't have any in the first place.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/7120
2024-10-30 23:39:23 +04:00
Benjamin Otte
20b50c80d3 Merge branch 'for-main' into 'main'
docs: Fix a few copy-paste errors

See merge request GNOME/gtk!7884
2024-10-30 14:39:35 +00:00
Benjamin Otte
8b9ab19f15 docs: Fix various issues in texture builder docs 2024-10-30 09:37:06 -04:00
Matthias Clasen
926e969abb docs: Fix a few copy-paste errors 2024-10-30 09:18:17 -04:00
Matthias Clasen
c8cc8c4842 Merge branch 'amolenaar/color-picker-min-version' into 'main'
macos: Check for minimal macOS SDK version (>= 10.15)

See merge request GNOME/gtk!7881
2024-10-30 11:26:35 +00:00
Arjan Molenaar
0b9d1fc27c meson: Cleanup darwin system check
'ios' is not a meson host manchine system type.
2024-10-30 11:26:00 +01:00
Arjan Molenaar
5b78ee2227 macos: Remove obsolete version check blocks.
All code works on macOS 10.15+.
2024-10-30 11:04:15 +01:00
Arjan Molenaar
64dd9b4bdd macos: use SDK 10.15.6 for macos/intel testing 2024-10-30 10:45:56 +01:00
Arjan Molenaar
6fc6de6123 List available SDKs 2024-10-30 10:39:19 +01:00
Arjan Molenaar
f9cc88aece macos: Assert minmal macOS SDK version in meson file 2024-10-30 10:16:28 +01:00
Matthias Clasen
eea3e8f395 Merge branch 'wip/chergert/quanitize-textview' into 'main'
GtkTextView: allow scrolling in quantized device pixels

See merge request GNOME/gtk!7853
2024-10-30 00:22:20 +00:00
Christian Hergert
462920ea21 gtk/textview: quanitize X/Y by device pixels
This attempts to improve the somewhat "erratic" feeling of scrolling a
GtkTextView with fractional scaling. However, it also improves the
situation where you have a natural integer scaling factor such as 2x.

To do so, it quantizes the X/Y origin of the visible rect to something that
naturally alignes with device pixels. By doing so this aims to get
consistent pixel alignment when hinting so that you no longer see jumps
as the Y position of the buffer changes. X is also done for symmetry.

The buffer itself is left in integer coordinates to avoid any sort
of ABI breakage with existing applications. Only the origin x/y of the
drawing area is affected and thus should only affect the ABI of
gtk_text_view_get_visible_rect() by < 1 device pixel.

Applications which require precision in the visible rect origin may use
the new API introduced here as gtk_text_view_get_visible_offset(). This
provides the X,Y point as doubles. graphene_point_t was not used here
beacuse that appeared to cause aliasing due to float usage.

GNOME/GtkSourceView!375 provides an example of consuming this new API to
keep line numbers aligned in the same fashion as the textview contents.
2024-10-29 14:46:21 -07:00
Emmanuele Bassi
b9fa5abff0 Merge branch 'fix_6663' into 'main'
a11y: When setting the selected state for list items, don't try to be smart and let the a11y layer handle deduplication.

Closes #6663

See merge request GNOME/gtk!7258
2024-10-29 10:51:46 +00:00
Benjamin Otte
9890e0d6db Merge branch 'wip/corey/print-crash' into 'main'
printunixdialog: Set selection after list view item created

Closes #7109

See merge request GNOME/gtk!7880
2024-10-29 10:12:22 +00:00
Emmanuele Bassi
dbf34f1dd8 Merge branch 'active_state_for_all' into 'main'
gtkatspicontext: Allow all widgets to have the active platform state

See merge request GNOME/gtk!7765
2024-10-29 09:41:56 +00:00
Corey Berla
9e1016a581 printunixdialog: Set selection after list view item created
Commit b807b84e16 ("print dialog: Fix initial selection") made a
change where we connect to items-changed before the list item manager.
That leads to us attempting to set a selection for a tile that does
not yet exist.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/7109
2024-10-28 22:25:37 -07:00
Matthias Clasen
3c68746f41 Merge branch 'for-main' into 'main'
Tweak init requirement for displays

See merge request GNOME/gtk!7879
2024-10-29 04:15:05 +00:00
Matthias Clasen
64d56746e8 Tweak init requirement for displays
gdk_display_get_default is nullable, so it is less painful
and more practical to simply return NULL if GDK hasn't been
initialized yet.
2024-10-28 23:45:55 -04:00
Matthias Clasen
6722e3307e Merge branch 'textbuffer-clipboard-charset' into 'main'
textbuffer: Handle charsets in serialization

Closes #7123

See merge request GNOME/gtk!7878
2024-10-29 01:22:02 +00:00
Matthias Clasen
d6d600cac4 textbuffer: Handle charsets in serialization
Offer and accept text/plain and other charset variations.

Fixes: #7123
2024-10-28 20:39:19 -04:00
Benjamin Otte
1449e11033 Merge branch 'wip/otte/win32-fixes' into 'main'
testsuite/win32: Various fixes

See merge request GNOME/gtk!7877
2024-10-29 00:26:58 +00:00
Benjamin Otte
d2930695ca testsuite: Allow renderers in misc test to fail
When GL or Vulkan is not supported, the test should not fail.

It would be nicer if we could detect GL/Vulkan not being available
otherwise, but I'm not aware of a better solution, in particular because
rendeers might have stricter requirements than GTK itself.

So this is the next best fix.
2024-10-29 00:46:54 +01:00
Benjamin Otte
1b33e2c3b2 Revert "testsuite: Fix introspection test on Windows"
This change is no longer necessary now that we properly set the right
directory for the needed DLLs.

This reverts commit 3471c22f52.
2024-10-29 00:46:54 +01:00
Benjamin Otte
dfb075699c testsuite: Set $PATH for introspection tests
This is necessary because Windows uses $PATH to search for DLLs and
meson isn't smart enough to figure out that this test needs access
to the DLL.
2024-10-29 00:46:54 +01:00
Benjamin Otte
3ca5a75ab0 testsuite: depend on gir and libgtk in introspection test
We also don't need to LD_PRELOAD anymore if we do that.
2024-10-29 00:46:54 +01:00
Benjamin Otte
7d87118151 testsuite: Handle gdk_display_open() returning NULL
It turns out the Windows backend does that.
2024-10-29 00:46:54 +01:00
Benjamin Otte
f4bcb80ab8 Merge branch 'wip/otte/most-important-source-ever' into 'main'
Rework the Wayland source again

Closes #7091

See merge request GNOME/gtk!7865
2024-10-28 21:54:26 +00:00
Benjamin Otte
239f45ce8e wayland: Split event source into two
We need to guarantee that we call wayland_display_read_events() after a
poll() and before any other source runs, including any source with
higher priority.

As GSourceFuncs doesn't have a after_poll() vfunc and check() is not
guaranteed to be called for anything but the highest priority, we only
have once chance:
Run with the highest priority

But because we don't want event delivery with ultrahigh priority, we
split the source into two:
 * a poll source that polls while blocking wayland reading and
   then immediately calls read_events() with priority G_MININT
 * our old trusty event source with PRIORITY_EVENTS that dispatches
   events

Fixes !7859
Fixes #7091
2024-10-28 13:34:09 +01:00
Matthias Clasen
e37f9ba213 Merge branch 'demo-inscriptions' into 'main'
demo: Use GtkInscription more

See merge request GNOME/gtk!7874
2024-10-26 19:55:56 +00:00
Matthias Clasen
277f445970 Merge branch 'css-classes-notify' into 'main'
css: Avoid redundant change notification

Closes #7111

See merge request GNOME/gtk!7871
2024-10-26 02:23:17 +00:00
Matthias Clasen
4bf6668906 demo: Use GtkInscription more
Port the columnview Unicode demo to GtkInscription.
2024-10-25 22:14:45 -04:00
Matthias Clasen
abfad75182 css: Avoid redundant change notification
When adding or removing css class doesn't change anything, we
should not notify the css-classes property. This is more efficient
and avoids some suboptimal behavior in the inspector.

Fixes: #7111
2024-10-25 21:43:55 -04:00
Matthias Clasen
23d855d799 Merge branch 'for-main' into 'main'
docs: Drop mention of X from general docs

See merge request GNOME/gtk!7868
2024-10-25 21:02:31 +00:00
Matthias Clasen
9d94ecad64 Merge branch 'application-display' into 'main'
application: Don't use a display needlessly

Closes #7119

See merge request GNOME/gtk!7870
2024-10-25 21:02:12 +00:00
Matthias Clasen
332abfb011 application: Don't use a display needlessly
We are potentially before gtk_init, so we can't get a default display.
Thankfully, we don't need it anyway.

Fixes: #7119
2024-10-25 15:59:28 -04:00
Emmanuele Bassi
5a2d55c4d3 docs: Add some markup
Use <kbd> for keys, to improve the consistency of our docs.
2024-10-25 16:49:58 +00:00
Matthias Clasen
c1e5609565 docs: Drop mention of X from general docs
Our docs should not allude to specifics of X11, unless they are
about the X11 backend.
2024-10-25 12:45:33 -04:00
Matthias Clasen
3885f75bc6 Merge branch 'application-portal-use' into 'main'
application: Respect GDK_DEBUG=no-portals

Closes #7116

See merge request GNOME/gtk!7867
2024-10-25 16:40:40 +00:00
Martin
1a068bf76b Update Slovenian translation 2024-10-25 16:20:18 +00:00
Matthias Clasen
f14c05dbb0 application: Respect GDK_DEBUG=no-portals
If that debug flag is set, don't activate portals by talking to
the Inhibit portal.

Fixes: #7116
2024-10-25 11:23:03 -04:00
Matthias Clasen
aef6b1b932 Merge branch 'inspector/extensions' into 'main'
inspector: List all extensions

See merge request GNOME/gtk!7866
2024-10-25 11:40:12 +00:00
Matthias Clasen
508d91d182 inspector: Show GL and Vulkan features
This information can to some degree inform about the extensions
that GTK is using.
2024-10-24 23:18:42 -04:00
Matthias Clasen
06ef33271f gdk: Export feature keys privately
Export these. They will be used in the inspector in later commits.
2024-10-24 23:04:37 -04:00
Matthias Clasen
58ef21514e inspector: Make GL and Vulkan more similar
When Vulkan initialization fails, show the error message, as we
do for GL. Also reorder items to be in similar order, and tweak
labels.
2024-10-24 23:04:08 -04:00
Matthias Clasen
d40be28ff4 inspector: List all Vulkan extensions and layers
Same as for GL.
2024-10-24 22:20:26 -04:00
Matthias Clasen
9adc09bc0b inspector: Make extensions non-activatable
There's nothing to activate here.
2024-10-24 22:20:26 -04:00
Matthias Clasen
78262ecd51 inspector: Cosmetics 2024-10-24 22:20:26 -04:00
Benjamin Otte
6723fe0d5c inspector: Add search for extensions
My Windows AMD driver has 295 GL extensions...
2024-10-24 22:19:58 -04:00
Benjamin Otte
9c564eb893 inspector: Sort extensions list
Mesa sorts its extensions, but not every GL driver does. So now we do.
2024-10-24 22:19:58 -04:00
Benjamin Otte
155db90f20 inspector: List all GL extensions
Instead of checking availability of a few hardcoded extensions, print a
full list of extensions.

It's a bit awkward to find the ones the GTK cares about, but it allows
quickly checking any extension that might be needed for new features or
in applications or GStreamer.

This overlaps somewhat with tools like eglinfo, but eglinfo prints all
combinations of X11/Wayland and GL/GLES so it's easy to get confused,
while this one prints the actual extensions of the device in use.
2024-10-24 22:19:58 -04:00
Matthias Clasen
bee6e3acc5 Merge branch 'android_misc' into 'main'
Non directly android-backend related changes for the android backend

See merge request GNOME/gtk!7817
2024-10-25 00:05:24 +00:00
Benjamin Otte
21afd2bf77 Merge branch 'wip/otte/for-main' into 'main'
gdk: Remove unused display vfunc

See merge request GNOME/gtk!7864
2024-10-24 17:24:24 +00:00
Віктар Гаўрылавец
71d4b9893b Update Belarusian translation
(cherry picked from commit cc92230f56)
2024-10-24 16:41:31 +00:00
Benjamin Otte
4eba4ad640 wayland: Move all GSource handling into gdkeventsource.c 2024-10-24 17:29:33 +02:00
Benjamin Otte
0722ede806 wayland: Remove unused variable 2024-10-24 17:29:33 +02:00
Benjamin Otte
6b0e1ed7dc wayland: Rename source functions
It's a GdkWaylandEventSource, name the function accordingly.
2024-10-24 17:29:33 +02:00
Benjamin Otte
8454ec7181 Revert "wayland: Don't block the event queue"
This reverts commit a9723fc96b.

This approach was wrong as it can lead to deadlocks when multiple
threads call poll() at almost the same time and the slower thread only
starts poll()ing when the faster thread has already read the fd.

See further comments for a (hopefully) correct fix.

Reverts !7859
2024-10-24 17:29:33 +02:00
Benjamin Otte
4dec70e1a6 gdk: Remove unused display vfunc
But it's nice that everyone still implements it.
2024-10-24 17:24:43 +02:00
Matthias Clasen
71b065cf07 Merge branch 'bugfix/compile-32-bit' into 'main'
gdk/loaders/gdkjpeg.c: fix compilation on 32-bit systems

See merge request GNOME/gtk!7721
2024-10-24 03:04:18 +00:00
Matthias Clasen
97554c1211 Merge branch 'main' into 'main'
Fix typo in NEWS

See merge request GNOME/gtk!7863
2024-10-23 23:54:14 +00:00
Urtsi Santsi
be50be64ce Fix typo in NEWS 2024-10-23 19:32:21 +00:00
Matthias Clasen
f7dddcb258 Merge branch 'wip/chergert/for-main' into 'main'
NEWS: add recent changes to GtkTextView

See merge request GNOME/gtk!7862
2024-10-23 19:07:42 +00:00
Christian Hergert
3bf1603fae NEWS: add recent changes to GtkTextView 2024-10-23 11:04:20 -07:00
Matthias Clasen
5bf78e047d NEWS: Updates 2024-10-22 23:49:33 -04:00
Matthias Clasen
b1a82942ee Merge branch 'wip/otte/block-the-clock' into 'main'
wayland: Don't block the event queue

Closes #7091

See merge request GNOME/gtk!7859
2024-10-23 03:06:42 +00:00
Matthias Clasen
da9657245d Merge branch 'wip/chergert/fix-7108' into 'main'
gtk/textlayout: remove one_style_cache

Closes #7108

See merge request GNOME/gtk!7860
2024-10-23 01:58:06 +00:00
Christian Hergert
92715975da gtk/textlayout: remove one_style_cache
When porting textlayout to GTK 4 a line display cache was introduced. That
cache creates a situation where you may not create GtkTextLineDisplay in
order from GtkTextLineSegment.

Because of that, we must start the creation of each line display from
fresh line state or we could re-apply the GtkTextAppearance of another
row. However, once you do that, one_style_cache will never have a match
and therefore is pure overhead.

This removes one_style_cache altogether.

Fixes: #7108
2024-10-22 17:53:18 -07:00
Benjamin Otte
a9723fc96b wayland: Don't block the event queue
The Wayland source was blocking the Wayland display queue between its
check() and prepare() callbacks.

This is a rare event to cause problems because it requires
1. Another source with
2. a higher priority that
3. triggers at the same time as the Wayland source and
4. triggers a roundtrip or other operation that requires reading events
   from the display.

Introduced in commit 2893526a48 during GTK 3.21, so this should
probably be fixed in GTK3, too.

Fixes #7091
2024-10-22 23:38:13 +02:00
Matthias Clasen
1731530189 Merge branch 'wip/chergert/overshoot_width' into 'main'
kineticscrolling: use overshoot_width in calculation

See merge request GNOME/gtk!7851
2024-10-22 17:47:28 +00:00
Christian Hergert
8d537a943f gtk/kineticscrolling: use overshoot_width in calculation
We create the GtkKineticScrolling with the known overshoot_width but then
fail to use it (and instead a hardcoded value) during tick calculation.

This fixes that, which will also be necessary if we enable scrolled
overshooting.
2024-10-22 10:16:50 -07:00
Thomas Devoogdt
45680ffc8f gdk/loaders/gdkjpeg.c: fix compilation on 32-bit systems
../gdk/loaders/gdkjpeg.c: In function ‘gdk_save_jpeg’:
../gdk/loaders/gdkjpeg.c:291:32: error: passing argument 3 of ‘jpeg_mem_dest’ from incompatible pointer type [-Wincompatible-pointer-types]
  291 |   jpeg_mem_dest (&info, &data, &size);
      |                                ^~~~~
      |                                |
      |                                gulong * {aka long unsigned int *}
In file included from ../gdk/loaders/gdkjpeg.c:30:
/home/thomas/br-test-pkg/bootlin-armv7-glibc/host/arm-buildroot-linux-gnueabihf/sysroot/usr/include/jpeglib.h:979:28: note: expected ‘size_t *’ {aka ‘unsigned int *’} but argument is of type ‘gulong *’ {aka ‘long unsigned int *’}

See multiple versions:

https://www.ijg.org/files/jpegsrc.v9c.tar.gz
- #define JPEG_LIB_VERSION        90	/* Compatibility version 9.0 */
- #define JPEG_LIB_VERSION_MAJOR  9
- #define JPEG_LIB_VERSION_MINOR  3
- EXTERN(void) jpeg_mem_dest JPP((j_compress_ptr cinfo,
			       unsigned char ** outbuffer,
			       unsigned long * outsize));

https://www.ijg.org/files/jpegsrc.v9d.tar.gz
- #define JPEG_LIB_VERSION        90	/* Compatibility version 9.0 */
- #define JPEG_LIB_VERSION_MAJOR  9
- #define JPEG_LIB_VERSION_MINOR  4
- EXTERN(void) jpeg_mem_dest JPP((j_compress_ptr cinfo,
			       unsigned char ** outbuffer,
			       size_t * outsize));

https://github.com/libjpeg-turbo/libjpeg-turbo/blob/3.0.4/jpeglib.h
https://github.com/libjpeg-turbo/libjpeg-turbo/blob/3.0.4/jconfig.h.in
- #define LIBJPEG_TURBO_VERSION  @VERSION@
- EXTERN(void) jpeg_mem_dest(j_compress_ptr cinfo, unsigned char **outbuffer,
                           unsigned long *outsize);

The jpegsrc changed the method signature with the v9d release,
libjpeg-turbo did not changed it's signature (yet).

Signed-off-by: Thomas Devoogdt <thomas@devoogdt.com>
2024-10-22 17:16:35 +02:00
Emmanuele Bassi
f5413c5226 Merge branch 'ebassi/issue-7106' into 'main'
docs: Fix typo in Gdk.ContentProvider.new_union

Closes #7106

See merge request GNOME/gtk!7857
2024-10-22 14:05:01 +00:00
Emmanuele Bassi
3fac7762d7 docs: Fix typo in Gdk.ContentProvider.new_union
It's GDK_TYPE_TEXTURE, not G_TYPE_TEXTURE.

Fixes: #7106
2024-10-22 14:04:01 +01:00
Matthias Clasen
f0a7a003e7 Merge branch 'gtk-init-fixes' into 'main'
gtk4-demo: Call gtk_init in main

See merge request GNOME/gtk!7854
2024-10-22 02:28:04 +00:00
Matthias Clasen
111230f5f9 bloatpad: Call gtk_init in main
We end up using a display via gtk_application_set_accels_for_action,
and that can't happen before gtk_init anymore.
2024-10-21 21:17:00 -04:00
Matthias Clasen
c09a51628b gtk4-demo: Call gtk_init in main
We end up using a display via gtk_application_set_accels_for_action,
and that can't happen before gtk_init anymore.
2024-10-21 21:17:00 -04:00
Matthias Clasen
96f8eb9c98 Merge branch 'wip/chergert/kinetic-frame-time' into 'main'
kineticscrolling: use computed frame times

See merge request GNOME/gtk!7842
2024-10-22 00:20:41 +00:00
Christian Hergert
c9facb5554 kineticscrolling: use computed frame times
Instead of accumulating a series of doubles, use the actual computed frame
time for duration tracking. While there is extremely low chance of
aliasing with animations under a few seconds, this just ensures we're
using the same clocking inside and outside of GtkKineticScrolling.
2024-10-21 16:15:26 -07:00
Matthias Clasen
a1d9b3e47d Merge branch 'display-init' into 'main'
gdk: No displays before init

See merge request GNOME/gtk!7836
2024-10-21 22:53:50 +00:00
Matthias Clasen
758e9787d4 Merge branch 'icon-lookup-none' into 'main'
icontheme: Add GTK_ICON_LOOKUP_NONE

See merge request GNOME/gtk!7852
2024-10-21 22:01:39 +00:00
Benjamin Otte
a84cbe22d1 Merge branch 'wip/otte/win32-fixes' into 'main'
win32: Various fixes

See merge request GNOME/gtk!7848
2024-10-21 21:39:30 +00:00
Matthias Clasen
d6f93a3213 docs: Beef up docs for gtk_init
Mention explictly that this opens the default display.
2024-10-21 17:24:53 -04:00
Maximiliano Sandoval
169795a374 icontheme: Add GTK_ICON_LOOKUP_NONE
From bindings it is not clear that one can pass `0` as a value.
2024-10-21 23:00:26 +02:00
Benjamin Otte
62b1ef9f72 CI: Enable -Werror in MSVC build 2024-10-21 20:18:46 +02:00
Benjamin Otte
e6cfc5e3cd CI: Add pcre2 to disabled werrors 2024-10-21 20:18:46 +02:00
Benjamin Otte
07a5f75fe4 gpu: Make definition match declaration 2024-10-21 20:18:46 +02:00
Matthias Clasen
1f20d0c9ed 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 13:30:19 -04:00
Matthias Clasen
c239788a34 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 13:30:19 -04:00
Matthias Clasen
51f3f6f8d1 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 13:30:19 -04:00
Matthias Clasen
84779ccdbc tests: Cosmetics
Our test setups aready enforce GSETTINGS_BACKEND=memory, don't set
it again in code.
2024-10-21 13:30:19 -04:00
Matthias Clasen
acd00ceb4d tests: Fix the displaymanager tests
Don't open a display without gtk_init().
2024-10-21 13:30:19 -04:00
Daniel Șerbănescu
015665ca9f Update Romanian translation
(cherry picked from commit b0b1d7a928)
2024-10-21 16:55:57 +00: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
Benjamin Otte
7aa8afa9d7 build: Disable MSVC warnings
Those 2 warnings happen with legitimate usage, so we don't want
to see them.
In particular not when using "-Werror" (or the MSVC equivalent "/WX")
2024-10-21 08:59:24 +02:00
Benjamin Otte
a68f1d6155 testsuite: Fix MSVC warnings
ints/longs have a different size to pointers on Windows 64bit.
And casts from int to pointer of diferent size cause a warning.
2024-10-21 07:35:42 +02:00
Benjamin Otte
a74457697e build: Fix MSVC warning due to Pango bug
Pango unconditionally defines STRICT, which we use, see
https://learn.microsoft.com/en-us/windows/win32/winprog/enabling-strict

And that causes a duplicate definition, so we undefined it before
including the offending Pango header.

See also https://gitlab.gnome.org/GNOME/pango/-/merge_requests/749
2024-10-21 07:35:42 +02:00
Benjamin Otte
9a59fce106 treerbtree: Fix MSVC compiler warnings the simplest way
It's deprecated code after all.
2024-10-21 07:35:42 +02:00
Benjamin Otte
ea3aad2848 inspector: Don't shadow connect(2) 2024-10-21 07:35:42 +02:00
Benjamin Otte
4f3ebb9e9f shortcutssection: Fix MSVC warning
... and simplify what's actually going on.

  ABS (n_rows - n) < ABS ((n_rows - height) - (n + height))
Those values are all unsigned, so this is equivalent to
  n_rows - n < (n_rows - height) - (n + height)
The math on the right is confusing but can be rearranged:
  n_rows - n < n_rows - n - 2 * height
With x = n_rows - n, this simplifies to:
  x < x - 2 * height
Which is only true if it underflows, ie if
  x < 2 * height
Resubstituting the old values gives:
  n_rows - n < 2 * height
Which is the value I used.
2024-10-21 07:35:42 +02:00
Benjamin Otte
5a6ea4ac86 timsort: add ELEM_REV()
for reverse-element lookup.

Because our indices are always unsigned, we need to take special care
to not trigger compiler warnings when doing negative array indexing.

And yes, for now "0 - x" is good enough.
2024-10-21 07:35:42 +02:00
Benjamin Otte
516506e1ad inspector: Rename enum
SEVERITY_ERROR is part of Windows COM error handling, see
https://learn.microsoft.com/en-us/windows/win32/com/structure-of-com-error-codes
2024-10-21 07:35:42 +02:00
Benjamin Otte
faae6f4c19 tests: Fix file to be Unicode 2024-10-21 07:35:42 +02:00
Benjamin Otte
4fcdcc2e50 textview: Don't overflow
Both numbers are unsigned, so the result is always unsigned.
(Which also means ABS() doing a < 0 check doesn't work.)
And that in particular means that end - begin overflows to a very
large number when begin > end.
2024-10-21 07:35:42 +02:00
Benjamin Otte
5637b3ba20 gpu: Avoid duplicated name with Windows API
CacheData is an enum value, see
https://learn.microsoft.com/en-us/windows/win32/api/winnt/ne-winnt-processor_cache_type
2024-10-21 07:35:42 +02:00
Benjamin Otte
225acbb12b build: Fix MSVC warning about casting
enums and uints might have a different size, so
pointers to enums and poiters to uints don't match.
2024-10-21 07:35:42 +02:00
Benjamin Otte
9e38c628f2 roundedbox: Fix shadowed name of Windows API
Arc() is a GDI function that draws an arc:
https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-arc
2024-10-21 07:35:42 +02:00
Benjamin Otte
19e1eee05a treeview: Fix MSVC warning
This code was unnecessary.
2024-10-21 07:35:42 +02:00
Benjamin Otte
67a34ac1d2 build: Fix MSVC warning about type mismatch
G_STRUCT_OFFSET() returns a long.
long is a 32bit type on 64bit Windows.
Casting int to pointer of different size causes a warning.
2024-10-21 07:35:42 +02:00
Benjamin Otte
be08be2fa9 renderer: Remove unneeded headers 2024-10-21 07:35:42 +02:00
Benjamin Otte
2646785e4c build: Fix MSVC warning about non-matching types 2024-10-21 07:35:41 +02:00
Benjamin Otte
66e059ae52 build: Fix MSVC warning about function prototypes
We're using custom sorters and those want int as the return value,
not GtkOrdering.
2024-10-21 07:35:41 +02:00
Benjamin Otte
591bc5edc0 build: Work around duplicated define of APIENTRY
epoxy defines it if windows.h hasn't been included.
So include windows.h before epoxy.

See also https://github.com/anholt/libepoxy/issues/299
2024-10-21 07:35:41 +02:00
Benjamin Otte
b5f9d98955 build: Fix MSVC warning
INPUT is a name for a Windows type, see
https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-input
2024-10-21 05:25:25 +02:00
Benjamin Otte
fdb4469234 testsuite: Don't use random numbers in test output
glibc prints the value as 0.096203, msvcrt prints 0.0962031.
And I don't think any spec defines which way things need to be rounded.
2024-10-20 23:53:04 +02:00
Benjamin Otte
01c754f93b testsuite: Windows separators are different
On top of that we defined a preprocessor constant to 2 different
values, but instead of checking the value, we only checked if
it was defined. Now we only define it in one place.
2024-10-20 23:53:04 +02:00
Benjamin Otte
3694aed022 build: Use sources argument
Being more explicit is better.
2024-10-20 23:53:04 +02:00
Benjamin Otte
a891c90798 win32: Use right name for GIO_USE_VOLUME_MONITOR in CI 2024-10-20 23:53:04 +02:00
Benjamin Otte
5d01fe96c6 testsuite: Create timezone without guessing names
Guessing names is not portable, in particular not to Windows.

See also commit 4881ef2.
2024-10-20 23:53:04 +02:00
Benjamin Otte
6ef3fc2dbb testsuite: Hey, everyone has an NGL renderer, right?
No.

This fix is not that much better, but I'm too tired to fix stuff
like this properly.

And the Cairo renderer did at least work everywhere during 4.x
2024-10-20 23:53:04 +02:00
Benjamin Otte
3a7f242e08 testsuite: MIME types aren't CONTENT types
Somebody came up with the great idea of content types, which
are just like mime types, only that they aren't on Windows.

So if we want a working testsuite that actually works on Windows,
we cannot mix them up.
2024-10-20 23:53:04 +02:00
Mat
07a44ffa0f gtklabel: Use correct modifier keys for macOS shortcuts 2024-10-20 22:21:59 +03: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
f907d8a17a win32: Don't crash when threads start too slow
Passing on-stack items to a thread in a function that exits right
after spawning the threads is a bad idea:
By the time the thread starts up and reads the values, the stack might
be in use for other stuff.

So instead of putting the items on the stack, just read them out of the
clipdrop struct.
2024-10-19 22:33:54 +02:00
Benjamin Otte
35c0068345 rendernodeparser: Implement font loading on Windows 2024-10-19 22:33:54 +02:00
Benjamin Otte
5e9e8a6f5d testsuite: Canonicalize filenames
It looks weird on Windows if half the paths use \ and the other
half use /
2024-10-19 20:22:03 +02:00
Benjamin Otte
fddd5f33ab win32: Avoid g_warning() when layout doesn't exist
If the registry key doesn't exist, it doesn't warrant a warning.

We hit that case in CI and it aborts every test during startup.
2024-10-19 20:22:03 +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
Mat
4865af6b6c gtktext/gtktextview: Use correct modifier keys for macOS shortcuts
The shortcuts for moving the insertion point to the beginning and
end should use the Command modifier, not Option.
2024-10-16 00:22:13 +03: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
Florian "sp1rit"​
cbbf741f4b inspector: fix incorrect usage of g_flags_get_first_value
g_flags_get_first_value gets the value for the first bit set in the
bitflags passed to it. It expects a bitflag passed to it, but previously
add_tool iterated from GDK_AXIS_X up to GDK_AXIS_LAST and passed i into
get_first_value. This is obviously incorrect, as i isn't a bitflag
array.

While it could have been fixed by simply passing (1 << i) into
get_first_value, the new implementation is better, as we only iterate as
many times as necessary over axes instead of GDK_AXIS_LAST times.
2024-10-10 14:30:17 +02:00
Florian "sp1rit"​
067688684f gdk: Have Surface.check_autohide also check touch events 2024-10-10 14:30:17 +02:00
Florian "sp1rit"​
347f5fdda4 gtk: Fixed memory leak in Gtk.TextHandle
gdk_surface_set_input_region does not take ownership of the region
passed into it, so we'll need to free it afterward.
2024-10-10 14:30:14 +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
Lukáš Tyrychtr
02b520ad5d gtkatspicontext: Allow all widgets to have the active platform state
Previously, we reported it only for applications, but we need it
definitely at least for windows for Orca to report new windows ,
so, to not introduce another role hacks in the backend, allow the state for
everything, it should not be set anywhere we don't way anyway.

The issue where this turned out to be an issue: orca#537
2024-09-30 10:58:00 +02: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
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
Lukáš Tyrychtr
a03963ad72 a11y: When setting the selected state for list items, don't try to be smart
and let the a11y layer handle deduplication.

When done on the widget layer, initially unselected items never got their a11y
state set, so they did not receive the selectable state on the ATSPI2 layer.

Fixes #6663.
2024-05-16 14:45:32 +02:00
393 changed files with 44472 additions and 20502 deletions

2
.gitignore vendored
View File

@@ -1,2 +1,4 @@
/subprojects/*/
.flatpak-builder/
.vscode/
subprojects/*.wrap

View File

@@ -22,7 +22,7 @@ stages:
# Common variables
variables:
COMMON_MESON_FLAGS: "-Dwerror=true -Dcairo:werror=false -Dgi-docgen:werror=false -Dgraphene:werror=false -Dlibepoxy:werror=false -Dlibsass:werror=false -Dpango:werror=false -Dsassc:werror=false -Dgdk-pixbuf:werror=false -Dglib:werror=false -Dlibcloudproviders:werror=false -Dlibpng:werror=false -Dlibtiff:werror=false -Dsysprof:werror=false -Dwayland-protocols:werror=false -Dharfbuzz:werror=false -Dfreetype2:werror=false -Dfontconfig:werror=false -Dfribidi:werror=false -Dlibffi:werror=false -Dlibjpeg-turbo:werror=false -Dmutest:werror=false -Dpixman:werror=false -Dproxy-libintl:werror=false"
COMMON_MESON_FLAGS: "-Dwerror=true -Dcairo:werror=false -Dgi-docgen:werror=false -Dgraphene:werror=false -Dlibepoxy:werror=false -Dlibsass:werror=false -Dpango:werror=false -Dsassc:werror=false -Dgdk-pixbuf:werror=false -Dglib:werror=false -Dlibcloudproviders:werror=false -Dlibpng:werror=false -Dlibtiff:werror=false -Dsysprof:werror=false -Dwayland-protocols:werror=false -Dharfbuzz:werror=false -Dfreetype2:werror=false -Dfontconfig:werror=false -Dfribidi:werror=false -Dlibffi:werror=false -Dlibjpeg-turbo:werror=false -Dmutest:werror=false -Dpcre2:werror=false -Dpixman:werror=false -Dproxy-libintl:werror=false"
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
@@ -62,18 +62,16 @@ style-check-diff:
.build-fedora-default:
image: $FEDORA_IMAGE
artifacts:
name: "gtk-${CI_COMMIT_REF_NAME}"
when: always
reports:
junit:
- "${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-broadway.xml"
name: "gtk-${CI_COMMIT_REF_NAME}"
- "${CI_PROJECT_DIR}/_build/meson-logs/testlog-x11.junit.xml"
- "${CI_PROJECT_DIR}/_build/meson-logs/testlog-wayland.junit.xml"
- "${CI_PROJECT_DIR}/_build/meson-logs/testlog-wayland_gl.junit.xml"
- "${CI_PROJECT_DIR}/_build/meson-logs/testlog-broadway.junit.xml"
paths:
- "${CI_PROJECT_DIR}/_build/meson-logs"
- "${CI_PROJECT_DIR}/_build/report*.xml"
- "${CI_PROJECT_DIR}/_build/report*.html"
- "${CI_PROJECT_DIR}/_build/testsuite/reftests/output/*/*.png"
- "${CI_PROJECT_DIR}/_build/testsuite/reftests/output/*/*.node"
- "${CI_PROJECT_DIR}/_build/testsuite/tools/output/*/*"
@@ -118,8 +116,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
@@ -197,11 +196,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
@@ -217,7 +216,7 @@ macos:
when: never
- if: $RUNNER == "macosintel"
variables:
SDKROOT: /opt/sdks/MacOSX10.13.4.sdk
SDKROOT: /opt/sdks/MacOSX10.15.6.sdk
NINJA_PKG: $CI_API_V4_URL/projects/30745/packages/generic/ninja_macos/v1.11.1.1+9/ninja-1.11.1.1-cp38-cp38-macosx_11_0_x86_64.whl
when: manual
allow_failure: true
@@ -241,6 +240,7 @@ macos:
PIPENV_CACHE_DIR: $PIP_CACHE_DIR
PYTHONPYCACHEPREFIX: $PIP_CACHE_DIR
before_script:
- ls /opt/sdks/
- .gitlab-ci/show-info-macos.sh
- python3 -m venv .venv
# Building the introspection feature requires pkg-config and bison.
@@ -264,7 +264,7 @@ macos:
paths:
- "${CI_PROJECT_DIR}/_build/meson-logs"
vs2017-x64:
vs2019-x64:
# TODO: Uncomment this when ready to merge.
# rules:
# - if: $CI_PROJECT_NAMESPACE == "GNOME"
@@ -273,7 +273,7 @@ vs2017-x64:
- win32-ps
needs: []
script:
- .gitlab-ci/test-msvc.bat
- .gitlab-ci/test-msvc.bat ${COMMON_MESON_FLAGS}
artifacts:
when: always
paths:
@@ -326,20 +326,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: []
@@ -373,14 +359,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']

View File

View File

@@ -11,7 +11,9 @@ 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 LSAN_OPTIONS=suppressions=$srcdir/lsan.supp:print_suppressions=0:detect_leaks=0:allocator_may_return_null=1:symbolize=1
export ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer
case "${setup}" in
x11*)
@@ -93,13 +95,6 @@ esac
cd ${builddir}
$srcdir/.gitlab-ci/meson-junit-report.py \
--project-name=gtk \
--backend="${setup}" \
--job-id="${CI_JOB_NAME}" \
--output="report-${setup}.xml" \
"meson-logs/testlog-${setup}.json"
$srcdir/.gitlab-ci/meson-html-report.py \
--project-name=gtk \
--backend="${setup}" \

View File

@@ -1,12 +1,11 @@
@echo on
:: vcvarsall.bat sets various env vars like PATH, INCLUDE, LIB, LIBPATH for the
:: specified build architecture
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x64
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x64
@echo on
:: FIXME: make warnings fatal
pip3 install --upgrade --user meson~=0.64 || goto :error
meson setup -Dbackend_max_links=1 -Ddebug=false -Dmedia-gstreamer=disabled -Dvulkan=disabled _build || goto :error
pip3 install --upgrade --user meson~=1.2 || goto :error
meson setup -Dbackend_max_links=1 -Ddebug=false -Dmedia-gstreamer=disabled -Dvulkan=disabled %~1 _build || goto :error
ninja -C _build || goto :error
goto :EOF

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)"

113
NEWS
View File

@@ -1,6 +1,117 @@
Overview of Changes in 4.17.0, xx-xx-xxxx
Overview of Changes in 4.17.1, xx-xx-xxxx
=========================================
Overview of Changes in 4.17.0, 06-11-2024
=========================================
* GtkScrolledWindow
- Fix criticals in size allocation code
* GtkFileChooser
- Fix a crash in the portal code
* GtkFontChoser
- Make the dialog more shrinkable
* GtkPicture
- Avoid unnecessary resizes
* GtkVideo
- Make dmabufs work without GL
* GtkListBox:
- Add a tab-behavior property to influence keynav
* GtkEmojiChooser:
- Fix problems with insertion and selection
* GtkStringList:
- Add gtk_string_list_find
* GtkApplication:
- Respect GDK_DEBUG=no-portals
- Set default window icon from app ID
* GtkTextView:
- Vertical and horizontal positioning of the textview is now quantized
to the nearest device pixel. This should improve the perceived smoothness
of scrolling with fractional scaling and font hinting.
- Incorrect re-use of cached styling was fixed
- Fix some missing CSS invalidation
- Handle charsets in clipboard datatypes
* Printing:
- Avoid warnings for avahi errors
- Fix a segfault in the print dialog setup code
* Accessibility:
- Always realize non-widget accessibles, to help webkit
- Fix list view selection implementation
- Handle NULL values in more places
* Gstreamer:
- Make dmabufs works without GL
* Gdk:
- Add OKLAB and OKLCH color states
- GL: Drop support for GLES 2 and GL < 3.3
- GL: Use the ngl dmabuf downloader instead of the GL downloader
- Vulkan: Drop the GDK_VULKAN_DEVICE env var. Use MESA_VK_DEVICE_SELECT instead
- Vulkan: Use the swapchain maintenance extension to release swap images
- Forbid opening displays before gtk_init()
* Gsk:
- Many improvements to the dmabuf downloaders
- ngl: Avoid glBufferSubData for globals, speeding up llvmpipe
- Renderer selection will no longer consider the GL renderer
- Allow Vulkan software rendering as fallback
- Support gradient interpolation in different color states
* Wayland:
- Improve settings portal handling
- Improve fallback for cursor themes
- Make cursor theme changes apply immediately
- Use a viewporter for cursor image scaling
- Improve cursor size handling
- Use the system bell protocol if available
- Fix possible deadlock with high-priority sources triggering roundtrips
* Windows:
- Improve the backend code
- Fix some problems with WGL on NVidia
- Many testsuite fixes for Windows compatibility
- Make all pixbuf loaders builtin in the gdk-pixbuf subproject
- Add GDK_DISABLE=aerosnap to disable aerosnap
- Improve clipboard handling
- Fix behavior or gdk_display_open() on Windows
- Numerous papercut fixes
- Require Windows 10
* Macos:
- Fix crashes when dragging libadwaita TabView tabs
- Require macOS 10.15
* Tools and demos
- gtk4-demo: Make demos standalone
- gtk4-demo: Drop GL shader demos
- gtk4-demo: Improve scrolling benchmarks
- gtk4-builder-tool: Improve separator handling
- gtk4-image-tool: Better color state support
* Build:
- Don't set GSK_RENDERER in our flatpaks
- Require meson 1.2
* Translation updates
Belarusian
Brazilian Portuguese
British English
Galician
Lithuanian
Romanian
Slovenian
Swedish
Overview of Changes in 4.16.2, 09-25-2024
=========================================

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,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
*/
#pragma once
#include <gtk/gtk.h>
#define CONSTRAINT_EDITOR_APPLICATION_TYPE (constraint_editor_application_get_type ())
G_DECLARE_FINAL_TYPE (ConstraintEditorApplication, constraint_editor_application, CONSTRAINT, EDITOR_APPLICATION, GtkApplication)
ConstraintEditorApplication *constraint_editor_application_new (void);

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>
@@ -457,6 +441,7 @@
<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

@@ -579,6 +579,8 @@ released_cb (GtkGesture *gesture,
widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture));
child = gtk_widget_pick (widget, x, y, 0);
if (!child)
return;
item = (CanvasItem *)gtk_widget_get_ancestor (child, canvas_item_get_type ());
if (!item)
return;

View File

@@ -12,11 +12,13 @@
static GtkWidget *window = NULL;
static void
response_cb (GtkDialog *dialog, int response_id)
static gboolean
close_request_cb (GtkWidget *win, gpointer user_data)
{
gtk_window_destroy (GTK_WINDOW (window));
g_assert (window == win);
gtk_window_destroy ((GtkWindow *)window);
window = NULL;
return TRUE;
}
static void
@@ -117,7 +119,7 @@ do_expander (GtkWidget *do_widget)
g_signal_connect (expander, "notify::expanded",
G_CALLBACK (expander_cb), window);
g_signal_connect (window, "response", G_CALLBACK (response_cb), NULL);
g_signal_connect (window, "close-request", G_CALLBACK (close_request_cb), NULL);
}
if (!gtk_widget_get_visible (window))

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

@@ -811,7 +811,7 @@ tag_pair_equal (gconstpointer a, gconstpointer b)
}
static GtkOrdering
static int
script_sort (const void *item1,
const void *item2,
void *data)
@@ -1869,4 +1869,4 @@ do_font_features (GtkWidget *do_widget)
return window;
}
/* vim:set foldmethod=marker expandtab: */
/* vim:set foldmethod=marker: */

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

@@ -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

@@ -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

@@ -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);
}

View File

@@ -101,7 +101,7 @@ setup_centered_label (GtkSignalListItemFactory *factory,
GObject *listitem)
{
GtkWidget *label;
label = gtk_label_new ("");
label = gtk_inscription_new ("");
gtk_list_item_set_child (GTK_LIST_ITEM (listitem), label);
}
@@ -110,8 +110,8 @@ setup_label (GtkSignalListItemFactory *factory,
GObject *listitem)
{
GtkWidget *label;
label = gtk_label_new ("");
gtk_label_set_xalign (GTK_LABEL (label), 0);
label = gtk_inscription_new ("");
gtk_inscription_set_xalign (GTK_INSCRIPTION (label), 0);
gtk_list_item_set_child (GTK_LIST_ITEM (listitem), label);
}
@@ -120,10 +120,10 @@ setup_ellipsizing_label (GtkSignalListItemFactory *factory,
GObject *listitem)
{
GtkWidget *label;
label = gtk_label_new ("");
gtk_label_set_xalign (GTK_LABEL (label), 0);
gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
gtk_label_set_width_chars (GTK_LABEL (label), 20);
label = gtk_inscription_new ("");
gtk_inscription_set_xalign (GTK_INSCRIPTION (label), 0);
gtk_inscription_set_text_overflow (GTK_INSCRIPTION (label), GTK_INSCRIPTION_OVERFLOW_ELLIPSIZE_END);
gtk_inscription_set_nat_chars (GTK_INSCRIPTION (label), 20);
gtk_list_item_set_child (GTK_LIST_ITEM (listitem), label);
}
@@ -141,7 +141,7 @@ bind_codepoint (GtkSignalListItemFactory *factory,
codepoint = ucd_item_get_codepoint (UCD_ITEM (item));
g_snprintf (buffer, 10, "%#06x", codepoint);
gtk_label_set_label (GTK_LABEL (label), buffer);
gtk_inscription_set_text (GTK_INSCRIPTION (label), buffer);
}
static void
@@ -160,7 +160,7 @@ bind_char (GtkSignalListItemFactory *factory,
if (g_unichar_isprint (codepoint))
g_unichar_to_utf8 (codepoint, buffer);
gtk_label_set_label (GTK_LABEL (label), buffer);
gtk_inscription_set_text (GTK_INSCRIPTION (label), buffer);
}
static void
@@ -175,7 +175,7 @@ bind_name (GtkSignalListItemFactory *factory,
item = gtk_list_item_get_item (GTK_LIST_ITEM (listitem));
name = ucd_item_get_name (UCD_ITEM (item));
gtk_label_set_label (GTK_LABEL (label), name);
gtk_inscription_set_text (GTK_INSCRIPTION (label), name);
}
static void
@@ -190,7 +190,7 @@ bind_type (GtkSignalListItemFactory *factory,
item = gtk_list_item_get_item (GTK_LIST_ITEM (listitem));
codepoint = ucd_item_get_codepoint (UCD_ITEM (item));
gtk_label_set_label (GTK_LABEL (label), get_unicode_type_name (g_unichar_type (codepoint)));
gtk_inscription_set_text (GTK_INSCRIPTION (label), get_unicode_type_name (g_unichar_type (codepoint)));
}
static void
@@ -205,7 +205,7 @@ bind_break_type (GtkSignalListItemFactory *factory,
item = gtk_list_item_get_item (GTK_LIST_ITEM (listitem));
codepoint = ucd_item_get_codepoint (UCD_ITEM (item));
gtk_label_set_label (GTK_LABEL (label), get_break_type_name (g_unichar_break_type (codepoint)));
gtk_inscription_set_text (GTK_INSCRIPTION (label), get_break_type_name (g_unichar_break_type (codepoint)));
}
static void
@@ -220,7 +220,7 @@ bind_combining_class (GtkSignalListItemFactory *factory,
item = gtk_list_item_get_item (GTK_LIST_ITEM (listitem));
codepoint = ucd_item_get_codepoint (UCD_ITEM (item));
gtk_label_set_label (GTK_LABEL (label), get_combining_class_name (g_unichar_combining_class (codepoint)));
gtk_inscription_set_text (GTK_INSCRIPTION (label), get_combining_class_name (g_unichar_combining_class (codepoint)));
}
static void
@@ -237,7 +237,7 @@ bind_script (GtkSignalListItemFactory *factory,
codepoint = ucd_item_get_codepoint (UCD_ITEM (item));
script = g_unichar_get_script (codepoint);
gtk_label_set_label (GTK_LABEL (label), get_script_name (script));
gtk_inscription_set_text (GTK_INSCRIPTION (label), get_script_name (script));
}
static void
@@ -255,7 +255,7 @@ selection_changed (GObject *object,
if (g_unichar_isprint (codepoint))
g_unichar_to_utf8 (codepoint, buffer);
gtk_label_set_label (GTK_LABEL (label), buffer);
gtk_inscription_set_text (GTK_INSCRIPTION (label), buffer);
}
GtkWidget *

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;
}
@@ -1068,8 +1056,6 @@ 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;
@@ -1158,6 +1144,8 @@ main (int argc, char **argv)
};
int i;
gtk_init ();
app = gtk_application_new ("org.gtk.Demo4", G_APPLICATION_NON_UNIQUE|G_APPLICATION_HANDLES_COMMAND_LINE);
g_action_map_add_action_entries (G_ACTION_MAP (app),

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

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<component xmlns="https://specifications.freedesktop.org/metainfo/1.0" type="desktop">
<id>org.gtk.Demo4</id>
<launchable type="desktop-id">org.gtk.Demo4.desktop</launchable>
<metadata_license>CC0-1.0</metadata_license>

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

@@ -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,160 +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_set_icon_name (GTK_WINDOW (win), "org.gtk.IconBrowser4");
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,8 +223,6 @@ 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);

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<component xmlns="https://specifications.freedesktop.org/metainfo/1.0" type="desktop">
<id>org.gtk.gtk4.NodeEditor</id>
<launchable type="desktop-id">org.gtk.gtk4.NodeEditor.desktop</launchable>
<metadata_license>CC0-1.0</metadata_license>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<component xmlns="https://specifications.freedesktop.org/metainfo/1.0" type="desktop">
<id>org.gtk.PrintEditor4</id>
<launchable type="desktop-id">org.gtk.PrintEditor4.desktop</launchable>
<metadata_license>CC0-1.0</metadata_license>

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,6 @@ 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), "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

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<component xmlns="https://specifications.freedesktop.org/metainfo/1.0" type="desktop">
<id>org.gtk.WidgetFactory4</id>
<launchable type="desktop-id">org.gtk.WidgetFactory4.desktop</launchable>
<metadata_license>CC0-1.0</metadata_license>

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,7 +2232,6 @@ 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

@@ -38,7 +38,7 @@ if get_option('documentation')
gdk_gir[0],
],
depends: gdk_gir[0],
suite: ['docs', 'failing'],
suite: ['docs'],
)
if x11_enabled
@@ -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,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

@@ -98,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

@@ -205,7 +205,8 @@ Other libraries, such as libadwaita, may provide replacements as well.
## gtk_show_uri is being replaced
Instead of `gtk_show_uri()`, you should use [class@Gtk.UriLauncher]or [class@Gtk.FileLauncher].
Instead of `gtk_show_uri()`, you should use [class@Gtk.UriLauncher]
or [class@Gtk.FileLauncher].
## GtkStatusbar is going away

View File

@@ -181,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 |
@@ -258,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.
@@ -305,15 +313,17 @@ 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.

View File

@@ -358,6 +358,9 @@ disable certain features.
`color-mgmt`
: Disable color management
`aerosnap`
: Disable Aerosnap support on Windows
### `GDK_GL_DISABLE`
This variable can be set to a list of values, which cause GDK to
@@ -380,13 +383,6 @@ does not support them.
`base-instance`
:GL_EXT_base_instance
### `GDK_VULKAN_DEVICE`
This variable can be set to the index of a Vulkan device to override
the default selection of the device that is used for Vulkan rendering.
The special value `list` can be used to obtain a list of all Vulkan
devices.
### `GDK_VULKAN_DISABLE`
This variable can be set to a list of values, which cause GDK to
@@ -430,14 +426,8 @@ using and the GDK backend supports them:
`cairo`
: Selects the fallback Cairo renderer
`opengl`
: Selects the default OpenGL renderer
`gl`
: Selects the "gl" OpenGL renderer
`ngl`
: Selects the "ngl" OpenGL renderer
: Selects the OpenGL renderer
`vulkan`
: Selects the Vulkan renderer
@@ -487,6 +477,8 @@ disable certain optimizations of the "ngl" and "vulkan" renderer.
`occlusion`
: Disable occlusion culling via opacity tracking
`repeat`
: Repeat drawing operations instead of using offscreen and GL_REPEAT
The special value `all` can be used to turn on all values. The special
value `help` can be used to obtain a list of all supported values.

View File

@@ -717,6 +717,8 @@ main (int argc, char **argv)
int status;
const char *accels[] = { "F11", NULL };
gtk_init ();
bloat_pad = bloat_pad_new ();
gtk_application_set_accels_for_action (GTK_APPLICATION (bloat_pad),

View File

@@ -257,12 +257,6 @@ gdk_broadway_display_flush (GdkDisplay *display)
_gdk_broadway_server_flush (broadway_display->server);
}
static gboolean
gdk_broadway_display_has_pending (GdkDisplay *display)
{
return FALSE;
}
static void
gdk_broadway_display_dispose (GObject *object)
{
@@ -485,7 +479,6 @@ gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class)
display_class->beep = gdk_broadway_display_beep;
display_class->sync = gdk_broadway_display_sync;
display_class->flush = gdk_broadway_display_flush;
display_class->has_pending = gdk_broadway_display_has_pending;
display_class->queue_events = _gdk_broadway_display_queue_events;
display_class->get_next_serial = gdk_broadway_display_get_next_serial;

View File

@@ -113,6 +113,12 @@ static int gdk_initialized = 0; /* 1 if the library is initi
* 0 otherwise.
*/
gboolean
gdk_is_initialized (void)
{
return gdk_initialized != 0;
}
static const GdkDebugKey gdk_debug_keys[] = {
{ "misc", GDK_DEBUG_MISC, "Miscellaneous information" },
{ "events", GDK_DEBUG_EVENTS, "Information about events" },
@@ -152,6 +158,7 @@ static const GdkDebugKey gdk_feature_keys[] = {
{ "dmabuf", GDK_FEATURE_DMABUF, "Disable dmabuf support" },
{ "offload", GDK_FEATURE_OFFLOAD, "Disable graphics offload" },
{ "color-mgmt", GDK_FEATURE_COLOR_MANAGEMENT, "Disable color management" },
{ "aerosnap", GDK_FEATURE_AEROSNAP, "Disable Aerosnap support on Windows" },
};
@@ -360,13 +367,12 @@ gdk_display_open_default (void)
{
GdkDisplay *display;
g_return_val_if_fail (gdk_initialized, NULL);
gdk_ensure_initialized ();
display = gdk_display_get_default ();
if (display)
return display;
display = gdk_display_open (NULL);
if (!display)
display = gdk_display_open (NULL);
return display;
}

View File

@@ -122,6 +122,18 @@ gdk_cairo_pattern_add_color_stop_rgba_ccs (cairo_pattern_t *pattern,
cairo_pattern_add_color_stop_rgba (pattern, offset, color[0], color[1], color[2], color[3]);
}
static inline void
gdk_cairo_pattern_add_color_stop_color (cairo_pattern_t *pattern,
GdkColorState *ccs,
double offset,
const GdkColor *color)
{
float values[4];
gdk_color_to_float (color, ccs, values);
cairo_pattern_add_color_stop_rgba (pattern, offset, values[0], values[1], values[2], values[3]);
}
static inline void
gdk_cairo_rect (cairo_t *cr,
const graphene_rect_t *rect)

View File

@@ -478,4 +478,4 @@ gdk_cicp_params_get_cicp (GdkCicpParams *self)
/* }}} */
/* vim:set foldmethod=marker expandtab: */
/* vim:set foldmethod=marker: */

View File

@@ -2,6 +2,8 @@
#include "gdkcicpparams.h"
G_BEGIN_DECLS
typedef struct _GdkCicp GdkCicp;
struct _GdkCicp
@@ -82,3 +84,5 @@ gdk_cicp_equivalent (const GdkCicp *p1,
const GdkCicp * gdk_cicp_params_get_cicp (GdkCicpParams *self);
GdkCicpParams * gdk_cicp_params_new_for_cicp (const GdkCicp *cicp);
G_END_DECLS

View File

@@ -233,3 +233,53 @@ static const float srgb_to_rec2020[9] = {
0.069108, 0.919519, 0.011360,
0.016394, 0.088011, 0.895380,
};
/* oklab conversion */
static float
from_oklab_nl (float v)
{
return v * v * v;
}
static float
to_oklab_nl (float v)
{
return cbrtf (v);
}
static const float oklab_to_lms[9] = {
1, 0.3963377774, 0.2158037573,
1, -0.1055613458, -0.0638541728,
1, -0.0894841775, -1.2914855480
};
static const float lms_to_srgb[9] = {
4.0767416621, -3.3077115913, 0.2309699292,
-1.2684380046, 2.6097574011, -0.3413193965,
-0.0041960863, -0.7034186147, 1.7076147010,
};
static const float srgb_to_lms[9] = {
0.4122214708, 0.5363325363, 0.0514459929,
0.2119034982, 0.6806995451, 0.1073969566,
0.0883024619, 0.2817188376, 0.6299787005,
};
static const float lms_to_oklab[9] = {
0.2104542553, 0.7936177850, -0.0040720468,
1.9779984951, -2.4285922050, 0.4505937099,
0.0259040371, 0.7827717662, -0.8086757660,
};
static const float rec2020_to_lms[9] = {
0.616645, 0.360250, 0.023064,
0.265075, 0.635874, 0.099059,
0.100076, 0.203907, 0.696161,
};
static const float lms_to_rec2020[9] = {
2.140325, -1.246734, 0.106491,
-0.884665, 2.163141, -0.278489,
-0.048559, -0.454366, 1.502711,
};

View File

@@ -172,6 +172,41 @@ gdk_color_state_get_rec2100_linear (void)
return GDK_COLOR_STATE_REC2100_LINEAR;
}
/**
* gdk_color_state_get_oklab:
*
* Returns the color state object representing the oklab color space.
*
* This is a perceptually uniform color state.
*
* Returns: the color state object for oklab
*
* Since: 4.18
*/
GdkColorState *
gdk_color_state_get_oklab (void)
{
return GDK_COLOR_STATE_OKLAB;
}
/**
* gdk_color_state_get_oklch:
*
* Returns the color state object representing the oklch color space.
*
* This is the polar variant of oklab, in which the hue is encoded as
* a polar coordinate.
*
* Returns: the color state object for oklch
*
* Since: 4.18
*/
GdkColorState *
gdk_color_state_get_oklch (void)
{
return GDK_COLOR_STATE_OKLCH;
}
/**
* gdk_color_state_equal:
* @self: a `GdkColorState`
@@ -223,56 +258,171 @@ gdk_color_state_create_cicp_params (GdkColorState *self)
/* {{{ Conversion functions */
typedef float (* GdkTransferFunc) (float v);
typedef void (* GdkConvertFunc) (GdkColorState *self,
float values[4]);
typedef const float GdkColorMatrix[9];
#define IDENTITY ((float*)0)
#define NONE ((GdkTransferFunc)0)
#define TRANSFORM(name, eotf, matrix, oetf) \
#define CONVERT_FUNC(name) \
static void \
name (GdkColorState *self, \
float (*values)[4], \
gsize n_values) \
gdk_convert_ ## name (GdkColorState *self, \
float (*values)[4], \
gsize n_values) \
{ \
for (gsize i = 0; i < n_values; i++) \
{ \
if (eotf != NONE) \
{ \
values[i][0] = eotf (values[i][0]); \
values[i][1] = eotf (values[i][1]); \
values[i][2] = eotf (values[i][2]); \
} \
if (matrix != IDENTITY) \
{ \
float res[3]; \
res[0] = matrix[0] * values[i][0] + matrix[1] * values[i][1] + matrix[2] * values[i][2]; \
res[1] = matrix[3] * values[i][0] + matrix[4] * values[i][1] + matrix[5] * values[i][2]; \
res[2] = matrix[6] * values[i][0] + matrix[7] * values[i][1] + matrix[8] * values[i][2]; \
values[i][0] = res[0]; \
values[i][1] = res[1]; \
values[i][2] = res[2]; \
} \
if (oetf != NONE) \
{ \
values[i][0] = oetf (values[i][0]); \
values[i][1] = oetf (values[i][1]); \
values[i][2] = oetf (values[i][2]); \
} \
name (self, values[i]); \
} \
}
TRANSFORM(gdk_default_srgb_to_srgb_linear, srgb_eotf, IDENTITY, NONE);
TRANSFORM(gdk_default_srgb_linear_to_srgb, NONE, IDENTITY, srgb_oetf)
TRANSFORM(gdk_default_rec2100_pq_to_rec2100_linear, pq_eotf, IDENTITY, NONE)
TRANSFORM(gdk_default_rec2100_linear_to_rec2100_pq, NONE, IDENTITY, pq_oetf)
TRANSFORM(gdk_default_srgb_linear_to_rec2100_linear, NONE, srgb_to_rec2020, NONE)
TRANSFORM(gdk_default_rec2100_linear_to_srgb_linear, NONE, rec2020_to_srgb, NONE)
TRANSFORM(gdk_default_srgb_to_rec2100_linear, srgb_eotf, srgb_to_rec2020, NONE)
TRANSFORM(gdk_default_rec2100_pq_to_srgb_linear, pq_eotf, rec2020_to_srgb, NONE)
TRANSFORM(gdk_default_srgb_linear_to_rec2100_pq, NONE, srgb_to_rec2020, pq_oetf)
TRANSFORM(gdk_default_rec2100_linear_to_srgb, NONE, rec2020_to_srgb, srgb_oetf)
TRANSFORM(gdk_default_srgb_to_rec2100_pq, srgb_eotf, srgb_to_rec2020, pq_oetf)
TRANSFORM(gdk_default_rec2100_pq_to_srgb, pq_eotf, rec2020_to_srgb, srgb_oetf)
#define TRANSFORM(name, eotf, matrix, nonlinear, matrix2, oetf) \
static inline void \
name (GdkColorState *self, \
float values[4]) \
{ \
if (eotf != NONE) \
{ \
values[0] = eotf (values[0]); \
values[1] = eotf (values[1]); \
values[2] = eotf (values[2]); \
} \
if (matrix != IDENTITY) \
{ \
float res[3]; \
res[0] = matrix[0] * values[0] + matrix[1] * values[1] + matrix[2] * values[2]; \
res[1] = matrix[3] * values[0] + matrix[4] * values[1] + matrix[5] * values[2]; \
res[2] = matrix[6] * values[0] + matrix[7] * values[1] + matrix[8] * values[2]; \
values[0] = res[0]; \
values[1] = res[1]; \
values[2] = res[2]; \
} \
if (nonlinear != NONE) \
{ \
values[0] = nonlinear (values[0]); \
values[1] = nonlinear (values[1]); \
values[2] = nonlinear (values[2]); \
} \
if (matrix2 != IDENTITY) \
{ \
float res[3]; \
res[0] = matrix2[0] * values[0] + matrix2[1] * values[1] + matrix2[2] * values[2]; \
res[1] = matrix2[3] * values[0] + matrix2[4] * values[1] + matrix2[5] * values[2]; \
res[2] = matrix2[6] * values[0] + matrix2[7] * values[1] + matrix2[8] * values[2]; \
values[0] = res[0]; \
values[1] = res[1]; \
values[2] = res[2]; \
} \
if (oetf != NONE) \
{ \
values[0] = oetf (values[0]); \
values[1] = oetf (values[1]); \
values[2] = oetf (values[2]); \
} \
} \
CONVERT_FUNC (name)
#define TRANSFORM_PAIR(name, func1, func2) \
static inline void \
name (GdkColorState *self, \
float values[4]) \
{ \
func1 (self, values); \
func2 (self, values); \
} \
CONVERT_FUNC (name)
TRANSFORM(srgb_to_srgb_linear, srgb_eotf, IDENTITY, NONE, IDENTITY, NONE)
TRANSFORM(srgb_linear_to_srgb, NONE, IDENTITY, NONE, IDENTITY, srgb_oetf)
TRANSFORM(rec2100_pq_to_rec2100_linear, pq_eotf, IDENTITY, NONE, IDENTITY, NONE)
TRANSFORM(rec2100_linear_to_rec2100_pq, NONE, IDENTITY, NONE, IDENTITY, pq_oetf)
TRANSFORM(srgb_linear_to_rec2100_linear, NONE, srgb_to_rec2020, NONE, IDENTITY, NONE)
TRANSFORM(rec2100_linear_to_srgb_linear, NONE, rec2020_to_srgb, NONE, IDENTITY, NONE)
TRANSFORM(srgb_to_rec2100_linear, srgb_eotf, srgb_to_rec2020, NONE, IDENTITY, NONE)
TRANSFORM(rec2100_pq_to_srgb_linear, pq_eotf, rec2020_to_srgb, NONE, IDENTITY, NONE)
TRANSFORM(srgb_linear_to_rec2100_pq, NONE, srgb_to_rec2020, NONE, IDENTITY, pq_oetf)
TRANSFORM(rec2100_linear_to_srgb, NONE, rec2020_to_srgb, NONE, IDENTITY, srgb_oetf)
TRANSFORM(srgb_to_rec2100_pq, srgb_eotf, srgb_to_rec2020, NONE, IDENTITY, pq_oetf)
TRANSFORM(rec2100_pq_to_srgb, pq_eotf, rec2020_to_srgb, NONE, IDENTITY, srgb_oetf)
TRANSFORM(oklab_to_srgb_linear, NONE, oklab_to_lms, from_oklab_nl, lms_to_srgb, NONE)
TRANSFORM(oklab_to_srgb, NONE, oklab_to_lms, from_oklab_nl, lms_to_srgb, srgb_oetf)
TRANSFORM(oklab_to_rec2100_linear, NONE, oklab_to_lms, from_oklab_nl, lms_to_rec2020, NONE)
TRANSFORM(oklab_to_rec2100_pq, NONE, oklab_to_lms, from_oklab_nl, lms_to_rec2020, pq_oetf)
TRANSFORM(srgb_linear_to_oklab, NONE, srgb_to_lms, to_oklab_nl, lms_to_oklab, NONE)
TRANSFORM(srgb_to_oklab, srgb_eotf, srgb_to_lms, to_oklab_nl, lms_to_oklab, NONE)
TRANSFORM(rec2100_linear_to_oklab, NONE, rec2020_to_lms, to_oklab_nl, lms_to_oklab, NONE)
TRANSFORM(rec2100_pq_to_oklab, pq_eotf, rec2020_to_lms, to_oklab_nl, lms_to_oklab, NONE)
#define DEG_TO_RAD(x) ((x) * G_PI / 180)
#define RAD_TO_DEG(x) ((x) * 180 / G_PI)
static inline void
_sincosf (float angle,
float *out_s,
float *out_c)
{
#ifdef HAVE_SINCOSF
sincosf (angle, out_s, out_c);
#else
*out_s = sinf (angle);
*out_c = cosf (angle);
#endif
}
static void
oklch_to_oklab (GdkColorState *self,
float values[4])
{
float L, C, H, a, b;
L = values[0];
C = values[1];
H = values[2];
_sincosf (DEG_TO_RAD (H), &b, &a);
a *= C;
b *= C;
values[0] = L;
values[1] = a;
values[2] = b;
}
static void
oklab_to_oklch (GdkColorState *self,
float values[4])
{
float L, a, b, C, H;
L = values[0];
a = values[1];
b = values[2];
C = hypotf (a, b);
H = RAD_TO_DEG (atan2 (b, a));
H = fmod (H, 360);
if (H < 0)
H += 360;
values[0] = L;
values[1] = C;
values[2] = H;
}
CONVERT_FUNC (oklch_to_oklab)
CONVERT_FUNC (oklab_to_oklch)
TRANSFORM_PAIR (srgb_to_oklch, srgb_to_oklab, oklab_to_oklch)
TRANSFORM_PAIR (srgb_linear_to_oklch, srgb_linear_to_oklab, oklab_to_oklch)
TRANSFORM_PAIR (rec2100_pq_to_oklch, rec2100_pq_to_oklab, oklab_to_oklch)
TRANSFORM_PAIR (rec2100_linear_to_oklch, rec2100_linear_to_oklab, oklab_to_oklch)
TRANSFORM_PAIR (oklch_to_srgb, oklch_to_oklab, oklab_to_srgb)
TRANSFORM_PAIR (oklch_to_srgb_linear, oklch_to_oklab, oklab_to_srgb_linear)
TRANSFORM_PAIR (oklch_to_rec2100_pq, oklch_to_oklab, oklab_to_rec2100_pq)
TRANSFORM_PAIR (oklch_to_rec2100_linear, oklch_to_oklab, oklab_to_rec2100_pq)
/* }}} */
/* {{{ Default implementation */
@@ -328,6 +478,9 @@ gdk_default_color_state_get_cicp (GdkColorState *color_state)
{
GdkDefaultColorState *self = (GdkDefaultColorState *) color_state;
if (self->cicp.color_primaries == 0)
return NULL;
return &self->cicp;
}
@@ -419,9 +572,11 @@ GdkDefaultColorState gdk_default_color_states[] = {
.name = "srgb",
.no_srgb = GDK_COLOR_STATE_SRGB_LINEAR,
.convert_to = {
[GDK_COLOR_STATE_ID_SRGB_LINEAR] = gdk_default_srgb_to_srgb_linear,
[GDK_COLOR_STATE_ID_REC2100_PQ] = gdk_default_srgb_to_rec2100_pq,
[GDK_COLOR_STATE_ID_REC2100_LINEAR] = gdk_default_srgb_to_rec2100_linear,
[GDK_COLOR_STATE_ID_SRGB_LINEAR] = gdk_convert_srgb_to_srgb_linear,
[GDK_COLOR_STATE_ID_REC2100_PQ] = gdk_convert_srgb_to_rec2100_pq,
[GDK_COLOR_STATE_ID_REC2100_LINEAR] = gdk_convert_srgb_to_rec2100_linear,
[GDK_COLOR_STATE_ID_OKLAB] = gdk_convert_srgb_to_oklab,
[GDK_COLOR_STATE_ID_OKLCH] = gdk_convert_srgb_to_oklch,
},
.clamp = gdk_color_state_clamp_0_1,
.cicp = { 1, 13, 0, 1 },
@@ -437,9 +592,11 @@ GdkDefaultColorState gdk_default_color_states[] = {
.name = "srgb-linear",
.no_srgb = NULL,
.convert_to = {
[GDK_COLOR_STATE_ID_SRGB] = gdk_default_srgb_linear_to_srgb,
[GDK_COLOR_STATE_ID_REC2100_PQ] = gdk_default_srgb_linear_to_rec2100_pq,
[GDK_COLOR_STATE_ID_REC2100_LINEAR] = gdk_default_srgb_linear_to_rec2100_linear,
[GDK_COLOR_STATE_ID_SRGB] = gdk_convert_srgb_linear_to_srgb,
[GDK_COLOR_STATE_ID_REC2100_PQ] = gdk_convert_srgb_linear_to_rec2100_pq,
[GDK_COLOR_STATE_ID_REC2100_LINEAR] = gdk_convert_srgb_linear_to_rec2100_linear,
[GDK_COLOR_STATE_ID_OKLAB] = gdk_convert_srgb_linear_to_oklab,
[GDK_COLOR_STATE_ID_OKLCH] = gdk_convert_srgb_linear_to_oklch,
},
.clamp = gdk_color_state_clamp_0_1,
.cicp = { 1, 8, 0, 1 },
@@ -455,9 +612,11 @@ GdkDefaultColorState gdk_default_color_states[] = {
.name = "rec2100-pq",
.no_srgb = NULL,
.convert_to = {
[GDK_COLOR_STATE_ID_SRGB] = gdk_default_rec2100_pq_to_srgb,
[GDK_COLOR_STATE_ID_SRGB_LINEAR] = gdk_default_rec2100_pq_to_srgb_linear,
[GDK_COLOR_STATE_ID_REC2100_LINEAR] = gdk_default_rec2100_pq_to_rec2100_linear,
[GDK_COLOR_STATE_ID_SRGB] = gdk_convert_rec2100_pq_to_srgb,
[GDK_COLOR_STATE_ID_SRGB_LINEAR] = gdk_convert_rec2100_pq_to_srgb_linear,
[GDK_COLOR_STATE_ID_REC2100_LINEAR] = gdk_convert_rec2100_pq_to_rec2100_linear,
[GDK_COLOR_STATE_ID_OKLAB] = gdk_convert_rec2100_pq_to_oklab,
[GDK_COLOR_STATE_ID_OKLCH] = gdk_convert_rec2100_pq_to_oklch,
},
.clamp = gdk_color_state_clamp_0_1,
.cicp = { 9, 16, 0, 1 },
@@ -473,16 +632,54 @@ GdkDefaultColorState gdk_default_color_states[] = {
.name = "rec2100-linear",
.no_srgb = NULL,
.convert_to = {
[GDK_COLOR_STATE_ID_SRGB] = gdk_default_rec2100_linear_to_srgb,
[GDK_COLOR_STATE_ID_SRGB_LINEAR] = gdk_default_rec2100_linear_to_srgb_linear,
[GDK_COLOR_STATE_ID_REC2100_PQ] = gdk_default_rec2100_linear_to_rec2100_pq,
[GDK_COLOR_STATE_ID_SRGB] = gdk_convert_rec2100_linear_to_srgb,
[GDK_COLOR_STATE_ID_SRGB_LINEAR] = gdk_convert_rec2100_linear_to_srgb_linear,
[GDK_COLOR_STATE_ID_REC2100_PQ] = gdk_convert_rec2100_linear_to_rec2100_pq,
[GDK_COLOR_STATE_ID_OKLAB] = gdk_convert_rec2100_linear_to_oklab,
[GDK_COLOR_STATE_ID_OKLCH] = gdk_convert_rec2100_linear_to_oklch,
},
.clamp = gdk_color_state_clamp_unbounded,
.cicp = { 9, 8, 0, 1 },
},
[GDK_COLOR_STATE_ID_OKLAB] = {
.parent = {
.klass = &GDK_DEFAULT_COLOR_STATE_CLASS,
.ref_count = 0,
.depth = GDK_MEMORY_FLOAT16,
.rendering_color_state = GDK_COLOR_STATE_SRGB,
},
.name = "oklab",
.no_srgb = NULL,
.convert_to = {
[GDK_COLOR_STATE_ID_SRGB] = gdk_convert_oklab_to_srgb,
[GDK_COLOR_STATE_ID_SRGB_LINEAR] = gdk_convert_oklab_to_srgb_linear,
[GDK_COLOR_STATE_ID_REC2100_PQ] = gdk_convert_oklab_to_rec2100_pq,
[GDK_COLOR_STATE_ID_REC2100_LINEAR] = gdk_convert_oklab_to_rec2100_linear,
[GDK_COLOR_STATE_ID_OKLCH] = gdk_convert_oklab_to_oklch,
},
.cicp = { 0, 0, 0, 0 },
},
[GDK_COLOR_STATE_ID_OKLCH] = {
.parent = {
.klass = &GDK_DEFAULT_COLOR_STATE_CLASS,
.ref_count = 0,
.depth = GDK_MEMORY_FLOAT16,
.rendering_color_state = GDK_COLOR_STATE_SRGB,
},
.name = "oklch",
.no_srgb = NULL,
.convert_to = {
[GDK_COLOR_STATE_ID_SRGB] = gdk_convert_oklch_to_srgb,
[GDK_COLOR_STATE_ID_SRGB_LINEAR] = gdk_convert_oklch_to_srgb_linear,
[GDK_COLOR_STATE_ID_REC2100_PQ] = gdk_convert_oklch_to_rec2100_pq,
[GDK_COLOR_STATE_ID_REC2100_LINEAR] = gdk_convert_oklch_to_rec2100_linear,
[GDK_COLOR_STATE_ID_OKLAB] = gdk_convert_oklch_to_oklab,
},
.cicp = { 0, 0, 0, 0 },
},
};
/* }}} */
/* }}} */
/* {{{ Cicp implementation */
typedef struct _GdkCicpColorState GdkCicpColorState;
@@ -509,17 +706,22 @@ struct _GdkCicpColorState
#define cicp ((GdkCicpColorState *)self)
TRANSFORM(gdk_cicp_to_srgb, cicp->eotf, cicp->to_srgb, srgb_oetf)
TRANSFORM(gdk_cicp_to_srgb_linear, cicp->eotf, cicp->to_srgb, NONE)
TRANSFORM(gdk_cicp_to_rec2100_pq, cicp->eotf, cicp->to_rec2020, pq_oetf)
TRANSFORM(gdk_cicp_to_rec2100_linear, cicp->eotf, cicp->to_rec2020, NONE)
TRANSFORM(gdk_cicp_from_srgb, srgb_eotf, cicp->from_srgb, cicp->oetf)
TRANSFORM(gdk_cicp_from_srgb_linear, NONE, cicp->from_srgb, cicp->oetf)
TRANSFORM(gdk_cicp_from_rec2100_pq, pq_eotf, cicp->from_rec2020, cicp->oetf)
TRANSFORM(gdk_cicp_from_rec2100_linear, NONE, cicp->from_rec2020, cicp->oetf)
TRANSFORM(cicp_to_srgb, cicp->eotf, cicp->to_srgb, NONE, IDENTITY, srgb_oetf)
TRANSFORM(cicp_to_srgb_linear, cicp->eotf, cicp->to_srgb, NONE, IDENTITY, NONE)
TRANSFORM(cicp_to_rec2100_pq, cicp->eotf, cicp->to_rec2020, NONE, IDENTITY, pq_oetf)
TRANSFORM(cicp_to_rec2100_linear, cicp->eotf, cicp->to_rec2020, NONE, IDENTITY, NONE)
TRANSFORM(cicp_from_srgb, srgb_eotf, cicp->from_srgb, NONE, IDENTITY, cicp->oetf)
TRANSFORM(cicp_from_srgb_linear, NONE, cicp->from_srgb, NONE, IDENTITY, cicp->oetf)
TRANSFORM(cicp_from_rec2100_pq, pq_eotf, cicp->from_rec2020, NONE, IDENTITY, cicp->oetf)
TRANSFORM(cicp_from_rec2100_linear, NONE, cicp->from_rec2020, NONE, IDENTITY, cicp->oetf)
#undef cicp
TRANSFORM_PAIR (cicp_to_oklab, cicp_to_srgb_linear, srgb_linear_to_oklab)
TRANSFORM_PAIR (cicp_from_oklab, oklab_to_srgb_linear, cicp_from_srgb_linear)
TRANSFORM_PAIR (cicp_to_oklch, cicp_to_srgb_linear, srgb_linear_to_oklch)
TRANSFORM_PAIR (cicp_from_oklch, oklch_to_srgb_linear, cicp_from_srgb_linear)
/* }}} */
/* {{{ Vfuncs */
@@ -572,13 +774,17 @@ gdk_cicp_color_state_get_convert_to (GdkColorState *self,
switch (GDK_DEFAULT_COLOR_STATE_ID (target))
{
case GDK_COLOR_STATE_ID_SRGB:
return gdk_cicp_to_srgb;
return gdk_convert_cicp_to_srgb;
case GDK_COLOR_STATE_ID_SRGB_LINEAR:
return gdk_cicp_to_srgb_linear;
return gdk_convert_cicp_to_srgb_linear;
case GDK_COLOR_STATE_ID_REC2100_PQ:
return gdk_cicp_to_rec2100_pq;
return gdk_convert_cicp_to_rec2100_pq;
case GDK_COLOR_STATE_ID_REC2100_LINEAR:
return gdk_cicp_to_rec2100_linear;
return gdk_convert_cicp_to_rec2100_linear;
case GDK_COLOR_STATE_ID_OKLAB:
return gdk_convert_cicp_to_oklab;
case GDK_COLOR_STATE_ID_OKLCH:
return gdk_convert_cicp_to_oklch;
case GDK_COLOR_STATE_N_IDS:
default:
@@ -598,13 +804,17 @@ gdk_cicp_color_state_get_convert_from (GdkColorState *self,
switch (GDK_DEFAULT_COLOR_STATE_ID (source))
{
case GDK_COLOR_STATE_ID_SRGB:
return gdk_cicp_from_srgb;
return gdk_convert_cicp_from_srgb;
case GDK_COLOR_STATE_ID_SRGB_LINEAR:
return gdk_cicp_from_srgb_linear;
return gdk_convert_cicp_from_srgb_linear;
case GDK_COLOR_STATE_ID_REC2100_PQ:
return gdk_cicp_from_rec2100_pq;
return gdk_convert_cicp_from_rec2100_pq;
case GDK_COLOR_STATE_ID_REC2100_LINEAR:
return gdk_cicp_from_rec2100_linear;
return gdk_convert_cicp_from_rec2100_linear;
case GDK_COLOR_STATE_ID_OKLAB:
return gdk_convert_cicp_from_oklab;
case GDK_COLOR_STATE_ID_OKLCH:
return gdk_convert_cicp_from_oklch;
case GDK_COLOR_STATE_N_IDS:
default:
@@ -858,4 +1068,4 @@ gdk_color_state_clamp (GdkColorState *self,
/* }}} */
/* vim:set foldmethod=marker expandtab: */
/* vim:set foldmethod=marker: */

View File

@@ -49,6 +49,12 @@ GdkColorState * gdk_color_state_get_rec2100_pq (void);
GDK_AVAILABLE_IN_4_16
GdkColorState * gdk_color_state_get_rec2100_linear (void);
GDK_AVAILABLE_IN_4_16
GdkColorState * gdk_color_state_get_oklab (void);
GDK_AVAILABLE_IN_4_16
GdkColorState * gdk_color_state_get_oklch (void);
GDK_AVAILABLE_IN_4_16
gboolean gdk_color_state_equal (GdkColorState *self,
GdkColorState *other);
@@ -57,6 +63,6 @@ GDK_AVAILABLE_IN_4_16
GdkCicpParams *gdk_color_state_create_cicp_params (GdkColorState *self);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkColorState, gdk_color_state_unref);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkColorState, gdk_color_state_unref)
G_END_DECLS

View File

@@ -13,6 +13,8 @@ typedef enum
GDK_COLOR_STATE_ID_SRGB_LINEAR,
GDK_COLOR_STATE_ID_REC2100_PQ,
GDK_COLOR_STATE_ID_REC2100_LINEAR,
GDK_COLOR_STATE_ID_OKLAB,
GDK_COLOR_STATE_ID_OKLCH,
GDK_COLOR_STATE_N_IDS
} GdkColorStateId;
@@ -73,6 +75,8 @@ extern GdkDefaultColorState gdk_default_color_states[GDK_COLOR_STATE_N_IDS];
#define GDK_COLOR_STATE_SRGB_LINEAR ((GdkColorState *) &gdk_default_color_states[GDK_COLOR_STATE_ID_SRGB_LINEAR])
#define GDK_COLOR_STATE_REC2100_PQ ((GdkColorState *) &gdk_default_color_states[GDK_COLOR_STATE_ID_REC2100_PQ])
#define GDK_COLOR_STATE_REC2100_LINEAR ((GdkColorState *) &gdk_default_color_states[GDK_COLOR_STATE_ID_REC2100_LINEAR])
#define GDK_COLOR_STATE_OKLAB ((GdkColorState *) &gdk_default_color_states[GDK_COLOR_STATE_ID_OKLAB])
#define GDK_COLOR_STATE_OKLCH ((GdkColorState *) &gdk_default_color_states[GDK_COLOR_STATE_ID_OKLCH])
#define GDK_IS_DEFAULT_COLOR_STATE(c) ((GdkDefaultColorState *) (c) >= &gdk_default_color_states[0] && \
(GdkDefaultColorState *) (c) < &gdk_default_color_states[GDK_COLOR_STATE_N_IDS])

View File

@@ -1,22 +0,0 @@
/* gdkconfig.h
*
* This is a generated file. Please modify `configure.ac'
*/
#ifndef __GDKCONFIG_H__
#define __GDKCONFIG_H__
#if !defined (__GDK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gdk/gdk.h> can be included directly."
#endif
#include <glib.h>
G_BEGIN_DECLS
#define GDK_WINDOWING_WIN32
G_END_DECLS
#endif /* __GDKCONFIG_H__ */

View File

@@ -1,23 +0,0 @@
/* gdkconfig.h
*
* This is a generated file. Please modify `configure.ac'
*/
#ifndef __GDKCONFIG_H__
#define __GDKCONFIG_H__
#if !defined (__GDK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gdk/gdk.h> can be included directly."
#endif
#include <glib.h>
G_BEGIN_DECLS
#define GDK_WINDOWING_WIN32
#define GDK_RENDERING_VULKAN
G_END_DECLS
#endif /* __GDKCONFIG_H__ */

View File

@@ -124,7 +124,7 @@ gdk_content_provider_new_for_value (const GValue *value)
content = g_object_new (GDK_TYPE_CONTENT_PROVIDER_VALUE, NULL);
g_value_init (&content->value, G_VALUE_TYPE (value));
g_value_copy (value, &content->value);
return GDK_CONTENT_PROVIDER (content);
}
@@ -409,7 +409,7 @@ gdk_content_provider_union_init (GdkContentProviderUnion *self)
* ```c
* gdk_content_provider_new_union ((GdkContentProvider *[2]) {
* gdk_content_provider_new_typed (G_TYPE_FILE, file),
* gdk_content_provider_new_typed (G_TYPE_TEXTURE, texture)
* gdk_content_provider_new_typed (GDK_TYPE_TEXTURE, texture)
* }, 2);
* ```
*
@@ -594,7 +594,7 @@ gdk_content_provider_new_for_bytes (const char *mime_type,
content = g_object_new (GDK_TYPE_CONTENT_PROVIDER_BYTES, NULL);
content->mime_type = g_intern_string (mime_type);
content->bytes = g_bytes_ref (bytes);
return GDK_CONTENT_PROVIDER (content);
}

View File

@@ -64,6 +64,7 @@ typedef enum {
GDK_FEATURE_DMABUF = 1 << 7,
GDK_FEATURE_OFFLOAD = 1 << 8,
GDK_FEATURE_COLOR_MANAGEMENT = 1 << 9,
GDK_FEATURE_AEROSNAP = 1 << 10,
} GdkFeatures;
#define GDK_ALL_FEATURES ((1 << 10) - 1)
@@ -119,3 +120,4 @@ guint gdk_parse_debug_var (const char *variable,
const GdkDebugKey *keys,
guint nkeys);
G_END_DECLS

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