Compare commits

...

1286 Commits

Author SHA1 Message Date
Matthias Clasen
deb89d8d29 stroke: Remove erroneous preconditions 2020-11-28 12:38:07 -05:00
Matthias Clasen
9518f86ba9 Fix bounding boxes for axis-aligned lines
The docs say "returns FALSE if the path is known
to be empty". Lines are not empty, so don't return
FALSE. Even if they are axis-aligned.
2020-11-28 12:36:47 -05:00
Matthias Clasen
e60e583bb5 Documentation typo fixes 2020-11-28 12:36:25 -05:00
Benjamin Otte
c82080ccea WIP: path: Add conic curves
So far this just adds the API, if you use it, you'll get lots of
g_warnings().
2020-11-28 07:35:55 +01:00
Benjamin Otte
91923c29da path: Add GSK_CIRCLE_POINT_INIT() to initialize points on the circle
This is just splitting out a commonly done operation into a macro.
2020-11-28 07:35:55 +01:00
Benjamin Otte
d62c987f63 xxx: split builder 2020-11-28 07:35:55 +01:00
Benjamin Otte
bd206429eb pathbuilder: Redo semantics for starting curves
We now always have a "current point" which is either the last point an
operation was made to, or (0, 0) if no drawing operation has
been made yet.

Adding a contour of any kind to the builder will always update the
current point to that contour's end point.
2020-11-28 07:35:55 +01:00
Benjamin Otte
42c7490b05 path: Split GskPathBuilder into its own file
... and add missing API docs.
2020-11-28 07:35:55 +01:00
Benjamin Otte
11dbab714a testsuite: Add a test using get_point() and get_closest_point() 2020-11-28 07:35:55 +01:00
Benjamin Otte
47defabe0c testsuite: Add a test for get_point() 2020-11-28 07:35:55 +01:00
Benjamin Otte
8cd1f2bf08 testsuite: Update create_random_path()
1. Allow specifying the max number of contours
2. Be smarter about creating the paths:
   With 10% chance, create a "weird" path like the empty one or only
   points or things like that.
   Otherwise create a bunch of contours, with 2/3 a standard contour,
   with 1/3 a predetermined one.
2020-11-28 07:35:55 +01:00
Benjamin Otte
2aab906174 gtk-demo: Add cute maze demo 2020-11-28 07:35:55 +01:00
Benjamin Otte
52ca3fa73f testsuite: Add tests for gsk_path_measure_get_closest_point() 2020-11-28 07:35:55 +01:00
Benjamin Otte
188c435549 path: Add gsk_path_measure_get_closest_point()
... and gsk_path_measure_get_closest_point_full().

Those 2 functions allow finding the closest point on a path to a given
point.
2020-11-28 07:35:55 +01:00
Benjamin Otte
73269f9601 spline: Use Skia's tolerance checks
This avoids measuring being too far off (it's still off, but it's less
than a percent now.
2020-11-28 05:55:52 +01:00
Benjamin Otte
bf5473e78a xxx: demo 2020-11-28 05:55:52 +01:00
Benjamin Otte
f7da082a88 testsuite: Add tests for gsk_path_measure_add_segment() 2020-11-28 05:55:52 +01:00
Benjamin Otte
cca39077b3 gtk-demo: Add a text-on-path demo 2020-11-28 04:00:16 +01:00
Benjamin Otte
c5a6848b2c xxx: path_fill demo 2020-11-28 04:00:16 +01:00
Benjamin Otte
2a41ad7bd6 path: Add gsk_path_measure_get_point()
Allows querying the coordinates and direction of any specific point on a
path.
2020-11-28 04:00:16 +01:00
Matthias Clasen
c2375809fc path: Add gsk_path_add_circle()
Adds a circle contour, too.
2020-11-28 04:00:16 +01:00
Benjamin Otte
25b0ed1911 pathmeasure: Implement support for beziers
Instead of treating bezier curves as lines, we properly decompose them
into line segments now so that we can treat those as lines.
2020-11-28 04:00:16 +01:00
Benjamin Otte
549bcceb42 path: Implement gsk_path_to_cairo() using foreach() 2020-11-28 04:00:16 +01:00
Benjamin Otte
fd5f54df15 path: Add gsk_path_foreach() 2020-11-28 04:00:16 +01:00
Benjamin Otte
b94382e9d2 path: Collect flags
We don't need them yet, but maybe later.
2020-11-28 04:00:16 +01:00
Benjamin Otte
a017ebf944 testsuite: Add path tests 2020-11-28 04:00:16 +01:00
Benjamin Otte
e102c52964 pathmeasure: Add gsk_path_measure_add_segment()
This allows chunking paths, weeee.
2020-11-28 04:00:16 +01:00
Benjamin Otte
e3cec72cce path: Add gsk_path_builder_add_path() 2020-11-28 04:00:16 +01:00
Benjamin Otte
626ba8716d gsk: Add GskPathMeasure
An object to do measuring operations on paths - determining their
length, cutting off subpaths, things like that.
2020-11-28 04:00:16 +01:00
Benjamin Otte
7deaf6b648 path: Change data structure for standard path
Instead of the Cairo method and imitating cairo_path_data_t, use the
Skia method and keep points and operations separate.

That way we get a points array that includes the starting point -
because it's always the end point of the previous operation.
2020-11-28 04:00:16 +01:00
Benjamin Otte
026c0ed347 popover: Use fill and stroke nodes instead of Cairo
... to render the arrow.

The arrow should really be turned into a real thing - maybe an icon?
2020-11-28 04:00:16 +01:00
Benjamin Otte
87a09e07fd snapshot: Add gtk_snapshot_push_stroke() 2020-11-28 04:00:16 +01:00
Benjamin Otte
68ac24ef65 gsk: Add GskStrokeNode 2020-11-28 04:00:16 +01:00
Benjamin Otte
6ce05c23f1 gsk: Add GskStroke
It's unused in this commit. This just prepares the new object.
2020-11-28 04:00:16 +01:00
Benjamin Otte
3f77e0455d demos: Add a simple demo filling a path 2020-11-28 04:00:16 +01:00
Benjamin Otte
1eacc48580 snapshot: Add gtk_snapshot_push_fill() 2020-11-28 04:00:16 +01:00
Benjamin Otte
21d19fddbd gsk: Add GskFillNode
Take a rendernode as source and a GskPath and fill the region in the
path just like cairo_fill() would.
2020-11-28 04:00:16 +01:00
Benjamin Otte
7daf99a1c8 gsk: Add GskPath 2020-11-28 04:00:16 +01:00
Benjamin Otte
5c9a8f69e5 listview: Use the correct scroll policy
Use the horizontal policy for horizontal decisions, not the vertical
one.

This broke in 0011ce949c.
2020-11-25 15:50:48 +01:00
Benjamin Otte
fbe3f2e581 docs: Put render nodes in their own sections 2020-11-25 15:50:46 +01:00
Matthias Clasen
c84c014536 Merge branch 'wip/chergert/for-master' into 'master'
textview: fix precondition assertions

Closes #3386

See merge request GNOME/gtk!2886
2020-11-24 17:14:53 +00:00
Christian Hergert
1e994419ee textview: fix precondition assertions
It is a programmer error to call this with a child widget that has not
been placed within the GtkTextView.

Fixes #3386
2020-11-24 08:29:52 -08:00
Matthias Clasen
7b22c44b39 Merge branch 'fix-integer-overflow' into 'master'
gdk/win32: fix integer overflow in monitor refresh rate calculation

Closes #3394

See merge request GNOME/gtk!2884
2020-11-24 16:22:49 +00:00
Anders Jonsson
2e744260e0 Update Swedish translation 2020-11-23 22:09:28 +00:00
Volker Rümelin
7190a31b5f gdk/win32: fix integer overflow in monitor refresh rate calculation
In gdk/win32/gdkmonitor-win32.c in function
populate_monitor_devices_from_display_config() refresh->Numerator * 1000
overflows for refresh->Numerator > 4294976.

Cast the factor 1000 to UINT64 to prevent the overflow.

Fixes #3394
2020-11-23 21:42:58 +01:00
Matthias Clasen
729f007379 Merge branch 'no-more-devel-headers' into 'master'
Drop devel styling from our windows

See merge request GNOME/gtk!2882
2020-11-23 19:01:44 +00:00
Matthias Clasen
b75b359f19 Drop devel styling from our windows
We are about to do a stable release. Time to get used
again to plain old, boring header bars.
2020-11-23 12:10:01 -05:00
Emmanuele Bassi
d7de720275 Merge branch 'ebassi/for-master' into 'master'
Ebassi/for master

See merge request GNOME/gtk!2876
2020-11-23 15:41:03 +00:00
Emmanuele Bassi
ef86e46238 a11y: Cache the accessibility bus address
Just check for it once; doing it every time we failed to create an
ATContext is just going to fill up the logs.
2020-11-23 14:34:46 +00:00
Emmanuele Bassi
0a46baeb56 a11y: Turn critical warnings into debug messages
The accessibility bus might not be available, and if it isn't the case,
it means something has failed at a level where the user can't do much
about it. There's no need to emit a critical warning.
2020-11-23 14:34:46 +00:00
Emmanuele Bassi
fd3a6299ce Merge branch 'ebassi/glib-min-version' into 'master'
Ebassi/glib min version

See merge request GNOME/gtk!2880
2020-11-23 14:33:20 +00:00
Emmanuele Bassi
803b147483 Disable deprecation warnings from GLib
We don't want to test the latest changes in GLib in our own build.
2020-11-23 13:04:11 +00:00
Emmanuele Bassi
1f44319588 Drop redundant dependencies
PangoCairo already depends on Pango; Cairo-gobject already depends on
Cairo.
2020-11-23 13:04:11 +00:00
Emmanuele Bassi
505478bc59 Drop GLib dependency from GTK's declared dependencies
We depend on GObject, which already depends on GLib; on older versions
of Meson, this ends up trying to depend on the system copy of GLib,
instead of the sub-project copy, in case the version of GLib we have
installed is too old.
2020-11-23 12:29:32 +00:00
Emmanuele Bassi
de7833b6a0 Use the right GLib macros for version checking
There's a typo in the name, and we never noticed.
2020-11-23 12:06:22 +00:00
Emmanuele Bassi
3a1b2083d6 Do not depend on GLib API introduced after 2.66
To avoid bleeding edge deprecations we use GLIB_VERSION_MIN_REQUIRED and
GLIB_VERSION_MAX_ALLOWED. Since we depend on GLib 2.66, we cannot use
API introduced in 2.67, even when conditionally compiled.
2020-11-23 12:06:22 +00:00
nana-4
3e996f61ae icon-browser: Add .sidebar style class in the main window
So the sidebar can get the proper background and border colors.
2020-11-23 10:51:58 +01:00
nana-4
56eac4f846 gtk-demo: Add .sidebar style class in the main window
So the sidebar can get the proper background and border colors.
2020-11-23 10:51:58 +01:00
nana-4
61dcb685b2 Adwaita: Unify sidebar background-color
The sidebar item style is already unified. The sidebar background-color
should be unified as well.

See https://gitlab.gnome.org/GNOME/gtk/-/issues/3382
2020-11-23 10:51:58 +01:00
nana-4
bd0d75e237 Adwaita: Make sidebar row styling better
- Reorder declaration blocks for code legibility.
- Don't lighten text color on :hover and :selected for better contrast.
- Add missing :focus-visible:focus-within styling to non-:selected row.
2020-11-23 10:51:58 +01:00
nana-4
179fc68355 Adwaita: Fix some sidebar sizing
- Don't set the sidebar padding twice.
- Add padding to the assistant sidebar directly, as it doesn't have
  .navigation-sidebar internally.
- Set missing margin to the sidebar separator.

See https://gitlab.gnome.org/GNOME/gtk/-/issues/3382
2020-11-23 10:51:58 +01:00
nana-4
9828756e05 Adwaita: Move placessidebar-specific sizing from .navigation-sidebar
The common .navigation-sidebar styling should be more generic.
2020-11-23 10:51:58 +01:00
nana-4
40f2b49c0d Adwaita: Make treeexpander styling generic
The widget can be used outside .navigation-sidebar.

This also fixes the label misalignment in the widget.
2020-11-23 10:51:58 +01:00
nana-4
8e81cbef2c stacksidebar: Add missing .navigation-sidebar to the inner list
Also don't set :show-separators, which is not applied in other sidebars.

See https://gitlab.gnome.org/GNOME/gtk/-/issues/3382
2020-11-23 10:51:58 +01:00
Timm Bäder
47d572834b Merge branch 'scalebutton' into 'master'
properly set ScaleButton's parent_class

Closes #3381

See merge request GNOME/gtk!2877
2020-11-23 07:38:17 +00:00
Bilal Elmoussaoui
46601325f1 properly set ScaleButton's parent_class
GtkScaleButton doesn't subclass GtkButton anymore
Fixes #3381
2020-11-23 02:47:12 +01:00
Emmanuele Bassi
0abc7a3361 Merge branch 'nullables-1' into 'master'
Fix some nullable return annotations

See merge request GNOME/gtk!2873
2020-11-21 16:11:34 +00:00
Sophie Herold
1e01b9079d Fix some nullable return annotations 2020-11-21 16:33:40 +01:00
Piotr Drąg
be688c46f2 Update POTFILES.skip 2020-11-21 14:39:17 +01:00
Jakub Steiner
ab163f168d Merge branch 'wip/jimmac/clipped-menu-shadows' into 'master'
Adwaita: avoid clipping menu shadows

Closes #1987

See merge request GNOME/gtk!2872
2020-11-20 12:37:49 +00:00
Jakub Steiner
e937f7eac8 Revert "Adwaita: unified sidebar styles"
Doing the same mistake twice :( Even margin is eating from the container,
not expanding outside of it.

This reverts commit 6be575992f.
2020-11-20 13:24:23 +01:00
Jakub Steiner
b84945e43f Merge branch 'wip/jimmac/sidebar-backdrop' into 'master'
Adwaita: don't backdrop labels

Closes #3377

See merge request GNOME/gtk!2868
2020-11-20 12:08:59 +00:00
Jakub Steiner
b3dba1dca6 Adwaita: avoid clipping menu shadows
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/1987
2020-11-20 13:04:04 +01:00
Jakub Steiner
060cfc713f Merge branch 'wip/jimmac/unified-sidebar-styles' into 'master'
Adwaita: unified sidebar styles

Closes #3382

See merge request GNOME/gtk!2871
2020-11-20 11:40:30 +00:00
Jakub Steiner
6be575992f Adwaita: unified sidebar styles
- stacksidebar focus, separation and color as everything else
- eliminate placessidebar double padding

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3382
2020-11-20 12:24:40 +01:00
Jakub Steiner
4bec75c66b Adwaita: don't backdrop labels
- instead of overriding :backdrop for sidebars, continue pursuing
  not to backdrop anything but headerbar items and buttons.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3377
2020-11-20 09:34:23 +01:00
Matthias Clasen
8e4cc59a7a Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2870
2020-11-20 02:02:10 +00:00
Matthias Clasen
c17227966d Merge branch 'wip/carlosg/for-master' into 'master'
gtk/main: Do not unset active state on button release w/o implicit grab

See merge request GNOME/gtk!2869
2020-11-20 01:46:03 +00:00
Matthias Clasen
a2ce6268b2 gtk-demo: Make a more interesting constraints demo
Show various ways to influence spacing. This is more or
less modeled on the way Androids constraint layout lets
you set up 'chains'.
2020-11-19 20:35:15 -05:00
Carlos Garnacho
5ab14ff7f6 gtk/main: Do not unset active state on button release w/o implicit grab
If an active grab gets undone on button press (e.g. closing a menu), we
will receive a button release on the new target even though it didn't handle
the button press, and disable ::active state.

This causes warnings when handling the button release, as it tries to undo
::active state that is not really there.

In order to fix this, check that the pointer focus actually had an implicit
grab at the time of receiving the button release, before trying to unset
the ::active state.
2020-11-19 22:58:14 +01:00
Emmanuele Bassi
8482b956d6 Merge branch 'ebassi/for-master' into 'master'
Ebassi/for master

See merge request GNOME/gtk!2867
2020-11-19 16:37:58 +00:00
Matthias Clasen
562c7b1ff3 Merge branch 'wip/chergert/gdk-macos-for-master' into 'master'
GTK4: various fixes

See merge request GNOME/gtk!2864
2020-11-19 16:05:47 +00:00
Jakub Steiner
8099de22f9 Merge branch 'wip/jimmac/industrial-style-menuitems' into 'master'
Adwaita: revert edge-to-edge menuitems

Closes #3366

See merge request GNOME/gtk!2866
2020-11-19 15:52:25 +00:00
Emmanuele Bassi
a4c3bee4a1 a11y: Hide children of GtkFishBowl
The fishbowl widget is purely presentational, and its children should
not be visible in the accessibility tree.
2020-11-19 15:20:56 +00:00
Emmanuele Bassi
5afa985e85 demo: Make GtkFishBowl a presentation widget
It has no accessible content, even if it displays widgets.
2020-11-19 15:20:56 +00:00
Emmanuele Bassi
e600a07237 a11y: Skip atspi.Cache signals for hidden elements
If the accessible object is hidden, we can skip the emission of the
AddAccessible and RemoveAccessible signals on the cache, as those
objects won't be visible in the accessibility tree.
2020-11-19 15:20:56 +00:00
Emmanuele Bassi
8fa58c2e17 a11y: Get the accessible role once
Simplify getting the accessible role when checking if an accessible
implementation should present itself; this avoids going through
GtkAccessible twice to get the same data.
2020-11-19 15:20:56 +00:00
Emmanuele Bassi
d436c2e839 a11y: Remove weak ref from atspi.Cache
The GtkAtSpiContext is responsible for removing itself from the root,
which will remove itself from the cache. Any code path that leads to the
GtkAtSpiContext instance being collected passes through the
unrealization phase, which will also unregister the context from the
accessibility bus and from the cache.
2020-11-19 15:20:56 +00:00
Emmanuele Bassi
b37634dcd5 a11y: Add a fallback for the root base path
In case g_get_prgname() returns NULL, which seems to be the case for the
GTK tests.
2020-11-19 15:20:56 +00:00
Emmanuele Bassi
2d636fdda0 a11y: Reuse the generated AT-SPI interface name
We already have the name available.
2020-11-19 15:20:56 +00:00
Emmanuele Bassi
28095641c5 a11y: Use the appropriate GVariant for cache signals
We need to wrap the argument for AddAccessible and RemoveAccessible into
a tuple, as that's what GDBus expects.
2020-11-19 12:14:55 +00:00
Jakub Steiner
d58b06ceeb Adwaita: revert edge-to-edge menuitems
- use the old Industrial style menuitems to make the design feel purposeful
- adjust corners to have compatible border-radii of child elements
- include sidebars and navigation sidebars to look consistent
  (plus the assistant sidebar)

Implements https://gitlab.gnome.org/GNOME/gtk/-/issues/3366
2020-11-19 11:16:28 +01:00
Christian Hergert
82b4c34eca gl: add some debugging information to DEBUG_OPS 2020-11-18 20:16:40 -08:00
Christian Hergert
ee47ddf5fd lpr: fix cast warning 2020-11-18 20:16:40 -08:00
Christian Hergert
f32ae2964a macos: fix various compiler warnings 2020-11-18 20:16:37 -08:00
Christian Hergert
eae5eaeb21 gl: use glFramebufferTexture2D to set framebuffer texture
When mapping a texture to the framebuffer, we can use the 2D
form instead of the cube mapping form.
2020-11-18 20:09:01 -08:00
Matthias Clasen
09fd2d61c4 gtk-demo: Rename some demos
This is just to make it easier for myself to
find the right sources.
2020-11-18 18:58:45 -05:00
Matthias Clasen
86d7ab7c50 docs: Update GtkSensitivityType docs
Don't talk about steppers here, since we are only using
this type for combobox buttons nowadays.
2020-11-18 18:18:31 -05:00
Matthias Clasen
88be92ceee scrollbar: Don't talk about steppers
There steppers were lost on the way from GtkRange
to GtkScrollbar, so don't talk about them in the docs.
2020-11-18 17:27:13 -05:00
Matthias Clasen
04c4b387a0 gtk-demo: Add more keywords
Add GtkShortcutController as a keyword to some demos that
show its use.
2020-11-18 10:48:57 -05:00
Matthias Clasen
7551f85d4c Merge branch 'wayland-minimize' into 'master'
wayland: Implement minimization

Closes #2688

See merge request GNOME/gtk!2861
2020-11-18 14:23:56 +00:00
Matthias Clasen
184886f893 Merge branch 'constraint-editor-work' into 'master'
Constraint editor work

See merge request GNOME/gtk!2863
2020-11-18 12:19:07 +00:00
Matthias Clasen
36ef94b002 constraint-editor: Fix creating constant constraints
We were not making the button sensitive in the case
of a constant constraint, and we were not properly
creating constant constraints either.
2020-11-17 23:16:57 -05:00
Matthias Clasen
831ebe3ef2 constraint-editor: Fix saving of constraints
g_file_replace_contents take a gsize, so passing -1
for string length does not work here.
2020-11-17 23:14:29 -05:00
Matthias Clasen
76b8676955 constraintlayout: Fix parsing of constant constraints
We were inadvertently turning constant constraints into
constraints against super, due to confusion between target
and source attribute.
2020-11-17 23:11:16 -05:00
Matthias Clasen
b3243132a0 Merge branch 'wip/chergert/gdk-macos-for-master' into 'master'
macos: fix rendering artifacts with hover transitions

See merge request GNOME/gtk!2862
2020-11-18 03:04:01 +00:00
Matthias Clasen
de461712a1 constraint-editor: Improve display of constraints
No need to go for ALGOL60 style operators when we
have Unicode.
2020-11-17 21:52:15 -05:00
Christian Hergert
dd7f52c59a macos: fix rendering artifacts with hover transitions
Using an image surface seems to fix some rendering artifacts when
performing cross-fade CSS transitions.
2020-11-17 18:20:55 -08:00
Matthias Clasen
3f1bc740e4 wayland: Implement minimization
Use the set_minimized method of the xdg_toplevel
interface to implement minimization as well as possible.
It is not possible, since there is no corresponding
state that we could use to update our surface state,
but in practice, it works well enough.

Fixes: #2688
2020-11-17 19:57:56 -05:00
Matthias Clasen
9128ad105b Merge branch 'wip/carlosg/for-master' into 'master'
gdk/wayland: Update to gtk_shell1 version 3

See merge request GNOME/gtk!2860
2020-11-18 00:13:17 +00:00
Carlos Garnacho
745cbc6c91 gdk/wayland: Update to gtk_shell1 version 3
Bring in line with gtk3, in terms of startup notification and
activation support.
2020-11-18 00:41:46 +01:00
Matthias Clasen
b635736ac2 Merge branch 'wip/chergert/gdk-macos-for-master' into 'master'
node-editor: fix length of text during save

See merge request GNOME/gtk!2859
2020-11-17 22:49:05 +00:00
Matthias Clasen
ba081bf119 Merge branch 'fix-doc-packtype' into 'master'
doc: Adapt GtkPackType documentation to GTK4 changes

See merge request GNOME/gtk!2858
2020-11-17 22:46:43 +00:00
Christian Hergert
3003f37e9d node-editor: fix length of text during save
The length parameter for g_file_replace_contents() is a gsize, so -1 is
unsuitable here. Just use strlen() directly.
2020-11-17 14:34:11 -08:00
Matthias Clasen
c1e05e7c52 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #3278

See merge request GNOME/gtk!2856
2020-11-17 19:25:05 +00:00
Matthias Clasen
6b475aacd2 Merge branch 'wip/chergert/gdk-macos-for-master' into 'master'
inspector: handle differences in DPI between backends

See merge request GNOME/gtk!2857
2020-11-17 19:24:47 +00:00
vanadiae
bc4969ec42 doc: Adapt GtkPackType documentation to GTK4 changes
Since GTK4, the functions that used the GtkPackType enumeration,
`gtk_box_pack_{start,end}`, were replaced by `gtk_box_{append,prepend}`,
hence this enumeration isn't used anymore by any function within the
GtkBox type, and the child packing properties were also removed for GTK4.
So this commit adapts the documentation accordingly.
2020-11-17 20:19:16 +01:00
Benjamin Otte
1c7daece7a Merge branch 'wip/otte/for-master' into 'master'
Wip/otte/for master

See merge request GNOME/gtk!2855
2020-11-17 19:08:01 +00:00
Christian Hergert
37a8c138f9 inspector: handle differences in DPI between backends
This fixes an issue on macOS where the text gets much larger once opening
the inspector.
2020-11-17 10:45:25 -08:00
Matthias Clasen
34d547a2aa inspector: Limit the width of readonly properties
For readonly properties, we show the serialized value
in a label. If we don't take precautions, this can cause
our window to grow extremely wide, and break things.
So, ellipsize things at a reasonable size.

Fixes: #3278
2020-11-17 13:36:57 -05:00
Benjamin Otte
163c04c101 snapshot: Add cleanup function to snapshot state
Otherwise we're leaking data in error cases.
2020-11-17 19:04:39 +01:00
Benjamin Otte
f2284ff40f rendernode: Rename all gsk_render_node_peek_*() functions
Those are getters, they should be gsk_render_node_get_*() functions.
2020-11-17 19:04:39 +01:00
Benjamin Otte
eded9459df tests: Fix for new tranfer behavior of constructors
We were still unreffing a listmodel where the reference wasn't ours
anymore.
2020-11-17 19:04:39 +01:00
Benjamin Otte
8fd1530848 testsuite: Make defaultvalue test always get the property
Make the test not skip properties completely, just skip checking the
property.

This caught the last 2 commits.
2020-11-17 19:04:39 +01:00
Benjamin Otte
77f9efa747 textbuffer: Remove unused properties
The getters and setters were removed in
f53848c360 but the pspecs were forgotten.
2020-11-17 19:04:39 +01:00
Benjamin Otte
109ec523cb shortcut: Actions are objects 2020-11-17 19:04:39 +01:00
Emmanuele Bassi
5cc5022a8f Merge branch 'wip/chergert/gdk-macos-for-master' into 'master'
macos: bring forward quartz search engine updates

See merge request GNOME/gtk!2854
2020-11-17 17:58:14 +00:00
Emmanuele Bassi
3c769bb11d Merge branch 'ebassi/inout-args' into 'master'
Remove pointless inout arguments

See merge request GNOME/gtk!2853
2020-11-17 17:40:13 +00:00
Christian Hergert
33b07e4825 macos: bring forward quartz search engine updates
These were not cherry picked after GTK branched for 4 development.
2020-11-17 09:37:13 -08:00
Matthias Clasen
714e5c72f6 docs: Add details about plain builds
Mention that build type 'plain' puts the responsibility
for debug features into the hands of the builder.

Related: !2831
2020-11-17 12:21:29 -05:00
Emmanuele Bassi
153c6424d3 Remove pointless inout arguments
GtkTreeView.get_tooltip_context() takes an inout X and Y coordinates,
but the "out" side is a side effect: the conversion from widget-relative
to bin window-relative coordinates is not documented, and can be done
using public API, if needed.

GtkIconView.get_tooltip_context() follows the same pattern, and takes
two inout arguments for the coordinates, but it does not change them any
more, after GtkIconView's bin window was dropped in commit 8dc5e13e.

There's really no point in having these `inout` arguments, and while
GtkTreeView and GtkIconView are certainly de-emphasised in GTK4, and we
nudge developers to move to the new list views, we should take advantage
of the API break to remove warts.
2020-11-17 16:38:12 +00:00
Emmanuele Bassi
b76e514322 Merge branch 'ebassi/for-master' into 'master'
Introspection fixes

Closes #3281

See merge request GNOME/gtk!2852
2020-11-17 16:04:03 +00:00
Jakub Steiner
1501aa0603 Revert "Adwaita: avoid clipping menu/popover shadow"
There are big side effects to adding padding around all menus and popovers.

https://gitlab.gnome.org/GNOME/gtk/-/issues/1987#note_963889

This reverts commit d266bd62de.
2020-11-17 16:53:32 +01:00
Emmanuele Bassi
cf5a173a4f Add type annotations for GtkShortcutAction types
The constructors and singleton getters need proper annotations for their
return type, given that we return a base type.
2020-11-17 14:17:26 +00:00
Matthias Clasen
2b8c3731c1 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2851
2020-11-17 14:12:23 +00:00
Emmanuele Bassi
ade2f1030a Annotate GdkTimeCoord's array field
We need to resolve the array length manually, because g-ir-scanner
cannot turn an enumeration member into a constant size.
2020-11-17 14:07:11 +00:00
Emmanuele Bassi
4f12df5f1c Annotate the return type for GtkTreeExpander.get_item()
We use gpointer for C convenience, but the returned value is really a
GObject.
2020-11-17 13:54:22 +00:00
Emmanuele Bassi
9941799449 Annotate out argument for gdk_popup_layout_get_offset() 2020-11-17 13:52:15 +00:00
Emmanuele Bassi
5a938ad83d Annotate the gsk_border_node_peek_widths() return value
We return a fixed sized C array of floats.
2020-11-17 13:48:07 +00:00
Matthias Clasen
835c807d7a widget-factory: Remove an unused size group
This was left behind when 361407201b removed
the unused popover that this size group applied to.
2020-11-17 07:34:53 -05:00
Matthias Clasen
2ef72442ec docs: Fix the links for keybinding signals
GtkBindingSignal does not exist anymore, so link to
GtkSignalAction for an explanation of keybinding signals.
2020-11-17 07:34:52 -05:00
Matthias Clasen
3bc2bf40a8 popover: Document signals 2020-11-17 07:34:52 -05:00
Matthias Clasen
cd4c0b6127 menubutton: Fix a gtk-doc complaint 2020-11-17 07:34:52 -05:00
Matthias Clasen
fa79e8651e gtk: Fix a doc oversight 2020-11-17 07:34:52 -05:00
Matthias Clasen
9a29487e25 gsk: Fix a doc oversight 2020-11-17 07:34:52 -05:00
Matthias Clasen
fceff93994 Merge branch 'fix-gi-warning' into 'master'
Fix a warning caused by difference between prototype and definition

See merge request GNOME/gtk!2849
2020-11-17 12:31:36 +00:00
Matthias Clasen
acd8b08d35 Merge branch 'wip/exalm/caption' into 'master'
widget-factory: Fix caption style class name

See merge request GNOME/gtk!2850
2020-11-17 12:22:29 +00:00
Alexander Mikhaylenko
2abee57421 widget-factory: Fix caption style class name
It's lowercase.
2020-11-17 13:16:47 +05:00
Qiu Wenbo
437f902c9d Fix a warning caused by difference between prototype and definition
This commit fix the warning:

../gdk/wayland/gdkdisplay-wayland.c:1079: Warning: GdkWayland: gdk_wayland_display_set_cursor_theme: unknown parameter 'name' in documentation comment, should be 'theme'
2020-11-17 14:59:14 +08:00
Matthias Clasen
a7befc647e Merge branch 'gsk-binding-api' into 'master'
gsk: Avoid using gtk css types in public api

Closes #2454

See merge request GNOME/gtk!2848
2020-11-17 05:36:15 +00:00
Matthias Clasen
121e61cf01 gsk: Avoid using gtk css types in public api
Using GtkCssSection in public headers here may be
ok from the C perspective, since it all ends up in
the same library anyway. But it causes circular
dependency problems for our gir files that are still
split by namespace.

To avoid this problem, copy the GtkCssLocation struct
struct as GskParseLocation, and pass take two of them
instead of a GtkCssSection in the error callback.

Update all users.

Fixes: #2454
2020-11-16 23:27:44 -05:00
Matthias Clasen
f7ac13b78f Merge branch 'matthiasc/for-master' into 'master'
popover: Fix submenu navigation

Closes #3301

See merge request GNOME/gtk!2847
2020-11-17 03:11:13 +00:00
Matthias Clasen
c2ae73f247 popover: Fix submenu navigation
In commit 024d832d94, we introduced a
cascade-popdown property that makes closing a submenu
propagate up and close its parent menus. This is the
behavior we want when a menuitem in the submen is
activated.

What we overlooked is that we still need to be able to
close a submenu during navigation, before opening another
one. And in this case, propagating the closing is breaking
things. Fix this by adding a private close_submenu api
to GtkPopoverMenu that avoids the propagation.

Fixes: #3301
2020-11-16 21:34:33 -05:00
Benjamin Otte
4b0b6100d6 build: Include GSK types in gtk_test_register_all_type() 2020-11-17 03:13:31 +01:00
Matthias Clasen
2c9bf55eea Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2846
2020-11-17 01:07:34 +00:00
Emmanuele Bassi
1d11d42aa0 Merge branch 'ebassi/for-master' into 'master'
Ebassi/for master

See merge request GNOME/gtk!2840
2020-11-16 23:06:55 +00:00
Matthias Clasen
361407201b widget-factory: Remove an unused popover
We are no longer using the hand-rolled variant of that
popover on page 3, so drop it from the ui file.
2020-11-16 15:22:12 -05:00
Matthias Clasen
50c29398e6 Merge branch 'wip/exalm/button' into 'master'
Allow pressing multiple buttons at once on touch

See merge request GNOME/gtk!2813
2020-11-16 20:16:10 +00:00
Jakub Steiner
dff8a9eb46 Merge branch 'wip/jimmac/popover-menu-submenus' into 'master'
Adwaita: fix up submenus again

See merge request GNOME/gtk!2845
2020-11-16 19:50:08 +00:00
Matthias Clasen
1bb4e660fd Merge branch 'wip/chergert/for-master' into 'master'
gsk: use glFrameBufferTexture2D and release texture

See merge request GNOME/gtk!2842
2020-11-16 19:20:19 +00:00
Jakub Steiner
ded6ec6424 Merge branch 'wip/jimmac/circular-button-focus' into 'master'
Adwaita: circular button focus

Closes #3368

See merge request GNOME/gtk!2844
2020-11-16 18:55:30 +00:00
Jakub Steiner
47e49acc7d Adwaita: fix up submenus again
- move menubar section under more generic popover.menu
  rather than resort to specificity dir(ltr) hacks
2020-11-16 19:48:11 +01:00
Jakub Steiner
0996b178dc Adwaita: circular button focus
- have the same focus look like the other items

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3368
2020-11-16 19:11:52 +01:00
Matthias Clasen
4befd13744 Merge branch 'wip/jimmac/spinbutton-spacing' into 'master'
Adwaita: spinbutton spacing

Closes #3370

See merge request GNOME/gtk!2841
2020-11-16 17:50:56 +00:00
Emmanuele Bassi
bb1463871c a11y: Ensure valid object paths in the fallback code
When falling back to using the program name to create a unique base path
for the objects on the accessibility bus we need to ensure that the name
is a valid DBus object path.
2020-11-16 17:47:15 +00:00
Christian Hergert
12a9164414 gsk: use glFrameBufferTexture2D and release texture
glFrameBufferTexture maps to all faces of a cube and that is not needed
here. Additionally, texture_id is not deleted after we use the additional
flipped texture, but should be.
2020-11-16 09:26:07 -08:00
Jakub Steiner
108fe033aa Adwaita: spinbutton spacing
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3370
2020-11-16 18:22:17 +01:00
Emmanuele Bassi
9de2b4b0e1 a11y: Implement atspi.Cache
The AT-SPI cache interface is used to quickly populate the accessible
objects tree.

The tricky bit is ensuring that we emit change notifications on the
cache only when the cache is available, which means waiting until the
root is asynchronously registered.
2020-11-16 16:44:56 +00:00
Emmanuele Bassi
ee056fd8bd a11y: Update the Cache interface introspection
The type for cached items is, unsurprisingly, wrong when compared to the
implementation inside atk-spi2-atk.
2020-11-16 16:44:56 +00:00
Emmanuele Bassi
bc4f71a107 a11y: Add getters for GtkAtSpiContext
We are going to use them in order to implement atspi.Cache.
2020-11-16 16:44:56 +00:00
Emmanuele Bassi
125442297f a11y: Use the tab widget to label the notebook stack page 2020-11-16 16:44:56 +00:00
Emmanuele Bassi
eec92b40ea a11y: Compute the base path in the root object
The root path is shared by all AtSpiContext instances, so we should
compute it once, instead of every time we instantiate a new context.

This allows us to defer the path creation at realization time and ensure
that we have a registered application.
2020-11-16 16:44:56 +00:00
Emmanuele Bassi
d392f6f2a4 a11y: Resync the AT-SPI XML
Mostly just changes in the annotations coming from at-spi2-core, but
it's good to try and keep the XML in sync.
2020-11-16 16:44:56 +00:00
Jakub Steiner
41a9c46ec8 Merge branch 'wip/jimmac/circular-button-padding' into 'master'
Adwaita: circular buttons

See merge request GNOME/gtk!2838
2020-11-16 14:50:16 +00:00
Matthias Clasen
0530aeec17 docs: Mention cairo-gobject as build requires
Using cairo from a system dependency and cairo-gobject
as subproject is problematic and left me stuck on a
hard-to-understand build error.
2020-11-16 09:31:23 -05:00
Jakub Steiner
22741a74ff Adwaita: circular buttons
- the vertical padding was thown off with the chin/forehead of menus removed
2020-11-16 15:21:46 +01:00
Jakub Steiner
23331c1919 Merge branch 'wip/jimmac/menu-clipped-shadow' into 'master'
Wip/jimmac/menu clipped shadow

Closes #1987

See merge request GNOME/gtk!2837
2020-11-16 14:10:21 +00:00
Jakub Steiner
d266bd62de Adwaita: avoid clipping menu/popover shadow
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/1987
2020-11-16 14:20:24 +01:00
Matthias Clasen
57c95937b1 gsk: Fix some docs oversights
These apis have been renamed a few times, and the docs
haven't kept up.
2020-11-16 07:44:41 -05:00
Matthias Clasen
1d86086434 gdk: Docs cosmetics
Add a few missing parameters in doc comments.
2020-11-16 07:44:17 -05:00
Matthias Clasen
e2f26b0d9a docs: Fix a typo 2020-11-16 07:37:33 -05:00
Matthias Clasen
7816fc2b83 docs: Remove gtk_render_insertion_cursor
This function was removed in 2bcef7f030.
2020-11-16 07:35:41 -05:00
Jakub Steiner
04d802f7f4 Adwaita: remove chin on menus
- clipping a rounded corner seems to be working fine for first and last item.

Addresses https://gitlab.gnome.org/GNOME/gtk/-/issues/3366
2020-11-16 13:31:27 +01:00
Jakub Steiner
994cc32d7b Merge branch 'wip/jimmac/subtle-sidebar' into 'master'
Adwaita: navigation sidebar color changes

Closes #3362

See merge request GNOME/gtk!2836
2020-11-16 09:34:36 +00:00
Jakub Steiner
f14ca28c4e Adwaita: navigation sidebar color changes
- use more subtle selected state grey

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3362
2020-11-16 10:17:57 +01:00
Matthias Clasen
da9d32e472 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2835
2020-11-16 04:29:10 +00:00
Matthias Clasen
08d6db4ab6 gtk-demo: Plug a memory leak
The Characters demo was leaking its columns.
2020-11-15 23:03:30 -05:00
Matthias Clasen
6891f40110 modelbutton: Fix keynav for check and radio
The expected behavior when activating check or radio
menuitems via keynav is that Space toggles the item
but keeps the menu open, while Return toggles the
item and closes the menu.
2020-11-15 21:52:07 -05:00
Matthias Clasen
cdbf24c3af Merge branch 'fix-tooltip-trigger' into 'master'
Fix tooltip triggering

See merge request GNOME/gtk!2833
2020-11-15 17:37:47 +00:00
Matthias Clasen
b30715da6a Fix tooltip triggering
Ever since 5b5d2665d3, tooltips don't work properly,
since we get more motion events now, and those keep the
tooltips from appearing. This can be seen e.g. on the icon
in the password entry in widget-factory, or on the section
switcher buttons in the Emoji chooser.

Ignore synthetic motion events for the purposes of
determining whether the user moved the mouse.
2020-11-15 10:54:36 -05:00
Emmanuele Bassi
5e9883453d Merge branch 'widget-no-a11y-crash' into 'master'
gtkwidget: fix crashes with GTK_A11Y=none

Closes #3333

See merge request GNOME/gtk!2834
2020-11-15 15:23:42 +00:00
Christoph Reiter
b97b95b0c7 gtkwidget: fix crashes with GTK_A11Y=none
at_context can be NULL in that case, so guard against it.

Fixes #3333
2020-11-15 15:59:31 +01:00
Matthias Clasen
dd0a854bbb Merge branch 'button-fill-var-removal' into 'master'
Adwaita: Stop using $button_fill

Closes #3354

See merge request GNOME/gtk!2828
2020-11-15 13:45:42 +00:00
Matthias Clasen
b8d0ad8643 Merge branch 'parse-debug-env-vars-always' into 'master'
Always parse GTK/GDK/GSK_DEBUG env vars and make some entries available in non-debug mode

See merge request GNOME/gtk!2830
2020-11-15 13:37:44 +00:00
Christoph Reiter
65d57877a8 Revert "Update comment annotations of gtk_tree_model_iter_previous and gtk_tree_model_iter_next to state that the ITER parameter is modified."
This reverts commit 1340ff2bc2.

Same as with 53cd499621
2020-11-15 13:36:42 +01:00
Christoph Reiter
afc73c38ce Always parse GTK/GDK/GSK_DEBUG env vars and make some entries available in non-debug mode
Currently GTK can be built with G_ENABLE_DEBUG which enables various debug code and parsing
of those env vars, or without, which instead of parsing them prints a warning if they are set.
While building with G_ENABLE_DEBUG isn't strictly needed it's the only way to make GTK_DEBUG=interactive work,
which is a nice thing to have always.

This enables parsing of those env vars in any case and allows specific values being marked as also
available when not built with G_ENABLE_DEBUG (interactive for example). If not built with G_ENABLE_DEBUG
then all unavailable values will be marked as such in the help output and a note is added that
GTK needs to be built with G_ENABLE_DEBUG to use them, which should help discoverability.
2020-11-15 11:34:54 +01:00
Yuri Chornoivan
f4e1c271ea Update Ukrainian translation 2020-11-15 08:01:26 +00:00
Matthias Clasen
8e42239439 Merge branch 'wip/carlosg/for-master' into 'master'
gtk/main: Reset active state on grab broken only if implicit

See merge request GNOME/gtk!2832
2020-11-14 14:41:01 +00:00
Carlos Garnacho
5b4ac5456e gtk/main: Reset active state on grab broken only if implicit
An implicit grab means some button is down, reset the active state
only in that case when we get a grab broken event.

Avoids active state accounting warnings when we do get active grabs
broken (e.g. after selecting a menu option).
2020-11-14 10:52:34 +01:00
nana-4
f1db73379e Adwaita: Stop using $button_fill
Since the $button_fill variables are no longer used outside of the
button() mixin (and it was for an ugly hack), there is no need to keep
that anymore.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3354
2020-11-14 10:13:05 +09:00
Matthias Clasen
20918dbe8e Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #3359 and #3353

See merge request GNOME/gtk!2827
2020-11-14 00:15:34 +00:00
Matthias Clasen
b5ec20db88 Adwaita: Fix list separators
Commit bfe5b0d1b7 ran into some specificity
trouble.

Fixes: #3353
2020-11-13 17:18:05 -05:00
Matthias Clasen
d347df431d label: Avoid short-circuiting
Commit 0db504edde made a mistake described here:
https://en.wikipedia.org/wiki/Short-circuit_evaluation#Possible_problems

Fixes: #3359
2020-11-13 15:35:51 -05:00
Matthias Clasen
25e6988d95 Merge branch 'alatiera/nightly-demos' into 'master'
ci: publish demo apps to the Nightly repository

See merge request GNOME/gtk!2825
2020-11-13 19:28:44 +00:00
Matthias Clasen
a7f05b8d91 Merge branch 'wip/jimmac/tooltips' into 'master'
Adwaita: tooltip styling

Closes #3352

See merge request GNOME/gtk!2826
2020-11-13 19:23:58 +00:00
Jordan Petridis
fe690265eb ci: publish demo apps to the Nightly repository 2020-11-13 20:38:09 +02:00
Jakub Steiner
f45ea3fa90 Adwaita: tooltip styling
- balance padding
- increase border radius, yuck
- get rid of text shadow

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3352
2020-11-13 19:36:26 +01:00
Jakub Steiner
bdc28cd870 Merge branch 'wip/jimmac/submenus' into 'master'
Wip/jimmac/submenus

See merge request GNOME/gtk!2824
2020-11-13 17:05:00 +00:00
Jakub Steiner
c648c1f235 Merge branch 'wip/jimmac/declare-buttonfill-once' into 'master'
Adwaita: double declated $button_fill

See merge request GNOME/gtk!2823
2020-11-13 16:57:18 +00:00
Jakub Steiner
8a92ee03ea Adwaita: rounded submenus
- all corners have rounded corners

See https://gitlab.gnome.org/GNOME/gtk/-/issues/2745
2020-11-13 17:27:40 +01:00
Jakub Steiner
e3c72f8f09 Adwaita: double declared $button_fill
- this was already in place in _common, no need to have it in _colors
2020-11-13 17:24:13 +01:00
Jakub Steiner
1f472104ad Adwaita: double declated $button_fill
- this was already in place in _common, no need to have it in _colors
2020-11-13 17:21:03 +01:00
Jakub Steiner
4b41580041 Merge branch 'wip/exalm/window' into 'master'
Round window corners

See merge request GNOME/gtk!1952
2020-11-13 15:33:15 +00:00
Matthias Clasen
c136f84584 Merge branch 'wip/carlosg/for-master' into 'master'
Improve handling of ::active with touch and multiple foci

Closes #3348

See merge request GNOME/gtk!2821
2020-11-13 04:13:34 +00:00
Carlos Garnacho
80de00a248 gtk/main: Stack ::active calls
We may have the situation of multiple touchpoints in the same
widget, or combinations with other devices. Stack those ::active
states are preserved on widgets on all but the last pointer/touch
going away.
2020-11-13 00:39:23 +01:00
Carlos Garnacho
50a7e59623 gtk/main: Toggle active flag with touch events
This went missing at some point, add the missing toggling of active
state with GDK_TOUCH_BEGIN/END/CANCEL events.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3348
2020-11-13 00:39:23 +01:00
Emmanuele Bassi
92ca3a3419 Merge branch 'ebassi/for-master' into 'master'
Ebassi/for master

See merge request GNOME/gtk!2819
2020-11-12 22:22:20 +00:00
Emmanuele Bassi
8203d9cc40 a11y: Use GROUP role for ShortcutsShortcut
And hide the image from the accessible tree.
2020-11-12 21:46:06 +00:00
Emmanuele Bassi
abc9b403f8 a11y: Implement atspi.Text.ScrollSubstringTo for GtkTextView
We reuse the existing implementation in GTK3.
2020-11-12 21:46:06 +00:00
Emmanuele Bassi
b9ad3172a4 a11y: Document GtkRevealer's accessible state
Use the GROUP role, and make sure to note that the child is always
revealed. Unlike GtkExpander, GtkRevealer can only be programmatically
toggled, so we cannot turn it into a "button" object.
2020-11-12 21:46:06 +00:00
Emmanuele Bassi
0d7fcdda28 a11y: Add more accessible data to GtkTreeExpander
Document the role of the GtkTreeExpander, and the behaviour of the
expander button.

Additionally, improve the label of the expander button, by adding a
fixed "Expand" label, and setting the "labelled-by" relation to the
child of the GtkTreeExpander.
2020-11-12 21:46:06 +00:00
Emmanuele Bassi
75f9b83b1e Establish a control relation between demo search and list
The search entry changes the content of the list view, so we should
mention that relation to assistive technologies.
2020-11-12 21:46:06 +00:00
Emmanuele Bassi
61e980bfb6 a11y: Add accessible actions to GtkSearchEntry
Just like GtkPasswordEntry, GtkSearchEntry should have its set of
accessible actions.
2020-11-12 21:46:06 +00:00
Emmanuele Bassi
ebda736a09 a11y: Mark SearchEntry icons as presentational
While the "clear the search entry" icon behaves like a button, we don't
have any actual action that can trigger it, so let's ignore it.
2020-11-12 21:46:06 +00:00
Emmanuele Bassi
d4ddfdc265 a11y: Set the role on GtkSearchBar
The search bar widget has a "SEARCH" landmark role, which is described
as:

    A landmark region that contains a collection of items and
    objects that, as a whole, combine to create a search facility.
2020-11-12 21:46:06 +00:00
Emmanuele Bassi
f8bb206034 a11y: Icons in buttons are presentational
Buttons are described by text, and the icon child can be safely ignored.
2020-11-12 21:46:06 +00:00
Emmanuele Bassi
87f92a93d3 a11y: Add more accessibility labels to GtkNotebook
Label the various components:

 - the tab list
 - the tab widget
 - the arrow widgets
2020-11-12 21:46:06 +00:00
Emmanuele Bassi
e49e084f4c a11y: Use the stack page title as its accessible label 2020-11-12 21:46:06 +00:00
Emmanuele Bassi
995daa1e29 a11y: GtkStack is a group of stack pages 2020-11-12 21:46:06 +00:00
Emmanuele Bassi
d34936c1ea Handle empty stack pages when creating an ATContext
If we don't have a widget inside GtkStackPage, we should use the default
GdkDisplay.
2020-11-12 21:46:06 +00:00
Emmanuele Bassi
a59889a274 Unrealize the ATContext in StackPage on dispose
Otherwise we're going to try to unrealize it during the GtkStack
destruction, which will emit warnings.
2020-11-12 21:46:05 +00:00
Emmanuele Bassi
bfb054a023 a11y: Icons in WindowControls are presentational only
They don't contribute anything to the accessible description.
2020-11-12 21:46:05 +00:00
Emmanuele Bassi
e940704018 a11y: Ignore more structural roles when computing labels
These roles should not have a fallback name when explicitly unlabelled.
2020-11-12 21:46:05 +00:00
Emmanuele Bassi
429c7fc039 a11y: Add role exception for GtkScrolledWindow
ARIA does not have a "scroll pane" role, but AT-SPI does.
2020-11-12 21:46:05 +00:00
Emmanuele Bassi
0d6e4f7a6e demo: Add more accessibility labels to the UI 2020-11-12 21:46:05 +00:00
Matthias Clasen
1f9eb5c64c Merge branch 'clear-search-entry' into 'master'
searchbar: Fix clearing search entry on hide

See merge request GNOME/gtk!2820
2020-11-12 19:25:57 +00:00
Florian Müllner
056a073061 searchbar: Fix clearing search entry on hide
Commit fa3d1940bf added separate grab handling for GtkSearchEntry, but
didn't consider whether the bar was revealed or concealed. The expected
behavior for the latter is that the entry is cleared rather than focused,
fix the condition accordingly.
2020-11-12 19:59:55 +01:00
Alexander Mikhaylenko
e46522e4b5 theme: Round all window corners 2020-11-12 22:19:00 +05:00
Alexander Mikhaylenko
7ac7919697 theme: Restructure window style 2020-11-12 22:17:52 +05:00
Matthias Clasen
5d9799d4e3 Merge branch 'ebassi/for-master' into 'master'
ATContext lifetime fixes

Closes #3341

See merge request GNOME/gtk!2811
2020-11-12 12:35:23 +00:00
Jakub Steiner
f95943a752 Merge branch 'wip/jimmac/sassc-global-vars' into 'master'
Adwaita: avoid !global

See merge request GNOME/gtk!2816
2020-11-12 12:34:10 +00:00
Jakub Steiner
ef88e9ffcc Adwaita: avoid !global
- Work around having !global variables as sassc will
  no longer support it
2020-11-12 13:14:37 +01:00
Alexander Mikhaylenko
49613dca8e button: Don't make the gesture exclusive
With the last commit, pressing the same button with multiple fingers
doesn't cause extra emissions, so we can remove exclusive and allow
pressing multiple buttons at once on touch.
2020-11-12 15:27:16 +05:00
Alexander Mikhaylenko
a651a0ce69 gestureclick: Only emit release for the same sequence
Avoid spurious releases when touching the same widget with another finger.
2020-11-12 15:26:36 +05:00
Emmanuele Bassi
08d59d3f68 docs: Add "Accessibility" section to various widgets
There are a few widgets that gained an accessible role, which means
adding an "Accessibility" section in their description.
2020-11-12 00:36:32 +00:00
Matthias Clasen
afff39c503 Merge branch 'suggestion-entry-demo2' into 'master'
gtk-demo: Add suggestion entry demos

See merge request GNOME/gtk!2812
2020-11-11 21:40:07 +00:00
Matthias Clasen
a2897e1868 gtk-demo: Add suggestion entry demos
Add a possible replacement for GtkEntryCompletion
as a demo.

Move the Dropdowns demo to Lists/Selections, and make
it show both GtkDropDown and the suggestion entry, with
some variations.
2020-11-11 15:54:43 -05:00
Matthias Clasen
15172ebdb0 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2810
2020-11-11 20:49:51 +00:00
Emmanuele Bassi
9ac4a7d99f a11y: Simplify GtkModelButton
Instead of recreating GtkATContexts in order to change their role, we
can simply unrealize and realize them back.
2020-11-11 19:45:43 +00:00
Emmanuele Bassi
8157717e03 a11y: Add missing fallback for accessible-role getter
If the per-instance accessible role is unset, use the class role.
2020-11-11 19:45:43 +00:00
Emmanuele Bassi
9052f6dafe a11y: Rework ownership and lifetime of GtkATContext
Now that GtkATContext is explicitly realized and unrealized, we should
always create an instance at widget initialization time, and drop it
during the widget finalization. This should make it easier to set up the
initial accessible state of a widget during the instance initialization,
as well as reduce the chances of accidental creation of GtkATContext
instances during the destruction sequence.
2020-11-11 19:45:43 +00:00
Emmanuele Bassi
292576f312 a11y: Defer to the GtkAccessible's implementation
Since GtkATContexts are now lazily realized, we need to go through the
GtkAccessible's implementation to access the :accessible-role property,
in case there are fallbacks.
2020-11-11 19:45:43 +00:00
Emmanuele Bassi
2285382074 a11y: Create AtSpiRoot on realization
There's no need to do a lot of work on construction, if we're delaying
all remote work after the GtkATContext is realized.

The GtkAtSpiContext should also keep a reference on the root, and drop
it at unrealize time.
2020-11-11 18:46:44 +00:00
Emmanuele Bassi
526f1e315b a11y: Use GROUP role for GtkNotebook
A notebook is a grouping of a tab list, tabs, and tab pages.
2020-11-11 18:46:11 +00:00
Emmanuele Bassi
877a7f98ca a11y: Protect should_present() from empty contexts
If the GtkAccessible implementation returns a NULL context, we should
not be calling methods on it.
2020-11-11 18:33:15 +00:00
Emmanuele Bassi
73b14a3c3a a11y: Do not leak the ATContext in GtkStackPage
GtkStackPage is not a widget, so it must release the reference on the
ATContext it owns.
2020-11-11 18:33:15 +00:00
Emmanuele Bassi
40c0826921 a11y: Mark more containers as structural elements
Widgets that just provide grouping and layout to other widgets should
not be relevant to the accessible tree.
2020-11-11 18:33:15 +00:00
Emmanuele Bassi
27b9b2e76c a11y: Use the window title as its label 2020-11-11 18:33:15 +00:00
Emmanuele Bassi
04c4d293a7 a11y: Skip unlabelled structural roles
If a structural role is left unlabelled, just leave it unnamed.
2020-11-11 18:33:15 +00:00
Emmanuele Bassi
033791b374 a11y: Translate ARIA windows to AT-SPI frames
For backward compatibility with GTK3.
2020-11-11 18:33:15 +00:00
Emmanuele Bassi
95ee5ff424 a11y: Add more ARIA/AT-SPI role translations 2020-11-11 18:33:15 +00:00
Emmanuele Bassi
65d29e00c7 a11y: Realize parent ATContext for the stack page
Just like for popovers, the stack page is not directly connected on the
widget's DOM, so we need to realize the parent ATContext ourselves.
2020-11-11 18:33:15 +00:00
Emmanuele Bassi
3b2cd972d5 a11y: Implement missing atspi.Component getters
Some of them are entirely innocuous, and we can easily provide values
that match what GTK3 provides.
2020-11-11 18:33:15 +00:00
Emmanuele Bassi
428ec29598 a11y: Unrealize ATContext on dispose()
By unrealizing the context we avoid additional work during the dispose
phase, in case widget code updates the accessible state. We use
GtkAccessible's API, to ensure we unrealize the right ATContext, instead
of the one we store inside GtkWidgetPrivate.

We drop the ATContext instance inside GtkWidget during finalization, to
mop up eventual vivifications there.
2020-11-11 18:33:15 +00:00
Matthias Clasen
bfe5b0d1b7 Adwaita: Don't do n-th child things for list rows
Making the list row child css depend on the position
is very expensive, and does not acutally work correctly
(since we don't have widgets for all children, so the
position of the child widget does not reflect the actual
model item position).

To make this more palatable, use the bottom border
instead of the top border, since most lists have a natural
border at the top (with headers), and may end up with
empty space at the bottom.
2020-11-11 13:18:08 -05:00
Matthias Clasen
82b855cc4b label: Avoid a needless strdup
Don't duplicate the string before we know if it
has actually changed.
2020-11-11 12:24:35 -05:00
Matthias Clasen
0db504edde label: Optimize GtkLabel setters
The overarching goal here is to not queue a resize
unless something has actually changed. In columnview
scenarios, we often deal with hundreds of labels.

Labels are cattle, not pets.
2020-11-11 11:48:27 -05:00
Matthias Clasen
5ed3ad6cc8 gtk-demo: Split off SvgPaintable
Put the SvgPaintable implementation into its
own source files, for ease of copying.
2020-11-11 10:35:54 -05:00
Matthias Clasen
27c4c19333 Don't hide widgets in dispose()
This is leftover code from when widgets were hidden
by default, and was setting them back to their initial
state.

This is getting in the way now, as hiding the widget
updates the HIDDEN accessible state, which ends up
re-creating the at context that we've already disposed
of, leading to memory leaks.
2020-11-11 10:35:54 -05:00
Matthias Clasen
74a7f73239 Merge branch 'matthiasc/builder-requires' into 'master'
Matthiasc/builder requires

See merge request GNOME/gtk!2806
2020-11-11 03:53:52 +00:00
Matthias Clasen
a047b7d6d1 Merge branch 'fix-demos-wo-pangoft2' into 'master'
gtk-demo: Fix building scrolling demo without PangoFT2

See merge request GNOME/gtk!2807
2020-11-11 03:50:46 +00:00
Chun-wei Fan
a76f37a501 gtk-demo: Fix building scrolling demo without PangoFT2
For builds that do not have PangoFT2, the demo fails to link because we weren't
building listview_ucd.c.  Fix the build by building listview_ucd.c with
script-names.c and unicode-names.c for all builds, as we now require a Pango
version that already always depends on HarfBuzz and those sources do not use
anything from PangoFT2.
2020-11-11 11:15:05 +08:00
Matthias Clasen
d6a0948182 testsuite: Update buildertool tests
gtk-builder-tool simplify --3to4 now produces a
<requires lib="gtk" version="4.0"/>.
Adapt for that, and also add some tests that check that we
actually verify the requires, and accept 3.99 and 4.0, but
not 5.x.
2020-11-10 19:20:51 -05:00
Matthias Clasen
7215c74933 buildertool: Supplant a requires
When we convert a ui file to GTK 4 syntax, we *know*
that it requires GTK 4, so put that in the output.
2020-11-10 19:19:40 -05:00
Matthias Clasen
e4be785c6c builder: Be a bit more strict about requires
Check that the major version matches (without this, the
requires check is really toothless), but allow 3.99 to
match 4.0.
2020-11-10 19:18:26 -05:00
Matthias Clasen
18779b9d67 testsuite: Remove <requires> from ui files
We don't need these here, the testsuite is shipped
with GTK.
2020-11-10 19:17:45 -05:00
Matthias Clasen
9b056f57f7 examples: Remove requires from ui files
No need to check requires for things that are shipped
with GTK.
2020-11-10 18:38:54 -05:00
Matthias Clasen
d6c753bde7 gtk4-demo: Remove <requires> from ui files
No need to check requires for things that are shipped
with GTK.
2020-11-10 18:37:40 -05:00
Matthias Clasen
d69a943661 gtk: Remove <requires> from ui files
We don't need to check requirements for things
that are shipped *with* gtk.
2020-11-10 18:36:03 -05:00
Matthias Clasen
0ececc7109 Merge branch 'ebassi/for-master' into 'master'
Ebassi/for master

Closes #3343 and #3342

See merge request GNOME/gtk!2804
2020-11-10 18:33:36 +00:00
Matthias Clasen
3cc0870084 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2805
2020-11-10 16:59:47 +00:00
Emmanuele Bassi
2229d7f66c docs: Add example of relations with lists of references 2020-11-10 14:38:09 +00:00
Emmanuele Bassi
ed7619ec16 a11y: Clone GtkATContext in GtkModelButton
The hypothetical widget that needs to clone ATContext instances
because it needs to control the accessible role post-construction is
really GtkModelButton.

Fixes: #3342
2020-11-10 14:31:57 +00:00
Emmanuele Bassi
7ed06480cf a11y: Add private API to clone a GtkATContext
Some widgets might want to override GtkAccessible and create their own
context in order to control the accessible role post-construction time.
To avoid explicitly copying the existing state over from the original
ATContext to the new one, we need a way to clone the context's state
from inside the ATContext itself.
2020-11-10 14:31:56 +00:00
Emmanuele Bassi
f9db651f32 a11y: Do not copy the list of references
The constructor for GtkReferenceListAccessibleValue is transfer full,
which means we should not be copying the GList around.

Fixes: #3343
2020-11-10 14:31:56 +00:00
Emmanuele Bassi
c264254d4b a11y: Parse reference lists using varargs
Using GList is a bit lame, and makes the API more complicated to use
than necessary in the common case.

The only real use case for a GList is gtk_widget_add_mnemonic_label(),
and for that we can use the GValue-based API instead.

Fixes: #3343
2020-11-10 14:31:56 +00:00
Emmanuele Bassi
6af89e9034 a11y: Add GValue initializers for accessible attributes
Consumers of the GValue-based API for GtkAccessible need to have a way
to initialize the GValue with the correct type for the given attribute.
2020-11-10 14:31:56 +00:00
Emmanuele Bassi
1bdc8b9061 a11y: Proxy GtkWidget:accessible-role
The accessible-role property in GtkWidget has three possible targets:

 - the :accessible-role of a GtkATContext, if realized
 - the accessible_role field of GtkWidgetPrivate
 - the accessible_role field of GtkWidgetClassPrivate

When we set the accessible role of a widget using the GObject property
mechanism, we want to either set the GtkWidgetPrivate.accessible_role
field, if there's no ATContext *or* if the ATContext is not realized.
Conversely, when we get the accessible-role property we want to have a
series of fallbacks in place:

 - if GtkAccessible.get_at_context() returns an ATContext, and that
   ATContext is realized, return the :accessible-role of the context
 - if GtkWidgetPrivate.accessible_role is not WIDGET, return the
   stored accessible role
 - return GtkWidgetClassPrivate.accessible_role

This should help catch the case of getting the accessible role of
widgets that override GtkAccessible.get_at_context(), like
GtkModelButton.

See: #3342
2020-11-10 14:31:56 +00:00
Matthias Clasen
c442f9f05a printdialog: Plug listmodel memory leaks
We were leaking references returned from g_list_model_get_item
in some places.
2020-11-10 09:07:54 -05:00
Matthias Clasen
6cbd7e29dd fontchooser: Plug listmodel memory leaks
We were leaking references returned from g_list_model_get_item
in some places.
2020-11-10 09:07:40 -05:00
Matthias Clasen
6079033cde columnview: Plug listmodel memory leaks
We were leaking references returned from g_list_model_get_item
in some places.
2020-11-10 09:07:22 -05:00
Matthias Clasen
d63afaf5ad x11: Plug listmodel memory leaks
We were leaking references returned from g_list_model_get_item
in some places.
2020-11-10 09:07:01 -05:00
Matthias Clasen
7e089664fc win32: Plug listmodel memory leaks
We were leaking references returned from g_list_model_get_item
in some places.
2020-11-10 09:06:37 -05:00
Matthias Clasen
06fbad0b26 wayland: Plug listmodel memory leaks
We were leaking references returned from g_list_model_get_item
in some places.
2020-11-10 09:05:55 -05:00
Yuri Chornoivan
2a3c3b4c6a Update Ukrainian translation 2020-11-10 08:15:59 +00:00
Yuri Chornoivan
eb3933cffd Update Ukrainian translation 2020-11-10 07:58:38 +00:00
Matthias Clasen
d1de9234c5 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2803
2020-11-10 04:47:28 +00:00
Matthias Clasen
3e8260d528 gtk-demo: Plug a memory leak 2020-11-09 23:29:03 -05:00
Matthias Clasen
192f515682 gtk-demo: Tweak a demo title 2020-11-09 23:28:45 -05:00
Matthias Clasen
2543c9f5a3 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2802
2020-11-10 01:42:30 +00:00
Matthias Clasen
a745dbfc15 gkt-demo: Add a columview to the scroll demo
This is an interesting case, since it has many labels,
and we are struggling to provide good scrolling performance.
2020-11-09 20:07:09 -05:00
Matthias Clasen
14be50839e gtk-demo: Improve consistency
Make the shortcut triggers demo big enough
to not ellipsize the window title.
2020-11-09 19:54:17 -05:00
Matthias Clasen
a85d9cda07 gtk-demo: Improve consistency
Make the paintable svg demo follow the same
pattern we use for other demos.
2020-11-09 19:53:44 -05:00
Matthias Clasen
7d49f1e250 gtk-demo: Improve consistency
Make the paintable emblems demo follow the same
pattern we use for other demos.
2020-11-09 19:52:28 -05:00
Matthias Clasen
6fa2936956 gtk-demo: Set default size for drawingarea demo
Set a default size, so we don't ellipsize the window
title when the window is presented.
2020-11-09 18:50:43 -05:00
Matthias Clasen
b81463e7d3 gtk-demo: Plug a memory leak 2020-11-09 18:48:10 -05:00
Matthias Clasen
b622745501 gtk-demo: Plug a memory leak 2020-11-09 18:48:10 -05:00
Matthias Clasen
5379a4bf34 a11y: Clean up properly in unregister_object
Things that are set up in register_object should
be cleaned up in unregister_object.
2020-11-09 18:48:10 -05:00
Matthias Clasen
b966f593a5 Merge branch 'wip/jimmac/search-entry-icon' into 'master'
search entry: icon

Closes #3340

See merge request GNOME/gtk!2801
2020-11-09 22:41:41 +00:00
Jakub Steiner
706a8f9784 search entry: icon
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3340
2020-11-09 22:55:21 +01:00
Matthias Clasen
2dc7e327ad Merge branch 'ebassi/for-master' into 'master'
docs: Add missing a11y environment variables

See merge request GNOME/gtk!2788
2020-11-09 17:19:12 +00:00
Matthias Clasen
7b151c3ef0 Merge branch 'kinetic-scroll-velocity-accumulation' into 'master'
scrolledwindow: Accumulate velocity with kinetic scrolling

See merge request GNOME/gtk!2768
2020-11-09 17:14:03 +00:00
Emmanuele Bassi
0af6630521 a11y: Consolidate accessibility environment variables
Use a single environment variable for everything:

 - select the ATContext implementation
 - select the test ATContext
 - disable ATContext entirely

We use the same pattern as GSK_RENDERER, GTK_DEBUG, etc.

The documentation needs to be updated to include the environment
variable.
2020-11-09 16:21:49 +00:00
Chris Lord
4b459a99be scrolledwindow: Accumulate velocity with kinetic scrolling
Accumulate existing velocity when decelerating from a swipe if the swipe
velocity is above a certain fraction of that existing velocity.
2020-11-09 15:28:32 +00:00
Matthias Clasen
e093ed7d67 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #3337

See merge request GNOME/gtk!2799
2020-11-09 14:21:26 +00:00
Matthias Clasen
ddbea8feda Remove GtkPlacesOpenFlags from public headers
The GtkPlacesOpenFlags enum is only used in private
API, so move it to private headers. Since we still need
a GType for it, add gtkplacessidebarprivate.h to the
headers we use for generating private enum types. In turn,
this registers the other private enums in that header, so
take the opportunity to fix their naming, and use the
generated types for the corresponding sidebarrow properties.

Fixes: #3337
2020-11-09 08:45:36 -05:00
Matthias Clasen
6b5dff5667 docs: Document GTK_MEDIA
Add a paragraph about the GTK_MEDIA environment variable.
2020-11-08 09:58:26 -05:00
Matthias Clasen
53cd499621 Revert "Update gtktreestore.c: gtk_tree_store_remove didn't have the proper comment annotation"
This reverts commit 32baa0a549.

See discussion in https://gitlab.gnome.org/GNOME/gtk/-/issues/78
for the background.
2020-11-07 21:36:34 -05:00
Matthias Clasen
30c5a6f79c Merge branch 'patch-3' into 'master'
gtk/gtktextbuffer: remove GtkTextBufferTargetInfo

See merge request GNOME/gtk!2797
2020-11-08 01:11:26 +00:00
Emmanuele Bassi
4e1191550c Merge branch 'patch-4' into 'master'
gtk/gtkversion: fix doc comment references

See merge request GNOME/gtk!2798
2020-11-08 00:50:40 +00:00
David Lechner
3b1363d31a gtk/gtkversion: fix doc comment references
Cross-references for constants use the "%" prefix rather than the "#" prefix.
2020-11-07 23:57:13 +00:00
David Lechner
160e29ea95 gtk/gtktextbuffer: remove GtkTextBufferTargetInfo
GtkTextBufferTargetInfo is not used anywhere and can be removed.
2020-11-07 22:29:11 +00:00
Emmanuele Bassi
b9adad304e Merge branch 'patch-6' into 'master'
gtk/enums: remove GtkPopoverConstraint

See merge request GNOME/gtk!2796
2020-11-07 22:19:33 +00:00
Emmanuele Bassi
ef17d716d7 Merge branch 'patch-4' into 'master'
doc: fix missing GtkNotebookTab

See merge request GNOME/gtk!2794
2020-11-07 22:01:33 +00:00
Emmanuele Bassi
8ec01772be Merge branch 'patch-5' into 'master'
gtk/enums: remove GtkMenuDirectionType

Closes #3336

See merge request GNOME/gtk!2795
2020-11-07 21:59:04 +00:00
David Lechner
4084b4c6c6 gtk/enums: remove GtkPopoverConstraint
GtkPopoverConstraint is no longer used anywhere and can be removed.
2020-11-07 21:47:32 +00:00
David Lechner
c3cb8e0a79 gtk/enums: remove GtkMenuDirectionType
This was used by GtkMenu and can safely be removed.

Closes #3336
2020-11-07 21:39:34 +00:00
Emmanuele Bassi
19b5e5349e Merge branch 'gles-no-queries' into 'master'
gl renderer: Generate queries only on desktop GL

See merge request GNOME/gtk!2792
2020-11-07 21:33:09 +00:00
Emmanuele Bassi
f87923e09e Merge branch 'patch-3' into 'master'
docs: include GtkFilterMatch

See merge request GNOME/gtk!2793
2020-11-07 21:32:40 +00:00
David Lechner
05684f6c3c doc: fix missing GtkNotebookTab
GtkNotebookTab was listed under private, but it is used by the "focus-tab" signal, so it needs to be public.
2020-11-07 21:17:09 +00:00
Emmanuel Gil Peyrot
08193ecf1c gl renderer: Generate queries only on desktop GL
On desktop GL, GL 1.5 or GL_ARB_occlusion_query is required to get the
glGenQueries() etc. symbols.  This isn’t the case on GLES, where they
are provided by GL_EXT_occlusion_query_boolean, and more importantly
have never been made core.

This patch allows gtk4-demo to start when GDK_DEBUG=gl-gles is set, on
my Mali 400 MP running the Lima driver from Mesa.
2020-11-07 21:49:42 +01:00
David Lechner
8c9a827516 docs: include GtkFilterMatch
The GtkFilterMatch enum type was missing from the documentation.
2020-11-07 20:45:41 +00:00
Timm Bäder
638987f359 Merge branch 'dlech-master-patch-13962' into 'master'
gtk/enums: fix doc comment references

See merge request GNOME/gtk!2791
2020-11-07 18:47:55 +00:00
David Lechner
8190f0c420 gtk/enums: fix doc comment references
Enum members need a "%" prefix rather than "@" or "%@" in order to
automatically create links in the documentation.
2020-11-07 17:46:26 +00:00
Arnaud Bonatti
f7de0bc9c8 Fix tests with regard to GtkBuilder <requires>. 2020-11-07 16:17:36 +01:00
Arnaud Bonatti
08f2990eac Document the GtkBuilder <requires> tag changes. 2020-11-07 16:17:14 +01:00
Arnaud Bonatti
e6d46ec5ad Teach gtk-builder-tool to rewrite <requires>. 2020-11-07 16:17:01 +01:00
Arnaud Bonatti
db6d7dccd8 Drop “gtk+” plus sign in GtkBuilder <requires>. 2020-11-07 16:16:55 +01:00
Piotr Drąg
4e8a5f2ec8 Update POTFILES.skip 2020-11-07 11:45:07 +01:00
Matthias Clasen
63e9414210 Merge branch 'wip/carlosg/for-master' into 'master'
Minor text handle fixes

See merge request GNOME/gtk!2787
2020-11-07 03:10:27 +00:00
Carlos Garnacho
4751ac1ac8 gtk/textview: Improve check for cursor-mode
Check the text handle role, instead of looking for the other handle
visibility. The other handle may be invisible during selection mode
(e.g. pointing to offscreen contents). This fixes both this code
switching to cursor mode out of the blue, and possible crashes later
on as this handle might be hidden in the process, while its own event
controller is handling events on the parent surface.
2020-11-06 14:30:18 +01:00
Carlos Garnacho
9d56c56117 gtk/texthandle: Point handle to the middle of the pointing_to rect
At least vertically, this gives again as much space up and down before
moving the selection the the prev/next line.
2020-11-06 14:28:46 +01:00
Matthias Clasen
0d82faa239 Merge branch 'wip/carlosg/for-master' into 'master'
Text handle fixes

Closes #3176

See merge request GNOME/gtk!2785
2020-11-06 01:23:16 +00:00
Matthias Clasen
fb27724042 Merge branch 'wip/chergert/gdk-macos-for-master' into 'master'
macos: tweak opacity, color/alpha size requests

See merge request GNOME/gtk!2786
2020-11-06 01:20:23 +00:00
Christian Hergert
90141ef305 macos: use NSOpenGLContext directly for current tracking
We don't need to interact with GdkGLContext here to keep the
current context active.
2020-11-05 13:57:41 -08:00
Christian Hergert
bc05da8dc0 macos: explicitly request color and alpha sizes 2020-11-05 13:37:25 -08:00
Christian Hergert
bf3e1e5b40 macos: use opaque GL context when possible
This is better for situations where the window is decorated and therefore we can
rely on window system clipping of rounded corners.
2020-11-05 13:34:29 -08:00
Carlos Garnacho
0ae93c8cdc gtk/textview: Do not forcibly show text handles
The gtk_text_view_set_handle_position() function called some lines above
takes care of handle visibility already, also accounting for other
conditions (e.g. whether the handle points to contents onscreen).
Forcibly showing handles here misbehaves if the handle should stay hidden,
and somewhat expensively as it involves creating and throwing a native
surface every time.
2020-11-05 21:29:20 +01:00
Carlos Garnacho
f9813019a7 gtk/textview: Defer touchscreen focus placing to drag end
With the scrolledwindow drag gesture not claiming the sequence immediately,
we end up placing the cursor (and undoing the previous selection) each time
we scroll.

There is already handling too short drags in ::drag-end, so let this code
handle touchscreens as well.
2020-11-05 21:29:20 +01:00
Carlos Garnacho
5e907ebd58 gtk/textview: Clean up further if the drag gesture is taken over
If the gesture becomes captured (e.g. from a parent scrolledwindow), we
leave some things in the air. Clean these up properly. This is recurrent
with touch scroll.
2020-11-05 21:29:20 +01:00
Carlos Garnacho
fa5fa3a881 gtk/imcontextwayland: Unset focus when unsetting widget
In destruction paths of a focused entry, the IM context might first
end up detached from its widget, then destroyed. This currently prevents
the IM context from detaching itself from the GtkIMContextWaylandGlobal.

Make it do so when unsetting the client widget, so the IM context gets
properly unfocused before destruction.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3176
2020-11-05 21:29:20 +01:00
Carlos Garnacho
9b9cc2f947 gtk/texthandle: Handle events on parent surface's native
In wayland, popup positioning and event handling are doubly async.
This makes it unreliable to figure out parent surface coordinates
out of the popup position and the events received. This results in
jumpy text handles there.

The best way to deal with parent surface coordinates is to handle
the events there. Make the handles transparent to input, and make
the drag gesture be set up on the parent widget's native.

The gesture is set up in the capture phase, setting it on the native
(as opposed to the parent widget) achieves a feeling similar to it
being a distinct surface, as it should take precedence over other
gestures in the emission chain (e.g. scrolledwindows).

As everything is in parent widget's native's coordinates, the drag
handles become smooth again.
2020-11-05 21:29:20 +01:00
Carlos Garnacho
80f5be8b13 gdk/wayland: Ensure to update input area on map
If a surface is hidden, then shown again, it should preserve the
input area specified. Make sure that happens.
2020-11-05 21:29:20 +01:00
Matthias Clasen
ec5b5e8aaa Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #3325

See merge request GNOME/gtk!2784
2020-11-05 16:43:08 +00:00
Emmanuele Bassi
95463719ae Merge branch 'ebassi/for-master' into 'master'
Ebassi/for master

See merge request GNOME/gtk!2783
2020-11-05 15:37:38 +00:00
Emmanuele Bassi
041415e9b4 docs: Add a note on the "presentation" role 2020-11-05 14:50:40 +00:00
Emmanuele Bassi
abd5383d40 docs: Add a section on accessible buttons
Anything that behaves like a button should do so at the accessibility
level as well.
2020-11-05 13:57:50 +00:00
Emmanuele Bassi
c5dc0e2e4c a11y: Use proper role and state for tree expander image
The "expander" image is a button, and it controls the expansion of the
row, so it has a state associated to it that we must update.
2020-11-05 13:46:43 +00:00
Emmanuele Bassi
88116712f6 a11y: Use "presentation" role instead of "hidden" state
The intended use case of the "presentation" role is

| […] when an element is used to change the look of the page but does not
| have all the functional, interactive, or structural relevance implied
| by the element type, or may be used to provide for an accessible
| fallback in older browsers that do not support WAI-ARIA.

One of the examples is, literally:

| An element whose content is completely presentational (like a spacer
| image, decorative graphic, or clearing element);

Which fits perfectly for the GtkTreeExpander's "indent" builtin icon
widget.
2020-11-05 13:25:53 +00:00
Emmanuele Bassi
7dfa41bbc4 a11y: ARIA's "presentation" role maps to ATSPI_ROLE_SECTION
See the mapping role table in the Core-AAM normative document:

https://w3c.github.io/core-aam/#mapping_role_table
2020-11-05 13:14:08 +00:00
Matthias Clasen
c09ff35df4 dragicon: Make a function propertly exported
Mark gtk_drag_icon_create_widget_for_value with
GDK_AVAILABLE_IN_ALL, since it is meant to be public.
Also, clarify the documentation a bit.

Fixes: #3325
2020-11-05 07:23:38 -05:00
Matthias Clasen
d526bcc71b Cosmetics
Fix argument ordering of gdk_cursor_new_from_name.
2020-11-04 23:36:09 -05:00
Matthias Clasen
13d1e497f7 testsuite: Improve GdkCursor coverage 2020-11-04 23:36:09 -05:00
Matthias Clasen
3eaae748d3 3.99.4 2020-11-04 21:46:10 -05:00
Matthias Clasen
7f16067383 Merge branch 'wip/chergert/gdk-macos-gl-renderer' into 'master'
macos: gl context improvements and event cleanup

See merge request GNOME/gtk!2780
2020-11-05 02:21:02 +00:00
Matthias Clasen
024e048c26 Merge branch 'wip/chergert/fix-macos-pointer-position-over-surface' into 'master'
macos: fix calculation of mouse position

See merge request GNOME/gtk!2781
2020-11-05 02:19:18 +00:00
Christian Hergert
c31c3848df macos: fix calculation of mouse position
This fixes the calculation of the position of the pointer over the surface
which was incorrectly providing negative values.
2020-11-04 18:03:54 -08:00
Matthias Clasen
b0e0af1838 Merge branch 'patch-5' into 'master'
Update comment annotations of gtk_tree_model_iter_previous and...

See merge request GNOME/gtk!2775
2020-11-05 01:53:34 +00:00
Matthias Clasen
3785bf1f17 Merge branch 'fix-issue-2019-for-master' into 'master'
[master] GdkW32: remove klassTEMPSHADOW

Closes #2019

See merge request GNOME/gtk!2750
2020-11-05 01:53:02 +00:00
Matthias Clasen
79fb5724f9 Merge branch 'mr1063-for-master' into 'master'
Forward port MR !1063 (Win32 IME fixes) to GTK master

See merge request GNOME/gtk!2777
2020-11-05 01:48:37 +00:00
Christian Hergert
65b2ea1888 macos: resize extra GL window/view when surface changes
Once we figure out what is going on with textures, changes are we'll be
able to let this stay a zero rect. But that is still a bit up in the air right now.
2020-11-04 17:21:21 -08:00
Christian Hergert
6309bd12ac macos: clip damage when swapping buffers
This ensures that we only copy the changed area.
2020-11-04 17:21:17 -08:00
Christian Hergert
7444a151b2 macos: remove synthesize_motion helper
We can use gdk_surface_request_motion() now instead of our extra
helper to do essentially the same thing.
2020-11-04 16:58:50 -08:00
Christian Hergert
ce9cc2db86 macos: always create dummy window/view for GL context
This simplifies the creation by always creating the dummy views, and then
removes it if necessary by detecting the begin_frame/end_frame pair.
2020-11-04 16:52:12 -08:00
Christian Hergert
e91b930648 Revert "Simplify gdk_surface_queue_render"
This reverts commit 2120e9df88.
2020-11-04 16:28:13 -08:00
Matthias Clasen
ed78fb1366 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2779
2020-11-04 20:41:09 +00:00
Matthias Clasen
388f12b7d9 Merge branch 'ebassi/for-master' into 'master'
Ebassi/for master

See merge request GNOME/gtk!2778
2020-11-04 20:37:39 +00:00
Matthias Clasen
8ae415acff popovermenu: Fail gracefully if no model
If we don't have a model yet, return FALSE from
gtk_popover_menu_add_custom().
2020-11-04 14:59:32 -05:00
Matthias Clasen
d2cc9365fc Cosmetics
Extraneous pair of parens snuck in with 2120e9df88.
2020-11-04 14:59:27 -05:00
Matthias Clasen
dcfb6e5ef5 surface: Be smarter about autohide
When we close grabbing popups due to an outside
click, check at each level if the click is still
outside. This makes closing the nested popover
menu in the popover on page 3 of widget-factory
work as expected, when you click the menubutton
again.
2020-11-04 14:56:30 -05:00
Matthias Clasen
75f96b83de surface: Be more lenient for autohide
When an event happens on a non-grabbing popup that hangs off
a grabbing popup, don't trigger the autohide. This makes touch
text handles work inside the popover on page 3 of widget-factory.
2020-11-04 14:56:30 -05:00
Emmanuele Bassi
66bba1493e a11y: Remove stray g_printerr() 2020-11-04 19:39:08 +00:00
Emmanuele Bassi
1dde54b872 a11y: Hide the "indent" in GtkTreeExpander
It's just padding.
2020-11-04 19:38:14 +00:00
Emmanuele Bassi
c48a990778 a11y: Describe window controls
The window controls for client side decorations have only icons, which
means they are not accessible.
2020-11-04 18:59:11 +00:00
Matthias Clasen
23c425618e Merge branch 'a11y/atcontext-realize' into 'master'
A11y/atcontext realize

See merge request GNOME/gtk!2772
2020-11-04 18:10:55 +00:00
Matthias Clasen
d2a7ecf72c gtk-demo: Simplify the run button
Don't create the label manually. It is not necessary,
and letting the button do it also improves the
accessibility setup.
2020-11-04 12:54:48 -05:00
Matthias Clasen
f220a1e3c7 gtk-demo: Set some accessible properties
Set labels in the builder demo. The ARIA authoring practices
say that both menubars and toolbars *must* have an accessible
label.
2020-11-04 12:53:23 -05:00
Emmanuele Bassi
ba63aa76ca a11y: Move parent context ref getter to its own function
Keeps the body of handle_accessible_get_property() readable.
2020-11-04 17:16:24 +00:00
Emmanuele Bassi
72415eaa49 a11y: Make the Button labelled by its child label
Establish the relation whenever we set the label widget.
2020-11-04 17:15:13 +00:00
Emmanuele Bassi
d88f7c9459 a11y: Use the tooltip text as the accessible description
It's more common to have a tooltip as the accessible description than an
explicit description. This is also the behaviour of GTK3.
2020-11-04 17:15:13 +00:00
Emmanuele Bassi
425d8ad02a Set accessible label on GTK Demo's primary menu
Otherwise its label is going to be "GtkMenuButton".
2020-11-04 17:15:13 +00:00
Emmanuele Bassi
ae9758b964 a11y: Unrealize ATContext on dispose 2020-11-04 17:15:13 +00:00
Matthias Clasen
828a067b2b Propagate accessible-role to backend
We want to allow setting the accessible role as long
as the context is unrealized, so we need to propagate
the new role.
2020-11-04 11:53:07 -05:00
Matthias Clasen
bb24b350ac gtk-demo: Set an accessible role
Set an accessible role for the toolbar in the
builder demo. This tests accessibility support
in GtkBuilder.
2020-11-04 11:36:52 -05:00
Emmanuele Bassi
dafb2b0361 a11y: Allow updating role on unrealized contexts
We can still change the accessible role if an ATContext instance is
unrealized.
2020-11-04 15:22:31 +00:00
Emmanuele Bassi
30210c7087 a11y: Move ATContext to an explicit realization model
We are doing too much work during the construction phase of the
AT-SPI backend for GtkATContext. Instead of having the AtSpiContext
register itself at construction time, let's add explicit realize
and unrealize operations, and connect the ATContext realization to the
rooting operation of a GtkWidget.
2020-11-04 15:02:44 +00:00
Philip Zander
d8a795df0a Win32 IME fixes
See merge request !1063
2020-11-04 17:17:52 +08:00
kai-berlin
499e4b4c50 broadway: Set modifier state of scroll events
Set modifier state of scroll events, so Ctrl-scroll
works.

Fixes: #2733
2020-11-03 19:21:00 -05:00
Matthias Clasen
fd52220b1b Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #3318, #3319, and #3320

See merge request GNOME/gtk!2776
2020-11-03 20:15:08 +00:00
Matthias Clasen
e9438224ab texthandle: Queue a draw when role changes
This helps with role changes not taking immediate
effect.

Fixes: #3320
2020-11-03 14:39:29 -05:00
Matthias Clasen
2120e9df88 Simplify gdk_surface_queue_render
We can just call gdk_surface_invalidate_rect here
like we do elsewhere in gdk, and I'm a bit uncertain
about the current code that adds an empty update
region.
2020-11-03 14:37:27 -05:00
Matthias Clasen
ddd16dd312 texthandle: Fix positioning
Use the same approach we use for popovers, using
gtk_widget_get_surface_allocation. It works.

Fixes: #3319
2020-11-03 12:37:39 -05:00
Matthias Clasen
7624f66fec widget-factory: Make sure we close popover on page 3
We don't want the popover to stay open when we open
an about dialog or shortcuts window. Since cascade-popdown
would also affect e.g. the context menu of the text widgets,
do this explicitly.
2020-11-03 12:09:43 -05:00
Matthias Clasen
dab11ea841 popover: Change default for cascade-popdown
We've found a number of cases where this cascading
has unexpected side-effects. So, turn it off by
default, and only set it for menus.
2020-11-03 11:00:32 -05:00
Matthias Clasen
a3f3dc0f1c Adwaita: Set a background for magnifiers
The magnifier in entries is magnifying the GtkText
widget, which does not draw any background itself.
Therefore, we give the magnifier a background, to
make things look as expected.

Fixes: #3318
2020-11-03 11:00:32 -05:00
Matthias Clasen
5d59447ccb magnifier: Set a css name
Predictably, we use the name "magnifier".
2020-11-03 11:00:32 -05:00
Matthias Clasen
e3c38e4143 NEWS: Updates 2020-11-03 11:00:32 -05:00
Matthias Clasen
e5ec4df702 docs: Mention g_file_get_basename
Mention g_file_get_basename in the migration guide section
about GtkFileChooser api changes.
2020-11-03 11:00:32 -05:00
Danny Milosavljevic
1340ff2bc2 Update comment annotations of gtk_tree_model_iter_previous and gtk_tree_model_iter_next to state that the ITER parameter is modified. 2020-11-03 15:10:11 +00:00
Matthias Clasen
dbdc909e19 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2774
2020-11-03 12:14:21 +00:00
Matthias Clasen
c6ef1943e4 gtk-demo: Remove more gtk3-demo icon uses
Use our own logo everywhere.
2020-11-02 22:50:03 -05:00
Matthias Clasen
a3c9f8594a gtk-demo: Tweak images demo
Use our own logo instead of the gtk3-demo one, and
tweak the headings to refledct what we show.
2020-11-02 22:43:44 -05:00
Matthias Clasen
354f2b65fa gtk-demo: Reanimate floppy buddy
Implement a GdkPaintable wrapper around GdkPixbufAnimation,
so floppy buddy can waive again.
2020-11-02 21:38:02 -05:00
Matthias Clasen
b3657d5f2e widget-factory: Restore modality of the about dialog
Make the about dialog of widget-factory modal again.
This was lost in 87a8fda163.
2020-11-02 21:37:55 -05:00
Timm Bäder
82ca65956f gl renderer: Make debugging code shorter 2020-11-02 14:55:14 -05:00
Timm Bäder
c8c2106f3e gl renderer: Refactor vertex data loading code 2020-11-02 14:55:14 -05:00
Timm Bäder
8178dfb85a gl renderer: Use the load_vertex_data* functions more often 2020-11-02 14:55:14 -05:00
Timm Bäder
50e78198a8 gl renderer: More load_vertex_data* usage 2020-11-02 14:55:14 -05:00
Timm Bäder
ee04cbcfa8 gl renderer: Reword a comment 2020-11-02 14:55:14 -05:00
Timm Bäder
fc312f7ffe gl renderer: Remove an outdated comment 2020-11-02 14:55:14 -05:00
Timm Bäder
e6e964c3f3 gl renderer: Refactor rendering shadow nodes
Also use load_vertex_data_with_region here.
2020-11-02 14:55:14 -05:00
Timm Bäder
df5e796d99 gl renderer: Refactor blurred shadow drawing code
We already have various load_vertex_data* code, so try to reuse that
here.
2020-11-02 14:55:14 -05:00
Timm Bäder
d3239c953d gl renderer: Nine-slice unblurred outset shadows
See #3284
2020-11-02 14:55:13 -05:00
Timm Bäder
fb9a3bf32b printoperation: Remove double assignment 2020-11-02 14:55:13 -05:00
Matthias Clasen
ace83a938d Merge branch 'matthiasc/for-master' into 'master'
gtk-demo polish

See merge request GNOME/gtk!2773
2020-11-02 19:36:09 +00:00
Matthias Clasen
fb028f0fe7 gtk-demo: Renovate the paned demo
Make this look less like testgtk from GTK 2.
2020-11-02 13:56:19 -05:00
Matthias Clasen
8a13909bab fixup: window titles 2020-11-02 12:02:19 -05:00
Matthias Clasen
4e745f06e9 gtk-demo: Polish all entry demos
Make the spacing a bit more consistent, and tweak
some strings here and there.
2020-11-02 12:01:11 -05:00
Matthias Clasen
14b65a3c4f gtk-demo: Polish the search bar demo
Rename this, and make it look a bit less like a
debugging tool, and more like a demo.
2020-11-02 12:00:24 -05:00
Matthias Clasen
64ad490bc1 gtk-demo: Tweak tagged entry styling
Move the tags closer together, and avoid resizing too much.
2020-11-02 11:59:22 -05:00
Matthias Clasen
d2d7a4bcab gtk-demo: Tweak window titles
This is an attempt to improve consistency in the sidebar
and the window titles.
2020-11-02 11:11:44 -05:00
Matthias Clasen
14cbd13ef2 gtk-demo: Use typographic style classes
We don't need to hardcode <u> in markup anymore.
Use the heading style class instead.
2020-11-02 08:38:20 -05:00
Matthias Clasen
efc314196d Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2769
2020-11-02 11:52:13 +00:00
Matthias Clasen
403a70ca89 testsuite: Add tests for gtk4-builder-tool validate 2020-11-01 23:09:26 -05:00
Matthias Clasen
44b36b6321 builder-tool: Stop rewriting GtkPopoverMenu
We no longer allow manual creation of GtkPopoverMenu,
translating individual properties is not going to
change that.
2020-11-01 23:09:26 -05:00
Matthias Clasen
4bd829e3e1 testsuite: Test GtkFixed rewriting 2020-11-01 23:09:26 -05:00
Matthias Clasen
38f74d8a23 builder-tool: Rewrite GtkFixed more
GtkFixedLayout does not have layout properties
for x and y, so turn those into a transform.
2020-11-01 23:09:26 -05:00
Matthias Clasen
2613c2ef9b builder-tool: Avoid duplicate path prefixes
It is enough to print the file in which the error
occurred once; GtkBuilder already makes that part
of its error message.
2020-11-01 23:09:26 -05:00
Matthias Clasen
5751cd662d builder-tool: Install a log writer
Install a log writer function that is a bit simpler than
the default GLib log writer, and does not put PIDs and
timestamps in the output, so we can compare easily in
our testsuite.
2020-11-01 23:09:26 -05:00
Matthias Clasen
4039b713c3 Set G_LOG_USE_STRUCTURED globally
It doesn't make much sense to set this in per-directory
meson files, since that makes use use different logging
facilities in different parts of the project. Set it
globally.
2020-11-01 21:23:35 -05:00
Matthias Clasen
c3f8010b19 testsuite: Test GtkToolbar rewriting 2020-11-01 21:23:35 -05:00
Matthias Clasen
3e8a22ae8a builder-tool: Rewrite GtkToolbar more
Replace GtkToolbar with GtkBox and GtkToolButton with
GtkButton.
2020-11-01 21:23:35 -05:00
Matthias Clasen
c01f3be6e6 testsuite: Test GtkActionBar rewriting 2020-11-01 21:23:35 -05:00
Matthias Clasen
0cf372c814 testsuite: Test GtkPaned rewriting 2020-11-01 21:23:35 -05:00
Matthias Clasen
ac20c9cd41 builder-tool: Fix rewriting GtkPaned
The properties have been renamed in bc6643f3c2.
2020-11-01 21:23:35 -05:00
Matthias Clasen
d74c2a74e5 builder-tool: Drop unneeded code
We are rewriting the tree before simplifying it,
so there is no need to 'keep things for rewriting'
in the simplify phase.
2020-11-01 21:23:35 -05:00
Matthias Clasen
b79637ac41 testsuite: Test GtkOverlay rewriting 2020-11-01 21:23:35 -05:00
Matthias Clasen
e135772119 buildertool: Improve GtkOverlay rewriting
Translate the GtkOverlay:pass-through child property to
the GtkWidget:measure property, and drop the :index
child property.
2020-11-01 21:23:35 -05:00
Matthias Clasen
3cf26b471b Fix the definition of GtkWidget:can-target
We are setting the value to TRUE initially, but
the property had a declared default of FALSE.
This is messing up the simplification of .ui files
with gtk4-builder-tool, since it thinks it can
omit can-target properties when it really can't.
2020-11-01 21:23:35 -05:00
Matthias Clasen
c630285692 Cosmetics 2020-11-01 21:23:35 -05:00
Matthias Clasen
5702b71037 Remove leftover file
This was never used in tests.
2020-11-01 21:23:35 -05:00
Matthias Clasen
a4e5f5ca50 testsuite: More gtk4-builder-tool tests 2020-11-01 21:23:35 -05:00
Matthias Clasen
b0b00d49d2 testsuite: Test gtk4-builder-tool simplify --replace
Run all gtk4-builder-tool test with and without --replace.
This improves test coverage for gtk4-builder-tool
2020-11-01 21:23:35 -05:00
Matthias Clasen
cb018ec047 builder-tool: Avoid a crash
Be more careful about types that have been removed.
I was getting criticals when converting ui files
containing GtkToolbars.
2020-11-01 21:23:35 -05:00
Matthias Clasen
168b21c77e testsuite: Improve coverage for GdkTexture 2020-11-01 21:23:35 -05:00
Matthias Clasen
2dcc641d5a testsuite: Improve coverage for GdkDisplayManager 2020-11-01 21:23:35 -05:00
Matthias Clasen
c8432ae668 testsuite: Improve coverage for seats 2020-11-01 21:23:35 -05:00
Matthias Clasen
642ad4e06f testsuite: Improve coverage for rectangles 2020-11-01 21:23:35 -05:00
Tim Sabsch
924796b478 Update German translation 2020-11-01 14:08:13 +00:00
Piotr Drąg
319d4c7e01 Update Polish translation 2020-11-01 10:37:21 +01:00
Matthias Clasen
07c491f235 testsuite: Improve coverage for keys 2020-10-31 14:57:02 -04:00
Matthias Clasen
970f91ec24 testsuite: Add more css parser tests
Add tests for url parsing.
2020-10-31 09:18:40 -04:00
Matthias Clasen
48381bd4f6 testsuite: Add a forgotten test
I've written this test a while ago, but did not add
it to the test data list in meson.build.
2020-10-31 08:30:02 -04:00
Matthias Clasen
1a12999431 testsuite: Add a css test
This test verifies that CDO and CDC are ignored
as required.
2020-10-31 00:38:49 -04:00
Matthias Clasen
90676540ec css: Fix tokenization of CDO
A CDO is 4 characters: <!--, not 3 as our tokenizer
was pretending.
2020-10-31 00:38:49 -04:00
Matthias Clasen
7db58d5f8d gsk: Don't compile unused code
The NodeSample and GskGLImage code is not used,
so don't compile it.
2020-10-30 23:36:39 -04:00
Matthias Clasen
875452b476 testsuite: Improve coverage for GtkMultiSorter 2020-10-30 23:33:34 -04:00
Matthias Clasen
1c4c5e3b80 testsuite: Improve coverage for GtkStringList 2020-10-30 23:33:15 -04:00
Matthias Clasen
af5e13b9a1 Remove an unused function
The only property of GtkStringObject is readonly since
commit fb14f50ec1, so we don't need a
set_property implementation.
2020-10-30 23:32:30 -04:00
Matthias Clasen
9b78bc4af7 testsuite: Improve coverage 2020-10-30 23:04:23 -04:00
Matthias Clasen
1702a4c223 Drop an unused private function 2020-10-30 22:51:54 -04:00
Matthias Clasen
f0e35c8ed8 Drop unused includes 2020-10-30 22:50:38 -04:00
Matthias Clasen
26150d8489 testsuite: Improve coverage for GtkExpression 2020-10-30 22:27:40 -04:00
Matthias Clasen
48dcbf4935 expression: Fix property expressions for interfaces
We were not checking the passed-in type in the right
way. An interface type can still pass the
g_type_is_a (..., G_TYPE_OBJECT) check, if G_TYPE_OBJECT
is one of its prerequisites. What we need to check is
whether the fundamental type is G_TYPE_OBJECT.
2020-10-30 22:27:40 -04:00
Matthias Clasen
59dd7d8900 testsuite: Improve coverage for GtkMultiFilter 2020-10-30 22:27:40 -04:00
Matthias Clasen
c279bdaa81 testsuite: Improve coverage for GtkStringFilter 2020-10-30 20:15:25 -04:00
Matthias Clasen
01d52a7292 testsuite: Make all css tests run again
The tests in subdirectories of testsuite/css were
using an environment defined in the parent directory,
causing them to not find their test data. Give each
test directory its own environment.
2020-10-30 20:14:17 -04:00
Matthias Clasen
2b38d14bf5 tests: Improve coverage for css data url parsing
Cover the error conditions as well.
2020-10-30 19:26:56 -04:00
Matthias Clasen
d35a21873e testsuite: Improve coverage for GtkBoolFilter 2020-10-30 18:17:50 -04:00
Matthias Clasen
b23cae9643 Drop unused gtk_buildable_set_buildable_property 2020-10-30 17:19:52 -04:00
Matthias Clasen
505df337c2 Add a test for constraints in ui files
Test the various values that are possible for the constraint
attributes.
2020-10-30 16:21:14 -04:00
Matthias Clasen
117997da54 Merge branch 'wip/chergert/gdk-macos-gl-renderer' into 'master'
macos: add more aggressive clip to transparent subview

See merge request GNOME/gtk!2762
2020-10-30 19:48:57 +00:00
Matthias Clasen
19052d4360 gtk-demo: Tweak descriptions of constraints demos
Make these a little longer, and include more details.
2020-10-30 15:26:37 -04:00
Matthias Clasen
2dbaca2464 constraintlayout: Make sure guides get their constraints
When using GtkBuilder to create constraints and guides,
the layout manager is already rooted when the guides get
created, and we were forgetting to create the guides
constraints in this case. Fix it by adding a call to
gtk_constraint_guide_update().

This was showing up in the new builder-based constraints
demo as the guide not having the expected effect.
2020-10-30 15:04:13 -04:00
Matthias Clasen
4b8134b19b constraintlayout: Emit less change notification
This isn't strictly required for correctness, but
it makes the GtkBuilder codepath do the same that
the vfl codepath does: call gtk_layout_manager_layout_changed
only once, after all the constraints have been added.
2020-10-30 15:04:13 -04:00
Matthias Clasen
588fe5b5c1 gtk-demo: Tweak the new constraints demo
With these somewhat random ordering changes, things get
closer to working the same as the code example. Still,
the guide doesn't work right.
2020-10-30 15:04:13 -04:00
Matthias Clasen
b8f44de48e constraintlayout: Fix parsing from ui file
Guides were not properly looked up when creating
constraints in a ui file.
2020-10-30 15:04:13 -04:00
Matthias Clasen
49bdc4f0c2 Add another constraints demo
This one attempts to use constraints in a ui file.
It doesn't work.
2020-10-30 15:04:13 -04:00
Matthias Clasen
a0ee25a21e gtk-demo: Remove unnecessary code
I was distracted by this code that sets names
on widgets in the constraints demo - the names
aren't used and aren't needed, so remove them.
2020-10-30 15:01:50 -04:00
Christian Hergert
d8192013f3 macos: add more aggressive clip to transparent subview
The Cairo implementation for the Macos backend uses a toplevel
window with full transparency and a series of NSView to create opaque
regions. This improves compositor performance because it allows the
display server to avoid costly blends.

However, we want to ensure we clip better when exposing the
transparent region so that we only expose the shadows/corners as
necessary.
2020-10-29 19:41:21 -07:00
Matthias Clasen
8ed1f51f7f Merge branch 'wip/chergert/remove-GDK_WINDOWING_QUARTZ' into 'master'
gdk: remove remaining GDK_WINDOWING_QUARTZ usage

See merge request GNOME/gtk!2761
2020-10-30 01:36:10 +00:00
Matthias Clasen
03fec389f4 docs: Add details for gsk_renderer_new_for_surface
Mention the GSK_RENDERER variable here.
2020-10-29 18:21:44 -04:00
Matthias Clasen
38c39e2aa1 NEWS: Updates 2020-10-29 18:21:32 -04:00
Christian Hergert
6298fd1eef gdk: remove remaining GDK_WINDOWING_QUARTZ usage 2020-10-29 13:57:28 -07:00
Matthias Clasen
5a77994516 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2760
2020-10-29 18:55:53 +00:00
Matthias Clasen
6142238237 Merge branch 'wip/chergert/gdk-macos-gl-renderer' into 'master'
macos: implement GL rendering on with Cairo renderer

See merge request GNOME/gtk!2759
2020-10-29 18:33:13 +00:00
Matthias Clasen
3164f328b5 docs: Some restructuring
Give the GDK docs some more structure.
2020-10-29 14:23:46 -04:00
Matthias Clasen
ce78d0c301 docs: Tweak GdkToplevel docs 2020-10-29 14:23:46 -04:00
Matthias Clasen
94305f248b docs: Tweak GdkPopup docs 2020-10-29 14:23:46 -04:00
Matthias Clasen
3afd5d7a89 docs: Tweak GdkSurface docs
Add more details, and refer to the GdkToplevel / GdkPopup
docs.
2020-10-29 14:23:46 -04:00
Matthias Clasen
d2adbad408 docs: Tweak frame clock docs 2020-10-29 14:23:46 -04:00
Matthias Clasen
2df382277d docs: Small additions for GdkCursor docs 2020-10-29 14:23:46 -04:00
Matthias Clasen
9f71bdd045 docs: Cosmetics
Make the GdkRGBA heading less repetitive.
2020-10-29 14:23:46 -04:00
Matthias Clasen
838d0924b9 docs: Tweak GdkPaintable docs
Minor additions here and there.
2020-10-29 14:23:46 -04:00
Matthias Clasen
1f8d593931 docs: Add some detail to GdkTexture docs
Minor additions here and there.
2020-10-29 14:23:46 -04:00
Matthias Clasen
574a3a456d gdk: Drop GdkPoint from the api
This typedef was not used in any public APIs, and is
only used in the MacOS backend. It is not worth preserving
as public API, move it to the only user.
2020-10-29 14:23:46 -04:00
Matthias Clasen
3617fbab42 docs: Include GDK_WINDOWING_MACOS
We no longer have a Quartz backend, it is called
MacOS now.
2020-10-29 14:23:46 -04:00
Matthias Clasen
29ccd13e15 docs: Stop referring to the Quartz backend
Its MacOS now.
2020-10-29 14:23:46 -04:00
Christian Hergert
de9c9efa6f macos: implement GL context
This implements the basics for a GdkGLContext on macOS. Currently, rendering
only is fully working for the GskCairoRenderer case where we read back pixels
into a cairo surface for rendering. More work on synchronization is required for
the GL on GskGLRenderer case.

When we attempt to render a surface itself with GL, the context will ensure that
the new GdkMacosGLView is placed within the NSWindow. In other cases, we
use a dummy NSView and NSWindow for backing the NSOpenGLContext to
ensure that we can get accelerated drawing.

This gets GtkGLArea working when running with GSK_RENDERER=cairo.
2020-10-29 10:57:02 -07:00
Christian Hergert
eb809ba425 macos: tweak gravity while resizing
This helps a situation where the window contents has not changed
in time for a drawing. Setting the texture gravity helps that side or
corner to be less jittery while moving.

Ideally, we can get to a point where we are synchronized and keeping
up with drawing fast enough to not need this. That may require some
work to drive frame clocks from drawRect: though.
2020-10-29 10:57:02 -07:00
Christian Hergert
adf60fb3a1 macos: be tolerant of NULL GL context
Some code appears to unconditionally attempt to make the context current,
so this makes things tolerant to a NULL GdkGLContext and just return FALSE.
2020-10-29 10:57:02 -07:00
Christian Hergert
a3fd46c516 glsl: tweak pre-processor to support Apple GLSL compiler
The Apple GLSL compiler cannot deal with empty pre-processor blocks such as

  #if GSK_GLES
  #elif GSK_LEGACY
2020-10-29 10:57:02 -07:00
Christian Hergert
0040667965 macos: remove unused GL layer
This isn't being used, and instead we'll go the route of a NSView for
the OpenGL implementation.
2020-10-29 10:57:02 -07:00
Christian Hergert
60e67a62e6 macos: move setNeedsDisplay helper to GdkMacosCairoView
This isn't needed in the base class, which will eventually get a GL subclass.
2020-10-29 10:57:02 -07:00
Matthias Clasen
931f130377 Merge branch 'wip/chergert/gdk-remove-texture_from_surface' into 'master'
gl: remove unused texture_from_surface API

See merge request GNOME/gtk!2756
2020-10-29 15:50:01 +00:00
Christian Hergert
524fbc35a7 gl: remove unused texture_from_surface API
This is not used anywhere and only exists within the X11 backend. It
can be removed now.
2020-10-29 08:26:27 -07:00
Matthias Clasen
51d35750f6 Cosmetics
Whitespace fix.
2020-10-29 07:40:30 -04:00
Matthias Clasen
90fde9c939 Merge branch 'matthiasc/for-master' into 'master'
textview: Update child allocations

See merge request GNOME/gtk!2757
2020-10-29 11:21:30 +00:00
Matthias Clasen
5cbc55578f textview: Update child allocations
This was accidentally lost when display line caching
was introduced.
2020-10-28 20:18:54 -04:00
Piotr Drąg
f90e7b9c56 Update POTFILES.skip 2020-10-28 15:12:01 +01:00
Matthias Clasen
d5b9489408 Merge branch 'wip/baedert/for-master' into 'master'
Wip/baedert/for master

Closes #3282

See merge request GNOME/gtk!2755
2020-10-27 22:38:58 +00:00
Matthias Clasen
975d763db1 Merge branch 'dropdown-checkmark' into 'master'
Dropdown checkmark

Closes #3291

See merge request GNOME/gtk!2754
2020-10-27 20:41:34 +00:00
Matthias Clasen
907fc30fac gtk-demo: Add checkmarks to all dropdown demos
This follows the mockups that these demos are
copied from. Unfortunately, it has to be implemented
for every item factory, so we repeat it here.

Fixes: #3291
2020-10-27 16:13:44 -04:00
Matthias Clasen
25d2efeabe dropdown: Add a checkmark to the selected item
Make the default factory add a checkmark to the
currently selected item (not the hovered item)
in the popup. This will unfortunately have to be
done in non-default factories too.

Related: #3291
2020-10-27 16:13:38 -04:00
Matthias Clasen
3a119a3d3a dropdown: Make search entry shrink
We don't want the popup to be wider than the button
if we can help it. The search entry does not need
to be very wide.
2020-10-27 15:35:34 -04:00
Matthias Clasen
8df883ed71 Merge branch 'matthiasc/atspi-child' into 'master'
Emit ChildrenChanged signal on hierarchy updates

See merge request GNOME/gtk!2752
2020-10-27 18:24:43 +00:00
Matthias Clasen
0c49f7349d Merge branch 'matthiasc/a11y-buildable' into 'master'
Implement accessible attributes for ui files

See merge request GNOME/gtk!2751
2020-10-27 18:13:44 +00:00
Luca Bacci
eef1097c90 GdkW32: remove klassTEMPSHADOW
Fixes issue #2019
2020-10-27 18:26:45 +01:00
Benjamin Otte
08004d4eed Merge branch 'wip/otte/for-master' into 'master'
Wip/otte/for master

Closes #3295

See merge request GNOME/gtk!2748
2020-10-27 16:27:10 +00:00
Benjamin Otte
6d7e56bed6 cloudprint: Make compile without warnings 2020-10-27 16:43:34 +01:00
Benjamin Otte
8e6701c9a6 gtkmediafile: Use cubic volume function
Gstreamer suggests doing that.

https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/issues/1439

Fixes #3295
2020-10-27 16:32:53 +01:00
Jakub Steiner
6d5c512571 Merge branch 'wip/jimmac/gtk4-dropdown-papercuts' into 'master'
Adwaita: dropdown search box

See merge request GNOME/gtk!2747
2020-10-27 12:55:33 +00:00
Jakub Steiner
b94ea1b4f7 Adwaita: dropdown search box
- have some whitespace around entry

Partial fix for https://gitlab.gnome.org/GNOME/gtk/-/issues/3291
2020-10-27 13:32:04 +01:00
Matthias Clasen
b2d6011679 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2746
2020-10-27 05:05:33 +00:00
Matthias Clasen
c0aa1c8a49 Merge branch 'popover-menu-custom-child' into 'master'
popovermenu: Allow custom items

Closes #3260

See merge request GNOME/gtk!2728
2020-10-27 04:51:00 +00:00
Matthias Clasen
5fe837483c docs: Add GtkOverlay to the widget gallery 2020-10-27 00:42:38 -04:00
Matthias Clasen
4f15b988e7 docs: Add box, grid and center box to the gallery 2020-10-27 00:24:54 -04:00
Matthias Clasen
6cd3bc7384 modelbutton: Explicitly set up LABELLED-By relation
GTK does this automatically based on mnemonics, but only
if the string actually contains a mnemonic. This makes
orca read out menuitems, as expected.
2020-10-26 22:48:01 -04:00
Matthias Clasen
0faadef36f widget-factory: Add a scale to the gear menu
This tests the custom menuitem support, and lets you
control the transition duration for the main stack.
2020-10-26 22:43:12 -04:00
Matthias Clasen
af6c3017fb popovermenu: Allow adding custom items in ui files
Support <child type="ID"> to fill custom child slots
in both GtkPopoverMenus and GtkPopoverMenuBars that
are created in ui files.
2020-10-26 22:42:28 -04:00
Matthias Clasen
8157abe591 popovermenu: Allow custom items
Add a way to add children at certain places in
the generated menu for both GtkPopoverMenu and
GtkPopoverMenuBar.

New apis:
gtk_popover_menu_add_child
gtk_popover_menu_remove_child
gtk_popover_menu_bar_add_child
gtk_popover_menu_bar_remove_child

Fixes: #3260
2020-10-26 22:41:33 -04:00
Matthias Clasen
61e08baec1 Merge branch 'master' into 'master'
Fix the build with cups < 2.2.12

Closes #2968

See merge request GNOME/gtk!2744
2020-10-26 20:09:30 +00:00
Thomas Lange
0493e89897 Fix the build with cups < 2.2.12
PPD_CUSTOM_UNKNOWN was introduced in cups 2.3.
and has been backported to 2.2.12.
Only handle it when we build against a new enough cups.

Fixes: #2968
2020-10-26 19:16:26 +01:00
Matthias Clasen
c783e9aa5f Treat tristate as an enum when parsing
This makes it so that you have to explicitly specify
"true" and "false" for the checked state, but it
matches how this enumeration is meant to be used.
2020-10-26 08:01:13 -04:00
Matthias Clasen
4661f15fab Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2741
2020-10-26 05:28:43 +00:00
Matthias Clasen
e51a98d184 docs: Add GtkDrawingArea to the gallery 2020-10-26 01:08:49 -04:00
Matthias Clasen
b67eee5741 docs: Add GtkShortcutsWindow to the widget gallery 2020-10-26 01:08:49 -04:00
Matthias Clasen
d9259fc958 docs: Add GtkPopoverMenu to the widget gallery 2020-10-26 01:08:49 -04:00
Matthias Clasen
65f748fc62 docs: Add GtkPopover to the widget gallery 2020-10-26 01:08:49 -04:00
Matthias Clasen
bed3616bf0 docs: Add GtkPopoverMenuBar to the gallery 2020-10-26 01:08:49 -04:00
Matthias Clasen
1605ca0140 docs: Add GtkExpander to the gallery 2020-10-26 01:08:49 -04:00
Matthias Clasen
8692f5d8e3 docs: Add GtkEmojiChooser to the gallery
To make this possible enable the doc shooter
to take screenshots of popovers.
2020-10-26 01:08:49 -04:00
Matthias Clasen
42e2c54922 docs: Redo the GtkColorChooserDialog gallery image
Show the new palette.
2020-10-25 22:54:53 -04:00
Matthias Clasen
291c61891a docs: Improve the GtkStackSidebar gallery image 2020-10-25 22:54:41 -04:00
Matthias Clasen
59e08c0dac docs: Tweak gallery layout
Now that the volume button image is small, move it
to a better place in its section. Improves the layout.
2020-10-25 22:46:30 -04:00
Matthias Clasen
a70c9c69a0 docs: Fix the GtkVolumeButton gallery image
Give up on showing the popup, we don't do that
for other buttons either.
2020-10-25 22:42:40 -04:00
Matthias Clasen
dffe6b87e4 docs: Add GtkCalendar to the gallery
It has been missing far too long.
2020-10-25 22:32:27 -04:00
Matthias Clasen
28b7962bee docs: Improve the GtkMediaControls gallery image 2020-10-25 22:26:19 -04:00
Matthias Clasen
64e131f285 docs: Improve the GtkVideo gallery image 2020-10-25 22:17:15 -04:00
Matthias Clasen
a9f0f18c3a docs: Tweak gallery layout
Improve the breaks in the container section.
2020-10-25 22:16:26 -04:00
Matthias Clasen
2e0822bed0 docs: Shrink the editable label gallery image
Makes it fit better with the other entries.
2020-10-25 21:52:51 -04:00
Matthias Clasen
b0fb31fc96 docs: Some reordering in the gallery
Align things better.
2020-10-25 21:47:40 -04:00
Matthias Clasen
163d32eea1 docs: Work around GtkPicture growing
Make the GtkPicture gallery image stay within its
limits, by overpowering its request mode.
2020-10-25 21:30:15 -04:00
Matthias Clasen
b7728a884b docs: Tweak gallery ordering
Move GtkSpinButton to the entries, where it
belongs, despite its name.
2020-10-25 21:10:12 -04:00
Matthias Clasen
86b4b2eef2 docs: Fix links from the gallery
It turns out gtk-doc can't even parse its own custom
links if you don't arrange for the <link> element to
on a single line, since it is just a glorified sed
script :(
2020-10-25 21:07:12 -04:00
Matthias Clasen
09eda804f7 docs: Add GtkWindowControls to the gallery 2020-10-25 21:06:46 -04:00
Matthias Clasen
37d4932b31 a11y: Add more tests
Test some of the attributes that GTK maintains
for every widget.
2020-10-25 19:29:00 -04:00
Matthias Clasen
0fddf73ddb a11y: Add some parser tests
Checking basic support for acessible states, properties
and relations in ui files.
2020-10-25 13:01:44 -04:00
Matthias Clasen
f981ab7a9e Remove erroneous preconditions
Tests found these functions to be non-working.
2020-10-25 12:43:52 -04:00
Matthias Clasen
677ea5f22d a11y: Reuse builder parsing for enums
No need to manually write all these parsing functions
when _gtk_builder_enum_from_string does exactly what
is needed here.
2020-10-25 12:38:52 -04:00
Matthias Clasen
fce455ae0b a11y: Parse booleans in ui files as expected
Accept the same syntax for booleans as GtkBuilder
does elsewhere.
2020-10-25 12:20:55 -04:00
Matthias Clasen
e050a2661c builder: Expot _gtk_builder_boolean_from_string privately
When specifying accessible properties in ui files, it
is better to accept the same syntax for booleans as
elsewhere, so lets reuse this function.
2020-10-25 12:19:21 -04:00
Piotr Drąg
a03581ce39 Update Polish translation 2020-10-25 10:37:47 +01:00
Matthias Clasen
13b9b9b7d8 scale: Set round-digits to -1 initially
This ensures that keybindings for small-step changes
work despite draw-value being FALSE now. This was
fallout from 8ca612c966 that showed up
as arrow keys not working anymore for the color scales
in the color chooser.
2020-10-25 00:31:18 -04:00
Matthias Clasen
0a3b370805 Cosmetics
Remove some comments that refer to no longer
existing menu code.
2020-10-25 00:31:18 -04:00
Matthias Clasen
313ba0280a color editor: Add accessible labels
Add some labels to the controls in this dialog.
2020-10-24 23:55:56 -04:00
Matthias Clasen
adb7676fc1 a11y: More State<>Change confusion
We should really avoid this needless duplication
- the 'state' is never stored anywhere.
2020-10-24 23:12:36 -04:00
Matthias Clasen
8ffb398517 a11y: Handle all cases for state change
Make state_change handle state changes for non-widgets,
and handle the cases for HIDDEN involving stack pages.
2020-10-24 22:05:17 -04:00
Matthias Clasen
9a943e21d3 stack: Update HIDDEN a11y state for stack pages
This will let us handle additions and removals
in the AT-SPI backend.
2020-10-24 22:04:26 -04:00
Matthias Clasen
7c106578ed Cosmetics
Make gtk_at_spi_root_child_changed take a
GtkAccessible for the child.
2020-10-24 21:35:35 -04:00
Matthias Clasen
d1d9b92aee Merge branch 'meson-deps-continued' into 'master'
Turn more options into "feature"

See merge request GNOME/gtk!2708
2020-10-25 01:10:01 +00:00
Matthias Clasen
434b145ee0 stack: Don't transition when the visible child is remove
This is a corner-case, and it is causing crashes in
the shortcuts window, after a11ab6c995.
2020-10-24 20:54:55 -04:00
Matthias Clasen
2546b88661 a11y: Redo child-added/-removed for toplevels
Instead of monitoring the list of toplevels, rely
on GtkWindow updating the HIDDEN state before windows
get removed. This is better, since we still have the
object available when it happens, so we can pass it
to the ATs.
2020-10-24 15:26:12 -04:00
Matthias Clasen
bba6d604f0 window: Maintain accessible HIDDEN state
We want to use the HIDDEN state to control when
things get added and removed from the accessible
tree, so ensure that we a) set HIDDEN to true
initially for windows, and b) we update HIDDEN
when a window is shown or hidden.

The second part is handled by gtk_widget_hide
for other widgets, but hiding a window does not
always go through that code path.
2020-10-24 15:25:03 -04:00
Matthias Clasen
274f9ad919 a11y: Emit child notification when toplevels get hidden
When a toplevel window gets hidden (and not destroyed),
the frontend code set the HIDDEN state, and we need to
emit child notification when that happens.
2020-10-24 13:17:20 -04:00
Matthias Clasen
89a8c89663 a11y: Improve child index helpers
We need to use gtk_accessible_should_present() whenever we
calculate accessible tree positions, to avoid inconsistencies.

While we are at it, make these helpers usable for finding
the position of accesibles that are now ignored, by not
looking at should_present for the object itself. This will
be relevant when we calculate the position of objects whose
HIDDEN state changes.
2020-10-24 13:14:44 -04:00
Matthias Clasen
e7b290debb a11y: Improve child notification for toplevels
We need to translate the list model position into
an accessible tree position, since hidden toplevels
will be skipped.

While we are at it, add an api for this notification
that will be used in the next commit.
2020-10-24 13:13:07 -04:00
Matthias Clasen
46e754a17d a11y: Skip non-presented children when required
Whenever we determine the index of a child, we need
to skip its non-presented siblings.
2020-10-24 11:22:09 -04:00
Matthias Clasen
b12992c1cb a11y: Handle HIDDEN state changes
Hidden elements are not presented in the accessible
tree, so when then HIDDEN state changes, we should
emit child-added or -removed signals.

This commit does not yet handle all cases (HIDDEN
toplevels or hidden stack pages are not handled),
but it should cover the common case.
2020-10-24 11:17:56 -04:00
Matthias Clasen
374a451eeb a11y: Don't present HIDDEN accessibles
The ARIA spec is clear on this: when an element has the
HIDDEN state, it should not be presented in the accessible
tree.

This change is incomplete, we also need to emit child-added/
removed signals when the state changes, but that needs to
wait for the child added infrastructure to land.
2020-10-24 11:17:56 -04:00
Matthias Clasen
1e13acb206 widget: Don't add reordered children
gtk_widget_reposition_after is called both to add new children,
and to reposition existing children. We only want to emit
accessible changes in the former case (since AT-SPI doesn't
have events for reordering).
2020-10-24 11:17:56 -04:00
Matthias Clasen
5b2b2feb9f a11y: Fix up state / change enum confusion 2020-10-24 11:17:56 -04:00
Matthias Clasen
77af993181 Merge branch 'flush-events' into 'master'
Flush events

See merge request GNOME/gtk!2740
2020-10-24 12:53:01 +00:00
Matthias Clasen
c5ed5c5ff9 gdk: Deliver queued events on flush
The current code was marking queued events as flushed,
but left them in the queue. That doesn't make sense to
me - we should deliver all events we have before we
reach the paint phase of the frame cycle.
2020-10-23 17:03:00 -04:00
Matthias Clasen
6b53a55dd7 NEWS: Updates 2020-10-23 15:07:25 -04:00
Matthias Clasen
83fbdcd5e6 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #3226

See merge request GNOME/gtk!2739
2020-10-23 17:25:33 +00:00
Matthias Clasen
cb8bf6540c editablelabel: Properly clean up in dispose
Unparenting the stack finalizes the entry and label,
but at least the label is available via the
gtk_editable_get_delegate API, and the a11y
implementation uses that at dispose time. So, clear
the pointers to prevent them from being dangling.

This was showing up as a segfault of the doc-shooter.
2020-10-23 12:27:55 -04:00
Matthias Clasen
fdb1fa4d08 Give all search entries an icon
This was first requested for the search entry in
GtkDropDown, but it is better to be consistent and
give every search entry an icon.

Related: #3291
2020-10-23 12:19:31 -04:00
Matthias Clasen
10d7ccc8e0 window: Fix state updates
When the compositor unmaximized the window, we get a
state-changed signal, and we update the maximized field.
But then we go and recompute our layout based on the
maximize_initially field, and that is still TRUE, when
we were maximized initially. So we need to update both
fields.

This fixes a problem where using the window menu to
unmaximize an initially maximized window would not
work.

Fixes: #3226
2020-10-23 11:51:02 -04:00
Matthias Clasen
b973f7f375 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2737
2020-10-23 01:45:22 +00:00
Matthias Clasen
7671c1074b Tweak focus tests
These tests are a bit fragile because the initial focus
that is taken depends on what ends up in the center of
the window, horizontally or vertically, which depends
on things like fonts, or theme spacing.

This commit makes some tweaks to push things in the
widget-factory example around far enough to make the
tests work again.

We should figure out a way to make this more robust.
2020-10-22 21:18:46 -04:00
Matthias Clasen
6ce2e19bbe Merge branch 'ebassi/for-master' into 'master'
Ebassi/for master

See merge request GNOME/gtk!2735
2020-10-22 22:53:34 +00:00
Matthias Clasen
3a08706e40 dropdown: Add an icon the search entry
A small detail for #3291.
2020-10-22 14:33:41 -04:00
Matthias Clasen
e5722fe9d2 passwordentry: Respect border spacing
We are not using a box layout here since we want
to ignore the icons for measuring. But we still
want the layout to respect border spacing that
comes from the theme.
2020-10-22 14:27:19 -04:00
Matthias Clasen
700f957d9a Adwaita: Set border-spacing for entries
When our entries contain icons, they should not run
directly into the text, so put some spacing between
the children of entries.
2020-10-22 14:26:21 -04:00
Timm Bäder
9109dee072 gl renderer: Don't use blur node bounds
The blur node bounds are different/larger than the ones we use. This
made the textures get stretched to the blur node bounds.

Fixes #3282
2020-10-22 17:46:34 +02:00
Timm Bäder
b6a843a05b gl renderer: Fix two scale_x/y mixups 2020-10-22 17:46:34 +02:00
Timm Bäder
ff1fb4f10d text: Remove empty root() implementation 2020-10-22 17:46:34 +02:00
Timm Bäder
1bf79a4dae text: Fix a documentation mishap 2020-10-22 17:46:34 +02:00
Timm Bäder
85d4b86545 text: Fold focus_{in,out} into only caller 2020-10-22 17:46:34 +02:00
Timm Bäder
98e88b7b53 text: Avoid a crash
Calculate the "was previous focus in a child widget" condition before
chaining up into grab_focus, to a void that unreffing the prev_focus
widget.
2020-10-22 17:46:34 +02:00
Timm Bäder
85702f8f5d dnd demo: Make the transform code a bit more idiomatic 2020-10-22 17:46:34 +02:00
Timm Bäder
d97cb851f1 textview: Remove a broken debug output statement
redraw_rect does not exist.
2020-10-22 17:46:34 +02:00
Timm Bäder
6dcdb4a601 atspitextbuffer: Explicitly cast between pango and gtk enums 2020-10-22 17:46:34 +02:00
Timm Bäder
41ef1d87ef atspicontext: Add a few missing break statements 2020-10-22 17:46:34 +02:00
Timm Bäder
44728d09a9 stack: assert for some assumptions 2020-10-22 17:46:34 +02:00
Timm Bäder
b1664534af gdksurface: Ensure some assumptions
Just to please scan-build
2020-10-22 17:46:34 +02:00
Timm Bäder
56e89e8d26 demos: Remove a dead assignment 2020-10-22 17:46:34 +02:00
Timm Bäder
f6ebc06767 filechooserwidget: Avoid an uninitialized value
If the operation mode is OPERATION_MODE_RECENT and we end up in the
'goto file_entry' case, we don't set info.result. Then later after
calling check_save_entry, is_empty is TRUE which causes a goto out and
here we then try to use info.result, which is uninitialized.

Initialize info.result before doing all this.

Found by scan-build
2020-10-22 17:46:33 +02:00
Timm Bäder
3db5e15bde filechooserwidget: gtk_widget_get_root() can return NULL 2020-10-22 17:46:33 +02:00
Timm Bäder
a2291fb989 showrendernode: Pass error to deserialize() 2020-10-22 17:46:33 +02:00
Timm Bäder
af97f19926 textview: Respect return value of get_text_surface_coords() 2020-10-22 17:46:33 +02:00
Timm Bäder
0dae1f48fd listbox test: Only compare values for rows we have
This shouldn't happen, but don't compare 100 values if we didnt' get 100
values from the listbox.
2020-10-22 17:46:33 +02:00
Timm Bäder
c7dbb8ef91 label: Plug a potential memory leak
This only happens in error cases so pretty insignificant.

Found by scan-build
2020-10-22 17:46:33 +02:00
Timm Bäder
3a1e019e83 print-editor: Fix a wrong comparison
If error is NULL, replacing the file contents worked and we don't
show the error dialog. The previous version pretty explicitly
dereferenced a NULL pointer by first ensuring that error is NULL and
then accessing error->message.

Found by scan-build
2020-10-22 17:46:33 +02:00
Matthias Clasen
a923be95b3 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2736
2020-10-22 14:52:57 +00:00
Matthias Clasen
a11ab6c995 a11y: Handle stack case for addition/removal
Since we interpose stack pages as non-widget accessibles,
we need to tweak the signals we emit when their corresponding
widgets get added or removed.
2020-10-22 10:06:06 -04:00
Matthias Clasen
1d802881eb stack: Change ordering for removal
Unparent the child widget before tearing down its
stack page. This is necessary so a11y can still access
the stack page accessible to emit change notification
when it learns that the child is removed.
2020-10-22 10:05:17 -04:00
Emmanuele Bassi
6c796cf201 docs: Fix cross-linking for GIO types 2020-10-22 13:33:49 +01:00
Matthias Clasen
44c6619660 gtk-demo: Speed up image demo
The progressive loading demo here was so slow as to appear
broken. Make it faster, and ensure that it updates regularly.
2020-10-22 07:51:44 -04:00
Matthias Clasen
ef7499a31b gtk-demo: Add alternative text to a GtkPicture
This lets us text GtkPicture a11y support.
2020-10-22 07:51:44 -04:00
Matthias Clasen
ed571ae68a picture: Set alternative text as description
Use the alternative text as accessible description
for GtkPicture.
2020-10-22 07:51:44 -04:00
Matthias Clasen
e2b3cbac23 colorbutton: Improve accessibility
Make the swatch not appear selectable, and
set an accessible label on it.
2020-10-22 07:51:44 -04:00
Matthias Clasen
ba290eb9b0 a11y: Add actions for color swatches
Add the same actions that we exported in GTK 3.
2020-10-21 23:36:22 -04:00
Matthias Clasen
3805e1d507 colorswatch: Export some functions for a11y
Make simple functions to activate, select or customize
a GtkColorSwatch. These will be exported by a11y as
actions.
2020-10-21 23:36:22 -04:00
Matthias Clasen
daf3b3a3b4 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2734
2020-10-22 02:52:46 +00:00
Matthias Clasen
800eb76a2d linkbutton: Use the LINK role
It is a bit ambiguous, but I think link buttons are
more links than buttons. See WAI-ARIA for a discussion
of the differences.

Update tests to match.
2020-10-21 22:19:54 -04:00
Matthias Clasen
bcbc6159f4 a11y: Document abstract roles
Since we mention abstract roles in the documentation
for GtkAccessibleRole, we should say what roles are
abstract. Doing this shows that we actually use two
abstract roles heavily, ourselves: WIDGET and WINDOW.
2020-10-21 21:47:14 -04:00
Matthias Clasen
5f8c6d2287 a11y: Document roles used in menu 2020-10-21 21:40:19 -04:00
Matthias Clasen
88eb3a9c34 atspi: Give model buttons a click action too
GtkModelButton is no longer derived from GtkButton,
but can still treat it like a button for the purposes
of having a click action. This lets ATs activate
menu items again.
2020-10-21 21:27:38 -04:00
Matthias Clasen
3e43dda9d4 modelbutton: Recreate our AT context
When the button role changes, we want to update the
accessible role to match. Since accessible roles are
unchangeable post-creation of the AT context, we have
to cheat a bit and recreate the whole context.
2020-10-21 21:27:38 -04:00
Matthias Clasen
f96a1cfadd modelbutton: Initial accessibility setup
Set the accessible role to GTK_ACCESSIBLE_ROLE_MENU_ITEM.
This is incomplete, we need to recreate the context when
the buttons role changes, and there are other things that
need to be set.
2020-10-21 21:27:38 -04:00
Matthias Clasen
758bcd5343 popovermenubar: Initial accessibility setup
Set roles, properties and relations according to the
ARIA authoring practices document. This is not quite
complete.
2020-10-21 21:27:38 -04:00
Matthias Clasen
2bfd4196fb popovermenu: Initial accessibility setup
Set roles, properties and relations according to the
ARIA authoring practices document.
2020-10-21 21:27:38 -04:00
Xavier Claessens
1b7a99cb24 Apply 1 suggestion(s) to 1 file(s) 2020-10-22 00:36:23 +00:00
Matthias Clasen
087c0078ca menubutton: initial accessibility setup
Set roles, properties and relations according to the
ARIA authoring practices document.
2020-10-21 19:47:48 -04:00
Matthias Clasen
b9ae54c951 separator: Remove unnecessary code
gtk_widget_update_orientation already sets the
accessible property, no need to do it again.
2020-10-21 19:47:48 -04:00
Emmanuele Bassi
7ac6e25ffc Use GtkApplication in the examples
Some people read the "Getting Started" section as a series of
incremental lessons, and having the examples go from GtkApplication to
the old style "init / spin the main loop" confuses them.

We should be using GtkApplication everywhere in our examples.
2020-10-21 22:44:53 +01:00
Matthias Clasen
d3089ebbc2 progressbar: Hide internal structure from a11y
According to section 7.1 of WAI-ARIA, the progressbar role
has the "Children presentational" characteristic, which
indicates that children should not be represented in
the a11y tree.
2020-10-21 15:09:55 -04:00
Matthias Clasen
14a64c7372 levelbar: Hide internal structure from a11y
According to section 7.1 of WAI-ARIA, the meter role
has the "Children presentational" characteristic, which
indicates that children should not be represented in
the a11y tree.
2020-10-21 15:04:34 -04:00
Matthias Clasen
ca9b06878d switch: Hide internal structure from a11y
According to section 7.1 of WAI-ARIA, the switch role
has the "Children presentational" characteristic, which
indicates that children should not be represented in
the a11y tree.
2020-10-21 14:55:13 -04:00
Matthias Clasen
8f100269ad scale: Hide internal structure from a11y
According to section 7.1 of WAI-ARIA, the slider role
has the "Children presentational" characteristic, which
indicates that children should not be represented in
the a11y tree, which makes sense, since these are all
just internal gizmos.
2020-10-21 14:53:17 -04:00
Matthias Clasen
48bb9200d9 a11y: Treat PRESENTATION like NONE
This is what ARIA tells us to do. NONE is just another
name for PRESENTATION.
2020-10-21 14:40:34 -04:00
Matthias Clasen
d7794bf608 docs: Add some more to the migration guide
Expand the section on life-cycle handling with some
more details.
2020-10-21 14:30:17 -04:00
Matthias Clasen
3151906157 docs: Small corrections to the a11y overview
The section titles were mixed up wrt to the content
of the sections.
2020-10-21 14:23:10 -04:00
Matthias Clasen
6153efd02a Document GTK_ACCESSIBLE_ROLE_NONE
We use it for a specific purpose now, so document it.
2020-10-21 14:21:12 -04:00
Matthias Clasen
b5b8f42a0c Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #3285

See merge request GNOME/gtk!2733
2020-10-21 18:09:42 +00:00
Matthias Clasen
043ffd38bc text: React to text attribute changes in css
Recompute the layout when the css style change
affects text attributes. This matches what we do
in GtkLabel, and without this, changing the
font-features-setting css property in the Inspector
does not have immediate effect.
2020-10-21 13:46:58 -04:00
Carlos Garnacho
32b826e312 Merge branch 'wip/exalm/swipe4' into 'master'
gestureswipe: Count last event when calculating velocity

See merge request GNOME/gtk!2715
2020-10-21 16:20:58 +00:00
Alexander Mikhaylenko
700ca3b946 gestureswipe: Count last event when calculating velocity
The last event, matching lifting the finger/releasing the mouse button,
is important when there's a large delay between it and the previous events,
as in when performing a movement, stopping, then releasing fingers as
opposed to doing a swipe.

If this event is skipped, doing this will result in kinetic deceleration
matching the previous finger movement, while the expected behavior would
be no deceleration.

See also 5dc6194b98 for a similar fix in
GtkEventControllerScroll.
2020-10-21 20:59:15 +05:00
Emmanuele Bassi
e45dd771db a11y: Emit ChildrenChanged for toplevel list changes
GtkAtSpiRoot is not a context, which means it needs to emit
ChildrenChanged events by itself whenever a toplevel is added to, or
removed from, the list of toplevels.
2020-10-21 15:37:57 +01:00
Emmanuele Bassi
698cbee1fb a11y: Move ChildrenChanged emitter to ATSPI utilities
We are going to use it from GtkAtSpiRoot, which is not a
GtkAtSpiContext.
2020-10-21 15:18:23 +01:00
Emmanuele Bassi
80756322cd a11y: Handle relations in UI files
A bit hacky: we skip parsing values that have a reference or
reference-list type, but we do not error out. Instead, we return a NULL
value, which we catch in the GtkBuildable interface implementation to
get the actual object, and construct a reference list value.

There's still some ickyness around the value type that can only be
solved by having an attribute and role taxonomy.
2020-10-21 14:48:49 +01:00
Emmanuele Bassi
f1e14c4858 a11y: Implement ChildrenChanged atspi.Event 2020-10-21 14:33:20 +01:00
Emmanuele Bassi
8d46bd1d7c a11y: Notify of changes in the children list 2020-10-21 14:04:49 +01:00
Emmanuele Bassi
fbb08a30e2 a11y: Add child state change to GtkATContext
And the required private API in GtkAccessible to notify AT contexts of
changes in the children list.
2020-10-21 14:04:49 +01:00
Matthias Clasen
81371e7c79 columnview: Put overshoot underneath the headers
This matches what we do in GtkTreeView.

Fixes: #3285
2020-10-21 08:39:50 -04:00
Emmanuele Bassi
7702670d86 docs: Document the "accessibility" custom tag 2020-10-21 13:33:37 +01:00
Emmanuele Bassi
9e4316bf96 a11y: Add an "accessibility" section to the builder XML tree
Accessible attributes are not GObject properties. This means that we
need a custom parser for setting attributes in our UI description files.

The new section is defined as a sub-tree with the `<accessibility>`
element at its root, and elements for each type of accessible
attributes, i.e. properties, relations, and states:

```xml
  <object class="..." id="...">
    <accessibility>
      <property name="label">The accessible label</property>
      <state name="pressed">false</state>
      <relation name="labelled-by">label1</relation>
    </accessibility>
  </object>
```

The name of the attribute is the enumeration value; the value is defined
by the WAI-ARIA specification.
2020-10-21 13:33:37 +01:00
Emmanuele Bassi
4ea2a6628f a11y: Add parsing code for accessible values
We need to be able to go from a string representation of an accessible
value to its GtkAccessibleValue instance.
2020-10-21 13:33:37 +01:00
Matthias Clasen
39dfdac771 range: Hide internals from accessibility
The nameless, faceless gizmos inside a range do not
contribute to the accessible experience at all, lets
not add them to the tree. All the accessible functionality
is on the main widget (either a scale or a scrollbar).
2020-10-21 08:01:25 -04:00
Matthias Clasen
b7fa00e22d Cosmetics 2020-10-21 08:01:25 -04:00
Matthias Clasen
3df0a333ad frame: Set up accessible relations
Mark the child as labelled-by the label.
2020-10-21 08:01:25 -04:00
Matthias Clasen
8880e3bd2e Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2729
2020-10-21 11:43:58 +00:00
Timm Bäder
0b5b908a74 Merge branch 'wip/exalm/nullable' into 'master'
widget: Add missing (nullable) on binding functions

See merge request GNOME/gtk!2730
2020-10-21 08:17:45 +00:00
Alexander Mikhaylenko
31a072497d widget: Add missing (nullable) on binding functions
Even though they are marked as (skip), they are used in Vala and have wrong
types there atm.
2020-10-21 12:27:51 +05:00
Matthias Clasen
cbb6828657 docs: Document more accessible roles
Document that GtkText is skipped in accessibility.
2020-10-20 23:19:30 -04:00
Matthias Clasen
8e170217a1 Cosmetics
Typo fix.
2020-10-20 23:19:18 -04:00
Matthias Clasen
36d4a8090f docs: Document more accessible roles
GtkColumnView and its various components use a lot
of accessible roles.
2020-10-20 23:09:11 -04:00
Matthias Clasen
341244203f docs: Document more accessible roles
GtkListView and GtkGridView were missing this as well.
2020-10-20 22:53:30 -04:00
Matthias Clasen
2023914186 docs: Document accessible roles of some classes
GtkListBox and GtkFlowBox were missing this.
2020-10-20 22:51:11 -04:00
Matthias Clasen
ef9ec43469 a11y: Add some more tests 2020-10-20 22:44:24 -04:00
Matthias Clasen
67411701c6 inspector: Show accessible object path
Show the object path of the object on the a11y bus,
this is can be useful information. While we are here,
make sure that the Inspector does not throw criticals
when used with GTK_NO_A11Y=1.
2020-10-20 21:56:54 -04:00
Matthias Clasen
e20a3339bf atsi: Fix emission of text selection changes
We were not emitting text-selection-changed and
text-caret-moved as expected.
2020-10-20 21:31:23 -04:00
Matthias Clasen
a8baee342c a11y: Fix handling of LABELLED_BY relation
There were several places where we were confusing
GList and GSList and list->data and list->next, causing
a crash in the accessible name computation for buttons
with mnemonic labels.
2020-10-20 21:27:39 -04:00
Matthias Clasen
6a1cb3304b docs: Mention subclassing and destroy in the migration guide
Mention changes regarding subclassing and life-cycle
handling in the migration guide.
2020-10-20 18:26:38 -04:00
Benjamin Otte
45400fe381 Merge branch 'wip/otte/for-master' into 'master'
Wip/otte/for master

Closes #3280

See merge request GNOME/gtk!2725
2020-10-20 14:05:49 +00:00
Matthias Clasen
5504278b78 Merge branch 'matthiasc/for-master' into 'master'
Some more a11y tests

See merge request GNOME/gtk!2726
2020-10-20 05:57:45 +00:00
Matthias Clasen
93481e6c2e a11y: Add tests for GtkFlowBox
Test that roles, states and properties are as expected.
2020-10-20 01:12:20 -04:00
Matthias Clasen
b9e9898212 a11y: Add tests for GtkListBox
Test that roles, states and properties are as expected.
2020-10-20 01:07:13 -04:00
Matthias Clasen
7c47b6907b a11y: Add tests for GtkStack and GtkStackSwitcher
Test that the roles, states and relations are
as expected.
2020-10-20 00:46:07 -04:00
Matthias Clasen
b10d5ec8ff a11y: Add a test for label properties
Now that we set the label property, we should test it too.
2020-10-20 00:25:39 -04:00
Benjamin Otte
8dad615f04 gtk: Remove unused header include
gtkcssnodeprivate.h was mainly used for repositioning CSS nodes in
gadgets, and gadgets are gone now.
2020-10-20 04:50:12 +02:00
Benjamin Otte
23e086089d entry: Keep widget order
... instead of just ordering the CSS nodes.
2020-10-20 04:50:12 +02:00
Benjamin Otte
9317a9f35c flowbox: Keep widget order
... instead of just ordering the CSS nodes.
2020-10-20 04:50:12 +02:00
Benjamin Otte
22100089c3 listbox: Reorder the widgets when sorting
... instead of just reordering the CSS nodes.
2020-10-20 04:50:12 +02:00
Benjamin Otte
074d54ef5a listitemwidget: Remove unnecessary code
gtk_widget_insert_after() reorders CSS nodes properly.
2020-10-20 04:50:12 +02:00
Benjamin Otte
ddd1b0958d notebook: Remove unnecessary code
gtk_widget_insert_after() reorders CSS nodes properly.

Also fix page reordering code to actually reorder the widget instead of
just the CSS nodes.
2020-10-20 04:50:12 +02:00
Benjamin Otte
d77902365d box: Remove unnecessary code
gtk_widget_insert_after() reorders CSS nodes properly.
2020-10-20 04:50:12 +02:00
Benjamin Otte
d9b216e629 widget: Always update the CSS node
Anybody who keeps their own CSS nodes around or wants to order CSS nodes
different from widgets will from now on have to do it manually all the
time.

This is outdated behavior, nobody should be doing either of those two
things.

Also, the correct case is much more common, and not doing it
automatically was causing bugs.

Fixes #3280
2020-10-20 04:50:12 +02:00
Matthias Clasen
a7bd6b094a Merge branch 'matthiasc/for-master' into 'master'
Some a11y docs and fixes

See merge request GNOME/gtk!2724
2020-10-20 01:45:17 +00:00
Matthias Clasen
eeae1b1ea7 a11y: Fix accessible tree inconsistency
The stack page objects were not properly integrated
in the accessible tree - they were appearing as parent
of the pages when navigating up, but not as children
of the stack when navigating down.
2020-10-19 21:15:44 -04:00
Matthias Clasen
0a71dc1bed stack: Minor doc addition 2020-10-19 21:15:44 -04:00
Matthias Clasen
feb73a5ebb docs: Flesh out a11y section
Add some advice for making custom widgets accessible.
2020-10-19 20:01:57 -04:00
Matthias Clasen
83d8ae2f30 Merge branch 'wip/chergert/fix-macos-surface-under-pointer' into 'master'
macos: fix discovery of surface under pointer

See merge request GNOME/gtk!2722
2020-10-19 21:26:47 +00:00
Emmanuele Bassi
51f5690ae3 Merge branch 'ebassi/for-master' into 'master'
Ebassi/for master

See merge request GNOME/gtk!2720
2020-10-19 20:26:57 +00:00
Matthias Clasen
e58e6a0fbe Merge branch 'a11y/editable' into 'master'
Improve the accessible support for editables

See merge request GNOME/gtk!2719
2020-10-19 20:16:21 +00:00
Christian Hergert
eb82b2a9ca macos: fix discovery of surface under pointer 2020-10-19 12:35:41 -07:00
Matthias Clasen
dfc7d26275 a11y: Tweak name and description computation
Instead of falling back to the role nick for both,
fall back to the class name for the name, and to
the empty string for the description. This makes
labels show up in Accerciser the same way they
did in GTK 3, and seems more useful to me than
the alternative.
2020-10-19 14:58:34 -04:00
Matthias Clasen
77d1026c5a atspi: Use name and description as provided
GtkATContext already does fallbacks to derive values
for these, so no need for the atspi implementation to
do its own fallback on top of that.
2020-10-19 14:57:43 -04:00
Matthias Clasen
08ae513064 label: Set the accessible label property
This will make label text show up in ATs again.
2020-10-19 14:29:19 -04:00
Emmanuele Bassi
f52c86ae21 docs: Add a section on a11y patterns 2020-10-19 18:39:40 +01:00
Emmanuele Bassi
03745a489c docs: Start outlining a11y authoring practices
We should have documentation for application developers and widget
authors, so they can deal with the new accessibility API.
2020-10-19 18:37:30 +01:00
Matthias Clasen
63421b1876 a11y: Rename some methods
Our EditableText implementation works fine for any
editable, so don't name the functions in a way that
looks like they are only for entries.
2020-10-19 12:58:29 -04:00
Matthias Clasen
80e0e3fe4f gtk-demo: Set an accessible role
Set the expected accessible role on the tagged entry
widget in the demo of the same name. Accessible tools
may decide to ignore widgets that have the wrong role,
so setting an appropriate role is important.
2020-10-19 12:56:50 -04:00
Matthias Clasen
ef46fe0e8e Merge branch 'a11y/component' into 'master'
a11y: Implement Component

See merge request GNOME/gtk!2718
2020-10-19 16:54:45 +00:00
Emmanuele Bassi
7c7dabae8c a11y: Rework accessible name/description computation
The ARIA spec determines the name and description of accessible elements
in a more complex way that simply mapping to a single property; instead,
it will chain up multiple definitions (if it finds them). For instance,
let's assume we have a button that saves a file selected from a file
selection widget; the widgets have the following attributes:

 - the file selection widget has a "label" attribute set to the
   selected file, e.g. "Final paper.pdf"
 - the "download" button has a "label" attribute set to the
   "Download" string
 - the "download" button has a "labelled-by" attribute set to
   reference the file selection widget

The ARIA spec says that the accessible name of the "Download" button
should be computed as "Download Final paper.pdf".

The algorithm defined in section 4.3 of the WAI-ARIA specification
applies to both accessible names (using the "label" and "labelled-by"
attributes), and to accessible descriptions (using the "description" and
"described-by" attributes).
2020-10-19 17:54:14 +01:00
Matthias Clasen
9f9e7dffef atspi: Implement Text for more editables
Our Text implementation requires that we have
a GtkEditable with a delegate that is a GtkText
widget.

This change make the Text implementation work for
the custom widget in the tagged entry demo.
2020-10-19 12:44:50 -04:00
Goran Vidović
94729b4880 Update Croatian translation
(cherry picked from commit fab2558747)
2020-10-19 16:37:36 +00:00
Matthias Clasen
3918dd4643 Add gtk_editable_get_delegate
We need access to the delegate in the a11y layer,
so we might as well make this function public.
2020-10-19 12:36:54 -04:00
Matthias Clasen
04a51837f7 atspi: Emit bounds-changed
This is using the new bounds_change vfunc in GtkATContext.
2020-10-19 12:19:55 -04:00
Matthias Clasen
75a0bef921 widget: Mark the size as changed when it changes
This notifies the AT context that the widgets size
has changed.
2020-10-19 12:19:55 -04:00
Matthias Clasen
d50ebd947c a11y: Add bounds change api
Add a way for GTK to pass bounds change information
to the AT context.
2020-10-19 12:19:55 -04:00
Matthias Clasen
8e4f8a45a9 atspi: Implement Component
Implement the non-questionable parts of the Component interface
for accessibles which are widgets.

This does not include:
 - global coordinates
 - setters
 - scrolling
 - alpha, layers, zorder, and the like
2020-10-19 12:19:55 -04:00
Matthias Clasen
3ad03b1706 a11y: Add a separate vfunc for platform changes
The state_change vfunc is becoming unwieldy. Lets move
the platform changes to their own vfunc, as a start.
2020-10-19 12:09:08 -04:00
Matthias Clasen
dfe00c4ac4 atspi: Be more careful
We have non-widget accessibles now, so guard against
change notification being emitted on them.
2020-10-19 12:09:08 -04:00
Matthias Clasen
5bb656af4c Cosmetics
Add some more fold markers.
2020-10-19 12:08:47 -04:00
Matthias Clasen
469b913cdf Cosmetics 2020-10-19 12:00:53 -04:00
Matthias Clasen
9c1c8a554a Cosmetics 2020-10-19 11:46:25 -04:00
Matthias Clasen
2359510b1f Merge branch 'matthiasc/for-master' into 'master'
Various columnview fixes

Closes #3265, #3272, and #3276

See merge request GNOME/gtk!2717
2020-10-19 15:00:17 +00:00
Xavier Claessens
25a1c421b5 Merge branch 'msvc' into 'master'
gdkglcontext: Fix build with MSVC

Closes #3268

See merge request GNOME/gtk!2713
2020-10-19 13:46:54 +00:00
Matthias Clasen
ef308e5f17 Merge branch 'annotations_gtkaboutdialog' into 'master'
Add nullable return annotations in GtkAboutDialog

See merge request GNOME/gtk!2712
2020-10-19 13:46:32 +00:00
Sophie Herold
33f0809784 Add nullable return annotations in GtkAboutDialog 2020-10-19 13:46:32 +00:00
Matthias Clasen
81ee273e98 columnview: Make right-aligned content work
Make right-aligned content work in resized columns.
There is currently no way to make a title right-aligned,
but we can still make it work correctly. This is a follow
up to 7eb0ae39c5.

Fixes: #3276
2020-10-19 09:39:07 -04:00
Matthias Clasen
f3fe1812aa Adwaita: Put column separators on the left
When resizing columns, we clip a shrunk column
on the right, so the separator disappears in that
case unless we put it on the left side of the other
column.
2020-10-19 09:39:05 -04:00
Xavier Claessens
be8246a6cb gdkglcontext: Fix build with MSVC
GLDEBUGPROC callback is defined with APIENTRY which is a windows
specific calling convention. That macro expands to nothing when building
on other platforms.

Fixes: #3268.
2020-10-19 09:17:53 -04:00
Matthias Clasen
25d0fb4c76 columview: Make resize area a bit larger
This make column resizing feel less like a game
of hit-and-miss. Ultimatively, we should add an
alternative to this.
2020-10-19 08:31:37 -04:00
Matthias Clasen
98b66acbdd columview: Implement double-click to reset headers
Implement the same behavior as GtkTreeView:
double-click on the header boundary resets the
header to its automatic width.

Fixes: #3272
2020-10-19 08:31:37 -04:00
Matthias Clasen
1976df1e54 columnview: Make resize cursors reliable
Ensure that the column resize cursor stays in place
for the duration of the resize drag. This is a bit
annoying, since the implicit grab can end up on the
header of a different column from the one we are
resizing, so just set the cursor on all column headers.
2020-10-19 08:30:22 -04:00
Matthias Clasen
39baf4fff4 columnview: Fix more issues with column resizing
Make it so that for overlapping resize rectangles (with
very narrow columns), we prefer the narrow column, so you
can regrow a column after shrinking it all the way.

Related: #3274
2020-10-19 08:30:05 -04:00
Matthias Clasen
a88e5a5f4e columnview: Fix some issues with column resizing
Ensure that we place the resize rectangle at the visible
right edge of the column, not where the allocation ends
(we clip the header drawing, after all).

Related: #3274
2020-10-19 08:29:29 -04:00
Matthias Clasen
a39e519bed inspector: Clear overlays on unroot
In dispose(), we can't access the root anymore,
since we're already unrooted.

Fixes: #3265
2020-10-17 13:11:58 -04:00
Emmanuele Bassi
e9eb385f25 Merge branch 'patch-1' into 'master'
Add some missing nullable return annotations

See merge request GNOME/gtk!2707
2020-10-17 14:08:29 +00:00
Xavier Claessens
a4aa6d79ad meson: Use feature options for media and print backends
This gracefully disable ffmpeg, gstreamer, cups and cloudprint optional
dependencies when they are not available, while still giving full
control to distributors using -Dauto_features=enabled.
2020-10-17 09:54:47 -04:00
Xavier Claessens
ea3933b87a meson: Make vulkan and xinerama optional deps default to 'auto'
It is nicer for contributors to have a build that works by default.
Distributors should be using -Dauto_features=enabled to get ride of
automagic options.
2020-10-17 09:54:47 -04:00
Xavier Claessens
6ae9f7e7c3 meson: Simplify xinerama dependency check 2020-10-17 09:54:47 -04:00
Xavier Claessens
efbbfb6547 meson: Simplify how cairo dependencies are checked
There is no reason to fallback to find_library for cairo and still rely
on pkg-config for all other dependencies, and just when using MSVC. When
building and pkg-config is not working it is preferable to fallback to a
subproject just like for all other dependencies.

Also add cairo.wrap now that meson support has been merged upstream.
2020-10-17 09:54:47 -04:00
Sophie Herold
cd0bef9390 Add some missing nullable return annotations 2020-10-17 15:32:36 +02:00
Matthias Clasen
5a79cc4d70 Merge branch 'wip/chergert/fix-macos-fps-calculation' into 'master'
macos: fix fps calculation for frame timings

See merge request GNOME/gtk!2705
2020-10-17 12:20:04 +00:00
Piotr Drąg
954855783a Update POTFILES.in 2020-10-17 11:11:24 +02:00
Christian Hergert
7ae8ed82c9 macos: fix fps calculation for frame timings
We need to mark the timings as complete after adding the
presentation time so that we have a valid FPS for the overlay
widget and/or fishbowl demo.
2020-10-15 21:04:51 -07:00
Matthias Clasen
1021e12121 3.99.3 2020-10-15 23:03:03 -04:00
Matthias Clasen
5833e8afa6 Merge branch 'win32.modal' into 'master'
GDK/Win32: Fix modal window handling and window stacking (for GTK4)

See merge request GNOME/gtk!2675
2020-10-16 03:01:38 +00:00
Matthias Clasen
34625142f4 docs: Expand opacity docs
Explain the situation with popovers and opacity.

Fixes: #3246
2020-10-15 22:39:01 -04:00
Matthias Clasen
6cbf1d0379 Merge branch 'a11y-action-fixes' into 'master'
A11y action fixes

See merge request GNOME/gtk!2703
2020-10-16 02:19:08 +00:00
Chun-wei Fan
2cc650ced2 gdk/Win32: Fix mouse pointer capture
Call SetCapture() explcitly for the (new) modal window so that we make the
modal window respond to mouse input, and also call SetCapture() to the parent
of the transient window that we are destroying so that mouse input capture is
returned to the parent window.

This attempts to fix the following:

*  Upon creating a new modal window, the new modal window does not receive
   pointer input unless one switches to another program and back

*  Upon closing a transient window, the parent window that activated the
   transient window does not receive pointer input unless one switches to
   another and back
2020-10-16 10:03:50 +08:00
Matthias Clasen
7165deb630 Merge branch 'fix-listbox-selection' into 'master'
Revert "listbox: Activate single-click rows if n_press >= 1"

Closes #3263

See merge request GNOME/gtk!2704
2020-10-16 02:03:16 +00:00
Руслан Ижбулатов
6a0c181886 GDK W32: Remove stacking functions
Stacking functions enforce non-native stacking behaviour that is
mostly unneeded, and doing so introduces bugs and complicates things.
2020-10-16 10:02:57 +08:00
Руслан Ижбулатов
89286af620 Revert "GDK W32: Use SWP_NOOWNERZORDER everywhere it can be applied"
This reverts commit fc2008f2.

Turns out, we *don't* have code to maintain Z-order. Restacking
code is not doint that, it just enforces a few weird Z-order-related
behaviours.
2020-10-16 10:01:46 +08:00
Chun-wei Fan
bc142b9c43 GDK/Win32: Fix modal window handling
Make sure that we get the state of the modal window properly, and send out the
corresponding notification signals.

This will ensure that we do not try to activate windows that should have become
inactivated due to it opening modal windows and render the program unresponsive
because we are not activating the correct window that is due to receive user
input.
2020-10-16 09:56:42 +08:00
Matthias Clasen
8eb6e876bd Revert "listbox: Activate single-click rows if n_press >= 1"
This reverts commit e669433cde.

This broke selection in several listbox examples.

Fixes: #3263
2020-10-15 21:46:58 -04:00
Matthias Clasen
ab61b7b9ae atspi: Properly filter out parent actions
We only want to show relevant, local actions for
widgets, but _gtk_widget_get_action_muxer() will
return the muxer of a parent widget (all the way
up to the toplevel), if the widget does not have
any actions of its own. To detect this situation,
compare what _gtk_widget_get_action_muxer() returns
for the parent widget, and act accordingly.
2020-10-15 21:32:11 -04:00
Matthias Clasen
3eae91255d atspi: Fix a thinko in action filtering
get_action_at_index() was trying hard to find out
which actions are valid, only to then return the
invalid ones anyway.
2020-10-15 21:31:58 -04:00
Matthias Clasen
5bbacc647c Merge branch 'a11y/atspi-action' into 'master'
A11y/atspi action

See merge request GNOME/gtk!2699
2020-10-16 00:13:23 +00:00
Emmanuele Bassi
cfb327974b a11y: Add atspi.Action for GtkPasswordEntry 2020-10-16 00:34:01 +01:00
Emmanuele Bassi
a83d3078c2 Allow toggling the password entry visibility programmatically
We are going to need a method for toggling the visibility from the
accessibility layer.
2020-10-16 00:34:01 +01:00
Emmanuele Bassi
f67345eb55 a11y: Add atspi.Action for GtkEntry
We need to handle the activation on the entry widget, as well as the
activation of the primary and secondary icons.
2020-10-16 00:34:01 +01:00
Emmanuele Bassi
c10bcf0a60 Add GtkEntry icon signals emitter
We need a (private) way to programmatically trigger the activation of
the entry's icons, so that we can call it from the accessibility layer.
2020-10-16 00:34:01 +01:00
Emmanuele Bassi
9ae08fc0f0 a11y: Add atspi.Action for GtkExpander 2020-10-16 00:34:01 +01:00
Emmanuele Bassi
5f1128899c a11y: De-duplicate some action code
The widgets with hard coded actions should share more code, instead of
copy-pasting it.
2020-10-16 00:34:01 +01:00
Emmanuele Bassi
e44f27a7ed a11y: Special case buttons and switches
These widgets have specific actions.
2020-10-16 00:34:01 +01:00
Emmanuele Bassi
374bd21340 Initial ATSPI Action implementation for widget
Use the actions from the GtkActionMuxer of each widget to populate the
list of actions available.
2020-10-16 00:34:01 +01:00
Matthias Clasen
916ef485d1 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #3245

See merge request GNOME/gtk!2702
2020-10-15 21:00:44 +00:00
Matthias Clasen
92585b75fa Fix compiler warnings 2020-10-15 16:33:35 -04:00
Matthias Clasen
4bd2595421 actionmuxer: Make it possible to enumerate local actions
This will be useful for exposing actions via the
AT-SPI Actions interface.

Update all callers.
2020-10-15 16:32:55 -04:00
Matthias Clasen
aa4c0bf272 spinbutton: Hide the buttons from accessibility
The buttons here are not really buttons (the action
is not tied to the "clicked" signal), so triggering
the buttons via a11y does not have the expected effect.

And we expose the Value interface that ATs can use
to set the value.
2020-10-15 16:32:55 -04:00
Matthias Clasen
4e04c39609 emojicompletion: Avoid a memory overrun
Don't read beyond the beginning of the string.

Fixes: #3245
2020-10-15 16:32:55 -04:00
Matthias Clasen
0bd5a96d71 gtk-demo: Fix some issues with the multi view demo
The nested window was not modal, causing it to be
inoperable. And the nested views within were all
shrunk down to nothingness. Give them some width.

Fixes: #3257
2020-10-15 14:42:43 -04:00
Matthias Clasen
7d22616a0e Merge branch 'a11y-list-view-selection-fixes' into 'master'
atspi: Add fold markers

See merge request GNOME/gtk!2701
2020-10-15 17:36:47 +00:00
Matthias Clasen
8a14f019d0 atspi: Add fold markers
This makes it much easier to navigate in these
multi-implementation files.
2020-10-15 13:14:56 -04:00
Matthias Clasen
329efee643 Merge branch 'a11y-list-view-selection-fixes' into 'master'
A11y list view selection fixes

See merge request GNOME/gtk!2700
2020-10-15 17:10:00 +00:00
Matthias Clasen
bf58b6f88c Merge branch 'ebassi/for-master' into 'master'
GdkWayland API cleanups

Closes #3249

See merge request GNOME/gtk!2688
2020-10-15 16:55:19 +00:00
Matthias Clasen
8701e65635 atspi: Implement Selection more correctly
The Selection interface is defined in terms of child
positions, so we need to always translate from that
to model positions if we want to use the selection
model apis.
2020-10-15 12:46:52 -04:00
Matthias Clasen
5f22ad8848 Remove debug spew 2020-10-15 12:19:58 -04:00
Matthias Clasen
1d40f29776 wayland: Make gdk_wayland_device_pad_set_feedback private
It is not a generally useful api, and awkwardly named.
2020-10-15 12:00:00 -04:00
Matthias Clasen
6d1dcaa92a docs: Explain the symbolic icon paintable situation
Add a paragraph to the migration guide that explains
how to properly render symbolic GtkIconPaintables.

Also mention this in the GtkIconPaintable docs.

There's a reason you can't spell 'paintable' without
'pain'...
2020-10-15 11:42:50 -04:00
Matthias Clasen
9c28ecb0da Merge branch 'a11y/atspi' into 'master'
A11y/atspi

See merge request GNOME/gtk!2698
2020-10-15 14:59:24 +00:00
Matthias Clasen
2488d71a0a Merge branch 'clipboard-emo' into 'master'
gtk-demo: Fix up image handling in the clipboard demo

Closes #3252

See merge request GNOME/gtk!2697
2020-10-15 14:50:54 +00:00
Matthias Clasen
5c8663e383 Merge branch 'wip/wayland-dont-respond-to-destroyed-surface-configure' into 'master'
wayland/surface: Clear has_uncommitted_ack_configure when hiding

Closes #3262

See merge request GNOME/gtk!2696
2020-10-15 14:25:55 +00:00
Matthias Clasen
4b36bceb26 Merge branch 'meson-epoxy-subproject' into 'master'
meson: Fix error when epoxy is a subproject on Windows

See merge request GNOME/gtk!2695
2020-10-15 13:41:47 +00:00
Matthias Clasen
8cf955731f gtk-demo: Fix up image handling in the clipboard demo
Using GtkIconPaintable+GtkPicture is not good for symbolic
icons - they don't get properly colored that way. So change
things around to use the icon name if we have it.

Fixes: #3252
2020-10-15 09:19:17 -04:00
Jonas Ådahl
7dfb25f124 wayland/surface: Clear has_uncommitted_ack_configure when hiding
The 'has_uncommitted_ack_configure' state was added to make sure we're
responding to 'xdg_surface.configure' events with
'xdg_surface.ack_configure' requests, as is necessary according to spec.
What we didn't do was to clear this state when hiding, meaning that if
we hid the surface after a configure event, but before the frame
finished and we processed the 'has_uncommitted_ack_configure', we'd try
to acknowledge the surface configuration after having destroyed the
surface.

Closes: #3262
2020-10-15 14:56:06 +02:00
Matthias Clasen
8737692b2b atspi: Implement Selection for list views
This implementation works for both GtkListView and
GtkGridView, and by extension, also for GtkColumnView
and GtkDropDown, since those just use a list view
internally.
2020-10-15 08:35:06 -04:00
Xavier Claessens
fe89fd2317 meson: Fix error when epoxy is a subproject on Windows
epoxy_dep cannot be used in a configure time check when it comes from a
subproject. Use variables set in pc file instead.

This requires https://github.com/anholt/libepoxy/pull/231.
2020-10-15 08:01:16 -04:00
Matthias Clasen
c7bf33a3de columnview: Set accessible roles
Use the TREE_GRID, ROW, COLUMN_HEADER and GRID_CELL roles
for the various widgets involved in a GtkColumnView. To
enable this, we subclass GtkListView for the internal
list in the column view.
2020-10-15 00:16:25 -04:00
Matthias Clasen
6d562b6176 listview: Set accessible roles
Use the LIST and LIST_ITEM roles for GtkListView
and its children. Use the GRID and GRID_CELL roles
for GtkGridView and its children.
2020-10-14 23:34:51 -04:00
Matthias Clasen
1bf21d3dba Document accessible roles for stacks and notebooks
This was forgotten when I implemented the Tabs pattern.
2020-10-14 22:27:09 -04:00
Matthias Clasen
14640cec85 flowbox: Set accessible roles
Use the GRID and GRID_CELL roles for GtkFlowBox
and GtkFlowBoxChild.
2020-10-14 22:20:43 -04:00
Matthias Clasen
147868a30c listbox: Set accessible roles
Use the LIST and LIST_ITEM roles for GtkListBox
and GtkListBoxRow.
2020-10-14 22:18:21 -04:00
Matthias Clasen
57ebc351a9 Merge branch 'wip/chergert/fix-macos-popup-events' into 'master'
macos: fix popup motion and button event delivery

See merge request GNOME/gtk!2694
2020-10-15 01:41:42 +00:00
Matthias Clasen
375bd5e691 Merge branch 'wip/chergert/gdk-macos-fixes' into 'master'
macos: fix crash when displaying a context menu

See merge request GNOME/gtk!2693
2020-10-15 01:41:06 +00:00
Matthias Clasen
f4f732694a atspi: Add some docs
Add a comment that explains a few of the more subtle
points of the Atspi context tree contstruction.
2020-10-14 21:04:25 -04:00
Matthias Clasen
bf04beb711 atspi: Implement Selection for notebook tabs
This is a bit different from the way things were done
in GTK 3 - we follow what was done for GtkStackSwitcher,
and make the tab bar carry the GTK_ACCESSIBLE_TAB_LIST
role, and implement Selection there.
2020-10-14 21:04:25 -04:00
Matthias Clasen
08b586bb57 notebook: Set accessible roles and properties
Set up the necessary roles, relations and properties
for the tab patterns. This parallels what we have done
for GtkStackSwitcher, and implements the Tabs pattern
as described in the ARIA authoring guidelines.
2020-10-14 21:04:25 -04:00
Matthias Clasen
41d4c37563 atspi: Don't crash on unnamed stack pages
GtkNotebook creates unnamed stack pages, and we should
not crash when that happens.
2020-10-14 21:04:25 -04:00
Matthias Clasen
984e8ac5e3 gizmo: Add a way to set accessible role
This will be used for some of the gizmo used
inside GtkNotebook.
2020-10-14 21:04:25 -04:00
Matthias Clasen
512387afcc atspi: Implement Selection for GtkStackSwitcher 2020-10-14 21:04:25 -04:00
Matthias Clasen
b39684b692 stackswitcher: Set up relations and states
Set up a CONTROLS relation between each tab button
and its page, and update the SELECTED property of
the buttons to match their active state.
2020-10-14 21:04:25 -04:00
Matthias Clasen
380488f829 stackswitcher: Use the tablist and tab roles
Set the tablist role on the stackswitcher itself, and
the tab role on the buttons. This is another step towards
implementing the tabs pattern for GtkStack.
2020-10-14 21:04:25 -04:00
Matthias Clasen
2370429752 accessible: Avoid realizing the context prematurely
platform change is called from gtk_widget_set_focusable
which is likely to be called early on in init(). We don't
want to create an AT context that early if we can help
it, e.g. since it makes it impossible to override the
accessible-role with a construct property.
2020-10-14 21:04:25 -04:00
Matthias Clasen
7c6c718e19 stack: Turn pages into accessibles
This requires some cleanup to remove assumptions
about accessibles being widgets in the backend,
and some code to navigate the tree with these
extra objects in between widgets.

The accessibles for stack pages have the role
GTK_ACCESSIBLE_ROLE_TAB_PANEL. This is the first
step towards implementing the tabs patterns
as described in the aria authoring guidelines
for GtkStack.
2020-10-14 21:04:17 -04:00
Christian Hergert
6e84c7c59e macos: fix discover of surface under cursor
This was incorrectly reporting the toplevel surface instead of the
popup surface that was placed above it. This fixes event delivery
to popups for selecting menu items and more.
2020-10-14 16:59:38 -07:00
Christian Hergert
0af3d21573 macos: only emit popup-layout-changed after initial present
Otherwise we risk being re-entrant where GtkPopover will not have a
GdkPopupLayout causing other issues.
2020-10-14 16:28:44 -07:00
Christian Hergert
e089bba4f5 macos: ensure we have access to a GdkMonitor 2020-10-14 16:28:44 -07:00
Matthias Clasen
2dfced7edc Merge branch 'wip/chergert/gdk-macos-fixes' into 'master'
macos: fix button release events outside of window during grabs

See merge request GNOME/gtk!2692
2020-10-14 23:04:03 +00:00
Christian Hergert
b462bc35c0 macos: allow pointer release event outside surface coords
This helps with grab situations so that we can end it when releasing
the pointer buttons outside of the window coordinates.
2020-10-14 15:45:50 -07:00
Christian Hergert
d700cfa2ef macos: break grabs after sending release event 2020-10-14 15:45:50 -07:00
Christian Hergert
cdb2c1698c macos: dont send crossing events during grab
Fixes an issue where we can't drag scrollbars or text selections while
outside of the application window.
2020-10-14 15:45:50 -07:00
Matthias Clasen
85394b04e0 Merge branch 'wip/chergert/gdk-macos-fixes' into 'master'
GTK4: fix macos device state query for surfaces

See merge request GNOME/gtk!2690
2020-10-14 19:10:11 +00:00
Matthias Clasen
a772d8fcac Merge branch 'wip/baedert/for-master'
Leaving out the gboolean -> bool change.
2020-10-14 15:07:09 -04:00
Timm Bäder
f93784f9e7 pixbufutils: Pass calculated height value along 2020-10-14 15:06:13 -04:00
Timm Bäder
d695b15f1a main: Make sure we don't leak axes
Mainly a change to appease the static analyzer
2020-10-14 15:06:13 -04:00
Timm Bäder
e1e53cd8cc infobar: Remove unused include 2020-10-14 15:06:12 -04:00
Timm Bäder
211d669ae7 overlay: Remove empty finalize implementation 2020-10-14 15:06:12 -04:00
Timm Bäder
20bd8e56ee gtk4-demo: Add missing margin-bottom
This was setting margin-end twice
2020-10-14 15:06:12 -04:00
Timm Bäder
df2d7c56c7 gtk4-demo: Remove connection to removed signal 2020-10-14 15:06:12 -04:00
Timm Bäder
8f24b7ad27 stacksidebar: Fold some functions into their only callers 2020-10-14 15:06:12 -04:00
Timm Bäder
61afb0984c stacksidebar: Set GtkListBox:show-separators
Instead of doing this ourselves
2020-10-14 15:06:12 -04:00
Timm Bäder
93b12a8110 frame: Remove need_resize logic
gtk_widget_set_parent() will queue a resize anyway.
2020-10-14 15:06:12 -04:00
Timm Bäder
d9cc589339 windowcontrols: gtk_widget_get_root() can return NULL 2020-10-14 15:06:12 -04:00
Timm Bäder
557a363b4f windowcontrols: decoration-layout is nullable 2020-10-14 15:06:12 -04:00
Timm Bäder
ae009b344f stylecontext: Remove some unnused includes 2020-10-14 15:06:12 -04:00
Timm Bäder
78c343ba96 snapshot: Refactor some device code
Make a bit clearer what this does.
2020-10-14 15:06:12 -04:00
Timm Bäder
eca3eab96f Remove unneeded gtkstylecontext.h includes 2020-10-14 15:06:12 -04:00
Timm Bäder
2bcef7f030 stylecontext: Remove render_insertion_cursor()
This is unused and there already is a snapshot alternative.
2020-10-14 15:06:12 -04:00
Timm Bäder
18c4bdad6f widget: Remove gtk_widget_list_devices() from private header 2020-10-14 15:06:12 -04:00
Timm Bäder
f20795471c window: Remove unused struct member 2020-10-14 15:06:12 -04:00
Timm Bäder
ec8f329332 widget: Slightly update opacity docs 2020-10-14 15:06:12 -04:00
Timm Bäder
07fb33c033 gl renderer: Fix private function name
It's a GskGLRenderer, not a GskGLRender
2020-10-14 15:06:12 -04:00
Timm Bäder
1fe7043be4 gl renderer: Add more scale_x/scale_y code
We really need all of this to be aware of both dimensions of course...
2020-10-14 15:06:12 -04:00
Timm Bäder
0e6014f2f6 gl renderer: Remove two unused uniforms 2020-10-14 15:06:12 -04:00
Timm Bäder
0a4d442849 gl renderer: return empty texture for too small blurred nodes 2020-10-14 15:06:12 -04:00
Timm Bäder
5f9fa13c65 gl renderer: Use op builder to render flipped texture
Otherwise, we don't know about the uniform state
2020-10-14 15:06:12 -04:00
Timm Bäder
da0abfce3a showrendernode: Plug GOptionContext memory leak 2020-10-14 15:06:12 -04:00
Timm Bäder
161b171004 gl renderer: Remove unused parameter 2020-10-14 15:06:12 -04:00
Timm Bäder
4eee6e732b filechooserwidget: Cosmetics 2020-10-14 15:06:12 -04:00
Timm Bäder
958e4be86d testfilechooser: Stop listening to ::selection-changed
Doesn't exist anymore.
2020-10-14 15:06:12 -04:00
Timm Bäder
eb345cd033 gl renderer: Use nearest filtering for textures in render_texture()
Makes the output in the node editor a bit more bearable.
2020-10-14 15:06:12 -04:00
Timm Bäder
ef7c5747c4 build: Only add -Wcast-align for gcc
Either we or clang needs to get its shit together about this warning.
But using it during development with clang just makes actually usable
warnings get lost in a flood of -Wcast-align warnings.
2020-10-14 15:06:12 -04:00
Timm Bäder
f456438051 vulkan: Remove double initialization
Clang said:

../gsk/vulkan/gskvulkanrenderpass.c:250:5: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
    .render.node = node
    ^~~~~~~~~~~~~~~~~~~
../gsk/vulkan/gskvulkanrenderpass.c:249:13: note: previous initialization is here
    .type = GSK_VULKAN_OP_FALLBACK,
            ^~~~~~~~~~~~~~~~~~~~~~
2020-10-14 15:06:12 -04:00
Timm Bäder
4735c27e69 gl renderer: Avoid some code duplication 2020-10-14 15:06:12 -04:00
Timm Bäder
44f10c5861 gl renderer: Flip texture in render_texture() 2020-10-14 15:06:12 -04:00
Timm Bäder
44d1e81ae9 glsl: Add a comment 2020-10-14 15:06:12 -04:00
Timm Bäder
c5909d4dc4 gtkbuilder: Remove pointless function prototype 2020-10-14 15:06:12 -04:00
Timm Bäder
9698cd67a1 gdkgl: Remove flipping when downloading GL texture
This fix is correct and fixes:

  1) GL textures being upside down in the inspector. They are getting
     downloaded because they've been created in a different GL context
  2) GL textures being upside down in the cairo renderer (same reason)

However, it breaks the testsuite. We do the flipping via the projection
matrix, but most of the shaders don't care about that.
2020-10-14 15:06:12 -04:00
Timm Bäder
d4efb5b738 gdkgl: Stop getting the clip region from cairo
Unused
2020-10-14 15:06:12 -04:00
Timm Bäder
ddcff9eb0f gl renderer: simplify ->render() implementation a bit
We already use self->scale_factor when initialized whole_surface,
so set self->scale_factor first.
2020-10-14 15:06:12 -04:00
Timm Bäder
9fe21b7181 shaderbuilder: Print error message after source code
My terminal scrolls down, so showing the error message last makes sense.
2020-10-14 15:06:12 -04:00
Timm Bäder
7bf858b9d0 gl renderer: Add a helper to setup projection matrix 2020-10-14 15:06:12 -04:00
Timm Bäder
bc034d1190 gl renderer: Ignore rendering if accumulated opacity is too small 2020-10-14 15:06:12 -04:00
Timm Bäder
904772c719 gdkgl: Rename function
This returns the name of the shader type.
2020-10-14 15:06:12 -04:00
Timm Bäder
7222a0901d unblurred outset shadow shader: Use premultiply() 2020-10-14 15:06:12 -04:00
Timm Bäder
a0bb248bb3 gl renderer: Use premultiply() in inset shadow shader` 2020-10-14 15:06:12 -04:00
Timm Bäder
0dc0b03d6f glarea demo: Add min size to gl area 2020-10-14 15:06:12 -04:00
Timm Bäder
9f574a596f gdkgl: Remove unused cairo_get_matrix() call 2020-10-14 15:06:12 -04:00
Timm Bäder
4b8f3e9b92 colorscale: Refactor creating the hue texture
Make this a bit shorter and don't call gtk_hsv_to_rgb in the inner
loop as that is unnecessary.
2020-10-14 15:06:12 -04:00
Timm Bäder
769b15c29b colorplane: Remove (un)realize handlers
Creating the texture in realize() is unnecessary these days, since we
can just rely on size_allocate to do that.
2020-10-14 15:06:12 -04:00
Timm Bäder
8e9a810045 colorutils: Refactor hsv_to_rgb and fold into only caller 2020-10-14 15:06:12 -04:00
Timm Bäder
663ae67935 colorplane: Refactor create_texture()
Create a R8G8B8 texture here so we don't waste memory and do work for
an alpha channel we don't care about.
2020-10-14 15:06:12 -04:00
Timm Bäder
76e4002226 colorutils: Remove unused macro 2020-10-14 15:06:12 -04:00
Timm Bäder
ae71fe3739 colorplane: Whitespace 2020-10-14 15:06:12 -04:00
Emmanuele Bassi
66ce0cbec0 Generate introspection for GdkWayland API
Like we do for GdkX11. We can't use all of the public C API, but we can
expose enough type information to allow non-C developers to actually
check if they are running the Wayland GDK backend or not—plus some
additional Wayland-specific API.
2020-10-14 15:06:12 -04:00
Emmanuele Bassi
fe871f9d46 Add type annotations for GdkWayland API
The GdkWayland API takes generic GDK types and performs a run time
check, which means we need to properly annotate the actual expected
type in order to have methods recognised as such.
2020-10-14 15:06:12 -04:00
Emmanuele Bassi
40e4f3758e Skip GdkWayland symbols that use wayland-client types
The wayland-client API does not have introspection annotations, so we
can't use these types anyway.
2020-10-14 15:06:12 -04:00
Aurimas Černius
2fb1f4a747 Updated Lithuanian translation 2020-10-14 15:06:12 -04:00
Christian Hergert
fb02c99868 macos: port gtk to GDK_WINDOWING_MACOS
For the various uses of GDK_WINDOWING_QUARTZ, we need to use
alternatives from GDK_WINDOWING_MACOS.

Some minor loss of functionality is here, such as icons sent with
application menus. That can certainly be added back at a future
point.
2020-10-14 15:06:12 -04:00
Christian Hergert
036b56a43b gtk: use GDK_WINDOWING_MACOS in gentypefuncs.py 2020-10-14 15:06:12 -04:00
Christian Hergert
9279c2cbd1 gdk: remove quartz subdirectory from backends 2020-10-14 15:06:12 -04:00
Christian Hergert
aed279ed4e macos: add key equivalent helper
This is needed by quartz code in gtk/.
2020-10-14 15:06:12 -04:00
Christian Hergert
cc2e69cbd8 macos: remove workaround for scroll delta
This gets handled differently in gtk/ and so we shouldn't translate it here.
2020-10-14 15:06:12 -04:00
Christian Hergert
ff279d03b2 macos: track various changes in GDK 2020-10-14 15:06:12 -04:00
Christian Hergert
1519b40ffa macos: lookup NSEvent by translated GdkEvent
This will be needed by the quartz imcontext.
2020-10-14 15:06:12 -04:00
Christian Hergert
28d2e608f9 macos: move input method names to private header 2020-10-14 15:06:12 -04:00
Piotr Drąg
c753f8f30b Update Polish translation 2020-10-14 15:05:46 -04:00
Marek Černocký
58769467cf Updated Czech translation 2020-10-14 15:05:46 -04:00
Matthias Clasen
8a361f901d gtk-demo: Keep undisplayable resources out of view
No point in showing an apologetic tab for a blob of binary data.
gtk4-demo shows the resources under /DEMONAME/ for each demo,
so move the data to /DEMONAME_data/.
2020-10-14 15:05:46 -04:00
Matthias Clasen
9b26660095 Send focus events to the root
We are not propagating focus change events, and that is the only
place where we are listening for focus change events. If GtkWindow
does not see focus-in events for its popovers, we end up with
inadvertendly inactive windows.

Fixes: #3240
2020-10-14 15:05:46 -04:00
Matthias Clasen
8dce92e82b window: Be more careful when looking for focus
When passing focus up to a parent, make sure the
newly chosen focus widget actually accepts the focus.
2020-10-14 15:05:46 -04:00
Matthias Clasen
2d927d0ee0 build: Require sysprof 3.38.0
We use sysprof_collector_request_counters, which
was introduced in sysprof 3.38.0.
2020-10-14 15:05:46 -04:00
Matthias Clasen
2273e27808 gtk-demo: Ellipsize columns in the characters demo
some of the columns have uneven widths, causing them
to bounce around as you scroll. Ellipsize them and
give them a fixed with.
2020-10-14 15:05:46 -04:00
Matthias Clasen
2bdc8c7d9e docs: Add more details to the migration guide
Add some details about GdkSurface and GtkWindow api changes.

Fixes: #3242
2020-10-14 15:05:45 -04:00
Christian Hergert
9f01d4fe44 macos: fix coordinates and state when querying device
When querying a device, we need to ensure we are providing coordinates
in the coordinate system of the surface. Further, we need to actually
provide the button and keyboard state.

This fixes some issues related to dragging scrollbars and selecting list
box rows more reliably.
2020-10-14 11:34:44 -07:00
Christian Hergert
d5b5410b8f macos: use simple monotonic for event serial 2020-10-14 11:34:44 -07:00
Christian Hergert
d6abc125ad macos: fix compiler warnings 2020-10-14 11:34:44 -07:00
Matthias Clasen
2142c6c086 docs: Fix a copy-paste error 2020-10-14 08:23:06 -04:00
Emmanuele Bassi
9377192102 Correctly annotate gdk_wayland_seat_get_wl_seat()
We expect a `GdkWaylandSeat` as the instance parameter.
2020-10-14 11:57:06 +01:00
Emmanuele Bassi
da007ac97b Add a public header for GdkWaylandSeat
We have public API requiring it as a type.
2020-10-14 11:55:34 +01:00
Jakub Steiner
974ce500d6 Merge branch 'wip/jimmac/sidebar-hover-selected-focus' into 'master'
Adwaita: selected:hover and focus:selected:hover states

Closes #3251

See merge request GNOME/gtk!2686
2020-10-14 07:36:06 +00:00
Matthias Clasen
b818b34143 Cosmetics
Fix a few copy-paste errors.
2020-10-13 21:27:56 -04:00
Matthias Clasen
32d8db103a Cosmetics
Avoid typo-prone repetition of the full interface names.
We have them in the introspection data already.
2020-10-13 18:58:25 -04:00
Matthias Clasen
9955d900db dropdown: Use the combox accessible role
Its really just a combobox with another name.
2020-10-13 18:31:53 -04:00
Matthias Clasen
e3620bdc22 combobox: Use the combobox accessible role
Makes sense.
2020-10-13 17:53:39 -04:00
Matthias Clasen
b15328e0d6 atspi: Implement Selection for GtkFlowBox
This is a copy of the listbox implementation.
2020-10-13 17:24:06 -04:00
Matthias Clasen
2664c29454 flowbox: Update accessible state for children
Set the SELECTED state to reflect whether the selected
is selected, unselected, or unselectable. This is
enough to make selection changes appear in Accerciser.

While we are at it, also set the multi-selectable
property for the flowbox itself.
2020-10-13 17:24:06 -04:00
Matthias Clasen
db97f99359 atspi: Implement Selection for GtkComboBox
This doesn't really work in Accerciser. But then,
neither does the GTK 3 implementation from which
this is copied.
2020-10-13 17:24:06 -04:00
Matthias Clasen
caeea0e368 Remove excessively spammy debug messages
Non need to announce the same things for every context
we create, and the path is not really that interesting.
without knowing what it belongs to. I would suggest to
make it visible in the inspector instead, so you can
look it up for the widgets you are interested in.
2020-10-13 17:24:06 -04:00
Matthias Clasen
d0753f645e Fix compiler warnings 2020-10-13 17:24:06 -04:00
Matthias Clasen
81e107885c Remove some unused code 2020-10-13 17:24:06 -04:00
Matthias Clasen
8f4bc4a65d atspi: Fix a variant parser oversight
When you pass a variant, the format needs an @.
GVariant is not your friend.
2020-10-13 17:24:06 -04:00
Matthias Clasen
08f57d5c3d atspi: Implement Selection for listbox
Implement the selection interface for GtkListBox.

This also includes a convenience api for context
addresses: gtk_at_spi_context_to_ref.
2020-10-13 17:24:06 -04:00
Matthias Clasen
3cc9ac406d listbox: Update accessible state for rows
Set the SELECTED state to reflect whether the row
is selected, unselected, or unselectable. This is
enough to make selection changes appear in Accerciser.

While we are at it, also set the multi-selectable
property for the listbox itself.
2020-10-13 17:24:06 -04:00
Jakub Steiner
f1e9f853de Adwaita: selected:hover and focus:selected:hover states
- getting pretty deep, but visually seems to make sense. Selected row hovers
  increase contrast.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3251
2020-10-13 21:27:17 +02:00
Matthias Clasen
18b6c4e69d Merge branch 'wip/carlosg/for-master' into 'master'
Cascade-close popovers by default

Closes #3200

See merge request GNOME/gtk!2685
2020-10-13 19:25:59 +00:00
Matthias Clasen
ccbacb5cce Fix the build
I forgot a few casts in a02c50e72f.
2020-10-13 11:23:13 -04:00
Carlos Garnacho
a939203e6e gtkmodelbutton: Drop special case to close GtkPopoverMenu
With ::cascade-popdown in place, this special case is not necessary
anymore.
2020-10-13 16:55:53 +02:00
Carlos Garnacho
3ba60b06fe gtkpopover: Remove GtkPopoverMenu special case
Now that there's ::cascade-popdown, we don't need to treat
GtkPopoverMenu especially here.
2020-10-13 16:55:53 +02:00
Carlos Garnacho
024d832d94 gtkpopover: Add cascade-popdown property/functions
And honor it in gtk_popover_popdown(). By default, a GtkPopover
pops down automatically if a child popover was closed, if this
property is FALSE, the popover will remain opened.
2020-10-13 16:55:53 +02:00
Matthias Clasen
b909455154 atspi: Fix up the role for password entries
We use to set the the 'password text' role for entries with
visibility = FALSE. Nowadays, we have a separate class for
password entries, so fix up the role mapping based on that.
2020-10-13 10:52:43 -04:00
Matthias Clasen
bf0f3a82cf atspi: Make text change notification work
Make text change notification work for editables, by connecting
to the ::insert-text and ::delete-text signals on the wrapped
GtkText widget, and for GtkTextView by connecting to the
corresponding GtkTextBuffer signals.

This code is more or less directly copied from GtkTextViewAccessible
and GtkEntryAccessible in GTK 3.
2020-10-13 09:44:04 -04:00
Matthias Clasen
a02c50e72f text: Make editable signals work again
Since the big editable reorg, GtkText was not emitting
::insert-text and ::delete-text, as is expected of
editables. We want to use those signals for a11y
change notification, so make them work again.
2020-10-13 00:49:10 -04:00
Matthias Clasen
81440675af atspi: Set placeholder-text attribute
This is how GTK3 passes placeholder-text to orca,
and it works - orca reads it.
2020-10-12 23:31:03 -04:00
Matthias Clasen
3af56f5216 atspi: Implement EditableText interface for the entry wrappers
Drop the EditableText implementation for GtkText,
and implement it for all the wrapper widgets instead.
2020-10-12 22:07:18 -04:00
Matthias Clasen
63dd0405c7 accessible: Add some docs
Explain briefly how a11y works for entry wrappers
(since I won't remember a few months from now).
2020-10-12 21:58:49 -04:00
Matthias Clasen
b7ac660f37 atspi: Implement Text interface for the entry wrappers
Drop the Text implementation for GtkText, and implement
it for all the wrapper widgets instead.
2020-10-12 21:45:48 -04:00
Matthias Clasen
76b87272a6 spinbutton: Implement GtkAccessible
This copies what was done for GtkEntry: get
the focused state from the GtkText within.

We also add a private getter for the text widget,
which was missing here.
2020-10-12 21:45:48 -04:00
Matthias Clasen
852c72fa28 passwordentry: Implement GtkAccessible
This copies what was done for GtkEntry: get
the focused state from the GtkText within.
2020-10-12 21:45:48 -04:00
Matthias Clasen
f796d02fea searchentry: Implement GtkAccessible
This copies what was done for GtkEntry: get
the focused state from the GtkText within.
2020-10-12 21:45:48 -04:00
Matthias Clasen
8faf1f64ee entry: Implement GtkAccessible
Override the get_platform_state vfunc to get
the focused state from the GtkText widget within.
2020-10-12 21:45:48 -04:00
Matthias Clasen
8182fab4d9 text: Ignore text widgets for a11y
We want to implement the Text interface on the
wrapper entries.
2020-10-12 21:45:48 -04:00
Matthias Clasen
d0d7848cf2 atspi: Use gtk_accessible_get_platform_state 2020-10-12 21:45:48 -04:00
Matthias Clasen
ade9e4b82a accessible: Add gtk_accessible_get_platform_state
As a companion to go with the platform_change api,
add a gtk_accessible_get_platform_state() function
that can be used by backends to get the platform
state.

This is in preparation for making entries inherit
their focus states from the text widget within.
2020-10-12 21:45:41 -04:00
Matthias Clasen
663934b2dc atspi: Use gtk_accessible_should_present
Replace explicit visibility check by this
more general method of determining whether
an accessible should be presented to the
a11y layer.
2020-10-12 21:43:17 -04:00
Matthias Clasen
d9adc1b5aa accessible: Add a way to hide accessibles
Similar to gtk_widget_should_layout(), add a
gtk_accessible_should_present() function that backends can
use to determine whether an accessible should be presented
or not.

Ways to make a widget not presented in a11y:
- hide the widget
- set its role to NONE
- make it have a NULL AT context

We will use this in future to hide the GtkText inside
an entry, since the Text implementation will be done
by the wrapper.
2020-10-12 21:43:17 -04:00
Matthias Clasen
3bfb32e699 Cosmetics 2020-10-12 21:43:17 -04:00
Matthias Clasen
5eb482ebaa atspi: Treat all entries the same for collecting state
We are determining editable state based on the
accessible role (although we could make it platform
state now), so cover all the roles that we use for
entry wrappers.
2020-10-12 21:43:17 -04:00
Matthias Clasen
61474b5a94 atspi: Fix collecting states
This is somewhat embarrassing.
2020-10-12 21:42:51 -04:00
Matthias Clasen
8f63443393 Fix the build 2020-10-12 21:37:09 -04:00
Matthias Clasen
dd650ff90e atspi: D-Bus methods return tuples
I've learned this the hard way: When returning a
value from a D-Bus call, the variant construct must
*always* be g_variant_new ("(...)"...
2020-10-12 15:50:36 -04:00
Matthias Clasen
101cbe690e Don't unref a floating variant
It gets consumed somewhere along the way.
2020-10-12 15:10:40 -04:00
Matthias Clasen
62747eb243 atspi: Unregister objects on the bus
When a widget is going away, we need to remove
the context from the bus, or else ATs might have
the idea to call methods on them, leading to badness.
2020-10-12 15:10:40 -04:00
Matthias Clasen
d432cbb02b atspi: Emit property changes for focus
With this orca, actually speaks \o/.  Sadly, it only
says 'gtk modelbutton widget' so far, but its a start.
2020-10-12 15:10:40 -04:00
Matthias Clasen
45e82adf87 atspi: Cosmetics
Use simple wrappers instead of opencoding bit twiddling
all over the place.
2020-10-12 15:10:40 -04:00
Matthias Clasen
a2d220edfa widget: Notify a11y of focus changes
This is using the new 'platform changes' mechanism
to tell the a11y backends when focus changes.
2020-10-12 15:10:40 -04:00
Matthias Clasen
b5ee73d299 a11y: Pass on platform changes
Add an enum for 'platform changes' to the at context
change notification mechanism. This will let us pass
along things that ARIA considers 'platform state' such
as focus or editability. The difference between the
platform state and other ARIA states is that we don't
keep the platform state separately in the at context
- backends are expected to just query the widgets.

This is just about avoiding notify listeners for
change notification.
2020-10-12 15:10:40 -04:00
Matthias Clasen
578c8b5068 atspi: Be more careful about indexes
Don't return a number for IndexInParent when we
don't have one.
2020-10-12 15:10:40 -04:00
Matthias Clasen
f9ee23825e atspi: Set some more atspi states
Pass on more of the states that are represented
as properties in aria: modal, multi-line, orientation.
2020-10-12 15:10:40 -04:00
Matthias Clasen
35f70d5a99 Pass orientation property to accessible
We should set the accessible properties we have,
where they make sense. So set orientation, if the
widget is orientable.
2020-10-12 15:10:40 -04:00
Matthias Clasen
54f1eb4c04 wip: Emit StateChanged signals
This is not fully baked, but it is enough to make accerciser
notice when a text entry goes from editable to not editable.
2020-10-12 15:10:40 -04:00
Matthias Clasen
66a81f1187 atspi: Derive readonly state from aria properties
We can use the read-only property, together with the
accessible role, to determine whether to set editable
and read-only states for at-spi. This lets us avoid
directly poking at the widgets.
2020-10-12 15:10:40 -04:00
Matthias Clasen
2a5af4e1d6 text: Set the readonly accessible property
This mirrors what we already do for GtkTextView.
2020-10-12 15:10:40 -04:00
Matthias Clasen
d37b0357b3 atspi: Set editable state
ATs look at not just the implemented interfaces, but
also the states to decide what to do. It turns out that
the EditableText interface is only used by accerciser
if the editable state is set. So set it.
2020-10-12 15:10:40 -04:00
Matthias Clasen
aea25cbbe5 atspi: Implement EditableText interface
Implement EditableText for GtkText and GtkTextView.
2020-10-12 15:10:40 -04:00
Matthias Clasen
a72a7d4aeb atspi: Break out the Value implementation
This isn't necessarily very big, but it keeps
the widget checks out of gtkatspicontext.c, and
it is a nice pattern.
2020-10-12 15:10:40 -04:00
Matthias Clasen
d38182bb5d atspi: Break out the Text implementations
Move the implementation of the Text interface
to its own source file, and split it up along
widget lines, to avoid it becoming too messy.
2020-10-12 15:10:40 -04:00
Matthias Clasen
f22edccb2a scalebutton: Set accessible value properties
This is what we did in GTK 3.
2020-10-12 15:10:40 -04:00
Matthias Clasen
dc9fee6185 paned: Set accessible value properties
This is what we did in GTK 3.
2020-10-12 15:10:40 -04:00
Matthias Clasen
776b4aee0c Simplify GetInterfaces handling
It is error prone to keep the same conditions in sync
in two places. Instead, just assemble the list of interfaces
as we register objects, and use when GetInterfaces is called.
2020-10-12 15:10:40 -04:00
Matthias Clasen
d37782c533 atspi: Implement Value for more widgets
Apply the Value implementation to the widgets where
we had one in GTK 3: GtkLevelBar, GtkRange, GtkScaleButton,
GtkSpinButton, GtkPaned, GtkProgressBar. To make these
work, the widgets need to set the accessible value properties.
2020-10-12 15:10:40 -04:00
Matthias Clasen
8c3e5124c2 atspi: Implement Value interface for ranges 2020-10-12 15:10:40 -04:00
Matthias Clasen
190059dca1 atspi: Implement Text interface for text views
With this, all relevant widgets support the
Text interface.
2020-10-12 15:10:40 -04:00
Matthias Clasen
925ef1f90f atspi: Add textview utilities
These are very similar to the pango utilities,
and are copying code from the textview accessible
implementation in GTK 3.
2020-10-12 15:10:40 -04:00
Matthias Clasen
ba63daa1d2 atspi: Export more pango utils
We are going to reuse some of the code that does
the pango -> atspi attribute conversion for text
tags.
2020-10-12 15:10:40 -04:00
Matthias Clasen
5b076fee12 atspi: Implement text for GtkText widgets too
There is some open question here whether the interface
should be implemented on the outer or the inner widget
of the entry-text pairs. For now, our hand is forced,
since only GtkText provides access to the layout that
we need for implementing many of the interface methods.
2020-10-12 15:10:40 -04:00
Matthias Clasen
b80272a7e7 atspi: Implement Text interface for labels
This is a not-quite-complete implementation of the
Text interface for GtkLabel. The missing parts are
anything around extents and positions, as well as
the ScrollSubstring apis.
2020-10-12 15:10:40 -04:00
Matthias Clasen
7c8a16812e atspi: Add pango utilities
This code is more or less a direct copy of what
we had in gtkpango.c in 3.x.
2020-10-12 15:10:40 -04:00
Matthias Clasen
ddb72accc0 atspicontext: Fix GetIndexInParent for toplevels
For toplevels, we need to return the index in the
list of toplevels, since that is what GtkAtspiRoot
is using.
2020-10-12 15:10:40 -04:00
Matthias Clasen
824ab7e4ed atcontext: labelled-by has a reference list
This is unclear - our docs state that all the
relations have value type reference, but in fact
they all have value type reference list.
2020-10-12 15:10:40 -04:00
Matthias Clasen
3a867e26d0 atspicontext: Implement GetRelationSet
This translates relations as far as the match.

I'm not sure yet what we can do about the fact that
atspi expects relations to be bidirectional (ie have
label-for *and* labelled-by) while aria has only one
direction.
2020-10-12 15:10:40 -04:00
Matthias Clasen
e269cb7a81 atspiroot: Stub out GetRelationSet
This needs to be fully implemented, for now sending
an empty relation set back prevents accerciser from
getting hung up.
2020-10-12 15:10:40 -04:00
Matthias Clasen
0ae2ae7944 atspi: Add the AtspiRelationType enum
This is what we need to map the aria relation
types to.
2020-10-12 15:10:40 -04:00
Matthias Clasen
5db6c4b038 Move atspi enums to gtkatspiprivate.h 2020-10-12 15:10:40 -04:00
Matthias Clasen
db6bd018ca Add a GetInterfaces method
It turns out that accerciser depends on this undocumented
method that is not in the xml at all, otherwise interface
sections in the accerciser ui never get enabled.
2020-10-12 15:10:40 -04:00
Matthias Clasen
9d43e5bd59 Don't pass NULL to g_variant_new_string
That does not work.
2020-10-12 15:10:40 -04:00
Matthias Clasen
edfc55ae89 atspi utils: Fix an oversight
gtk_accessible_role_to_atspi_role must always return
an atspi role. The fallback was returning an aria
role.
2020-10-12 15:10:40 -04:00
Matthias Clasen
d6b64b5e29 Fixup: Add a forgotten #pragma once 2020-10-12 15:10:40 -04:00
Emmanuele Bassi
13aa053f6b Rename libgtk_only symbol in GdkWaylandToplevel
All public non-exported symbols in GDK can be used by GTK.
2020-10-12 16:49:10 +01:00
Emmanuele Bassi
4f316f3249 docs: Remove private GdkWayland API from the reference 2020-10-12 16:44:36 +01:00
Emmanuele Bassi
38304fc138 Hide gdk_wayland_display_prefers_ssd()
The function is not exported, so it should not be in a public header.
2020-10-12 16:44:05 +01:00
Emmanuele Bassi
da6c0f3ecb Move private GdkSurface Wayland API into its own header
This allows us to hide private API from installed headers,
documentation, and introspection.
2020-10-12 16:40:19 +01:00
Emmanuele Bassi
9ce790032d a11y: Convenience API for referencing ATSPI root node
We turn the root node into a reference fairly often, so it's worth it to
have a utility function that does this for us.
2020-10-12 16:19:32 +01:00
Emmanuele Bassi
35163bd7cc a11y: Add utility function for null refs
ATSPI was written for CORBA, which allows passing around "nil"
as valid object references.
2020-10-12 16:19:32 +01:00
Matthias Clasen
9d0952bd7f atspicontext: Implement GetState
Translate the aria states to at-spi's interpretation
of atk states.
2020-10-12 16:19:32 +01:00
Matthias Clasen
e189ccc8ed atspiroot: Fix GetState implementation
When the GetState signature says 'au', it actually
means a bitset that is sent as a pair of 32bit integers.
2020-10-12 16:19:32 +01:00
Matthias Clasen
762fbf34fc atspiroot: Implement GetIndexInParent
Just for good measure
2020-10-12 16:19:32 +01:00
Matthias Clasen
9f73638d43 atspicontext: Implement GetIndexInParent
This is needed for ATs to take our tree seriously.
2020-10-12 16:19:32 +01:00
Matthias Clasen
057b447137 atspicontext: Implement more accessible api
Implement GetChildAtIndex, GetChildren and ChildCount.
2020-10-12 16:19:32 +01:00
Matthias Clasen
78690845b1 atspiroot: Implement GetChildren
No surprises here.
2020-10-12 16:19:32 +01:00
Matthias Clasen
2ea338a8cf atspiroot: Don't leak references
The reffing getter trap, lurking behind g_list_model_get_item().
2020-10-12 16:19:32 +01:00
Matthias Clasen
e2f3039663 atspiroot: Implement GetLocale 2020-10-12 16:19:32 +01:00
Matthias Clasen
8f20133769 atspicontext: Print out the a11y bus address
Make our debug spew useful: Having the bus address
makes it easy to jump on the a11y bus to look around
with dbus tools.
2020-10-12 16:19:32 +01:00
Emmanuele Bassi
55b1fbd0f3 a11y: Localise the role name of the root node 2020-10-12 16:19:32 +01:00
Emmanuele Bassi
b57f1588df a11y: Register the Accessible interface on all AtSpiContext instances
This is not a complement implementation.
2020-10-12 16:19:32 +01:00
Emmanuele Bassi
60acdb9cad a11y: Implement more ATSPI methods on the root node 2020-10-12 16:19:32 +01:00
Emmanuele Bassi
07759b158a a11y: Add method to extract desktop data
We are going to need the desktop name and path to populate the parent
property of AtSpiContexts associated to top level widgets.
2020-10-12 16:19:32 +01:00
Emmanuele Bassi
9511c8273a a11y: Validate the DBus context path
UUIDs use dashes to separate the various blocks; unfortunately, this
results in an invalid DBus object path. Replace the dashes with an
underscore.
2020-10-12 16:19:32 +01:00
Emmanuele Bassi
b85b1f5b51 a11y: Turn accessible roles to string
Add a simple utility function to turn GtkAccessibleRole values into the
appropriate string, including localization.
2020-10-12 16:19:32 +01:00
Emmanuele Bassi
716024d882 a11y: Convert GTK roles to ATSPI ones
There's not a precise, 1:1 mapping between the newer ARIA roles and the
older ATSPI ones. We make do with what we have.
2020-10-12 16:19:32 +01:00
Emmanuele Bassi
21482e8264 a11y: Compute the label for a GtkATContext
The ARIA spec defines the mechanism for determining the name of an
accessible element—see §4.3 of the WAI-ARIA spec.

We follow the specification as much as it makes sense for GTK to do
so:

 1. if the element is hidden, return an empty string
 1. if the element has a labelled-by relation set, retrieve the
    label of the related element
 2. if the element has a label property set, use the value of
    the property
 3. if neither labelled-by nor label attributes are set, we use
    the role to compute the name:
   - for a `range` role, we return the contents of the value of
     the `value-text` or `value-now` properties
   - for any other role, we return a textual representation of
     the GtkAccessibleRole enumeration value
2020-10-12 16:19:32 +01:00
Emmanuele Bassi
88113956a3 tests: Use the test ATContext for every test
Otherwise we're going to need a full desktop session in order to run the
test suite.
2020-10-12 16:19:32 +01:00
Emmanuele Bassi
e6c5d57ffe a11y: Return the ATSPI role for the root element 2020-10-12 16:19:32 +01:00
Emmanuele Bassi
d7ebf18723 a11y: Add AT-SPI cache object
Right now, the cache is unused, and we still need to implement the
serialisation method and emit the signals.
2020-10-12 16:19:32 +01:00
Emmanuele Bassi
658d910967 a11y: Ignore widgets during destruction
There's no point in creating a GtkATContext when a widget is getting
destroyed.
2020-10-12 16:19:32 +01:00
Emmanuele Bassi
bd43e9cfc5 a11y: Register the accessible root object
When we create the first AT-SPI context we also need to register the
accessible root on the accessibility bus. The accessible root object is
the main entry point of an accessible application, and it holds the
global state to present to the ATs that connect to the bus.
2020-10-12 16:19:32 +01:00
Emmanuele Bassi
8c18480092 a11y: Add a display to GtkATContext
Since we need to check at run time what kind of AT context to use, we
need a hook into the whole GDK backend machinery. The display connection
seems to be the best choice, in this case, as it allows us to determine
whether we're running on an X11 or Wayland system, and thus whether we
should create a GtkAtSpiContext.

This requires some surgery to fix the GtkATContext creation function, in
order to include a GdkDisplay instance.
2020-10-12 16:19:32 +01:00
Emmanuele Bassi
8f19bb0832 a11y: Add dummy AT-SPI context
Does not do anything, at the moment, but it's going to get filled out
soon.

The backend is selected depending on the platform being compiled in;
since we're using AT-SPI on X11 and Wayland, and we don't have other
accessibility implementations, we currently don't care about run time
selection, but we're going to have to deal with that.
2020-10-12 16:19:31 +01:00
Emmanuele Bassi
c50916d27b a11y: Add the AT-SPI DBus descriptions
And generate the code for the DBus interfaces.

We don't want the full object manager experience, here, because we're
going to have a single object responding to various interfaces and
remote method calls. For this reason, we're not using the gnome module
in Meson to call gdbus-codegen for us: we need to use the interface info
command line arguments, and those are not available from Meson.
2020-10-12 16:19:31 +01:00
Emmanuele Bassi
4b60e7470a Use test AT context with installed tests
Otherwise we're going to need an AT-SPI service on the session, and the
accessibility bus.
2020-10-12 16:19:31 +01:00
Matthias Clasen
77d4729483 Merge branch 'ebassi/for-master' into 'master'
Ebassi/for master

See merge request GNOME/gtk!2683
2020-10-12 14:39:39 +00:00
Emmanuele Bassi
daac36ea4c Generate introspection for GdkWayland API
Like we do for GdkX11. We can't use all of the public C API, but we can
expose enough type information to allow non-C developers to actually
check if they are running the Wayland GDK backend or not—plus some
additional Wayland-specific API.
2020-10-12 14:07:26 +01:00
Emmanuele Bassi
f83ee2ab6a Add type annotations for GdkWayland API
The GdkWayland API takes generic GDK types and performs a run time
check, which means we need to properly annotate the actual expected
type in order to have methods recognised as such.
2020-10-12 14:07:26 +01:00
Emmanuele Bassi
33e84edf0c Skip GdkWayland symbols that use wayland-client types
The wayland-client API does not have introspection annotations, so we
can't use these types anyway.
2020-10-12 14:07:26 +01:00
Aurimas Černius
08fb8c1c2a Updated Lithuanian translation 2020-10-11 17:25:45 +03:00
Matthias Clasen
035e303f83 Merge branch 'wip/chergert/gdk-macos-fixes' into 'master'
various build fixes for GDK/GTK on macos

See merge request GNOME/gtk!2680
2020-10-10 11:55:01 +00:00
Piotr Drąg
91ba0a31e7 Update Polish translation 2020-10-10 12:45:37 +02:00
Marek Černocký
72ea3a1655 Updated Czech translation 2020-10-10 12:17:27 +02:00
Christian Hergert
07bb07abbe macos: port gtk to GDK_WINDOWING_MACOS
For the various uses of GDK_WINDOWING_QUARTZ, we need to use
alternatives from GDK_WINDOWING_MACOS.

Some minor loss of functionality is here, such as icons sent with
application menus. That can certainly be added back at a future
point.
2020-10-09 20:08:23 -07:00
Christian Hergert
41101673c3 gtk: use GDK_WINDOWING_MACOS in gentypefuncs.py 2020-10-09 20:05:20 -07:00
Christian Hergert
97f03edae4 gdk: remove quartz subdirectory from backends 2020-10-09 20:04:27 -07:00
Christian Hergert
d8ba916586 macos: add key equivalent helper
This is needed by quartz code in gtk/.
2020-10-09 20:03:52 -07:00
Christian Hergert
3f519e4d9b macos: remove workaround for scroll delta
This gets handled differently in gtk/ and so we shouldn't translate it here.
2020-10-09 20:02:38 -07:00
Christian Hergert
58f9413464 macos: track various changes in GDK 2020-10-09 20:02:18 -07:00
Christian Hergert
59cdd7ae69 macos: lookup NSEvent by translated GdkEvent
This will be needed by the quartz imcontext.
2020-10-09 19:59:21 -07:00
Christian Hergert
a30adfe1e0 macos: move input method names to private header 2020-10-09 19:56:21 -07:00
Christian Hergert
6706623731 demo: fix out of bounds array index usage 2020-10-09 19:55:25 -07:00
Matthias Clasen
758675f44e Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #3242 and #3240

See merge request GNOME/gtk!2679
2020-10-09 13:35:57 +00:00
Matthias Clasen
8fcd4ac0f9 gtk-demo: Keep undisplayable resources out of view
No point in showing an apologetic tab for a blob of binary data.
gtk4-demo shows the resources under /DEMONAME/ for each demo,
so move the data to /DEMONAME_data/.
2020-10-09 07:52:29 -04:00
Matthias Clasen
4c3eb7c6f7 Merge branch 'ebassi/for-master' into 'master'
Tone down a user visible message

See merge request GNOME/gtk!2678
2020-10-09 11:47:38 +00:00
Matthias Clasen
115ed005e6 Send focus events to the root
We are not propagating focus change events, and that is the only
place where we are listening for focus change events. If GtkWindow
does not see focus-in events for its popovers, we end up with
inadvertendly inactive windows.

Fixes: #3240
2020-10-09 07:43:40 -04:00
Matthias Clasen
6a0704aeb4 window: Be more careful when looking for focus
When passing focus up to a parent, make sure the
newly chosen focus widget actually accepts the focus.
2020-10-09 07:43:25 -04:00
Matthias Clasen
eb647299d4 build: Require sysprof 3.38.0
We use sysprof_collector_request_counters, which
was introduced in sysprof 3.38.0.
2020-10-09 07:43:25 -04:00
Matthias Clasen
e7aa10342b gtk-demo: Ellipsize columns in the characters demo
some of the columns have uneven widths, causing them
to bounce around as you scroll. Ellipsize them and
give them a fixed with.
2020-10-09 07:43:25 -04:00
Matthias Clasen
c835df5602 docs: Add more details to the migration guide
Add some details about GdkSurface and GtkWindow api changes.

Fixes: #3242
2020-10-09 07:43:25 -04:00
Emmanuele Bassi
43300b4047 Tone down a user visible message
Self-deprecating humour badly translates to a demo message.
2020-10-09 10:14:41 +01:00
Timm Bäder
cdd2a2af1b Merge branch 'kjellahl/gdkseat' into 'master'
gdkseat: Make gdk_seat_get_tools() public

Closes #3241

See merge request GNOME/gtk!2677
2020-10-08 15:05:57 +00:00
Kjell Ahlstedt
cb98a732e4 gdkseat: Make gdk_seat_get_tools() public
Fixes #3241
2020-10-08 16:22:05 +02:00
Timm Bäder
4450f64421 Merge branch 'fix.builder.msvc' into 'master'
testsuite/gtk/builder.c: Fix running on Visual Studio

See merge request GNOME/gtk!2676
2020-10-08 09:42:04 +00:00
Chun-wei Fan
1e4d3b6ca1 testsuite/gtk/builder.c: Fix running on Visual Studio
Explicitly say in the code that we are exporting the symbols so that when the
test program runs, it can find the required builder symbols.
2020-10-08 16:11:35 +08:00
Matthias Clasen
08ecf779f9 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2674
2020-10-08 02:19:42 +00:00
Matthias Clasen
5d7907caa5 gdk: Drop gdk_surface_new_temp
It is not used anymore.
2020-10-07 21:18:25 -04:00
Matthias Clasen
606ab611bd win32: Stop using gdk_surface_new_temp
No need to roundtrip through the frontend to create
one of our own surfaces.
2020-10-07 21:07:40 -04:00
Matthias Clasen
27ef9d9e5e broadway: Stop using gdk_surface_new_temp
No need to roundtrip through the frontend to create
one of our own surfaces.
2020-10-07 21:04:05 -04:00
Matthias Clasen
839baf2bef x11: Stop using gdk_surface_new_temp
No need to roundtrip through the frontend to create
one of our own surfaces.
2020-10-07 21:02:22 -04:00
Matthias Clasen
e602d67e59 wayland: Stop using gdk_surface_new_temp
No need to roundtrip through the frontend to create
one of our own surfaces.
2020-10-07 21:02:22 -04:00
Matthias Clasen
ba108f261f gdk: Drop some unused private api
No users of gdk_display_peek_event, gdk_display_has_pending
_gdk_display_event_data_copy or _gdk_display_event_data_free,
so drop all of these, and related vfuncs.
2020-10-07 21:02:22 -04:00
Matthias Clasen
668868fb1f Merge branch 'master' into 'master'
Allow LPR backend to print PDF and PS file formats

See merge request GNOME/gtk!418
2020-10-07 20:51:40 +00:00
Benjamin Otte
bc5723a846 Merge branch 'wip/otte/for-master' into 'master'
textbuffer: Don't serialize the \0 byte

See merge request GNOME/gtk!2672
2020-10-07 20:33:25 +00:00
Matthias Clasen
98c7de4aa3 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #3237

See merge request GNOME/gtk!2673
2020-10-07 20:30:52 +00:00
Benjamin Otte
0fdb33e82a textbuffer: Don't serialize the \0 byte
... when converting to text/plain.
2020-10-07 22:14:18 +02:00
Matthias Clasen
cfb316799a colorchooser: Bring color names back
These are useful for accessibility.

Fixes: #3237
2020-10-07 15:56:11 -04:00
Jan Alexander Steffens (heftig)
fb0c062506 gtkplacessidebar: Disconnect and unref cloud_manager in dispose
The manager's providers-changed signal can fire after the sidebar has
been freed. Make sure we disconnect the sidebar from the manager.

https://bugs.archlinux.org/task/57984
https://bugs.archlinux.org/task/68123
2020-10-07 15:16:31 -04:00
Matthias Clasen
3d9eb61bba gtk-demo: Fix an off-by-one error
This was found by the asan build in our ci.
2020-10-07 15:16:31 -04:00
Timm Bäder
4993cde0cb Merge branch 'migration-guide-fix' into 'master'
migration guide: Remove stray html tags

See merge request GNOME/gtk!2670
2020-10-07 08:00:43 +00:00
Nicola Fontana
35b0796a1f migration guide: Remove stray html tags 2020-10-07 08:38:26 +02:00
Matthias Clasen
d839c1beab Merge branch 'svg-demo' into 'master'
Svg demo

See merge request GNOME/gtk!2668
2020-10-06 20:55:28 +00:00
Matthias Clasen
5a9547da41 gtk-demo: Add an svg paintable demo
It is a little annoying that this demo will not show up
if we don't find librsvg, but I think showing how easy
this paintable is outweights the annoyance.
2020-10-06 15:12:09 -04:00
Matthias Clasen
25cbc1a15a gtk-demo: Recognize .svg as images
We can't guarantee that we can load it, but worst
case you'll get a missing image.
2020-10-06 15:11:08 -04:00
Matthias Clasen
043207133d Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #3235

See merge request GNOME/gtk!2667
2020-10-06 18:25:48 +00:00
Matthias Clasen
490163efcd Merge branch 'aboutwindow' into 'master'
gtkaboutdialog: Directly specialize GtkWindow

See merge request GNOME/gtk!2666
2020-10-06 18:25:27 +00:00
Matthias Clasen
44fd0c18c8 aboutdialog: Fix updating license tab
We need to update the license button visibility
whenever the license type changes.
2020-10-06 12:53:46 -04:00
Adrien Plazas
a17f33b1fe gtkaboutdialog: Directly specialize GtkWindow
As it doesn't act as a dialog, there is no point specializing GtkDialog,
so his makes it specialize GtkWindow directly.
2020-10-06 18:46:48 +02:00
Matthias Clasen
22eac2f407 window: Fix setting min size
We were inadvertedly setting the windows min size
to the default size, making it so that you can never
shrink a window below its default size.

Fixes: #3235
2020-10-06 11:06:36 -04:00
Matthias Clasen
bdbfaef4d8 gdk: Tweak our GL debug message callback
Go back to installing our debug message callback
unconditionally if G_ENABLE_CONSISTENCY_CHECKS is
defined, and allow opting into it using GDK_DEBUG=gl-debug
otherwise.
2020-10-06 10:34:30 -04:00
Matthias Clasen
214c35ffc7 gdk: Docs tweaks
We don't have library initialization api anymore,
update the section title to reflect that.
2020-10-06 07:58:01 -04:00
Matthias Clasen
7698b4dd63 treelistrowsorter: Add a bandaid
The GtkTreeListRowSortKeys implementation doesn't
know how it wants to cache its keys, and just crashes.

Since that is not cool, add a bandaid fix that forces
it to recreate its keys instead. Extra work, but hey,
no crash.

Related: #3228
2020-10-06 07:58:01 -04:00
Emmanuele Bassi
e532f2322b Merge branch 'FixWin32PopupFocus' into 'master'
Gtk4/Win32: Fix popup focus stealing when CSD is disabled

See merge request GNOME/gtk!2665
2020-10-06 10:30:07 +00:00
firox263
f0a8c6311e Fix Win32 popup focus when using SSD
Prevents GDK Popups from stealing focus from the parent window when
using Server Side Decorations on win32.

It uses `ShowWindow` and the `SW_SHOWNOACTIVATE` flag.
2020-10-06 22:37:35 +13:00
Matthias Clasen
b6d4067717 Merge branch 'wip/carlosg/for-master' into 'master'
gtkpopover: Revert focus to parent on hide()

Closes #3214

See merge request GNOME/gtk!2653
2020-10-06 02:14:54 +00:00
Matthias Clasen
ac164d240b Cosmetic
Don't call gtk_root_get_focus when we already have
the GtkWindowPrivate struct at hand. And use
gtk_window_set_focus to update the focus, like the
old code did.
2020-10-05 21:53:05 -04:00
Carlos Garnacho
38547120b2 gtkwindow: Ensure to revert focus to a parent on hide()
When a widget is hidden, check harder for the keyboard focus being
contained in that widget, in order to reset it. Portions of the
focus child hierarchy may be outdated at the time, so it is more
reliable to check GtkRoot::focus (i.e. the property we intend to
update here).

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3214
2020-10-06 03:29:13 +02:00
Matthias Clasen
7f5deed2eb Merge branch 'simple-resizing-fixes' into 'master'
Simple resizing fixes

Closes #3076

See merge request GNOME/gtk!2661
2020-10-06 01:25:25 +00:00
Matthias Clasen
ccdc10d9df Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #3196

See merge request GNOME/gtk!2662
2020-10-06 00:57:30 +00:00
Timm Bäder
982ebf1b69 gradient shaders: Reduce out values as well
We only do 6 color stops here now. Also works around a driver bug.

Fixes #3196
2020-10-05 20:35:34 -04:00
Matthias Clasen
20fb7812df window: Fix window size snapping back
We were not updating the remembered size at all when
the window is interactively resized, causing it to
snap back to its default size the next time we call
gdk_toplevel_present().

This is a bandaid fix to prevent very broken resizing
behavior, until we have properly redone toplevel sizing.

Fixes: #3076
2020-10-05 20:24:19 -04:00
Matthias Clasen
082edd957e wayland: Don't forget to reapply margins
When using the saved size because the compositor
told us to, we were forgetting to readd the margins.

The visible symptom of this was the window getting
smaller every time we went to tiled state and back.
2020-10-05 20:17:50 -04:00
Matthias Clasen
e5cd2568c8 wayland: Don't save size when tiled
Don't remember the surface size when we are in tiled
state either. This matches the 'fixed_size' condition
in gdk_wayland_surface_configure_toplevel.

This change fixes an issue where moving a window first
to tiled, then to maximized state and back would lead
to the unmaximized window having the tiled dimensions.
2020-10-05 20:15:33 -04:00
Matthias Clasen
d51608a2c9 wayland: Don't emit premature configure events
We should not emit configure events before we are realized - size
changes at this point are not relevant.

This gets rid of a mysterious emission of GdkSurface::size-changed
with a size of 52x52, that is happening when GtkWindow sets the
shadow_width before the window is mapped.
2020-10-05 17:18:14 -04:00
Matthias Clasen
67c6f0a08a gtk-demo: Mention dataset size for Characters 2020-10-05 14:43:38 -04:00
Matthias Clasen
7311464c67 gl: Install the debug message callback for gl-debug
Always install the debug message callback when we can
and GDK_DEBUG=gl-debug is specified. Previously, we
were only installing the callback when the build was
a non-optimized debug build.
2020-10-05 14:43:31 -04:00
Matthias Clasen
aaab461c27 Merge branch 'fix-texture-cache' into 'master'
gl renderer: Fix up texture cache key

See merge request GNOME/gtk!2659
2020-10-05 14:58:20 +00:00
Matthias Clasen
6b0c65cc38 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2660
2020-10-05 14:23:08 +00:00
Matthias Clasen
74d99766e4 gtk-demo: Fix up the Characters demo
Move the Unicode names to a separate source file,
and only build the demo if we have harfbuzz (since
we use script names, and those are only available
with harfbuzz).

Also, fix a forgotten type name.
2020-10-05 09:56:04 -04:00
Alexander Larsson
24a27ba44f gl renderer: Fix up texture cache key
The commit e14d2be1 forgot to actually set the parent_rect in the texture
key in the case it is necessary.
2020-10-05 15:43:04 +02:00
Matthias Clasen
6156c3583d NEWS: Updates
Trying a new scheme - when updating NEWS outside of doing
a release, keep the version out, to make the it clear that
this is just about the tip of the branch, not a complete
release.
2020-10-05 08:18:56 -04:00
Matthias Clasen
2b03674464 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2658
2020-10-05 11:29:10 +00:00
Matthias Clasen
5d26d11868 gtk-demo: Add a column view demo
Make a column view that is showing some Unicode data.
2020-10-04 22:53:45 -04:00
Matthias Clasen
34f33b36f8 Prevent a crash with script names
We can't pass NULL to gettext().
2020-10-04 21:20:48 -04:00
Matthias Clasen
bea3bc5d27 Update the copy in gtk-demo too 2020-10-04 19:48:46 -04:00
Matthias Clasen
5d5625dec8 Update script names to Unicode 13
It would be better if this was provided elsewhere...
2020-10-04 16:15:09 -04:00
Matthias Clasen
cb833d52fb Merge branch 'emoji-data-cldr' into 'master'
Update Emoji data

Closes #1511 and #950

See merge request GNOME/gtk!2656
2020-10-04 13:56:40 +00:00
Matthias Clasen
9007d153c8 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2657
2020-10-04 13:56:30 +00:00
Matthias Clasen
8ca612c966 scale: Make draw-value default to FALSE
This is rarely what you want, so lets turn it off
by default.

Update the one place in our demos where we want to
draw a value, add support for this to gtk-builder-tool,
add a test and mention this change in the migration
guide.
2020-10-04 08:26:44 -04:00
Matthias Clasen
452c909b64 Redo the handling of Emoji data
Use the data files from https://github.com/milesj/emojibase.git
as source for our Emoji data. Slightly change our data format by
adding a group to each item, in both the Emoji data and in the
setting for recent-emoji.

Install translated versions of the data as separate resource
bundles in $prefix/gtk-4.0/emoji, and load them when appropriate.

Currently, we have data for de, en, es, fr, zh, with data taken
from Unicode 13 and CLDR 13.

Fixes: #950 #1511
2020-10-04 01:14:42 -04:00
Matthias Clasen
7ef5921022 Emoji: Drop the shortname field from emoji.data
Match the name for Emoji completion, and display
it too. 'man worker' looks a lot more natural in
the UI than ':man_worker:'.
2020-10-03 20:06:31 -04:00
Matthias Clasen
1d9d5fcf39 Do case-folding and tokenization when creating emoji.data
We can avoid doing the extra work of case-folding and
tokenization whenever we filter in the Emoji chooser.
2020-10-03 19:46:46 -04:00
Matthias Clasen
ed724ebc35 emoji: Add keywords to the data
And use them for matching in the Emoji chooser.
2020-10-03 19:46:46 -04:00
Matthias Clasen
44448016e8 emoji: Some work on the conversion tool
Document the variant format, and write out json
format if asked to.
2020-10-03 19:46:46 -04:00
Matthias Clasen
a4284569c0 Fix Emoji completion
This is some late fallout from the container removal.
2020-10-03 19:42:19 -04:00
Matthias Clasen
9a2faf2197 widget-factory: Enable emoji completion somewhere
Without a quick way to test this, it is bound to
fall apart. As it has.
2020-10-03 19:41:26 -04:00
Matthias Clasen
6e594da5f2 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #506

See merge request GNOME/gtk!2655
2020-10-03 19:27:15 +00:00
Matthias Clasen
ac79c0e799 textbuffer: Improve some get_iter apis
Make these functions return FALSE if they did not
return the exact position that was requested.

Adapt tests.

Based on a patch by Sebastien Wilmet

Fixes: #506
2020-10-03 14:29:07 -04:00
Matthias Clasen
d0b7a4a4ec testsuite: Add a test that checks for property accessors
Make sure that every object property in GTK has accessors for getting
its value (if the property is readable) or setting it (if it is
writable).

Since we are still missing accessors, the test is allowed to
fail for now. Sadly, mesons xfail support is busted, so we just
disable the test entirely :(

Based on initial work by Benjamin Otte.

Related: #2440
2020-10-03 14:28:37 -04:00
Matthias Clasen
60b1b4669e spinbutton: Add some missing accessors
Add a setter and getter for the climb-rate property.
2020-10-03 13:11:20 -04:00
Matthias Clasen
9d0d4cef03 Cosmetics 2020-10-03 13:11:20 -04:00
Matthias Clasen
1b1bf6c90a text: Add some missing setters and getters
Add getters and setters for the enable-emoji-completion,
propagate-text-width and truncate-multiline properties.
2020-10-03 13:11:20 -04:00
Matthias Clasen
38bd4439e8 directorylist: Drop the item-type property
No need for this to be a property.
This showed up in a test for missing accessors.
2020-10-03 13:11:20 -04:00
Matthias Clasen
9fdb71cbd2 icontheme: Add a missing getter
We want to have a get_display() method on every object
that is tied to the display, so add one here.
2020-10-03 13:11:20 -04:00
Matthias Clasen
ff7bcf738c colorbutton: Properly override interface properties
This showed up in a test for missing property accessors.
2020-10-03 13:11:20 -04:00
Matthias Clasen
5640208f31 node-editor: Don't insert hyphens
This can be a bit confusing in multi-line strings.
2020-10-03 13:11:20 -04:00
Matthias Clasen
cef1cd19ff gsk: Avoid long lines in serialized nodes
When encoding big blobs of data in base64, insert newlines.
Base64 allows it, CSS allows it, so not need to make GtkTextView
struggle with multi-megabyte lines.

Update nodeparser tests to reflect this change.
2020-10-03 13:10:55 -04:00
Matthias Clasen
279d3c08a9 gtk-demo: Rename the transition shader files
Easier to find them when their name matches the title
that we show in the UI.
2020-10-03 00:01:25 -04:00
Matthias Clasen
949f22b8b2 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #2261 and #1002

See merge request GNOME/gtk!2654
2020-10-03 03:55:32 +00:00
Matthias Clasen
19d760f9dd gtk-demo: Fix a typo 2020-10-02 23:54:15 -04:00
Matthias Clasen
a9809b0f67 Allow inserting newlines in css strings
Rename _gtk_css_print_string to strip the _ and add
an insert_newlines argument to it. Update all callers,
and make the render node serializer insert newlines.
2020-10-02 23:40:16 -04:00
Matthias Clasen
9033336a23 css: Move _gtk_css_print_string around
Move this to a separate header, since it is not
parser functionality, and kill the duplicate
gtkcssparserprivate.h header.
2020-10-02 23:40:16 -04:00
Jakub Steiner
68ae8506d5 Merge branch 'stackswitcher-button-styling' into 'master'
Adwaita: Simplify stackswitcher button styling

See merge request GNOME/gtk!2498
2020-10-02 15:09:07 +00:00
Matthias Clasen
da8ee53e2d emojichooser: Allow inserting multiple Emoji
Don't close the Emoji chooser when the Control
key is held while clicking. So you can insert
multiple Emoji without having to reopen the
chooser every time.

Fixes: #1002
2020-10-01 23:45:05 -04:00
Matthias Clasen
f6bd2f4d3f Add a test for gsk_gl_shader_compile
This is not super useful, but at least we can
test that we get an error message including the
shader text.
2020-10-01 23:45:05 -04:00
Matthias Clasen
c9f3034e82 gdk: Remove an unused variable 2020-10-01 19:33:43 -04:00
Matthias Clasen
3cf8904d0b Add GTK_INPUT_HINT_PRIVATE
Add a flag that requests that input methods should not
update personalized data (such as typing history).

Fixes: #2261
2020-10-01 17:14:58 -04:00
Matthias Clasen
c43d535aab docs: Fix a copy-paste error 2020-10-01 17:07:53 -04:00
Matthias Clasen
f4bfa16136 Update the release script
If things go according to plan, we don't need to include
gtk-doc as a subproject in the next snapshot.
2020-10-01 15:14:33 -04:00
Matthias Clasen
4d90259b9b Use gtk-doc from master
I've merged the relevant parts from the gtk-doc-for-gtk4
branch.
2020-10-01 15:11:37 -04:00
Matthias Clasen
ffb51b6888 Require gtk-doc 1.33
We'll hopefully get a gtk-doc release out with that
version number soon.
2020-10-01 15:09:26 -04:00
Matthias Clasen
dc3b140fd7 Cosmetics 2020-10-01 13:48:24 -04:00
Matthias Clasen
ce29545470 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #3220

See merge request GNOME/gtk!2652
2020-10-01 14:21:34 +00:00
Matthias Clasen
cbe3de9ce7 Merge branch 'master' into 'matthiasc/for-master'
# Conflicts:
#   .gitlab-ci/test-msys2.sh
2020-10-01 13:56:37 +00:00
Matthias Clasen
6de7022458 Merge branch 'ci-win32-introspection-enabled' into 'master'
CI: Enable introspection again for the Windows build

See merge request GNOME/gtk!2651
2020-10-01 13:50:02 +00:00
Christoph Reiter
9601863569 CI: Enable introspection again for the Windows build
The underlying bug was fixed in glib and backported in MSYS2:
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1665
2020-10-01 15:16:18 +02:00
Matthias Clasen
c278261be0 Merge branch 'wip/jimmac/infosearch-close' into 'master'
Adwaita: close button for infobar, searchbar

Closes #3215

See merge request GNOME/gtk!2650
2020-10-01 12:01:23 +00:00
Matthias Clasen
028cd1e23a Revert "Fix the build with cups < 2.3"
This reverts commit d761e3cf2c.

I am seeing PPD_CUSTOM_UNKNOWN in the cups headers in our
ci images, and that is cups 2.2.12. So this commit was
mistaken.
2020-10-01 07:59:30 -04:00
Matthias Clasen
6e7c0ce06b ci: Give up on sysprof for now
Using sysprof and glib as subprojects of the same
project sadly does not work. Subprojects are not
as robust as they should be.
2020-10-01 07:37:44 -04:00
Jakub Steiner
81cfcba5ad Adwaita: close button for infobar, searchbar
fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3215
2020-10-01 13:14:25 +02:00
Matthias Clasen
9bac129707 ci: Try to get everything building again
It turns out that the sysprof meson setup does not
work with meson 0.54 :( So version 25 of our ci images
bumps the meson version to 0.55.3.
2020-09-30 23:43:03 -04:00
Matthias Clasen
91c8f6b7df build: Try to fix docs+subprojects
Apparently, subprojects don't have pkgconfig variables :(
2020-09-30 16:21:39 -04:00
Matthias Clasen
103080c384 build: Remove an unneeded version check
We are requiring a newer meson than we were checking
for here.
2020-09-30 16:09:56 -04:00
Matthias Clasen
b936419125 ci: Remove --fatal-meson-warnings
meson adds features that then trigger warnings when we run
a newer meson over some of our subprojects. This is all too
fragile.
2020-09-30 15:53:15 -04:00
Matthias Clasen
72eb89eda7 gtk-demo: Add the shader paintable sources
This is currently not public GTK api, just part of
the demo. So we should show it here.
2020-09-30 15:41:05 -04:00
Matthias Clasen
b0da095944 gsk: Fix compiler warnings
We forgot to teach the broadway renderer about new enum
values, and our ci didn't catch it because werror didn't
actually work there until now.
2020-09-30 15:39:30 -04:00
Matthias Clasen
21c8bc2b47 build: Require meson 0.54 2020-09-30 15:26:20 -04:00
Matthias Clasen
7780b89e8a ci: Really enable werror
We wanted to enable werror for gtk without enabling it
for all our subprojects. Sadly, we failed. Try again
2020-09-30 15:26:20 -04:00
Matthias Clasen
517a8406b0 ci: Use the v24 images
These images have meson 0.54.
2020-09-30 15:26:20 -04:00
Matthias Clasen
dfd16e3982 ci: Use a newer meson in images
We need meson 0.54.
2020-09-30 15:26:20 -04:00
Xavier Claessens
fd1e8afe9d meson: Change introspection option to yielding feature
Yielding option means that if pango is built as a subproject, it will
take the value of that option from the parent project (e.g. gst-build).
For that to work it must be of the same type, which is "feature" instead
of "boolean" in all GStreamer modules.
2020-09-30 15:11:27 -04:00
Benjamin Otte
5829bc7c91 Use correct child widget when measuring
Fixes a copy/paste error.

Fixed #3220
2020-09-30 15:11:27 -04:00
Matthias Clasen
5a3aed8ade Merge branch 'introspection' into 'master'
meson: Change introspection option to yielding feature

See merge request GNOME/gtk!2648
2020-09-30 17:50:21 +00:00
Benjamin Otte
5b89253fd9 Use correct child widget when measuring
Fixes a copy/paste error.

Fixed #3220
2020-09-30 17:48:24 +00:00
Matthias Clasen
fd631937f3 transition demo: Make buttons symbolic
It looks better.
2020-09-30 13:43:36 -04:00
Matthias Clasen
77ec961126 Merge branch 'ebassi/for-master' into 'master'
demo: Replace g_print with g_debug

See merge request GNOME/gtk!2645
2020-09-30 15:22:57 +00:00
Matthias Clasen
924e510512 gtk-demo: Update text for the transitions demo
The fire is gone, but we have wobbly widgets!
2020-09-30 11:19:12 -04:00
Matthias Clasen
97ffd94d20 Merge branch 'snazzy-demo' into 'master'
gtk-demo: Make gltransitions demo a bit snazzier

See merge request GNOME/gtk!2644
2020-09-30 15:00:58 +00:00
Alexander Larsson
d6648871b1 gtk-demo/gltransition: Replace fire background with more mellow blobs 2020-09-30 16:38:50 +02:00
Alexander Larsson
5d4a6940fa gtk-demo: Use duck in transitions to get some alpha example 2020-09-30 16:25:30 +02:00
Xavier Claessens
0e5dac8c25 meson: Change introspection option to yielding feature
Yielding option means that if pango is built as a subproject, it will
take the value of that option from the parent project (e.g. gst-build).
For that to work it must be of the same type, which is "feature" instead
of "boolean" in all GStreamer modules.
2020-09-30 09:50:24 -04:00
Matthias Clasen
2dcf750198 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2647
2020-09-30 13:42:55 +00:00
Matthias Clasen
5fa765b284 Mention icon theme in the migration guide
This was requested in #3216.
2020-09-30 08:55:39 -04:00
Matthias Clasen
9d701129cc icontheme: Clarify the docs
Mention that icons directly in /$app_id/icons/ are treated
as unthemed icons.

See #3216
2020-09-30 08:55:39 -04:00
Alexander Larsson
e14d2be1e8 gl renderer: Fix render node texture cache
We're caching two things, either a node itself being rendered, or a
parent storing a cached version of a child as rendered to an offscreen
the size and location of the parent.

If both the parent and child uses the cache this will cause a conflict in
the cache as it is currently use keying of a node pointer which will have
the same value for the node-as-itself and the child-node-of-the-parent.

We fix this by adding another part to the key "pointer_is_child" which means
we can have the same node pointer twice in the cache.

Additionally, in the child-is-rendered-offscreen case the offscreen
result actually depends on the position and size of the parent viewport,
so we need to store the parent bounds in that case.
2020-09-30 14:53:13 +02:00
Emmanuele Bassi
b0a0f07bd7 demo: Replace g_print with g_debug
The GtkGears widget is a bit too chatty, especially when used inside
demos like the fishbowl. Let's use g_debug() instead of g_print() for
the GL debugging message.
2020-09-30 12:35:31 +01:00
Matthias Clasen
7defc3b759 Fix the release script some more
Still trying to master the tar commandline.
2020-09-30 06:51:46 -04:00
Alexander Larsson
e9885f9cde gtk-demo: Make gltransitions demo a bit snazzier
This adds a bunch of snazz to the gltransitions demo. It is perhaps
a bit overloaded now, but it demos everything that we can do.

Changes:
 * The fire shader is now not a bin, it just renders an animating
   background with no textures involved.
 * The stacks don't all start on the same page.
 * The shaderbin passes the mouse coordinate to the shader.
 * The shaderbin allows specifying a "border" so that you can
   cause effects outside the bin child (something that is new to gtk4).
 * All the buttons and the stacks are now in shader-bins that runs
   a wobbly-widget effect based on the mouse position that
   wobbles outside the child allocation.
2020-09-30 11:40:37 +02:00
Matthias Clasen
87393c7fb6 Merge branch 'small-cleanup' into 'master'
menubutton: Remove obsolete private method

See merge request GNOME/gtk!2643
2020-09-29 21:52:37 +00:00
Matthias Clasen
76d616909f Merge branch 'ebassi/for-master' into 'master'
Ebassi/for master

See merge request GNOME/gtk!2642
2020-09-29 20:45:00 +00:00
Matthias Clasen
31069d5e96 release script: Fix doc tarball generation
Strip one level from the directories.
2020-09-29 15:07:13 -04:00
Florian Müllner
7ad42df727 menubutton: Remove obsolete private method
It was only added for the fallback app menu in headerbars, which
has been removed in the meantime.
2020-09-29 20:58:25 +02:00
Emmanuele Bassi
c6cedf608a Add annotations for GtkBuildable virtual functions
Now that the functions that wrap them have gone away from the public
API, we need proper annotations for the virtual functions, otherwise
languages will not have enough information on nullable arguments and
ownership transfer.
2020-09-29 19:48:55 +01:00
Matthias Clasen
218b905a88 3.99.2 2020-09-29 14:44:31 -04:00
Matthias Clasen
00c6340777 gsk: Add some more shader docs
Do a pass over the docs and address minor inconsistencies,
cosmetics and formatting differences.

Mention GSK_DEBUG=shaders.
2020-09-29 14:44:31 -04:00
Matthias Clasen
687ed74d46 Merge branch 'snapshot-stack-optimize' into 'master'
Minor optimizations to GtkSnapshot state stack

See merge request GNOME/gtk!2641
2020-09-29 18:44:07 +00:00
Emmanuele Bassi
97276a5cd4 Remove gtk-doc stanzas from private GtkBuildable API
Various functions were moved to the private GtkBuildable header by
commit 2715b3ec31, but the functions still
have gtk-doc stanzas.
2020-09-29 19:39:34 +01:00
Alexander Larsson
796e6ee306 snapshot: Preallocate and don't memset the state stack
Most of the time the snapshot is less than 16 levels deep (did some testing
in gtk-demo), so lets pre-allocate 16 levels of state stack to avoid the
extra allocation most of the time.
2020-09-29 16:03:06 +02:00
Alexander Larsson
18b8b499de gdkarray: Add support for GDK_ARRAY_NO_MEMSET
If all your callers already initialize the array element as needed,
then we don't need to memset it to zero first.

This is pretty useful for the snapshot state stack, because due
to the per-node-type data area the elements on the stack are
quite large, but often a lot of it is not used.
2020-09-29 16:02:59 +02:00
Alexander Larsson
8a0dd452d2 gdkarray: Inline splice and reserve
This inlines the splice and reserver GdkArray calls. These are
typically only called from the gdk_array_(append/set_size) functions
anyway, and inlining the caller means we can constant propagate the
constant arguments in those calls. Its hard to get exact numbers, but
in fishbowl i noticed a significant decrease in the time spent in
the array code when pushing and poping states.
2020-09-29 15:57:33 +02:00
Matthias Clasen
4cfa9ee19f Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2639
2020-09-29 12:57:36 +00:00
Matthias Clasen
719c44a610 Merge branch 'glshader-track-uniform-state' into 'master'
gl: Track the current uniform state for custom programs

See merge request GNOME/gtk!2638
2020-09-29 12:49:22 +00:00
Matthias Clasen
4a2c817690 docs: Document various entry ::activate signals 2020-09-29 07:04:07 -04:00
Matthias Clasen
aac9414117 statusbar: Remove a misleading doc comment 2020-09-29 07:04:07 -04:00
Matthias Clasen
c897daf797 snapshot: Document radial gradient apis 2020-09-29 07:04:07 -04:00
Matthias Clasen
f1299410bf docs: Fix a typo 2020-09-29 07:04:07 -04:00
Matthias Clasen
165768b6ad wayland: Match header and doc arguments
gtk-doc doesn't take this lightly.
2020-09-29 07:04:07 -04:00
Matthias Clasen
07c338b487 gsk: Document radial gradient api 2020-09-29 07:04:07 -04:00
Matthias Clasen
3af249c046 Silence a compiler warning
These variables are not used anymore since
commit 11e4a46967.
2020-09-29 07:04:07 -04:00
Matthias Clasen
91c3edba35 NEWS: Updates 2020-09-29 07:04:07 -04:00
Alexander Larsson
51ab56d33a gl: Track the current uniform state for custom programs
This allows us to avoid updating uniforms if that is not necessary. This
in turn allows us to sometimes reuse the same draw op by just extending the
vertex array size we draw rather than doing a separate glDraw call.

For example, in the fishbowl demo, all the icons added at the same
time will have the same time and size, so we emit single draw calls
with 100s of triangles instead of 100s of draw calls with 2 triangles.
2020-09-29 11:52:39 +02:00
Alexander Larsson
2e5caa68bc Merge branch 'glshader-node' into 'master'
Add support for GLShader nodes

See merge request GNOME/gtk!2594
2020-09-29 08:30:48 +00:00
Matthias Clasen
4e55220d76 Add some shader tests
These are just basic api usage tests, no rendering.
They found the issues fixed in the preceding commits.
2020-09-29 09:51:16 +02:00
Alexander Larsson
e76cb3e1e4 gtk-demo: Add a shader paintable to the fishbowl
This gets around 500 instances at 60fps on my system.
2020-09-29 09:51:16 +02:00
Alexander Larsson
8bcb031418 gtk-demo: Add GskGLShaderNode demo
Add adds a demo showing off GskGLShaderNode in various ways.

It has a transistion widget, using some examples from
gl-transitions.com, with child widgets being both images, a GL area
and real widgets (that let you edit the transition shaders
themselves.

It also has a fancy fire effect on hove on the buttons.
2020-09-29 09:51:16 +02:00
Alexander Larsson
4d697283ae Support GLShaderNode in backends
For vulkan/broadway this just means to ignore it, but for the gl
backend we support (with up to 4 texture inputs, which is similar to
what shadertoy does, so should be widely supported).
2020-09-29 09:51:16 +02:00
Alexander Larsson
950cc41e15 GtkSnapshot: Add gtk_snapshot_push_glshader() 2020-09-29 09:51:16 +02:00
Alexander Larsson
7ea755e206 Add GskGLShaderNode and GskGLShader
A GskGLShader is an abstraction of a GLSL fragment shader that
can produce pixel values given inputs:
 * N (currently max 4) textures
 * Current arguments for the shader uniform
Uniform types are: float,(u)int,bool,vec234)
There is also a builder for the uniform arguments which are
passed around as immutable GBytes in the built form.

A GskGLShaderNode is a render node that renders a GskGLShader inside a
specified rectangular bounds. It renders its child nodes as textures
and passes those as texture arguments to the shader. You also pass it
a uniform arguments object.
2020-09-29 09:51:16 +02:00
Matthias Clasen
6e9b58b6f0 gsk: Add more shader debug spew
Print out the full assembled shader sources when
GSK_DEBUG=shaders is given. This is very verbose,
but may be useful to see what we actually pass
to the compiler.
2020-09-29 09:51:16 +02:00
Alexander Larsson
645fc6a9a5 GtkWindow: Create renderer before realizing child widgets
This way the child widgets can rely on the renderer (for example what
type it is) to decide details about how they render (such as if they
should use OpenGL shaders).
2020-09-29 09:51:16 +02:00
Matthias Clasen
a91b6b4786 css: Move the last parser api to the new header
This lets us use it from the render node parser
in gsk.
2020-09-29 09:51:16 +02:00
Alexander Larsson
16cdb33c6c shadertoy demo: Fix GLSL on GLES
I was getting "assignment to varying fragColor" errors
2020-09-29 09:51:16 +02:00
Alexander Larsson
bacb3affb3 gl: Add some namespacing to the preamble symbols
This adds a gsk prefix to the stuff in the preamble, as we want to
avoid it conflicting with things in the main shader. Especially once
we start allow some customization of shaders.
2020-09-29 09:51:16 +02:00
Alexander Larsson
9460d0131f gl backend: Add line numbers to source in glsl compilation errors
Almost always the source is created by combining various sources, which
means the line numbers in the error messages are hard to use. Adding
the line numbers to the source in the error message helps with this.
2020-09-29 09:51:16 +02:00
Alexander Larsson
7edcd1748c gl: Properly report error if shader linking fails
In gsk_gl_shader_builder_create_program(), if linking fails we
need to return -1 to indicate error, rather than the old deleted
program id.
2020-09-29 09:51:16 +02:00
Alexander Larsson
6887d0ce24 glrenderer: Move ProgramState into Program
There is no real reason to have this on the side indexed via the
index, as it is stored next to each other anyway. Plus, storing them
together lets use use `Program` structures not in the array.
2020-09-29 09:51:10 +02:00
Matthias Clasen
e29c586b7c Merge branch 'arnaudb/menubutton-direction' into 'master'
Make GtkMenuButton::direction more useful.

Closes #2811

See merge request GNOME/gtk!2636
2020-09-29 01:55:24 +00:00
Matthias Clasen
4f8a211c51 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #3202

See merge request GNOME/gtk!2637
2020-09-29 01:53:02 +00:00
Matthias Clasen
30b7545fb5 Add a reftest for flipping transforms
Verify that a scale of -1 does in fact cause a
gradient to go the other direction.
2020-09-28 21:07:51 -04:00
Matthias Clasen
a799c86edb textbuffer: Elaborate docs
Explain a bit more what gtk_text_buffer_get_content_provider()
is for.

Fixes: #3202
2020-09-28 20:51:13 -04:00
Matthias Clasen
68bb532290 window: Don't get surfaces needlessly
There is a 1-1 correspondence between natives and
surfaces, so we can just compare the natives, no
need to get the surface for every single one.
2020-09-28 20:51:13 -04:00
Matthias Clasen
d2f0e3fa6b doc: Document some apis as widget implementor only
A better solution for this would be nice. For the
time being, just add a sentence to the docs.
2020-09-28 20:51:13 -04:00
Arnaud Bonatti
4684082232 Make GtkMenuButton::direction more useful.
This property was only used until now when
there was neither an icon nor a label set,
for arrow direction and popover placement.

Starting with Gtk4, a GtkMenuButton with a
label shows an arrow at the right (in LTR)
of the label. Allow disabling the arrow or
changing its direction using the direction
property, to have a way to restore a Gtk3-
like look or to improve popover placement.

Fixes #2811.
2020-09-29 02:26:13 +02:00
Matthias Clasen
5536a2ffe6 Merge branch 'wip/carlosg/for-master' into 'master'
gtkeventcontrollerscroll: Drop device type checks

Closes #3210

See merge request GNOME/gtk!2635
2020-09-28 22:03:36 +00:00
Carlos Garnacho
11e4a46967 gtkeventcontrollerscroll: Drop device type checks
Kinetic scrolling (and begin/end tracking) broke with commit cab1dcb696
since the pointing device used on X11 does not get as much GdkInputSource
granularity as the source device used to have in GTK3.

Actually this is kinda pointless, devices incapable of smooth scroll
should send discrete events, without those devices in the picture, we
want kinetic scroll to apply on every other device capable of smooth
scroll, so just do that.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3210
2020-09-28 23:35:36 +02:00
Yosef Or Boczko
01ddc181f9 Update Hebrew translation
(cherry picked from commit f6e3dfd73e)
2020-09-28 19:00:52 +00:00
Yosef Or Boczko
2b3c2962ab Update Hebrew translation
(cherry picked from commit 02d1d9714e)
2020-09-28 18:59:32 +00:00
Matthias Clasen
27b3bb59eb Merge branch 'another-attempt-to-fix-shadertoy' into 'master'
Flip GLArea textures

See merge request GNOME/gtk!2634
2020-09-28 16:16:51 +00:00
Matthias Clasen
ff61f35b77 Merge branch 'cloudproviders-ci' into 'master'
Cloudproviders ci

Closes #2480

See merge request GNOME/gtk!2632
2020-09-28 15:45:08 +00:00
Matthias Clasen
5206cfa837 Merge branch 'wip/otte/for-master' into 'master'
snapshot: Don't flip textures

See merge request GNOME/gtk!2633
2020-09-28 15:43:02 +00:00
Matthias Clasen
b711c12bbe glarea: Flip our texture
The texture that produce is upside-down, compared to what
GSK expects, so flip things around with a transform.

This fixes the shadertoy demo being upside-down after a
recent fix to avoid downloading and reuploading the texture.
2020-09-28 11:34:23 -04:00
Matthias Clasen
431f144f37 gsk: Normalize when transforming bounds
Bounds are assumed to be normalized, and transforms
with negative scales or 3d rotations can make us get
negative sizes.

Fix by Benjamin Otte.
2020-09-28 11:34:16 -04:00
Benjamin Otte
651c92c0ed snapshot: Don't flip textures
... or gradients or borders or shadows. Instead, ensure that affines
have non-negative scale factors. Otherwise add a transform node.

The only place where this check is not necessary is color nodes, but
special casing them seems not worth it.
2020-09-28 16:14:28 +02:00
Milo Casagrande
8487e82133 Update Italian translation 2020-09-28 07:41:47 +00:00
Aurimas Černius
15b635d7bd Updated Lithuanian translation 2020-09-27 22:06:30 +03:00
Matthias Clasen
3aa2519c2b ci: Use v23 images
I added libcloudproviders to the base image, but
now I see that we already enabled libcloudproviders
in the build anyway, so I'm a bit confused.

Fixes: #2480
2020-09-27 11:48:19 -04:00
Matthias Clasen
55bd6d08d4 ci: Add libcloudproviders to the image
Add libcloudproviders to fedora-base:v23 and fedora:v23.
This is so we can enable the cloud-providers feature in
our ci builds.
2020-09-27 11:41:04 -04:00
Matthias Clasen
536e1a1954 Merge branch 'patch-1' into 'master'
treestore: Document the fact that iter is modified by the function, in a machine-readable fashion.

See merge request GNOME/gtk!2613
2020-09-27 15:03:04 +00:00
Danny Milosavljevic
32baa0a549 Update gtktreestore.c: gtk_tree_store_remove didn't have the proper comment annotation
"inout" for the parameter ITER passed.  This means that bindings would misjudge what
the function does.  In the case of guile-gi, it would be misjudged for a predicate,
see gulie-gi bug 87.
2020-09-27 15:03:03 +00:00
Matthias Clasen
6f823cd0bd Merge branch 'issue2627-gtk4' into 'master'
gdk/wayland: Replace gtk-primary-selection with primary-selection-unstable-v1

See merge request GNOME/gtk!2630
2020-09-27 14:51:23 +00:00
Matthias Clasen
97d052ef1b Merge branch 'avoid-gl-texture-download' into 'master'
gsk: Avoid downloading GL textures when possible

See merge request GNOME/gtk!2628
2020-09-27 14:47:52 +00:00
Robert Mader
9ea0469ab0 gdk/wayland: Replace gtk-primary-selection with primary-selection-unstable-v1
The later is the public upstream version, while identical implementation wise.

https://gitlab.gnome.org/GNOME/gtk/-/issues/2591
2020-09-27 16:23:42 +02:00
Matthias Clasen
895c1681f0 Merge branch 'fontchooser-no-lang' into 'master'
fontchooser: Fix builds without PangoFT2

See merge request GNOME/gtk!2629
2020-09-27 12:42:42 +00:00
Matthias Clasen
9ca9f42452 gsk: Avoid downloading GL textures when possible
I found that the gears demo was spending 40% cpu
downloading a GL texture every frame, only to
upload it again to another context.

While the GSK rendering and the GtkGLArea use different
GL contexts, they are (usually) connected by sharing data
with the same global context, so we can just use the
texture without the download/upload dance. This brings
gears down to < 10% cpu.
2020-09-26 21:55:28 -04:00
Matthias Clasen
752270253f fontchooser: Fix builds without PangoFT2
Currently, only if PangoFT2 is present and used it is supported
to retrieve the languages that are supported by a particular font.

If we don't have PangoFT2, remove the language filtering and the
sample text selection.

Based on earlier work by Chun-wei Fan, see
https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/2614
2020-09-26 19:15:45 -04:00
Matthias Clasen
92e551f895 Merge branch 'BUG_gtktreeview_headers_focus_on_click_GTK4' into 'master'
GtkTreeviewColumn: don't focus-on-click header buttons

See merge request GNOME/gtk!1806
2020-09-26 22:50:23 +00:00
Matthias Clasen
593907f7b0 testupload: Test more formats
Copy the format conversion code from GdkMemoryTexture
so we can produce all formats, and test them all.

The upload fast paths assume that the stride is a
multiple of four, so some of the padding values cause
it to fail. Apart from that, things seem to work for
all combinations.
2020-09-26 17:26:12 -04:00
Matthias Clasen
34ec226852 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2626
2020-09-26 14:00:32 +00:00
Matthias Clasen
d56ad7c40c Add a test for various texture uploads
Create textures with various characteristics (alpha, premultiplication,
stride) that trigger different code paths in the gl texture upload
function, and show the resulting images. If all goes well, they all
should look the same.

On my system, this tests texture upload for memory formats
GDK_MEMORY_B8G8R8A8_PREMULTIPLIED, GDK_MEMORY_R8G8B8A8, and
GDK_MEMORY_R8G8B8, and it works with both gl and gles.
2020-09-26 09:20:00 -04:00
Matthias Clasen
ae09e20e8a NEWS: Updates 2020-09-26 09:04:42 -04:00
Matthias Clasen
54944c9cea Merge branch 'fix-texture-upload-more' into 'master'
More texture upload fixes

Closes #3198

See merge request GNOME/gtk!2624
2020-09-26 12:52:25 +00:00
Matthias Clasen
fe8986f2d5 Merge branch 'matthiasc/for-master' into 'master'
gl: Make debug spew more complete

Closes #3197

See merge request GNOME/gtk!2623
2020-09-26 02:02:13 +00:00
Matthias Clasen
d6912a6791 More texture upload fixes
In some cases, with bpp == 3 and a rowstride
that is divisible by 4, we were passing invalid
parameters to GL.

Fixes: #3198
2020-09-25 21:59:33 -04:00
Matthias Clasen
db4b7e3d11 Merge branch 'add-child-clash' into 'master'
Make GtkBuildable vfunc accessor functions private

Closes #3191

See merge request GNOME/gtk!2619
2020-09-26 01:17:08 +00:00
Matthias Clasen
6cdbf1a352 popup: Fix up a doc blurb
The GdkPopup:autohide property was mis-documented.

Fixes: #3197
2020-09-25 20:43:01 -04:00
Matthias Clasen
3d881752bf gl: Make debug spew more complete
List GL_EXT_unpack_subimage among the extensions
we check for.
2020-09-25 20:42:01 -04:00
Matthias Clasen
1b93108d10 Merge branch 'fix-rgb-upload' into 'master'
gl: Fix RGB uploads

Closes #3194

See merge request GNOME/gtk!2620
2020-09-26 00:30:31 +00:00
Florian Müllner
e4d4b50d6d docs: Document GtkBuildable changes in migration guide
https://gitlab.gnome.org/GNOME/gtk/-/issues/3191
2020-09-26 02:16:57 +02:00
Florian Müllner
2715b3ec31 buildable: Make vfunc accessor functions private
With the exception of gtk_buildable_get_id(), those are only used
to construct objects from XML descriptions, which is functionality
internal to GTK.

The API is therefore unlikely to be missed, and keeping it internal
means they can no longer unintentionally shadow object methods in
bindings with less namespacing; for example it's currently ambiguous
whether `infoBar.add_child()` refers to gtk_info_bar_add_child() or
gtk_buildable_add_child().

https://gitlab.gnome.org/GNOME/gtk/-/issues/3191
2020-09-26 02:16:57 +02:00
Florian Müllner
12189bc10f buildable: Rename set_name() to set_buildable_id()
GtkBuildable's get_name()/set_name() methods may shadow
GtkWidget's methods. Avoid that by renaming the API to
get_buildable_id()/set_buildable_id(), which also reflects
the name of the XML attribute the API refers to.

https://gitlab.gnome.org/GNOME/gtk/-/issues/3191
2020-09-26 02:16:05 +02:00
Matthias Clasen
3db217ab7a gl: Reset GL_UNPACK_ALIGNMENT
Reset GL_UNPACK_ALIGNMENT to its initial value of 4 after
changing it for a glTexImage2D call.
2020-09-25 16:17:45 -04:00
Matthias Clasen
a9de1d702e Merge branch 'matthiasc/for-master' into 'master'
columnview: Simplify column constructors

See merge request GNOME/gtk!2622
2020-09-25 18:25:09 +00:00
Matthias Clasen
0c3f42e06e columnview: Simplify column constructors
Drop gtk_column_view_column_new_with_factory and
just make gtk_column_view_column_new accept a
nullable factory. This follows what we've been
doing elsewhere.

Update all callers.
2020-09-25 13:57:10 -04:00
Matthias Clasen
d4b740ce62 Merge branch 'wip/carlosg/for-master' into 'master'
Wip/carlosg/for master

Closes #3125 and #3121

See merge request GNOME/gtk!2621
2020-09-25 17:49:59 +00:00
Carlos Garnacho
d9d494826f gtkbutton: Clean up priv->in_button
This is now only toggled around, may be cleaned up.
2020-09-25 19:20:27 +02:00
Carlos Garnacho
ea6e575901 gtkbutton: Check release coordinates on all release event types
The priv->in_button state that used to be relied upon for pointer
events has been reduced over time to a broken state, since the button
does not track crossing events anymore.

Make the coordinate-based checks apply for pointer events too, besides
touch events. This fixes GtkButton mistakenly emitting ::clicked with
pointer button releases outside the widget.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3121
2020-09-25 19:20:04 +02:00
Matthias Clasen
12f05e80aa gl: Fix RGB uploads
I don't really know what to say, other than:
OpenGL is terrible

Fixes: #3194
2020-09-25 13:16:47 -04:00
Carlos Garnacho
0ccdbfd802 gtktextview: Avoid GtkGestureClick claiming on touch press
We still want the drag gesture (and text selection) to work. Avoid claiming
the gesture early, like it's done in the pointer case.
2020-09-25 19:02:26 +02:00
Carlos Garnacho
7d5accc69f gtkscrolledwindow: Do not eagerly claim touch press event
Claiming early makes the contents unable to react to the touch press
event. Do this on GtkGestureDrag::update past a threshold, so the
child widget(s) can claim before the scrolledwindow does.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3125
2020-09-25 18:58:44 +02:00
Carlos Garnacho
b1606db839 gtkscrolledwindow: Drop gtk_scrolled_window_set_capture_button_press()
This API is kinda stuck in the GdkEvent days, we now negotiate ownership
of the input sequence via GtkGestures. Remove it as it reflects a way to
work that was not exactly accurate and it will turn plainly wrong soon.
2020-09-25 18:57:40 +02:00
Matthias Clasen
c9f6a9f7c5 Merge branch 'gles-texture-colors' into 'master'
Fix uploads of textures in GLES (and make texture uploads better)

See merge request GNOME/gtk!2616
2020-09-25 14:53:19 +00:00
Timm Bäder
09564a5798 Merge branch 'wip/baedert/for-master' into 'master'
Wip/baedert/for master

See merge request GNOME/gtk!2617
2020-09-25 13:35:20 +00:00
Alexander Larsson
a299bbfc58 Drop gdk_cairo_surface_upload_to_gl() helper
There is nothing really special about this code, its just a helper for
uploading pixel data to opengl, and we're not really in the business
of doing opengl-specific helper functions.
2020-09-25 15:00:07 +02:00
Alexander Larsson
90fc671ef8 gl backend: Avoid roundtripping via surface when updloading
Do custom uploads rather than using gdk_cairo_surface_upload_to_gl(),
because this way we avoids a roundtrip (memcpy and possibly conversion)
to the cairo image surface format.
2020-09-25 10:04:48 +02:00
Alexander Larsson
c71921a6be gdk_gl_context_upload_texture() avoid conversion for pixbuf format
The gdk-pixbuf non-rgba format can be directly uploaded without
conversion.

The rgba format needs alpha premultiplication though, which is not
supported by GL during upload.
2020-09-25 09:31:43 +02:00
Alexander Larsson
1001995d49 Correctly upload textures for GLES
GLES doesn't support the GL_BGRA +  GL_UNSIGNED_INT_24_8 hack that
we use on desktop OpenGL to upload textures directly in the cairo
pixel format. This adds the required conversions to all the places
that currently need it.

We also add a data_format to the internal gdk_gl_context_upload_texture()
function to make it clearer what the format are. Currently it is always
the cairo image surface format, but eventually we want to support other
formats so that we can avoid some of the unnecessary conversions we do.

Also, the current gdk_gl_context_upload_texture() code always converts
to a cairo format and uploads that like we did before. Later commits
will allow this to use other upload formats that gl supports to avoid
conversions.
2020-09-25 09:31:43 +02:00
Alexander Larsson
8e59cdabac Add GDK_MEMORY_R8G8B8A8_PREMULTIPLIED
This is the default OpenGL format, and in fact the only pixel format
that GLES supports uploading as. Actually, the premultiplied part is
really just about how we use the textures, but all textures in GTK
are premultiplied.
2020-09-25 09:31:43 +02:00
Alexander Larsson
88b709d5ec texture: Unvirtualize download_surface
We only have one implementation, so why do all this vfunc work?
2020-09-25 09:31:43 +02:00
Matthias Clasen
e6d5a3c4e8 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #3180, #3178, and #3179

See merge request GNOME/gtk!2618
2020-09-24 18:50:26 +00:00
Matthias Clasen
e70ed905d1 columview: Don't overdraw
Just always tell the title and cell widgets to
clip their children to the right size. Otherwise
we risk things getting out of sync and unintended
overdraw.

Fixes: #3179
2020-09-24 14:30:40 -04:00
Matthias Clasen
7eb0ae39c5 columview: Fix column resizing
We were not handling the fixed_width quite right,
and that was causing screaming from the GTK size
allocation machinery.

Fixes: #3178
2020-09-24 14:18:38 -04:00
Timm Bäder
2f93287473 cssimagefallback: Whitespace 2020-09-24 19:08:22 +02:00
Timm Bäder
484dcc043b cssimagefallback: Avoid allocating GPtrArray for colors
If we just parse a color, like image(#FFF), avoid allocating the
GPtrArray to store images. This happens in Adwaita for background images
of backdrop buttons. We save around 70 GPtrArrays this way.
2020-09-24 19:08:22 +02:00
Timm Bäder
716b5afe6a Adwaita: Fix calendar header button backdrop bg color 2020-09-24 19:08:22 +02:00
Timm Bäder
fd728ea8bc gl renderer: Lower maximum gradient stop count
6 is still plenty according to my market research.

Should help with #2624
2020-09-24 19:08:22 +02:00
Timm Bäder
8d7b3bade3 gl renderer: Fall back to cairo if gradients use too many stops 2020-09-24 19:08:22 +02:00
Timm Bäder
12cc178756 textbuffer: Don't try to inset NULL text from clipboard
That used to generate a critical error message.

Also free() the data.
2020-09-24 19:08:22 +02:00
Timm Bäder
9eaa8bd1e7 gl renderer: Only return error if creating programs failed 2020-09-24 19:08:22 +02:00
Timm Bäder
15994db74d gl renderer: Use scale_x/y when rendering clipped nodes 2020-09-24 19:08:22 +02:00
Timm Bäder
467be0b7dc gl renderer: Don't use ops_get_scale() when rendering clip nodes
Differentiate between scale_x and scale_y. This works better for e.g.
transform nodes using scaleX().
2020-09-24 19:08:22 +02:00
Timm Bäder
84d2a33c10 gl renderer: Support scaleX/Y better when rendering radial gradients
We should do this everywhere, but this is a start.
2020-09-24 19:08:22 +02:00
Matthias Clasen
9fde0137a0 listview: Avoid a critical when reordering
When sorting a cell into the place its already at,
we were triggering criticals. Avoid that.

Fixes: #3180
2020-09-23 22:53:21 -04:00
Matthias Clasen
9dab51e7be Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #3188

See merge request GNOME/gtk!2612
2020-09-23 22:44:22 +00:00
Matthias Clasen
810218b2f5 fontchooser: Don't center the list
The centered layout of the font previews don't look appealing
and make it harder to judge the relative width and weight of
the individual styles.

Fixes: #3188
2020-09-23 16:32:48 -04:00
Balázs Úr
7acbbd6bdd Update Hungarian translation 2020-09-23 15:25:12 +00:00
Balázs Úr
a364ab1efb Update Hungarian translation 2020-09-23 14:39:40 +00:00
Thomas Holder
4325c20013 gtktreeview: Fix child access after TEST_EXPAND_ROW
In gtk_tree_view_build_tree with recurse=TRUE, the TEST_EXPAND_ROW
signal might invalidate the child iterator. Getting the iterator after
the signal (instead of before) fixes the issue.

Fixes https://gitlab.com/inkscape/inkscape/-/issues/1879
2020-09-23 07:53:33 -04:00
Matthias Clasen
7bae48335f Merge branch 'wip/jimmac/osd-spinbutton' into 'master'
Adwaita: osd spinbutton specificity bump

Closes #2769

See merge request GNOME/gtk!2610
2020-09-23 11:47:01 +00:00
Matthias Clasen
571f15cac6 Merge branch 'make-claiming-button-release-work' into 'master'
gestures: Make claiming button release work

See merge request GNOME/gtk!2576
2020-09-23 11:35:59 +00:00
Jakub Steiner
78236bfdbe Adwaita: osd spinbutton specificity bump
- mimic the peculiar selector from the normal style onto osd to
  override.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/2769
2020-09-23 10:16:55 +02:00
Matthias Clasen
53dddf163d gestures: Make claiming button release work
When claiming a sequence in a gesture signal handler,
the expected result is that GtkGesture::handle-event
returns TRUE, causing the event to not be propagated
further.

This doesn't work for button release events, since
gtk_gesture_handle_event does the following:
  add point
  emit ::update
  remove point
  check claimed status
The ::update signal is where the application code
claims the sequence. But removing the point purges
the sequence from the gestures memory, so checking
the claimed status returns FALSE.

This patch fixes things to behave as expected, by
checking the claimed status before removing the point.
2020-09-14 08:35:44 -04:00
nana-4
68379c3ff7 Adwaita: Simplify stackswitcher button styling
Simply use negative margins against the padding.

Also remove the indicator only when the .needs-attention style class is
removed.
2020-08-28 22:06:44 +09:00
Nelson Benítez León
ba9b4f418d GtkTreeviewColumn: don't focus-on-click header buttons
currently when mouse clicking on a column header
to sort it it is grabbing keyboard focus, this
should not happen, keyboard focus should remain
where it was before. This can be seen on the
GtkFileChooser widget, when having the keyboard
focus on the file list items and clicking on a
column header to sort it the keyboard focus is
now on the header.
2020-04-30 22:59:08 -04:00
Sean Farley
99dfdfcd5e Allow LPR backend to print PDF and PS file formats
At least from GTK v3.22.30, the code disallows attempts to print PDF and
PS files using the LPR backend. Although it is not easy or possible for
GTK to determine if the printer can print these formats by querying lpr,
the print backend should allow lpr to try.

There are two uses cases:
- A filter is being used by lpr, specified in the printcap file, to process the
  files prior to printing them.
- The printer can print PDF and PS files directly. There are many printers that
  can print these formats, so GTK should allow for the possibility.
2018-11-17 13:04:35 -05:00
937 changed files with 62931 additions and 72946 deletions

View File

@@ -1,3 +1,7 @@
include:
- project: 'gnome/citemplates'
file: 'flatpak/flatpak_ci_initiative.yml'
stages:
- build
- analysis
@@ -16,13 +20,13 @@ stages:
# Common variables
variables:
COMMON_MESON_FLAGS: "--fatal-meson-warnings -Dgtk:werror=true"
COMMON_MESON_FLAGS: "-Dwerror=true -Dglib:werror=false -Dpango:werror=false -Dgtk-doc:werror=false -Dwayland-protocols:werror=false -Dsysprof:werror=false"
BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true"
FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled"
MESON_TEST_TIMEOUT_MULTIPLIER: 3
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v22"
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v25"
FLATPAK_IMAGE: "registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master"
DOCS_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora-docs:v19"
DOCS_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora-docs:v25"
.only-default:
only:
@@ -74,7 +78,6 @@ fedora-x86_64:
script:
- meson subprojects update
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} ${BACKEND_FLAGS} ${FEATURE_FLAGS}
-Dsysprof=enabled
_build
- ninja -C _build
- .gitlab-ci/run-tests.sh _build x11
@@ -100,6 +103,7 @@ installed-tests:
needs: []
variables:
EXTRA_MESON_FLAGS: "--prefix=/usr --libdir=/usr/lib64 -Dinstall-tests=true"
G_TEST_ACCESSIBLE: 1
script:
- meson subprojects update
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} ${BACKEND_FLAGS} ${FEATURE_FLAGS}
@@ -149,6 +153,7 @@ msys2-mingw64:
artifacts:
paths:
- "${APPID}-dev.flatpak"
- 'repo.tar'
expire_in: 1 day
script:
- bash -x ./.gitlab-ci/flatpak-build.sh "${APPID}"
@@ -200,6 +205,24 @@ flatpak-master:icon-browser:
variables:
APPID: org.gtk.IconBrowser4
# Publish the demo apps to the GNOME Nightly repo
# https://wiki.gnome.org/Apps/Nightly
# https://gitlab.gnome.org/GNOME/Initiatives/-/wikis/DevOps-with-Flatpak
nightly demo:
extends: '.publish_nightly'
dependencies: ['flatpak-master:demo']
needs: ['flatpak-master:demo']
nightly factory:
extends: '.publish_nightly'
dependencies: ['flatpak-master:widget-factory']
needs: ['flatpak-master:widget-factory']
nightly icon-browser:
extends: '.publish_nightly'
dependencies: ['flatpak-master:icon-browser']
needs: ['flatpak-master:icon-browser']
static-scan:
image: $FEDORA_IMAGE
stage: analysis
@@ -223,7 +246,7 @@ asan-build:
needs: []
variables:
script:
- CC=clang meson --buildtype=debugoptimized -Db_sanitize=address -Db_lundef=false -Dintrospection=false _build
- CC=clang meson --buildtype=debugoptimized -Db_sanitize=address -Db_lundef=false -Dintrospection=disabled _build
- ninja -C _build
- .gitlab-ci/run-tests.sh _build wayland
artifacts:

View File

@@ -44,6 +44,7 @@ RUN dnf -y install \
lcov \
libasan \
libattr-devel \
libcloudproviders-devel \
libepoxy-devel \
libffi-devel \
libmount-devel \
@@ -86,5 +87,5 @@ RUN dnf -y install \
xorg-x11-server-Xvfb \
&& dnf clean all
RUN pip3 install meson==0.53.1
RUN pip3 install meson==0.55.3

View File

@@ -1,4 +1,4 @@
FROM registry.gitlab.gnome.org/gnome/gtk/fedora-base:v19
FROM registry.gitlab.gnome.org/gnome/gtk/fedora-base:v25
RUN dnf -y install pandoc

View File

@@ -1,4 +1,4 @@
FROM registry.gitlab.gnome.org/gnome/gtk/fedora-base:v21
FROM registry.gitlab.gnome.org/gnome/gtk/fedora-base:v25
# Enable sudo for wheel users
RUN sed -i -e 's/# %wheel/%wheel/' -e '0,/%wheel/{s/%wheel/# %wheel/}' /etc/sudoers

View File

@@ -22,7 +22,7 @@ flatpak build ${builddir} meson \
-Dprint-backends=file \
-Dbuild-tests=false \
-Dbuild-examples=false \
-Dintrospection=false \
-Dintrospection=disabled \
-Ddemos=true \
_flatpak_build
@@ -40,3 +40,8 @@ flatpak build-bundle \
${appid}-dev.flatpak \
--runtime-repo=https://nightly.gnome.org/gnome-nightly.flatpakrepo \
${appid}
# to be consumed by the nightly publish jobs
if [[ $CI_COMMIT_BRANCH == master ]]; then
tar cf repo.tar ${repodir}
fi

View File

@@ -60,14 +60,12 @@ pkg-config --modversion pango
ccache --zero-stats
ccache --show-stats
export CCACHE_DISABLE=true
# FIXME: introspection disabled for now because of
# https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/340
meson \
-Dx11-backend=false \
-Dwayland-backend=false \
-Dwin32-backend=true \
-Dvulkan=disabled \
-Dintrospection=false \
-Dintrospection=enabled \
-Dgtk:werror=true \
_build
unset CCACHE_DISABLE

206
NEWS
View File

@@ -1,19 +1,189 @@
Overview of Changes in 3.99.4
=============================
* GtkColumnView:
- Improve column resizing
- Make double-click reset column widths
- Move header outside of scrollbars
* GtkSearchEntry:
- Add an icon
* GtkDropDown:
- Polish the appearance
* GtkColorChooser:
- Accessibility improvements
* GtkPopoverMenu:
- Add accessibility support
- Allow custom items. This adds new API:
gtk_popover_menu_add/remove_child
gtk_popover_menu_bar_add/remove_child
* GtkTextView:
- Fix rendering and positioning of anchored children
- Fix positioning of touch handles
* Constraints:
- Fix loading constraints from ui files
* Media support:
- Use cubic instead of linear volume
* Accessibility:
- Implement Component for all widgets
- Implement Text and EditableText for all editables
- Rework accessible name/description computation
- Add documentation for app and widget developers
- Handle HIDDEN state changes by adding/removing elements
- Support setting accessibility attributes in ui files
- Make window controls accessible
* Introspection:
- Add some missing annotations
* gdk:
- Deliver events on flush
- Drop the unused GdkPoint struct from the API
- Improve popup autohide behavior
* Demos:
- Add another constraints demo
- Tweak various demos to improve consistency
- Small accessibility improvements
* Tools:
- Improve gtk4-builder-tool handling of various
widgets when converting ui files from GTK 3
* Documentation:
- Use GtkApplication in all examples
- Improve and expand the widget gallery
* Testsuite:
- Improve coverage of GDK
- Improve coverage of gtk4-builder-tool
* Build:
- Fix the build with cups 2.2.12
- Make cloudprint support build without warnings
* Broadway:
- Support modifiers for scroll events
* Windows:
- Improve IME support
* OS X:
- Fix various input issues
- Make GtkGLArea work (with the cairo backend)
* Translation updates:
German
Polish
Overview of Changes in 3.99.3
=============================
* Accessibility:
- Add an initial AT-SPI backend
* GtkEmojiChooser:
- Allow inserting multiple Emoji by pressing Control
- Update Emoji data to Unicode 13 / CLDR 37
- Use translations
- The recent-emoji setting type changed. Call
gsettings reset org.gtk.gtk4.Settings.EmojiChooser recent-emoji
* GtkTextBuffer:
- Add boolean returns to some get_iter functions
* GtkScale:
- Change the default value of the :draw-value property
* GtkPopover:
- Avoid losing focus when popovers are close
* GtkColorChooser:
- Add color names back for accessibility
* Input methods:
- Add a 'private' input hint
* GL Renderer:
- Fix issues with texture caching
- Fix texture flipping problems
* Build:
- Use meson yield feature for some options
- Require gtk-doc 1.33
- Require sysprof 3.38
* Wayland:
- Clean up Wayland backend api, add annotations
- Generate introspection for Wayland backend api
* Windows:
- Fix modal window handling and window stacking
* MacOS:
- Fix the build
- Define GDK_WINDOWING_MACOS
- Fix various event handling issues
* Demos:
- Add another column view demo
- Add an svg paintable demo
* Translation updates
Czech
Lithuanian
Polish
Overview of Changes in GTK 3.99.2
=================================
* GtkButton:
- Check coordinates for button releases
* GtkColorChooser:
- Update the default palette
* GtkEntry:
- Fix issues with Emoji insertion
- Fix issues with dnd
- Set correct hotspot for dnd icon
* GtkFileChooser:
- Fix a crash
- Fix setting unlisted filters
* GtkFontChooser:
- Determine sample text based on font coverage (requires fontconfig)
- Allow filtering by language (requires fontconfig)
- Don't center the list
* GtkMenuButton:
- Always use the direction property for the arrow
* GtkPasswordEntry:
- Use non-pageable memory
- Add an ::activate signal
* GtkRevealer:
- Fix clipping issues in the swing transitions
* GtkScrolledWindow:
- Fix kinetic scrolling in X11
* GtkSearchEntry:
- Don't handle forwarded events twice
* GtkPasswordEntry:
- Add an ::activate signal
* GtkStack:
- Add gtk_stack_add_child
* GtkTextView:
- Fix dnd
@@ -22,28 +192,12 @@ Overview of Changes in GTK 3.99.2
- Make clickable links work again
- Fix handling of anchored children
* GtkRevealer:
- Fix clipping issues in the swing transitions
* GtkColorChooser:
- Update the default palette
* GtkFileChooser:
- Fix a crash
- Fix setting unlisted filters
* GtkFontChooser:
- Determine sample text based on font coverage
- Allow filtering by language
* GtkStack:
- Add gtk_stack_add_child
* GtkVideo:
- Make autoplay work
* CSS:
- Allow more than 64 selectors per rule
- Avoid some allocation overhead
* Adwaita:
- Improve gesture graphics
@@ -52,15 +206,20 @@ Overview of Changes in GTK 3.99.2
* GDK:
- Add gdk_frame_clock_get_fps
- GLES: Fix color channel mixup in textures
- GL: Reduce image copying for texture uploads
* GSK:
- Add radial gradient nodes
- Add GskGLShader and shader nodes
* GL renderer:
- Fix clipping with projective transforms
- Use linear interpolation for offscreen rendering
with non-axis-aligned transforms
- Fix texture caching to avoid size mismatches
- Avoid downloading GL textures when possible,
improving GtkGLArea performance
* Vulkan renderer:
- Fix swapchain creation
@@ -70,18 +229,26 @@ Overview of Changes in GTK 3.99.2
* Wayland
- Always ack configure to avoid jumping windows
- Use the primary-selection-unstable-v1 protocol
* API cleanups:
- Make filter and sorter constructors return exact types
- Rename GdkSurfaceState to GdkToplevelState
- Remove GdkWaylandSurface::committed
- Make Wayland backend api take GdkToplevel
- Drop gtk_widget_new
- Drop cairo_surface_upload_to_gl
- Drop gtk_scrolled_window_set_capture_button_press
- Drop gtk_column_view_column_new_with_factory
- Rename gtk_buildable_set_name to gtk_buildable_set_buildable_id
- Drop other GtkBuildable api
* Demos:
- Bug and crash fixes
- Cosmetic improvements for several demos
- Improve search in the sidebar
- Add a Shadertoy demo
- Add a OpenGL transitions demo
- Add an Emblem demo
- Add a demo for input validation and error states
- Add a demo for context menus
@@ -101,6 +268,7 @@ Overview of Changes in GTK 3.99.2
French
Galician
German
Hebrew
Hungarian
Indonesian
Italian

View File

@@ -1,8 +1,9 @@
/* config.h.in. Generated from configure.ac by autoheader. */
/* always defined to indicate that i18n is enabled */
#define ENABLE_NLS 1
/* Use structured logging */
#define G_LOG_STRUCTURED 1
/* The prefix for our gettext translation domains. */
#mesondefine GETTEXT_PACKAGE

View File

@@ -36,7 +36,7 @@ struct _ConstraintEditorWindow
G_DEFINE_TYPE(ConstraintEditorWindow, constraint_editor_window, GTK_TYPE_APPLICATION_WINDOW);
static GtkConstraintTarget *
find_target (GListModel *model,
find_target (GListModel *model,
GtkConstraintTarget *orig)
{
const char *name;
@@ -163,20 +163,30 @@ constraint_editor_window_load (ConstraintEditorWindow *self,
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);
clone = gtk_constraint_new (find_target (constraint_view_get_model (CONSTRAINT_VIEW (self->view)), target),
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),
find_target (constraint_view_get_model (CONSTRAINT_VIEW (self->view)), source),
gtk_constraint_get_target_attribute (constraint),
gtk_constraint_get_multiplier (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);
@@ -300,7 +310,7 @@ save_response_cb (GtkNativeDialog *dialog,
model = constraint_view_get_model (CONSTRAINT_VIEW (self->view));
text = serialize_model (model);
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
g_file_replace_contents (file, text, -1,
g_file_replace_contents (file, text, strlen (text),
NULL, FALSE,
G_FILE_CREATE_NONE,
NULL,

View File

@@ -1,9 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="ConstraintEditorWindow" parent="GtkApplicationWindow">
<style>
<class name="devel"/>
</style>
<property name="title" translatable="yes">GTK Constraint Editor</property>
<property name="default-width">1024</property>
<property name="default-height">768</property>

View File

@@ -142,6 +142,9 @@ get_target (GListModel *model,
{
int i;
if (id == NULL)
return NULL;
if (strcmp ("super", id) == 0)
return NULL;
@@ -212,6 +215,22 @@ get_relation_nick (GtkConstraintRelation relation)
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 (const char *id)
{
@@ -331,6 +350,7 @@ source_attr_changed (ConstraintEditor *editor)
{
gtk_widget_set_sensitive (editor->source, TRUE);
gtk_widget_set_sensitive (editor->multiplier, TRUE);
gtk_editable_set_text (GTK_EDITABLE (editor->multiplier), "1");
}
}
@@ -347,7 +367,7 @@ constraint_editor_constraint_to_string (GtkConstraint *constraint)
name = get_target_name (gtk_constraint_get_target (constraint));
attr = get_attr_nick (gtk_constraint_get_target_attribute (constraint));
relation = get_relation_nick (gtk_constraint_get_relation (constraint));
relation = get_relation_display_name (gtk_constraint_get_relation (constraint));
if (name == NULL)
name = "[ ]";
@@ -441,8 +461,12 @@ update_preview (ConstraintEditor *editor)
static void
update_button (ConstraintEditor *editor)
{
if (gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->target)) != NULL &&
gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->source)) != NULL)
const char *target = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->target));
const char *source = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->source));
const char *source_attr = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->source_attr));
if (target &&
(source || (source_attr && get_target_attr (source_attr) == GTK_CONSTRAINT_ATTRIBUTE_NONE)))
gtk_widget_set_sensitive (editor->button, TRUE);
else
gtk_widget_set_sensitive (editor->button, FALSE);

View File

@@ -78,6 +78,7 @@
<object class="GtkComboBoxText" id="source_attr">
<signal name="changed" handler="update_preview" swapped="yes"/>
<signal name="changed" handler="source_attr_changed" swapped="yes"/>
<signal name="changed" handler="update_button" swapped="yes"/>
<layout>
<property name="column">2</property>
<property name="row">3</property>

View File

@@ -0,0 +1,26 @@
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)*pow (10.0, 40*0.7);
fragColor = vec4 (r*0.5, g*0.5, b*0.5, 1.0) * alpha;
}

View File

@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkWindow" id="window">
<property name="resizable">0</property>
<property name="title">CSS Blend Modes</property>

View File

@@ -1,5 +1,5 @@
/* Builder
* #Keywords: GMenu, GtkPopoverMenuBar, GtkBuilder, GtkStatusBar, toolbar
* #Keywords: GMenu, GtkPopoverMenuBar, GtkBuilder, GtkStatusBar, GtkShortcutController, toolbar
*
* Demonstrates a traditional interface, loaded from a XML description,
* and shows how to connect actions to the menu items and toolbar buttons.
@@ -158,7 +158,6 @@ do_builder (GtkWidget *do_widget)
about = GTK_WIDGET (gtk_builder_get_object (builder, "aboutdialog1"));
gtk_window_set_transient_for (GTK_WINDOW (about), GTK_WINDOW (window));
gtk_window_set_hide_on_close (GTK_WINDOW (about), TRUE);
g_signal_connect (about, "response", G_CALLBACK (gtk_widget_hide), NULL);
g_object_set_data_full (G_OBJECT (window), "about",
about, (GDestroyNotify)gtk_window_destroy);

226
demos/gtk-demo/cogs2.glsl Normal file
View File

@@ -0,0 +1,226 @@
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 = round(nn);
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,9 +1,16 @@
/* Constraints/Simple
/* Constraints/Simple Constraints
* #Keywords: GtkLayoutManager
*
* GtkConstraintLayout provides a layout manager that uses relations
* between widgets (also known as "constraints") to compute the position
* between widgets (also known as constraints) to compute the position
* and size of each child.
*
* In addition to child widgets, the constraints can involve spacer
* objects (also known as “guides”). This example has a guide between
* the two buttons in the top row.
*
* Try resizing the window to see how the constraints react to update
* the layout.
*/
#include <glib/gi18n.h>
@@ -234,15 +241,12 @@ simple_grid_init (SimpleGrid *self)
self->button1 = gtk_button_new_with_label ("Child 1");
gtk_widget_set_parent (self->button1, widget);
gtk_widget_set_name (self->button1, "button1");
self->button2 = gtk_button_new_with_label ("Child 2");
gtk_widget_set_parent (self->button2, widget);
gtk_widget_set_name (self->button2, "button2");
self->button3 = gtk_button_new_with_label ("Child 3");
gtk_widget_set_parent (self->button3, widget);
gtk_widget_set_name (self->button3, "button3");
GtkLayoutManager *manager = gtk_widget_get_layout_manager (GTK_WIDGET (self));
build_constraints (self, GTK_CONSTRAINT_LAYOUT (manager));
@@ -259,7 +263,8 @@ do_constraints (GtkWidget *do_widget)
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Constraints");
gtk_window_set_title (GTK_WINDOW (window), "Simple Constraints");
gtk_window_set_default_size (GTK_WINDOW (window), 260, -1);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);

View File

@@ -0,0 +1,74 @@
/* Constraints/Builder
*
* GtkConstraintLayouts can be created in .ui files, and constraints can
* be set up at that time as well, as this example demonstrates. It shows
* various ways to do spacing and sizing with constraints.
*
* Make the window wider to see the rows react differently
*/
#include <glib/gi18n.h>
#include <gtk/gtk.h>
G_DECLARE_FINAL_TYPE (ConstraintsGrid, constraints_grid, CONSTRAINTS, GRID, GtkWidget)
struct _ConstraintsGrid
{
GtkWidget parent_instance;
};
G_DEFINE_TYPE (ConstraintsGrid, constraints_grid, GTK_TYPE_WIDGET)
static void
constraints_grid_init (ConstraintsGrid *grid)
{
}
static void
constraints_grid_dispose (GObject *object)
{
GtkWidget *widget = GTK_WIDGET (object);
GtkWidget *child;
while ((child = gtk_widget_get_first_child (widget)))
gtk_widget_unparent (child);
G_OBJECT_CLASS (constraints_grid_parent_class)->dispose (object);
}
static void
constraints_grid_class_init (ConstraintsGridClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->dispose = constraints_grid_dispose;
}
GtkWidget *
do_constraints_builder (GtkWidget *do_widget)
{
static GtkWidget *window;
if (!window)
{
GtkBuilder *builder;
g_type_ensure (constraints_grid_get_type ());
builder = gtk_builder_new_from_resource ("/constraints_builder/constraints_builder.ui");
window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
g_object_unref (builder);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
gtk_window_destroy (GTK_WINDOW (window));
return window;
}

View File

@@ -0,0 +1,460 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkWindow" id="window1">
<property name="title" translatable="yes">ConstraintsBuilder</property>
<property name="default-width">260</property>
<child>
<object class="ConstraintsGrid">
<property name="halign">fill</property>
<property name="valign">fill</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="layout-manager">
<object class="GtkConstraintLayout">
<constraints>
<guide name="guide1" min-width="10" nat-width="200" strength="weak"/>
<guide name="guide2" min-width="10" nat-width="200" strength="weak"/>
<guide name="guide3" min-width="10" nat-width="200" strength="weak"/>
<guide name="guide4" min-width="10" nat-width="200" strength="weak"/>
<guide name="guide5" min-width="10" nat-width="200" strength="weak"/>
<guide name="guide6" min-width="10" nat-width="200" strength="weak"/>
<guide name="guide7" min-width="10" nat-width="200" strength="weak"/>
<guide name="guide8" min-width="10" nat-width="200" strength="weak"/>
<guide name="guide9" min-width="0" nat-width="200" strength="weak"/>
<guide name="guide10" min-width="0" nat-width="200" strength="weak"/>
<guide name="barrier1" min-height="10"/>
<guide name="barrier2" min-height="10"/>
<guide name="barrier3" min-height="10"/>
<guide name="barrier4" min-height="10"/>
<!-- Spread Chain -->
<constraint target="super" target-attribute="top"
relation="eq"
source="button1" source-attribute="top"
strength="required"/>
<constraint target="super" target-attribute="top"
relation="eq"
source="button2" source-attribute="top"
strength="required"/>
<constraint target="super" target-attribute="top"
relation="eq"
source="button3" source-attribute="top"
strength="required"/>
<constraint target="super" target-attribute="left"
relation="eq"
source="guide1" source-attribute="left"
strength="required"/>
<constraint target="button1" target-attribute="left"
relation="eq"
source="guide1" source-attribute="right"
strength="required"/>
<constraint target="guide2" target-attribute="left"
relation="eq"
source="button1" source-attribute="right"
strength="required"/>
<constraint target="button2" target-attribute="left"
relation="eq"
source="guide2" source-attribute="right"
strength="required"/>
<constraint target="guide3" target-attribute="left"
relation="eq"
source="button2" source-attribute="right"
strength="required"/>
<constraint target="button3" target-attribute="left"
relation="eq"
source="guide3" source-attribute="right"
strength="required"/>
<constraint target="guide4" target-attribute="left"
relation="eq"
source="button3" source-attribute="right"
strength="required"/>
<constraint target="super" target-attribute="right"
relation="eq"
source="guide4" source-attribute="right"
strength="required"/>
<constraint target="guide1" target-attribute="width"
relation="eq"
source="guide2" source-attribute="width"
strength="required"/>
<constraint target="guide2" target-attribute="width"
relation="eq"
source="guide3" source-attribute="width"
strength="required"/>
<constraint target="guide3" target-attribute="width"
relation="eq"
source="guide4" source-attribute="width"
strength="required"/>
<constraint target="button1" target-attribute="width"
relation="eq"
source="button2" source-attribute="width"
strength="required"/>
<constraint target="button2" target-attribute="width"
relation="eq"
source="button3" source-attribute="width"
strength="required"/>
<constraint target="button1" target-attribute="bottom"
relation="eq"
source="barrier1" source-attribute="top"
strength="required"/>
<constraint target="button2" target-attribute="bottom"
relation="eq"
source="barrier1" source-attribute="top"
strength="required"/>
<constraint target="button3" target-attribute="bottom"
relation="eq"
source="barrier1" source-attribute="top"
strength="required"/>
<!-- Spread Inside Chain -->
<constraint target="super" target-attribute="left"
relation="eq"
source="button4" source-attribute="left"
strength="required"/>
<constraint target="guide5" target-attribute="left"
relation="eq"
source="button4" source-attribute="right"
strength="required"/>
<constraint target="button5" target-attribute="left"
relation="eq"
source="guide5" source-attribute="right"
strength="required"/>
<constraint target="guide6" target-attribute="left"
relation="eq"
source="button5" source-attribute="right"
strength="required"/>
<constraint target="button6" target-attribute="left"
relation="eq"
source="guide6" source-attribute="right"
strength="required"/>
<constraint target="super" target-attribute="right"
relation="eq"
source="button6" source-attribute="right"
strength="required"/>
<constraint target="guide5" target-attribute="width"
relation="eq"
source="guide6" source-attribute="width"
strength="required"/>
<constraint target="button4" target-attribute="width"
relation="eq"
source="button5" source-attribute="width"
strength="required"/>
<constraint target="button5" target-attribute="width"
relation="eq"
source="button6" source-attribute="width"
strength="required"/>
<constraint target="button4" target-attribute="top"
relation="eq"
source="barrier1" source-attribute="bottom"
strength="required"/>
<constraint target="button5" target-attribute="top"
relation="eq"
source="barrier1" source-attribute="bottom"
strength="required"/>
<constraint target="button6" target-attribute="top"
relation="eq"
source="barrier1" source-attribute="bottom"
strength="required"/>
<constraint target="button4" target-attribute="bottom"
relation="eq"
source="barrier2" source-attribute="top"
strength="required"/>
<constraint target="button5" target-attribute="bottom"
relation="eq"
source="barrier2" source-attribute="top"
strength="required"/>
<constraint target="button6" target-attribute="bottom"
relation="eq"
source="barrier2" source-attribute="top"
strength="required"/>
<!-- Weighted Chain -->
<constraint target="super" target-attribute="left"
relation="eq"
source="button7" source-attribute="left"
strength="required"/>
<constraint target="button8" target-attribute="left"
relation="eq"
source="button7" source-attribute="right"
constant="10"
strength="required"/>
<constraint target="button9" target-attribute="left"
relation="eq"
source="button8" source-attribute="right"
constant="10"
strength="required"/>
<constraint target="super" target-attribute="right"
relation="eq"
source="button9" source-attribute="right"
strength="required"/>
<constraint target="button8" target-attribute="width"
relation="eq"
source="button7" source-attribute="width"
multiplier="2"
strength="required"/>
<constraint target="button9" target-attribute="width"
relation="eq"
source="button7" source-attribute="width"
multiplier="3"
strength="required"/>
<constraint target="button7" target-attribute="top"
relation="eq"
source="barrier2" source-attribute="bottom"
strength="required"/>
<constraint target="button8" target-attribute="top"
relation="eq"
source="barrier2" source-attribute="bottom"
strength="required"/>
<constraint target="button9" target-attribute="top"
relation="eq"
source="barrier2" source-attribute="bottom"
strength="required"/>
<constraint target="button7" target-attribute="bottom"
relation="eq"
source="barrier3" source-attribute="top"
strength="required"/>
<constraint target="button8" target-attribute="bottom"
relation="eq"
source="barrier3" source-attribute="top"
strength="required"/>
<constraint target="button9" target-attribute="bottom"
relation="eq"
source="barrier3" source-attribute="top"
strength="required"/>
<!-- Packed Chain -->
<constraint target="super" target-attribute="left"
relation="eq"
source="guide7" source-attribute="left"
strength="required"/>
<constraint target="button10" target-attribute="left"
relation="eq"
source="guide7" source-attribute="right"
strength="required"/>
<constraint target="button11" target-attribute="left"
relation="eq"
source="button10" source-attribute="right"
constant="10"
strength="required"/>
<constraint target="button12" target-attribute="left"
relation="eq"
source="button11" source-attribute="right"
constant="10"
strength="required"/>
<constraint target="guide8" target-attribute="left"
relation="eq"
source="button12" source-attribute="right"
strength="required"/>
<constraint target="super" target-attribute="right"
relation="eq"
source="guide8" source-attribute="right"
strength="required"/>
<constraint target="guide7" target-attribute="width"
relation="eq"
source="guide8" source-attribute="width"
strength="required"/>
<constraint target="button10" target-attribute="width"
relation="eq"
source="button11" source-attribute="width"
strength="required"/>
<constraint target="button11" target-attribute="width"
relation="eq"
source="button12" source-attribute="width"
strength="required"/>
<constraint target="button10" target-attribute="top"
relation="eq"
source="barrier3" source-attribute="bottom"
strength="required"/>
<constraint target="button11" target-attribute="top"
relation="eq"
source="barrier3" source-attribute="bottom"
strength="required"/>
<constraint target="button12" target-attribute="top"
relation="eq"
source="barrier3" source-attribute="bottom"
strength="required"/>
<constraint target="button10" target-attribute="bottom"
relation="eq"
source="barrier4" source-attribute="top"
strength="required"/>
<constraint target="button11" target-attribute="bottom"
relation="eq"
source="barrier4" source-attribute="top"
strength="required"/>
<constraint target="button12" target-attribute="bottom"
relation="eq"
source="barrier4" source-attribute="top"
strength="required"/>
<!-- Packed Chain with Bias -->
<constraint target="super" target-attribute="left"
relation="eq"
source="guide9" source-attribute="left"
strength="required"/>
<constraint target="button13" target-attribute="left"
relation="eq"
source="guide9" source-attribute="right"
constant="10"
strength="required"/>
<constraint target="button14" target-attribute="left"
relation="eq"
source="button13" source-attribute="right"
constant="10"
strength="required"/>
<constraint target="button15" target-attribute="left"
relation="eq"
source="button14" source-attribute="right"
constant="10"
strength="required"/>
<constraint target="guide10" target-attribute="left"
relation="eq"
source="button15" source-attribute="right"
constant="10"
strength="required"/>
<constraint target="super" target-attribute="right"
relation="eq"
source="guide10" source-attribute="right"
strength="required"/>
<constraint target="guide9" target-attribute="width"
relation="eq"
source="guide10" source-attribute="width"
multiplier="4"
strength="required"/>
<constraint target="button13" target-attribute="width"
relation="eq"
source="button14" source-attribute="width"
strength="required"/>
<constraint target="button14" target-attribute="width"
relation="eq"
source="button15" source-attribute="width"
strength="required"/>
<constraint target="button13" target-attribute="top"
relation="eq"
source="barrier4" source-attribute="bottom"
strength="required"/>
<constraint target="button14" target-attribute="top"
relation="eq"
source="barrier4" source-attribute="bottom"
strength="required"/>
<constraint target="button15" target-attribute="top"
relation="eq"
source="barrier4" source-attribute="bottom"
strength="required"/>
<constraint target="super" target-attribute="bottom"
relation="ge"
source="button13" source-attribute="bottom"
strength="required"/>
<constraint target="super" target-attribute="bottom"
relation="ge"
source="button14" source-attribute="bottom"
strength="required"/>
<constraint target="super" target-attribute="bottom"
relation="ge"
source="button15" source-attribute="bottom"
strength="required"/>
</constraints>
</object>
</property>
<child>
<object class="GtkButton" id="button1">
<property name="label">A</property>
</object>
</child>
<child>
<object class="GtkButton" id="button2">
<property name="label">B</property>
</object>
</child>
<child>
<object class="GtkButton" id="button3">
<property name="label">C</property>
</object>
</child>
<child>
<object class="GtkButton" id="button4">
<property name="label">A</property>
</object>
</child>
<child>
<object class="GtkButton" id="button5">
<property name="label">B</property>
</object>
</child>
<child>
<object class="GtkButton" id="button6">
<property name="label">C</property>
</object>
</child>
<child>
<object class="GtkButton" id="button7">
<property name="label">A</property>
</object>
</child>
<child>
<object class="GtkButton" id="button8">
<property name="label">B</property>
</object>
</child>
<child>
<object class="GtkButton" id="button9">
<property name="label">C</property>
</object>
</child>
<child>
<object class="GtkButton" id="button10">
<property name="label">A</property>
</object>
</child>
<child>
<object class="GtkButton" id="button11">
<property name="label">B</property>
</object>
</child>
<child>
<object class="GtkButton" id="button12">
<property name="label">C</property>
</object>
</child>
<child>
<object class="GtkButton" id="button13">
<property name="label">A</property>
</object>
</child>
<child>
<object class="GtkButton" id="button14">
<property name="label">B</property>
</object>
</child>
<child>
<object class="GtkButton" id="button15">
<property name="label">C</property>
</object>
</child>
</object>
</child>
</object>
</interface>

View File

@@ -1,7 +1,7 @@
/* Constraints/Interactive
/* Constraints/Interactive Constraints
* #Keywords: GtkConstraintLayout
*
* Demonstrate how constraints can be updates during user interaction.
* This example shows how constraints can be updated during user interaction.
* The vertical edge between the buttons can be dragged with the mouse.
*/
@@ -205,7 +205,7 @@ interactive_grid_init (InteractiveGrid *self)
}
GtkWidget *
do_constraints2 (GtkWidget *do_widget)
do_constraints_interactive (GtkWidget *do_widget)
{
static GtkWidget *window;
@@ -215,7 +215,8 @@ do_constraints2 (GtkWidget *do_widget)
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Constraints");
gtk_window_set_title (GTK_WINDOW (window), "Interactive Constraints");
gtk_window_set_default_size (GTK_WINDOW (window), 260, -1);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);

View File

@@ -2,6 +2,10 @@
*
* GtkConstraintLayout allows defining constraints using a
* compact syntax called Visual Format Language, or VFL.
*
* A typical example of a VFL specification looks like this:
*
* H:|-[button1(==button2)]-12-[button2]-|
*/
#include <glib/gi18n.h>
@@ -124,7 +128,7 @@ vfl_grid_init (VflGrid *self)
}
GtkWidget *
do_constraints3 (GtkWidget *do_widget)
do_constraints_vfl (GtkWidget *do_widget)
{
static GtkWidget *window;
@@ -134,7 +138,8 @@ do_constraints3 (GtkWidget *do_widget)
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Constraints");
gtk_window_set_title (GTK_WINDOW (window), "ConstraintsVFL");
gtk_window_set_default_size (GTK_WINDOW (window), 260, -1);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);

View File

@@ -0,0 +1,27 @@
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

@@ -18,6 +18,9 @@
<file>demoimage.c</file>
<file>demoimage.h</file>
</gresource>
<gresource prefix="/constraints_builder">
<file>constraints_builder.ui</file>
</gresource>
<gresource prefix="/css_accordion">
<file>css_accordion.css</file>
<file>reset.css</file>
@@ -40,6 +43,11 @@
<file>cssview.css</file>
<file>reset.css</file>
</gresource>
<gresource prefix="/dropdown">
<file>suggestionentry.h</file>
<file>suggestionentry.c</file>
<file>suggestionentry.css</file>
</gresource>
<gresource prefix="/theming_style_classes">
<file>theming.ui</file>
</gresource>
@@ -133,6 +141,21 @@
<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>
@@ -169,6 +192,9 @@
<gresource prefix="/listview_settings">
<file>listview_settings.ui</file>
</gresource>
<gresource prefix="/listview_ucd_data/">
<file>ucdnames.data</file>
</gresource>
<gresource prefix="/listview_weather">
<file compressed="true">listview_weather.txt</file>
</gresource>
@@ -186,6 +212,11 @@
<file>demo3widget.h</file>
<file>demo3widget.ui</file>
</gresource>
<gresource prefix="/paintable_svg">
<file>svgpaintable.h</file>
<file>svgpaintable.c</file>
<file>org.gtk.gtk4.NodeEditor.Devel.svg</file>
</gresource>
<gresource prefix="/shortcuts">
<file>shortcuts.ui</file>
<file>shortcuts-builder.ui</file>
@@ -205,9 +236,12 @@
<file>revealer.ui</file>
</gresource>
<gresource prefix="/images">
<file>pixbufpaintable.h</file>
<file>pixbufpaintable.c</file>
<file>alphatest.png</file>
<file>floppybuddy.gif</file>
<file>gtk-logo.webm</file>
<file alias="org.gtk.Demo4.svg">data/scalable/apps/org.gtk.Demo4.svg</file>
</gresource>
<gresource prefix="/video-player">
<file>bbb.png</file>
@@ -219,8 +253,9 @@
<file>clipboard.c</file>
<file>combobox.c</file>
<file>constraints.c</file>
<file>constraints2.c</file>
<file>constraints3.c</file>
<file>constraints_interactive.c</file>
<file>constraints_vfl.c</file>
<file>constraints_builder.c</file>
<file>css_accordion.c</file>
<file>css_basics.c</file>
<file>css_blendmodes.c</file>
@@ -247,6 +282,7 @@
<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>
@@ -258,13 +294,14 @@
<file>layoutmanager2.c</file>
<file>links.c</file>
<file>listbox.c</file>
<file>listbox2.c</file>
<file>listbox_controls.c</file>
<file>listview_applauncher.c</file>
<file>listview_colors.c</file>
<file>listview_clocks.c</file>
<file>listview_filebrowser.c</file>
<file>listview_minesweeper.c</file>
<file>listview_settings.c</file>
<file>listview_ucd.c</file>
<file>listview_weather.c</file>
<file>listview_words.c</file>
<file>list_store.c</file>
@@ -272,15 +309,19 @@
<file>markup.c</file>
<file>menu.c</file>
<file>overlay.c</file>
<file>overlay2.c</file>
<file>overlay_decorative.c</file>
<file>paint.c</file>
<file>pagesetup.c</file>
<file>paintable.c</file>
<file>paintable_animated.c</file>
<file>paintable_emblem.c</file>
<file>paintable_mediastream.c</file>
<file>paintable_svg.c</file>
<file>panes.c</file>
<file>password_entry.c</file>
<file>path_fill.c</file>
<file>path_maze.c</file>
<file>path_text.c</file>
<file>peg_solitaire.c</file>
<file>pickers.c</file>
<file>printing.c</file>
@@ -321,8 +362,8 @@
<file>messages.txt</file>
<file>apple-red.png</file>
</gresource>
<gresource prefix="/listbox2">
<file>listbox2.ui</file>
<gresource prefix="/listbox_controls">
<file>listbox_controls.ui</file>
</gresource>
<gresource prefix="/glarea">
<file>glarea-gl.fs.glsl</file>
@@ -365,6 +406,9 @@
<gresource prefix="/fontrendering">
<file>fontrendering.ui</file>
</gresource>
<gresource prefix="/path_text">
<file>path_text.ui</file>
</gresource>
<gresource prefix="/org/gtk/Demo4">
<file>icons/16x16/actions/application-exit.png</file>
<file>icons/16x16/actions/document-new.png</file>

View File

@@ -83,7 +83,7 @@
</menu>
<object class="GtkAboutDialog" id="aboutdialog1">
<property name="program-name" translatable="yes">Builder demo</property>
<property name="logo-icon-name" translatable="yes">gtk3-demo</property>
<property name="logo-icon-name" translatable="yes">org.gtk.Demo4</property>
<property name="modal">True</property>
</object>
<object class="GtkWindow" id="window1">
@@ -96,13 +96,18 @@
<child>
<object class="GtkPopoverMenuBar" id="menubar1">
<property name="menu-model">menubar</property>
<accessibility>
<property name="label">Main Menu</property>
</accessibility>
</object>
</child>
<child>
<object class="GtkBox" id="toolbar1">
<style>
<class name="toolbar"/>
</style>
<property name="accessible-role">toolbar</property>
<property name="css-classes">toolbar</property>
<accessibility>
<property name="label">Toolbar</property>
</accessibility>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">New</property>

View File

@@ -47,6 +47,38 @@ get_image_paintable (GtkImage *image)
}
}
static void
update_drag_icon (DemoImage *demo,
GtkDragIcon *icon)
{
const char *icon_name;
GdkPaintable *paintable;
GtkWidget *image;
switch (gtk_image_get_storage_type (GTK_IMAGE (demo->image)))
{
case GTK_IMAGE_PAINTABLE:
paintable = gtk_image_get_paintable (GTK_IMAGE (demo->image));
image = gtk_image_new_from_paintable (paintable);
break;
case GTK_IMAGE_ICON_NAME:
icon_name = gtk_image_get_icon_name (GTK_IMAGE (demo->image));
image = gtk_image_new_from_icon_name (icon_name);
break;
case GTK_IMAGE_EMPTY:
case GTK_IMAGE_GICON:
default:
g_warning ("Image storage type %d not handled",
gtk_image_get_storage_type (GTK_IMAGE (demo->image)));
return;
}
gtk_image_set_pixel_size (GTK_IMAGE (image),
gtk_image_get_pixel_size (GTK_IMAGE (demo->image)));
gtk_drag_icon_set_child (icon, image);
}
static void
drag_begin (GtkDragSource *source,
GdkDrag *drag,
@@ -54,14 +86,8 @@ drag_begin (GtkDragSource *source,
{
GtkWidget *widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (source));
DemoImage *demo = DEMO_IMAGE (widget);
GdkPaintable *paintable;
paintable = get_image_paintable (GTK_IMAGE (demo->image));
if (paintable)
{
gtk_drag_icon_set_from_paintable (drag, paintable, -2, -2);
g_object_unref (paintable);
}
update_drag_icon (demo, GTK_DRAG_ICON (gtk_drag_icon_get_for_drag (drag)));
}
static GdkContentProvider *

View File

@@ -44,11 +44,23 @@ G_DEFINE_TYPE_WITH_CODE (DemoTaggedEntry, demo_tagged_entry, GTK_TYPE_WIDGET,
static void
demo_tagged_entry_init (DemoTaggedEntry *entry)
{
GtkCssProvider *provider;
entry->text = gtk_text_new ();
gtk_widget_set_hexpand (entry->text, TRUE);
gtk_widget_set_vexpand (entry->text, TRUE);
gtk_widget_set_parent (entry->text, GTK_WIDGET (entry));
gtk_editable_init_delegate (GTK_EDITABLE (entry));
gtk_editable_set_width_chars (GTK_EDITABLE (entry->text), 6);
gtk_editable_set_max_width_chars (GTK_EDITABLE (entry->text), 6);
gtk_widget_add_css_class (GTK_WIDGET (entry), "tagged");
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_resource (provider, "/tagged_entry/tagstyle.css");
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (provider),
800);
g_object_unref (provider);
}
static void
@@ -116,6 +128,7 @@ demo_tagged_entry_class_init (DemoTaggedEntryClass *klass)
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BOX_LAYOUT);
gtk_widget_class_set_css_name (widget_class, "entry");
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_TEXT_BOX);
}
static GtkEditable *
@@ -211,7 +224,6 @@ static void
demo_tagged_entry_tag_init (DemoTaggedEntryTag *tag)
{
GtkGesture *gesture;
GtkCssProvider *provider;
tag->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_set_parent (tag->box, GTK_WIDGET (tag));
@@ -221,13 +233,6 @@ demo_tagged_entry_tag_init (DemoTaggedEntryTag *tag)
gesture = gtk_gesture_click_new ();
g_signal_connect (gesture, "released", G_CALLBACK (on_released), tag);
gtk_widget_add_controller (GTK_WIDGET (tag), GTK_EVENT_CONTROLLER (gesture));
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_resource (provider, "/tagged_entry/tagstyle.css");
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (provider),
800);
g_object_unref (provider);
}
static void

View File

@@ -113,12 +113,9 @@ apply_transform (CanvasItem *item)
y = gtk_widget_get_allocated_height (item->label) / 2.0;
item->r = sqrt (x*x + y*y);
transform = gsk_transform_translate (
gsk_transform_rotate (
gsk_transform_translate (NULL,
&(graphene_point_t) { item->r, item->r }),
item->angle + item->delta),
&(graphene_point_t) { - x, - y });
transform = gsk_transform_translate (NULL, &(graphene_point_t) { item->r, item->r });
transform = gsk_transform_rotate (transform, item->angle + item->delta);
transform = gsk_transform_translate (transform, &(graphene_point_t) { -x, -y });
gtk_fixed_set_child_transform (GTK_FIXED (item->fixed), item->label, transform);
gsk_transform_unref (transform);

View File

@@ -311,6 +311,7 @@ do_drawingarea (GtkWidget *do_widget)
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Drawing Area");
gtk_window_set_default_size (GTK_WINDOW (window), 250, -1);
g_signal_connect (window, "destroy",
G_CALLBACK (close_window), NULL);
@@ -325,9 +326,8 @@ do_drawingarea (GtkWidget *do_widget)
/*
* Create the groups area
*/
label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label),
"<u>Knockout groups</u>");
label = gtk_label_new ("Knockout groups");
gtk_widget_add_css_class (label, "heading");
gtk_box_append (GTK_BOX (vbox), label);
frame = gtk_frame_new (NULL);
@@ -344,9 +344,8 @@ do_drawingarea (GtkWidget *do_widget)
* Create the scribble area
*/
label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label),
"<u>Scribble area</u>");
label = gtk_label_new ("Scribble area");
gtk_widget_add_css_class (label, "heading");
gtk_box_append (GTK_BOX (vbox), label);
frame = gtk_frame_new (NULL);

View File

@@ -1,17 +1,16 @@
/* Drop Downs
/* Lists/Selections
*
* The GtkDropDown widget is a modern alternative to GtkComboBox.
* It uses list models instead of tree models, and the content is
* displayed using widgets instead of cell renderers.
*
* The examples here demonstrate how to use different kinds of
* list models with GtkDropDown, how to use search and how to
* display the selected item differently from the presentation
* in the popup.
* This example also shows a custom widget that can replace
* GtkEntryCompletion or GtkComboBoxText. It is not currently
* part of GTK.
*/
#include <gtk/gtk.h>
#include "suggestionentry.h"
#define STRING_TYPE_HOLDER (string_holder_get_type ())
G_DECLARE_FINAL_TYPE (StringHolder, string_holder, STRING, HOLDER, GObject)
@@ -65,18 +64,22 @@ strings_setup_item_single_line (GtkSignalListItemFactory *factory,
GtkListItem *item)
{
GtkWidget *box, *image, *title;
GtkWidget *checkmark;
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
image = gtk_image_new ();
title = gtk_label_new ("");
gtk_label_set_xalign (GTK_LABEL (title), 0.0);
checkmark = gtk_image_new_from_icon_name ("object-select-symbolic");
gtk_box_append (GTK_BOX (box), image);
gtk_box_append (GTK_BOX (box), title);
gtk_box_append (GTK_BOX (box), checkmark);
g_object_set_data (G_OBJECT (item), "title", title);
g_object_set_data (G_OBJECT (item), "image", image);
g_object_set_data (G_OBJECT (item), "checkmark", checkmark);
gtk_list_item_set_child (item, box);
}
@@ -86,6 +89,7 @@ strings_setup_item_full (GtkSignalListItemFactory *factory,
GtkListItem *item)
{
GtkWidget *box, *box2, *image, *title, *description;
GtkWidget *checkmark;
image = gtk_image_new ();
title = gtk_label_new ("");
@@ -93,6 +97,7 @@ strings_setup_item_full (GtkSignalListItemFactory *factory,
description = gtk_label_new ("");
gtk_label_set_xalign (GTK_LABEL (description), 0.0);
gtk_widget_add_css_class (description, "dim-label");
checkmark = gtk_image_new_from_icon_name ("object-select-symbolic");
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
@@ -101,26 +106,48 @@ strings_setup_item_full (GtkSignalListItemFactory *factory,
gtk_box_append (GTK_BOX (box), box2);
gtk_box_append (GTK_BOX (box2), title);
gtk_box_append (GTK_BOX (box2), description);
gtk_box_append (GTK_BOX (box), checkmark);
g_object_set_data (G_OBJECT (item), "title", title);
g_object_set_data (G_OBJECT (item), "image", image);
g_object_set_data (G_OBJECT (item), "description", description);
g_object_set_data (G_OBJECT (item), "checkmark", checkmark);
gtk_list_item_set_child (item, box);
}
static void
strings_bind_item (GtkSignalListItemFactory *factory,
GtkListItem *item)
selected_item_changed (GtkDropDown *dropdown,
GParamSpec *pspec,
GtkListItem *item)
{
GtkWidget *checkmark;
checkmark = g_object_get_data (G_OBJECT (item), "checkmark");
if (gtk_drop_down_get_selected_item (dropdown) == gtk_list_item_get_item (item))
gtk_widget_set_opacity (checkmark, 1.0);
else
gtk_widget_set_opacity (checkmark, 0.0);
}
static void
strings_bind_item (GtkSignalListItemFactory *factory,
GtkListItem *item,
gpointer data)
{
GtkDropDown *dropdown = data;
GtkWidget *image, *title, *description;
GtkWidget *checkmark;
StringHolder *holder;
GtkWidget *popup;
holder = gtk_list_item_get_item (item);
title = g_object_get_data (G_OBJECT (item), "title");
image = g_object_get_data (G_OBJECT (item), "image");
description = g_object_get_data (G_OBJECT (item), "description");
checkmark = g_object_get_data (G_OBJECT (item), "checkmark");
gtk_label_set_label (GTK_LABEL (title), holder->title);
if (image)
@@ -133,19 +160,43 @@ strings_bind_item (GtkSignalListItemFactory *factory,
gtk_label_set_label (GTK_LABEL (description), holder->description);
gtk_widget_set_visible (description , holder->description != NULL);
}
popup = gtk_widget_get_ancestor (title, GTK_TYPE_POPOVER);
if (popup && gtk_widget_is_ancestor (popup, GTK_WIDGET (dropdown)))
{
gtk_widget_show (checkmark);
g_signal_connect (dropdown, "notify::selected-item",
G_CALLBACK (selected_item_changed), item);
selected_item_changed (dropdown, NULL, item);
}
else
{
gtk_widget_hide (checkmark);
}
}
static void
strings_unbind_item (GtkSignalListItemFactory *factory,
GtkListItem *list_item,
gpointer data)
{
GtkDropDown *dropdown = data;
g_signal_handlers_disconnect_by_func (dropdown, selected_item_changed, list_item);
}
static GtkListItemFactory *
strings_factory_new (gboolean full)
strings_factory_new (gpointer data, gboolean full)
{
GtkListItemFactory *factory;
factory = gtk_signal_list_item_factory_new ();
if (full)
g_signal_connect (factory, "setup", G_CALLBACK (strings_setup_item_full), NULL);
g_signal_connect (factory, "setup", G_CALLBACK (strings_setup_item_full), data);
else
g_signal_connect (factory, "setup", G_CALLBACK (strings_setup_item_single_line), NULL);
g_signal_connect (factory, "bind", G_CALLBACK (strings_bind_item), NULL);
g_signal_connect (factory, "setup", G_CALLBACK (strings_setup_item_single_line), data);
g_signal_connect (factory, "bind", G_CALLBACK (strings_bind_item), data);
g_signal_connect (factory, "unbind", G_CALLBACK (strings_unbind_item), data);
return factory;
}
@@ -186,19 +237,22 @@ drop_down_new_from_strings (const char *const *titles,
g_return_val_if_fail (descriptions == NULL || g_strv_length ((char **)icons) == g_strv_length ((char **)descriptions), NULL);
model = strings_model_new (titles, icons, descriptions);
factory = strings_factory_new (FALSE);
widget = g_object_new (GTK_TYPE_DROP_DOWN,
"model", model,
NULL);
g_object_unref (model);
factory = strings_factory_new (widget, FALSE);
if (icons != NULL || descriptions != NULL)
list_factory = strings_factory_new (TRUE);
list_factory = strings_factory_new (widget, TRUE);
else
list_factory = NULL;
widget = g_object_new (GTK_TYPE_DROP_DOWN,
"model", model,
"factory", factory,
"list-factory", list_factory,
NULL);
g_object_set (widget,
"factory", factory,
"list-factory", list_factory,
NULL);
g_object_unref (model);
g_object_unref (factory);
if (list_factory)
g_object_unref (list_factory);
@@ -218,13 +272,110 @@ get_title (gpointer item)
return g_strdup (STRING_HOLDER (item)->title);
}
static char *
get_file_name (gpointer item)
{
return g_strdup (g_file_info_get_display_name (G_FILE_INFO (item)));
}
static void
setup_item (GtkSignalListItemFactory *factory,
GtkListItem *item)
{
GtkWidget *box;
GtkWidget *icon;
GtkWidget *label;
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
icon = gtk_image_new ();
label = gtk_label_new ("");
gtk_label_set_xalign (GTK_LABEL (label), 0);
gtk_box_append (GTK_BOX (box), icon);
gtk_box_append (GTK_BOX (box), label);
gtk_list_item_set_child (item, box);
}
static void
bind_item (GtkSignalListItemFactory *factory,
GtkListItem *item)
{
MatchObject *match = MATCH_OBJECT (gtk_list_item_get_item (item));
GFileInfo *info = G_FILE_INFO (match_object_get_item (match));
GtkWidget *box = gtk_list_item_get_child (item);
GtkWidget *icon = gtk_widget_get_first_child (box);
GtkWidget *label = gtk_widget_get_last_child (box);
gtk_image_set_from_gicon (GTK_IMAGE (icon), g_file_info_get_icon (info));
gtk_label_set_label (GTK_LABEL (label), g_file_info_get_display_name (info));
}
static void
setup_highlight_item (GtkSignalListItemFactory *factory,
GtkListItem *item)
{
GtkWidget *label;
label = gtk_label_new ("");
gtk_label_set_xalign (GTK_LABEL (label), 0);
gtk_list_item_set_child (item, label);
}
static void
bind_highlight_item (GtkSignalListItemFactory *factory,
GtkListItem *item)
{
MatchObject *obj;
GtkWidget *label;
PangoAttrList *attrs;
PangoAttribute *attr;
const char *str;
obj = MATCH_OBJECT (gtk_list_item_get_item (item));
label = gtk_list_item_get_child (item);
str = match_object_get_string (obj);
gtk_label_set_label (GTK_LABEL (label), str);
attrs = pango_attr_list_new ();
attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
attr->start_index = match_object_get_match_start (obj);
attr->end_index = match_object_get_match_end (obj);
pango_attr_list_insert (attrs, attr);
gtk_label_set_attributes (GTK_LABEL (label), attrs);
pango_attr_list_unref (attrs);
}
static void
match_func (MatchObject *obj,
const char *search,
gpointer user_data)
{
char *tmp1, *tmp2;
char *p;
tmp1 = g_utf8_normalize (match_object_get_string (obj), -1, G_NORMALIZE_ALL);
tmp2 = g_utf8_normalize (search, -1, G_NORMALIZE_ALL);
if ((p = strstr (tmp1, tmp2)) != NULL)
match_object_set_match (obj,
p - tmp1,
(p - tmp1) + g_utf8_strlen (search, -1),
1);
else
match_object_set_match (obj, 0, 0, 0);
g_free (tmp1);
g_free (tmp2);
}
GtkWidget *
do_dropdown (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;
GtkWidget *button, *box, *spin, *check;
GtkWidget *button, *box, *spin, *check, *hbox, *label, *entry;
GListModel *model;
GtkExpression *expression;
GtkListItemFactory *factory;
const char * const times[] = { "1 minute", "2 minutes", "5 minutes", "20 minutes", NULL };
const char * const many_times[] = {
"1 minute", "2 minutes", "5 minutes", "10 minutes", "15 minutes", "20 minutes",
@@ -237,22 +388,49 @@ do_dropdown (GtkWidget *do_widget)
const char * const device_descriptions[] = {
"Built-in Audio", "Built-in audio", "Thinkpad Tunderbolt 3 Dock USB Audio", "Thinkpad Tunderbolt 3 Dock USB Audio", NULL
};
char *cwd;
GFile *file;
GListModel *dir;
GtkStringList *strings;
if (!window)
{
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Drop Downs");
gtk_window_set_title (GTK_WINDOW (window), "Selections");
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 20);
gtk_widget_set_margin_start (hbox, 20);
gtk_widget_set_margin_end (hbox, 20);
gtk_widget_set_margin_top (hbox, 20);
gtk_widget_set_margin_bottom (hbox, 20);
gtk_window_set_child (GTK_WINDOW (window), hbox);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
gtk_widget_set_margin_start (box, 10);
gtk_widget_set_margin_end (box, 10);
gtk_widget_set_margin_top (box, 10);
gtk_widget_set_margin_bottom (box, 10);
gtk_window_set_child (GTK_WINDOW (window), box);
gtk_box_append (GTK_BOX (hbox), box);
label = gtk_label_new ("Dropdowns");
gtk_widget_add_css_class (label, "title-4");
gtk_box_append (GTK_BOX (box), label);
/* A basic dropdown */
button = drop_down_new_from_strings (times, NULL, NULL);
gtk_box_append (GTK_BOX (box), button);
/* A dropdown using an expression to obtain strings */
button = drop_down_new_from_strings (many_times, NULL, NULL);
gtk_drop_down_set_enable_search (GTK_DROP_DOWN (button), TRUE);
expression = gtk_cclosure_expression_new (G_TYPE_STRING, NULL,
0, NULL,
(GCallback)get_title,
NULL, NULL);
gtk_drop_down_set_expression (GTK_DROP_DOWN (button), expression);
gtk_expression_unref (expression);
gtk_box_append (GTK_BOX (box), button);
button = gtk_drop_down_new (NULL, NULL);
@@ -270,30 +448,118 @@ do_dropdown (GtkWidget *do_widget)
spin = gtk_spin_button_new_with_range (-1, g_list_model_get_n_items (G_LIST_MODEL (model)), 1);
gtk_widget_set_halign (spin, GTK_ALIGN_START);
gtk_widget_set_margin_start (spin, 20);
g_object_bind_property (button, "selected", spin, "value", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
gtk_box_append (GTK_BOX (box), spin);
check = gtk_check_button_new_with_label ("Enable search");
gtk_widget_set_margin_start (check, 20);
g_object_bind_property (button, "enable-search", check, "active", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
gtk_box_append (GTK_BOX (box), check);
g_object_unref (model);
button = drop_down_new_from_strings (times, NULL, NULL);
gtk_box_append (GTK_BOX (box), button);
button = drop_down_new_from_strings (many_times, NULL, NULL);
gtk_drop_down_set_enable_search (GTK_DROP_DOWN (button), TRUE);
expression = gtk_cclosure_expression_new (G_TYPE_STRING, NULL,
0, NULL,
(GCallback)get_title,
NULL, NULL);
gtk_drop_down_set_expression (GTK_DROP_DOWN (button), expression);
gtk_expression_unref (expression);
gtk_box_append (GTK_BOX (box), button);
/* A dropdown with a separate list factory */
button = drop_down_new_from_strings (device_titles, device_icons, device_descriptions);
gtk_box_append (GTK_BOX (box), button);
gtk_box_append (GTK_BOX (hbox), gtk_separator_new (GTK_ORIENTATION_VERTICAL));
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
gtk_box_append (GTK_BOX (hbox), box);
label = gtk_label_new ("Suggestions");
gtk_widget_add_css_class (label, "title-4");
gtk_box_append (GTK_BOX (box), label);
/* A basic suggestion entry */
entry = suggestion_entry_new ();
g_object_set (entry, "placeholder-text", "Words with T or G…", NULL);
strings = gtk_string_list_new ((const char *[]){
"GNOME",
"gnominious",
"Gnomonic projection",
"total",
"totally",
"toto",
"tottery",
"totterer",
"Totten trust",
"totipotent",
"totipotency",
"totemism",
"totem pole",
"Totara",
"totalizer",
"totalizator",
"totalitarianism",
"total parenteral nutrition",
"total hysterectomy",
"total eclipse",
"Totipresence",
"Totipalmi",
"Tomboy",
"zombie",
NULL});
suggestion_entry_set_model (SUGGESTION_ENTRY (entry), G_LIST_MODEL (strings));
g_object_unref (strings);
gtk_box_append (GTK_BOX (box), entry);
/* A suggestion entry using a custom model, and no filtering */
entry = suggestion_entry_new ();
cwd = g_get_current_dir ();
file = g_file_new_for_path (cwd);
dir = G_LIST_MODEL (gtk_directory_list_new ("standard::display-name,standard::content-type,standard::icon,standard::size", file));
suggestion_entry_set_model (SUGGESTION_ENTRY (entry), dir);
g_object_unref (dir);
g_object_unref (file);
g_free (cwd);
expression = gtk_cclosure_expression_new (G_TYPE_STRING, NULL,
0, NULL,
(GCallback)get_file_name,
NULL, NULL);
suggestion_entry_set_expression (SUGGESTION_ENTRY (entry), expression);
gtk_expression_unref (expression);
factory = gtk_signal_list_item_factory_new ();
g_signal_connect (factory, "setup", G_CALLBACK (setup_item), NULL);
g_signal_connect (factory, "bind", G_CALLBACK (bind_item), NULL);
suggestion_entry_set_factory (SUGGESTION_ENTRY (entry), factory);
g_object_unref (factory);
suggestion_entry_set_use_filter (SUGGESTION_ENTRY (entry), FALSE);
suggestion_entry_set_show_arrow (SUGGESTION_ENTRY (entry), TRUE);
gtk_box_append (GTK_BOX (box), entry);
/* A suggestion entry with match highlighting */
entry = suggestion_entry_new ();
g_object_set (entry, "placeholder-text", "Destination", NULL);
strings = gtk_string_list_new ((const char *[]){
"app-mockups",
"settings-mockups",
"os-mockups",
"software-mockups",
"mocktails",
NULL});
suggestion_entry_set_model (SUGGESTION_ENTRY (entry), G_LIST_MODEL (strings));
g_object_unref (strings);
gtk_box_append (GTK_BOX (box), entry);
suggestion_entry_set_match_func (SUGGESTION_ENTRY (entry), match_func, NULL, NULL);
factory = gtk_signal_list_item_factory_new ();
g_signal_connect (factory, "setup", G_CALLBACK (setup_highlight_item), NULL);
g_signal_connect (factory, "bind", G_CALLBACK (bind_highlight_item), NULL);
suggestion_entry_set_factory (SUGGESTION_ENTRY (entry), factory);
g_object_unref (factory);
}
if (!gtk_widget_get_visible (window))

View File

@@ -78,11 +78,11 @@ do_entry_completion (GtkWidget *do_widget)
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
gtk_widget_set_margin_start (vbox, 5);
gtk_widget_set_margin_end (vbox, 5);
gtk_widget_set_margin_top (vbox, 5);
gtk_widget_set_margin_bottom (vbox, 5);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
gtk_widget_set_margin_start (vbox, 18);
gtk_widget_set_margin_end (vbox, 18);
gtk_widget_set_margin_top (vbox, 18);
gtk_widget_set_margin_bottom (vbox, 18);
gtk_window_set_child (GTK_WINDOW (window), vbox);
label = gtk_label_new (NULL);

View File

@@ -27,16 +27,16 @@ do_entry_undo (GtkWidget *do_widget)
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
gtk_widget_set_margin_start (vbox, 5);
gtk_widget_set_margin_end (vbox, 5);
gtk_widget_set_margin_top (vbox, 5);
gtk_widget_set_margin_bottom (vbox, 5);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
gtk_widget_set_margin_start (vbox, 18);
gtk_widget_set_margin_end (vbox, 18);
gtk_widget_set_margin_top (vbox, 18);
gtk_widget_set_margin_bottom (vbox, 18);
gtk_window_set_child (GTK_WINDOW (window), vbox);
label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label),
"Use Primary+z or Primary+Shift+z to undo or redo changes");
"Use Control+z or Control+Shift+z to undo or redo changes");
gtk_box_append (GTK_BOX (vbox), label);
/* Create our entry */

View File

@@ -1,4 +1,4 @@
/* Error states
/* Error States
*
* GtkLabel and GtkEntry can indicate errors if you set the .error
* style class on them.

View File

@@ -5,7 +5,7 @@
<property name="modal">1</property>
<property name="resizable">0</property>
<property name="use-header-bar">1</property>
<property name="title" translatable="yes">Settings</property>
<property name="title" translatable="yes">Error States</property>
<property name="hide-on-close">1</property>
<child internal-child="content_area">
<object class="GtkBox">

View File

@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.16"/>
<object class="GtkListStore" id="liststore1">
<columns>
<column type="gint"/>

View File

@@ -9,6 +9,7 @@
#include "gtkfishbowl.h"
#include "gtkgears.h"
#include "gskshaderpaintable.h"
const char *const css =
".blurred-button {"
@@ -149,6 +150,38 @@ 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)
{
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;
}
static void
mapped (GtkWidget *w)
{
@@ -185,6 +218,7 @@ static const struct {
{ "Gears", create_gears },
{ "Switch", create_switch },
{ "Menubutton", create_menu_button },
{ "Shader", create_cogs },
};
static int selected_widget_type = -1;

View File

@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.12"/>
<object class="GtkWindow" id="window">
<property name="default-width">600</property>
<property name="default-height">500</property>

View File

@@ -1068,7 +1068,6 @@ update_font_variations (void)
unsigned int length;
int i;
child = gtk_widget_get_first_child (variations_grid);
while ((child = gtk_widget_get_first_child (variations_grid)))
gtk_grid_remove (GTK_GRID (variations_grid), child);

View File

@@ -501,7 +501,7 @@ fontify (const char *format,
char *theme;
gboolean prefer_dark;
const char *style_arg;
const char *text;
char *text;
GtkTextIter start, end;
GBytes *bytes;
GError *error = NULL;
@@ -553,7 +553,7 @@ fontify (const char *format,
gtk_text_buffer_get_bounds (source_buffer, &start, &end);
text = gtk_text_buffer_get_text (source_buffer, &start, &end, TRUE);
bytes = g_bytes_new_static (text, strlen (text));
bytes = g_bytes_new_take (text, strlen (text));
#ifdef HAVE_GIO_UNIX
/* Work around https://gitlab.gnome.org/GNOME/glib/-/issues/2182 */
@@ -570,4 +570,5 @@ fontify (const char *format,
NULL,
fontify_finish,
g_object_ref (source_buffer));
g_bytes_unref (bytes);
}

View File

@@ -1,4 +1,4 @@
/* Pango/Font rendering
/* Pango/Font Rendering
*
* Demonstrates various aspects of font rendering.
*/

View File

@@ -406,6 +406,7 @@ create_glarea_window (GtkWidget *do_widget)
gl_area = gtk_gl_area_new ();
gtk_widget_set_hexpand (gl_area, TRUE);
gtk_widget_set_vexpand (gl_area, TRUE);
gtk_widget_set_size_request (gl_area, 100, 200);
gtk_box_append (GTK_BOX (box), gl_area);
/* We need to initialize and free GL resources, so we use

View File

@@ -0,0 +1,351 @@
/* 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"
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_show (button);
}
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_hide (button);
}
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;
GtkCssProvider *provider;
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);
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (provider, "button.small { padding: 0; }", -1);
gtk_style_context_add_provider (gtk_widget_get_style_context (button),
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_unref (provider);
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_hide (button);
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 GtkWidget *
create_gltransition_window (GtkWidget *do_widget)
{
GtkWidget *window, *headerbar, *scale, *outer_grid, *grid, *background;
GdkPaintable *paintable;
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);
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_show (demo_window);
else
gtk_window_destroy (GTK_WINDOW (demo_window));
return demo_window;
}

View File

@@ -0,0 +1,337 @@
/*
* 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"
/**
* SECTION:gskshaderpaintable
* @Short_description: Drawing with shaders
* @Title: GskShaderPaintable
* @see_also: #GdkPaintable
*
* 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);
}

View File

@@ -0,0 +1,53 @@
/*
* 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>
*/
#ifndef __GSK_SHADER_PAINTABLE_H__
#define __GSK_SHADER_PAINTABLE_H__
#include <gdk/gdk.h>
#include <gsk/gsk.h>
G_BEGIN_DECLS
#define GSK_TYPE_SHADER_PAINTABLE (gsk_shader_paintable_get_type ())
GDK_AVAILABLE_IN_ALL
G_DECLARE_FINAL_TYPE (GskShaderPaintable, gsk_shader_paintable, GSK, SHADER_PAINTABLE, GObject)
GDK_AVAILABLE_IN_ALL
GdkPaintable * gsk_shader_paintable_new (GskGLShader *shader,
GBytes *data);
GDK_AVAILABLE_IN_ALL
GskGLShader * gsk_shader_paintable_get_shader (GskShaderPaintable *self);
GDK_AVAILABLE_IN_ALL
void gsk_shader_paintable_set_shader (GskShaderPaintable *self,
GskGLShader *shader);
GDK_AVAILABLE_IN_ALL
GBytes * gsk_shader_paintable_get_args (GskShaderPaintable *self);
GDK_AVAILABLE_IN_ALL
void gsk_shader_paintable_set_args (GskShaderPaintable *self,
GBytes *data);
GDK_AVAILABLE_IN_ALL
void gsk_shader_paintable_update_time (GskShaderPaintable *self,
int time_idx,
gint64 frame_time);
G_END_DECLS
#endif /* __GSK_SHADER_PAINTABLE_H__ */

View File

@@ -179,6 +179,9 @@ gtk_fishbowl_add (GtkFishbowl *fishbowl,
child_info->dy = new_speed ();
gtk_widget_set_parent (widget, GTK_WIDGET (fishbowl));
gtk_accessible_update_state (GTK_ACCESSIBLE (widget),
GTK_ACCESSIBLE_STATE_HIDDEN, TRUE,
-1);
g_hash_table_insert (priv->children, widget, child_info);
priv->count++;
@@ -342,6 +345,8 @@ gtk_fishbowl_class_init (GtkFishbowlClass *klass)
G_PARAM_READWRITE);
g_object_class_install_properties (object_class, NUM_PROPERTIES, props);
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_PRESENTATION);
}
guint

View File

@@ -764,7 +764,7 @@ gtk_gears_realize (GtkWidget *widget)
glShaderSource(v, 1, &p, NULL);
glCompileShader(v);
glGetShaderInfoLog(v, sizeof msg, NULL, msg);
g_print ("vertex shader info: %s\n", msg);
g_debug ("vertex shader info: %s\n", msg);
/* Compile the fragment shader */
if (gdk_gl_context_get_use_es (context))
@@ -775,7 +775,7 @@ gtk_gears_realize (GtkWidget *widget)
glShaderSource(f, 1, &p, NULL);
glCompileShader(f);
glGetShaderInfoLog(f, sizeof msg, NULL, msg);
g_print ("fragment shader info: %s\n", msg);
g_debug ("fragment shader info: %s\n", msg);
/* Create and link the shader program */
program = glCreateProgram();
@@ -786,7 +786,7 @@ gtk_gears_realize (GtkWidget *widget)
glLinkProgram(program);
glGetProgramInfoLog(program, sizeof msg, NULL, msg);
g_print ("program info: %s\n", msg);
g_debug ("program info: %s\n", msg);
glDeleteShader (v);
glDeleteShader (f);

View File

@@ -0,0 +1,264 @@
#include "gtkshaderbin.h"
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);
}

View File

@@ -0,0 +1,23 @@
#ifndef __GTK_SHADER_BIN_H__
#define __GTK_SHADER_BIN_H__
#include <gtk/gtk.h>
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
#endif /* __GTK_SHADER_BIN_H__ */

View File

@@ -0,0 +1,361 @@
#include "gtkshaderstack.h"
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);
}

View File

@@ -0,0 +1,23 @@
#ifndef __GTK_SHADER_STACK_H__
#define __GTK_SHADER_STACK_H__
#include <gtk/gtk.h>
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
#endif /* __GTK_SHADER_STACK_H__ */

View File

@@ -56,13 +56,15 @@ const char *fragment_prefix =
"uniform float iSampleRate; // sound sample rate (i.e., 44100)\n"
"\n"
"in vec2 fragCoord;\n"
"out vec4 fragColor;\n";
"out vec4 vFragColor;\n";
// Fragment shader suffix
const char *fragment_suffix =
" void main() {\n"
" mainImage(fragColor, fragCoord);\n"
" vec4 c;\n"
" mainImage(c, fragCoord);\n"
" vFragColor = c;\n"
" }\n";
typedef struct {

View File

@@ -13,7 +13,7 @@ static GtkWidget *window = NULL;
static GtkWidget *scrolledwindow;
static int selected;
#define N_WIDGET_TYPES 6
#define N_WIDGET_TYPES 7
static int hincrement = 5;
@@ -177,6 +177,24 @@ populate_grid (void)
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scrolledwindow), list);
}
extern GtkWidget *create_ucd_view (GtkWidget *label);
static void
populate_list2 (void)
{
GtkWidget *list;
list = create_ucd_view (NULL);
hincrement = 0;
vincrement = 5;
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scrolledwindow), list);
}
static void
set_widget_type (int type)
{
@@ -216,6 +234,11 @@ set_widget_type (int type)
break;
case 5:
gtk_window_set_title (GTK_WINDOW (window), "Scrolling a columned list");
populate_list2 ();
break;
case 6:
gtk_window_set_title (GTK_WINDOW (window), "Scrolling a grid");
populate_grid ();
break;

View File

@@ -17,6 +17,7 @@
#include <glib/gstdio.h>
#include <stdio.h>
#include <errno.h>
#include "pixbufpaintable.h"
static GtkWidget *window = NULL;
static GdkPixbufLoader *pixbuf_loader = NULL;
@@ -56,6 +57,7 @@ progressive_updated_callback (GdkPixbufLoader *loader,
picture = GTK_WIDGET (data);
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
gtk_picture_set_pixbuf (GTK_PICTURE (picture), NULL);
gtk_picture_set_pixbuf (GTK_PICTURE (picture), pixbuf);
}
@@ -262,7 +264,7 @@ start_progressive_loading (GtkWidget *picture)
* The timeout simply simulates a slow data source by inserting
* pauses in the reading process.
*/
load_timeout = g_timeout_add (1500, progressive_timeout, picture);
load_timeout = g_timeout_add (300, progressive_timeout, picture);
g_source_set_name_by_id (load_timeout, "[gtk] progressive_timeout");
}
@@ -345,9 +347,8 @@ do_images (GtkWidget *do_widget)
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
gtk_box_append (GTK_BOX (hbox), vbox);
label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label),
"<u>Image loaded from a file</u>");
label = gtk_label_new ("Image from a resource");
gtk_widget_add_css_class (label, "heading");
gtk_box_append (GTK_BOX (vbox), label);
frame = gtk_frame_new (NULL);
@@ -355,7 +356,7 @@ do_images (GtkWidget *do_widget)
gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
gtk_box_append (GTK_BOX (vbox), frame);
image = gtk_image_new_from_icon_name ("gtk3-demo");
image = gtk_image_new_from_resource ("/images/org.gtk.Demo4.svg");
gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
gtk_frame_set_child (GTK_FRAME (frame), image);
@@ -363,9 +364,8 @@ do_images (GtkWidget *do_widget)
/* Animation */
label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label),
"<u>Animation loaded from a file</u>");
label = gtk_label_new ("Animation from a resource");
gtk_widget_add_css_class (label, "heading");
gtk_box_append (GTK_BOX (vbox), label);
frame = gtk_frame_new (NULL);
@@ -373,15 +373,16 @@ do_images (GtkWidget *do_widget)
gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
gtk_box_append (GTK_BOX (vbox), frame);
picture = gtk_picture_new_for_resource ("/images/floppybuddy.gif");
paintable = pixbuf_paintable_new_from_resource ("/images/floppybuddy.gif");
picture = gtk_picture_new_for_paintable (paintable);
g_object_unref (paintable);
gtk_frame_set_child (GTK_FRAME (frame), picture);
/* Symbolic icon */
label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label),
"<u>Symbolic themed icon</u>");
label = gtk_label_new ("Symbolic themed icon");
gtk_widget_add_css_class (label, "heading");
gtk_box_append (GTK_BOX (vbox), label);
frame = gtk_frame_new (NULL);
@@ -400,9 +401,8 @@ do_images (GtkWidget *do_widget)
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
gtk_box_append (GTK_BOX (hbox), vbox);
label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label),
"<u>Progressive image loading</u>");
label = gtk_label_new ("Progressive image loading");
gtk_widget_add_css_class (label, "heading");
gtk_box_append (GTK_BOX (vbox), label);
frame = gtk_frame_new (NULL);
@@ -414,6 +414,7 @@ do_images (GtkWidget *do_widget)
* will create the pixbuf and fill it in.
*/
picture = gtk_picture_new ();
gtk_picture_set_alternative_text (GTK_PICTURE (picture), "A slowly loading image");
gtk_frame_set_child (GTK_FRAME (frame), picture);
start_progressive_loading (picture);
@@ -422,9 +423,8 @@ do_images (GtkWidget *do_widget)
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
gtk_box_append (GTK_BOX (hbox), vbox);
label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label),
"<u>Displaying video</u>");
label = gtk_label_new ("Displaying video");
gtk_widget_add_css_class (label, "heading");
gtk_box_append (GTK_BOX (vbox), label);
frame = gtk_frame_new (NULL);
@@ -440,9 +440,8 @@ do_images (GtkWidget *do_widget)
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
gtk_box_append (GTK_BOX (hbox), vbox);
label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label),
"<u>GtkWidgetPaintable</u>");
label = gtk_label_new ("GtkWidgetPaintable");
gtk_widget_add_css_class (label, "heading");
gtk_box_append (GTK_BOX (vbox), label);
paintable = gtk_widget_paintable_new (do_widget);

View File

@@ -0,0 +1,41 @@
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

@@ -34,7 +34,7 @@ do_layoutmanager (GtkWidget *parent)
int i;
window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (window), "Layout ManagerTransition");
gtk_window_set_title (GTK_WINDOW (window), "Layout Manager — Transition");
gtk_window_set_default_size (GTK_WINDOW (window), 600, 600);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);

View File

@@ -170,7 +170,7 @@ do_layoutmanager2 (GtkWidget *parent)
int i;
window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (window), "Layout ManagerTransformation");
gtk_window_set_title (GTK_WINDOW (window), "Layout Manager — Transformation");
gtk_window_set_default_size (GTK_WINDOW (window), 600, 620);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);

View File

@@ -1,4 +1,4 @@
/* List Box/Complex list
/* List Box/Complex
*
* GtkListBox allows lists with complicated layouts, using
* regular widgets supporting sorting and filtering.
@@ -197,7 +197,7 @@ gtk_message_row_update (GtkMessageRow *row)
if (strcmp (priv->message->sender_nick, "@GTKtoolkit") == 0)
{
gtk_image_set_from_icon_name (priv->avatar_image, "gtk3-demo");
gtk_image_set_from_icon_name (priv->avatar_image, "org.gtk.Demo4");
gtk_image_set_icon_size (priv->avatar_image, GTK_ICON_SIZE_LARGE);
}
else
@@ -349,7 +349,7 @@ do_listbox (GtkWidget *do_widget)
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "List Box");
gtk_window_set_title (GTK_WINDOW (window), "List BoxComplex");
gtk_window_set_default_size (GTK_WINDOW (window), 400, 600);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);

View File

@@ -34,7 +34,7 @@ row_activated (GtkListBox *list,
}
GtkWidget *
do_listbox2 (GtkWidget *do_widget)
do_listbox_controls (GtkWidget *do_widget)
{
if (!window)
{
@@ -47,7 +47,7 @@ do_listbox2 (GtkWidget *do_widget)
builder = gtk_builder_new ();
gtk_builder_set_scope (builder, scope);
gtk_builder_add_from_resource (builder, "/listbox2/listbox2.ui", NULL);
gtk_builder_add_from_resource (builder, "/listbox_controls/listbox_controls.ui", NULL);
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
gtk_window_set_display (GTK_WINDOW (window),

View File

@@ -0,0 +1,382 @@
/* Lists/Characters
*
* This demo shows a multi-column representation of some parts
* of the Unicode Character Database, or UCD.
*
* The dataset used here has 33796 items.
*/
#include <gtk/gtk.h>
#include "script-names.h"
#include "unicode-names.h"
#define UCD_TYPE_ITEM (ucd_item_get_type ())
G_DECLARE_FINAL_TYPE (UcdItem, ucd_item, UCD, ITEM, GObject)
struct _UcdItem
{
GObject parent_instance;
gunichar codepoint;
const char *name;
};
struct _UcdItemClass
{
GObjectClass parent_class;
};
G_DEFINE_TYPE (UcdItem, ucd_item, G_TYPE_OBJECT)
static void
ucd_item_init (UcdItem *item)
{
}
static void
ucd_item_class_init (UcdItemClass *class)
{
}
static UcdItem *
ucd_item_new (gunichar codepoint,
const char *name)
{
UcdItem *item;
item = g_object_new (UCD_TYPE_ITEM, NULL);
item->codepoint = codepoint;
item->name = name;
return item;
}
static gunichar
ucd_item_get_codepoint (UcdItem *item)
{
return item->codepoint;
}
static const char *
ucd_item_get_name (UcdItem *item)
{
return item->name;
}
static GListModel *
ucd_model_new (void)
{
GBytes *bytes;
GVariant *v;
GVariantIter *iter;
GListStore *store;
guint u;
char *name;
bytes = g_resources_lookup_data ("/listview_ucd_data/ucdnames.data", 0, NULL);
v = g_variant_ref_sink (g_variant_new_from_bytes (G_VARIANT_TYPE ("a(us)"), bytes, TRUE));
iter = g_variant_iter_new (v);
store = g_list_store_new (G_TYPE_OBJECT);
while (g_variant_iter_next (iter, "(u&s)", &u, &name))
{
if (u == 0)
continue;
UcdItem *item = ucd_item_new (u, name);
g_list_store_append (store, item);
g_object_unref (item);
}
g_variant_iter_free (iter);
g_variant_unref (v);
g_bytes_unref (bytes);
return G_LIST_MODEL (store);
}
static void
setup_centered_label (GtkSignalListItemFactory *factory,
GObject *listitem)
{
GtkWidget *label;
label = gtk_label_new ("");
gtk_list_item_set_child (GTK_LIST_ITEM (listitem), label);
}
static void
setup_label (GtkSignalListItemFactory *factory,
GObject *listitem)
{
GtkWidget *label;
label = gtk_label_new ("");
gtk_label_set_xalign (GTK_LABEL (label), 0);
gtk_list_item_set_child (GTK_LIST_ITEM (listitem), label);
}
static void
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);
gtk_list_item_set_child (GTK_LIST_ITEM (listitem), label);
}
static void
bind_codepoint (GtkSignalListItemFactory *factory,
GObject *listitem)
{
GtkWidget *label;
GObject *item;
gunichar codepoint;
char buffer[16] = { 0, };
label = gtk_list_item_get_child (GTK_LIST_ITEM (listitem));
item = gtk_list_item_get_item (GTK_LIST_ITEM (listitem));
codepoint = ucd_item_get_codepoint (UCD_ITEM (item));
g_snprintf (buffer, 10, "%#06x", codepoint);
gtk_label_set_label (GTK_LABEL (label), buffer);
}
static void
bind_char (GtkSignalListItemFactory *factory,
GObject *listitem)
{
GtkWidget *label;
GObject *item;
gunichar codepoint;
char buffer[16] = { 0, };
label = gtk_list_item_get_child (GTK_LIST_ITEM (listitem));
item = gtk_list_item_get_item (GTK_LIST_ITEM (listitem));
codepoint = ucd_item_get_codepoint (UCD_ITEM (item));
if (g_unichar_isprint (codepoint))
g_unichar_to_utf8 (codepoint, buffer);
gtk_label_set_label (GTK_LABEL (label), buffer);
}
static void
bind_name (GtkSignalListItemFactory *factory,
GObject *listitem)
{
GtkWidget *label;
GObject *item;
const char *name;
label = gtk_list_item_get_child (GTK_LIST_ITEM (listitem));
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);
}
static void
bind_type (GtkSignalListItemFactory *factory,
GObject *listitem)
{
GtkWidget *label;
GObject *item;
gunichar codepoint;
label = gtk_list_item_get_child (GTK_LIST_ITEM (listitem));
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)));
}
static void
bind_break_type (GtkSignalListItemFactory *factory,
GObject *listitem)
{
GtkWidget *label;
GObject *item;
gunichar codepoint;
label = gtk_list_item_get_child (GTK_LIST_ITEM (listitem));
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)));
}
static void
bind_combining_class (GtkSignalListItemFactory *factory,
GObject *listitem)
{
GtkWidget *label;
GObject *item;
gunichar codepoint;
label = gtk_list_item_get_child (GTK_LIST_ITEM (listitem));
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)));
}
static void
bind_script (GtkSignalListItemFactory *factory,
GObject *listitem)
{
GtkWidget *label;
GObject *item;
gunichar codepoint;
GUnicodeScript script;
label = gtk_list_item_get_child (GTK_LIST_ITEM (listitem));
item = gtk_list_item_get_item (GTK_LIST_ITEM (listitem));
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));
}
static void
selection_changed (GObject *object,
GParamSpec *pspec,
GtkWidget *label)
{
UcdItem *item;
guint codepoint;
char buffer[16] = { 0, };
item = gtk_single_selection_get_selected_item (GTK_SINGLE_SELECTION (object));
codepoint = ucd_item_get_codepoint (item);
if (g_unichar_isprint (codepoint))
g_unichar_to_utf8 (codepoint, buffer);
gtk_label_set_label (GTK_LABEL (label), buffer);
}
GtkWidget *
create_ucd_view (GtkWidget *label)
{
GtkWidget *cv;
GListModel *ucd_model;
GtkSingleSelection *selection;
GtkListItemFactory *factory;
GtkColumnViewColumn *column;
ucd_model = ucd_model_new ();
selection = gtk_single_selection_new (ucd_model);
gtk_single_selection_set_autoselect (selection, TRUE);
gtk_single_selection_set_can_unselect (selection, FALSE);
if (label)
g_signal_connect (selection, "notify::selected", G_CALLBACK (selection_changed), label);
cv = gtk_column_view_new (GTK_SELECTION_MODEL (selection));
gtk_column_view_set_show_column_separators (GTK_COLUMN_VIEW (cv), TRUE);
factory = gtk_signal_list_item_factory_new ();
g_signal_connect (factory, "setup", G_CALLBACK (setup_centered_label), NULL);
g_signal_connect (factory, "bind", G_CALLBACK (bind_codepoint), NULL);
column = gtk_column_view_column_new ("Codepoint", factory);
gtk_column_view_append_column (GTK_COLUMN_VIEW (cv), column);
g_object_unref (column);
factory = gtk_signal_list_item_factory_new ();
g_signal_connect (factory, "setup", G_CALLBACK (setup_centered_label), NULL);
g_signal_connect (factory, "bind", G_CALLBACK (bind_char), NULL);
column = gtk_column_view_column_new ("Char", factory);
gtk_column_view_append_column (GTK_COLUMN_VIEW (cv), column);
g_object_unref (column);
factory = gtk_signal_list_item_factory_new ();
g_signal_connect (factory, "setup", G_CALLBACK (setup_ellipsizing_label), NULL);
g_signal_connect (factory, "bind", G_CALLBACK (bind_name), NULL);
column = gtk_column_view_column_new ("Name", factory);
gtk_column_view_column_set_resizable (column, TRUE);
gtk_column_view_append_column (GTK_COLUMN_VIEW (cv), column);
g_object_unref (column);
factory = gtk_signal_list_item_factory_new ();
g_signal_connect (factory, "setup", G_CALLBACK (setup_ellipsizing_label), NULL);
g_signal_connect (factory, "bind", G_CALLBACK (bind_type), NULL);
column = gtk_column_view_column_new ("Type", factory);
gtk_column_view_column_set_resizable (column, TRUE);
gtk_column_view_append_column (GTK_COLUMN_VIEW (cv), column);
g_object_unref (column);
factory = gtk_signal_list_item_factory_new ();
g_signal_connect (factory, "setup", G_CALLBACK (setup_ellipsizing_label), NULL);
g_signal_connect (factory, "bind", G_CALLBACK (bind_break_type), NULL);
column = gtk_column_view_column_new ("Break Type", factory);
gtk_column_view_column_set_resizable (column, TRUE);
gtk_column_view_append_column (GTK_COLUMN_VIEW (cv), column);
g_object_unref (column);
factory = gtk_signal_list_item_factory_new ();
g_signal_connect (factory, "setup", G_CALLBACK (setup_label), NULL);
g_signal_connect (factory, "bind", G_CALLBACK (bind_combining_class), NULL);
column = gtk_column_view_column_new ("Combining Class", factory);
gtk_column_view_column_set_resizable (column, TRUE);
gtk_column_view_append_column (GTK_COLUMN_VIEW (cv), column);
g_object_unref (column);
factory = gtk_signal_list_item_factory_new ();
g_signal_connect (factory, "setup", G_CALLBACK (setup_label), NULL);
g_signal_connect (factory, "bind", G_CALLBACK (bind_script), NULL);
column = gtk_column_view_column_new ("Script", factory);
gtk_column_view_column_set_resizable (column, TRUE);
gtk_column_view_append_column (GTK_COLUMN_VIEW (cv), column);
g_object_unref (column);
return cv;
}
static GtkWidget *window;
GtkWidget *
do_listview_ucd (GtkWidget *do_widget)
{
if (window == NULL)
{
GtkWidget *listview, *sw;
GtkWidget *box, *label;
GtkCssProvider *provider;
window = gtk_window_new ();
gtk_window_set_default_size (GTK_WINDOW (window), 800, 400);
gtk_window_set_title (GTK_WINDOW (window), "Characters");
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *) &window);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
label = gtk_label_new ("");
gtk_label_set_width_chars (GTK_LABEL (label), 2);
gtk_widget_add_css_class (label, "enormous");
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (provider, "label.enormous { font-size: 80px; }", -1);
gtk_style_context_add_provider (gtk_widget_get_style_context (label), GTK_STYLE_PROVIDER (provider), 800);
gtk_widget_set_hexpand (label, TRUE);
gtk_box_append (GTK_BOX (box), label);
sw = gtk_scrolled_window_new ();
gtk_scrolled_window_set_propagate_natural_width (GTK_SCROLLED_WINDOW (sw), TRUE);
listview = create_ucd_view (label);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), listview);
gtk_box_prepend (GTK_BOX (box), sw);
gtk_window_set_child (GTK_WINDOW (window), box);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
gtk_window_destroy (GTK_WINDOW (window));
return window;
}

View File

@@ -337,8 +337,8 @@ display_text (const char *format,
bytes = g_resources_lookup_data (resource, 0, NULL);
g_assert (bytes);
g_assert (g_utf8_validate (g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes), NULL));
text = g_bytes_get_data (bytes, &len);
g_assert (g_utf8_validate (text, len, NULL));
textview = gtk_text_view_new ();
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (textview), 20);
@@ -354,9 +354,8 @@ display_text (const char *format,
gtk_text_view_set_monospace (GTK_TEXT_VIEW (textview), TRUE);
buffer = gtk_text_buffer_new (NULL);
text = g_bytes_unref_to_data (bytes, &len);
gtk_text_buffer_set_text (buffer, text, len);
g_bytes_unref (bytes);
if (format)
fontify (format, buffer);
@@ -391,7 +390,7 @@ display_nothing (const char *resource)
GtkWidget *widget;
char *str;
str = g_strdup_printf ("The lazy GTK developers forgot to add a way to display the resource '%s'", resource);
str = g_strdup_printf ("The contents of the resource at '%s' cannot be displayed", resource);
widget = gtk_label_new (str);
gtk_label_set_wrap (GTK_LABEL (widget), TRUE);
@@ -410,6 +409,7 @@ static struct {
{ ".gif", NULL, display_image },
{ ".jpg", NULL, display_image },
{ ".png", NULL, display_image },
{ ".svg", NULL, display_image },
{ ".c", "c", display_text },
{ ".css", "css", display_text },
{ ".glsl", NULL, display_text },

View File

@@ -17,9 +17,6 @@
</section>
</menu>
<object class="GtkApplicationWindow" id="window">
<style>
<class name="devel"/>
</style>
<property name="default-width">800</property>
<property name="default-height">600</property>
<child type="titlebar">
@@ -28,14 +25,7 @@
<object class="GtkButton">
<property name="valign">center</property>
<property name="action-name">win.run</property>
<style>
<class name="text-button"/>
</style>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Run</property>
</object>
</child>
<property name="label" translatable="yes">Run</property>
</object>
</child>
<child type="end">
@@ -43,6 +33,9 @@
<property name="valign">center</property>
<property name="menu-model">gear_menu</property>
<property name="icon-name">open-menu-symbolic</property>
<accessibility>
<property name="label" translatable="yes">Primary menu</property>
</accessibility>
</object>
</child>
</object>
@@ -51,6 +44,9 @@
<object class="GtkBox">
<child>
<object class="GtkScrolledWindow">
<style>
<class name="sidebar"/>
</style>
<property name="width-request">120</property>
<property name="hscrollbar-policy">never</property>
<property name="min-content-width">150</property>
@@ -63,7 +59,11 @@
<object class="GtkSearchBar" id="searchbar">
<property name="key-capture-widget">window</property>
<child>
<object class="GtkSearchEntry" id="search-entry"/>
<object class="GtkSearchEntry" id="search-entry">
<accessibility>
<relation name="controls">listview</relation>
</accessibility>
</object>
</child>
</object>
</child>
@@ -78,6 +78,10 @@
<property name="resource">/ui/main-listitem.ui</property>
</object>
</property>
<accessibility>
<property name="label" translatable="yes">Demo list</property>
<relation name="controls">notebook</relation>
</accessibility>
</object>
</child>
@@ -85,9 +89,6 @@
</child>
</object>
</child>
<child>
<object class="GtkSeparator"/>
</child>
<child>
<object class="GtkNotebook" id="notebook">
<property name="scrollable">1</property>
@@ -112,6 +113,10 @@
<property name="editable">0</property>
<property name="wrap-mode">word</property>
<property name="cursor-visible">0</property>
<accessibility>
<property name="label" translatable="yes">Info</property>
<property name="description" translatable="yes">A description of the demo</property>
</accessibility>
</object>
</child>
</object>
@@ -142,6 +147,10 @@
<property name="wrap-mode">word</property>
<property name="pixels-above-lines">2</property>
<property name="pixels-below-lines">2</property>
<accessibility>
<property name="label" translatable="yes">Source</property>
<property name="description" translatable="yes">The source code of the demo</property>
</accessibility>
</object>
</child>
</object>

View File

@@ -7,8 +7,9 @@ demos = files([
'clipboard.c',
'combobox.c',
'constraints.c',
'constraints2.c',
'constraints3.c',
'constraints_interactive.c',
'constraints_vfl.c',
'constraints_builder.c',
'css_accordion.c',
'css_basics.c',
'css_blendmodes.c',
@@ -18,7 +19,6 @@ demos = files([
'cursors.c',
'dialog.c',
'drawingarea.c',
'dropdown.c',
'dnd.c',
'editable_cells.c',
'entry_completion.c',
@@ -32,6 +32,7 @@ demos = files([
'gears.c',
'gestures.c',
'glarea.c',
'gltransition.c',
'headerbar.c',
'hypertext.c',
'iconscroll.c',
@@ -43,7 +44,7 @@ demos = files([
'layoutmanager2.c',
'links.c',
'listbox.c',
'listbox2.c',
'listbox_controls.c',
'menu.c',
'flowbox.c',
'list_store.c',
@@ -52,12 +53,14 @@ demos = files([
'listview_colors.c',
'listview_filebrowser.c',
'listview_minesweeper.c',
'dropdown.c',
'listview_settings.c',
'listview_ucd.c',
'listview_weather.c',
'listview_words.c',
'markup.c',
'overlay.c',
'overlay2.c',
'overlay_decorative.c',
'paint.c',
'paintable.c',
'paintable_animated.c',
@@ -65,6 +68,9 @@ demos = files([
'paintable_mediastream.c',
'panes.c',
'password_entry.c',
'path_fill.c',
'path_maze.c',
'path_text.c',
'peg_solitaire.c',
'pickers.c',
'printing.c',
@@ -102,7 +108,10 @@ extra_demo_sources = files(['main.c',
'gtkfishbowl.c',
'fontplane.c',
'gtkgears.c',
'gtkshaderbin.c',
'gtkshadertoy.c',
'gtkshaderstack.c',
'gskshaderpaintable.c',
'puzzlepiece.c',
'bluroverlay.c',
'demoimage.c',
@@ -114,11 +123,15 @@ extra_demo_sources = files(['main.c',
'singular_value_decomposition.c',
'four_point_transform.c',
'demo2widget.c',
'demo3widget.c'])
'demo3widget.c',
'pixbufpaintable.c',
'script-names.c',
'unicode-names.c',
'suggestionentry.c'])
if harfbuzz_dep.found() and pangoft_dep.found()
demos += files('font_features.c')
extra_demo_sources += files(['script-names.c', 'language-names.c'])
demos += files(['font_features.c'])
extra_demo_sources += files(['language-names.c'])
gtkdemo_deps += [ harfbuzz_dep, epoxy_dep ]
endif
@@ -126,6 +139,14 @@ if os_unix
demos += files('pagesetup.c')
endif
librsvg_dep = dependency('librsvg-2.0', version: '>= 2.46.0', required: false)
if librsvg_dep.found()
demos += files('paintable_svg.c')
extra_demo_sources += files(['svgpaintable.c'])
gtkdemo_deps += [ librsvg_dep ]
endif
gtkdemo_args = [ '-DGDK_DISABLE_DEPRECATED', '-DGTK_DISABLE_DEPRECATED', ]
demos_h = custom_target('gtk4 demo header',

View File

@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg height="128px" viewBox="0 0 128 128" width="128px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<linearGradient id="a" gradientUnits="userSpaceOnUse" x1="43.000351" x2="85.000351" y1="39.000164" y2="39.000164">
<stop offset="0" stop-color="#26a269"/>
<stop offset="0.0934161" stop-color="#84e3b7"/>
<stop offset="0.330831" stop-color="#26a269"/>
<stop offset="0.686952" stop-color="#26a269"/>
<stop offset="0.89736" stop-color="#175e3c"/>
<stop offset="1" stop-color="#26a269"/>
</linearGradient>
<linearGradient id="b" gradientUnits="userSpaceOnUse">
<stop offset="0" stop-color="#c0bfbc"/>
<stop offset="0.154754" stop-color="#ffffff"/>
<stop offset="0.433722" stop-color="#bdbbb5"/>
<stop offset="0.650505" stop-color="#c1c0ba"/>
<stop offset="0.825253" stop-color="#ffffff"/>
<stop offset="1" stop-color="#c0bfbc"/>
</linearGradient>
<linearGradient id="c" gradientTransform="matrix(0.0811899 -0.046875 0.069079 0.119648 307.03142 127.069456)" x1="-1710.210571" x2="-1774.45166" xlink:href="#b" y1="-1202.376709" y2="-1202.376709"/>
<linearGradient id="d" gradientTransform="matrix(-0.0811899 -0.046875 -0.069079 0.119648 -177.242852 127.069447)" x1="-1710.210571" x2="-1774.45166" xlink:href="#b" y1="-1202.376709" y2="-1202.376709"/>
<linearGradient id="e" gradientUnits="userSpaceOnUse" x1="14" x2="56" y1="94.999964" y2="94.999964">
<stop offset="0" stop-color="#813d9c"/>
<stop offset="0.109119" stop-color="#b378ca"/>
<stop offset="0.241583" stop-color="#813d9c"/>
<stop offset="0.731841" stop-color="#813d9c"/>
<stop offset="0.872163" stop-color="#4d255d"/>
<stop offset="1" stop-color="#813d9c"/>
</linearGradient>
<linearGradient id="f" gradientUnits="userSpaceOnUse" x1="72" x2="114" y1="94.999964" y2="94.999964">
<stop offset="0" stop-color="#e66100"/>
<stop offset="0.0678478" stop-color="#ff903e"/>
<stop offset="0.168852" stop-color="#e66100"/>
<stop offset="0.886626" stop-color="#e66100"/>
<stop offset="1" stop-color="#9d4200"/>
</linearGradient>
<clipPath id="g">
<rect height="128" width="128"/>
</clipPath>
<clipPath id="h">
<rect height="128" width="128"/>
</clipPath>
<filter id="i" height="100%" width="100%" x="0%" y="0%">
<feColorMatrix in="SourceGraphic" type="matrix" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"/>
</filter>
<mask id="j">
<g clip-path="url(#h)" filter="url(#i)">
<g clip-path="url(#g)">
<path d="m 51 18 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="url(#a)"/>
<path d="m 51 12 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="#57e389"/>
<path d="m 76.976562 55.453125 c 1.480469 -0.855469 3.371094 -0.347656 4.226563 1.132813 l 6.742187 11.679687 c 0.855469 1.480469 0.347657 3.371094 -1.132812 4.226563 c -1.480469 0.851562 -3.371094 0.347656 -4.226562 -1.132813 l -6.742188 -11.679687 c -0.855469 -1.480469 -0.347656 -3.371094 1.132812 -4.226563 z m 0 0" fill="url(#c)"/>
<path d="m 52.8125 55.453125 c -1.480469 -0.855469 -3.371094 -0.347656 -4.226562 1.132813 l -6.742188 11.679687 c -0.855469 1.480469 -0.347656 3.371094 1.132812 4.226563 c 1.480469 0.851562 3.371094 0.347656 4.226563 -1.132813 l 6.742187 -11.679687 c 0.855469 -1.480469 0.347657 -3.371094 -1.132812 -4.226563 z m 0 0" fill="url(#d)"/>
<path d="m 22 74 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="url(#e)"/>
<path d="m 22 68 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="#dc8add"/>
<path d="m 80 74 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="url(#f)"/>
<path d="m 80 68 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="#ffa348"/>
</g>
</g>
</mask>
<mask id="k">
<g filter="url(#i)">
<rect fill-opacity="0.8" height="128" width="128"/>
</g>
</mask>
<linearGradient id="l" gradientTransform="matrix(0 0.37 -0.98462 0 295.38501 -30.360001)" gradientUnits="userSpaceOnUse" x1="300" x2="428" y1="235" y2="235">
<stop offset="0" stop-color="#f9f06b"/>
<stop offset="1" stop-color="#f5c211"/>
</linearGradient>
<clipPath id="m">
<rect height="128" width="128"/>
</clipPath>
<clipPath id="n">
<rect height="128" width="128"/>
</clipPath>
<path d="m 51 18 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="url(#a)"/>
<path d="m 51 12 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="#57e389"/>
<path d="m 76.976562 55.453125 c 1.480469 -0.855469 3.371094 -0.347656 4.226563 1.132813 l 6.742187 11.679687 c 0.855469 1.480469 0.347657 3.371094 -1.132812 4.226563 c -1.480469 0.851562 -3.371094 0.347656 -4.226562 -1.132813 l -6.742188 -11.679687 c -0.855469 -1.480469 -0.347656 -3.371094 1.132812 -4.226563 z m 0 0" fill="url(#c)"/>
<path d="m 52.8125 55.453125 c -1.480469 -0.855469 -3.371094 -0.347656 -4.226562 1.132813 l -6.742188 11.679687 c -0.855469 1.480469 -0.347656 3.371094 1.132812 4.226563 c 1.480469 0.851562 3.371094 0.347656 4.226563 -1.132813 l 6.742187 -11.679687 c 0.855469 -1.480469 0.347657 -3.371094 -1.132812 -4.226563 z m 0 0" fill="url(#d)"/>
<path d="m 22 74 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="url(#e)"/>
<path d="m 22 68 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="#dc8add"/>
<path d="m 80 74 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="url(#f)"/>
<path d="m 80 68 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="#ffa348"/>
<g clip-path="url(#n)" mask="url(#j)">
<g clip-path="url(#m)" mask="url(#k)">
<path d="m 128 80.640625 v 47.359375 h -128 v -47.359375 z m 0 0" fill="url(#l)"/>
<path d="m 13.308594 80.640625 l 47.355468 47.359375 h 21.214844 l -47.359375 -47.359375 z m 42.421875 0 l 47.363281 47.359375 h 21.214844 l -47.363282 -47.359375 z m 42.429687 0 l 29.839844 29.839844 v -21.210938 l -8.628906 -8.628906 z m -98.160156 7.90625 v 21.214844 l 18.238281 18.238281 h 21.214844 z m 0 0"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 7.4 KiB

View File

@@ -21,7 +21,7 @@ margin_changed (GtkAdjustment *adjustment,
}
GtkWidget *
do_overlay2 (GtkWidget *do_widget)
do_overlay_decorative (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;

View File

@@ -1,4 +1,4 @@
/* Paintable/A simple paintable
/* Paintable/Simple Paintable
*
* GdkPaintable is an interface used by GTK for drawings of any sort
* that do not require layouting or positioning.

View File

@@ -1,4 +1,4 @@
/* Paintable/An animated paintable
/* Paintable/Animated Paintable
*
* GdkPaintable also allows paintables to change.
*

View File

@@ -153,7 +153,7 @@ do_paintable_emblem (GtkWidget *do_widget)
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Emblems");
gtk_window_set_title (GTK_WINDOW (window), "PaintableEmblems");
gtk_window_set_default_size (GTK_WINDOW (window), 300, 200);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);

View File

@@ -1,4 +1,4 @@
/* Paintable/A media stream
/* Paintable/Media Stream
*
* GdkPaintable is also used by the GtkMediaStream class.
*

View File

@@ -0,0 +1,79 @@
/* Paintable/SVG
*
* This demo shows wrapping a librsvg RsvgHandle in a GdkPaintable
* to display an SVG image that can be scaled by resizing the window.
*
* This demo relies on librsvg, which GTK itself does not link against.
*/
#include <gtk/gtk.h>
#include <librsvg/rsvg.h>
#include "svgpaintable.h"
static void
file_set (GtkFileChooserButton *button,
GtkWidget *picture)
{
GFile *file;
GdkPaintable *paintable;
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (button));
paintable = svg_paintable_new (file);
gtk_picture_set_paintable (GTK_PICTURE (picture), paintable);
g_object_unref (paintable);
g_object_unref (file);
}
static GtkWidget *window;
GtkWidget *
do_paintable_svg (GtkWidget *do_widget)
{
GtkWidget *header;
GtkWidget *picture;
GtkFileFilter *filter;
GtkWidget *button;
GFile *file;
GdkPaintable *paintable;
if (!window)
{
window = gtk_window_new ();
header = gtk_header_bar_new ();
gtk_window_set_titlebar (GTK_WINDOW (window), header);
gtk_window_set_default_size (GTK_WINDOW (window), 330, 330);
gtk_window_set_title (GTK_WINDOW (window), "PaintableSVG");
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
button = gtk_file_chooser_button_new ("Select an SVG file", GTK_FILE_CHOOSER_ACTION_OPEN);
filter = gtk_file_filter_new ();
gtk_file_filter_add_mime_type (filter, "image/svg+xml");
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (button), filter);
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), button);
picture = gtk_picture_new ();
gtk_picture_set_can_shrink (GTK_PICTURE (picture), TRUE);
gtk_widget_set_size_request (picture, 16, 16);
g_signal_connect (button, "file-set", G_CALLBACK (file_set), picture);
gtk_window_set_child (GTK_WINDOW (window), picture);
file = g_file_new_for_uri ("resource:///paintable_svg/org.gtk.gtk4.NodeEditor.Devel.svg");
paintable = svg_paintable_new (file);
gtk_picture_set_paintable (GTK_PICTURE (picture), paintable);
g_object_unref (paintable);
g_object_unref (file);
}
if (!gtk_widget_get_visible (window))
gtk_window_present (GTK_WINDOW (window));
else
gtk_window_destroy (GTK_WINDOW (window));
return window;
}

View File

@@ -3,100 +3,16 @@
* The GtkPaned Widget divides its content area into two panes
* with a divider in between that the user can adjust. A separate
* child is placed into each pane. GtkPaned widgets can be split
* horizontally or vertially.
* horizontally or vertically. This test contains both a horizontal
* and a vertical GtkPaned widget.
*
* There are a number of options that can be set for each pane.
* This test contains both a horizontal and a vertical GtkPaned
* widget, and allows you to adjust the options for each side of
* each widget.
* You can use the Inspector to adjust the options for each side
* of each widget.
*/
#include <gtk/gtk.h>
static void
toggle_resize (GtkWidget *widget,
GtkWidget *child)
{
GtkWidget *parent;
GtkPaned *paned;
parent = gtk_widget_get_parent (child);
paned = GTK_PANED (parent);
if (child == gtk_paned_get_start_child (paned))
gtk_paned_set_resize_start_child (paned, !gtk_paned_get_resize_start_child (paned));
else
gtk_paned_set_resize_end_child (paned, !gtk_paned_get_resize_end_child (paned));
}
static void
toggle_shrink (GtkWidget *widget,
GtkWidget *child)
{
GtkWidget *parent;
GtkPaned *paned;
parent = gtk_widget_get_parent (child);
paned = GTK_PANED (parent);
if (child == gtk_paned_get_start_child (paned))
gtk_paned_set_shrink_start_child (paned, !gtk_paned_get_shrink_start_child (paned));
else
gtk_paned_set_shrink_end_child (paned, !gtk_paned_get_shrink_end_child (paned));
}
static GtkWidget *
create_pane_options (GtkPaned *paned,
const char *frame_label,
const char *label1,
const char *label2)
{
GtkWidget *child1, *child2;
GtkWidget *frame;
GtkWidget *table;
GtkWidget *label;
GtkWidget *check_button;
child1 = gtk_paned_get_start_child (paned);
child2 = gtk_paned_get_end_child (paned);
frame = gtk_frame_new (frame_label);
table = gtk_grid_new ();
gtk_frame_set_child (GTK_FRAME (frame), table);
label = gtk_label_new (label1);
gtk_grid_attach (GTK_GRID (table), label, 0, 0, 1, 1);
check_button = gtk_check_button_new_with_mnemonic ("_Resize");
gtk_grid_attach (GTK_GRID (table), check_button, 0, 1, 1, 1);
g_signal_connect (check_button, "toggled",
G_CALLBACK (toggle_resize), child1);
check_button = gtk_check_button_new_with_mnemonic ("_Shrink");
gtk_grid_attach (GTK_GRID (table), check_button, 0, 2, 1, 1);
gtk_check_button_set_active (GTK_CHECK_BUTTON (check_button), TRUE);
g_signal_connect (check_button, "toggled",
G_CALLBACK (toggle_shrink), child1);
label = gtk_label_new (label2);
gtk_grid_attach (GTK_GRID (table), label, 1, 0, 1, 1);
check_button = gtk_check_button_new_with_mnemonic ("_Resize");
gtk_grid_attach (GTK_GRID (table), check_button, 1, 1, 1, 1);
gtk_check_button_set_active (GTK_CHECK_BUTTON (check_button), TRUE);
g_signal_connect (check_button, "toggled",
G_CALLBACK (toggle_resize), child2);
check_button = gtk_check_button_new_with_mnemonic ("_Shrink");
gtk_grid_attach (GTK_GRID (table), check_button, 1, 2, 1, 1);
gtk_check_button_set_active (GTK_CHECK_BUTTON (check_button), TRUE);
g_signal_connect (check_button, "toggled",
G_CALLBACK (toggle_shrink), child2);
return frame;
}
GtkWidget *
do_panes (GtkWidget *do_widget)
{
@@ -104,19 +20,19 @@ do_panes (GtkWidget *do_widget)
GtkWidget *frame;
GtkWidget *hpaned;
GtkWidget *vpaned;
GtkWidget *button;
GtkWidget *label;
GtkWidget *vbox;
GtkWidget *box;
if (!window)
{
window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (window), "Paned Widgets");
gtk_window_set_default_size (GTK_WINDOW (window), 330, 250);
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
gtk_window_set_title (GTK_WINDOW (window), "Paned Widgets");
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
gtk_widget_set_margin_start (vbox, 8);
gtk_widget_set_margin_end (vbox, 8);
@@ -132,41 +48,37 @@ do_panes (GtkWidget *do_widget)
hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
gtk_paned_set_start_child (GTK_PANED (vpaned), hpaned);
gtk_paned_set_shrink_start_child (GTK_PANED (vpaned), FALSE);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_set_size_request (box, 60, 60);
gtk_paned_set_start_child (GTK_PANED (hpaned), box);
label = gtk_label_new ("Hi there");
gtk_widget_set_margin_start (label, 4);
gtk_widget_set_margin_end (label, 4);
gtk_widget_set_margin_top (label, 4);
gtk_widget_set_margin_bottom (label, 4);
gtk_widget_set_hexpand (label, TRUE);
gtk_widget_set_vexpand (label, TRUE);
gtk_paned_set_start_child (GTK_PANED (hpaned), label);
gtk_paned_set_shrink_start_child (GTK_PANED (hpaned), FALSE);
button = gtk_button_new_with_mnemonic ("_Hi there");
gtk_widget_set_margin_start (button, 4);
gtk_widget_set_margin_end (button, 4);
gtk_widget_set_margin_top (button, 4);
gtk_widget_set_margin_bottom (button, 4);
gtk_widget_set_hexpand (button, TRUE);
gtk_widget_set_vexpand (button, TRUE);
gtk_box_append (GTK_BOX (box), button);
label = gtk_label_new ("Hello");
gtk_widget_set_margin_start (label, 4);
gtk_widget_set_margin_end (label, 4);
gtk_widget_set_margin_top (label, 4);
gtk_widget_set_margin_bottom (label, 4);
gtk_widget_set_hexpand (label, TRUE);
gtk_widget_set_vexpand (label, TRUE);
gtk_paned_set_end_child (GTK_PANED (hpaned), label);
gtk_paned_set_shrink_end_child (GTK_PANED (hpaned), FALSE);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_set_size_request (box, 80, 60);
gtk_paned_set_end_child (GTK_PANED (hpaned), box);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_set_size_request (box, 60, 80);
gtk_paned_set_end_child (GTK_PANED (vpaned), box);
/* Now create toggle buttons to control sizing */
gtk_box_append (GTK_BOX (vbox),
create_pane_options (GTK_PANED (hpaned),
"Horizontal",
"Left",
"Right"));
gtk_box_append (GTK_BOX (vbox),
create_pane_options (GTK_PANED (vpaned),
"Vertical",
"Top",
"Bottom"));
label = gtk_label_new ("Goodbye");
gtk_widget_set_margin_start (label, 4);
gtk_widget_set_margin_end (label, 4);
gtk_widget_set_margin_top (label, 4);
gtk_widget_set_margin_bottom (label, 4);
gtk_widget_set_hexpand (label, TRUE);
gtk_widget_set_vexpand (label, TRUE);
gtk_paned_set_end_child (GTK_PANED (vpaned), label);
gtk_paned_set_shrink_end_child (GTK_PANED (vpaned), FALSE);
}
if (!gtk_widget_get_visible (window))

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

@@ -0,0 +1,303 @@
/* Path/Fill
*
* This demo shows how to use PangoCairo to draw text with more than
* just a single color.
*/
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include "paintable.h"
#define GTK_TYPE_PATH_PAINTABLE (gtk_path_paintable_get_type ())
G_DECLARE_FINAL_TYPE (GtkPathPaintable, gtk_path_paintable, GTK, PATH_PAINTABLE, GObject)
struct _GtkPathPaintable
{
GObject parent_instance;
int width;
int height;
GskPath *path;
GdkPaintable *background;
};
struct _GtkPathPaintableClass
{
GObjectClass parent_class;
};
static int
gtk_path_paintable_get_intrinsic_width (GdkPaintable *paintable)
{
GtkPathPaintable *self = GTK_PATH_PAINTABLE (paintable);
if (self->background)
return MAX (gdk_paintable_get_intrinsic_width (self->background), self->width);
else
return self->width;
}
static int
gtk_path_paintable_get_intrinsic_height (GdkPaintable *paintable)
{
GtkPathPaintable *self = GTK_PATH_PAINTABLE (paintable);
if (self->background)
return MAX (gdk_paintable_get_intrinsic_height (self->background), self->height);
else
return self->height;
}
static void
gtk_path_paintable_snapshot (GdkPaintable *paintable,
GdkSnapshot *snapshot,
double width,
double height)
{
GtkPathPaintable *self = GTK_PATH_PAINTABLE (paintable);
#if 0
gtk_snapshot_push_fill (snapshot, self->path, GSK_FILL_RULE_WINDING);
#else
GskStroke *stroke = gsk_stroke_new (4.0);
gtk_snapshot_push_stroke (snapshot, self->path, stroke);
gsk_stroke_free (stroke);
#endif
if (self->background)
{
gdk_paintable_snapshot (self->background, snapshot, width, height);
}
else
{
gtk_snapshot_append_linear_gradient (snapshot,
&GRAPHENE_RECT_INIT (0, 0, width, height),
&GRAPHENE_POINT_INIT (0, 0),
&GRAPHENE_POINT_INIT (width, height),
(GskColorStop[8]) {
{ 0.0, { 1.0, 0.0, 0.0, 1.0 } },
{ 0.2, { 1.0, 0.0, 0.0, 1.0 } },
{ 0.3, { 1.0, 1.0, 0.0, 1.0 } },
{ 0.4, { 0.0, 1.0, 0.0, 1.0 } },
{ 0.6, { 0.0, 1.0, 1.0, 1.0 } },
{ 0.7, { 0.0, 0.0, 1.0, 1.0 } },
{ 0.8, { 1.0, 0.0, 1.0, 1.0 } },
{ 1.0, { 1.0, 0.0, 1.0, 1.0 } }
},
8);
}
gtk_snapshot_pop (snapshot);
}
static GdkPaintableFlags
gtk_path_paintable_get_flags (GdkPaintable *paintable)
{
GtkPathPaintable *self = GTK_PATH_PAINTABLE (paintable);
if (self->background)
return gdk_paintable_get_flags (self->background);
else
return GDK_PAINTABLE_STATIC_CONTENTS | GDK_PAINTABLE_STATIC_SIZE;
}
static void
gtk_path_paintable_paintable_init (GdkPaintableInterface *iface)
{
iface->get_intrinsic_width = gtk_path_paintable_get_intrinsic_width;
iface->get_intrinsic_height = gtk_path_paintable_get_intrinsic_height;
iface->snapshot = gtk_path_paintable_snapshot;
iface->get_flags = gtk_path_paintable_get_flags;
}
/* When defining the GType, we need to implement the GdkPaintable interface */
G_DEFINE_TYPE_WITH_CODE (GtkPathPaintable, gtk_path_paintable, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
gtk_path_paintable_paintable_init))
/* Here's the boilerplate for the GObject declaration.
* We don't need to do anything special here, because we keep no
* data of our own.
*/
static void
gtk_path_paintable_class_init (GtkPathPaintableClass *klass)
{
}
static void
gtk_path_paintable_init (GtkPathPaintable *self)
{
}
/* And finally, we add a simple constructor.
* It is declared in the header so that the other examples
* can use it.
*/
GdkPaintable *
gtk_path_paintable_new (GskPath *path,
GdkPaintable *background,
int width,
int height)
{
GtkPathPaintable *self;
self = g_object_new (GTK_TYPE_PATH_PAINTABLE, NULL);
self->path = path;
self->background = background;
if (self->background)
{
g_signal_connect_swapped (self->background, "invalidate-contents", G_CALLBACK (gdk_paintable_invalidate_contents), self);
g_signal_connect_swapped (self->background, "invalidate-size", G_CALLBACK (gdk_paintable_invalidate_size), self);
}
self->width = width;
self->height = height;
return GDK_PAINTABLE (self);
}
void
gtk_path_paintable_set_path (GtkPathPaintable *self,
GskPath *path)
{
g_clear_pointer (&self->path, gsk_path_unref);
self->path = gsk_path_ref (path);
gdk_paintable_invalidate_contents (GDK_PAINTABLE (self));
}
static GskPath *
create_hexagon (GtkWidget *widget)
{
GskPathBuilder *builder;
builder = gsk_path_builder_new ();
gsk_path_builder_move_to (builder, 120, 0);
gsk_path_builder_line_to (builder, 360, 0);
gsk_path_builder_line_to (builder, 480, 208);
gsk_path_builder_line_to (builder, 360, 416);
gsk_path_builder_line_to (builder, 120, 416);
gsk_path_builder_line_to (builder, 0, 208);
gsk_path_builder_close (builder);
return gsk_path_builder_free_to_path (builder);
}
static GskPath *
create_path_from_text (GtkWidget *widget)
{
cairo_surface_t *surface;
cairo_t *cr;
cairo_path_t *path;
PangoLayout *layout;
PangoFontDescription *desc;
GskPath *result;
surface = cairo_recording_surface_create (CAIRO_CONTENT_COLOR_ALPHA, NULL);
cr = cairo_create (surface);
layout = gtk_widget_create_pango_layout (widget, "Pango power!\nPango power!\nPango power!");
desc = pango_font_description_from_string ("sans bold 36");
pango_layout_set_font_description (layout, desc);
pango_font_description_free (desc);
pango_cairo_layout_path (cr, layout);
path = cairo_copy_path_flat (cr);
result = gsk_path_new_from_cairo (path);
cairo_path_destroy (path);
g_object_unref (layout);
cairo_destroy (cr);
cairo_surface_destroy (surface);
return result;
}
static gboolean
update_path (GtkWidget *widget,
GdkFrameClock *frame_clock,
gpointer measure)
{
float progress = gdk_frame_clock_get_frame_time (frame_clock) % (60 * G_USEC_PER_SEC) / (float) (30 * G_USEC_PER_SEC);
GskPathBuilder *builder;
GskPath *path;
graphene_point_t pos;
graphene_vec2_t tangent;
builder = gsk_path_builder_new ();
gsk_path_measure_add_segment (measure,
builder,
progress > 1 ? (progress - 1) * gsk_path_measure_get_length (measure) : 0.0,
(progress < 1 ? progress : 1.0) * gsk_path_measure_get_length (measure));
gsk_path_measure_get_point (measure,
(progress > 1 ? (progress - 1) : progress) * gsk_path_measure_get_length (measure),
&pos,
&tangent);
gsk_path_builder_move_to (builder, pos.x + 5 * graphene_vec2_get_x (&tangent), pos.y + 5 * graphene_vec2_get_y (&tangent));
gsk_path_builder_line_to (builder, pos.x + 3 * graphene_vec2_get_y (&tangent), pos.y + 3 * graphene_vec2_get_x (&tangent));
gsk_path_builder_line_to (builder, pos.x - 3 * graphene_vec2_get_y (&tangent), pos.y - 3 * graphene_vec2_get_x (&tangent));
gsk_path_builder_close (builder);
path = gsk_path_builder_free_to_path (builder);
gtk_path_paintable_set_path (GTK_PATH_PAINTABLE (gtk_picture_get_paintable (GTK_PICTURE (widget))),
path);
gsk_path_unref (path);
return G_SOURCE_CONTINUE;
}
GtkWidget *
do_path_fill (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;
if (!window)
{
GtkWidget *picture;
GdkPaintable *paintable;
GtkMediaStream *stream;
GskPath *path;
graphene_rect_t bounds;
GskPathMeasure *measure;
window = gtk_window_new ();
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
gtk_window_set_title (GTK_WINDOW (window), "Path Fill");
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
#if 0
stream = gtk_media_file_new_for_resource ("/images/gtk-logo.webm");
#else
stream = gtk_nuclear_media_stream_new ();
#endif
gtk_media_stream_play (stream);
gtk_media_stream_set_loop (stream, TRUE);
path = create_hexagon (window);
path = create_path_from_text (window);
gsk_path_get_bounds (path, &bounds);
paintable = gtk_path_paintable_new (path,
GDK_PAINTABLE (stream),
bounds.origin.x + bounds.size.width,
bounds.origin.y + bounds.size.height);
picture = gtk_picture_new_for_paintable (paintable);
measure = gsk_path_measure_new (path);
gtk_widget_add_tick_callback (picture, update_path, measure, (GDestroyNotify) gsk_path_measure_unref);
gtk_picture_set_keep_aspect_ratio (GTK_PICTURE (picture), FALSE);
gtk_picture_set_can_shrink (GTK_PICTURE (picture), FALSE);
g_object_unref (paintable);
gtk_window_set_child (GTK_WINDOW (window), picture);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
gtk_window_destroy (GTK_WINDOW (window));
return window;
}

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

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

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

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

View File

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

View File

@@ -0,0 +1,187 @@
#include <gtk/gtk.h>
#include "pixbufpaintable.h"
struct _PixbufPaintable {
GObject parent_instance;
char *resource_path;
GdkPixbufAnimation *anim;
GdkPixbufAnimationIter *iter;
guint timeout;
};
enum {
PROP_RESOURCE_PATH = 1,
NUM_PROPERTIES
};
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
static void
pixbuf_paintable_snapshot (GdkPaintable *paintable,
GdkSnapshot *snapshot,
double width,
double height)
{
PixbufPaintable *self = PIXBUF_PAINTABLE (paintable);
GTimeVal val;
GdkPixbuf *pixbuf;
GdkTexture *texture;
g_get_current_time (&val);
gdk_pixbuf_animation_iter_advance (self->iter, &val);
pixbuf = gdk_pixbuf_animation_iter_get_pixbuf (self->iter);
texture = gdk_texture_new_for_pixbuf (pixbuf);
gdk_paintable_snapshot (GDK_PAINTABLE (texture), snapshot, width, height);
g_object_unref (texture);
}
G_GNUC_END_IGNORE_DEPRECATIONS;
static int
pixbuf_paintable_get_intrinsic_width (GdkPaintable *paintable)
{
PixbufPaintable *self = PIXBUF_PAINTABLE (paintable);
return gdk_pixbuf_animation_get_width (self->anim);
}
static int
pixbuf_paintable_get_intrinsic_height (GdkPaintable *paintable)
{
PixbufPaintable *self = PIXBUF_PAINTABLE (paintable);
return gdk_pixbuf_animation_get_height (self->anim);
}
static void
pixbuf_paintable_init_interface (GdkPaintableInterface *iface)
{
iface->snapshot = pixbuf_paintable_snapshot;
iface->get_intrinsic_width = pixbuf_paintable_get_intrinsic_width;
iface->get_intrinsic_height = pixbuf_paintable_get_intrinsic_height;
}
G_DEFINE_TYPE_WITH_CODE(PixbufPaintable, pixbuf_paintable, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
pixbuf_paintable_init_interface))
static void
pixbuf_paintable_init (PixbufPaintable *paintable)
{
}
static gboolean
delay_cb (gpointer data)
{
PixbufPaintable *self = data;
int delay;
delay = gdk_pixbuf_animation_iter_get_delay_time (self->iter);
self->timeout = g_timeout_add (delay, delay_cb, self);
gdk_paintable_invalidate_contents (GDK_PAINTABLE (self));
return G_SOURCE_REMOVE;
}
static void
pixbuf_paintable_set_resource_path (PixbufPaintable *self,
const char *resource_path)
{
int delay;
g_free (self->resource_path);
self->resource_path = g_strdup (resource_path);
g_clear_object (&self->anim);
self->anim = gdk_pixbuf_animation_new_from_resource (resource_path, NULL);
g_clear_object (&self->iter);
self->iter = gdk_pixbuf_animation_get_iter (self->anim, NULL);
delay = gdk_pixbuf_animation_iter_get_delay_time (self->iter);
self->timeout = g_timeout_add (delay, delay_cb, self);
gdk_paintable_invalidate_contents (GDK_PAINTABLE (self));
g_object_notify (G_OBJECT (self), "resource-path");
}
static void
pixbuf_paintable_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
PixbufPaintable *self = PIXBUF_PAINTABLE (object);
switch (prop_id)
{
case PROP_RESOURCE_PATH:
pixbuf_paintable_set_resource_path (self, g_value_get_string (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
pixbuf_paintable_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
PixbufPaintable *self = PIXBUF_PAINTABLE (object);
switch (prop_id)
{
case PROP_RESOURCE_PATH:
g_value_set_string (value, self->resource_path);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
pixbuf_paintable_dispose (GObject *object)
{
PixbufPaintable *self = PIXBUF_PAINTABLE (object);
g_clear_pointer (&self->resource_path, g_free);
g_clear_object (&self->anim);
g_clear_object (&self->iter);
if (self->timeout)
{
g_source_remove (self->timeout);
self->timeout = 0;
}
G_OBJECT_CLASS (pixbuf_paintable_parent_class)->dispose (object);
}
static void
pixbuf_paintable_class_init (PixbufPaintableClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->dispose = pixbuf_paintable_dispose;
object_class->get_property = pixbuf_paintable_get_property;
object_class->set_property = pixbuf_paintable_set_property;
g_object_class_install_property (object_class, PROP_RESOURCE_PATH,
g_param_spec_string ("resource-path", "Resource path", "Resource path",
NULL, G_PARAM_READWRITE));
}
GdkPaintable *
pixbuf_paintable_new_from_resource (const char *path)
{
return g_object_new (PIXBUF_TYPE_PAINTABLE,
"resource-path", path,
NULL);
}

View File

@@ -0,0 +1,13 @@
#pragma once
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define PIXBUF_TYPE_PAINTABLE (pixbuf_paintable_get_type ())
G_DECLARE_FINAL_TYPE(PixbufPaintable, pixbuf_paintable, PIXBUF, PAINTABLE, GObject)
GdkPaintable * pixbuf_paintable_new_from_resource (const char *path);
G_END_DECLS

View File

@@ -0,0 +1,34 @@
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

@@ -0,0 +1,43 @@
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;
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

@@ -91,7 +91,7 @@ static struct {
{ G_UNICODE_SCRIPT_LYDIAN, HB_SCRIPT_LYDIAN, NC_("Script", "Lydian") },
{ G_UNICODE_SCRIPT_AVESTAN, HB_SCRIPT_AVESTAN, NC_("Script", "Avestan") },
{ G_UNICODE_SCRIPT_BAMUM, HB_SCRIPT_BAMUM, NC_("Script", "Bamum") },
{ G_UNICODE_SCRIPT_EGYPTIAN_HIEROGLYPHS, HB_SCRIPT_EGYPTIAN_HIEROGLYPHS, NC_("Script", "Egyptian Hieroglpyhs") },
{ G_UNICODE_SCRIPT_EGYPTIAN_HIEROGLYPHS, HB_SCRIPT_EGYPTIAN_HIEROGLYPHS, NC_("Script", "Egyptian Hieroglyphs") },
{ G_UNICODE_SCRIPT_IMPERIAL_ARAMAIC, HB_SCRIPT_IMPERIAL_ARAMAIC, NC_("Script", "Imperial Aramaic") },
{ G_UNICODE_SCRIPT_INSCRIPTIONAL_PAHLAVI, HB_SCRIPT_INSCRIPTIONAL_PAHLAVI, NC_("Script", "Inscriptional Pahlavi") },
{ G_UNICODE_SCRIPT_INSCRIPTIONAL_PARTHIAN, HB_SCRIPT_INSCRIPTIONAL_PARTHIAN, NC_("Script", "Inscriptional Parthian") },
@@ -119,7 +119,7 @@ static struct {
{ G_UNICODE_SCRIPT_DUPLOYAN, HB_SCRIPT_DUPLOYAN, NC_("Script", "Duployan") },
{ G_UNICODE_SCRIPT_ELBASAN, HB_SCRIPT_ELBASAN, NC_("Script", "Elbasan") },
{ G_UNICODE_SCRIPT_GRANTHA, HB_SCRIPT_GRANTHA, NC_("Script", "Grantha") },
{ G_UNICODE_SCRIPT_KHOJKI, HB_SCRIPT_KHOJKI, NC_("Script", "Kjohki") },
{ G_UNICODE_SCRIPT_KHOJKI, HB_SCRIPT_KHOJKI, NC_("Script", "Khojki") },
{ G_UNICODE_SCRIPT_KHUDAWADI, HB_SCRIPT_KHUDAWADI, NC_("Script", "Khudawadi, Sindhi") },
{ G_UNICODE_SCRIPT_LINEAR_A, HB_SCRIPT_LINEAR_A, NC_("Script", "Linear A") },
{ G_UNICODE_SCRIPT_MAHAJANI, HB_SCRIPT_MAHAJANI, NC_("Script", "Mahajani") },
@@ -149,10 +149,40 @@ static struct {
{ G_UNICODE_SCRIPT_NEWA, HB_SCRIPT_NEWA, NC_("Script", "Newa") },
{ G_UNICODE_SCRIPT_OSAGE, HB_SCRIPT_OSAGE, NC_("Script", "Osage") },
{ G_UNICODE_SCRIPT_TANGUT, HB_SCRIPT_TANGUT, NC_("Script", "Tangut") },
{ G_UNICODE_SCRIPT_MASARAM_GONDI, HB_SCRIPT_INVALID, NC_("Script", "Masaram Gondi") },
{ G_UNICODE_SCRIPT_NUSHU, HB_SCRIPT_INVALID, NC_("Script", "Nushu") },
{ G_UNICODE_SCRIPT_SOYOMBO, HB_SCRIPT_INVALID, NC_("Script", "Soyombo") },
{ G_UNICODE_SCRIPT_ZANABAZAR_SQUARE, HB_SCRIPT_INVALID, NC_("Script", "Zanabazar Square") },
{ G_UNICODE_SCRIPT_MASARAM_GONDI, HB_SCRIPT_MASARAM_GONDI, NC_("Script", "Masaram Gondi") },
{ G_UNICODE_SCRIPT_NUSHU, HB_SCRIPT_NUSHU, NC_("Script", "Nushu") },
{ G_UNICODE_SCRIPT_SOYOMBO, HB_SCRIPT_SOYOMBO, NC_("Script", "Soyombo") },
{ G_UNICODE_SCRIPT_ZANABAZAR_SQUARE, HB_SCRIPT_ZANABAZAR_SQUARE, NC_("Script", "Zanabazar Square") },
{ G_UNICODE_SCRIPT_DOGRA, HB_SCRIPT_DOGRA, NC_("Script", "Dogra") },
{ G_UNICODE_SCRIPT_GUNJALA_GONDI, HB_SCRIPT_GUNJALA_GONDI, NC_("Script", "Gunjala Gondi") },
{ G_UNICODE_SCRIPT_HANIFI_ROHINGYA, HB_SCRIPT_HANIFI_ROHINGYA, NC_("Script", "Hanifi Rohingya") },
{ G_UNICODE_SCRIPT_MAKASAR, HB_SCRIPT_MAKASAR, NC_("Script", "Makasar") },
{ G_UNICODE_SCRIPT_MEDEFAIDRIN, HB_SCRIPT_MEDEFAIDRIN, NC_("Script", "Medefaidrin") },
{ G_UNICODE_SCRIPT_OLD_SOGDIAN, HB_SCRIPT_OLD_SOGDIAN, NC_("Script", "Old Sogdian") },
{ G_UNICODE_SCRIPT_SOGDIAN, HB_SCRIPT_SOGDIAN, NC_("Script", "Sogdian") },
#if HB_VERSION_ATLEAST(2,4,0)
{ G_UNICODE_SCRIPT_ELYMAIC, HB_SCRIPT_ELYMAIC, NC_("Script", "Elym") },
{ G_UNICODE_SCRIPT_NANDINAGARI, HB_SCRIPT_NANDINAGARI, NC_("Script", "Nand") },
{ G_UNICODE_SCRIPT_NYIAKENG_PUACHUE_HMONG, HB_SCRIPT_NYIAKENG_PUACHUE_HMONG, NC_("Script", "Rohg") },
{ G_UNICODE_SCRIPT_WANCHO, HB_SCRIPT_WANCHO, NC_("Script", "Wcho") },
#else
{ G_UNICODE_SCRIPT_ELYMAIC, HB_SCRIPT_INVALID, NC_("Script", "Elym") },
{ G_UNICODE_SCRIPT_NANDINAGARI, HB_SCRIPT_INVALID, NC_("Script", "Nand") },
{ G_UNICODE_SCRIPT_NYIAKENG_PUACHUE_HMONG, HB_SCRIPT_INVALID, NC_("Script", "Rohg") },
{ G_UNICODE_SCRIPT_WANCHO, HB_SCRIPT_INVALID, NC_("Script", "Wcho") },
#endif
#if HB_VERSION_ATLEAST(2,6,7)
{ G_UNICODE_SCRIPT_CHORASMIAN, HB_SCRIPT_CHORASMIAN, NC_("Script", "Chorasmian") },
{ G_UNICODE_SCRIPT_DIVES_AKURU, HB_SCRIPT_DIVES_AKURU, NC_("Script", "Dives Akuru") },
{ G_UNICODE_SCRIPT_KHITAN_SMALL_SCRIPT, HB_SCRIPT_KHITAN_SMALL_SCRIPT, NC_("Script", "Khitan small script") },
{ G_UNICODE_SCRIPT_YEZIDI, HB_SCRIPT_YEZIDI, NC_("Script", "Yezidi") },
#else
{ G_UNICODE_SCRIPT_CHORASMIAN, HB_SCRIPT_INVALID, NC_("Script", "Chorasmian") },
{ G_UNICODE_SCRIPT_DIVES_AKURU, HB_SCRIPT_INVALID, NC_("Script", "Dives Akuru") },
{ G_UNICODE_SCRIPT_KHITAN_SMALL_SCRIPT, HB_SCRIPT_INVALID, NC_("Script", "Khitan small script") },
{ G_UNICODE_SCRIPT_YEZIDI, HB_SCRIPT_INVALID, NC_("Script", "Yezidi") },
#endif
};
const char *
@@ -163,7 +193,12 @@ get_script_name (GUnicodeScript script)
for (i = 0; i < G_N_ELEMENTS (scripts); i++)
{
if (scripts[i].script == script)
return g_dpgettext2 (GETTEXT_PACKAGE, "Script", scripts[i].name);
{
if (scripts[i].name)
return g_dpgettext2 (GETTEXT_PACKAGE, "Script", scripts[i].name);
else
return "";
}
}
return NULL;

View File

@@ -110,17 +110,17 @@ set_search_by (GSimpleAction *action,
if (g_str_equal (term, "name"))
{
gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, "Search by name");
gtk_entry_set_placeholder_text (entry, "name");
gtk_entry_set_placeholder_text (entry, "Name");
}
else if (g_str_equal (term, "description"))
{
gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, "Search by description");
gtk_entry_set_placeholder_text (entry, "description");
gtk_entry_set_placeholder_text (entry, "Description");
}
else if (g_str_equal (term, "filename"))
{
gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, "Search by file name");
gtk_entry_set_placeholder_text (entry, "file name");
gtk_entry_set_placeholder_text (entry, "File name");
}
}
@@ -254,7 +254,6 @@ do_search_entry (GtkWidget *do_widget)
{
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *label;
GtkWidget *entry;
GtkWidget *find_button;
GtkWidget *cancel_button;
@@ -268,18 +267,14 @@ do_search_entry (GtkWidget *do_widget)
g_object_weak_ref (G_OBJECT (window), search_entry_destroyed, &window);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
gtk_widget_set_margin_start (vbox, 5);
gtk_widget_set_margin_end (vbox, 5);
gtk_widget_set_margin_top (vbox, 5);
gtk_widget_set_margin_bottom (vbox, 5);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
gtk_widget_set_margin_start (vbox, 18);
gtk_widget_set_margin_end (vbox, 18);
gtk_widget_set_margin_top (vbox, 18);
gtk_widget_set_margin_bottom (vbox, 18);
gtk_window_set_child (GTK_WINDOW (window), vbox);
label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label), "Search entry demo");
gtk_box_append (GTK_BOX (vbox), label);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
gtk_box_append (GTK_BOX (vbox), hbox);
/* Create our entry */

View File

@@ -1,10 +1,10 @@
/* Entry/Delayed Search Entry
/* Entry/Type to Search
*
* GtkSearchEntry provides an entry that is ready for search.
*
* Search entries have their "changed" signal delayed and should
* be used when the searched operation is slow such as loads of
* entries to search, or online searches.
* Search entries have their "search-changed" signal delayed and
* should be used when the search operation is slow, such as big
* datasets to search, or online searches.
*
* GtkSearchBar allows have a hidden search entry that 'springs
* into action' upon keyboard input.
@@ -18,101 +18,69 @@ search_changed_cb (GtkSearchEntry *entry,
{
const char *text;
text = gtk_editable_get_text (GTK_EDITABLE (entry));
g_message ("search changed: %s", text);
gtk_label_set_text (result_label, text ? text : "");
}
static void
changed_cb (GtkEditable *editable)
{
const char *text;
text = gtk_editable_get_text (GTK_EDITABLE (editable));
g_message ("changed: %s", text);
}
static void
search_changed (GtkSearchEntry *entry,
GtkLabel *label)
{
gtk_label_set_text (label, "search-changed");
}
static void
next_match (GtkSearchEntry *entry,
GtkLabel *label)
{
gtk_label_set_text (label, "next-match");
}
static void
previous_match (GtkSearchEntry *entry,
GtkLabel *label)
{
gtk_label_set_text (label, "previous-match");
}
static void
stop_search (GtkSearchEntry *entry,
GtkLabel *label)
{
gtk_label_set_text (label, "stop-search");
}
GtkWidget *
do_search_entry2 (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *box;
GtkWidget *label;
GtkWidget *entry;
GtkWidget *container;
GtkWidget *searchbar;
GtkWidget *button;
GtkWidget *header;
if (!window)
{
window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (window), "Delayed Search Entry");
gtk_window_set_title (GTK_WINDOW (window), "Type to Search");
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
gtk_widget_set_size_request (window, 200, -1);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
header = gtk_header_bar_new ();
gtk_window_set_titlebar (GTK_WINDOW (window), header);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_window_set_child (GTK_WINDOW (window), vbox);
entry = gtk_search_entry_new ();
container = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
gtk_widget_set_halign (container, GTK_ALIGN_CENTER);
gtk_box_append (GTK_BOX (container), entry);
gtk_widget_set_halign (entry, GTK_ALIGN_CENTER);
searchbar = gtk_search_bar_new ();
gtk_search_bar_connect_entry (GTK_SEARCH_BAR (searchbar), GTK_EDITABLE (entry));
gtk_search_bar_set_show_close_button (GTK_SEARCH_BAR (searchbar), FALSE);
gtk_search_bar_set_child (GTK_SEARCH_BAR (searchbar), container);
gtk_search_bar_set_child (GTK_SEARCH_BAR (searchbar), entry);
gtk_box_append (GTK_BOX (vbox), searchbar);
/* Hook the search bar to key presses */
gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (searchbar), window);
/* Help */
label = gtk_label_new ("Start Typing to search");
gtk_box_append (GTK_BOX (vbox), label);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18);
gtk_widget_set_margin_start (box, 18);
gtk_widget_set_margin_end (box, 18);
gtk_widget_set_margin_top (box, 18);
gtk_widget_set_margin_bottom (box, 18);
gtk_box_append (GTK_BOX (vbox), box);
/* Toggle button */
button = gtk_toggle_button_new_with_label ("Search");
button = gtk_toggle_button_new ();
gtk_button_set_icon_name (GTK_BUTTON (button), "system-search-symbolic");
g_object_bind_property (button, "active",
searchbar, "search-mode-enabled",
G_BINDING_BIDIRECTIONAL);
gtk_box_append (GTK_BOX (vbox), button);
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
/* Result */
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
gtk_box_append (GTK_BOX (vbox), hbox);
gtk_box_append (GTK_BOX (box), hbox);
label = gtk_label_new ("Result:");
label = gtk_label_new ("Searching for:");
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
gtk_widget_set_margin_start (label, 6);
gtk_box_append (GTK_BOX (hbox), label);
label = gtk_label_new ("");
@@ -120,28 +88,6 @@ do_search_entry2 (GtkWidget *do_widget)
g_signal_connect (entry, "search-changed",
G_CALLBACK (search_changed_cb), label);
g_signal_connect (entry, "changed",
G_CALLBACK (changed_cb), label);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
gtk_box_append (GTK_BOX (vbox), hbox);
label = gtk_label_new ("Signal:");
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
gtk_widget_set_margin_start (label, 6);
gtk_box_append (GTK_BOX (hbox), label);
label = gtk_label_new ("");
gtk_box_append (GTK_BOX (hbox), label);
g_signal_connect (entry, "search-changed",
G_CALLBACK (search_changed), label);
g_signal_connect (entry, "next-match",
G_CALLBACK (next_match), label);
g_signal_connect (entry, "previous-match",
G_CALLBACK (previous_match), label);
g_signal_connect (entry, "stop-search",
G_CALLBACK (stop_search), label);
}
if (!gtk_widget_get_visible (window))

View File

@@ -57,6 +57,8 @@ do_shortcut_triggers (GtkWidget *do_widget)
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Shortcuts");
gtk_window_set_default_size (GTK_WINDOW (window), 200, -1);
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
list = gtk_list_box_new ();

View File

@@ -8,7 +8,7 @@
<property name="margin-start">50</property>
<property name="margin-end">50</property>
<property name="margin-top">50</property>
<property name="margin-end">50</property>
<property name="margin-bottom">50</property>
<property name="spacing">10</property>
<child>
<object class="GtkButton">

View File

@@ -1,5 +1,5 @@
/* Sliding Puzzle
* #Keywords: GdkPaintable, GdkGesture, game
* #Keywords: GdkPaintable, GdkGesture, GtkShortcutController, game
*
* This demo demonstrates how to use gestures and paintables to create a
* small sliding puzzle game.
@@ -281,7 +281,8 @@ start_puzzle (GdkPaintable *paintable)
gtk_aspect_frame_set_obey_child (GTK_ASPECT_FRAME (frame), FALSE);
/* Add shortcuts so people can use the arrow
* keys to move the puzzle */
* keys to move the puzzle
*/
controller = gtk_shortcut_controller_new ();
gtk_shortcut_controller_set_scope (GTK_SHORTCUT_CONTROLLER (controller),
GTK_SHORTCUT_SCOPE_LOCAL);

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,28 @@
entry.suggestion > popover.menu.background > contents {
padding: 0;
}
entry.suggestion arrow {
-gtk-icon-source: -gtk-icontheme('pan-down-symbolic');
min-height: 16px;
min-width: 16px;
}
entry.suggestion > popover {
margin-top: 6px;
padding: 0;
}
entry.suggestion > popover listview {
margin: 8px 0;
}
entry.suggestion > popover listview > row {
padding: 8px;
}
entry.suggestion > popover listview > row:selected {
outline-color: rgba(1,1,1,0.2);
color: @theme_text_color;
background-color: shade(#f6f5f4, 0.97);
}

View File

@@ -0,0 +1,66 @@
#pragma once
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define MATCH_TYPE_OBJECT (match_object_get_type ())
#define MATCH_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MATCH_TYPE_OBJECT, MatchObject))
#define MATCH_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MATCH_TYPE_OBJECT))
typedef struct _MatchObject MatchObject;
GType match_object_get_type (void) G_GNUC_CONST;
gpointer match_object_get_item (MatchObject *object);
const char * match_object_get_string (MatchObject *object);
guint match_object_get_match_start (MatchObject *object);
guint match_object_get_match_end (MatchObject *object);
guint match_object_get_score (MatchObject *object);
void match_object_set_match (MatchObject *object,
guint start,
guint end,
guint score);
#define SUGGESTION_TYPE_ENTRY (suggestion_entry_get_type ())
#define SUGGESTION_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SUGGESTION_TYPE_ENTRY, SuggestionEntry))
#define SUGGESTION_IS_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SUGGESTION_TYPE_ENTRY))
typedef struct _SuggestionEntry SuggestionEntry;
GType suggestion_entry_get_type (void) G_GNUC_CONST;
GtkWidget* suggestion_entry_new (void);
void suggestion_entry_set_model (SuggestionEntry *self,
GListModel *model);
GListModel * suggestion_entry_get_model (SuggestionEntry *self);
void suggestion_entry_set_factory (SuggestionEntry *self,
GtkListItemFactory *factory);
GtkListItemFactory *
suggestion_entry_get_factory (SuggestionEntry *self);
void suggestion_entry_set_use_filter (SuggestionEntry *self,
gboolean use_ilter);
gboolean suggestion_entry_get_use_filter (SuggestionEntry *self);
void suggestion_entry_set_expression (SuggestionEntry *self,
GtkExpression *expression);
GtkExpression * suggestion_entry_get_expression (SuggestionEntry *self);
void suggestion_entry_set_show_arrow (SuggestionEntry *self,
gboolean show_arrow);
gboolean suggestion_entry_get_show_arrow (SuggestionEntry *self);
typedef void (* SuggestionEntryMatchFunc) (MatchObject *object,
const char *search,
gpointer user_data);
void suggestion_entry_set_match_func (SuggestionEntry *self,
SuggestionEntryMatchFunc func,
gpointer user_data,
GDestroyNotify destroy);
G_END_DECLS

View File

@@ -0,0 +1,166 @@
#include "svgpaintable.h"
#include <gtk/gtk.h>
#include <librsvg/rsvg.h>
struct _SvgPaintable
{
GObject parent_instance;
GFile *file;
RsvgHandle *handle;
};
struct _SvgPaintableClass
{
GObjectClass parent_class;
};
enum {
PROP_FILE = 1,
NUM_PROPERTIES
};
static void
svg_paintable_snapshot (GdkPaintable *paintable,
GdkSnapshot *snapshot,
double width,
double height)
{
SvgPaintable *self = SVG_PAINTABLE (paintable);
cairo_t *cr;
GError *error = NULL;
cr = gtk_snapshot_append_cairo (GTK_SNAPSHOT (snapshot),
&GRAPHENE_RECT_INIT (0, 0, width, height));
if (!rsvg_handle_render_document (self->handle, cr,
&(RsvgRectangle) {0, 0, width, height},
&error))
{
g_error ("%s", error->message);
}
cairo_destroy (cr);
}
static int
svg_paintable_get_intrinsic_width (GdkPaintable *paintable)
{
SvgPaintable *self = SVG_PAINTABLE (paintable);
RsvgDimensionData data;
rsvg_handle_get_dimensions (self->handle, &data);
return data.width;
}
static int
svg_paintable_get_intrinsic_height (GdkPaintable *paintable)
{
SvgPaintable *self = SVG_PAINTABLE (paintable);
RsvgDimensionData data;
rsvg_handle_get_dimensions (self->handle, &data);
return data.height;
}
static void
svg_paintable_init_interface (GdkPaintableInterface *iface)
{
iface->snapshot = svg_paintable_snapshot;
iface->get_intrinsic_width = svg_paintable_get_intrinsic_width;
iface->get_intrinsic_height = svg_paintable_get_intrinsic_height;
}
G_DEFINE_TYPE_WITH_CODE (SvgPaintable, svg_paintable, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
svg_paintable_init_interface))
static void
svg_paintable_init (SvgPaintable *self)
{
}
static void
svg_paintable_dispose (GObject *object)
{
SvgPaintable *self = SVG_PAINTABLE (object);
g_clear_object (&self->file);
g_clear_object (&self->handle);
G_OBJECT_CLASS (svg_paintable_parent_class)->dispose (object);
}
static void
svg_paintable_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
SvgPaintable *self = SVG_PAINTABLE (object);
switch (prop_id)
{
case PROP_FILE:
{
GFile *file = g_value_get_object (value);
RsvgHandle *handle = rsvg_handle_new_from_gfile_sync (file,
RSVG_HANDLE_FLAGS_NONE,
NULL,
NULL);
rsvg_handle_set_dpi (handle, 90);
g_set_object (&self->file, file);
g_set_object (&self->handle, handle);
}
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
svg_paintable_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
SvgPaintable *self = SVG_PAINTABLE (object);
switch (prop_id)
{
case PROP_FILE:
g_value_set_object (value, self->file);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
svg_paintable_class_init (SvgPaintableClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->dispose = svg_paintable_dispose;
object_class->set_property = svg_paintable_set_property;
object_class->get_property = svg_paintable_get_property;
g_object_class_install_property (object_class, PROP_FILE,
g_param_spec_object ("file", "File", "File",
G_TYPE_FILE,
G_PARAM_READWRITE));
}
GdkPaintable *
svg_paintable_new (GFile *file)
{
return g_object_new (SVG_TYPE_PAINTABLE,
"file", file,
NULL);
}

View File

@@ -0,0 +1,13 @@
#pragma once
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define SVG_TYPE_PAINTABLE (svg_paintable_get_type ())
G_DECLARE_FINAL_TYPE (SvgPaintable, svg_paintable, SVG, PAINTABLE, GObject)
GdkPaintable * svg_paintable_new (GFile *file);
G_END_DECLS

View File

@@ -66,6 +66,7 @@ do_tagged_entry (GtkWidget *do_widget)
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Tagged Entry");
gtk_window_set_default_size (GTK_WINDOW (window), 260, -1);
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);

View File

@@ -1,5 +1,5 @@
tag {
margin: 4px;
margin: 4px 0px;
padding: 4px;
border-radius: 4px;
background: lightskyblue;
@@ -17,3 +17,7 @@ tag button {
padding: 0;
border: 1px solid white;
}
entry.tagged {
border-spacing: 4px;
}

View File

@@ -545,6 +545,7 @@ recursive_attach_view (int depth,
return;
child_view = gtk_text_view_new_with_buffer (gtk_text_view_get_buffer (view));
gtk_widget_set_size_request (child_view, 260 - 20 * depth, -1);
/* Frame is to add a black border around each child view */
frame = gtk_frame_new (NULL);
@@ -590,6 +591,8 @@ easter_egg_callback (GtkWidget *button,
g_object_unref (buffer);
window = gtk_window_new ();
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (gtk_widget_get_root (button)));
gtk_window_set_modal (GTK_WINDOW (window), TRUE);
sw = gtk_scrolled_window_new ();
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,

View File

@@ -11,6 +11,7 @@
</object>
<object class="GtkWindow" id="window">
<property name="resizable">0</property>
<property name="title">Themes</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="header">
<child type="start">

Binary file not shown.

View File

@@ -0,0 +1,174 @@
#include "unicode-names.h"
const char *
get_unicode_type_name (GUnicodeType type)
{
const char *names[] = {
"Other, Control",
"Other, Format",
"Other, Not Assigned",
"Other, Private Use",
"Other, Surrogate",
"Letter, Lowercase",
"Letter, Modifier",
"Letter, Other",
"Letter, Titlecase",
"Letter, Uppercase",
"Mark, Spacing",
"Mark, Enclosing",
"Mark, Nonspacing",
"Number, Decimal Digit",
"Number, Letter",
"Number, Other",
"Punctuation, Connector",
"Punctuation, Dash",
"Punctuation, Close",
"Punctuation, Final quote",
"Punctuation, Initial quote",
"Punctuation, Other",
"Punctuation, Open",
"Symbol, Currency",
"Symbol, Modifier",
"Symbol, Math",
"Symbol, Other",
"Separator, Line",
"Separator, Paragraph",
"Separator, Space",
};
if (type < G_N_ELEMENTS (names))
return names[type];
return "Unknown";
}
const char *
get_break_type_name (GUnicodeBreakType type)
{
const char *names[] = {
"Mandatory Break",
"Carriage Return",
"Line Feed",
"Attached Characters and Combining Marks",
"Surrogates",
"Zero Width Space",
"Inseparable",
"Non-breaking (\"Glue\")",
"Contingent Break Opportunity",
"Space",
"Break Opportunity After",
"Break Opportunity Before",
"Break Opportunity Before and After",
"Hyphen",
"Nonstarter",
"Opening Punctuation",
"Closing Punctuation",
"Ambiguous Quotation",
"Exclamation/Interrogation",
"Ideographic",
"Numeric",
"Infix Separator (Numeric)",
"Symbols Allowing Break After",
"Ordinary Alphabetic and Symbol Characters",
"Prefix (Numeric)",
"Postfix (Numeric)",
"Complex Content Dependent (South East Asian)",
"Ambiguous (Alphabetic or Ideographic)",
"Unknown",
"Next Line",
"Word Joiner",
"Hangul L Jamo",
"Hangul V Jamo",
"Hangul T Jamo",
"Hangul LV Syllable",
"Hangul LVT Syllable",
"Closing Parenthesis",
"Conditional Japanese Starter",
"Hebrew Letter",
"Regional Indicator",
"Emoji Base",
"Emoji Modifier",
"Zero Width Joiner",
};
if (type < G_N_ELEMENTS (names))
return names[type];
return "Unknown";
}
const char *
get_combining_class_name (int cclass)
{
const char *classes[256] = { 0, };
classes[0] = "Not Reordered";
classes[1] = "Overlay";
classes[7] = "Nukta";
classes[8] = "Kana Voicing";
classes[9] = "Virama";
classes[10] = "CCC10 (Hebrew)";
classes[11] = "CCC11 (Hebrew)";
classes[12] = "CCC12 (Hebrew)";
classes[13] = "CCC13 (Hebrew)";
classes[14] = "CCC14 (Hebrew)";
classes[15] = "CCC15 (Hebrew)";
classes[16] = "CCC16 (Hebrew)";
classes[17] = "CCC17 (Hebrew)";
classes[18] = "CCC18 (Hebrew)";
classes[19] = "CCC19 (Hebrew)";
classes[20] = "CCC20 (Hebrew)";
classes[21] = "CCC21 (Hebrew)";
classes[22] = "CCC22 (Hebrew)";
classes[23] = "CCC23 (Hebrew)";
classes[24] = "CCC24 (Hebrew)";
classes[25] = "CCC25 (Hebrew)";
classes[26] = "CCC26 (Hebrew)";
classes[27] = "CCC27 (Arabic)";
classes[28] = "CCC28 (Arabic)";
classes[29] = "CCC29 (Arabic)";
classes[30] = "CCC30 (Arabic)";
classes[31] = "CCC31 (Arabic)";
classes[32] = "CCC32 (Arabic)";
classes[33] = "CCC33 (Arabic)";
classes[34] = "CCC34 (Arabic)";
classes[35] = "CCC35 (Arabic)";
classes[36] = "CCC36 (Syriac)";
classes[84] = "CCC84 (Telugu)";
classes[85] = "CCC85 (Telugu)";
classes[103] = "CCC103 (Thai)";
classes[107] = "CCC107 (Thai)";
classes[118] = "CCC118 (Lao)";
classes[122] = "CCC122 (Lao)";
classes[129] = "CCC129 (Tibetan)";
classes[130] = "CCC130 (Tibetan)";
classes[133] = "CCC133 (Tibetan)";
classes[200] = "Attached Below Left";
classes[202] = "Attached Below";
classes[214] = "Attached Above";
classes[216] = "Attached Above Right";
classes[218] = "Below Left";
classes[220] = "Below";
classes[222] = "Below Right";
classes[224] = "Left";
classes[226] = "Right";
classes[228] = "Above Left";
classes[230] = "Above";
classes[232] = "Above Right";
classes[233] = "Double Below";
classes[234] = "Double Above";
classes[240] = "Iota Subscript";
classes[255] = "Invalid";
if (cclass < 256 && classes[cclass] != NULL)
return classes[cclass];
return "Unknown";
}

View File

@@ -0,0 +1,7 @@
#pragma once
#include <glib.h>
const char * get_unicode_type_name (GUnicodeType type);
const char * get_break_type_name (GUnicodeBreakType type);
const char * get_combining_class_name (int cclass);

33
demos/gtk-demo/wind.glsl Normal file
View File

@@ -0,0 +1,33 @@
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);
}

View File

@@ -13,9 +13,6 @@
</section>
</menu>
<template class="IconBrowserWindow" parent="GtkApplicationWindow">
<style>
<class name="devel"/>
</style>
<property name="title" translatable="yes">Icon Browser</property>
<property name="default-width">1024</property>
<property name="default-height">768</property>
@@ -66,11 +63,14 @@
<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" />
<class name="navigation-sidebar"/>
</style>
<property name="model">
<object class="GtkSingleSelection" id="context_model">
@@ -108,11 +108,6 @@
</child>
</object>
</child>
<child>
<object class="GtkSeparator">
<property name="orientation">vertical</property>
</object>
</child>
<child>
<object class="GtkBox" id="content_box">
<property name="orientation">vertical</property>

View File

@@ -1,9 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkWindow" id="window">
<style>
<class name="devel"/>
</style>
<property name="title" translatable="yes">Help</property>
<property name="default-width">720</property>
<property name="default-height">520</property>

View File

@@ -102,12 +102,11 @@ text_buffer_remove_all_tags (GtkTextBuffer *buffer)
}
static void
deserialize_error_func (const GtkCssSection *section,
const GError *error,
gpointer user_data)
deserialize_error_func (const GskParseLocation *start_location,
const GskParseLocation *end_location,
const GError *error,
gpointer user_data)
{
const GtkCssLocation *start_location = gtk_css_section_get_start_location (section);
const GtkCssLocation *end_location = gtk_css_section_get_end_location (section);
NodeEditorWindow *self = user_data;
GtkTextIter start_iter, end_iter;
TextViewError text_view_error;
@@ -171,6 +170,8 @@ text_changed (GtkTextBuffer *buffer,
GskRenderNode *node;
char *text;
GBytes *bytes;
GtkTextIter iter;
GtkTextIter start, end;
g_array_remove_range (self->errors, 0, self->errors->len);
text = get_current_text (self->text_buffer);
@@ -208,8 +209,6 @@ text_changed (GtkTextBuffer *buffer,
gtk_picture_set_paintable (GTK_PICTURE (self->picture), NULL);
}
GtkTextIter iter;
gtk_text_buffer_get_start_iter (self->text_buffer, &iter);
while (!gtk_text_iter_is_end (&iter))
@@ -272,6 +271,10 @@ text_changed (GtkTextBuffer *buffer,
gtk_text_iter_forward_char (&iter);
}
gtk_text_buffer_get_bounds (self->text_buffer, &start, &end);
gtk_text_buffer_apply_tag_by_name (self->text_buffer, "no-hyphens",
&start, &end);
}
static gboolean
@@ -462,7 +465,7 @@ save_response_cb (GtkWidget *dialog,
text = get_current_text (self->text_buffer);
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
g_file_replace_contents (file, text, -1,
g_file_replace_contents (file, text, strlen (text),
NULL, FALSE,
G_FILE_CREATE_NONE,
NULL,
@@ -898,6 +901,11 @@ node_editor_window_init (NodeEditorWindow *self)
"name", "number",
"foreground-rgba", &(GdkRGBA) { 0.8, 0.52, 0.43, 1},
NULL));
gtk_text_tag_table_add (self->tag_table,
g_object_new (GTK_TYPE_TEXT_TAG,
"name", "no-hyphens",
"insert-hyphens", FALSE,
NULL));
self->text_buffer = gtk_text_buffer_new (self->tag_table);
g_signal_connect (self->text_buffer, "changed", G_CALLBACK (text_changed), self);

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