Compare commits

..

29 Commits

Author SHA1 Message Date
Matthias Clasen
f19001d4c3 Add some more docs
Add an example to the GskGLShader docs.
2020-09-25 20:38:22 -04:00
Matthias Clasen
6ecf612677 Add another shader test
This one tests the convenience api for creating
uniform data.
2020-09-25 20:37:48 -04:00
Matthias Clasen
e0b3746655 gtk-demo: Add a shader paintable to the fishbowl
This gets around 500 instances at 60fps on my system.
2020-09-25 17:22:22 -04:00
Matthias Clasen
1bc81fac2a gtk-demo: Add a shader paintable demo
Add a shader paintable to the OpenGL transitions
demo. This is reusing one of the shadertoy examples,
tweaked slightly to work as a standalone fragment
shader.
2020-09-25 17:22:22 -04:00
Matthias Clasen
bdcc29ebef gtk-demo: Add a shader paintable
This is a GdkPaintable implementation wrapped
around a GskGLShader. It can optionally be hooked
up to a frame clock to update a time uniform.

The code is set up for this to live as public api
in GSK, if we find it useful enough.
2020-09-25 17:21:40 -04:00
Alexander Larsson
810e9c238e snapshot: Drop the varargs versions of push_gl_shader()
We can now just use gsk_gl_shader_format_args() directly, relying
on the transfer-full of the shader args argument.
2020-09-25 16:51:46 +02:00
Alexander Larsson
e4dfa5597a gtk_snapshot_push_gl_shader: Make @args transfer-full
This makes the common case of this just being created a lot easier.
2020-09-25 16:46:39 +02:00
Alexander Larsson
32aa470f68 Rename uniform_data to shader args, or just args
This makes a lot of types and function names shorter.
Also, we add a "..." version of gsk_gl_shader_format_args_va().
2020-09-25 16:38:10 +02:00
Alexander Larsson
a234ab1e55 Finish remaining renames from GLSHADER to GL_SHADER (etc)
This fixes all remaining cases in public headers.
2020-09-25 14:31:44 +02:00
Alexander Larsson
e93a51b1cc GskGLShader: Drop fallback node and add try_compile function to replace it
This removes the fallback node from GskGLShaderNode and adds
a new function gsk_gl_shader_try_compile_for() which tries to compile a
shader against a renderer. Then you can use the return value of this
both as a way to implement the fallback, and as a way to get at
the error report in a saner way.
2020-09-25 14:31:33 +02:00
Matthias Clasen
66cd15d858 Add some shader tests
These are just basic api usage tests, no rendering.
They found the issues fixed in the preceding commits.
2020-09-23 18:05:57 -04:00
Matthias Clasen
a0bc9d65da gsk: Make uniform regex more forgiving
Accept - in initializers, otherwise we don't accept
things like uniform int n = -2;
2020-09-23 18:03:52 -04:00
Matthias Clasen
a580c711e5 gsk: Make uniform regex more forgiving
Accept comments after a uniform declaration - the
very first shader example I tried had these, so we
better support it.
2020-09-23 17:48:35 -04:00
Matthias Clasen
e91d5b82ce gsk: Fix getters and setters for vector types
The types we store for the uniforms are VEC2/3/4,
even though we just store a bunch of floats.

This was found while adding some simple tests.
2020-09-23 17:42:10 -04:00
Matthias Clasen
0516c59ff5 gsk: Add more shader debug spew
Print out the full assembled shader sources when
GSK_DEBUG=shaders is given. This is very verbose,
but may be useful to see what we actually pass
to the compiler.
2020-09-23 16:17:56 -04:00
Matthias Clasen
a3ea3f94dc gsk: Add some shader debug spew
When we're done extracting uniform info from the glsl,
print out what we've found for GSK_DEBUG=shaders. If
something goes wrong, this will be useful.
2020-09-23 15:40:57 -04:00
Matthias Clasen
5e9fe2f6e8 docs: Add new snapshot apis 2020-09-23 14:59:25 -04:00
Matthias Clasen
6613c523c2 Rename gl shader snapshot apis
Rename gtk_snapshot_push_glshader and friends to
gtk_snapshot_push_gl_shader, following the similar
renaming in GSK.

Update all callers.
2020-09-23 14:53:42 -04:00
Matthias Clasen
efa0fa0bf4 gsk: Small doc fixups
Tweak the gl shader docs here and there.
2020-09-23 14:46:35 -04:00
Matthias Clasen
1b6f7917ed Add GskGLShader apis to the docs 2020-09-23 14:41:22 -04:00
Alexander Larsson
8cc18d2c82 shadertoy demo: Fix GLSL on GLES
I was getting "assignment to varying fragColor" errors
2020-09-23 17:38:03 +02:00
Alexander Larsson
d97267b897 gtk-demo: Add GskGLShaderNode demo
Add adds a demo showing off GskGLShaderNode in various ways.

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

It also has a fancy fire effect on hove on the buttons.
2020-09-23 17:28:23 +02:00
Alexander Larsson
21e0ad0561 Support GLShaderNode in backends
For vulkan/broadway this just means to ignore it, but for the gl
backend we support (with up to 4 texture inputs, which is similar to
what shadertoy does, so should be widely supported).
2020-09-23 17:01:17 +02:00
Alexander Larsson
94cccc5e71 GtkSnapshot: Add gtk_snapshot_push_glshader() 2020-09-23 17:01:13 +02:00
Alexander Larsson
111dfdf3f5 Add GskGLShaderNode
This is a rendernode that is supposed to run a GLSL fragment
shader with a set of inputs and produce outputs.
The inputs are:
 * A GskGLShader object with the source and uniforms definitions
   computed from the source.
 * A the data for the uniforms, formated according to the GskGLShader
 * a list of render nodes that are rendered to textures

Additionally there is a fallback node which is used in case
OpenGL is not supported or there is some kind of failure
with the shader code.
2020-09-23 17:01:08 +02:00
Alexander Larsson
0693deb02f gl: Add some namespacing to the preamble symbols
This adds a gsk prefix to the stuff in the preamble, as we want to
avoid it conflicting with things in the main shader. Especially once
we start allow some customization of shaders.
2020-09-22 12:50:10 +02:00
Alexander Larsson
ffd39c257a gl backend: Add line numbers to source in glsl compilation errors
Almost always the source is created by combining various sources, which
means the line numbers in the error messages are hard to use. Adding
the line numbers to the source in the error message helps with this.
2020-09-22 12:50:10 +02:00
Alexander Larsson
ec0ad5738c gl: Properly report error if shader linking fails
In gsk_gl_shader_builder_create_program(), if linking fails we
need to return -1 to indicate error, rather than the old deleted
program id.
2020-09-22 09:40:16 +02:00
Alexander Larsson
c958fd8e86 glrenderer: Move ProgramState into Program
There is no real reason to have this on the side indexed via the
index, as it is stored next to each other anyway. Plus, storing them
together lets use use `Program` structures not in the array.
2020-09-22 09:40:16 +02:00
2807 changed files with 300959 additions and 336051 deletions

View File

@@ -1,13 +1,8 @@
include:
- project: 'gnome/citemplates'
file: 'flatpak/flatpak_ci_initiative.yml'
stages: stages:
- build - build
- analysis - analysis
- docs - docs
- flatpak - flatpak
- publish
- deploy - deploy
.cache-paths: &cache-paths .cache-paths: &cache-paths
@@ -21,12 +16,13 @@ stages:
# Common variables # Common variables
variables: variables:
COMMON_MESON_FLAGS: "-Dwerror=true -Dglib:werror=false -Dpango:werror=false -Dgtk-doc:werror=false -Dwayland-protocols:werror=false -Dsysprof:werror=false" COMMON_MESON_FLAGS: "--fatal-meson-warnings -Dgtk:werror=true"
BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true" BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true"
FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled" FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled"
MESON_TEST_TIMEOUT_MULTIPLIER: 3 MESON_TEST_TIMEOUT_MULTIPLIER: 3
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v33" FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v22"
FLATPAK_IMAGE: "registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master" FLATPAK_IMAGE: "registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master"
DOCS_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora-docs:v19"
.only-default: .only-default:
only: only:
@@ -43,7 +39,6 @@ style-check-diff:
- .gitlab-ci/run-style-check-diff.sh - .gitlab-ci/run-style-check-diff.sh
.build-fedora-default: .build-fedora-default:
extends: .only-default
image: $FEDORA_IMAGE image: $FEDORA_IMAGE
artifacts: artifacts:
when: always when: always
@@ -58,10 +53,8 @@ style-check-diff:
- "${CI_PROJECT_DIR}/_build/report*.xml" - "${CI_PROJECT_DIR}/_build/report*.xml"
- "${CI_PROJECT_DIR}/_build/report*.html" - "${CI_PROJECT_DIR}/_build/report*.html"
- "${CI_PROJECT_DIR}/_build/testsuite/reftests/output/*/*.png" - "${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/gsk/compare/*/*/*.png"
- "${CI_PROJECT_DIR}/_build/testsuite/css/output/*/*.syscap" - "${CI_PROJECT_DIR}/_build/testsuite/css/output/*/*.syscap"
- "${CI_PROJECT_DIR}/_build_hello/meson-logs"
cache: cache:
key: "$CI_JOB_NAME" key: "$CI_JOB_NAME"
paths: paths:
@@ -79,16 +72,11 @@ fedora-x86_64:
variables: variables:
EXTRA_MESON_FLAGS: "--buildtype=debug --default-library=both" EXTRA_MESON_FLAGS: "--buildtype=debug --default-library=both"
script: script:
- .gitlab-ci/show-info-linux.sh
- meson subprojects update - meson subprojects update
- mkdir _install - meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} ${BACKEND_FLAGS} ${FEATURE_FLAGS}
- meson --prefix=${CI_PROJECT_DIR}/_install -Dsysprof=enabled
${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} ${BACKEND_FLAGS} ${FEATURE_FLAGS}
_build _build
- meson compile -C _build - ninja -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
- .gitlab-ci/run-tests.sh _build x11 - .gitlab-ci/run-tests.sh _build x11
- .gitlab-ci/run-tests.sh _build wayland - .gitlab-ci/run-tests.sh _build wayland
- .gitlab-ci/run-tests.sh _build broadway - .gitlab-ci/run-tests.sh _build broadway
@@ -100,7 +88,6 @@ release-build:
variables: variables:
EXTRA_MESON_FLAGS: "--buildtype=release" EXTRA_MESON_FLAGS: "--buildtype=release"
script: script:
- .gitlab-ci/show-info-linux.sh
- meson subprojects update - meson subprojects update
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} ${BACKEND_FLAGS} ${FEATURE_FLAGS} - meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} ${BACKEND_FLAGS} ${FEATURE_FLAGS}
_build _build
@@ -113,9 +100,7 @@ installed-tests:
needs: [] needs: []
variables: variables:
EXTRA_MESON_FLAGS: "--prefix=/usr --libdir=/usr/lib64 -Dinstall-tests=true" EXTRA_MESON_FLAGS: "--prefix=/usr --libdir=/usr/lib64 -Dinstall-tests=true"
G_TEST_ACCESSIBLE: 1
script: script:
- .gitlab-ci/show-info-linux.sh
- meson subprojects update - meson subprojects update
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} ${BACKEND_FLAGS} ${FEATURE_FLAGS} - meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} ${BACKEND_FLAGS} ${FEATURE_FLAGS}
_build _build
@@ -132,7 +117,6 @@ installed-tests:
.mingw-defaults: .mingw-defaults:
extends: .only-default
stage: build stage: build
tags: tags:
- win32-ps - win32-ps
@@ -156,51 +140,6 @@ msys2-mingw64:
MSYSTEM: "MINGW64" MSYSTEM: "MINGW64"
CHERE_INVOKING: "yes" 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: .flatpak-defaults:
image: $FLATPAK_IMAGE image: $FLATPAK_IMAGE
stage: flatpak stage: flatpak
@@ -210,7 +149,6 @@ vs2017-x64:
artifacts: artifacts:
paths: paths:
- "${APPID}-dev.flatpak" - "${APPID}-dev.flatpak"
- 'repo.tar'
expire_in: 1 day expire_in: 1 day
script: script:
- bash -x ./.gitlab-ci/flatpak-build.sh "${APPID}" - bash -x ./.gitlab-ci/flatpak-build.sh "${APPID}"
@@ -262,24 +200,6 @@ flatpak-master:icon-browser:
variables: variables:
APPID: org.gtk.IconBrowser4 APPID: org.gtk.IconBrowser4
# Publish the demo apps to the GNOME Nightly repo
# https://wiki.gnome.org/Apps/Nightly
# https://gitlab.gnome.org/GNOME/Initiatives/-/wikis/DevOps-with-Flatpak
nightly demo:
extends: '.publish_nightly'
dependencies: ['flatpak-master:demo']
needs: ['flatpak-master:demo']
nightly factory:
extends: '.publish_nightly'
dependencies: ['flatpak-master:widget-factory']
needs: ['flatpak-master:widget-factory']
nightly icon-browser:
extends: '.publish_nightly'
dependencies: ['flatpak-master:icon-browser']
needs: ['flatpak-master:icon-browser']
static-scan: static-scan:
image: $FEDORA_IMAGE image: $FEDORA_IMAGE
stage: analysis stage: analysis
@@ -303,7 +223,7 @@ asan-build:
needs: [] needs: []
variables: variables:
script: script:
- CC=clang meson --buildtype=debugoptimized -Db_sanitize=address -Db_lundef=false -Dintrospection=disabled _build - CC=clang meson --buildtype=debugoptimized -Db_sanitize=address -Db_lundef=false -Dintrospection=false _build
- ninja -C _build - ninja -C _build
- .gitlab-ci/run-tests.sh _build wayland - .gitlab-ci/run-tests.sh _build wayland
artifacts: artifacts:
@@ -312,37 +232,29 @@ asan-build:
allow_failure: true allow_failure: true
reference: reference:
image: $FEDORA_IMAGE image: $DOCS_IMAGE
stage: docs stage: docs
needs: [] needs: []
variables: variables:
EXTRA_MESON_FLAGS: "--buildtype=release --force-fallback-for=gdk-pixbuf,pango" EXTRA_MESON_FLAGS: "--buildtype=release"
script: script:
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} -Dgtk_doc=true -Dgdk-pixbuf:gtk_doc=true -Dpango:gtk_doc=true _build - meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} -Dgtk_doc=true _build
- meson compile -C _build - ninja -C _build gdk4-doc gsk4-doc gtk4-doc
- mkdir -p _reference/ - mkdir -p _reference/
- mv _build/docs/reference/gdk/gdk4/ _reference/gdk4/ - mv _build/docs/reference/gdk/html/ _reference/gdk/
- mv _build/docs/reference/gdk/gdk4-x11/ _reference/gdk4-x11/ - mv _build/docs/reference/gsk/html/ _reference/gsk/
- mv _build/docs/reference/gdk/gdk4-wayland/ _reference/gdk4-wayland/ - mv _build/docs/reference/gtk/html/ _reference/gtk/
- 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/
artifacts: artifacts:
paths: paths:
- _reference - _reference
publish-docs: pages:
stage: publish stage: deploy
needs: ['reference'] needs: ['reference']
script: 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: only:
refs: - master
- master

