Compare commits

..

85 Commits

Author SHA1 Message Date
Matthias Clasen
f088650181 gtk-demo: Rewrite the text mask demo
Use GtkSnapshot and GskPath instead of cairo for this.
2020-12-27 02:01:38 -05:00
Matthias Clasen
aadcc60583 path fill demo: Use gsk_path_builder_add_layout
We have an api now to hide the cairo use.
2020-12-27 01:10:02 -05:00
Matthias Clasen
2a70b590f1 gsk: Add gsk_path_builder_add_layout
This api makes it easy to turn text into a path that
can be further manipulated. The implementation currently
goes via cairo.
2020-12-27 01:10:02 -05:00
Benjamin Otte
e9d01c1a63 Ottie: Add ottie-editor 2020-12-27 01:12:11 +01:00
Benjamin Otte
e235392894 ottie: Add a snapshot testsuite test
The test takes a lottie file and a timestamp in seconds and produces a
rendernode at that timestamp.

It then serializes that node and compares it via diff(1) with a file
containing the expected output.

This is a lot stricter than it needs to be (because different node files
can generate the same output and updates to the rendering pipeline can
break everything) but I chose this method on purpose because it does a
good job at guarding against accidental changes in other parts of the
code.

It's also better than comparing image output because it avoids
antialiasing artifacts when using curves and things like that.
2020-12-27 01:12:11 +01:00
Benjamin Otte
73904f3034 ottie: Add a command-line tool
Supports:

 * Taking a screenie:
   ottie image file.lottie image.png

 * Recording a rendernode:
   ottie node file.lottie render.node

 * Encoding an image:
   ottie video file.lottie video.webm
2020-12-27 01:12:11 +01:00
Benjamin Otte
c2ed71af7a Ottie: Add 2020-12-27 01:12:11 +01:00
Benjamin Otte
aa2f6345c8 path: Add gsk_path_builder_add_ellipse() 2020-12-27 00:31:18 +01:00
Benjamin Otte
cef1bc9098 path: Change semantics of gtk_path_builder_add_segment()
Allow start >= end to mean that the path continues at the beginning
after reaching the end until it reaches the point at @end.
2020-12-27 00:31:18 +01:00
Benjamin Otte
828ccc51d9 path: Add gsk_path_measure_is_closed () 2020-12-27 00:31:18 +01:00
Benjamin Otte
8397d10c20 path: Add gsk_path_measure_restrict_to_contour() 2020-12-27 00:31:18 +01:00
Matthias Clasen
78d06e58d0 Add gsk_path_measure_get_{path,tolerance}
These are just nice apis to have and avoid having to carry
these around as extra arguments in many places.

This was showing up as inconvenience in writing tests
for the measure apis.
2020-12-27 00:31:18 +01:00
Benjamin Otte
a5e13cc96b xxx path)_fill 2020-12-27 00:31:18 +01:00
Matthias Clasen
776dc54c8a Add gsk_path_get_stroke_bounds
A relatively cheap way to get bounds for the area
that would be affected by stroking a path.
2020-12-27 00:31:18 +01:00
Benjamin Otte
ee6879fba8 testsuite: Add tests for the dasher 2020-12-27 00:31:18 +01:00
Benjamin Otte
14f9395476 path: Add a foreach function that dashes a path 2020-12-27 00:31:18 +01:00
Benjamin Otte
1349cf2454 path: Deal with non-uniformness of progress parameter
The progress is non-uniform, so simple translation of progress doesn't work.
So check if larger and smaller values inch closer towards minimal distance.
2020-12-27 00:31:18 +01:00
Benjamin Otte
d47ebd388c path: Always decompose conics into at least 2 segments
Conics are evil in that their parameter skews towards the center, and if
it's a very flat conic (weight almost equal to 0), then we'd approximate
it with a single segment and not subdivide, which would cause the
parameter to be wildly off around 0.25 or 0.75.

And that would cause offset calculations to fail.
2020-12-27 00:31:18 +01:00
Matthias Clasen
61214221b3 testsuite Add curve tangent tests 2020-12-27 00:31:18 +01:00
Benjamin Otte
7eb4ed8f86 testsuite: Add a test for the conic that got us segment() 2020-12-27 00:31:18 +01:00
Benjamin Otte
92b472fec1 path: Add gsk_curve_segment()
Using split() twice with scaled t values does not work with conics.
2020-12-27 00:31:18 +01:00
Benjamin Otte
7a6b008479 testsuite: Add a test for gsk_curve_decompose() 2020-12-27 00:31:18 +01:00
Benjamin Otte
d8c26172a5 testuite: Add tests for gsk_curve_get_tangent() 2020-12-27 00:31:18 +01:00
Matthias Clasen
da835321a5 testuite: Add tests for gsk_curve_get_point()
Add a few tests for gsk_curve_get_point().

Since GskCurve is not public api, we add gskcurve.c
as source to the test binary.
2020-12-27 00:31:18 +01:00
Benjamin Otte
30635d1cac curve: Split eval() into get_point() and get_tangent()
That's more in line with the get_start/end_point/tangent() functions.

Plus, those calls are independent and we usually want one or the other.
2020-12-27 00:31:18 +01:00
Matthias Clasen
a60b72ba58 Add gsk_curve_get_{start,end}_tangent
Add a way to get the tangents at the start and end of the curve.
This will be used in stroking.
2020-12-27 00:31:18 +01:00
Benjamin Otte
36347892d8 testsuite: Add conics to the random paths 2020-12-27 00:31:18 +01:00
Benjamin Otte
924f0bc2c5 path: Add GskCurve
GskCurve is an abstraction for path operations. It's essentially a
collection of vfuncs per GskPathOperation.

GskStandardContour has been ported to use it where appropriate.
2020-12-27 00:31:18 +01:00
Benjamin Otte
23c5318de1 path: Introduce gskpathop
A gskpathop is a pointer to a graphene_point_t* with the low bits used
to encode the GskPathOperation. It's an easy way to introduce API for
operations.

So far it's just used to replace GskStandardOperation.
2020-12-27 00:31:18 +01:00
Benjamin Otte
678405bd22 WIP: css: Replace border rendering code with GskPath
The weight is wrong still, I need to compute the correct one to get real
45deg circle corners and not just roughly correct ones.
2020-12-27 00:31:18 +01:00
Benjamin Otte
946b76881b WIP: pathbuilder: Add gsk_path_builder_add_rounded_rect()
It works, but does not use a custom contour yet.
2020-12-27 00:31:18 +01:00
Benjamin Otte
061683344f path: Add conic curves
So far this just adds the API, if you use it, you'll get lots of
g_warnings().

This will be fixed in future commits.
2020-12-27 00:31:18 +01:00
Benjamin Otte
af9a85616d path: Rename to gtk_path_builder_add_segment()
It's about bulding paths, not about measuring them.
2020-12-27 00:31:18 +01:00
Benjamin Otte
0f332de3d3 path: Split contours into their own file
I'm not sure I want to keep all contours in one file, but for now that's
how it is.
2020-12-27 00:31:18 +01:00
Benjamin Otte
15e8f2bacc path: Make all private contour APIs take a GskContour
... instead of a path, index tuple.
2020-12-27 00:31:18 +01:00
Benjamin Otte
25f9eadb0d stroke: Add support for dashes
... and hook it up in the node parser and for Cairo rendering.
2020-12-27 00:31:18 +01:00
Matthias Clasen
ced2959cdd gsk: Implement parsing fill and stroke nodes
Make serialization and deserialization work for stroke and
fill nodes.
2020-12-27 00:31:18 +01:00
Benjamin Otte
3c363f00d5 path: Add flags to gsk_path_foreach()
This way we can default to the siplest possible foreach() output - like
cairo_copy_path_flat() decomposing everything into lines - and add flags
to get more and more fancy.

This will be useful to have conics automatically decomposed for Cairo
drawing or if we want to add more line types in the future.
2020-12-27 00:31:18 +01:00
Benjamin Otte
a9ad37ed89 testsuite: Add an in_fill() test 2020-12-27 00:31:18 +01:00
Matthias Clasen
acdf04287d Implement gsk_path_measure_in_fill
Implement this in the obvious way, using the decomposed form
of standard contours. Since the decomposed form is part of the
measure object, this api moves from gsk_path_in_fill to
gsk_path_measure_in_fill.
2020-12-27 00:31:18 +01:00
Benjamin Otte
34725c1207 testsuite: Add a parsing test
This test includes an implementation of a gsk_path_equal() func with
a tolerance that is necessary because parsing does not always work
100% exactly due to floating point rounding, so we can't just
compare the to_string() output.
2020-12-27 00:31:18 +01:00
Matthias Clasen
cb10cf07e6 path: Special-case rects and circles
Write out the commands for rects and circles in a special
way, and add code in the parser to recognize this, so we
can successfully round-trip these through the SVG path format.

The special way - for people who want to use it for debugging -
for now is that we use uppercase "Z" to close standard paths, but
lowercase "z" to close our special paths.

A test is included, but the random path serializations should take care
of it, too.
2020-12-27 00:31:18 +01:00
Matthias Clasen
a7ba2bde86 path: Fix serialization for circles
The svg A can not do a full circle, since it is a two point
parametrization - if the start and end point are the same,
it draws nothing. So, use two arcs.
2020-12-27 00:31:18 +01:00
Benjamin Otte
87b3cb1df8 testsuite: Add librsvg path tests 2020-12-27 00:31:18 +01:00
Matthias Clasen
2478963cbb path: Implement gsk_path_parse
Implement the SVG path syntax to read back the strings
that we generate when serializing paths. The tests for
this code are taken from librsvg.

This includes an elliptical arc implementation according
to the SVG spec. The code is mostly taken from librsvg,
but pretty directly follows the SVG spec implementation
notes. We don't export this, since the parametrization
is inconvenient. We do want an arc_to API, but
these are not the arcs we are looking for.
2020-12-27 00:31:18 +01:00
Matthias Clasen
abbbaef7e8 path: Implement SVG arcs
This is elliptical arc implementation according to the SVG spec.
The code is mostly taken from librsvg, but pretty directly
follows the SVG spec implementation notes.

We don't export this, since the parametrization is inconvenient.
We do want an arc_to API, but these are not the arcs we are
looking for.

It will be used in parsing SVG path syntax.
2020-12-27 00:31:18 +01:00
Matthias Clasen
69177416a0 stroke: Add miter limit
Add a miter limit to GskStroke. This will be needed to
fully implement line joins.

Also introduce the GSK_LINE_JOIN_MITER_CLIP value,
following SVG 2.0. cairo does not have it, so translate
it to plain miter when using cairo.
2020-12-27 00:31:18 +01:00
Matthias Clasen
ff47bfdbcf Documentation typo fixes 2020-12-27 00:31:18 +01:00
Benjamin Otte
120e449bdd testsuite: Add relative path functions
They're making the paths slightly weirder, but they test public API, so
woohoo!
2020-12-27 00:31:18 +01:00
Benjamin Otte
237c37f6c2 pathbuilder: Add relative path commands
And gsk_path_builder_get_current_point().

They will be needed by the string parser.
2020-12-27 00:31:18 +01:00
Benjamin Otte
683729c388 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-12-27 00:31:18 +01:00
Benjamin Otte
9fe71e7dae 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-12-27 00:31:18 +01:00
Benjamin Otte
c74970e6c1 xxx: demo 2020-12-27 00:31:18 +01:00
Benjamin Otte
5225d01504 path: Split GskPathBuilder into its own file
... and add missing API docs.
2020-12-27 00:31:18 +01:00
Benjamin Otte
916d950069 testsuite: Add a test using get_point() and get_closest_point() 2020-12-27 00:31:18 +01:00
Benjamin Otte
76d6fed248 testsuite: Add a test for get_point() 2020-12-27 00:31:18 +01:00
Benjamin Otte
7ff6235ae6 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-12-27 00:31:18 +01:00
Benjamin Otte
9b957c26cb gtk-demo: Add cute maze demo 2020-12-27 00:31:18 +01:00
Benjamin Otte
445b2382e6 testsuite: Add tests for gsk_path_measure_get_closest_point() 2020-12-27 00:31:18 +01:00
Benjamin Otte
790a4201c3 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-12-27 00:31:18 +01:00
Benjamin Otte
00b9af65b5 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-12-27 00:31:18 +01:00
Benjamin Otte
f7c367338c testsuite: Add tests for gsk_path_measure_add_segment() 2020-12-27 00:31:18 +01:00
Benjamin Otte
5d69887618 gtk-demo: Add a text-on-path demo 2020-12-27 00:31:18 +01:00
Benjamin Otte
b658c26a3e xxx: path_fill demo 2020-12-27 00:31:18 +01:00
Benjamin Otte
e4c147cf2f path: Add gsk_path_measure_get_point()
Allows querying the coordinates and direction of any specific point on a
path.
2020-12-27 00:31:18 +01:00
Matthias Clasen
fc2c6f1566 path: Add gsk_path_add_circle()
Adds a circle contour, too.
2020-12-27 00:31:18 +01:00
Benjamin Otte
b0d6130905 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-12-27 00:31:18 +01:00
Benjamin Otte
a0b9238a15 path: Implement gsk_path_to_cairo() using foreach() 2020-12-27 00:31:18 +01:00
Benjamin Otte
801c63494c path: Add gsk_path_foreach() 2020-12-27 00:31:17 +01:00
Benjamin Otte
d2cfe74140 path: Collect flags
We don't need them yet, but maybe later.
2020-12-27 00:31:17 +01:00
Benjamin Otte
a3ac003546 testsuite: Add path tests 2020-12-27 00:31:17 +01:00
Benjamin Otte
483a4773cd pathmeasure: Add gsk_path_measure_add_segment()
This allows chunking paths, weeee.
2020-12-27 00:31:17 +01:00
Benjamin Otte
c82ad0214e path: Add gsk_path_builder_add_path() 2020-12-27 00:31:17 +01:00
Benjamin Otte
207feeb7a9 gsk: Add GskPathMeasure
An object to do measuring operations on paths - determining their
length, cutting off subpaths, things like that.
2020-12-27 00:31:17 +01:00
Benjamin Otte
9a2e4ac9a9 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-12-27 00:31:17 +01:00
Benjamin Otte
2bd3aa3cbe 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-12-27 00:31:17 +01:00
Benjamin Otte
118e41f432 snapshot: Add gtk_snapshot_push_stroke() 2020-12-27 00:31:17 +01:00
Benjamin Otte
2d7897a769 gsk: Add GskStrokeNode 2020-12-27 00:31:17 +01:00
Benjamin Otte
c279e1aa1e gsk: Add GskStroke
It's unused in this commit. This just prepares the new object.
2020-12-27 00:31:17 +01:00
Benjamin Otte
3c91d0be91 demos: Add a simple demo filling a path 2020-12-27 00:31:17 +01:00
Benjamin Otte
e7bbed54b5 snapshot: Add gtk_snapshot_push_fill() 2020-12-27 00:31:17 +01:00
Benjamin Otte
4eb7d68970 gsk: Add GskFillNode
Take a rendernode as source and a GskPath and fill the region in the
path just like cairo_fill() would.
2020-12-27 00:31:17 +01:00
Benjamin Otte
98337f7115 gsk: Add GskPath 2020-12-27 00:31:17 +01:00
Benjamin Otte
08ee6c7acf mediafile: Load extension at startup with GTK_MEDIA
When the GTK_MEDIA env var is set, check at startup that it works, not
only when the first MeidaFile is instantiated.

This has the fortunate side effect that it prints help output for
GTK_MEDIA=help at startup, too.
2020-12-27 00:31:17 +01:00
Benjamin Otte
c815496fe3 gtk: Build as static library first
This allows linking against the static libgtk from the testsuite.

We build the dynamic library by linking all the static libraries into
the final product.
2020-12-27 00:31:16 +01:00
2685 changed files with 287876 additions and 317901 deletions

View File

@@ -1,32 +0,0 @@
# SPDX-FileCopyrightText: 2021 The GTK Authors
# SPDX-License-Identifier: CC0-1.0
root = true
[*]
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
[*.[ch]]
indent_size = 2
indent_style = space
insert_final_newline = true
# For the legacy tabs which still exist in the code:
tab_width = 8
[*.ui]
indent_size = 2
indent_style = space
insert_final_newline = true
[*.xml]
indent_size = 2
indent_style = space
[meson.build]
indent_size = 2
indent_style = space
[*.md]
max_line_length = 80

View File

@@ -7,7 +7,6 @@ stages:
- analysis
- docs
- flatpak
- publish
- deploy
.cache-paths: &cache-paths
@@ -25,8 +24,9 @@ variables:
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:v35"
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:v25"
.only-default:
only:
@@ -43,7 +43,6 @@ style-check-diff:
- .gitlab-ci/run-style-check-diff.sh
.build-fedora-default:
extends: .only-default
image: $FEDORA_IMAGE
artifacts:
when: always
@@ -58,10 +57,8 @@ style-check-diff:
- "${CI_PROJECT_DIR}/_build/report*.xml"
- "${CI_PROJECT_DIR}/_build/report*.html"
- "${CI_PROJECT_DIR}/_build/testsuite/reftests/output/*/*.png"
- "${CI_PROJECT_DIR}/_build/testsuite/tools/output/*/*"
- "${CI_PROJECT_DIR}/_build/testsuite/gsk/compare/*/*/*.png"
- "${CI_PROJECT_DIR}/_build/testsuite/css/output/*/*.syscap"
- "${CI_PROJECT_DIR}/_build_hello/meson-logs"
cache:
key: "$CI_JOB_NAME"
paths:
@@ -79,19 +76,12 @@ fedora-x86_64:
variables:
EXTRA_MESON_FLAGS: "--buildtype=debug --default-library=both"
script:
- .gitlab-ci/show-info-linux.sh
- meson subprojects update
- mkdir _install
- meson --prefix=${CI_PROJECT_DIR}/_install
${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} ${BACKEND_FLAGS} ${FEATURE_FLAGS}
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} ${BACKEND_FLAGS} ${FEATURE_FLAGS}
_build
- meson compile -C _build
- meson install -C _build
- PKG_CONFIG_PATH=${CI_PROJECT_DIR}/_install/lib64/pkgconfig:${CI_PROJECT_DIR}/_install/share/pkgconfig meson setup _build_hello examples/hello
- meson compile -C _build_hello
- ninja -C _build
- .gitlab-ci/run-tests.sh _build x11
- .gitlab-ci/run-tests.sh _build wayland
- .gitlab-ci/run-tests.sh _build waylandgles
- .gitlab-ci/run-tests.sh _build broadway
release-build:
@@ -101,7 +91,6 @@ release-build:
variables:
EXTRA_MESON_FLAGS: "--buildtype=release"
script:
- .gitlab-ci/show-info-linux.sh
- meson subprojects update
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} ${BACKEND_FLAGS} ${FEATURE_FLAGS}
_build
@@ -116,7 +105,6 @@ installed-tests:
EXTRA_MESON_FLAGS: "--prefix=/usr --libdir=/usr/lib64 -Dinstall-tests=true"
G_TEST_ACCESSIBLE: 1
script:
- .gitlab-ci/show-info-linux.sh
- meson subprojects update
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} ${BACKEND_FLAGS} ${FEATURE_FLAGS}
_build
@@ -133,7 +121,6 @@ installed-tests:
.mingw-defaults:
extends: .only-default
stage: build
tags:
- win32-ps
@@ -157,51 +144,6 @@ msys2-mingw64:
MSYSTEM: "MINGW64"
CHERE_INVOKING: "yes"
macos:
extends: .only-default
only:
- branches@GNOME/gtk
stage: build
tags:
- macos
needs: []
before_script:
- bash .gitlab-ci/show-info-osx.sh
- pip3 install --user meson==0.56
- pip3 install --user ninja
- export PATH=/Users/gitlabrunner/Library/Python/3.7/bin:$PATH
- export MESON_FORCE_BACKTRACE=1
script:
- meson -Dx11-backend=false
-Dbroadway-backend=true
-Dmacos-backend=true
-Dmedia-gstreamer=disabled
-Dintrospection=disabled
-Dcpp_std=c++11
-Dpixman:tests=disabled
_build
- ninja -C _build
artifacts:
when: always
paths:
- "${CI_PROJECT_DIR}/_build/meson-logs"
vs2017-x64:
extends: .only-default
# TODO: Uncomment this when ready to merge.
#only:
# - branches@GNOME/gtk
stage: build
tags:
- win32-ps
needs: []
script:
- .gitlab-ci/test-msvc.bat
artifacts:
when: always
paths:
- "${CI_PROJECT_DIR}/_build/meson-logs"
.flatpak-defaults:
image: $FLATPAK_IMAGE
stage: flatpak
@@ -313,37 +255,29 @@ asan-build:
allow_failure: true
reference:
image: $FEDORA_IMAGE
image: $DOCS_IMAGE
stage: docs
needs: []
variables:
EXTRA_MESON_FLAGS: "--buildtype=release --force-fallback-for=gdk-pixbuf,pango"
EXTRA_MESON_FLAGS: "--buildtype=release"
script:
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} -Dgtk_doc=true -Dgdk-pixbuf:gtk_doc=true -Dpango:gtk_doc=true _build
- meson compile -C _build
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} -Dgtk_doc=true _build
- ninja -C _build gdk4-doc gsk4-doc gtk4-doc
- mkdir -p _reference/
- mv _build/docs/reference/gdk/gdk4/ _reference/gdk4/
- mv _build/docs/reference/gdk/gdk4-x11/ _reference/gdk4-x11/
- mv _build/docs/reference/gdk/gdk4-wayland/ _reference/gdk4-wayland/
- mv _build/docs/reference/gsk/gsk4/ _reference/gsk4/
- mv _build/docs/reference/gtk/gtk4/ _reference/gtk4/
- mv _build/subprojects/pango/docs/Pango/ _reference/Pango/
- mv _build/subprojects/pango/docs/PangoCairo/ _reference/PangoCairo/
- mv _build/subprojects/pango/docs/PangoFc/ _reference/PangoFc/
- mv _build/subprojects/pango/docs/PangoFT2/ _reference/PangoFT2/
- mv _build/subprojects/pango/docs/PangoOT/ _reference/PangoOT/
- mv _build/subprojects/pango/docs/PangoXft/ _reference/PangoXft/
- mv _build/subprojects/gdk-pixbuf/docs/gdk-pixbuf/ _reference/gdk-pixbuf/
- mv _build/subprojects/gdk-pixbuf/docs/gdk-pixdata/ _reference/gdk-pixdata/
- mv _build/docs/reference/gdk/html/ _reference/gdk/
- mv _build/docs/reference/gsk/html/ _reference/gsk/
- mv _build/docs/reference/gtk/html/ _reference/gtk/
artifacts:
paths:
- _reference
publish-docs:
stage: publish
pages:
stage: deploy
needs: ['reference']
script:
- "curl -X POST -F token=${PAGES_TRIGGER_TOKEN} -F ref=docs-gtk-org https://gitlab.gnome.org/api/v4/projects/665/trigger/pipeline"
- mv _reference/ public/
artifacts:
paths:
- public
only:
refs:
- master
- master

View File

@@ -17,8 +17,8 @@ branch, as well as their available versions.
### Checklist for Updating a CI image
- [ ] Update the `${image}.Dockerfile` file with the dependencies
- [ ] Run `./run-docker.sh build --base ${image} --version ${number}`
- [ ] Run `./run-docker.sh push --base ${image} --version ${number}`
- [ ] Run `./run-docker.sh build --base ${image} --base-version ${number}`
- [ ] Run `./run-docker.sh push --base ${image} --base-version ${number}`
once the Docker image is built; you may need to log in by using
`docker login` or `podman login`
- [ ] Update the `image` keys in the `.gitlab-ci.yml` file with the new
@@ -30,8 +30,8 @@ branch, as well as their available versions.
- [ ] Write a new `${image}.Dockerfile` with the instructions to set up
a build environment
- [ ] Add the `pip3 install meson` incantation
- [ ] Run `./run-docker.sh build --base ${image} --version ${number}`
- [ ] Run `./run-docker.sh push --base ${image} --version ${number}`
- [ ] Run `./run-docker.sh build --base ${image} --base-version ${number}`
- [ ] Run `./run-docker.sh push --base ${image} --base-version ${number}`
- [ ] Add the new job to `.gitlab-ci.yml` referencing the image
- [ ] Open a merge request with your changes and let it run

View File

@@ -0,0 +1,91 @@
FROM fedora:31
RUN dnf -y install \
adwaita-icon-theme \
atk-devel \
at-spi2-atk-devel \
avahi-gobject-devel \
cairo-devel \
cairo-gobject-devel \
ccache \
clang \
clang-analyzer \
colord-devel \
cups-devel \
dbus-daemon \
dbus-x11 \
dejavu-sans-mono-fonts \
desktop-file-utils \
diffutils \
elfutils-libelf-devel \
fribidi-devel \
gcc \
gcc-c++ \
gdk-pixbuf2-devel \
gdk-pixbuf2-modules \
gettext \
git \
glib2-devel \
glib2-static \
glibc-devel \
glibc-headers \
gnome-desktop-testing \
gobject-introspection-devel \
graphene-devel \
gstreamer1-devel \
gstreamer1-plugins-good \
gstreamer1-plugins-bad-free-devel \
gstreamer1-plugins-base-devel \
gtk-doc \
hicolor-icon-theme \
iso-codes \
itstool \
json-glib-devel \
lcov \
libasan \
libattr-devel \
libcloudproviders-devel \
libepoxy-devel \
libffi-devel \
libmount-devel \
librsvg2 \
libselinux-devel \
libubsan \
libXcomposite-devel \
libXcursor-devel \
libXcursor-devel \
libXdamage-devel \
libXfixes-devel \
libXi-devel \
libXinerama-devel \
libxkbcommon-devel \
libXrandr-devel \
libXrender-devel \
libXtst-devel \
libxslt \
mesa-dri-drivers \
mesa-libEGL-devel \
mesa-libwayland-egl-devel \
ninja-build \
pango-devel \
pcre-devel \
pcre-static \
python3 \
python3-jinja2 \
python3-pip \
python3-pygments \
python3-wheel \
redhat-rpm-config \
sassc \
systemtap-sdt-devel \
vulkan-devel \
wayland-devel \
wayland-protocols-devel \
weston \
weston-libs \
which \
xorg-x11-server-Xvfb \
&& dnf clean all
RUN pip3 install meson==0.55.3

View File

@@ -0,0 +1,12 @@
FROM registry.gitlab.gnome.org/gnome/gtk/fedora-base:v25
RUN dnf -y install pandoc
ARG HOST_USER_ID=5555
ENV HOST_USER_ID ${HOST_USER_ID}
RUN useradd -u $HOST_USER_ID -ms /bin/bash user
USER user
WORKDIR /home/user
ENV LANG C.UTF-8

