Compare commits
158 Commits
css-variab
...
gtk-4-8
Author | SHA1 | Date | |
---|---|---|---|
|
7f9f29b7d1 | ||
|
cfdbacbc96 | ||
|
ac5f95f856 | ||
|
6af8a31893 | ||
|
4e0633a6ef | ||
|
7b0c6b6c9c | ||
|
76c7602b92 | ||
|
d671fdab7c | ||
|
fc4044bbce | ||
|
770e5460d2 | ||
|
2c5784977a | ||
|
6c88cc7215 | ||
|
ea1bb79566 | ||
|
d0e3dc7ce0 | ||
|
fec951c2b2 | ||
|
d84dab39b9 | ||
|
40ff1f442b | ||
|
c8b4f0c8e8 | ||
|
52f7afeecd | ||
|
370ab8aa52 | ||
|
08479ae4b2 | ||
|
45d6ffcce8 | ||
|
f3b09a8725 | ||
|
d6d5a22306 | ||
|
512dec54d3 | ||
|
5cf5b9c7f5 | ||
|
c4ddf47d8f | ||
|
fb36c167e1 | ||
|
d221d314b5 | ||
|
069fef6f99 | ||
|
5caecf16ac | ||
|
8203b69e74 | ||
|
189c1dd306 | ||
|
a4512a4c95 | ||
|
ce01d7d7a3 | ||
|
a4758db75e | ||
|
6a991cf05a | ||
|
0c83807a5a | ||
|
254eca269a | ||
|
a59bf6e3cc | ||
|
b06294d5d7 | ||
|
3f9b7dd863 | ||
|
3b36459630 | ||
|
5c4f3a1943 | ||
|
b53bd5b670 | ||
|
6257243574 | ||
|
e18e99209e | ||
|
8e9e32abaf | ||
|
f4768f16c8 | ||
|
790b9d59ad | ||
|
37843ec941 | ||
|
1ef03e6eb8 | ||
|
1ff3a26c96 | ||
|
92ebf8ab13 | ||
|
7169d346ec | ||
|
162b061ad2 | ||
|
83284e6a9d | ||
|
4a38d5d1d5 | ||
|
a87b3f63ec | ||
|
66091f8139 | ||
|
46eebcb2ac | ||
|
1e27563425 | ||
|
2aaefd9ff6 | ||
|
826030dcc2 | ||
|
748b68d58b | ||
|
74ed1b9e35 | ||
|
793831af8a | ||
|
d51734d83b | ||
|
40ed5ed494 | ||
|
9b75292a63 | ||
|
db5543e83b | ||
|
5844ecf381 | ||
|
afaeadcf67 | ||
|
14823c6bd6 | ||
|
a2d95db723 | ||
|
ecbfccfc55 | ||
|
ef6f9cd7c6 | ||
|
9df10fa96f | ||
|
779f8063d3 | ||
|
24508e07f0 | ||
|
dcc0da218a | ||
|
70cb06abcd | ||
|
1f40e88153 | ||
|
93df6447fa | ||
|
1e60aa122a | ||
|
cee282a282 | ||
|
19aa79d511 | ||
|
55d8469fde | ||
|
8d4a14e082 | ||
|
3ab28f8f8e | ||
|
55dd442955 | ||
|
9f4baac5a2 | ||
|
0dbf91123d | ||
|
4733352ce3 | ||
|
aabae92482 | ||
|
b2380a21ef | ||
|
573204987c | ||
|
2f84859847 | ||
|
f4abf696f2 | ||
|
dc59b1c588 | ||
|
88c6c55d3a | ||
|
c7185c65c9 | ||
|
d758ea2e5e | ||
|
4a04cf610e | ||
|
9252b88c23 | ||
|
b2356dbe7b | ||
|
5186430d9d | ||
|
272e354d57 | ||
|
b17ccd13e6 | ||
|
b061d413e4 | ||
|
3ec2526776 | ||
|
e50fbb6c86 | ||
|
753c6f2435 | ||
|
cc5ba83eba | ||
|
3b940b12f6 | ||
|
205783d9b0 | ||
|
873c304a94 | ||
|
e551a9d1c4 | ||
|
824ff01eee | ||
|
9b74027dea | ||
|
5b98e171b2 | ||
|
f7d4a52ec3 | ||
|
1e5b47c7ef | ||
|
953c2ec3ae | ||
|
ff8aadba7b | ||
|
381c056070 | ||
|
f70c3548e1 | ||
|
5863ddbfdd | ||
|
c1c1daba40 | ||
|
339b9eb1b9 | ||
|
f569318d6f | ||
|
c5beeddff0 | ||
|
81b8426360 | ||
|
bb61b5fb5b | ||
|
b760f57ae1 | ||
|
070926a4cc | ||
|
7a183681b1 | ||
|
14c7a001a6 | ||
|
bcad03da6c | ||
|
5d9576abb9 | ||
|
b86c91de1d | ||
|
a0d85f36ab | ||
|
8455b9ac74 | ||
|
e87801f7e6 | ||
|
a4df9f3d09 | ||
|
f2ccb4192e | ||
|
b71b7ea47f | ||
|
ec9f9d9e96 | ||
|
52dd917c6a | ||
|
8070cfd173 | ||
|
47b7988ccb | ||
|
79eab08797 | ||
|
2ca2a15637 | ||
|
82ca302ec4 | ||
|
6387863256 | ||
|
8c24e1467d | ||
|
e7984a84cb | ||
|
a66b3caa1a |
@@ -1,4 +1,4 @@
|
|||||||
# See https://www.apertis.org/policies/coding_conventions/#code-formatting
|
# See https://wiki.apertis.org/Guidelines/Coding_conventions#Code_formatting
|
||||||
BasedOnStyle: GNU
|
BasedOnStyle: GNU
|
||||||
AlwaysBreakAfterDefinitionReturnType: All
|
AlwaysBreakAfterDefinitionReturnType: All
|
||||||
BreakBeforeBinaryOperators: None
|
BreakBeforeBinaryOperators: None
|
||||||
|
1
.gitignore
vendored
@@ -1,2 +1 @@
|
|||||||
/subprojects/*/
|
/subprojects/*/
|
||||||
.flatpak-builder/
|
|
||||||
|
364
.gitlab-ci.yml
@@ -22,43 +22,29 @@ stages:
|
|||||||
|
|
||||||
# Common variables
|
# Common variables
|
||||||
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"
|
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
|
MESON_TEST_TIMEOUT_MULTIPLIER: 3
|
||||||
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v49"
|
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v39"
|
||||||
|
FLATPAK_IMAGE: "quay.io/gnome_infrastructure/gnome-runtime-images:gnome-master"
|
||||||
|
|
||||||
workflow:
|
.only-default:
|
||||||
rules:
|
only:
|
||||||
# run merge request pipelines
|
- branches
|
||||||
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
except:
|
||||||
# do not run branch pipelines if corresponding merge requests exist...
|
- tags
|
||||||
# (this avoids duplicate pipelines)
|
|
||||||
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
|
|
||||||
when: never
|
|
||||||
# ...but otherwise run branch pipelines
|
|
||||||
- if: $CI_COMMIT_BRANCH
|
|
||||||
# run tag pipelines
|
|
||||||
- if: $CI_COMMIT_TAG
|
|
||||||
|
|
||||||
default:
|
|
||||||
retry:
|
|
||||||
max: 2
|
|
||||||
when:
|
|
||||||
- 'runner_system_failure'
|
|
||||||
- 'stuck_or_timeout_failure'
|
|
||||||
- 'scheduler_failure'
|
|
||||||
- 'api_failure'
|
|
||||||
interruptible: true
|
|
||||||
|
|
||||||
style-check-diff:
|
style-check-diff:
|
||||||
|
extends: .only-default
|
||||||
image: $FEDORA_IMAGE
|
image: $FEDORA_IMAGE
|
||||||
stage: check
|
stage: check
|
||||||
when: manual
|
allow_failure: true
|
||||||
script:
|
script:
|
||||||
- .gitlab-ci/run-style-check-diff.sh
|
- .gitlab-ci/run-style-check-diff.sh
|
||||||
|
|
||||||
.build-fedora-default:
|
.build-fedora-default:
|
||||||
|
extends: .only-default
|
||||||
image: $FEDORA_IMAGE
|
image: $FEDORA_IMAGE
|
||||||
artifacts:
|
artifacts:
|
||||||
when: always
|
when: always
|
||||||
@@ -66,8 +52,6 @@ style-check-diff:
|
|||||||
junit:
|
junit:
|
||||||
- "${CI_PROJECT_DIR}/_build/report-x11.xml"
|
- "${CI_PROJECT_DIR}/_build/report-x11.xml"
|
||||||
- "${CI_PROJECT_DIR}/_build/report-wayland.xml"
|
- "${CI_PROJECT_DIR}/_build/report-wayland.xml"
|
||||||
- "${CI_PROJECT_DIR}/_build/report-wayland_gl.xml"
|
|
||||||
- "${CI_PROJECT_DIR}/_build/report-wayland_gles2.xml"
|
|
||||||
- "${CI_PROJECT_DIR}/_build/report-broadway.xml"
|
- "${CI_PROJECT_DIR}/_build/report-broadway.xml"
|
||||||
name: "gtk-${CI_COMMIT_REF_NAME}"
|
name: "gtk-${CI_COMMIT_REF_NAME}"
|
||||||
paths:
|
paths:
|
||||||
@@ -78,14 +62,17 @@ style-check-diff:
|
|||||||
- "${CI_PROJECT_DIR}/_build/testsuite/reftests/output/*/*.node"
|
- "${CI_PROJECT_DIR}/_build/testsuite/reftests/output/*/*.node"
|
||||||
- "${CI_PROJECT_DIR}/_build/testsuite/tools/output/*/*"
|
- "${CI_PROJECT_DIR}/_build/testsuite/tools/output/*/*"
|
||||||
- "${CI_PROJECT_DIR}/_build/testsuite/gsk/compare/*/*/*.png"
|
- "${CI_PROJECT_DIR}/_build/testsuite/gsk/compare/*/*/*.png"
|
||||||
- "${CI_PROJECT_DIR}/_build/testsuite/gsk/compare/*/*/*.node"
|
|
||||||
- "${CI_PROJECT_DIR}/_build/testsuite/css/output/*/*.syscap"
|
- "${CI_PROJECT_DIR}/_build/testsuite/css/output/*/*.syscap"
|
||||||
- "${CI_PROJECT_DIR}/_build/testsuite/headless/*/*.log"
|
|
||||||
- "${CI_PROJECT_DIR}/_build_hello/meson-logs"
|
- "${CI_PROJECT_DIR}/_build_hello/meson-logs"
|
||||||
cache:
|
cache:
|
||||||
key: "$CI_JOB_NAME"
|
key: "$CI_JOB_NAME"
|
||||||
paths:
|
paths:
|
||||||
- _ccache/
|
- _ccache/
|
||||||
|
- subprojects/gdk-pixbuf/
|
||||||
|
- subprojects/glib/
|
||||||
|
- subprojects/graphene/
|
||||||
|
- subprojects/libepoxy/
|
||||||
|
- subprojects/pango/
|
||||||
|
|
||||||
fedora-x86_64:
|
fedora-x86_64:
|
||||||
extends: .build-fedora-default
|
extends: .build-fedora-default
|
||||||
@@ -93,21 +80,24 @@ fedora-x86_64:
|
|||||||
needs: []
|
needs: []
|
||||||
variables:
|
variables:
|
||||||
EXTRA_MESON_FLAGS: "--buildtype=debug --default-library=both"
|
EXTRA_MESON_FLAGS: "--buildtype=debug --default-library=both"
|
||||||
|
before_script:
|
||||||
|
- PATH="/home/user/.local/bin:$PATH"
|
||||||
script:
|
script:
|
||||||
- .gitlab-ci/show-info-linux.sh
|
- .gitlab-ci/show-info-linux.sh
|
||||||
- export PATH="$HOME/.local/bin:$PATH"
|
- pip3 install --user meson~=0.64
|
||||||
- meson subprojects download
|
|
||||||
- meson subprojects update --reset
|
- meson subprojects update --reset
|
||||||
- meson setup
|
- mkdir _install
|
||||||
${COMMON_MESON_FLAGS}
|
- meson --prefix=${CI_PROJECT_DIR}/_install
|
||||||
${EXTRA_MESON_FLAGS}
|
${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} ${BACKEND_FLAGS} ${FEATURE_FLAGS}
|
||||||
${BACKEND_FLAGS}
|
|
||||||
${FEATURE_FLAGS}
|
|
||||||
_build
|
_build
|
||||||
- meson compile -C _build
|
- meson compile -C _build
|
||||||
- .gitlab-ci/run-tests.sh _build x11 gtk
|
- meson install -C _build
|
||||||
# only repeat test runs that are likely affected by test setups
|
- PKG_CONFIG_PATH=${CI_PROJECT_DIR}/_install/lib64/pkgconfig:${CI_PROJECT_DIR}/_install/share/pkgconfig meson setup _build_hello examples/hello
|
||||||
- .gitlab-ci/run-tests.sh _build wayland_gl gtk:gdk,gtk:gsk-gl
|
- 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 waylandgles
|
||||||
|
- .gitlab-ci/run-tests.sh _build broadway
|
||||||
|
|
||||||
release-build:
|
release-build:
|
||||||
extends: .build-fedora-default
|
extends: .build-fedora-default
|
||||||
@@ -115,46 +105,18 @@ release-build:
|
|||||||
needs: []
|
needs: []
|
||||||
variables:
|
variables:
|
||||||
EXTRA_MESON_FLAGS: "--buildtype=release"
|
EXTRA_MESON_FLAGS: "--buildtype=release"
|
||||||
|
before_script:
|
||||||
|
- PATH="/home/user/.local/bin:$PATH"
|
||||||
script:
|
script:
|
||||||
- .gitlab-ci/show-info-linux.sh
|
- .gitlab-ci/show-info-linux.sh
|
||||||
- export PATH="$HOME/.local/bin:$PATH"
|
- pip3 install --user meson~=0.64
|
||||||
- meson subprojects download
|
- rm -rf subprojects/glib
|
||||||
|
- meson subprojects download glib
|
||||||
- meson subprojects update --reset
|
- meson subprojects update --reset
|
||||||
- mkdir _install
|
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} ${BACKEND_FLAGS} ${FEATURE_FLAGS}
|
||||||
- meson setup
|
|
||||||
--prefix=${CI_PROJECT_DIR}/_install
|
|
||||||
${COMMON_MESON_FLAGS}
|
|
||||||
${EXTRA_MESON_FLAGS}
|
|
||||||
${BACKEND_FLAGS}
|
|
||||||
${FEATURE_FLAGS}
|
|
||||||
_build
|
_build
|
||||||
- meson compile -C _build
|
- ninja -C _build
|
||||||
- meson install -C _build
|
- .gitlab-ci/run-tests.sh _build x11
|
||||||
- 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 wayland gtk
|
|
||||||
# only repeat test runs that are likely affected by test setups
|
|
||||||
- .gitlab-ci/run-tests.sh _build wayland_gles2 gtk:gdk,gtk:gsk-gl
|
|
||||||
|
|
||||||
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:
|
fedora-mingw64:
|
||||||
extends: .build-fedora-default
|
extends: .build-fedora-default
|
||||||
@@ -172,16 +134,44 @@ fedora-mingw64:
|
|||||||
mingw64-libepoxy
|
mingw64-libepoxy
|
||||||
mingw64-pango
|
mingw64-pango
|
||||||
# mingw64-graphene (rawhide)
|
# mingw64-graphene (rawhide)
|
||||||
|
- PATH="/home/user/.local/bin:$PATH"
|
||||||
script:
|
script:
|
||||||
- .gitlab-ci/show-info-linux.sh
|
- .gitlab-ci/show-info-linux.sh
|
||||||
- export PATH="$HOME/.local/bin:$PATH"
|
- pip3 install --user meson~=0.64
|
||||||
- pip3 install --user meson~=1.0
|
|
||||||
- meson subprojects download
|
|
||||||
- meson subprojects update --reset
|
- meson subprojects update --reset
|
||||||
- meson -Dintrospection=disabled -Dgraphene:introspection=disabled _build
|
- mkdir _build && cd _build
|
||||||
- meson compile -C _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
|
||||||
|
before_script:
|
||||||
|
- PATH="/home/user/.local/bin:$PATH"
|
||||||
|
script:
|
||||||
|
- .gitlab-ci/show-info-linux.sh
|
||||||
|
- pip3 install --user meson~=0.64
|
||||||
|
- meson subprojects update --reset
|
||||||
|
- 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:
|
.mingw-defaults:
|
||||||
|
extends: .only-default
|
||||||
stage: build
|
stage: build
|
||||||
tags:
|
tags:
|
||||||
- win32-ps
|
- win32-ps
|
||||||
@@ -211,64 +201,39 @@ msys2-mingw64:
|
|||||||
- "${CI_PROJECT_DIR}/_build/gtkdll.tar.gz"
|
- "${CI_PROJECT_DIR}/_build/gtkdll.tar.gz"
|
||||||
|
|
||||||
macos:
|
macos:
|
||||||
rules:
|
extends: .only-default
|
||||||
# Do not run in forks as the runner is not available there.
|
only:
|
||||||
# (except for dehesselle who maintains the runner)
|
- branches@GNOME/gtk
|
||||||
- if: $CI_PROJECT_NAMESPACE != "GNOME" && $CI_PROJECT_NAMESPACE != "dehesselle"
|
|
||||||
when: never
|
|
||||||
- if: $RUNNER == "macosintel"
|
|
||||||
variables:
|
|
||||||
SDKROOT: /opt/sdks/MacOSX10.13.4.sdk
|
|
||||||
NINJA_PKG: $CI_API_V4_URL/projects/30745/packages/generic/ninja_macos/v1.11.1.1+9/ninja-1.11.1.1-cp38-cp38-macosx_11_0_x86_64.whl
|
|
||||||
when: manual
|
|
||||||
allow_failure: true
|
|
||||||
- if: $RUNNER == "macosarm"
|
|
||||||
variables:
|
|
||||||
SDKROOT: /opt/sdks/MacOSX11.3.sdk
|
|
||||||
NINJA_PKG: ninja==1.11.1.1
|
|
||||||
stage: build
|
stage: build
|
||||||
parallel:
|
|
||||||
matrix:
|
|
||||||
- RUNNER: [ "macosintel", "macosarm" ]
|
|
||||||
tags:
|
tags:
|
||||||
- ${RUNNER}
|
- macos
|
||||||
needs: []
|
needs: []
|
||||||
variables:
|
|
||||||
EXTRA_MESON_FLAGS: ""
|
|
||||||
BACKEND_FLAGS: "-Dx11-backend=false -Dbroadway-backend=true"
|
|
||||||
FEATURE_FLAGS: "-Dmedia-gstreamer=disabled -Dintrospection=enabled -Dgobject-introspection:werror=false"
|
|
||||||
TMPDIR: /Users/Shared/work/tmp
|
|
||||||
PIP_CACHE_DIR: /Users/Shared/build/cache
|
|
||||||
PIPENV_CACHE_DIR: $PIP_CACHE_DIR
|
|
||||||
PYTHONPYCACHEPREFIX: $PIP_CACHE_DIR
|
|
||||||
before_script:
|
before_script:
|
||||||
- .gitlab-ci/show-info-macos.sh
|
- bash .gitlab-ci/show-info-osx.sh
|
||||||
- python3 -m venv .venv
|
- pip3 install --user meson~=0.64
|
||||||
# Building the introspection feature requires pkg-config and bison.
|
- pip3 install --user ninja
|
||||||
- curl -L $CI_API_V4_URL/projects/30437/packages/generic/pkgconfig/v0.29.2+10/pkg-config-0.29.2+10_$(uname -m).tar.xz | tar -C .venv -xJ
|
- export PATH=/Users/gitlabrunner/Library/Python/3.7/bin:$PATH
|
||||||
- curl -L $CI_API_V4_URL/projects/30438/packages/generic/bison/v3.8.2+3/bison-3.8.2+3_$(uname -m).tar.xz | tar -C .venv -xJ
|
- export MESON_FORCE_BACKTRACE=1
|
||||||
- source .venv/bin/activate
|
|
||||||
- pip3 install meson==1.3.2 $NINJA_PKG
|
|
||||||
# We're not setting up ccache here on purpose as it accelerates the build
|
|
||||||
# so much that it triggers race conditions in the gobject-introspection
|
|
||||||
# subproject.
|
|
||||||
script:
|
script:
|
||||||
- meson setup
|
- meson -Dx11-backend=false
|
||||||
${COMMON_MESON_FLAGS}
|
-Dbroadway-backend=true
|
||||||
${EXTRA_MESON_FLAGS}
|
-Dmacos-backend=true
|
||||||
${BACKEND_FLAGS}
|
-Dmedia-gstreamer=disabled
|
||||||
${FEATURE_FLAGS}
|
-Dintrospection=disabled
|
||||||
|
-Dcpp_std=c++11
|
||||||
|
-Dpixman:tests=disabled
|
||||||
_build
|
_build
|
||||||
- meson compile -C _build
|
- ninja -C _build
|
||||||
artifacts:
|
artifacts:
|
||||||
when: always
|
when: always
|
||||||
paths:
|
paths:
|
||||||
- "${CI_PROJECT_DIR}/_build/meson-logs"
|
- "${CI_PROJECT_DIR}/_build/meson-logs"
|
||||||
|
|
||||||
vs2017-x64:
|
vs2017-x64:
|
||||||
|
extends: .only-default
|
||||||
# TODO: Uncomment this when ready to merge.
|
# TODO: Uncomment this when ready to merge.
|
||||||
# rules:
|
#only:
|
||||||
# - if: $CI_PROJECT_NAMESPACE == "GNOME"
|
# - branches@GNOME/gtk
|
||||||
stage: build
|
stage: build
|
||||||
tags:
|
tags:
|
||||||
- win32-ps
|
- win32-ps
|
||||||
@@ -281,7 +246,7 @@ vs2017-x64:
|
|||||||
- "${CI_PROJECT_DIR}/_build/meson-logs"
|
- "${CI_PROJECT_DIR}/_build/meson-logs"
|
||||||
|
|
||||||
.flatpak-defaults:
|
.flatpak-defaults:
|
||||||
image: "quay.io/gnome_infrastructure/gnome-runtime-images:gnome-master"
|
image: $FLATPAK_IMAGE
|
||||||
stage: flatpak
|
stage: flatpak
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
tags:
|
tags:
|
||||||
@@ -291,67 +256,65 @@ vs2017-x64:
|
|||||||
- "${APPID}-dev.flatpak"
|
- "${APPID}-dev.flatpak"
|
||||||
- 'repo.tar'
|
- 'repo.tar'
|
||||||
expire_in: 1 day
|
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:
|
script:
|
||||||
- bash -x ./.gitlab-ci/flatpak-build.sh "${APPID}"
|
- bash -x ./.gitlab-ci/flatpak-build.sh "${APPID}"
|
||||||
|
|
||||||
flatpak:demo:
|
# Manual jobs, for branches and MRs
|
||||||
extends: '.flatpak-defaults'
|
.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: []
|
needs: []
|
||||||
variables:
|
variables:
|
||||||
APPID: org.gtk.Demo4
|
APPID: org.gtk.Demo4
|
||||||
|
|
||||||
flatpak:demo:aarch64:
|
flatpak-main:demo:
|
||||||
extends: '.flatpak-defaults'
|
extends: .flatpak-main
|
||||||
needs: []
|
needs: []
|
||||||
tags:
|
|
||||||
- flatpak-aarch64
|
|
||||||
variables:
|
variables:
|
||||||
APPID: org.gtk.Demo4
|
APPID: org.gtk.Demo4
|
||||||
|
|
||||||
flatpak:widget-factory:
|
flatpak-manual:widget-factory:
|
||||||
extends: '.flatpak-defaults'
|
extends: .flatpak-manual
|
||||||
needs: []
|
needs: []
|
||||||
variables:
|
variables:
|
||||||
APPID: org.gtk.WidgetFactory4
|
APPID: org.gtk.WidgetFactory4
|
||||||
|
|
||||||
flatpak:widget-factory:aarch64:
|
flatpak-main:widget-factory:
|
||||||
extends: '.flatpak-defaults'
|
extends: .flatpak-main
|
||||||
needs: []
|
needs: []
|
||||||
tags:
|
|
||||||
- flatpak-aarch64
|
|
||||||
variables:
|
variables:
|
||||||
APPID: org.gtk.WidgetFactory4
|
APPID: org.gtk.WidgetFactory4
|
||||||
|
|
||||||
flatpak:icon-browser:
|
flatpak-manual:icon-browser:
|
||||||
extends: '.flatpak-defaults'
|
extends: .flatpak-manual
|
||||||
needs: []
|
needs: []
|
||||||
variables:
|
variables:
|
||||||
APPID: org.gtk.IconBrowser4
|
APPID: org.gtk.IconBrowser4
|
||||||
|
|
||||||
flatpak:icon-browser:aarch64:
|
flatpak-main:icon-browser:
|
||||||
extends: '.flatpak-defaults'
|
extends: .flatpak-main
|
||||||
needs: []
|
needs: []
|
||||||
tags:
|
|
||||||
- flatpak-aarch64
|
|
||||||
variables:
|
variables:
|
||||||
APPID: org.gtk.IconBrowser4
|
APPID: org.gtk.IconBrowser4
|
||||||
|
|
||||||
flatpak:node-editor:
|
flatpak-manual:node-editor:
|
||||||
extends: '.flatpak-defaults'
|
extends: .flatpak-manual
|
||||||
needs: []
|
needs: []
|
||||||
variables:
|
variables:
|
||||||
APPID: org.gtk.gtk4.NodeEditor
|
APPID: org.gtk.gtk4.NodeEditor
|
||||||
|
|
||||||
flatpak:node-editor:aarch64:
|
flatpak-main:node-editor:
|
||||||
extends: '.flatpak-defaults'
|
extends: .flatpak-main
|
||||||
needs: []
|
needs: []
|
||||||
tags:
|
|
||||||
- flatpak-aarch64
|
|
||||||
variables:
|
variables:
|
||||||
APPID: org.gtk.gtk4.NodeEditor
|
APPID: org.gtk.gtk4.NodeEditor
|
||||||
|
|
||||||
@@ -360,35 +323,23 @@ flatpak:node-editor:aarch64:
|
|||||||
# https://gitlab.gnome.org/GNOME/Initiatives/-/wikis/DevOps-with-Flatpak
|
# https://gitlab.gnome.org/GNOME/Initiatives/-/wikis/DevOps-with-Flatpak
|
||||||
nightly demo:
|
nightly demo:
|
||||||
extends: '.publish_nightly'
|
extends: '.publish_nightly'
|
||||||
needs: ['flatpak:demo']
|
dependencies: ['flatpak-main:demo']
|
||||||
|
needs: ['flatpak-main:demo']
|
||||||
nightly demo aarch64:
|
|
||||||
extends: '.publish_nightly'
|
|
||||||
needs: ['flatpak:demo:aarch64']
|
|
||||||
|
|
||||||
nightly factory:
|
nightly factory:
|
||||||
extends: '.publish_nightly'
|
extends: '.publish_nightly'
|
||||||
needs: ['flatpak:widget-factory']
|
dependencies: ['flatpak-main:widget-factory']
|
||||||
|
needs: ['flatpak-main:widget-factory']
|
||||||
nightly factory aarch64:
|
|
||||||
extends: '.publish_nightly'
|
|
||||||
needs: ['flatpak:widget-factory:aarch64']
|
|
||||||
|
|
||||||
nightly icon-browser:
|
nightly icon-browser:
|
||||||
extends: '.publish_nightly'
|
extends: '.publish_nightly'
|
||||||
needs: ['flatpak:icon-browser']
|
dependencies: ['flatpak-main:icon-browser']
|
||||||
|
needs: ['flatpak-main:icon-browser']
|
||||||
nightly icon-browser aarch64:
|
|
||||||
extends: '.publish_nightly'
|
|
||||||
needs: ['flatpak:icon-browser:aarch64']
|
|
||||||
|
|
||||||
nightly node-editor:
|
nightly node-editor:
|
||||||
extends: '.publish_nightly'
|
extends: '.publish_nightly'
|
||||||
needs: ['flatpak:node-editor']
|
dependencies: ['flatpak-main:node-editor']
|
||||||
|
needs: ['flatpak-main:node-editor']
|
||||||
nightly node-editor aarch64:
|
|
||||||
extends: '.publish_nightly'
|
|
||||||
needs: ['flatpak:node-editor:aarch64']
|
|
||||||
|
|
||||||
static-scan:
|
static-scan:
|
||||||
image: $FEDORA_IMAGE
|
image: $FEDORA_IMAGE
|
||||||
@@ -396,62 +347,46 @@ static-scan:
|
|||||||
needs: []
|
needs: []
|
||||||
variables:
|
variables:
|
||||||
EXTRA_MESON_FLAGS: "--buildtype=debug"
|
EXTRA_MESON_FLAGS: "--buildtype=debug"
|
||||||
|
before_script:
|
||||||
|
- PATH="/home/user/.local/bin:$PATH"
|
||||||
script:
|
script:
|
||||||
- export PATH="$HOME/.local/bin:$PATH"
|
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} _scan_build
|
||||||
- meson setup
|
|
||||||
${COMMON_MESON_FLAGS}
|
|
||||||
${EXTRA_MESON_FLAGS}
|
|
||||||
${BACKEND_FLAGS}
|
|
||||||
${FEATURE_FLAGS}
|
|
||||||
_scan_build
|
|
||||||
- ninja -C _scan_build scan-build
|
- ninja -C _scan_build scan-build
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- _scan_build/meson-logs
|
- _scan_build/meson-logs
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
|
||||||
# Run tests with the address sanitizer. We need to turn off introspection
|
# Run tests with the address sanitizer. We need to turn off introspection,
|
||||||
# and f16c, since they are incompatible with asan
|
# since it is incompatible with asan
|
||||||
asan-build:
|
asan-build:
|
||||||
image: $FEDORA_IMAGE
|
image: $FEDORA_IMAGE
|
||||||
tags: [ asan ]
|
tags: [ asan ]
|
||||||
stage: analysis
|
stage: analysis
|
||||||
needs: []
|
needs: []
|
||||||
variables:
|
variables:
|
||||||
|
before_script:
|
||||||
|
- PATH="/home/user/.local/bin:$PATH"
|
||||||
script:
|
script:
|
||||||
- export PATH="$HOME/.local/bin:$PATH"
|
- CC=clang meson --buildtype=debugoptimized -Db_sanitize=address -Db_lundef=false -Dintrospection=disabled _build
|
||||||
- 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
|
|
||||||
- ninja -C _build
|
- ninja -C _build
|
||||||
- .gitlab-ci/run-tests.sh _build wayland gtk
|
- .gitlab-ci/run-tests.sh _build wayland
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- _build/meson-logs
|
||||||
|
allow_failure: true
|
||||||
|
|
||||||
reference:
|
reference:
|
||||||
image: $FEDORA_IMAGE
|
image: $FEDORA_IMAGE
|
||||||
stage: docs
|
stage: docs
|
||||||
needs: []
|
needs: []
|
||||||
|
variables:
|
||||||
|
EXTRA_MESON_FLAGS: "--buildtype=release --force-fallback-for=gdk-pixbuf,pango"
|
||||||
|
before_script:
|
||||||
|
- PATH="/home/user/.local/bin:$PATH"
|
||||||
script:
|
script:
|
||||||
- export PATH="$HOME/.local/bin:$PATH"
|
- pip3 install --user meson~=0.64
|
||||||
- meson setup
|
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} -Dgtk_doc=true -Dgdk-pixbuf:gtk_doc=true -Dpango:gtk_doc=true _build
|
||||||
${COMMON_MESON_FLAGS}
|
|
||||||
--buildtype=release
|
|
||||||
--force-fallback-for=gdk-pixbuf,pango
|
|
||||||
-Dintrospection=enabled
|
|
||||||
-Ddocumentation=true
|
|
||||||
-Dgdk-pixbuf:gtk_doc=true
|
|
||||||
-Dpango:documentation=true
|
|
||||||
-Dbuild-demos=false
|
|
||||||
-Dbuild-examples=false
|
|
||||||
-Dbuild-tests=false
|
|
||||||
-Dbuild-testsuite=false
|
|
||||||
_build
|
|
||||||
- meson compile -C _build
|
- meson compile -C _build
|
||||||
- mkdir -p _reference/
|
- mkdir -p _reference/
|
||||||
- mv _build/docs/reference/gdk/gdk4/ _reference/gdk4/
|
- mv _build/docs/reference/gdk/gdk4/ _reference/gdk4/
|
||||||
@@ -474,10 +409,9 @@ reference:
|
|||||||
publish-docs:
|
publish-docs:
|
||||||
image: fedora:latest
|
image: fedora:latest
|
||||||
stage: publish
|
stage: publish
|
||||||
interruptible: false
|
|
||||||
needs: ['reference']
|
needs: ['reference']
|
||||||
script:
|
script:
|
||||||
- "curl -X POST -F token=${PAGES_TRIGGER_TOKEN} -F ref=docs-gtk-org https://gitlab.gnome.org/api/v4/projects/665/trigger/pipeline"
|
- "curl -X POST -F token=${PAGES_TRIGGER_TOKEN} -F ref=docs-gtk-org https://gitlab.gnome.org/api/v4/projects/665/trigger/pipeline"
|
||||||
rules:
|
only:
|
||||||
- if: $CI_COMMIT_REF_NAME == "main"
|
refs:
|
||||||
|
- main
|
||||||
|
@@ -1,7 +1,9 @@
|
|||||||
FROM fedora:39
|
FROM fedora:36
|
||||||
|
|
||||||
RUN dnf -y install \
|
RUN dnf -y install \
|
||||||
adwaita-icon-theme \
|
adwaita-icon-theme \
|
||||||
|
atk-devel \
|
||||||
|
at-spi2-atk-devel \
|
||||||
avahi-gobject-devel \
|
avahi-gobject-devel \
|
||||||
cairo-devel \
|
cairo-devel \
|
||||||
cairo-gobject-devel \
|
cairo-gobject-devel \
|
||||||
@@ -17,7 +19,6 @@ RUN dnf -y install \
|
|||||||
desktop-file-utils \
|
desktop-file-utils \
|
||||||
diffutils \
|
diffutils \
|
||||||
elfutils-libelf-devel \
|
elfutils-libelf-devel \
|
||||||
expat-devel \
|
|
||||||
fribidi-devel \
|
fribidi-devel \
|
||||||
gcc \
|
gcc \
|
||||||
gcc-c++ \
|
gcc-c++ \
|
||||||
@@ -29,8 +30,7 @@ RUN dnf -y install \
|
|||||||
glib2-static \
|
glib2-static \
|
||||||
glibc-devel \
|
glibc-devel \
|
||||||
glibc-headers \
|
glibc-headers \
|
||||||
glslc \
|
gnome-desktop-testing \
|
||||||
gnupg2 \
|
|
||||||
gobject-introspection-devel \
|
gobject-introspection-devel \
|
||||||
graphene-devel \
|
graphene-devel \
|
||||||
graphviz \
|
graphviz \
|
||||||
@@ -71,22 +71,18 @@ RUN dnf -y install \
|
|||||||
mesa-libEGL-devel \
|
mesa-libEGL-devel \
|
||||||
mesa-libGLES-devel \
|
mesa-libGLES-devel \
|
||||||
meson \
|
meson \
|
||||||
mutter \
|
|
||||||
ninja-build \
|
ninja-build \
|
||||||
pango-devel \
|
pango-devel \
|
||||||
pcre-devel \
|
pcre-devel \
|
||||||
pcre-static \
|
pcre-static \
|
||||||
pipewire \
|
|
||||||
pipewire-gstreamer \
|
|
||||||
python3 \
|
python3 \
|
||||||
python3-docutils \
|
python3-docutils \
|
||||||
python3-gobject \
|
python3-gobject \
|
||||||
python3-jinja2 \
|
python3-jinja2 \
|
||||||
python3-markdown \
|
python3-markdown \
|
||||||
python3-packaging \
|
|
||||||
python3-pip \
|
python3-pip \
|
||||||
python3-pydbus \
|
|
||||||
python3-pygments \
|
python3-pygments \
|
||||||
|
python3-toml \
|
||||||
python3-typogrify \
|
python3-typogrify \
|
||||||
python3-wheel \
|
python3-wheel \
|
||||||
redhat-rpm-config \
|
redhat-rpm-config \
|
||||||
@@ -97,8 +93,9 @@ RUN dnf -y install \
|
|||||||
weston \
|
weston \
|
||||||
weston-libs \
|
weston-libs \
|
||||||
which \
|
which \
|
||||||
wireplumber \
|
|
||||||
xorg-x11-server-Xvfb \
|
xorg-x11-server-Xvfb \
|
||||||
|
&& dnf install -y 'dnf-command(builddep)' \
|
||||||
|
&& dnf builddep -y wayland \
|
||||||
&& dnf clean all
|
&& dnf clean all
|
||||||
|
|
||||||
# Enable sudo for wheel users
|
# Enable sudo for wheel users
|
||||||
|
@@ -20,14 +20,13 @@ flatpak build ${builddir} meson \
|
|||||||
-Dx11-backend=true \
|
-Dx11-backend=true \
|
||||||
-Dwayland-backend=true \
|
-Dwayland-backend=true \
|
||||||
-Dbuild-tests=false \
|
-Dbuild-tests=false \
|
||||||
-Dbuild-testsuite=false \
|
|
||||||
-Dbuild-examples=false \
|
-Dbuild-examples=false \
|
||||||
-Dintrospection=disabled \
|
-Dintrospection=disabled \
|
||||||
-Dbuild-demos=true \
|
-Ddemos=true \
|
||||||
-Dprofile=devel \
|
-Dprofile=devel \
|
||||||
_flatpak_build
|
_flatpak_build
|
||||||
|
|
||||||
flatpak build --env=CI_COMMIT_SHORT_SHA=$CI_COMMIT_SHORT_SHA ${builddir} ninja -C _flatpak_build install
|
flatpak build ${builddir} ninja -C _flatpak_build install
|
||||||
|
|
||||||
flatpak-builder \
|
flatpak-builder \
|
||||||
--user --disable-rofiles-fuse \
|
--user --disable-rofiles-fuse \
|
||||||
|
@@ -324,7 +324,7 @@ for line in args.infile:
|
|||||||
units.append(unit)
|
units.append(unit)
|
||||||
|
|
||||||
report = {}
|
report = {}
|
||||||
report['date'] = datetime.datetime.now(datetime.UTC)
|
report['date'] = datetime.datetime.utcnow()
|
||||||
report['locale_date'] = report['date'].strftime("%c")
|
report['locale_date'] = report['date'].strftime("%c")
|
||||||
report['project_name'] = args.project_name
|
report['project_name'] = args.project_name
|
||||||
report['backend'] = args.backend
|
report['backend'] = args.backend
|
||||||
|
@@ -44,7 +44,7 @@ outfile = args.output
|
|||||||
testsuites = ET.Element('testsuites')
|
testsuites = ET.Element('testsuites')
|
||||||
testsuites.set('id', '{}/{}'.format(args.job_id, args.branch))
|
testsuites.set('id', '{}/{}'.format(args.job_id, args.branch))
|
||||||
testsuites.set('package', args.project_name)
|
testsuites.set('package', args.project_name)
|
||||||
testsuites.set('timestamp', datetime.datetime.now(datetime.UTC).isoformat(timespec='minutes'))
|
testsuites.set('timestamp', datetime.datetime.utcnow().isoformat(timespec='minutes'))
|
||||||
|
|
||||||
suites = {}
|
suites = {}
|
||||||
for line in args.infile:
|
for line in args.infile:
|
||||||
|
@@ -23,7 +23,6 @@ push=0
|
|||||||
list=0
|
list=0
|
||||||
print_help=0
|
print_help=0
|
||||||
no_login=0
|
no_login=0
|
||||||
no_cache=0
|
|
||||||
|
|
||||||
while (($# > 0)); do
|
while (($# > 0)); do
|
||||||
case "${1%%=*}" in
|
case "${1%%=*}" in
|
||||||
@@ -35,7 +34,6 @@ while (($# > 0)); do
|
|||||||
--base|-b) read_arg base "$@" || shift;;
|
--base|-b) read_arg base "$@" || shift;;
|
||||||
--version|-v) read_arg base_version "$@" || shift;;
|
--version|-v) read_arg base_version "$@" || shift;;
|
||||||
--no-login) no_login=1;;
|
--no-login) no_login=1;;
|
||||||
--no-cache) no_cache=1;;
|
|
||||||
*) echo -e "\e[1;31mERROR\e[0m: Unknown option '$1'"; exit 1;;
|
*) echo -e "\e[1;31mERROR\e[0m: Unknown option '$1'"; exit 1;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
@@ -105,21 +103,11 @@ TAG="${REGISTRY}/gnome/gtk/${base}:${base_version}"
|
|||||||
|
|
||||||
if [ $build == 1 ]; then
|
if [ $build == 1 ]; then
|
||||||
echo -e "\e[1;32mBUILDING\e[0m: ${base} as ${TAG}"
|
echo -e "\e[1;32mBUILDING\e[0m: ${base} as ${TAG}"
|
||||||
if [ $no_cache == 0 ]; then
|
|
||||||
${CMD} build \
|
${CMD} build \
|
||||||
${format} \
|
${format} \
|
||||||
--build-arg HOST_USER_ID="$UID" \
|
--build-arg HOST_USER_ID="$UID" \
|
||||||
--tag "${TAG}" \
|
--tag "${TAG}" \
|
||||||
--file "${base}.Dockerfile" .
|
--file "${base}.Dockerfile" .
|
||||||
else
|
|
||||||
${CMD} build \
|
|
||||||
${format} \
|
|
||||||
--no-cache \
|
|
||||||
--build-arg HOST_USER_ID="$UID" \
|
|
||||||
--tag "${TAG}" \
|
|
||||||
--file "${base}.Dockerfile" .
|
|
||||||
fi
|
|
||||||
|
|
||||||
exit $?
|
exit $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -138,8 +126,7 @@ if [ $run == 1 ]; then
|
|||||||
echo -e "\e[1;32mRUNNING\e[0m: ${base} as ${TAG}"
|
echo -e "\e[1;32mRUNNING\e[0m: ${base} as ${TAG}"
|
||||||
${CMD} run \
|
${CMD} run \
|
||||||
--rm \
|
--rm \
|
||||||
--userns=keep-id \
|
--volume "$(pwd)/..:/home/user/app" \
|
||||||
--volume "$(pwd)/..:/home/user/app:rw,z" \
|
|
||||||
--workdir "/home/user/app" \
|
--workdir "/home/user/app" \
|
||||||
--tty \
|
--tty \
|
||||||
--interactive "${TAG}" \
|
--interactive "${TAG}" \
|
||||||
|
@@ -1,32 +0,0 @@
|
|||||||
#!/usr/bin/sh
|
|
||||||
#
|
|
||||||
builddir=$1
|
|
||||||
suite=$2
|
|
||||||
unit=$3
|
|
||||||
|
|
||||||
echo "** builddir: ${builddir}"
|
|
||||||
echo "** suite: ${suite}"
|
|
||||||
echo "** unit: ${unit}"
|
|
||||||
|
|
||||||
export XDG_RUNTIME_DIR="$(mktemp -p $(pwd) -d xdg-runtime-XXXXXX)"
|
|
||||||
|
|
||||||
weston --backend=headless-backend.so --socket=wayland-5 --idle-time=0 &
|
|
||||||
compositor=$!
|
|
||||||
|
|
||||||
export WAYLAND_DISPLAY=wayland-5
|
|
||||||
|
|
||||||
meson test -C ${builddir} \
|
|
||||||
--print-errorlogs \
|
|
||||||
--setup=wayland \
|
|
||||||
--suite=${suite} \
|
|
||||||
--no-suite=failing \
|
|
||||||
--no-suite=flaky \
|
|
||||||
--no-suite=wayland_failing \
|
|
||||||
--no-suite=gsk-compare-broadway \
|
|
||||||
--verbose \
|
|
||||||
"${unit}"
|
|
||||||
|
|
||||||
exit_code=$?
|
|
||||||
kill ${compositor}
|
|
||||||
|
|
||||||
exit ${exit_code}
|
|
@@ -1,31 +1,24 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -x
|
set +x
|
||||||
set +e
|
set +e
|
||||||
|
|
||||||
srcdir=$( pwd )
|
srcdir=$( pwd )
|
||||||
builddir=$1
|
builddir=$1
|
||||||
setup=$2
|
backend=$2
|
||||||
suite=$3
|
|
||||||
multiplier=${MESON_TEST_TIMEOUT_MULTIPLIER:-1}
|
|
||||||
|
|
||||||
# Ignore memory leaks lower in dependencies
|
# 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
|
export G_SLICE=always-malloc
|
||||||
|
|
||||||
case "${setup}" in
|
case "${backend}" in
|
||||||
x11*)
|
x11)
|
||||||
xvfb-run -a -s "-screen 0 1024x768x24 -noreset" \
|
xvfb-run -a -s "-screen 0 1024x768x24 -noreset" \
|
||||||
meson test -C ${builddir} \
|
meson test -C ${builddir} \
|
||||||
--quiet \
|
--timeout-multiplier "${MESON_TEST_TIMEOUT_MULTIPLIER}" \
|
||||||
--timeout-multiplier "${multiplier}" \
|
|
||||||
--print-errorlogs \
|
--print-errorlogs \
|
||||||
--setup=${setup} \
|
--setup=${backend} \
|
||||||
--suite=${suite//,/ --suite=} \
|
--suite=gtk \
|
||||||
--no-suite=failing \
|
|
||||||
--no-suite=${setup}_failing \
|
|
||||||
--no-suite=flaky \
|
|
||||||
--no-suite=headless \
|
|
||||||
--no-suite=gsk-compare-broadway
|
--no-suite=gsk-compare-broadway
|
||||||
|
|
||||||
# Store the exit code for the CI run, but always
|
# Store the exit code for the CI run, but always
|
||||||
@@ -33,7 +26,7 @@ case "${setup}" in
|
|||||||
exit_code=$?
|
exit_code=$?
|
||||||
;;
|
;;
|
||||||
|
|
||||||
wayland*)
|
wayland)
|
||||||
export XDG_RUNTIME_DIR="$(mktemp -p $(pwd) -d xdg-runtime-XXXXXX)"
|
export XDG_RUNTIME_DIR="$(mktemp -p $(pwd) -d xdg-runtime-XXXXXX)"
|
||||||
|
|
||||||
weston --backend=headless-backend.so --socket=wayland-5 --idle-time=0 &
|
weston --backend=headless-backend.so --socket=wayland-5 --idle-time=0 &
|
||||||
@@ -41,22 +34,35 @@ case "${setup}" in
|
|||||||
export WAYLAND_DISPLAY=wayland-5
|
export WAYLAND_DISPLAY=wayland-5
|
||||||
|
|
||||||
meson test -C ${builddir} \
|
meson test -C ${builddir} \
|
||||||
--quiet \
|
--timeout-multiplier "${MESON_TEST_TIMEOUT_MULTIPLIER}" \
|
||||||
--timeout-multiplier "${multiplier}" \
|
|
||||||
--print-errorlogs \
|
--print-errorlogs \
|
||||||
--setup=${setup} \
|
--setup=${backend} \
|
||||||
--suite=${suite//,/ --suite=} \
|
--suite=gtk \
|
||||||
--no-suite=failing \
|
|
||||||
--no-suite=${setup}_failing \
|
|
||||||
--no-suite=flaky \
|
|
||||||
--no-suite=headless \
|
|
||||||
--no-suite=gsk-compare-broadway
|
--no-suite=gsk-compare-broadway
|
||||||
exit_code=$?
|
|
||||||
|
|
||||||
|
exit_code=$?
|
||||||
kill ${compositor}
|
kill ${compositor}
|
||||||
;;
|
;;
|
||||||
|
|
||||||
broadway*)
|
waylandgles)
|
||||||
|
export XDG_RUNTIME_DIR="$(mktemp -p $(pwd) -d xdg-runtime-XXXXXX)"
|
||||||
|
|
||||||
|
weston --backend=headless-backend.so --socket=wayland-6 --idle-time=0 &
|
||||||
|
compositor=$!
|
||||||
|
export WAYLAND_DISPLAY=wayland-6
|
||||||
|
|
||||||
|
meson test -C ${builddir} \
|
||||||
|
--timeout-multiplier "${MESON_TEST_TIMEOUT_MULTIPLIER}" \
|
||||||
|
--print-errorlogs \
|
||||||
|
--setup=${backend} \
|
||||||
|
--suite=gtk \
|
||||||
|
--no-suite=gsk-compare-broadway
|
||||||
|
|
||||||
|
exit_code=$?
|
||||||
|
kill ${compositor}
|
||||||
|
;;
|
||||||
|
|
||||||
|
broadway)
|
||||||
export XDG_RUNTIME_DIR="$(mktemp -p $(pwd) -d xdg-runtime-XXXXXX)"
|
export XDG_RUNTIME_DIR="$(mktemp -p $(pwd) -d xdg-runtime-XXXXXX)"
|
||||||
|
|
||||||
${builddir}/gdk/broadway/gtk4-broadwayd :5 &
|
${builddir}/gdk/broadway/gtk4-broadwayd :5 &
|
||||||
@@ -64,22 +70,19 @@ case "${setup}" in
|
|||||||
export BROADWAY_DISPLAY=:5
|
export BROADWAY_DISPLAY=:5
|
||||||
|
|
||||||
meson test -C ${builddir} \
|
meson test -C ${builddir} \
|
||||||
--quiet \
|
--timeout-multiplier "${MESON_TEST_TIMEOUT_MULTIPLIER}" \
|
||||||
--timeout-multiplier "${multiplier}" \
|
|
||||||
--print-errorlogs \
|
--print-errorlogs \
|
||||||
--setup=${setup} \
|
--setup=${backend} \
|
||||||
--suite=${suite//,/ --suite=} \
|
--suite=gtk \
|
||||||
--no-suite=failing \
|
|
||||||
--no-suite=${setup}_failing \
|
|
||||||
--no-suite=flaky \
|
|
||||||
--no-suite=headless \
|
|
||||||
--no-suite=gsk-compare-opengl
|
--no-suite=gsk-compare-opengl
|
||||||
|
|
||||||
|
# don't let Broadway failures fail the run, for now
|
||||||
|
exit_code=0
|
||||||
kill ${server}
|
kill ${server}
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
echo "Failed to add ${setup} to .gitlab-ci/run-tests.sh"
|
echo "Failed to add ${backend} to .gitlab-ci/run-tests.sh"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@@ -89,17 +92,16 @@ cd ${builddir}
|
|||||||
|
|
||||||
$srcdir/.gitlab-ci/meson-junit-report.py \
|
$srcdir/.gitlab-ci/meson-junit-report.py \
|
||||||
--project-name=gtk \
|
--project-name=gtk \
|
||||||
--backend="${setup}" \
|
--backend=${backend} \
|
||||||
--job-id="${CI_JOB_NAME}" \
|
--job-id="${CI_JOB_NAME}" \
|
||||||
--output="report-${setup}.xml" \
|
--output=report-${backend}.xml \
|
||||||
"meson-logs/testlog-${setup}.json"
|
meson-logs/testlog-${backend}.json
|
||||||
|
|
||||||
$srcdir/.gitlab-ci/meson-html-report.py \
|
$srcdir/.gitlab-ci/meson-html-report.py \
|
||||||
--project-name=gtk \
|
--project-name=gtk \
|
||||||
--backend="${setup}" \
|
--backend=${backend} \
|
||||||
--job-id="${CI_JOB_NAME}" \
|
--job-id="${CI_JOB_NAME}" \
|
||||||
--reftest-output-dir="testsuite/reftests/output/${setup}" \
|
--reftest-output-dir="testsuite/reftests/output/${backend}" \
|
||||||
--output="report-${setup}.html" \
|
--output=report-${backend}.html \
|
||||||
"meson-logs/testlog-${setup}.json"
|
meson-logs/testlog-${backend}.json
|
||||||
|
|
||||||
exit $exit_code
|
exit $exit_code
|
||||||
|
@@ -3,11 +3,6 @@
|
|||||||
set -eux -o pipefail
|
set -eux -o pipefail
|
||||||
|
|
||||||
xcodebuild -version || :
|
xcodebuild -version || :
|
||||||
|
|
||||||
if [ -z "$SDKROOT" ]; then
|
|
||||||
xcodebuild -showsdks || :
|
xcodebuild -showsdks || :
|
||||||
else
|
|
||||||
echo "SDKROOT = $SDKROOT"
|
|
||||||
fi
|
|
||||||
|
|
||||||
system_profiler SPSoftwareDataType || :
|
system_profiler SPSoftwareDataType || :
|
@@ -5,8 +5,8 @@ call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliar
|
|||||||
@echo on
|
@echo on
|
||||||
|
|
||||||
:: FIXME: make warnings fatal
|
:: FIXME: make warnings fatal
|
||||||
pip3 install --upgrade --user meson~=0.64 || goto :error
|
pip3 install --upgrade --user meson==0.60.3 || goto :error
|
||||||
meson setup -Dbackend_max_links=1 -Ddebug=false -Dmedia-gstreamer=disabled -Dvulkan=disabled _build || goto :error
|
meson -Ddebug=false -Dmedia-gstreamer=disabled _build || goto :error
|
||||||
ninja -C _build || goto :error
|
ninja -C _build || goto :error
|
||||||
|
|
||||||
goto :EOF
|
goto :EOF
|
||||||
|
@@ -32,10 +32,7 @@ pacman --noconfirm -S --needed \
|
|||||||
mingw-w64-$MSYS2_ARCH-fribidi \
|
mingw-w64-$MSYS2_ARCH-fribidi \
|
||||||
mingw-w64-$MSYS2_ARCH-gst-plugins-bad-libs \
|
mingw-w64-$MSYS2_ARCH-gst-plugins-bad-libs \
|
||||||
mingw-w64-$MSYS2_ARCH-shared-mime-info \
|
mingw-w64-$MSYS2_ARCH-shared-mime-info \
|
||||||
mingw-w64-$MSYS2_ARCH-python-gobject \
|
mingw-w64-$MSYS2_ARCH-python-gobject
|
||||||
mingw-w64-$MSYS2_ARCH-shaderc \
|
|
||||||
mingw-w64-$MSYS2_ARCH-vulkan \
|
|
||||||
mingw-w64-$MSYS2_ARCH-vulkan-headers
|
|
||||||
|
|
||||||
mkdir -p _ccache
|
mkdir -p _ccache
|
||||||
export CCACHE_BASEDIR="$(pwd)"
|
export CCACHE_BASEDIR="$(pwd)"
|
||||||
@@ -45,10 +42,11 @@ export CCACHE_DIR="${CCACHE_BASEDIR}/_ccache"
|
|||||||
ccache --zero-stats
|
ccache --zero-stats
|
||||||
ccache --show-stats
|
ccache --show-stats
|
||||||
export CCACHE_DISABLE=true
|
export CCACHE_DISABLE=true
|
||||||
meson setup \
|
meson \
|
||||||
-Dx11-backend=false \
|
-Dx11-backend=false \
|
||||||
-Dwayland-backend=false \
|
-Dwayland-backend=false \
|
||||||
-Dwin32-backend=true \
|
-Dwin32-backend=true \
|
||||||
|
-Dvulkan=disabled \
|
||||||
-Dintrospection=enabled \
|
-Dintrospection=enabled \
|
||||||
-Dgtk:werror=true \
|
-Dgtk:werror=true \
|
||||||
_build
|
_build
|
||||||
|
45
AUTHORS
@@ -7,7 +7,7 @@ Peter Mattis <petm@xcf.berkeley.edu>
|
|||||||
Spencer Kimball <spencer@xcf.berkeley.edu>
|
Spencer Kimball <spencer@xcf.berkeley.edu>
|
||||||
Josh MacDonald <jmacd@xcf.berkeley.edu>
|
Josh MacDonald <jmacd@xcf.berkeley.edu>
|
||||||
|
|
||||||
The team that build GTK 2 (in alphabetical order)
|
The Team that build GTK 2 (in alphabetical order)
|
||||||
-------------------------------------------------
|
-------------------------------------------------
|
||||||
Shawn T. Amundson <amundson@gtk.org>
|
Shawn T. Amundson <amundson@gtk.org>
|
||||||
Jerome Bolliet <bolliet@gtk.org>
|
Jerome Bolliet <bolliet@gtk.org>
|
||||||
@@ -28,8 +28,9 @@ Jay Painter <jpaint@gtk.org>
|
|||||||
Manish Singh <manish@gtk.org>
|
Manish Singh <manish@gtk.org>
|
||||||
Owen Taylor <otaylor@gtk.org>
|
Owen Taylor <otaylor@gtk.org>
|
||||||
|
|
||||||
The team that built GTK 3
|
The current team (GTK 3 and 4)
|
||||||
-------------------------
|
------------------------------
|
||||||
|
|
||||||
Jonas Ådahl <jadahl@gmail.com>
|
Jonas Ådahl <jadahl@gmail.com>
|
||||||
Tim Bäder <mail@baedert.org>
|
Tim Bäder <mail@baedert.org>
|
||||||
Emmanuele Bassi <ebassi@gnome.org>
|
Emmanuele Bassi <ebassi@gnome.org>
|
||||||
@@ -39,16 +40,6 @@ Carlos Garnacho <mrgarnacho@gmail.com>
|
|||||||
Alexander Larsson <alexl@redhat.com>
|
Alexander Larsson <alexl@redhat.com>
|
||||||
Benjamin Otte <otte@gnome.org>
|
Benjamin Otte <otte@gnome.org>
|
||||||
|
|
||||||
The current team (GTK 4)
|
|
||||||
------------------------
|
|
||||||
Jonas Ådahl <jadahl@gmail.com>
|
|
||||||
Emmanuele Bassi <ebassi@gnome.org>
|
|
||||||
Christian Hergert <chergert@gnome.org>
|
|
||||||
Chun-wei Fan <fanchunwei@src.gnome.org>
|
|
||||||
Matthias Clasen <mclasen@redhat.com>
|
|
||||||
Carlos Garnacho <mrgarnacho@gmail.com>
|
|
||||||
Benjamin Otte <otte@gnome.org>
|
|
||||||
|
|
||||||
|
|
||||||
There are many others who have contributed patches; we thank them,
|
There are many others who have contributed patches; we thank them,
|
||||||
GTK is much better because of them.
|
GTK is much better because of them.
|
||||||
@@ -58,15 +49,35 @@ Over time, GTK has incorporated some pieces of software which
|
|||||||
started as independent projects. We list the original authors here:
|
started as independent projects. We list the original authors here:
|
||||||
|
|
||||||
|
|
||||||
|
MS-Windows theme engine
|
||||||
|
-----------------------
|
||||||
|
Raymond Penners
|
||||||
|
Dom Lachowicz
|
||||||
|
|
||||||
|
|
||||||
|
Pixbuf theme engine
|
||||||
|
-------------------
|
||||||
|
Owen Taylor
|
||||||
|
|
||||||
|
|
||||||
IME input method
|
IME input method
|
||||||
----------------
|
----------------
|
||||||
Takuro Ashie
|
Takuro Ashie
|
||||||
Kazuki IWAMOTO
|
Kazuki IWAMOTO
|
||||||
|
|
||||||
MacOS backend
|
|
||||||
-------------
|
Mac OS X backend
|
||||||
|
----------------
|
||||||
Anders Carlsson
|
Anders Carlsson
|
||||||
|
|
||||||
GtkInspector (originally gtkparasite)
|
|
||||||
-------------------------------------
|
DirectFB backend
|
||||||
|
----------------
|
||||||
|
Denis Oliver Kropp
|
||||||
|
Sven Neumann
|
||||||
|
Mike Emmel
|
||||||
|
|
||||||
|
|
||||||
|
gtkparasite
|
||||||
|
-----------
|
||||||
Christian Hammond
|
Christian Hammond
|
||||||
|
@@ -21,7 +21,7 @@ many things that we value:
|
|||||||
Please, do not use the issue tracker for support questions. If you have
|
Please, do not use the issue tracker for support questions. If you have
|
||||||
questions on how to use GTK effectively, you can use:
|
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)
|
- the [gtk tag on the GNOME Discourse instance](https://discourse.gnome.org/tag/gtk)
|
||||||
|
|
||||||
You can also look at the GTK tag on [Stack
|
You can also look at the GTK tag on [Stack
|
||||||
@@ -35,7 +35,8 @@ The issue tracker is meant to be used for actionable issues only.
|
|||||||
|
|
||||||
You should not open a new issue for security related questions.
|
You should not open a new issue for security related questions.
|
||||||
|
|
||||||
When in doubt, follow the process for [GNOME security issues](https://security.gnome.org/).
|
When in doubt, send an email to the [security](mailto:security@gnome.org)
|
||||||
|
mailing list.
|
||||||
|
|
||||||
### Bug reports
|
### Bug reports
|
||||||
|
|
||||||
@@ -43,7 +44,6 @@ If you're reporting a bug make sure to list:
|
|||||||
|
|
||||||
0. which version of GTK are you using?
|
0. which version of GTK are you using?
|
||||||
0. which operating system 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 necessary steps to reproduce the issue
|
||||||
0. the expected outcome
|
0. the expected outcome
|
||||||
0. a description of the behavior; screenshots are also welcome
|
0. a description of the behavior; screenshots are also welcome
|
||||||
@@ -144,28 +144,33 @@ $ git clone https://gitlab.gnome.org/yourusername/gtk.git
|
|||||||
$ cd gtk
|
$ cd gtk
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Note**: if you plan to push changes to back to the main repository and
|
||||||
|
have a GNOME account, you can skip the fork, and use the following instead:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ git clone git@gitlab.gnome.org:GNOME/gtk.git
|
||||||
|
$ cd gtk
|
||||||
|
```
|
||||||
|
|
||||||
To compile the Git version of GTK on your system, you will need to
|
To compile the Git version of GTK on your system, you will need to
|
||||||
configure your build using Meson:
|
configure your build using Meson:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ meson setup _builddir .
|
$ meson _builddir .
|
||||||
$ meson compile -C _builddir
|
$ cd _builddir
|
||||||
|
$ ninja
|
||||||
```
|
```
|
||||||
|
|
||||||
Typically, you should work on your own branch:
|
Typically, you should work on your own branch:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ git switch -C your-branch
|
$ git checkout -b your-branch
|
||||||
```
|
```
|
||||||
|
|
||||||
Once you've finished working on the bug fix or feature, push the branch
|
Once you've finished working on the bug fix or feature, push the branch
|
||||||
to the Git repository and open a new merge request, to let the GTK
|
to the Git repository and open a new merge request, to let the GTK
|
||||||
maintainers review your contribution.
|
maintainers review your contribution.
|
||||||
|
|
||||||
**Important**: Do **not** attach a diff or a patch file to a GitLab issue.
|
|
||||||
Patches cannot be reviewed, and do not not go through the CI pipeline. If
|
|
||||||
you wish to submit your changes to GTK, always use a merge request.
|
|
||||||
|
|
||||||
### Code reviews
|
### Code reviews
|
||||||
|
|
||||||
Each contribution is reviewed by the core developers of the GTK project.
|
Each contribution is reviewed by the core developers of the GTK project.
|
||||||
@@ -208,7 +213,7 @@ Closes #1234
|
|||||||
`git commit -a --author "Joe Coder <joe@coder.org>"` and `--signoff`.
|
`git commit -a --author "Joe Coder <joe@coder.org>"` and `--signoff`.
|
||||||
|
|
||||||
- If your commit is addressing an issue, use the
|
- If your commit is addressing an issue, use the
|
||||||
[GitLab syntax](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
[GitLab syntax](https://docs.gitlab.com/ce/user/project/issues/automatic_issue_closing.html)
|
||||||
to automatically close the issue when merging the commit with the upstream
|
to automatically close the issue when merging the commit with the upstream
|
||||||
repository:
|
repository:
|
||||||
|
|
||||||
@@ -238,11 +243,13 @@ people committing to GTK to follow a few rules:
|
|||||||
code, you should always ask. If your change is minor and you've been
|
code, you should always ask. If your change is minor and you've been
|
||||||
working on GTK for a while it probably isn't necessary to ask. But when
|
working on GTK for a while it probably isn't necessary to ask. But when
|
||||||
in doubt, ask. Even if your change is correct, somebody may know a
|
in doubt, ask. Even if your change is correct, somebody may know a
|
||||||
better way to do things.
|
better way to do things. If you are making changes to GTK, you should
|
||||||
The `gtk` [room on matrix](https://matrix.to/#/#gtk:gnome.org) is also a
|
be subscribed to the [gtk-devel](https://mail.gnome.org/mailman/listinfo/gtk-devel-list)
|
||||||
good place to find GTK developers to discuss changes, but if you live
|
mailing list; this is a good place to ask about intended changes.
|
||||||
outside of the EU/US time zones, the [gtk tag on the GNOME Discourse instance](https://discourse.gnome.org/tag/gtk)
|
The `#gtk` IRC channel on irc.gnome.org is also a good place to find GTK
|
||||||
is the most certain and preferred method.
|
developers to discuss changes, but if you live outside of the EU/US time
|
||||||
|
zones, an email to the gtk-devel mailing list is the most certain and
|
||||||
|
preferred method.
|
||||||
|
|
||||||
0. Ask _first_.
|
0. Ask _first_.
|
||||||
|
|
||||||
@@ -257,4 +264,4 @@ people committing to GTK to follow a few rules:
|
|||||||
|
|
||||||
If you have been contributing to GTK for a while and you don't have commit
|
If you have been contributing to GTK for a while and you don't have commit
|
||||||
access to the repository, you may ask to obtain it following the [GNOME account
|
access to the repository, you may ask to obtain it following the [GNOME account
|
||||||
process](https://handbook.gnome.org/infrastructure/developer-access.html).
|
process](https://wiki.gnome.org/AccountsTeam/NewAccounts).
|
||||||
|
42
README.md
@@ -67,13 +67,6 @@ building for:
|
|||||||
- [Graphene](https://github.com/ebassi/graphene)
|
- [Graphene](https://github.com/ebassi/graphene)
|
||||||
- [Xkb-common](https://github.com/xkbcommon/libxkbcommon)
|
- [Xkb-common](https://github.com/xkbcommon/libxkbcommon)
|
||||||
|
|
||||||
If you are building the Wayland backend, you will also need:
|
|
||||||
|
|
||||||
- Wayland-client
|
|
||||||
- Wayland-protocols
|
|
||||||
- Wayland-cursor
|
|
||||||
- Wayland-EGL
|
|
||||||
|
|
||||||
If you are building the X11 backend, you will also need:
|
If you are building the X11 backend, you will also need:
|
||||||
|
|
||||||
- Xlib, and the following X extensions:
|
- Xlib, and the following X extensions:
|
||||||
@@ -86,24 +79,32 @@ If you are building the X11 backend, you will also need:
|
|||||||
- xdamage
|
- xdamage
|
||||||
- xcomposite
|
- xcomposite
|
||||||
|
|
||||||
|
If you are building the Wayland backend, you will also need:
|
||||||
|
|
||||||
|
- Wayland-client
|
||||||
|
- Wayland-protocols
|
||||||
|
- Wayland-cursor
|
||||||
|
- Wayland-EGL
|
||||||
|
|
||||||
Once you have all the necessary dependencies, you can build GTK by using
|
Once you have all the necessary dependencies, you can build GTK by using
|
||||||
Meson:
|
Meson:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ meson setup _build
|
$ meson _build .
|
||||||
$ meson compile -C_build
|
$ cd _build
|
||||||
|
$ ninja
|
||||||
```
|
```
|
||||||
|
|
||||||
You can run the test suite using:
|
You can run the test suite using:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ meson test -C_build
|
$ meson test
|
||||||
```
|
```
|
||||||
|
|
||||||
And, finally, you can install GTK using:
|
And, finally, you can install GTK using:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ sudo meson install -C_build
|
$ sudo ninja install
|
||||||
```
|
```
|
||||||
|
|
||||||
Complete information about installing GTK and related libraries
|
Complete information about installing GTK and related libraries
|
||||||
@@ -115,17 +116,24 @@ docs/reference/gtk/html/gtk-building.html
|
|||||||
|
|
||||||
Or [online](https://docs.gtk.org/gtk4/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
|
The default development branch of GTK has been renamed to `main`.
|
||||||
development branch is called `main`, and stable branches are named after their minor
|
To update your local checkout, use:
|
||||||
version, for example `gtk-4-10`.
|
```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
|
How to report bugs
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
Bugs should be reported on the [issues page](https://gitlab.gnome.org/GNOME/gtk/issues/).
|
Bugs should be reported on the [issues page](https://gitlab.gnome.org/GNOME/gtk/issues/new).
|
||||||
|
|
||||||
In the bug report please include:
|
In the bug report please include:
|
||||||
|
|
||||||
|
@@ -185,6 +185,7 @@
|
|||||||
"builddir" : true,
|
"builddir" : true,
|
||||||
"config-opts" : [
|
"config-opts" : [
|
||||||
"--libdir=/app/lib",
|
"--libdir=/app/lib",
|
||||||
|
"-Dvulkan=disabled",
|
||||||
"-Dbuildtype=debugoptimized",
|
"-Dbuildtype=debugoptimized",
|
||||||
"-Dprofile=devel"
|
"-Dprofile=devel"
|
||||||
],
|
],
|
||||||
|
@@ -114,6 +114,7 @@
|
|||||||
"builddir" : true,
|
"builddir" : true,
|
||||||
"config-opts" : [
|
"config-opts" : [
|
||||||
"--libdir=/app/lib",
|
"--libdir=/app/lib",
|
||||||
|
"-Dvulkan=disabled",
|
||||||
"-Dbuildtype=debugoptimized",
|
"-Dbuildtype=debugoptimized",
|
||||||
"-Dprofile=devel"
|
"-Dprofile=devel"
|
||||||
],
|
],
|
||||||
|
@@ -114,6 +114,7 @@
|
|||||||
"builddir" : true,
|
"builddir" : true,
|
||||||
"config-opts" : [
|
"config-opts" : [
|
||||||
"--libdir=/app/lib",
|
"--libdir=/app/lib",
|
||||||
|
"-Dvulkan=disabled",
|
||||||
"-Dbuildtype=debugoptimized",
|
"-Dbuildtype=debugoptimized",
|
||||||
"-Dprofile=devel"
|
"-Dprofile=devel"
|
||||||
],
|
],
|
||||||
@@ -130,6 +131,7 @@
|
|||||||
"env" : {
|
"env" : {
|
||||||
"DBUS_SESSION_BUS_ADDRESS" : "''",
|
"DBUS_SESSION_BUS_ADDRESS" : "''",
|
||||||
"GSK_RENDERER" : "opengl",
|
"GSK_RENDERER" : "opengl",
|
||||||
|
"GDK_DEBUG" : "vulkan-disable",
|
||||||
"G_ENABLE_DEBUG" : "true"
|
"G_ENABLE_DEBUG" : "true"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -114,6 +114,7 @@
|
|||||||
"builddir" : true,
|
"builddir" : true,
|
||||||
"config-opts" : [
|
"config-opts" : [
|
||||||
"--libdir=/app/lib",
|
"--libdir=/app/lib",
|
||||||
|
"-Dvulkan=disabled",
|
||||||
"-Dbuildtype=debugoptimized",
|
"-Dbuildtype=debugoptimized",
|
||||||
"-Dprofile=devel"
|
"-Dprofile=devel"
|
||||||
],
|
],
|
||||||
@@ -130,6 +131,7 @@
|
|||||||
"env" : {
|
"env" : {
|
||||||
"DBUS_SESSION_BUS_ADDRESS" : "''",
|
"DBUS_SESSION_BUS_ADDRESS" : "''",
|
||||||
"GSK_RENDERER" : "opengl",
|
"GSK_RENDERER" : "opengl",
|
||||||
|
"GDK_DEBUG" : "vulkan-disable",
|
||||||
"G_ENABLE_DEBUG" : "true"
|
"G_ENABLE_DEBUG" : "true"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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()
|
|
@@ -1,41 +0,0 @@
|
|||||||
#ifndef _MSC_VER
|
|
||||||
#pragma error "This header is for Microsoft VC or clang-cl only."
|
|
||||||
#endif /* _MSC_VER */
|
|
||||||
|
|
||||||
/* Make MSVC more pedantic, this is a recommended pragma list
|
|
||||||
* from _Win32_Programming_ by Rector and Newcomer.
|
|
||||||
*/
|
|
||||||
#ifndef __clang__
|
|
||||||
#pragma warning(error:4002) /* too many actual parameters for macro */
|
|
||||||
#pragma warning(error:4003) /* not enough actual parameters for macro */
|
|
||||||
#pragma warning(1:4010) /* single-line comment contains line-continuation character */
|
|
||||||
#pragma warning(error:4013) /* 'function' undefined; assuming extern returning int */
|
|
||||||
#pragma warning(1:4016) /* no function return type; using int as default */
|
|
||||||
#pragma warning(error:4020) /* too many actual parameters */
|
|
||||||
#pragma warning(error:4021) /* too few actual parameters */
|
|
||||||
#pragma warning(error:4027) /* function declared without formal parameter list */
|
|
||||||
#pragma warning(error:4029) /* declared formal parameter list different from definition */
|
|
||||||
#pragma warning(error:4033) /* 'function' must return a value */
|
|
||||||
#pragma warning(error:4035) /* 'function' : no return value */
|
|
||||||
#pragma warning(error:4045) /* array bounds overflow */
|
|
||||||
#pragma warning(error:4047) /* different levels of indirection */
|
|
||||||
#pragma warning(error:4049) /* terminating line number emission */
|
|
||||||
#pragma warning(error:4053) /* An expression of type void was used as an operand */
|
|
||||||
#pragma warning(error:4071) /* no function prototype given */
|
|
||||||
#pragma warning(disable:4101) /* unreferenced local variable */
|
|
||||||
#pragma warning(error:4150)
|
|
||||||
|
|
||||||
/* G_NORETURN */
|
|
||||||
#pragma warning(error:4646) /* function declared with __declspec(noreturn) has non-void return type */
|
|
||||||
#pragma warning(error:4715) /* 'function': not all control paths return a value */
|
|
||||||
#pragma warning(error:4098) /* 'void' function returning a value */
|
|
||||||
|
|
||||||
#pragma warning(disable:4244) /* No possible loss of data warnings */
|
|
||||||
#pragma warning(disable:4305) /* No truncation from int to char warnings */
|
|
||||||
|
|
||||||
#pragma warning(error:4819) /* The file contains a character that cannot be represented in the current code page */
|
|
||||||
#endif /* __clang__ */
|
|
||||||
|
|
||||||
/* work around Microsoft's premature attempt to deprecate the C-Library */
|
|
||||||
#define _CRT_SECURE_NO_WARNINGS
|
|
||||||
#define _CRT_NONSTDC_NO_WARNINGS
|
|
@@ -202,36 +202,43 @@ constraint_editor_window_load (ConstraintEditorWindow *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
open_response_cb (GObject *source,
|
open_response_cb (GtkNativeDialog *dialog,
|
||||||
GAsyncResult *result,
|
int response,
|
||||||
void *user_data)
|
ConstraintEditorWindow *self)
|
||||||
|
{
|
||||||
|
gtk_native_dialog_hide (dialog);
|
||||||
|
|
||||||
|
if (response == GTK_RESPONSE_ACCEPT)
|
||||||
{
|
{
|
||||||
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
|
||||||
ConstraintEditorWindow *self = user_data;
|
|
||||||
GFile *file;
|
GFile *file;
|
||||||
|
|
||||||
file = gtk_file_dialog_open_finish (dialog, result, NULL);
|
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
||||||
if (file)
|
|
||||||
{
|
|
||||||
constraint_editor_window_load (self, file);
|
constraint_editor_window_load (self, file);
|
||||||
g_object_unref (file);
|
g_object_unref (file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gtk_native_dialog_destroy (dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
open_cb (GtkWidget *button,
|
open_cb (GtkWidget *button,
|
||||||
ConstraintEditorWindow *self)
|
ConstraintEditorWindow *self)
|
||||||
{
|
{
|
||||||
GtkFileDialog *dialog;
|
GtkFileChooserNative *dialog;
|
||||||
GFile *cwd;
|
|
||||||
|
|
||||||
dialog = gtk_file_dialog_new ();
|
dialog = gtk_file_chooser_native_new ("Open file",
|
||||||
gtk_file_dialog_set_title (dialog, "Open file");
|
GTK_WINDOW (self),
|
||||||
cwd = g_file_new_for_path (".");
|
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||||
gtk_file_dialog_set_initial_folder (dialog, cwd);
|
"_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);
|
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
|
static void
|
||||||
@@ -287,23 +294,22 @@ serialize_model (GListModel *list)
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
save_response_cb (GObject *source,
|
save_response_cb (GtkNativeDialog *dialog,
|
||||||
GAsyncResult *result,
|
int response,
|
||||||
void *user_data)
|
ConstraintEditorWindow *self)
|
||||||
{
|
{
|
||||||
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
gtk_native_dialog_hide (dialog);
|
||||||
ConstraintEditorWindow *self = user_data;
|
|
||||||
GFile *file;
|
|
||||||
|
|
||||||
file = gtk_file_dialog_save_finish (dialog, result, NULL);
|
if (response == GTK_RESPONSE_ACCEPT)
|
||||||
if (file)
|
|
||||||
{
|
{
|
||||||
GListModel *model;
|
GListModel *model;
|
||||||
|
GFile *file;
|
||||||
char *text;
|
char *text;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
model = constraint_view_get_model (CONSTRAINT_VIEW (self->view));
|
model = constraint_view_get_model (CONSTRAINT_VIEW (self->view));
|
||||||
text = serialize_model (model);
|
text = serialize_model (model);
|
||||||
|
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
||||||
g_file_replace_contents (file, text, strlen (text),
|
g_file_replace_contents (file, text, strlen (text),
|
||||||
NULL, FALSE,
|
NULL, FALSE,
|
||||||
G_FILE_CREATE_NONE,
|
G_FILE_CREATE_NONE,
|
||||||
@@ -312,38 +318,46 @@ save_response_cb (GObject *source,
|
|||||||
&error);
|
&error);
|
||||||
if (error != NULL)
|
if (error != NULL)
|
||||||
{
|
{
|
||||||
GtkAlertDialog *alert;
|
GtkWidget *message_dialog;
|
||||||
|
|
||||||
alert = gtk_alert_dialog_new ("Saving failed");
|
message_dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (self))),
|
||||||
gtk_alert_dialog_set_detail (alert, error->message);
|
GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||||
gtk_alert_dialog_show (alert,
|
GTK_MESSAGE_INFO,
|
||||||
GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (self))));
|
GTK_BUTTONS_OK,
|
||||||
g_object_unref (alert);
|
"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_error_free (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (text);
|
g_free (text);
|
||||||
g_object_unref (file);
|
g_object_unref (file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gtk_native_dialog_destroy (dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
save_cb (GtkWidget *button,
|
save_cb (GtkWidget *button,
|
||||||
ConstraintEditorWindow *self)
|
ConstraintEditorWindow *self)
|
||||||
{
|
{
|
||||||
GtkFileDialog *dialog;
|
GtkFileChooserNative *dialog;
|
||||||
GFile *cwd;
|
|
||||||
|
|
||||||
dialog = gtk_file_dialog_new ();
|
dialog = gtk_file_chooser_native_new ("Save constraints",
|
||||||
gtk_file_dialog_set_title (dialog, "Save constraints");
|
|
||||||
cwd = g_file_new_for_path (".");
|
|
||||||
gtk_file_dialog_set_initial_folder (dialog, cwd);
|
|
||||||
g_object_unref (cwd);
|
|
||||||
gtk_file_dialog_save (dialog,
|
|
||||||
GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (button))),
|
GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (button))),
|
||||||
NULL,
|
GTK_FILE_CHOOSER_ACTION_SAVE,
|
||||||
save_response_cb, self);
|
"_Save",
|
||||||
g_object_unref (dialog);
|
"_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);
|
||||||
|
|
||||||
|
g_signal_connect (dialog, "response", G_CALLBACK (save_response_cb), self);
|
||||||
|
gtk_native_dialog_show (GTK_NATIVE_DIALOG (dialog));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -426,7 +440,7 @@ edit_constraint (ConstraintEditorWindow *win,
|
|||||||
|
|
||||||
g_signal_connect (editor, "done", G_CALLBACK (constraint_editor_done), win);
|
g_signal_connect (editor, "done", G_CALLBACK (constraint_editor_done), win);
|
||||||
|
|
||||||
gtk_window_present (GTK_WINDOW (window));
|
gtk_widget_show (window);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -459,7 +473,7 @@ edit_guide (ConstraintEditorWindow *win,
|
|||||||
gtk_window_set_child (GTK_WINDOW (window), GTK_WIDGET (editor));
|
gtk_window_set_child (GTK_WINDOW (window), GTK_WIDGET (editor));
|
||||||
|
|
||||||
g_signal_connect (editor, "done", G_CALLBACK (guide_editor_done), win);
|
g_signal_connect (editor, "done", G_CALLBACK (guide_editor_done), win);
|
||||||
gtk_window_present (GTK_WINDOW (window));
|
gtk_widget_show (window);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -483,8 +497,6 @@ constraint_editor_window_class_init (ConstraintEditorWindowClass *class)
|
|||||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
||||||
|
|
||||||
g_type_ensure (CONSTRAINT_VIEW_TYPE);
|
|
||||||
|
|
||||||
object_class->dispose = constraint_editor_window_dispose;
|
object_class->dispose = constraint_editor_window_dispose;
|
||||||
|
|
||||||
gtk_widget_class_set_template_from_resource (widget_class,
|
gtk_widget_class_set_template_from_resource (widget_class,
|
||||||
|
@@ -20,7 +20,6 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "constraint-editor.h"
|
#include "constraint-editor.h"
|
||||||
#include "constraint-view.h"
|
|
||||||
|
|
||||||
struct _ConstraintEditor
|
struct _ConstraintEditor
|
||||||
{
|
{
|
||||||
@@ -65,7 +64,7 @@ static const char *
|
|||||||
get_target_name (GtkConstraintTarget *target)
|
get_target_name (GtkConstraintTarget *target)
|
||||||
{
|
{
|
||||||
if (target == NULL)
|
if (target == NULL)
|
||||||
return "Super";
|
return "super";
|
||||||
else if (GTK_IS_WIDGET (target))
|
else if (GTK_IS_WIDGET (target))
|
||||||
return gtk_widget_get_name (GTK_WIDGET (target));
|
return gtk_widget_get_name (GTK_WIDGET (target));
|
||||||
else if (GTK_IS_CONSTRAINT_GUIDE (target))
|
else if (GTK_IS_CONSTRAINT_GUIDE (target))
|
||||||
@@ -79,29 +78,62 @@ constraint_target_combo (GListModel *model,
|
|||||||
GtkWidget *combo,
|
GtkWidget *combo,
|
||||||
gboolean is_source)
|
gboolean is_source)
|
||||||
{
|
{
|
||||||
GtkStringList *targets;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
targets = gtk_string_list_new (NULL);
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "super", "Super");
|
||||||
|
|
||||||
gtk_string_list_append (targets, "Super");
|
|
||||||
|
|
||||||
if (model)
|
if (model)
|
||||||
{
|
{
|
||||||
for (i = 0; i < g_list_model_get_n_items (model); i++)
|
for (i = 0; i < g_list_model_get_n_items (model); i++)
|
||||||
{
|
{
|
||||||
GObject *item = g_list_model_get_object (model, i);
|
GObject *item = g_list_model_get_object (model, i);
|
||||||
|
const char *name;
|
||||||
|
|
||||||
if (GTK_IS_CONSTRAINT (item))
|
if (GTK_IS_CONSTRAINT (item))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
gtk_string_list_append (targets, get_target_name (GTK_CONSTRAINT_TARGET (item)));
|
name = get_target_name (GTK_CONSTRAINT_TARGET (item));
|
||||||
|
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), name, name);
|
||||||
g_object_unref (item);
|
g_object_unref (item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gtk_drop_down_set_model (GTK_DROP_DOWN (combo), G_LIST_MODEL (targets));
|
static void
|
||||||
g_object_unref (targets);
|
constraint_attribute_combo (GtkWidget *combo,
|
||||||
|
gboolean is_source)
|
||||||
|
{
|
||||||
|
if (is_source)
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "none", "None");
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "left", "Left");
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "right", "Right");
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "top", "Top");
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "bottom", "Bottom");
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "start", "Start");
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "end", "End");
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "width", "Width");
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "height", "Height");
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "center-x", "Center X");
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "center-y", "Center Y");
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "baseline", "Baseline");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
constraint_relation_combo (GtkWidget *combo)
|
||||||
|
{
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "le", "≤");
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "eq", "=");
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "ge", "≥");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
constraint_strength_combo (GtkWidget *combo)
|
||||||
|
{
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "weak", "Weak");
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "medium", "Medium");
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "strong", "Strong");
|
||||||
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "required", "Required");
|
||||||
}
|
}
|
||||||
|
|
||||||
static gpointer
|
static gpointer
|
||||||
@@ -113,7 +145,7 @@ get_target (GListModel *model,
|
|||||||
if (id == NULL)
|
if (id == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (strcmp ("Super", id) == 0)
|
if (strcmp ("super", id) == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for (i = 0; i < g_list_model_get_n_items (model); i++)
|
for (i = 0; i < g_list_model_get_n_items (model); i++)
|
||||||
@@ -137,65 +169,16 @@ get_target (GListModel *model,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
select_target (GtkDropDown *combo,
|
|
||||||
const char *target_name)
|
|
||||||
{
|
|
||||||
GListModel *model = gtk_drop_down_get_model (combo);
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < g_list_model_get_n_items (model); i++)
|
|
||||||
{
|
|
||||||
GtkStringObject *s = g_list_model_get_item (model, i);
|
|
||||||
|
|
||||||
g_object_unref (s);
|
|
||||||
if (strcmp (target_name, gtk_string_object_get_string (s)) == 0)
|
|
||||||
{
|
|
||||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (combo), i);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static GtkConstraintAttribute
|
static GtkConstraintAttribute
|
||||||
get_attr (unsigned int id)
|
get_target_attr (const char *id)
|
||||||
{
|
{
|
||||||
switch (id)
|
GtkConstraintAttribute attr;
|
||||||
{
|
GEnumClass *class = g_type_class_ref (GTK_TYPE_CONSTRAINT_ATTRIBUTE);
|
||||||
case 0: return GTK_CONSTRAINT_ATTRIBUTE_NONE;
|
GEnumValue *value = g_enum_get_value_by_nick (class, id);
|
||||||
case 1: return GTK_CONSTRAINT_ATTRIBUTE_LEFT;
|
attr = value->value;
|
||||||
case 2: return GTK_CONSTRAINT_ATTRIBUTE_RIGHT;
|
g_type_class_unref (class);
|
||||||
case 3: return GTK_CONSTRAINT_ATTRIBUTE_TOP;
|
|
||||||
case 4: return GTK_CONSTRAINT_ATTRIBUTE_BOTTOM;
|
|
||||||
case 5: return GTK_CONSTRAINT_ATTRIBUTE_START;
|
|
||||||
case 6: return GTK_CONSTRAINT_ATTRIBUTE_END;
|
|
||||||
case 7: return GTK_CONSTRAINT_ATTRIBUTE_WIDTH;
|
|
||||||
case 8: return GTK_CONSTRAINT_ATTRIBUTE_HEIGHT;
|
|
||||||
case 9: return GTK_CONSTRAINT_ATTRIBUTE_CENTER_X;
|
|
||||||
case 10: return GTK_CONSTRAINT_ATTRIBUTE_CENTER_Y;
|
|
||||||
case 11: return GTK_CONSTRAINT_ATTRIBUTE_BASELINE;
|
|
||||||
default: g_assert_not_reached ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned int
|
return attr;
|
||||||
get_attr_id (GtkConstraintAttribute attr)
|
|
||||||
{
|
|
||||||
switch (attr)
|
|
||||||
{
|
|
||||||
case GTK_CONSTRAINT_ATTRIBUTE_NONE: return 0;
|
|
||||||
case GTK_CONSTRAINT_ATTRIBUTE_LEFT: return 1;
|
|
||||||
case GTK_CONSTRAINT_ATTRIBUTE_RIGHT: return 2;
|
|
||||||
case GTK_CONSTRAINT_ATTRIBUTE_TOP: return 3;
|
|
||||||
case GTK_CONSTRAINT_ATTRIBUTE_BOTTOM: return 4;
|
|
||||||
case GTK_CONSTRAINT_ATTRIBUTE_START: return 5;
|
|
||||||
case GTK_CONSTRAINT_ATTRIBUTE_END: return 6;
|
|
||||||
case GTK_CONSTRAINT_ATTRIBUTE_WIDTH: return 7;
|
|
||||||
case GTK_CONSTRAINT_ATTRIBUTE_HEIGHT: return 8;
|
|
||||||
case GTK_CONSTRAINT_ATTRIBUTE_CENTER_X: return 9;
|
|
||||||
case GTK_CONSTRAINT_ATTRIBUTE_CENTER_Y: return 10;
|
|
||||||
case GTK_CONSTRAINT_ATTRIBUTE_BASELINE: return 11;
|
|
||||||
default: g_assert_not_reached ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
@@ -210,27 +193,15 @@ get_attr_nick (GtkConstraintAttribute attr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GtkConstraintRelation
|
static GtkConstraintRelation
|
||||||
get_relation (unsigned int id)
|
get_relation (const char *id)
|
||||||
{
|
{
|
||||||
switch (id)
|
GtkConstraintRelation relation;
|
||||||
{
|
GEnumClass *class = g_type_class_ref (GTK_TYPE_CONSTRAINT_RELATION);
|
||||||
case 0: return GTK_CONSTRAINT_RELATION_LE;
|
GEnumValue *value = g_enum_get_value_by_nick (class, id);
|
||||||
case 1: return GTK_CONSTRAINT_RELATION_EQ;
|
relation = value->value;
|
||||||
case 2: return GTK_CONSTRAINT_RELATION_GE;
|
g_type_class_unref (class);
|
||||||
default: g_assert_not_reached ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned int
|
return relation;
|
||||||
get_relation_id (GtkConstraintRelation relation)
|
|
||||||
{
|
|
||||||
switch (relation)
|
|
||||||
{
|
|
||||||
case GTK_CONSTRAINT_RELATION_LE: return 0;
|
|
||||||
case GTK_CONSTRAINT_RELATION_EQ: return 1;
|
|
||||||
case GTK_CONSTRAINT_RELATION_GE: return 2;
|
|
||||||
default: g_assert_not_reached ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
@@ -261,29 +232,15 @@ get_relation_display_name (GtkConstraintRelation relation)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GtkConstraintStrength
|
static GtkConstraintStrength
|
||||||
get_strength (unsigned int id)
|
get_strength (const char *id)
|
||||||
{
|
{
|
||||||
switch (id)
|
GtkConstraintStrength strength;
|
||||||
{
|
GEnumClass *class = g_type_class_ref (GTK_TYPE_CONSTRAINT_STRENGTH);
|
||||||
case 0: return GTK_CONSTRAINT_STRENGTH_WEAK;
|
GEnumValue *value = g_enum_get_value_by_nick (class, id);
|
||||||
case 1: return GTK_CONSTRAINT_STRENGTH_MEDIUM;
|
strength = value->value;
|
||||||
case 2: return GTK_CONSTRAINT_STRENGTH_STRONG;
|
g_type_class_unref (class);
|
||||||
case 3: return GTK_CONSTRAINT_STRENGTH_REQUIRED;
|
|
||||||
default: g_assert_not_reached ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned int
|
return strength;
|
||||||
get_strength_id (GtkConstraintStrength strength)
|
|
||||||
{
|
|
||||||
switch (strength)
|
|
||||||
{
|
|
||||||
case GTK_CONSTRAINT_STRENGTH_WEAK: return 0;
|
|
||||||
case GTK_CONSTRAINT_STRENGTH_MEDIUM: return 1;
|
|
||||||
case GTK_CONSTRAINT_STRENGTH_STRONG: return 2;
|
|
||||||
case GTK_CONSTRAINT_STRENGTH_REQUIRED: return 3;
|
|
||||||
default: g_assert_not_reached ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
@@ -335,7 +292,7 @@ static void
|
|||||||
create_constraint (GtkButton *button,
|
create_constraint (GtkButton *button,
|
||||||
ConstraintEditor *editor)
|
ConstraintEditor *editor)
|
||||||
{
|
{
|
||||||
gpointer obj;
|
const char *id;
|
||||||
gpointer target;
|
gpointer target;
|
||||||
GtkConstraintAttribute target_attr;
|
GtkConstraintAttribute target_attr;
|
||||||
gpointer source;
|
gpointer source;
|
||||||
@@ -346,27 +303,25 @@ create_constraint (GtkButton *button,
|
|||||||
int strength;
|
int strength;
|
||||||
GtkConstraint *constraint;
|
GtkConstraint *constraint;
|
||||||
|
|
||||||
obj = gtk_drop_down_get_selected_item (GTK_DROP_DOWN (editor->target));
|
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->target));
|
||||||
if (obj)
|
target = get_target (editor->model, id);
|
||||||
target = get_target (editor->model, gtk_string_object_get_string (GTK_STRING_OBJECT (obj)));
|
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->target_attr));
|
||||||
else
|
target_attr = get_target_attr (id);
|
||||||
target = NULL;
|
|
||||||
target_attr = get_attr (gtk_drop_down_get_selected (GTK_DROP_DOWN (editor->target_attr)));
|
|
||||||
|
|
||||||
obj = gtk_drop_down_get_selected_item (GTK_DROP_DOWN (editor->source));
|
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->source));
|
||||||
if (obj)
|
source = get_target (editor->model, id);
|
||||||
source = get_target (editor->model, gtk_string_object_get_string (GTK_STRING_OBJECT (obj)));
|
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->source_attr));
|
||||||
else
|
source_attr = get_target_attr (id);
|
||||||
source = NULL;
|
|
||||||
source_attr = get_attr (gtk_drop_down_get_selected (GTK_DROP_DOWN(editor->source_attr)));
|
|
||||||
|
|
||||||
relation = get_relation (gtk_drop_down_get_selected (GTK_DROP_DOWN (editor->relation)));
|
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->relation));
|
||||||
|
relation = get_relation (id);
|
||||||
|
|
||||||
multiplier = g_ascii_strtod (gtk_editable_get_text (GTK_EDITABLE (editor->multiplier)), NULL);
|
multiplier = g_ascii_strtod (gtk_editable_get_text (GTK_EDITABLE (editor->multiplier)), NULL);
|
||||||
|
|
||||||
constant = g_ascii_strtod (gtk_editable_get_text (GTK_EDITABLE (editor->constant)), NULL);
|
constant = g_ascii_strtod (gtk_editable_get_text (GTK_EDITABLE (editor->constant)), NULL);
|
||||||
|
|
||||||
strength = get_strength (gtk_drop_down_get_selected (GTK_DROP_DOWN (editor->strength)));
|
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->strength));
|
||||||
|
strength = get_strength (id);
|
||||||
|
|
||||||
constraint = gtk_constraint_new (target, target_attr,
|
constraint = gtk_constraint_new (target, target_attr,
|
||||||
relation,
|
relation,
|
||||||
@@ -381,9 +336,12 @@ create_constraint (GtkButton *button,
|
|||||||
static void
|
static void
|
||||||
source_attr_changed (ConstraintEditor *editor)
|
source_attr_changed (ConstraintEditor *editor)
|
||||||
{
|
{
|
||||||
if (get_attr (gtk_drop_down_get_selected (GTK_DROP_DOWN (editor->source_attr))) == GTK_CONSTRAINT_ATTRIBUTE_NONE)
|
const char *id;
|
||||||
|
|
||||||
|
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->source_attr));
|
||||||
|
if (strcmp (id, "none") == 0)
|
||||||
{
|
{
|
||||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->source), GTK_INVALID_LIST_POSITION);
|
gtk_combo_box_set_active (GTK_COMBO_BOX (editor->source), -1);
|
||||||
gtk_editable_set_text (GTK_EDITABLE (editor->multiplier), "");
|
gtk_editable_set_text (GTK_EDITABLE (editor->multiplier), "");
|
||||||
gtk_widget_set_sensitive (editor->source, FALSE);
|
gtk_widget_set_sensitive (editor->source, FALSE);
|
||||||
gtk_widget_set_sensitive (editor->multiplier, FALSE);
|
gtk_widget_set_sensitive (editor->multiplier, FALSE);
|
||||||
@@ -449,7 +407,7 @@ update_preview (ConstraintEditor *editor)
|
|||||||
GString *str;
|
GString *str;
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *attr;
|
const char *attr;
|
||||||
const char *relation;
|
char *relation;
|
||||||
const char *multiplier;
|
const char *multiplier;
|
||||||
const char *constant;
|
const char *constant;
|
||||||
double c, m;
|
double c, m;
|
||||||
@@ -459,22 +417,23 @@ update_preview (ConstraintEditor *editor)
|
|||||||
|
|
||||||
str = g_string_new ("");
|
str = g_string_new ("");
|
||||||
|
|
||||||
name = gtk_string_object_get_string (GTK_STRING_OBJECT (gtk_drop_down_get_selected_item (GTK_DROP_DOWN (editor->target))));
|
name = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->target));
|
||||||
attr = get_attr_nick (get_attr (gtk_drop_down_get_selected ((GTK_DROP_DOWN (editor->target_attr)))));
|
attr = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->target_attr));
|
||||||
relation = get_relation_nick (get_relation (gtk_drop_down_get_selected (GTK_DROP_DOWN (editor->relation))));
|
relation = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (editor->relation));
|
||||||
|
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
name = "[ ]";
|
name = "[ ]";
|
||||||
|
|
||||||
g_string_append_printf (str, "%s.%s %s ", name, attr, relation);
|
g_string_append_printf (str, "%s.%s %s ", name, attr, relation);
|
||||||
|
g_free (relation);
|
||||||
|
|
||||||
constant = gtk_editable_get_text (GTK_EDITABLE (editor->constant));
|
constant = gtk_editable_get_text (GTK_EDITABLE (editor->constant));
|
||||||
c = g_ascii_strtod (constant, NULL);
|
c = g_ascii_strtod (constant, NULL);
|
||||||
|
|
||||||
attr = get_attr_nick (get_attr (gtk_drop_down_get_selected (GTK_DROP_DOWN (editor->source_attr))));
|
attr = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->source_attr));
|
||||||
if (strcmp (attr, "none") != 0)
|
if (strcmp (attr, "none") != 0)
|
||||||
{
|
{
|
||||||
name = gtk_string_object_get_string (GTK_STRING_OBJECT (gtk_drop_down_get_selected_item (GTK_DROP_DOWN (editor->source))));
|
name = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->source));
|
||||||
multiplier = gtk_editable_get_text (GTK_EDITABLE (editor->multiplier));
|
multiplier = gtk_editable_get_text (GTK_EDITABLE (editor->multiplier));
|
||||||
m = g_ascii_strtod (multiplier, NULL);
|
m = g_ascii_strtod (multiplier, NULL);
|
||||||
|
|
||||||
@@ -502,18 +461,12 @@ update_preview (ConstraintEditor *editor)
|
|||||||
static void
|
static void
|
||||||
update_button (ConstraintEditor *editor)
|
update_button (ConstraintEditor *editor)
|
||||||
{
|
{
|
||||||
gpointer obj;
|
const char *target = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->target));
|
||||||
const char *target;
|
const char *source = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->source));
|
||||||
const char *source;
|
const char *source_attr = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->source_attr));
|
||||||
GtkConstraintAttribute source_attr = get_attr (gtk_drop_down_get_selected (GTK_DROP_DOWN (editor->source_attr)));
|
|
||||||
|
|
||||||
obj = gtk_drop_down_get_selected_item (GTK_DROP_DOWN (editor->target));
|
if (target &&
|
||||||
target = obj ? gtk_string_object_get_string (GTK_STRING_OBJECT (obj)) : NULL;
|
(source || (source_attr && get_target_attr (source_attr) == GTK_CONSTRAINT_ATTRIBUTE_NONE)))
|
||||||
|
|
||||||
obj = gtk_drop_down_get_selected_item (GTK_DROP_DOWN (editor->source));
|
|
||||||
source = obj ? gtk_string_object_get_string (GTK_STRING_OBJECT (obj)) : NULL;
|
|
||||||
|
|
||||||
if (target && (source || (source_attr == GTK_CONSTRAINT_ATTRIBUTE_NONE)))
|
|
||||||
gtk_widget_set_sensitive (editor->button, TRUE);
|
gtk_widget_set_sensitive (editor->button, TRUE);
|
||||||
else
|
else
|
||||||
gtk_widget_set_sensitive (editor->button, FALSE);
|
gtk_widget_set_sensitive (editor->button, FALSE);
|
||||||
@@ -531,7 +484,12 @@ constraint_editor_constructed (GObject *object)
|
|||||||
ConstraintEditor *editor = CONSTRAINT_EDITOR (object);
|
ConstraintEditor *editor = CONSTRAINT_EDITOR (object);
|
||||||
|
|
||||||
constraint_target_combo (editor->model, editor->target, FALSE);
|
constraint_target_combo (editor->model, editor->target, FALSE);
|
||||||
|
constraint_attribute_combo (editor->target_attr, FALSE);
|
||||||
|
constraint_relation_combo (editor->relation);
|
||||||
constraint_target_combo (editor->model, editor->source, TRUE);
|
constraint_target_combo (editor->model, editor->source, TRUE);
|
||||||
|
constraint_attribute_combo (editor->source_attr, TRUE);
|
||||||
|
|
||||||
|
constraint_strength_combo (editor->strength);
|
||||||
|
|
||||||
if (editor->constraint)
|
if (editor->constraint)
|
||||||
{
|
{
|
||||||
@@ -539,24 +497,30 @@ constraint_editor_constructed (GObject *object)
|
|||||||
GtkConstraintAttribute attr;
|
GtkConstraintAttribute attr;
|
||||||
GtkConstraintRelation relation;
|
GtkConstraintRelation relation;
|
||||||
GtkConstraintStrength strength;
|
GtkConstraintStrength strength;
|
||||||
|
const char *nick;
|
||||||
char *val;
|
char *val;
|
||||||
double multiplier;
|
double multiplier;
|
||||||
double constant;
|
double constant;
|
||||||
|
|
||||||
target = gtk_constraint_get_target (editor->constraint);
|
target = gtk_constraint_get_target (editor->constraint);
|
||||||
select_target (GTK_DROP_DOWN (editor->target), get_target_name (target));
|
nick = get_target_name (target);
|
||||||
|
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->target), nick);
|
||||||
|
|
||||||
attr = gtk_constraint_get_target_attribute (editor->constraint);
|
attr = gtk_constraint_get_target_attribute (editor->constraint);
|
||||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->target_attr), get_attr_id (attr));
|
nick = get_attr_nick (attr);
|
||||||
|
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->target_attr), nick);
|
||||||
|
|
||||||
target = gtk_constraint_get_source (editor->constraint);
|
target = gtk_constraint_get_source (editor->constraint);
|
||||||
select_target (GTK_DROP_DOWN (editor->source), get_target_name (target));
|
nick = get_target_name (target);
|
||||||
|
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->source), nick);
|
||||||
|
|
||||||
attr = gtk_constraint_get_source_attribute (editor->constraint);
|
attr = gtk_constraint_get_source_attribute (editor->constraint);
|
||||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->source_attr), get_attr_id (attr));
|
nick = get_attr_nick (attr);
|
||||||
|
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->source_attr), nick);
|
||||||
|
|
||||||
relation = gtk_constraint_get_relation (editor->constraint);
|
relation = gtk_constraint_get_relation (editor->constraint);
|
||||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->relation), get_relation_id (relation));
|
nick = get_relation_nick (relation);
|
||||||
|
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->relation), nick);
|
||||||
|
|
||||||
multiplier = gtk_constraint_get_multiplier (editor->constraint);
|
multiplier = gtk_constraint_get_multiplier (editor->constraint);
|
||||||
val = g_strdup_printf ("%g", multiplier);
|
val = g_strdup_printf ("%g", multiplier);
|
||||||
@@ -569,16 +533,17 @@ constraint_editor_constructed (GObject *object)
|
|||||||
g_free (val);
|
g_free (val);
|
||||||
|
|
||||||
strength = gtk_constraint_get_strength (editor->constraint);
|
strength = gtk_constraint_get_strength (editor->constraint);
|
||||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->strength), get_strength_id (strength));
|
nick = get_strength_nick (strength);
|
||||||
|
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->strength), nick);
|
||||||
|
|
||||||
gtk_button_set_label (GTK_BUTTON (editor->button), "Apply");
|
gtk_button_set_label (GTK_BUTTON (editor->button), "Apply");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->target_attr), get_attr_id (GTK_CONSTRAINT_ATTRIBUTE_LEFT));
|
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->target_attr), "left");
|
||||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->source_attr), get_attr_id (GTK_CONSTRAINT_ATTRIBUTE_LEFT));
|
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->source_attr), "left");
|
||||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->relation), get_relation_id (GTK_CONSTRAINT_RELATION_EQ));
|
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->relation), "eq");
|
||||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->strength), get_strength_id (GTK_CONSTRAINT_STRENGTH_REQUIRED));
|
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->strength), "required");
|
||||||
|
|
||||||
gtk_editable_set_text (GTK_EDITABLE (editor->multiplier), "1.0");
|
gtk_editable_set_text (GTK_EDITABLE (editor->multiplier), "1.0");
|
||||||
gtk_editable_set_text (GTK_EDITABLE (editor->constant), "0.0");
|
gtk_editable_set_text (GTK_EDITABLE (editor->constant), "0.0");
|
||||||
|
@@ -1,21 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
<object class="GtkStringList" id="targets">
|
|
||||||
<items>
|
|
||||||
<item>None</item>
|
|
||||||
<item>Left</item>
|
|
||||||
<item>Right</item>
|
|
||||||
<item>Top</item>
|
|
||||||
<item>Bottom</item>
|
|
||||||
<item>Start</item>
|
|
||||||
<item>End</item>
|
|
||||||
<item>Width</item>
|
|
||||||
<item>Height</item>
|
|
||||||
<item>Center X</item>
|
|
||||||
<item>Center Y</item>
|
|
||||||
<item>Baseline</item>
|
|
||||||
</items>
|
|
||||||
</object>
|
|
||||||
<template class="ConstraintEditor" parent="GtkWidget">
|
<template class="ConstraintEditor" parent="GtkWidget">
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkGrid" id="grid">
|
<object class="GtkGrid" id="grid">
|
||||||
@@ -35,9 +19,9 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkDropDown" id="target">
|
<object class="GtkComboBoxText" id="target">
|
||||||
<signal name="notify::selected" handler="update_preview" swapped="yes"/>
|
<signal name="changed" handler="update_preview" swapped="yes"/>
|
||||||
<signal name="notify::selected" handler="update_button" swapped="yes"/>
|
<signal name="changed" handler="update_button" swapped="yes"/>
|
||||||
<layout>
|
<layout>
|
||||||
<property name="column">1</property>
|
<property name="column">1</property>
|
||||||
<property name="row">1</property>
|
<property name="row">1</property>
|
||||||
@@ -45,9 +29,8 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkDropDown" id="target_attr">
|
<object class="GtkComboBoxText" id="target_attr">
|
||||||
<property name="model">targets</property>
|
<signal name="changed" handler="update_preview" swapped="yes"/>
|
||||||
<signal name="notify::selected" handler="update_preview" swapped="yes"/>
|
|
||||||
<layout>
|
<layout>
|
||||||
<property name="column">2</property>
|
<property name="column">2</property>
|
||||||
<property name="row">1</property>
|
<property name="row">1</property>
|
||||||
@@ -64,17 +47,8 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkDropDown" id="relation">
|
<object class="GtkComboBoxText" id="relation">
|
||||||
<signal name="notify::selected" handler="update_preview" swapped="yes"/>
|
<signal name="changed" handler="update_preview" swapped="yes"/>
|
||||||
<property name="model">
|
|
||||||
<object class="GtkStringList">
|
|
||||||
<items>
|
|
||||||
<item>≤</item>
|
|
||||||
<item>=</item>
|
|
||||||
<item>≥</item>
|
|
||||||
</items>
|
|
||||||
</object>
|
|
||||||
</property>
|
|
||||||
<layout>
|
<layout>
|
||||||
<property name="column">1</property>
|
<property name="column">1</property>
|
||||||
<property name="row">2</property>
|
<property name="row">2</property>
|
||||||
@@ -91,9 +65,9 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkDropDown" id="source">
|
<object class="GtkComboBoxText" id="source">
|
||||||
<signal name="notify::selected" handler="update_preview" swapped="yes"/>
|
<signal name="changed" handler="update_preview" swapped="yes"/>
|
||||||
<signal name="notify::selected" handler="update_button" swapped="yes"/>
|
<signal name="changed" handler="update_button" swapped="yes"/>
|
||||||
<layout>
|
<layout>
|
||||||
<property name="column">1</property>
|
<property name="column">1</property>
|
||||||
<property name="row">3</property>
|
<property name="row">3</property>
|
||||||
@@ -101,11 +75,10 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkDropDown" id="source_attr">
|
<object class="GtkComboBoxText" id="source_attr">
|
||||||
<property name="model">targets</property>
|
<signal name="changed" handler="update_preview" swapped="yes"/>
|
||||||
<signal name="notify::selected" handler="update_preview" swapped="yes"/>
|
<signal name="changed" handler="source_attr_changed" swapped="yes"/>
|
||||||
<signal name="notify::selected" handler="source_attr_changed" swapped="yes"/>
|
<signal name="changed" handler="update_button" swapped="yes"/>
|
||||||
<signal name="notify::selected" handler="update_button" swapped="yes"/>
|
|
||||||
<layout>
|
<layout>
|
||||||
<property name="column">2</property>
|
<property name="column">2</property>
|
||||||
<property name="row">3</property>
|
<property name="row">3</property>
|
||||||
@@ -158,17 +131,7 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkDropDown" id="strength">
|
<object class="GtkComboBoxText" id="strength">
|
||||||
<property name="model">
|
|
||||||
<object class="GtkStringList">
|
|
||||||
<items>
|
|
||||||
<item>Weak</item>
|
|
||||||
<item>Medium</item>
|
|
||||||
<item>Strong</item>
|
|
||||||
<item>Required</item>
|
|
||||||
</items>
|
|
||||||
</object>
|
|
||||||
</property>
|
|
||||||
<layout>
|
<layout>
|
||||||
<property name="column">1</property>
|
<property name="column">1</property>
|
||||||
<property name="row">6</property>
|
<property name="row">6</property>
|
||||||
|
@@ -57,30 +57,25 @@ static guint signals[LAST_SIGNAL];
|
|||||||
|
|
||||||
G_DEFINE_TYPE(GuideEditor, guide_editor, GTK_TYPE_WIDGET);
|
G_DEFINE_TYPE(GuideEditor, guide_editor, GTK_TYPE_WIDGET);
|
||||||
|
|
||||||
static GtkConstraintStrength
|
static void
|
||||||
get_strength (unsigned int id)
|
guide_strength_combo (GtkWidget *combo)
|
||||||
{
|
{
|
||||||
switch (id)
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "weak", "Weak");
|
||||||
{
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "medium", "Medium");
|
||||||
case 0: return GTK_CONSTRAINT_STRENGTH_WEAK;
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "strong", "Strong");
|
||||||
case 1: return GTK_CONSTRAINT_STRENGTH_MEDIUM;
|
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "required", "Required");
|
||||||
case 2: return GTK_CONSTRAINT_STRENGTH_STRONG;
|
|
||||||
case 3: return GTK_CONSTRAINT_STRENGTH_REQUIRED;
|
|
||||||
default: g_assert_not_reached ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int
|
static GtkConstraintStrength
|
||||||
get_strength_id (GtkConstraintStrength strength)
|
get_strength (const char *id)
|
||||||
{
|
{
|
||||||
switch (strength)
|
GtkConstraintStrength strength;
|
||||||
{
|
GEnumClass *class = g_type_class_ref (GTK_TYPE_CONSTRAINT_STRENGTH);
|
||||||
case GTK_CONSTRAINT_STRENGTH_WEAK: return 0;
|
GEnumValue *value = g_enum_get_value_by_nick (class, id);
|
||||||
case GTK_CONSTRAINT_STRENGTH_MEDIUM: return 1;
|
strength = value->value;
|
||||||
case GTK_CONSTRAINT_STRENGTH_STRONG: return 2;
|
g_type_class_unref (class);
|
||||||
case GTK_CONSTRAINT_STRENGTH_REQUIRED: return 3;
|
|
||||||
default: g_assert_not_reached ();
|
return strength;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
@@ -121,11 +116,11 @@ static void
|
|||||||
create_guide (GtkButton *button,
|
create_guide (GtkButton *button,
|
||||||
GuideEditor *editor)
|
GuideEditor *editor)
|
||||||
{
|
{
|
||||||
|
const char *id;
|
||||||
int strength;
|
int strength;
|
||||||
const char *name;
|
const char *name;
|
||||||
int w, h;
|
int w, h;
|
||||||
GtkConstraintGuide *guide;
|
GtkConstraintGuide *guide;
|
||||||
unsigned int id;
|
|
||||||
|
|
||||||
if (editor->guide)
|
if (editor->guide)
|
||||||
guide = g_object_ref (editor->guide);
|
guide = g_object_ref (editor->guide);
|
||||||
@@ -147,7 +142,7 @@ create_guide (GtkButton *button,
|
|||||||
h = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (editor->max_height));
|
h = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (editor->max_height));
|
||||||
gtk_constraint_guide_set_max_size (guide, w, h);
|
gtk_constraint_guide_set_max_size (guide, w, h);
|
||||||
|
|
||||||
id = gtk_drop_down_get_selected (GTK_DROP_DOWN (editor->strength));
|
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->strength));
|
||||||
strength = get_strength (id);
|
strength = get_strength (id);
|
||||||
gtk_constraint_guide_set_strength (guide, strength);
|
gtk_constraint_guide_set_strength (guide, strength);
|
||||||
|
|
||||||
@@ -194,9 +189,14 @@ guide_editor_constructed (GObject *object)
|
|||||||
{
|
{
|
||||||
GuideEditor *editor = GUIDE_EDITOR (object);
|
GuideEditor *editor = GUIDE_EDITOR (object);
|
||||||
|
|
||||||
|
guide_strength_combo (editor->strength);
|
||||||
|
|
||||||
g_signal_connect (editor->min_width, "input", G_CALLBACK (min_input), NULL);
|
g_signal_connect (editor->min_width, "input", G_CALLBACK (min_input), NULL);
|
||||||
|
|
||||||
g_signal_connect (editor->min_height, "input", G_CALLBACK (min_input), NULL);
|
g_signal_connect (editor->min_height, "input", G_CALLBACK (min_input), NULL);
|
||||||
|
|
||||||
g_signal_connect (editor->max_width, "input", G_CALLBACK (max_input), NULL);
|
g_signal_connect (editor->max_width, "input", G_CALLBACK (max_input), NULL);
|
||||||
|
|
||||||
g_signal_connect (editor->max_height, "input", G_CALLBACK (max_input), NULL);
|
g_signal_connect (editor->max_height, "input", G_CALLBACK (max_input), NULL);
|
||||||
|
|
||||||
if (editor->guide)
|
if (editor->guide)
|
||||||
@@ -222,7 +222,8 @@ guide_editor_constructed (GObject *object)
|
|||||||
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->max_height), h);
|
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->max_height), h);
|
||||||
|
|
||||||
strength = gtk_constraint_guide_get_strength (editor->guide);
|
strength = gtk_constraint_guide_get_strength (editor->guide);
|
||||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->strength), get_strength_id (strength));
|
nick = get_strength_nick (strength);
|
||||||
|
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->strength), nick);
|
||||||
|
|
||||||
gtk_button_set_label (GTK_BUTTON (editor->button), "Apply");
|
gtk_button_set_label (GTK_BUTTON (editor->button), "Apply");
|
||||||
}
|
}
|
||||||
@@ -242,7 +243,7 @@ guide_editor_constructed (GObject *object)
|
|||||||
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->max_width), G_MAXINT);
|
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->max_width), G_MAXINT);
|
||||||
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->max_height), G_MAXINT);
|
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->max_height), G_MAXINT);
|
||||||
|
|
||||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (editor->strength), get_strength_id (GTK_CONSTRAINT_STRENGTH_MEDIUM));
|
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->strength), "medium");
|
||||||
|
|
||||||
gtk_button_set_label (GTK_BUTTON (editor->button), "Create");
|
gtk_button_set_label (GTK_BUTTON (editor->button), "Create");
|
||||||
}
|
}
|
||||||
|
@@ -167,17 +167,7 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkDropDown" id="strength">
|
<object class="GtkComboBoxText" id="strength">
|
||||||
<property name="model">
|
|
||||||
<object class="GtkStringList">
|
|
||||||
<items>
|
|
||||||
<item>Weak</item>
|
|
||||||
<item>Medium</item>
|
|
||||||
<item>Strong</item>
|
|
||||||
<item>Required</item>
|
|
||||||
</items>
|
|
||||||
</object>
|
|
||||||
</property>
|
|
||||||
<layout>
|
<layout>
|
||||||
<property name="column">1</property>
|
<property name="column">1</property>
|
||||||
<property name="row">4</property>
|
<property name="row">4</property>
|
||||||
|
@@ -9,7 +9,7 @@ constraint_editor_sources = [
|
|||||||
|
|
||||||
constraint_editor_resources = gnome.compile_resources('constraint_editor_resources',
|
constraint_editor_resources = gnome.compile_resources('constraint_editor_resources',
|
||||||
'constraint-editor.gresource.xml',
|
'constraint-editor.gresource.xml',
|
||||||
source_dir: meson.current_source_dir(),
|
source_dir: '.',
|
||||||
)
|
)
|
||||||
|
|
||||||
executable('gtk4-constraint-editor',
|
executable('gtk4-constraint-editor',
|
||||||
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.7 KiB |
@@ -33,12 +33,22 @@ static void create_window (GApplication *app, const char *contents);
|
|||||||
static void
|
static void
|
||||||
show_action_dialog (GSimpleAction *action)
|
show_action_dialog (GSimpleAction *action)
|
||||||
{
|
{
|
||||||
GtkAlertDialog *dialog;
|
const char *name;
|
||||||
|
GtkWidget *dialog;
|
||||||
|
|
||||||
dialog = gtk_alert_dialog_new ("You activated action: \"%s\"",
|
name = g_action_get_name (G_ACTION (action));
|
||||||
g_action_get_name (G_ACTION (action)));
|
|
||||||
gtk_alert_dialog_show (dialog, NULL);
|
dialog = gtk_message_dialog_new (NULL,
|
||||||
g_object_unref (dialog);
|
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
|
static void
|
||||||
@@ -57,7 +67,7 @@ show_action_infobar (GSimpleAction *action,
|
|||||||
text = g_strdup_printf ("You activated radio action: \"%s\".\n"
|
text = g_strdup_printf ("You activated radio action: \"%s\".\n"
|
||||||
"Current value: %s", name, value);
|
"Current value: %s", name, value);
|
||||||
gtk_label_set_text (GTK_LABEL (window->message), text);
|
gtk_label_set_text (GTK_LABEL (window->message), text);
|
||||||
gtk_widget_set_visible (window->infobar, TRUE);
|
gtk_widget_show (window->infobar);
|
||||||
g_free (text);
|
g_free (text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,38 +90,43 @@ activate_new (GSimpleAction *action,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
open_response_cb (GObject *source,
|
open_response_cb (GtkNativeDialog *dialog,
|
||||||
GAsyncResult *result,
|
int response_id,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
GtkFileChooserNative *native = user_data;
|
||||||
GApplication *app = G_APPLICATION (user_data);
|
GApplication *app = g_object_get_data (G_OBJECT (native), "app");
|
||||||
|
GtkWidget *message_dialog;
|
||||||
GFile *file;
|
GFile *file;
|
||||||
|
char *contents;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
file = gtk_file_dialog_open_finish (dialog, result, &error);
|
if (response_id == GTK_RESPONSE_ACCEPT)
|
||||||
if (file)
|
|
||||||
{
|
{
|
||||||
char *contents;
|
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (native));
|
||||||
|
|
||||||
if (g_file_load_contents (file, NULL, &contents, NULL, NULL, &error))
|
if (g_file_load_contents (file, NULL, &contents, NULL, NULL, &error))
|
||||||
{
|
{
|
||||||
create_window (app, contents);
|
create_window (app, contents);
|
||||||
g_free (contents);
|
g_free (contents);
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
|
||||||
if (error)
|
|
||||||
{
|
{
|
||||||
GtkAlertDialog *alert;
|
message_dialog = gtk_message_dialog_new (NULL,
|
||||||
|
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||||
alert = gtk_alert_dialog_new ("Error loading file: \"%s\"", error->message);
|
GTK_MESSAGE_ERROR,
|
||||||
gtk_alert_dialog_show (alert, NULL);
|
GTK_BUTTONS_CLOSE,
|
||||||
g_object_unref (alert);
|
"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);
|
g_error_free (error);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
g_object_unref (app);
|
gtk_native_dialog_destroy (GTK_NATIVE_DIALOG (native));
|
||||||
|
g_object_unref (native);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -121,11 +136,21 @@ activate_open (GSimpleAction *action,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GApplication *app = user_data;
|
GApplication *app = user_data;
|
||||||
GtkFileDialog *dialog;
|
GtkFileChooserNative *native;
|
||||||
|
|
||||||
dialog = gtk_file_dialog_new ();
|
native = gtk_file_chooser_native_new ("Open File",
|
||||||
gtk_file_dialog_open (dialog, NULL, NULL, open_response_cb, g_object_ref (app));
|
NULL,
|
||||||
g_object_unref (dialog);
|
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
|
static void
|
||||||
@@ -214,41 +239,6 @@ activate_quit (GSimpleAction *action,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
delete_messages (gpointer data)
|
|
||||||
{
|
|
||||||
g_list_free_full ((GList *)data, g_free);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
pop_message (GtkWidget *status)
|
|
||||||
{
|
|
||||||
GList *messages = (GList *) g_object_steal_data (G_OBJECT (status), "messages");
|
|
||||||
|
|
||||||
if (messages)
|
|
||||||
{
|
|
||||||
char *message = messages->data;
|
|
||||||
messages = g_list_remove (messages, message);
|
|
||||||
|
|
||||||
g_object_set_data_full (G_OBJECT (status), "messages",
|
|
||||||
messages, delete_messages);
|
|
||||||
|
|
||||||
gtk_label_set_label (GTK_LABEL (status), message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
push_message (GtkWidget *status,
|
|
||||||
const char *message)
|
|
||||||
{
|
|
||||||
GList *messages = (GList *) g_object_steal_data (G_OBJECT (status), "messages");
|
|
||||||
|
|
||||||
gtk_label_set_label (GTK_LABEL (status), message);
|
|
||||||
messages = g_list_prepend (messages, g_strdup (message));
|
|
||||||
g_object_set_data_full (G_OBJECT (status), "messages",
|
|
||||||
messages, delete_messages);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_statusbar (GtkTextBuffer *buffer,
|
update_statusbar (GtkTextBuffer *buffer,
|
||||||
DemoApplicationWindow *window)
|
DemoApplicationWindow *window)
|
||||||
@@ -259,7 +249,7 @@ update_statusbar (GtkTextBuffer *buffer,
|
|||||||
GtkTextIter iter;
|
GtkTextIter iter;
|
||||||
|
|
||||||
/* clear any previous message, underflow is allowed */
|
/* clear any previous message, underflow is allowed */
|
||||||
pop_message (window->status);
|
gtk_statusbar_pop (GTK_STATUSBAR (window->status), 0);
|
||||||
|
|
||||||
count = gtk_text_buffer_get_char_count (buffer);
|
count = gtk_text_buffer_get_char_count (buffer);
|
||||||
|
|
||||||
@@ -273,7 +263,7 @@ update_statusbar (GtkTextBuffer *buffer,
|
|||||||
msg = g_strdup_printf ("Cursor at row %d column %d - %d chars in document",
|
msg = g_strdup_printf ("Cursor at row %d column %d - %d chars in document",
|
||||||
row, col, count);
|
row, col, count);
|
||||||
|
|
||||||
push_message (window->status, msg);
|
gtk_statusbar_push (GTK_STATUSBAR (window->status), 0, msg);
|
||||||
|
|
||||||
g_free (msg);
|
g_free (msg);
|
||||||
}
|
}
|
||||||
@@ -330,7 +320,7 @@ static GActionEntry win_entries[] = {
|
|||||||
static void
|
static void
|
||||||
clicked_cb (GtkWidget *widget, DemoApplicationWindow *window)
|
clicked_cb (GtkWidget *widget, DemoApplicationWindow *window)
|
||||||
{
|
{
|
||||||
gtk_widget_set_visible (window->infobar, FALSE);
|
gtk_widget_hide (window->infobar);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@@ -76,13 +76,8 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="status">
|
<object class="GtkStatusbar" id="status">
|
||||||
<property name="hexpand">1</property>
|
<property name="hexpand">1</property>
|
||||||
<property name="xalign">0</property>
|
|
||||||
<property name="margin-start">2</property>
|
|
||||||
<property name="margin-end">2</property>
|
|
||||||
<property name="margin-top">2</property>
|
|
||||||
<property name="margin-bottom">2</property>
|
|
||||||
<layout>
|
<layout>
|
||||||
<property name="column">0</property>
|
<property name="column">0</property>
|
||||||
<property name="row">3</property>
|
<property name="row">3</property>
|
||||||
|
@@ -7,8 +7,6 @@
|
|||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
||||||
|
|
||||||
static GtkWidget *progress_bar = NULL;
|
static GtkWidget *progress_bar = NULL;
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@@ -142,6 +140,7 @@ create_page3 (GtkWidget *assistant)
|
|||||||
|
|
||||||
label = gtk_label_new ("This is a confirmation page, press 'Apply' to apply changes");
|
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_append_page (GTK_ASSISTANT (assistant), label);
|
||||||
gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), label, GTK_ASSISTANT_PAGE_CONFIRM);
|
gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), label, GTK_ASSISTANT_PAGE_CONFIRM);
|
||||||
gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), label, TRUE);
|
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_start (progress_bar, 40);
|
||||||
gtk_widget_set_margin_end (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_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_type (GTK_ASSISTANT (assistant), progress_bar, GTK_ASSISTANT_PAGE_PROGRESS);
|
||||||
gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), progress_bar, "Applying changes");
|
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
|
/* This prevents the assistant window from being
|
||||||
* closed while we're "busy" applying changes.
|
* closed while we're "busy" applying changes.
|
||||||
*/
|
*/
|
||||||
@@ -203,7 +199,7 @@ do_assistant (GtkWidget *do_widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (assistant))
|
if (!gtk_widget_get_visible (assistant))
|
||||||
gtk_widget_set_visible (assistant, TRUE);
|
gtk_widget_show (assistant);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (assistant));
|
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;
|
return direction == GTK_TEXT_DIR_RTL ? GTK_ALIGN_START : GTK_ALIGN_END;
|
||||||
case GTK_ALIGN_FILL:
|
case GTK_ALIGN_FILL:
|
||||||
case GTK_ALIGN_CENTER:
|
case GTK_ALIGN_CENTER:
|
||||||
case GTK_ALIGN_BASELINE_FILL:
|
case GTK_ALIGN_BASELINE:
|
||||||
case GTK_ALIGN_BASELINE_CENTER:
|
|
||||||
default:
|
default:
|
||||||
return align;
|
return align;
|
||||||
}
|
}
|
||||||
@@ -259,8 +258,7 @@ blur_overlay_get_child_position (BlurOverlay *overlay,
|
|||||||
case GTK_ALIGN_END:
|
case GTK_ALIGN_END:
|
||||||
alloc->x += width - alloc->width;
|
alloc->x += width - alloc->width;
|
||||||
break;
|
break;
|
||||||
case GTK_ALIGN_BASELINE_FILL:
|
case GTK_ALIGN_BASELINE:
|
||||||
case GTK_ALIGN_BASELINE_CENTER:
|
|
||||||
default:
|
default:
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
break;
|
break;
|
||||||
@@ -283,8 +281,7 @@ blur_overlay_get_child_position (BlurOverlay *overlay,
|
|||||||
case GTK_ALIGN_END:
|
case GTK_ALIGN_END:
|
||||||
alloc->y += height - alloc->height;
|
alloc->y += height - alloc->height;
|
||||||
break;
|
break;
|
||||||
case GTK_ALIGN_BASELINE_FILL:
|
case GTK_ALIGN_BASELINE:
|
||||||
case GTK_ALIGN_BASELINE_CENTER:
|
|
||||||
default:
|
default:
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
break;
|
break;
|
||||||
@@ -300,13 +297,12 @@ blur_overlay_snapshot (GtkWidget *widget,
|
|||||||
GtkWidget *main_widget;
|
GtkWidget *main_widget;
|
||||||
GskRenderNode *main_widget_node = NULL;
|
GskRenderNode *main_widget_node = NULL;
|
||||||
GtkWidget *child;
|
GtkWidget *child;
|
||||||
int width, height;
|
GtkAllocation main_alloc;
|
||||||
cairo_region_t *clip = NULL;
|
cairo_region_t *clip = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
main_widget = BLUR_OVERLAY (widget)->main_widget;
|
main_widget = BLUR_OVERLAY (widget)->main_widget;
|
||||||
width = gtk_widget_get_width (widget);
|
gtk_widget_get_allocation (widget, &main_alloc);
|
||||||
height = gtk_widget_get_height (widget);
|
|
||||||
|
|
||||||
for (child = gtk_widget_get_first_child (widget);
|
for (child = gtk_widget_get_first_child (widget);
|
||||||
child != NULL;
|
child != NULL;
|
||||||
@@ -319,7 +315,7 @@ blur_overlay_snapshot (GtkWidget *widget,
|
|||||||
|
|
||||||
if (blur > 0)
|
if (blur > 0)
|
||||||
{
|
{
|
||||||
cairo_rectangle_int_t rect;
|
GtkAllocation alloc;
|
||||||
graphene_rect_t bounds;
|
graphene_rect_t bounds;
|
||||||
|
|
||||||
if (main_widget_node == NULL)
|
if (main_widget_node == NULL)
|
||||||
@@ -331,8 +327,8 @@ blur_overlay_snapshot (GtkWidget *widget,
|
|||||||
main_widget_node = gtk_snapshot_free_to_node (child_snapshot);
|
main_widget_node = gtk_snapshot_free_to_node (child_snapshot);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_compute_bounds (child, gtk_widget_get_parent (child), &bounds))
|
gtk_widget_get_allocation (child, &alloc);
|
||||||
graphene_rect_init (&bounds, 0, 0, 0, 0);
|
graphene_rect_init (&bounds, alloc.x, alloc.y, alloc.width, alloc.height);
|
||||||
gtk_snapshot_push_blur (snapshot, blur);
|
gtk_snapshot_push_blur (snapshot, blur);
|
||||||
gtk_snapshot_push_clip (snapshot, &bounds);
|
gtk_snapshot_push_clip (snapshot, &bounds);
|
||||||
gtk_snapshot_append_node (snapshot, main_widget_node);
|
gtk_snapshot_append_node (snapshot, main_widget_node);
|
||||||
@@ -341,17 +337,13 @@ blur_overlay_snapshot (GtkWidget *widget,
|
|||||||
|
|
||||||
if (clip == NULL)
|
if (clip == NULL)
|
||||||
{
|
{
|
||||||
|
cairo_rectangle_int_t rect;
|
||||||
rect.x = rect.y = 0;
|
rect.x = rect.y = 0;
|
||||||
rect.width = width;
|
rect.width = main_alloc.width;
|
||||||
rect.height = height;
|
rect.height = main_alloc.height;
|
||||||
clip = cairo_region_create_rectangle (&rect);
|
clip = cairo_region_create_rectangle (&rect);
|
||||||
}
|
}
|
||||||
|
cairo_region_subtract_rectangle (clip, (cairo_rectangle_int_t *)&alloc);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -18,7 +18,8 @@
|
|||||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#ifndef __BLUR_OVERLAY_H__
|
||||||
|
#define __BLUR_OVERLAY_H__
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
@@ -50,12 +51,18 @@ struct _BlurOverlayClass
|
|||||||
GtkAllocation *allocation);
|
GtkAllocation *allocation);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GDK_AVAILABLE_IN_ALL
|
||||||
GType blur_overlay_get_type (void) G_GNUC_CONST;
|
GType blur_overlay_get_type (void) G_GNUC_CONST;
|
||||||
|
GDK_AVAILABLE_IN_ALL
|
||||||
GtkWidget *blur_overlay_new (void);
|
GtkWidget *blur_overlay_new (void);
|
||||||
|
GDK_AVAILABLE_IN_ALL
|
||||||
void blur_overlay_add_overlay (BlurOverlay *overlay,
|
void blur_overlay_add_overlay (BlurOverlay *overlay,
|
||||||
GtkWidget *widget,
|
GtkWidget *widget,
|
||||||
double blur);
|
double blur);
|
||||||
|
GDK_AVAILABLE_IN_ALL
|
||||||
void blur_overlay_set_child (BlurOverlay *overlay,
|
void blur_overlay_set_child (BlurOverlay *overlay,
|
||||||
GtkWidget *widget);
|
GtkWidget *widget);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __BLUR_OVERLAY_H__ */
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* Builder
|
/* Builder
|
||||||
* #Keywords: GMenu, GtkPopoverMenuBar, GtkBuilder, GtkShortcutController, toolbar
|
* #Keywords: GMenu, GtkPopoverMenuBar, GtkBuilder, GtkStatusBar, GtkShortcutController, toolbar
|
||||||
*
|
*
|
||||||
* Demonstrates a traditional interface, loaded from a XML description,
|
* Demonstrates a traditional interface, loaded from a XML description,
|
||||||
* and shows how to connect actions to the menu items and toolbar buttons.
|
* and shows how to connect actions to the menu items and toolbar buttons.
|
||||||
@@ -37,30 +37,22 @@ remove_timeout (gpointer data)
|
|||||||
g_source_remove (id);
|
g_source_remove (id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static gboolean
|
||||||
pop_message (gpointer data)
|
pop_status (gpointer data)
|
||||||
{
|
{
|
||||||
GtkWidget *status = data;
|
gtk_statusbar_pop (GTK_STATUSBAR (data), 0);
|
||||||
|
g_object_set_data (G_OBJECT (data), "timeout", NULL);
|
||||||
gtk_label_set_label (GTK_LABEL (status), "");
|
|
||||||
g_object_set_data (G_OBJECT (status), "timeout", GUINT_TO_POINTER (0));
|
|
||||||
|
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
status_message (GtkWidget *status,
|
status_message (GtkStatusbar *status,
|
||||||
const char *text)
|
const char *text)
|
||||||
{
|
{
|
||||||
guint id;
|
guint id;
|
||||||
|
|
||||||
id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (status), "timeout"));
|
gtk_statusbar_push (GTK_STATUSBAR (status), 0, text);
|
||||||
if (id)
|
id = g_timeout_add (5000, pop_status, status);
|
||||||
g_source_remove (id);
|
|
||||||
|
|
||||||
gtk_label_set_text (GTK_LABEL (status), text);
|
|
||||||
|
|
||||||
id = g_timeout_add (5000, pop_message, status);
|
|
||||||
|
|
||||||
g_object_set_data_full (G_OBJECT (status), "timeout", GUINT_TO_POINTER (id), remove_timeout);
|
g_object_set_data_full (G_OBJECT (status), "timeout", GUINT_TO_POINTER (id), remove_timeout);
|
||||||
}
|
}
|
||||||
@@ -73,7 +65,7 @@ help_activate (GSimpleAction *action,
|
|||||||
GtkWidget *status;
|
GtkWidget *status;
|
||||||
|
|
||||||
status = GTK_WIDGET (g_object_get_data (G_OBJECT (user_data), "status"));
|
status = GTK_WIDGET (g_object_get_data (G_OBJECT (user_data), "status"));
|
||||||
status_message (status, "Help not available");
|
status_message (GTK_STATUSBAR (status), "Help not available");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -86,7 +78,7 @@ not_implemented (GSimpleAction *action,
|
|||||||
|
|
||||||
text = g_strdup_printf ("Action “%s” not implemented", g_action_get_name (G_ACTION (action)));
|
text = g_strdup_printf ("Action “%s” not implemented", g_action_get_name (G_ACTION (action)));
|
||||||
status = GTK_WIDGET (g_object_get_data (G_OBJECT (user_data), "status"));
|
status = GTK_WIDGET (g_object_get_data (G_OBJECT (user_data), "status"));
|
||||||
status_message (status, text);
|
status_message (GTK_STATUSBAR (status), text);
|
||||||
g_free (text);
|
g_free (text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,7 +168,7 @@ do_builder (GtkWidget *do_widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
gtk_widget_set_visible (window, TRUE);
|
gtk_widget_show (window);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (window));
|
gtk_window_destroy (GTK_WINDOW (window));
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.1 KiB |
@@ -1,5 +1,4 @@
|
|||||||
/* Clipboard
|
/* Clipboard
|
||||||
* #Keywords: drag-and-drop, dnd
|
|
||||||
*
|
*
|
||||||
* GdkClipboard is used for clipboard handling. This demo shows how to
|
* GdkClipboard is used for clipboard handling. This demo shows how to
|
||||||
* copy and paste text, images, colors or files to and from the clipboard.
|
* 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)
|
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));
|
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (visible_child), &color);
|
||||||
gdk_clipboard_set (clipboard, GDK_TYPE_RGBA, color);
|
gdk_clipboard_set (clipboard, GDK_TYPE_RGBA, &color);
|
||||||
}
|
}
|
||||||
else if (strcmp (visible_child_name, "File") == 0)
|
else if (strcmp (visible_child_name, "File") == 0)
|
||||||
{
|
{
|
||||||
@@ -216,71 +215,37 @@ file_button_set_file (GtkButton *button,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
file_chooser_response (GObject *source,
|
file_chooser_response (GtkNativeDialog *dialog,
|
||||||
GAsyncResult *result,
|
int response,
|
||||||
gpointer user_data)
|
GtkButton *button)
|
||||||
{
|
{
|
||||||
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
gtk_native_dialog_hide (dialog);
|
||||||
GtkButton *button = GTK_BUTTON (user_data);
|
|
||||||
GFile *file;
|
|
||||||
|
|
||||||
file = gtk_file_dialog_open_finish (dialog, result, NULL);
|
if (response == GTK_RESPONSE_ACCEPT)
|
||||||
if (file)
|
|
||||||
{
|
{
|
||||||
|
GFile *file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
||||||
file_button_set_file (button, file);
|
file_button_set_file (button, file);
|
||||||
g_object_unref (file);
|
g_object_unref (file);
|
||||||
|
|
||||||
update_copy_button_sensitivity (gtk_widget_get_ancestor (GTK_WIDGET (button), GTK_TYPE_STACK));
|
update_copy_button_sensitivity (gtk_widget_get_ancestor (GTK_WIDGET (button), GTK_TYPE_STACK));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gtk_native_dialog_destroy (dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
open_file_cb (GtkWidget *button)
|
open_file_cb (GtkWidget *button)
|
||||||
{
|
{
|
||||||
GtkFileDialog *dialog;
|
GtkFileChooserNative *chooser;
|
||||||
|
|
||||||
dialog = gtk_file_dialog_new ();
|
chooser = gtk_file_chooser_native_new ("Choose a file",
|
||||||
|
|
||||||
gtk_file_dialog_open (dialog,
|
|
||||||
GTK_WINDOW (gtk_widget_get_ancestor (button, GTK_TYPE_WINDOW)),
|
GTK_WINDOW (gtk_widget_get_ancestor (button, GTK_TYPE_WINDOW)),
|
||||||
NULL,
|
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||||
file_chooser_response, button);
|
"_Open",
|
||||||
|
"_Cancel");
|
||||||
|
|
||||||
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
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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, source_changed_cb);
|
||||||
gtk_builder_cscope_add_callback (scope, text_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_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, on_drop);
|
||||||
gtk_builder_cscope_add_callback (scope, drag_prepare);
|
gtk_builder_cscope_add_callback (scope, drag_prepare);
|
||||||
builder = gtk_builder_new ();
|
builder = gtk_builder_new ();
|
||||||
@@ -405,7 +369,7 @@ do_clipboard (GtkWidget *do_widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
gtk_widget_set_visible (window, TRUE);
|
gtk_widget_show (window);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (window));
|
gtk_window_destroy (GTK_WINDOW (window));
|
||||||
|
|
||||||
|
@@ -4,9 +4,6 @@
|
|||||||
<object class="GtkWindow" id="window">
|
<object class="GtkWindow" id="window">
|
||||||
<property name="resizable">1</property>
|
<property name="resizable">1</property>
|
||||||
<property name="title">Clipboard</property>
|
<property name="title">Clipboard</property>
|
||||||
<accessibility>
|
|
||||||
<relation name="described-by">label</relation>
|
|
||||||
</accessibility>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox">
|
<object class="GtkBox">
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
@@ -16,7 +13,7 @@
|
|||||||
<property name="margin-bottom">12</property>
|
<property name="margin-bottom">12</property>
|
||||||
<property name="spacing">12</property>
|
<property name="spacing">12</property>
|
||||||
<child>
|
<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="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="wrap">1</property>
|
||||||
<property name="max-width-chars">40</property>
|
<property name="max-width-chars">40</property>
|
||||||
@@ -27,9 +24,6 @@
|
|||||||
<property name="spacing">12</property>
|
<property name="spacing">12</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkDropDown" id="source_chooser">
|
<object class="GtkDropDown" id="source_chooser">
|
||||||
<accessibility>
|
|
||||||
<property name="label">Source Type</property>
|
|
||||||
</accessibility>
|
|
||||||
<property name="valign">center</property>
|
<property name="valign">center</property>
|
||||||
<property name="model">
|
<property name="model">
|
||||||
<object class="GtkStringList">
|
<object class="GtkStringList">
|
||||||
@@ -38,7 +32,6 @@
|
|||||||
<item>Color</item>
|
<item>Color</item>
|
||||||
<item>Image</item>
|
<item>Image</item>
|
||||||
<item>File</item>
|
<item>File</item>
|
||||||
<item>Folder</item>
|
|
||||||
</items>
|
</items>
|
||||||
</object>
|
</object>
|
||||||
</property>
|
</property>
|
||||||
@@ -60,9 +53,6 @@
|
|||||||
<property name="name">Text</property>
|
<property name="name">Text</property>
|
||||||
<property name="child">
|
<property name="child">
|
||||||
<object class="GtkEntry" id="source_text">
|
<object class="GtkEntry" id="source_text">
|
||||||
<accessibility>
|
|
||||||
<property name="label">Text Drag Source</property>
|
|
||||||
</accessibility>
|
|
||||||
<property name="valign">center</property>
|
<property name="valign">center</property>
|
||||||
<signal name="notify::text" handler="text_changed_cb" object="copy_button"/>
|
<signal name="notify::text" handler="text_changed_cb" object="copy_button"/>
|
||||||
<property name="text">Copy this!</property>
|
<property name="text">Copy this!</property>
|
||||||
@@ -74,14 +64,7 @@
|
|||||||
<object class="GtkStackPage">
|
<object class="GtkStackPage">
|
||||||
<property name="name">Color</property>
|
<property name="name">Color</property>
|
||||||
<property name="child">
|
<property name="child">
|
||||||
<object class="GtkColorDialogButton" id="source_color">
|
<object class="GtkColorButton" id="source_color">
|
||||||
<accessibility>
|
|
||||||
<property name="label">Color Drag Source</property>
|
|
||||||
</accessibility>
|
|
||||||
<property name="dialog">
|
|
||||||
<object class="GtkColorDialog">
|
|
||||||
</object>
|
|
||||||
</property>
|
|
||||||
<property name="valign">center</property>
|
<property name="valign">center</property>
|
||||||
<property name="rgba">purple</property>
|
<property name="rgba">purple</property>
|
||||||
</object>
|
</object>
|
||||||
@@ -99,17 +82,14 @@
|
|||||||
</style>
|
</style>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkToggleButton" id="image_rose">
|
<object class="GtkToggleButton" id="image_rose">
|
||||||
<accessibility>
|
|
||||||
<property name="label">Photo Drag Source</property>
|
|
||||||
</accessibility>
|
|
||||||
<property name="active">1</property>
|
<property name="active">1</property>
|
||||||
<child>
|
<child>
|
||||||
|
<object class="GtkDragSource">
|
||||||
|
<signal name="prepare" handler="drag_prepare"/>
|
||||||
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage">
|
<object class="GtkImage">
|
||||||
<accessibility>
|
|
||||||
<property name="label">Portland Rose Photo</property>
|
|
||||||
</accessibility>
|
|
||||||
<style>
|
<style>
|
||||||
<class name="large-icons"/>
|
<class name="large-icons"/>
|
||||||
</style>
|
</style>
|
||||||
@@ -120,9 +100,6 @@
|
|||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkToggleButton" id="image_floppy">
|
<object class="GtkToggleButton" id="image_floppy">
|
||||||
<accessibility>
|
|
||||||
<property name="label">Icon Drag Source</property>
|
|
||||||
</accessibility>
|
|
||||||
<property name="group">image_rose</property>
|
<property name="group">image_rose</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkDragSource">
|
<object class="GtkDragSource">
|
||||||
@@ -131,9 +108,6 @@
|
|||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage">
|
<object class="GtkImage">
|
||||||
<accessibility>
|
|
||||||
<property name="label">Floppy Buddy Icon</property>
|
|
||||||
</accessibility>
|
|
||||||
<style>
|
<style>
|
||||||
<class name="large-icons"/>
|
<class name="large-icons"/>
|
||||||
</style>
|
</style>
|
||||||
@@ -144,9 +118,6 @@
|
|||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkToggleButton" id="image_logo">
|
<object class="GtkToggleButton" id="image_logo">
|
||||||
<accessibility>
|
|
||||||
<property name="label">SVG Drag Source</property>
|
|
||||||
</accessibility>
|
|
||||||
<property name="group">image_floppy</property>
|
<property name="group">image_floppy</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkDragSource">
|
<object class="GtkDragSource">
|
||||||
@@ -155,9 +126,6 @@
|
|||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage">
|
<object class="GtkImage">
|
||||||
<accessibility>
|
|
||||||
<property name="label">gtk-demo logo</property>
|
|
||||||
</accessibility>
|
|
||||||
<style>
|
<style>
|
||||||
<class name="large-icons"/>
|
<class name="large-icons"/>
|
||||||
</style>
|
</style>
|
||||||
@@ -175,9 +143,6 @@
|
|||||||
<property name="name">File</property>
|
<property name="name">File</property>
|
||||||
<property name="child">
|
<property name="child">
|
||||||
<object class="GtkButton" id="source_file">
|
<object class="GtkButton" id="source_file">
|
||||||
<accessibility>
|
|
||||||
<property name="label">File Drag Source</property>
|
|
||||||
</accessibility>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkDragSource">
|
<object class="GtkDragSource">
|
||||||
<property name="propagation-phase">capture</property>
|
<property name="propagation-phase">capture</property>
|
||||||
@@ -197,33 +162,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</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>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
@@ -258,7 +196,7 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="paste_label">
|
<object class="GtkLabel">
|
||||||
<property name="xalign">0</property>
|
<property name="xalign">0</property>
|
||||||
<binding name="label">
|
<binding name="label">
|
||||||
<lookup name="visible-child-name" type="GtkStack">
|
<lookup name="visible-child-name" type="GtkStack">
|
||||||
@@ -285,9 +223,6 @@
|
|||||||
<property name="name">Text</property>
|
<property name="name">Text</property>
|
||||||
<property name="child">
|
<property name="child">
|
||||||
<object class="GtkLabel">
|
<object class="GtkLabel">
|
||||||
<accessibility>
|
|
||||||
<relation name="labelled-by">paste_label</relation>
|
|
||||||
</accessibility>
|
|
||||||
<property name="halign">end</property>
|
<property name="halign">end</property>
|
||||||
<property name="valign">center</property>
|
<property name="valign">center</property>
|
||||||
<property name="xalign">0</property>
|
<property name="xalign">0</property>
|
||||||
@@ -301,9 +236,6 @@
|
|||||||
<property name="name">Image</property>
|
<property name="name">Image</property>
|
||||||
<property name="child">
|
<property name="child">
|
||||||
<object class="GtkImage">
|
<object class="GtkImage">
|
||||||
<accessibility>
|
|
||||||
<relation name="labelled-by">paste_label</relation>
|
|
||||||
</accessibility>
|
|
||||||
<property name="halign">end</property>
|
<property name="halign">end</property>
|
||||||
<property name="valign">center</property>
|
<property name="valign">center</property>
|
||||||
<style>
|
<style>
|
||||||
@@ -322,9 +254,6 @@
|
|||||||
<property name="valign">center</property>
|
<property name="valign">center</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkColorSwatch">
|
<object class="GtkColorSwatch">
|
||||||
<accessibility>
|
|
||||||
<relation name="labelled-by">paste_label</relation>
|
|
||||||
</accessibility>
|
|
||||||
<property name="accessible-role">img</property>
|
<property name="accessible-role">img</property>
|
||||||
<property name="can-focus">0</property>
|
<property name="can-focus">0</property>
|
||||||
<property name="selectable">0</property>
|
<property name="selectable">0</property>
|
||||||
@@ -340,9 +269,6 @@
|
|||||||
<property name="name">File</property>
|
<property name="name">File</property>
|
||||||
<property name="child">
|
<property name="child">
|
||||||
<object class="GtkLabel">
|
<object class="GtkLabel">
|
||||||
<accessibility>
|
|
||||||
<relation name="labelled-by">paste_label</relation>
|
|
||||||
</accessibility>
|
|
||||||
<property name="halign">end</property>
|
<property name="halign">end</property>
|
||||||
<property name="valign">center</property>
|
<property name="valign">center</property>
|
||||||
<property name="xalign">0</property>
|
<property name="xalign">0</property>
|
||||||
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.4 KiB |
@@ -11,8 +11,6 @@
|
|||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
ICON_NAME_COL,
|
ICON_NAME_COL,
|
||||||
@@ -449,7 +447,7 @@ do_combobox (GtkWidget *do_widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
gtk_widget_set_visible (window, TRUE);
|
gtk_widget_show (window);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (window));
|
gtk_window_destroy (GTK_WINDOW (window));
|
||||||
|
|
||||||
|
@@ -277,7 +277,7 @@ do_constraints (GtkWidget *do_widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
gtk_widget_set_visible (window, TRUE);
|
gtk_widget_show (window);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (window));
|
gtk_window_destroy (GTK_WINDOW (window));
|
||||||
|
|
||||||
|
@@ -66,7 +66,7 @@ do_constraints_builder (GtkWidget *do_widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
gtk_widget_set_visible (window, TRUE);
|
gtk_widget_show (window);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (window));
|
gtk_window_destroy (GTK_WINDOW (window));
|
||||||
|
|
||||||
|
@@ -229,7 +229,7 @@ do_constraints_interactive (GtkWidget *do_widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
gtk_widget_set_visible (window, TRUE);
|
gtk_widget_show (window);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (window));
|
gtk_window_destroy (GTK_WINDOW (window));
|
||||||
|
|
||||||
|
@@ -152,7 +152,7 @@ do_constraints_vfl (GtkWidget *do_widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
gtk_widget_set_visible (window, TRUE);
|
gtk_widget_show (window);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (window));
|
gtk_window_destroy (GTK_WINDOW (window));
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1019 B After Width: | Height: | Size: 985 B |
@@ -1,16 +1,20 @@
|
|||||||
/* Theming/CSS Accordion
|
/* Theming/CSS Accordion
|
||||||
*
|
*
|
||||||
* A simple accordion demo written using CSS transitions and multiple backgrounds
|
* A simple accordion demo written using CSS transitions and multiple backgrounds
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
static void
|
static void
|
||||||
destroy_provider (GtkWidget *window,
|
apply_css (GtkWidget *widget, GtkStyleProvider *provider)
|
||||||
GtkStyleProvider *provider)
|
|
||||||
{
|
{
|
||||||
gtk_style_context_remove_provider_for_display (gtk_widget_get_display (window), provider);
|
GtkWidget *child;
|
||||||
|
|
||||||
|
gtk_style_context_add_provider (gtk_widget_get_style_context (widget), provider, G_MAXUINT);
|
||||||
|
for (child = gtk_widget_get_first_child (widget);
|
||||||
|
child != NULL;
|
||||||
|
child = gtk_widget_get_next_sibling (child))
|
||||||
|
apply_css (child, provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
@@ -20,8 +24,8 @@ do_css_accordion (GtkWidget *do_widget)
|
|||||||
|
|
||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
GtkWidget *container, *styled_box, *child;
|
GtkWidget *container, *child;
|
||||||
GtkCssProvider *provider;
|
GtkStyleProvider *provider;
|
||||||
|
|
||||||
window = gtk_window_new ();
|
window = gtk_window_new ();
|
||||||
gtk_window_set_title (GTK_WINDOW (window), "CSS Accordion");
|
gtk_window_set_title (GTK_WINDOW (window), "CSS Accordion");
|
||||||
@@ -29,13 +33,10 @@ do_css_accordion (GtkWidget *do_widget)
|
|||||||
gtk_window_set_default_size (GTK_WINDOW (window), 600, 300);
|
gtk_window_set_default_size (GTK_WINDOW (window), 600, 300);
|
||||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||||
|
|
||||||
styled_box = gtk_frame_new (NULL);
|
|
||||||
gtk_window_set_child (GTK_WINDOW (window), styled_box);
|
|
||||||
gtk_widget_add_css_class (styled_box, "accordion");
|
|
||||||
container = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
container = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||||
gtk_widget_set_halign (container, GTK_ALIGN_CENTER);
|
gtk_widget_set_halign (container, GTK_ALIGN_CENTER);
|
||||||
gtk_widget_set_valign (container, GTK_ALIGN_CENTER);
|
gtk_widget_set_valign (container, GTK_ALIGN_CENTER);
|
||||||
gtk_frame_set_child (GTK_FRAME (styled_box), container);
|
gtk_window_set_child (GTK_WINDOW (window), container);
|
||||||
|
|
||||||
child = gtk_button_new_with_label ("This");
|
child = gtk_button_new_with_label ("This");
|
||||||
gtk_box_append (GTK_BOX (container), child);
|
gtk_box_append (GTK_BOX (container), child);
|
||||||
@@ -55,20 +56,14 @@ do_css_accordion (GtkWidget *do_widget)
|
|||||||
child = gtk_button_new_with_label (":-)");
|
child = gtk_button_new_with_label (":-)");
|
||||||
gtk_box_append (GTK_BOX (container), child);
|
gtk_box_append (GTK_BOX (container), child);
|
||||||
|
|
||||||
provider = gtk_css_provider_new ();
|
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
|
||||||
gtk_css_provider_load_from_resource (provider, "/css_accordion/css_accordion.css");
|
gtk_css_provider_load_from_resource (GTK_CSS_PROVIDER (provider), "/css_accordion/css_accordion.css");
|
||||||
|
|
||||||
gtk_style_context_add_provider_for_display (gtk_widget_get_display (window),
|
apply_css (window, provider);
|
||||||
GTK_STYLE_PROVIDER (provider),
|
|
||||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
|
||||||
|
|
||||||
g_signal_connect (window, "destroy",
|
|
||||||
G_CALLBACK (destroy_provider), provider);
|
|
||||||
g_object_unref (provider);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
gtk_widget_set_visible (window, TRUE);
|
gtk_widget_show (window);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (window));
|
gtk_window_destroy (GTK_WINDOW (window));
|
||||||
|
|
||||||
|
@@ -1,13 +1,13 @@
|
|||||||
.accordion, .accordion * {
|
@import url("resource://css_accordion/reset.css");
|
||||||
all: unset;
|
|
||||||
|
|
||||||
|
* {
|
||||||
transition-property: color, background-color, border-color, background-image, padding, border-width;
|
transition-property: color, background-color, border-color, background-image, padding, border-width;
|
||||||
transition-duration: 1s;
|
transition-duration: 1s;
|
||||||
|
|
||||||
font: 20px Cantarell;
|
font: 20px Cantarell;
|
||||||
}
|
}
|
||||||
|
|
||||||
.accordion {
|
window {
|
||||||
background: linear-gradient(153deg, #151515, #151515 5px, transparent 5px) 0 0,
|
background: linear-gradient(153deg, #151515, #151515 5px, transparent 5px) 0 0,
|
||||||
linear-gradient(333deg, #151515, #151515 5px, transparent 5px) 10px 5px,
|
linear-gradient(333deg, #151515, #151515 5px, transparent 5px) 10px 5px,
|
||||||
linear-gradient(153deg, #222, #222 5px, transparent 5px) 0 5px,
|
linear-gradient(153deg, #222, #222 5px, transparent 5px) 0 5px,
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
background-size: 20px 20px;
|
background-size: 20px 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.accordion button {
|
button {
|
||||||
color: black;
|
color: black;
|
||||||
background-color: #bbb;
|
background-color: #bbb;
|
||||||
border-style: solid;
|
border-style: solid;
|
||||||
@@ -28,25 +28,25 @@
|
|||||||
padding: 12px 4px;
|
padding: 12px 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.accordion button:first-child {
|
button:first-child {
|
||||||
border-radius: 5px 0 0 5px;
|
border-radius: 5px 0 0 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.accordion button:last-child {
|
button:last-child {
|
||||||
border-radius: 0 5px 5px 0;
|
border-radius: 0 5px 5px 0;
|
||||||
border-width: 2px;
|
border-width: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.accordion button:hover {
|
button:hover {
|
||||||
padding: 12px 48px;
|
padding: 12px 48px;
|
||||||
background-color: #4870bc;
|
background-color: #4870bc;
|
||||||
}
|
}
|
||||||
|
|
||||||
.accordion button *:hover {
|
button *:hover {
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.accordion button:hover:active,
|
button:hover:active,
|
||||||
.accordion button:active {
|
button:active {
|
||||||
background-color: #993401;
|
background-color: #993401;
|
||||||
}
|
}
|
||||||
|
@@ -47,23 +47,20 @@ css_text_changed (GtkTextBuffer *buffer,
|
|||||||
gtk_text_buffer_remove_all_tags (buffer, &start, &end);
|
gtk_text_buffer_remove_all_tags (buffer, &start, &end);
|
||||||
|
|
||||||
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
|
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
|
||||||
gtk_css_provider_load_from_string (provider, text);
|
gtk_css_provider_load_from_data (provider, text, -1);
|
||||||
g_free (text);
|
g_free (text);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
clear_provider (gpointer data)
|
|
||||||
{
|
|
||||||
GtkStyleProvider *provider = data;
|
|
||||||
|
|
||||||
gtk_style_context_remove_provider_for_display (gdk_display_get_default (), provider);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
apply_css (GtkWidget *widget, GtkStyleProvider *provider)
|
apply_css (GtkWidget *widget, GtkStyleProvider *provider)
|
||||||
{
|
{
|
||||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (), provider, G_MAXUINT);
|
GtkWidget *child;
|
||||||
g_object_set_data_full (G_OBJECT (widget), "provider", provider, clear_provider);
|
|
||||||
|
gtk_style_context_add_provider (gtk_widget_get_style_context (widget), provider, G_MAXUINT);
|
||||||
|
for (child = gtk_widget_get_first_child (widget);
|
||||||
|
child != NULL;
|
||||||
|
child = gtk_widget_get_next_sibling (child))
|
||||||
|
apply_css (child, provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
@@ -82,7 +79,6 @@ do_css_basics (GtkWidget *do_widget)
|
|||||||
gtk_window_set_title (GTK_WINDOW (window), "CSS Basics");
|
gtk_window_set_title (GTK_WINDOW (window), "CSS Basics");
|
||||||
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
|
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
|
||||||
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
|
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
|
||||||
gtk_widget_add_css_class (window, "demo");
|
|
||||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||||
|
|
||||||
text = gtk_text_buffer_new (NULL);
|
text = gtk_text_buffer_new (NULL);
|
||||||
@@ -117,7 +113,7 @@ do_css_basics (GtkWidget *do_widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
gtk_widget_set_visible (window, TRUE);
|
gtk_widget_show (window);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (window));
|
gtk_window_destroy (GTK_WINDOW (window));
|
||||||
|
|
||||||
|
@@ -4,24 +4,23 @@
|
|||||||
* anymore. :)
|
* anymore. :)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* This resets all properties to their defaults values
|
/* This CSS resets all properties to their defaults values
|
||||||
* and overrides all user settings and the theme in use
|
* and overrides all user settings and the theme in use */
|
||||||
*/
|
@import url("resource://css_basics/reset.css");
|
||||||
@import url("resource://css_shadows/reset.css");
|
|
||||||
|
|
||||||
/* Set a very futuristic style by default */
|
/* Set a very futuristic style by default */
|
||||||
.demo * {
|
* {
|
||||||
color: green;
|
color: green;
|
||||||
font-family: Monospace;
|
font-family: Monospace;
|
||||||
border: 1px solid;
|
border: 1px solid;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.demo {
|
window {
|
||||||
background-color: white;
|
background-color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure selections are visible */
|
/* Make sure selections are visible */
|
||||||
.demo selection {
|
selection {
|
||||||
background-color: darkGreen;
|
background-color: darkGreen;
|
||||||
color: black;
|
color: black;
|
||||||
}
|
}
|
||||||
|
@@ -50,7 +50,7 @@ update_css_for_blend_mode (GtkCssProvider *provider,
|
|||||||
blend_mode,
|
blend_mode,
|
||||||
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_bytes_unref (bytes);
|
||||||
g_free (css);
|
g_free (css);
|
||||||
@@ -139,7 +139,7 @@ do_css_blendmodes (GtkWidget *do_widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
gtk_widget_set_visible (window, TRUE);
|
gtk_widget_show (window);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (window));
|
gtk_window_destroy (GTK_WINDOW (window));
|
||||||
|
|
||||||
|
@@ -48,23 +48,33 @@ css_text_changed (GtkTextBuffer *buffer,
|
|||||||
gtk_text_buffer_remove_all_tags (buffer, &start, &end);
|
gtk_text_buffer_remove_all_tags (buffer, &start, &end);
|
||||||
|
|
||||||
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
|
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
|
||||||
gtk_css_provider_load_from_string (provider, text);
|
gtk_css_provider_load_from_data (provider, text, -1);
|
||||||
g_free (text);
|
g_free (text);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clear_provider (gpointer data)
|
drawing_area_draw (GtkDrawingArea *da,
|
||||||
|
cairo_t *cr,
|
||||||
|
int width,
|
||||||
|
int height,
|
||||||
|
gpointer data)
|
||||||
{
|
{
|
||||||
GtkStyleProvider *provider = data;
|
GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET (da));
|
||||||
|
|
||||||
gtk_style_context_remove_provider_for_display (gdk_display_get_default (), provider);
|
gtk_render_background (context, cr, 0, 0, width, height);
|
||||||
|
gtk_render_frame (context, cr, 0, 0, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
apply_css (GtkWidget *widget, GtkStyleProvider *provider)
|
apply_css (GtkWidget *widget, GtkStyleProvider *provider)
|
||||||
{
|
{
|
||||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (), provider, G_MAXUINT);
|
GtkWidget *child;
|
||||||
g_object_set_data_full (G_OBJECT (widget), "provider", provider, clear_provider);
|
|
||||||
|
gtk_style_context_add_provider (gtk_widget_get_style_context (widget), provider, G_MAXUINT);
|
||||||
|
for (child = gtk_widget_get_first_child (widget);
|
||||||
|
child != NULL;
|
||||||
|
child = gtk_widget_get_next_sibling (child))
|
||||||
|
apply_css (child, provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
@@ -83,17 +93,16 @@ do_css_multiplebgs (GtkWidget *do_widget)
|
|||||||
gtk_window_set_title (GTK_WINDOW (window), "Multiple Backgrounds");
|
gtk_window_set_title (GTK_WINDOW (window), "Multiple Backgrounds");
|
||||||
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
|
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
|
||||||
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
|
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
|
||||||
gtk_widget_add_css_class (window, "demo");
|
|
||||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||||
|
|
||||||
overlay = gtk_overlay_new ();
|
overlay = gtk_overlay_new ();
|
||||||
gtk_window_set_child (GTK_WINDOW (window), overlay);
|
gtk_window_set_child (GTK_WINDOW (window), overlay);
|
||||||
|
|
||||||
child = gtk_drawing_area_new ();
|
child = gtk_drawing_area_new ();
|
||||||
/* Don't set a draw_func, since we are only interested in CSS drawing,
|
|
||||||
* which happens automatically.
|
|
||||||
*/
|
|
||||||
gtk_widget_set_name (child, "canvas");
|
gtk_widget_set_name (child, "canvas");
|
||||||
|
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (child),
|
||||||
|
drawing_area_draw,
|
||||||
|
NULL, NULL);
|
||||||
gtk_overlay_set_child (GTK_OVERLAY (overlay), child);
|
gtk_overlay_set_child (GTK_OVERLAY (overlay), child);
|
||||||
|
|
||||||
child = gtk_button_new ();
|
child = gtk_button_new ();
|
||||||
@@ -144,7 +153,7 @@ do_css_multiplebgs (GtkWidget *do_widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
gtk_widget_set_visible (window, TRUE);
|
gtk_widget_show (window);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (window));
|
gtk_window_destroy (GTK_WINDOW (window));
|
||||||
|
|
||||||
|
@@ -49,23 +49,20 @@ css_text_changed (GtkTextBuffer *buffer,
|
|||||||
gtk_text_buffer_remove_all_tags (buffer, &start, &end);
|
gtk_text_buffer_remove_all_tags (buffer, &start, &end);
|
||||||
|
|
||||||
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
|
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
|
||||||
gtk_css_provider_load_from_string (provider, text);
|
gtk_css_provider_load_from_data (provider, text, -1);
|
||||||
g_free (text);
|
g_free (text);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
clear_provider (gpointer data)
|
|
||||||
{
|
|
||||||
GtkStyleProvider *provider = data;
|
|
||||||
|
|
||||||
gtk_style_context_remove_provider_for_display (gdk_display_get_default (), provider);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
apply_css (GtkWidget *widget, GtkStyleProvider *provider)
|
apply_css (GtkWidget *widget, GtkStyleProvider *provider)
|
||||||
{
|
{
|
||||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (), provider, G_MAXUINT);
|
GtkWidget *child;
|
||||||
g_object_set_data_full (G_OBJECT (widget), "provider", provider, clear_provider);
|
|
||||||
|
gtk_style_context_add_provider (gtk_widget_get_style_context (widget), provider, G_MAXUINT);
|
||||||
|
for (child = gtk_widget_get_first_child (widget);
|
||||||
|
child != NULL;
|
||||||
|
child = gtk_widget_get_next_sibling (child))
|
||||||
|
apply_css (child, provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
@@ -84,7 +81,6 @@ do_css_pixbufs (GtkWidget *do_widget)
|
|||||||
gtk_window_set_title (GTK_WINDOW (window), "Animated Backgrounds");
|
gtk_window_set_title (GTK_WINDOW (window), "Animated Backgrounds");
|
||||||
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
|
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
|
||||||
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
|
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
|
||||||
gtk_widget_add_css_class (window, "demo");
|
|
||||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||||
|
|
||||||
paned = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
|
paned = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
|
||||||
@@ -126,7 +122,7 @@ do_css_pixbufs (GtkWidget *do_widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
gtk_widget_set_visible (window, TRUE);
|
gtk_widget_show (window);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (window));
|
gtk_window_destroy (GTK_WINDOW (window));
|
||||||
|
|
||||||
|
@@ -50,7 +50,7 @@
|
|||||||
100% { background-size: 12px, 96px, 12px, 96px, 12px, 96px, 12px, 96px, auto; }
|
100% { background-size: 12px, 96px, 12px, 96px, 12px, 96px, 12px, 96px, auto; }
|
||||||
}
|
}
|
||||||
|
|
||||||
window.demo {
|
window {
|
||||||
background-image: url("resource://css_pixbufs/images/apple-red.png"),
|
background-image: url("resource://css_pixbufs/images/apple-red.png"),
|
||||||
url("resource://css_pixbufs/images/gnome-applets.png"),
|
url("resource://css_pixbufs/images/gnome-applets.png"),
|
||||||
url("resource://css_pixbufs/images/gnome-calendar.png"),
|
url("resource://css_pixbufs/images/gnome-calendar.png"),
|
||||||
@@ -66,11 +66,11 @@ window.demo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Make the text editor has a nice style */
|
/* Make the text editor has a nice style */
|
||||||
window.demo .view, scrollbar, separator {
|
.view, scrollbar, separator {
|
||||||
color: black;
|
color: black;
|
||||||
background-color: rgba(255,255,255,0.5);
|
background-color: rgba(255,255,255,0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.demo .view:selected {
|
.view:selected {
|
||||||
background-color: rgba(127,127,255,0.5);
|
background-color: rgba(127,127,255,0.5);
|
||||||
}
|
}
|
||||||
|
@@ -46,23 +46,20 @@ css_text_changed (GtkTextBuffer *buffer,
|
|||||||
gtk_text_buffer_remove_all_tags (buffer, &start, &end);
|
gtk_text_buffer_remove_all_tags (buffer, &start, &end);
|
||||||
|
|
||||||
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
|
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
|
||||||
gtk_css_provider_load_from_string (provider, text);
|
gtk_css_provider_load_from_data (provider, text, -1);
|
||||||
g_free (text);
|
g_free (text);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
clear_provider (gpointer data)
|
|
||||||
{
|
|
||||||
GtkStyleProvider *provider = data;
|
|
||||||
|
|
||||||
gtk_style_context_remove_provider_for_display (gdk_display_get_default (), provider);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
apply_css (GtkWidget *widget, GtkStyleProvider *provider)
|
apply_css (GtkWidget *widget, GtkStyleProvider *provider)
|
||||||
{
|
{
|
||||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (), provider, G_MAXUINT);
|
GtkWidget *child;
|
||||||
g_object_set_data_full (G_OBJECT (widget), "provider", provider, clear_provider);
|
|
||||||
|
gtk_style_context_add_provider (gtk_widget_get_style_context (widget), provider, G_MAXUINT);
|
||||||
|
for (child = gtk_widget_get_first_child (widget);
|
||||||
|
child != NULL;
|
||||||
|
child = gtk_widget_get_next_sibling (child))
|
||||||
|
apply_css (child, provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
@@ -102,7 +99,6 @@ do_css_shadows (GtkWidget *do_widget)
|
|||||||
gtk_window_set_title (GTK_WINDOW (window), "Shadows");
|
gtk_window_set_title (GTK_WINDOW (window), "Shadows");
|
||||||
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
|
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
|
||||||
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
|
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
|
||||||
gtk_widget_add_css_class (window, "demo");
|
|
||||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||||
|
|
||||||
paned = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
|
paned = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
|
||||||
@@ -144,7 +140,7 @@ do_css_shadows (GtkWidget *do_widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
gtk_window_present (GTK_WINDOW (window));
|
gtk_widget_show (window);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (window));
|
gtk_window_destroy (GTK_WINDOW (window));
|
||||||
|
|
||||||
|
@@ -5,13 +5,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* This CSS resets all properties to their defaults values
|
/* This CSS resets all properties to their defaults values
|
||||||
* and overrides all user settings and the theme in use
|
* and overrides all user settings and the theme in use */
|
||||||
*/
|
|
||||||
@import url("resource://css_shadows/reset.css");
|
@import url("resource://css_shadows/reset.css");
|
||||||
@import url("resource://css_shadows/cssview.css");
|
@import url("resource://css_shadows/cssview.css");
|
||||||
|
|
||||||
/* Get a nice background for the window */
|
/* Get a nice background for the window */
|
||||||
window.demo.background {
|
.background {
|
||||||
background-color: #4870bc;
|
background-color: #4870bc;
|
||||||
background-image: linear-gradient(to left, transparent, rgba(255,255,255,.07) 50%, transparent 50%),
|
background-image: linear-gradient(to left, transparent, rgba(255,255,255,.07) 50%, transparent 50%),
|
||||||
linear-gradient(to left, transparent, rgba(255,255,255,.13) 50%, transparent 50%),
|
linear-gradient(to left, transparent, rgba(255,255,255,.13) 50%, transparent 50%),
|
||||||
@@ -20,7 +19,7 @@ window.demo.background {
|
|||||||
background-size: 29px, 59px, 73px, 109px;
|
background-size: 29px, 59px, 73px, 109px;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.demo button {
|
button {
|
||||||
color: black;
|
color: black;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
@@ -28,15 +27,18 @@ window.demo button {
|
|||||||
border: 1px transparent solid;
|
border: 1px transparent solid;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.demo button:hover {
|
button:hover {
|
||||||
text-shadow: 3px 3px 5px alpha(black, 0.75);
|
text-shadow: 3px 3px 5px alpha(black, 0.75);
|
||||||
-gtk-icon-shadow: 3px 3px 5px alpha(black, 0.75);
|
-gtk-icon-shadow: 3px 3px 5px alpha(black, 0.75);
|
||||||
box-shadow: 3px 3px 5px alpha(black, 0.5) inset;
|
box-shadow: 3px 3px 5px alpha(black, 0.5) inset;
|
||||||
border: solid 1px alpha(black, 0.75);
|
border: solid 1px alpha(black, 0.75);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.demo button:active {
|
button:active {
|
||||||
padding: 11px 9px 9px 11px;
|
padding: 11px 9px 9px 11px;
|
||||||
text-shadow: 1px 1px 2.5px alpha(black, 0.6);
|
text-shadow: 1px 1px 2.5px alpha(black, 0.6);
|
||||||
-gtk-icon-shadow: 1px 1px 2.5px alpha(black, 0.6);
|
-gtk-icon-shadow: 1px 1px 2.5px alpha(black, 0.6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,21 +1,21 @@
|
|||||||
/* Make the text editor has a nice style */
|
/* Make the text editor has a nice style */
|
||||||
window.demo .view {
|
.view {
|
||||||
color: #2e3436;
|
color: #2e3436;
|
||||||
font-family: Monospace;
|
font-family: Monospace;
|
||||||
background-color: alpha(white, 0.30);
|
background-color: alpha(white, 0.30);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.demo .view:selected {
|
.view:selected {
|
||||||
color: white;
|
color: white;
|
||||||
background-color: #4a90d9;
|
background-color: #4a90d9;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.demo scrollbar trough,
|
scrollbar trough,
|
||||||
.scrollbars-junction {
|
.scrollbars-junction {
|
||||||
background-color: alpha(white, 0.80);
|
background-color: alpha(white, 0.80);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.demo scrollbar slider {
|
scrollbar slider {
|
||||||
border-width: 3px;
|
border-width: 3px;
|
||||||
border-style: solid;
|
border-style: solid;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
@@ -24,11 +24,11 @@ window.demo scrollbar slider {
|
|||||||
background-color: #999;
|
background-color: #999;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.demo scrollbar slider:hover {
|
scrollbar slider:hover {
|
||||||
background-color: #555;
|
background-color: #555;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.demo paned separator {
|
paned separator {
|
||||||
background-color: alpha(white, 0.80);
|
background-color: alpha(white, 0.80);
|
||||||
background-image: linear-gradient(transparent, transparent 1px, #999 1px, #999 4px, transparent 4px);
|
background-image: linear-gradient(transparent, transparent 1px, #999 1px, #999 4px, transparent 4px);
|
||||||
background-size: 40px auto;
|
background-size: 40px auto;
|
||||||
@@ -36,6 +36,6 @@ window.demo paned separator {
|
|||||||
background-position: center;
|
background-position: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.demo paned separator:hover {
|
paned separator:hover {
|
||||||
background-image: linear-gradient(transparent, transparent 1px, #555 1px, #555 4px, transparent 4px);
|
background-image: linear-gradient(transparent, transparent 1px, #555 1px, #555 4px, transparent 4px);
|
||||||
}
|
}
|
||||||
|
@@ -15,54 +15,12 @@ on_destroy (gpointer data)
|
|||||||
window = NULL;
|
window = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GdkTexture *
|
|
||||||
cursor_callback (GdkCursor *cursor,
|
|
||||||
int cursor_size,
|
|
||||||
double scale,
|
|
||||||
int *width,
|
|
||||||
int *height,
|
|
||||||
int *hotspot_x,
|
|
||||||
int *hotspot_y,
|
|
||||||
gpointer data)
|
|
||||||
{
|
|
||||||
GdkPixbuf *pixbuf;
|
|
||||||
GdkTexture *texture;
|
|
||||||
GError *error = NULL;
|
|
||||||
int scaled_size;
|
|
||||||
|
|
||||||
scaled_size = ceil (cursor_size * scale);
|
|
||||||
|
|
||||||
pixbuf = gdk_pixbuf_new_from_resource_at_scale ("/cursors/images/gtk-logo.svg",
|
|
||||||
scaled_size, scaled_size,
|
|
||||||
TRUE,
|
|
||||||
&error);
|
|
||||||
if (!pixbuf)
|
|
||||||
{
|
|
||||||
g_print ("%s\n", error->message);
|
|
||||||
g_error_free (error);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
|
||||||
|
|
||||||
g_object_unref (pixbuf);
|
|
||||||
|
|
||||||
*width = cursor_size;
|
|
||||||
*height = cursor_size;
|
|
||||||
*hotspot_x = 18 * cursor_size / 32.0;
|
|
||||||
*hotspot_y = 2 * cursor_size / 32.0;
|
|
||||||
|
|
||||||
return texture;
|
|
||||||
}
|
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
do_cursors (GtkWidget *do_widget)
|
do_cursors (GtkWidget *do_widget)
|
||||||
{
|
{
|
||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
GtkBuilder *builder;
|
GtkBuilder *builder;
|
||||||
GtkWidget *logo_callback;
|
|
||||||
GdkCursor *cursor;
|
|
||||||
|
|
||||||
builder = gtk_builder_new_from_resource ("/cursors/cursors.ui");
|
builder = gtk_builder_new_from_resource ("/cursors/cursors.ui");
|
||||||
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
|
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
|
||||||
@@ -71,15 +29,11 @@ do_cursors (GtkWidget *do_widget)
|
|||||||
gtk_widget_get_display (do_widget));
|
gtk_widget_get_display (do_widget));
|
||||||
g_signal_connect (window, "destroy",
|
g_signal_connect (window, "destroy",
|
||||||
G_CALLBACK (on_destroy), NULL);
|
G_CALLBACK (on_destroy), NULL);
|
||||||
logo_callback = GTK_WIDGET (gtk_builder_get_object (builder, "logo_callback"));
|
|
||||||
cursor = gdk_cursor_new_from_callback (cursor_callback, NULL, NULL, NULL);
|
|
||||||
gtk_widget_set_cursor (logo_callback, cursor);
|
|
||||||
g_object_unref (cursor);
|
|
||||||
g_object_unref (builder);
|
g_object_unref (builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
gtk_widget_set_visible (window, TRUE);
|
gtk_widget_show (window);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (window));
|
gtk_window_destroy (GTK_WINDOW (window));
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
@@ -24,6 +24,7 @@
|
|||||||
</gresource>
|
</gresource>
|
||||||
<gresource prefix="/css_accordion">
|
<gresource prefix="/css_accordion">
|
||||||
<file>css_accordion.css</file>
|
<file>css_accordion.css</file>
|
||||||
|
<file>reset.css</file>
|
||||||
</gresource>
|
</gresource>
|
||||||
<gresource prefix="/css_basics">
|
<gresource prefix="/css_basics">
|
||||||
<file>css_basics.css</file>
|
<file>css_basics.css</file>
|
||||||
@@ -43,7 +44,7 @@
|
|||||||
<file>cssview.css</file>
|
<file>cssview.css</file>
|
||||||
<file>reset.css</file>
|
<file>reset.css</file>
|
||||||
</gresource>
|
</gresource>
|
||||||
<gresource prefix="/listview_selections">
|
<gresource prefix="/dropdown">
|
||||||
<file>suggestionentry.h</file>
|
<file>suggestionentry.h</file>
|
||||||
<file>suggestionentry.c</file>
|
<file>suggestionentry.c</file>
|
||||||
<file>suggestionentry.css</file>
|
<file>suggestionentry.css</file>
|
||||||
@@ -116,7 +117,6 @@
|
|||||||
<file>w_resize_cursor.png</file>
|
<file>w_resize_cursor.png</file>
|
||||||
<file>zoom_in_cursor.png</file>
|
<file>zoom_in_cursor.png</file>
|
||||||
<file>zoom_out_cursor.png</file>
|
<file>zoom_out_cursor.png</file>
|
||||||
<file>gtk-logo.svg</file>
|
|
||||||
</gresource>
|
</gresource>
|
||||||
<gresource prefix="/dnd">
|
<gresource prefix="/dnd">
|
||||||
<file>dnd.css</file>
|
<file>dnd.css</file>
|
||||||
@@ -128,7 +128,6 @@
|
|||||||
<file>fishbowl.ui</file>
|
<file>fishbowl.ui</file>
|
||||||
<file>gtkfishbowl.c</file>
|
<file>gtkfishbowl.c</file>
|
||||||
<file>gtkfishbowl.h</file>
|
<file>gtkfishbowl.h</file>
|
||||||
<file>tiger.node</file>
|
|
||||||
</gresource>
|
</gresource>
|
||||||
<gresource prefix="/frames">
|
<gresource prefix="/frames">
|
||||||
<file>frames.ui</file>
|
<file>frames.ui</file>
|
||||||
@@ -197,9 +196,6 @@
|
|||||||
<gresource prefix="/listview_settings">
|
<gresource prefix="/listview_settings">
|
||||||
<file>listview_settings.ui</file>
|
<file>listview_settings.ui</file>
|
||||||
</gresource>
|
</gresource>
|
||||||
<gresource prefix="/listview_settings2">
|
|
||||||
<file>listview_settings2.ui</file>
|
|
||||||
</gresource>
|
|
||||||
<gresource prefix="/listview_ucd_data/">
|
<gresource prefix="/listview_ucd_data/">
|
||||||
<file>ucdnames.data</file>
|
<file>ucdnames.data</file>
|
||||||
</gresource>
|
</gresource>
|
||||||
@@ -220,12 +216,6 @@
|
|||||||
<file>demo3widget.h</file>
|
<file>demo3widget.h</file>
|
||||||
<file>demo3widget.ui</file>
|
<file>demo3widget.ui</file>
|
||||||
</gresource>
|
</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">
|
<gresource prefix="/paintable_svg">
|
||||||
<file>svgpaintable.h</file>
|
<file>svgpaintable.h</file>
|
||||||
<file>svgpaintable.c</file>
|
<file>svgpaintable.c</file>
|
||||||
@@ -279,6 +269,7 @@
|
|||||||
<file>cursors.c</file>
|
<file>cursors.c</file>
|
||||||
<file>dialog.c</file>
|
<file>dialog.c</file>
|
||||||
<file>drawingarea.c</file>
|
<file>drawingarea.c</file>
|
||||||
|
<file>dropdown.c</file>
|
||||||
<file>dnd.c</file>
|
<file>dnd.c</file>
|
||||||
<file>editable_cells.c</file>
|
<file>editable_cells.c</file>
|
||||||
<file>entry_completion.c</file>
|
<file>entry_completion.c</file>
|
||||||
@@ -302,7 +293,6 @@
|
|||||||
<file>iconscroll.c</file>
|
<file>iconscroll.c</file>
|
||||||
<file>iconview.c</file>
|
<file>iconview.c</file>
|
||||||
<file>iconview_edit.c</file>
|
<file>iconview_edit.c</file>
|
||||||
<file>image_scaling.c</file>
|
|
||||||
<file>images.c</file>
|
<file>images.c</file>
|
||||||
<file>infobar.c</file>
|
<file>infobar.c</file>
|
||||||
<file>layoutmanager.c</file>
|
<file>layoutmanager.c</file>
|
||||||
@@ -315,16 +305,14 @@
|
|||||||
<file>listview_clocks.c</file>
|
<file>listview_clocks.c</file>
|
||||||
<file>listview_filebrowser.c</file>
|
<file>listview_filebrowser.c</file>
|
||||||
<file>listview_minesweeper.c</file>
|
<file>listview_minesweeper.c</file>
|
||||||
<file>listview_selections.c</file>
|
|
||||||
<file>listview_settings.c</file>
|
<file>listview_settings.c</file>
|
||||||
<file>listview_settings2.c</file>
|
|
||||||
<file>listview_ucd.c</file>
|
<file>listview_ucd.c</file>
|
||||||
<file>listview_weather.c</file>
|
<file>listview_weather.c</file>
|
||||||
<file>listview_words.c</file>
|
<file>listview_words.c</file>
|
||||||
<file>list_store.c</file>
|
<file>list_store.c</file>
|
||||||
<file>main.c</file>
|
<file>main.c</file>
|
||||||
<file>markup.c</file>
|
<file>markup.c</file>
|
||||||
<file>mask.c</file>
|
<file>menu.c</file>
|
||||||
<file>overlay.c</file>
|
<file>overlay.c</file>
|
||||||
<file>overlay_decorative.c</file>
|
<file>overlay_decorative.c</file>
|
||||||
<file>paint.c</file>
|
<file>paint.c</file>
|
||||||
@@ -337,11 +325,6 @@
|
|||||||
<file>paintable_symbolic.c</file>
|
<file>paintable_symbolic.c</file>
|
||||||
<file>panes.c</file>
|
<file>panes.c</file>
|
||||||
<file>password_entry.c</file>
|
<file>password_entry.c</file>
|
||||||
<file>path_fill.c</file>
|
|
||||||
<file>path_maze.c</file>
|
|
||||||
<file>path_spinner.c</file>
|
|
||||||
<file>path_walk.c</file>
|
|
||||||
<file>path_text.c</file>
|
|
||||||
<file>peg_solitaire.c</file>
|
<file>peg_solitaire.c</file>
|
||||||
<file>pickers.c</file>
|
<file>pickers.c</file>
|
||||||
<file>printing.c</file>
|
<file>printing.c</file>
|
||||||
@@ -427,13 +410,6 @@
|
|||||||
<gresource prefix="/fontrendering">
|
<gresource prefix="/fontrendering">
|
||||||
<file>fontrendering.ui</file>
|
<file>fontrendering.ui</file>
|
||||||
</gresource>
|
</gresource>
|
||||||
<gresource prefix="/path_walk">
|
|
||||||
<file>path_walk.ui</file>
|
|
||||||
<file compressed="true">path_world.txt</file>
|
|
||||||
</gresource>
|
|
||||||
<gresource prefix="/path_text">
|
|
||||||
<file>path_text.ui</file>
|
|
||||||
</gresource>
|
|
||||||
<gresource prefix="/org/gtk/Demo4">
|
<gresource prefix="/org/gtk/Demo4">
|
||||||
<file>icons/16x16/actions/application-exit.png</file>
|
<file>icons/16x16/actions/application-exit.png</file>
|
||||||
<file>icons/16x16/actions/document-new.png</file>
|
<file>icons/16x16/actions/document-new.png</file>
|
||||||
|
@@ -208,13 +208,7 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="statusbar1">
|
<object class="GtkStatusbar" id="statusbar1"/>
|
||||||
<property name="xalign">0</property>
|
|
||||||
<property name="margin-start">2</property>
|
|
||||||
<property name="margin-end">2</property>
|
|
||||||
<property name="margin-top">2</property>
|
|
||||||
<property name="margin-bottom">2</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
@@ -3,20 +3,16 @@
|
|||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_TEXTURE = 1,
|
PROP_PAINTABLE = 1,
|
||||||
PROP_FILTER,
|
PROP_SCALE
|
||||||
PROP_SCALE,
|
|
||||||
PROP_ANGLE,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Demo3Widget
|
struct _Demo3Widget
|
||||||
{
|
{
|
||||||
GtkWidget parent_instance;
|
GtkWidget parent_instance;
|
||||||
|
|
||||||
GdkTexture *texture;
|
GdkPaintable *paintable;
|
||||||
float scale;
|
float scale;
|
||||||
float angle;
|
|
||||||
GskScalingFilter filter;
|
|
||||||
|
|
||||||
GtkWidget *menu;
|
GtkWidget *menu;
|
||||||
};
|
};
|
||||||
@@ -28,88 +24,10 @@ struct _Demo3WidgetClass
|
|||||||
|
|
||||||
G_DEFINE_TYPE (Demo3Widget, demo3_widget, GTK_TYPE_WIDGET)
|
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;
|
|
||||||
s = NULL;
|
|
||||||
do {
|
|
||||||
g_free (s);
|
|
||||||
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
|
static void
|
||||||
demo3_widget_init (Demo3Widget *self)
|
demo3_widget_init (Demo3Widget *self)
|
||||||
{
|
{
|
||||||
self->scale = 1.f;
|
self->scale = 1.f;
|
||||||
self->angle = 0.f;
|
|
||||||
self->filter = GSK_SCALING_FILTER_LINEAR;
|
|
||||||
gtk_widget_init_template (GTK_WIDGET (self));
|
gtk_widget_init_template (GTK_WIDGET (self));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +36,7 @@ demo3_widget_dispose (GObject *object)
|
|||||||
{
|
{
|
||||||
Demo3Widget *self = DEMO3_WIDGET (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);
|
gtk_widget_dispose_template (GTK_WIDGET (self), DEMO3_TYPE_WIDGET);
|
||||||
|
|
||||||
@@ -131,35 +49,21 @@ demo3_widget_snapshot (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
Demo3Widget *self = DEMO3_WIDGET (widget);
|
Demo3Widget *self = DEMO3_WIDGET (widget);
|
||||||
int x, y, width, height;
|
int x, y, width, height;
|
||||||
double w, h, w2, h2;
|
double w, h;
|
||||||
|
|
||||||
width = gtk_widget_get_width (widget);
|
width = gtk_widget_get_width (widget);
|
||||||
height = gtk_widget_get_height (widget);
|
height = gtk_widget_get_height (widget);
|
||||||
|
|
||||||
w2 = w = self->scale * gdk_texture_get_width (self->texture);
|
w = self->scale * gdk_paintable_get_intrinsic_width (self->paintable);
|
||||||
h2 = h = self->scale * gdk_texture_get_height (self->texture);
|
h = self->scale * gdk_paintable_get_intrinsic_height (self->paintable);
|
||||||
|
|
||||||
if (G_APPROX_VALUE (self->angle, 90.f, FLT_EPSILON) ||
|
x = MAX (0, (width - ceil (w)) / 2);
|
||||||
G_APPROX_VALUE (self->angle, 270.f, FLT_EPSILON))
|
y = MAX (0, (height - ceil (h)) / 2);
|
||||||
{
|
|
||||||
double s = w2;
|
|
||||||
w2 = h2;
|
|
||||||
h2 = s;
|
|
||||||
}
|
|
||||||
|
|
||||||
x = (width - ceil (w2)) / 2;
|
|
||||||
y = (height - ceil (h2)) / 2;
|
|
||||||
|
|
||||||
gtk_snapshot_push_clip (snapshot, &GRAPHENE_RECT_INIT (0, 0, width, height));
|
gtk_snapshot_push_clip (snapshot, &GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||||
gtk_snapshot_save (snapshot);
|
gtk_snapshot_save (snapshot);
|
||||||
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (x, y));
|
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (x, y));
|
||||||
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (w2 / 2, h2 / 2));
|
gdk_paintable_snapshot (self->paintable, snapshot, w, h);
|
||||||
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));
|
|
||||||
gtk_snapshot_restore (snapshot);
|
gtk_snapshot_restore (snapshot);
|
||||||
gtk_snapshot_pop (snapshot);
|
gtk_snapshot_pop (snapshot);
|
||||||
}
|
}
|
||||||
@@ -174,26 +78,14 @@ demo3_widget_measure (GtkWidget *widget,
|
|||||||
int *natural_baseline)
|
int *natural_baseline)
|
||||||
{
|
{
|
||||||
Demo3Widget *self = DEMO3_WIDGET (widget);
|
Demo3Widget *self = DEMO3_WIDGET (widget);
|
||||||
int width, height;
|
|
||||||
int size;
|
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)
|
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||||
size = width;
|
size = gdk_paintable_get_intrinsic_width (self->paintable);
|
||||||
else
|
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
|
static void
|
||||||
@@ -211,8 +103,6 @@ demo3_widget_size_allocate (GtkWidget *widget,
|
|||||||
gtk_popover_present (GTK_POPOVER (self->menu));
|
gtk_popover_present (GTK_POPOVER (self->menu));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_actions (Demo3Widget *self);
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
demo3_widget_set_property (GObject *object,
|
demo3_widget_set_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
@@ -223,32 +113,14 @@ demo3_widget_set_property (GObject *object,
|
|||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_TEXTURE:
|
case PROP_PAINTABLE:
|
||||||
g_clear_object (&self->texture);
|
g_clear_object (&self->paintable);
|
||||||
self->texture = g_value_dup_object (value);
|
self->paintable = g_value_dup_object (value);
|
||||||
self->scale = 1.f;
|
|
||||||
self->angle = 0.f;
|
|
||||||
self->filter = GSK_SCALING_FILTER_LINEAR;
|
|
||||||
update_actions (self);
|
|
||||||
gtk_widget_queue_resize (GTK_WIDGET (object));
|
gtk_widget_queue_resize (GTK_WIDGET (object));
|
||||||
g_object_notify (object, "scale");
|
|
||||||
g_object_notify (object, "angle");
|
|
||||||
g_object_notify (object, "filter");
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_SCALE:
|
case PROP_SCALE:
|
||||||
self->scale = g_value_get_float (value);
|
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));
|
gtk_widget_queue_resize (GTK_WIDGET (object));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -268,22 +140,14 @@ demo3_widget_get_property (GObject *object,
|
|||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_TEXTURE:
|
case PROP_PAINTABLE:
|
||||||
g_value_set_object (value, self->texture);
|
g_value_set_object (value, self->paintable);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_SCALE:
|
case PROP_SCALE:
|
||||||
g_value_set_float (value, self->scale);
|
g_value_set_float (value, self->scale);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_ANGLE:
|
|
||||||
g_value_set_float (value, self->angle);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PROP_FILTER:
|
|
||||||
g_value_set_enum (value, self->filter);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@@ -305,14 +169,6 @@ pressed_cb (GtkGestureClick *gesture,
|
|||||||
gtk_popover_popup (GTK_POPOVER (self->menu));
|
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
|
static void
|
||||||
zoom_cb (GtkWidget *widget,
|
zoom_cb (GtkWidget *widget,
|
||||||
const char *action_name,
|
const char *action_name,
|
||||||
@@ -322,30 +178,19 @@ zoom_cb (GtkWidget *widget,
|
|||||||
float scale;
|
float scale;
|
||||||
|
|
||||||
if (g_str_equal (action_name, "zoom.in"))
|
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"))
|
else if (g_str_equal (action_name, "zoom.out"))
|
||||||
scale = MAX (1./1024., self->scale / M_SQRT2);
|
scale = MAX (0.01, self->scale / M_SQRT2);
|
||||||
else if (g_str_equal (action_name, "zoom.reset"))
|
|
||||||
scale = 1.0;
|
|
||||||
else
|
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);
|
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
|
static void
|
||||||
demo3_widget_class_init (Demo3WidgetClass *class)
|
demo3_widget_class_init (Demo3WidgetClass *class)
|
||||||
{
|
{
|
||||||
@@ -360,55 +205,40 @@ demo3_widget_class_init (Demo3WidgetClass *class)
|
|||||||
widget_class->measure = demo3_widget_measure;
|
widget_class->measure = demo3_widget_measure;
|
||||||
widget_class->size_allocate = demo3_widget_size_allocate;
|
widget_class->size_allocate = demo3_widget_size_allocate;
|
||||||
|
|
||||||
g_object_class_install_property (object_class, PROP_TEXTURE,
|
g_object_class_install_property (object_class, PROP_PAINTABLE,
|
||||||
g_param_spec_object ("texture", NULL, NULL,
|
g_param_spec_object ("paintable", "Paintable", "Paintable",
|
||||||
GDK_TYPE_TEXTURE,
|
GDK_TYPE_PAINTABLE,
|
||||||
G_PARAM_READWRITE));
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
g_object_class_install_property (object_class, PROP_SCALE,
|
g_object_class_install_property (object_class, PROP_SCALE,
|
||||||
g_param_spec_float ("scale", NULL, NULL,
|
g_param_spec_float ("scale", "Scale", "Scale",
|
||||||
1./1024., 1024., 1.0,
|
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));
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
/* These are the actions that we are using in the menu */
|
/* 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.in", NULL, zoom_cb);
|
||||||
gtk_widget_class_install_action (widget_class, "zoom.out", 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, "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_set_template_from_resource (widget_class, "/menu/demo3widget.ui");
|
||||||
gtk_widget_class_bind_template_child (widget_class, Demo3Widget, menu);
|
gtk_widget_class_bind_template_child (widget_class, Demo3Widget, menu);
|
||||||
gtk_widget_class_bind_template_callback (widget_class, pressed_cb);
|
gtk_widget_class_bind_template_callback (widget_class, pressed_cb);
|
||||||
|
|
||||||
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_IMG);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
demo3_widget_new (const char *resource)
|
demo3_widget_new (const char *resource)
|
||||||
{
|
{
|
||||||
Demo3Widget *self;
|
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,
|
self = g_object_new (DEMO3_TYPE_WIDGET, "paintable", paintable, NULL);
|
||||||
"texture", texture,
|
|
||||||
"has-tooltip", TRUE,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
g_signal_connect (self, "query-tooltip", G_CALLBACK (query_tooltip), NULL);
|
g_object_unref (pixbuf);
|
||||||
|
g_object_unref (paintable);
|
||||||
g_object_unref (texture);
|
|
||||||
|
|
||||||
return GTK_WIDGET (self);
|
return GTK_WIDGET (self);
|
||||||
}
|
}
|
||||||
|
@@ -12,21 +12,10 @@
|
|||||||
<attribute name="label">1∶1</attribute>
|
<attribute name="label">1∶1</attribute>
|
||||||
<attribute name="action">zoom.reset</attribute>
|
<attribute name="action">zoom.reset</attribute>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<attribute name="label">Rotate</attribute>
|
|
||||||
<attribute name="action">rotate</attribute>
|
|
||||||
<attribute name="target" type="i">90</attribute>
|
|
||||||
</item>
|
|
||||||
</menu>
|
</menu>
|
||||||
<template class="Demo3Widget">
|
<template class="Demo3Widget">
|
||||||
<accessibility>
|
|
||||||
<property name="label">Demo image</property>
|
|
||||||
</accessibility>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkPopoverMenu" id="menu">
|
<object class="GtkPopoverMenu" id="menu">
|
||||||
<accessibility>
|
|
||||||
<property name="label">Context menu</property>
|
|
||||||
</accessibility>
|
|
||||||
<property name="has-arrow">0</property>
|
<property name="has-arrow">0</property>
|
||||||
<property name="menu-model">model</property>
|
<property name="menu-model">model</property>
|
||||||
</object>
|
</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);
|
|
@@ -18,7 +18,8 @@
|
|||||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#ifndef __DEMO_TAGGED_ENTRY_H__
|
||||||
|
#define __DEMO_TAGGED_ENTRY_H__
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
@@ -56,3 +57,5 @@ void demo_tagged_entry_tag_set_has_close_button (DemoTaggedEntryTag *
|
|||||||
gboolean has_close_button);
|
gboolean has_close_button);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __DEMO_TAGGED_ENTRY_H__ */
|
||||||
|
@@ -34,7 +34,7 @@ transition (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
DemoWidget *self = DEMO_WIDGET (widget);
|
DemoWidget *self = DEMO_WIDGET (widget);
|
||||||
DemoLayout *demo_layout = DEMO_LAYOUT (gtk_widget_get_layout_manager (widget));
|
DemoLayout *demo_layout = DEMO_LAYOUT (gtk_widget_get_layout_manager (widget));
|
||||||
gint64 now = gdk_frame_clock_get_frame_time (frame_clock);
|
gint64 now = g_get_monotonic_time ();
|
||||||
|
|
||||||
gtk_widget_queue_allocate (widget);
|
gtk_widget_queue_allocate (widget);
|
||||||
|
|
||||||
@@ -66,13 +66,11 @@ clicked (GtkGestureClick *gesture,
|
|||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
DemoWidget *self = data;
|
DemoWidget *self = data;
|
||||||
GdkFrameClock *frame_clock;
|
|
||||||
|
|
||||||
if (self->tick_id != 0)
|
if (self->tick_id != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
frame_clock = gtk_widget_get_frame_clock (GTK_WIDGET (self));
|
self->start_time = g_get_monotonic_time ();
|
||||||
self->start_time = gdk_frame_clock_get_frame_time (frame_clock);
|
|
||||||
self->tick_id = gtk_widget_add_tick_callback (GTK_WIDGET (self), transition, NULL, NULL);
|
self->tick_id = gtk_widget_add_tick_callback (GTK_WIDGET (self), transition, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -8,8 +8,6 @@
|
|||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
||||||
|
|
||||||
static GtkWidget *window = NULL;
|
static GtkWidget *window = NULL;
|
||||||
static GtkWidget *entry1 = NULL;
|
static GtkWidget *entry1 = NULL;
|
||||||
static GtkWidget *entry2 = NULL;
|
static GtkWidget *entry2 = NULL;
|
||||||
@@ -29,7 +27,7 @@ message_dialog_clicked (GtkButton *button,
|
|||||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
||||||
ngettext ("Has been shown once", "Has been shown %d times", i), i);
|
ngettext ("Has been shown once", "Has been shown %d times", i), i);
|
||||||
g_signal_connect (dialog, "response", G_CALLBACK (gtk_window_destroy), NULL);
|
g_signal_connect (dialog, "response", G_CALLBACK (gtk_window_destroy), NULL);
|
||||||
gtk_window_present (GTK_WINDOW (dialog));
|
gtk_widget_show (dialog);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,7 +114,7 @@ interactive_dialog_clicked (GtkButton *button,
|
|||||||
data, (GClosureNotify) g_free,
|
data, (GClosureNotify) g_free,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
gtk_window_present (GTK_WINDOW (dialog));
|
gtk_widget_show (dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
@@ -186,7 +184,7 @@ do_dialog (GtkWidget *do_widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
gtk_widget_set_visible (window, TRUE);
|
gtk_widget_show (window);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (window));
|
gtk_window_destroy (GTK_WINDOW (window));
|
||||||
|
|
||||||
|
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
|
||||||
G_DECLARE_FINAL_TYPE (CanvasItem, canvas_item, CANVAS, ITEM, GtkWidget)
|
G_DECLARE_FINAL_TYPE (CanvasItem, canvas_item, CANVAS, ITEM, GtkWidget)
|
||||||
|
|
||||||
struct _CanvasItem {
|
struct _CanvasItem {
|
||||||
@@ -25,9 +24,6 @@ struct _CanvasItem {
|
|||||||
double delta;
|
double delta;
|
||||||
|
|
||||||
GtkWidget *editor;
|
GtkWidget *editor;
|
||||||
|
|
||||||
GtkStyleProvider *provider;
|
|
||||||
char *css_class;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _CanvasItemClass {
|
struct _CanvasItemClass {
|
||||||
@@ -38,41 +34,32 @@ G_DEFINE_TYPE (CanvasItem, canvas_item, GTK_TYPE_WIDGET)
|
|||||||
|
|
||||||
static int n_items = 0;
|
static int n_items = 0;
|
||||||
|
|
||||||
static void
|
|
||||||
unstyle_item (CanvasItem *item)
|
|
||||||
{
|
|
||||||
if (item->provider)
|
|
||||||
{
|
|
||||||
gtk_style_context_remove_provider_for_display (gtk_widget_get_display (item->label), item->provider);
|
|
||||||
g_clear_object (&item->provider);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item->css_class)
|
|
||||||
{
|
|
||||||
gtk_widget_remove_css_class (item->label, item->css_class);
|
|
||||||
g_clear_pointer (&item->css_class, g_free);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_color (CanvasItem *item,
|
set_color (CanvasItem *item,
|
||||||
GdkRGBA *color)
|
GdkRGBA *color)
|
||||||
{
|
{
|
||||||
char *css;
|
char *css;
|
||||||
char *str;
|
char *str;
|
||||||
|
GtkStyleContext *context;
|
||||||
GtkCssProvider *provider;
|
GtkCssProvider *provider;
|
||||||
const char *name;
|
const char *old_class;
|
||||||
|
|
||||||
unstyle_item (item);
|
|
||||||
|
|
||||||
str = gdk_rgba_to_string (color);
|
str = gdk_rgba_to_string (color);
|
||||||
name = gtk_widget_get_name (item->label);
|
css = g_strdup_printf ("* { background: %s; }", str);
|
||||||
css = g_strdup_printf ("#%s { background: %s; }", name, str);
|
|
||||||
|
context = gtk_widget_get_style_context (item->label);
|
||||||
|
provider = g_object_get_data (G_OBJECT (context), "style-provider");
|
||||||
|
if (provider)
|
||||||
|
gtk_style_context_remove_provider (context, GTK_STYLE_PROVIDER (provider));
|
||||||
|
|
||||||
|
old_class = (const char *)g_object_get_data (G_OBJECT (item->label), "css-class");
|
||||||
|
if (old_class)
|
||||||
|
gtk_widget_remove_css_class (item->label, old_class);
|
||||||
|
|
||||||
provider = gtk_css_provider_new ();
|
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);
|
gtk_style_context_add_provider (gtk_widget_get_style_context (item->label), GTK_STYLE_PROVIDER (provider), 800);
|
||||||
item->provider = GTK_STYLE_PROVIDER (provider);
|
g_object_set_data_full (G_OBJECT (context), "style-provider", provider, g_object_unref);
|
||||||
|
|
||||||
g_free (str);
|
g_free (str);
|
||||||
g_free (css);
|
g_free (css);
|
||||||
@@ -82,10 +69,21 @@ static void
|
|||||||
set_css (CanvasItem *item,
|
set_css (CanvasItem *item,
|
||||||
const char *class)
|
const char *class)
|
||||||
{
|
{
|
||||||
unstyle_item (item);
|
GtkStyleContext *context;
|
||||||
|
GtkCssProvider *provider;
|
||||||
|
const char *old_class;
|
||||||
|
|
||||||
|
context = gtk_widget_get_style_context (item->label);
|
||||||
|
provider = g_object_get_data (G_OBJECT (context), "style-provider");
|
||||||
|
if (provider)
|
||||||
|
gtk_style_context_remove_provider (context, GTK_STYLE_PROVIDER (provider));
|
||||||
|
|
||||||
|
old_class = (const char *)g_object_get_data (G_OBJECT (item->label), "css-class");
|
||||||
|
if (old_class)
|
||||||
|
gtk_widget_remove_css_class (item->label, old_class);
|
||||||
|
|
||||||
|
g_object_set_data_full (G_OBJECT (item->label), "css-class", g_strdup (class), g_free);
|
||||||
gtk_widget_add_css_class (item->label, class);
|
gtk_widget_add_css_class (item->label, class);
|
||||||
item->css_class = g_strdup (class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@@ -109,21 +107,15 @@ static void
|
|||||||
apply_transform (CanvasItem *item)
|
apply_transform (CanvasItem *item)
|
||||||
{
|
{
|
||||||
GskTransform *transform;
|
GskTransform *transform;
|
||||||
graphene_rect_t bounds;
|
|
||||||
double x, y;
|
double x, y;
|
||||||
|
|
||||||
/* Add css padding and margin */
|
x = gtk_widget_get_allocated_width (item->label) / 2.0;
|
||||||
if (!gtk_widget_compute_bounds (item->label, item->label, &bounds))
|
y = gtk_widget_get_allocated_height (item->label) / 2.0;
|
||||||
return;
|
|
||||||
|
|
||||||
x = bounds.size.width / 2.;
|
|
||||||
y = bounds.size.height / 2.;
|
|
||||||
|
|
||||||
item->r = sqrt (x*x + y*y);
|
item->r = sqrt (x*x + y*y);
|
||||||
|
|
||||||
transform = gsk_transform_translate (NULL, &(graphene_point_t) { item->r, item->r });
|
transform = gsk_transform_translate (NULL, &(graphene_point_t) { item->r, item->r });
|
||||||
transform = gsk_transform_rotate (transform, item->angle + item->delta);
|
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);
|
gtk_fixed_set_child_transform (GTK_FIXED (item->fixed), item->label, transform);
|
||||||
gsk_transform_unref (transform);
|
gsk_transform_unref (transform);
|
||||||
@@ -162,39 +154,27 @@ click_done (GtkGesture *gesture)
|
|||||||
gtk_widget_insert_after (item, canvas, last_child);
|
gtk_widget_insert_after (item, canvas, last_child);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* GtkSettings treats `GTK_THEME=foo:dark` as theme name `foo`, variant `dark`,
|
|
||||||
* and our embedded CSS files let `foo-dark` work as an alias for `foo:dark`. */
|
|
||||||
static gboolean
|
|
||||||
has_dark_suffix (const char *theme)
|
|
||||||
{
|
|
||||||
return g_str_has_suffix (theme, ":dark") ||
|
|
||||||
g_str_has_suffix (theme, "-dark");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* So we can make a good guess whether the current theme is dark by checking for
|
|
||||||
* either: it is suffixed `[:-]dark`, or Settings:…prefer-dark-theme is TRUE. */
|
|
||||||
static gboolean
|
static gboolean
|
||||||
theme_is_dark (void)
|
theme_is_dark (void)
|
||||||
{
|
{
|
||||||
const char *env_theme;
|
|
||||||
GtkSettings *settings;
|
GtkSettings *settings;
|
||||||
char *theme;
|
char *theme;
|
||||||
gboolean prefer_dark;
|
gboolean prefer_dark;
|
||||||
gboolean dark;
|
gboolean dark;
|
||||||
|
|
||||||
/* Like GtkSettings, 1st see if theme is overridden by environment variable */
|
|
||||||
env_theme = g_getenv ("GTK_THEME");
|
|
||||||
if (env_theme != NULL)
|
|
||||||
return has_dark_suffix (env_theme);
|
|
||||||
|
|
||||||
/* If not, test Settings:…theme-name in the same way OR :…prefer-dark-theme */
|
|
||||||
settings = gtk_settings_get_default ();
|
settings = gtk_settings_get_default ();
|
||||||
g_object_get (settings,
|
g_object_get (settings,
|
||||||
"gtk-theme-name", &theme,
|
"gtk-theme-name", &theme,
|
||||||
"gtk-application-prefer-dark-theme", &prefer_dark,
|
"gtk-application-prefer-dark-theme", &prefer_dark,
|
||||||
NULL);
|
NULL);
|
||||||
dark = prefer_dark || has_dark_suffix (theme);
|
|
||||||
|
if ((strcmp (theme, "Adwaita") == 0 && prefer_dark) || strcmp (theme, "HighContrastInverse") == 0)
|
||||||
|
dark = TRUE;
|
||||||
|
else
|
||||||
|
dark = FALSE;
|
||||||
|
|
||||||
g_free (theme);
|
g_free (theme);
|
||||||
|
|
||||||
return dark;
|
return dark;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,7 +322,7 @@ canvas_item_start_editing (CanvasItem *item)
|
|||||||
GtkWidget *canvas = gtk_widget_get_parent (GTK_WIDGET (item));
|
GtkWidget *canvas = gtk_widget_get_parent (GTK_WIDGET (item));
|
||||||
GtkWidget *entry;
|
GtkWidget *entry;
|
||||||
GtkWidget *scale;
|
GtkWidget *scale;
|
||||||
graphene_point_t p;
|
double x, y;
|
||||||
|
|
||||||
if (item->editor)
|
if (item->editor)
|
||||||
return;
|
return;
|
||||||
@@ -368,17 +348,12 @@ canvas_item_start_editing (CanvasItem *item)
|
|||||||
|
|
||||||
gtk_box_append (GTK_BOX (item->editor), scale);
|
gtk_box_append (GTK_BOX (item->editor), scale);
|
||||||
|
|
||||||
if (!gtk_widget_compute_point (GTK_WIDGET (item), canvas, &GRAPHENE_POINT_INIT (0, 0), &p))
|
gtk_widget_translate_coordinates (GTK_WIDGET (item), canvas, 0, 0, &x, &y);
|
||||||
graphene_point_init (&p, 0, 0);
|
gtk_fixed_put (GTK_FIXED (canvas), item->editor, x, y + 2 * item->r);
|
||||||
gtk_fixed_put (GTK_FIXED (canvas), item->editor, p.x, p.y + 2 * item->r);
|
|
||||||
gtk_widget_grab_focus (entry);
|
gtk_widget_grab_focus (entry);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
double x, y;
|
|
||||||
} Hotspot;
|
|
||||||
|
|
||||||
static GdkContentProvider *
|
static GdkContentProvider *
|
||||||
prepare (GtkDragSource *source,
|
prepare (GtkDragSource *source,
|
||||||
double x,
|
double x,
|
||||||
@@ -386,8 +361,6 @@ prepare (GtkDragSource *source,
|
|||||||
{
|
{
|
||||||
GtkWidget *canvas;
|
GtkWidget *canvas;
|
||||||
GtkWidget *item;
|
GtkWidget *item;
|
||||||
Hotspot *hotspot;
|
|
||||||
graphene_point_t p;
|
|
||||||
|
|
||||||
canvas = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (source));
|
canvas = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (source));
|
||||||
item = gtk_widget_pick (canvas, x, y, GTK_PICK_DEFAULT);
|
item = gtk_widget_pick (canvas, x, y, GTK_PICK_DEFAULT);
|
||||||
@@ -398,13 +371,6 @@ prepare (GtkDragSource *source,
|
|||||||
|
|
||||||
g_object_set_data (G_OBJECT (canvas), "dragged-item", item);
|
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);
|
return gdk_content_provider_new_typed (GTK_TYPE_WIDGET, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -415,14 +381,12 @@ drag_begin (GtkDragSource *source,
|
|||||||
GtkWidget *canvas;
|
GtkWidget *canvas;
|
||||||
CanvasItem *item;
|
CanvasItem *item;
|
||||||
GdkPaintable *paintable;
|
GdkPaintable *paintable;
|
||||||
Hotspot *hotspot;
|
|
||||||
|
|
||||||
canvas = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (source));
|
canvas = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (source));
|
||||||
item = CANVAS_ITEM (g_object_get_data (G_OBJECT (canvas), "dragged-item"));
|
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);
|
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);
|
g_object_unref (paintable);
|
||||||
|
|
||||||
gtk_widget_set_opacity (GTK_WIDGET (item), 0.3);
|
gtk_widget_set_opacity (GTK_WIDGET (item), 0.3);
|
||||||
@@ -758,9 +722,8 @@ do_dnd (GtkWidget *do_widget)
|
|||||||
int i;
|
int i;
|
||||||
int x, y;
|
int x, y;
|
||||||
GtkCssProvider *provider;
|
GtkCssProvider *provider;
|
||||||
GString *css;
|
|
||||||
|
|
||||||
button = gtk_color_dialog_button_new (gtk_color_dialog_new ());
|
button = gtk_color_button_new ();
|
||||||
g_object_unref (g_object_ref_sink (button));
|
g_object_unref (g_object_ref_sink (button));
|
||||||
|
|
||||||
provider = gtk_css_provider_new ();
|
provider = gtk_css_provider_new ();
|
||||||
@@ -770,18 +733,6 @@ do_dnd (GtkWidget *do_widget)
|
|||||||
800);
|
800);
|
||||||
g_object_unref (provider);
|
g_object_unref (provider);
|
||||||
|
|
||||||
css = g_string_new ("");
|
|
||||||
for (i = 0; colors[i]; i++)
|
|
||||||
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_style_context_add_provider_for_display (gdk_display_get_default (),
|
|
||||||
GTK_STYLE_PROVIDER (provider),
|
|
||||||
800);
|
|
||||||
g_object_unref (provider);
|
|
||||||
g_string_free (css, TRUE);
|
|
||||||
|
|
||||||
window = gtk_window_new ();
|
window = gtk_window_new ();
|
||||||
gtk_window_set_display (GTK_WINDOW (window),
|
gtk_window_set_display (GTK_WINDOW (window),
|
||||||
gtk_widget_get_display (do_widget));
|
gtk_widget_get_display (do_widget));
|
||||||
@@ -834,7 +785,7 @@ do_dnd (GtkWidget *do_widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
gtk_widget_set_visible (window, TRUE);
|
gtk_widget_show (window);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (window));
|
gtk_window_destroy (GTK_WINDOW (window));
|
||||||
|
|
||||||
|
@@ -334,17 +334,11 @@ do_drawingarea (GtkWidget *do_widget)
|
|||||||
gtk_widget_set_vexpand (frame, TRUE);
|
gtk_widget_set_vexpand (frame, TRUE);
|
||||||
gtk_box_append (GTK_BOX (vbox), frame);
|
gtk_box_append (GTK_BOX (vbox), frame);
|
||||||
|
|
||||||
da = g_object_new (GTK_TYPE_DRAWING_AREA,
|
da = gtk_drawing_area_new ();
|
||||||
"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);
|
|
||||||
|
|
||||||
gtk_drawing_area_set_content_width (GTK_DRAWING_AREA (da), 100);
|
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_content_height (GTK_DRAWING_AREA (da), 100);
|
||||||
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (da), groups_draw, NULL, NULL);
|
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
|
* Create the scribble area
|
||||||
@@ -358,17 +352,11 @@ do_drawingarea (GtkWidget *do_widget)
|
|||||||
gtk_widget_set_vexpand (frame, TRUE);
|
gtk_widget_set_vexpand (frame, TRUE);
|
||||||
gtk_box_append (GTK_BOX (vbox), frame);
|
gtk_box_append (GTK_BOX (vbox), frame);
|
||||||
|
|
||||||
da = g_object_new (GTK_TYPE_DRAWING_AREA,
|
da = gtk_drawing_area_new ();
|
||||||
"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);
|
|
||||||
|
|
||||||
gtk_drawing_area_set_content_width (GTK_DRAWING_AREA (da), 100);
|
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_content_height (GTK_DRAWING_AREA (da), 100);
|
||||||
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (da), scribble_draw, NULL, NULL);
|
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_signal_connect (da, "resize",
|
||||||
G_CALLBACK (scribble_resize), NULL);
|
G_CALLBACK (scribble_resize), NULL);
|
||||||
@@ -384,7 +372,7 @@ do_drawingarea (GtkWidget *do_widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
gtk_window_present (GTK_WINDOW (window));
|
gtk_widget_show (window);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (window));
|
gtk_window_destroy (GTK_WINDOW (window));
|
||||||
|
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
/* Lists/Selections
|
/* Lists/Selections
|
||||||
* #Keywords: suggestion, completion
|
|
||||||
*
|
*
|
||||||
* The GtkDropDown widget is a modern alternative to GtkComboBox.
|
* The GtkDropDown widget is a modern alternative to GtkComboBox.
|
||||||
* It uses list models instead of tree models, and the content is
|
* It uses list models instead of tree models, and the content is
|
||||||
@@ -165,14 +164,14 @@ strings_bind_item (GtkSignalListItemFactory *factory,
|
|||||||
popup = gtk_widget_get_ancestor (title, GTK_TYPE_POPOVER);
|
popup = gtk_widget_get_ancestor (title, GTK_TYPE_POPOVER);
|
||||||
if (popup && gtk_widget_is_ancestor (popup, GTK_WIDGET (dropdown)))
|
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_signal_connect (dropdown, "notify::selected-item",
|
||||||
G_CALLBACK (selected_item_changed), item);
|
G_CALLBACK (selected_item_changed), item);
|
||||||
selected_item_changed (dropdown, NULL, item);
|
selected_item_changed (dropdown, NULL, item);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gtk_widget_set_visible (checkmark, FALSE);
|
gtk_widget_hide (checkmark);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,40 +368,8 @@ match_func (MatchObject *obj,
|
|||||||
g_free (tmp2);
|
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 *
|
GtkWidget *
|
||||||
do_listview_selections (GtkWidget *do_widget)
|
do_dropdown (GtkWidget *do_widget)
|
||||||
{
|
{
|
||||||
static GtkWidget *window = NULL;
|
static GtkWidget *window = NULL;
|
||||||
GtkWidget *button, *box, *spin, *check, *hbox, *label, *entry;
|
GtkWidget *button, *box, *spin, *check, *hbox, *label, *entry;
|
||||||
@@ -410,12 +377,10 @@ do_listview_selections (GtkWidget *do_widget)
|
|||||||
GtkExpression *expression;
|
GtkExpression *expression;
|
||||||
GtkListItemFactory *factory;
|
GtkListItemFactory *factory;
|
||||||
const char * const times[] = { "1 minute", "2 minutes", "5 minutes", "20 minutes", NULL };
|
const char * const times[] = { "1 minute", "2 minutes", "5 minutes", "20 minutes", NULL };
|
||||||
const char * const minutes[] = {
|
const char * const many_times[] = {
|
||||||
"1 minute", "2 minutes", "5 minutes", "10 minutes", "15 minutes", "20 minutes",
|
"1 minute", "2 minutes", "5 minutes", "10 minutes", "15 minutes", "20 minutes",
|
||||||
"25 minutes", "30 minutes", "35 minutes", "40 minutes", "45 minutes", "50 minutes",
|
"25 minutes", "30 minutes", "35 minutes", "40 minutes", "45 minutes", "50 minutes",
|
||||||
"55 minutes", NULL
|
"55 minutes", "1 hour", "2 hours", "3 hours", "5 hours", "6 hours", "7 hours",
|
||||||
};
|
|
||||||
const char * const hours[] = { "1 hour", "2 hours", "3 hours", "5 hours", "6 hours", "7 hours",
|
|
||||||
"8 hours", "9 hours", "10 hours", "11 hours", "12 hours", NULL
|
"8 hours", "9 hours", "10 hours", "11 hours", "12 hours", NULL
|
||||||
};
|
};
|
||||||
const char * const device_titles[] = { "Digital Output", "Headphones", "Digital Output", "Analog Output", NULL };
|
const char * const device_titles[] = { "Digital Output", "Headphones", "Digital Output", "Analog Output", NULL };
|
||||||
@@ -430,10 +395,6 @@ do_listview_selections (GtkWidget *do_widget)
|
|||||||
|
|
||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
GtkStringList *minutes_model, *hours_model;
|
|
||||||
GListStore *store;
|
|
||||||
GtkFlattenListModel *flat;
|
|
||||||
|
|
||||||
window = gtk_window_new ();
|
window = gtk_window_new ();
|
||||||
gtk_window_set_display (GTK_WINDOW (window),
|
gtk_window_set_display (GTK_WINDOW (window),
|
||||||
gtk_widget_get_display (do_widget));
|
gtk_widget_get_display (do_widget));
|
||||||
@@ -461,25 +422,14 @@ do_listview_selections (GtkWidget *do_widget)
|
|||||||
gtk_box_append (GTK_BOX (box), button);
|
gtk_box_append (GTK_BOX (box), button);
|
||||||
|
|
||||||
/* A dropdown using an expression to obtain strings */
|
/* A dropdown using an expression to obtain strings */
|
||||||
minutes_model = gtk_string_list_new (minutes);
|
button = drop_down_new_from_strings (many_times, NULL, NULL);
|
||||||
hours_model = gtk_string_list_new (hours);
|
gtk_drop_down_set_enable_search (GTK_DROP_DOWN (button), TRUE);
|
||||||
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));
|
|
||||||
expression = gtk_cclosure_expression_new (G_TYPE_STRING, NULL,
|
expression = gtk_cclosure_expression_new (G_TYPE_STRING, NULL,
|
||||||
0, NULL,
|
0, NULL,
|
||||||
(GCallback)get_title,
|
(GCallback)get_title,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
button = gtk_drop_down_new (G_LIST_MODEL (flat), expression);
|
gtk_drop_down_set_expression (GTK_DROP_DOWN (button), expression);
|
||||||
gtk_drop_down_set_enable_search (GTK_DROP_DOWN (button), TRUE);
|
gtk_expression_unref (expression);
|
||||||
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_box_append (GTK_BOX (box), button);
|
gtk_box_append (GTK_BOX (box), button);
|
||||||
|
|
||||||
button = gtk_drop_down_new (NULL, NULL);
|
button = gtk_drop_down_new (NULL, NULL);
|
||||||
@@ -613,7 +563,7 @@ do_listview_selections (GtkWidget *do_widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
gtk_widget_set_visible (window, TRUE);
|
gtk_widget_show (window);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (window));
|
gtk_window_destroy (GTK_WINDOW (window));
|
||||||
|
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
@@ -14,8 +14,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int number;
|
int number;
|
||||||
@@ -409,7 +407,7 @@ do_editable_cells (GtkWidget *do_widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
gtk_widget_set_visible (window, TRUE);
|
gtk_widget_show (window);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (window));
|
gtk_window_destroy (GTK_WINDOW (window));
|
||||||
|
|
||||||
|
@@ -8,8 +8,6 @@
|
|||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
||||||
|
|
||||||
/* Creates a tree model containing the completions */
|
/* Creates a tree model containing the completions */
|
||||||
static GtkTreeModel *
|
static GtkTreeModel *
|
||||||
create_completion_model (void)
|
create_completion_model (void)
|
||||||
@@ -95,13 +93,6 @@ do_entry_completion (GtkWidget *do_widget)
|
|||||||
entry = gtk_entry_new ();
|
entry = gtk_entry_new ();
|
||||||
gtk_box_append (GTK_BOX (vbox), entry);
|
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 */
|
/* Create the completion object */
|
||||||
completion = gtk_entry_completion_new ();
|
completion = gtk_entry_completion_new ();
|
||||||
|
|
||||||
@@ -122,7 +113,7 @@ do_entry_completion (GtkWidget *do_widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
gtk_widget_set_visible (window, TRUE);
|
gtk_widget_show (window);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (window));
|
gtk_window_destroy (GTK_WINDOW (window));
|
||||||
|
|
||||||
|
@@ -43,14 +43,10 @@ do_entry_undo (GtkWidget *do_widget)
|
|||||||
entry = gtk_entry_new ();
|
entry = gtk_entry_new ();
|
||||||
gtk_editable_set_enable_undo (GTK_EDITABLE (entry), TRUE);
|
gtk_editable_set_enable_undo (GTK_EDITABLE (entry), TRUE);
|
||||||
gtk_box_append (GTK_BOX (vbox), entry);
|
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))
|
if (!gtk_widget_get_visible (window))
|
||||||
gtk_widget_set_visible (window, TRUE);
|
gtk_widget_show (window);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (window));
|
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_set_tooltip_text (GTK_WIDGET (entry), "Must have details first");
|
||||||
gtk_widget_add_css_class (GTK_WIDGET (entry), "error");
|
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
|
else
|
||||||
{
|
{
|
||||||
gtk_widget_set_tooltip_text (GTK_WIDGET (entry), "");
|
gtk_widget_set_tooltip_text (GTK_WIDGET (entry), "");
|
||||||
gtk_widget_remove_css_class (GTK_WIDGET (entry), "error");
|
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 ||
|
if (!state ||
|
||||||
(gtk_range_get_value (GTK_RANGE (scale)) > 50))
|
(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_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
|
else
|
||||||
{
|
{
|
||||||
gtk_widget_set_visible (label, TRUE);
|
gtk_widget_show (label);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -77,7 +65,7 @@ level_scale_value_changed (GtkRange *range,
|
|||||||
!gtk_switch_get_state (GTK_SWITCH (sw)) &&
|
!gtk_switch_get_state (GTK_SWITCH (sw)) &&
|
||||||
(gtk_range_get_value (range) > 50))
|
(gtk_range_get_value (range) > 50))
|
||||||
{
|
{
|
||||||
gtk_widget_set_visible (label, FALSE);
|
gtk_widget_hide (label);
|
||||||
gtk_switch_set_state (GTK_SWITCH (sw), TRUE);
|
gtk_switch_set_state (GTK_SWITCH (sw), TRUE);
|
||||||
}
|
}
|
||||||
else if (gtk_switch_get_state (GTK_SWITCH (sw)) &&
|
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_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 *
|
GtkWidget *
|
||||||
@@ -128,7 +113,7 @@ do_errorstates (GtkWidget *do_widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
gtk_widget_set_visible (window, TRUE);
|
gtk_widget_show (window);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (window));
|
gtk_window_destroy (GTK_WINDOW (window));
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.4 KiB |
@@ -43,22 +43,21 @@ do_expander (GtkWidget *do_widget)
|
|||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
toplevel = GTK_WIDGET (gtk_widget_get_root (do_widget));
|
toplevel = GTK_WIDGET (gtk_widget_get_root (do_widget));
|
||||||
window = gtk_window_new ();
|
window = gtk_message_dialog_new_with_markup (GTK_WINDOW (toplevel),
|
||||||
gtk_window_set_title (GTK_WINDOW (window), "Expander");
|
0,
|
||||||
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (toplevel));
|
GTK_MESSAGE_ERROR,
|
||||||
area = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
|
GTK_BUTTONS_CLOSE,
|
||||||
gtk_widget_set_margin_start (area, 10);
|
"<big><b>%s</b></big>",
|
||||||
gtk_widget_set_margin_end (area, 10);
|
"Something went wrong");
|
||||||
gtk_widget_set_margin_top (area, 10);
|
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (window),
|
||||||
gtk_widget_set_margin_bottom (area, 10);
|
"Here are some more details "
|
||||||
gtk_window_set_child (GTK_WINDOW (window), area);
|
"but not the full story.");
|
||||||
label = gtk_label_new ("<big><b>Something went wrong</b></big>");
|
|
||||||
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
|
area = gtk_message_dialog_get_message_area (GTK_MESSAGE_DIALOG (window));
|
||||||
gtk_box_append (GTK_BOX (area), label);
|
|
||||||
label = gtk_label_new ("Here are some more details but not the full story");
|
label = gtk_widget_get_last_child (area);
|
||||||
gtk_label_set_wrap (GTK_LABEL (label), FALSE);
|
gtk_label_set_wrap (GTK_LABEL (label), FALSE);
|
||||||
gtk_widget_set_vexpand (label, FALSE);
|
gtk_widget_set_vexpand (label, FALSE);
|
||||||
gtk_box_append (GTK_BOX (area), label);
|
|
||||||
|
|
||||||
expander = gtk_expander_new ("Details:");
|
expander = gtk_expander_new ("Details:");
|
||||||
gtk_widget_set_vexpand (expander, TRUE);
|
gtk_widget_set_vexpand (expander, TRUE);
|
||||||
@@ -121,7 +120,7 @@ do_expander (GtkWidget *do_widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
gtk_window_present (GTK_WINDOW (window));
|
gtk_widget_show (window);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (window));
|
gtk_window_destroy (GTK_WINDOW (window));
|
||||||
|
|
||||||
|
@@ -9,8 +9,6 @@
|
|||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
WIDTH_COLUMN,
|
WIDTH_COLUMN,
|
||||||
HEIGHT_COLUMN,
|
HEIGHT_COLUMN,
|
||||||
@@ -199,7 +197,7 @@ do_filtermodel (GtkWidget *do_widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
gtk_widget_set_visible (window, TRUE);
|
gtk_widget_show (window);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (window));
|
gtk_window_destroy (GTK_WINDOW (window));
|
||||||
|
|
||||||
|
@@ -11,9 +11,6 @@
|
|||||||
#include "gtkgears.h"
|
#include "gtkgears.h"
|
||||||
#include "gskshaderpaintable.h"
|
#include "gskshaderpaintable.h"
|
||||||
|
|
||||||
#include "nodewidget.h"
|
|
||||||
#include "graphwidget.h"
|
|
||||||
|
|
||||||
const char *const css =
|
const char *const css =
|
||||||
".blurred-button {"
|
".blurred-button {"
|
||||||
" box-shadow: 0px 0px 5px 10px rgba(0, 0, 0, 0.5);"
|
" box-shadow: 0px 0px 5px 10px rgba(0, 0, 0, 0.5);"
|
||||||
@@ -74,7 +71,7 @@ create_blurred_button (void)
|
|||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
create_font_button (void)
|
create_font_button (void)
|
||||||
{
|
{
|
||||||
return gtk_font_dialog_button_new (gtk_font_dialog_new ());
|
return gtk_font_button_new ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
@@ -184,12 +181,6 @@ create_cogs (void)
|
|||||||
return picture;
|
return picture;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
check_cogs (GtkFishbowl *fb)
|
|
||||||
{
|
|
||||||
return GSK_IS_GL_RENDERER (gtk_native_get_renderer (gtk_widget_get_native (GTK_WIDGET (fb))));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mapped (GtkWidget *w)
|
mapped (GtkWidget *w)
|
||||||
{
|
{
|
||||||
@@ -210,55 +201,36 @@ create_menu_button (void)
|
|||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkWidget *
|
|
||||||
create_tiger (void)
|
|
||||||
{
|
|
||||||
return node_widget_new ("/fishbowl/tiger.node");
|
|
||||||
}
|
|
||||||
|
|
||||||
static GtkWidget *
|
|
||||||
create_graph (void)
|
|
||||||
{
|
|
||||||
return graph_widget_new ();
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct {
|
static const struct {
|
||||||
const char *name;
|
const char *name;
|
||||||
GtkWidget * (*create_func) (void);
|
GtkWidget * (*create_func) (void);
|
||||||
gboolean (* check) (GtkFishbowl *fb);
|
|
||||||
} widget_types[] = {
|
} widget_types[] = {
|
||||||
{ "Icon", create_icon, NULL },
|
{ "Icon", create_icon },
|
||||||
{ "Button", create_button, NULL },
|
{ "Button", create_button },
|
||||||
{ "Blurbutton", create_blurred_button, NULL },
|
{ "Blurbutton", create_blurred_button },
|
||||||
{ "Fontbutton", create_font_button, NULL },
|
{ "Fontbutton", create_font_button },
|
||||||
{ "Levelbar", create_level_bar, NULL },
|
{ "Levelbar", create_level_bar },
|
||||||
{ "Label", create_label, NULL },
|
{ "Label", create_label },
|
||||||
{ "Spinner", create_spinner, NULL },
|
{ "Spinner", create_spinner },
|
||||||
{ "Spinbutton", create_spinbutton, NULL },
|
{ "Spinbutton", create_spinbutton },
|
||||||
{ "Video", create_video, NULL },
|
{ "Video", create_video },
|
||||||
{ "Gears", create_gears, NULL },
|
{ "Gears", create_gears },
|
||||||
{ "Switch", create_switch, NULL },
|
{ "Switch", create_switch },
|
||||||
{ "Menubutton", create_menu_button, NULL },
|
{ "Menubutton", create_menu_button },
|
||||||
{ "Shader", create_cogs, check_cogs },
|
{ "Shader", create_cogs },
|
||||||
{ "Tiger", create_tiger, NULL },
|
|
||||||
{ "Graph", create_graph, NULL },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int selected_widget_type = -1;
|
static int selected_widget_type = -1;
|
||||||
static const int N_WIDGET_TYPES = G_N_ELEMENTS (widget_types);
|
static const int N_WIDGET_TYPES = G_N_ELEMENTS (widget_types);
|
||||||
|
|
||||||
static gboolean
|
static void
|
||||||
set_widget_type (GtkFishbowl *fishbowl,
|
set_widget_type (GtkFishbowl *fishbowl,
|
||||||
int widget_type_index)
|
int widget_type_index)
|
||||||
{
|
{
|
||||||
GtkWidget *window;
|
GtkWidget *window;
|
||||||
|
|
||||||
if (widget_type_index == selected_widget_type)
|
if (widget_type_index == selected_widget_type)
|
||||||
return TRUE;
|
return;
|
||||||
|
|
||||||
if (widget_types[widget_type_index].check != NULL &&
|
|
||||||
!widget_types[widget_type_index].check (fishbowl))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
selected_widget_type = widget_type_index;
|
selected_widget_type = widget_type_index;
|
||||||
|
|
||||||
@@ -268,8 +240,6 @@ set_widget_type (GtkFishbowl *fishbowl,
|
|||||||
window = GTK_WIDGET (gtk_widget_get_root (GTK_WIDGET (fishbowl)));
|
window = GTK_WIDGET (gtk_widget_get_root (GTK_WIDGET (fishbowl)));
|
||||||
gtk_window_set_title (GTK_WINDOW (window),
|
gtk_window_set_title (GTK_WINDOW (window),
|
||||||
widget_types[selected_widget_type].name);
|
widget_types[selected_widget_type].name);
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
G_MODULE_EXPORT void
|
G_MODULE_EXPORT void
|
||||||
@@ -277,17 +247,14 @@ fishbowl_next_button_clicked_cb (GtkButton *source,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GtkFishbowl *fishbowl = user_data;
|
GtkFishbowl *fishbowl = user_data;
|
||||||
int new_index = selected_widget_type;
|
int new_index;
|
||||||
|
|
||||||
do
|
if (selected_widget_type + 1 >= N_WIDGET_TYPES)
|
||||||
{
|
|
||||||
if (new_index + 1 >= N_WIDGET_TYPES)
|
|
||||||
new_index = 0;
|
new_index = 0;
|
||||||
else
|
else
|
||||||
new_index = new_index + 1;
|
new_index = selected_widget_type + 1;
|
||||||
|
|
||||||
}
|
set_widget_type (fishbowl, new_index);
|
||||||
while (!set_widget_type (fishbowl, new_index));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
G_MODULE_EXPORT void
|
G_MODULE_EXPORT void
|
||||||
@@ -295,18 +262,14 @@ fishbowl_prev_button_clicked_cb (GtkButton *source,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GtkFishbowl *fishbowl = user_data;
|
GtkFishbowl *fishbowl = user_data;
|
||||||
int new_index = selected_widget_type;
|
int new_index;
|
||||||
|
|
||||||
do
|
if (selected_widget_type - 1 < 0)
|
||||||
{
|
|
||||||
if (new_index - 1 < 0)
|
|
||||||
new_index = N_WIDGET_TYPES - 1;
|
new_index = N_WIDGET_TYPES - 1;
|
||||||
else
|
else
|
||||||
new_index = new_index - 1;
|
new_index = selected_widget_type - 1;
|
||||||
|
|
||||||
}
|
set_widget_type (fishbowl, new_index);
|
||||||
|
|
||||||
while (!set_widget_type (fishbowl, new_index));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
G_MODULE_EXPORT void
|
G_MODULE_EXPORT void
|
||||||
@@ -336,7 +299,7 @@ do_fishbowl (GtkWidget *do_widget)
|
|||||||
if (provider == NULL)
|
if (provider == NULL)
|
||||||
{
|
{
|
||||||
provider = gtk_css_provider_new ();
|
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_context_add_provider_for_display (gdk_display_get_default (),
|
||||||
GTK_STYLE_PROVIDER (provider),
|
GTK_STYLE_PROVIDER (provider),
|
||||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||||
@@ -345,20 +308,11 @@ do_fishbowl (GtkWidget *do_widget)
|
|||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
GtkBuilder *builder;
|
GtkBuilder *builder;
|
||||||
GtkBuilderScope *scope;
|
|
||||||
GtkWidget *bowl;
|
GtkWidget *bowl;
|
||||||
|
|
||||||
g_type_ensure (GTK_TYPE_FISHBOWL);
|
g_type_ensure (GTK_TYPE_FISHBOWL);
|
||||||
|
|
||||||
scope = gtk_builder_cscope_new ();
|
builder = gtk_builder_new_from_resource ("/fishbowl/fishbowl.ui");
|
||||||
gtk_builder_cscope_add_callback (GTK_BUILDER_CSCOPE (scope), fishbowl_prev_button_clicked_cb);
|
|
||||||
gtk_builder_cscope_add_callback (GTK_BUILDER_CSCOPE (scope), fishbowl_next_button_clicked_cb);
|
|
||||||
gtk_builder_cscope_add_callback (GTK_BUILDER_CSCOPE (scope), fishbowl_changes_toggled_cb);
|
|
||||||
gtk_builder_cscope_add_callback (GTK_BUILDER_CSCOPE (scope), format_header_cb);
|
|
||||||
|
|
||||||
builder = gtk_builder_new ();
|
|
||||||
gtk_builder_set_scope (builder, scope);
|
|
||||||
gtk_builder_add_from_resource (builder, "/fishbowl/fishbowl.ui", NULL);
|
|
||||||
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
|
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
|
||||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||||
|
|
||||||
@@ -370,11 +324,10 @@ do_fishbowl (GtkWidget *do_widget)
|
|||||||
|
|
||||||
gtk_widget_realize (window);
|
gtk_widget_realize (window);
|
||||||
g_object_unref (builder);
|
g_object_unref (builder);
|
||||||
g_object_unref (scope);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
gtk_widget_set_visible (window, TRUE);
|
gtk_widget_show (window);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (window));
|
gtk_window_destroy (GTK_WINDOW (window));
|
||||||
|
|
||||||
|
@@ -160,7 +160,7 @@ do_fixed (GtkWidget *do_widget)
|
|||||||
demo_window = create_demo_window (do_widget);
|
demo_window = create_demo_window (do_widget);
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (demo_window))
|
if (!gtk_widget_get_visible (demo_window))
|
||||||
gtk_widget_set_visible (demo_window, TRUE);
|
gtk_widget_show (demo_window);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (demo_window));
|
gtk_window_destroy (GTK_WINDOW (demo_window));
|
||||||
|
|
||||||
|
@@ -742,7 +742,7 @@ do_flowbox (GtkWidget *do_widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
gtk_widget_set_visible (window, TRUE);
|
gtk_widget_show (window);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (window));
|
gtk_window_destroy (GTK_WINDOW (window));
|
||||||
|
|
||||||
|
@@ -21,77 +21,6 @@
|
|||||||
#include "script-names.h"
|
#include "script-names.h"
|
||||||
#include "language-names.h"
|
#include "language-names.h"
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
||||||
|
|
||||||
/* {{{ ScriptLang object */
|
|
||||||
|
|
||||||
G_DECLARE_FINAL_TYPE (ScriptLang, script_lang, SCRIPT, LANG, GObject)
|
|
||||||
|
|
||||||
struct _ScriptLang
|
|
||||||
{
|
|
||||||
GObject parent;
|
|
||||||
|
|
||||||
char *langname;
|
|
||||||
unsigned int script_index;
|
|
||||||
unsigned int lang_index;
|
|
||||||
hb_tag_t lang_tag;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _ScriptLangClass
|
|
||||||
{
|
|
||||||
GObjectClass parent_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
G_DEFINE_TYPE (ScriptLang, script_lang, G_TYPE_OBJECT)
|
|
||||||
|
|
||||||
static void
|
|
||||||
script_lang_init (ScriptLang *self)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
script_lang_finalize (GObject *object)
|
|
||||||
{
|
|
||||||
ScriptLang *self = SCRIPT_LANG (object);
|
|
||||||
|
|
||||||
g_free (self->langname);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (script_lang_parent_class)->finalize (object);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
script_lang_class_init (ScriptLangClass *class)
|
|
||||||
{
|
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
|
||||||
|
|
||||||
object_class->finalize = script_lang_finalize;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ScriptLang *
|
|
||||||
script_lang_new (const char *langname,
|
|
||||||
unsigned int script_index,
|
|
||||||
unsigned int lang_index,
|
|
||||||
hb_tag_t lang_tag)
|
|
||||||
{
|
|
||||||
ScriptLang *self;
|
|
||||||
|
|
||||||
self = g_object_new (script_lang_get_type (), NULL);
|
|
||||||
|
|
||||||
self->langname = g_strdup (langname);
|
|
||||||
self->script_index = script_index;
|
|
||||||
self->lang_index = lang_index;
|
|
||||||
self->lang_tag = lang_tag;
|
|
||||||
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *
|
|
||||||
script_lang_get_langname (ScriptLang *self)
|
|
||||||
{
|
|
||||||
return g_strdup (self->langname);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* }}} */
|
|
||||||
|
|
||||||
#define MAKE_TAG(a,b,c,d) (unsigned int)(((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
|
#define MAKE_TAG(a,b,c,d) (unsigned int)(((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
|
||||||
|
|
||||||
@@ -165,10 +94,6 @@ demo_free (gpointer data)
|
|||||||
g_clear_pointer (&demo->axes, g_hash_table_unref);
|
g_clear_pointer (&demo->axes, g_hash_table_unref);
|
||||||
g_clear_pointer (&demo->text, g_free);
|
g_clear_pointer (&demo->text, g_free);
|
||||||
|
|
||||||
gtk_style_context_remove_provider_for_display (gdk_display_get_default (),
|
|
||||||
GTK_STYLE_PROVIDER (demo->provider));
|
|
||||||
g_object_unref (demo->provider);
|
|
||||||
|
|
||||||
g_free (demo);
|
g_free (demo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,10 +183,10 @@ swap_colors (void)
|
|||||||
GdkRGBA fg;
|
GdkRGBA fg;
|
||||||
GdkRGBA bg;
|
GdkRGBA bg;
|
||||||
|
|
||||||
fg = *gtk_color_dialog_button_get_rgba (GTK_COLOR_DIALOG_BUTTON (demo->foreground));
|
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (demo->foreground), &fg);
|
||||||
bg = *gtk_color_dialog_button_get_rgba (GTK_COLOR_DIALOG_BUTTON (demo->background));
|
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (demo->background), &bg);
|
||||||
gtk_color_dialog_button_set_rgba (GTK_COLOR_DIALOG_BUTTON (demo->foreground), &bg);
|
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (demo->foreground), &bg);
|
||||||
gtk_color_dialog_button_set_rgba (GTK_COLOR_DIALOG_BUTTON (demo->background), &fg);
|
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (demo->background), &fg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -270,8 +195,8 @@ font_features_reset_basic (void)
|
|||||||
gtk_adjustment_set_value (demo->size_adjustment, 20);
|
gtk_adjustment_set_value (demo->size_adjustment, 20);
|
||||||
gtk_adjustment_set_value (demo->letterspacing_adjustment, 0);
|
gtk_adjustment_set_value (demo->letterspacing_adjustment, 0);
|
||||||
gtk_adjustment_set_value (demo->line_height_adjustment, 1);
|
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_chooser_set_rgba (GTK_COLOR_CHOOSER (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->background), &(GdkRGBA){1.,1.,1.,1.});
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -279,7 +204,7 @@ update_basic (void)
|
|||||||
{
|
{
|
||||||
PangoFontDescription *desc;
|
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,
|
gtk_adjustment_set_value (demo->size_adjustment,
|
||||||
pango_font_description_get_size (desc) / (double) PANGO_SCALE);
|
pango_font_description_get_size (desc) / (double) PANGO_SCALE);
|
||||||
@@ -546,6 +471,8 @@ update_display (void)
|
|||||||
GString *s;
|
GString *s;
|
||||||
char *text;
|
char *text;
|
||||||
gboolean has_feature;
|
gboolean has_feature;
|
||||||
|
GtkTreeIter iter;
|
||||||
|
GtkTreeModel *model;
|
||||||
PangoFontDescription *desc;
|
PangoFontDescription *desc;
|
||||||
GList *l;
|
GList *l;
|
||||||
PangoAttrList *attrs;
|
PangoAttrList *attrs;
|
||||||
@@ -590,7 +517,7 @@ update_display (void)
|
|||||||
end = PANGO_ATTR_INDEX_TO_TEXT_END;
|
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);
|
value = gtk_adjustment_get_value (demo->size_adjustment);
|
||||||
pango_font_description_set_size (desc, value * PANGO_SCALE);
|
pango_font_description_set_size (desc, value * PANGO_SCALE);
|
||||||
@@ -600,8 +527,8 @@ update_display (void)
|
|||||||
if (s->len > 0)
|
if (s->len > 0)
|
||||||
{
|
{
|
||||||
pango_font_description_set_variations (desc, s->str);
|
pango_font_description_set_variations (desc, s->str);
|
||||||
}
|
|
||||||
g_string_free (s, TRUE);
|
g_string_free (s, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
font_desc = pango_font_description_to_string (desc);
|
font_desc = pango_font_description_to_string (desc);
|
||||||
|
|
||||||
@@ -648,13 +575,14 @@ update_display (void)
|
|||||||
|
|
||||||
features = g_string_free (s, FALSE);
|
features = g_string_free (s, FALSE);
|
||||||
|
|
||||||
if (gtk_drop_down_get_selected (GTK_DROP_DOWN (demo->script_lang)) != 0)
|
if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (demo->script_lang), &iter))
|
||||||
{
|
{
|
||||||
ScriptLang *selected;
|
hb_tag_t lang_tag;
|
||||||
|
|
||||||
selected = gtk_drop_down_get_selected_item (GTK_DROP_DOWN (demo->script_lang));
|
model = gtk_combo_box_get_model (GTK_COMBO_BOX (demo->script_lang));
|
||||||
|
gtk_tree_model_get (model, &iter, 3, &lang_tag, -1);
|
||||||
|
|
||||||
lang = pango_language_from_string (hb_language_to_string (hb_ot_tag_to_language (selected->lang_tag)));
|
lang = pango_language_from_string (hb_language_to_string (hb_ot_tag_to_language (lang_tag)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
lang = NULL;
|
lang = NULL;
|
||||||
@@ -681,7 +609,7 @@ update_display (void)
|
|||||||
GdkRGBA rgba;
|
GdkRGBA rgba;
|
||||||
char *fg, *bg, *css;
|
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,
|
attr = pango_attr_foreground_new (65535 * rgba.red,
|
||||||
65535 * rgba.green,
|
65535 * rgba.green,
|
||||||
65535 * rgba.blue);
|
65535 * rgba.blue);
|
||||||
@@ -694,7 +622,7 @@ update_display (void)
|
|||||||
pango_attr_list_insert (attrs, attr);
|
pango_attr_list_insert (attrs, attr);
|
||||||
|
|
||||||
fg = gdk_rgba_to_string (&rgba);
|
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);
|
bg = gdk_rgba_to_string (&rgba);
|
||||||
css = g_strdup_printf (".font_features_background { caret-color: %s; background-color: %s; }", fg, bg);
|
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));
|
gtk_css_provider_load_from_data (demo->provider, css, strlen (css));
|
||||||
@@ -769,6 +697,7 @@ update_display (void)
|
|||||||
gtk_label_set_attributes (GTK_LABEL (demo->the_label), attrs);
|
gtk_label_set_attributes (GTK_LABEL (demo->the_label), attrs);
|
||||||
|
|
||||||
g_free (font_desc);
|
g_free (font_desc);
|
||||||
|
pango_font_description_free (desc);
|
||||||
g_free (features);
|
g_free (features);
|
||||||
pango_attr_list_unref (attrs);
|
pango_attr_list_unref (attrs);
|
||||||
g_free (text);
|
g_free (text);
|
||||||
@@ -780,7 +709,7 @@ get_pango_font (void)
|
|||||||
PangoFontDescription *desc;
|
PangoFontDescription *desc;
|
||||||
PangoContext *context;
|
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);
|
context = gtk_widget_get_pango_context (demo->font);
|
||||||
|
|
||||||
return pango_context_load_font (context, desc);
|
return pango_context_load_font (context, desc);
|
||||||
@@ -810,40 +739,50 @@ tag_pair_equal (gconstpointer a, gconstpointer b)
|
|||||||
return pair_a->script_tag == pair_b->script_tag && pair_a->lang_tag == pair_b->lang_tag;
|
return pair_a->script_tag == pair_b->script_tag && pair_a->lang_tag == pair_b->lang_tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
static GtkOrdering
|
script_sort_func (GtkTreeModel *model,
|
||||||
script_sort (const void *item1,
|
GtkTreeIter *a,
|
||||||
const void *item2,
|
GtkTreeIter *b,
|
||||||
void *data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
ScriptLang *a = (ScriptLang *)item1;
|
char *sa, *sb;
|
||||||
ScriptLang *b = (ScriptLang *)item2;
|
int ret;
|
||||||
|
|
||||||
return strcmp (a->langname, b->langname);
|
gtk_tree_model_get (model, a, 0, &sa, -1);
|
||||||
|
gtk_tree_model_get (model, b, 0, &sb, -1);
|
||||||
|
|
||||||
|
ret = strcmp (sa, sb);
|
||||||
|
|
||||||
|
g_free (sa);
|
||||||
|
g_free (sb);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_script_combo (void)
|
update_script_combo (void)
|
||||||
{
|
{
|
||||||
GListStore *store;
|
GtkListStore *store;
|
||||||
GtkSortListModel *sortmodel;
|
|
||||||
hb_font_t *hb_font;
|
hb_font_t *hb_font;
|
||||||
|
int i, j, k;
|
||||||
PangoFont *pango_font;
|
PangoFont *pango_font;
|
||||||
GHashTable *tags;
|
GHashTable *tags;
|
||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
TagPair *pair;
|
TagPair *pair;
|
||||||
PangoLanguage *language;
|
char *lang;
|
||||||
const char *lang;
|
|
||||||
hb_tag_t active;
|
hb_tag_t active;
|
||||||
|
GtkTreeIter active_iter;
|
||||||
|
gboolean have_active = FALSE;
|
||||||
|
|
||||||
language = gtk_font_dialog_button_get_language (GTK_FONT_DIALOG_BUTTON (demo->font));
|
lang = gtk_font_chooser_get_language (GTK_FONT_CHOOSER (demo->font));
|
||||||
lang = pango_language_to_string (language);
|
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||||
active = hb_ot_tag_from_language (hb_language_from_string (lang, -1));
|
active = hb_ot_tag_from_language (hb_language_from_string (lang, -1));
|
||||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||||
|
|
||||||
store = g_list_store_new (script_lang_get_type ());
|
g_free (lang);
|
||||||
|
|
||||||
|
store = gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT);
|
||||||
|
|
||||||
pango_font = get_pango_font ();
|
pango_font = get_pango_font ();
|
||||||
hb_font = pango_font_get_hb_font (pango_font);
|
hb_font = pango_font_get_hb_font (pango_font);
|
||||||
@@ -855,6 +794,11 @@ update_script_combo (void)
|
|||||||
pair->lang_tag = 0;
|
pair->lang_tag = 0;
|
||||||
g_hash_table_add (tags, pair);
|
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)
|
if (hb_font)
|
||||||
{
|
{
|
||||||
hb_tag_t tables[2] = { HB_OT_TAG_GSUB, HB_OT_TAG_GPOS };
|
hb_tag_t tables[2] = { HB_OT_TAG_GSUB, HB_OT_TAG_GPOS };
|
||||||
@@ -862,19 +806,19 @@ update_script_combo (void)
|
|||||||
|
|
||||||
hb_face = hb_font_get_face (hb_font);
|
hb_face = hb_font_get_face (hb_font);
|
||||||
|
|
||||||
for (guint i = 0; i < 2; i++)
|
for (i= 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
hb_tag_t scripts[80];
|
hb_tag_t scripts[80];
|
||||||
unsigned int script_count = G_N_ELEMENTS (scripts);
|
unsigned int script_count = G_N_ELEMENTS (scripts);
|
||||||
|
|
||||||
hb_ot_layout_table_get_script_tags (hb_face, tables[i], 0, &script_count, scripts);
|
hb_ot_layout_table_get_script_tags (hb_face, tables[i], 0, &script_count, scripts);
|
||||||
for (guint j = 0; j < script_count; j++)
|
for (j = 0; j < script_count; j++)
|
||||||
{
|
{
|
||||||
hb_tag_t languages[80];
|
hb_tag_t languages[80];
|
||||||
unsigned int language_count = G_N_ELEMENTS (languages);
|
unsigned int language_count = G_N_ELEMENTS (languages);
|
||||||
|
|
||||||
hb_ot_layout_script_get_language_tags (hb_face, tables[i], j, 0, &language_count, languages);
|
hb_ot_layout_script_get_language_tags (hb_face, tables[i], j, 0, &language_count, languages);
|
||||||
for (guint k = 0; k < language_count; k++)
|
for (k = 0; k < language_count; k++)
|
||||||
{
|
{
|
||||||
pair = g_new (TagPair, 1);
|
pair = g_new (TagPair, 1);
|
||||||
pair->script_tag = scripts[j];
|
pair->script_tag = scripts[j];
|
||||||
@@ -894,6 +838,7 @@ update_script_combo (void)
|
|||||||
{
|
{
|
||||||
const char *langname;
|
const char *langname;
|
||||||
char langbuf[5];
|
char langbuf[5];
|
||||||
|
GtkTreeIter tree_iter;
|
||||||
|
|
||||||
if (pair->lang_tag == 0 && pair->script_tag == 0)
|
if (pair->lang_tag == 0 && pair->script_tag == 0)
|
||||||
langname = NC_("Language", "None");
|
langname = NC_("Language", "None");
|
||||||
@@ -910,31 +855,31 @@ update_script_combo (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_list_store_append (store, script_lang_new (langname,
|
gtk_list_store_insert_with_values (store, &tree_iter, -1,
|
||||||
pair->script_index,
|
0, langname,
|
||||||
pair->lang_index,
|
1, pair->script_index,
|
||||||
pair->lang_tag));
|
2, pair->lang_index,
|
||||||
|
3, pair->lang_tag,
|
||||||
|
-1);
|
||||||
|
if (pair->lang_tag == active)
|
||||||
|
{
|
||||||
|
have_active = TRUE;
|
||||||
|
active_iter = tree_iter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_hash_table_destroy (tags);
|
g_hash_table_destroy (tags);
|
||||||
|
|
||||||
sortmodel = gtk_sort_list_model_new (G_LIST_MODEL (store),
|
gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (store),
|
||||||
GTK_SORTER (gtk_custom_sorter_new (script_sort, NULL, NULL)));
|
script_sort_func, NULL, NULL);
|
||||||
gtk_drop_down_set_model (GTK_DROP_DOWN (demo->script_lang), G_LIST_MODEL (sortmodel));
|
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
|
||||||
|
GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
|
||||||
for (guint i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (sortmodel)); i++)
|
GTK_SORT_ASCENDING);
|
||||||
{
|
gtk_combo_box_set_model (GTK_COMBO_BOX (demo->script_lang), GTK_TREE_MODEL (store));
|
||||||
ScriptLang *item = g_list_model_get_item (G_LIST_MODEL (sortmodel), i);
|
if (have_active)
|
||||||
g_object_unref (item);
|
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (demo->script_lang), &active_iter);
|
||||||
|
else
|
||||||
if (item->lang_tag == active)
|
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (demo->script_lang), 0);
|
||||||
{
|
|
||||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (demo->script_lang), i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
g_object_unref (sortmodel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
@@ -959,22 +904,33 @@ static void
|
|||||||
update_features (void)
|
update_features (void)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
|
GtkTreeModel *model;
|
||||||
|
GtkTreeIter iter;
|
||||||
|
guint script_index, lang_index;
|
||||||
|
hb_tag_t lang_tag;
|
||||||
PangoFont *pango_font;
|
PangoFont *pango_font;
|
||||||
hb_font_t *hb_font;
|
hb_font_t *hb_font;
|
||||||
GList *l;
|
GList *l;
|
||||||
ScriptLang *selected;
|
|
||||||
|
|
||||||
/* set feature presence checks from the font features */
|
/* set feature presence checks from the font features */
|
||||||
|
|
||||||
selected = gtk_drop_down_get_selected_item (GTK_DROP_DOWN (demo->script_lang));
|
if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (demo->script_lang), &iter))
|
||||||
|
return;
|
||||||
|
|
||||||
if (selected->lang_tag == 0) /* None is selected */
|
model = gtk_combo_box_get_model (GTK_COMBO_BOX (demo->script_lang));
|
||||||
|
gtk_tree_model_get (model, &iter,
|
||||||
|
1, &script_index,
|
||||||
|
2, &lang_index,
|
||||||
|
3, &lang_tag,
|
||||||
|
-1);
|
||||||
|
|
||||||
|
if (lang_tag == 0) /* None is selected */
|
||||||
{
|
{
|
||||||
for (l = demo->feature_items; l; l = l->next)
|
for (l = demo->feature_items; l; l = l->next)
|
||||||
{
|
{
|
||||||
FeatureItem *item = l->data;
|
FeatureItem *item = l->data;
|
||||||
gtk_widget_set_visible (item->feat, TRUE);
|
gtk_widget_show (item->feat);
|
||||||
gtk_widget_set_visible (gtk_widget_get_parent (item->feat), TRUE);
|
gtk_widget_show (gtk_widget_get_parent (item->feat));
|
||||||
if (strcmp (item->name, "xxxx") == 0)
|
if (strcmp (item->name, "xxxx") == 0)
|
||||||
gtk_check_button_set_active (GTK_CHECK_BUTTON (item->feat), TRUE);
|
gtk_check_button_set_active (GTK_CHECK_BUTTON (item->feat), TRUE);
|
||||||
}
|
}
|
||||||
@@ -985,8 +941,8 @@ update_features (void)
|
|||||||
for (l = demo->feature_items; l; l = l->next)
|
for (l = demo->feature_items; l; l = l->next)
|
||||||
{
|
{
|
||||||
FeatureItem *item = l->data;
|
FeatureItem *item = l->data;
|
||||||
gtk_widget_set_visible (item->feat, FALSE);
|
gtk_widget_hide (item->feat);
|
||||||
gtk_widget_set_visible (gtk_widget_get_parent (item->feat), FALSE);
|
gtk_widget_hide (gtk_widget_get_parent (item->feat));
|
||||||
if (strcmp (item->name, "xxxx") == 0)
|
if (strcmp (item->name, "xxxx") == 0)
|
||||||
gtk_check_button_set_active (GTK_CHECK_BUTTON (item->feat), TRUE);
|
gtk_check_button_set_active (GTK_CHECK_BUTTON (item->feat), TRUE);
|
||||||
}
|
}
|
||||||
@@ -994,13 +950,11 @@ update_features (void)
|
|||||||
pango_font = get_pango_font ();
|
pango_font = get_pango_font ();
|
||||||
hb_font = pango_font_get_hb_font (pango_font);
|
hb_font = pango_font_get_hb_font (pango_font);
|
||||||
|
|
||||||
g_print ("language %s\n", selected->langname);
|
|
||||||
|
|
||||||
if (hb_font)
|
if (hb_font)
|
||||||
{
|
{
|
||||||
hb_tag_t tables[2] = { HB_OT_TAG_GSUB, HB_OT_TAG_GPOS };
|
hb_tag_t tables[2] = { HB_OT_TAG_GSUB, HB_OT_TAG_GPOS };
|
||||||
hb_face_t *hb_face;
|
hb_face_t *hb_face;
|
||||||
const char *feat;
|
char *feat;
|
||||||
|
|
||||||
hb_face = hb_font_get_face (hb_font);
|
hb_face = hb_font_get_face (hb_font);
|
||||||
|
|
||||||
@@ -1011,8 +965,8 @@ update_features (void)
|
|||||||
|
|
||||||
hb_ot_layout_language_get_feature_tags (hb_face,
|
hb_ot_layout_language_get_feature_tags (hb_face,
|
||||||
tables[i],
|
tables[i],
|
||||||
selected->script_index,
|
script_index,
|
||||||
selected->lang_index,
|
lang_index,
|
||||||
0,
|
0,
|
||||||
&count,
|
&count,
|
||||||
features);
|
features);
|
||||||
@@ -1022,6 +976,9 @@ update_features (void)
|
|||||||
char buf[5];
|
char buf[5];
|
||||||
hb_tag_to_string (features[j], buf);
|
hb_tag_to_string (features[j], buf);
|
||||||
buf[4] = 0;
|
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"))
|
if (g_str_has_prefix (buf, "ss") || g_str_has_prefix (buf, "cv"))
|
||||||
{
|
{
|
||||||
@@ -1031,8 +988,8 @@ update_features (void)
|
|||||||
|
|
||||||
hb_ot_layout_language_find_feature (hb_face,
|
hb_ot_layout_language_find_feature (hb_face,
|
||||||
tables[i],
|
tables[i],
|
||||||
selected->script_index,
|
script_index,
|
||||||
selected->lang_index,
|
lang_index,
|
||||||
features[j],
|
features[j],
|
||||||
&feature_index);
|
&feature_index);
|
||||||
|
|
||||||
@@ -1071,15 +1028,15 @@ update_features (void)
|
|||||||
|
|
||||||
if (item->tag == features[j])
|
if (item->tag == features[j])
|
||||||
{
|
{
|
||||||
gtk_widget_set_visible (item->feat, TRUE);
|
gtk_widget_show (item->feat);
|
||||||
gtk_widget_set_visible (gtk_widget_get_parent (item->feat), TRUE);
|
gtk_widget_show (gtk_widget_get_parent (item->feat));
|
||||||
if (GTK_IS_CHECK_BUTTON (item->feat))
|
if (GTK_IS_CHECK_BUTTON (item->feat))
|
||||||
{
|
{
|
||||||
GtkWidget *def = GTK_WIDGET (g_object_get_data (G_OBJECT (item->feat), "default"));
|
GtkWidget *def = GTK_WIDGET (g_object_get_data (G_OBJECT (item->feat), "default"));
|
||||||
if (def)
|
if (def)
|
||||||
{
|
{
|
||||||
gtk_widget_set_visible (def, TRUE);
|
gtk_widget_show (def);
|
||||||
gtk_widget_set_visible (gtk_widget_get_parent (def), TRUE);
|
gtk_widget_show (gtk_widget_get_parent (def));
|
||||||
gtk_check_button_set_active (GTK_CHECK_BUTTON (def), TRUE);
|
gtk_check_button_set_active (GTK_CHECK_BUTTON (def), TRUE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1090,7 +1047,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)
|
if (feat)
|
||||||
{
|
{
|
||||||
for (l = demo->feature_items; l; l = l->next)
|
for (l = demo->feature_items; l; l = l->next)
|
||||||
@@ -1116,6 +1073,8 @@ update_features (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_free (feat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1294,18 +1253,18 @@ add_axis (hb_face_t *hb_face,
|
|||||||
|
|
||||||
axis_label = gtk_label_new (name);
|
axis_label = gtk_label_new (name);
|
||||||
gtk_widget_set_halign (axis_label, GTK_ALIGN_START);
|
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);
|
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,
|
adjustment = gtk_adjustment_new (value, ax->min_value, ax->max_value,
|
||||||
1.0, 10.0, 0.0);
|
1.0, 10.0, 0.0);
|
||||||
axis_scale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, adjustment);
|
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_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_hexpand (axis_scale, TRUE);
|
||||||
gtk_widget_set_size_request (axis_scale, 100, -1);
|
gtk_widget_set_size_request (axis_scale, 100, -1);
|
||||||
gtk_grid_attach (GTK_GRID (demo->variations_grid), axis_scale, 1, i, 1, 1);
|
gtk_grid_attach (GTK_GRID (demo->variations_grid), axis_scale, 1, i, 1, 1);
|
||||||
axis_entry = gtk_entry_new ();
|
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_width_chars (GTK_EDITABLE (axis_entry), 4);
|
||||||
gtk_editable_set_max_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);
|
gtk_widget_set_hexpand (axis_entry, FALSE);
|
||||||
@@ -1364,7 +1323,8 @@ free_instance (gpointer data)
|
|||||||
static void
|
static void
|
||||||
add_instance (hb_face_t *face,
|
add_instance (hb_face_t *face,
|
||||||
unsigned int index,
|
unsigned int index,
|
||||||
GtkStringList *strings)
|
GtkWidget *combo,
|
||||||
|
int pos)
|
||||||
{
|
{
|
||||||
Instance *instance;
|
Instance *instance;
|
||||||
hb_ot_name_id_t name_id;
|
hb_ot_name_id_t name_id;
|
||||||
@@ -1380,20 +1340,20 @@ add_instance (hb_face_t *face,
|
|||||||
instance->index = index;
|
instance->index = index;
|
||||||
|
|
||||||
g_hash_table_add (demo->instances, instance);
|
g_hash_table_add (demo->instances, instance);
|
||||||
gtk_string_list_append (GTK_STRING_LIST (strings), instance->name);
|
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), instance->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unset_instance (GtkAdjustment *adjustment)
|
unset_instance (GtkAdjustment *adjustment)
|
||||||
{
|
{
|
||||||
if (demo->instance_combo)
|
if (demo->instance_combo)
|
||||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (demo->instance_combo), 0);
|
gtk_combo_box_set_active (GTK_COMBO_BOX (demo->instance_combo), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
instance_changed (GtkDropDown *combo)
|
instance_changed (GtkComboBox *combo)
|
||||||
{
|
{
|
||||||
const char *text;
|
char *text;
|
||||||
Instance *instance;
|
Instance *instance;
|
||||||
Instance ikey;
|
Instance ikey;
|
||||||
int i;
|
int i;
|
||||||
@@ -1405,15 +1365,17 @@ instance_changed (GtkDropDown *combo)
|
|||||||
hb_font_t *hb_font;
|
hb_font_t *hb_font;
|
||||||
hb_face_t *hb_face;
|
hb_face_t *hb_face;
|
||||||
|
|
||||||
text = gtk_string_list_get_string (GTK_STRING_LIST (gtk_drop_down_get_model (combo)),
|
text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (combo));
|
||||||
gtk_drop_down_get_selected (combo));
|
|
||||||
if (text[0] == '\0')
|
if (text[0] == '\0')
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
ikey.name = (char *) text;
|
ikey.name = text;
|
||||||
instance = g_hash_table_lookup (demo->instances, &ikey);
|
instance = g_hash_table_lookup (demo->instances, &ikey);
|
||||||
if (!instance)
|
if (!instance)
|
||||||
|
{
|
||||||
|
g_print ("did not find instance %s\n", text);
|
||||||
goto out;
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
pango_font = get_pango_font ();
|
pango_font = get_pango_font ();
|
||||||
hb_font = pango_font_get_hb_font (pango_font);
|
hb_font = pango_font_get_hb_font (pango_font);
|
||||||
@@ -1448,6 +1410,7 @@ instance_changed (GtkDropDown *combo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
g_free (text);
|
||||||
g_clear_object (&pango_font);
|
g_clear_object (&pango_font);
|
||||||
g_free (ai);
|
g_free (ai);
|
||||||
g_free (coords);
|
g_free (coords);
|
||||||
@@ -1557,36 +1520,33 @@ update_font_variations (void)
|
|||||||
{
|
{
|
||||||
GtkWidget *label;
|
GtkWidget *label;
|
||||||
GtkWidget *combo;
|
GtkWidget *combo;
|
||||||
GtkStringList *strings;
|
|
||||||
|
|
||||||
label = gtk_label_new ("Instance");
|
label = gtk_label_new ("Instance");
|
||||||
gtk_label_set_xalign (GTK_LABEL (label), 0);
|
gtk_label_set_xalign (GTK_LABEL (label), 0);
|
||||||
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
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);
|
gtk_grid_attach (GTK_GRID (demo->variations_grid), label, 0, -1, 1, 1);
|
||||||
|
|
||||||
strings = gtk_string_list_new (NULL);
|
combo = gtk_combo_box_text_new ();
|
||||||
combo = gtk_drop_down_new (G_LIST_MODEL (strings), NULL);
|
|
||||||
|
|
||||||
gtk_widget_set_halign (combo, GTK_ALIGN_START);
|
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, "");
|
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "");
|
||||||
|
|
||||||
for (i = 0; i < hb_ot_var_get_named_instance_count (hb_face); i++)
|
for (i = 0; i < hb_ot_var_get_named_instance_count (hb_face); i++)
|
||||||
add_instance (hb_face, i, strings);
|
add_instance (hb_face, i, combo, i);
|
||||||
|
|
||||||
for (i = 0; i < hb_ot_var_get_named_instance_count (hb_face); i++)
|
for (i = 0; i < hb_ot_var_get_named_instance_count (hb_face); i++)
|
||||||
{
|
{
|
||||||
if (matches_instance (hb_face, i, n_axes, design_coords))
|
if (matches_instance (hb_face, i, n_axes, design_coords))
|
||||||
{
|
{
|
||||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (combo), i + 1);
|
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), i + 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_grid_attach (GTK_GRID (demo->variations_grid), combo, 1, -1, 3, 1);
|
gtk_grid_attach (GTK_GRID (demo->variations_grid), combo, 1, -1, 3, 1);
|
||||||
g_signal_connect (combo, "notify::selected", G_CALLBACK (instance_changed), NULL);
|
g_signal_connect (combo, "changed", G_CALLBACK (instance_changed), NULL);
|
||||||
demo->instance_combo = combo;
|
demo->instance_combo = combo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1733,7 +1693,6 @@ do_font_features (GtkWidget *do_widget)
|
|||||||
GtkBuilder *builder;
|
GtkBuilder *builder;
|
||||||
GtkBuilderScope *scope;
|
GtkBuilderScope *scope;
|
||||||
GtkEventController *controller;
|
GtkEventController *controller;
|
||||||
GtkExpression *expression;
|
|
||||||
|
|
||||||
builder = gtk_builder_new ();
|
builder = gtk_builder_new ();
|
||||||
|
|
||||||
@@ -1767,10 +1726,6 @@ do_font_features (GtkWidget *do_widget)
|
|||||||
demo->description = GTK_WIDGET (gtk_builder_get_object (builder, "description"));
|
demo->description = GTK_WIDGET (gtk_builder_get_object (builder, "description"));
|
||||||
demo->font = GTK_WIDGET (gtk_builder_get_object (builder, "font"));
|
demo->font = GTK_WIDGET (gtk_builder_get_object (builder, "font"));
|
||||||
demo->script_lang = GTK_WIDGET (gtk_builder_get_object (builder, "script_lang"));
|
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);
|
|
||||||
demo->feature_list = GTK_WIDGET (gtk_builder_get_object (builder, "feature_list"));
|
demo->feature_list = GTK_WIDGET (gtk_builder_get_object (builder, "feature_list"));
|
||||||
demo->stack = GTK_WIDGET (gtk_builder_get_object (builder, "stack"));
|
demo->stack = GTK_WIDGET (gtk_builder_get_object (builder, "stack"));
|
||||||
demo->entry = GTK_WIDGET (gtk_builder_get_object (builder, "entry"));
|
demo->entry = GTK_WIDGET (gtk_builder_get_object (builder, "entry"));
|
||||||
@@ -1789,7 +1744,7 @@ do_font_features (GtkWidget *do_widget)
|
|||||||
demo->swin = GTK_WIDGET (gtk_builder_get_object (builder, "swin"));
|
demo->swin = GTK_WIDGET (gtk_builder_get_object (builder, "swin"));
|
||||||
|
|
||||||
demo->provider = gtk_css_provider_new ();
|
demo->provider = gtk_css_provider_new ();
|
||||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
gtk_style_context_add_provider (gtk_widget_get_style_context (demo->swin),
|
||||||
GTK_STYLE_PROVIDER (demo->provider), 800);
|
GTK_STYLE_PROVIDER (demo->provider), 800);
|
||||||
|
|
||||||
basic_value_changed (demo->size_adjustment, demo->size_entry);
|
basic_value_changed (demo->size_adjustment, demo->size_entry);
|
||||||
@@ -1868,5 +1823,3 @@ do_font_features (GtkWidget *do_widget)
|
|||||||
|
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim:set foldmethod=marker expandtab: */
|
|
||||||
|
@@ -58,17 +58,11 @@
|
|||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<property name="spacing">6</property>
|
<property name="spacing">6</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkFontDialogButton" id="font">
|
<object class="GtkFontButton" id="font">
|
||||||
<accessibility>
|
|
||||||
<property name="label">Font</property>
|
|
||||||
</accessibility>
|
|
||||||
<property name="dialog">
|
|
||||||
<object class="GtkFontDialog">
|
|
||||||
</object>
|
|
||||||
</property>
|
|
||||||
<property name="receives-default">1</property>
|
<property name="receives-default">1</property>
|
||||||
<property name="level">face</property>
|
<property name="font">Sans 12</property>
|
||||||
<signal name="notify::font-desc" handler="font_features_font_changed" swapped="no"/>
|
<property name="level">family|style</property>
|
||||||
|
<signal name="font-set" handler="font_features_font_changed" swapped="no"/>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
@@ -76,7 +70,7 @@
|
|||||||
<property name="column-spacing">10</property>
|
<property name="column-spacing">10</property>
|
||||||
<property name="row-spacing">10</property>
|
<property name="row-spacing">10</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="size_label">
|
<object class="GtkLabel">
|
||||||
<property name="label">Size</property>
|
<property name="label">Size</property>
|
||||||
<property name="xalign">0</property>
|
<property name="xalign">0</property>
|
||||||
<property name="valign">baseline</property>
|
<property name="valign">baseline</property>
|
||||||
@@ -92,9 +86,6 @@
|
|||||||
<property name="width-request">100</property>
|
<property name="width-request">100</property>
|
||||||
<property name="valign">baseline</property>
|
<property name="valign">baseline</property>
|
||||||
<property name="adjustment">size_adjustment</property>
|
<property name="adjustment">size_adjustment</property>
|
||||||
<accessibility>
|
|
||||||
<relation name="labelled-by">size_label</relation>
|
|
||||||
</accessibility>
|
|
||||||
<layout>
|
<layout>
|
||||||
<property name="column">1</property>
|
<property name="column">1</property>
|
||||||
<property name="row">0</property>
|
<property name="row">0</property>
|
||||||
@@ -107,9 +98,6 @@
|
|||||||
<property name="max-width-chars">4</property>
|
<property name="max-width-chars">4</property>
|
||||||
<property name="hexpand">0</property>
|
<property name="hexpand">0</property>
|
||||||
<property name="valign">baseline</property>
|
<property name="valign">baseline</property>
|
||||||
<accessibility>
|
|
||||||
<relation name="labelled-by">size_label</relation>
|
|
||||||
</accessibility>
|
|
||||||
<signal name="activate" handler="basic_entry_activated"
|
<signal name="activate" handler="basic_entry_activated"
|
||||||
object="size_adjustment" swapped="false"/>
|
object="size_adjustment" swapped="false"/>
|
||||||
<layout>
|
<layout>
|
||||||
@@ -119,7 +107,7 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="letterspacing_label">
|
<object class="GtkLabel">
|
||||||
<property name="label">Letterspacing</property>
|
<property name="label">Letterspacing</property>
|
||||||
<property name="xalign">0</property>
|
<property name="xalign">0</property>
|
||||||
<property name="valign">baseline</property>
|
<property name="valign">baseline</property>
|
||||||
@@ -135,9 +123,6 @@
|
|||||||
<property name="width-request">100</property>
|
<property name="width-request">100</property>
|
||||||
<property name="valign">baseline</property>
|
<property name="valign">baseline</property>
|
||||||
<property name="adjustment">letterspacing_adjustment</property>
|
<property name="adjustment">letterspacing_adjustment</property>
|
||||||
<accessibility>
|
|
||||||
<relation name="labelled-by">letterspacing_label</relation>
|
|
||||||
</accessibility>
|
|
||||||
<layout>
|
<layout>
|
||||||
<property name="column">1</property>
|
<property name="column">1</property>
|
||||||
<property name="row">1</property>
|
<property name="row">1</property>
|
||||||
@@ -150,9 +135,6 @@
|
|||||||
<property name="max-width-chars">4</property>
|
<property name="max-width-chars">4</property>
|
||||||
<property name="hexpand">0</property>
|
<property name="hexpand">0</property>
|
||||||
<property name="valign">baseline</property>
|
<property name="valign">baseline</property>
|
||||||
<accessibility>
|
|
||||||
<relation name="labelled-by">letterspacing_label</relation>
|
|
||||||
</accessibility>
|
|
||||||
<signal name="activate" handler="basic_entry_activated"
|
<signal name="activate" handler="basic_entry_activated"
|
||||||
object="letterspacing_adjustment" swapped="false"/>
|
object="letterspacing_adjustment" swapped="false"/>
|
||||||
<layout>
|
<layout>
|
||||||
@@ -162,7 +144,7 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="line_height_label">
|
<object class="GtkLabel">
|
||||||
<property name="label">Line Height</property>
|
<property name="label">Line Height</property>
|
||||||
<property name="xalign">0</property>
|
<property name="xalign">0</property>
|
||||||
<property name="valign">baseline</property>
|
<property name="valign">baseline</property>
|
||||||
@@ -178,9 +160,6 @@
|
|||||||
<property name="width-request">100</property>
|
<property name="width-request">100</property>
|
||||||
<property name="valign">baseline</property>
|
<property name="valign">baseline</property>
|
||||||
<property name="adjustment">line_height_adjustment</property>
|
<property name="adjustment">line_height_adjustment</property>
|
||||||
<accessibility>
|
|
||||||
<relation name="labelled-by">line_height_label</relation>
|
|
||||||
</accessibility>
|
|
||||||
<layout>
|
<layout>
|
||||||
<property name="column">1</property>
|
<property name="column">1</property>
|
||||||
<property name="row">2</property>
|
<property name="row">2</property>
|
||||||
@@ -193,9 +172,6 @@
|
|||||||
<property name="max-width-chars">4</property>
|
<property name="max-width-chars">4</property>
|
||||||
<property name="hexpand">0</property>
|
<property name="hexpand">0</property>
|
||||||
<property name="valign">baseline</property>
|
<property name="valign">baseline</property>
|
||||||
<accessibility>
|
|
||||||
<relation name="labelled-by">line_height_label</relation>
|
|
||||||
</accessibility>
|
|
||||||
<signal name="activate" handler="basic_entry_activated"
|
<signal name="activate" handler="basic_entry_activated"
|
||||||
object="line_height_adjustment" swapped="false"/>
|
object="line_height_adjustment" swapped="false"/>
|
||||||
<layout>
|
<layout>
|
||||||
@@ -205,7 +181,7 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="foreground_label">
|
<object class="GtkLabel">
|
||||||
<property name="label">Foreground</property>
|
<property name="label">Foreground</property>
|
||||||
<property name="xalign">0</property>
|
<property name="xalign">0</property>
|
||||||
<property name="valign">baseline</property>
|
<property name="valign">baseline</property>
|
||||||
@@ -216,16 +192,9 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkColorDialogButton" id="foreground">
|
<object class="GtkColorButton" id="foreground">
|
||||||
<property name="dialog">
|
|
||||||
<object class="GtkColorDialog">
|
|
||||||
</object>
|
|
||||||
</property>
|
|
||||||
<property name="valign">baseline</property>
|
<property name="valign">baseline</property>
|
||||||
<property name="rgba">black</property>
|
<property name="rgba">black</property>
|
||||||
<accessibility>
|
|
||||||
<relation name="labelled-by">foreground_label</relation>
|
|
||||||
</accessibility>
|
|
||||||
<signal name="notify::rgba" handler="color_set_cb"/>
|
<signal name="notify::rgba" handler="color_set_cb"/>
|
||||||
<layout>
|
<layout>
|
||||||
<property name="column">1</property>
|
<property name="column">1</property>
|
||||||
@@ -234,7 +203,7 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="background_label">
|
<object class="GtkLabel">
|
||||||
<property name="label">Background</property>
|
<property name="label">Background</property>
|
||||||
<property name="xalign">0</property>
|
<property name="xalign">0</property>
|
||||||
<property name="valign">baseline</property>
|
<property name="valign">baseline</property>
|
||||||
@@ -245,16 +214,9 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkColorDialogButton" id="background">
|
<object class="GtkColorButton" id="background">
|
||||||
<property name="dialog">
|
|
||||||
<object class="GtkColorDialog">
|
|
||||||
</object>
|
|
||||||
</property>
|
|
||||||
<property name="valign">baseline</property>
|
<property name="valign">baseline</property>
|
||||||
<property name="rgba">white</property>
|
<property name="rgba">white</property>
|
||||||
<accessibility>
|
|
||||||
<relation name="labelled-by">background_label</relation>
|
|
||||||
</accessibility>
|
|
||||||
<signal name="notify::rgba" handler="color_set_cb"/>
|
<signal name="notify::rgba" handler="color_set_cb"/>
|
||||||
<layout>
|
<layout>
|
||||||
<property name="column">1</property>
|
<property name="column">1</property>
|
||||||
@@ -267,9 +229,6 @@
|
|||||||
<property name="icon-name">object-flip-vertical-symbolic</property>
|
<property name="icon-name">object-flip-vertical-symbolic</property>
|
||||||
<property name="halign">start</property>
|
<property name="halign">start</property>
|
||||||
<property name="valign">center</property>
|
<property name="valign">center</property>
|
||||||
<accessibility>
|
|
||||||
<property name="label">Swap colors</property>
|
|
||||||
</accessibility>
|
|
||||||
<style>
|
<style>
|
||||||
<class name="circular"/>
|
<class name="circular"/>
|
||||||
</style>
|
</style>
|
||||||
@@ -300,10 +259,16 @@
|
|||||||
<object class="GtkBox" id="feature_list">
|
<object class="GtkBox" id="feature_list">
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkDropDown" id="script_lang">
|
<object class="GtkComboBox" id="script_lang">
|
||||||
<property name="tooltip-text" translatable="yes">Language System</property>
|
<property name="tooltip-text" translatable="yes">Language System</property>
|
||||||
<property name="margin-top">10</property>
|
<property name="margin-top">10</property>
|
||||||
<signal name="notify::selected" handler="font_features_script_changed" swapped="no"/>
|
<signal name="changed" handler="font_features_script_changed" swapped="no"/>
|
||||||
|
<child>
|
||||||
|
<object class="GtkCellRendererText"/>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="text">0</attribute>
|
||||||
|
</attributes>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
@@ -371,9 +336,6 @@
|
|||||||
<property name="yalign">0</property>
|
<property name="yalign">0</property>
|
||||||
<property name="valign">start</property>
|
<property name="valign">start</property>
|
||||||
<property name="selectable">1</property>
|
<property name="selectable">1</property>
|
||||||
<accessibility>
|
|
||||||
<property name="label">Font example</property>
|
|
||||||
</accessibility>
|
|
||||||
</object>
|
</object>
|
||||||
</property>
|
</property>
|
||||||
</object>
|
</object>
|
||||||
@@ -383,9 +345,6 @@
|
|||||||
<property name="name">entry</property>
|
<property name="name">entry</property>
|
||||||
<property name="child">
|
<property name="child">
|
||||||
<object class="GtkTextView" id="entry">
|
<object class="GtkTextView" id="entry">
|
||||||
<accessibility>
|
|
||||||
<property name="label">Example text</property>
|
|
||||||
</accessibility>
|
|
||||||
<property name="buffer">
|
<property name="buffer">
|
||||||
<object class="GtkTextBuffer">
|
<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.
|
<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 +441,6 @@
|
|||||||
<property name="icon-name">document-edit-symbolic</property>
|
<property name="icon-name">document-edit-symbolic</property>
|
||||||
<property name="halign">end</property>
|
<property name="halign">end</property>
|
||||||
<property name="valign">end</property>
|
<property name="valign">end</property>
|
||||||
<accessibility>
|
|
||||||
<property name="label">Edit text</property>
|
|
||||||
</accessibility>
|
|
||||||
<signal name="clicked" handler="font_features_toggle_edit"/>
|
<signal name="clicked" handler="font_features_toggle_edit"/>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
@@ -363,9 +363,7 @@ insert_markup_idle (gpointer data)
|
|||||||
|
|
||||||
if (g_get_monotonic_time () - begin > G_TIME_SPAN_MILLISECOND)
|
if (g_get_monotonic_time () - begin > G_TIME_SPAN_MILLISECOND)
|
||||||
{
|
{
|
||||||
guint id;
|
g_idle_add (insert_markup_idle, data);
|
||||||
id = g_idle_add (insert_markup_idle, data);
|
|
||||||
g_source_set_name_by_id (id, "[gtk-demo] insert_markup_idle");
|
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -400,9 +398,7 @@ parse_markup_idle (gpointer data)
|
|||||||
do {
|
do {
|
||||||
if (g_get_monotonic_time () - begin > G_TIME_SPAN_MILLISECOND)
|
if (g_get_monotonic_time () - begin > G_TIME_SPAN_MILLISECOND)
|
||||||
{
|
{
|
||||||
guint id;
|
g_idle_add (parse_markup_idle, data);
|
||||||
id = g_idle_add (parse_markup_idle, data);
|
|
||||||
g_source_set_name_by_id (id, "[gtk-demo] parse_markup_idle");
|
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -42,8 +42,8 @@ val_to_xy (GtkFontPlane *plane,
|
|||||||
double u, v;
|
double u, v;
|
||||||
int width, height;
|
int width, height;
|
||||||
|
|
||||||
width = gtk_widget_get_width (GTK_WIDGET (plane));
|
width = gtk_widget_get_allocated_width (GTK_WIDGET (plane));
|
||||||
height = gtk_widget_get_height (GTK_WIDGET (plane));
|
height = gtk_widget_get_allocated_height (GTK_WIDGET (plane));
|
||||||
|
|
||||||
u = adjustment_get_normalized_value (plane->width_adj);
|
u = adjustment_get_normalized_value (plane->width_adj);
|
||||||
v = adjustment_get_normalized_value (plane->weight_adj);
|
v = adjustment_get_normalized_value (plane->weight_adj);
|
||||||
@@ -62,8 +62,8 @@ plane_snapshot (GtkWidget *widget,
|
|||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
|
|
||||||
val_to_xy (plane, &x, &y);
|
val_to_xy (plane, &x, &y);
|
||||||
width = gtk_widget_get_width (widget);
|
width = gtk_widget_get_allocated_width (widget);
|
||||||
height = gtk_widget_get_height (widget);
|
height = gtk_widget_get_allocated_height (widget);
|
||||||
|
|
||||||
cr = gtk_snapshot_append_cairo (snapshot,
|
cr = gtk_snapshot_append_cairo (snapshot,
|
||||||
&GRAPHENE_RECT_INIT (0, 0, width, height));
|
&GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||||
@@ -131,8 +131,8 @@ update_value (GtkFontPlane *plane,
|
|||||||
GtkWidget *widget = GTK_WIDGET (plane);
|
GtkWidget *widget = GTK_WIDGET (plane);
|
||||||
double u, v;
|
double u, v;
|
||||||
|
|
||||||
u = CLAMP (x * (1.0 / gtk_widget_get_width (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_height (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->width_adj, u);
|
||||||
adjustment_set_normalized_value (plane->weight_adj, v);
|
adjustment_set_normalized_value (plane->weight_adj, v);
|
||||||
|
@@ -15,7 +15,8 @@
|
|||||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#ifndef __GTK_FONT_PLANE_H__
|
||||||
|
#define __GTK_FONT_PLANE_H__
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
@@ -59,3 +60,5 @@ GtkWidget * gtk_font_plane_new (GtkAdjustment *width_adj,
|
|||||||
GtkAdjustment *weight_adj);
|
GtkAdjustment *weight_adj);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GTK_FONT_PLANE_H__ */
|
||||||
|
@@ -43,7 +43,7 @@ update_image (void)
|
|||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
GdkPixbuf *pixbuf2;
|
GdkPixbuf *pixbuf2;
|
||||||
GdkTexture *texture;
|
const char *hint;
|
||||||
cairo_font_options_t *fopt;
|
cairo_font_options_t *fopt;
|
||||||
cairo_hint_style_t hintstyle;
|
cairo_hint_style_t hintstyle;
|
||||||
cairo_hint_metrics_t hintmetrics;
|
cairo_hint_metrics_t hintmetrics;
|
||||||
@@ -54,27 +54,22 @@ update_image (void)
|
|||||||
context = gtk_widget_create_pango_context (image);
|
context = gtk_widget_create_pango_context (image);
|
||||||
|
|
||||||
text = gtk_editable_get_text (GTK_EDITABLE (entry));
|
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));
|
fopt = cairo_font_options_copy (pango_cairo_context_get_font_options (context));
|
||||||
|
|
||||||
switch (gtk_drop_down_get_selected (GTK_DROP_DOWN (hinting)))
|
hint = gtk_combo_box_get_active_id (GTK_COMBO_BOX (hinting));
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
hintstyle = CAIRO_HINT_STYLE_NONE;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
hintstyle = CAIRO_HINT_STYLE_SLIGHT;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
hintstyle = CAIRO_HINT_STYLE_MEDIUM;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
hintstyle = CAIRO_HINT_STYLE_FULL;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
hintstyle = CAIRO_HINT_STYLE_DEFAULT;
|
hintstyle = CAIRO_HINT_STYLE_DEFAULT;
|
||||||
break;
|
if (hint)
|
||||||
|
{
|
||||||
|
if (strcmp (hint, "none") == 0)
|
||||||
|
hintstyle = CAIRO_HINT_STYLE_NONE;
|
||||||
|
else if (strcmp (hint, "slight") == 0)
|
||||||
|
hintstyle = CAIRO_HINT_STYLE_SLIGHT;
|
||||||
|
else if (strcmp (hint, "medium") == 0)
|
||||||
|
hintstyle = CAIRO_HINT_STYLE_MEDIUM;
|
||||||
|
else if (strcmp (hint, "full") == 0)
|
||||||
|
hintstyle = CAIRO_HINT_STYLE_FULL;
|
||||||
}
|
}
|
||||||
cairo_font_options_set_hint_style (fopt, hintstyle);
|
cairo_font_options_set_hint_style (fopt, hintstyle);
|
||||||
|
|
||||||
@@ -121,17 +116,8 @@ update_image (void)
|
|||||||
cairo_destroy (cr);
|
cairo_destroy (cr);
|
||||||
g_object_unref (layout);
|
g_object_unref (layout);
|
||||||
|
|
||||||
pixbuf = gdk_pixbuf_new_from_data (cairo_image_surface_get_data (surface),
|
pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, cairo_image_surface_get_width (surface), cairo_image_surface_get_height (surface));
|
||||||
GDK_COLORSPACE_RGB, TRUE, 8,
|
pixbuf2 = gdk_pixbuf_scale_simple (pixbuf, gdk_pixbuf_get_width (pixbuf) * scale, gdk_pixbuf_get_height (pixbuf) * scale, GDK_INTERP_NEAREST);
|
||||||
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);
|
|
||||||
|
|
||||||
g_object_unref (pixbuf);
|
g_object_unref (pixbuf);
|
||||||
cairo_surface_destroy (surface);
|
cairo_surface_destroy (surface);
|
||||||
@@ -288,25 +274,17 @@ retry:
|
|||||||
pango_layout_iter_free (iter);
|
pango_layout_iter_free (iter);
|
||||||
g_object_unref (layout);
|
g_object_unref (layout);
|
||||||
|
|
||||||
pixbuf = gdk_pixbuf_new_from_data (cairo_image_surface_get_data (surface),
|
pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, cairo_image_surface_get_width (surface), cairo_image_surface_get_height (surface));
|
||||||
GDK_COLORSPACE_RGB, TRUE, 8,
|
pixbuf2 = gdk_pixbuf_scale_simple (pixbuf, gdk_pixbuf_get_width (pixbuf) * scale, gdk_pixbuf_get_height (pixbuf) * scale, GDK_INTERP_NEAREST);
|
||||||
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);
|
|
||||||
g_object_unref (pixbuf);
|
g_object_unref (pixbuf);
|
||||||
cairo_surface_destroy (surface);
|
cairo_surface_destroy (surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
texture = gdk_texture_new_for_pixbuf (pixbuf2);
|
gtk_picture_set_pixbuf (GTK_PICTURE (image), pixbuf2);
|
||||||
gtk_picture_set_paintable (GTK_PICTURE (image), GDK_PAINTABLE (texture));
|
|
||||||
g_object_unref (pixbuf2);
|
g_object_unref (pixbuf2);
|
||||||
g_object_unref (texture);
|
|
||||||
|
pango_font_description_free (desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean fading = FALSE;
|
static gboolean fading = FALSE;
|
||||||
@@ -440,7 +418,7 @@ do_fontrendering (GtkWidget *do_widget)
|
|||||||
g_signal_connect (down_button, "clicked", G_CALLBACK (scale_down), NULL);
|
g_signal_connect (down_button, "clicked", G_CALLBACK (scale_down), NULL);
|
||||||
g_signal_connect (entry, "notify::text", G_CALLBACK (update_image), NULL);
|
g_signal_connect (entry, "notify::text", G_CALLBACK (update_image), NULL);
|
||||||
g_signal_connect (font_button, "notify::font-desc", G_CALLBACK (update_image), NULL);
|
g_signal_connect (font_button, "notify::font-desc", G_CALLBACK (update_image), NULL);
|
||||||
g_signal_connect (hinting, "notify::selected", G_CALLBACK (update_image), NULL);
|
g_signal_connect (hinting, "notify::active", G_CALLBACK (update_image), NULL);
|
||||||
g_signal_connect (anti_alias, "notify::active", G_CALLBACK (update_image), NULL);
|
g_signal_connect (anti_alias, "notify::active", G_CALLBACK (update_image), NULL);
|
||||||
g_signal_connect (hint_metrics, "notify::active", G_CALLBACK (update_image), NULL);
|
g_signal_connect (hint_metrics, "notify::active", G_CALLBACK (update_image), NULL);
|
||||||
g_signal_connect (text_radio, "notify::active", G_CALLBACK (update_image), NULL);
|
g_signal_connect (text_radio, "notify::active", G_CALLBACK (update_image), NULL);
|
||||||
@@ -455,7 +433,7 @@ do_fontrendering (GtkWidget *do_widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
gtk_widget_set_visible (window, TRUE);
|
gtk_widget_show (window);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (window));
|
gtk_window_destroy (GTK_WINDOW (window));
|
||||||
|
|
||||||
|
@@ -39,7 +39,7 @@
|
|||||||
<property name="row-spacing">10</property>
|
<property name="row-spacing">10</property>
|
||||||
<property name="column-spacing">10</property>
|
<property name="column-spacing">10</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="text_label">
|
<object class="GtkLabel">
|
||||||
<property name="margin-start">10</property>
|
<property name="margin-start">10</property>
|
||||||
<property name="label">Text</property>
|
<property name="label">Text</property>
|
||||||
<property name="xalign">1</property>
|
<property name="xalign">1</property>
|
||||||
@@ -57,13 +57,10 @@
|
|||||||
<layout>
|
<layout>
|
||||||
<property name="column">2</property>
|
<property name="column">2</property>
|
||||||
</layout>
|
</layout>
|
||||||
<accessibility>
|
|
||||||
<relation name="labelled-by">text_label</relation>
|
|
||||||
</accessibility>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="font_label">
|
<object class="GtkLabel">
|
||||||
<property name="margin-start">10</property>
|
<property name="margin-start">10</property>
|
||||||
<property name="label">Font</property>
|
<property name="label">Font</property>
|
||||||
<property name="xalign">1</property>
|
<property name="xalign">1</property>
|
||||||
@@ -77,14 +74,7 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkFontDialogButton" id="font_button">
|
<object class="GtkFontButton" id="font_button">
|
||||||
<accessibility>
|
|
||||||
<relation name="labelled-by">font_label</relation>
|
|
||||||
</accessibility>
|
|
||||||
<property name="dialog">
|
|
||||||
<object class="GtkFontDialog">
|
|
||||||
</object>
|
|
||||||
</property>
|
|
||||||
<layout>
|
<layout>
|
||||||
<property name="column">2</property>
|
<property name="column">2</property>
|
||||||
<property name="row">1</property>
|
<property name="row">1</property>
|
||||||
@@ -126,19 +116,16 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkDropDown" id="hinting">
|
<object class="GtkComboBoxText" id="hinting">
|
||||||
|
<property name="active">0</property>
|
||||||
<property name="valign">center</property>
|
<property name="valign">center</property>
|
||||||
<property name="model">
|
|
||||||
<object class="GtkStringList">
|
|
||||||
<items>
|
<items>
|
||||||
<item translatable="yes">None</item>
|
<item translatable="yes" id="none">None</item>
|
||||||
<item translatable="yes">Slight</item>
|
<item translatable="yes" id="slight">Slight</item>
|
||||||
<item translatable="yes">Medium</item>
|
<item translatable="yes" id="medium">Medium</item>
|
||||||
<item translatable="yes">Full</item>
|
<item translatable="yes" id="full">Full</item>
|
||||||
</items>
|
</items>
|
||||||
</object>
|
</object>
|
||||||
</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
</child>
|
||||||
<layout>
|
<layout>
|
||||||
<property name="column">4</property>
|
<property name="column">4</property>
|
||||||
@@ -192,9 +179,6 @@
|
|||||||
<property name="icon-name">list-add-symbolic</property>
|
<property name="icon-name">list-add-symbolic</property>
|
||||||
<property name="halign">center</property>
|
<property name="halign">center</property>
|
||||||
<property name="valign">center</property>
|
<property name="valign">center</property>
|
||||||
<accessibility>
|
|
||||||
<property name="label">Zoom in</property>
|
|
||||||
</accessibility>
|
|
||||||
<style>
|
<style>
|
||||||
<class name="circular"/>
|
<class name="circular"/>
|
||||||
</style>
|
</style>
|
||||||
@@ -220,9 +204,6 @@
|
|||||||
<property name="icon-name">list-remove-symbolic</property>
|
<property name="icon-name">list-remove-symbolic</property>
|
||||||
<property name="halign">center</property>
|
<property name="halign">center</property>
|
||||||
<property name="valign">center</property>
|
<property name="valign">center</property>
|
||||||
<accessibility>
|
|
||||||
<property name="label">Zoom out</property>
|
|
||||||
</accessibility>
|
|
||||||
<style>
|
<style>
|
||||||
<class name="circular"/>
|
<class name="circular"/>
|
||||||
</style>
|
</style>
|
||||||
@@ -263,9 +244,6 @@
|
|||||||
<property name="vexpand">1</property>
|
<property name="vexpand">1</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkPicture" id="image">
|
<object class="GtkPicture" id="image">
|
||||||
<accessibility>
|
|
||||||
<property name="label">Font rendering example</property>
|
|
||||||
</accessibility>
|
|
||||||
<property name="halign">center</property>
|
<property name="halign">center</property>
|
||||||
<property name="valign">center</property>
|
<property name="valign">center</property>
|
||||||
<property name="can-shrink">0</property>
|
<property name="can-shrink">0</property>
|
||||||
|
@@ -157,7 +157,7 @@ do_frames (GtkWidget *do_widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
gtk_widget_set_visible (window, TRUE);
|
gtk_widget_show (window);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (window));
|
gtk_window_destroy (GTK_WINDOW (window));
|
||||||
|
|
||||||
|
@@ -54,6 +54,7 @@ create_axis_slider (GtkGears *gears,
|
|||||||
|
|
||||||
label = gtk_label_new (text);
|
label = gtk_label_new (text);
|
||||||
gtk_box_append (GTK_BOX (box), label);
|
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);
|
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));
|
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_scale_set_draw_value (GTK_SCALE (slider), FALSE);
|
||||||
gtk_box_append (GTK_BOX (box), slider);
|
gtk_box_append (GTK_BOX (box), slider);
|
||||||
gtk_widget_set_vexpand (slider, TRUE);
|
gtk_widget_set_vexpand (slider, TRUE);
|
||||||
|
gtk_widget_show (slider);
|
||||||
|
|
||||||
|
gtk_widget_show (box);
|
||||||
|
|
||||||
return box;
|
return box;
|
||||||
}
|
}
|
||||||
@@ -125,7 +129,7 @@ do_gears (GtkWidget *do_widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
gtk_widget_set_visible (window, TRUE);
|
gtk_widget_show (window);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (window));
|
gtk_window_destroy (GTK_WINDOW (window));
|
||||||
|
|
||||||
|
@@ -208,7 +208,7 @@ do_gestures (GtkWidget *do_widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
gtk_widget_set_visible (window, TRUE);
|
gtk_widget_show (window);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (window));
|
gtk_window_destroy (GTK_WINDOW (window));
|
||||||
|
|
||||||
|
@@ -221,13 +221,16 @@ static void
|
|||||||
realize (GtkWidget *widget)
|
realize (GtkWidget *widget)
|
||||||
{
|
{
|
||||||
const char *vertex_path, *fragment_path;
|
const char *vertex_path, *fragment_path;
|
||||||
|
GdkGLContext *context;
|
||||||
|
|
||||||
gtk_gl_area_make_current (GTK_GL_AREA (widget));
|
gtk_gl_area_make_current (GTK_GL_AREA (widget));
|
||||||
|
|
||||||
if (gtk_gl_area_get_error (GTK_GL_AREA (widget)) != NULL)
|
if (gtk_gl_area_get_error (GTK_GL_AREA (widget)) != NULL)
|
||||||
return;
|
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";
|
vertex_path = "/glarea/glarea-gles.vs.glsl";
|
||||||
fragment_path = "/glarea/glarea-gles.fs.glsl";
|
fragment_path = "/glarea/glarea-gles.fs.glsl";
|
||||||
@@ -352,6 +355,7 @@ create_axis_slider (int axis)
|
|||||||
|
|
||||||
label = gtk_label_new (text);
|
label = gtk_label_new (text);
|
||||||
gtk_box_append (GTK_BOX (box), label);
|
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);
|
adj = gtk_adjustment_new (0.0, 0.0, 360.0, 1.0, 12.0, 0.0);
|
||||||
g_signal_connect (adj, "value-changed",
|
g_signal_connect (adj, "value-changed",
|
||||||
@@ -360,6 +364,9 @@ create_axis_slider (int axis)
|
|||||||
slider = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, adj);
|
slider = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, adj);
|
||||||
gtk_box_append (GTK_BOX (box), slider);
|
gtk_box_append (GTK_BOX (box), slider);
|
||||||
gtk_widget_set_hexpand (slider, TRUE);
|
gtk_widget_set_hexpand (slider, TRUE);
|
||||||
|
gtk_widget_show (slider);
|
||||||
|
|
||||||
|
gtk_widget_show (box);
|
||||||
|
|
||||||
return box;
|
return box;
|
||||||
}
|
}
|
||||||
@@ -433,7 +440,7 @@ do_glarea (GtkWidget *do_widget)
|
|||||||
demo_window = create_glarea_window (do_widget);
|
demo_window = create_glarea_window (do_widget);
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (demo_window))
|
if (!gtk_widget_get_visible (demo_window))
|
||||||
gtk_widget_set_visible (demo_window, TRUE);
|
gtk_widget_show (demo_window);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (demo_window));
|
gtk_window_destroy (GTK_WINDOW (demo_window));
|
||||||
|
|
||||||
|
@@ -33,7 +33,7 @@ static void
|
|||||||
text_changed (GtkTextBuffer *buffer,
|
text_changed (GtkTextBuffer *buffer,
|
||||||
GtkWidget *button)
|
GtkWidget *button)
|
||||||
{
|
{
|
||||||
gtk_widget_set_visible (button, TRUE);
|
gtk_widget_show (button);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -58,7 +58,7 @@ apply_text (GtkWidget *button,
|
|||||||
g_object_unref (shader);
|
g_object_unref (shader);
|
||||||
g_bytes_unref (bytes);
|
g_bytes_unref (bytes);
|
||||||
|
|
||||||
gtk_widget_set_visible (button, FALSE);
|
gtk_widget_hide (button);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -144,6 +144,7 @@ make_shader_stack (const char *name,
|
|||||||
GtkTextBuffer *buffer;
|
GtkTextBuffer *buffer;
|
||||||
GBytes *bytes;
|
GBytes *bytes;
|
||||||
GtkEventController *controller;
|
GtkEventController *controller;
|
||||||
|
GtkCssProvider *provider;
|
||||||
GdkPaintable *paintable;
|
GdkPaintable *paintable;
|
||||||
|
|
||||||
stack = gtk_shader_stack_new ();
|
stack = gtk_shader_stack_new ();
|
||||||
@@ -234,10 +235,16 @@ make_shader_stack (const char *name,
|
|||||||
g_signal_connect (buffer, "changed", G_CALLBACK (text_changed), button);
|
g_signal_connect (buffer, "changed", G_CALLBACK (text_changed), button);
|
||||||
g_object_set_data (G_OBJECT (button), "the-stack", stack);
|
g_object_set_data (G_OBJECT (button), "the-stack", stack);
|
||||||
g_signal_connect (button, "clicked", G_CALLBACK (apply_text), buffer);
|
g_signal_connect (button, "clicked", G_CALLBACK (apply_text), buffer);
|
||||||
|
provider = gtk_css_provider_new ();
|
||||||
|
gtk_css_provider_load_from_data (provider, "button.small { padding: 0; }", -1);
|
||||||
|
gtk_style_context_add_provider (gtk_widget_get_style_context (button),
|
||||||
|
GTK_STYLE_PROVIDER (provider),
|
||||||
|
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||||
|
g_object_unref (provider);
|
||||||
gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
|
gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
|
||||||
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
|
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
|
||||||
gtk_widget_add_css_class (button, "small");
|
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_center_box_set_end_widget (GTK_CENTER_BOX (widget), button);
|
||||||
|
|
||||||
gtk_box_append (GTK_BOX (vbox), widget);
|
gtk_box_append (GTK_BOX (vbox), widget);
|
||||||
@@ -267,21 +274,11 @@ make_shader_stack (const char *name,
|
|||||||
return vbox;
|
return vbox;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
remove_provider (gpointer data)
|
|
||||||
{
|
|
||||||
GtkStyleProvider *provider = GTK_STYLE_PROVIDER (data);
|
|
||||||
|
|
||||||
gtk_style_context_remove_provider_for_display (gdk_display_get_default (), provider);
|
|
||||||
g_object_unref (provider);
|
|
||||||
}
|
|
||||||
|
|
||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
create_gltransition_window (GtkWidget *do_widget)
|
create_gltransition_window (GtkWidget *do_widget)
|
||||||
{
|
{
|
||||||
GtkWidget *window, *headerbar, *scale, *outer_grid, *grid, *background;
|
GtkWidget *window, *headerbar, *scale, *outer_grid, *grid, *background;
|
||||||
GdkPaintable *paintable;
|
GdkPaintable *paintable;
|
||||||
GtkCssProvider *provider;
|
|
||||||
|
|
||||||
window = gtk_window_new ();
|
window = gtk_window_new ();
|
||||||
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
|
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
|
||||||
@@ -336,14 +333,6 @@ create_gltransition_window (GtkWidget *do_widget)
|
|||||||
make_shader_stack ("Kaleidoscope", "/gltransition/kaleidoscope.glsl", 3, scale),
|
make_shader_stack ("Kaleidoscope", "/gltransition/kaleidoscope.glsl", 3, scale),
|
||||||
1, 1, 1, 1);
|
1, 1, 1, 1);
|
||||||
|
|
||||||
provider = gtk_css_provider_new ();
|
|
||||||
gtk_css_provider_load_from_string (provider, "button.small { padding: 0; }");
|
|
||||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
|
||||||
GTK_STYLE_PROVIDER (provider),
|
|
||||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
|
||||||
|
|
||||||
g_object_set_data_full (G_OBJECT (window), "provider", provider, remove_provider);
|
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -354,7 +343,7 @@ do_gltransition (GtkWidget *do_widget)
|
|||||||
demo_window = create_gltransition_window (do_widget);
|
demo_window = create_gltransition_window (do_widget);
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (demo_window))
|
if (!gtk_widget_get_visible (demo_window))
|
||||||
gtk_widget_set_visible (demo_window, TRUE);
|
gtk_widget_show (demo_window);
|
||||||
else
|
else
|
||||||
gtk_window_destroy (GTK_WINDOW (demo_window));
|
gtk_window_destroy (GTK_WINDOW (demo_window));
|
||||||
|
|
||||||
|