View File

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

View File

@@ -0,0 +1,90 @@
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 \
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.53.1

View File

@@ -0,0 +1,12 @@
FROM registry.gitlab.gnome.org/gnome/gtk/fedora-base:v19
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,99 +1,4 @@
FROM fedora:34 FROM registry.gitlab.gnome.org/gnome/gtk/fedora-base:v21
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 \
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-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
# Enable sudo for wheel users # Enable sudo for wheel users
RUN sed -i -e 's/# %wheel/%wheel/' -e '0,/%wheel/{s/%wheel/# %wheel/}' /etc/sudoers RUN sed -i -e 's/# %wheel/%wheel/' -e '0,/%wheel/{s/%wheel/# %wheel/}' /etc/sudoers

View File

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

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;; list) list=1;;
help) print_help=1;; help) print_help=1;;
--base|-b) read_arg base "$@" || shift;; --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;; --no-login) no_login=1;;
*) echo -e "\e[1;31mERROR\e[0m: Unknown option '$1'"; exit 1;; *) echo -e "\e[1;31mERROR\e[0m: Unknown option '$1'"; exit 1;;
esac esac

View File

@@ -8,8 +8,7 @@ builddir=$1
backend=$2 backend=$2
# Ignore memory leaks lower in dependencies # Ignore memory leaks lower in dependencies
export LSAN_OPTIONS=suppressions=$srcdir/lsan.supp:print_suppressions=0 export LSAN_OPTIONS=suppressions=$srcdir/lsan.supp
export G_SLICE=always-malloc
case "${backend}" in case "${backend}" in
x11) x11)

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 \ -Dx11-backend=true \
-Dwayland-backend=true \ -Dwayland-backend=true \
-Dbroadway-backend=true \ -Dbroadway-backend=true \
-Dvulkan=enabled \ -Dvulkan=yes \
-Dprofiler=true \ -Dprofiler=true \
--werror \ --werror \
${EXTRA_MESON_FLAGS:-} \ ${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/2243
# https://gitlab.gnome.org/GNOME/gtk/-/issues/3002 # 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 git clone https://gitlab.gnome.org/GNOME/glib.git _glib
meson setup _glib_build _glib meson setup _glib_build _glib
meson compile -C _glib_build meson compile -C _glib_build
@@ -48,7 +48,7 @@ if ! pkg-config --atleast-version=2.66.0 glib-2.0; then
fi fi
pkg-config --modversion glib-2.0 pkg-config --modversion glib-2.0
if ! pkg-config --atleast-version=1.49.1 pango; then if ! pkg-config --atleast-version=1.47.0 pango; then
git clone https://gitlab.gnome.org/GNOME/pango.git _pango git clone https://gitlab.gnome.org/GNOME/pango.git _pango
meson setup _pango_build _pango meson setup _pango_build _pango
meson compile -C _pango_build meson compile -C _pango_build
@@ -60,12 +60,14 @@ pkg-config --modversion pango
ccache --zero-stats ccache --zero-stats
ccache --show-stats ccache --show-stats
export CCACHE_DISABLE=true export CCACHE_DISABLE=true
# FIXME: introspection disabled for now because of
# https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/340
meson \ meson \
-Dx11-backend=false \ -Dx11-backend=false \
-Dwayland-backend=false \ -Dwayland-backend=false \
-Dwin32-backend=true \ -Dwin32-backend=true \
-Dvulkan=disabled \ -Dvulkan=disabled \
-Dintrospection=enabled \ -Dintrospection=false \
-Dgtk:werror=true \ -Dgtk:werror=true \
_build _build
unset CCACHE_DISABLE unset CCACHE_DISABLE

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 ## Steps to reproduce
<!--
Please, explain the sequence of actions necessary to reproduce the
bug
-->
1. ... 1. ...
2. ... 2. ...
@@ -41,8 +32,5 @@
## Additional information ## Additional information
<!-- <!--
- Screenshots or screen recordings are useful for visual errors - 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 - 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 ## Steps to reproduce
<!--
Please, explain the sequence of actions necessary to reproduce the
crash
-->
1. ... 1. ...
2. ... 2. ...

View File

@@ -56,12 +56,6 @@ If the issue includes a crash, you should also include:
0. the eventual warnings printed on the terminal 0. the eventual warnings printed on the terminal
0. a backtrace, obtained with tools such as GDB or LLDB 0. a backtrace, obtained with tools such as GDB or LLDB
It is fine to include screenshots of screen recordings to demonstrate
an issue that is best to understand visually, but please don't just
dump screen recordings without further details into issues. It is
essential that the problem is described in enough detail to reproduce
it without watching a video.
For small issues, such as: For small issues, such as:
- spelling/grammar fixes in the documentation - spelling/grammar fixes in the documentation

9474
NEWS

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -17,7 +17,7 @@ license fees or royalties.
The official download location The official download location
- https://download.gnome.org/sources/gtk/ - https://download.gnome.org/sources/gtk+
The official web site The official web site
@@ -32,16 +32,9 @@ Discussion forum
- https://discourse.gnome.org/c/platform/core/ - https://discourse.gnome.org/c/platform/core/
Nightly documentation can be found at Nightly documentation can be found at
- Gtk: https://gnome.pages.gitlab.gnome.org/gtk/gtk4/ - Gtk: https://gnome.pages.gitlab.gnome.org/gtk/gtk/
- Gdk: https://gnome.pages.gitlab.gnome.org/gtk/gdk4/ - Gdk: https://gnome.pages.gitlab.gnome.org/gtk/gdk/
- Gsk: https://gnome.pages.gitlab.gnome.org/gtk/gsk4/ - Gsk: https://gnome.pages.gitlab.gnome.org/gtk/gsk/
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`
Building and installing Building and installing
----------------------- -----------------------
@@ -56,11 +49,11 @@ In order to build GTK you will need:
You will also need various dependencies, based on the platform you are You will also need various dependencies, based on the platform you are
building for: building for:
- [GLib](https://download.gnome.org/sources/glib/) - [GLib](https://download.gnome.org/sources/glib)
- [GdkPixbuf](https://download.gnome.org/sources/gdk-pixbuf/) - [GdkPixbuf](https://download.gnome.org/sources/gdk-pixbuf)
- [GObject-Introspection](https://download.gnome.org/sources/gobject-introspection/) - [GObject-Introspection](https://download.gnome.org/sources/gobject-introspection)
- [Cairo](https://www.cairographics.org/) - [Cairo](https://www.cairographics.org)
- [Pango](https://download.gnome.org/sources/pango/) - [Pango](https://download.gnome.org/sources/pango)
- [Epoxy](https://github.com/anholt/libepoxy) - [Epoxy](https://github.com/anholt/libepoxy)
- [Graphene](https://github.com/ebassi/graphene) - [Graphene](https://github.com/ebassi/graphene)
- [Xkb-common](https://github.com/xkbcommon/libxkbcommon) - [Xkb-common](https://github.com/xkbcommon/libxkbcommon)
@@ -157,8 +150,8 @@ Release notes
The release notes for GTK are part of the migration guide in the API The release notes for GTK are part of the migration guide in the API
reference. See: reference. See:
- [3.x release notes](https://developer.gnome.org/gtk3/stable/gtk-migrating-2-to-3.html) - [3.x release notes](https://developer.gnome.org/gtk3/unstable/gtk-migrating-2-to-3.html)
- [4.x release notes](https://docs.gtk.org/gtk4/migrating-3to4.html) - [4.x release notes](https://developer.gnome.org/gtk4/unstable/gtk-migrating-3-to-4.html)
Licensing terms 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" : [ "modules" : [
{ {
"name" : "wayland", "name" : "wayland",
"buildsystem" : "meson", "buildsystem" : "autotools",
"builddir" : true, "builddir" : true,
"config-opts" : [ "config-opts" : [
"-Ddocumentation=false" "--disable-documentation"
], ],
"sources" : [ "sources" : [
{ {
"type" : "git", "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", "name" : "gtk",
"buildsystem" : "meson", "buildsystem" : "meson",
@@ -171,8 +100,7 @@
"config-opts" : [ "config-opts" : [
"--libdir=/app/lib", "--libdir=/app/lib",
"-Denable_vulkan=no", "-Denable_vulkan=no",
"-Dbuildtype=debugoptimized", "-Dbuildtype=debugoptimized"
"-Dprofile=devel"
], ],
"sources" : [ "sources" : [
{ {

View File

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

View File

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

View File

@@ -1,21 +1,20 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os import os
import sys import sys
import subprocess import subprocess
if 'DESTDIR' not in os.environ: if 'DESTDIR' not in os.environ:
gtk_api_version = sys.argv[1] gtk_api_version = sys.argv[1]
gtk_abi_version = sys.argv[2] gtk_abi_version = sys.argv[2]
gtk_libdir = sys.argv[3] gtk_libdir = sys.argv[3]
gtk_datadir = sys.argv[4] gtk_datadir = sys.argv[4]
gtk_bindir = sys.argv[5]
gtk_moduledir = os.path.join(gtk_libdir, 'gtk-' + gtk_api_version, gtk_abi_version)
gtk_moduledir = os.path.join(gtk_libdir, 'gtk-' + gtk_api_version, gtk_abi_version) gtk_printmodule_dir = os.path.join(gtk_moduledir, 'printbackends')
gtk_printmodule_dir = os.path.join(gtk_moduledir, 'printbackends') gtk_immodule_dir = os.path.join(gtk_moduledir, 'immodules')
gtk_immodule_dir = os.path.join(gtk_moduledir, 'immodules')
print('Compiling GSettings schemas...')
print('Compiling GSettings schemas...')
glib_compile_schemas = subprocess.check_output(['pkg-config', glib_compile_schemas = subprocess.check_output(['pkg-config',
'--variable=glib_compile_schemas', '--variable=glib_compile_schemas',
'gio-2.0']).strip() 'gio-2.0']).strip()
@@ -23,14 +22,13 @@ if 'DESTDIR' not in os.environ:
# pkg-config variables only available since GLib 2.62.0. # pkg-config variables only available since GLib 2.62.0.
glib_compile_schemas = 'glib-compile-schemas' glib_compile_schemas = 'glib-compile-schemas'
subprocess.call([glib_compile_schemas, subprocess.call([glib_compile_schemas,
os.path.join(gtk_datadir, 'glib-2.0', 'schemas')]) os.path.join(gtk_datadir, 'glib-2.0', 'schemas')])
print('Updating icon cache...') print('Updating icon cache...')
update_icon_cache = os.path.join(gtk_bindir, 'gtk4-update-icon-cache') subprocess.call(['gtk4-update-icon-cache', '-q', '-t' ,'-f',
subprocess.call([update_icon_cache, '-q', '-t' ,'-f', os.path.join(gtk_datadir, 'icons', 'hicolor')])
os.path.join(gtk_datadir, 'icons', 'hicolor')])
print('Updating module cache for print backends...')
print('Updating module cache for print backends...')
os.makedirs(gtk_printmodule_dir, exist_ok=True) os.makedirs(gtk_printmodule_dir, exist_ok=True)
gio_querymodules = subprocess.check_output(['pkg-config', gio_querymodules = subprocess.check_output(['pkg-config',
'--variable=gio_querymodules', '--variable=gio_querymodules',
@@ -39,7 +37,7 @@ if 'DESTDIR' not in os.environ:
# pkg-config variables only available since GLib 2.62.0. # pkg-config variables only available since GLib 2.62.0.
gio_querymodules = 'gio-querymodules' gio_querymodules = 'gio-querymodules'
subprocess.call([gio_querymodules, gtk_printmodule_dir]) subprocess.call([gio_querymodules, gtk_printmodule_dir])
print('Updating module cache for input methods...') print('Updating module cache for input methods...')
os.makedirs(gtk_immodule_dir, exist_ok=True) os.makedirs(gtk_immodule_dir, exist_ok=True)
subprocess.call([gio_querymodules, gtk_immodule_dir]) subprocess.call([gio_querymodules, gtk_immodule_dir])

View File

@@ -1,9 +1,8 @@
/* config.h.in. Generated from configure.ac by autoheader. */
/* always defined to indicate that i18n is enabled */ /* always defined to indicate that i18n is enabled */
#define ENABLE_NLS 1 #define ENABLE_NLS 1
/* Use structured logging */
#define G_LOG_STRUCTURED 1
/* The prefix for our gettext translation domains. */ /* The prefix for our gettext translation domains. */
#mesondefine GETTEXT_PACKAGE #mesondefine GETTEXT_PACKAGE
@@ -76,9 +75,6 @@
/* Define to 1 if you have a working `mmap' system call. */ /* Define to 1 if you have a working `mmap' system call. */
#mesondefine HAVE_MMAP #mesondefine HAVE_MMAP
/* Define to 1 if you have a working `madvise' system call. */
#mesondefine HAVE_MADVISE
/* Define to 1 if you have the `posix_fallocate' function. */ /* Define to 1 if you have the `posix_fallocate' function. */
#mesondefine HAVE_POSIX_FALLOCATE #mesondefine HAVE_POSIX_FALLOCATE
@@ -124,6 +120,9 @@
/* Define to 1 if you have the <unistd.h> header file. */ /* Define to 1 if you have the <unistd.h> header file. */
#mesondefine HAVE_UNISTD_H #mesondefine HAVE_UNISTD_H
/* Have the XCOMPOSITE X extension */
#mesondefine HAVE_XCOMPOSITE
/* Have the Xcursor library */ /* Have the Xcursor library */
#mesondefine HAVE_XCURSOR #mesondefine HAVE_XCURSOR
@@ -279,8 +278,3 @@
/* Define if tracker3 is available */ /* Define if tracker3 is available */
#mesondefine HAVE_TRACKER3 #mesondefine HAVE_TRACKER3
#mesondefine HAVE_F16C
/* Does the OS support GDesktopAppInfo? */
#mesondefine HAVE_DESKTOPAPPINFO

View File

@@ -36,7 +36,7 @@ struct _ConstraintEditorWindow
G_DEFINE_TYPE(ConstraintEditorWindow, constraint_editor_window, GTK_TYPE_APPLICATION_WINDOW); G_DEFINE_TYPE(ConstraintEditorWindow, constraint_editor_window, GTK_TYPE_APPLICATION_WINDOW);
static GtkConstraintTarget * static GtkConstraintTarget *
find_target (GListModel *model, find_target (GListModel *model,
GtkConstraintTarget *orig) GtkConstraintTarget *orig)
{ {
const char *name; const char *name;
@@ -163,30 +163,20 @@ constraint_editor_window_load (ConstraintEditorWindow *self,
GtkConstraint *clone; GtkConstraint *clone;
GtkConstraintTarget *target; GtkConstraintTarget *target;
GtkConstraintTarget *source; GtkConstraintTarget *source;
GtkConstraintAttribute source_attr;
item = g_list_model_get_item (list, i); item = g_list_model_get_item (list, i);
constraint = GTK_CONSTRAINT (item); constraint = GTK_CONSTRAINT (item);
target = gtk_constraint_get_target (constraint); target = gtk_constraint_get_target (constraint);
source = gtk_constraint_get_source (constraint); source = gtk_constraint_get_source (constraint);
source_attr = gtk_constraint_get_source_attribute (constraint); clone = gtk_constraint_new (find_target (constraint_view_get_model (CONSTRAINT_VIEW (self->view)), target),
if (source == NULL && source_attr == GTK_CONSTRAINT_ATTRIBUTE_NONE)
clone = gtk_constraint_new_constant (find_target (constraint_view_get_model (CONSTRAINT_VIEW (self->view)), target),
gtk_constraint_get_target_attribute (constraint), gtk_constraint_get_target_attribute (constraint),
gtk_constraint_get_relation (constraint), gtk_constraint_get_relation (constraint),
find_target (constraint_view_get_model (CONSTRAINT_VIEW (self->view)), source),
gtk_constraint_get_target_attribute (constraint),
gtk_constraint_get_multiplier (constraint),
gtk_constraint_get_constant (constraint), gtk_constraint_get_constant (constraint),
gtk_constraint_get_strength (constraint)); gtk_constraint_get_strength (constraint));
else
clone = gtk_constraint_new (find_target (constraint_view_get_model (CONSTRAINT_VIEW (self->view)), target),
gtk_constraint_get_target_attribute (constraint),
gtk_constraint_get_relation (constraint),
find_target (constraint_view_get_model (CONSTRAINT_VIEW (self->view)), source),
source_attr,
gtk_constraint_get_multiplier (constraint),
gtk_constraint_get_constant (constraint),
gtk_constraint_get_strength (constraint));
constraint_view_add_constraint (CONSTRAINT_VIEW (self->view), clone); constraint_view_add_constraint (CONSTRAINT_VIEW (self->view), clone);
@@ -310,7 +300,7 @@ save_response_cb (GtkNativeDialog *dialog,
model = constraint_view_get_model (CONSTRAINT_VIEW (self->view)); model = constraint_view_get_model (CONSTRAINT_VIEW (self->view));
text = serialize_model (model); text = serialize_model (model);
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog)); file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
g_file_replace_contents (file, text, strlen (text), g_file_replace_contents (file, text, -1,
NULL, FALSE, NULL, FALSE,
G_FILE_CREATE_NONE, G_FILE_CREATE_NONE,
NULL, NULL,

View File

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

View File

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

View File

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

View File

@@ -8,16 +8,14 @@ constraint_editor_sources = [
] ]
constraint_editor_resources = gnome.compile_resources('constraint_editor_resources', constraint_editor_resources = gnome.compile_resources('constraint_editor_resources',
'constraint-editor.gresource.xml', 'constraint-editor.gresource.xml',
source_dir: '.', source_dir: '.')
)
executable('gtk4-constraint-editor', executable('gtk4-constraint-editor',
sources: [ constraint_editor_sources, constraint_editor_resources, ], constraint_editor_sources, constraint_editor_resources,
c_args: common_cflags, c_args: common_cflags,
dependencies: libgtk_dep, dependencies: libgtk_dep,
include_directories: confinc, include_directories: confinc,
gui_app: true, gui_app: true,
link_args: extra_demo_ldflags, link_args: extra_demo_ldflags,
install: false, install: false)
)

View File

@@ -67,7 +67,7 @@ vec2 raySphere(vec3 ro, vec3 rd, vec4 sphere) {
return vec2(t0, t1); return vec2(t0, t1);
} }
float noize1(vec2 p) { float noise1(vec2 p) {
vec2 n = mod2(p, vec2(cellWidth)); vec2 n = mod2(p, vec2(cellWidth));
vec2 hh = hash(sqrt(2.0)*(n+1000.0)); vec2 hh = hash(sqrt(2.0)*(n+1000.0));
hh.x *= hh.y; hh.x *= hh.y;
@@ -81,7 +81,7 @@ float noize1(vec2 p) {
return h*0.25; return h*0.25;
} }
float noize2(vec2 p) { float noise2(vec2 p) {
vec2 n = mod2(p, vec2(cellWidth)); vec2 n = mod2(p, vec2(cellWidth));
vec2 hh = hash(sqrt(2.0)*(n+1000.0)); vec2 hh = hash(sqrt(2.0)*(n+1000.0));
hh.x *= hh.y; hh.x *= hh.y;
@@ -114,7 +114,7 @@ float height(vec2 p, float dd, int mx) {
int i = 0; int i = 0;
for (; i < 4;++i) { for (; i < 4;++i) {
float nn = a*noize2(p); float nn = a*noise2(p);
s += nn; s += nn;
d += abs(a); d += abs(a);
p += o; p += o;
@@ -130,7 +130,7 @@ float height(vec2 p, float dd, int mx) {
mx = int(mix(float(4), float(mx), step(rdd, far))); mx = int(mix(float(4), float(mx), step(rdd, far)));
for (; i < mx; ++i) { for (; i < mx; ++i) {
float nn = a*noize1(p); float nn = a*noise1(p);
s += nn; s += nn;
d += abs(a); d += abs(a);
p += o; p += o;

View File

@@ -465,7 +465,7 @@ demo_application_window_size_allocate (GtkWidget *widget,
baseline); baseline);
if (!window->maximized && !window->fullscreen) if (!window->maximized && !window->fullscreen)
gtk_window_get_default_size (GTK_WINDOW (window), &window->width, &window->height); gtk_window_get_size (GTK_WINDOW (window), &window->width, &window->height);
} }
static void static void

View File

@@ -98,9 +98,6 @@ create_page1 (GtkWidget *assistant)
gtk_box_append (GTK_BOX (box), label); gtk_box_append (GTK_BOX (box), label);
entry = gtk_entry_new (); 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_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
gtk_widget_set_valign (entry, GTK_ALIGN_CENTER); gtk_widget_set_valign (entry, GTK_ALIGN_CENTER);
gtk_box_append (GTK_BOX (box), entry); gtk_box_append (GTK_BOX (box), entry);

View File

@@ -1,26 +0,0 @@
uniform float u_time;
void
mainImage(out vec4 fragColor, in vec2 fragCoord, in vec2 resolution, in vec2 uv)
{
vec2 pos = (fragCoord.xy * 2.0 - resolution.xy)/ min (resolution.x, resolution.y) ;
float t0 = sin ((u_time + 0.00)*1.0);
float t1 = sin ((u_time + 0.30)*0.4);
float t2 = cos ((u_time + 0.23)*0.9);
float t3 = cos ((u_time + 0.41)*0.6);
float t4 = cos ((u_time + 0.11)*0.3);
vec2 p0 = vec2 (t1, t0) ;
vec2 p1 = vec2 (t2, t3) ;
vec2 p2 = vec2 (t4, t3) ;
float r = 1.0/distance (pos, p0);
float g = 1.0/distance (pos, p1);
float b = 1.0/distance (pos, p2);
float sum = r + g + b;
float alpha = 1.0 - pow (1.0/(sum), 40.0)*pow (10.0, 40.0*0.7);
fragColor = vec4 (r*0.5, g*0.5, b*0.5, 1.0) * alpha;
}

View File

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

View File

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

View File

@@ -177,7 +177,7 @@ float ccell2(vec2 p, float r) {
float df(vec2 p, float scale, inout vec2 nn) { float df(vec2 p, float scale, inout vec2 nn) {
p /= scale; p /= scale;
nn = hextile(p); nn = hextile(p);
nn = floor(nn + 0.5); nn = round(nn);
float r = hash(nn); float r = hash(nn);
float d;; float d;;

View File

@@ -1,5 +1,8 @@
uniform float iTime; uniform float iTime;
in vec2 fragCoord;
out vec4 vFragColor;
// Originally from: https://www.shadertoy.com/view/3ljyDD // Originally from: https://www.shadertoy.com/view/3ljyDD
// License CC0: Hexagonal tiling + cog wheels // License CC0: Hexagonal tiling + cog wheels
// Nothing fancy, just hexagonal tiling + cog wheels // Nothing fancy, just hexagonal tiling + cog wheels
@@ -179,7 +182,7 @@ float ccell2(vec2 p, float r) {
float df(vec2 p, float scale, inout vec2 nn) { float df(vec2 p, float scale, inout vec2 nn) {
p /= scale; p /= scale;
nn = hextile(p); nn = hextile(p);
nn = floor(nn + 0.5); nn = round(nn);
float r = hash(nn); float r = hash(nn);
float d;; float d;;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -18,9 +18,6 @@
<file>demoimage.c</file> <file>demoimage.c</file>
<file>demoimage.h</file> <file>demoimage.h</file>
</gresource> </gresource>
<gresource prefix="/constraints_builder">
<file>constraints_builder.ui</file>
</gresource>
<gresource prefix="/css_accordion"> <gresource prefix="/css_accordion">
<file>css_accordion.css</file> <file>css_accordion.css</file>
<file>reset.css</file> <file>reset.css</file>
@@ -43,11 +40,6 @@
<file>cssview.css</file> <file>cssview.css</file>
<file>reset.css</file> <file>reset.css</file>
</gresource> </gresource>
<gresource prefix="/dropdown">
<file>suggestionentry.h</file>
<file>suggestionentry.c</file>
<file>suggestionentry.css</file>
</gresource>
<gresource prefix="/theming_style_classes"> <gresource prefix="/theming_style_classes">
<file>theming.ui</file> <file>theming.ui</file>
</gresource> </gresource>
@@ -128,9 +120,6 @@
<file>gtkfishbowl.c</file> <file>gtkfishbowl.c</file>
<file>gtkfishbowl.h</file> <file>gtkfishbowl.h</file>
</gresource> </gresource>
<gresource prefix="/frames">
<file>frames.ui</file>
</gresource>
<gresource prefix="/gears"> <gresource prefix="/gears">
<file>gtkgears.c</file> <file>gtkgears.c</file>
<file>gtkgears.h</file> <file>gtkgears.h</file>
@@ -149,15 +138,12 @@
<file>gtkshaderstack.h</file> <file>gtkshaderstack.h</file>
<file>gtkshaderbin.h</file> <file>gtkshaderbin.h</file>
<file>gtkshaderbin.c</file> <file>gtkshaderbin.c</file>
<file>gskshaderpaintable.h</file> <file>fire.glsl</file>
<file>gskshaderpaintable.c</file> <file>transition1.glsl</file>
<file>wind.glsl</file> <file>transition2.glsl</file>
<file>radial.glsl</file> <file>transition3.glsl</file>
<file>crosswarp.glsl</file> <file>transition4.glsl</file>
<file>kaleidoscope.glsl</file>
<file>cogs2.glsl</file> <file>cogs2.glsl</file>
<file>ripple.glsl</file>
<file>background.glsl</file>
</gresource> </gresource>
<gresource prefix="/iconscroll"> <gresource prefix="/iconscroll">
<file>iconscroll.ui</file> <file>iconscroll.ui</file>
@@ -195,9 +181,6 @@
<gresource prefix="/listview_settings"> <gresource prefix="/listview_settings">
<file>listview_settings.ui</file> <file>listview_settings.ui</file>
</gresource> </gresource>
<gresource prefix="/listview_ucd_data/">
<file>ucdnames.data</file>
</gresource>
<gresource prefix="/listview_weather"> <gresource prefix="/listview_weather">
<file compressed="true">listview_weather.txt</file> <file compressed="true">listview_weather.txt</file>
</gresource> </gresource>
@@ -215,11 +198,6 @@
<file>demo3widget.h</file> <file>demo3widget.h</file>
<file>demo3widget.ui</file> <file>demo3widget.ui</file>
</gresource> </gresource>
<gresource prefix="/paintable_svg">
<file>svgpaintable.h</file>
<file>svgpaintable.c</file>
<file>org.gtk.gtk4.NodeEditor.Devel.svg</file>
</gresource>
<gresource prefix="/shortcuts"> <gresource prefix="/shortcuts">
<file>shortcuts.ui</file> <file>shortcuts.ui</file>
<file>shortcuts-builder.ui</file> <file>shortcuts-builder.ui</file>
@@ -239,12 +217,9 @@
<file>revealer.ui</file> <file>revealer.ui</file>
</gresource> </gresource>
<gresource prefix="/images"> <gresource prefix="/images">
<file>pixbufpaintable.h</file>
<file>pixbufpaintable.c</file>
<file>alphatest.png</file> <file>alphatest.png</file>
<file>floppybuddy.gif</file> <file>floppybuddy.gif</file>
<file>gtk-logo.webm</file> <file>gtk-logo.webm</file>
<file alias="org.gtk.Demo4.svg">data/scalable/apps/org.gtk.Demo4.svg</file>
</gresource> </gresource>
<gresource prefix="/video-player"> <gresource prefix="/video-player">
<file>bbb.png</file> <file>bbb.png</file>
@@ -256,9 +231,8 @@
<file>clipboard.c</file> <file>clipboard.c</file>
<file>combobox.c</file> <file>combobox.c</file>
<file>constraints.c</file> <file>constraints.c</file>
<file>constraints_interactive.c</file> <file>constraints2.c</file>
<file>constraints_vfl.c</file> <file>constraints3.c</file>
<file>constraints_builder.c</file>
<file>css_accordion.c</file> <file>css_accordion.c</file>
<file>css_basics.c</file> <file>css_basics.c</file>
<file>css_blendmodes.c</file> <file>css_blendmodes.c</file>
@@ -279,7 +253,6 @@
<file>fishbowl.c</file> <file>fishbowl.c</file>
<file>fixed.c</file> <file>fixed.c</file>
<file>flowbox.c</file> <file>flowbox.c</file>
<file>frames.c</file>
<file>font_features.c</file> <file>font_features.c</file>
<file>fontplane.c</file> <file>fontplane.c</file>
<file>fontrendering.c</file> <file>fontrendering.c</file>
@@ -298,14 +271,13 @@
<file>layoutmanager2.c</file> <file>layoutmanager2.c</file>
<file>links.c</file> <file>links.c</file>
<file>listbox.c</file> <file>listbox.c</file>
<file>listbox_controls.c</file> <file>listbox2.c</file>
<file>listview_applauncher.c</file> <file>listview_applauncher.c</file>
<file>listview_colors.c</file> <file>listview_colors.c</file>
<file>listview_clocks.c</file> <file>listview_clocks.c</file>
<file>listview_filebrowser.c</file> <file>listview_filebrowser.c</file>
<file>listview_minesweeper.c</file> <file>listview_minesweeper.c</file>
<file>listview_settings.c</file> <file>listview_settings.c</file>
<file>listview_ucd.c</file>
<file>listview_weather.c</file> <file>listview_weather.c</file>
<file>listview_words.c</file> <file>listview_words.c</file>
<file>list_store.c</file> <file>list_store.c</file>
@@ -313,15 +285,13 @@
<file>markup.c</file> <file>markup.c</file>
<file>menu.c</file> <file>menu.c</file>
<file>overlay.c</file> <file>overlay.c</file>
<file>overlay_decorative.c</file> <file>overlay2.c</file>
<file>paint.c</file> <file>paint.c</file>
<file>pagesetup.c</file> <file>pagesetup.c</file>
<file>paintable.c</file> <file>paintable.c</file>
<file>paintable_animated.c</file> <file>paintable_animated.c</file>
<file>paintable_emblem.c</file> <file>paintable_emblem.c</file>
<file>paintable_mediastream.c</file> <file>paintable_mediastream.c</file>
<file>paintable_svg.c</file>
<file>paintable_symbolic.c</file>
<file>panes.c</file> <file>panes.c</file>
<file>password_entry.c</file> <file>password_entry.c</file>
<file>peg_solitaire.c</file> <file>peg_solitaire.c</file>
@@ -364,8 +334,8 @@
<file>messages.txt</file> <file>messages.txt</file>
<file>apple-red.png</file> <file>apple-red.png</file>
</gresource> </gresource>
<gresource prefix="/listbox_controls"> <gresource prefix="/listbox2">
<file>listbox_controls.ui</file> <file>listbox2.ui</file>
</gresource> </gresource>
<gresource prefix="/glarea"> <gresource prefix="/glarea">
<file>glarea-gl.fs.glsl</file> <file>glarea-gl.fs.glsl</file>

View File

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

View File

@@ -97,9 +97,9 @@ demo3_widget_size_allocate (GtkWidget *widget,
/* Since we are not using a layout manager (who would do this /* Since we are not using a layout manager (who would do this
* for us), we need to allocate a size for our menu by calling * for us), we need to allocate a size for our menu by calling
* gtk_popover_present(). * gtk_native_check_resize().
*/ */
gtk_popover_present (GTK_POPOVER (self->menu)); gtk_native_check_resize (GTK_NATIVE (self->menu));
} }
static void static void

View File

@@ -47,38 +47,6 @@ get_image_paintable (GtkImage *image)
} }
} }
static void
update_drag_icon (DemoImage *demo,
GtkDragIcon *icon)
{
const char *icon_name;
GdkPaintable *paintable;
GtkWidget *image;
switch (gtk_image_get_storage_type (GTK_IMAGE (demo->image)))
{
case GTK_IMAGE_PAINTABLE:
paintable = gtk_image_get_paintable (GTK_IMAGE (demo->image));
image = gtk_image_new_from_paintable (paintable);
break;
case GTK_IMAGE_ICON_NAME:
icon_name = gtk_image_get_icon_name (GTK_IMAGE (demo->image));
image = gtk_image_new_from_icon_name (icon_name);
break;
case GTK_IMAGE_EMPTY:
case GTK_IMAGE_GICON:
default:
g_warning ("Image storage type %d not handled",
gtk_image_get_storage_type (GTK_IMAGE (demo->image)));
return;
}
gtk_image_set_pixel_size (GTK_IMAGE (image),
gtk_image_get_pixel_size (GTK_IMAGE (demo->image)));
gtk_drag_icon_set_child (icon, image);
}
static void static void
drag_begin (GtkDragSource *source, drag_begin (GtkDragSource *source,
GdkDrag *drag, GdkDrag *drag,
@@ -86,8 +54,14 @@ drag_begin (GtkDragSource *source,
{ {
GtkWidget *widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (source)); GtkWidget *widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (source));
DemoImage *demo = DEMO_IMAGE (widget); DemoImage *demo = DEMO_IMAGE (widget);
GdkPaintable *paintable;
update_drag_icon (demo, GTK_DRAG_ICON (gtk_drag_icon_get_for_drag (drag))); paintable = get_image_paintable (GTK_IMAGE (demo->image));
if (paintable)
{
gtk_drag_icon_set_from_paintable (drag, paintable, -2, -2);
g_object_unref (paintable);
}
} }
static GdkContentProvider * static GdkContentProvider *
@@ -100,11 +74,7 @@ prepare_drag (GtkDragSource *source,
DemoImage *demo = DEMO_IMAGE (widget); DemoImage *demo = DEMO_IMAGE (widget);
GdkPaintable *paintable = get_image_paintable (GTK_IMAGE (demo->image)); GdkPaintable *paintable = get_image_paintable (GTK_IMAGE (demo->image));
/* Textures can be serialized, paintables can't, so special case the textures */ return gdk_content_provider_new_typed (GDK_TYPE_PAINTABLE, paintable);
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);
} }
static gboolean static gboolean
@@ -133,11 +103,7 @@ copy_image (GtkWidget *widget,
GdkPaintable *paintable = get_image_paintable (GTK_IMAGE (demo->image)); GdkPaintable *paintable = get_image_paintable (GTK_IMAGE (demo->image));
GValue value = G_VALUE_INIT; GValue value = G_VALUE_INIT;
/* Textures can be serialized, paintables can't, so special case the textures */ g_value_init (&value, GDK_TYPE_PAINTABLE);
if (GDK_IS_TEXTURE (paintable))
g_value_init (&value, GDK_TYPE_TEXTURE);
else
g_value_init (&value, GDK_TYPE_PAINTABLE);
g_value_set_object (&value, paintable); g_value_set_object (&value, paintable);
gdk_clipboard_set_value (clipboard, &value); gdk_clipboard_set_value (clipboard, &value);
g_value_unset (&value); g_value_unset (&value);
@@ -146,46 +112,24 @@ copy_image (GtkWidget *widget,
g_object_unref (paintable); 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 static void
paste_image (GtkWidget *widget, paste_image (GtkWidget *widget,
const char *action_name, const char *action_name,
GVariant *parameter) GVariant *parameter)
{ {
GdkClipboard *clipboard = gtk_widget_get_clipboard (widget); 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)) g_value_init (&value, GDK_TYPE_PAINTABLE);
type = GDK_TYPE_TEXTURE; if (!gdk_content_provider_get_value (content, &value, NULL))
else return;
type = GDK_TYPE_PAINTABLE;
gdk_clipboard_read_value_async (clipboard, paintable = GDK_PAINTABLE (g_value_get_object (&value));
type, gtk_image_set_from_paintable (GTK_IMAGE (demo->image), paintable);
G_PRIORITY_DEFAULT, g_value_unset (&value);
NULL,
paste_image_cb,
g_object_ref (widget));
} }
static void static void

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

72
demos/gtk-demo/fire.glsl Normal file
View File

@@ -0,0 +1,72 @@
uniform float u_time;
uniform sampler2D u_texture1;
/* 2D -> [0..1] random number generator */
float random(vec2 st) {
return fract(sin(dot(st.xy,
vec2(12.9898,78.233))) *
43758.5453123);
}
/* Generate a smoothed 2d noise based on random() */
float noise(vec2 v) {
/* Round point v to integer grid grid */
vec2 grid_point = floor(v);
/* Randomize in grid corners */
float corner1 = random(grid_point);
float corner2 = random(grid_point + vec2(1, 0));
float corner3 = random(grid_point + vec2(0, 1));
float corner4 = random(grid_point + vec2(1, 1));
/* Interpolate smoothly between grid points */
vec2 fraction = smoothstep(vec2(0.0), vec2(1.0), fract(v));
return mix(mix(corner1, corner2, fraction.x),
mix(corner3, corner4, fraction.x),
fraction.y);
}
/* fractal brownian motion noice, see https://www.iquilezles.org/www/articles/fbm/fbm.htm */
float fbm(in vec2 x)
{
const float octaveScale = 1.9;
const float G = 0.5;
float f = 1.0;
float a = 1.0;
float t = 0.0;
int numOctaves = 5;
for (int i = 0; i < numOctaves; i++) {
t += a*noise(f*x);
f *= octaveScale;
a *= G;
}
return t;
}
void mainImage(out vec4 fragColor, in vec2 fragCoord, in vec2 resolution, in vec2 uv)
{
vec2 xy = fragCoord / resolution;
float zoom = 3.0 - sin(u_time*0.5)*0.3;
// Normalize coord to height of widget
vec2 p = (vec2 (-resolution.x/2.0 + fragCoord.x, resolution.y - fragCoord.y) / resolution.yy)* zoom;
// Use recursive incantations of fbm
float q1 = fbm(p - vec2(0.8, 0.3) * u_time);
float q2 = fbm(p - vec2(0.5, 1.3) * u_time);
float r = fbm(2.0*p + vec2(q1,q2) - vec2(0.0, 1.0)*u_time*10.0 *0.4);
// Compute intensity, mostly on the bottom
float w = 2.0 * r * p.y;
// Smooth out left/right side and fade in at start
w /= smoothstep(0.0,0.1, xy.x)* smoothstep(0.0,0.1, 1.0-xy.x) * smoothstep(0.0,0.4, u_time);
// Compute colors
vec3 c = vec3(1.0,.2,.05);
vec3 color = 1.0 / (w*w/c + 1.0);
// Mix in widget
vec4 widget = GskTexture(u_texture1,uv);
fragColor = mix(vec4(color,1), widget, 1.0-color.x);
}

View File

@@ -119,12 +119,13 @@ create_label (void)
static GtkWidget * static GtkWidget *
create_video (void) 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_widget_set_size_request (w, 64, 64);
gtk_video_set_loop (GTK_VIDEO (w), TRUE); gtk_media_stream_set_loop (stream, TRUE);
gtk_video_set_autoplay (GTK_VIDEO (w), TRUE); gtk_media_stream_play (stream);
gtk_video_set_resource (GTK_VIDEO (w), "/images/gtk-logo.webm"); g_object_unref (stream);
return w; return w;
} }
@@ -168,12 +169,11 @@ static GtkWidget *
create_cogs (void) create_cogs (void)
{ {
GtkWidget *picture; GtkWidget *picture;
static GskGLShader *cog_shader = NULL; GskGLShader *shader;
GdkPaintable *paintable; GdkPaintable *paintable;
if (cog_shader == NULL) shader = gsk_gl_shader_new_from_resource ("/gltransition/cogs2.glsl");
cog_shader = gsk_gl_shader_new_from_resource ("/gltransition/cogs2.glsl"); paintable = gsk_shader_paintable_new (shader, NULL);
paintable = gsk_shader_paintable_new (g_object_ref (cog_shader), NULL);
picture = gtk_picture_new_for_paintable (paintable); picture = gtk_picture_new_for_paintable (paintable);
gtk_widget_set_size_request (picture, 150, 75); gtk_widget_set_size_request (picture, 150, 75);
gtk_widget_add_tick_callback (picture, update_paintable, NULL, NULL); gtk_widget_add_tick_callback (picture, update_paintable, NULL, NULL);

View File

@@ -13,13 +13,13 @@
</style> </style>
<child> <child>
<object class="GtkButton"> <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"/> <signal name="clicked" handler="fishbowl_prev_button_clicked_cb" object="bowl" swapped="no"/>
</object> </object>
</child> </child>
<child> <child>
<object class="GtkButton"> <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"/> <signal name="clicked" handler="fishbowl_next_button_clicked_cb" object="bowl" swapped="no"/>
</object> </object>
</child> </child>

View File

@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<interface> <interface>
<requires lib="gtk+" version="3.12"/>
<object class="GtkWindow" id="window"> <object class="GtkWindow" id="window">
<property name="default-width">600</property> <property name="default-width">600</property>
<property name="default-height">500</property> <property name="default-height">500</property>
@@ -10,8 +11,12 @@
<object class="GtkButton" id="reset"> <object class="GtkButton" id="reset">
<property name="receives-default">1</property> <property name="receives-default">1</property>
<property name="tooltip-text">Reset</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"/> <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> </object>
</child> </child>
</object> </object>

View File

@@ -1068,6 +1068,7 @@ update_font_variations (void)
unsigned int length; unsigned int length;
int i; int i;
child = gtk_widget_get_first_child (variations_grid);
while ((child = gtk_widget_get_first_child (variations_grid))) while ((child = gtk_widget_get_first_child (variations_grid)))
gtk_grid_remove (GTK_GRID (variations_grid), child); gtk_grid_remove (GTK_GRID (variations_grid), child);
@@ -1136,7 +1137,7 @@ done:
g_free (design_coords); g_free (design_coords);
} }
G_MODULE_EXPORT void void
font_features_font_changed (void) font_features_font_changed (void)
{ {
update_script_combo (); update_script_combo ();
@@ -1144,14 +1145,14 @@ font_features_font_changed (void)
update_font_variations (); update_font_variations ();
} }
G_MODULE_EXPORT void void
font_features_script_changed (void) font_features_script_changed (void)
{ {
update_features (); update_features ();
update_display (); update_display ();
} }
G_MODULE_EXPORT void void
font_features_reset_features (void) font_features_reset_features (void)
{ {
GList *l; GList *l;
@@ -1197,7 +1198,7 @@ switch_to_label (void)
update_display (); update_display ();
} }
G_MODULE_EXPORT void void
font_features_toggle_edit (void) font_features_toggle_edit (void)
{ {
if (strcmp (gtk_stack_get_visible_child_name (GTK_STACK (stack)), "label") == 0) if (strcmp (gtk_stack_get_visible_child_name (GTK_STACK (stack)), "label") == 0)
@@ -1206,7 +1207,7 @@ font_features_toggle_edit (void)
switch_to_label (); switch_to_label ();
} }
G_MODULE_EXPORT void void
font_features_stop_edit (void) font_features_stop_edit (void)
{ {
g_signal_emit_by_name (edit_toggle, "clicked"); 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); \ 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.; fg_alpha = bg_alpha = 1.;
attrs = pango_attr_iterator_get_attrs (iter); attrs = pango_attr_iterator_get_attrs (iter);
@@ -268,29 +255,6 @@ insert_tags_for_attributes (GtkTextBuffer *buffer,
INT_ATTR (insert_hyphens); INT_ATTR (insert_hyphens);
break; 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_SHAPE:
case PANGO_ATTR_ABSOLUTE_SIZE: case PANGO_ATTR_ABSOLUTE_SIZE:
case PANGO_ATTR_GRAVITY: case PANGO_ATTR_GRAVITY:
@@ -299,10 +263,6 @@ insert_tags_for_attributes (GtkTextBuffer *buffer,
case PANGO_ATTR_BACKGROUND_ALPHA: case PANGO_ATTR_BACKGROUND_ALPHA:
break; break;
case PANGO_ATTR_TEXT_TRANSFORM:
INT_ATTR (text_transform);
break;
case PANGO_ATTR_INVALID: case PANGO_ATTR_INVALID:
default: default:
g_assert_not_reached (); g_assert_not_reached ();
@@ -541,7 +501,7 @@ fontify (const char *format,
char *theme; char *theme;
gboolean prefer_dark; gboolean prefer_dark;
const char *style_arg; const char *style_arg;
char *text; const char *text;
GtkTextIter start, end; GtkTextIter start, end;
GBytes *bytes; GBytes *bytes;
GError *error = NULL; GError *error = NULL;
@@ -593,7 +553,7 @@ fontify (const char *format,
gtk_text_buffer_get_bounds (source_buffer, &start, &end); gtk_text_buffer_get_bounds (source_buffer, &start, &end);
text = gtk_text_buffer_get_text (source_buffer, &start, &end, TRUE); text = gtk_text_buffer_get_text (source_buffer, &start, &end, TRUE);
bytes = g_bytes_new_take (text, strlen (text)); bytes = g_bytes_new_static (text, strlen (text));
#ifdef HAVE_GIO_UNIX #ifdef HAVE_GIO_UNIX
/* Work around https://gitlab.gnome.org/GNOME/glib/-/issues/2182 */ /* Work around https://gitlab.gnome.org/GNOME/glib/-/issues/2182 */
@@ -610,5 +570,4 @@ fontify (const char *format,
NULL, NULL,
fontify_finish, fontify_finish,
g_object_ref (source_buffer)); g_object_ref (source_buffer));
g_bytes_unref (bytes);
} }

View File

@@ -1,4 +1,4 @@
/* Pango/Font Rendering /* Pango/Font rendering
* *
* Demonstrates various aspects of font rendering. * Demonstrates various aspects of font rendering.
*/ */
@@ -10,7 +10,6 @@ static GtkWidget *font_button = NULL;
static GtkWidget *entry = NULL; static GtkWidget *entry = NULL;
static GtkWidget *image = NULL; static GtkWidget *image = NULL;
static GtkWidget *hinting = NULL; static GtkWidget *hinting = NULL;
static GtkWidget *anti_alias = NULL;
static GtkWidget *hint_metrics = NULL; static GtkWidget *hint_metrics = NULL;
static GtkWidget *up_button = NULL; static GtkWidget *up_button = NULL;
static GtkWidget *down_button = NULL; static GtkWidget *down_button = NULL;
@@ -38,7 +37,6 @@ update_image (void)
cairo_font_options_t *fopt; cairo_font_options_t *fopt;
cairo_hint_style_t hintstyle; cairo_hint_style_t hintstyle;
cairo_hint_metrics_t hintmetrics; cairo_hint_metrics_t hintmetrics;
cairo_antialias_t antialias;
if (!context) if (!context)
context = gtk_widget_create_pango_context (image); context = gtk_widget_create_pango_context (image);
@@ -67,13 +65,6 @@ update_image (void)
hintmetrics = CAIRO_HINT_METRICS_OFF; hintmetrics = CAIRO_HINT_METRICS_OFF;
cairo_font_options_set_hint_metrics (fopt, hintmetrics); 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); pango_cairo_context_set_font_options (context, fopt);
cairo_font_options_destroy (fopt); cairo_font_options_destroy (fopt);
pango_context_changed (context); pango_context_changed (context);
@@ -261,7 +252,6 @@ do_fontrendering (GtkWidget *do_widget)
entry = GTK_WIDGET (gtk_builder_get_object (builder, "entry")); entry = GTK_WIDGET (gtk_builder_get_object (builder, "entry"));
image = GTK_WIDGET (gtk_builder_get_object (builder, "image")); image = GTK_WIDGET (gtk_builder_get_object (builder, "image"));
hinting = GTK_WIDGET (gtk_builder_get_object (builder, "hinting")); 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")); hint_metrics = GTK_WIDGET (gtk_builder_get_object (builder, "hint_metrics"));
text_radio = GTK_WIDGET (gtk_builder_get_object (builder, "text_radio")); text_radio = GTK_WIDGET (gtk_builder_get_object (builder, "text_radio"));
show_grid = GTK_WIDGET (gtk_builder_get_object (builder, "show_grid")); show_grid = GTK_WIDGET (gtk_builder_get_object (builder, "show_grid"));
@@ -272,7 +262,6 @@ do_fontrendering (GtkWidget *do_widget)
g_signal_connect (entry, "notify::text", G_CALLBACK (update_image), 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 (font_button, "notify::font-desc", G_CALLBACK (update_image), NULL);
g_signal_connect (hinting, "notify::active", 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 (hint_metrics, "notify::active", G_CALLBACK (update_image), NULL);
g_signal_connect (text_radio, "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_grid, "notify::active", G_CALLBACK (update_image), NULL);

View File

@@ -98,15 +98,6 @@
</layout> </layout>
</object> </object>
</child> </child>
<child>
<object class="GtkCheckButton" id="antialias">
<property name="label">Antialias</property>
<layout>
<property name="column">3</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child> <child>
<object class="GtkComboBoxText" id="hinting"> <object class="GtkComboBoxText" id="hinting">
<property name="active">0</property> <property name="active">0</property>

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

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

View File

@@ -1,16 +1,11 @@
/* OpenGL/Transitions and Effects /* OpenGL/Transitions
* #Keywords: OpenGL, shader, effect * #Keywords: OpenGL, shader
* *
* Create transitions between pages using a custom fragment shader. * Create transitions between pages using a custom fragment shader.
* The examples here are taken from gl-transitions.com, and you
* can edit the transision code itself on the last page of the stack.
* *
* The example transitions here are taken from gl-transitions.com, and you * It also shows some sample fire effects on the buttons.
* can edit the shader code itself on the last page of the stack.
*
* The transitions work with arbitrary content. We use images, shaders
* GL areas and plain old widgets to demonstrate this.
*
* The demo also shows some over-the-top effects like wobbly widgets,
* and animated backgrounds.
*/ */
#include <math.h> #include <math.h>
@@ -86,15 +81,15 @@ clicked_cb (GtkGestureClick *gesture,
} }
static GtkWidget * static GtkWidget *
ripple_bin_new (void) fire_bin_new (void)
{ {
GtkWidget *bin = gtk_shader_bin_new (); GtkWidget *bin = gtk_shader_bin_new ();
static GskGLShader *shader = NULL; static GskGLShader *shader = NULL;
if (shader == NULL) if (shader == NULL)
shader = gsk_gl_shader_new_from_resource ("/gltransition/ripple.glsl"); shader = gsk_gl_shader_new_from_resource ("/gltransition/fire.glsl");
gtk_shader_bin_add_shader (GTK_SHADER_BIN (bin), shader, GTK_STATE_FLAG_PRELIGHT, GTK_STATE_FLAG_PRELIGHT, 20); gtk_shader_bin_add_shader (GTK_SHADER_BIN (bin), shader, GTK_STATE_FLAG_PRELIGHT, GTK_STATE_FLAG_PRELIGHT);
return bin; return bin;
} }
@@ -130,10 +125,10 @@ update_paintable (GtkWidget *widget,
} }
static GtkWidget * static GtkWidget *
make_shader_stack (const char *name, make_shader_stack (const char *name,
const char *resource_path, const char *resource_path,
int active_child, GtkWidget *scale,
GtkWidget *scale) GdkFrameClock *frame_clock)
{ {
GtkWidget *stack, *child, *widget, *vbox, *hbox, *bin; GtkWidget *stack, *child, *widget, *vbox, *hbox, *bin;
GtkWidget *label, *button, *tv; GtkWidget *label, *button, *tv;
@@ -152,7 +147,7 @@ make_shader_stack (const char *name,
gtk_shader_stack_set_shader (GTK_SHADER_STACK (stack), shader); gtk_shader_stack_set_shader (GTK_SHADER_STACK (stack), shader);
g_object_unref (shader); g_object_unref (shader);
child = gtk_picture_new_for_resource ("/css_blendmodes/ducky.png"); child = gtk_picture_new_for_resource ("/css_pixbufs/background.jpg");
gtk_picture_set_can_shrink (GTK_PICTURE (child), TRUE); gtk_picture_set_can_shrink (GTK_PICTURE (child), TRUE);
gtk_shader_stack_add_child (GTK_SHADER_STACK (stack), child); gtk_shader_stack_add_child (GTK_SHADER_STACK (stack), child);
@@ -221,8 +216,6 @@ make_shader_stack (const char *name,
gtk_shader_stack_add_child (GTK_SHADER_STACK (stack), child); gtk_shader_stack_add_child (GTK_SHADER_STACK (stack), child);
gtk_shader_stack_set_active (GTK_SHADER_STACK (stack), active_child);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
widget = gtk_center_box_new (); widget = gtk_center_box_new ();
@@ -249,25 +242,22 @@ make_shader_stack (const char *name,
gtk_box_append (GTK_BOX (vbox), widget); gtk_box_append (GTK_BOX (vbox), widget);
GtkWidget *bin2 = ripple_bin_new (); gtk_box_append (GTK_BOX (vbox), stack);
gtk_shader_bin_set_child (GTK_SHADER_BIN (bin2), stack);
gtk_box_append (GTK_BOX (vbox), bin2);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_widget_set_halign (hbox, GTK_ALIGN_CENTER); gtk_widget_set_halign (hbox, GTK_ALIGN_CENTER);
gtk_box_append (GTK_BOX (vbox), hbox); gtk_box_append (GTK_BOX (vbox), hbox);
button = gtk_button_new_from_icon_name ("go-previous-symbolic"); button = gtk_button_new_from_icon_name ("go-previous");
g_signal_connect (button, "clicked", G_CALLBACK (go_back), stack); g_signal_connect (button, "clicked", G_CALLBACK (go_back), stack);
bin = ripple_bin_new (); bin = fire_bin_new ();
gtk_shader_bin_set_child (GTK_SHADER_BIN (bin), button); gtk_shader_bin_set_child (GTK_SHADER_BIN (bin), button);
gtk_box_append (GTK_BOX (hbox), bin); gtk_box_append (GTK_BOX (hbox), bin);
button = gtk_button_new_from_icon_name ("go-next-symbolic"); button = gtk_button_new_from_icon_name ("go-next");
g_signal_connect (button, "clicked", G_CALLBACK (go_forward), stack); g_signal_connect (button, "clicked", G_CALLBACK (go_forward), stack);
bin = ripple_bin_new (); bin = fire_bin_new ();
gtk_shader_bin_set_child (GTK_SHADER_BIN (bin), button); gtk_shader_bin_set_child (GTK_SHADER_BIN (bin), button);
gtk_box_append (GTK_BOX (hbox), bin); gtk_box_append (GTK_BOX (hbox), bin);
@@ -277,37 +267,23 @@ make_shader_stack (const char *name,
static GtkWidget * static GtkWidget *
create_gltransition_window (GtkWidget *do_widget) create_gltransition_window (GtkWidget *do_widget)
{ {
GtkWidget *window, *headerbar, *scale, *outer_grid, *grid, *background; GtkWidget *window, *headerbar, *scale, *grid;
GdkPaintable *paintable; GdkFrameClock *frame_clock;
window = gtk_window_new (); window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget)); gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Transitions and Effects"); gtk_window_set_title (GTK_WINDOW (window), "Transitions");
headerbar = gtk_header_bar_new (); headerbar = gtk_header_bar_new ();
scale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, NULL); scale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, NULL);
gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE); gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
gtk_widget_set_size_request (scale, 100, -1); gtk_widget_set_size_request (scale, 100, -1);
gtk_widget_set_tooltip_text (scale, "Transition duration");
gtk_header_bar_pack_end (GTK_HEADER_BAR (headerbar), scale); gtk_header_bar_pack_end (GTK_HEADER_BAR (headerbar), scale);
gtk_window_set_titlebar (GTK_WINDOW (window), headerbar); gtk_window_set_titlebar (GTK_WINDOW (window), headerbar);
gtk_window_set_default_size (GTK_WINDOW (window), 800, 600); gtk_window_set_default_size (GTK_WINDOW (window), 800, 600);
g_signal_connect (window, "destroy", G_CALLBACK (close_window), NULL); g_signal_connect (window, "destroy", G_CALLBACK (close_window), NULL);
outer_grid = gtk_grid_new ();
gtk_window_set_child (GTK_WINDOW (window), outer_grid);
paintable = gsk_shader_paintable_new (gsk_gl_shader_new_from_resource ("/gltransition/background.glsl"), NULL);
background = gtk_picture_new_for_paintable (paintable);
gtk_widget_add_tick_callback (background, update_paintable, NULL, NULL);
gtk_grid_attach (GTK_GRID (outer_grid),
background,
0, 0, 1, 1);
grid = gtk_grid_new (); grid = gtk_grid_new ();
gtk_grid_attach (GTK_GRID (outer_grid), gtk_window_set_child (GTK_WINDOW (window), grid);
grid,
0, 0, 1, 1);
gtk_widget_set_halign (grid, GTK_ALIGN_CENTER); gtk_widget_set_halign (grid, GTK_ALIGN_CENTER);
gtk_widget_set_valign (grid, GTK_ALIGN_CENTER); gtk_widget_set_valign (grid, GTK_ALIGN_CENTER);
@@ -320,17 +296,20 @@ create_gltransition_window (GtkWidget *do_widget)
gtk_grid_set_row_homogeneous (GTK_GRID (grid), TRUE); gtk_grid_set_row_homogeneous (GTK_GRID (grid), TRUE);
gtk_grid_set_column_homogeneous (GTK_GRID (grid), TRUE); gtk_grid_set_column_homogeneous (GTK_GRID (grid), TRUE);
gtk_widget_realize (window);
frame_clock = gtk_widget_get_frame_clock (window);
gtk_grid_attach (GTK_GRID (grid), gtk_grid_attach (GTK_GRID (grid),
make_shader_stack ("Wind", "/gltransition/wind.glsl", 0, scale), make_shader_stack ("Wind", "/gltransition/transition1.glsl", scale, frame_clock),
0, 0, 1, 1); 0, 0, 1, 1);
gtk_grid_attach (GTK_GRID (grid), gtk_grid_attach (GTK_GRID (grid),
make_shader_stack ("Radial", "/gltransition/radial.glsl", 1, scale), make_shader_stack ("Radial", "/gltransition/transition2.glsl", scale, frame_clock),
1, 0, 1, 1); 1, 0, 1, 1);
gtk_grid_attach (GTK_GRID (grid), gtk_grid_attach (GTK_GRID (grid),
make_shader_stack ("Crosswarp", "/gltransition/crosswarp.glsl", 2, scale), make_shader_stack ("Crosswarp", "/gltransition/transition3.glsl", scale, frame_clock),
0, 1, 1, 1); 0, 1, 1, 1);
gtk_grid_attach (GTK_GRID (grid), gtk_grid_attach (GTK_GRID (grid),
make_shader_stack ("Kaleidoscope", "/gltransition/kaleidoscope.glsl", 3, scale), make_shader_stack ("Kaleidoscope", "/gltransition/transition4.glsl", scale, frame_clock),
1, 1, 1, 1); 1, 1, 1, 1);
return window; return window;

View File

@@ -23,19 +23,22 @@
#include "gskshaderpaintable.h" #include "gskshaderpaintable.h"
/** /**
* GskShaderPaintable: * SECTION:gskshaderpaintable
* @Short_description: Drawing with shaders
* @Title: GskShaderPaintable
* @see_also: #GdkPaintable
* *
* `GskShaderPaintable` is an implementation of the `GdkPaintable` interface * GskShaderPaintable is an implementation of the #GdkPaintable interface
* that uses a `GskGLShader` to create pixels. * that uses a #GskGLShader to create pixels.
* *
* You can set the uniform data that the shader needs for rendering * You can set the uniform data that the shader needs for rendering
* using gsk_shader_paintable_set_args(). This function can * using gsk_shader_paintable_set_uniform_data(). This function can
* be called repeatedly to change the uniform data for the next * be called repeatedly to change the uniform data for the next
* snapshot. * snapshot.
* *
* Commonly, time is passed to shaders as a float uniform containing * Commonly, time is passed to shaders as a float uniform containing
* the elapsed time in seconds. The convenience API * 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. * to update the time based on the frame time of the frame clock.
*/ */
@@ -45,7 +48,7 @@ struct _GskShaderPaintable
GObject parent_instance; GObject parent_instance;
GskGLShader *shader; GskGLShader *shader;
GBytes *args; GBytes *uniform_data;
gint64 start_time; gint64 start_time;
}; };
@@ -58,7 +61,7 @@ struct _GskShaderPaintableClass
enum { enum {
PROP_0, PROP_0,
PROP_SHADER, PROP_SHADER,
PROP_ARGS, PROP_UNIFORM_DATA,
N_PROPS, N_PROPS,
}; };
@@ -73,7 +76,12 @@ gsk_shader_paintable_paintable_snapshot (GdkPaintable *paintable,
{ {
GskShaderPaintable *self = GSK_SHADER_PAINTABLE (paintable); GskShaderPaintable *self = GSK_SHADER_PAINTABLE (paintable);
gtk_snapshot_push_gl_shader (snapshot, self->shader, &GRAPHENE_RECT_INIT(0, 0, width, height), g_bytes_ref (self->args)); /* FIXME: We have to add a pointless extra child here to
* keep GtkSnapshot from blowing up. We really want n_children = 0,
* but then we would pop() 0 times, and... no pop, no node.
*/
gtk_snapshot_push_gl_shader (snapshot, self->shader, &GRAPHENE_RECT_INIT(0, 0, width, height), g_bytes_ref (self->uniform_data), 1);
gtk_snapshot_append_color (snapshot, &(GdkRGBA){1.0, 0.5, 0.6, 1.0}, &GRAPHENE_RECT_INIT(0, 0, width, height));
gtk_snapshot_pop (snapshot); gtk_snapshot_pop (snapshot);
} }
@@ -102,8 +110,8 @@ gsk_shader_paintable_set_property (GObject *object,
gsk_shader_paintable_set_shader (self, g_value_get_object (value)); gsk_shader_paintable_set_shader (self, g_value_get_object (value));
break; break;
case PROP_ARGS: case PROP_UNIFORM_DATA:
gsk_shader_paintable_set_args (self, g_value_get_boxed (value)); gsk_shader_paintable_set_uniform_data (self, g_value_get_boxed (value));
break; break;
default: default:
@@ -126,8 +134,8 @@ gsk_shader_paintable_get_property (GObject *object,
g_value_set_object (value, self->shader); g_value_set_object (value, self->shader);
break; break;
case PROP_ARGS: case PROP_UNIFORM_DATA:
g_value_set_boxed (value, self->args); g_value_set_boxed (value, self->uniform_data);
break; break;
default: default:
@@ -141,7 +149,7 @@ gsk_shader_paintable_finalize (GObject *object)
{ {
GskShaderPaintable *self = GSK_SHADER_PAINTABLE (object); GskShaderPaintable *self = GSK_SHADER_PAINTABLE (object);
g_clear_pointer (&self->args, g_bytes_unref); g_clear_pointer (&self->uniform_data, g_bytes_unref);
g_clear_object (&self->shader); g_clear_object (&self->shader);
G_OBJECT_CLASS (gsk_shader_paintable_parent_class)->finalize (object); G_OBJECT_CLASS (gsk_shader_paintable_parent_class)->finalize (object);
@@ -161,8 +169,8 @@ gsk_shader_paintable_class_init (GskShaderPaintableClass *klass)
GSK_TYPE_GL_SHADER, GSK_TYPE_GL_SHADER,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS); G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
properties[PROP_ARGS] = properties[PROP_UNIFORM_DATA] =
g_param_spec_boxed ("args", "Arguments", "The uniform arguments", g_param_spec_boxed ("uniform-data", "Uniform data", "The uniform data",
G_TYPE_BYTES, G_TYPE_BYTES,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS); G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
@@ -183,7 +191,7 @@ gsk_shader_paintable_init (GskShaderPaintable *self)
* pixels. The shader must not require input textures. * pixels. The shader must not require input textures.
* If @data is %NULL, all uniform values are set to zero. * If @data is %NULL, all uniform values are set to zero.
* *
* Returns: (transfer full): a new `GskShaderPaintable` * Returns: (transfer full): a new #GskShaderPaintable
*/ */
GdkPaintable * GdkPaintable *
gsk_shader_paintable_new (GskGLShader *shader, gsk_shader_paintable_new (GskGLShader *shader,
@@ -201,7 +209,7 @@ gsk_shader_paintable_new (GskGLShader *shader,
ret = g_object_new (GSK_TYPE_SHADER_PAINTABLE, ret = g_object_new (GSK_TYPE_SHADER_PAINTABLE,
"shader", shader, "shader", shader,
"args", data, "uniform-data", data,
NULL); NULL);
g_clear_object (&shader); g_clear_object (&shader);
@@ -212,8 +220,8 @@ gsk_shader_paintable_new (GskGLShader *shader,
/** /**
* gsk_shader_paintable_set_shader: * gsk_shader_paintable_set_shader:
* @self: a `GskShaderPaintable` * @self: a #GskShaderPaintable
* @shader: the `GskGLShader` to use * @shader: the #GskGLShader to use
* *
* Sets the shader that the paintable will use * Sets the shader that the paintable will use
* to create pixels. The shader must not require * to create pixels. The shader must not require
@@ -225,7 +233,7 @@ gsk_shader_paintable_set_shader (GskShaderPaintable *self,
{ {
g_return_if_fail (GSK_IS_SHADER_PAINTABLE (self)); g_return_if_fail (GSK_IS_SHADER_PAINTABLE (self));
g_return_if_fail (shader == NULL || GSK_IS_GL_SHADER (shader)); g_return_if_fail (shader == NULL || GSK_IS_GL_SHADER (shader));
g_return_if_fail (shader == NULL || gsk_gl_shader_get_n_textures (shader) == 0); g_return_if_fail (shader == NULL || gsk_gl_shader_get_n_required_textures (shader) == 0);
if (!g_set_object (&self->shader, shader)) if (!g_set_object (&self->shader, shader))
return; return;
@@ -233,16 +241,16 @@ gsk_shader_paintable_set_shader (GskShaderPaintable *self,
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SHADER]); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SHADER]);
gdk_paintable_invalidate_contents (GDK_PAINTABLE (self)); gdk_paintable_invalidate_contents (GDK_PAINTABLE (self));
g_clear_pointer (&self->args, g_bytes_unref); g_clear_pointer (&self->uniform_data, g_bytes_unref);
} }
/** /**
* gsk_shader_paintable_get_shader: * gsk_shader_paintable_get_shader:
* @self: a `GskShaderPaintable` * @self: a #GskShaderPaintable
* *
* Returns the shader that the paintable is using. * 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 * GskGLShader *
gsk_shader_paintable_get_shader (GskShaderPaintable *self) gsk_shader_paintable_get_shader (GskShaderPaintable *self)
@@ -253,82 +261,89 @@ gsk_shader_paintable_get_shader (GskShaderPaintable *self)
} }
/** /**
* gsk_shader_paintable_set_args: * gsk_shader_paintable_set_uniform_data:
* @self: a `GskShaderPaintable` * @self: a #GskShaderPaintable
* @data: Data block with uniform data for the shader * @data: Data block with uniform data for the shader
* *
* Sets the uniform data that will be passed to the * Sets the uniform data that will be passed to the
* shader when rendering. The @data will typically * 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 * Note that the @data should be considered immutable
* after it has been passed to this function. * after it has been passed to this function.
*/ */
void void
gsk_shader_paintable_set_args (GskShaderPaintable *self, gsk_shader_paintable_set_uniform_data (GskShaderPaintable *self,
GBytes *data) GBytes *data)
{ {
g_return_if_fail (GSK_IS_SHADER_PAINTABLE (self)); g_return_if_fail (GSK_IS_SHADER_PAINTABLE (self));
g_return_if_fail (data == NULL || g_bytes_get_size (data) == gsk_gl_shader_get_args_size (self->shader)); g_return_if_fail (data == NULL || g_bytes_get_size (data) == gsk_gl_shader_get_args_size (self->shader));
g_clear_pointer (&self->args, g_bytes_unref); g_clear_pointer (&self->uniform_data, g_bytes_unref);
if (data) if (data)
self->args = g_bytes_ref (data); self->uniform_data = g_bytes_ref (data);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ARGS]); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_UNIFORM_DATA]);
gdk_paintable_invalidate_contents (GDK_PAINTABLE (self)); gdk_paintable_invalidate_contents (GDK_PAINTABLE (self));
} }
/** /**
* gsk_shader_paintable_get_args: * gsk_shader_paintable_get_uniform_data:
* @self: a `GskShaderPaintable` * @self: a #GskShaderPaintable
* *
* Returns the uniform data set with * Returns the uniform data set with
* gsk_shader_paintable_get_args(). * gsk_shader_paintable_get_uniform_data().
* *
* Returns: (transfer none): the uniform data * Returns: (transfer none): the uniform data
*/ */
GBytes * GBytes *
gsk_shader_paintable_get_args (GskShaderPaintable *self) gsk_shader_paintable_get_uniform_data (GskShaderPaintable *self)
{ {
g_return_val_if_fail (GSK_IS_SHADER_PAINTABLE (self), NULL); g_return_val_if_fail (GSK_IS_SHADER_PAINTABLE (self), NULL);
return self->args; return self->uniform_data;
} }
/** /**
* gsk_shader_paintable_update_time: * gsk_shader_paintable_update_time:
* @self: a `GskShaderPaintable` * @self: a #GskShaderPaintable
* @time_idx: the index of the uniform for time in seconds as float * @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 * This function is a convenience wrapper for
* gsk_shader_paintable_set_args() that leaves all * gsk_shader_paintable_set_uniform_data() that leaves all
* uniform values unchanged, except for the uniform with * uniform values unchanged, except for the uniform with
* index @time_idx, which will be set to the elapsed time * index @time_idx, which will be set to the elapsed time
* in seconds, since the first call to this function. * 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 void
gsk_shader_paintable_update_time (GskShaderPaintable *self, gsk_shader_paintable_update_time (GskShaderPaintable *self,
int time_idx, int time_idx,
gint64 frame_time) gint64 frame_time)
{ {
GskShaderArgsBuilder *builder; int size;
GBytes *args; int offset;
guchar *data;
float time; float time;
GBytes *uniform_data;
size = gsk_gl_shader_get_args_size (self->shader);
offset = gsk_gl_shader_get_uniform_offset (self->shader, time_idx);
data = g_new0 (guchar, size);
memcpy (data, g_bytes_get_data (self->uniform_data, NULL), size);
if (self->start_time == 0) if (self->start_time == 0)
self->start_time = frame_time; self->start_time = frame_time;
time = (frame_time - self->start_time) / (float)G_TIME_SPAN_SECOND; time = (frame_time - self->start_time) / (float)G_TIME_SPAN_SECOND;
*(float*)(data + offset) = time;
builder = gsk_shader_args_builder_new (self->shader, self->args); uniform_data = g_bytes_new_take (data, size);
gsk_shader_args_builder_set_float (builder, time_idx, time);
args = gsk_shader_args_builder_free_to_args (builder);
gsk_shader_paintable_set_args (self, args); gsk_shader_paintable_set_uniform_data (self, uniform_data);
g_bytes_unref (args); g_bytes_unref (uniform_data);
} }

View File

@@ -40,9 +40,9 @@ GDK_AVAILABLE_IN_ALL
void gsk_shader_paintable_set_shader (GskShaderPaintable *self, void gsk_shader_paintable_set_shader (GskShaderPaintable *self,
GskGLShader *shader); GskGLShader *shader);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GBytes * gsk_shader_paintable_get_args (GskShaderPaintable *self); GBytes * gsk_shader_paintable_get_uniform_data (GskShaderPaintable *self);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
void gsk_shader_paintable_set_args (GskShaderPaintable *self, void gsk_shader_paintable_set_uniform_data (GskShaderPaintable *self,
GBytes *data); GBytes *data);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
void gsk_shader_paintable_update_time (GskShaderPaintable *self, void gsk_shader_paintable_update_time (GskShaderPaintable *self,

View File

@@ -74,9 +74,9 @@ gtk_fishbowl_init (GtkFishbowl *fishbowl)
/** /**
* gtk_fishbowl_new: * gtk_fishbowl_new:
* *
* Creates a new `GtkFishbowl`. * Creates a new #GtkFishbowl.
* *
* Returns: a new `GtkFishbowl`. * Returns: a new #GtkFishbowl.
*/ */
GtkWidget* GtkWidget*
gtk_fishbowl_new (void) gtk_fishbowl_new (void)
@@ -179,9 +179,6 @@ gtk_fishbowl_add (GtkFishbowl *fishbowl,
child_info->dy = new_speed (); child_info->dy = new_speed ();
gtk_widget_set_parent (widget, GTK_WIDGET (fishbowl)); gtk_widget_set_parent (widget, GTK_WIDGET (fishbowl));
gtk_accessible_update_state (GTK_ACCESSIBLE (widget),
GTK_ACCESSIBLE_STATE_HIDDEN, TRUE,
-1);
g_hash_table_insert (priv->children, widget, child_info); g_hash_table_insert (priv->children, widget, child_info);
priv->count++; priv->count++;
@@ -345,8 +342,6 @@ gtk_fishbowl_class_init (GtkFishbowlClass *klass)
G_PARAM_READWRITE); G_PARAM_READWRITE);
g_object_class_install_properties (object_class, NUM_PROPERTIES, props); g_object_class_install_properties (object_class, NUM_PROPERTIES, props);
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_PRESENTATION);
} }
guint guint

View File

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

View File

@@ -4,7 +4,6 @@ typedef struct {
GskGLShader *shader; GskGLShader *shader;
GtkStateFlags state; GtkStateFlags state;
GtkStateFlags state_mask; GtkStateFlags state_mask;
float extra_border;
gboolean compiled; gboolean compiled;
gboolean compiled_ok; gboolean compiled_ok;
} ShaderInfo; } ShaderInfo;
@@ -17,7 +16,6 @@ struct _GtkShaderBin
GPtrArray *shaders; GPtrArray *shaders;
guint tick_id; guint tick_id;
float time; float time;
float mouse_x, mouse_y;
gint64 first_frame_time; gint64 first_frame_time;
}; };
@@ -73,25 +71,10 @@ gtk_shader_bin_tick (GtkWidget *widget,
return G_SOURCE_CONTINUE; return G_SOURCE_CONTINUE;
} }
static void
motion_cb (GtkEventControllerMotion *controller,
double x,
double y,
GtkShaderBin *self)
{
self->mouse_x = x;
self->mouse_y = y;
}
static void static void
gtk_shader_bin_init (GtkShaderBin *self) gtk_shader_bin_init (GtkShaderBin *self)
{ {
GtkEventController *controller;
self->shaders = g_ptr_array_new_with_free_func ((GDestroyNotify)shader_info_free); self->shaders = g_ptr_array_new_with_free_func ((GDestroyNotify)shader_info_free);
controller = gtk_event_controller_motion_new ();
g_signal_connect (controller, "motion", G_CALLBACK (motion_cb), self);
gtk_widget_add_controller (GTK_WIDGET (self), controller);
} }
void void
@@ -149,14 +132,12 @@ void
gtk_shader_bin_add_shader (GtkShaderBin *self, gtk_shader_bin_add_shader (GtkShaderBin *self,
GskGLShader *shader, GskGLShader *shader,
GtkStateFlags state, GtkStateFlags state,
GtkStateFlags state_mask, GtkStateFlags state_mask)
float extra_border)
{ {
ShaderInfo *info = g_new0 (ShaderInfo, 1); ShaderInfo *info = g_new0 (ShaderInfo, 1);
info->shader = g_object_ref (shader); info->shader = g_object_ref (shader);
info->state = state; info->state = state;
info->state_mask = state_mask; info->state_mask = state_mask;
info->extra_border = extra_border;
g_ptr_array_add (self->shaders, info); g_ptr_array_add (self->shaders, info);
@@ -206,8 +187,8 @@ gtk_shader_bin_snapshot (GtkWidget *widget,
self->active_shader->compiled = TRUE; self->active_shader->compiled = TRUE;
self->active_shader->compiled_ok = self->active_shader->compiled_ok =
gsk_gl_shader_compile (self->active_shader->shader, gsk_gl_shader_try_compile_for (self->active_shader->shader,
renderer, &error); renderer, &error);
if (!self->active_shader->compiled_ok) if (!self->active_shader->compiled_ok)
{ {
g_warning ("GtkShaderBin failed to compile shader: %s", error->message); g_warning ("GtkShaderBin failed to compile shader: %s", error->message);
@@ -217,17 +198,13 @@ gtk_shader_bin_snapshot (GtkWidget *widget,
if (self->active_shader->compiled_ok) if (self->active_shader->compiled_ok)
{ {
float border = self->active_shader->extra_border;
graphene_vec2_t mouse;
graphene_vec2_init (&mouse, self->mouse_x + border, self->mouse_y + border);
gtk_snapshot_push_gl_shader (snapshot, self->active_shader->shader, gtk_snapshot_push_gl_shader (snapshot, self->active_shader->shader,
&GRAPHENE_RECT_INIT(-border, -border, width+2*border, height+2*border), &GRAPHENE_RECT_INIT(0, 0, width, height),
gsk_gl_shader_format_args (self->active_shader->shader, gsk_gl_shader_format_args (self->active_shader->shader,
"u_time", self->time, "u_time", &self->time,
"u_mouse", &mouse, NULL),
NULL)); 1);
gtk_widget_snapshot_child (widget, self->child, snapshot); gtk_widget_snapshot_child (widget, self->child, snapshot);
gtk_snapshot_gl_shader_pop_texture (snapshot);
gtk_snapshot_pop (snapshot); gtk_snapshot_pop (snapshot);
return; return;

View File

@@ -12,8 +12,7 @@ GtkWidget *gtk_shader_bin_new (void);
void gtk_shader_bin_add_shader (GtkShaderBin *self, void gtk_shader_bin_add_shader (GtkShaderBin *self,
GskGLShader *shader, GskGLShader *shader,
GtkStateFlags state, GtkStateFlags state,
GtkStateFlags state_mask, GtkStateFlags state_mask);
float extra_border);
void gtk_shader_bin_set_child (GtkShaderBin *self, void gtk_shader_bin_set_child (GtkShaderBin *self,
GtkWidget *child); GtkWidget *child);
GtkWidget *gtk_shader_bin_get_child (GtkShaderBin *self); GtkWidget *gtk_shader_bin_get_child (GtkShaderBin *self);

View File

@@ -238,20 +238,21 @@ gtk_shader_stack_snapshot (GtkWidget *widget,
progress = 1. - progress; progress = 1. - progress;
} }
if (gsk_gl_shader_compile (self->shader, renderer, NULL)) if (gsk_gl_shader_try_compile_for (self->shader,
renderer, NULL))
{ {
gtk_snapshot_push_gl_shader (snapshot, gtk_snapshot_push_gl_shader (snapshot,
self->shader, self->shader,
&GRAPHENE_RECT_INIT(0, 0, width, height), &GRAPHENE_RECT_INIT(0, 0, width, height),
gsk_gl_shader_format_args (self->shader, gsk_gl_shader_format_args (self->shader,
"progress", progress, "progress", &progress,
NULL)); NULL),
2);
gtk_widget_snapshot_child (widget, current, snapshot); gtk_widget_snapshot_child (widget, current, snapshot);
gtk_snapshot_gl_shader_pop_texture (snapshot); /* current child */ gtk_snapshot_pop (snapshot); /* current child */
gtk_widget_snapshot_child (widget, next, snapshot); gtk_widget_snapshot_child (widget, next, snapshot);
gtk_snapshot_gl_shader_pop_texture (snapshot); /* next child */ gtk_snapshot_pop (snapshot); /* next child */
gtk_snapshot_pop (snapshot);
} }
else else
{ {
@@ -350,12 +351,3 @@ gtk_shader_stack_add_child (GtkShaderStack *self,
else else
gtk_widget_set_child_visible (child, FALSE); gtk_widget_set_child_visible (child, FALSE);
} }
void
gtk_shader_stack_set_active (GtkShaderStack *self,
int index)
{
stop_transition (self);
self->current = MIN (index, self->children->len);
update_child_visible (self);
}

View File

@@ -14,9 +14,7 @@ void gtk_shader_stack_set_shader (GtkShaderStack *self,
void gtk_shader_stack_add_child (GtkShaderStack *self, void gtk_shader_stack_add_child (GtkShaderStack *self,
GtkWidget *child); GtkWidget *child);
void gtk_shader_stack_transition (GtkShaderStack *self, void gtk_shader_stack_transition (GtkShaderStack *self,
gboolean forward); gboolean forward);
void gtk_shader_stack_set_active (GtkShaderStack *self,
int index);
G_END_DECLS G_END_DECLS

View File

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

View File

@@ -18,6 +18,8 @@ do_headerbar (GtkWidget *do_widget)
GtkWidget *header; GtkWidget *header;
GtkWidget *button; GtkWidget *button;
GtkWidget *box; GtkWidget *box;
GtkWidget *image;
GIcon *icon;
if (!window) if (!window)
{ {
@@ -30,14 +32,20 @@ do_headerbar (GtkWidget *do_widget)
header = gtk_header_bar_new (); 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); gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_add_css_class (box, "linked"); 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); 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_box_append (GTK_BOX (box), button);
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), box); gtk_header_bar_pack_start (GTK_HEADER_BAR (header), box);

View File

@@ -61,26 +61,12 @@ show_page (GtkTextView *text_view,
int page) int page)
{ {
GtkTextBuffer *buffer; GtkTextBuffer *buffer;
GtkTextIter iter, start; GtkTextIter iter;
GtkTextMark *mark;
GtkWidget *child; GtkWidget *child;
GtkTextChildAnchor *anchor; GtkTextChildAnchor *anchor;
GtkEventController *controller; GtkEventController *controller;
GtkTextTag *bold, *mono, *nobreaks;
buffer = gtk_text_view_get_buffer (text_view); 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_set_text (buffer, "", 0);
gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0); gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0);
gtk_text_buffer_begin_irreversible_action (buffer); gtk_text_buffer_begin_irreversible_action (buffer);
@@ -118,22 +104,17 @@ show_page (GtkTextView *text_view,
} }
else if (page == 2) 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); tag = gtk_text_buffer_create_tag (buffer, NULL,
gtk_text_buffer_insert (buffer, &iter, " /", -1); "weight", PANGO_WEIGHT_BOLD,
"scale", PANGO_SCALE_X_LARGE,
gtk_text_buffer_get_iter_at_mark (buffer, &start, mark); NULL);
gtk_text_buffer_apply_tag (buffer, nobreaks, &start, &iter); gtk_text_buffer_insert_with_tags (buffer, &iter, "tag", -1, tag, NULL);
gtk_text_buffer_insert (buffer, &iter, " ", -1); tag = gtk_text_buffer_create_tag (buffer, NULL,
"family", "monospace",
gtk_text_buffer_move_mark (buffer, mark, &iter); NULL);
gtk_text_buffer_insert_with_tags (buffer, &iter, "tag", -1, mono, NULL); gtk_text_buffer_insert_with_tags (buffer, &iter, " /tag/ ", -1, tag, 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);
anchor = gtk_text_buffer_create_child_anchor (buffer, &iter); anchor = gtk_text_buffer_create_child_anchor (buffer, &iter);
child = gtk_image_new_from_icon_name ("audio-volume-high-symbolic"); child = gtk_image_new_from_icon_name ("audio-volume-high-symbolic");
@@ -151,26 +132,20 @@ show_page (GtkTextView *text_view,
"behavior of mouse and key presses, “lock” a range of text so the " "behavior of mouse and key presses, “lock” a range of text so the "
"user can't edit it, or countless other things.\n", -1); "user can't edit it, or countless other things.\n", -1);
insert_link (buffer, &iter, "Go back", 1); insert_link (buffer, &iter, "Go back", 1);
gtk_text_buffer_delete_mark (buffer, mark);
} }
else if (page == 3) 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); tag = gtk_text_buffer_create_tag (buffer, NULL,
gtk_text_buffer_insert (buffer, &iter, " /", -1); "weight", PANGO_WEIGHT_BOLD,
"scale", PANGO_SCALE_X_LARGE,
gtk_text_buffer_get_iter_at_mark (buffer, &start, mark); NULL);
gtk_text_buffer_apply_tag (buffer, nobreaks, &start, &iter); gtk_text_buffer_insert_with_tags (buffer, &iter, "hypertext", -1, tag, NULL);
gtk_text_buffer_insert (buffer, &iter, " ", -1); tag = gtk_text_buffer_create_tag (buffer, NULL,
"family", "monospace",
gtk_text_buffer_move_mark (buffer, mark, &iter); NULL);
gtk_text_buffer_insert_with_tags (buffer, &iter, "ˈhaɪ pərˌtɛkst", -1, mono, NULL); gtk_text_buffer_insert_with_tags (buffer, &iter, " /ˈhaɪ pərˌtɛkst/ ", -1, tag, 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);
anchor = gtk_text_buffer_create_child_anchor (buffer, &iter); anchor = gtk_text_buffer_create_child_anchor (buffer, &iter);
child = gtk_image_new_from_icon_name ("audio-volume-high-symbolic"); child = gtk_image_new_from_icon_name ("audio-volume-high-symbolic");
@@ -184,8 +159,6 @@ show_page (GtkTextView *text_view,
"Machine-readable text that is not sequential but is organized " "Machine-readable text that is not sequential but is organized "
"so that related items of information are connected.\n", -1); "so that related items of information are connected.\n", -1);
insert_link (buffer, &iter, "Go back", 1); insert_link (buffer, &iter, "Go back", 1);
gtk_text_buffer_delete_mark (buffer, mark);
} }
gtk_text_buffer_end_irreversible_action (buffer); gtk_text_buffer_end_irreversible_action (buffer);
} }
@@ -385,7 +358,7 @@ do_hypertext (GtkWidget *do_widget)
sw = gtk_scrolled_window_new (); sw = gtk_scrolled_window_new ();
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC); GTK_POLICY_AUTOMATIC);
gtk_window_set_child (GTK_WINDOW (window), sw); gtk_window_set_child (GTK_WINDOW (window), sw);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), view); gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), view);