View File

@@ -1,101 +1,4 @@
FROM fedora:34
RUN dnf -y install \
adwaita-icon-theme \
atk-devel \
at-spi2-atk-devel \
avahi-gobject-devel \
cairo-devel \
cairo-gobject-devel \
ccache \
clang \
clang-analyzer \
clang-tools-extra \
colord-devel \
cups-devel \
dbus-daemon \
dbus-x11 \
dejavu-sans-mono-fonts \
desktop-file-utils \
diffutils \
elfutils-libelf-devel \
fribidi-devel \
gcc \
gcc-c++ \
gdk-pixbuf2-devel \
gdk-pixbuf2-modules \
gettext \
git \
glib2-devel \
glib2-static \
glibc-devel \
glibc-headers \
gnome-desktop-testing \
gobject-introspection-devel \
graphene-devel \
graphviz \
gstreamer1-devel \
gstreamer1-plugins-good \
gstreamer1-plugins-bad-free-devel \
gstreamer1-plugins-base-devel \
hicolor-icon-theme \
iso-codes \
itstool \
json-glib-devel \
lcov \
libasan \
libattr-devel \
libcloudproviders-devel \
libepoxy-devel \
libffi-devel \
libjpeg-turbo-devel \
libmount-devel \
libpng-devel \
librsvg2 \
libselinux-devel \
libtiff-devel \
libubsan \
libXcomposite-devel \
libXcursor-devel \
libXcursor-devel \
libXdamage-devel \
libXfixes-devel \
libXi-devel \
libXinerama-devel \
libxkbcommon-devel \
libXrandr-devel \
libXrender-devel \
libXtst-devel \
libxslt \
mesa-dri-drivers \
mesa-libEGL-devel \
mesa-libGLES-devel \
meson \
ninja-build \
pango-devel \
pcre-devel \
pcre-static \
python3 \
python3-docutils \
python3-gobject \
python3-jinja2 \
python3-markdown \
python3-pip \
python3-pygments \
python3-toml \
python3-typogrify \
python3-wheel \
redhat-rpm-config \
sassc \
systemtap-sdt-devel \
vulkan-devel \
wayland-devel \
wayland-protocols-devel \
weston \
weston-libs \
which \
xorg-x11-server-Xvfb \
&& dnf clean all
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

@@ -24,7 +24,6 @@ flatpak build ${builddir} meson \
-Dbuild-examples=false \
-Dintrospection=disabled \
-Ddemos=true \
-Dprofile=devel \
_flatpak_build
flatpak build ${builddir} ninja -C _flatpak_build install

View File

@@ -1,154 +0,0 @@
/*
* SPDX-FileCopyrightText: 2021 GNOME Foundation
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
/**
* RedHat Fonts taken from https://github.com/RedHatOfficial/RedHatFont
* License: SIL Open Font License 1.1 http://scripts.sil.org/OFL
*/
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif:ital,wght@0,400;0,700;1,400;1,700&family=Red+Hat+Display:ital,wght@0,400;0,500;0,700;0,900;1,400;1,500;1,700;1,900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif:ital,wght@0,400;0,700;1,400;1,700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Source+Code+Pro:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500;1,600&display=swap');
@font-face {
font-family: "RedHatDisplayWeb";
src: local('RedHatDisplayWeb'),
url("RedHatDisplay-Regular.woff2") format("woff2"),
url("RedHatDisplay-Regular.woff") format("woff");
font-style: normal;
font-weight: 400;
font-display: fallback;
}
@font-face {
font-family: "RedHatDisplayWeb";
src: local('RedHatDisplayWeb'),
url("RedHatDisplay-RegularItalic.woff2") format("woff2"),
url("RedHatDisplay-RegularItalic.woff") format("woff");
font-style: italic;
font-weight: 400;
font-display: fallback;
}
@font-face {
font-family: "RedHatDisplayWeb";
src: local('RedHatDisplayWeb'),
url("RedHatDisplay-Medium.woff2") format("woff2"),
url("RedHatDisplay-Medium.woff") format("woff");
font-style: normal;
font-weight: 500;
font-display: fallback;
}
@font-face {
font-family: "RedHatDisplayWeb";
src: local('RedHatDisplayWeb'),
url("RedHatDisplay-MediumItalic.woff2") format("woff2"),
url("RedHatDisplay-MediumItalic.woff") format("woff");
font-style: italic;
font-weight: 500;
font-display: fallback;
}
@font-face {
font-family: "RedHatDisplayWeb";
src: local('RedHatDisplayWeb'),
url("RedHatDisplay-Bold.woff2") format("woff2"),
url("RedHatDisplay-Bold.woff") format("woff");
font-style: normal;
font-weight: 700;
font-display: fallback;
}
@font-face {
font-family: "RedHatDisplayWeb";
src: local('RedHatDisplayWeb'),
url("RedHatDisplay-BoldItalic.woff2") format("woff2"),
url("RedHatDisplay-BoldItalic.woff") format("woff");
font-style: italic;
font-weight: 700;
font-display: fallback;
}
@font-face {
font-family: "RedHatDisplayWeb";
src: local('RedHatDisplayWeb'),
url("RedHatDisplay-Black.woff2") format("woff2"),
url("RedHatDisplay-Black.woff") format("woff");
font-style: normal;
font-weight: 900;
font-display: fallback;
}
@font-face {
font-family: "RedHatDisplayWeb";
src: local('RedHatDisplayWeb'),
url("RedHatDisplay-BlackItalic.woff2") format("woff2"),
url("RedHatDisplay-BlackItalic.woff") format("woff");
font-style: italic;
font-weight: 900;
font-display: fallback;
}
@font-face {
font-family: "RedHatTextWeb";
src: local('RedHatTextWeb'),
url("RedHatText-Regular.woff2") format("woff2"),
url("RedHatText-Regular.woff") format("woff");
font-style: normal;
font-weight: 400;
font-display: fallback;
}
@font-face {
font-family: "RedHatTextWeb";
src: local('RedHatTextWeb'),
url("RedHatText-RegularItalic.woff2") format("woff2"),
url("RedHatText-RegularItalic.woff") format("woff");
font-style: italic;
font-weight: 400;
font-display: fallback;
}
@font-face {
font-family: "RedHatTextWeb";
src: local('RedHatTextWeb'),
url("RedHatText-Medium.woff2") format("woff2"),
url("RedHatText-Medium.woff") format("woff");
font-style: normal;
font-weight: 700;
font-display: fallback;
}
@font-face {
font-family: "RedHatTextWeb";
src: local('RedHatTextWeb'),
url("RedHatText-MediumItalic.woff2") format("woff2"),
url("RedHatText-MediumItalic.woff") format("woff");
font-style: italic;
font-weight: 700;
font-display: fallback;
}
@font-face {
font-family: "RedHatTextWeb";
src: local('RedHatTextWeb'),
url("RedHatText-Bold.woff2") format("woff2"),
url("RedHatText-Bold.woff") format("woff");
font-style: normal;
font-weight: 900;
font-display: fallback;
}
@font-face {
font-family: "RedHatTextWeb";
src: local('RedHatTextWeb'),
url("RedHatText-BoldItalic.woff2") format("woff2"),
url("RedHatText-BoldItalic.woff") format("woff");
font-style: italic;
font-weight: 900;
font-display: fallback;
}

View File

@@ -1,138 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="128"
height="128"
id="svg6843"
sodipodi:version="0.32"
inkscape:version="0.92.4 5da689c313, 2019-01-14"
version="1.0"
sodipodi:docname="gtk-logo.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
inkscape:export-filename="/home/ebassi/Pictures/gtk-logo-256.png"
inkscape:export-xdpi="192"
inkscape:export-ydpi="192">
<defs
id="defs6845">
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="-50 : 600 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="700 : 600 : 1"
inkscape:persp3d-origin="300 : 400 : 1"
id="perspective13" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:zoom="2.8284271"
inkscape:cx="69.874353"
inkscape:cy="64.313526"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:document-units="px"
inkscape:grid-bbox="true"
width="128px"
height="128px"
showguides="true"
inkscape:guide-bbox="true"
inkscape:window-width="1920"
inkscape:window-height="1016"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1">
<inkscape:grid
type="xygrid"
id="grid7947" />
</sodipodi:namedview>
<metadata
id="metadata6848">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
<dc:date />
<dc:creator>
<cc:Agent>
<dc:title />
</cc:Agent>
</dc:creator>
<dc:rights>
<cc:Agent>
<dc:title />
</cc:Agent>
</dc:rights>
<dc:publisher>
<cc:Agent>
<dc:title />
</cc:Agent>
</dc:publisher>
<dc:identifier />
<dc:source />
<dc:relation />
<dc:language />
<dc:subject>
<rdf:Bag />
</dc:subject>
<dc:coverage />
<dc:description />
<dc:contributor>
<cc:Agent>
<dc:title />
</cc:Agent>
</dc:contributor>
<cc:license
rdf:resource="" />
</cc:Work>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<path
sodipodi:nodetypes="ccccc"
id="path6976"
d="M 20.88413,30.82696 L 53.816977,55.527708 L 107.33282,39.060543 L 70.587303,17.177763 L 20.88413,30.82696 z"
style="fill:#729fcf;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:2.12364459;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;display:inline" />
<path
id="path6978"
d="M 22.94243,82.287118 L 20.88413,30.82696 L 53.816977,55.527708 L 53.816977,111.10486 L 22.94243,82.287118 z"
style="fill:#e40000;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:2.12364459;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;display:inline" />
<path
id="path6980"
d="M 53.816977,111.10486 L 103.21619,90.5207 L 107.33282,39.060543 L 53.816977,55.527708 L 53.816977,111.10486 z"
style="fill:#7fe719;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:2.12364459;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;display:inline" />
<path
sodipodi:nodetypes="ccc"
id="path6982"
d="M 23.216626,81.319479 L 70.48573,67.361442 L 103.38422,90.444516"
style="opacity:1;fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:1.25;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
sodipodi:nodetypes="cc"
id="path6984"
d="M 70.434539,17.875593 L 70.434539,66.984877"
style="opacity:1;fill:#babdb6;fill-rule:evenodd;stroke:#ffffff;stroke-width:1.25;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 4.8 KiB

View File

@@ -1,149 +0,0 @@
<!--
SPDX-FileCopyrightText: 2021 GNOME Foundation
SPDX-License-Identifier: LGPL-2.1-or-later
-->
<!DOCTYPE html>
<html lang="en">
<head>
<title>GTK Documentation</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8" />
<meta property="og:site_name" content="https://docs.gtk.org"/>
<meta property="og:title" content="GTK Documentation"/>
<meta property="og:url" content="https://docs.gtk.org"/>
<meta property="og:type" content="website"/>
<meta property="og:description" content="API reference for GTK"/>
<meta name="twitter:title" content="GTK Documentation"/>
<meta name="twitter:url" content="https://docs.gtk.org"/>
<meta name="twitter:card" content="summary"/>
<link rel="canonical" href="https://docs.gtk.org"/>
<link rel="stylesheet" href="style.css" type="text/css" />
<script src="main.js"></script>
<!--[if IE]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
</head>
<body>
<div id="body-wrapper" tabindex="-1">
<nav class="sidebar">
<div class="section">
<img src="gtk-logo.svg" class="logo"/>
</div>
<div class="section">
<h5>Sections</h5>
<div class="links">
<a href="#user-interface">User interface</a>
<a href="#core-libraries">Core libraries</a>
</div>
</div>
</nav>
<button id="btn-to-top" class="hidden"><span class="up-arrow"></span></button>
<section id="main" class="content">
<header>
<h1>GTK Documentation</h1>
</header>
<div class="toggle-wrapper">
<h4 id="user-interface">
User interface
<a href="#user-interface" class="anchor"></a>
</h4>
<div class="docblock">
<h5 id="gdk">GTK</h5>
<p>GTK is the primary library used to construct user interfaces. It
provides user interface controls and signal callbacks to respond to
user actions.</p>
<p><a href="https://docs.gtk.org/gtk4/">GTK API reference</a></p>
</div>
<div class="docblock">
<h5 id="gdk">GSK</h5>
<p>An intermediate layer which provides a rendering API implemented using Cairo, OpenGL or Vulkan.</p>
<p><a href="https://docs.gtk.org/gsk4/">GSK API reference</a></p>
</div>
<div class="docblock">
<h5 id="gdk">GDK</h5>
<p>An intermediate layer which isolates GTK from the details of the windowing system.</p>
<p><a href="https://docs.gtk.org/gdk4/">GDK API reference</a></p>
</div>
<div class="docblock">
<h5 id="pango">Pango</h5>
<p>Pango is the core text and font handling library used in GTK
applications. It has extensive support for the different writing
systems used throughout the world.</p>
<p><a href="https://docs.gtk.org/Pango/">Pango API reference</a></p>
</div>
<div class="docblock">
<h5 id="gdk-pixbuf">GdkPixbuf</h5>
<p>GdkPixbuf is a library for image loading and manipulation.</p>
<p><a href="https://docs.gtk.org/gdk-pixbuf/">GdkPixbuf API reference</a></p>
</div>
<div class="docblock">
<h5 id="cairo">Cairo</h5>
<p>Cairo is a 2D graphics library with support for multiple output
devices. It is designed to produce consistent, high quality output
on all media.</p>
<p><a href="https://www.cairographics.org/manual/" class="external">Cairo API reference</a></p>
</div>
</div>
<div class="toggle-wrapper">
<h4 id="core-libraries" style="display:flex;">
Core libraries
<a href="#core-libraries" class="anchor"></a>
</h4>
<div class="docblock">
<h5 id="glib">GLib</h5>
<p>GLib provides the core application building blocks for libraries
and applications written in C. It provides common data types
used in GTK, the main loop implementation, and a large set of
utility functions for strings and general portability across
different platforms.</p>
<p><a href="https://developer.gnome.org/glib/" class="external">GLib API reference</a></p>
</div>
<div class="docblock">
<h5 id="gobject">GObject</h5>
<p>GObject provides the object system used by GTK.</p>
<p><a href="https://developer.gnome.org/gobject/" class="external">GObject API reference</a></p>
</div>
<div class="docblock">
<h5 id="gio">GIO</h5>
<p>GIO provides a portable, modern and easy-to-use file system
abstraction API for accessing local and remote files; a set of
low and high level abstractions over the <a href="https://www.freedesktop.org/wiki/Software/dbus/" class="external">DBus</a>
IPC specification; an application settings API; portable networking
abstractions; and additional utilities for writing asynchronous
operations without blocking the user interface of your application.</p>
<p><a href="https://developer.gnome.org/gio/" class="external">GIO API reference</a></p>
</div>
</div>
</section>
<footer>
</footer>
</div>
</body>
</html>

View File

@@ -1,140 +0,0 @@
// SPDX-FileCopyrightText: 2021 GNOME Foundation
//
// SPDX-License-Identifier: LGPL-2.1-or-later
// eslint-disable-next-line no-unused-vars
function hasClass(elem, className) {
return elem && elem.classList && elem.classList.contains(className);
}
// eslint-disable-next-line no-unused-vars
function addClass(elem, className) {
if (!elem || !elem.classList) {
return;
}
elem.classList.add(className);
}
// eslint-disable-next-line no-unused-vars
function removeClass(elem, className) {
if (!elem || !elem.classList) {
return;
}
elem.classList.remove(className);
}
function insertAfter(newNode, referenceNode) {
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
}
function onEach(arr, func, reversed) {
if (arr && arr.length > 0 && func) {
var length = arr.length;
var i;
if (reversed !== true) {
for (i = 0; i < length; ++i) {
if (func(arr[i]) === true) {
return true;
}
}
} else {
for (i = length - 1; i >= 0; --i) {
if (func(arr[i]) === true) {
return true;
}
}
}
}
return false;
}
function onEachLazy(lazyArray, func, reversed) {
return onEach(
Array.prototype.slice.call(lazyArray),
func,
reversed);
}
// eslint-disable-next-line no-unused-vars
function hasOwnProperty(obj, property) {
return Object.prototype.hasOwnProperty.call(obj, property);
}
window.addEventListener("load", function() {
"use strict;"
var main = document.getElementById("main");
var btnToTop = document.getElementById("btn-to-top");
function labelForToggleButton(isCollapsed) {
if (isCollapsed) {
return "+";
}
return "\u2212";
}
function createToggle(isCollapsed) {
var toggle = document.createElement("a");
toggle.href = "javascript:void(0)";
toggle.className = "collapse-toggle";
toggle.innerHTML = "[<span class=\"inner\">"
+ labelForToggleButton(isCollapsed)
+ "</span>]";
return toggle;
}
function toggleClicked() {
if (hasClass(this, "collapsed")) {
removeClass(this, "collapsed");
this.innerHTML = "[<span class=\"inner\">"
+ labelForToggleButton(false)
+ "</span>]";
onEachLazy(this.parentNode.getElementsByClassName("docblock"), function(e) {
removeClass(e, "hidden");
});
} else {
addClass(this, "collapsed");
this.innerHTML = "[<span class=\"inner\">"
+ labelForToggleButton(true)
+ "</span>]";
onEachLazy(this.parentNode.getElementsByClassName("docblock"), function(e) {
addClass(e, "hidden");
});
}
}
onEachLazy(document.getElementsByClassName("toggle-wrapper"), function(e) {
let sectionHeader = e.querySelector(".section-header");
let fragmentMatches = sectionHeader !== null && location.hash === "#" + sectionHeader.getAttribute('id');
collapsedByDefault = hasClass(e, "default-hide") && !fragmentMatches;
var toggle = createToggle(collapsedByDefault);
toggle.onclick = toggleClicked;
e.insertBefore(toggle, e.firstChild);
if (collapsedByDefault) {
addClass(toggle, "collapsed");
onEachLazy(e.getElementsByClassName("docblock"), function(d) {
addClass(d, "hidden");
});
}
});
function scrollBackTop(e) {
e.preventDefault();
window.scroll({
top: 0,
behavior: 'smooth',
});
}
function toggleScrollButton() {
if (window.scrollY < 400) {
addClass(btnToTop, "hidden");
} else {
removeClass(btnToTop, "hidden");
}
}
window.onscroll = toggleScrollButton;
btnToTop.onclick = scrollBackTop;
}, false);

View File

@@ -1,747 +0,0 @@
/*
* SPDX-FileCopyrightText: 2021 GNOME Foundation
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
@import url("fonts.css");
/*********************************
* LIGHT THEME
*********************************/
:root {
/* colors */
--text-color: #333;
--text-color-muted: #999;
--primary: rgb(28, 118, 228);
--body-bg: #fff;
--sidebar-primary: rgb(144, 194, 255);
--sidebar-bg: #151515;
--sidebar-selected-bg: var(--primary);
--sidebar-text-color: #fafafa;
--sidebar-padding: 1.5em;
/* boxes, e.g. code blocks */
--box-bg: rgba(135, 135, 135, 0.085);
--box-radius: 0.35rem;
--box-padding: 0.75rem;
--box-margin: 0.75rem 0;
--box-text-color: #111;
/* typography */
--body-font-family: "Noto Serif",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";
--body-font-scale: 0.95;
--body-font-size: calc(var(--body-font-scale) * clamp(16px, 1vw, 20px));
--body-font-weight: normal;
--monospace-font-family: "Source Code Pro", monospace;
--monospace-font-size: calc(0.86 * var(--body-font-size)); /* Monospace fonts are very different in terms of font-sizes. Adjust this value to scale it */
--heading-font-family: "Red Hat Display", var(--body-font-family);
--heading-weight: 900;
--heading-font-scale: 1.05;
--heading-small-font-family: var(--heading-font-family);
--heading-small-weight: 600;
--heading-small-font-scale: 1;
--heading-table-font-family: var(--heading-font-family);
--heading-table-weight: 600;
--heading-docblock-color: #6d6d6d; /* docblocks have headings from source comments. we want them to differ.*/
--heading-docblock-scale: 0.9; /* docblocks have headings from source comments. we want them to differ.*/
--symbol-font-family: var(--heading-font-family);
--symbol-font-weight: 500;
--symbol-font-scale: 1;
--table-font-size: 0.92em; /* Tables often contain lots information. It's better to scale them down a big to get more sutff fitted inside */
/* misc */
--prefered-content-width: 90ch; /* The preferred width for the readable content */
--anchor-sign: "#";
}
/*********************************
* DARK THEME (overrides)
*********************************/
@media (prefers-color-scheme: dark) {
:root {
--primary: rgb(144, 194, 255);
--text-color: #f6f6f6;
--text-color-muted: #686868;
--body-bg: #121212;
--sidebar-primary: rgb(144, 194, 255);
--sidebar-bg: #1e1e1e;
--sidebar-selected-bg: rgb(17, 112, 228);
--sidebar-text-color: #fafafa;
--box-bg: rgba(135, 135, 135, 0.1);
--box-text-color: #fff;
--heading-docblock-color: #b7b7b7;
}
/* fix dark theme syntax highlighting with a filter (for now) */
.highlight pre span {
filter: brightness(6);
}
}
/*********************************
* GENERAL STYLING
*********************************/
*,
*:before,
*:after {
box-sizing: border-box;
}
::-moz-selection {
color: white;
background: var(--primary);
}
::selection {
color: white;
background: var(--primary);
}
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-thumb {
border-radius: 10px;
background: rgba(128, 128, 128, 0.6);
}
::-webkit-scrollbar-thumb:hover {
background: rgba(128, 128, 128, 1);
}
::-webkit-scrollbar-track {
background: rgba(128, 128, 128, 0.15);
}
* {
scrollbar-width: initial;
}
body {
font: 16px/1.5 var(--body-font-family);
font-weight: var(--body-font-weight);
font-size: var(--body-font-size);
margin: 0;
padding: 0;
position: relative;
-webkit-font-feature-settings: "kern", "liga";
-moz-font-feature-settings: "kern", "liga";
font-feature-settings: "kern", "liga";
color: var(--text-color);
background: var(--body-bg);
}
h1, h2, h3, h4, h5, h6 {
font-family: var(--heading-font-family);
font-weight: var(--heading-weight);
margin: 1.75em 0 0.75em 0;
display: flex;
align-items: center;
}
h1 {
font-size: calc(1.75em * var(--heading-font-scale));
}
header h1 {
margin-top: 0;
}
h2 {
font-size: calc(1.4em * var(--heading-font-scale));
}
h3 {
font-size: calc(1.2em * var(--heading-font-scale));
}
header h3 {
color: var(--text-color-muted);
margin-bottom: 0;
}
h4, h5 {
font-size: calc(1em * var(--heading-font-scale));
}
h6 {
font-size: calc(1em * var(--heading-small-font-scale));
font-family: var(--heading-small-font-family);
font-weight: var(--heading-small-weight);
}
ol, ul {
padding-left: 1rem;
}
ul ul, ol ul, ul ol, ol ol {
margin-bottom: .6em;
}
p {
margin: 0 0 .6em 0;
}
a {
color: var(--primary);
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
summary {
outline: none;
}
blockquote {
border-left: 3px solid var(--primary);
background: var(--box-bg);
padding: var(--box-padding);
border-radius: var(--box-radius);
margin: var(--box--margin);
}
code,
pre {
font-family: var(--monospace-font-family);
font-size: var(--monospace-font-size);
color: var(--box-text-color);
}
pre {
background: var(--box-bg);
padding: var(--box-padding);
border-radius: var(--box-radius);
overflow: auto;
}
code {
background: var(--box-bg);
padding: 0 0.35em;
border-radius: 0.35rem;
word-break: break-word;
}
a > code {
color: var(--primary);
}
pre pre,
pre code {
padding: 0;
margin: 0;
font-size: 1em;
background: none;
color: inherit;
}
h1 code, h2 code, h3 code, h4 code, h5 code, h6 code {
font-family: inherit;
font-weight: inherit;
font-size: 0.85em;
}
strong, b {
font-weight: 600;
}
/* fix unwanted margins in tables, code, lists and blockquotes */
li > *:first-child,
li > *:first-child > *:first-child,
li > *:first-child > *:first-child > *:first-child,
td > *:first-child,
td > *:first-child > *:first-child,
td > *:first-child > *:first-child > *:first-child,
pre > *:first-child,
pre > *:first-child > *:first-child,
pre > *:first-child > *:first-child > *:first-child,
blockquote > *:first-child,
blockquote > *:first-child > *:first-child,
blockquote > *:first-child > *:first-child > *:first-child {
margin-top: 0;
}
li > *:last-child,
li > *:last-child > *:last-child,
li > *:last-child > *:last-child > *:last-child,
td > *:last-child,
td > *:last-child > *:last-child,
td > *:last-child > *:last-child > *:last-child,
pre > *:last-child,
pre > *:last-child > *:last-child,
pre > *:last-child > *:last-child > *:last-child,
blockquote > *:last-child,
blockquote > *:last-child > *:last-child,
blockquote > *:last-child > *:last-child > *:last-child {
margin-bottom: 0;
}
/*********************************
* PAGE STRUCTURE
*********************************/
#body-wrapper {
display: flex;
flex-wrap: nowrap;
flex-direction: row;
}
#body-wrapper:focus {
outline: none;
}
#main {
position: relative;
flex-grow: 1;
min-width: 0;
box-shadow: 0 0 134px rgba(0, 0, 0, 0.1);
}
footer {
width: 100%;
display: none;
}
/*********************************
* Button
*********************************/
#btn-to-top {
position: fixed;
bottom: 12px;
right: 32px;
z-index: 1000;
border-radius: 50%;
width: 42px;
height: 42px;
border: 1px solid var(--primary);
background: var(--box-bg);
color: var(--text-color);
cursor: pointer;
text-transform: none;
}
#btn-to-top > .up-arrow:after {
content: "🡅"
}
/*********************************
* SIDEBAR
*********************************/
.sidebar {
scrollbar-width: thin;
background: var(--sidebar-bg);
border-right: 1px solid var(--sidebar-bg);
min-width: 40ch;
padding: var(--sidebar-padding);
color: var(--sidebar-text-color);
position: sticky;
top: 0;
z-index: 2;
height: 100vh;
overflow-y: auto;
}
.sidebar a,
.sidebar a:hover {
text-decoration: none;
}
.sidebar .logo {
display: block;
margin: 2rem auto 0 auto;
width: 70%;
}
.sidebar .section > ul > li {
margin-right: -10px;
}
.sidebar .section h3, .sidebar .section h5 {
text-align: left;
padding-left: 0.5rem;
padding-right: 0.5rem;
font-weight: var(--heading-weight);
}
.sidebar .section h5 {
font-size: 1em;
margin-bottom: 0.5em;
}
.sidebar .namespace > h3 {
margin-bottom: 0;
padding: 0;
font-size: 1.5em;
text-transform: uppercase;
font-weight: 900;
}
.sidebar .namespace > p {
font-size: 0.9em;
opacity: 0.8;
padding-left: 0.5rem;
}
.sidebar .section {
padding-left: 0.5rem;
padding-right: 0.5rem;
}
.sidebar .links {
margin-bottom: 1rem;
}
.sidebar .section a {
display: block;
text-overflow: ellipsis;
overflow: hidden;
transition: background-color 150ms ease;
color: var(--sidebar-primary);
border-radius: var(--box-radius);
padding: 0.2rem 0.5rem;
margin-bottom: 0.15rem;
}
.sidebar .section a:hover {
background-color: rgba(127, 127, 127, 0.2);
color: var(--sidebar-text-color);
}
.sidebar .section a.current {
background-color: var(--sidebar-selected-bg);
color: white;
}
.sidebar .search {
box-sizing: border-box;
text-align: center;
}
.sidebar .search input[type="text"] {
border-color: transparent;
width: 100%;
border: 1px solid #ccc;
border-radius: 50px;
padding: 6px 12px;
display: inline-block;
font-size: 80%;
box-shadow: inset 0 1px 3px #ddd;
transition: border .3s linear;
}
/*********************************
* ANCHORS & TOGGLERS
*********************************/
.anchor,
.md-anchor {
position: relative;
z-index: 1;
text-decoration: none;
padding: 0 0.5em;
color: var(--text-color-muted);
}
.anchor:hover,
.md-anchor:hover {
color: var(--primary);
}
.anchor:not([href]),
.md-anchor:not([href]) {
display: none;
}
.anchor:before,
.md-anchor:before {
content: var(--anchor-sign); /*'§'*/
}
.toggle-wrapper {
position: relative;
}
.collapse-toggle {
position: absolute;
right: 0;
left: -2em;
white-space: nowrap;
text-decoration: none;
font-size: 0.8em;
color: transparent;
}
.collapse-toggle > .inner {
width: 1rem;
height: 1rem;
border-radius: calc(0.75 * var(--box-radius));
display: inline-flex;
justify-content: center;
align-items: center;
text-align: center;
vertical-align: middle;
color: var(--box-text-color);
position: relative;
left: -0.25rem;
font-family: monospace;
font-size: 0.7rem;
font-weight: bold;
background: var(--box-bg);
}
/*********************************
* UTILITY
*********************************/
.deprecated > h6 > a {
opacity: 0.65;
}
.hidden {
display: none !important;
}
/*********************************
* CONTENT STYLING
*********************************/
.content {
padding: 2em 4em;
overflow: visible;
max-width: calc(var(--prefered-content-width) + 8em);
}
.content table:not(.table-display) {
border-spacing: 0 0.25rem;
}
.content td {
vertical-align: top;
}
.content td:first-child {
padding-right: 1rem;
}
.content td p:first-child {
margin-top: 0;
}
.content td h1, .content td h2 {
margin-left: 0;
font-size: 1.1em;
}
.content tr:first-child td {
border-top: 0;
}
kbd {
display: inline-block;
padding: 3px 5px;
font: 15px monospace;
line-height: 10px;
vertical-align: middle;
border: solid 1px;
border-radius: 3px;
box-shadow: inset 0 -1px 0;
cursor: default;
}
.content tr:first-child {
border-bottom: 1px solid rgba(0, 0, 0, 0.35);
}
.content td {
vertical-align: top;
}
.content td:first-child {
padding-right: 1rem;
}
.content td p:first-child {
margin-top: 0;
}
.content td h4, .content td h5 {
margin-left: 0;
font-size: 1.1em;
}
.content tr:first-child td {
border-top: 0;
}
.srclink {
color: var(--text-color-muted);
font-size: 1rem;
font-weight: var(--body-font-weight);
flex-grow: 0;
text-decoration: none;
margin-left: auto;
position: relative;
z-index: 1;
}
.meta tr > td:not(:first-child) {
width: 100%;
}
.meta tr > td:first-child {
white-space: nowrap;
}
/*********************************
* DOCBLOCK STYLING
*********************************/
.docblock {
position: relative;
text-align: left;
}
.docblock h1 {
font-size: calc(1.3em * var(--heading-docblock-scale) * var(--heading-font-scale));
}
.docblock h2 {
font-size: calc(1.2em * var(--heading-docblock-scale) * var(--heading-font-scale));
}
.docblock h3 {
font-size: calc(1.1em * var(--heading-docblock-scale) * var(--heading-font-scale));
}
.docblock h4 {
font-size: calc(1.05em * var(--heading-docblock-scale) * var(--heading-font-scale));
}
.docblock h1,
.docblock h2,
.docblock h3,
.docblock h4,
.docblock h5,
.docblock h6 {
color: var(--heading-docblock-color)
}
.docblock table {
margin: .25em 0;
max-width: 100%;
font-size: var(--table-font-size);
}
.docblock table td {
padding: .25em;
}
.docblock table th {
padding: .25em;
text-align: left;
font-family: var(--heading-table-font-family);
font-weight: var(--heading-table-weight);
}
.docblock table tr th:first-child,
.docblock table tr td:first-child {
padding-left: 0;
}
.docblock table tr th:last-child,
.docblock table tr td:last-child {
padding-right: 0;
}
table.enum-members,
table.results {
border-radius: var(--box-radius);
border: 1px solid var(--text-color-muted);
border-spacing: 0 0 !important;
font-size: 80%;
}
table.enum-members tr th,
table.results tr th {
border-top-color: var(--body-bg);
background-color: var(--box-bg);
border-bottom: 1px solid var(--text-color-muted);
}
table.enum-members tr th:first-child,
table.enum-members tr td:first-child {
min-width: 25em;
padding-left: .5em;
}
table.results tr th:first-child,
table.results tr td:first-child {
padding-left: .5em;
}
table.enum-members tr th:last-child,
table.enum-members tr td:last-child,
table.results tr th:last-child,
table.results tr td:last-child {
max-width: 35em;
padding-right: .5em;
}
table.results tr td code {
font-size: 100%;
}
.docblock ul li,
.docblock ol li {
padding-top: 0.15rem;
padding-bottom: 0.15rem;
}
.docblock ul.type {
list-style: none;
}
.docblock ul.type li::before {
content: "»";
color: var(--text-color);
display: inline-block;
width: 1em;
margin-left: -1em;
}
/**************************
RESPONSIVENESS
**************************/
@media (max-width: 700px) {
body {
padding-top: 0px;
}
#body-wrapper {
flex-direction: column;
overflow: hidden;
}
#main {
width: 100%;
padding: 2rem;
}
.sidebar {
position: static;
height: initial;
order: 1;
}
}

