Compare commits
5 Commits
wip/matthi
...
async-colo
Author | SHA1 | Date | |
---|---|---|---|
|
2c42750efd | ||
|
ab833951db | ||
|
aa5041e65c | ||
|
4022786847 | ||
|
029bb9ad18 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1 @@
|
||||
/subprojects/*/
|
||||
.flatpak-builder/
|
||||
|
292
.gitlab-ci.yml
292
.gitlab-ci.yml
@@ -22,35 +22,29 @@ stages:
|
||||
|
||||
# Common variables
|
||||
variables:
|
||||
COMMON_MESON_FLAGS: "-Dwerror=true -Dcairo:werror=false -Dgi-docgen:werror=false -Dgraphene:werror=false -Dlibepoxy:werror=false -Dlibsass:werror=false -Dpango:werror=false -Dsassc:werror=false -Dgdk-pixbuf:werror=false -Dglib:werror=false -Dlibcloudproviders:werror=false -Dlibpng:werror=false -Dlibtiff:werror=false -Dsysprof:werror=false -Dwayland-protocols:werror=false -Dharfbuzz:werror=false -Dfreetype2:werror=false -Dfontconfig:werror=false -Dfribidi:werror=false -Dlibffi:werror=false -Dlibjpeg-turbo:werror=false -Dmutest:werror=false -Dpixman:werror=false -Dproxy-libintl:werror=false"
|
||||
COMMON_MESON_FLAGS: "-Dwerror=true -Dglib:werror=false -Dpango:werror=false -Dgtk-doc:werror=false -Dwayland-protocols:werror=false -Dsysprof:werror=false -Dwayland:werror=false"
|
||||
BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true"
|
||||
FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled -Dbuild-testsuite=true -Dintrospection=enabled"
|
||||
FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled"
|
||||
MESON_TEST_TIMEOUT_MULTIPLIER: 3
|
||||
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v46"
|
||||
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v38"
|
||||
FLATPAK_IMAGE: "quay.io/gnome_infrastructure/gnome-runtime-images:gnome-master"
|
||||
|
||||
workflow:
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG
|
||||
- if: $CI_COMMIT_BRANCH
|
||||
|
||||
default:
|
||||
retry:
|
||||
max: 2
|
||||
when:
|
||||
- 'runner_system_failure'
|
||||
- 'stuck_or_timeout_failure'
|
||||
- 'scheduler_failure'
|
||||
- 'api_failure'
|
||||
interruptible: true
|
||||
.only-default:
|
||||
only:
|
||||
- branches
|
||||
except:
|
||||
- tags
|
||||
|
||||
style-check-diff:
|
||||
extends: .only-default
|
||||
image: $FEDORA_IMAGE
|
||||
stage: check
|
||||
when: manual
|
||||
allow_failure: true
|
||||
script:
|
||||
- .gitlab-ci/run-style-check-diff.sh
|
||||
|
||||
.build-fedora-default:
|
||||
extends: .only-default
|
||||
image: $FEDORA_IMAGE
|
||||
artifacts:
|
||||
when: always
|
||||
@@ -58,7 +52,6 @@ style-check-diff:
|
||||
junit:
|
||||
- "${CI_PROJECT_DIR}/_build/report-x11.xml"
|
||||
- "${CI_PROJECT_DIR}/_build/report-wayland.xml"
|
||||
- "${CI_PROJECT_DIR}/_build/report-wayland_gles.xml"
|
||||
- "${CI_PROJECT_DIR}/_build/report-broadway.xml"
|
||||
name: "gtk-${CI_COMMIT_REF_NAME}"
|
||||
paths:
|
||||
@@ -70,12 +63,16 @@ style-check-diff:
|
||||
- "${CI_PROJECT_DIR}/_build/testsuite/tools/output/*/*"
|
||||
- "${CI_PROJECT_DIR}/_build/testsuite/gsk/compare/*/*/*.png"
|
||||
- "${CI_PROJECT_DIR}/_build/testsuite/css/output/*/*.syscap"
|
||||
- "${CI_PROJECT_DIR}/_build/testsuite/headless/*/*.log"
|
||||
- "${CI_PROJECT_DIR}/_build_hello/meson-logs"
|
||||
cache:
|
||||
key: "$CI_JOB_NAME"
|
||||
paths:
|
||||
- _ccache/
|
||||
- subprojects/gdk-pixbuf/
|
||||
- subprojects/glib/
|
||||
- subprojects/graphene/
|
||||
- subprojects/libepoxy/
|
||||
- subprojects/pango/
|
||||
|
||||
fedora-x86_64:
|
||||
extends: .build-fedora-default
|
||||
@@ -85,18 +82,19 @@ fedora-x86_64:
|
||||
EXTRA_MESON_FLAGS: "--buildtype=debug --default-library=both"
|
||||
script:
|
||||
- .gitlab-ci/show-info-linux.sh
|
||||
- export PATH="$HOME/.local/bin:$PATH"
|
||||
- meson subprojects download
|
||||
- meson subprojects update --reset
|
||||
- meson setup
|
||||
${COMMON_MESON_FLAGS}
|
||||
${EXTRA_MESON_FLAGS}
|
||||
${BACKEND_FLAGS}
|
||||
${FEATURE_FLAGS}
|
||||
- meson subprojects update
|
||||
- mkdir _install
|
||||
- meson --prefix=${CI_PROJECT_DIR}/_install
|
||||
${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} ${BACKEND_FLAGS} ${FEATURE_FLAGS}
|
||||
_build
|
||||
- meson compile -C _build
|
||||
- meson install -C _build
|
||||
- PKG_CONFIG_PATH=${CI_PROJECT_DIR}/_install/lib64/pkgconfig:${CI_PROJECT_DIR}/_install/share/pkgconfig meson setup _build_hello examples/hello
|
||||
- LD_LIBRARY_PATH=${CI_PROJECT_DIR}/_install/lib64 meson compile -C _build_hello
|
||||
- .gitlab-ci/run-tests.sh _build x11
|
||||
- .gitlab-ci/run-tests.sh _build wayland
|
||||
- .gitlab-ci/run-tests.sh _build wayland_gles
|
||||
- .gitlab-ci/run-tests.sh _build waylandgles
|
||||
- .gitlab-ci/run-tests.sh _build broadway
|
||||
|
||||
release-build:
|
||||
extends: .build-fedora-default
|
||||
@@ -106,43 +104,12 @@ release-build:
|
||||
EXTRA_MESON_FLAGS: "--buildtype=release"
|
||||
script:
|
||||
- .gitlab-ci/show-info-linux.sh
|
||||
- export PATH="$HOME/.local/bin:$PATH"
|
||||
- meson subprojects download
|
||||
- meson subprojects update --reset
|
||||
- mkdir _install
|
||||
- meson setup
|
||||
--prefix=${CI_PROJECT_DIR}/_install
|
||||
${COMMON_MESON_FLAGS}
|
||||
${EXTRA_MESON_FLAGS}
|
||||
${BACKEND_FLAGS}
|
||||
${FEATURE_FLAGS}
|
||||
- meson subprojects update
|
||||
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} ${BACKEND_FLAGS} ${FEATURE_FLAGS}
|
||||
_build
|
||||
- meson compile -C _build
|
||||
- meson install -C _build
|
||||
- PKG_CONFIG_PATH=${CI_PROJECT_DIR}/_install/lib64/pkgconfig:${CI_PROJECT_DIR}/_install/share/pkgconfig meson setup _build_hello examples/hello
|
||||
- LD_LIBRARY_PATH=${CI_PROJECT_DIR}/_install/lib64 meson compile -C _build_hello
|
||||
- ninja -C _build
|
||||
- .gitlab-ci/run-tests.sh _build x11
|
||||
|
||||
fedora-clang:
|
||||
extends: .build-fedora-default
|
||||
stage: build
|
||||
needs: []
|
||||
variables:
|
||||
EXTRA_MESON_FLAGS: "--buildtype=release"
|
||||
script:
|
||||
- .gitlab-ci/show-info-linux.sh
|
||||
- export PATH="$HOME/.local/bin:$PATH"
|
||||
- export CC=clang
|
||||
- meson subprojects download
|
||||
- meson subprojects update --reset
|
||||
- meson setup
|
||||
${COMMON_MESON_FLAGS}
|
||||
${EXTRA_MESON_FLAGS}
|
||||
${BACKEND_FLAGS}
|
||||
${FEATURE_FLAGS}
|
||||
_build
|
||||
- meson compile -C _build
|
||||
|
||||
fedora-mingw64:
|
||||
extends: .build-fedora-default
|
||||
stage: build
|
||||
@@ -161,14 +128,37 @@ fedora-mingw64:
|
||||
# mingw64-graphene (rawhide)
|
||||
script:
|
||||
- .gitlab-ci/show-info-linux.sh
|
||||
- export PATH="$HOME/.local/bin:$PATH"
|
||||
- pip3 install --user meson~=1.0
|
||||
- meson subprojects download
|
||||
- meson subprojects update --reset
|
||||
- meson -Dintrospection=disabled -Dgraphene:introspection=disabled _build
|
||||
- meson compile -C _build
|
||||
- meson subprojects update
|
||||
- mkdir _build && cd _build
|
||||
- mingw64-meson -Dintrospection=disabled -Dgraphene:introspection=disabled
|
||||
- ninja
|
||||
|
||||
installed-tests:
|
||||
extends: .build-fedora-default
|
||||
stage: build
|
||||
needs: []
|
||||
variables:
|
||||
EXTRA_MESON_FLAGS: "--prefix=/usr --libdir=/usr/lib64 -Dinstall-tests=true"
|
||||
G_TEST_ACCESSIBLE: 1
|
||||
script:
|
||||
- .gitlab-ci/show-info-linux.sh
|
||||
- meson subprojects update
|
||||
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} ${BACKEND_FLAGS} ${FEATURE_FLAGS}
|
||||
_build
|
||||
- ninja -C _build
|
||||
- sudo ninja -C _build install
|
||||
- dbus-run-session xvfb-run -a -s "-screen 0 1024x768x24"
|
||||
gnome-desktop-testing-runner
|
||||
--report-directory=_build/installed-tests-report/failed/
|
||||
--parallel=0
|
||||
gtk-4.0
|
||||
artifacts:
|
||||
paths:
|
||||
- "_build/installed-tests-report/"
|
||||
|
||||
|
||||
.mingw-defaults:
|
||||
extends: .only-default
|
||||
stage: build
|
||||
tags:
|
||||
- win32-ps
|
||||
@@ -198,45 +188,40 @@ msys2-mingw64:
|
||||
- "${CI_PROJECT_DIR}/_build/gtkdll.tar.gz"
|
||||
|
||||
macos:
|
||||
# Sadly, this fails regularly, and its failure is never enlightening
|
||||
allow_failure: true
|
||||
rules:
|
||||
- if: $CI_PROJECT_NAMESPACE == "GNOME"
|
||||
extends: .only-default
|
||||
only:
|
||||
- branches@GNOME/gtk
|
||||
stage: build
|
||||
allow_failure: true
|
||||
tags:
|
||||
- macos
|
||||
needs: []
|
||||
before_script:
|
||||
- bash .gitlab-ci/show-info-osx.sh
|
||||
- pip3 install --user meson~=1.0
|
||||
- pip3 install --user meson==0.60.3
|
||||
- pip3 install --user ninja
|
||||
- export PATH=/Users/gitlabrunner/Library/Python/3.7/bin:$PATH
|
||||
- export MESON_FORCE_BACKTRACE=1
|
||||
script:
|
||||
- meson setup ${COMMON_MESON_FLAGS}
|
||||
-Dx11-backend=false
|
||||
- meson -Dx11-backend=false
|
||||
-Dbroadway-backend=true
|
||||
-Dmacos-backend=true
|
||||
-Dmedia-gstreamer=disabled
|
||||
-Dintrospection=disabled
|
||||
-Dcpp_std=c++11
|
||||
-Dpixman:tests=disabled
|
||||
-Dlibjpeg-turbo:simd=disabled
|
||||
-Dbuild-demos=false
|
||||
-Dbuild-tests=false
|
||||
-Dbuild-examples=false
|
||||
-Dbuild-testsuite=false
|
||||
_build
|
||||
- meson compile -C _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.
|
||||
# rules:
|
||||
# - if: $CI_PROJECT_NAMESPACE == "GNOME"
|
||||
#only:
|
||||
# - branches@GNOME/gtk
|
||||
stage: build
|
||||
tags:
|
||||
- win32-ps
|
||||
@@ -249,7 +234,7 @@ vs2017-x64:
|
||||
- "${CI_PROJECT_DIR}/_build/meson-logs"
|
||||
|
||||
.flatpak-defaults:
|
||||
image: "quay.io/gnome_infrastructure/gnome-runtime-images:gnome-master"
|
||||
image: $FLATPAK_IMAGE
|
||||
stage: flatpak
|
||||
allow_failure: true
|
||||
tags:
|
||||
@@ -259,67 +244,65 @@ vs2017-x64:
|
||||
- "${APPID}-dev.flatpak"
|
||||
- 'repo.tar'
|
||||
expire_in: 1 day
|
||||
rules:
|
||||
# Only build Flatpak bundles automatically on main
|
||||
- if: $CI_COMMIT_BRANCH == "main"
|
||||
- if: $CI_COMMIT_BRANCH != "main"
|
||||
when: "manual"
|
||||
script:
|
||||
- bash -x ./.gitlab-ci/flatpak-build.sh "${APPID}"
|
||||
|
||||
flatpak:demo:
|
||||
extends: '.flatpak-defaults'
|
||||
# Manual jobs, for branches and MRs
|
||||
.flatpak-manual:
|
||||
extends: .flatpak-defaults
|
||||
when: manual
|
||||
|
||||
# Only build Flatpak bundles automatically on main
|
||||
.flatpak-main:
|
||||
extends: .flatpak-defaults
|
||||
only:
|
||||
- main
|
||||
|
||||
flatpak-manual:demo:
|
||||
extends: .flatpak-manual
|
||||
needs: []
|
||||
variables:
|
||||
APPID: org.gtk.Demo4
|
||||
|
||||
flatpak:demo:aarch64:
|
||||
extends: '.flatpak-defaults'
|
||||
flatpak-main:demo:
|
||||
extends: .flatpak-main
|
||||
needs: []
|
||||
tags:
|
||||
- flatpak-aarch64
|
||||
variables:
|
||||
APPID: org.gtk.Demo4
|
||||
|
||||
flatpak:widget-factory:
|
||||
extends: '.flatpak-defaults'
|
||||
flatpak-manual:widget-factory:
|
||||
extends: .flatpak-manual
|
||||
needs: []
|
||||
variables:
|
||||
APPID: org.gtk.WidgetFactory4
|
||||
|
||||
flatpak:widget-factory:aarch64:
|
||||
extends: '.flatpak-defaults'
|
||||
flatpak-main:widget-factory:
|
||||
extends: .flatpak-main
|
||||
needs: []
|
||||
tags:
|
||||
- flatpak-aarch64
|
||||
variables:
|
||||
APPID: org.gtk.WidgetFactory4
|
||||
|
||||
flatpak:icon-browser:
|
||||
extends: '.flatpak-defaults'
|
||||
flatpak-manual:icon-browser:
|
||||
extends: .flatpak-manual
|
||||
needs: []
|
||||
variables:
|
||||
APPID: org.gtk.IconBrowser4
|
||||
|
||||
flatpak:icon-browser:aarch64:
|
||||
extends: '.flatpak-defaults'
|
||||
flatpak-main:icon-browser:
|
||||
extends: .flatpak-main
|
||||
needs: []
|
||||
tags:
|
||||
- flatpak-aarch64
|
||||
variables:
|
||||
APPID: org.gtk.IconBrowser4
|
||||
|
||||
flatpak:node-editor:
|
||||
extends: '.flatpak-defaults'
|
||||
flatpak-manual:node-editor:
|
||||
extends: .flatpak-manual
|
||||
needs: []
|
||||
variables:
|
||||
APPID: org.gtk.gtk4.NodeEditor
|
||||
|
||||
flatpak:node-editor:aarch64:
|
||||
extends: '.flatpak-defaults'
|
||||
flatpak-main:node-editor:
|
||||
extends: .flatpak-main
|
||||
needs: []
|
||||
tags:
|
||||
- flatpak-aarch64
|
||||
variables:
|
||||
APPID: org.gtk.gtk4.NodeEditor
|
||||
|
||||
@@ -328,35 +311,23 @@ flatpak:node-editor:aarch64:
|
||||
# https://gitlab.gnome.org/GNOME/Initiatives/-/wikis/DevOps-with-Flatpak
|
||||
nightly demo:
|
||||
extends: '.publish_nightly'
|
||||
needs: ['flatpak:demo']
|
||||
|
||||
nightly demo aarch64:
|
||||
extends: '.publish_nightly'
|
||||
needs: ['flatpak:demo:aarch64']
|
||||
dependencies: ['flatpak-main:demo']
|
||||
needs: ['flatpak-main:demo']
|
||||
|
||||
nightly factory:
|
||||
extends: '.publish_nightly'
|
||||
needs: ['flatpak:widget-factory']
|
||||
|
||||
nightly factory aarch64:
|
||||
extends: '.publish_nightly'
|
||||
needs: ['flatpak:widget-factory:aarch64']
|
||||
dependencies: ['flatpak-main:widget-factory']
|
||||
needs: ['flatpak-main:widget-factory']
|
||||
|
||||
nightly icon-browser:
|
||||
extends: '.publish_nightly'
|
||||
needs: ['flatpak:icon-browser']
|
||||
|
||||
nightly icon-browser aarch64:
|
||||
extends: '.publish_nightly'
|
||||
needs: ['flatpak:icon-browser:aarch64']
|
||||
dependencies: ['flatpak-main:icon-browser']
|
||||
needs: ['flatpak-main:icon-browser']
|
||||
|
||||
nightly node-editor:
|
||||
extends: '.publish_nightly'
|
||||
needs: ['flatpak:node-editor']
|
||||
|
||||
nightly node-editor aarch64:
|
||||
extends: '.publish_nightly'
|
||||
needs: ['flatpak:node-editor:aarch64']
|
||||
dependencies: ['flatpak-main:node-editor']
|
||||
needs: ['flatpak-main:node-editor']
|
||||
|
||||
static-scan:
|
||||
image: $FEDORA_IMAGE
|
||||
@@ -365,21 +336,15 @@ static-scan:
|
||||
variables:
|
||||
EXTRA_MESON_FLAGS: "--buildtype=debug"
|
||||
script:
|
||||
- export PATH="$HOME/.local/bin:$PATH"
|
||||
- meson setup
|
||||
${COMMON_MESON_FLAGS}
|
||||
${EXTRA_MESON_FLAGS}
|
||||
${BACKEND_FLAGS}
|
||||
${FEATURE_FLAGS}
|
||||
_scan_build
|
||||
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} _scan_build
|
||||
- ninja -C _scan_build scan-build
|
||||
artifacts:
|
||||
paths:
|
||||
- _scan_build/meson-logs
|
||||
allow_failure: true
|
||||
|
||||
# Run tests with the address sanitizer. We need to turn off introspection
|
||||
# and f16c, since they are incompatible with asan
|
||||
# Run tests with the address sanitizer. We need to turn off introspection,
|
||||
# since it is incompatible with asan
|
||||
asan-build:
|
||||
image: $FEDORA_IMAGE
|
||||
tags: [ asan ]
|
||||
@@ -387,45 +352,22 @@ asan-build:
|
||||
needs: []
|
||||
variables:
|
||||
script:
|
||||
- export PATH="$HOME/.local/bin:$PATH"
|
||||
- CC=clang meson setup
|
||||
--buildtype=debugoptimized
|
||||
-Db_sanitize=address
|
||||
-Db_lundef=false
|
||||
-Dbuild-demos=false
|
||||
-Dbuild-tests=false
|
||||
-Dbuild-examples=false
|
||||
-Dintrospection=disabled
|
||||
-Df16c=disabled
|
||||
_build
|
||||
- CC=clang meson --buildtype=debugoptimized -Db_sanitize=address -Db_lundef=false -Dintrospection=disabled _build
|
||||
- ninja -C _build
|
||||
- .gitlab-ci/run-tests.sh _build wayland
|
||||
- .gitlab-ci/run-tests.sh _build wayland_gles
|
||||
- .gitlab-ci/run-tests.sh _build x11
|
||||
artifacts:
|
||||
when: always
|
||||
paths:
|
||||
- "${CI_PROJECT_DIR}/_build/meson-logs"
|
||||
- _build/meson-logs
|
||||
allow_failure: true
|
||||
|
||||
reference:
|
||||
image: $FEDORA_IMAGE
|
||||
stage: docs
|
||||
needs: []
|
||||
variables:
|
||||
EXTRA_MESON_FLAGS: "--buildtype=release --force-fallback-for=gdk-pixbuf,pango"
|
||||
script:
|
||||
- export PATH="$HOME/.local/bin:$PATH"
|
||||
- meson setup
|
||||
${COMMON_MESON_FLAGS}
|
||||
--buildtype=release
|
||||
--force-fallback-for=gdk-pixbuf,pango
|
||||
-Dintrospection=enabled
|
||||
-Dgtk_doc=true
|
||||
-Dgdk-pixbuf:gtk_doc=true
|
||||
-Dpango:gtk_doc=true
|
||||
-Ddemos=false
|
||||
-Dbuild-examples=false
|
||||
-Dbuild-tests=false
|
||||
-Dbuild-testsuite=false
|
||||
_build
|
||||
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} -Dgtk_doc=true -Dgdk-pixbuf:gtk_doc=true -Dpango:gtk_doc=true _build
|
||||
- meson compile -C _build
|
||||
- mkdir -p _reference/
|
||||
- mv _build/docs/reference/gdk/gdk4/ _reference/gdk4/
|
||||
@@ -448,9 +390,9 @@ reference:
|
||||
publish-docs:
|
||||
image: fedora:latest
|
||||
stage: publish
|
||||
interruptible: false
|
||||
needs: ['reference']
|
||||
script:
|
||||
- "curl -X POST -F token=${PAGES_TRIGGER_TOKEN} -F ref=docs-gtk-org https://gitlab.gnome.org/api/v4/projects/665/trigger/pipeline"
|
||||
rules:
|
||||
- if: $CI_COMMIT_REF_NAME == "main"
|
||||
only:
|
||||
refs:
|
||||
- main
|
||||
|
@@ -1,4 +1,4 @@
|
||||
FROM fedora:38
|
||||
FROM fedora:36
|
||||
|
||||
RUN dnf -y install \
|
||||
adwaita-icon-theme \
|
||||
@@ -18,9 +18,7 @@ RUN dnf -y install \
|
||||
dejavu-sans-mono-fonts \
|
||||
desktop-file-utils \
|
||||
diffutils \
|
||||
docbook-style-xsl \
|
||||
elfutils-libelf-devel \
|
||||
expat-devel \
|
||||
fribidi-devel \
|
||||
gcc \
|
||||
gcc-c++ \
|
||||
@@ -32,7 +30,7 @@ RUN dnf -y install \
|
||||
glib2-static \
|
||||
glibc-devel \
|
||||
glibc-headers \
|
||||
gnupg2 \
|
||||
gnome-desktop-testing \
|
||||
gobject-introspection-devel \
|
||||
graphene-devel \
|
||||
graphviz \
|
||||
@@ -73,22 +71,18 @@ RUN dnf -y install \
|
||||
mesa-libEGL-devel \
|
||||
mesa-libGLES-devel \
|
||||
meson \
|
||||
mutter \
|
||||
ninja-build \
|
||||
pango-devel \
|
||||
pcre-devel \
|
||||
pcre-static \
|
||||
pipewire \
|
||||
pipewire-gstreamer \
|
||||
python3 \
|
||||
python3-docutils \
|
||||
python3-gobject \
|
||||
python3-jinja2 \
|
||||
python3-markdown \
|
||||
python3-packaging \
|
||||
python3-pip \
|
||||
python3-pydbus \
|
||||
python3-pygments \
|
||||
python3-toml \
|
||||
python3-typogrify \
|
||||
python3-wheel \
|
||||
redhat-rpm-config \
|
||||
@@ -99,8 +93,9 @@ RUN dnf -y install \
|
||||
weston \
|
||||
weston-libs \
|
||||
which \
|
||||
wireplumber \
|
||||
xorg-x11-server-Xvfb \
|
||||
&& dnf install -y 'dnf-command(builddep)' \
|
||||
&& dnf builddep -y wayland \
|
||||
&& dnf clean all
|
||||
|
||||
# Enable sudo for wheel users
|
||||
|
@@ -20,7 +20,6 @@ flatpak build ${builddir} meson \
|
||||
-Dx11-backend=true \
|
||||
-Dwayland-backend=true \
|
||||
-Dbuild-tests=false \
|
||||
-Dbuild-testsuite=false \
|
||||
-Dbuild-examples=false \
|
||||
-Dintrospection=disabled \
|
||||
-Ddemos=true \
|
||||
|
@@ -23,7 +23,6 @@ push=0
|
||||
list=0
|
||||
print_help=0
|
||||
no_login=0
|
||||
no_cache=0
|
||||
|
||||
while (($# > 0)); do
|
||||
case "${1%%=*}" in
|
||||
@@ -35,7 +34,6 @@ while (($# > 0)); do
|
||||
--base|-b) read_arg base "$@" || shift;;
|
||||
--version|-v) read_arg base_version "$@" || shift;;
|
||||
--no-login) no_login=1;;
|
||||
--no-cache) no_cache=1;;
|
||||
*) echo -e "\e[1;31mERROR\e[0m: Unknown option '$1'"; exit 1;;
|
||||
esac
|
||||
shift
|
||||
@@ -105,21 +103,11 @@ TAG="${REGISTRY}/gnome/gtk/${base}:${base_version}"
|
||||
|
||||
if [ $build == 1 ]; then
|
||||
echo -e "\e[1;32mBUILDING\e[0m: ${base} as ${TAG}"
|
||||
if [ $no_cache == 0 ]; then
|
||||
${CMD} build \
|
||||
${format} \
|
||||
--build-arg HOST_USER_ID="$UID" \
|
||||
--tag "${TAG}" \
|
||||
--file "${base}.Dockerfile" .
|
||||
else
|
||||
${CMD} build \
|
||||
${format} \
|
||||
--no-cache \
|
||||
--build-arg HOST_USER_ID="$UID" \
|
||||
--tag "${TAG}" \
|
||||
--file "${base}.Dockerfile" .
|
||||
fi
|
||||
|
||||
${CMD} build \
|
||||
${format} \
|
||||
--build-arg HOST_USER_ID="$UID" \
|
||||
--tag "${TAG}" \
|
||||
--file "${base}.Dockerfile" .
|
||||
exit $?
|
||||
fi
|
||||
|
||||
@@ -138,8 +126,7 @@ if [ $run == 1 ]; then
|
||||
echo -e "\e[1;32mRUNNING\e[0m: ${base} as ${TAG}"
|
||||
${CMD} run \
|
||||
--rm \
|
||||
--userns=keep-id \
|
||||
--volume "$(pwd)/..:/home/user/app:rw,z" \
|
||||
--volume "$(pwd)/..:/home/user/app" \
|
||||
--workdir "/home/user/app" \
|
||||
--tty \
|
||||
--interactive "${TAG}" \
|
||||
|
@@ -6,23 +6,19 @@ set +e
|
||||
srcdir=$( pwd )
|
||||
builddir=$1
|
||||
backend=$2
|
||||
multiplier=${MESON_TEST_TIMEOUT_MULTIPLIER:-1}
|
||||
|
||||
# Ignore memory leaks lower in dependencies
|
||||
export LSAN_OPTIONS=suppressions=$srcdir/lsan.supp:print_suppressions=0:detect_leaks=0:allocator_may_return_null=1
|
||||
export LSAN_OPTIONS=suppressions=$srcdir/lsan.supp:print_suppressions=0
|
||||
export G_SLICE=always-malloc
|
||||
|
||||
case "${backend}" in
|
||||
x11)
|
||||
xvfb-run -a -s "-screen 0 1024x768x24 -noreset" \
|
||||
meson test -C ${builddir} \
|
||||
--quiet \
|
||||
--timeout-multiplier "${multiplier}" \
|
||||
--timeout-multiplier "${MESON_TEST_TIMEOUT_MULTIPLIER}" \
|
||||
--print-errorlogs \
|
||||
--setup=${backend} \
|
||||
--suite=gtk \
|
||||
--no-suite=failing \
|
||||
--no-suite=flaky \
|
||||
--no-suite=gsk-compare-broadway
|
||||
|
||||
# Store the exit code for the CI run, but always
|
||||
@@ -30,7 +26,7 @@ case "${backend}" in
|
||||
exit_code=$?
|
||||
;;
|
||||
|
||||
wayland*)
|
||||
wayland)
|
||||
export XDG_RUNTIME_DIR="$(mktemp -p $(pwd) -d xdg-runtime-XXXXXX)"
|
||||
|
||||
weston --backend=headless-backend.so --socket=wayland-5 --idle-time=0 &
|
||||
@@ -38,17 +34,31 @@ case "${backend}" in
|
||||
export WAYLAND_DISPLAY=wayland-5
|
||||
|
||||
meson test -C ${builddir} \
|
||||
--quiet \
|
||||
--timeout-multiplier "${multiplier}" \
|
||||
--timeout-multiplier "${MESON_TEST_TIMEOUT_MULTIPLIER}" \
|
||||
--print-errorlogs \
|
||||
--setup=${backend} \
|
||||
--suite=gtk \
|
||||
--no-suite=failing \
|
||||
--no-suite=flaky \
|
||||
--no-suite=${backend}_failing \
|
||||
--no-suite=gsk-compare-broadway
|
||||
exit_code=$?
|
||||
|
||||
exit_code=$?
|
||||
kill ${compositor}
|
||||
;;
|
||||
|
||||
waylandgles)
|
||||
export XDG_RUNTIME_DIR="$(mktemp -p $(pwd) -d xdg-runtime-XXXXXX)"
|
||||
|
||||
weston --backend=headless-backend.so --socket=wayland-6 --idle-time=0 &
|
||||
compositor=$!
|
||||
export WAYLAND_DISPLAY=wayland-6
|
||||
|
||||
meson test -C ${builddir} \
|
||||
--timeout-multiplier "${MESON_TEST_TIMEOUT_MULTIPLIER}" \
|
||||
--print-errorlogs \
|
||||
--setup=${backend} \
|
||||
--suite=gtk \
|
||||
--no-suite=gsk-compare-broadway
|
||||
|
||||
exit_code=$?
|
||||
kill ${compositor}
|
||||
;;
|
||||
|
||||
@@ -60,15 +70,14 @@ case "${backend}" in
|
||||
export BROADWAY_DISPLAY=:5
|
||||
|
||||
meson test -C ${builddir} \
|
||||
--quiet \
|
||||
--timeout-multiplier "${multiplier}" \
|
||||
--timeout-multiplier "${MESON_TEST_TIMEOUT_MULTIPLIER}" \
|
||||
--print-errorlogs \
|
||||
--setup=${backend} \
|
||||
--suite=gtk \
|
||||
--no-suite=failing \
|
||||
--no-suite=flaky \
|
||||
--no-suite=gsk-compare-opengl
|
||||
|
||||
# don't let Broadway failures fail the run, for now
|
||||
exit_code=0
|
||||
kill ${server}
|
||||
;;
|
||||
|
||||
@@ -82,18 +91,17 @@ esac
|
||||
cd ${builddir}
|
||||
|
||||
$srcdir/.gitlab-ci/meson-junit-report.py \
|
||||
--project-name=gtk \
|
||||
--backend="${backend}" \
|
||||
--job-id="${CI_JOB_NAME}" \
|
||||
--output="report-${backend}.xml" \
|
||||
"meson-logs/testlog-${backend}.json"
|
||||
|
||||
--project-name=gtk \
|
||||
--backend=${backend} \
|
||||
--job-id="${CI_JOB_NAME}" \
|
||||
--output=report-${backend}.xml \
|
||||
meson-logs/testlog-${backend}.json
|
||||
$srcdir/.gitlab-ci/meson-html-report.py \
|
||||
--project-name=gtk \
|
||||
--backend="${backend}" \
|
||||
--job-id="${CI_JOB_NAME}" \
|
||||
--reftest-output-dir="testsuite/reftests/output/${backend}" \
|
||||
--output="report-${backend}.html" \
|
||||
"meson-logs/testlog-${backend}.json"
|
||||
--project-name=gtk \
|
||||
--backend=${backend} \
|
||||
--job-id="${CI_JOB_NAME}" \
|
||||
--reftest-output-dir="testsuite/reftests/output/${backend}" \
|
||||
--output=report-${backend}.html \
|
||||
meson-logs/testlog-${backend}.json
|
||||
|
||||
exit $exit_code
|
||||
|
@@ -5,7 +5,7 @@ call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliar
|
||||
@echo on
|
||||
|
||||
:: FIXME: make warnings fatal
|
||||
pip3 install --upgrade --user meson~=0.64 || goto :error
|
||||
pip3 install --upgrade --user meson==0.60.3 || goto :error
|
||||
meson -Ddebug=false -Dmedia-gstreamer=disabled _build || goto :error
|
||||
ninja -C _build || goto :error
|
||||
|
||||
|
@@ -21,7 +21,7 @@ many things that we value:
|
||||
Please, do not use the issue tracker for support questions. If you have
|
||||
questions on how to use GTK effectively, you can use:
|
||||
|
||||
- the `gtk` [room on matrix](https://matrix.to/#/#gtk:gnome.org)
|
||||
- the `#gtk` IRC channel on irc.gnome.org
|
||||
- the [gtk tag on the GNOME Discourse instance](https://discourse.gnome.org/tag/gtk)
|
||||
|
||||
You can also look at the GTK tag on [Stack
|
||||
@@ -44,7 +44,6 @@ If you're reporting a bug make sure to list:
|
||||
|
||||
0. which version of GTK are you using?
|
||||
0. which operating system are you using?
|
||||
0. what display and graphics driver are you using?
|
||||
0. the necessary steps to reproduce the issue
|
||||
0. the expected outcome
|
||||
0. a description of the behavior; screenshots are also welcome
|
||||
|
574
NEWS
574
NEWS
@@ -1,557 +1,9 @@
|
||||
Overview of Changes in 4.11.4, xx-xx-xxxx
|
||||
=========================================
|
||||
|
||||
Overview of Changes in 4.11.3, 05-06-2023
|
||||
=========================================
|
||||
|
||||
* GtkGridView:
|
||||
- Respect css border-spacing
|
||||
- Don't leak the factories
|
||||
|
||||
* GtkListView:
|
||||
- Don't leak the factories
|
||||
|
||||
* GtkColumnView:
|
||||
- Support displaying sections
|
||||
|
||||
* GtkNotebook:
|
||||
- Make the pages model implement GtkSelectionModel
|
||||
|
||||
* GtkScrolledWindow:
|
||||
- Propagate child measure size whenever possible
|
||||
|
||||
* GtkPopoverMenu:
|
||||
- Avoid unnecessary left padding
|
||||
|
||||
* GtkSearchEntry:
|
||||
- Improve size allocation for the clear icon
|
||||
|
||||
* GtkBoxLayout:
|
||||
- Fix a regression from recent baseline work
|
||||
|
||||
* CSS:
|
||||
- Add new binding-friendly css provider apis
|
||||
|
||||
* Theme:
|
||||
- Show focus in the shortcuts window
|
||||
|
||||
* GDK:
|
||||
- Support grayscale and alpha texture formats for loading
|
||||
and saving to png and tiff, and in GL
|
||||
- Fix some regressions in GL context initialization
|
||||
|
||||
* GSK:
|
||||
- Support grayscale and alpha texture formats in the GL renderer
|
||||
- Support straight alpha textures in the GL renderer
|
||||
- Many improvements to the experimental Vulkan renderer
|
||||
|
||||
* Wayland:
|
||||
- Make exporting surface handles more flexible
|
||||
|
||||
* X11:
|
||||
- Trap XRandr errors
|
||||
- Stop using passive grabs during DND
|
||||
|
||||
* Windows:
|
||||
- Many cleanups and simplifications
|
||||
|
||||
* Tests:
|
||||
- Improve test coverage
|
||||
|
||||
* Build:
|
||||
- Some build options have been renamed:
|
||||
demos -> build-demos
|
||||
profile -> demo-profile
|
||||
The old names still work
|
||||
|
||||
* Deprecations:
|
||||
- gtk_css_provider_load_from_data
|
||||
- gdk_wayland_toplevel_unexport_handle
|
||||
- gdk_pixbuf_get_from_surface
|
||||
- gdk_pixbuf_get_from_texture
|
||||
- gtk_image_new_from_pixbuf
|
||||
- gtk_image_set_from_pixbuf
|
||||
- gtk_picture_new_for_pixbuf
|
||||
- gtk_picture_set_pixbuf
|
||||
|
||||
* Translation updates:
|
||||
Basque
|
||||
Catalan
|
||||
Georgian
|
||||
Russian
|
||||
Turkish
|
||||
|
||||
|
||||
Overview of Changes in 4.11.2, 09-05-2023
|
||||
=========================================
|
||||
|
||||
* GtkGLArea:
|
||||
- Add an allowed-apis property
|
||||
|
||||
* GtkListBox:
|
||||
- Fix a problem with gtk_list_box_remove_all
|
||||
|
||||
* Add the GtkSectionModel interface, and implement it in most
|
||||
of our list models
|
||||
|
||||
* GtkListView:
|
||||
- Support displaying sections
|
||||
|
||||
* GtkCenterBox:
|
||||
- Add a shrink-center-last property
|
||||
|
||||
* GtkButton, GtkMenuButton:
|
||||
- Add a can-shrink property
|
||||
|
||||
* GtkPopover:
|
||||
- Fix problems with grabs
|
||||
|
||||
* GtkFileChooser:
|
||||
- Fix a problem with removing files
|
||||
- Make the date, time and location columns work
|
||||
- Fix filtering in the save entry popup
|
||||
- A few memory leak fixes
|
||||
- Handle webdav in the pathbar
|
||||
|
||||
* GtkBox:
|
||||
- Support baselines in vertical orientation with GtkBox:baseline-child
|
||||
|
||||
* Dialogs:
|
||||
- Destroy windows promptly when the async callback finishes
|
||||
- Detect absence of the OpenURI portal and fall back
|
||||
|
||||
* Theme:
|
||||
- Add explicit style classes to a number of widgets
|
||||
- Fix some contrast issues in the dark theme
|
||||
|
||||
* Accessibility:
|
||||
- Fix alert dialogs in the a11y tree
|
||||
- Improve accessibility of GtkShortcutsWindow
|
||||
|
||||
* Layout:
|
||||
- Some fixes to baseline alignment
|
||||
- Separate GTK_ALIGN_BASELINE_CENTER and _FILL
|
||||
|
||||
* CSS:
|
||||
- Fix a crash with color transitions
|
||||
|
||||
* GSK:
|
||||
- Fix problems with negative scales
|
||||
- Improve scaling of offscreens for (cross-fades, masks, blends)
|
||||
|
||||
* GL:
|
||||
- Add GdkGLTextureBuilder, a more flexible api for creating textures
|
||||
- Support setting update regions for GL textures
|
||||
- Ensure that we work with GLES 2
|
||||
|
||||
* Vulkan:
|
||||
- More fixes to the experimental Vulkan renderer
|
||||
- Rework glyph caching
|
||||
|
||||
* Wayland:
|
||||
- Don't destroy wl_surfaces on hide
|
||||
- Plug leaks of compositor-side resources
|
||||
|
||||
* X11:
|
||||
- Fix artifacts in gnome-shell frame decorations
|
||||
|
||||
* Windows:
|
||||
- Fix GL context initialization
|
||||
|
||||
* Inspector:
|
||||
- Improve the action list
|
||||
- Improve the accessibility pane
|
||||
- Fix a crash
|
||||
|
||||
* Tools:
|
||||
- gtk4-node-editor: Improve scaling
|
||||
- gtk4-node-editor: Preserve aspect ratio of textures
|
||||
- gtk4-node-editor: Add some smarter editing
|
||||
- gtk4-demo: Make the stylus demo work with mice
|
||||
|
||||
* Deprecations:
|
||||
- gtk_widget_get_allocated_width/height/baseline
|
||||
- GTK_ALIGN_BASELINE
|
||||
|
||||
* Translation updates
|
||||
Bulgarian
|
||||
Chinese (China)
|
||||
Friulian
|
||||
Galician
|
||||
Hebrew
|
||||
Persian
|
||||
Polish
|
||||
Portuguese
|
||||
`Russian
|
||||
Turkish
|
||||
|
||||
|
||||
Overview of Changes in 4.11.1, 03-04-2023
|
||||
=========================================
|
||||
|
||||
* GtkLabel, GtkLinkButton:
|
||||
- Make file:// uris work again
|
||||
|
||||
* GtkListView/GtkColumnView/GtkGridView:
|
||||
- Fix clipping issues
|
||||
- Handle focus movement better
|
||||
- Introduce ::tab-behavior properties
|
||||
- Introduce GtkListItem::focusable
|
||||
- Introduce GtkColumnViewCell
|
||||
- Introduce row factories in GtkColumnView
|
||||
- Make list grid and column views inert when not rendering
|
||||
|
||||
* Drag-and-Drop:
|
||||
- Support resizing drag surfaces, using the new
|
||||
GdkDragSurface::compute-size signal
|
||||
|
||||
* Theme:
|
||||
- Port .boxed-list style from Adwaita
|
||||
- Make insensitive pictures appear grayed out
|
||||
|
||||
* Accessibility:
|
||||
- Fix memory leaks
|
||||
- Fix a crash
|
||||
|
||||
* GDK:
|
||||
- Add gdk_surface_get_scale to get the fractional scale
|
||||
- Use fractional scales on Wayland with cairo
|
||||
- Use fractional scales on Wayland with GL if GDK_DEBUG=gl-fractional
|
||||
is set. This support is still experimental
|
||||
|
||||
* GSK:
|
||||
- Allow limiting texture sizes with GSK_MAX_TEXTURE_SIZE
|
||||
- Use samplers for GL texture filtering
|
||||
- Fix problems with texture slicing
|
||||
- Avoid re-uploading textures when possible
|
||||
- Use mipmaps when it is beneficial
|
||||
|
||||
* Wayland:
|
||||
- Fix handling of Drag hotspots
|
||||
- Fix a crash with cursor size 0
|
||||
- Support absolute paths in WAYLAND_DISPLAY
|
||||
- Use the fractional scale protocol
|
||||
- Use a viewporter to set buffer scale
|
||||
|
||||
* Windows:
|
||||
- Fix problems with WGL
|
||||
|
||||
* Vulkan:
|
||||
- Some fixes to the experimental Vulkan renderer
|
||||
- Support fractional scaling
|
||||
|
||||
* Debugging:
|
||||
- Show more Wayland-specific information in the inspector
|
||||
|
||||
* Deprecations:
|
||||
- gtk_widget_translate_coordinates
|
||||
- gdk_surface_create_similar_surface
|
||||
|
||||
* Documentation:
|
||||
- Add a section on coordinate systems
|
||||
|
||||
* Build:
|
||||
- Require wayland-protocols 1.31
|
||||
|
||||
* Translation updates
|
||||
- British English
|
||||
- Bulgarian
|
||||
- Chinese (China)
|
||||
- Dutch
|
||||
- French
|
||||
- Persian
|
||||
- Russian
|
||||
|
||||
|
||||
Overview of Changes in 4.10.1, 14-03-2023
|
||||
=========================================
|
||||
|
||||
* GtkFileChooser
|
||||
- Improve search performance
|
||||
- Be safe against pathless files
|
||||
- Fix memory leaks
|
||||
- Only show local files in recent files
|
||||
- Show most recent files first
|
||||
- Make files non-selectable in selet_folder mode
|
||||
|
||||
* GtkListView / GtkColumnView / GtkGridView
|
||||
- Fix scrolling problems
|
||||
- Support CSS border-spacing
|
||||
|
||||
* GtkComboBox
|
||||
- Fix a size allocation problem
|
||||
|
||||
* gtk
|
||||
- Size allocation fixes
|
||||
|
||||
* Accessibility
|
||||
- Miscellaneous property fixes and improvements
|
||||
|
||||
* Wayland
|
||||
- Fix an ordering problem in surface disposal
|
||||
|
||||
* Windows
|
||||
- Fix Visual Studio build with older GLib
|
||||
|
||||
* Translation updates
|
||||
Basque
|
||||
Bulgarian
|
||||
Catalan
|
||||
Czech
|
||||
Danish
|
||||
Finnish
|
||||
Friulian
|
||||
Galician
|
||||
Georgian
|
||||
Hungarian
|
||||
Lithuanian
|
||||
Polish
|
||||
Portuguese
|
||||
Swedish
|
||||
Turkish
|
||||
Ukrainian
|
||||
|
||||
|
||||
Overview of Changes in 4.10.0, 04-03-2023
|
||||
=========================================
|
||||
|
||||
* GtkTextView
|
||||
- Document hanging indentation
|
||||
|
||||
* GtkListView
|
||||
- Fix a size allocation problem
|
||||
|
||||
* GtkFileChooser
|
||||
- Fix paned behavior
|
||||
- Fix a crash
|
||||
|
||||
* GtkText
|
||||
- Fix various problems with undo
|
||||
|
||||
* Accessibility
|
||||
- Make some getters transfer-full
|
||||
- Allow setting accessible parents and siblings
|
||||
- Add a role for toggle buttons
|
||||
- Miscellaneous property fixes and improvements
|
||||
|
||||
* gtk
|
||||
- Improve the handling resize-during-size-allocate
|
||||
|
||||
* gdk
|
||||
- Introduce GdkTextureDownloader and use it
|
||||
- Make gdk_texture_get_format public
|
||||
|
||||
* gsk
|
||||
- Make mask nodes more versatile
|
||||
- Improve the GL implementation for texture scale nodes
|
||||
|
||||
* X11
|
||||
- Fix key handling during DND
|
||||
|
||||
* Tools
|
||||
- gtk-builder-tool: Try harder to handle templates
|
||||
- gtk-builder-tool: Prefer properties over <child>
|
||||
|
||||
* Translation updates
|
||||
Basque
|
||||
Belarusian
|
||||
Bulgarian
|
||||
Indonesian
|
||||
Galician
|
||||
Georgian
|
||||
German
|
||||
Hebrew
|
||||
Lithuanian
|
||||
Portuguese
|
||||
Spanish
|
||||
Swedish
|
||||
Turkish
|
||||
Ukrainian
|
||||
|
||||
|
||||
Overview of Changes in 4.9.4, 12-02-2023
|
||||
Overview of Changes in 4.9.1, dd-mm-yyyy
|
||||
========================================
|
||||
|
||||
* Printing:
|
||||
- Add a CPDB backend
|
||||
- Drop the lpr backend
|
||||
|
||||
* GtkFileDialog:
|
||||
- Robustness fixes
|
||||
|
||||
* GtkScaleButton:
|
||||
- Add an 'active' property
|
||||
|
||||
* GtkSearchEntry:
|
||||
- Add placeholder text
|
||||
|
||||
* Fix conflicting type names between gtk and gio
|
||||
|
||||
* Gsk:
|
||||
- Settable filtering for scaled textures
|
||||
- Add mask nodes
|
||||
- Some robustness and crash fixes
|
||||
|
||||
* Wayland:
|
||||
- Handle dispatch failing in more places
|
||||
|
||||
* Deprecations:
|
||||
- GtkVolumeButton
|
||||
|
||||
* Translation updates:
|
||||
Belarusian
|
||||
Chinese (Taiwan)
|
||||
Georgian
|
||||
Turkish
|
||||
Ukrainian
|
||||
|
||||
|
||||
Overview of Changes in 4.9.3, 04-02-2023
|
||||
========================================
|
||||
|
||||
* Add GtkUriLauncher, as replacement for gtk_show_uri
|
||||
|
||||
* Add GdkMonitor::description
|
||||
|
||||
* Fix problems with tooltip sizing
|
||||
|
||||
* Deprecations:
|
||||
- GtkStatusbar
|
||||
- GtkAssistant
|
||||
- GtkLockButton
|
||||
- gtk_gesture_set_sequence_state
|
||||
|
||||
* GtkColumnView:
|
||||
- Only create widgets for visible columns
|
||||
|
||||
* GtkFileDialog:
|
||||
- Drop shortcut folders API
|
||||
|
||||
* GtkCalendar:
|
||||
- Make marked days work again
|
||||
|
||||
* GtkSwitch:
|
||||
- Make state and active independently settable
|
||||
|
||||
* GtkFileChooser:
|
||||
- Fix a crash with DND
|
||||
- Fix excessively wide sidebar
|
||||
- Make context menus work again
|
||||
|
||||
* Accessibility:
|
||||
- Make GtkAccessible public, so it can be implemented outside GTK
|
||||
- Support accessible implementation for editables
|
||||
|
||||
* CSS:
|
||||
- Fix randomly stopping CSS animations
|
||||
|
||||
* GL:
|
||||
- Fix synchronization with GStreamer
|
||||
- Fix problems with 3rd party GL in the same thread
|
||||
|
||||
* Wayland:
|
||||
- Fix startup notification with xdg_activation
|
||||
|
||||
* Broadway:
|
||||
- Implement modal windows
|
||||
|
||||
* macOS:
|
||||
- Make DND work
|
||||
|
||||
* Build:
|
||||
- Require graphene 1.10
|
||||
- Require gobject-introspection 1.72
|
||||
|
||||
* Translation updates
|
||||
Catalan
|
||||
Galician
|
||||
German
|
||||
Hebrew
|
||||
Indonesian
|
||||
Portuguese
|
||||
Russian
|
||||
Spanish
|
||||
Swedish
|
||||
Turkish
|
||||
Ukrainian
|
||||
|
||||
|
||||
Overview of Changes in 4.9.2, 26-12-2022
|
||||
========================================
|
||||
|
||||
* GtkFileChooserWidget:
|
||||
- Add a grid view
|
||||
|
||||
* GtkText, GtkTextView:
|
||||
- Fix activation of the on-screen keyboard
|
||||
- Prevent unexpected text direction changes
|
||||
|
||||
* GtkCenterBox:
|
||||
- Add properties for children
|
||||
|
||||
* GtkTreeExpander:
|
||||
- Add a hide-expander property
|
||||
|
||||
* GtkStringList:
|
||||
- Add a construct-only strings property
|
||||
|
||||
* GtkBuilder:
|
||||
- Support parsing Pango attributes in string form
|
||||
|
||||
* GtkGestureStylus:
|
||||
- Add a stylus-only property
|
||||
|
||||
* GtkFileLauncher:
|
||||
- New async-style api to replace gtk_show_uri
|
||||
|
||||
* GtkColorDialog, GtkFontDialog, GtkFileDialog,
|
||||
GtkAlertDialog:
|
||||
- APIs have seen some tweaks
|
||||
- Prefer portals when available
|
||||
- Fixes for cancellation
|
||||
|
||||
* Add GDK_DEBUG=no-portals
|
||||
|
||||
* Improve file DND with remote files
|
||||
|
||||
* GtkInfoBar has been deprecated
|
||||
|
||||
* gtk_widget_show/hide have been deprecated
|
||||
|
||||
* gtk_show_uri has been deprecated
|
||||
|
||||
* Wayland:
|
||||
- Fix button mask handling
|
||||
- Fix problems with cursor size on hi-dpi screens
|
||||
- Support newer versions of some protocols
|
||||
- Fix handling of surrounding text in input methods
|
||||
|
||||
* X11:
|
||||
- Fix some ordering problems with surface destruction
|
||||
|
||||
* Windows:
|
||||
- Improved system settings integration
|
||||
- Fix window resizing work with native decorations
|
||||
- Include a full hicolor index.theme file as a resource
|
||||
|
||||
* Translation updates
|
||||
Croatian
|
||||
Dutch
|
||||
Hungarian
|
||||
Interlingua
|
||||
Persian
|
||||
Turkish
|
||||
Ukrainian
|
||||
|
||||
|
||||
Overview of Changes in 4.9.1, 31-10-2022
|
||||
========================================
|
||||
|
||||
Note that deprecations are an early outlook at changes
|
||||
that will appear in an eventual GTK 5 release, which is
|
||||
still far away. We are introducing deprecations in 4.10
|
||||
as a way to give users time to adapt, and to provide
|
||||
feedback on our plans.
|
||||
Note that deprecations are an early outlook
|
||||
at changes that will appear in an eventual
|
||||
GTK 5 release, which is still far away.
|
||||
|
||||
* GtkTreeView, GtkIconView, GtkComboBox and
|
||||
auxiliary classes have been deprecated
|
||||
@@ -563,21 +15,7 @@ feedback on our plans.
|
||||
* gtk_render_ and gtk_snapshot_render_ APIs
|
||||
have been deprecated
|
||||
|
||||
* GtkAppChooser widgets have been deprecated
|
||||
|
||||
* GtkMessageDialog has been deprecated and
|
||||
replaced by a new async dialog API
|
||||
|
||||
* GtkDialog has been deprecated
|
||||
|
||||
* GtkColorChooser, GtkFontChooser, GtkFileChooser
|
||||
interfaces and their implementations have been
|
||||
deprecated. A new family of async dialog APIs
|
||||
has been introduced to replace them
|
||||
|
||||
* GtkColorDialog, GtkFontDialog, GtkFileDialog
|
||||
and GtkAlertDialog are new dialog classes with
|
||||
a consistent and well-bindable API
|
||||
* GtkAppChooser widgets hae been deprecated
|
||||
|
||||
* GtkMountOperation:
|
||||
- Fix the dialog to look reasonable
|
||||
@@ -594,8 +32,6 @@ feedback on our plans.
|
||||
- Make make debug options available in
|
||||
non-debug builds
|
||||
|
||||
* Increase the memory limit for the jpeg loader to 1G
|
||||
|
||||
* Translation updates:
|
||||
Abkhazian
|
||||
Basque
|
||||
|
17
README.md
17
README.md
@@ -116,12 +116,19 @@ docs/reference/gtk/html/gtk-building.html
|
||||
|
||||
Or [online](https://docs.gtk.org/gtk4/building.html)
|
||||
|
||||
Building from git
|
||||
-----------------
|
||||
Default branch renamed to `main`
|
||||
--------------------------------
|
||||
|
||||
The GTK sources are hosted on [gitlab.gnome.org](http://gitlab.gnome.org). The main
|
||||
development branch is called `main`, and stable branches are named after their minor
|
||||
version, for example `gtk-4-10`.
|
||||
The default development branch of GTK has been renamed to `main`.
|
||||
To update your local checkout, use:
|
||||
```sh
|
||||
git checkout master
|
||||
git branch -m master main
|
||||
git fetch
|
||||
git branch --unset-upstream
|
||||
git branch -u origin/main
|
||||
git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main
|
||||
```
|
||||
|
||||
How to report bugs
|
||||
------------------
|
||||
|
@@ -187,7 +187,7 @@
|
||||
"--libdir=/app/lib",
|
||||
"-Dvulkan=disabled",
|
||||
"-Dbuildtype=debugoptimized",
|
||||
"-Ddemo-profile=devel"
|
||||
"-Dprofile=devel"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
|
@@ -116,7 +116,7 @@
|
||||
"--libdir=/app/lib",
|
||||
"-Dvulkan=disabled",
|
||||
"-Dbuildtype=debugoptimized",
|
||||
"-Ddemo-profile=devel"
|
||||
"-Dprofile=devel"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
|
@@ -116,7 +116,7 @@
|
||||
"--libdir=/app/lib",
|
||||
"-Dvulkan=disabled",
|
||||
"-Dbuildtype=debugoptimized",
|
||||
"-Ddemo-profile=devel"
|
||||
"-Dprofile=devel"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
|
@@ -116,7 +116,7 @@
|
||||
"--libdir=/app/lib",
|
||||
"-Dvulkan=disabled",
|
||||
"-Dbuildtype=debugoptimized",
|
||||
"-Ddemo-profile=devel"
|
||||
"-Dprofile=devel"
|
||||
],
|
||||
"sources" : [
|
||||
{
|
||||
|
@@ -1,201 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2022 Collabora Inc.
|
||||
# 2023 Emmanuele Bassi
|
||||
#
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
#
|
||||
# Original author: Xavier Claessens <xclaesse@gmail.com>
|
||||
|
||||
import argparse
|
||||
import textwrap
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
# Disable line length warnings as wrapping the C code templates would be hard
|
||||
# flake8: noqa: E501
|
||||
|
||||
|
||||
def gen_versions_macros(args, current_major_version, current_minor_version, current_micro_version):
|
||||
with args.out_path.open("w", encoding="utf-8") as ofile, args.in_path.open(
|
||||
"r", encoding="utf-8"
|
||||
) as ifile:
|
||||
for line in ifile.readlines():
|
||||
if "@GDK_VERSIONS@" in line:
|
||||
ofile.write(
|
||||
textwrap.dedent(
|
||||
f"""\
|
||||
/**
|
||||
* GDK_MAJOR_VERSION:
|
||||
*
|
||||
* The major version component of the library's version, e.g. "1" for "1.2.3".
|
||||
*/
|
||||
#define GDK_MAJOR_VERSION ({current_major_version})
|
||||
|
||||
/**
|
||||
* GDK_MINOR_VERSION:
|
||||
*
|
||||
* The minor version component of the library's version, e.g. "2" for "1.2.3".
|
||||
*/
|
||||
#define GDK_MINOR_VERSION ({current_minor_version})
|
||||
|
||||
/**
|
||||
* GDK_MICRO_VERSION:
|
||||
*
|
||||
* The micro version component of the library's version, e.g. "3" for "1.2.3".
|
||||
*/
|
||||
#define GDK_MICRO_VERSION ({current_micro_version})
|
||||
"""
|
||||
)
|
||||
)
|
||||
for minor in range(0, current_minor_version + 2, 2):
|
||||
ofile.write(
|
||||
textwrap.dedent(
|
||||
f"""\
|
||||
/**
|
||||
* GDK_VERSION_{current_major_version}_{minor}:
|
||||
*
|
||||
* A macro that evaluates to the {current_major_version}.{minor} version of GTK, in a format
|
||||
* that can be used by the C pre-processor.
|
||||
*
|
||||
* Since: {current_major_version}.{minor}
|
||||
*/
|
||||
#define GDK_VERSION_{current_major_version}_{minor} (G_ENCODE_VERSION ({current_major_version}, {minor}))
|
||||
"""
|
||||
)
|
||||
)
|
||||
else:
|
||||
ofile.write(line)
|
||||
|
||||
|
||||
def gen_visibility_macros(args, current_major_version, current_minor_version, current_micro_version):
|
||||
"""
|
||||
Generates a set of macros for each minor stable version of GTK
|
||||
|
||||
- GDK_DEPRECATED
|
||||
- GDK_DEPRECATED_IN_…
|
||||
- GDK_DEPRECATED_MACRO_IN_…
|
||||
- GDK_DEPRECATED_ENUMERATOR_IN_…
|
||||
- GDK_DEPRECATED_TYPE_IN_…
|
||||
|
||||
- GDK_AVAILABLE_IN_ALL
|
||||
- GDK_AVAILABLE_IN_…
|
||||
- GDK_AVAILABLE_STATIC_INLINE_IN_…
|
||||
- GDK_AVAILABLE_MACRO_IN_…
|
||||
- GDK_AVAILABLE_ENUMERATOR_IN_…
|
||||
- GDK_AVAILABLE_TYPE_IN_…
|
||||
|
||||
- GDK_UNAVAILABLE(maj,min)
|
||||
- GDK_UNAVAILABLE_STATIC_INLINE(maj,min)
|
||||
"""
|
||||
|
||||
ns = args.namespace
|
||||
with args.out_path.open("w", encoding="utf-8") as f:
|
||||
f.write(
|
||||
textwrap.dedent(
|
||||
f"""\
|
||||
#pragma once
|
||||
|
||||
#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined({ns}_STATIC_COMPILATION)
|
||||
# define _{ns}_EXPORT __declspec(dllexport)
|
||||
# define _{ns}_IMPORT __declspec(dllimport)
|
||||
#elif __GNUC__ >= 4
|
||||
# define _{ns}_EXPORT __attribute__((visibility("default")))
|
||||
# define _{ns}_IMPORT
|
||||
#else
|
||||
# define _{ns}_EXPORT
|
||||
# define _{ns}_IMPORT
|
||||
#endif
|
||||
#ifdef GTK_COMPILATION
|
||||
# define _{ns}_API _{ns}_EXPORT
|
||||
#else
|
||||
# define _{ns}_API _{ns}_IMPORT
|
||||
#endif
|
||||
|
||||
#define _{ns}_EXTERN _{ns}_API extern
|
||||
|
||||
#define {ns}_VAR _{ns}_EXTERN
|
||||
#define {ns}_AVAILABLE_IN_ALL _{ns}_EXTERN
|
||||
|
||||
#ifdef GDK_DISABLE_DEPRECATION_WARNINGS
|
||||
#define {ns}_DEPRECATED _{ns}_EXTERN
|
||||
#define {ns}_DEPRECATED_FOR(f) _{ns}_EXTERN
|
||||
#define {ns}_UNAVAILABLE(maj,min) _{ns}_EXTERN
|
||||
#define {ns}_UNAVAILABLE_STATIC_INLINE(maj,min)
|
||||
#else
|
||||
#define {ns}_DEPRECATED G_DEPRECATED _{ns}_EXTERN
|
||||
#define {ns}_DEPRECATED_FOR(f) G_DEPRECATED_FOR(f) _{ns}_EXTERN
|
||||
#define {ns}_UNAVAILABLE(maj,min) G_UNAVAILABLE(maj,min) _{ns}_EXTERN
|
||||
#define {ns}_UNAVAILABLE_STATIC_INLINE(maj,min) G_UNAVAILABLE(maj,min)
|
||||
#endif
|
||||
"""
|
||||
)
|
||||
)
|
||||
for minor in range(0, current_minor_version + 2, 2):
|
||||
f.write(
|
||||
textwrap.dedent(
|
||||
f"""
|
||||
#if GDK_VERSION_MIN_REQUIRED >= GDK_VERSION_4_{minor}
|
||||
#define {ns}_DEPRECATED_IN_{current_major_version}_{minor} {ns}_DEPRECATED
|
||||
#define {ns}_DEPRECATED_IN_{current_major_version}_{minor}_FOR(f) {ns}_DEPRECATED_FOR (f)
|
||||
#define {ns}_DEPRECATED_MACRO_IN_{current_major_version}_{minor} GDK_DEPRECATED_MACRO
|
||||
#define {ns}_DEPRECATED_MACRO_IN_{current_major_version}_{minor}_FOR(f) GDK_DEPRECATED_MACRO_FOR (f)
|
||||
#define {ns}_DEPRECATED_ENUMERATOR_IN_{current_major_version}_{minor} GDK_DEPRECATED_ENUMERATOR
|
||||
#define {ns}_DEPRECATED_ENUMERATOR_IN_{current_major_version}_{minor}_FOR(f) GDK_DEPRECATED_ENUMERATOR_FOR (f)
|
||||
#define {ns}_DEPRECATED_TYPE_IN_{current_major_version}_{minor} GDK_DEPRECATED_TYPE
|
||||
#define {ns}_DEPRECATED_TYPE_IN_{current_major_version}_{minor}_FOR(f) GDK_DEPRECATED_TYPE_FOR (f)
|
||||
#else
|
||||
#define {ns}_DEPRECATED_IN_{current_major_version}_{minor} _{ns}_EXTERN
|
||||
#define {ns}_DEPRECATED_IN_{current_major_version}_{minor}_FOR(f) _{ns}_EXTERN
|
||||
#define {ns}_DEPRECATED_MACRO_IN_{current_major_version}_{minor}
|
||||
#define {ns}_DEPRECATED_MACRO_IN_{current_major_version}_{minor}_FOR(f)
|
||||
#define {ns}_DEPRECATED_ENUMERATOR_IN_{current_major_version}_{minor}
|
||||
#define {ns}_DEPRECATED_ENUMERATOR_IN_{current_major_version}_{minor}_FOR(f)
|
||||
#define {ns}_DEPRECATED_TYPE_IN_{current_major_version}_{minor}
|
||||
#define {ns}_DEPRECATED_TYPE_IN_{current_major_version}_{minor}_FOR(f)
|
||||
#endif
|
||||
|
||||
#if GDK_VERSION_MAX_ALLOWED < GDK_VERSION_{current_major_version}_{minor}
|
||||
#define {ns}_AVAILABLE_IN_{current_major_version}_{minor} {ns}_UNAVAILABLE ({current_major_version}, {minor})
|
||||
#define {ns}_AVAILABLE_STATIC_INLINE_IN_{current_major_version}_{minor} GDK_UNAVAILABLE_STATIC_INLINE ({current_major_version}, {minor})
|
||||
#define {ns}_AVAILABLE_MACRO_IN_{current_major_version}_{minor} GDK_UNAVAILABLE_MACRO ({current_major_version}, {minor})
|
||||
#define {ns}_AVAILABLE_ENUMERATOR_IN_{current_major_version}_{minor} GDK_UNAVAILABLE_ENUMERATOR ({current_major_version}, {minor})
|
||||
#define {ns}_AVAILABLE_TYPE_IN_{current_major_version}_{minor} GDK_UNAVAILABLE_TYPE ({current_major_version}, {minor})
|
||||
#else
|
||||
#define {ns}_AVAILABLE_IN_{current_major_version}_{minor} _{ns}_EXTERN
|
||||
#define {ns}_AVAILABLE_STATIC_INLINE_IN_{current_major_version}_{minor}
|
||||
#define {ns}_AVAILABLE_MACRO_IN_{current_major_version}_{minor}
|
||||
#define {ns}_AVAILABLE_ENUMERATOR_IN_{current_major_version}_{minor}
|
||||
#define {ns}_AVAILABLE_TYPE_IN_{current_major_version}_{minor}
|
||||
#endif
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("gtk_version", help="Current GLib version")
|
||||
subparsers = parser.add_subparsers()
|
||||
|
||||
versions_parser = subparsers.add_parser(
|
||||
"versions-macros", help="Generate versions macros"
|
||||
)
|
||||
versions_parser.add_argument("in_path", help="input file", type=Path)
|
||||
versions_parser.add_argument("out_path", help="output file", type=Path)
|
||||
versions_parser.set_defaults(func=gen_versions_macros)
|
||||
|
||||
visibility_parser = subparsers.add_parser(
|
||||
"visibility-macros", help="Generate visibility macros"
|
||||
)
|
||||
visibility_parser.add_argument("namespace", help="Macro namespace")
|
||||
visibility_parser.add_argument("out_path", help="output file", type=Path)
|
||||
visibility_parser.set_defaults(func=gen_visibility_macros)
|
||||
|
||||
args = parser.parse_args()
|
||||
version = [int(i) for i in args.gtk_version.split(".")]
|
||||
args.func(args, version[0], version[1], version[2])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@@ -202,36 +202,43 @@ constraint_editor_window_load (ConstraintEditorWindow *self,
|
||||
}
|
||||
|
||||
static void
|
||||
open_response_cb (GObject *source,
|
||||
GAsyncResult *result,
|
||||
void *user_data)
|
||||
open_response_cb (GtkNativeDialog *dialog,
|
||||
int response,
|
||||
ConstraintEditorWindow *self)
|
||||
{
|
||||
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
||||
ConstraintEditorWindow *self = user_data;
|
||||
GFile *file;
|
||||
gtk_native_dialog_hide (dialog);
|
||||
|
||||
file = gtk_file_dialog_open_finish (dialog, result, NULL);
|
||||
if (file)
|
||||
if (response == GTK_RESPONSE_ACCEPT)
|
||||
{
|
||||
GFile *file;
|
||||
|
||||
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
||||
constraint_editor_window_load (self, file);
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
gtk_native_dialog_destroy (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
open_cb (GtkWidget *button,
|
||||
ConstraintEditorWindow *self)
|
||||
{
|
||||
GtkFileDialog *dialog;
|
||||
GFile *cwd;
|
||||
GtkFileChooserNative *dialog;
|
||||
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_set_title (dialog, "Open file");
|
||||
cwd = g_file_new_for_path (".");
|
||||
gtk_file_dialog_set_initial_folder (dialog, cwd);
|
||||
dialog = gtk_file_chooser_native_new ("Open file",
|
||||
GTK_WINDOW (self),
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
"_Load",
|
||||
"_Cancel");
|
||||
gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (dialog), TRUE);
|
||||
|
||||
GFile *cwd = g_file_new_for_path (".");
|
||||
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), cwd, NULL);
|
||||
g_object_unref (cwd);
|
||||
gtk_file_dialog_open (dialog, GTK_WINDOW (self), NULL, open_response_cb, self);
|
||||
g_object_unref (dialog);
|
||||
|
||||
g_signal_connect (dialog, "response", G_CALLBACK (open_response_cb), self);
|
||||
gtk_native_dialog_show (GTK_NATIVE_DIALOG (dialog));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -287,23 +294,22 @@ serialize_model (GListModel *list)
|
||||
|
||||
|
||||
static void
|
||||
save_response_cb (GObject *source,
|
||||
GAsyncResult *result,
|
||||
void *user_data)
|
||||
save_response_cb (GtkNativeDialog *dialog,
|
||||
int response,
|
||||
ConstraintEditorWindow *self)
|
||||
{
|
||||
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
||||
ConstraintEditorWindow *self = user_data;
|
||||
GFile *file;
|
||||
gtk_native_dialog_hide (dialog);
|
||||
|
||||
file = gtk_file_dialog_save_finish (dialog, result, NULL);
|
||||
if (file)
|
||||
if (response == GTK_RESPONSE_ACCEPT)
|
||||
{
|
||||
GListModel *model;
|
||||
GFile *file;
|
||||
char *text;
|
||||
GError *error = NULL;
|
||||
|
||||
model = constraint_view_get_model (CONSTRAINT_VIEW (self->view));
|
||||
text = serialize_model (model);
|
||||
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
||||
g_file_replace_contents (file, text, strlen (text),
|
||||
NULL, FALSE,
|
||||
G_FILE_CREATE_NONE,
|
||||
@@ -312,38 +318,46 @@ save_response_cb (GObject *source,
|
||||
&error);
|
||||
if (error != NULL)
|
||||
{
|
||||
GtkAlertDialog *alert;
|
||||
GtkWidget *message_dialog;
|
||||
|
||||
alert = gtk_alert_dialog_new ("Saving failed");
|
||||
gtk_alert_dialog_set_detail (alert, error->message);
|
||||
gtk_alert_dialog_show (alert,
|
||||
GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (self))));
|
||||
g_object_unref (alert);
|
||||
message_dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (self))),
|
||||
GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_INFO,
|
||||
GTK_BUTTONS_OK,
|
||||
"Saving failed");
|
||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message_dialog),
|
||||
"%s", error->message);
|
||||
g_signal_connect (message_dialog, "response", G_CALLBACK (gtk_window_destroy), NULL);
|
||||
gtk_widget_show (message_dialog);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
g_free (text);
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
gtk_native_dialog_destroy (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
save_cb (GtkWidget *button,
|
||||
ConstraintEditorWindow *self)
|
||||
{
|
||||
GtkFileDialog *dialog;
|
||||
GFile *cwd;
|
||||
GtkFileChooserNative *dialog;
|
||||
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_set_title (dialog, "Save constraints");
|
||||
cwd = g_file_new_for_path (".");
|
||||
gtk_file_dialog_set_initial_folder (dialog, cwd);
|
||||
dialog = gtk_file_chooser_native_new ("Save constraints",
|
||||
GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (button))),
|
||||
GTK_FILE_CHOOSER_ACTION_SAVE,
|
||||
"_Save",
|
||||
"_Cancel");
|
||||
gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (dialog), TRUE);
|
||||
|
||||
GFile *cwd = g_file_new_for_path (".");
|
||||
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), cwd, NULL);
|
||||
g_object_unref (cwd);
|
||||
gtk_file_dialog_save (dialog,
|
||||
GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (button))),
|
||||
NULL,
|
||||
save_response_cb, self);
|
||||
g_object_unref (dialog);
|
||||
|
||||
g_signal_connect (dialog, "response", G_CALLBACK (save_response_cb), self);
|
||||
gtk_native_dialog_show (GTK_NATIVE_DIALOG (dialog));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -426,7 +440,7 @@ edit_constraint (ConstraintEditorWindow *win,
|
||||
|
||||
g_signal_connect (editor, "done", G_CALLBACK (constraint_editor_done), win);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (window));
|
||||
gtk_widget_show (window);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -459,7 +473,7 @@ edit_guide (ConstraintEditorWindow *win,
|
||||
gtk_window_set_child (GTK_WINDOW (window), GTK_WIDGET (editor));
|
||||
|
||||
g_signal_connect (editor, "done", G_CALLBACK (guide_editor_done), win);
|
||||
gtk_window_present (GTK_WINDOW (window));
|
||||
gtk_widget_show (window);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -9,7 +9,7 @@ constraint_editor_sources = [
|
||||
|
||||
constraint_editor_resources = gnome.compile_resources('constraint_editor_resources',
|
||||
'constraint-editor.gresource.xml',
|
||||
source_dir: meson.current_source_dir(),
|
||||
source_dir: '.',
|
||||
)
|
||||
|
||||
executable('gtk4-constraint-editor',
|
||||
|
@@ -2,8 +2,6 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
typedef GtkApplication DemoApplication;
|
||||
typedef GtkApplicationClass DemoApplicationClass;
|
||||
|
||||
@@ -35,12 +33,22 @@ static void create_window (GApplication *app, const char *contents);
|
||||
static void
|
||||
show_action_dialog (GSimpleAction *action)
|
||||
{
|
||||
GtkAlertDialog *dialog;
|
||||
const char *name;
|
||||
GtkWidget *dialog;
|
||||
|
||||
dialog = gtk_alert_dialog_new ("You activated action: \"%s\n",
|
||||
g_action_get_name (G_ACTION (action)));
|
||||
gtk_alert_dialog_show (dialog, NULL);
|
||||
g_object_unref (dialog);
|
||||
name = g_action_get_name (G_ACTION (action));
|
||||
|
||||
dialog = gtk_message_dialog_new (NULL,
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_INFO,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"You activated action: \"%s\"",
|
||||
name);
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (gtk_window_destroy), NULL);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -59,7 +67,7 @@ show_action_infobar (GSimpleAction *action,
|
||||
text = g_strdup_printf ("You activated radio action: \"%s\".\n"
|
||||
"Current value: %s", name, value);
|
||||
gtk_label_set_text (GTK_LABEL (window->message), text);
|
||||
gtk_widget_set_visible (window->infobar, TRUE);
|
||||
gtk_widget_show (window->infobar);
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
@@ -82,38 +90,43 @@ activate_new (GSimpleAction *action,
|
||||
}
|
||||
|
||||
static void
|
||||
open_response_cb (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
open_response_cb (GtkNativeDialog *dialog,
|
||||
int response_id,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
||||
GApplication *app = G_APPLICATION (user_data);
|
||||
GtkFileChooserNative *native = user_data;
|
||||
GApplication *app = g_object_get_data (G_OBJECT (native), "app");
|
||||
GtkWidget *message_dialog;
|
||||
GFile *file;
|
||||
char *contents;
|
||||
GError *error = NULL;
|
||||
|
||||
file = gtk_file_dialog_open_finish (dialog, result, &error);
|
||||
if (file)
|
||||
if (response_id == GTK_RESPONSE_ACCEPT)
|
||||
{
|
||||
char *contents;
|
||||
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (native));
|
||||
|
||||
if (g_file_load_contents (file, NULL, &contents, NULL, NULL, &error))
|
||||
{
|
||||
create_window (app, contents);
|
||||
g_free (contents);
|
||||
}
|
||||
else
|
||||
{
|
||||
message_dialog = gtk_message_dialog_new (NULL,
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"Error loading file: \"%s\"",
|
||||
error->message);
|
||||
g_signal_connect (message_dialog, "response",
|
||||
G_CALLBACK (gtk_window_destroy), NULL);
|
||||
gtk_widget_show (message_dialog);
|
||||
g_error_free (error);
|
||||
}
|
||||
}
|
||||
|
||||
if (error)
|
||||
{
|
||||
GtkAlertDialog *alert;
|
||||
|
||||
alert = gtk_alert_dialog_new ("Error loading file: \"%s\"", error->message);
|
||||
gtk_alert_dialog_show (alert, NULL);
|
||||
g_object_unref (alert);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
g_object_unref (app);
|
||||
gtk_native_dialog_destroy (GTK_NATIVE_DIALOG (native));
|
||||
g_object_unref (native);
|
||||
}
|
||||
|
||||
|
||||
@@ -123,11 +136,21 @@ activate_open (GSimpleAction *action,
|
||||
gpointer user_data)
|
||||
{
|
||||
GApplication *app = user_data;
|
||||
GtkFileDialog *dialog;
|
||||
GtkFileChooserNative *native;
|
||||
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_open (dialog, NULL, NULL, open_response_cb, g_object_ref (app));
|
||||
g_object_unref (dialog);
|
||||
native = gtk_file_chooser_native_new ("Open File",
|
||||
NULL,
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
"_Open",
|
||||
"_Cancel");
|
||||
|
||||
g_object_set_data_full (G_OBJECT (native), "app", g_object_ref (app), g_object_unref);
|
||||
g_signal_connect (native,
|
||||
"response",
|
||||
G_CALLBACK (open_response_cb),
|
||||
native);
|
||||
|
||||
gtk_native_dialog_show (GTK_NATIVE_DIALOG (native));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -297,7 +320,7 @@ static GActionEntry win_entries[] = {
|
||||
static void
|
||||
clicked_cb (GtkWidget *widget, DemoApplicationWindow *window)
|
||||
{
|
||||
gtk_widget_set_visible (window->infobar, FALSE);
|
||||
gtk_widget_hide (window->infobar);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -7,8 +7,6 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
static GtkWidget *progress_bar = NULL;
|
||||
|
||||
static gboolean
|
||||
@@ -142,6 +140,7 @@ create_page3 (GtkWidget *assistant)
|
||||
|
||||
label = gtk_label_new ("This is a confirmation page, press 'Apply' to apply changes");
|
||||
|
||||
gtk_widget_show (label);
|
||||
gtk_assistant_append_page (GTK_ASSISTANT (assistant), label);
|
||||
gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), label, GTK_ASSISTANT_PAGE_CONFIRM);
|
||||
gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), label, TRUE);
|
||||
@@ -158,14 +157,11 @@ create_page4 (GtkWidget *assistant)
|
||||
gtk_widget_set_margin_start (progress_bar, 40);
|
||||
gtk_widget_set_margin_end (progress_bar, 40);
|
||||
|
||||
gtk_widget_show (progress_bar);
|
||||
gtk_assistant_append_page (GTK_ASSISTANT (assistant), progress_bar);
|
||||
gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), progress_bar, GTK_ASSISTANT_PAGE_PROGRESS);
|
||||
gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), progress_bar, "Applying changes");
|
||||
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (progress_bar),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, "Applying changes",
|
||||
-1);
|
||||
|
||||
/* This prevents the assistant window from being
|
||||
* closed while we're "busy" applying changes.
|
||||
*/
|
||||
@@ -203,7 +199,7 @@ do_assistant (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (assistant))
|
||||
gtk_widget_set_visible (assistant, TRUE);
|
||||
gtk_widget_show (assistant);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (assistant));
|
||||
|
||||
|
@@ -116,8 +116,7 @@ effective_align (GtkAlign align,
|
||||
return direction == GTK_TEXT_DIR_RTL ? GTK_ALIGN_START : GTK_ALIGN_END;
|
||||
case GTK_ALIGN_FILL:
|
||||
case GTK_ALIGN_CENTER:
|
||||
case GTK_ALIGN_BASELINE_FILL:
|
||||
case GTK_ALIGN_BASELINE_CENTER:
|
||||
case GTK_ALIGN_BASELINE:
|
||||
default:
|
||||
return align;
|
||||
}
|
||||
@@ -259,8 +258,7 @@ blur_overlay_get_child_position (BlurOverlay *overlay,
|
||||
case GTK_ALIGN_END:
|
||||
alloc->x += width - alloc->width;
|
||||
break;
|
||||
case GTK_ALIGN_BASELINE_FILL:
|
||||
case GTK_ALIGN_BASELINE_CENTER:
|
||||
case GTK_ALIGN_BASELINE:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
@@ -283,8 +281,7 @@ blur_overlay_get_child_position (BlurOverlay *overlay,
|
||||
case GTK_ALIGN_END:
|
||||
alloc->y += height - alloc->height;
|
||||
break;
|
||||
case GTK_ALIGN_BASELINE_FILL:
|
||||
case GTK_ALIGN_BASELINE_CENTER:
|
||||
case GTK_ALIGN_BASELINE:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
@@ -300,13 +297,12 @@ blur_overlay_snapshot (GtkWidget *widget,
|
||||
GtkWidget *main_widget;
|
||||
GskRenderNode *main_widget_node = NULL;
|
||||
GtkWidget *child;
|
||||
int width, height;
|
||||
GtkAllocation main_alloc;
|
||||
cairo_region_t *clip = NULL;
|
||||
int i;
|
||||
|
||||
main_widget = BLUR_OVERLAY (widget)->main_widget;
|
||||
width = gtk_widget_get_width (widget);
|
||||
height = gtk_widget_get_height (widget);
|
||||
gtk_widget_get_allocation (widget, &main_alloc);
|
||||
|
||||
for (child = gtk_widget_get_first_child (widget);
|
||||
child != NULL;
|
||||
@@ -319,7 +315,7 @@ blur_overlay_snapshot (GtkWidget *widget,
|
||||
|
||||
if (blur > 0)
|
||||
{
|
||||
cairo_rectangle_int_t rect;
|
||||
GtkAllocation alloc;
|
||||
graphene_rect_t bounds;
|
||||
|
||||
if (main_widget_node == NULL)
|
||||
@@ -331,8 +327,8 @@ blur_overlay_snapshot (GtkWidget *widget,
|
||||
main_widget_node = gtk_snapshot_free_to_node (child_snapshot);
|
||||
}
|
||||
|
||||
if (!gtk_widget_compute_bounds (child, gtk_widget_get_parent (child), &bounds))
|
||||
graphene_rect_init (&bounds, 0, 0, 0, 0);
|
||||
gtk_widget_get_allocation (child, &alloc);
|
||||
graphene_rect_init (&bounds, alloc.x, alloc.y, alloc.width, alloc.height);
|
||||
gtk_snapshot_push_blur (snapshot, blur);
|
||||
gtk_snapshot_push_clip (snapshot, &bounds);
|
||||
gtk_snapshot_append_node (snapshot, main_widget_node);
|
||||
@@ -341,17 +337,13 @@ blur_overlay_snapshot (GtkWidget *widget,
|
||||
|
||||
if (clip == NULL)
|
||||
{
|
||||
cairo_rectangle_int_t rect;
|
||||
rect.x = rect.y = 0;
|
||||
rect.width = width;
|
||||
rect.height = height;
|
||||
rect.width = main_alloc.width;
|
||||
rect.height = main_alloc.height;
|
||||
clip = cairo_region_create_rectangle (&rect);
|
||||
}
|
||||
|
||||
rect.x = floor (bounds.origin.x);
|
||||
rect.y = floor (bounds.origin.y);
|
||||
rect.width = ceil (bounds.origin.x + bounds.size.width - rect.x);
|
||||
rect.height = ceil (bounds.origin.y + bounds.size.height - rect.y);
|
||||
cairo_region_subtract_rectangle (clip, &rect);
|
||||
cairo_region_subtract_rectangle (clip, (cairo_rectangle_int_t *)&alloc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -51,11 +51,15 @@ struct _BlurOverlayClass
|
||||
GtkAllocation *allocation);
|
||||
};
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType blur_overlay_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget *blur_overlay_new (void);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void blur_overlay_add_overlay (BlurOverlay *overlay,
|
||||
GtkWidget *widget,
|
||||
double blur);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void blur_overlay_set_child (BlurOverlay *overlay,
|
||||
GtkWidget *widget);
|
||||
|
||||
|
@@ -37,8 +37,6 @@ remove_timeout (gpointer data)
|
||||
g_source_remove (id);
|
||||
}
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
static gboolean
|
||||
pop_status (gpointer data)
|
||||
{
|
||||
@@ -59,8 +57,6 @@ status_message (GtkStatusbar *status,
|
||||
g_object_set_data_full (G_OBJECT (status), "timeout", GUINT_TO_POINTER (id), remove_timeout);
|
||||
}
|
||||
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
static void
|
||||
help_activate (GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
@@ -172,7 +168,7 @@ do_builder (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -1,5 +1,4 @@
|
||||
/* Clipboard
|
||||
* #Keywords: drag-and-drop, dnd
|
||||
*
|
||||
* GdkClipboard is used for clipboard handling. This demo shows how to
|
||||
* copy and paste text, images, colors or files to and from the clipboard.
|
||||
@@ -51,10 +50,10 @@ copy_button_clicked (GtkStack *source_stack,
|
||||
}
|
||||
else if (strcmp (visible_child_name, "Color") == 0)
|
||||
{
|
||||
const GdkRGBA *color;
|
||||
GdkRGBA color;
|
||||
|
||||
color = gtk_color_dialog_button_get_rgba (GTK_COLOR_DIALOG_BUTTON (visible_child));
|
||||
gdk_clipboard_set (clipboard, GDK_TYPE_RGBA, color);
|
||||
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (visible_child), &color);
|
||||
gdk_clipboard_set (clipboard, GDK_TYPE_RGBA, &color);
|
||||
}
|
||||
else if (strcmp (visible_child_name, "File") == 0)
|
||||
{
|
||||
@@ -216,71 +215,37 @@ file_button_set_file (GtkButton *button,
|
||||
}
|
||||
|
||||
static void
|
||||
file_chooser_response (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
file_chooser_response (GtkNativeDialog *dialog,
|
||||
int response,
|
||||
GtkButton *button)
|
||||
{
|
||||
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
||||
GtkButton *button = GTK_BUTTON (user_data);
|
||||
GFile *file;
|
||||
gtk_native_dialog_hide (dialog);
|
||||
|
||||
file = gtk_file_dialog_open_finish (dialog, result, NULL);
|
||||
if (file)
|
||||
if (response == GTK_RESPONSE_ACCEPT)
|
||||
{
|
||||
GFile *file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
||||
file_button_set_file (button, file);
|
||||
g_object_unref (file);
|
||||
|
||||
update_copy_button_sensitivity (gtk_widget_get_ancestor (GTK_WIDGET (button), GTK_TYPE_STACK));
|
||||
}
|
||||
|
||||
gtk_native_dialog_destroy (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
open_file_cb (GtkWidget *button)
|
||||
{
|
||||
GtkFileDialog *dialog;
|
||||
GtkFileChooserNative *chooser;
|
||||
|
||||
dialog = gtk_file_dialog_new ();
|
||||
chooser = gtk_file_chooser_native_new ("Choose a file",
|
||||
GTK_WINDOW (gtk_widget_get_ancestor (button, GTK_TYPE_WINDOW)),
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
"_Open",
|
||||
"_Cancel");
|
||||
|
||||
gtk_file_dialog_open (dialog,
|
||||
GTK_WINDOW (gtk_widget_get_ancestor (button, GTK_TYPE_WINDOW)),
|
||||
NULL,
|
||||
file_chooser_response, button);
|
||||
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
folder_chooser_response (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
||||
GtkButton *button = GTK_BUTTON (user_data);
|
||||
GFile *file;
|
||||
|
||||
file = gtk_file_dialog_select_folder_finish (dialog, result, NULL);
|
||||
if (file)
|
||||
{
|
||||
file_button_set_file (button, file);
|
||||
g_object_unref (file);
|
||||
|
||||
update_copy_button_sensitivity (gtk_widget_get_ancestor (GTK_WIDGET (button), GTK_TYPE_STACK));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
open_folder_cb (GtkWidget *button)
|
||||
{
|
||||
GtkFileDialog *dialog;
|
||||
|
||||
dialog = gtk_file_dialog_new ();
|
||||
|
||||
gtk_file_dialog_select_folder (dialog,
|
||||
GTK_WINDOW (gtk_widget_get_ancestor (button, GTK_TYPE_WINDOW)),
|
||||
NULL,
|
||||
folder_chooser_response, button);
|
||||
|
||||
g_object_unref (dialog);
|
||||
g_signal_connect (chooser, "response", G_CALLBACK (file_chooser_response), button);
|
||||
gtk_native_dialog_show (GTK_NATIVE_DIALOG (chooser));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -381,7 +346,6 @@ do_clipboard (GtkWidget *do_widget)
|
||||
gtk_builder_cscope_add_callback (scope, source_changed_cb);
|
||||
gtk_builder_cscope_add_callback (scope, text_changed_cb);
|
||||
gtk_builder_cscope_add_callback (scope, open_file_cb);
|
||||
gtk_builder_cscope_add_callback (scope, open_folder_cb);
|
||||
gtk_builder_cscope_add_callback (scope, on_drop);
|
||||
gtk_builder_cscope_add_callback (scope, drag_prepare);
|
||||
builder = gtk_builder_new ();
|
||||
@@ -405,7 +369,7 @@ do_clipboard (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -4,9 +4,6 @@
|
||||
<object class="GtkWindow" id="window">
|
||||
<property name="resizable">1</property>
|
||||
<property name="title">Clipboard</property>
|
||||
<accessibility>
|
||||
<relation name="described-by">label</relation>
|
||||
</accessibility>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
@@ -16,7 +13,7 @@
|
||||
<property name="margin-bottom">12</property>
|
||||
<property name="spacing">12</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label">
|
||||
<object class="GtkLabel">
|
||||
<property name="label">“Copy” will copy the selected data the clipboard, “Paste” will show the current clipboard contents. You can also drag the data to the bottom.</property>
|
||||
<property name="wrap">1</property>
|
||||
<property name="max-width-chars">40</property>
|
||||
@@ -27,9 +24,6 @@
|
||||
<property name="spacing">12</property>
|
||||
<child>
|
||||
<object class="GtkDropDown" id="source_chooser">
|
||||
<accessibility>
|
||||
<property name="label">Source Type</property>
|
||||
</accessibility>
|
||||
<property name="valign">center</property>
|
||||
<property name="model">
|
||||
<object class="GtkStringList">
|
||||
@@ -38,7 +32,6 @@
|
||||
<item>Color</item>
|
||||
<item>Image</item>
|
||||
<item>File</item>
|
||||
<item>Folder</item>
|
||||
</items>
|
||||
</object>
|
||||
</property>
|
||||
@@ -60,9 +53,6 @@
|
||||
<property name="name">Text</property>
|
||||
<property name="child">
|
||||
<object class="GtkEntry" id="source_text">
|
||||
<accessibility>
|
||||
<property name="label">Text Drag Source</property>
|
||||
</accessibility>
|
||||
<property name="valign">center</property>
|
||||
<signal name="notify::text" handler="text_changed_cb" object="copy_button"/>
|
||||
<property name="text">Copy this!</property>
|
||||
@@ -74,14 +64,7 @@
|
||||
<object class="GtkStackPage">
|
||||
<property name="name">Color</property>
|
||||
<property name="child">
|
||||
<object class="GtkColorDialogButton" id="source_color">
|
||||
<accessibility>
|
||||
<property name="label">Color Drag Source</property>
|
||||
</accessibility>
|
||||
<property name="dialog">
|
||||
<object class="GtkColorDialog">
|
||||
</object>
|
||||
</property>
|
||||
<object class="GtkColorButton" id="source_color">
|
||||
<property name="valign">center</property>
|
||||
<property name="rgba">purple</property>
|
||||
</object>
|
||||
@@ -99,17 +82,14 @@
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkToggleButton" id="image_rose">
|
||||
<accessibility>
|
||||
<property name="label">Photo Drag Source</property>
|
||||
</accessibility>
|
||||
<property name="active">1</property>
|
||||
<child>
|
||||
<object class="GtkDragSource">
|
||||
<signal name="prepare" handler="drag_prepare"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<accessibility>
|
||||
<property name="label">Portland Rose Photo</property>
|
||||
</accessibility>
|
||||
<style>
|
||||
<class name="large-icons"/>
|
||||
</style>
|
||||
@@ -120,9 +100,6 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToggleButton" id="image_floppy">
|
||||
<accessibility>
|
||||
<property name="label">Icon Drag Source</property>
|
||||
</accessibility>
|
||||
<property name="group">image_rose</property>
|
||||
<child>
|
||||
<object class="GtkDragSource">
|
||||
@@ -131,9 +108,6 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<accessibility>
|
||||
<property name="label">Floppy Buddy Icon</property>
|
||||
</accessibility>
|
||||
<style>
|
||||
<class name="large-icons"/>
|
||||
</style>
|
||||
@@ -144,9 +118,6 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToggleButton" id="image_logo">
|
||||
<accessibility>
|
||||
<property name="label">SVG Drag Source</property>
|
||||
</accessibility>
|
||||
<property name="group">image_floppy</property>
|
||||
<child>
|
||||
<object class="GtkDragSource">
|
||||
@@ -155,9 +126,6 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<accessibility>
|
||||
<property name="label">gtk-demo logo</property>
|
||||
</accessibility>
|
||||
<style>
|
||||
<class name="large-icons"/>
|
||||
</style>
|
||||
@@ -175,9 +143,6 @@
|
||||
<property name="name">File</property>
|
||||
<property name="child">
|
||||
<object class="GtkButton" id="source_file">
|
||||
<accessibility>
|
||||
<property name="label">File Drag Source</property>
|
||||
</accessibility>
|
||||
<child>
|
||||
<object class="GtkDragSource">
|
||||
<property name="propagation-phase">capture</property>
|
||||
@@ -197,33 +162,6 @@
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkStackPage">
|
||||
<property name="name">Folder</property>
|
||||
<property name="child">
|
||||
<object class="GtkButton" id="source_folder">
|
||||
<accessibility>
|
||||
<property name="label">Folder Drag Source</property>
|
||||
</accessibility>
|
||||
<child>
|
||||
<object class="GtkDragSource">
|
||||
<property name="propagation-phase">capture</property>
|
||||
<signal name="prepare" handler="drag_prepare"/>
|
||||
</object>
|
||||
</child>
|
||||
<property name="valign">center</property>
|
||||
<property name="child">
|
||||
<object class="GtkLabel">
|
||||
<property name="label">—</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="ellipsize">start</property>
|
||||
</object>
|
||||
</property>
|
||||
<signal name="clicked" handler="open_folder_cb"/>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
@@ -258,7 +196,7 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="paste_label">
|
||||
<object class="GtkLabel">
|
||||
<property name="xalign">0</property>
|
||||
<binding name="label">
|
||||
<lookup name="visible-child-name" type="GtkStack">
|
||||
@@ -285,9 +223,6 @@
|
||||
<property name="name">Text</property>
|
||||
<property name="child">
|
||||
<object class="GtkLabel">
|
||||
<accessibility>
|
||||
<relation name="labelled-by">paste_label</relation>
|
||||
</accessibility>
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="xalign">0</property>
|
||||
@@ -301,9 +236,6 @@
|
||||
<property name="name">Image</property>
|
||||
<property name="child">
|
||||
<object class="GtkImage">
|
||||
<accessibility>
|
||||
<relation name="labelled-by">paste_label</relation>
|
||||
</accessibility>
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<style>
|
||||
@@ -322,9 +254,6 @@
|
||||
<property name="valign">center</property>
|
||||
<child>
|
||||
<object class="GtkColorSwatch">
|
||||
<accessibility>
|
||||
<relation name="labelled-by">paste_label</relation>
|
||||
</accessibility>
|
||||
<property name="accessible-role">img</property>
|
||||
<property name="can-focus">0</property>
|
||||
<property name="selectable">0</property>
|
||||
@@ -340,9 +269,6 @@
|
||||
<property name="name">File</property>
|
||||
<property name="child">
|
||||
<object class="GtkLabel">
|
||||
<accessibility>
|
||||
<relation name="labelled-by">paste_label</relation>
|
||||
</accessibility>
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="xalign">0</property>
|
||||
|
@@ -449,7 +449,7 @@ do_combobox (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -277,7 +277,7 @@ do_constraints (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -66,7 +66,7 @@ do_constraints_builder (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -229,7 +229,7 @@ do_constraints_interactive (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -152,7 +152,7 @@ do_constraints_vfl (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -68,7 +68,7 @@ do_css_accordion (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -115,7 +115,7 @@ do_css_basics (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -50,7 +50,7 @@ update_css_for_blend_mode (GtkCssProvider *provider,
|
||||
blend_mode,
|
||||
blend_mode);
|
||||
|
||||
gtk_css_provider_load_from_string (provider, css);
|
||||
gtk_css_provider_load_from_data (provider, css, -1);
|
||||
|
||||
g_bytes_unref (bytes);
|
||||
g_free (css);
|
||||
@@ -139,7 +139,7 @@ do_css_blendmodes (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -155,7 +155,7 @@ do_css_multiplebgs (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -124,7 +124,7 @@ do_css_pixbufs (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -142,7 +142,7 @@ do_css_shadows (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -33,7 +33,7 @@ do_cursors (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -43,7 +43,7 @@
|
||||
<file>cssview.css</file>
|
||||
<file>reset.css</file>
|
||||
</gresource>
|
||||
<gresource prefix="/listview_selections">
|
||||
<gresource prefix="/dropdown">
|
||||
<file>suggestionentry.h</file>
|
||||
<file>suggestionentry.c</file>
|
||||
<file>suggestionentry.css</file>
|
||||
@@ -195,9 +195,6 @@
|
||||
<gresource prefix="/listview_settings">
|
||||
<file>listview_settings.ui</file>
|
||||
</gresource>
|
||||
<gresource prefix="/listview_settings2">
|
||||
<file>listview_settings2.ui</file>
|
||||
</gresource>
|
||||
<gresource prefix="/listview_ucd_data/">
|
||||
<file>ucdnames.data</file>
|
||||
</gresource>
|
||||
@@ -218,12 +215,6 @@
|
||||
<file>demo3widget.h</file>
|
||||
<file>demo3widget.ui</file>
|
||||
</gresource>
|
||||
<gresource prefix="/mask">
|
||||
<file>demo4widget.c</file>
|
||||
<file>demo4widget.h</file>
|
||||
<file>hsla.h</file>
|
||||
<file>hsla.c</file>
|
||||
</gresource>
|
||||
<gresource prefix="/paintable_svg">
|
||||
<file>svgpaintable.h</file>
|
||||
<file>svgpaintable.c</file>
|
||||
@@ -277,6 +268,7 @@
|
||||
<file>cursors.c</file>
|
||||
<file>dialog.c</file>
|
||||
<file>drawingarea.c</file>
|
||||
<file>dropdown.c</file>
|
||||
<file>dnd.c</file>
|
||||
<file>editable_cells.c</file>
|
||||
<file>entry_completion.c</file>
|
||||
@@ -300,7 +292,6 @@
|
||||
<file>iconscroll.c</file>
|
||||
<file>iconview.c</file>
|
||||
<file>iconview_edit.c</file>
|
||||
<file>image_scaling.c</file>
|
||||
<file>images.c</file>
|
||||
<file>infobar.c</file>
|
||||
<file>layoutmanager.c</file>
|
||||
@@ -313,16 +304,14 @@
|
||||
<file>listview_clocks.c</file>
|
||||
<file>listview_filebrowser.c</file>
|
||||
<file>listview_minesweeper.c</file>
|
||||
<file>listview_selections.c</file>
|
||||
<file>listview_settings.c</file>
|
||||
<file>listview_settings2.c</file>
|
||||
<file>listview_ucd.c</file>
|
||||
<file>listview_weather.c</file>
|
||||
<file>listview_words.c</file>
|
||||
<file>list_store.c</file>
|
||||
<file>main.c</file>
|
||||
<file>markup.c</file>
|
||||
<file>mask.c</file>
|
||||
<file>menu.c</file>
|
||||
<file>overlay.c</file>
|
||||
<file>overlay_decorative.c</file>
|
||||
<file>paint.c</file>
|
||||
@@ -335,9 +324,6 @@
|
||||
<file>paintable_symbolic.c</file>
|
||||
<file>panes.c</file>
|
||||
<file>password_entry.c</file>
|
||||
<file>path_fill.c</file>
|
||||
<file>path_maze.c</file>
|
||||
<file>path_text.c</file>
|
||||
<file>peg_solitaire.c</file>
|
||||
<file>pickers.c</file>
|
||||
<file>printing.c</file>
|
||||
@@ -423,9 +409,6 @@
|
||||
<gresource prefix="/fontrendering">
|
||||
<file>fontrendering.ui</file>
|
||||
</gresource>
|
||||
<gresource prefix="/path_text">
|
||||
<file>path_text.ui</file>
|
||||
</gresource>
|
||||
<gresource prefix="/org/gtk/Demo4">
|
||||
<file>icons/16x16/actions/application-exit.png</file>
|
||||
<file>icons/16x16/actions/document-new.png</file>
|
||||
|
@@ -3,20 +3,16 @@
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_TEXTURE = 1,
|
||||
PROP_FILTER,
|
||||
PROP_SCALE,
|
||||
PROP_ANGLE,
|
||||
PROP_PAINTABLE = 1,
|
||||
PROP_SCALE
|
||||
};
|
||||
|
||||
struct _Demo3Widget
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
|
||||
GdkTexture *texture;
|
||||
GdkPaintable *paintable;
|
||||
float scale;
|
||||
float angle;
|
||||
GskScalingFilter filter;
|
||||
|
||||
GtkWidget *menu;
|
||||
};
|
||||
@@ -28,86 +24,10 @@ struct _Demo3WidgetClass
|
||||
|
||||
G_DEFINE_TYPE (Demo3Widget, demo3_widget, GTK_TYPE_WIDGET)
|
||||
|
||||
static gboolean
|
||||
query_tooltip (GtkWidget *widget,
|
||||
int x,
|
||||
int y,
|
||||
gboolean keyboard_mode,
|
||||
GtkTooltip *tooltip,
|
||||
gpointer data)
|
||||
{
|
||||
Demo3Widget *self = DEMO3_WIDGET (widget);
|
||||
GtkWidget *grid;
|
||||
GtkWidget *label;
|
||||
char *s, *s2;
|
||||
const char *filter[] = { "Linear", "Nearest", "Trilinear" };
|
||||
int precision, l;
|
||||
|
||||
grid = gtk_grid_new ();
|
||||
gtk_grid_set_column_spacing (GTK_GRID (grid), 12);
|
||||
gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
|
||||
label = gtk_label_new ("Texture");
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0);
|
||||
gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1);
|
||||
s = g_strdup_printf ("%d\342\200\206\303\227\342\200\206%d",
|
||||
gdk_texture_get_width (self->texture),
|
||||
gdk_texture_get_height (self->texture));
|
||||
label = gtk_label_new (s);
|
||||
g_free (s);
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 1);
|
||||
gtk_grid_attach (GTK_GRID (grid), label, 1, 0, 1, 1);
|
||||
|
||||
label = gtk_label_new ("Rotation");
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0);
|
||||
gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1);
|
||||
s = g_strdup_printf ("%.1f", self->angle);
|
||||
if (g_str_has_suffix (s, ".0"))
|
||||
s[strlen (s) - 2] = '\0';
|
||||
s2 = g_strconcat (s, "\302\260", NULL);
|
||||
label = gtk_label_new (s2);
|
||||
g_free (s2);
|
||||
g_free (s);
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 1);
|
||||
gtk_grid_attach (GTK_GRID (grid), label, 1, 1, 1, 1);
|
||||
|
||||
label = gtk_label_new ("Scale");
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0);
|
||||
gtk_grid_attach (GTK_GRID (grid), label, 0, 2, 1, 1);
|
||||
|
||||
precision = 1;
|
||||
do {
|
||||
s = g_strdup_printf ("%.*f", precision, self->scale);
|
||||
l = strlen (s) - 1;
|
||||
while (s[l] == '0')
|
||||
l--;
|
||||
if (s[l] == '.')
|
||||
s[l] = '\0';
|
||||
precision++;
|
||||
} while (strcmp (s, "0") == 0);
|
||||
|
||||
label = gtk_label_new (s);
|
||||
g_free (s);
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 1);
|
||||
gtk_grid_attach (GTK_GRID (grid), label, 1, 2, 1, 1);
|
||||
|
||||
label = gtk_label_new ("Filter");
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0);
|
||||
gtk_grid_attach (GTK_GRID (grid), label, 0, 3, 1, 1);
|
||||
label = gtk_label_new (filter[self->filter]);
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 1);
|
||||
gtk_grid_attach (GTK_GRID (grid), label, 1, 3, 1, 1);
|
||||
|
||||
gtk_tooltip_set_custom (tooltip, grid);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
demo3_widget_init (Demo3Widget *self)
|
||||
{
|
||||
self->scale = 1.f;
|
||||
self->angle = 0.f;
|
||||
self->filter = GSK_SCALING_FILTER_LINEAR;
|
||||
gtk_widget_init_template (GTK_WIDGET (self));
|
||||
}
|
||||
|
||||
@@ -116,7 +36,7 @@ demo3_widget_dispose (GObject *object)
|
||||
{
|
||||
Demo3Widget *self = DEMO3_WIDGET (object);
|
||||
|
||||
g_clear_object (&self->texture);
|
||||
g_clear_object (&self->paintable);
|
||||
|
||||
gtk_widget_dispose_template (GTK_WIDGET (self), DEMO3_TYPE_WIDGET);
|
||||
|
||||
@@ -129,35 +49,21 @@ demo3_widget_snapshot (GtkWidget *widget,
|
||||
{
|
||||
Demo3Widget *self = DEMO3_WIDGET (widget);
|
||||
int x, y, width, height;
|
||||
double w, h, w2, h2;
|
||||
double w, h;
|
||||
|
||||
width = gtk_widget_get_width (widget);
|
||||
height = gtk_widget_get_height (widget);
|
||||
|
||||
w2 = w = self->scale * gdk_texture_get_width (self->texture);
|
||||
h2 = h = self->scale * gdk_texture_get_height (self->texture);
|
||||
w = self->scale * gdk_paintable_get_intrinsic_width (self->paintable);
|
||||
h = self->scale * gdk_paintable_get_intrinsic_height (self->paintable);
|
||||
|
||||
if (G_APPROX_VALUE (self->angle, 90.f, FLT_EPSILON) ||
|
||||
G_APPROX_VALUE (self->angle, 270.f, FLT_EPSILON))
|
||||
{
|
||||
double s = w2;
|
||||
w2 = h2;
|
||||
h2 = s;
|
||||
}
|
||||
|
||||
x = (width - ceil (w2)) / 2;
|
||||
y = (height - ceil (h2)) / 2;
|
||||
x = MAX (0, (width - ceil (w)) / 2);
|
||||
y = MAX (0, (height - ceil (h)) / 2);
|
||||
|
||||
gtk_snapshot_push_clip (snapshot, &GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||
gtk_snapshot_save (snapshot);
|
||||
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (x, y));
|
||||
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (w2 / 2, h2 / 2));
|
||||
gtk_snapshot_rotate (snapshot, self->angle);
|
||||
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (- w / 2, - h / 2));
|
||||
gtk_snapshot_append_scaled_texture (snapshot,
|
||||
self->texture,
|
||||
self->filter,
|
||||
&GRAPHENE_RECT_INIT (0, 0, w, h));
|
||||
gdk_paintable_snapshot (self->paintable, snapshot, w, h);
|
||||
gtk_snapshot_restore (snapshot);
|
||||
gtk_snapshot_pop (snapshot);
|
||||
}
|
||||
@@ -172,26 +78,14 @@ demo3_widget_measure (GtkWidget *widget,
|
||||
int *natural_baseline)
|
||||
{
|
||||
Demo3Widget *self = DEMO3_WIDGET (widget);
|
||||
int width, height;
|
||||
int size;
|
||||
|
||||
width = gdk_texture_get_width (self->texture);
|
||||
height = gdk_texture_get_height (self->texture);
|
||||
|
||||
if (G_APPROX_VALUE (self->angle, 90.f, FLT_EPSILON) ||
|
||||
G_APPROX_VALUE (self->angle, 270.f, FLT_EPSILON))
|
||||
{
|
||||
int s = width;
|
||||
width = height;
|
||||
height = s;
|
||||
}
|
||||
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
size = width;
|
||||
size = gdk_paintable_get_intrinsic_width (self->paintable);
|
||||
else
|
||||
size = height;
|
||||
size = gdk_paintable_get_intrinsic_height (self->paintable);
|
||||
|
||||
*minimum = *natural = (int) ceil (self->scale * size);
|
||||
*minimum = *natural = self->scale * size;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -209,8 +103,6 @@ demo3_widget_size_allocate (GtkWidget *widget,
|
||||
gtk_popover_present (GTK_POPOVER (self->menu));
|
||||
}
|
||||
|
||||
static void update_actions (Demo3Widget *self);
|
||||
|
||||
static void
|
||||
demo3_widget_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
@@ -221,32 +113,14 @@ demo3_widget_set_property (GObject *object,
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_TEXTURE:
|
||||
g_clear_object (&self->texture);
|
||||
self->texture = g_value_dup_object (value);
|
||||
self->scale = 1.f;
|
||||
self->angle = 0.f;
|
||||
self->filter = GSK_SCALING_FILTER_LINEAR;
|
||||
update_actions (self);
|
||||
case PROP_PAINTABLE:
|
||||
g_clear_object (&self->paintable);
|
||||
self->paintable = g_value_dup_object (value);
|
||||
gtk_widget_queue_resize (GTK_WIDGET (object));
|
||||
g_object_notify (object, "scale");
|
||||
g_object_notify (object, "angle");
|
||||
g_object_notify (object, "filter");
|
||||
break;
|
||||
|
||||
case PROP_SCALE:
|
||||
self->scale = g_value_get_float (value);
|
||||
update_actions (self);
|
||||
gtk_widget_queue_resize (GTK_WIDGET (object));
|
||||
break;
|
||||
|
||||
case PROP_ANGLE:
|
||||
self->angle = fmodf (g_value_get_float (value), 360.f);
|
||||
gtk_widget_queue_resize (GTK_WIDGET (object));
|
||||
break;
|
||||
|
||||
case PROP_FILTER:
|
||||
self->filter = g_value_get_enum (value);
|
||||
gtk_widget_queue_resize (GTK_WIDGET (object));
|
||||
break;
|
||||
|
||||
@@ -266,22 +140,14 @@ demo3_widget_get_property (GObject *object,
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_TEXTURE:
|
||||
g_value_set_object (value, self->texture);
|
||||
case PROP_PAINTABLE:
|
||||
g_value_set_object (value, self->paintable);
|
||||
break;
|
||||
|
||||
case PROP_SCALE:
|
||||
g_value_set_float (value, self->scale);
|
||||
break;
|
||||
|
||||
case PROP_ANGLE:
|
||||
g_value_set_float (value, self->angle);
|
||||
break;
|
||||
|
||||
case PROP_FILTER:
|
||||
g_value_set_enum (value, self->filter);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@@ -303,14 +169,6 @@ pressed_cb (GtkGestureClick *gesture,
|
||||
gtk_popover_popup (GTK_POPOVER (self->menu));
|
||||
}
|
||||
|
||||
static void
|
||||
update_actions (Demo3Widget *self)
|
||||
{
|
||||
gtk_widget_action_set_enabled (GTK_WIDGET (self), "zoom.in", self->scale < 1024.);
|
||||
gtk_widget_action_set_enabled (GTK_WIDGET (self), "zoom.out", self->scale > 1./1024.);
|
||||
gtk_widget_action_set_enabled (GTK_WIDGET (self), "zoom.reset", self->scale != 1.);
|
||||
}
|
||||
|
||||
static void
|
||||
zoom_cb (GtkWidget *widget,
|
||||
const char *action_name,
|
||||
@@ -320,30 +178,19 @@ zoom_cb (GtkWidget *widget,
|
||||
float scale;
|
||||
|
||||
if (g_str_equal (action_name, "zoom.in"))
|
||||
scale = MIN (1024., self->scale * M_SQRT2);
|
||||
scale = MIN (10, self->scale * M_SQRT2);
|
||||
else if (g_str_equal (action_name, "zoom.out"))
|
||||
scale = MAX (1./1024., self->scale / M_SQRT2);
|
||||
else if (g_str_equal (action_name, "zoom.reset"))
|
||||
scale = 1.0;
|
||||
scale = MAX (0.01, self->scale / M_SQRT2);
|
||||
else
|
||||
g_assert_not_reached ();
|
||||
scale = 1.0;
|
||||
|
||||
gtk_widget_action_set_enabled (widget, "zoom.in", scale < 10);
|
||||
gtk_widget_action_set_enabled (widget, "zoom.out", scale > 0.01);
|
||||
gtk_widget_action_set_enabled (widget, "zoom.reset", scale != 1);
|
||||
|
||||
g_object_set (widget, "scale", scale, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
rotate_cb (GtkWidget *widget,
|
||||
const char *action_name,
|
||||
GVariant *parameter)
|
||||
{
|
||||
Demo3Widget *self = DEMO3_WIDGET (widget);
|
||||
int angle;
|
||||
|
||||
g_variant_get (parameter, "i", &angle);
|
||||
|
||||
g_object_set (widget, "angle", fmodf (self->angle + angle, 360.f), NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
demo3_widget_class_init (Demo3WidgetClass *class)
|
||||
{
|
||||
@@ -358,55 +205,40 @@ demo3_widget_class_init (Demo3WidgetClass *class)
|
||||
widget_class->measure = demo3_widget_measure;
|
||||
widget_class->size_allocate = demo3_widget_size_allocate;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_TEXTURE,
|
||||
g_param_spec_object ("texture", NULL, NULL,
|
||||
GDK_TYPE_TEXTURE,
|
||||
g_object_class_install_property (object_class, PROP_PAINTABLE,
|
||||
g_param_spec_object ("paintable", "Paintable", "Paintable",
|
||||
GDK_TYPE_PAINTABLE,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_SCALE,
|
||||
g_param_spec_float ("scale", NULL, NULL,
|
||||
1./1024., 1024., 1.0,
|
||||
g_param_spec_float ("scale", "Scale", "Scale",
|
||||
0.0, 10.0, 1.0,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_ANGLE,
|
||||
g_param_spec_float ("angle", NULL, NULL,
|
||||
0.0, 360.0, 0.0,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_FILTER,
|
||||
g_param_spec_enum ("filter", NULL, NULL,
|
||||
GSK_TYPE_SCALING_FILTER, GSK_SCALING_FILTER_LINEAR,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
/* These are the actions that we are using in the menu */
|
||||
gtk_widget_class_install_action (widget_class, "zoom.in", NULL, zoom_cb);
|
||||
gtk_widget_class_install_action (widget_class, "zoom.out", NULL, zoom_cb);
|
||||
gtk_widget_class_install_action (widget_class, "zoom.reset", NULL, zoom_cb);
|
||||
gtk_widget_class_install_action (widget_class, "rotate", "i", rotate_cb);
|
||||
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/menu/demo3widget.ui");
|
||||
gtk_widget_class_bind_template_child (widget_class, Demo3Widget, menu);
|
||||
gtk_widget_class_bind_template_callback (widget_class, pressed_cb);
|
||||
|
||||
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_IMG);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
demo3_widget_new (const char *resource)
|
||||
{
|
||||
Demo3Widget *self;
|
||||
GdkTexture *texture;
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkPaintable *paintable;
|
||||
|
||||
texture = gdk_texture_new_from_resource (resource);
|
||||
pixbuf = gdk_pixbuf_new_from_resource (resource, NULL);
|
||||
paintable = GDK_PAINTABLE (gdk_texture_new_for_pixbuf (pixbuf));
|
||||
|
||||
self = g_object_new (DEMO3_TYPE_WIDGET,
|
||||
"texture", texture,
|
||||
"has-tooltip", TRUE,
|
||||
NULL);
|
||||
self = g_object_new (DEMO3_TYPE_WIDGET, "paintable", paintable, NULL);
|
||||
|
||||
g_signal_connect (self, "query-tooltip", G_CALLBACK (query_tooltip), NULL);
|
||||
|
||||
g_object_unref (texture);
|
||||
g_object_unref (pixbuf);
|
||||
g_object_unref (paintable);
|
||||
|
||||
return GTK_WIDGET (self);
|
||||
}
|
||||
|
@@ -12,21 +12,10 @@
|
||||
<attribute name="label">1∶1</attribute>
|
||||
<attribute name="action">zoom.reset</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label">Rotate</attribute>
|
||||
<attribute name="action">rotate</attribute>
|
||||
<attribute name="target" type="i">90</attribute>
|
||||
</item>
|
||||
</menu>
|
||||
<template class="Demo3Widget">
|
||||
<accessibility>
|
||||
<property name="label">Demo image</property>
|
||||
</accessibility>
|
||||
<child>
|
||||
<object class="GtkPopoverMenu" id="menu">
|
||||
<accessibility>
|
||||
<property name="label">Context menu</property>
|
||||
</accessibility>
|
||||
<property name="has-arrow">0</property>
|
||||
<property name="menu-model">model</property>
|
||||
</object>
|
||||
|
@@ -1,226 +0,0 @@
|
||||
#include <math.h>
|
||||
#include "demo4widget.h"
|
||||
#include "hsla.h"
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_PROGRESS,
|
||||
};
|
||||
|
||||
struct _Demo4Widget
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
PangoLayout *layout;
|
||||
GskColorStop stops[8];
|
||||
gsize n_stops;
|
||||
double progress;
|
||||
|
||||
guint tick;
|
||||
};
|
||||
|
||||
struct _Demo4WidgetClass
|
||||
{
|
||||
GtkWidgetClass parent_class;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (Demo4Widget, demo4_widget, GTK_TYPE_WIDGET)
|
||||
|
||||
static void
|
||||
rotate_color (GdkRGBA *rgba)
|
||||
{
|
||||
GdkHSLA hsla;
|
||||
|
||||
_gdk_hsla_init_from_rgba (&hsla, rgba);
|
||||
hsla.hue -= 1;
|
||||
_gdk_rgba_init_from_hsla (rgba, &hsla);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
rotate_colors (GtkWidget *widget,
|
||||
GdkFrameClock *clock,
|
||||
gpointer user_data)
|
||||
{
|
||||
Demo4Widget *self = DEMO4_WIDGET (widget);
|
||||
|
||||
for (unsigned int i = 0; i < self->n_stops; i++)
|
||||
rotate_color (&self->stops[i].color);
|
||||
|
||||
gtk_widget_queue_draw (widget);
|
||||
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
|
||||
static void
|
||||
demo4_widget_init (Demo4Widget *self)
|
||||
{
|
||||
PangoFontDescription *desc;
|
||||
|
||||
self->progress = 0.5;
|
||||
|
||||
self->n_stops = 8;
|
||||
self->stops[0].offset = 0;
|
||||
self->stops[0].color = (GdkRGBA) { 1, 0, 0, 1 };
|
||||
|
||||
for (unsigned int i = 1; i < self->n_stops; i++)
|
||||
{
|
||||
GdkHSLA hsla;
|
||||
|
||||
self->stops[i].offset = i / (double)(self->n_stops - 1);
|
||||
_gdk_hsla_init_from_rgba (&hsla, &self->stops[i - 1].color);
|
||||
hsla.hue += 360.0 / (double)(self->n_stops - 1);
|
||||
_gdk_rgba_init_from_hsla (&self->stops[i].color, &hsla);
|
||||
}
|
||||
|
||||
self->layout = gtk_widget_create_pango_layout (GTK_WIDGET (self), "123");
|
||||
desc = pango_font_description_from_string ("Cantarell Bold 210");
|
||||
pango_layout_set_font_description (self->layout, desc);
|
||||
pango_font_description_free (desc);
|
||||
|
||||
self->tick = gtk_widget_add_tick_callback (GTK_WIDGET (self), rotate_colors, NULL, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
demo4_widget_dispose (GObject *object)
|
||||
{
|
||||
Demo4Widget *self = DEMO4_WIDGET (object);
|
||||
|
||||
g_clear_object (&self->layout);
|
||||
gtk_widget_remove_tick_callback (GTK_WIDGET (self), self->tick);
|
||||
|
||||
G_OBJECT_CLASS (demo4_widget_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
demo4_widget_snapshot_content (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot,
|
||||
GskMaskMode mode)
|
||||
{
|
||||
Demo4Widget *self = DEMO4_WIDGET (widget);
|
||||
int width, height, layout_width, layout_height;
|
||||
double scale;
|
||||
|
||||
width = gtk_widget_get_width (widget);
|
||||
height = gtk_widget_get_height (widget);
|
||||
|
||||
gtk_snapshot_push_mask (snapshot, mode);
|
||||
pango_layout_get_pixel_size (self->layout, &layout_width, &layout_height);
|
||||
scale = MIN ((double) width / layout_width, (double) height / layout_height);
|
||||
gtk_snapshot_translate (snapshot,
|
||||
&GRAPHENE_POINT_INIT ((width - scale * layout_width) / 2,
|
||||
(height - scale * layout_height) / 2));
|
||||
gtk_snapshot_scale (snapshot, scale, scale);
|
||||
gtk_snapshot_append_layout (snapshot, self->layout, &(GdkRGBA) { 0, 0, 0, 1 });
|
||||
gtk_snapshot_pop (snapshot);
|
||||
|
||||
gtk_snapshot_append_linear_gradient (snapshot,
|
||||
&GRAPHENE_RECT_INIT (0, 0, width, height),
|
||||
&GRAPHENE_POINT_INIT (0, 0),
|
||||
&GRAPHENE_POINT_INIT (width, height),
|
||||
self->stops,
|
||||
self->n_stops);
|
||||
gtk_snapshot_pop (snapshot);
|
||||
}
|
||||
|
||||
static void
|
||||
demo4_widget_snapshot (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot)
|
||||
{
|
||||
Demo4Widget *self = DEMO4_WIDGET (widget);
|
||||
int width, height;
|
||||
|
||||
width = gtk_widget_get_width (widget);
|
||||
height = gtk_widget_get_height (widget);
|
||||
|
||||
gtk_snapshot_push_mask (snapshot, GSK_MASK_MODE_INVERTED_LUMINANCE);
|
||||
gtk_snapshot_append_linear_gradient (snapshot,
|
||||
&GRAPHENE_RECT_INIT (0, 0, width, height),
|
||||
&GRAPHENE_POINT_INIT (0, 0),
|
||||
&GRAPHENE_POINT_INIT (width, 0),
|
||||
(GskColorStop[2]) {
|
||||
{ MAX (0.0, self->progress - 5.0 / width), { 1, 1, 1, 1 } },
|
||||
{ MIN (1.0, self->progress + 5.0 / width), { 0, 0, 0, 1 } }
|
||||
}, 2);
|
||||
gtk_snapshot_pop (snapshot);
|
||||
demo4_widget_snapshot_content (widget, snapshot, GSK_MASK_MODE_INVERTED_ALPHA);
|
||||
gtk_snapshot_pop (snapshot);
|
||||
|
||||
gtk_snapshot_push_mask (snapshot, GSK_MASK_MODE_LUMINANCE);
|
||||
gtk_snapshot_append_linear_gradient (snapshot,
|
||||
&GRAPHENE_RECT_INIT (0, 0, width, height),
|
||||
&GRAPHENE_POINT_INIT (0, 0),
|
||||
&GRAPHENE_POINT_INIT (width, 0),
|
||||
(GskColorStop[2]) {
|
||||
{ MAX (0.0, self->progress - 5.0 / width), { 1, 1, 1, 1 } },
|
||||
{ MIN (1.0, self->progress + 5.0 / width), { 0, 0, 0, 1 } }
|
||||
}, 2);
|
||||
gtk_snapshot_pop (snapshot);
|
||||
demo4_widget_snapshot_content (widget, snapshot, GSK_MASK_MODE_ALPHA);
|
||||
gtk_snapshot_pop (snapshot);
|
||||
}
|
||||
|
||||
static void
|
||||
demo4_widget_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
Demo4Widget *self = DEMO4_WIDGET (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_PROGRESS:
|
||||
self->progress = g_value_get_double (value);
|
||||
gtk_widget_queue_draw (GTK_WIDGET (object));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
demo4_widget_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
Demo4Widget *self = DEMO4_WIDGET (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_PROGRESS:
|
||||
g_value_set_double (value, self->progress);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
demo4_widget_class_init (Demo4WidgetClass *class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
||||
|
||||
object_class->dispose = demo4_widget_dispose;
|
||||
object_class->get_property = demo4_widget_get_property;
|
||||
object_class->set_property = demo4_widget_set_property;
|
||||
|
||||
widget_class->snapshot = demo4_widget_snapshot;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_PROGRESS,
|
||||
g_param_spec_double ("progress", NULL, NULL,
|
||||
0.0, 1.0, 0.5,
|
||||
G_PARAM_READWRITE));
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
demo4_widget_new (void)
|
||||
{
|
||||
return g_object_new (DEMO4_TYPE_WIDGET, NULL);
|
||||
}
|
||||
|
@@ -1,8 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#define DEMO4_TYPE_WIDGET (demo4_widget_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (Demo4Widget, demo4_widget, DEMO4, WIDGET, GtkWidget)
|
||||
|
||||
GtkWidget * demo4_widget_new (void);
|
@@ -8,8 +8,6 @@
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
static GtkWidget *window = NULL;
|
||||
static GtkWidget *entry1 = NULL;
|
||||
static GtkWidget *entry2 = NULL;
|
||||
@@ -29,7 +27,7 @@ message_dialog_clicked (GtkButton *button,
|
||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
||||
ngettext ("Has been shown once", "Has been shown %d times", i), i);
|
||||
g_signal_connect (dialog, "response", G_CALLBACK (gtk_window_destroy), NULL);
|
||||
gtk_window_present (GTK_WINDOW (dialog));
|
||||
gtk_widget_show (dialog);
|
||||
i++;
|
||||
}
|
||||
|
||||
@@ -116,7 +114,7 @@ interactive_dialog_clicked (GtkButton *button,
|
||||
data, (GClosureNotify) g_free,
|
||||
0);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (dialog));
|
||||
gtk_widget_show (dialog);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
@@ -186,7 +184,7 @@ do_dialog (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -70,7 +70,7 @@ set_color (CanvasItem *item,
|
||||
css = g_strdup_printf ("#%s { background: %s; }", name, str);
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_string (provider, css);
|
||||
gtk_css_provider_load_from_data (provider, css, -1);
|
||||
gtk_style_context_add_provider_for_display (gtk_widget_get_display (item->label), GTK_STYLE_PROVIDER (provider), 700);
|
||||
item->provider = GTK_STYLE_PROVIDER (provider);
|
||||
|
||||
@@ -109,21 +109,15 @@ static void
|
||||
apply_transform (CanvasItem *item)
|
||||
{
|
||||
GskTransform *transform;
|
||||
graphene_rect_t bounds;
|
||||
double x, y;
|
||||
|
||||
/* Add css padding and margin */
|
||||
if (!gtk_widget_compute_bounds (item->label, item->label, &bounds))
|
||||
return;
|
||||
|
||||
x = bounds.size.width / 2.;
|
||||
y = bounds.size.height / 2.;
|
||||
|
||||
item->r = sqrt (x * x + y * y);
|
||||
x = gtk_widget_get_allocated_width (item->label) / 2.0;
|
||||
y = gtk_widget_get_allocated_height (item->label) / 2.0;
|
||||
item->r = sqrt (x*x + y*y);
|
||||
|
||||
transform = gsk_transform_translate (NULL, &(graphene_point_t) { item->r, item->r });
|
||||
transform = gsk_transform_rotate (transform, item->angle + item->delta);
|
||||
transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (-x, -y));
|
||||
transform = gsk_transform_translate (transform, &(graphene_point_t) { -x, -y });
|
||||
|
||||
gtk_fixed_set_child_transform (GTK_FIXED (item->fixed), item->label, transform);
|
||||
gsk_transform_unref (transform);
|
||||
@@ -330,7 +324,7 @@ canvas_item_start_editing (CanvasItem *item)
|
||||
GtkWidget *canvas = gtk_widget_get_parent (GTK_WIDGET (item));
|
||||
GtkWidget *entry;
|
||||
GtkWidget *scale;
|
||||
graphene_point_t p;
|
||||
double x, y;
|
||||
|
||||
if (item->editor)
|
||||
return;
|
||||
@@ -356,17 +350,12 @@ canvas_item_start_editing (CanvasItem *item)
|
||||
|
||||
gtk_box_append (GTK_BOX (item->editor), scale);
|
||||
|
||||
if (!gtk_widget_compute_point (GTK_WIDGET (item), canvas, &GRAPHENE_POINT_INIT (0, 0), &p))
|
||||
graphene_point_init (&p, 0, 0);
|
||||
gtk_fixed_put (GTK_FIXED (canvas), item->editor, p.x, p.y + 2 * item->r);
|
||||
gtk_widget_translate_coordinates (GTK_WIDGET (item), canvas, 0, 0, &x, &y);
|
||||
gtk_fixed_put (GTK_FIXED (canvas), item->editor, x, y + 2 * item->r);
|
||||
gtk_widget_grab_focus (entry);
|
||||
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
double x, y;
|
||||
} Hotspot;
|
||||
|
||||
static GdkContentProvider *
|
||||
prepare (GtkDragSource *source,
|
||||
double x,
|
||||
@@ -374,8 +363,6 @@ prepare (GtkDragSource *source,
|
||||
{
|
||||
GtkWidget *canvas;
|
||||
GtkWidget *item;
|
||||
Hotspot *hotspot;
|
||||
graphene_point_t p;
|
||||
|
||||
canvas = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (source));
|
||||
item = gtk_widget_pick (canvas, x, y, GTK_PICK_DEFAULT);
|
||||
@@ -386,13 +373,6 @@ prepare (GtkDragSource *source,
|
||||
|
||||
g_object_set_data (G_OBJECT (canvas), "dragged-item", item);
|
||||
|
||||
hotspot = g_new (Hotspot, 1);
|
||||
if (!gtk_widget_compute_point (canvas, item, &GRAPHENE_POINT_INIT (x, y), &p))
|
||||
graphene_point_init (&p, x, y);
|
||||
hotspot->x = p.x;
|
||||
hotspot->y = p.y;
|
||||
g_object_set_data_full (G_OBJECT (canvas), "hotspot", hotspot, g_free);
|
||||
|
||||
return gdk_content_provider_new_typed (GTK_TYPE_WIDGET, item);
|
||||
}
|
||||
|
||||
@@ -403,14 +383,12 @@ drag_begin (GtkDragSource *source,
|
||||
GtkWidget *canvas;
|
||||
CanvasItem *item;
|
||||
GdkPaintable *paintable;
|
||||
Hotspot *hotspot;
|
||||
|
||||
canvas = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (source));
|
||||
item = CANVAS_ITEM (g_object_get_data (G_OBJECT (canvas), "dragged-item"));
|
||||
hotspot = (Hotspot *) g_object_get_data (G_OBJECT (canvas), "hotspot");
|
||||
|
||||
paintable = canvas_item_get_drag_icon (item);
|
||||
gtk_drag_source_set_icon (source, paintable, hotspot->x, hotspot->y);
|
||||
gtk_drag_source_set_icon (source, paintable, item->r, item->r);
|
||||
g_object_unref (paintable);
|
||||
|
||||
gtk_widget_set_opacity (GTK_WIDGET (item), 0.3);
|
||||
@@ -748,9 +726,7 @@ do_dnd (GtkWidget *do_widget)
|
||||
GtkCssProvider *provider;
|
||||
GString *css;
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
button = gtk_color_button_new ();
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
g_object_unref (g_object_ref_sink (button));
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
@@ -765,7 +741,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
g_string_append_printf (css, ".canvasitem.%s { background: %s; }\n", colors[i], colors[i]);
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_string (provider, css->str);
|
||||
gtk_css_provider_load_from_data (provider, css->str, css->len);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
800);
|
||||
@@ -824,7 +800,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -334,17 +334,11 @@ do_drawingarea (GtkWidget *do_widget)
|
||||
gtk_widget_set_vexpand (frame, TRUE);
|
||||
gtk_box_append (GTK_BOX (vbox), frame);
|
||||
|
||||
da = g_object_new (GTK_TYPE_DRAWING_AREA,
|
||||
"accessible-role", GTK_ACCESSIBLE_ROLE_IMG,
|
||||
NULL);
|
||||
gtk_frame_set_child (GTK_FRAME (frame), da);
|
||||
gtk_accessible_update_relation (GTK_ACCESSIBLE (da),
|
||||
GTK_ACCESSIBLE_RELATION_LABELLED_BY, label, NULL,
|
||||
-1);
|
||||
|
||||
da = gtk_drawing_area_new ();
|
||||
gtk_drawing_area_set_content_width (GTK_DRAWING_AREA (da), 100);
|
||||
gtk_drawing_area_set_content_height (GTK_DRAWING_AREA (da), 100);
|
||||
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (da), groups_draw, NULL, NULL);
|
||||
gtk_frame_set_child (GTK_FRAME (frame), da);
|
||||
|
||||
/*
|
||||
* Create the scribble area
|
||||
@@ -358,23 +352,17 @@ do_drawingarea (GtkWidget *do_widget)
|
||||
gtk_widget_set_vexpand (frame, TRUE);
|
||||
gtk_box_append (GTK_BOX (vbox), frame);
|
||||
|
||||
da = g_object_new (GTK_TYPE_DRAWING_AREA,
|
||||
"accessible-role", GTK_ACCESSIBLE_ROLE_IMG,
|
||||
NULL);
|
||||
gtk_frame_set_child (GTK_FRAME (frame), da);
|
||||
gtk_accessible_update_relation (GTK_ACCESSIBLE (da),
|
||||
GTK_ACCESSIBLE_RELATION_LABELLED_BY, label, NULL,
|
||||
-1);
|
||||
|
||||
da = gtk_drawing_area_new ();
|
||||
gtk_drawing_area_set_content_width (GTK_DRAWING_AREA (da), 100);
|
||||
gtk_drawing_area_set_content_height (GTK_DRAWING_AREA (da), 100);
|
||||
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (da), scribble_draw, NULL, NULL);
|
||||
gtk_frame_set_child (GTK_FRAME (frame), da);
|
||||
|
||||
g_signal_connect (da, "resize",
|
||||
G_CALLBACK (scribble_resize), NULL);
|
||||
|
||||
drag = gtk_gesture_drag_new ();
|
||||
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (drag), 0);
|
||||
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (drag), GDK_BUTTON_PRIMARY);
|
||||
gtk_widget_add_controller (da, GTK_EVENT_CONTROLLER (drag));
|
||||
|
||||
g_signal_connect (drag, "drag-begin", G_CALLBACK (drag_begin), da);
|
||||
@@ -384,7 +372,7 @@ do_drawingarea (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_window_present (GTK_WINDOW (window));
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -164,14 +164,14 @@ strings_bind_item (GtkSignalListItemFactory *factory,
|
||||
popup = gtk_widget_get_ancestor (title, GTK_TYPE_POPOVER);
|
||||
if (popup && gtk_widget_is_ancestor (popup, GTK_WIDGET (dropdown)))
|
||||
{
|
||||
gtk_widget_set_visible (checkmark, TRUE);
|
||||
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_set_visible (checkmark, FALSE);
|
||||
gtk_widget_hide (checkmark);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,40 +368,8 @@ match_func (MatchObject *obj,
|
||||
g_free (tmp2);
|
||||
}
|
||||
|
||||
static void
|
||||
setup_header (GtkSignalListItemFactory *factory,
|
||||
GObject *list_item,
|
||||
gpointer data)
|
||||
{
|
||||
GtkListHeader *self = GTK_LIST_HEADER (list_item);
|
||||
GtkWidget *child;
|
||||
|
||||
child = gtk_label_new ("");
|
||||
gtk_label_set_xalign (GTK_LABEL (child), 0);
|
||||
gtk_label_set_use_markup (GTK_LABEL (child), TRUE);
|
||||
gtk_widget_set_margin_top (child, 10);
|
||||
gtk_widget_set_margin_bottom (child, 10);
|
||||
|
||||
gtk_list_header_set_child (self, child);
|
||||
}
|
||||
|
||||
static void
|
||||
bind_header (GtkSignalListItemFactory *factory,
|
||||
GObject *list_item,
|
||||
gpointer data)
|
||||
{
|
||||
GtkListHeader *self = GTK_LIST_HEADER (list_item);
|
||||
GtkWidget *child = gtk_list_header_get_child (self);
|
||||
GObject *item = gtk_list_header_get_item (self);
|
||||
|
||||
if (strstr (gtk_string_object_get_string (GTK_STRING_OBJECT (item)), "hour"))
|
||||
gtk_label_set_label (GTK_LABEL (child), "<big><b>Hours</b></big>");
|
||||
else
|
||||
gtk_label_set_label (GTK_LABEL (child), "<big><b>Minutes</b></big>");
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_listview_selections (GtkWidget *do_widget)
|
||||
do_dropdown (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
GtkWidget *button, *box, *spin, *check, *hbox, *label, *entry;
|
||||
@@ -409,12 +377,10 @@ do_listview_selections (GtkWidget *do_widget)
|
||||
GtkExpression *expression;
|
||||
GtkListItemFactory *factory;
|
||||
const char * const times[] = { "1 minute", "2 minutes", "5 minutes", "20 minutes", NULL };
|
||||
const char * const minutes[] = {
|
||||
const char * const many_times[] = {
|
||||
"1 minute", "2 minutes", "5 minutes", "10 minutes", "15 minutes", "20 minutes",
|
||||
"25 minutes", "30 minutes", "35 minutes", "40 minutes", "45 minutes", "50 minutes",
|
||||
"55 minutes", NULL
|
||||
};
|
||||
const char * const hours[] = { "1 hour", "2 hours", "3 hours", "5 hours", "6 hours", "7 hours",
|
||||
"55 minutes", "1 hour", "2 hours", "3 hours", "5 hours", "6 hours", "7 hours",
|
||||
"8 hours", "9 hours", "10 hours", "11 hours", "12 hours", NULL
|
||||
};
|
||||
const char * const device_titles[] = { "Digital Output", "Headphones", "Digital Output", "Analog Output", NULL };
|
||||
@@ -429,10 +395,6 @@ do_listview_selections (GtkWidget *do_widget)
|
||||
|
||||
if (!window)
|
||||
{
|
||||
GtkStringList *minutes_model, *hours_model;
|
||||
GListStore *store;
|
||||
GtkFlattenListModel *flat;
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
@@ -460,25 +422,14 @@ do_listview_selections (GtkWidget *do_widget)
|
||||
gtk_box_append (GTK_BOX (box), button);
|
||||
|
||||
/* A dropdown using an expression to obtain strings */
|
||||
minutes_model = gtk_string_list_new (minutes);
|
||||
hours_model = gtk_string_list_new (hours);
|
||||
store = g_list_store_new (G_TYPE_LIST_MODEL);
|
||||
g_list_store_append (store, minutes_model);
|
||||
g_list_store_append (store, hours_model);
|
||||
g_object_unref (minutes_model);
|
||||
g_object_unref (hours_model);
|
||||
flat = gtk_flatten_list_model_new (G_LIST_MODEL (store));
|
||||
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);
|
||||
button = gtk_drop_down_new (G_LIST_MODEL (flat), expression);
|
||||
gtk_drop_down_set_enable_search (GTK_DROP_DOWN (button), TRUE);
|
||||
factory = gtk_signal_list_item_factory_new ();
|
||||
g_signal_connect (factory, "setup", G_CALLBACK (setup_header), NULL);
|
||||
g_signal_connect (factory, "bind", G_CALLBACK (bind_header), NULL);
|
||||
gtk_drop_down_set_header_factory (GTK_DROP_DOWN (button), factory);
|
||||
g_object_unref (factory);
|
||||
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);
|
||||
@@ -612,7 +563,7 @@ do_listview_selections (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
@@ -409,7 +409,7 @@ do_editable_cells (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -95,13 +95,6 @@ do_entry_completion (GtkWidget *do_widget)
|
||||
entry = gtk_entry_new ();
|
||||
gtk_box_append (GTK_BOX (vbox), entry);
|
||||
|
||||
gtk_accessible_update_relation (GTK_ACCESSIBLE (entry),
|
||||
GTK_ACCESSIBLE_RELATION_LABELLED_BY, label, NULL,
|
||||
-1);
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (entry),
|
||||
GTK_ACCESSIBLE_PROPERTY_AUTOCOMPLETE, GTK_ACCESSIBLE_AUTOCOMPLETE_LIST,
|
||||
-1);
|
||||
|
||||
/* Create the completion object */
|
||||
completion = gtk_entry_completion_new ();
|
||||
|
||||
@@ -122,7 +115,7 @@ do_entry_completion (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -43,14 +43,10 @@ do_entry_undo (GtkWidget *do_widget)
|
||||
entry = gtk_entry_new ();
|
||||
gtk_editable_set_enable_undo (GTK_EDITABLE (entry), TRUE);
|
||||
gtk_box_append (GTK_BOX (vbox), entry);
|
||||
|
||||
gtk_accessible_update_relation (GTK_ACCESSIBLE (entry),
|
||||
GTK_ACCESSIBLE_RELATION_LABELLED_BY, label, NULL,
|
||||
-1);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -22,15 +22,11 @@ validate_more_details (GtkEntry *entry,
|
||||
{
|
||||
gtk_widget_set_tooltip_text (GTK_WIDGET (entry), "Must have details first");
|
||||
gtk_widget_add_css_class (GTK_WIDGET (entry), "error");
|
||||
gtk_accessible_update_state (GTK_ACCESSIBLE (entry),
|
||||
GTK_ACCESSIBLE_STATE_INVALID, GTK_ACCESSIBLE_INVALID_TRUE,
|
||||
-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_set_tooltip_text (GTK_WIDGET (entry), "");
|
||||
gtk_widget_remove_css_class (GTK_WIDGET (entry), "error");
|
||||
gtk_accessible_reset_state (GTK_ACCESSIBLE (entry), GTK_ACCESSIBLE_STATE_INVALID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,20 +42,12 @@ mode_switch_state_set (GtkSwitch *sw,
|
||||
if (!state ||
|
||||
(gtk_range_get_value (GTK_RANGE (scale)) > 50))
|
||||
{
|
||||
gtk_widget_set_visible (label, FALSE);
|
||||
gtk_widget_hide (label);
|
||||
gtk_switch_set_state (sw, state);
|
||||
gtk_accessible_reset_relation (GTK_ACCESSIBLE (sw), GTK_ACCESSIBLE_RELATION_ERROR_MESSAGE);
|
||||
gtk_accessible_reset_state (GTK_ACCESSIBLE (sw), GTK_ACCESSIBLE_STATE_INVALID);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_set_visible (label, TRUE);
|
||||
gtk_accessible_update_relation (GTK_ACCESSIBLE (sw),
|
||||
GTK_ACCESSIBLE_RELATION_ERROR_MESSAGE, label,
|
||||
-1);
|
||||
gtk_accessible_update_state (GTK_ACCESSIBLE (sw),
|
||||
GTK_ACCESSIBLE_STATE_INVALID, GTK_ACCESSIBLE_INVALID_TRUE,
|
||||
-1);
|
||||
gtk_widget_show (label);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -77,7 +65,7 @@ level_scale_value_changed (GtkRange *range,
|
||||
!gtk_switch_get_state (GTK_SWITCH (sw)) &&
|
||||
(gtk_range_get_value (range) > 50))
|
||||
{
|
||||
gtk_widget_set_visible (label, FALSE);
|
||||
gtk_widget_hide (label);
|
||||
gtk_switch_set_state (GTK_SWITCH (sw), TRUE);
|
||||
}
|
||||
else if (gtk_switch_get_state (GTK_SWITCH (sw)) &&
|
||||
@@ -85,9 +73,6 @@ level_scale_value_changed (GtkRange *range,
|
||||
{
|
||||
gtk_switch_set_state (GTK_SWITCH (sw), FALSE);
|
||||
}
|
||||
|
||||
gtk_accessible_reset_relation (GTK_ACCESSIBLE (sw), GTK_ACCESSIBLE_RELATION_ERROR_MESSAGE);
|
||||
gtk_accessible_reset_state (GTK_ACCESSIBLE (sw), GTK_ACCESSIBLE_STATE_INVALID);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
@@ -128,7 +113,7 @@ do_errorstates (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -10,8 +10,6 @@
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
static GtkWidget *window = NULL;
|
||||
|
||||
static void
|
||||
@@ -122,7 +120,7 @@ do_expander (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -199,7 +199,7 @@ do_filtermodel (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -68,13 +68,11 @@ create_blurred_button (void)
|
||||
return w;
|
||||
}
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
static GtkWidget *
|
||||
create_font_button (void)
|
||||
{
|
||||
return gtk_font_button_new ();
|
||||
}
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
static GtkWidget *
|
||||
create_level_bar (void)
|
||||
@@ -301,7 +299,7 @@ do_fishbowl (GtkWidget *do_widget)
|
||||
if (provider == NULL)
|
||||
{
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_string (provider, css);
|
||||
gtk_css_provider_load_from_data (provider, css, -1);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
@@ -329,7 +327,7 @@ do_fishbowl (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -160,7 +160,7 @@ do_fixed (GtkWidget *do_widget)
|
||||
demo_window = create_demo_window (do_widget);
|
||||
|
||||
if (!gtk_widget_get_visible (demo_window))
|
||||
gtk_widget_set_visible (demo_window, TRUE);
|
||||
gtk_widget_show (demo_window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (demo_window));
|
||||
|
||||
|
@@ -742,7 +742,7 @@ do_flowbox (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -21,8 +21,6 @@
|
||||
#include "script-names.h"
|
||||
#include "language-names.h"
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
/* {{{ ScriptLang object */
|
||||
|
||||
G_DECLARE_FINAL_TYPE (ScriptLang, script_lang, SCRIPT, LANG, GObject)
|
||||
@@ -258,10 +256,10 @@ swap_colors (void)
|
||||
GdkRGBA fg;
|
||||
GdkRGBA bg;
|
||||
|
||||
fg = *gtk_color_dialog_button_get_rgba (GTK_COLOR_DIALOG_BUTTON (demo->foreground));
|
||||
bg = *gtk_color_dialog_button_get_rgba (GTK_COLOR_DIALOG_BUTTON (demo->background));
|
||||
gtk_color_dialog_button_set_rgba (GTK_COLOR_DIALOG_BUTTON (demo->foreground), &bg);
|
||||
gtk_color_dialog_button_set_rgba (GTK_COLOR_DIALOG_BUTTON (demo->background), &fg);
|
||||
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (demo->foreground), &fg);
|
||||
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (demo->background), &bg);
|
||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (demo->foreground), &bg);
|
||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (demo->background), &fg);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -270,8 +268,8 @@ font_features_reset_basic (void)
|
||||
gtk_adjustment_set_value (demo->size_adjustment, 20);
|
||||
gtk_adjustment_set_value (demo->letterspacing_adjustment, 0);
|
||||
gtk_adjustment_set_value (demo->line_height_adjustment, 1);
|
||||
gtk_color_dialog_button_set_rgba (GTK_COLOR_DIALOG_BUTTON (demo->foreground), &(GdkRGBA){0.,0.,0.,1.});
|
||||
gtk_color_dialog_button_set_rgba (GTK_COLOR_DIALOG_BUTTON (demo->background), &(GdkRGBA){1.,1.,1.,1.});
|
||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (demo->foreground), &(GdkRGBA){0.,0.,0.,1.});
|
||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (demo->background), &(GdkRGBA){1.,1.,1.,1.});
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -279,7 +277,7 @@ update_basic (void)
|
||||
{
|
||||
PangoFontDescription *desc;
|
||||
|
||||
desc = gtk_font_dialog_button_get_font_desc (GTK_FONT_DIALOG_BUTTON (demo->font));
|
||||
desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (demo->font));
|
||||
|
||||
gtk_adjustment_set_value (demo->size_adjustment,
|
||||
pango_font_description_get_size (desc) / (double) PANGO_SCALE);
|
||||
@@ -590,7 +588,7 @@ update_display (void)
|
||||
end = PANGO_ATTR_INDEX_TO_TEXT_END;
|
||||
}
|
||||
|
||||
desc = gtk_font_dialog_button_get_font_desc (GTK_FONT_DIALOG_BUTTON (demo->font));
|
||||
desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (demo->font));
|
||||
|
||||
value = gtk_adjustment_get_value (demo->size_adjustment);
|
||||
pango_font_description_set_size (desc, value * PANGO_SCALE);
|
||||
@@ -681,7 +679,7 @@ update_display (void)
|
||||
GdkRGBA rgba;
|
||||
char *fg, *bg, *css;
|
||||
|
||||
rgba = *gtk_color_dialog_button_get_rgba (GTK_COLOR_DIALOG_BUTTON (demo->foreground));
|
||||
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (demo->foreground), &rgba);
|
||||
attr = pango_attr_foreground_new (65535 * rgba.red,
|
||||
65535 * rgba.green,
|
||||
65535 * rgba.blue);
|
||||
@@ -694,7 +692,7 @@ update_display (void)
|
||||
pango_attr_list_insert (attrs, attr);
|
||||
|
||||
fg = gdk_rgba_to_string (&rgba);
|
||||
rgba = *gtk_color_dialog_button_get_rgba (GTK_COLOR_DIALOG_BUTTON (demo->background));
|
||||
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (demo->background), &rgba);
|
||||
bg = gdk_rgba_to_string (&rgba);
|
||||
css = g_strdup_printf (".font_features_background { caret-color: %s; background-color: %s; }", fg, bg);
|
||||
gtk_css_provider_load_from_data (demo->provider, css, strlen (css));
|
||||
@@ -769,6 +767,7 @@ update_display (void)
|
||||
gtk_label_set_attributes (GTK_LABEL (demo->the_label), attrs);
|
||||
|
||||
g_free (font_desc);
|
||||
pango_font_description_free (desc);
|
||||
g_free (features);
|
||||
pango_attr_list_unref (attrs);
|
||||
g_free (text);
|
||||
@@ -780,7 +779,7 @@ get_pango_font (void)
|
||||
PangoFontDescription *desc;
|
||||
PangoContext *context;
|
||||
|
||||
desc = gtk_font_dialog_button_get_font_desc (GTK_FONT_DIALOG_BUTTON (demo->font));
|
||||
desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (demo->font));
|
||||
context = gtk_widget_get_pango_context (demo->font);
|
||||
|
||||
return pango_context_load_font (context, desc);
|
||||
@@ -832,17 +831,17 @@ update_script_combo (void)
|
||||
GHashTable *tags;
|
||||
GHashTableIter iter;
|
||||
TagPair *pair;
|
||||
PangoLanguage *language;
|
||||
const char *lang;
|
||||
char *lang;
|
||||
hb_tag_t active;
|
||||
|
||||
language = gtk_font_dialog_button_get_language (GTK_FONT_DIALOG_BUTTON (demo->font));
|
||||
lang = pango_language_to_string (language);
|
||||
lang = gtk_font_chooser_get_language (GTK_FONT_CHOOSER (demo->font));
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
active = hb_ot_tag_from_language (hb_language_from_string (lang, -1));
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
g_free (lang);
|
||||
|
||||
store = g_list_store_new (script_lang_get_type ());
|
||||
|
||||
pango_font = get_pango_font ();
|
||||
@@ -855,6 +854,11 @@ update_script_combo (void)
|
||||
pair->lang_tag = 0;
|
||||
g_hash_table_add (tags, pair);
|
||||
|
||||
pair = g_new (TagPair, 1);
|
||||
pair->script_tag = HB_OT_TAG_DEFAULT_SCRIPT;
|
||||
pair->lang_tag = HB_OT_TAG_DEFAULT_LANGUAGE;
|
||||
g_hash_table_add (tags, pair);
|
||||
|
||||
if (hb_font)
|
||||
{
|
||||
hb_tag_t tables[2] = { HB_OT_TAG_GSUB, HB_OT_TAG_GPOS };
|
||||
@@ -966,6 +970,9 @@ update_features (void)
|
||||
|
||||
/* set feature presence checks from the font features */
|
||||
|
||||
if (gtk_drop_down_get_selected (GTK_DROP_DOWN (demo->script_lang)) == 0)
|
||||
return;
|
||||
|
||||
selected = gtk_drop_down_get_selected_item (GTK_DROP_DOWN (demo->script_lang));
|
||||
|
||||
if (selected->lang_tag == 0) /* None is selected */
|
||||
@@ -973,8 +980,8 @@ update_features (void)
|
||||
for (l = demo->feature_items; l; l = l->next)
|
||||
{
|
||||
FeatureItem *item = l->data;
|
||||
gtk_widget_set_visible (item->feat, TRUE);
|
||||
gtk_widget_set_visible (gtk_widget_get_parent (item->feat), TRUE);
|
||||
gtk_widget_show (item->feat);
|
||||
gtk_widget_show (gtk_widget_get_parent (item->feat));
|
||||
if (strcmp (item->name, "xxxx") == 0)
|
||||
gtk_check_button_set_active (GTK_CHECK_BUTTON (item->feat), TRUE);
|
||||
}
|
||||
@@ -985,8 +992,8 @@ update_features (void)
|
||||
for (l = demo->feature_items; l; l = l->next)
|
||||
{
|
||||
FeatureItem *item = l->data;
|
||||
gtk_widget_set_visible (item->feat, FALSE);
|
||||
gtk_widget_set_visible (gtk_widget_get_parent (item->feat), FALSE);
|
||||
gtk_widget_hide (item->feat);
|
||||
gtk_widget_hide (gtk_widget_get_parent (item->feat));
|
||||
if (strcmp (item->name, "xxxx") == 0)
|
||||
gtk_check_button_set_active (GTK_CHECK_BUTTON (item->feat), TRUE);
|
||||
}
|
||||
@@ -994,13 +1001,11 @@ update_features (void)
|
||||
pango_font = get_pango_font ();
|
||||
hb_font = pango_font_get_hb_font (pango_font);
|
||||
|
||||
g_print ("language %s\n", selected->langname);
|
||||
|
||||
if (hb_font)
|
||||
{
|
||||
hb_tag_t tables[2] = { HB_OT_TAG_GSUB, HB_OT_TAG_GPOS };
|
||||
hb_face_t *hb_face;
|
||||
const char *feat;
|
||||
char *feat;
|
||||
|
||||
hb_face = hb_font_get_face (hb_font);
|
||||
|
||||
@@ -1022,6 +1027,9 @@ update_features (void)
|
||||
char buf[5];
|
||||
hb_tag_to_string (features[j], buf);
|
||||
buf[4] = 0;
|
||||
#if 0
|
||||
g_print ("%s present in %s\n", buf, i == 0 ? "GSUB" : "GPOS");
|
||||
#endif
|
||||
|
||||
if (g_str_has_prefix (buf, "ss") || g_str_has_prefix (buf, "cv"))
|
||||
{
|
||||
@@ -1071,15 +1079,15 @@ update_features (void)
|
||||
|
||||
if (item->tag == features[j])
|
||||
{
|
||||
gtk_widget_set_visible (item->feat, TRUE);
|
||||
gtk_widget_set_visible (gtk_widget_get_parent (item->feat), TRUE);
|
||||
gtk_widget_show (item->feat);
|
||||
gtk_widget_show (gtk_widget_get_parent (item->feat));
|
||||
if (GTK_IS_CHECK_BUTTON (item->feat))
|
||||
{
|
||||
GtkWidget *def = GTK_WIDGET (g_object_get_data (G_OBJECT (item->feat), "default"));
|
||||
if (def)
|
||||
{
|
||||
gtk_widget_set_visible (def, TRUE);
|
||||
gtk_widget_set_visible (gtk_widget_get_parent (def), TRUE);
|
||||
gtk_widget_show (def);
|
||||
gtk_widget_show (gtk_widget_get_parent (def));
|
||||
gtk_check_button_set_active (GTK_CHECK_BUTTON (def), TRUE);
|
||||
}
|
||||
else
|
||||
@@ -1090,7 +1098,7 @@ update_features (void)
|
||||
}
|
||||
}
|
||||
|
||||
feat = gtk_font_dialog_button_get_font_features (GTK_FONT_DIALOG_BUTTON (demo->font));
|
||||
feat = gtk_font_chooser_get_font_features (GTK_FONT_CHOOSER (demo->font));
|
||||
if (feat)
|
||||
{
|
||||
for (l = demo->feature_items; l; l = l->next)
|
||||
@@ -1116,6 +1124,8 @@ update_features (void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_free (feat);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1294,18 +1304,18 @@ add_axis (hb_face_t *hb_face,
|
||||
|
||||
axis_label = gtk_label_new (name);
|
||||
gtk_widget_set_halign (axis_label, GTK_ALIGN_START);
|
||||
gtk_widget_set_valign (axis_label, GTK_ALIGN_BASELINE_FILL);
|
||||
gtk_widget_set_valign (axis_label, GTK_ALIGN_BASELINE);
|
||||
gtk_grid_attach (GTK_GRID (demo->variations_grid), axis_label, 0, i, 1, 1);
|
||||
adjustment = gtk_adjustment_new (value, ax->min_value, ax->max_value,
|
||||
1.0, 10.0, 0.0);
|
||||
axis_scale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, adjustment);
|
||||
gtk_scale_add_mark (GTK_SCALE (axis_scale), ax->default_value, GTK_POS_TOP, NULL);
|
||||
gtk_widget_set_valign (axis_scale, GTK_ALIGN_BASELINE_FILL);
|
||||
gtk_widget_set_valign (axis_scale, GTK_ALIGN_BASELINE);
|
||||
gtk_widget_set_hexpand (axis_scale, TRUE);
|
||||
gtk_widget_set_size_request (axis_scale, 100, -1);
|
||||
gtk_grid_attach (GTK_GRID (demo->variations_grid), axis_scale, 1, i, 1, 1);
|
||||
axis_entry = gtk_entry_new ();
|
||||
gtk_widget_set_valign (axis_entry, GTK_ALIGN_BASELINE_FILL);
|
||||
gtk_widget_set_valign (axis_entry, GTK_ALIGN_BASELINE);
|
||||
gtk_editable_set_width_chars (GTK_EDITABLE (axis_entry), 4);
|
||||
gtk_editable_set_max_width_chars (GTK_EDITABLE (axis_entry), 4);
|
||||
gtk_widget_set_hexpand (axis_entry, FALSE);
|
||||
@@ -1413,7 +1423,10 @@ instance_changed (GtkDropDown *combo)
|
||||
ikey.name = (char *) text;
|
||||
instance = g_hash_table_lookup (demo->instances, &ikey);
|
||||
if (!instance)
|
||||
goto out;
|
||||
{
|
||||
g_print ("did not find instance %s\n", text);
|
||||
goto out;
|
||||
}
|
||||
|
||||
pango_font = get_pango_font ();
|
||||
hb_font = pango_font_get_hb_font (pango_font);
|
||||
@@ -1562,14 +1575,14 @@ update_font_variations (void)
|
||||
label = gtk_label_new ("Instance");
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0);
|
||||
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
||||
gtk_widget_set_valign (label, GTK_ALIGN_BASELINE_FILL);
|
||||
gtk_widget_set_valign (label, GTK_ALIGN_BASELINE);
|
||||
gtk_grid_attach (GTK_GRID (demo->variations_grid), label, 0, -1, 1, 1);
|
||||
|
||||
strings = gtk_string_list_new (NULL);
|
||||
combo = gtk_drop_down_new (G_LIST_MODEL (strings), NULL);
|
||||
|
||||
gtk_widget_set_halign (combo, GTK_ALIGN_START);
|
||||
gtk_widget_set_valign (combo, GTK_ALIGN_BASELINE_FILL);
|
||||
gtk_widget_set_valign (combo, GTK_ALIGN_BASELINE);
|
||||
|
||||
gtk_string_list_append (strings, "");
|
||||
|
||||
@@ -1767,7 +1780,6 @@ do_font_features (GtkWidget *do_widget)
|
||||
demo->description = GTK_WIDGET (gtk_builder_get_object (builder, "description"));
|
||||
demo->font = GTK_WIDGET (gtk_builder_get_object (builder, "font"));
|
||||
demo->script_lang = GTK_WIDGET (gtk_builder_get_object (builder, "script_lang"));
|
||||
g_assert (GTK_IS_DROP_DOWN (demo->script_lang));
|
||||
expression = gtk_cclosure_expression_new (G_TYPE_STRING, NULL, 0, NULL, G_CALLBACK (script_lang_get_langname), NULL, NULL);
|
||||
gtk_drop_down_set_expression (GTK_DROP_DOWN (demo->script_lang), expression);
|
||||
gtk_expression_unref (expression);
|
||||
|
@@ -58,17 +58,11 @@
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkFontDialogButton" id="font">
|
||||
<accessibility>
|
||||
<property name="label">Font</property>
|
||||
</accessibility>
|
||||
<property name="dialog">
|
||||
<object class="GtkFontDialog">
|
||||
</object>
|
||||
</property>
|
||||
<object class="GtkFontButton" id="font">
|
||||
<property name="receives-default">1</property>
|
||||
<property name="level">face</property>
|
||||
<signal name="notify::font-desc" handler="font_features_font_changed" swapped="no"/>
|
||||
<property name="font">Sans 12</property>
|
||||
<property name="level">family|style</property>
|
||||
<signal name="font-set" handler="font_features_font_changed" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
@@ -76,7 +70,7 @@
|
||||
<property name="column-spacing">10</property>
|
||||
<property name="row-spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="size_label">
|
||||
<object class="GtkLabel">
|
||||
<property name="label">Size</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="valign">baseline</property>
|
||||
@@ -92,9 +86,6 @@
|
||||
<property name="width-request">100</property>
|
||||
<property name="valign">baseline</property>
|
||||
<property name="adjustment">size_adjustment</property>
|
||||
<accessibility>
|
||||
<relation name="labelled-by">size_label</relation>
|
||||
</accessibility>
|
||||
<layout>
|
||||
<property name="column">1</property>
|
||||
<property name="row">0</property>
|
||||
@@ -107,9 +98,6 @@
|
||||
<property name="max-width-chars">4</property>
|
||||
<property name="hexpand">0</property>
|
||||
<property name="valign">baseline</property>
|
||||
<accessibility>
|
||||
<relation name="labelled-by">size_label</relation>
|
||||
</accessibility>
|
||||
<signal name="activate" handler="basic_entry_activated"
|
||||
object="size_adjustment" swapped="false"/>
|
||||
<layout>
|
||||
@@ -119,7 +107,7 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="letterspacing_label">
|
||||
<object class="GtkLabel">
|
||||
<property name="label">Letterspacing</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="valign">baseline</property>
|
||||
@@ -135,9 +123,6 @@
|
||||
<property name="width-request">100</property>
|
||||
<property name="valign">baseline</property>
|
||||
<property name="adjustment">letterspacing_adjustment</property>
|
||||
<accessibility>
|
||||
<relation name="labelled-by">letterspacing_label</relation>
|
||||
</accessibility>
|
||||
<layout>
|
||||
<property name="column">1</property>
|
||||
<property name="row">1</property>
|
||||
@@ -150,9 +135,6 @@
|
||||
<property name="max-width-chars">4</property>
|
||||
<property name="hexpand">0</property>
|
||||
<property name="valign">baseline</property>
|
||||
<accessibility>
|
||||
<relation name="labelled-by">letterspacing_label</relation>
|
||||
</accessibility>
|
||||
<signal name="activate" handler="basic_entry_activated"
|
||||
object="letterspacing_adjustment" swapped="false"/>
|
||||
<layout>
|
||||
@@ -162,7 +144,7 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="line_height_label">
|
||||
<object class="GtkLabel">
|
||||
<property name="label">Line Height</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="valign">baseline</property>
|
||||
@@ -178,9 +160,6 @@
|
||||
<property name="width-request">100</property>
|
||||
<property name="valign">baseline</property>
|
||||
<property name="adjustment">line_height_adjustment</property>
|
||||
<accessibility>
|
||||
<relation name="labelled-by">line_height_label</relation>
|
||||
</accessibility>
|
||||
<layout>
|
||||
<property name="column">1</property>
|
||||
<property name="row">2</property>
|
||||
@@ -193,9 +172,6 @@
|
||||
<property name="max-width-chars">4</property>
|
||||
<property name="hexpand">0</property>
|
||||
<property name="valign">baseline</property>
|
||||
<accessibility>
|
||||
<relation name="labelled-by">line_height_label</relation>
|
||||
</accessibility>
|
||||
<signal name="activate" handler="basic_entry_activated"
|
||||
object="line_height_adjustment" swapped="false"/>
|
||||
<layout>
|
||||
@@ -205,7 +181,7 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="foreground_label">
|
||||
<object class="GtkLabel">
|
||||
<property name="label">Foreground</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="valign">baseline</property>
|
||||
@@ -216,16 +192,9 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkColorDialogButton" id="foreground">
|
||||
<property name="dialog">
|
||||
<object class="GtkColorDialog">
|
||||
</object>
|
||||
</property>
|
||||
<object class="GtkColorButton" id="foreground">
|
||||
<property name="valign">baseline</property>
|
||||
<property name="rgba">black</property>
|
||||
<accessibility>
|
||||
<relation name="labelled-by">foreground_label</relation>
|
||||
</accessibility>
|
||||
<signal name="notify::rgba" handler="color_set_cb"/>
|
||||
<layout>
|
||||
<property name="column">1</property>
|
||||
@@ -234,7 +203,7 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="background_label">
|
||||
<object class="GtkLabel">
|
||||
<property name="label">Background</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="valign">baseline</property>
|
||||
@@ -245,16 +214,9 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkColorDialogButton" id="background">
|
||||
<property name="dialog">
|
||||
<object class="GtkColorDialog">
|
||||
</object>
|
||||
</property>
|
||||
<object class="GtkColorButton" id="background">
|
||||
<property name="valign">baseline</property>
|
||||
<property name="rgba">white</property>
|
||||
<accessibility>
|
||||
<relation name="labelled-by">background_label</relation>
|
||||
</accessibility>
|
||||
<signal name="notify::rgba" handler="color_set_cb"/>
|
||||
<layout>
|
||||
<property name="column">1</property>
|
||||
@@ -267,9 +229,6 @@
|
||||
<property name="icon-name">object-flip-vertical-symbolic</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<accessibility>
|
||||
<property name="label">Swap colors</property>
|
||||
</accessibility>
|
||||
<style>
|
||||
<class name="circular"/>
|
||||
</style>
|
||||
@@ -371,9 +330,6 @@
|
||||
<property name="yalign">0</property>
|
||||
<property name="valign">start</property>
|
||||
<property name="selectable">1</property>
|
||||
<accessibility>
|
||||
<property name="label">Font example</property>
|
||||
</accessibility>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
@@ -383,9 +339,6 @@
|
||||
<property name="name">entry</property>
|
||||
<property name="child">
|
||||
<object class="GtkTextView" id="entry">
|
||||
<accessibility>
|
||||
<property name="label">Example text</property>
|
||||
</accessibility>
|
||||
<property name="buffer">
|
||||
<object class="GtkTextBuffer">
|
||||
<property name="text">Grumpy wizards make toxic brew for the evil Queen and Jack. A quick movement of the enemy will jeopardize six gunboats. The job of waxing linoleum frequently peeves chintzy kids. My girl wove six dozen plaid jackets before she quit. Twelve ziggurats quickly jumped a finch box.
|
||||
@@ -482,9 +435,6 @@
|
||||
<property name="icon-name">document-edit-symbolic</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">end</property>
|
||||
<accessibility>
|
||||
<property name="label">Edit text</property>
|
||||
</accessibility>
|
||||
<signal name="clicked" handler="font_features_toggle_edit"/>
|
||||
</object>
|
||||
</child>
|
||||
|
@@ -42,8 +42,8 @@ val_to_xy (GtkFontPlane *plane,
|
||||
double u, v;
|
||||
int width, height;
|
||||
|
||||
width = gtk_widget_get_width (GTK_WIDGET (plane));
|
||||
height = gtk_widget_get_height (GTK_WIDGET (plane));
|
||||
width = gtk_widget_get_allocated_width (GTK_WIDGET (plane));
|
||||
height = gtk_widget_get_allocated_height (GTK_WIDGET (plane));
|
||||
|
||||
u = adjustment_get_normalized_value (plane->width_adj);
|
||||
v = adjustment_get_normalized_value (plane->weight_adj);
|
||||
@@ -62,8 +62,8 @@ plane_snapshot (GtkWidget *widget,
|
||||
cairo_t *cr;
|
||||
|
||||
val_to_xy (plane, &x, &y);
|
||||
width = gtk_widget_get_width (widget);
|
||||
height = gtk_widget_get_height (widget);
|
||||
width = gtk_widget_get_allocated_width (widget);
|
||||
height = gtk_widget_get_allocated_height (widget);
|
||||
|
||||
cr = gtk_snapshot_append_cairo (snapshot,
|
||||
&GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||
@@ -131,8 +131,8 @@ update_value (GtkFontPlane *plane,
|
||||
GtkWidget *widget = GTK_WIDGET (plane);
|
||||
double u, v;
|
||||
|
||||
u = CLAMP (x * (1.0 / gtk_widget_get_width (widget)), 0, 1);
|
||||
v = CLAMP (1 - y * (1.0 / gtk_widget_get_height (widget)), 0, 1);
|
||||
u = CLAMP (x * (1.0 / gtk_widget_get_allocated_width (widget)), 0, 1);
|
||||
v = CLAMP (1 - y * (1.0 / gtk_widget_get_allocated_height (widget)), 0, 1);
|
||||
|
||||
adjustment_set_normalized_value (plane->width_adj, u);
|
||||
adjustment_set_normalized_value (plane->weight_adj, v);
|
||||
|
@@ -43,7 +43,6 @@ update_image (void)
|
||||
cairo_t *cr;
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkPixbuf *pixbuf2;
|
||||
GdkTexture *texture;
|
||||
cairo_font_options_t *fopt;
|
||||
cairo_hint_style_t hintstyle;
|
||||
cairo_hint_metrics_t hintmetrics;
|
||||
@@ -54,7 +53,7 @@ update_image (void)
|
||||
context = gtk_widget_create_pango_context (image);
|
||||
|
||||
text = gtk_editable_get_text (GTK_EDITABLE (entry));
|
||||
desc = gtk_font_dialog_button_get_font_desc (GTK_FONT_DIALOG_BUTTON (font_button));
|
||||
desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (font_button));
|
||||
|
||||
fopt = cairo_font_options_copy (pango_cairo_context_get_font_options (context));
|
||||
|
||||
@@ -121,17 +120,8 @@ update_image (void)
|
||||
cairo_destroy (cr);
|
||||
g_object_unref (layout);
|
||||
|
||||
pixbuf = gdk_pixbuf_new_from_data (cairo_image_surface_get_data (surface),
|
||||
GDK_COLORSPACE_RGB, TRUE, 8,
|
||||
cairo_image_surface_get_width (surface),
|
||||
cairo_image_surface_get_height (surface),
|
||||
cairo_image_surface_get_stride (surface),
|
||||
NULL, NULL);
|
||||
|
||||
pixbuf2 = gdk_pixbuf_scale_simple (pixbuf,
|
||||
gdk_pixbuf_get_width (pixbuf) * scale,
|
||||
gdk_pixbuf_get_height (pixbuf) * scale,
|
||||
GDK_INTERP_NEAREST);
|
||||
pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, cairo_image_surface_get_width (surface), cairo_image_surface_get_height (surface));
|
||||
pixbuf2 = gdk_pixbuf_scale_simple (pixbuf, gdk_pixbuf_get_width (pixbuf) * scale, gdk_pixbuf_get_height (pixbuf) * scale, GDK_INTERP_NEAREST);
|
||||
|
||||
g_object_unref (pixbuf);
|
||||
cairo_surface_destroy (surface);
|
||||
@@ -288,25 +278,17 @@ retry:
|
||||
pango_layout_iter_free (iter);
|
||||
g_object_unref (layout);
|
||||
|
||||
pixbuf = gdk_pixbuf_new_from_data (cairo_image_surface_get_data (surface),
|
||||
GDK_COLORSPACE_RGB, TRUE, 8,
|
||||
cairo_image_surface_get_width (surface),
|
||||
cairo_image_surface_get_height (surface),
|
||||
cairo_image_surface_get_stride (surface),
|
||||
NULL, NULL);
|
||||
|
||||
pixbuf2 = gdk_pixbuf_scale_simple (pixbuf,
|
||||
gdk_pixbuf_get_width (pixbuf) * scale,
|
||||
gdk_pixbuf_get_height (pixbuf) * scale,
|
||||
GDK_INTERP_NEAREST);
|
||||
pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, cairo_image_surface_get_width (surface), cairo_image_surface_get_height (surface));
|
||||
pixbuf2 = gdk_pixbuf_scale_simple (pixbuf, gdk_pixbuf_get_width (pixbuf) * scale, gdk_pixbuf_get_height (pixbuf) * scale, GDK_INTERP_NEAREST);
|
||||
g_object_unref (pixbuf);
|
||||
cairo_surface_destroy (surface);
|
||||
}
|
||||
|
||||
texture = gdk_texture_new_for_pixbuf (pixbuf2);
|
||||
gtk_picture_set_paintable (GTK_PICTURE (image), GDK_PAINTABLE (texture));
|
||||
gtk_picture_set_pixbuf (GTK_PICTURE (image), pixbuf2);
|
||||
|
||||
g_object_unref (pixbuf2);
|
||||
g_object_unref (texture);
|
||||
|
||||
pango_font_description_free (desc);
|
||||
}
|
||||
|
||||
static gboolean fading = FALSE;
|
||||
@@ -455,7 +437,7 @@ do_fontrendering (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -39,7 +39,7 @@
|
||||
<property name="row-spacing">10</property>
|
||||
<property name="column-spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="text_label">
|
||||
<object class="GtkLabel">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="label">Text</property>
|
||||
<property name="xalign">1</property>
|
||||
@@ -57,13 +57,10 @@
|
||||
<layout>
|
||||
<property name="column">2</property>
|
||||
</layout>
|
||||
<accessibility>
|
||||
<relation name="labelled-by">text_label</relation>
|
||||
</accessibility>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="font_label">
|
||||
<object class="GtkLabel">
|
||||
<property name="margin-start">10</property>
|
||||
<property name="label">Font</property>
|
||||
<property name="xalign">1</property>
|
||||
@@ -77,14 +74,7 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFontDialogButton" id="font_button">
|
||||
<accessibility>
|
||||
<relation name="labelled-by">font_label</relation>
|
||||
</accessibility>
|
||||
<property name="dialog">
|
||||
<object class="GtkFontDialog">
|
||||
</object>
|
||||
</property>
|
||||
<object class="GtkFontButton" id="font_button">
|
||||
<layout>
|
||||
<property name="column">2</property>
|
||||
<property name="row">1</property>
|
||||
@@ -192,9 +182,6 @@
|
||||
<property name="icon-name">list-add-symbolic</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<accessibility>
|
||||
<property name="label">Zoom in</property>
|
||||
</accessibility>
|
||||
<style>
|
||||
<class name="circular"/>
|
||||
</style>
|
||||
@@ -220,9 +207,6 @@
|
||||
<property name="icon-name">list-remove-symbolic</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<accessibility>
|
||||
<property name="label">Zoom out</property>
|
||||
</accessibility>
|
||||
<style>
|
||||
<class name="circular"/>
|
||||
</style>
|
||||
@@ -263,9 +247,6 @@
|
||||
<property name="vexpand">1</property>
|
||||
<child>
|
||||
<object class="GtkPicture" id="image">
|
||||
<accessibility>
|
||||
<property name="label">Font rendering example</property>
|
||||
</accessibility>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="can-shrink">0</property>
|
||||
|
@@ -157,7 +157,7 @@ do_frames (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -54,6 +54,7 @@ create_axis_slider (GtkGears *gears,
|
||||
|
||||
label = gtk_label_new (text);
|
||||
gtk_box_append (GTK_BOX (box), label);
|
||||
gtk_widget_show (label);
|
||||
|
||||
adj = gtk_adjustment_new (gtk_gears_get_axis (gears, axis), 0.0, 360.0, 1.0, 12.0, 0.0);
|
||||
g_object_set_data (G_OBJECT (adj), "axis", GINT_TO_POINTER (axis));
|
||||
@@ -64,6 +65,9 @@ create_axis_slider (GtkGears *gears,
|
||||
gtk_scale_set_draw_value (GTK_SCALE (slider), FALSE);
|
||||
gtk_box_append (GTK_BOX (box), slider);
|
||||
gtk_widget_set_vexpand (slider, TRUE);
|
||||
gtk_widget_show (slider);
|
||||
|
||||
gtk_widget_show (box);
|
||||
|
||||
return box;
|
||||
}
|
||||
@@ -125,7 +129,7 @@ do_gears (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -208,7 +208,7 @@ do_gestures (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -221,13 +221,16 @@ static void
|
||||
realize (GtkWidget *widget)
|
||||
{
|
||||
const char *vertex_path, *fragment_path;
|
||||
GdkGLContext *context;
|
||||
|
||||
gtk_gl_area_make_current (GTK_GL_AREA (widget));
|
||||
|
||||
if (gtk_gl_area_get_error (GTK_GL_AREA (widget)) != NULL)
|
||||
return;
|
||||
|
||||
if (gtk_gl_area_get_api (GTK_GL_AREA (widget)) == GDK_GL_API_GLES)
|
||||
context = gtk_gl_area_get_context (GTK_GL_AREA (widget));
|
||||
|
||||
if (gdk_gl_context_get_use_es (context))
|
||||
{
|
||||
vertex_path = "/glarea/glarea-gles.vs.glsl";
|
||||
fragment_path = "/glarea/glarea-gles.fs.glsl";
|
||||
@@ -352,6 +355,7 @@ create_axis_slider (int axis)
|
||||
|
||||
label = gtk_label_new (text);
|
||||
gtk_box_append (GTK_BOX (box), label);
|
||||
gtk_widget_show (label);
|
||||
|
||||
adj = gtk_adjustment_new (0.0, 0.0, 360.0, 1.0, 12.0, 0.0);
|
||||
g_signal_connect (adj, "value-changed",
|
||||
@@ -360,6 +364,9 @@ create_axis_slider (int axis)
|
||||
slider = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, adj);
|
||||
gtk_box_append (GTK_BOX (box), slider);
|
||||
gtk_widget_set_hexpand (slider, TRUE);
|
||||
gtk_widget_show (slider);
|
||||
|
||||
gtk_widget_show (box);
|
||||
|
||||
return box;
|
||||
}
|
||||
@@ -433,7 +440,7 @@ do_glarea (GtkWidget *do_widget)
|
||||
demo_window = create_glarea_window (do_widget);
|
||||
|
||||
if (!gtk_widget_get_visible (demo_window))
|
||||
gtk_widget_set_visible (demo_window, TRUE);
|
||||
gtk_widget_show (demo_window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (demo_window));
|
||||
|
||||
|
@@ -33,7 +33,7 @@ static void
|
||||
text_changed (GtkTextBuffer *buffer,
|
||||
GtkWidget *button)
|
||||
{
|
||||
gtk_widget_set_visible (button, TRUE);
|
||||
gtk_widget_show (button);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -58,7 +58,7 @@ apply_text (GtkWidget *button,
|
||||
g_object_unref (shader);
|
||||
g_bytes_unref (bytes);
|
||||
|
||||
gtk_widget_set_visible (button, FALSE);
|
||||
gtk_widget_hide (button);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -237,7 +237,7 @@ make_shader_stack (const char *name,
|
||||
gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
|
||||
gtk_widget_add_css_class (button, "small");
|
||||
gtk_widget_set_visible (button, FALSE);
|
||||
gtk_widget_hide (button);
|
||||
gtk_center_box_set_end_widget (GTK_CENTER_BOX (widget), button);
|
||||
|
||||
gtk_box_append (GTK_BOX (vbox), widget);
|
||||
@@ -337,7 +337,7 @@ create_gltransition_window (GtkWidget *do_widget)
|
||||
1, 1, 1, 1);
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_string (provider, "button.small { padding: 0; }");
|
||||
gtk_css_provider_load_from_data (provider, "button.small { padding: 0; }", -1);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
@@ -354,7 +354,7 @@ do_gltransition (GtkWidget *do_widget)
|
||||
demo_window = create_gltransition_window (do_widget);
|
||||
|
||||
if (!gtk_widget_get_visible (demo_window))
|
||||
gtk_widget_set_visible (demo_window, TRUE);
|
||||
gtk_widget_show (demo_window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (demo_window));
|
||||
|
||||
|
@@ -27,17 +27,24 @@ G_BEGIN_DECLS
|
||||
|
||||
#define GSK_TYPE_SHADER_PAINTABLE (gsk_shader_paintable_get_type ())
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (GskShaderPaintable, gsk_shader_paintable, GSK, SHADER_PAINTABLE, GObject)
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkPaintable * gsk_shader_paintable_new (GskGLShader *shader,
|
||||
GBytes *data);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskGLShader * gsk_shader_paintable_get_shader (GskShaderPaintable *self);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gsk_shader_paintable_set_shader (GskShaderPaintable *self,
|
||||
GskGLShader *shader);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GBytes * gsk_shader_paintable_get_args (GskShaderPaintable *self);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gsk_shader_paintable_set_args (GskShaderPaintable *self,
|
||||
GBytes *data);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gsk_shader_paintable_update_time (GskShaderPaintable *self,
|
||||
int time_idx,
|
||||
gint64 frame_time);
|
||||
|
@@ -48,16 +48,14 @@
|
||||
#define VERTICES_PER_TOOTH 34
|
||||
#define GEAR_VERTEX_STRIDE 6
|
||||
|
||||
static inline void
|
||||
_sincos (double x, double *_sin, double *_cos)
|
||||
#ifndef HAVE_SINCOS
|
||||
static void
|
||||
sincos (double x, double *_sin, double *_cos)
|
||||
{
|
||||
#ifdef HAVE_SINCOS
|
||||
sincos (x, _sin, _cos);
|
||||
#else
|
||||
*_sin = sin (x);
|
||||
*_cos = cos (x);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Struct describing the vertices in triangle strip
|
||||
@@ -309,11 +307,11 @@ create_gear (GLfloat inner_radius,
|
||||
struct point p[7];
|
||||
|
||||
/* Calculate needed sin/cos for various angles */
|
||||
_sincos(i * 2.0 * G_PI / teeth + da * 0, &s[0], &c[0]);
|
||||
_sincos(i * 2.0 * M_PI / teeth + da * 1, &s[1], &c[1]);
|
||||
_sincos(i * 2.0 * M_PI / teeth + da * 2, &s[2], &c[2]);
|
||||
_sincos(i * 2.0 * M_PI / teeth + da * 3, &s[3], &c[3]);
|
||||
_sincos(i * 2.0 * M_PI / teeth + da * 4, &s[4], &c[4]);
|
||||
sincos(i * 2.0 * G_PI / teeth + da * 0, &s[0], &c[0]);
|
||||
sincos(i * 2.0 * M_PI / teeth + da * 1, &s[1], &c[1]);
|
||||
sincos(i * 2.0 * M_PI / teeth + da * 2, &s[2], &c[2]);
|
||||
sincos(i * 2.0 * M_PI / teeth + da * 3, &s[3], &c[3]);
|
||||
sincos(i * 2.0 * M_PI / teeth + da * 4, &s[4], &c[4]);
|
||||
|
||||
GEAR_POINT(p[0], r2, 1);
|
||||
GEAR_POINT(p[1], r2, 2);
|
||||
@@ -522,7 +520,7 @@ void perspective(GLfloat *m, GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloa
|
||||
identity(tmp);
|
||||
|
||||
deltaZ = zFar - zNear;
|
||||
_sincos(radians, &sine, &cosine);
|
||||
sincos(radians, &sine, &cosine);
|
||||
|
||||
if ((deltaZ == 0) || (sine == 0) || (aspect == 0))
|
||||
return;
|
||||
@@ -737,6 +735,7 @@ gtk_gears_realize (GtkWidget *widget)
|
||||
GtkGLArea *glarea = GTK_GL_AREA (widget);
|
||||
GtkGears *gears = GTK_GEARS (widget);
|
||||
GtkGearsPrivate *priv = gtk_gears_get_instance_private (gears);
|
||||
GdkGLContext *context;
|
||||
GLuint vao, v, f, program;
|
||||
const char *p;
|
||||
char msg[512];
|
||||
@@ -747,6 +746,8 @@ gtk_gears_realize (GtkWidget *widget)
|
||||
if (gtk_gl_area_get_error (glarea) != NULL)
|
||||
return;
|
||||
|
||||
context = gtk_gl_area_get_context (glarea);
|
||||
|
||||
glEnable (GL_CULL_FACE);
|
||||
glEnable (GL_DEPTH_TEST);
|
||||
|
||||
@@ -756,7 +757,7 @@ gtk_gears_realize (GtkWidget *widget)
|
||||
priv->vao = vao;
|
||||
|
||||
/* Compile the vertex shader */
|
||||
if (gtk_gl_area_get_api (glarea) == GDK_GL_API_GLES)
|
||||
if (gdk_gl_context_get_use_es (context))
|
||||
p = vertex_shader_gles;
|
||||
else
|
||||
p = vertex_shader_gl;
|
||||
@@ -767,7 +768,7 @@ gtk_gears_realize (GtkWidget *widget)
|
||||
g_debug ("vertex shader info: %s\n", msg);
|
||||
|
||||
/* Compile the fragment shader */
|
||||
if (gtk_gl_area_get_api (glarea) == GDK_GL_API_GLES)
|
||||
if (gdk_gl_context_get_use_es (context))
|
||||
p = fragment_shader_gles;
|
||||
else
|
||||
p = fragment_shader_gl;
|
||||
|
@@ -18,7 +18,6 @@ do_headerbar (GtkWidget *do_widget)
|
||||
GtkWidget *header;
|
||||
GtkWidget *button;
|
||||
GtkWidget *box;
|
||||
GtkWidget *content;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
@@ -38,30 +37,20 @@ do_headerbar (GtkWidget *do_widget)
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_widget_add_css_class (box, "linked");
|
||||
button = gtk_button_new_from_icon_name ("go-previous-symbolic");
|
||||
gtk_widget_set_tooltip_text (button, "Back");
|
||||
gtk_box_append (GTK_BOX (box), button);
|
||||
button = gtk_button_new_from_icon_name ("go-next-symbolic");
|
||||
gtk_widget_set_tooltip_text (button, "Forward");
|
||||
gtk_box_append (GTK_BOX (box), button);
|
||||
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), box);
|
||||
button = gtk_switch_new ();
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (button),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, "Change something",
|
||||
-1);
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), button);
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), gtk_switch_new ());
|
||||
|
||||
gtk_window_set_titlebar (GTK_WINDOW (window), header);
|
||||
|
||||
content = gtk_text_view_new ();
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (content),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, "Content",
|
||||
-1);
|
||||
gtk_window_set_child (GTK_WINDOW (window), content);
|
||||
gtk_window_set_child (GTK_WINDOW (window), gtk_text_view_new ());
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -1,146 +0,0 @@
|
||||
#include <gdk/gdk.h>
|
||||
#include "hsla.h"
|
||||
|
||||
void
|
||||
_gdk_hsla_init_from_rgba (GdkHSLA *hsla,
|
||||
const GdkRGBA *rgba)
|
||||
{
|
||||
float min;
|
||||
float max;
|
||||
float red;
|
||||
float green;
|
||||
float blue;
|
||||
float delta;
|
||||
|
||||
g_return_if_fail (hsla != NULL);
|
||||
g_return_if_fail (rgba != NULL);
|
||||
|
||||
red = rgba->red;
|
||||
green = rgba->green;
|
||||
blue = rgba->blue;
|
||||
|
||||
if (red > green)
|
||||
{
|
||||
if (red > blue)
|
||||
max = red;
|
||||
else
|
||||
max = blue;
|
||||
|
||||
if (green < blue)
|
||||
min = green;
|
||||
else
|
||||
min = blue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (green > blue)
|
||||
max = green;
|
||||
else
|
||||
max = blue;
|
||||
|
||||
if (red < blue)
|
||||
min = red;
|
||||
else
|
||||
min = blue;
|
||||
}
|
||||
|
||||
hsla->lightness = (max + min) / 2;
|
||||
hsla->saturation = 0;
|
||||
hsla->hue = 0;
|
||||
hsla->alpha = rgba->alpha;
|
||||
|
||||
if (max != min)
|
||||
{
|
||||
if (hsla->lightness <= 0.5)
|
||||
hsla->saturation = (max - min) / (max + min);
|
||||
else
|
||||
hsla->saturation = (max - min) / (2 - max - min);
|
||||
|
||||
delta = max -min;
|
||||
if (red == max)
|
||||
hsla->hue = (green - blue) / delta;
|
||||
else if (green == max)
|
||||
hsla->hue = 2 + (blue - red) / delta;
|
||||
else if (blue == max)
|
||||
hsla->hue = 4 + (red - green) / delta;
|
||||
|
||||
hsla->hue *= 60;
|
||||
if (hsla->hue < 0.0)
|
||||
hsla->hue += 360;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_rgba_init_from_hsla (GdkRGBA *rgba,
|
||||
const GdkHSLA *hsla)
|
||||
{
|
||||
float hue;
|
||||
float lightness;
|
||||
float saturation;
|
||||
float m1, m2;
|
||||
|
||||
lightness = hsla->lightness;
|
||||
saturation = hsla->saturation;
|
||||
|
||||
if (lightness <= 0.5)
|
||||
m2 = lightness * (1 + saturation);
|
||||
else
|
||||
m2 = lightness + saturation - lightness * saturation;
|
||||
m1 = 2 * lightness - m2;
|
||||
|
||||
rgba->alpha = hsla->alpha;
|
||||
|
||||
if (saturation == 0)
|
||||
{
|
||||
rgba->red = lightness;
|
||||
rgba->green = lightness;
|
||||
rgba->blue = lightness;
|
||||
}
|
||||
else
|
||||
{
|
||||
hue = hsla->hue + 120;
|
||||
while (hue > 360)
|
||||
hue -= 360;
|
||||
while (hue < 0)
|
||||
hue += 360;
|
||||
|
||||
if (hue < 60)
|
||||
rgba->red = m1 + (m2 - m1) * hue / 60;
|
||||
else if (hue < 180)
|
||||
rgba->red = m2;
|
||||
else if (hue < 240)
|
||||
rgba->red = m1 + (m2 - m1) * (240 - hue) / 60;
|
||||
else
|
||||
rgba->red = m1;
|
||||
|
||||
hue = hsla->hue;
|
||||
while (hue > 360)
|
||||
hue -= 360;
|
||||
while (hue < 0)
|
||||
hue += 360;
|
||||
|
||||
if (hue < 60)
|
||||
rgba->green = m1 + (m2 - m1) * hue / 60;
|
||||
else if (hue < 180)
|
||||
rgba->green = m2;
|
||||
else if (hue < 240)
|
||||
rgba->green = m1 + (m2 - m1) * (240 - hue) / 60;
|
||||
else
|
||||
rgba->green = m1;
|
||||
|
||||
hue = hsla->hue - 120;
|
||||
while (hue > 360)
|
||||
hue -= 360;
|
||||
while (hue < 0)
|
||||
hue += 360;
|
||||
|
||||
if (hue < 60)
|
||||
rgba->blue = m1 + (m2 - m1) * hue / 60;
|
||||
else if (hue < 180)
|
||||
rgba->blue = m2;
|
||||
else if (hue < 240)
|
||||
rgba->blue = m1 + (m2 - m1) * (240 - hue) / 60;
|
||||
else
|
||||
rgba->blue = m1;
|
||||
}
|
||||
}
|
@@ -1,15 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
typedef struct _GdkHSLA GdkHSLA;
|
||||
|
||||
struct _GdkHSLA {
|
||||
float hue;
|
||||
float saturation;
|
||||
float lightness;
|
||||
float alpha;
|
||||
};
|
||||
|
||||
void _gdk_hsla_init_from_rgba (GdkHSLA *hsla,
|
||||
const GdkRGBA *rgba);
|
||||
void _gdk_rgba_init_from_hsla (GdkRGBA *rgba,
|
||||
const GdkHSLA *hsla);
|
@@ -399,7 +399,7 @@ do_hypertext (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -370,7 +370,7 @@ do_iconscroll (GtkWidget *do_widget)
|
||||
set_widget_type (0);
|
||||
|
||||
label = GTK_WIDGET (gtk_builder_get_object (builder, "fps_label"));
|
||||
id = g_timeout_add_full (G_PRIORITY_HIGH, 500, update_fps, label, NULL);
|
||||
id = g_timeout_add (500, update_fps, label);
|
||||
g_object_set_data_full (G_OBJECT (label), "timeout",
|
||||
GUINT_TO_POINTER (id), remove_timeout);
|
||||
|
||||
@@ -378,7 +378,7 @@ do_iconscroll (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -320,7 +320,7 @@ do_iconview (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -1,5 +1,4 @@
|
||||
/* Icon View/Editing and Drag-and-Drop
|
||||
* #Keywords: dnd
|
||||
*
|
||||
* The GtkIconView widget supports Editing and Drag-and-Drop.
|
||||
* This example also demonstrates using the generic GtkCellLayout
|
||||
@@ -151,7 +150,7 @@ do_iconview_edit (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -1,197 +0,0 @@
|
||||
/* Image Scaling
|
||||
* #Keywords: zoom, scale, filter, action, menu
|
||||
*
|
||||
* The custom widget we create here is similar to a GtkPicture,
|
||||
* but allows setting a zoom level and filtering mode for the
|
||||
* displayed paintable.
|
||||
*
|
||||
* It also demonstrates how to add a context menu to a custom
|
||||
* widget and connect it with widget actions.
|
||||
*
|
||||
* The context menu has items to change the zoom level.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "demo3widget.h"
|
||||
|
||||
static void
|
||||
file_opened (GObject *source,
|
||||
GAsyncResult *result,
|
||||
void *data)
|
||||
{
|
||||
GFile *file;
|
||||
GError *error = NULL;
|
||||
GdkTexture *texture;
|
||||
|
||||
file = gtk_file_dialog_open_finish (GTK_FILE_DIALOG (source), result, &error);
|
||||
|
||||
if (!file)
|
||||
{
|
||||
g_print ("%s\n", error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
texture = gdk_texture_new_from_file (file, &error);
|
||||
g_object_unref (file);
|
||||
if (!texture)
|
||||
{
|
||||
g_print ("%s\n", error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
g_object_set (G_OBJECT (data), "texture", texture, NULL);
|
||||
g_object_unref (texture);
|
||||
}
|
||||
|
||||
static void
|
||||
open_file (GtkWidget *picker,
|
||||
GtkWidget *demo)
|
||||
{
|
||||
GtkWindow *parent = GTK_WINDOW (gtk_widget_get_root (picker));
|
||||
GtkFileDialog *dialog;
|
||||
GtkFileFilter *filter;
|
||||
GListStore *filters;
|
||||
|
||||
dialog = gtk_file_dialog_new ();
|
||||
|
||||
filter = gtk_file_filter_new ();
|
||||
gtk_file_filter_set_name (filter, "Images");
|
||||
gtk_file_filter_add_pixbuf_formats (filter);
|
||||
filters = g_list_store_new (GTK_TYPE_FILE_FILTER);
|
||||
g_list_store_append (filters, filter);
|
||||
g_object_unref (filter);
|
||||
|
||||
gtk_file_dialog_set_filters (dialog, G_LIST_MODEL (filters));
|
||||
g_object_unref (filters);
|
||||
|
||||
gtk_file_dialog_open (dialog, parent, NULL, file_opened, demo);
|
||||
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
rotate (GtkWidget *button,
|
||||
GtkWidget *demo)
|
||||
{
|
||||
float angle;
|
||||
|
||||
g_object_get (demo, "angle", &angle, NULL);
|
||||
|
||||
angle = fmodf (angle + 90.f, 360.f);
|
||||
|
||||
g_object_set (demo, "angle", angle, NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
transform_to (GBinding *binding,
|
||||
const GValue *src,
|
||||
GValue *dest,
|
||||
gpointer user_data)
|
||||
{
|
||||
double from;
|
||||
float to;
|
||||
|
||||
from = g_value_get_double (src);
|
||||
to = (float) pow (2., from);
|
||||
g_value_set_float (dest, to);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
transform_from (GBinding *binding,
|
||||
const GValue *src,
|
||||
GValue *dest,
|
||||
gpointer user_data)
|
||||
{
|
||||
float to;
|
||||
double from;
|
||||
|
||||
to = g_value_get_float (src);
|
||||
from = log2 (to);
|
||||
g_value_set_double (dest, from);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_image_scaling (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
GtkWidget *box;
|
||||
GtkWidget *box2;
|
||||
GtkWidget *sw;
|
||||
GtkWidget *widget;
|
||||
GtkWidget *scale;
|
||||
GtkWidget *dropdown;
|
||||
GtkWidget *button;
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Image Scaling");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
|
||||
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_VERTICAL, 0);
|
||||
gtk_window_set_child (GTK_WINDOW (window), box);
|
||||
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_widget_set_vexpand (sw, TRUE);
|
||||
gtk_box_append (GTK_BOX (box), sw);
|
||||
|
||||
widget = demo3_widget_new ("/transparent/portland-rose.jpg");
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), widget);
|
||||
|
||||
box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_box_append (GTK_BOX (box), box2);
|
||||
|
||||
button = gtk_button_new_from_icon_name ("document-open-symbolic");
|
||||
gtk_widget_set_tooltip_text (button, "Open File");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (open_file), widget);
|
||||
gtk_box_append (GTK_BOX (box2), button);
|
||||
|
||||
button = gtk_button_new_from_icon_name ("object-rotate-right-symbolic");
|
||||
gtk_widget_set_tooltip_text (button, "Rotate");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (rotate), widget);
|
||||
gtk_box_append (GTK_BOX (box2), button);
|
||||
|
||||
scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, -10., 10., 0.1);
|
||||
gtk_scale_add_mark (GTK_SCALE (scale), 0., GTK_POS_TOP, NULL);
|
||||
gtk_widget_set_tooltip_text (scale, "Zoom");
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (scale),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, "Zoom",
|
||||
-1);
|
||||
gtk_range_set_value (GTK_RANGE (scale), 0.);
|
||||
gtk_widget_set_hexpand (scale, TRUE);
|
||||
gtk_box_append (GTK_BOX (box2), scale);
|
||||
|
||||
dropdown = gtk_drop_down_new (G_LIST_MODEL (gtk_string_list_new ((const char *[]){ "Linear", "Nearest", "Trilinear", NULL })), NULL);
|
||||
gtk_widget_set_tooltip_text (dropdown, "Filter");
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (dropdown),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, "Filter",
|
||||
-1);
|
||||
gtk_box_append (GTK_BOX (box2), dropdown);
|
||||
|
||||
g_object_bind_property (dropdown, "selected", widget, "filter", G_BINDING_DEFAULT);
|
||||
|
||||
g_object_bind_property_full (gtk_range_get_adjustment (GTK_RANGE (scale)), "value",
|
||||
widget, "scale",
|
||||
G_BINDING_BIDIRECTIONAL,
|
||||
transform_to,
|
||||
transform_from,
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
return window;
|
||||
}
|
@@ -30,7 +30,6 @@ progressive_prepared_callback (GdkPixbufLoader *loader,
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
GtkWidget *picture;
|
||||
GdkTexture *texture;
|
||||
|
||||
picture = GTK_WIDGET (data);
|
||||
|
||||
@@ -41,9 +40,7 @@ progressive_prepared_callback (GdkPixbufLoader *loader,
|
||||
*/
|
||||
gdk_pixbuf_fill (pixbuf, 0xaaaaaaff);
|
||||
|
||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
||||
gtk_picture_set_paintable (GTK_PICTURE (picture), GDK_PAINTABLE (texture));
|
||||
g_object_unref (texture);
|
||||
gtk_picture_set_pixbuf (GTK_PICTURE (picture), pixbuf);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -54,18 +51,22 @@ progressive_updated_callback (GdkPixbufLoader *loader,
|
||||
int height,
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *picture = GTK_WIDGET (data);
|
||||
GdkTexture *texture;
|
||||
GtkWidget *picture;
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
texture = gdk_texture_new_for_pixbuf (gdk_pixbuf_loader_get_pixbuf (loader));
|
||||
gtk_picture_set_paintable (GTK_PICTURE (picture), GDK_PAINTABLE (texture));
|
||||
g_object_unref (texture);
|
||||
picture = GTK_WIDGET (data);
|
||||
|
||||
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
|
||||
gtk_picture_set_pixbuf (GTK_PICTURE (picture), NULL);
|
||||
gtk_picture_set_pixbuf (GTK_PICTURE (picture), pixbuf);
|
||||
}
|
||||
|
||||
static int
|
||||
progressive_timeout (gpointer data)
|
||||
{
|
||||
GtkWidget *picture = GTK_WIDGET (data);
|
||||
GtkWidget *picture;
|
||||
|
||||
picture = GTK_WIDGET (data);
|
||||
|
||||
/* This shows off fully-paranoid error handling, so looks scary.
|
||||
* You could factor out the error handling code into a nice separate
|
||||
@@ -82,17 +83,24 @@ progressive_timeout (gpointer data)
|
||||
|
||||
if (bytes_read < 0)
|
||||
{
|
||||
GtkAlertDialog *dialog;
|
||||
GtkWidget *dialog;
|
||||
|
||||
dialog = gtk_alert_dialog_new ("Failure reading image file 'alphatest.png': %s",
|
||||
error->message);
|
||||
gtk_alert_dialog_show (dialog, NULL);
|
||||
g_object_unref (dialog);
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"Failure reading image file 'alphatest.png': %s",
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (gtk_window_destroy), NULL);
|
||||
|
||||
g_object_unref (image_stream);
|
||||
image_stream = NULL;
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
|
||||
load_timeout = 0;
|
||||
|
||||
return FALSE; /* uninstall the timeout */
|
||||
@@ -102,17 +110,25 @@ progressive_timeout (gpointer data)
|
||||
buf, bytes_read,
|
||||
&error))
|
||||
{
|
||||
GtkAlertDialog *dialog;
|
||||
GtkWidget *dialog;
|
||||
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"Failed to load image: %s",
|
||||
error->message);
|
||||
|
||||
dialog = gtk_alert_dialog_new ("Failed to load image: %s",
|
||||
error->message);
|
||||
gtk_alert_dialog_show (dialog, NULL);
|
||||
g_object_unref (dialog);
|
||||
g_error_free (error);
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (gtk_window_destroy), NULL);
|
||||
|
||||
g_object_unref (image_stream);
|
||||
image_stream = NULL;
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
|
||||
load_timeout = 0;
|
||||
|
||||
return FALSE; /* uninstall the timeout */
|
||||
@@ -127,14 +143,22 @@ progressive_timeout (gpointer data)
|
||||
error = NULL;
|
||||
if (!g_input_stream_close (image_stream, NULL, &error))
|
||||
{
|
||||
GtkAlertDialog *dialog;
|
||||
GtkWidget *dialog;
|
||||
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"Failed to load image: %s",
|
||||
error->message);
|
||||
|
||||
dialog = gtk_alert_dialog_new ("Failed to load image: %s",
|
||||
error->message);
|
||||
gtk_alert_dialog_show (dialog, NULL);
|
||||
g_object_unref (dialog);
|
||||
g_error_free (error);
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (gtk_window_destroy), NULL);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
|
||||
g_object_unref (image_stream);
|
||||
image_stream = NULL;
|
||||
g_object_unref (pixbuf_loader);
|
||||
@@ -153,16 +177,25 @@ progressive_timeout (gpointer data)
|
||||
* it was incomplete.
|
||||
*/
|
||||
error = NULL;
|
||||
if (!gdk_pixbuf_loader_close (pixbuf_loader, &error))
|
||||
if (!gdk_pixbuf_loader_close (pixbuf_loader,
|
||||
&error))
|
||||
{
|
||||
GtkAlertDialog *dialog;
|
||||
GtkWidget *dialog;
|
||||
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"Failed to load image: %s",
|
||||
error->message);
|
||||
|
||||
dialog = gtk_alert_dialog_new ("Failed to load image: %s",
|
||||
error->message);
|
||||
gtk_alert_dialog_show (dialog, NULL);
|
||||
g_object_unref (dialog);
|
||||
g_error_free (error);
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (gtk_window_destroy), NULL);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
|
||||
g_object_unref (pixbuf_loader);
|
||||
pixbuf_loader = NULL;
|
||||
|
||||
@@ -183,14 +216,20 @@ progressive_timeout (gpointer data)
|
||||
|
||||
if (image_stream == NULL)
|
||||
{
|
||||
GtkAlertDialog *dialog;
|
||||
GtkWidget *dialog;
|
||||
|
||||
dialog = gtk_alert_dialog_new ("%s",
|
||||
error->message);
|
||||
gtk_alert_dialog_show (dialog, NULL);
|
||||
g_object_unref (dialog);
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"%s", error->message);
|
||||
g_error_free (error);
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (gtk_window_destroy), NULL);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
|
||||
load_timeout = 0;
|
||||
|
||||
return FALSE; /* uninstall the timeout */
|
||||
@@ -421,7 +460,7 @@ do_images (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -7,15 +7,13 @@
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
static void
|
||||
on_bar_response (GtkInfoBar *info_bar,
|
||||
int response_id,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkAlertDialog *dialog;
|
||||
char *detail;
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *window;
|
||||
|
||||
if (response_id == GTK_RESPONSE_CLOSE)
|
||||
{
|
||||
@@ -23,12 +21,19 @@ on_bar_response (GtkInfoBar *info_bar,
|
||||
return;
|
||||
}
|
||||
|
||||
dialog = gtk_alert_dialog_new ("You clicked a button on an info bar");
|
||||
detail = g_strdup_printf ("Your response has been %d", response_id);
|
||||
gtk_alert_dialog_set_detail (dialog, detail);
|
||||
g_free (detail);
|
||||
gtk_alert_dialog_show (dialog, GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (info_bar))));
|
||||
g_object_unref (dialog);
|
||||
window = GTK_WIDGET (gtk_widget_get_root (GTK_WIDGET (info_bar)));
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
|
||||
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_INFO,
|
||||
GTK_BUTTONS_OK,
|
||||
"You clicked a button on an info bar");
|
||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
||||
"Your response has id %d", response_id);
|
||||
|
||||
g_signal_connect_swapped (dialog, "response",
|
||||
G_CALLBACK (gtk_window_destroy), dialog);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
@@ -140,7 +145,7 @@ do_infobar (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -311,12 +311,5 @@ get_language_name_for_tag (guint32 tag)
|
||||
lang = hb_ot_tag_to_language (tag);
|
||||
s = hb_language_to_string (lang);
|
||||
|
||||
if (strcmp (s, "und-fonipa") == 0)
|
||||
return "International Phonetic Alphabet";
|
||||
else if (strcmp (s, "und-fonnapa") == 0)
|
||||
return "North-American Phonetic Alphabet";
|
||||
else if (strcmp (s, "ro-md") == 0)
|
||||
return "Moldavian";
|
||||
|
||||
return get_language_name (pango_language_from_string (s));
|
||||
}
|
||||
|
@@ -54,7 +54,7 @@ do_layoutmanager (GtkWidget *parent)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -190,7 +190,7 @@ do_layoutmanager2 (GtkWidget *parent)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -7,22 +7,38 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static void
|
||||
response_cb (GtkWidget *dialog,
|
||||
int response_id,
|
||||
gpointer data)
|
||||
{
|
||||
gtk_window_destroy (GTK_WINDOW (dialog));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
activate_link (GtkWidget *label,
|
||||
activate_link (GtkWidget *label,
|
||||
const char *uri,
|
||||
gpointer data)
|
||||
gpointer data)
|
||||
{
|
||||
if (g_strcmp0 (uri, "keynav") == 0)
|
||||
{
|
||||
GtkAlertDialog *dialog;
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *parent;
|
||||
|
||||
dialog = gtk_alert_dialog_new ("Keyboard navigation");
|
||||
gtk_alert_dialog_set_detail (dialog,
|
||||
"The term ‘keynav’ is a shorthand for "
|
||||
"keyboard navigation and refers to the process of using "
|
||||
"a program (exclusively) via keyboard input.");
|
||||
gtk_alert_dialog_show (dialog, GTK_WINDOW (gtk_widget_get_root (label)));
|
||||
g_object_unref (dialog);
|
||||
parent = GTK_WIDGET (gtk_widget_get_root (label));
|
||||
dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (parent),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_INFO,
|
||||
GTK_BUTTONS_OK,
|
||||
"Keyboard navigation");
|
||||
gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog),
|
||||
"The term <i>keynav</i> is a shorthand for "
|
||||
"keyboard navigation and refers to the process of using "
|
||||
"a program (exclusively) via keyboard input.");
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (dialog));
|
||||
g_signal_connect (dialog, "response", G_CALLBACK (response_cb), NULL);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -63,10 +79,11 @@ do_links (GtkWidget *do_widget)
|
||||
gtk_widget_set_margin_top (label, 20);
|
||||
gtk_widget_set_margin_bottom (label, 20);
|
||||
gtk_window_set_child (GTK_WINDOW (window), label);
|
||||
gtk_widget_show (label);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -300,7 +300,7 @@ do_list_store (GtkWidget *do_widget)
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
{
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
if (timeout == 0) {
|
||||
/* FIXME this should use the animation-duration instead */
|
||||
timeout = g_timeout_add (80, spinner_timeout, NULL);
|
||||
|
@@ -380,6 +380,7 @@ do_listbox (GtkWidget *do_widget)
|
||||
{
|
||||
message = gtk_message_new (lines[i]);
|
||||
row = gtk_message_row_new (message);
|
||||
gtk_widget_show (GTK_WIDGET (row));
|
||||
gtk_list_box_insert (GTK_LIST_BOX (listbox), GTK_WIDGET (row), -1);
|
||||
}
|
||||
|
||||
@@ -388,7 +389,7 @@ do_listbox (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -64,8 +64,6 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="short_time_label">
|
||||
<property name="hexpand">1</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="valign">baseline</property>
|
||||
<property name="label" translatable="yes">38m</property>
|
||||
<style>
|
||||
|
@@ -62,7 +62,7 @@ do_listbox_controls (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -30,89 +30,90 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkListBox">
|
||||
<property name="selection-mode">none</property>
|
||||
<signal name="row-activated" handler="row_activated"/>
|
||||
<style>
|
||||
<class name="rich-list"/>
|
||||
<class name="boxed-list"/>
|
||||
</style>
|
||||
|
||||
<object class="GtkFrame">
|
||||
<child>
|
||||
<object class="GtkListBoxRow">
|
||||
<object class="GtkListBox">
|
||||
<property name="selection-mode">none</property>
|
||||
<property name="show-separators">1</property>
|
||||
<signal name="row-activated" handler="row_activated"/>
|
||||
<style>
|
||||
<class name="rich-list"/>
|
||||
</style>
|
||||
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<object class="GtkListBoxRow">
|
||||
<child>
|
||||
<object class="GtkLabel" id="switch_label">
|
||||
<property name="label" translatable="yes">Switch</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="mnemonic-widget">switch</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSwitch" id="switch">
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<object class="GtkBox">
|
||||
<child>
|
||||
<object class="GtkLabel" id="switch_label">
|
||||
<property name="label" translatable="yes">Switch</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="hexpand">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSwitch" id="switch">
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkListBoxRow">
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<object class="GtkListBoxRow">
|
||||
<child>
|
||||
<object class="GtkLabel" id="check_label">
|
||||
<property name="label" translatable="yes">Check</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="mnemonic-widget">check</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="check">
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="active">1</property>
|
||||
<object class="GtkBox">
|
||||
<child>
|
||||
<object class="GtkLabel" id="check_label">
|
||||
<property name="label" translatable="yes">Check</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="hexpand">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="check">
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="active">1</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkListBoxRow">
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<object class="GtkListBoxRow">
|
||||
<child>
|
||||
<object class="GtkLabel" id="image_label">
|
||||
<property name="label" translatable="yes">Click here!</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="hexpand">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage" id="image">
|
||||
<property name="icon-name">object-select-symbolic</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="opacity">0</property>
|
||||
<property name="accessible-role">status</property>
|
||||
<object class="GtkBox">
|
||||
<child>
|
||||
<object class="GtkLabel" id="image_label">
|
||||
<property name="label" translatable="yes">Click here!</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="hexpand">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage" id="image">
|
||||
<property name="icon-name">object-select-symbolic</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="opacity">0</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
@@ -133,146 +134,146 @@
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkListBox">
|
||||
<property name="selection-mode">none</property>
|
||||
<style>
|
||||
<class name="rich-list"/>
|
||||
<class name="boxed-list"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkFrame">
|
||||
<child>
|
||||
<object class="GtkListBox">
|
||||
<property name="selection-mode">none</property>
|
||||
<property name="show-separators">1</property>
|
||||
<style>
|
||||
<class name="rich-list"/>
|
||||
</style>
|
||||
|
||||
<child>
|
||||
<object class="GtkListBoxRow">
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<child>
|
||||
<object class="GtkLabel" id="scale_label">
|
||||
<property name="label" translatable="yes">Scale</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="mnemonic-widget">scale</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScale" id="scale">
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="draw-value">0</property>
|
||||
<property name="width-request">150</property>
|
||||
<property name="adjustment">
|
||||
<object class="GtkAdjustment">
|
||||
<property name="upper">100</property>
|
||||
<property name="value">50</property>
|
||||
<property name="step-increment">1</property>
|
||||
<property name="page-increment">10</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkListBoxRow">
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<child>
|
||||
<object class="GtkLabel" id="scale_label">
|
||||
<property name="label" translatable="yes">Scale</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="hexpand">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScale">
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="draw-value">0</property>
|
||||
<property name="width-request">150</property>
|
||||
<property name="adjustment">
|
||||
<object class="GtkAdjustment">
|
||||
<property name="upper">100</property>
|
||||
<property name="value">50</property>
|
||||
<property name="step-increment">1</property>
|
||||
<property name="page-increment">10</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkListBoxRow">
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<child>
|
||||
<object class="GtkLabel" id="spin_label">
|
||||
<property name="label" translatable="yes">Spinbutton</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="mnemonic-widget">spin</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinButton" id="spin">
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="adjustment">
|
||||
<object class="GtkAdjustment">
|
||||
<property name="upper">100</property>
|
||||
<property name="value">50</property>
|
||||
<property name="step-increment">1</property>
|
||||
<property name="page-increment">10</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkListBoxRow">
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<child>
|
||||
<object class="GtkLabel" id="dropdown_label">
|
||||
<property name="label" translatable="yes">Dropdown</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="mnemonic-widget">dropdown</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkDropDown" id="dropdown">
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="model">
|
||||
<object class="GtkStringList">
|
||||
<items>
|
||||
<item>Choice 1</item>
|
||||
<item>Choice 2</item>
|
||||
<item>Choice 3</item>
|
||||
<item>Choice 4</item>
|
||||
</items>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkListBoxRow">
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<child>
|
||||
<object class="GtkLabel" id="spin_label">
|
||||
<property name="label" translatable="yes">Spinbutton</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="hexpand">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinButton">
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="adjustment">
|
||||
<object class="GtkAdjustment">
|
||||
<property name="upper">100</property>
|
||||
<property name="value">50</property>
|
||||
<property name="step-increment">1</property>
|
||||
<property name="page-increment">10</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkListBoxRow">
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<child>
|
||||
<object class="GtkLabel" id="dropdown_label">
|
||||
<property name="label" translatable="yes">Dropdown</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="hexpand">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkDropDown">
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="model">
|
||||
<object class="GtkStringList">
|
||||
<items>
|
||||
<item>Choice 1</item>
|
||||
<item>Choice 2</item>
|
||||
<item>Choice 3</item>
|
||||
<item>Choice 4</item>
|
||||
</items>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkListBoxRow">
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<child>
|
||||
<object class="GtkLabel" id="entry_label">
|
||||
<property name="label" translatable="yes">Entry</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="mnemonic-widget">entry</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="entry">
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="placeholder-text">Type here…</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkListBoxRow">
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<child>
|
||||
<object class="GtkLabel" id="entry_label">
|
||||
<property name="label" translatable="yes">Entry</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="hexpand">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry">
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="placeholder-text">Type here…</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
@@ -117,16 +117,19 @@ activate_cb (GtkListView *list,
|
||||
G_APP_LAUNCH_CONTEXT (context),
|
||||
&error))
|
||||
{
|
||||
GtkAlertDialog *dialog;
|
||||
GtkWidget *dialog;
|
||||
|
||||
/* And because error handling is important, even a simple demo has it:
|
||||
* We display an error dialog that something went wrong.
|
||||
*/
|
||||
dialog = gtk_alert_dialog_new ("Could not launch %s", g_app_info_get_display_name (app_info));
|
||||
gtk_alert_dialog_set_detail (dialog, error->message);
|
||||
gtk_alert_dialog_show (dialog, GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (list))));
|
||||
g_object_unref (dialog);
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (list))),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"Could not launch %s", g_app_info_get_display_name (app_info));
|
||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
|
||||
g_clear_error (&error);
|
||||
gtk_widget_show (dialog);
|
||||
}
|
||||
|
||||
g_object_unref (context);
|
||||
@@ -191,7 +194,7 @@ do_listview_applauncher (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -494,7 +494,7 @@ do_listview_clocks (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -1124,7 +1124,7 @@ do_listview_colors (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -275,7 +275,7 @@ do_listview_filebrowser (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -485,7 +485,7 @@ do_listview_minesweeper (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -14,15 +14,145 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "settings-key.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Create an object that wraps GSettingsSchemaKey because that's a boxed type */
|
||||
typedef struct _SettingsKey SettingsKey;
|
||||
struct _SettingsKey
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GSettings *settings;
|
||||
GSettingsSchemaKey *key;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_NAME,
|
||||
PROP_SUMMARY,
|
||||
PROP_DESCRIPTION,
|
||||
PROP_VALUE,
|
||||
PROP_TYPE,
|
||||
PROP_DEFAULT_VALUE,
|
||||
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
#define SETTINGS_TYPE_KEY (settings_key_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (SettingsKey, settings_key, SETTINGS, KEY, GObject);
|
||||
|
||||
G_DEFINE_TYPE (SettingsKey, settings_key, G_TYPE_OBJECT);
|
||||
static GParamSpec *properties[N_PROPS] = { NULL, };
|
||||
|
||||
static void
|
||||
item_value_changed (GtkEditableLabel *label,
|
||||
GParamSpec *pspec,
|
||||
GtkColumnViewCell *cell)
|
||||
settings_key_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
SettingsKey *self = SETTINGS_KEY (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_DESCRIPTION:
|
||||
g_value_set_string (value, g_settings_schema_key_get_description (self->key));
|
||||
break;
|
||||
|
||||
case PROP_NAME:
|
||||
g_value_set_string (value, g_settings_schema_key_get_name (self->key));
|
||||
break;
|
||||
|
||||
case PROP_SUMMARY:
|
||||
g_value_set_string (value, g_settings_schema_key_get_summary (self->key));
|
||||
break;
|
||||
|
||||
case PROP_VALUE:
|
||||
{
|
||||
GVariant *variant = g_settings_get_value (self->settings, g_settings_schema_key_get_name (self->key));
|
||||
g_value_take_string (value, g_variant_print (variant, FALSE));
|
||||
g_variant_unref (variant);
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_TYPE:
|
||||
{
|
||||
const GVariantType *type = g_settings_schema_key_get_value_type (self->key);
|
||||
g_value_set_string (value, g_variant_type_peek_string (type));
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_DEFAULT_VALUE:
|
||||
{
|
||||
GVariant *variant = g_settings_schema_key_get_default_value (self->key);
|
||||
g_value_take_string (value, g_variant_print (variant, FALSE));
|
||||
g_variant_unref (variant);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
settings_key_finalize (GObject *object)
|
||||
{
|
||||
SettingsKey *self = SETTINGS_KEY (object);
|
||||
|
||||
g_object_unref (self->settings);
|
||||
g_settings_schema_key_unref (self->key);
|
||||
|
||||
G_OBJECT_CLASS (settings_key_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
settings_key_class_init (SettingsKeyClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
gobject_class->finalize = settings_key_finalize;
|
||||
gobject_class->get_property = settings_key_get_property;
|
||||
|
||||
properties[PROP_DESCRIPTION] =
|
||||
g_param_spec_string ("description", NULL, NULL, NULL, G_PARAM_READABLE);
|
||||
properties[PROP_NAME] =
|
||||
g_param_spec_string ("name", NULL, NULL, NULL, G_PARAM_READABLE);
|
||||
properties[PROP_SUMMARY] =
|
||||
g_param_spec_string ("summary", NULL, NULL, NULL, G_PARAM_READABLE);
|
||||
properties[PROP_VALUE] =
|
||||
g_param_spec_string ("value", NULL, NULL, NULL, G_PARAM_READABLE);
|
||||
properties[PROP_TYPE] =
|
||||
g_param_spec_string ("type", NULL, NULL, NULL, G_PARAM_READABLE);
|
||||
properties[PROP_DEFAULT_VALUE] =
|
||||
g_param_spec_string ("default-value", NULL, NULL, NULL, G_PARAM_READABLE);
|
||||
|
||||
g_object_class_install_properties (gobject_class, N_PROPS, properties);
|
||||
}
|
||||
|
||||
static void
|
||||
settings_key_init (SettingsKey *self)
|
||||
{
|
||||
}
|
||||
|
||||
static SettingsKey *
|
||||
settings_key_new (GSettings *settings,
|
||||
GSettingsSchemaKey *key)
|
||||
{
|
||||
SettingsKey *result = g_object_new (SETTINGS_TYPE_KEY, NULL);
|
||||
|
||||
result->settings = g_object_ref (settings);
|
||||
result->key = g_settings_schema_key_ref (key);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
item_value_changed (GtkEditableLabel *label,
|
||||
GParamSpec *pspec,
|
||||
GtkListItem *item)
|
||||
{
|
||||
SettingsKey *self;
|
||||
GSettingsSchemaKey *key;
|
||||
const char *text;
|
||||
const GVariantType *type;
|
||||
GVariant *variant;
|
||||
@@ -32,11 +162,11 @@ item_value_changed (GtkEditableLabel *label,
|
||||
|
||||
text = gtk_editable_get_text (GTK_EDITABLE (label));
|
||||
|
||||
self = gtk_column_view_cell_get_item (cell);
|
||||
key = settings_key_get_key (self);
|
||||
g_object_get (item, "item", &self, NULL);
|
||||
g_object_unref (self);
|
||||
|
||||
type = g_settings_schema_key_get_value_type (key);
|
||||
name = g_settings_schema_key_get_name (key);
|
||||
type = g_settings_schema_key_get_value_type (self->key);
|
||||
name = g_settings_schema_key_get_name (self->key);
|
||||
|
||||
variant = g_variant_parse (type, text, NULL, NULL, &error);
|
||||
if (!variant)
|
||||
@@ -46,13 +176,13 @@ item_value_changed (GtkEditableLabel *label,
|
||||
goto revert;
|
||||
}
|
||||
|
||||
if (!g_settings_schema_key_range_check (key, variant))
|
||||
if (!g_settings_schema_key_range_check (self->key, variant))
|
||||
{
|
||||
g_warning ("Not a valid value for %s", name);
|
||||
goto revert;
|
||||
}
|
||||
|
||||
g_settings_set_value (settings_key_get_settings (self), name, variant);
|
||||
g_settings_set_value (self->settings, name, variant);
|
||||
g_variant_unref (variant);
|
||||
return;
|
||||
|
||||
@@ -300,7 +430,7 @@ do_listview_settings (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -20,7 +20,6 @@
|
||||
<object class="GtkScrolledWindow">
|
||||
<child>
|
||||
<object class="GtkListView" id="listview">
|
||||
<property name="tab-behavior">item</property>
|
||||
<style>
|
||||
<class name="navigation-sidebar"/>
|
||||
</style>
|
||||
@@ -77,7 +76,6 @@
|
||||
<property name="vexpand">1</property>
|
||||
<child>
|
||||
<object class="GtkColumnView" id="columnview">
|
||||
<property name="tab-behavior">cell</property>
|
||||
<style>
|
||||
<class name="data-table"/>
|
||||
</style>
|
||||
@@ -90,13 +88,13 @@
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkColumnViewCell">
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkLabel">
|
||||
<property name="xalign">0</property>
|
||||
<binding name="label">
|
||||
<lookup name="name" type="SettingsKey">
|
||||
<lookup name="item">GtkColumnViewCell</lookup>
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
@@ -118,12 +116,12 @@
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkColumnViewCell">
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkEditableLabel">
|
||||
<binding name="text">
|
||||
<lookup name="value" type="SettingsKey">
|
||||
<lookup name="item">GtkColumnViewCell</lookup>
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
<signal name="notify::label" handler="item_value_changed"/>
|
||||
@@ -146,13 +144,13 @@
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkColumnViewCell">
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkLabel">
|
||||
<property name="xalign">0</property>
|
||||
<binding name="label">
|
||||
<lookup name="type" type="SettingsKey">
|
||||
<lookup name="item">GtkColumnViewCell</lookup>
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
@@ -175,13 +173,13 @@
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkColumnViewCell">
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkLabel">
|
||||
<property name="xalign">0</property>
|
||||
<binding name="label">
|
||||
<lookup name="default-value" type="SettingsKey">
|
||||
<lookup name="item">GtkColumnViewCell</lookup>
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
@@ -205,14 +203,14 @@
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkColumnViewCell">
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkLabel">
|
||||
<property name="xalign">0</property>
|
||||
<property name="wrap">1</property>
|
||||
<binding name="label">
|
||||
<lookup name="summary" type="SettingsKey">
|
||||
<lookup name="item">GtkColumnViewCell</lookup>
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
@@ -236,14 +234,14 @@
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkColumnViewCell">
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkLabel">
|
||||
<property name="xalign">0</property>
|
||||
<property name="wrap">1</property>
|
||||
<binding name="label">
|
||||
<lookup name="description" type="SettingsKey">
|
||||
<lookup name="item">GtkColumnViewCell</lookup>
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
|
@@ -1,230 +0,0 @@
|
||||
/* Lists/Alternative Settings
|
||||
* #Keywords: GtkListHeaderFactory, GtkSectionModel
|
||||
*
|
||||
* This demo shows an alternative settings viewer for GSettings.
|
||||
*
|
||||
* It demonstrates how to implement support for sections with GtkListView.
|
||||
*
|
||||
* It also shows how to quickly flatten a large tree of items into a list
|
||||
* that can be filtered to find the items one is looking for.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "settings-key.h"
|
||||
|
||||
static void
|
||||
item_value_changed (GtkEditableLabel *label,
|
||||
GParamSpec *pspec,
|
||||
GtkColumnViewCell *cell)
|
||||
{
|
||||
SettingsKey *self;
|
||||
GSettingsSchemaKey *key;
|
||||
const char *text;
|
||||
const GVariantType *type;
|
||||
GVariant *variant;
|
||||
GError *error = NULL;
|
||||
const char *name;
|
||||
char *value;
|
||||
|
||||
text = gtk_editable_get_text (GTK_EDITABLE (label));
|
||||
|
||||
self = gtk_column_view_cell_get_item (cell);
|
||||
key = settings_key_get_key (self);
|
||||
|
||||
type = g_settings_schema_key_get_value_type (key);
|
||||
name = g_settings_schema_key_get_name (key);
|
||||
|
||||
variant = g_variant_parse (type, text, NULL, NULL, &error);
|
||||
if (!variant)
|
||||
{
|
||||
g_warning ("%s", error->message);
|
||||
g_clear_error (&error);
|
||||
goto revert;
|
||||
}
|
||||
|
||||
if (!g_settings_schema_key_range_check (key, variant))
|
||||
{
|
||||
g_warning ("Not a valid value for %s", name);
|
||||
goto revert;
|
||||
}
|
||||
|
||||
g_settings_set_value (settings_key_get_settings (self), name, variant);
|
||||
g_variant_unref (variant);
|
||||
return;
|
||||
|
||||
revert:
|
||||
gtk_widget_error_bell (GTK_WIDGET (label));
|
||||
|
||||
g_object_get (self, "value", &value, NULL);
|
||||
gtk_editable_set_text (GTK_EDITABLE (label), value);
|
||||
g_free (value);
|
||||
}
|
||||
|
||||
static int
|
||||
strvcmp (gconstpointer p1,
|
||||
gconstpointer p2)
|
||||
{
|
||||
const char * const *s1 = p1;
|
||||
const char * const *s2 = p2;
|
||||
|
||||
return strcmp (*s1, *s2);
|
||||
}
|
||||
|
||||
static gpointer
|
||||
map_settings_to_keys (gpointer item,
|
||||
gpointer unused)
|
||||
{
|
||||
GSettings *settings = item;
|
||||
GSettingsSchema *schema;
|
||||
GListStore *store;
|
||||
char **keys;
|
||||
guint i;
|
||||
|
||||
g_object_get (settings, "settings-schema", &schema, NULL);
|
||||
|
||||
store = g_list_store_new (SETTINGS_TYPE_KEY);
|
||||
|
||||
keys = g_settings_schema_list_keys (schema);
|
||||
|
||||
for (i = 0; keys[i] != NULL; i++)
|
||||
{
|
||||
GSettingsSchemaKey *almost_there = g_settings_schema_get_key (schema, keys[i]);
|
||||
SettingsKey *finally = settings_key_new (settings, almost_there);
|
||||
g_list_store_append (store, finally);
|
||||
g_object_unref (finally);
|
||||
g_settings_schema_key_unref (almost_there);
|
||||
}
|
||||
|
||||
g_strfreev (keys);
|
||||
g_settings_schema_unref (schema);
|
||||
g_object_unref (settings);
|
||||
|
||||
return store;
|
||||
}
|
||||
|
||||
static GListModel *
|
||||
create_settings_model (gpointer item,
|
||||
gpointer unused)
|
||||
{
|
||||
GSettings *settings = item;
|
||||
char **schemas;
|
||||
GListStore *result;
|
||||
guint i;
|
||||
|
||||
if (settings == NULL)
|
||||
{
|
||||
g_settings_schema_source_list_schemas (g_settings_schema_source_get_default (),
|
||||
TRUE,
|
||||
&schemas,
|
||||
NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
schemas = g_settings_list_children (settings);
|
||||
}
|
||||
|
||||
if (schemas == NULL || schemas[0] == NULL)
|
||||
{
|
||||
g_free (schemas);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
qsort (schemas, g_strv_length (schemas), sizeof (char *), strvcmp);
|
||||
|
||||
result = g_list_store_new (G_TYPE_SETTINGS);
|
||||
for (i = 0; schemas[i] != NULL; i++)
|
||||
{
|
||||
GSettings *child;
|
||||
|
||||
if (settings == NULL)
|
||||
child = g_settings_new (schemas[i]);
|
||||
else
|
||||
child = g_settings_get_child (settings, schemas[i]);
|
||||
|
||||
g_list_store_append (result, child);
|
||||
g_object_unref (child);
|
||||
}
|
||||
|
||||
g_strfreev (schemas);
|
||||
|
||||
return G_LIST_MODEL (result);
|
||||
}
|
||||
|
||||
static void
|
||||
search_enabled (GtkSearchEntry *entry)
|
||||
{
|
||||
gtk_editable_set_text (GTK_EDITABLE (entry), "");
|
||||
}
|
||||
|
||||
static void
|
||||
stop_search (GtkSearchEntry *entry,
|
||||
gpointer data)
|
||||
{
|
||||
gtk_editable_set_text (GTK_EDITABLE (entry), "");
|
||||
}
|
||||
|
||||
static GtkWidget *window = NULL;
|
||||
|
||||
GtkWidget *
|
||||
do_listview_settings2 (GtkWidget *do_widget)
|
||||
{
|
||||
if (window == NULL)
|
||||
{
|
||||
GtkListView *listview;
|
||||
GListModel *model;
|
||||
GtkTreeListModel *treemodel;
|
||||
GtkNoSelection *selection;
|
||||
GtkBuilderScope *scope;
|
||||
GtkBuilder *builder;
|
||||
GError *error = NULL;
|
||||
GtkFilter *filter;
|
||||
|
||||
g_type_ensure (SETTINGS_TYPE_KEY);
|
||||
|
||||
scope = gtk_builder_cscope_new ();
|
||||
gtk_builder_cscope_add_callback (scope, search_enabled);
|
||||
gtk_builder_cscope_add_callback (scope, stop_search);
|
||||
gtk_builder_cscope_add_callback (scope, settings_key_get_search_string);
|
||||
gtk_builder_cscope_add_callback (scope, item_value_changed);
|
||||
|
||||
builder = gtk_builder_new ();
|
||||
gtk_builder_set_scope (builder, scope);
|
||||
g_object_unref (scope);
|
||||
|
||||
gtk_builder_add_from_resource (builder, "/listview_settings2/listview_settings2.ui", &error);
|
||||
g_assert_no_error (error);
|
||||
|
||||
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *) &window);
|
||||
|
||||
listview = GTK_LIST_VIEW (gtk_builder_get_object (builder, "listview"));
|
||||
filter = GTK_FILTER (gtk_builder_get_object (builder, "filter"));
|
||||
|
||||
model = create_settings_model (NULL, NULL);
|
||||
treemodel = gtk_tree_list_model_new (model,
|
||||
TRUE,
|
||||
TRUE,
|
||||
create_settings_model,
|
||||
NULL,
|
||||
NULL);
|
||||
model = G_LIST_MODEL (gtk_map_list_model_new (G_LIST_MODEL (treemodel), map_settings_to_keys, NULL, NULL));
|
||||
model = G_LIST_MODEL (gtk_flatten_list_model_new (model));
|
||||
model = G_LIST_MODEL (gtk_filter_list_model_new (model, g_object_ref (filter)));
|
||||
selection = gtk_no_selection_new (model);
|
||||
|
||||
gtk_list_view_set_model (GTK_LIST_VIEW (listview), GTK_SELECTION_MODEL (selection));
|
||||
g_object_unref (selection);
|
||||
|
||||
g_object_unref (builder);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
return window;
|
||||
}
|
@@ -1,130 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GtkStringFilter" id="filter">
|
||||
<property name="expression">
|
||||
<closure type="gchararray" function="settings_key_get_search_string" />
|
||||
</property>
|
||||
<property name="search" bind-source="entry" bind-property="text" />
|
||||
</object>
|
||||
<object class="GtkWindow" id="window">
|
||||
<property name="title" translatable="yes">Settings</property>
|
||||
<property name="default-width">640</property>
|
||||
<property name="default-height">480</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar">
|
||||
<child type="end">
|
||||
<object class="GtkToggleButton" id="search_button">
|
||||
<property name="icon-name">system-search-symbolic</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkSearchBar">
|
||||
<property name="search-mode-enabled" bind-source="search_button" bind-property="active" bind-flags="bidirectional"/>
|
||||
<signal name="notify::search-mode-enabled" handler="search_enabled" object="entry"/>
|
||||
<child>
|
||||
<object class="GtkSearchEntry" id="entry">
|
||||
<signal name="stop-search" handler="stop_search"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<child>
|
||||
<object class="GtkListView" id="listview">
|
||||
<property name="vexpand">1</property>
|
||||
<style>
|
||||
<class name="rich-list"/>
|
||||
</style>
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkBox">
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="xalign">0</property>
|
||||
<binding name="label">
|
||||
<lookup name="name" type="SettingsKey">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
<property name="xalign">0</property>
|
||||
<property name="ellipsize">end</property>
|
||||
<binding name="label">
|
||||
<lookup name="summary" type="SettingsKey">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry">
|
||||
<property name="hexpand">1</property>
|
||||
<property name="halign">end</property>
|
||||
<binding name="text">
|
||||
<lookup name="value" type="SettingsKey">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
<signal name="notify::label" handler="item_value_changed"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
</interface>
|
||||
]]></property>
|
||||
</object>
|
||||
</property>
|
||||
<property name="header-factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListHeader">
|
||||
<property name="child">
|
||||
<object class="GtkLabel">
|
||||
<property name="xalign">0</property>
|
||||
<binding name="label">
|
||||
<lookup name="schema" type="GSettings">
|
||||
<lookup name="settings" type="SettingsKey">
|
||||
<lookup name="item">GtkListHeader</lookup>
|
||||
</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
</interface>
|
||||
]]></property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
@@ -367,7 +367,7 @@ do_listview_ucd (GtkWidget *do_widget)
|
||||
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_string (provider, "label.enormous { font-size: 80px; }");
|
||||
gtk_css_provider_load_from_data (provider, "label.enormous { font-size: 80px; }", -1);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (), GTK_STYLE_PROVIDER (provider), 800);
|
||||
gtk_widget_set_hexpand (label, TRUE);
|
||||
gtk_box_append (GTK_BOX (box), label);
|
||||
@@ -383,7 +383,7 @@ do_listview_ucd (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -317,7 +317,7 @@ do_listview_weather (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -42,7 +42,7 @@ update_title_cb (GtkFilterListModel *model)
|
||||
title = g_strdup_printf ("%u lines", g_list_model_get_n_items (G_LIST_MODEL (model)));
|
||||
|
||||
gtk_widget_set_visible (progress, pending != 0);
|
||||
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress), total > 0 ? (total - pending) / (double) total : 0.);
|
||||
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress), (total - pending) / (double) total);
|
||||
gtk_window_set_title (GTK_WINDOW (window), title);
|
||||
g_free (title);
|
||||
}
|
||||
@@ -141,34 +141,39 @@ load_file (GtkStringList *list,
|
||||
}
|
||||
|
||||
static void
|
||||
open_response_cb (GObject *source,
|
||||
GAsyncResult *result,
|
||||
void *user_data)
|
||||
open_response_cb (GtkNativeDialog *dialog,
|
||||
int response,
|
||||
GtkStringList *stringlist)
|
||||
{
|
||||
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
||||
GtkStringList *stringlist = GTK_STRING_LIST (user_data);
|
||||
GFile *file;
|
||||
gtk_native_dialog_hide (dialog);
|
||||
|
||||
file = gtk_file_dialog_open_finish (dialog, result, NULL);
|
||||
if (file)
|
||||
if (response == GTK_RESPONSE_ACCEPT)
|
||||
{
|
||||
GFile *file;
|
||||
|
||||
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
||||
load_file (stringlist, file);
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
gtk_native_dialog_destroy (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
file_open_cb (GtkWidget *button,
|
||||
GtkStringList *stringlist)
|
||||
{
|
||||
GtkFileDialog *dialog;
|
||||
GtkFileChooserNative *dialog;
|
||||
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_open (dialog,
|
||||
GTK_WINDOW (gtk_widget_get_root (button)),
|
||||
NULL,
|
||||
open_response_cb, stringlist);
|
||||
g_object_unref (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 *
|
||||
@@ -248,7 +253,7 @@ do_listview_words (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
<property name="focusable">0</property>
|
||||
<property name="child">
|
||||
<object class="GtkTreeExpander" id="expander">
|
||||
<binding name="list-row">
|
||||
@@ -10,8 +9,6 @@
|
||||
<property name="child">
|
||||
<object class="GtkInscription">
|
||||
<property name="hexpand">1</property>
|
||||
<property name="nat-chars">25</property>
|
||||
<property name="text-overflow">ellipsize-end</property>
|
||||
<binding name="text">
|
||||
<lookup name="title" type="GtkDemo">
|
||||
<lookup name="item">expander</lookup>
|
||||
|
@@ -18,6 +18,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
@@ -267,9 +268,9 @@ activate_run (GSimpleAction *action,
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
display_image (const char *format,
|
||||
const char *resource,
|
||||
GtkWidget *label)
|
||||
display_image (const char *format,
|
||||
const char *resource,
|
||||
char **label)
|
||||
{
|
||||
GtkWidget *sw, *image;
|
||||
|
||||
@@ -279,17 +280,13 @@ display_image (const char *format,
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), image);
|
||||
|
||||
gtk_accessible_update_relation (GTK_ACCESSIBLE (image),
|
||||
GTK_ACCESSIBLE_RELATION_LABELLED_BY, label, NULL,
|
||||
-1);
|
||||
|
||||
return sw;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
display_images (const char *format,
|
||||
const char *resource_dir,
|
||||
GtkWidget *label)
|
||||
display_images (const char *format,
|
||||
const char *resource_dir,
|
||||
char **label)
|
||||
{
|
||||
char **resources;
|
||||
GtkWidget *grid;
|
||||
@@ -314,15 +311,13 @@ display_images (const char *format,
|
||||
{
|
||||
char *resource_name;
|
||||
GtkWidget *box;
|
||||
GtkWidget *image_label;
|
||||
|
||||
resource_name = g_strconcat (resource_dir, "/", resources[i], NULL);
|
||||
|
||||
image_label = gtk_label_new (resources[i]);
|
||||
widget = display_image (NULL, resource_name, image_label);
|
||||
widget = display_image (NULL, resource_name, NULL);
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_box_append (GTK_BOX (box), widget);
|
||||
gtk_box_append (GTK_BOX (box), image_label);
|
||||
gtk_box_append (GTK_BOX (box), gtk_label_new (resources[i]));
|
||||
gtk_flow_box_insert (GTK_FLOW_BOX (grid), box, -1);
|
||||
|
||||
g_free (resource_name);
|
||||
@@ -330,19 +325,15 @@ display_images (const char *format,
|
||||
|
||||
g_strfreev (resources);
|
||||
|
||||
gtk_label_set_label (GTK_LABEL (label), "Images");
|
||||
|
||||
gtk_accessible_update_relation (GTK_ACCESSIBLE (grid),
|
||||
GTK_ACCESSIBLE_RELATION_LABELLED_BY, label, NULL,
|
||||
-1);
|
||||
*label = g_strdup ("Images");
|
||||
|
||||
return sw;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
display_text (const char *format,
|
||||
const char *resource,
|
||||
GtkWidget *label)
|
||||
display_text (const char *format,
|
||||
const char *resource,
|
||||
char **label)
|
||||
{
|
||||
GtkTextBuffer *buffer;
|
||||
GtkWidget *textview, *sw;
|
||||
@@ -377,10 +368,6 @@ display_text (const char *format,
|
||||
|
||||
gtk_text_view_set_buffer (GTK_TEXT_VIEW (textview), buffer);
|
||||
|
||||
gtk_accessible_update_relation (GTK_ACCESSIBLE (textview),
|
||||
GTK_ACCESSIBLE_RELATION_LABELLED_BY, label, NULL,
|
||||
-1);
|
||||
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
@@ -391,19 +378,15 @@ display_text (const char *format,
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
display_video (const char *format,
|
||||
const char *resource,
|
||||
GtkWidget *label)
|
||||
display_video (const char *format,
|
||||
const char *resource,
|
||||
char **label)
|
||||
{
|
||||
GtkWidget *video;
|
||||
|
||||
video = gtk_video_new_for_resource (resource);
|
||||
gtk_video_set_loop (GTK_VIDEO (video), TRUE);
|
||||
|
||||
gtk_accessible_update_relation (GTK_ACCESSIBLE (video),
|
||||
GTK_ACCESSIBLE_RELATION_LABELLED_BY, label, NULL,
|
||||
-1);
|
||||
|
||||
return video;
|
||||
}
|
||||
|
||||
@@ -425,9 +408,9 @@ display_nothing (const char *resource)
|
||||
static struct {
|
||||
const char *extension;
|
||||
const char *format;
|
||||
GtkWidget * (* display_func) (const char *format,
|
||||
const char *resource,
|
||||
GtkWidget *label);
|
||||
GtkWidget * (* display_func) (const char *format,
|
||||
const char *resource,
|
||||
char **label);
|
||||
} display_funcs[] = {
|
||||
{ ".gif", NULL, display_image },
|
||||
{ ".jpg", NULL, display_image },
|
||||
@@ -450,6 +433,7 @@ add_data_tab (const char *demoname)
|
||||
char **resources;
|
||||
GtkWidget *widget, *label;
|
||||
guint i, j;
|
||||
char *label_string;
|
||||
|
||||
resource_dir = g_strconcat ("/", demoname, NULL);
|
||||
resources = g_resources_enumerate_children (resource_dir, 0, NULL);
|
||||
@@ -469,21 +453,24 @@ add_data_tab (const char *demoname)
|
||||
break;
|
||||
}
|
||||
|
||||
label = gtk_label_new (resources[i]);
|
||||
label_string = NULL;
|
||||
|
||||
if (j < G_N_ELEMENTS (display_funcs))
|
||||
widget = display_funcs[j].display_func (display_funcs[j].format,
|
||||
resource_name,
|
||||
label);
|
||||
&label_string);
|
||||
else
|
||||
widget = display_nothing (resource_name);
|
||||
|
||||
label = gtk_label_new (label_string ? label_string : resources[i]);
|
||||
gtk_widget_show (label);
|
||||
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), widget, label);
|
||||
g_object_set (gtk_notebook_get_page (GTK_NOTEBOOK (notebook), widget),
|
||||
"tab-expand", FALSE,
|
||||
NULL);
|
||||
|
||||
g_free (resource_name);
|
||||
g_free (label_string);
|
||||
}
|
||||
|
||||
g_strfreev (resources);
|
||||
|
@@ -57,17 +57,14 @@
|
||||
<object class="GtkBox">
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="width-request">220</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkSearchBar" id="searchbar">
|
||||
<accessibility>
|
||||
<relation name="labelled-by">search-entry</relation>
|
||||
</accessibility>
|
||||
<property name="key-capture-widget">window</property>
|
||||
<child>
|
||||
<object class="GtkSearchEntry" id="search-entry">
|
||||
<accessibility>
|
||||
<property name="label" translatable="yes">Search</property>
|
||||
<relation name="controls">listview</relation>
|
||||
</accessibility>
|
||||
</object>
|
||||
@@ -79,15 +76,15 @@
|
||||
<style>
|
||||
<class name="sidebar"/>
|
||||
</style>
|
||||
<property name="width-request">120</property>
|
||||
<property name="hscrollbar-policy">never</property>
|
||||
<property name="propagate-natural-width">1</property>
|
||||
<property name="min-content-width">150</property>
|
||||
<property name="vexpand">1</property>
|
||||
<child>
|
||||
<object class="GtkListView" id="listview">
|
||||
<style>
|
||||
<class name="navigation-sidebar"/>
|
||||
</style>
|
||||
<property name="tab-behavior">item</property>
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="resource">/ui/main-listitem.ui</property>
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user