View File

@@ -13,7 +13,7 @@ static GtkWidget *window = NULL;
static GtkWidget *scrolledwindow; static GtkWidget *scrolledwindow;
static int selected; static int selected;
#define N_WIDGET_TYPES 8 #define N_WIDGET_TYPES 6
static int hincrement = 5; static int hincrement = 5;
@@ -110,46 +110,6 @@ populate_text (gboolean highlight)
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scrolledwindow), textview); 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 static void
populate_image (void) populate_image (void)
{ {
@@ -217,24 +177,6 @@ populate_grid (void)
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scrolledwindow), list); gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scrolledwindow), list);
} }
extern GtkWidget *create_ucd_view (GtkWidget *label);
static void
populate_list2 (void)
{
GtkWidget *list;
list = create_ucd_view (NULL);
hincrement = 0;
vincrement = 5;
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scrolledwindow), list);
}
static void static void
set_widget_type (int type) set_widget_type (int type)
{ {
@@ -264,26 +206,16 @@ set_widget_type (int type)
break; break;
case 3: 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"); gtk_window_set_title (GTK_WINDOW (window), "Scrolling a big image");
populate_image (); populate_image ();
break; break;
case 5: case 4:
gtk_window_set_title (GTK_WINDOW (window), "Scrolling a list"); gtk_window_set_title (GTK_WINDOW (window), "Scrolling a list");
populate_list (); populate_list ();
break; break;
case 6: case 5:
gtk_window_set_title (GTK_WINDOW (window), "Scrolling a columned list");
populate_list2 ();
break;
case 7:
gtk_window_set_title (GTK_WINDOW (window), "Scrolling a grid"); gtk_window_set_title (GTK_WINDOW (window), "Scrolling a grid");
populate_grid (); populate_grid ();
break; break;

View File

@@ -13,13 +13,13 @@
</style> </style>
<child> <child>
<object class="GtkButton"> <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"/> <signal name="clicked" handler="iconscroll_prev_clicked_cb"/>
</object> </object>
</child> </child>
<child> <child>
<object class="GtkButton"> <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"/> <signal name="clicked" handler="iconscroll_next_clicked_cb"/>
</object> </object>
</child> </child>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -8,8 +8,8 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
/* This is the function that creates the GListModel that we need. /* This is the function that creates the #GListModel that we need.
* GTK list widgets need a GListModel to display, as models support change * GTK list widgets need a #GListModel to display, as models support change
* notifications. * notifications.
* Unfortunately various older APIs do not provide list models, so we create * Unfortunately various older APIs do not provide list models, so we create
* our own. * our own.
@@ -20,10 +20,10 @@ create_application_list (void)
GListStore *store; GListStore *store;
GList *apps, *l; 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. * for manual management.
* List models need to know what type of data they provide, so we need to * 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. * is the object we provide.
*/ */
store = g_list_store_new (G_TYPE_APP_INFO); 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. /* 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. * icon and name, as this is just a simple demo.
*/ */
static void 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 /* 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 * listitem already set up from the previous function, so we can reuse the
* GtkImage widget we set up above. * #GtkImage widget we set up above.
* We get the item - which we know is a GAppInfo because it comes out of * 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. * the model we set up above, grab its icon and display it.
*/ */
static void static void
@@ -85,7 +85,7 @@ bind_listitem_cb (GtkListItemFactory *factory,
* the listitem, but this is simple code, so the default implementations are * the listitem, but this is simple code, so the default implementations are
* enough. If we had connected signals, this step would have been necessary. * 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. * 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); 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 /* Prepare the context for launching the application and launch it. This
* code is explained in detail in the documentation for GdkAppLaunchContext * code is explained in detail in the documentation for #GdkAppLaunchContext
* and GAppInfo. * and #GAppInfo.
*/ */
context = gdk_display_get_app_launch_context (gtk_widget_get_display (GTK_WIDGET (list))); context = gdk_display_get_app_launch_context (gtk_widget_get_display (GTK_WIDGET (list)));
if (!g_app_info_launch (app_info, 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"); gtk_window_set_title (GTK_WINDOW (window), "Application Launcher");
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *) &window); 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 display the data from the model. So it is absolutely necessary
* to create one. * 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. * one to use. Different ones are available for different use cases.
* The most powerful one is GtkBuilderListItemFactory which uses * The most powerful one is #GtkBuilderListItemFactory which uses
* GtkBuilder .ui files, so it requires little code. * #GtkBuilder .ui files, so it requires little code.
*/ */
factory = gtk_signal_list_item_factory_new (); factory = gtk_signal_list_item_factory_new ();
g_signal_connect (factory, "setup", G_CALLBACK (setup_listitem_cb), NULL); 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); 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 * because otherwise they might get too large or they might not
* be scrollable. * be scrollable.
*/ */

View File

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

View File

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

View File

@@ -142,39 +142,16 @@ load_file (GtkStringList *list,
} }
static void static void
open_response_cb (GtkNativeDialog *dialog, file_selected_cb (GtkWidget *button,
int response, GtkStringList *stringlist)
GtkStringList *stringlist)
{ {
gtk_native_dialog_hide (dialog); GFile *file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (button));
if (response == GTK_RESPONSE_ACCEPT) if (file)
{ {
GFile *file;
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
load_file (stringlist, file); load_file (stringlist, file);
g_object_unref (file); g_object_unref (file);
} }
gtk_native_dialog_destroy (dialog);
}
static void
file_open_cb (GtkWidget *button,
GtkStringList *stringlist)
{
GtkFileChooserNative *dialog;
dialog = gtk_file_chooser_native_new ("Open file",
GTK_WINDOW (gtk_widget_get_root (button)),
GTK_FILE_CHOOSER_ACTION_OPEN,
"_Load",
"_Cancel");
gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (dialog), TRUE);
g_signal_connect (dialog, "response", G_CALLBACK (open_response_cb), stringlist);
gtk_native_dialog_show (GTK_NATIVE_DIALOG (dialog));
} }
GtkWidget * GtkWidget *
@@ -212,8 +189,8 @@ do_listview_words (GtkWidget *do_widget)
header = gtk_header_bar_new (); header = gtk_header_bar_new ();
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), TRUE); gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), TRUE);
open_button = gtk_button_new_with_mnemonic ("_Open"); open_button = gtk_file_chooser_button_new ("_Open", GTK_FILE_CHOOSER_ACTION_OPEN);
g_signal_connect (open_button, "clicked", G_CALLBACK (file_open_cb), stringlist); g_signal_connect (open_button, "file-set", G_CALLBACK (file_selected_cb), stringlist);
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), open_button); gtk_header_bar_pack_start (GTK_HEADER_BAR (header), open_button);
gtk_window_set_titlebar (GTK_WINDOW (window), header); gtk_window_set_titlebar (GTK_WINDOW (window), header);