View File

@@ -32,7 +32,7 @@ while (($# > 0)); do
list) list=1;;
help) print_help=1;;
--base|-b) read_arg base "$@" || shift;;
--version|-v) read_arg base_version "$@" || shift;;
--base-version) read_arg base_version "$@" || shift;;
--no-login) no_login=1;;
*) echo -e "\e[1;31mERROR\e[0m: Unknown option '$1'"; exit 1;;
esac

View File

@@ -8,8 +8,7 @@ builddir=$1
backend=$2
# Ignore memory leaks lower in dependencies
export LSAN_OPTIONS=suppressions=$srcdir/lsan.supp:print_suppressions=0
export G_SLICE=always-malloc
export LSAN_OPTIONS=suppressions=$srcdir/lsan.supp
case "${backend}" in
x11)
@@ -44,24 +43,6 @@ case "${backend}" in
kill ${compositor}
;;
waylandgles)
export XDG_RUNTIME_DIR="$(mktemp -p $(pwd) -d xdg-runtime-XXXXXX)"
weston --backend=headless-backend.so --socket=wayland-6 --idle-time=0 &
compositor=$!
export WAYLAND_DISPLAY=wayland-6
meson test -C ${builddir} \
--timeout-multiplier "${MESON_TEST_TIMEOUT_MULTIPLIER}" \
--print-errorlogs \
--setup=${backend} \
--suite=gtk \
--no-suite=gsk-compare-broadway
exit_code=$?
kill ${compositor}
;;
broadway)
export XDG_RUNTIME_DIR="$(mktemp -p $(pwd) -d xdg-runtime-XXXXXX)"
@@ -80,12 +61,6 @@ case "${backend}" in
exit_code=0
kill ${server}
;;
*)
echo "Failed to add ${backend} to .gitlab-ci/run-tests.sh"
exit 1
;;
esac
cd ${builddir}

View File

@@ -1,5 +0,0 @@
#! /bin/sh
. /etc/os-release
echo $PRETTY_NAME

View File

@@ -1,8 +0,0 @@
#!/bin/bash
set -eux -o pipefail
xcodebuild -version || :
xcodebuild -showsdks || :
system_profiler SPSoftwareDataType || :

View File

@@ -15,7 +15,7 @@ meson \
-Dx11-backend=true \
-Dwayland-backend=true \
-Dbroadway-backend=true \
-Dvulkan=enabled \
-Dvulkan=yes \
-Dprofiler=true \
--werror \
${EXTRA_MESON_FLAGS:-} \

View File

@@ -1,14 +0,0 @@
@echo on
:: vcvarsall.bat sets various env vars like PATH, INCLUDE, LIB, LIBPATH for the
:: specified build architecture
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x64
@echo on
:: FIXME: make warnings fatal
pip3 install --upgrade --user meson==0.56.2 || goto :error
meson -Dmedia-gstreamer=disabled _build || goto :error
ninja -C _build || goto :error
goto :EOF
:error
exit /b 1

View File

@@ -40,7 +40,7 @@ export CCACHE_DIR="${CCACHE_BASEDIR}/_ccache"
# https://gitlab.gnome.org/GNOME/gtk/-/issues/2243
# https://gitlab.gnome.org/GNOME/gtk/-/issues/3002
if ! pkg-config --atleast-version=2.66.0 glib-2.0; then
if ! pkg-config --atleast-version=2.65.0 glib-2.0; then
git clone https://gitlab.gnome.org/GNOME/glib.git _glib
meson setup _glib_build _glib
meson compile -C _glib_build
@@ -48,7 +48,7 @@ if ! pkg-config --atleast-version=2.66.0 glib-2.0; then
fi
pkg-config --modversion glib-2.0
if ! pkg-config --atleast-version=1.49.3 pango; then
if ! pkg-config --atleast-version=1.47.0 pango; then
git clone https://gitlab.gnome.org/GNOME/pango.git _pango
meson setup _pango_build _pango
meson compile -C _pango_build

View File

@@ -1,13 +1,4 @@
<!--
Please, read the CONTRIBUTING.md guide on how to file a new issue.
https://gitlab.gnome.org/GNOME/gtk/-/blob/master/CONTRIBUTING.md
-->
## Steps to reproduce
<!--
Please, explain the sequence of actions necessary to reproduce the
bug
-->
1. ...
2. ...
@@ -41,8 +32,5 @@
## Additional information
<!--
- Screenshots or screen recordings are useful for visual errors
- Attaching a screenshot or a video without explaining the current
behavior and the actions necessary to reproduce the bug will lead
to the bug being closed
- Please report any warning or message printed on the terminal
-->

View File

@@ -1,14 +1,4 @@
<!--
Please, read the CONTRIBUTING.md guide on how to file a new issue.
https://gitlab.gnome.org/GNOME/gtk/-/blob/master/CONTRIBUTING.md
-->
## Steps to reproduce
<!--
Please, explain the sequence of actions necessary to reproduce the
crash
-->
1. ...
2. ...

9712
NEWS

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -10,12 +10,10 @@ GTK is a multi-platform toolkit for creating graphical user interfaces.
Offering a complete set of widgets, GTK is suitable for projects ranging
from small one-off projects to complete application suites.
GTK is a free and open-source software project. The licensing terms
for GTK, the GNU LGPL, allow it to be used by all developers, including those
developing proprietary software, without any license fees or royalties.
GTK is hosted by the GNOME project (thanks!) and used by a wide variety
of applications and projects.
GTK is free software and part of the GNU Project. However, the
licensing terms for GTK, the GNU LGPL, allow it to be used by all
developers, including those developing proprietary software, without any
license fees or royalties.
The official download location
@@ -34,16 +32,9 @@ Discussion forum
- https://discourse.gnome.org/c/platform/core/
Nightly documentation can be found at
- Gtk: https://gnome.pages.gitlab.gnome.org/gtk/gtk4/
- Gdk: https://gnome.pages.gitlab.gnome.org/gtk/gdk4/
- Gsk: https://gnome.pages.gitlab.gnome.org/gtk/gsk4/
Nightly flatpaks of our demos can be installed from the
[GNOME Nightly](https://wiki.gnome.org/Apps/Nightly) repository:
- `flatpak remote-add --if-not-exists gnome-nightly https://nightly.gnome.org/gnome-nightly.flatpakrepo`
- `flatpak install gnome-nightly org.gtk.Demo4`
- `flatpak install gnome-nightly org.gtk.WidgetFactory4`
- `flatpak install gnome-nightly org.gtk.IconBrowser4`
- Gtk: https://gnome.pages.gitlab.gnome.org/gtk/gtk/
- Gdk: https://gnome.pages.gitlab.gnome.org/gtk/gdk/
- Gsk: https://gnome.pages.gitlab.gnome.org/gtk/gsk/
Building and installing
-----------------------
@@ -114,7 +105,7 @@ can be found in the file:
docs/reference/gtk/html/gtk-building.html
```
Or [online](https://docs.gtk.org/gtk4/building.html)
Or [online](https://developer.gnome.org/gtk4/stable/gtk-building.html)
How to report bugs
------------------
@@ -153,17 +144,14 @@ Contributing to GTK
Please, follow the [contribution guide](./CONTRIBUTING.md) to know how to
start contributing to GTK.
If you want to support GTK financially, please consider donating to
the GNOME project, which runs the infrastructure hosting GTK.
Release notes
-------------
The release notes for GTK are part of the migration guide in the API
reference. See:
- [3.x release notes](https://developer.gnome.org/gtk3/stable/gtk-migrating-2-to-3.html)
- [4.x release notes](https://docs.gtk.org/gtk4/migrating-3to4.html)
- [3.x release notes](https://developer.gnome.org/gtk3/unstable/gtk-migrating-2-to-3.html)
- [4.x release notes](https://developer.gnome.org/gtk4/unstable/gtk-migrating-3-to-4.html)
Licensing terms
---------------

View File

@@ -1,43 +0,0 @@
diff -ur lua-5.1.4/src/Makefile lua-5.1.4-new/src/Makefile
--- lua-5.1.4/src/Makefile 2008-01-19 20:37:58.000000000 +0100
+++ lua-5.1.4-new/src/Makefile 2012-02-23 18:26:43.000000000 +0100
@@ -23,6 +23,7 @@
PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
LUA_A= liblua.a
+LUA_SO= liblua.so
CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \
lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \
lundump.o lvm.o lzio.o
@@ -36,7 +37,7 @@
LUAC_O= luac.o print.o
ALL_O= $(CORE_O) $(LIB_O) $(LUA_O) $(LUAC_O)
-ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T)
+ALL_T= $(LUA_A) $(LUA_SO) $(LUA_T) $(LUAC_T)
ALL_A= $(LUA_A)
default: $(PLAT)
@@ -51,6 +52,11 @@
$(AR) $@ $?
$(RANLIB) $@
+$(LUA_SO): $(CORE_O) $(LIB_O)
+ $(CC) -shared -ldl -Wl,-soname,$(LUA_SO).$(V) -o $@.$(R) $? -lm $(MYLDFLAGS)
+ ln -sf $(LUA_SO).$(R) $(LUA_SO).$(V)
+ ln -sf $(LUA_SO).$(R) $(LUA_SO)
+
$(LUA_T): $(LUA_O) $(LUA_A)
$(CC) -o $@ $(MYLDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
--- lua-5.1.4/Makefile 2008-08-12 02:40:48.000000000 +0200
+++ lua-5.1.4-new/Makefile 2012-02-23 19:06:32.000000000 +0100
@@ -53,7 +53,7 @@
all: $(PLAT)
$(PLATS) clean:
- cd src && $(MAKE) $@
+ cd src && $(MAKE) $@ V=$(V) R=$(R)
test: dummy
src/lua test/hello.lua

View File

@@ -35,15 +35,15 @@
"modules" : [
{
"name" : "wayland",
"buildsystem" : "meson",
"buildsystem" : "autotools",
"builddir" : true,
"config-opts" : [
"-Ddocumentation=false"
"--disable-documentation"
],
"sources" : [
{
"type" : "git",
"url" : "https://gitlab.freedesktop.org/wayland/wayland.git"
"url" : "https://github.com/wayland-project/wayland.git"
}
]
},
@@ -93,77 +93,6 @@
}
]
},
{
"name": "boost",
"buildsystem": "simple",
"build-commands": [
"./bootstrap.sh --prefix=/app --with-libraries=date_time,filesystem,iostreams,locale,regex,system,thread,python,program_options,test,serialization",
"./b2 --build-type=minimal link=shared -j $FLATPAK_BUILDER_N_JOBS",
"./b2 --build-type=minimal link=shared install"
],
"sources": [
{
"type": "archive",
"url": "https://boostorg.jfrog.io/artifactory/main/release/1.69.0/source/boost_1_69_0.tar.bz2",
"sha256": "8f32d4617390d1c2d16f26a27ab60d97807b35440d45891fa340fc2648b04406"
}
]
},
{
"name": "lua-5.1",
"buildsystem": "simple",
"build-commands": [
"make -j $FLATPAK_BUILDER_N_JOBS CFLAGS=\"$CFLAGS -fPIC -DLUA_USE_LINUX\" linux",
"make INSTALL_TOP=$FLATPAK_DEST TO_LIB='liblua.a liblua.so.5.1.5' install",
"ln -sf liblua.so.5.1.5 $FLATPAK_DEST/lib/liblua.so",
"ln -sf liblua.so.5.1.5 $FLATPAK_DEST/lib/liblua.so.5.1",
"install -Dm0644 etc/lua.pc $FLATPAK_DEST/lib/pkgconfig/lua.pc",
"ln -sf lua.pc $FLATPAK_DEST/lib/pkgconfig/lua51.pc",
"ln -sf lua.pc $FLATPAK_DEST/lib/pkgconfig/lua5.1.pc",
"ln -sf lua.pc $FLATPAK_DEST/lib/pkgconfig/lua-5.1.pc"
],
"sources": [
{
"type": "archive",
"url": "https://www.lua.org/ftp/lua-5.1.5.tar.gz",
"sha256": "2640fc56a795f29d28ef15e13c34a47e223960b0240e8cb0a82d9b0738695333"
},
{
"type": "patch",
"path": "lua-5.1.5-so.patch"
},
{
"type": "shell",
"commands": [
"sed -i \"s|/usr/local|$FLATPAK_DEST|\" etc/lua.pc src/luaconf.h"
]
}
],
"cleanup": [
"*.a",
"/bin",
"/include",
"/lib/pkgconfig",
"/man"
]
},
{
"name" : "highlight",
"buildsystem" : "simple",
"builddir" : true,
"build-commands" : [
"sed -i -e 's#^PREFIX = /usr#PREFIX = /app#' makefile",
"make",
"make install"
],
"sources" : [
{
"type" : "archive",
"url" : "http://www.andre-simon.de/zip/highlight-4.0.tar.bz2",
"sha256" : "f40dcba26e011a2c67df874f4d9b0238c2c6b065163ce8de3d8371b9dfce864d"
}
]
},
{
"name" : "gtk",
"buildsystem" : "meson",
@@ -171,8 +100,7 @@
"config-opts" : [
"--libdir=/app/lib",
"-Denable_vulkan=no",
"-Dbuildtype=debugoptimized",
"-Dprofile=devel"
"-Dbuildtype=debugoptimized"
],
"sources" : [
{

View File

@@ -35,15 +35,15 @@
"modules" : [
{
"name" : "wayland",
"buildsystem" : "meson",
"buildsystem" : "autotools",
"builddir" : true,
"config-opts" : [
"-Ddocumentation=false"
"--disable-documentation"
],
"sources" : [
{
"type" : "git",
"url" : "https://gitlab.freedesktop.org/wayland/wayland.git"
"url" : "https://github.com/wayland-project/wayland.git"
}
]
},
@@ -100,8 +100,7 @@
"config-opts" : [
"--libdir=/app/lib",
"-Denable_vulkan=no",
"-Dbuildtype=debugoptimized",
"-Dprofile=devel"
"-Dbuildtype=debugoptimized"
],
"sources" : [
{

View File

@@ -35,15 +35,15 @@
"modules" : [
{
"name" : "wayland",
"buildsystem" : "meson",
"buildsystem" : "autotools",
"builddir" : true,
"config-opts" : [
"-Ddocumentation=false"
"--disable-documentation"
],
"sources" : [
{
"type" : "git",
"url" : "https://gitlab.freedesktop.org/wayland/wayland.git"
"url" : "https://github.com/wayland-project/wayland.git"
}
]
},
@@ -100,8 +100,7 @@
"config-opts" : [
"--libdir=/app/lib",
"-Denable_vulkan=no",
"-Dbuildtype=debugoptimized",
"-Dprofile=devel"
"-Dbuildtype=debugoptimized"
],
"sources" : [
{

View File

@@ -1,39 +0,0 @@
#!/usr/bin/env python3
import os
import shutil
import subprocess
from pathlib import PurePath
stylesheets = [
'gtk/theme/Default/Default-light.css',
'gtk/theme/Default/Default-dark.css',
'gtk/theme/Default/Default-hc.css',
'gtk/theme/Default/Default-hc-dark.css',
]
references = [
'docs/reference/gtk/gtk4',
'docs/reference/gsk/gsk4',
'docs/reference/gdk/gdk4',
'docs/reference/gdk/gdk4-wayland',
'docs/reference/gdk/gdk4-x11',
]
sourceroot = os.environ.get('MESON_SOURCE_ROOT')
buildroot = os.environ.get('MESON_BUILD_ROOT')
distroot = os.environ.get('MESON_DIST_ROOT')
for stylesheet in stylesheets:
stylesheet_path = PurePath(stylesheet)
src = PurePath(sourceroot, stylesheet_path.with_suffix('.scss'))
dst = PurePath(distroot, stylesheet_path)
subprocess.call(['sassc', '-a', '-M', '-t', 'compact', src, dst])
for reference in references:
src_path = os.path.join(buildroot, reference)
if os.path.isdir(src_path):
dst_path = os.path.join(distroot, reference)
shutil.copytree(src_path, dst_path)

View File

@@ -1,26 +0,0 @@
#!/usr/bin/env python3
import os
import subprocess
import sys
repodir = sys.argv[1]
profile = sys.argv[2]
sys.stdout.write("/* This file is auto-generated. Do not edit. */\n")
sys.stdout.write("#pragma once\n")
sys.stdout.write("\n")
sys.stdout.write(f"#define PROFILE \"{profile}\"\n")
short_sha = os.environ.get('CI_COMMIT_SHORT_SHA')
if short_sha is None:
cmd = ["git", "-C", repodir, "rev-parse", "--short", "HEAD"]
try:
with subprocess.Popen(cmd, stdout=subprocess.PIPE) as p:
short_sha = p.stdout.read().decode('utf-8').rstrip("\n")
except FileNotFoundError:
short_sha = ''
if profile != 'default':
short_sha = 'devel'
sys.stdout.write(f"#define VCS_TAG \"{short_sha}\"\n")

281
config.h.meson Normal file
View File

@@ -0,0 +1,281 @@
/* 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
/* Disable deprecation warnings from glib */
#mesondefine GLIB_DISABLE_DEPRECATION_WARNINGS
/* Define the location where the catalogs will be installed */
#mesondefine GTK_LOCALEDIR
/* Define to 1 if you have the `bind_textdomain_codeset' function. */
#mesondefine HAVE_BIND_TEXTDOMAIN_CODESET
/* Have the cloudproviders library */
#mesondefine HAVE_CLOUDPROVIDERS
/* define if we have colord */
#mesondefine HAVE_COLORD
/* Define to 1 if you have the <crt_externs.h> header file. */
#mesondefine HAVE_CRT_EXTERNS_H
/* Define to 1 if you have the `dcgettext' function. */
#mesondefine HAVE_DCGETTEXT
/* Define to 1 if you have the <dlfcn.h> header file. */
#mesondefine HAVE_DLFCN_H
/* Have the ffmpeg library */
#mesondefine HAVE_FFMPEG
/* Define to 1 if you have the <ftw.h> header file. */
#mesondefine HAVE_FTW_H
/* Define to 1 if you have the `getpagesize' function. */
#mesondefine HAVE_GETPAGESIZE
/* Define to 1 if you have the `getresuid' function. */
#mesondefine HAVE_GETRESUID
/* Define if gio-unix is available */
#mesondefine HAVE_GIO_UNIX
/* Define if GStreamer support is available */
#mesondefine HAVE_GSTREAMER
/* Define to 1 if you have the <inttypes.h> header file. */
#mesondefine HAVE_INTTYPES_H
/* Define to 1 if the system has the type `IPrintDialogCallback'. */
#mesondefine HAVE_IPRINTDIALOGCALLBACK
/* Define to 1 if you have the <locale.h> header file. */
#mesondefine HAVE_LOCALE_H
/* Define to 1 if you have the `lstat' function. */
#mesondefine HAVE_LSTAT
/* Define to 1 if you have the `mallinfo' function. */
#mesondefine HAVE_MALLINFO
/* Define to 1 if you have the <memory.h> header file. */
#mesondefine HAVE_MEMORY_H
/* Define to 1 if you have the `mkstemp' function. */
#mesondefine HAVE_MKSTEMP
/* Define to 1 if you have the `mlock` function. */
#mesondefine HAVE_MLOCK
/* Define to 1 if you have a working `mmap' system call. */
#mesondefine HAVE_MMAP
/* Define to 1 if you have the `posix_fallocate' function. */
#mesondefine HAVE_POSIX_FALLOCATE
/* Have the Xrandr extension library */
#mesondefine HAVE_RANDR
/* Have the Xrandr 1.5 extension library */
#mesondefine HAVE_RANDR15
/* Define to 1 if you have the `sincos' function. */
#mesondefine HAVE_SINCOS
/* Define to 1 if you have the <stdint.h> header file. */
#mesondefine HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#mesondefine HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#mesondefine HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#mesondefine HAVE_STRING_H
/* Define to 1 if you have the <sys/mman.h> header file. */
#mesondefine HAVE_SYS_MMAN_H
/* Define to 1 if you have the <sys/param.h> header file. */
#mesondefine HAVE_SYS_PARAM_H
/* Have the sysprof-capture library */
#mesondefine HAVE_SYSPROF
/* Define to 1 if you have the <sys/stat.h> header file. */
#mesondefine HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/time.h> header file. */
#mesondefine HAVE_SYS_TIME_H
/* Define to 1 if you have the <sys/types.h> header file. */
#mesondefine HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#mesondefine HAVE_UNISTD_H
/* Have the XCOMPOSITE X extension */
#mesondefine HAVE_XCOMPOSITE
/* Have the Xcursor library */
#mesondefine HAVE_XCURSOR
/* Have the XDAMAGE X extension */
#mesondefine HAVE_XDAMAGE
/* Have the XFIXES X extension */
#mesondefine HAVE_XFIXES
/* Define to 1 if XFree Xinerama is available */
#mesondefine HAVE_XFREE_XINERAMA
/* Have XGenericEvent */
#mesondefine HAVE_XGENERICEVENTS
/* Define to use XKB extension */
#mesondefine HAVE_XKB
/* Have the SYNC extension library */
#mesondefine HAVE_XSYNC
/* Define to 1 if you have the `_lock_file' function */
#mesondefine HAVE__LOCK_FILE
/* Define to 1 if you have the `flockfile' function */
#mesondefine HAVE_FLOCKFILE
/* Define if _NL_MEASUREMENT_MEASUREMENT is available */
#mesondefine HAVE__NL_MEASUREMENT_MEASUREMENT
/* Define if _NL_PAPER_HEIGHT is available */
#mesondefine HAVE__NL_PAPER_HEIGHT
/* Define if _NL_PAPER_WIDTH is available */
#mesondefine HAVE__NL_PAPER_WIDTH
/* Define if _NL_TIME_FIRST_WEEKDAY is available */
#mesondefine HAVE__NL_TIME_FIRST_WEEKDAY
/* Define to the sub-directory where libtool stores uninstalled libraries. */
#mesondefine LT_OBJDIR
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
#mesondefine NO_MINUS_C_MINUS_O
/* Define to the address where bug reports for this package should be sent. */
#mesondefine PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#mesondefine PACKAGE_NAME
/* Define to the full name and version of this package. */
#mesondefine PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#mesondefine PACKAGE_TARNAME
/* Define to the home page for this package. */
#mesondefine PACKAGE_URL
/* Define to the version of this package. */
#mesondefine PACKAGE_VERSION
/* Use NSBundle functions to determine load paths for libraries, translations,
etc. */
#mesondefine QUARTZ_RELOCATION
/* Define to 1 if you have the ANSI C header files. */
#mesondefine STDC_HEADERS
/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
# undef _ALL_SOURCE
#endif
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
# undef _GNU_SOURCE
#endif
/* Enable threading extensions on Solaris. */
#ifndef _POSIX_PTHREAD_SEMANTICS
# undef _POSIX_PTHREAD_SEMANTICS
#endif
/* Enable extensions on HP NonStop. */
#ifndef _TANDEM_SOURCE
# undef _TANDEM_SOURCE
#endif
/* Enable general extensions on Solaris. */
#ifndef __EXTENSIONS__
# undef __EXTENSIONS__
#endif
/* Define to 1 if XInput 2.2 is available */
#mesondefine XINPUT_2_2
/* Define to 1 if the X Window System is missing or not being used. */
#mesondefine X_DISPLAY_MISSING
/* Enable large inode numbers on Mac OS X 10.5. */
#ifndef _DARWIN_USE_64_BIT_INODE
# define _DARWIN_USE_64_BIT_INODE 1
#endif
/* Number of bits in a file offset, on hosts where this is settable. */
#mesondefine _FILE_OFFSET_BITS
/* defines how to decorate public symbols while building */
#mesondefine _GDK_EXTERN
/* Define for large files, on AIX-style hosts. */
#mesondefine _LARGE_FILES
/* Define to 1 if on MINIX. */
#mesondefine _MINIX
/* Define to 2 if the system does not provide POSIX.1 features except with
this defined. */
#mesondefine _POSIX_1_SOURCE
/* Define to 1 if you need to in order for `stat' and other things to work. */
#mesondefine _POSIX_SOURCE
/* Define to `int' if <sys/types.h> doesn't define. */
#mesondefine gid_t
/* Define to `int' if <sys/types.h> doesn't define. */
#mesondefine uid_t
/* Define to 1 if linux/memfd.h exists */
#mesondefine HAVE_LINUX_MEMFD_H
#mesondefine HAVE_LINUX_INPUT_H
#mesondefine HAVE_DEV_EVDEV_INPUT_H
#mesondefine GTK_SYSCONFDIR
#mesondefine GTK_LOCALEDIR
#mesondefine GTK_DATADIR
#mesondefine GTK_LIBDIR
#mesondefine GTK_PRINT_BACKENDS
#mesondefine HAVE_CAIRO_SCRIPT_INTERPRETER
#mesondefine HAVE_HARFBUZZ
#mesondefine HAVE_PANGOFT
#mesondefine ISO_CODES_PREFIX
/* Define if tracker3 is available */
#mesondefine HAVE_TRACKER3

View File

@@ -98,9 +98,6 @@ create_page1 (GtkWidget *assistant)
gtk_box_append (GTK_BOX (box), label);
entry = gtk_entry_new ();
gtk_accessible_update_relation (GTK_ACCESSIBLE (entry),
GTK_ACCESSIBLE_RELATION_LABELLED_BY, label, NULL,
-1);
gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
gtk_widget_set_valign (entry, GTK_ALIGN_CENTER);
gtk_box_append (GTK_BOX (box), entry);

View File

@@ -128,9 +128,6 @@
<file>gtkfishbowl.c</file>
<file>gtkfishbowl.h</file>
</gresource>
<gresource prefix="/frames">
<file>frames.ui</file>
</gresource>
<gresource prefix="/gears">
<file>gtkgears.c</file>
<file>gtkgears.h</file>
@@ -279,7 +276,6 @@
<file>fishbowl.c</file>
<file>fixed.c</file>
<file>flowbox.c</file>
<file>frames.c</file>
<file>font_features.c</file>
<file>fontplane.c</file>
<file>fontrendering.c</file>
@@ -321,9 +317,11 @@
<file>paintable_emblem.c</file>
<file>paintable_mediastream.c</file>
<file>paintable_svg.c</file>
<file>paintable_symbolic.c</file>
<file>panes.c</file>
<file>password_entry.c</file>
<file>path_fill.c</file>
<file>path_maze.c</file>
<file>path_text.c</file>
<file>peg_solitaire.c</file>
<file>pickers.c</file>
<file>printing.c</file>
@@ -408,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

@@ -100,11 +100,7 @@ prepare_drag (GtkDragSource *source,
DemoImage *demo = DEMO_IMAGE (widget);
GdkPaintable *paintable = get_image_paintable (GTK_IMAGE (demo->image));
/* Textures can be serialized, paintables can't, so special case the textures */
if (GDK_IS_TEXTURE (paintable))
return gdk_content_provider_new_typed (GDK_TYPE_TEXTURE, paintable);
else
return gdk_content_provider_new_typed (GDK_TYPE_PAINTABLE, paintable);
return gdk_content_provider_new_typed (GDK_TYPE_PAINTABLE, paintable);
}
static gboolean
@@ -133,11 +129,7 @@ copy_image (GtkWidget *widget,
GdkPaintable *paintable = get_image_paintable (GTK_IMAGE (demo->image));
GValue value = G_VALUE_INIT;
/* Textures can be serialized, paintables can't, so special case the textures */
if (GDK_IS_TEXTURE (paintable))
g_value_init (&value, GDK_TYPE_TEXTURE);
else
g_value_init (&value, GDK_TYPE_PAINTABLE);
g_value_init (&value, GDK_TYPE_PAINTABLE);
g_value_set_object (&value, paintable);
gdk_clipboard_set_value (clipboard, &value);
g_value_unset (&value);
@@ -146,46 +138,24 @@ copy_image (GtkWidget *widget,
g_object_unref (paintable);
}
static void
paste_image_cb (GObject *source,
GAsyncResult *result,
gpointer data)
{
GdkClipboard *clipboard = GDK_CLIPBOARD (source);
DemoImage *demo = DEMO_IMAGE (data);
const GValue *value;
value = gdk_clipboard_read_value_finish (clipboard, result, NULL);
if (value == NULL)
{
gtk_widget_error_bell (GTK_WIDGET (demo));
g_object_unref (demo);
return;
}
gtk_image_set_from_paintable (GTK_IMAGE (demo->image), g_value_get_object (value));
g_object_unref (demo);
}
static void
paste_image (GtkWidget *widget,
const char *action_name,
GVariant *parameter)
{
GdkClipboard *clipboard = gtk_widget_get_clipboard (widget);
GType type;
DemoImage *demo = DEMO_IMAGE (widget);
GdkContentProvider *content = gdk_clipboard_get_content (clipboard);
GValue value = G_VALUE_INIT;
GdkPaintable *paintable;
if (gdk_content_formats_contain_gtype (gdk_clipboard_get_formats (clipboard), GDK_TYPE_TEXTURE))
type = GDK_TYPE_TEXTURE;
else
type = GDK_TYPE_PAINTABLE;
g_value_init (&value, GDK_TYPE_PAINTABLE);
if (!gdk_content_provider_get_value (content, &value, NULL))
return;
gdk_clipboard_read_value_async (clipboard,
type,
G_PRIORITY_DEFAULT,
NULL,
paste_image_cb,
g_object_ref (widget));
paintable = GDK_PAINTABLE (g_value_get_object (&value));
gtk_image_set_from_paintable (GTK_IMAGE (demo->image), paintable);
g_value_unset (&value);
}
static void

View File

@@ -119,12 +119,13 @@ create_label (void)
static GtkWidget *
create_video (void)
{
GtkWidget *w = gtk_video_new ();
GtkMediaStream *stream = gtk_media_file_new_for_resource ("/images/gtk-logo.webm");
GtkWidget *w = gtk_picture_new_for_paintable (GDK_PAINTABLE (stream));
gtk_widget_set_size_request (w, 64, 64);
gtk_video_set_loop (GTK_VIDEO (w), TRUE);
gtk_video_set_autoplay (GTK_VIDEO (w), TRUE);
gtk_video_set_resource (GTK_VIDEO (w), "/images/gtk-logo.webm");
gtk_media_stream_set_loop (stream, TRUE);
gtk_media_stream_play (stream);
g_object_unref (stream);
return w;
}

View File

@@ -13,13 +13,13 @@
</style>
<child>
<object class="GtkButton">
<property name="icon-name">go-previous-symbolic</property>
<property name="icon-name">pan-start-symbolic</property>
<signal name="clicked" handler="fishbowl_prev_button_clicked_cb" object="bowl" swapped="no"/>
</object>
</child>
<child>
<object class="GtkButton">
<property name="icon-name">go-next-symbolic</property>
<property name="icon-name">pan-end-symbolic</property>
<signal name="clicked" handler="fishbowl_next_button_clicked_cb" object="bowl" swapped="no"/>
</object>
</child>

View File

@@ -10,8 +10,12 @@
<object class="GtkButton" id="reset">
<property name="receives-default">1</property>
<property name="tooltip-text">Reset</property>
<property name="icon-name">view-refresh-symbolic</property>
<signal name="clicked" handler="font_features_reset_features" swapped="no"/>
<child>
<object class="GtkImage">
<property name="icon-name">view-refresh-symbolic</property>
</object>
</child>
</object>
</child>
</object>

View File

@@ -1136,7 +1136,7 @@ done:
g_free (design_coords);
}
G_MODULE_EXPORT void
void
font_features_font_changed (void)
{
update_script_combo ();
@@ -1144,14 +1144,14 @@ font_features_font_changed (void)
update_font_variations ();
}
G_MODULE_EXPORT void
void
font_features_script_changed (void)
{
update_features ();
update_display ();
}
G_MODULE_EXPORT void
void
font_features_reset_features (void)
{
GList *l;
@@ -1197,7 +1197,7 @@ switch_to_label (void)
update_display ();
}
G_MODULE_EXPORT void
void
font_features_toggle_edit (void)
{
if (strcmp (gtk_stack_get_visible_child_name (GTK_STACK (stack)), "label") == 0)
@@ -1206,7 +1206,7 @@ font_features_toggle_edit (void)
switch_to_label ();
}
G_MODULE_EXPORT void
void
font_features_stop_edit (void)
{
g_signal_emit_by_name (edit_toggle, "clicked");

View File

@@ -131,19 +131,6 @@ insert_tags_for_attributes (GtkTextBuffer *buffer,
gtk_text_buffer_apply_tag (buffer, tag, start, end); \
}
#define VOID_ATTR(attr_name) \
{ \
tag = gtk_text_tag_table_lookup (table, #attr_name); \
if (!tag) \
{ \
tag = gtk_text_tag_new (#attr_name); \
g_object_set (tag, #attr_name, TRUE, NULL); \
gtk_text_tag_table_add (table, tag); \
g_object_unref (tag); \
} \
gtk_text_buffer_apply_tag (buffer, tag, start, end); \
}
fg_alpha = bg_alpha = 1.;
attrs = pango_attr_iterator_get_attrs (iter);
@@ -268,29 +255,6 @@ insert_tags_for_attributes (GtkTextBuffer *buffer,
INT_ATTR (insert_hyphens);
break;
case PANGO_ATTR_LINE_HEIGHT:
FLOAT_ATTR (line_height);
break;
case PANGO_ATTR_ABSOLUTE_LINE_HEIGHT:
break;
case PANGO_ATTR_WORD:
VOID_ATTR (word);
break;
case PANGO_ATTR_SENTENCE:
VOID_ATTR (sentence);
break;
case PANGO_ATTR_BASELINE_SHIFT:
INT_ATTR (baseline_shift);
break;
case PANGO_ATTR_FONT_SCALE:
INT_ATTR (font_scale);
break;
case PANGO_ATTR_SHAPE:
case PANGO_ATTR_ABSOLUTE_SIZE:
case PANGO_ATTR_GRAVITY:
@@ -299,10 +263,6 @@ insert_tags_for_attributes (GtkTextBuffer *buffer,
case PANGO_ATTR_BACKGROUND_ALPHA:
break;
case PANGO_ATTR_TEXT_TRANSFORM:
INT_ATTR (text_transform);
break;
case PANGO_ATTR_INVALID:
default:
g_assert_not_reached ();

View File

@@ -1,11 +1,6 @@
/* Pango/Font Rendering
*
* Demonstrates various aspects of font rendering,
* such as hinting, antialiasing and grid alignment.
*
* The demo lets you explore font rendering options
* interactively to get a feeling for they affect the
* shape and positioning of the glyphs.
* Demonstrates various aspects of font rendering.
*/
#include <gtk/gtk.h>
@@ -15,21 +10,16 @@ static GtkWidget *font_button = NULL;
static GtkWidget *entry = NULL;
static GtkWidget *image = NULL;
static GtkWidget *hinting = NULL;
static GtkWidget *anti_alias = NULL;
static GtkWidget *hint_metrics = NULL;
static GtkWidget *up_button = NULL;
static GtkWidget *down_button = NULL;
static GtkWidget *text_radio = NULL;
static GtkWidget *show_grid = NULL;
static GtkWidget *show_extents = NULL;
static GtkWidget *show_pixels = NULL;
static GtkWidget *show_outlines = NULL;
static PangoContext *context;
static int scale = 7;
static double pixel_alpha = 1.0;
static double outline_alpha = 0.0;
static int scale = 9;
static void
update_image (void)
@@ -37,7 +27,7 @@ update_image (void)
const char *text;
PangoFontDescription *desc;
PangoLayout *layout;
PangoRectangle ink, logical;
PangoRectangle ink, pink, logical;
int baseline;
cairo_surface_t *surface;
cairo_t *cr;
@@ -47,8 +37,6 @@ update_image (void)
cairo_font_options_t *fopt;
cairo_hint_style_t hintstyle;
cairo_hint_metrics_t hintmetrics;
cairo_antialias_t antialias;
cairo_path_t *path;
if (!context)
context = gtk_widget_create_pango_context (image);
@@ -59,18 +47,16 @@ update_image (void)
fopt = cairo_font_options_copy (pango_cairo_context_get_font_options (context));
hint = gtk_combo_box_get_active_id (GTK_COMBO_BOX (hinting));
hintstyle = CAIRO_HINT_STYLE_DEFAULT;
if (hint)
{
if (strcmp (hint, "none") == 0)
hintstyle = CAIRO_HINT_STYLE_NONE;
else if (strcmp (hint, "slight") == 0)
hintstyle = CAIRO_HINT_STYLE_SLIGHT;
else if (strcmp (hint, "medium") == 0)
hintstyle = CAIRO_HINT_STYLE_MEDIUM;
else if (strcmp (hint, "full") == 0)
hintstyle = CAIRO_HINT_STYLE_FULL;
}
if (strcmp (hint, "none") == 0)
hintstyle = CAIRO_HINT_STYLE_NONE;
else if (strcmp (hint, "slight") == 0)
hintstyle = CAIRO_HINT_STYLE_SLIGHT;
else if (strcmp (hint, "medium") == 0)
hintstyle = CAIRO_HINT_STYLE_MEDIUM;
else if (strcmp (hint, "full") == 0)
hintstyle = CAIRO_HINT_STYLE_FULL;
else
hintstyle = CAIRO_HINT_STYLE_DEFAULT;
cairo_font_options_set_hint_style (fopt, hintstyle);
if (gtk_check_button_get_active (GTK_CHECK_BUTTON (hint_metrics)))
@@ -79,13 +65,6 @@ update_image (void)
hintmetrics = CAIRO_HINT_METRICS_OFF;
cairo_font_options_set_hint_metrics (fopt, hintmetrics);
if (gtk_check_button_get_active (GTK_CHECK_BUTTON (anti_alias)))
antialias = CAIRO_ANTIALIAS_GRAY;
else
antialias = CAIRO_ANTIALIAS_NONE;
cairo_font_options_set_antialias (fopt, antialias);
pango_context_set_round_glyph_positions (context, hintmetrics == CAIRO_HINT_METRICS_ON);
pango_cairo_context_set_font_options (context, fopt);
cairo_font_options_destroy (fopt);
pango_context_changed (context);
@@ -96,6 +75,7 @@ update_image (void)
pango_layout_set_font_description (layout, desc);
pango_layout_set_text (layout, text, -1);
pango_layout_get_extents (layout, &ink, &logical);
pink = ink;
baseline = pango_layout_get_baseline (layout);
pango_extents_to_pixels (&ink, NULL);
@@ -105,14 +85,10 @@ update_image (void)
cairo_set_source_rgb (cr, 1, 1, 1);
cairo_paint (cr);
cairo_set_source_rgba (cr, 0, 0, 0, pixel_alpha);
cairo_set_source_rgb (cr, 0, 0, 0);
cairo_move_to (cr, 10, 10);
pango_cairo_show_layout (cr, layout);
pango_cairo_layout_path (cr, layout);
path = cairo_copy_path (cr);
cairo_destroy (cr);
g_object_unref (layout);
@@ -151,7 +127,7 @@ update_image (void)
if (gtk_check_button_get_active (GTK_CHECK_BUTTON (show_extents)))
{
cairo_set_source_rgb (cr, 0, 0, 1);
cairo_set_source_rgba (cr, 0, 0, 1, 1);
cairo_rectangle (cr,
scale * (10 + pango_units_to_double (logical.x)) - 0.5,
@@ -164,45 +140,17 @@ update_image (void)
cairo_line_to (cr, scale * (10 + pango_units_to_double (logical.x + logical.width)) + 1,
scale * (10 + pango_units_to_double (baseline)) - 0.5);
cairo_stroke (cr);
cairo_set_source_rgb (cr, 1, 0, 0);
cairo_set_source_rgba (cr, 1, 0, 0, 1);
cairo_rectangle (cr,
scale * (10 + ink.x) - 0.5,
scale * (10 + ink.y) - 0.5,
scale * ink.width + 1,
scale * ink.height + 1);
scale * (10 + pango_units_to_double (pink.x)) + 0.5,
scale * (10 + pango_units_to_double (pink.y)) + 0.5,
scale * pango_units_to_double (pink.width) - 1,
scale * pango_units_to_double (pink.height) - 1);
cairo_stroke (cr);
}
for (int i = 0; i < path->num_data; i += path->data[i].header.length)
{
cairo_path_data_t *data = &path->data[i];
switch (data->header.type)
{
case CAIRO_PATH_CURVE_TO:
data[3].point.x *= scale; data[3].point.y *= scale;
data[2].point.x *= scale; data[2].point.y *= scale;
data[1].point.x *= scale; data[1].point.y *= scale;
break;
case CAIRO_PATH_LINE_TO:
case CAIRO_PATH_MOVE_TO:
data[1].point.x *= scale; data[1].point.y *= scale;
break;
case CAIRO_PATH_CLOSE_PATH:
break;
default:
g_assert_not_reached ();
}
}
cairo_set_source_rgba (cr, 0, 0, 0, outline_alpha);
cairo_move_to (cr, scale * 20 - 0.5, scale * 20 - 0.5);
cairo_append_path (cr, path);
cairo_stroke (cr);
cairo_surface_destroy (surface);
cairo_destroy (cr);
cairo_path_destroy (path);
}
else
{
@@ -210,26 +158,10 @@ update_image (void)
PangoLayoutRun *run;
PangoGlyphInfo *g;
int i, j;
GString *str;
gunichar ch;
if (*text == '\0')
text = " ";
ch = g_utf8_get_char (text);
str = g_string_new ("");
for (i = 0; i < 4; i++)
{
g_string_append_unichar (str, ch);
g_string_append_unichar (str, 0x200c);
}
layout = pango_layout_new (context);
pango_layout_set_font_description (layout, desc);
pango_layout_set_text (layout, str->str, -1);
g_string_free (str, TRUE);
pango_layout_set_text (layout, "aaaa", -1);
pango_layout_get_extents (layout, &ink, &logical);
pango_extents_to_pixels (&logical, NULL);
@@ -244,7 +176,7 @@ update_image (void)
cairo_set_source_rgb (cr, 0, 0, 0);
for (i = 0; i < 4; i++)
{
g = &(run->glyphs->glyphs[2*i]);
g = &(run->glyphs->glyphs[i]);
g->geometry.width = PANGO_UNITS_ROUND (g->geometry.width * 3 / 2);
}
@@ -252,7 +184,7 @@ update_image (void)
{
for (i = 0; i < 4; i++)
{
g = &(run->glyphs->glyphs[2*i]);
g = &(run->glyphs->glyphs[i]);
g->geometry.x_offset = i * (PANGO_SCALE / 4);
g->geometry.y_offset = j * (PANGO_SCALE / 4);
}
@@ -271,6 +203,7 @@ update_image (void)
cairo_surface_destroy (surface);
}
gtk_picture_set_pixbuf (GTK_PICTURE (image), pixbuf2);
g_object_unref (pixbuf2);
@@ -278,78 +211,6 @@ update_image (void)
pango_font_description_free (desc);
}
static gboolean fading = FALSE;
static double start_pixel_alpha;
static double end_pixel_alpha;
static double start_outline_alpha;
static double end_outline_alpha;
static gint64 start_time;
static gint64 end_time;
static double
ease_out_cubic (double t)
{
double p = t - 1;
return p * p * p + 1;
}
static gboolean
change_alpha (GtkWidget *widget,
GdkFrameClock *clock,
gpointer user_data)
{
gint64 now = g_get_monotonic_time ();
double t;
t = ease_out_cubic ((now - start_time) / (double) (end_time - start_time));
pixel_alpha = start_pixel_alpha + (end_pixel_alpha - start_pixel_alpha) * t;
outline_alpha = start_outline_alpha + (end_outline_alpha - start_outline_alpha) * t;
update_image ();
if (now >= end_time)
{
fading = FALSE;
return G_SOURCE_REMOVE;
}
return G_SOURCE_CONTINUE;
}
static void
start_alpha_fade (void)
{
gboolean pixels;
gboolean outlines;
if (fading)
return;
pixels = gtk_check_button_get_active (GTK_CHECK_BUTTON (show_pixels));
outlines = gtk_check_button_get_active (GTK_CHECK_BUTTON (show_outlines));
start_pixel_alpha = pixel_alpha;
if (pixels && outlines)
end_pixel_alpha = 0.5;
else if (pixels)
end_pixel_alpha = 1;
else
end_pixel_alpha = 0;
start_outline_alpha = outline_alpha;
if (outlines)
end_outline_alpha = 1.0;
else
end_outline_alpha = 0.0;
start_time = g_get_monotonic_time ();
end_time = start_time + G_TIME_SPAN_SECOND / 2;
fading = TRUE;
gtk_widget_add_tick_callback (window, change_alpha, NULL, NULL);
}
static void
update_buttons (void)
{
@@ -357,26 +218,20 @@ update_buttons (void)
gtk_widget_set_sensitive (down_button, scale > 1);
}
static gboolean
scale_up (GtkWidget *widget,
GVariant *args,
gpointer user_data)
static void
scale_up (void)
{
scale += 1;
update_buttons ();
update_image ();
return TRUE;
}
static gboolean
scale_down (GtkWidget *widget,
GVariant *args,
gpointer user_data)
static void
scale_down (void)
{
scale -= 1;
update_buttons ();
update_image ();
return TRUE;
}
GtkWidget *
@@ -397,26 +252,20 @@ do_fontrendering (GtkWidget *do_widget)
entry = GTK_WIDGET (gtk_builder_get_object (builder, "entry"));
image = GTK_WIDGET (gtk_builder_get_object (builder, "image"));
hinting = GTK_WIDGET (gtk_builder_get_object (builder, "hinting"));
anti_alias = GTK_WIDGET (gtk_builder_get_object (builder, "antialias"));
hint_metrics = GTK_WIDGET (gtk_builder_get_object (builder, "hint_metrics"));
text_radio = GTK_WIDGET (gtk_builder_get_object (builder, "text_radio"));
show_grid = GTK_WIDGET (gtk_builder_get_object (builder, "show_grid"));
show_extents = GTK_WIDGET (gtk_builder_get_object (builder, "show_extents"));
show_pixels = GTK_WIDGET (gtk_builder_get_object (builder, "show_pixels"));
show_outlines = GTK_WIDGET (gtk_builder_get_object (builder, "show_outlines"));
g_signal_connect (up_button, "clicked", G_CALLBACK (scale_up), NULL);
g_signal_connect (down_button, "clicked", G_CALLBACK (scale_down), NULL);
g_signal_connect (entry, "notify::text", G_CALLBACK (update_image), NULL);
g_signal_connect (font_button, "notify::font-desc", G_CALLBACK (update_image), NULL);
g_signal_connect (hinting, "notify::active", G_CALLBACK (update_image), NULL);
g_signal_connect (anti_alias, "notify::active", G_CALLBACK (update_image), NULL);
g_signal_connect (hint_metrics, "notify::active", G_CALLBACK (update_image), NULL);
g_signal_connect (text_radio, "notify::active", G_CALLBACK (update_image), NULL);
g_signal_connect (show_grid, "notify::active", G_CALLBACK (update_image), NULL);
g_signal_connect (show_extents, "notify::active", G_CALLBACK (update_image), NULL);
g_signal_connect (show_pixels, "notify::active", G_CALLBACK (start_alpha_fade), NULL);
g_signal_connect (show_outlines, "notify::active", G_CALLBACK (start_alpha_fade), NULL);
update_image ();

View File

@@ -1,8 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkAdjustment" id="scale_adj">
<property name="upper">24</property>
<property name="step-increment">1</property>
<property name="page-increment">4</property>
</object>
<object class="GtkWindow" id="window">
<property name="default-width">1024</property>
<property name="default-height">768</property>
<property name="default-width">1080</property>
<property name="default-height">430</property>
<child type="titlebar">
<object class="GtkHeaderBar">
<child type="title">
@@ -82,119 +87,69 @@
</object>
</child>
<child>
<object class="GtkCheckButton" id="show_pixels">
<property name="label">Show _Pixels</property>
<property name="use-underline">1</property>
<property name="active">1</property>
<object class="GtkLabel">
<property name="label">Hinting</property>
<property name="xalign">1</property>
<style>
<class name="dim-label"/>
</style>
<layout>
<property name="column">3</property>
<property name="row">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkCheckButton" id="show_outlines">
<property name="label">Show _Outline</property>
<property name="use-underline">1</property>
<layout>
<property name="column">3</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkBox">
<property name="spacing">6</property>
<child>
<object class="GtkLabel">
<property name="label">_Hinting</property>
<property name="use-underline">1</property>
<property name="mnemonic-widget">hinting</property>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
<child>
<object class="GtkComboBoxText" id="hinting">
<property name="active">0</property>
<property name="valign">center</property>
<items>
<item translatable="yes" id="none">None</item>
<item translatable="yes" id="slight">Slight</item>
<item translatable="yes" id="medium">Medium</item>
<item translatable="yes" id="full">Full</item>
</items>
</object>
</child>
<object class="GtkComboBoxText" id="hinting">
<property name="active">0</property>
<property name="valign">center</property>
<items>
<item translatable="yes" id="none">None</item>
<item translatable="yes" id="slight">Slight</item>
<item translatable="yes" id="medium">Medium</item>
<item translatable="yes" id="full">Full</item>
</items>
<layout>
<property name="column">4</property>
<property name="column-span">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkCheckButton" id="antialias">
<property name="label">_Antialias</property>
<property name="use-underline">1</property>
<property name="active">1</property>
<layout>
<property name="column">4</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkCheckButton" id="hint_metrics">
<property name="label">Hint _Metrics</property>
<property name="use-underline">1</property>
<property name="label">Hint Metrics</property>
<layout>
<property name="column">4</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkCheckButton" id="show_extents">
<property name="label">Show Extents</property>
<property name="active">1</property>
<layout>
<property name="column">5</property>
<property name="row">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkCheckButton" id="show_grid">
<property name="active">1</property>
<property name="label">Show Grid</property>
<layout>
<property name="column">5</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkCheckButton" id="show_extents">
<property name="label">Show _Extents</property>
<property name="use-underline">1</property>
<layout>
<property name="column">6</property>
<property name="row">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkCheckButton" id="show_grid">
<property name="label">Show _Grid</property>
<property name="use-underline">1</property>
<layout>
<property name="column">6</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkButton" id="up_button">
<property name="icon-name">list-add-symbolic</property>
<property name="halign">center</property>
<property name="valign">center</property>
<style>
<class name="circular"/>
</style>
<child>
<object class="GtkShortcutController">
<property name="scope">managed</property>
<child>
<object class="GtkShortcut">
<property name="trigger">&lt;Control&gt;plus</property>
<property name="action">activate</property>
</object>
</child>
</object>
</child>
<layout>
<property name="column">7</property>
<property name="column">6</property>
<property name="row">0</property>
</layout>
</object>
@@ -202,24 +157,11 @@
<child>
<object class="GtkButton" id="down_button">
<property name="icon-name">list-remove-symbolic</property>
<property name="halign">center</property>
<property name="valign">center</property>
<style>
<class name="circular"/>
</style>
<child>
<object class="GtkShortcutController">
<property name="scope">managed</property>
<child>
<object class="GtkShortcut">
<property name="trigger">&lt;Control&gt;minus</property>
<property name="action">activate</property>
</object>
</child>
</object>
</child>
<layout>
<property name="column">7</property>
<property name="column">6</property>
<property name="row">1</property>
</layout>
</object>
@@ -228,7 +170,7 @@
<object class="GtkLabel">
<property name="hexpand">1</property>
<layout>
<property name="column">8</property>
<property name="column">7</property>
</layout>
</object>
</child>

View File

@@ -1,165 +0,0 @@
/* Benchmark/Frames
*
* This demo is intentionally as simple as possible, to see what
* framerate the windowing system can deliver on its own.
*
* It does nothing but change the drawn color, for every frame.
*/
#include <gtk/gtk.h>
typedef struct
{
GtkWidget parent_instance;
GdkRGBA color1;
GdkRGBA color2;
guint64 time2;
float t;
guint tick_cb;
} ColorWidget;
typedef struct
{
GtkWidgetClass parent_class;
} ColorWidgetClass;
G_DEFINE_TYPE (ColorWidget, color_widget, GTK_TYPE_WIDGET)
#define TIME_SPAN (3.0 * G_TIME_SPAN_SECOND)
static gboolean
change_color (GtkWidget *widget,
GdkFrameClock *frame_clock,
gpointer data)
{
ColorWidget *color = (ColorWidget *)widget;
gint64 time;
time = gdk_frame_clock_get_frame_time (frame_clock);
if (time >= color->time2)
{
color->time2 = time + TIME_SPAN;
color->color1 = color->color2;
color->color2.red = g_random_double_range (0, 1);
color->color2.green = g_random_double_range (0, 1);
color->color2.blue = g_random_double_range (0, 1);
color->color2.alpha = 1;
}
color->t = 1 - (color->time2 - time) / TIME_SPAN;
gtk_widget_queue_draw (widget);
return G_SOURCE_CONTINUE;
}
static void
color_widget_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot)
{
ColorWidget *color = (ColorWidget *)widget;
float w, h;
GdkRGBA c;
w = gtk_widget_get_width (widget);
h = gtk_widget_get_height (widget);
c.red = (1 - color->t) * color->color1.red + color->t * color->color2.red;
c.green = (1 - color->t) * color->color1.green + color->t * color->color2.green;
c.blue = (1 - color->t) * color->color1.blue + color->t * color->color2.blue;
c.alpha = 1;
gtk_snapshot_append_color (snapshot, &c, &GRAPHENE_RECT_INIT (0, 0, w, h));
}
static void
color_widget_init (ColorWidget *color)
{
gtk_widget_add_tick_callback (GTK_WIDGET (color), change_color, NULL, NULL);
gtk_widget_set_hexpand (GTK_WIDGET (color), TRUE);
gtk_widget_set_vexpand (GTK_WIDGET (color), TRUE);
}
static void
color_widget_class_init (ColorWidgetClass *class)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
widget_class->snapshot = color_widget_snapshot;
}
GtkWidget *
color_widget_new (void)
{
return g_object_new (color_widget_get_type (), NULL);
}
static gboolean
update_fps_label (gpointer data)
{
GtkWidget *label = GTK_WIDGET (data);
GdkFrameClock *frame_clock;
frame_clock = gtk_widget_get_frame_clock (label);
if (frame_clock)
{
char *fps;
fps = g_strdup_printf ("%.2f fps", gdk_frame_clock_get_fps (frame_clock));
gtk_label_set_label (GTK_LABEL (label), fps);
g_free (fps);
}
else
gtk_label_set_label (GTK_LABEL (label), "");
return G_SOURCE_CONTINUE;
}
static void
remove_id (gpointer data)
{
guint id = GPOINTER_TO_UINT (data);
g_source_remove (id);
}
GtkWidget *
do_frames (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;
if (!window)
{
GtkBuilder *builder;
GtkWidget *box;
GtkWidget *label;
guint id;
builder = gtk_builder_new_from_resource ("/frames/frames.ui");
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
label = GTK_WIDGET (gtk_builder_get_object (builder, "fps"));
box = GTK_WIDGET (gtk_builder_get_object (builder, "box"));
gtk_box_append (GTK_BOX (box), color_widget_new ());
id = g_timeout_add (500, update_fps_label, label);
g_object_set_data_full (G_OBJECT (label), "tick_cb",
GUINT_TO_POINTER (id), remove_id);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
gtk_window_destroy (GTK_WINDOW (window));
return window;
}

View File

@@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkWindow" id="window">
<property name="resizable">1</property>
<property name="default-width">600</property>
<property name="default-height">400</property>
<property name="title">Frames</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="header">
<child type="end">
<object class="GtkLabel" id="fps">
<attributes>
<attribute name="font-features" value="tnum=1"/>
</attributes>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox" id="box">
</object>
</child>
</object>
</interface>

View File

@@ -23,10 +23,13 @@
#include "gskshaderpaintable.h"
/**
* GskShaderPaintable:
* 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.
* 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
@@ -35,7 +38,7 @@
*
* 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`
* gsk_shader_paintable_update_time() can be called from a #GtkTickCallback
* to update the time based on the frame time of the frame clock.
*/
@@ -183,7 +186,7 @@ gsk_shader_paintable_init (GskShaderPaintable *self)
* 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`
* Returns: (transfer full): a new #GskShaderPaintable
*/
GdkPaintable *
gsk_shader_paintable_new (GskGLShader *shader,
@@ -212,8 +215,8 @@ gsk_shader_paintable_new (GskGLShader *shader,
/**
* gsk_shader_paintable_set_shader:
* @self: a `GskShaderPaintable`
* @shader: the `GskGLShader` to use
* @self: a #GskShaderPaintable
* @shader: the #GskGLShader to use
*
* Sets the shader that the paintable will use
* to create pixels. The shader must not require
@@ -238,11 +241,11 @@ gsk_shader_paintable_set_shader (GskShaderPaintable *self,
/**
* gsk_shader_paintable_get_shader:
* @self: a `GskShaderPaintable`
* @self: a #GskShaderPaintable
*
* Returns the shader that the paintable is using.
*
* Returns: (transfer none): the `GskGLShader` that is used
* Returns: (transfer none): the #GskGLShader that is used
*/
GskGLShader *
gsk_shader_paintable_get_shader (GskShaderPaintable *self)
@@ -254,12 +257,12 @@ gsk_shader_paintable_get_shader (GskShaderPaintable *self)
/**
* gsk_shader_paintable_set_args:
* @self: a `GskShaderPaintable`
* @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`.
* be produced by a #GskUniformDataBuilder.
*
* Note that the @data should be considered immutable
* after it has been passed to this function.
@@ -281,7 +284,7 @@ gsk_shader_paintable_set_args (GskShaderPaintable *self,
/**
* gsk_shader_paintable_get_args:
* @self: a `GskShaderPaintable`
* @self: a #GskShaderPaintable
*
* Returns the uniform data set with
* gsk_shader_paintable_get_args().
@@ -298,9 +301,9 @@ gsk_shader_paintable_get_args (GskShaderPaintable *self)
/**
* gsk_shader_paintable_update_time:
* @self: a `GskShaderPaintable`
* @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`
* @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
@@ -308,7 +311,7 @@ gsk_shader_paintable_get_args (GskShaderPaintable *self)
* 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`.
* This function is usually called from a #GtkTickCallback.
*/
void
gsk_shader_paintable_update_time (GskShaderPaintable *self,

View File

@@ -74,9 +74,9 @@ gtk_fishbowl_init (GtkFishbowl *fishbowl)
/**
* gtk_fishbowl_new:
*
* Creates a new `GtkFishbowl`.
* Creates a new #GtkFishbowl.
*
* Returns: a new `GtkFishbowl`.
* Returns: a new #GtkFishbowl.
*/
GtkWidget*
gtk_fishbowl_new (void)

View File

@@ -787,8 +787,6 @@ gtk_gears_realize (GtkWidget *widget)
glLinkProgram(program);
glGetProgramInfoLog(program, sizeof msg, NULL, msg);
g_debug ("program info: %s\n", msg);
glDetachShader (program, v);
glDetachShader (program, f);
glDeleteShader (v);
glDeleteShader (f);
@@ -874,8 +872,8 @@ gtk_gears_tick (GtkWidget *widget,
{
GtkGears *gears = GTK_GEARS (widget);
GtkGearsPrivate *priv = gtk_gears_get_instance_private (gears);
GdkFrameTimings *previous_timings;
gint64 previous_frame_time;
GdkFrameTimings *timings, *previous_timings;
gint64 previous_frame_time = 0;
gint64 frame_time;
gint64 history_start, history_len;
gint64 frame;
@@ -915,6 +913,12 @@ gtk_gears_tick (GtkWidget *widget,
}
}
timings = gdk_frame_clock_get_current_timings (frame_clock);
previous_timings = gdk_frame_clock_get_timings (frame_clock,
gdk_frame_timings_get_frame_counter (timings) - 1);
if (previous_timings != NULL)
previous_frame_time = gdk_frame_timings_get_frame_time (previous_timings);
return G_SOURCE_CONTINUE;
}

View File

@@ -163,8 +163,8 @@ drag_update_cb (GtkGestureDrag *drag,
static void
drag_end_cb (GtkGestureDrag *drag,
double dx,
double dy,
gdouble dx,
gdouble dy,
gpointer user_data)
{
GtkShadertoy *shadertoy = GTK_SHADERTOY (user_data);

View File

@@ -18,6 +18,8 @@ do_headerbar (GtkWidget *do_widget)
GtkWidget *header;
GtkWidget *button;
GtkWidget *box;
GtkWidget *image;
GIcon *icon;
if (!window)
{
@@ -30,14 +32,20 @@ do_headerbar (GtkWidget *do_widget)
header = gtk_header_bar_new ();
button = gtk_button_new_from_icon_name ("mail-send-receive-symbolic");
button = gtk_button_new ();
icon = g_themed_icon_new ("mail-send-receive-symbolic");
image = gtk_image_new_from_gicon (icon);
g_object_unref (icon);
gtk_button_set_child (GTK_BUTTON (button), image);
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_add_css_class (box, "linked");
button = gtk_button_new_from_icon_name ("go-previous-symbolic");
button = gtk_button_new ();
gtk_button_set_child (GTK_BUTTON (button), gtk_image_new_from_icon_name ("pan-start-symbolic"));
gtk_box_append (GTK_BOX (box), button);
button = gtk_button_new_from_icon_name ("go-next-symbolic");
button = gtk_button_new ();
gtk_button_set_child (GTK_BUTTON (button), gtk_image_new_from_icon_name ("pan-end-symbolic"));
gtk_box_append (GTK_BOX (box), button);
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), box);

View File

@@ -61,26 +61,12 @@ show_page (GtkTextView *text_view,
int page)
{
GtkTextBuffer *buffer;
GtkTextIter iter, start;
GtkTextMark *mark;
GtkTextIter iter;
GtkWidget *child;
GtkTextChildAnchor *anchor;
GtkEventController *controller;
GtkTextTag *bold, *mono, *nobreaks;
buffer = gtk_text_view_get_buffer (text_view);
bold = gtk_text_buffer_create_tag (buffer, NULL,
"weight", PANGO_WEIGHT_BOLD,
"scale", PANGO_SCALE_X_LARGE,
NULL);
mono = gtk_text_buffer_create_tag (buffer, NULL,
"family", "monospace",
NULL);
nobreaks = gtk_text_buffer_create_tag (buffer, NULL,
"allow-breaks", FALSE,
NULL);
gtk_text_buffer_set_text (buffer, "", 0);
gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0);
gtk_text_buffer_begin_irreversible_action (buffer);
@@ -94,12 +80,13 @@ show_page (GtkTextView *text_view,
gtk_text_buffer_insert (buffer, &iter, " can easily be realized with ", -1);
insert_link (buffer, &iter, "tags", 2);
gtk_text_buffer_insert (buffer, &iter, ".\n", -1);
gtk_text_buffer_insert (buffer, &iter, "Of course you can also embed Emoji 😋, ", -1);
gtk_text_buffer_insert (buffer, &iter, "icons ", -1);
gtk_text_buffer_insert (buffer, &iter,
"Of course you can also embed Emoji 😋, "
"icons ", -1);
theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (text_view)));
icon = gtk_icon_theme_lookup_icon (theme,
"eye-not-looking-symbolic",
"microphone-sensitivity-high-symbolic",
NULL,
16,
1,
@@ -117,22 +104,17 @@ show_page (GtkTextView *text_view,
}
else if (page == 2)
{
mark = gtk_text_buffer_create_mark (buffer, "mark", &iter, TRUE);
GtkTextTag *tag;
gtk_text_buffer_insert_with_tags (buffer, &iter, "tag", -1, bold, NULL);
gtk_text_buffer_insert (buffer, &iter, " /", -1);
gtk_text_buffer_get_iter_at_mark (buffer, &start, mark);
gtk_text_buffer_apply_tag (buffer, nobreaks, &start, &iter);
gtk_text_buffer_insert (buffer, &iter, " ", -1);
gtk_text_buffer_move_mark (buffer, mark, &iter);
gtk_text_buffer_insert_with_tags (buffer, &iter, "tag", -1, mono, NULL);
gtk_text_buffer_insert (buffer, &iter, " /", -1);
gtk_text_buffer_get_iter_at_mark (buffer, &start, mark);
gtk_text_buffer_apply_tag (buffer, nobreaks, &start, &iter);
gtk_text_buffer_insert (buffer, &iter, " ", -1);
tag = gtk_text_buffer_create_tag (buffer, NULL,
"weight", PANGO_WEIGHT_BOLD,
"scale", PANGO_SCALE_X_LARGE,
NULL);
gtk_text_buffer_insert_with_tags (buffer, &iter, "tag", -1, tag, NULL);
tag = gtk_text_buffer_create_tag (buffer, NULL,
"family", "monospace",
NULL);
gtk_text_buffer_insert_with_tags (buffer, &iter, " /tag/ ", -1, tag, NULL);
anchor = gtk_text_buffer_create_child_anchor (buffer, &iter);
child = gtk_image_new_from_icon_name ("audio-volume-high-symbolic");
@@ -150,26 +132,20 @@ show_page (GtkTextView *text_view,
"behavior of mouse and key presses, “lock” a range of text so the "
"user can't edit it, or countless other things.\n", -1);
insert_link (buffer, &iter, "Go back", 1);
gtk_text_buffer_delete_mark (buffer, mark);
}
else if (page == 3)
{
mark = gtk_text_buffer_create_mark (buffer, "mark", &iter, TRUE);
GtkTextTag *tag;
gtk_text_buffer_insert_with_tags (buffer, &iter, "hypertext", -1, bold, NULL);
gtk_text_buffer_insert (buffer, &iter, " /", -1);
gtk_text_buffer_get_iter_at_mark (buffer, &start, mark);
gtk_text_buffer_apply_tag (buffer, nobreaks, &start, &iter);
gtk_text_buffer_insert (buffer, &iter, " ", -1);
gtk_text_buffer_move_mark (buffer, mark, &iter);
gtk_text_buffer_insert_with_tags (buffer, &iter, "ˈhaɪ pərˌtɛkst", -1, mono, NULL);
gtk_text_buffer_insert (buffer, &iter, " /", -1);
gtk_text_buffer_get_iter_at_mark (buffer, &start, mark);
gtk_text_buffer_apply_tag (buffer, nobreaks, &start, &iter);
gtk_text_buffer_insert (buffer, &iter, " ", -1);
tag = gtk_text_buffer_create_tag (buffer, NULL,
"weight", PANGO_WEIGHT_BOLD,
"scale", PANGO_SCALE_X_LARGE,
NULL);
gtk_text_buffer_insert_with_tags (buffer, &iter, "hypertext", -1, tag, NULL);
tag = gtk_text_buffer_create_tag (buffer, NULL,
"family", "monospace",
NULL);
gtk_text_buffer_insert_with_tags (buffer, &iter, " /ˈhaɪ pərˌtɛkst/ ", -1, tag, NULL);
anchor = gtk_text_buffer_create_child_anchor (buffer, &iter);
child = gtk_image_new_from_icon_name ("audio-volume-high-symbolic");
@@ -183,8 +159,6 @@ show_page (GtkTextView *text_view,
"Machine-readable text that is not sequential but is organized "
"so that related items of information are connected.\n", -1);
insert_link (buffer, &iter, "Go back", 1);
gtk_text_buffer_delete_mark (buffer, mark);
}
gtk_text_buffer_end_irreversible_action (buffer);
}
@@ -384,7 +358,7 @@ do_hypertext (GtkWidget *do_widget)
sw = gtk_scrolled_window_new ();
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_NEVER,
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_window_set_child (GTK_WINDOW (window), sw);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), view);

View File

@@ -13,7 +13,7 @@ static GtkWidget *window = NULL;
static GtkWidget *scrolledwindow;
static int selected;
#define N_WIDGET_TYPES 8
#define N_WIDGET_TYPES 7
static int hincrement = 5;
@@ -110,46 +110,6 @@ populate_text (gboolean highlight)
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scrolledwindow), textview);
}
static void
populate_emoji_text (void)
{
GtkWidget *textview;
GtkTextBuffer *buffer;
GString *s;
GtkTextIter iter;
s = g_string_sized_new (500 * 30 * 4);
for (int i = 0; i < 500; i++)
{
if (i % 2)
g_string_append (s, "<span underline=\"single\" underline_color=\"red\">x</span>");
for (int j = 0; j < 30; j++)
{
g_string_append (s, "💓");
g_string_append (s, "<span underline=\"single\" underline_color=\"red\">x</span>");
}
g_string_append (s, "\n");
}
buffer = gtk_text_buffer_new (NULL);
gtk_text_buffer_get_start_iter (buffer, &iter);
gtk_text_buffer_insert_markup (buffer, &iter, s->str, s->len);
g_string_free (s, TRUE);
textview = gtk_text_view_new ();
gtk_text_view_set_buffer (GTK_TEXT_VIEW (textview), buffer);
hincrement = 0;
vincrement = 5;
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
GTK_POLICY_NEVER,
GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scrolledwindow), textview);
}
static void
populate_image (void)
{
@@ -264,26 +224,21 @@ set_widget_type (int type)
break;
case 3:
gtk_window_set_title (GTK_WINDOW (window), "Scrolling text with Emoji");
populate_emoji_text ();
break;
case 4:
gtk_window_set_title (GTK_WINDOW (window), "Scrolling a big image");
populate_image ();
break;
case 5:
case 4:
gtk_window_set_title (GTK_WINDOW (window), "Scrolling a list");
populate_list ();
break;
case 6:
case 5:
gtk_window_set_title (GTK_WINDOW (window), "Scrolling a columned list");
populate_list2 ();
break;
case 7:
case 6:
gtk_window_set_title (GTK_WINDOW (window), "Scrolling a grid");
populate_grid ();
break;

View File

@@ -13,13 +13,13 @@
</style>
<child>
<object class="GtkButton">
<property name="icon-name">go-previous-symbolic</property>
<property name="icon-name">pan-start-symbolic</property>
<signal name="clicked" handler="iconscroll_prev_clicked_cb"/>
</object>
</child>
<child>
<object class="GtkButton">
<property name="icon-name">go-next-symbolic</property>
<property name="icon-name">pan-end-symbolic</property>
<signal name="clicked" handler="iconscroll_next_clicked_cb"/>
</object>
</child>

View File

@@ -8,7 +8,7 @@
#include <stdlib.h>
#include <string.h>
static GdkTexture *avatar_texture_other;
static GdkPixbuf *avatar_pixbuf_other;
static GtkWidget *window = NULL;
#define GTK_TYPE_MESSAGE (gtk_message_get_type ())
@@ -196,9 +196,12 @@ gtk_message_row_update (GtkMessageRow *row)
gtk_button_set_label (GTK_BUTTON (priv->resent_by_button), priv->message->resent_by);
if (strcmp (priv->message->sender_nick, "@GTKtoolkit") == 0)
gtk_image_set_from_icon_name (priv->avatar_image, "org.gtk.Demo4");
{
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
gtk_image_set_from_paintable (priv->avatar_image, GDK_PAINTABLE (avatar_texture_other));
gtk_image_set_from_pixbuf (priv->avatar_image, avatar_pixbuf_other);
}
@@ -341,7 +344,7 @@ do_listbox (GtkWidget *do_widget)
if (!window)
{
avatar_texture_other = gdk_texture_new_from_resource ("/listbox/apple-red.png");
avatar_pixbuf_other = gdk_pixbuf_new_from_resource_at_scale ("/listbox/apple-red.png", 32, 32, FALSE, NULL);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),

View File

@@ -25,7 +25,6 @@
<property name="margin-start">8</property>
<property name="margin-end">8</property>
<property name="icon-name">image-missing</property>
<property name="icon-size">large</property>
<layout>
<property name="column">0</property>
<property name="row">0</property>

View File

@@ -8,8 +8,8 @@
#include <gtk/gtk.h>
/* This is the function that creates the GListModel that we need.
* GTK list widgets need a GListModel to display, as models support change
/* This is the function that creates the #GListModel that we need.
* GTK list widgets need a #GListModel to display, as models support change
* notifications.
* Unfortunately various older APIs do not provide list models, so we create
* our own.
@@ -20,10 +20,10 @@ create_application_list (void)
GListStore *store;
GList *apps, *l;
/* We use a GListStore here, which is a simple array-like list implementation
/* We use a #GListStore here, which is a simple array-like list implementation
* for manual management.
* List models need to know what type of data they provide, so we need to
* provide the type here. As we want to do a list of applications, GAppInfo
* provide the type here. As we want to do a list of applications, #GAppInfo
* is the object we provide.
*/
store = g_list_store_new (G_TYPE_APP_INFO);
@@ -39,7 +39,7 @@ create_application_list (void)
}
/* This is the function we use for setting up new listitems to display.
* We add just an GtkImage and a GtkLabel here to display the application's
* We add just an #GtkImage and a #GtkKabel here to display the application's
* icon and name, as this is just a simple demo.
*/
static void
@@ -61,8 +61,8 @@ setup_listitem_cb (GtkListItemFactory *factory,
/* Here we need to prepare the listitem for displaying its item. We get the
* listitem already set up from the previous function, so we can reuse the
* GtkImage widget we set up above.
* We get the item - which we know is a GAppInfo because it comes out of
* #GtkImage widget we set up above.
* We get the item - which we know is a #GAppInfo because it comes out of
* the model we set up above, grab its icon and display it.
*/
static void
@@ -85,7 +85,7 @@ bind_listitem_cb (GtkListItemFactory *factory,
* the listitem, but this is simple code, so the default implementations are
* enough. If we had connected signals, this step would have been necessary.
*
* The GtkSignalListItemFactory documentation contains more information about
* The #GtkSignalListItemFactory documentation contains more information about
* this step.
*/
@@ -108,8 +108,8 @@ activate_cb (GtkListView *list,
app_info = g_list_model_get_item (G_LIST_MODEL (gtk_list_view_get_model (list)), position);
/* Prepare the context for launching the application and launch it. This
* code is explained in detail in the documentation for GdkAppLaunchContext
* and GAppInfo.
* code is explained in detail in the documentation for #GdkAppLaunchContext
* and #GAppInfo.
*/
context = gdk_display_get_app_launch_context (gtk_widget_get_display (GTK_WIDGET (list)));
if (!g_app_info_launch (app_info,
@@ -155,13 +155,13 @@ do_listview_applauncher (GtkWidget *do_widget)
gtk_window_set_title (GTK_WINDOW (window), "Application Launcher");
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *) &window);
/* The GtkListitemFactory is what is used to create GtkListItems
/* The #GtkListitemFactory is what is used to create #GtkListItems
* to display the data from the model. So it is absolutely necessary
* to create one.
* We will use a GtkSignalListItemFactory because it is the simplest
* We will use a #GtkSignalListItemFactory because it is the simplest
* one to use. Different ones are available for different use cases.
* The most powerful one is GtkBuilderListItemFactory which uses
* GtkBuilder .ui files, so it requires little code.
* The most powerful one is #GtkBuilderListItemFactory which uses
* #GtkBuilder .ui files, so it requires little code.
*/
factory = gtk_signal_list_item_factory_new ();
g_signal_connect (factory, "setup", G_CALLBACK (setup_listitem_cb), NULL);
@@ -184,7 +184,7 @@ do_listview_applauncher (GtkWidget *do_widget)
*/
g_signal_connect (list, "activate", G_CALLBACK (activate_cb), NULL);
/* List widgets should always be contained in a GtkScrolledWindow,
/* List widgets should always be contained in a #GtkScrolledWindow,
* because otherwise they might get too large or they might not
* be scrollable.
*/

View File

@@ -34,7 +34,6 @@ enum {
};
#define FILE_BROWSER_TYPE_VIEW (file_browser_view_get_type ())
G_MODULE_EXPORT
G_DECLARE_FINAL_TYPE (FileBrowserView, file_browser_view, FILE_BROWSER, VIEW, GObject);
G_DEFINE_TYPE (FileBrowserView, file_browser_view, G_TYPE_OBJECT);
@@ -160,7 +159,7 @@ static void file_browser_view_init (FileBrowserView *self)
{
}
G_MODULE_EXPORT char *
char *
filebrowser_get_display_name (GObject *object,
GFileInfo *info)
{
@@ -170,7 +169,7 @@ filebrowser_get_display_name (GObject *object,
return g_strdup (g_file_info_get_attribute_string (info, "standard::display-name"));
}
G_MODULE_EXPORT char *
char *
filebrowser_get_content_type (GObject *object,
GFileInfo *info)
{
@@ -180,7 +179,7 @@ filebrowser_get_content_type (GObject *object,
return g_strdup (g_file_info_get_attribute_string (info, "standard::content-type"));
}
G_MODULE_EXPORT char *
char *
filebrowser_get_size (GObject *object,
GFileInfo *info)
{
@@ -190,7 +189,7 @@ filebrowser_get_size (GObject *object,
return g_format_size (g_file_info_get_attribute_uint64 (info, "standard::size"));
}
G_MODULE_EXPORT GIcon *
GIcon *
filebrowser_get_icon (GObject *object,
GFileInfo *info)
{
@@ -207,7 +206,7 @@ filebrowser_get_icon (GObject *object,
return icon;
}
G_MODULE_EXPORT void
void
filebrowser_up_clicked_cb (GtkButton *button,
GtkDirectoryList *list)
{
@@ -220,7 +219,7 @@ filebrowser_up_clicked_cb (GtkButton *button,
gtk_directory_list_set_file (list, file);
}
G_MODULE_EXPORT void
void
filebrowser_view_activated_cb (GtkGridView *view,
guint pos,
GtkDirectoryList *list)

View File

@@ -177,15 +177,6 @@ file_open_cb (GtkWidget *button,
gtk_native_dialog_show (GTK_NATIVE_DIALOG (dialog));
}
static void
listview_activate_cb (GtkListView *listview,
guint pos,
gpointer unused)
{
gtk_fixed_item_selection_set_selected_position (GTK_FIXED_ITEM_SELECTION (gtk_list_view_get_model (listview)),
pos);
}
GtkWidget *
do_listview_words (GtkWidget *do_widget)
{
@@ -194,7 +185,6 @@ do_listview_words (GtkWidget *do_widget)
GtkWidget *header, *listview, *sw, *vbox, *search_entry, *open_button, *overlay;
GtkFilterListModel *filter_model;
GtkStringList *stringlist;
GtkFixedItemSelection *selection;
GtkFilter *filter;
GFile *file;
@@ -251,15 +241,11 @@ do_listview_words (GtkWidget *do_widget)
gtk_widget_set_vexpand (sw, TRUE);
gtk_overlay_set_child (GTK_OVERLAY (overlay), sw);
selection = gtk_fixed_item_selection_new (G_LIST_MODEL (filter_model));
listview = gtk_list_view_new (
GTK_SELECTION_MODEL (selection),
GTK_SELECTION_MODEL (gtk_no_selection_new (G_LIST_MODEL (filter_model))),
gtk_builder_list_item_factory_new_from_bytes (NULL,
g_bytes_new_static (factory_text, strlen (factory_text))));
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), listview);
gtk_list_view_set_single_click_activate (GTK_LIST_VIEW (listview), TRUE);
g_signal_connect (listview, "activate", G_CALLBACK (listview_activate_cb), NULL);
g_signal_connect (filter_model, "items-changed", G_CALLBACK (update_title_cb), progress);
g_signal_connect (filter_model, "notify::pending", G_CALLBACK (update_title_cb), progress);

View File

@@ -25,8 +25,6 @@
#include "demos.h"
#include "fontify.h"
#include "demo_conf.h"
static GtkWidget *info_view;
static GtkWidget *source_view;
@@ -198,20 +196,16 @@ activate_about (GSimpleAction *action,
gtk_get_micro_version ());
g_string_append_printf (s, "\nA link can appear here: <http://www.gtk.org>");
version = g_strdup_printf ("%s%s%s\nRunning against GTK %d.%d.%d",
version = g_strdup_printf ("%s\nRunning against GTK %d.%d.%d",
PACKAGE_VERSION,
g_strcmp0 (PROFILE, "devel") == 0 ? "-" : "",
g_strcmp0 (PROFILE, "devel") == 0 ? VCS_TAG : "",
gtk_get_major_version (),
gtk_get_minor_version (),
gtk_get_micro_version ());
gtk_show_about_dialog (GTK_WINDOW (gtk_application_get_active_window (app)),
"program-name", g_strcmp0 (PROFILE, "devel") == 0
? "GTK Demo (Development)"
: "GTK Demo",
"program-name", "GTK Demo",
"version", version,
"copyright", "©1997—2021 The GTK Team",
"copyright", "©1997—2020 The GTK Team",
"license-type", GTK_LICENSE_LGPL_2_1,
"website", "http://www.gtk.org",
"comments", "Program to demonstrate GTK widgets",
@@ -751,6 +745,7 @@ demo_filter_by_name (gpointer item,
gpointer user_data)
{
GtkTreeListRow *row = item;
GtkFilterListModel *model = user_data;
GListModel *children;
GtkDemo *demo;
guint i, n;
@@ -761,7 +756,7 @@ demo_filter_by_name (gpointer item,
return TRUE;
g_assert (GTK_IS_TREE_LIST_ROW (row));
g_assert (GTK_IS_FILTER_LIST_MODEL (user_data));
g_assert (GTK_IS_FILTER_LIST_MODEL (model));
/* Show a row if itself of any parent matches */
for (parent = row; parent; parent = gtk_tree_list_row_get_parent (parent))
@@ -906,9 +901,6 @@ activate (GApplication *app)
window = (GtkWidget *)gtk_builder_get_object (builder, "window");
gtk_application_add_window (GTK_APPLICATION (app), GTK_WINDOW (window));
if (g_strcmp0 (PROFILE, "devel") == 0)
gtk_widget_add_css_class (window, "devel");
action = g_simple_action_new ("run", NULL);
g_signal_connect (action, "activate", G_CALLBACK (activate_run), window);
g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (action));
@@ -1051,10 +1043,10 @@ out:
static void
print_version (void)
{
g_print ("gtk4-demo %s%s%s\n",
PACKAGE_VERSION,
g_strcmp0 (PROFILE, "devel") == 0 ? "-" : "",
g_strcmp0 (PROFILE, "devel") == 0 ? VCS_TAG : "");
g_print ("gtk4-demo %d.%d.%d\n",
gtk_get_major_version (),
gtk_get_minor_version (),
gtk_get_micro_version ());
}
static int

View File

@@ -25,7 +25,6 @@
<object class="GtkButton">
<property name="valign">center</property>
<property name="action-name">win.run</property>
<property name="focus-on-click">0</property>
<property name="label" translatable="yes">Run</property>
</object>
</child>
@@ -33,7 +32,6 @@
<object class="GtkToggleButton">
<property name="icon-name">edit-find-symbolic</property>
<property name="valign">center</property>
<property name="focus-on-click">0</property>
<property name="active" bind-source="searchbar" bind-property="search-mode-enabled" bind-flags="bidirectional|sync-create"/>
<accessibility>
<property name="label" translatable="yes">Search</property>
@@ -43,7 +41,6 @@
<child type="end">
<object class="GtkMenuButton" id="gear_menu_button">
<property name="valign">center</property>
<property name="focus-on-click">0</property>
<property name="menu-model">gear_menu</property>
<property name="icon-name">open-menu-symbolic</property>
<accessibility>

View File

@@ -58,7 +58,7 @@ do_markup (GtkWidget *do_widget)
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_default_size (GTK_WINDOW (window), 600, 680);
gtk_window_set_default_size (GTK_WINDOW (window), 450, 450);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
stack = gtk_stack_new ();

View File

@@ -1,9 +1,5 @@
Text sizes: <span size="xx-small">tiny </span><span size="x-small">very small </span><span size="small">small </span><span size="medium">normal </span><span size="large">large </span><span size="x-large">very large </span><span size="xx-large">huge</span>
Text styles: <span style="normal">Normal</span> <span style="italic">Italic</span> <span style="oblique">Olique</span>
Text weights: <span weight="thin">thin</span> <span weight="light">light</span> <span weight="normal">normal</span> <span weight="bold">bold</span> <span weight="ultraheavy">ultraheavy</span>
Text sizes: <span size="xx-small">tiny</span> <span size="x-small">very small</span> <span size="small">small</span> <span size="medium">normal</span> <span size="large">large</span> <span size="x-large">very large</span> <span size="xx-large">huge</span>
Text <span color="gray">c<span color="green">o</span>l<span color="tomato">o</span>rs</span> and <span background="pink">backgrounds</span>
@@ -19,12 +15,6 @@ OpenType font features: <span font_desc="sans regular" font_features="dlig=0">fe
Shortcuts: <tt>Monospace</tt> <b>Bold</b> <i>Italic</i> <big>Big</big> <small>Small</small> <u>Underlined</u> <s>Strikethrough</s> Super<sup>script</sup> Sub<sub>script</sub>
hy­phen­ation al­go­rithm is a <span allow_breaks="false" style="italic">set of rules</span>, espe­ci­ally one co­di­fied for im­ple­men­tation in a com­pu­ter pro­gram, that de­ci­des at which points a word can be bro­ken over two lines with a hy­phen. For ex­am­ple, a hy­phen­ation al­go­rithm might de­cide that im­peach­ment can be broken as impeach‧ment or im‧peachment but not impe‧achment.
<span allow_breaks="false">A</span> hy­phen­ation al­go­rithm is a set of rules, espe­ci­ally one co­di­fied for im­ple­men­tation in a com­pu­ter pro­gram, that de­ci­des at which points a word can be bro­ken over two lines with a hy­phen. For ex­am­ple, a hy­phen­ation al­go­rithm might de­cide that im­peach­ment can be broken as <span allow_breaks="false">impeach‧ment</span> or <span allow_breaks="false">im‧peachment</span> but not <span allow_breaks="false">impe‧achment.</span>
<span insert_hyphens="false">one/two three/four five/six seven/eight nine/ten</span>
<span line_height='1.33'>Line height: This is an example of widely spaced text. It was achieved by setting the line-height factor to 1.33. You can set the line-height factor to any value between 0 and 10.
Note that the line height affects the spacing between paragraphs as well as between the wrapped lines inside a paragraph.</span>
Transforms: <span text_transform='uppercase'>straße</span> <span text_transform='capitalize'>up, up and away</span>

View File

@@ -21,10 +21,8 @@ do_menu (GtkWidget *do_widget)
if (!window)
{
GtkWidget *box;
GtkWidget *sw;
GtkWidget *widget;
GtkWidget *scale;
window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (window), "Menu");
@@ -33,23 +31,11 @@ do_menu (GtkWidget *do_widget)
gtk_widget_get_display (do_widget));
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_window_set_child (GTK_WINDOW (window), box);
sw = gtk_scrolled_window_new ();
gtk_widget_set_vexpand (sw, TRUE);
gtk_box_append (GTK_BOX (box), sw);
gtk_window_set_child (GTK_WINDOW (window), sw);
widget = demo3_widget_new ("/transparent/portland-rose.jpg");
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), widget);
scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0.01, 10.0, 0.1);
gtk_range_set_value (GTK_RANGE (scale), 1.0);
gtk_box_append (GTK_BOX (box), scale);
g_object_bind_property (gtk_range_get_adjustment (GTK_RANGE (scale)), "value",
widget, "scale",
G_BINDING_BIDIRECTIONAL);
}
if (!gtk_widget_get_visible (window))

View File

@@ -29,7 +29,6 @@ demos = files([
'fishbowl.c',
'fixed.c',
'fontrendering.c',
'frames.c',
'gears.c',
'gestures.c',
'glarea.c',
@@ -67,9 +66,11 @@ demos = files([
'paintable_animated.c',
'paintable_emblem.c',
'paintable_mediastream.c',
'paintable_symbolic.c',
'panes.c',
'password_entry.c',
'path_fill.c',
'path_maze.c',
'path_text.c',
'peg_solitaire.c',
'pickers.c',
'printing.c',
@@ -156,74 +157,10 @@ demos_h = custom_target('gtk4 demo header',
command: [ find_program('geninclude.py'), '@OUTPUT@', '@INPUT@' ],
)
objcopy_supports_add_symbol = false
objcopy = find_program('objcopy', required : false)
if objcopy.found()
objcopy_supports_add_symbol = run_command(objcopy, '--help').stdout().contains('--add-symbol')
endif
ld = find_program('ld', required : false)
if build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_add_symbol and ld.found()
glib_compile_resources = find_program('glib-compile-resources')
# Create the resource blob
gtkdemo_gresource = custom_target('gtkdemo.gresource',
input : 'demo.gresource.xml',
output : 'gtkdemo.gresource',
depfile : 'gtkdemo.gresource.d',
command : [glib_compile_resources,
'--generate',
'--target=@OUTPUT@',
'--dependency-file=@DEPFILE@',
'--sourcedir=' + meson.current_source_dir(),
'--sourcedir=' + meson.current_build_dir(),
'@INPUT@'])
# Create resource data file
gtkdemo_resources_c = custom_target('gtkdemo_resources.c',
input : 'demo.gresource.xml',
output : 'gtkdemo_resources.c',
depfile : 'gtkdemo_resources.c.d',
command : [glib_compile_resources,
'--generate-source',
'--target=@OUTPUT@',
'--dependency-file=@DEPFILE@',
'--sourcedir=' + meson.current_source_dir(),
'--sourcedir=' + meson.current_build_dir(),
'--external-data',
'--c-name', '_g_binary_gtkdemo',
'@INPUT@'])
# Create object file containing resource data
gtkdemo_resources_binary = custom_target('gtkdemo_resources.o',
input : gtkdemo_gresource,
output : 'gtkdemo_resources.o',
command : [ld,
'-r',
'-b','binary',
'@INPUT@',
'-o','@OUTPUT@'])
# Rename symbol to match the one in the C file
gtkdemo_resources_o = custom_target('gtkdemo_resources2.o',
input : gtkdemo_resources_binary,
output : 'gtkdemo_resources2.o',
command : [objcopy,
'--add-symbol','_g_binary_gtkdemo_resource_data=.data:0',
'@INPUT@',
'@OUTPUT@'])
gtkdemo_resources = [
gtkdemo_resources_c,
gtkdemo_resources_o,
]
else
gtkdemo_resources = gnome.compile_resources('gtkdemo_resources',
'demo.gresource.xml',
source_dir: '.',
)
endif
gtkdemo_resources = gnome.compile_resources('gtkdemo_resources',
'demo.gresource.xml',
source_dir: '.',
)
# Use a subset of compiler flags
demo_cflags = []
@@ -233,8 +170,6 @@ foreach flag: common_cflags
endif
endforeach
gtkdemo_deps += [ demo_conf_h ]
executable('gtk4-demo',
sources: [demos, demos_h, extra_demo_sources, gtkdemo_resources],
c_args: gtkdemo_args + demo_cflags,
@@ -270,9 +205,4 @@ install_data('org.gtk.Demo4.gschema.xml', install_dir: gtk_schemasdir)
gnome.compile_schemas()
# appdata
configure_file(
input: 'org.gtk.Demo4.appdata.xml.in',
output: 'org.gtk.Demo4.appdata.xml',
configuration: appdata_config,
install_dir: gtk_appdatadir
)
install_data('org.gtk.Demo4.appdata.xml', install_dir: gtk_appdatadir)

View File

@@ -1,9 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<id>org.gtk.Demo4</id>
<launchable type="desktop-id">org.gtk.Demo4.desktop</launchable>
<id>org.gtk.Demo4.desktop</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>LGPL-2.1-or-later</project_license>
<project_license>LGPL-2.0+</project_license>
<name>GTK Demo</name>
<summary>Program to demonstrate GTK functions</summary>
<description>
@@ -31,11 +30,15 @@
<translation type="gettext">gtk-4.0</translation>
<update_contact>matthias.clasen_at_gmail.com</update_contact>
<developer_name>Matthias Clasen and others</developer_name>
<content_rating type="oars-1.1"/>
<releases>
<release version="@BUILD_VERSION@">
<release version="3.99.0" date="2020-07-30">
<description>
<p>A new build of GTK.</p>
<p>A new developers snapshot towards GTK 4.0.</p>
</description>
</release>
<release version="3.94.0" date="2018-06-25">
<description>
<p>A new developers snapshot towards GTK 4.0.</p>
</description>
</release>
</releases>

View File

@@ -45,27 +45,26 @@ struct _GtkNuclearIconClass
* so that it can be called from all the other demos, too.
*/
void
gtk_nuclear_snapshot (GtkSnapshot *snapshot,
const GdkRGBA *foreground,
const GdkRGBA *background,
double width,
double height,
double rotation)
gtk_nuclear_snapshot (GtkSnapshot *snapshot,
double width,
double height,
double rotation,
gboolean draw_background)
{
#define RADIUS 0.3
cairo_t *cr;
double size;
gtk_snapshot_append_color (snapshot,
background,
&GRAPHENE_RECT_INIT (0, 0, width, height));
if (draw_background)
gtk_snapshot_append_color (snapshot,
&(GdkRGBA) { 0.9, 0.75, 0.15, 1.0 },
&GRAPHENE_RECT_INIT (0, 0, width, height));
size = MIN (width, height);
cr = gtk_snapshot_append_cairo (snapshot,
&GRAPHENE_RECT_INIT ((width - size) / 2.0,
(height - size) / 2.0,
size, size));
gdk_cairo_set_source_rgba (cr, foreground);
cairo_translate (cr, width / 2.0, height / 2.0);
cairo_scale (cr, size, size);
cairo_rotate (cr, rotation);
@@ -95,10 +94,9 @@ gtk_nuclear_icon_snapshot (GdkPaintable *paintable,
*/
gtk_nuclear_snapshot (snapshot,
&(GdkRGBA) { 0, 0, 0, 1 }, /* black */
&(GdkRGBA) { 0.9, 0.75, 0.15, 1.0 }, /* yellow */
width, height,
nuclear->rotation);
nuclear->rotation,
TRUE);
}
static GdkPaintableFlags

View File

@@ -4,11 +4,10 @@
#include <gtk/gtk.h>
void gtk_nuclear_snapshot (GtkSnapshot *snapshot,
const GdkRGBA *foreground,
const GdkRGBA *background,
double width,
double height,
double rotation);
double rotation,
gboolean draw_background);
GdkPaintable * gtk_nuclear_icon_new (double rotation);
GdkPaintable * gtk_nuclear_animation_new (gboolean draw_background);

View File

@@ -65,12 +65,9 @@ gtk_nuclear_animation_snapshot (GdkPaintable *paintable,
/* We call the function from the previous example here. */
gtk_nuclear_snapshot (snapshot,
&(GdkRGBA) { 0, 0, 0, 1 }, /* black */
nuclear->draw_background
? &(GdkRGBA) { 0.9, 0.75, 0.15, 1.0 } /* yellow */
: &(GdkRGBA) { 0, 0, 0, 0 }, /* transparent */
width, height,
2 * G_PI * nuclear->progress / MAX_PROGRESS);
2 * G_PI * nuclear->progress / MAX_PROGRESS,
nuclear->draw_background);
}
static GdkPaintable *

View File

@@ -73,10 +73,9 @@ gtk_nuclear_media_stream_snapshot (GdkPaintable *paintable,
/* We call the function from the previous example here. */
gtk_nuclear_snapshot (snapshot,
&(GdkRGBA) { 0, 0, 0, 1 }, /* black */
&(GdkRGBA) { 0.9, 0.75, 0.15, 1.0 }, /* yellow */
width, height,
2 * G_PI * nuclear->progress / DURATION);
2 * G_PI * nuclear->progress / DURATION,
TRUE);
}
static GdkPaintable *
@@ -151,7 +150,7 @@ gtk_nuclear_media_stream_step (gpointer data)
* call our pause function to pause the stream.
*/
if (nuclear->progress >= DURATION)
gtk_media_stream_stream_ended (GTK_MEDIA_STREAM (nuclear));
gtk_media_stream_ended (GTK_MEDIA_STREAM (nuclear));
/* The timeout function is removed by the pause function,
* so we can just always return this value.
@@ -268,11 +267,11 @@ gtk_nuclear_media_stream_init (GtkNuclearMediaStream *nuclear)
* However, media streams need to tell GTK once they are initialized,
* so we do that here.
*/
gtk_media_stream_stream_prepared (GTK_MEDIA_STREAM (nuclear),
FALSE,
TRUE,
TRUE,
DURATION);
gtk_media_stream_prepared (GTK_MEDIA_STREAM (nuclear),
FALSE,
TRUE,
TRUE,
DURATION);
}
/* And finally, we add the simple constructor we declared in the header. */

View File

@@ -1,208 +0,0 @@
/* Paintable/Symbolic Paintable
*
* GdkPaintables can be made to follow the theme's colors. GTK calls
* icons that do this symbolic icons, paintables that want to have
* the same effect can implement the GtkSymbolicPaintable interface.
*
* We will adapt the original paintable example by adding the ability
* to recolor the paintable based on the symbolic colors.
*/
#include <gtk/gtk.h>
#include "paintable.h"
static GtkWidget *window = NULL;
/* First, add the boilerplate for the object itself.
* This part would normally go in the header.
*/
#define GTK_TYPE_NUCLEAR_SYMBOLIC (gtk_nuclear_symbolic_get_type ())
G_DECLARE_FINAL_TYPE (GtkNuclearSymbolic, gtk_nuclear_symbolic, GTK, NUCLEAR_SYMBOLIC, GObject)
/* Declare a few warning levels, so we can pick colors based on them */
typedef enum
{
WARNING_NONE,
WARNING_ALERT,
WARNING_EMERGENCY
} WarningLevel;
/* Declare the struct. */
struct _GtkNuclearSymbolic
{
GObject parent_instance;
WarningLevel warning_level;
};
struct _GtkNuclearSymbolicClass
{
GObjectClass parent_class;
};
/* Add a function to draw the nuclear icon in the given colors */
static void
gtk_nuclear_symbolic_snapshot_symbolic (GtkSymbolicPaintable *paintable,
GdkSnapshot *snapshot,
double width,
double height,
const GdkRGBA *colors,
gsize n_colors)
{
GtkNuclearSymbolic *self = GTK_NUCLEAR_SYMBOLIC (paintable);
static const GdkRGBA transparent = { 0, };
const GdkRGBA *bg_color;
/* select the right background color from the warning level */
switch (self->warning_level)
{
case WARNING_NONE:
bg_color = &transparent;
break;
case WARNING_ALERT:
bg_color = &colors[GTK_SYMBOLIC_COLOR_WARNING];
break;
case WARNING_EMERGENCY:
bg_color = &colors[GTK_SYMBOLIC_COLOR_ERROR];
break;
default:
/* This should never happen, but we better do defensive coding
* with this critical icon */
g_assert_not_reached ();
bg_color = &transparent;
break;
}
/* Draw the icon with the selected warning color */
gtk_nuclear_snapshot (snapshot,
&colors[GTK_SYMBOLIC_COLOR_FOREGROUND],
bg_color,
width, height,
0);
}
static void
gtk_nuclear_symbolic_symbolic_paintable_init (GtkSymbolicPaintableInterface *iface)
{
iface->snapshot_symbolic = gtk_nuclear_symbolic_snapshot_symbolic;
}
/* We need to implement the functionality required by the GdkPaintable interface */
static void
gtk_nuclear_symbolic_snapshot (GdkPaintable *paintable,
GdkSnapshot *snapshot,
double width,
double height)
{
/* Calling this function without passing a color is a neat trick
* to make GTK use default colors and otherwise forward the call
* to the snapshotting function above.
*/
gtk_symbolic_paintable_snapshot_symbolic (GTK_SYMBOLIC_PAINTABLE (paintable),
snapshot,
width, height,
NULL, 0);
}
static GdkPaintableFlags
gtk_nuclear_symbolic_get_flags (GdkPaintable *paintable)
{
/* This image has a static size, but the contents may change:
* We draw different things when the warning level changes.
*/
return GDK_PAINTABLE_STATIC_SIZE;
}
static void
gtk_nuclear_symbolic_paintable_init (GdkPaintableInterface *iface)
{
iface->snapshot = gtk_nuclear_symbolic_snapshot;
iface->get_flags = gtk_nuclear_symbolic_get_flags;
}
/* When defining the GType, we need to implement bot the GdkPaintable
* and the GtkSymbolicPaintable interface */
G_DEFINE_TYPE_WITH_CODE (GtkNuclearSymbolic, gtk_nuclear_symbolic, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
gtk_nuclear_symbolic_paintable_init)
G_IMPLEMENT_INTERFACE (GTK_TYPE_SYMBOLIC_PAINTABLE,
gtk_nuclear_symbolic_symbolic_paintable_init))
static void
gtk_nuclear_symbolic_class_init (GtkNuclearSymbolicClass *klass)
{
}
static void
gtk_nuclear_symbolic_init (GtkNuclearSymbolic *nuclear)
{
}
/* And finally, we add the simple constructor we declared in the header. */
GdkPaintable *
gtk_nuclear_symbolic_new (void)
{
return g_object_new (GTK_TYPE_NUCLEAR_SYMBOLIC, NULL);
}
/* Add some fun feature to the button */
static void
nuclear_button_clicked (GtkButton *button,
GtkNuclearSymbolic *nuclear)
{
if (nuclear->warning_level >= WARNING_EMERGENCY)
{
/* On maximum warning level, reset the warning */
nuclear->warning_level = WARNING_NONE;
/* And sometimes (but not always to confuse people)
* close the window.
*/
if (g_random_boolean ())
gtk_window_close (GTK_WINDOW (window));
}
else
{
/* Otherwise just increase the warning level */
nuclear->warning_level++;
}
/* Don't forget to emit the signal causing the paintable to redraw.
* Changing the warning level changes the background color after all.
*/
gdk_paintable_invalidate_contents (GDK_PAINTABLE (nuclear));
}
GtkWidget *
do_paintable_symbolic (GtkWidget *do_widget)
{
GdkPaintable *nuclear;
GtkWidget *image, *button;
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), "Don't click!");
gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
button = gtk_button_new ();
gtk_window_set_child (GTK_WINDOW (window), button);
nuclear = gtk_nuclear_symbolic_new ();
image = gtk_image_new_from_paintable (nuclear);
gtk_button_set_child (GTK_BUTTON (button), image);
g_signal_connect (button, "clicked", G_CALLBACK (nuclear_button_clicked), nuclear);
g_object_unref (nuclear);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
gtk_window_destroy (GTK_WINDOW (window));
return window;
}

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

@@ -0,0 +1,348 @@
/* 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"
#include "gsk/gskpathdashprivate.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 (2.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)
{
PangoLayout *layout;
PangoFontDescription *desc;
GskPathBuilder *builder;
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);
builder = gsk_path_builder_new ();
gsk_path_builder_add_layout (builder, layout);
return gsk_path_builder_free_to_path (builder);
}
static gboolean
build_path (GskPathOperation op,
const graphene_point_t *pts,
gsize n_pts,
float weight,
gpointer user_data)
{
GskPathBuilder *builder = user_data;
switch (op)
{
case GSK_PATH_MOVE:
gsk_path_builder_move_to (builder, pts[0].x, pts[0].y);
break;
case GSK_PATH_CLOSE:
gsk_path_builder_close (builder);
break;
case GSK_PATH_LINE:
gsk_path_builder_line_to (builder, pts[1].x, pts[1].y);
break;
case GSK_PATH_CURVE:
gsk_path_builder_curve_to (builder, pts[1].x, pts[1].y, pts[2].x, pts[2].y, pts[3].x, pts[3].y);
break;
case GSK_PATH_CONIC:
gsk_path_builder_conic_to (builder, pts[1].x, pts[1].y, pts[2].x, pts[2].y, weight);
break;
default:
g_assert_not_reached ();
break;
}
return TRUE;
}
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;
GskStroke *stroke;
builder = gsk_path_builder_new ();
gsk_path_builder_add_segment (builder,
measure,
#if 1
0.0, gsk_path_measure_get_length (measure));
#else
progress > 1 ? (progress - 1) * gsk_path_measure_get_length (measure) : 0.0,
(progress < 1 ? progress : 1.0) * gsk_path_measure_get_length (measure));
#endif
path = gsk_path_builder_free_to_path (builder);
stroke = gsk_stroke_new (1);
gsk_stroke_set_dash (stroke, (float[2]) { 10, 5 }, 2);
gsk_stroke_set_dash_offset (stroke, - (gdk_frame_clock_get_frame_time (frame_clock) % G_USEC_PER_SEC) * 15. / G_USEC_PER_SEC);
builder = gsk_path_builder_new ();
gsk_path_dash (path, stroke, 0.2, build_path, builder);
gsk_path_unref (path);
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, GSK_PATH_FOREACH_ALLOW_CURVE, 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 && self->line_path)
{
GskPathBuilder *builder;
/* draw the control line */
stroke = gsk_stroke_new (1.0);
gtk_snapshot_push_stroke (snapshot, self->line_path, stroke);
gsk_stroke_free (stroke);
gtk_snapshot_append_color (snapshot, &(GdkRGBA) { 0, 0, 0, 1 }, &GRAPHENE_RECT_INIT (0, 0, width, height));
gtk_snapshot_pop (snapshot);
/* draw the points */
builder = gsk_path_builder_new ();
for (i = 0; i < 4; i++)
{
gsk_path_builder_add_circle (builder, &GRAPHENE_POINT_INIT (self->points[i].x * width, self->points[i].y * height), POINT_SIZE);
}
path = gsk_path_builder_free_to_path (builder);
gtk_snapshot_push_fill (snapshot, path, GSK_FILL_RULE_WINDING);
gtk_snapshot_append_color (snapshot, &(GdkRGBA) { 1, 1, 1, 1 }, &GRAPHENE_RECT_INIT (0, 0, width, height));
gtk_snapshot_pop (snapshot);
stroke = gsk_stroke_new (1.0);
gtk_snapshot_push_stroke (snapshot, path, stroke);
gsk_stroke_free (stroke);
gtk_snapshot_append_color (snapshot, &(GdkRGBA) { 0, 0, 0, 1 }, &GRAPHENE_RECT_INIT (0, 0, width, height));
gtk_snapshot_pop (snapshot);
gsk_path_unref (path);
}
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

@@ -1,7 +1,7 @@
/* Peg Solitaire
* #Keywords: GtkGridView, game
*
* This demo demonstrates how to use drag-and-drop to implement peg solitaire.
* This demo demonstrates how to use drag'n'drop to implement peg solitaire.
*
*/
@@ -98,7 +98,7 @@ solitaire_peg_init (SolitairePeg *peg)
/* Add a little setter for the peg's position.
* We want to track those so that we can check for legal moves
* during drag-and-drop operations.
* during drag'n'drop operations.
*/
static void
solitaire_peg_set_position (SolitairePeg *peg,

View File

@@ -25,43 +25,43 @@ show_shortcuts (GtkWidget *window,
g_object_unref (builder);
}
G_MODULE_EXPORT void
void
shortcuts_builder_shortcuts (GtkWidget *window)
{
show_shortcuts (window, "shortcuts-builder", NULL);
}
G_MODULE_EXPORT void
void
shortcuts_gedit_shortcuts (GtkWidget *window)
{
show_shortcuts (window, "shortcuts-gedit", NULL);
}
G_MODULE_EXPORT void
void
shortcuts_clocks_shortcuts (GtkWidget *window)
{
show_shortcuts (window, "shortcuts-clocks", NULL);
}
G_MODULE_EXPORT void
void
shortcuts_clocks_shortcuts_stopwatch (GtkWidget *window)
{
show_shortcuts (window, "shortcuts-clocks", "stopwatch");
}
G_MODULE_EXPORT void
void
shortcuts_boxes_shortcuts (GtkWidget *window)
{
show_shortcuts (window, "shortcuts-boxes", NULL);
}
G_MODULE_EXPORT void
void
shortcuts_boxes_shortcuts_wizard (GtkWidget *window)
{
show_shortcuts (window, "shortcuts-boxes", "wizard");
}
G_MODULE_EXPORT void
void
shortcuts_boxes_shortcuts_display (GtkWidget *window)
{
show_shortcuts (window, "shortcuts-boxes", "display");

View File

@@ -2,7 +2,6 @@
#include <float.h>
#include <math.h>
#include <glib.h>
#include <assert.h>
/* See Golub and Reinsch,
* "Handbook for Automatic Computation vol II - Linear Algebra",
@@ -40,9 +39,6 @@ householder_reduction (double *A,
double *pu, *pui, *pv, *pvi;
double half_norm_squared;
assert (nrows >= 2);
assert (ncols >= 2);
memcpy (U, A, sizeof (double) * nrows * ncols);
diagonal[0] = 0.0;
@@ -209,9 +205,6 @@ givens_reduction (int nrows,
int rotation_test;
int iteration_count;
assert (nrows >= 2);
assert (ncols >= 2);
for (i = 0, x = 0.0; i < ncols; i++)
{
y = fabs (diagonal[i]) + fabs (superdiagonal[i]);
@@ -349,9 +342,6 @@ sort_singular_values (int nrows,
double temp;
double *p1, *p2;
assert (nrows >= 2);
assert (ncols >= 2);
for (i = 0; i < ncols - 1; i++)
{
max_index = i;
@@ -443,12 +433,9 @@ singular_value_decomposition_solve (double *U,
double d;
double tolerance;
assert (nrows >= 2);
assert (ncols >= 2);
tolerance = DBL_EPSILON * S[0] * (double) ncols;
for (i = 0, pv = V; i < ncols; i++, pv += ncols)
for ( i = 0, pv = V; i < ncols; i++, pv += ncols)
{
x[i] = 0.0;
for (j = 0; j < ncols; j++)

View File

@@ -12,7 +12,7 @@
#include <math.h>
#include <stdlib.h>
G_MODULE_EXPORT int
int
spinbutton_hex_spin_input (GtkSpinButton *spin_button,
double *new_val)
{
@@ -29,7 +29,7 @@ spinbutton_hex_spin_input (GtkSpinButton *spin_button,
return TRUE;
}
G_MODULE_EXPORT int
int
spinbutton_hex_spin_output (GtkSpinButton *spin_button)
{
GtkAdjustment *adjustment;
@@ -49,7 +49,7 @@ spinbutton_hex_spin_output (GtkSpinButton *spin_button)
return TRUE;
}
G_MODULE_EXPORT int
int
spinbutton_time_spin_input (GtkSpinButton *spin_button,
double *new_val)
{
@@ -88,7 +88,7 @@ spinbutton_time_spin_input (GtkSpinButton *spin_button,
return TRUE;
}
G_MODULE_EXPORT int
int
spinbutton_time_spin_output (GtkSpinButton *spin_button)
{
GtkAdjustment *adjustment;
@@ -122,7 +122,7 @@ static const char *month[12] = {
"December"
};
G_MODULE_EXPORT int
int
spinbutton_month_spin_input (GtkSpinButton *spin_button,
double *new_val)
{
@@ -151,7 +151,7 @@ spinbutton_month_spin_input (GtkSpinButton *spin_button,
return TRUE;
}
G_MODULE_EXPORT int
int
spinbutton_month_spin_output (GtkSpinButton *spin_button)
{
GtkAdjustment *adjustment;

View File

@@ -7,68 +7,186 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
static void
draw_text (GtkDrawingArea *da,
cairo_t *cr,
int width,
int height,
gpointer data)
#define TEXT_TYPE_MASK_DEMO (text_mask_demo_get_type ())
G_DECLARE_FINAL_TYPE (TextMaskDemo, text_mask_demo, TEXT, MASK_DEMO, GtkWidget)
struct _TextMaskDemo
{
cairo_pattern_t *pattern;
PangoLayout *layout;
GtkWidget parent_instance;
char *text;
PangoFontDescription *desc;
GskPath *path;
};
cairo_save (cr);
struct _TextMaskDemoClass
{
GtkWidgetClass parent_class;
};
layout = gtk_widget_create_pango_layout (GTK_WIDGET (da), "Pango power!\nPango power!\nPango power!");
desc = pango_font_description_from_string ("sans bold 34");
pango_layout_set_font_description (layout, desc);
pango_font_description_free (desc);
G_DEFINE_TYPE (TextMaskDemo, text_mask_demo, GTK_TYPE_WIDGET)
cairo_move_to (cr, 30, 20);
pango_cairo_layout_path (cr, layout);
g_object_unref (layout);
static void
update_path (TextMaskDemo *demo)
{
PangoLayout *layout;
GskPathBuilder *builder;
pattern = cairo_pattern_create_linear (0.0, 0.0, width, height);
cairo_pattern_add_color_stop_rgb (pattern, 0.0, 1.0, 0.0, 0.0);
cairo_pattern_add_color_stop_rgb (pattern, 0.2, 1.0, 0.0, 0.0);
cairo_pattern_add_color_stop_rgb (pattern, 0.3, 1.0, 1.0, 0.0);
cairo_pattern_add_color_stop_rgb (pattern, 0.4, 0.0, 1.0, 0.0);
cairo_pattern_add_color_stop_rgb (pattern, 0.6, 0.0, 1.0, 1.0);
cairo_pattern_add_color_stop_rgb (pattern, 0.7, 0.0, 0.0, 1.0);
cairo_pattern_add_color_stop_rgb (pattern, 0.8, 1.0, 0.0, 1.0);
cairo_pattern_add_color_stop_rgb (pattern, 1.0, 1.0, 0.0, 1.0);
g_clear_pointer (&demo->path, gsk_path_unref);
cairo_set_source (cr, pattern);
cairo_fill_preserve (cr);
layout = gtk_widget_create_pango_layout (GTK_WIDGET (demo), demo->text);
pango_layout_set_font_description (layout, demo->desc);
cairo_pattern_destroy (pattern);
builder = gsk_path_builder_new ();
gsk_path_builder_add_layout (builder, layout);
demo->path = gsk_path_builder_free_to_path (builder);
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
cairo_set_line_width (cr, 0.5);
cairo_stroke (cr);
gtk_widget_queue_draw (GTK_WIDGET (demo));
}
cairo_restore (cr);
static void
text_mask_demo_init (TextMaskDemo *demo)
{
demo->text = g_strdup ("No text. No fun");
demo->desc = pango_font_description_from_string ("Cantarell 20");
update_path (demo);
}
static void
text_mask_demo_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot)
{
TextMaskDemo *demo = TEXT_MASK_DEMO (widget);
float width, height;
GskColorStop stops[4];
GskStroke *stroke;
gdk_rgba_parse (&stops[0].color, "red");
gdk_rgba_parse (&stops[1].color, "green");
gdk_rgba_parse (&stops[2].color, "yellow");
gdk_rgba_parse (&stops[3].color, "blue");
width = gtk_widget_get_width (widget);
height = gtk_widget_get_height (widget);
stops[0].offset = 0;
stops[1].offset = 0.25;
stops[2].offset = 0.50;
stops[3].offset = 0.75;
gtk_snapshot_push_fill (snapshot, demo->path, GSK_FILL_RULE_WINDING);
gtk_snapshot_append_linear_gradient (snapshot,
&GRAPHENE_RECT_INIT (0, 0, width, height),
&GRAPHENE_POINT_INIT (0, 0),
&GRAPHENE_POINT_INIT (width, height),
stops, 4);
gtk_snapshot_pop (snapshot);
stroke = gsk_stroke_new (1.0);
gtk_snapshot_push_stroke (snapshot, demo->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);
}
void
text_mask_demo_measure (GtkWidget *widget,
GtkOrientation orientation,
int for_size,
int *minimum_size,
int *natural_size,
int *minimum_baseline,
int *natural_baseline)
{
TextMaskDemo *demo = TEXT_MASK_DEMO (widget);
graphene_rect_t rect;
gsk_path_get_bounds (demo->path, &rect);
if (orientation == GTK_ORIENTATION_HORIZONTAL)
*minimum_size = *natural_size = rect.size.width;
else
*minimum_size = *natural_size = rect.size.height;
}
static void
text_mask_demo_finalize (GObject *object)
{
TextMaskDemo *demo = TEXT_MASK_DEMO (object);
g_free (demo->text);
pango_font_description_free (demo->desc);
gsk_path_unref (demo->path);
G_OBJECT_CLASS (text_mask_demo_parent_class)->finalize (object);
}
static void
text_mask_demo_class_init (TextMaskDemoClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
object_class->finalize = text_mask_demo_finalize;
widget_class->snapshot = text_mask_demo_snapshot;
widget_class->measure = text_mask_demo_measure;
}
static GtkWidget *
text_mask_demo_new (void)
{
return g_object_new (text_mask_demo_get_type (), NULL);
}
static void
text_mask_demo_set_text (TextMaskDemo *demo,
const char *text)
{
g_free (demo->text);
demo->text = g_strdup (text);
update_path (demo);
}
static void
text_mask_demo_set_font (TextMaskDemo *demo,
PangoFontDescription *desc)
{
pango_font_description_free (demo->desc);
demo->desc = pango_font_description_copy (desc);
update_path (demo);
}
GtkWidget *
do_textmask (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;
static GtkWidget *da;
static GtkWidget *demo;
if (!window)
{
PangoFontDescription *desc;
window = gtk_window_new ();
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
gtk_widget_set_size_request (window, 400, 240);
gtk_window_set_title (GTK_WINDOW (window), "Text Mask");
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
da = gtk_drawing_area_new ();
demo = text_mask_demo_new ();
text_mask_demo_set_text (TEXT_MASK_DEMO (demo), "Pango power!\nPango power!\nPango power!");
desc = pango_font_description_from_string ("Sans Bold 34");
text_mask_demo_set_font (TEXT_MASK_DEMO (demo), desc);
pango_font_description_free (desc);
gtk_window_set_child (GTK_WINDOW (window), da);
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (da), draw_text, NULL, NULL);
gtk_window_set_child (GTK_WINDOW (window), demo);
}
if (!gtk_widget_get_visible (window))

View File

@@ -41,26 +41,11 @@ open_clicked_cb (GtkWidget *button,
"_Open",
"_Cancel");
filter = gtk_file_filter_new ();
gtk_file_filter_add_pattern (filter, "*");
gtk_file_filter_set_name (filter, "All Files");
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
g_object_unref (filter);
filter = gtk_file_filter_new ();
gtk_file_filter_add_mime_type (filter, "image/*");
gtk_file_filter_set_name (filter, "Images");
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
g_object_unref (filter);
filter = gtk_file_filter_new ();
gtk_file_filter_add_mime_type (filter, "video/*");
gtk_file_filter_set_name (filter, "Video");
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filter);
g_object_unref (filter);
gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (dialog), TRUE);
g_signal_connect (dialog, "response", G_CALLBACK (open_dialog_response_cb), video);
gtk_native_dialog_show (GTK_NATIVE_DIALOG (dialog));

View File

@@ -4,8 +4,6 @@
#include "iconbrowserapp.h"
#include "iconbrowserwin.h"
#include "demo_conf.h"
struct _IconBrowserApp
{
GtkApplication parent;
@@ -77,25 +75,21 @@ about_activated (GSimpleAction *action,
gtk_get_minor_version (),
gtk_get_micro_version ());
g_string_append_printf (s, "\nIcon theme\n\t%s", icon_theme);
version = g_strdup_printf ("%s%s%s\nRunning against GTK %d.%d.%d",
version = g_strdup_printf ("%s\nRunning against GTK %d.%d.%d",
PACKAGE_VERSION,
g_strcmp0 (PROFILE, "devel") == 0 ? "-" : "",
g_strcmp0 (PROFILE, "devel") == 0 ? VCS_TAG : "",
gtk_get_major_version (),
gtk_get_minor_version (),
gtk_get_micro_version ());
gtk_show_about_dialog (GTK_WINDOW (gtk_application_get_active_window (app)),
"program-name", g_strcmp0 (PROFILE, "devel") == 0
? "GTK Icon Browser (Development)"
: "GTK Icon Browser",
"program-name", "GTK Icon Browser",
"version", version,
"copyright", "©1997—2021 The GTK Team",
"copyright", "©1997—2020 The GTK Team",
"license-type", GTK_LICENSE_LGPL_2_1,
"website", "http://www.gtk.org",
"comments", "Program to browse themed icons",
"authors", authors,
"logo-icon-name", "org.gtk.IconBrowser4",
"logo-icon-name", "org.gtk.Demo4",
"title", "About GTK Icon Browser",
"system-information", s->str,
NULL);
@@ -135,10 +129,6 @@ icon_browser_app_activate (GApplication *app)
IconBrowserWindow *win;
win = icon_browser_window_new (ICON_BROWSER_APP (app));
if (g_strcmp0 (PROFILE, "devel") == 0)
gtk_widget_add_css_class (GTK_WIDGET (win), "devel");
gtk_window_present (GTK_WINDOW (win));
}

View File

@@ -14,10 +14,8 @@ struct _IconBrowserWindow
GtkWidget *searchbar;
GListModel *icon_filter_model;
GListStore *icon_store;
GListModel *context_model;
GListStore *context_store;
GtkFilter *name_filter;
GtkFilter *search_mode_filter;
GtkWidget *details;
GtkWidget *image1;
GtkWidget *image2;
@@ -281,31 +279,11 @@ drag_prepare_texture (GtkDragSource *source,
GtkWidget *widget)
{
GdkPaintable *paintable = get_image_paintable (GTK_IMAGE (widget));
GtkSnapshot *snapshot;
double width, height;
GskRenderNode *node;
GskRenderer *renderer;
GdkTexture *texture;
GdkContentProvider *ret;
if (!GDK_IS_PAINTABLE (paintable))
return NULL;
snapshot = gtk_snapshot_new ();
width = gdk_paintable_get_intrinsic_width (paintable);
height = gdk_paintable_get_intrinsic_height (paintable);
gdk_paintable_snapshot (paintable, snapshot, width, height);
node = gtk_snapshot_free_to_node (snapshot);
renderer = gtk_native_get_renderer (gtk_widget_get_native (widget));
texture = gsk_renderer_render_texture (renderer, node, &GRAPHENE_RECT_INIT (0, 0, width, height));
ret = gdk_content_provider_new_typed (GDK_TYPE_TEXTURE, texture);
g_object_unref (texture);
gsk_render_node_unref (node);
return ret;
return gdk_content_provider_new_typed (GDK_TYPE_PAINTABLE, paintable);
}
static GdkContentProvider *
@@ -356,28 +334,6 @@ setup_scalable_image_dnd (GtkWidget *image)
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (source));
}
static void
search_mode_toggled (GtkSearchBar *searchbar,
GParamSpec *pspec,
IconBrowserWindow *win)
{
if (gtk_search_bar_get_search_mode (searchbar))
gtk_single_selection_set_selected (GTK_SINGLE_SELECTION (win->context_model), GTK_INVALID_LIST_POSITION);
else if (gtk_single_selection_get_selected (GTK_SINGLE_SELECTION (win->context_model)) == GTK_INVALID_LIST_POSITION)
gtk_single_selection_set_selected (GTK_SINGLE_SELECTION (win->context_model), 0);
gtk_filter_changed (win->search_mode_filter, GTK_FILTER_CHANGE_DIFFERENT);
}
static void
selected_name_changed (GtkSingleSelection *selection,
GParamSpec *pspec,
IconBrowserWindow *win)
{
if (gtk_single_selection_get_selected (selection) != GTK_INVALID_LIST_POSITION)
gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (win->searchbar), FALSE);
}
static void
icon_browser_window_init (IconBrowserWindow *win)
{
@@ -404,9 +360,6 @@ icon_browser_window_init (IconBrowserWindow *win)
win->name_filter = GTK_FILTER (gtk_custom_filter_new (filter_by_icon_name, NULL, NULL));
gtk_multi_filter_append (GTK_MULTI_FILTER (filter), g_object_ref (win->name_filter));
g_signal_connect (win->searchbar, "notify::search-mode-enabled", G_CALLBACK (search_mode_toggled), win);
g_signal_connect (win->context_model, "notify::selected", G_CALLBACK (selected_name_changed), win);
}
static void
@@ -436,7 +389,6 @@ icon_browser_window_class_init (IconBrowserWindowClass *class)
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, searchbar);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, icon_store);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, icon_filter_model);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, context_model);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, context_store);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, details);
@@ -450,7 +402,6 @@ icon_browser_window_class_init (IconBrowserWindowClass *class)
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, image8);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, label8);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, description);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, search_mode_filter);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), item_activated);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), copy_to_clipboard);

View File

@@ -14,7 +14,7 @@ iconbrowser_resources = gnome.compile_resources('iconbrowser_resources',
executable('gtk4-icon-browser',
sources: [iconbrowser_sources, iconbrowser_resources],
c_args: common_cflags,
dependencies: [ libgtk_dep, demo_conf_h ],
dependencies: libgtk_dep,
include_directories: confinc,
gui_app: true,
link_args: extra_demo_ldflags,
@@ -32,10 +32,5 @@ endforeach
install_data('org.gtk.IconBrowser4.desktop', install_dir: gtk_applicationsdir)
# appdata
configure_file(
input: 'org.gtk.IconBrowser4.appdata.xml.in',
output: 'org.gtk.IconBrowser4.appdata.xml',
configuration: appdata_config,
install_dir: gtk_appdatadir
)
install_data('org.gtk.IconBrowser4.appdata.xml', install_dir: gtk_appdatadir)

View File

@@ -1,9 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<id>org.gtk.IconBrowser4</id>
<launchable type="desktop-id">org.gtk.IconBrowser4.desktop</launchable>
<id>org.gtk.IconBrowser4.desktop</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>LGPL-2.1-or-later</project_license>
<project_license>LGPL-2.0+</project_license>
<name>GTK Icon Browser</name>
<summary>Program to browse themed icons</summary>
<description>
@@ -30,11 +29,15 @@
<translation type="gettext">gtk-4.0</translation>
<update_contact>matthias.clasen_at_gmail.com</update_contact>
<developer_name>Matthias Clasen and others</developer_name>
<content_rating type="oars-1.1"/>
<releases>
<release version="@BUILD_VERSION@">
<release version="3.99.0" date="2020-07-30">
<description>
<p>A new build of GTK.</p>
<p>A new developers snapshot towards GTK 4.0.</p>
</description>
</release>
<release version="3.94.0" date="2018-06-25">
<description>
<p>A new developers snapshot towards GTK 4.0.</p>
</description>
</release>
</releases>

View File

@@ -25,14 +25,12 @@
</style>
<child>
<object class="GtkToggleButton" id="normal_radio">
<property name="focus-on-click">0</property>
<property name="label" translatable="yes">Normal</property>
<property name="active">1</property>
</object>
</child>
<child>
<object class="GtkToggleButton" id="symbolic_radio">
<property name="focus-on-click">0</property>
<property name="label" translatable="yes">Symbolic</property>
<property name="group">normal_radio</property>
<signal name="notify::active" handler="symbolic_toggled" swapped="yes" after="yes"/>
@@ -42,7 +40,6 @@
</child>
<child type="end">
<object class="GtkMenuButton" id="gear_menu_button">
<property name="focus-on-click">0</property>
<property name="valign">center</property>
<property name="menu-model">gear_menu</property>
<property name="icon-name">open-menu-symbolic</property>
@@ -50,7 +47,6 @@
</child>
<child type="end">
<object class="GtkToggleButton" id="search">
<property name="focus-on-click">0</property>
<style>
<class name="image-button"/>
</style>
@@ -155,32 +151,19 @@
</object>
</child>
<child>
<object class="GtkAnyFilter">
<child>
<object class="GtkBoolFilter" id="search_mode_filter">
<property name="expression">
<lookup name="search-mode-enabled">
searchbar
</lookup>
</property>
</object>
</child>
<child>
<object class="GtkStringFilter">
<property name="ignore-case">0</property>
<property name="match-mode">exact</property>
<property name="expression">
<lookup name="context" type="IbIcon"/>
</property>
<binding name="search">
<lookup name="id" type="IbContext">
<lookup name="selected-item" type="GtkSingleSelection">
context_model
</lookup>
</lookup>
</binding>
</object>
</child>
<object class="GtkStringFilter">
<property name="ignore-case">0</property>
<property name="match-mode">exact</property>
<property name="expression">
<lookup name="context" type="IbIcon"/>
</property>
<binding name="search">
<lookup name="id" type="IbContext">
<lookup name="selected-item" type="GtkSingleSelection">
context_model
</lookup>
</lookup>
</binding>
</object>
</child>
</object>

View File

@@ -1,21 +1,3 @@
gen_demo_header = find_program('../build-aux/meson/gen-demo-header.py')
demo_profile = get_option('profile')
demo_conf_h = declare_dependency(
sources: custom_target('demo-header',
command: [gen_demo_header, meson.source_root(), demo_profile],
capture: true,
output: 'demo_conf.h',
build_by_default: true,
build_always_stale: true,
)
)
# appdata
appdata_config = configuration_data()
appdata_config.set('BUILD_VERSION', meson.project_version())
subdir('constraint-editor')
subdir('gtk-demo')
subdir('icon-browser')

View File

@@ -2,8 +2,8 @@
<interface>
<object class="GtkWindow" id="window">
<property name="title" translatable="yes">Help</property>
<property name="default-width">920</property>
<property name="default-height">600</property>
<property name="default-width">720</property>
<property name="default-height">520</property>
<child>
<object class="GtkScrolledWindow">
<child>
@@ -13,7 +13,6 @@
<property name="right-margin">20</property>
<property name="top-margin">20</property>
<property name="bottom-margin">20</property>
<property name="monospace">1</property>
<property name="buffer">
<object class="GtkTextBuffer" id="buffer"/>
</property>

View File

@@ -12,7 +12,7 @@ node_editor_resources = gnome.compile_resources('node_editor_resources',
executable('gtk4-node-editor',
sources: [node_editor_sources, node_editor_resources],
dependencies: [ libgtk_dep, demo_conf_h ],
dependencies: libgtk_dep,
include_directories: confinc,
c_args: [
'-DNODE_EDITOR_SOURCE_DIR="@0@/../../testsuite/gsk/compare/"'.format(meson.current_source_dir())

View File

@@ -23,8 +23,6 @@
#include "node-editor-window.h"
#include "demo_conf.h"
static const char *css =
"textview.editor {"
" color: rgb(192, 197, 206);"
@@ -96,26 +94,22 @@ activate_about (GSimpleAction *action,
g_string_append_printf (s, "\nRenderer\n\t%s", renderer);
version = g_strdup_printf ("%s%s%s\nRunning against GTK %d.%d.%d",
version = g_strdup_printf ("%s\nRunning against GTK %d.%d.%d",
PACKAGE_VERSION,
g_strcmp0 (PROFILE, "devel") == 0 ? "-" : "",
g_strcmp0 (PROFILE, "devel") == 0 ? VCS_TAG : "",
gtk_get_major_version (),
gtk_get_minor_version (),
gtk_get_micro_version ());
dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG,
"transient-for", gtk_application_get_active_window (app),
"program-name", g_strcmp0 (PROFILE, "devel") == 0
? "GTK Node Editor (Development)"
: "GTK Node Editor",
"program-name", "GTK Node Editor",
"version", version,
"copyright", "©2019—2021 The GTK Team",
"copyright", "©2019—2020 The GTK Team",
"license-type", GTK_LICENSE_LGPL_2_1,
"website", "http://www.gtk.org",
"comments", "Program to test GTK rendering",
"authors", (const char *[]){ "Benjamin Otte", "Timm Bäder", NULL},
"logo-icon-name", "org.gtk.gtk4.NodeEditor",
"logo-icon-name", "org.gtk.gtk4.NodeEditor.Devel",
"title", "About GTK Node Editor",
"system-information", s->str,
NULL);
@@ -213,10 +207,6 @@ node_editor_application_activate (GApplication *app)
NodeEditorWindow *win;
win = node_editor_window_new (NODE_EDITOR_APPLICATION (app));
if (g_strcmp0 (PROFILE, "devel") == 0)
gtk_widget_add_css_class (GTK_WIDGET (win), "devel");
gtk_window_present (GTK_WINDOW (win));
}

View File

@@ -60,7 +60,7 @@ struct _NodeEditorWindow
GtkWidget *renderer_listbox;
GListStore *renderers;
GskRenderNode *node;
GdkPaintable *paintable;
GFileMonitor *file_monitor;
@@ -167,6 +167,7 @@ static void
text_changed (GtkTextBuffer *buffer,
NodeEditorWindow *self)
{
GskRenderNode *node;
char *text;
GBytes *bytes;
GtkTextIter iter;
@@ -177,12 +178,10 @@ text_changed (GtkTextBuffer *buffer,
text_buffer_remove_all_tags (self->text_buffer);
bytes = g_bytes_new_take (text, strlen (text));
g_clear_pointer (&self->node, gsk_render_node_unref);
/* If this is too slow, go fix the parser performance */
self->node = gsk_render_node_deserialize (bytes, deserialize_error_func, self);
node = gsk_render_node_deserialize (bytes, deserialize_error_func, self);
g_bytes_unref (bytes);
if (self->node)
if (node)
{
/* XXX: Is this code necessary or can we have API to turn nodes into paintables? */
GtkSnapshot *snapshot;
@@ -191,9 +190,10 @@ text_changed (GtkTextBuffer *buffer,
guint i;
snapshot = gtk_snapshot_new ();
gsk_render_node_get_bounds (self->node, &bounds);
gsk_render_node_get_bounds (node, &bounds);
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (- bounds.origin.x, - bounds.origin.y));
gtk_snapshot_append_node (snapshot, self->node);
gtk_snapshot_append_node (snapshot, node);
gsk_render_node_unref (node);
paintable = gtk_snapshot_free_to_paintable (snapshot, &bounds.size);
gtk_picture_set_paintable (GTK_PICTURE (self->picture), paintable);
for (i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (self->renderers)); i++)
@@ -337,9 +337,15 @@ text_view_query_tooltip_cb (GtkWidget *widget,
}
static gboolean
load_bytes (NodeEditorWindow *self,
GBytes *bytes)
load_file_contents (NodeEditorWindow *self,
GFile *file)
{
GBytes *bytes;
bytes = g_file_load_bytes (file, NULL, NULL, NULL);
if (bytes == NULL)
return FALSE;
if (!g_utf8_validate (g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes), NULL))
{
g_bytes_unref (bytes);
@@ -355,105 +361,6 @@ load_bytes (NodeEditorWindow *self,
return TRUE;
}
static gboolean
load_file_contents (NodeEditorWindow *self,
GFile *file)
{
GBytes *bytes;
bytes = g_file_load_bytes (file, NULL, NULL, NULL);
if (bytes == NULL)
return FALSE;
return load_bytes (self, bytes);
}
static GdkContentProvider *
on_picture_drag_prepare_cb (GtkDragSource *source,
double x,
double y,
NodeEditorWindow *self)
{
if (self->node == NULL)
return NULL;
return gdk_content_provider_new_typed (GSK_TYPE_RENDER_NODE, self->node);
}
static void
on_picture_drop_read_done_cb (GObject *source,
GAsyncResult *res,
gpointer data)
{
NodeEditorWindow *self = data;
GOutputStream *stream = G_OUTPUT_STREAM (source);
GdkDrop *drop = g_object_get_data (source, "drop");
GdkDragAction action = 0;
GBytes *bytes;
if (g_output_stream_splice_finish (stream, res, NULL) >= 0)
{
bytes = g_memory_output_stream_steal_as_bytes (G_MEMORY_OUTPUT_STREAM (stream));
if (load_bytes (self, bytes))
action = GDK_ACTION_COPY;
}
g_object_unref (self);
gdk_drop_finish (drop, action);
g_object_unref (drop);
return;
}
static void
on_picture_drop_read_cb (GObject *source,
GAsyncResult *res,
gpointer data)
{
NodeEditorWindow *self = data;
GdkDrop *drop = GDK_DROP (source);
GInputStream *input;
GOutputStream *output;
input = gdk_drop_read_finish (drop, res, NULL, NULL);
if (input == NULL)
{
g_object_unref (self);
gdk_drop_finish (drop, 0);
return;
}
output = g_memory_output_stream_new_resizable ();
g_object_set_data (G_OBJECT (output), "drop", drop);
g_object_ref (drop);
g_output_stream_splice_async (output,
input,
G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET,
G_PRIORITY_DEFAULT,
NULL,
on_picture_drop_read_done_cb,
self);
g_object_unref (output);
g_object_unref (input);
}
static gboolean
on_picture_drop_cb (GtkDropTargetAsync *dest,
GdkDrop *drop,
double x,
double y,
NodeEditorWindow *self)
{
gdk_drop_read_async (drop,
(const char *[2]) { "application/x-gtk-render-node", NULL },
G_PRIORITY_DEFAULT,
NULL,
on_picture_drop_read_cb,
g_object_ref (self));
return TRUE;
}
static void
file_changed_cb (GFileMonitor *monitor,
GFile *file,
@@ -646,6 +553,7 @@ create_cairo_texture (NodeEditorWindow *self)
GskRenderer *renderer;
GskRenderNode *node;
GdkTexture *texture;
GdkSurface *surface;
paintable = gtk_picture_get_paintable (GTK_PICTURE (self->picture));
if (paintable == NULL ||
@@ -658,8 +566,9 @@ create_cairo_texture (NodeEditorWindow *self)
if (node == NULL)
return NULL;
surface = gtk_native_get_surface (gtk_widget_get_native (GTK_WIDGET (self)));
renderer = gsk_cairo_renderer_new ();
gsk_renderer_realize (renderer, NULL, NULL);
gsk_renderer_realize (renderer, surface, NULL);
texture = gsk_renderer_render_texture (renderer, node, NULL);
gsk_render_node_unref (node);
@@ -725,24 +634,6 @@ export_image_cb (GtkWidget *button,
gtk_widget_show (dialog);
}
static void
clip_image_cb (GtkWidget *button,
NodeEditorWindow *self)
{
GdkTexture *texture;
GdkClipboard *clipboard;
texture = create_texture (self);
if (texture == NULL)
return;
clipboard = gtk_widget_get_clipboard (GTK_WIDGET (self));
gdk_clipboard_set_texture (clipboard, texture);
g_object_unref (texture);
}
static void
testcase_name_entry_changed_cb (GtkWidget *button,
GParamSpec *pspec,
@@ -809,16 +700,6 @@ out:
g_free (source_dir);
}
static void
dark_mode_cb (GtkToggleButton *button,
GParamSpec *pspec,
NodeEditorWindow *self)
{
g_object_set (gtk_widget_get_settings (GTK_WIDGET (self)),
"gtk-application-prefer-dark-theme", gtk_toggle_button_get_active (button),
NULL);
}
static void
node_editor_window_finalize (GObject *object)
{
@@ -826,7 +707,6 @@ node_editor_window_finalize (GObject *object)
g_array_free (self->errors, TRUE);
g_clear_pointer (&self->node, gsk_render_node_unref);
g_clear_object (&self->renderers);
G_OBJECT_CLASS (node_editor_window_parent_class)->finalize (object);
@@ -837,18 +717,16 @@ node_editor_window_add_renderer (NodeEditorWindow *self,
GskRenderer *renderer,
const char *description)
{
GdkSurface *surface;
GdkPaintable *paintable;
if (!gsk_renderer_realize (renderer, NULL, NULL))
{
GdkSurface *surface = gtk_native_get_surface (GTK_NATIVE (self));
g_assert (surface != NULL);
surface = gtk_native_get_surface (GTK_NATIVE (self));
g_assert (surface != NULL);
if (!gsk_renderer_realize (renderer, surface, NULL))
{
g_object_unref (renderer);
return;
}
if (renderer != NULL && !gsk_renderer_realize (renderer, surface, NULL))
{
g_object_unref (renderer);
return;
}
paintable = gtk_renderer_paintable_new (renderer, gtk_picture_get_paintable (GTK_PICTURE (self->picture)));
@@ -934,12 +812,8 @@ node_editor_window_class_init (NodeEditorWindowClass *class)
gtk_widget_class_bind_template_callback (widget_class, open_cb);
gtk_widget_class_bind_template_callback (widget_class, save_cb);
gtk_widget_class_bind_template_callback (widget_class, export_image_cb);
gtk_widget_class_bind_template_callback (widget_class, clip_image_cb);
gtk_widget_class_bind_template_callback (widget_class, testcase_save_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, testcase_name_entry_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, dark_mode_cb);
gtk_widget_class_bind_template_callback (widget_class, on_picture_drag_prepare_cb);
gtk_widget_class_bind_template_callback (widget_class, on_picture_drop_cb);
}
static GtkWidget *
@@ -1036,26 +910,6 @@ node_editor_window_init (NodeEditorWindow *self)
self->text_buffer = gtk_text_buffer_new (self->tag_table);
g_signal_connect (self->text_buffer, "changed", G_CALLBACK (text_changed), self);
gtk_text_view_set_buffer (GTK_TEXT_VIEW (self->text_view), self->text_buffer);
/* Default */
gtk_text_buffer_set_text (self->text_buffer,
"shadow {\n"
" child: texture {\n"
" bounds: 0 0 128 128;\n"
" texture: url(\"resource:///org/gtk/gtk4/node-editor/icons/apps/org.gtk.gtk4.NodeEditor.svg\");\n"
" }\n"
" shadows: rgba(0,0,0,0.5) 0 1 12;\n"
"}\n"
"\n"
"transform {\n"
" child: text {\n"
" color: rgb(46,52,54);\n"
" font: \"Cantarell Bold 11\";\n"
" glyphs: \"GTK Node Editor\";\n"
" offset: 8 14.418;\n"
" }\n"
" transform: translate(0, 140);\n"
"}", -1);
}
NodeEditorWindow *

View File

@@ -102,7 +102,6 @@
<object class="GtkHeaderBar" id="header">
<child type="start">
<object class="GtkButton">
<property name="focus-on-click">0</property>
<property name="icon-name">document-open-symbolic</property>
<property name="tooltip-text">Open node file</property>
<signal name="clicked" handler="open_cb"/>
@@ -110,7 +109,6 @@
</child>
<child type="start">
<object class="GtkButton">
<property name="focus-on-click">0</property>
<property name="icon-name">document-save-symbolic</property>
<property name="tooltip-text">Save to node file</property>
<signal name="clicked" handler="save_cb"/>
@@ -118,45 +116,29 @@
</child>
<child type="start">
<object class="GtkButton">
<property name="focus-on-click">0</property>
<property name="icon-name">insert-image-symbolic</property>
<property name="tooltip-text">Export to image</property>
<signal name="clicked" handler="export_image_cb"/>
</object>
</child>
<child type="start">
<object class="GtkButton">
<property name="focus-on-click">0</property>
<property name="icon-name">edit-copy-symbolic</property>
<property name="tooltip-text">Copy image to clipboard</property>
<signal name="clicked" handler="clip_image_cb"/>
<object class="GtkSeparator">
<property name="orientation">vertical</property>
</object>
</child>
<child type="start">
<object class="GtkMenuButton">
<property name="focus-on-click">0</property>
<property name="label">Save Testcase</property>
<property name="popover">testcase_popover</property>
</object>
</child>
<child type="end">
<object class="GtkMenuButton" id="gear_menu_button">
<property name="focus-on-click">0</property>
<property name="valign">center</property>
<property name="menu-model">gear_menu</property>
<property name="icon-name">open-menu-symbolic</property>
</object>
</child>
<child type="end">
<object class="GtkToggleButton" id="dark_bg_button">
<property name="focus-on-click">0</property>
<property name="valign">center</property>
<property name="has-frame">0</property>
<property name="icon-name">display-brightness-symbolic</property>
<property name="tooltip-text" translatable="yes">Use a dark background</property>
<signal name="notify::active" handler="dark_mode_cb" swapped="0"/>
</object>
</child>
</object>
</child>
<child>
@@ -198,22 +180,8 @@
<child>
<object class="GtkPicture" id="picture">
<property name="can-shrink">0</property>
<property name="keep-aspect-ratio">1</property>
<property name="halign">center</property>
<property name="valign">center</property>
<child>
<object class="GtkDragSource">
<property name="actions">copy</property>
<signal name="prepare" handler="on_picture_drag_prepare_cb" swapped="no"/>
</object>
</child>
</object>
</child>
<child>
<object class="GtkDropTargetAsync">
<property name="actions">copy</property>
<property name="formats">application/x-gtk-render-node</property>
<signal name="drop" handler="on_picture_drop_cb" swapped="no"/>
</object>
</child>
</object>

View File

@@ -4,6 +4,6 @@
<file preprocess="xml-stripblanks">node-editor-window.ui</file>
<file preprocess="xml-stripblanks">help-window.ui</file>
<file>node-format.md</file>
<file alias='icons/apps/org.gtk.gtk4.NodeEditor.svg'>data/scalable/apps/org.gtk.gtk4.NodeEditor.svg</file>
<file alias='icons/apps/org.gtk.gtk4.NodeEditor.Devel.svg'>data/scalable/apps/org.gtk.gtk4.NodeEditor.Devel.svg</file>
</gresource>
</gresources>

View File

@@ -42,9 +42,9 @@ Creates a node like `gsk_blur_node_new()` with the given properties.
| property | syntax | default | printed |
| -------- | ---------------- | ---------------------- | ----------- |
| colors | `<color>{1,4}` | black | non-default |
| color | `<color>{1,4}` | black | non-default |
| outline | `<rounded-rect>` | 50 | always |
| widths | `<number>{1,4}` | 1 | non-default |
| width | `<number>{1,4}` | 1 | non-default |
Creates a node like `gsk_border_node_new()` with the given properties.
@@ -121,7 +121,7 @@ Creates a node like `gsk_conic_gradient_node_new()` with the given properties.
| property | syntax | default | printed |
| -------- | ---------------- | ---------------------- | ----------- |
| end | `<node>` | color { } | always |
| progress | `<number>` | 0.5 | non-default |
| mode | `<number>` | 0.5 | non-default |
| start | `<node>` | color { } | always |
Creates a node like `gsk_cross_fade_node_new()` with the given properties.
@@ -246,7 +246,7 @@ Creates a node like `gsk_rounded_clip_node_new()` with the given properties.
| property | syntax | default | printed |
| -------- | ---------------- | ---------------------- | ----------- |
| child | `<node>` | color { } | always |
| shadows | `<shadow>` | black 1 1 | always |
| shadow | `<shadow>` | black 1 1 | always |
Creates a node like `gsk_shadow_node_new()` with the given properties.

View File

@@ -1,7 +1,7 @@
executable('gtk4-print-editor',
sources: ['print-editor.c'],
c_args: common_cflags,
dependencies: [ libgtk_dep, demo_conf_h ],
dependencies: libgtk_dep,
include_directories: confinc,
gui_app: true,
link_args: extra_demo_ldflags,

View File

@@ -1,9 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<id>org.gtk.PrintEditor4</id>
<launchable type="desktop-id">org.gtk.PrintEditor4.desktop</launchable>
<id>org.gtk.PrintEditor4.desktop</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>LGPL-2.1-or-later</project_license>
<project_license>LGPL-2.0+</project_license>
<name>GTK Print Editor</name>
<summary>Program to demonstrate GTK printing</summary>
<description>
@@ -25,7 +24,6 @@
<translation type="gettext">gtk-4.0</translation>
<update_contact>matthias.clasen_at_gmail.com</update_contact>
<developer_name>Matthias Clasen and others</developer_name>
<content_rating type="oars-1.1"/>
<releases>
<release version="3.99.0" date="2020-07-30">
<description>

View File

@@ -2,7 +2,7 @@
Name=Print Editor
Comment=A simple editor demonstrating GTK printing
Exec=gtk4-print-editor %f
Icon=org.gtk.PrintEditor4
Icon=org.gtk.PrintEditor4.Devel
Terminal=false
Type=Application
StartupNotify=true

View File

@@ -4,8 +4,6 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include "demo_conf.h"
static GtkWidget *main_window;
static GFile *filename = NULL;
static GtkPageSetup *page_setup = NULL;
@@ -159,7 +157,7 @@ save_file (GFile *save_filename)
error = NULL;
g_file_replace_contents (save_filename,
text, strlen (text),
text, -1,
NULL, FALSE,
G_FILE_CREATE_NONE,
NULL,
@@ -643,26 +641,22 @@ activate_about (GSimpleAction *action,
g_strfreev (backends);
g_free (setting);
version = g_strdup_printf ("%s%s%s\nRunning against GTK %d.%d.%d",
version = g_strdup_printf ("%s\nRunning against GTK %d.%d.%d",
PACKAGE_VERSION,
g_strcmp0 (PROFILE, "devel") == 0 ? "-" : "",
g_strcmp0 (PROFILE, "devel") == 0 ? VCS_TAG : "",
gtk_get_major_version (),
gtk_get_minor_version (),
gtk_get_micro_version ());
dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG,
"transient-for", main_window,
"program-name", g_strcmp0 (PROFILE, "devel") == 0
? "GTK Print Editor (Development)"
: "GTK Print Editor",
"program-name", "GTK Print Editor",
"version", version,
"copyright", "© 2006-2021 Red Hat, Inc",
"copyright", "© 2006-2020 Red Hat, Inc",
"license-type", GTK_LICENSE_LGPL_2_1,
"website", "http://www.gtk.org",
"comments", "Program to demonstrate GTK printing",
"authors", authors,
"logo-icon-name", "org.gtk.PrintEditor4",
"logo-icon-name", "org.gtk.PrintEditor4.Devel",
"title", "About GTK Print Editor",
"system-information", sysinfo->str,
NULL);
@@ -721,6 +715,7 @@ static const char ui_info[] =
" <item>"
" <attribute name='label'>_New</attribute>"
" <attribute name='action'>app.new</attribute>"
" <attribute name='accel'>&lt;Primary&gt;n</attribute>"
" </item>"
" <item>"
" <attribute name='label'>_Open</attribute>"
@@ -729,10 +724,12 @@ static const char ui_info[] =
" <item>"
" <attribute name='label'>_Save</attribute>"
" <attribute name='action'>app.save</attribute>"
" <attribute name='accel'>&lt;Primary&gt;s</attribute>"
" </item>"
" <item>"
" <attribute name='label'>Save _As...</attribute>"
" <attribute name='action'>app.save-as</attribute>"
" <attribute name='accel'>&lt;Primary&gt;s</attribute>"
" </item>"
" </section>"
" <section>"
@@ -753,6 +750,7 @@ static const char ui_info[] =
" <item>"
" <attribute name='label'>_Quit</attribute>"
" <attribute name='action'>app.quit</attribute>"
" <attribute name='accel'>&lt;Primary&gt;q</attribute>"
" </item>"
" </section>"
" </submenu>"
@@ -762,6 +760,7 @@ static const char ui_info[] =
" <item>"
" <attribute name='label'>_About Print Editor</attribute>"
" <attribute name='action'>app.about</attribute>"
" <attribute name='accel'>&lt;Primary&gt;a</attribute>"
" </item>"
" </section>"
" </submenu>"
@@ -789,15 +788,6 @@ startup (GApplication *app)
{
GtkBuilder *builder;
GMenuModel *menubar;
struct {
const char *action_and_target;
const char *accelerators[2];
} accels[] = {
{ "app.new", { "<Control>n", NULL } },
{ "app.quit", { "<Control>q", NULL } },
{ "app.save", { "<Control>s", NULL } },
{ "app.about", { "<Control>a", NULL } },
};
builder = gtk_builder_new ();
gtk_builder_add_from_string (builder, ui_info, -1, NULL);
@@ -806,9 +796,6 @@ startup (GApplication *app)
gtk_application_set_menubar (GTK_APPLICATION (app), menubar);
for (int i = 0; i < G_N_ELEMENTS (accels); i++)
gtk_application_set_accels_for_action (GTK_APPLICATION (app), accels[i].action_and_target, accels[i].accelerators);
g_object_unref (builder);
}
@@ -820,10 +807,6 @@ activate (GApplication *app)
GtkWidget *contents;
main_window = gtk_application_window_new (GTK_APPLICATION (app));
if (g_strcmp0 (PROFILE, "devel") == 0)
gtk_widget_add_css_class (GTK_WIDGET (main_window), "devel");
gtk_window_set_icon_name (GTK_WINDOW (main_window), "text-editor");
gtk_window_set_default_size (GTK_WINDOW (main_window), 400, 600);
gtk_application_window_set_show_menubar (GTK_APPLICATION_WINDOW (main_window), TRUE);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 231 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 184 B

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