View File

@@ -25,8 +25,6 @@
#include "demos.h" #include "demos.h"
#include "fontify.h" #include "fontify.h"
#include "demo_conf.h"
static GtkWidget *info_view; static GtkWidget *info_view;
static GtkWidget *source_view; static GtkWidget *source_view;
@@ -198,20 +196,16 @@ activate_about (GSimpleAction *action,
gtk_get_micro_version ()); gtk_get_micro_version ());
g_string_append_printf (s, "\nA link can appear here: <http://www.gtk.org>"); 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, PACKAGE_VERSION,
g_strcmp0 (PROFILE, "devel") == 0 ? "-" : "",
g_strcmp0 (PROFILE, "devel") == 0 ? VCS_TAG : "",
gtk_get_major_version (), gtk_get_major_version (),
gtk_get_minor_version (), gtk_get_minor_version (),
gtk_get_micro_version ()); gtk_get_micro_version ());
gtk_show_about_dialog (GTK_WINDOW (gtk_application_get_active_window (app)), gtk_show_about_dialog (GTK_WINDOW (gtk_application_get_active_window (app)),
"program-name", g_strcmp0 (PROFILE, "devel") == 0 "program-name", "GTK Demo",
? "GTK Demo (Development)"
: "GTK Demo",
"version", version, "version", version,
"copyright", "©1997—2021 The GTK Team", "copyright", "©1997—2020 The GTK Team",
"license-type", GTK_LICENSE_LGPL_2_1, "license-type", GTK_LICENSE_LGPL_2_1,
"website", "http://www.gtk.org", "website", "http://www.gtk.org",
"comments", "Program to demonstrate GTK widgets", "comments", "Program to demonstrate GTK widgets",
@@ -343,8 +337,8 @@ display_text (const char *format,
bytes = g_resources_lookup_data (resource, 0, NULL); bytes = g_resources_lookup_data (resource, 0, NULL);
g_assert (bytes); g_assert (bytes);
text = g_bytes_get_data (bytes, &len);
g_assert (g_utf8_validate (text, len, NULL)); g_assert (g_utf8_validate (g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes), NULL));
textview = gtk_text_view_new (); textview = gtk_text_view_new ();
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (textview), 20); gtk_text_view_set_left_margin (GTK_TEXT_VIEW (textview), 20);
@@ -360,8 +354,9 @@ display_text (const char *format,
gtk_text_view_set_monospace (GTK_TEXT_VIEW (textview), TRUE); gtk_text_view_set_monospace (GTK_TEXT_VIEW (textview), TRUE);
buffer = gtk_text_buffer_new (NULL); buffer = gtk_text_buffer_new (NULL);
text = g_bytes_unref_to_data (bytes, &len);
gtk_text_buffer_set_text (buffer, text, len); gtk_text_buffer_set_text (buffer, text, len);
g_bytes_unref (bytes);
if (format) if (format)
fontify (format, buffer); fontify (format, buffer);
@@ -396,7 +391,7 @@ display_nothing (const char *resource)
GtkWidget *widget; GtkWidget *widget;
char *str; char *str;
str = g_strdup_printf ("The contents of the resource at '%s' cannot be displayed", resource); str = g_strdup_printf ("The lazy GTK developers forgot to add a way to display the resource '%s'", resource);
widget = gtk_label_new (str); widget = gtk_label_new (str);
gtk_label_set_wrap (GTK_LABEL (widget), TRUE); gtk_label_set_wrap (GTK_LABEL (widget), TRUE);
@@ -415,7 +410,6 @@ static struct {
{ ".gif", NULL, display_image }, { ".gif", NULL, display_image },
{ ".jpg", NULL, display_image }, { ".jpg", NULL, display_image },
{ ".png", NULL, display_image }, { ".png", NULL, display_image },
{ ".svg", NULL, display_image },
{ ".c", "c", display_text }, { ".c", "c", display_text },
{ ".css", "css", display_text }, { ".css", "css", display_text },
{ ".glsl", NULL, display_text }, { ".glsl", NULL, display_text },
@@ -751,6 +745,7 @@ demo_filter_by_name (gpointer item,
gpointer user_data) gpointer user_data)
{ {
GtkTreeListRow *row = item; GtkTreeListRow *row = item;
GtkFilterListModel *model = user_data;
GListModel *children; GListModel *children;
GtkDemo *demo; GtkDemo *demo;
guint i, n; guint i, n;
@@ -761,7 +756,7 @@ demo_filter_by_name (gpointer item,
return TRUE; return TRUE;
g_assert (GTK_IS_TREE_LIST_ROW (row)); 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 */ /* Show a row if itself of any parent matches */
for (parent = row; parent; parent = gtk_tree_list_row_get_parent (parent)) 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"); window = (GtkWidget *)gtk_builder_get_object (builder, "window");
gtk_application_add_window (GTK_APPLICATION (app), GTK_WINDOW (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); action = g_simple_action_new ("run", NULL);
g_signal_connect (action, "activate", G_CALLBACK (activate_run), window); g_signal_connect (action, "activate", G_CALLBACK (activate_run), window);
g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (action)); g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (action));
@@ -1051,10 +1043,10 @@ out:
static void static void
print_version (void) print_version (void)
{ {
g_print ("gtk4-demo %s%s%s\n", g_print ("gtk4-demo %d.%d.%d\n",
PACKAGE_VERSION, gtk_get_major_version (),
g_strcmp0 (PROFILE, "devel") == 0 ? "-" : "", gtk_get_minor_version (),
g_strcmp0 (PROFILE, "devel") == 0 ? VCS_TAG : ""); gtk_get_micro_version ());
} }
static int static int

View File

@@ -17,6 +17,9 @@
</section> </section>
</menu> </menu>
<object class="GtkApplicationWindow" id="window"> <object class="GtkApplicationWindow" id="window">
<style>
<class name="devel"/>
</style>
<property name="default-width">800</property> <property name="default-width">800</property>
<property name="default-height">600</property> <property name="default-height">600</property>
<child type="titlebar"> <child type="titlebar">
@@ -25,30 +28,21 @@
<object class="GtkButton"> <object class="GtkButton">
<property name="valign">center</property> <property name="valign">center</property>
<property name="action-name">win.run</property> <property name="action-name">win.run</property>
<property name="focus-on-click">0</property> <style>
<property name="label" translatable="yes">Run</property> <class name="text-button"/>
</object> </style>
</child> <child>
<child> <object class="GtkLabel">
<object class="GtkToggleButton"> <property name="label" translatable="yes">Run</property>
<property name="icon-name">edit-find-symbolic</property> </object>
<property name="valign">center</property> </child>
<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>
</accessibility>
</object> </object>
</child> </child>
<child type="end"> <child type="end">
<object class="GtkMenuButton" id="gear_menu_button"> <object class="GtkMenuButton" id="gear_menu_button">
<property name="valign">center</property> <property name="valign">center</property>
<property name="focus-on-click">0</property>
<property name="menu-model">gear_menu</property> <property name="menu-model">gear_menu</property>
<property name="icon-name">open-menu-symbolic</property> <property name="icon-name">open-menu-symbolic</property>
<accessibility>
<property name="label" translatable="yes">Primary menu</property>
</accessibility>
</object> </object>
</child> </child>
</object> </object>
@@ -56,30 +50,24 @@
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<child> <child>
<object class="GtkBox"> <object class="GtkScrolledWindow">
<property name="width-request">220</property> <property name="width-request">120</property>
<property name="orientation">vertical</property> <property name="hscrollbar-policy">never</property>
<property name="min-content-width">150</property>
<child> <child>
<object class="GtkSearchBar" id="searchbar"> <object class="GtkBox">
<property name="key-capture-widget">window</property> <property name="width-request">220</property>
<property name="orientation">vertical</property>
<child> <child>
<object class="GtkSearchEntry" id="search-entry"> <object class="GtkSearchBar" id="searchbar">
<accessibility> <property name="key-capture-widget">window</property>
<relation name="controls">listview</relation> <child>
</accessibility> <object class="GtkSearchEntry" id="search-entry"/>
</child>
</object> </object>
</child> </child>
</object>
</child>
<child>
<object class="GtkScrolledWindow">
<style>
<class name="sidebar"/>
</style>
<property name="width-request">120</property>
<property name="hscrollbar-policy">never</property>
<property name="min-content-width">150</property>
<property name="vexpand">1</property>
<child> <child>
<object class="GtkListView" id="listview"> <object class="GtkListView" id="listview">
<style> <style>
@@ -90,16 +78,16 @@
<property name="resource">/ui/main-listitem.ui</property> <property name="resource">/ui/main-listitem.ui</property>
</object> </object>
</property> </property>
<accessibility>
<property name="label" translatable="yes">Demo list</property>
<relation name="controls">notebook</relation>
</accessibility>
</object> </object>
</child> </child>
</object> </object>
</child> </child>
</object> </object>
</child> </child>
<child>
<object class="GtkSeparator"/>
</child>
<child> <child>
<object class="GtkNotebook" id="notebook"> <object class="GtkNotebook" id="notebook">
<property name="scrollable">1</property> <property name="scrollable">1</property>
@@ -124,10 +112,6 @@
<property name="editable">0</property> <property name="editable">0</property>
<property name="wrap-mode">word</property> <property name="wrap-mode">word</property>
<property name="cursor-visible">0</property> <property name="cursor-visible">0</property>
<accessibility>
<property name="label" translatable="yes">Info</property>
<property name="description" translatable="yes">A description of the demo</property>
</accessibility>
</object> </object>
</child> </child>
</object> </object>
@@ -158,10 +142,6 @@
<property name="wrap-mode">word</property> <property name="wrap-mode">word</property>
<property name="pixels-above-lines">2</property> <property name="pixels-above-lines">2</property>
<property name="pixels-below-lines">2</property> <property name="pixels-below-lines">2</property>
<accessibility>
<property name="label" translatable="yes">Source</property>
<property name="description" translatable="yes">The source code of the demo</property>
</accessibility>
</object> </object>
</child> </child>
</object> </object>

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